Cocoa Port:

- Add SoftRasterizer hack from r4984.
- Update UI to reflect the current feature set.
- Do some code cleanup.
This commit is contained in:
rogerman 2014-02-10 07:14:05 +00:00
parent 443b24cac2
commit cf109b69dd
12 changed files with 755 additions and 495 deletions

View File

@ -686,6 +686,8 @@
<true/> <true/>
<key>Render3D_Fog</key> <key>Render3D_Fog</key>
<true/> <true/>
<key>Render3D_FragmentSamplingHack</key>
<true/>
<key>Render3D_HighPrecisionColorInterpolation</key> <key>Render3D_HighPrecisionColorInterpolation</key>
<true/> <true/>
<key>Render3D_LineHack</key> <key>Render3D_LineHack</key>

View File

@ -363,7 +363,7 @@ void OGLVideoOutput::UpdateDisplayTransformationOGL()
} }
} }
void OGLVideoOutput::RespondToVideoFilterChangeOGL(const VideoFilterTypeID videoFilterTypeID) void OGLVideoOutput::SetVideoFilterOGL(const VideoFilterTypeID videoFilterTypeID)
{ {
this->_vfSingle->ChangeFilterByID(videoFilterTypeID); this->_vfSingle->ChangeFilterByID(videoFilterTypeID);
this->_vfDual->ChangeFilterByID(videoFilterTypeID); this->_vfDual->ChangeFilterByID(videoFilterTypeID);

View File

@ -70,6 +70,10 @@ protected:
GLubyte vtxIndexBuffer[12]; GLubyte vtxIndexBuffer[12];
size_t _vtxBufferOffset; size_t _vtxBufferOffset;
void CalculateDisplayNormalSize(double *w, double *h);
void UpdateVertices();
void UpdateTexCoords(GLfloat s, GLfloat t);
void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet); void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const; bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const;
bool SetupShadersOGL(const char *vertexProgram, const char *fragmentProgram); bool SetupShadersOGL(const char *vertexProgram, const char *fragmentProgram);
@ -90,11 +94,7 @@ public:
virtual void RenderOGL(); virtual void RenderOGL();
virtual void SetViewportSizeOGL(GLsizei w, GLsizei h); virtual void SetViewportSizeOGL(GLsizei w, GLsizei h);
virtual void UpdateDisplayTransformationOGL(); virtual void UpdateDisplayTransformationOGL();
virtual void RespondToVideoFilterChangeOGL(const VideoFilterTypeID videoFilterTypeID); virtual void SetVideoFilterOGL(const VideoFilterTypeID videoFilterTypeID);
void CalculateDisplayNormalSize(double *w, double *h);
void UpdateVertices();
void UpdateTexCoords(GLfloat s, GLfloat t);
int GetDisplayMode(); int GetDisplayMode();
void SetDisplayMode(int dispMode); void SetDisplayMode(int dispMode);

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2013 DeSmuME team Copyright (C) 2013-2014 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -54,6 +54,7 @@
@property (assign) NSUInteger render3DThreads; @property (assign) NSUInteger render3DThreads;
@property (assign) BOOL render3DLineHack; @property (assign) BOOL render3DLineHack;
@property (assign) BOOL render3DMultisample; @property (assign) BOOL render3DMultisample;
@property (assign) BOOL render3DFragmentSamplingHack;
- (BOOL) gpuStateByBit:(const UInt32)stateBit; - (BOOL) gpuStateByBit:(const UInt32)stateBit;
- (BOOL) isGPUTypeDisplayed:(const NSInteger)theGpuType; - (BOOL) isGPUTypeDisplayed:(const NSInteger)theGpuType;

View File

@ -67,6 +67,7 @@ GPU3DInterface *core3DList[] = {
@dynamic render3DThreads; @dynamic render3DThreads;
@dynamic render3DLineHack; @dynamic render3DLineHack;
@dynamic render3DMultisample; @dynamic render3DMultisample;
@dynamic render3DFragmentSamplingHack;
- (id)init - (id)init
@ -321,6 +322,22 @@ GPU3DInterface *core3DList[] = {
return state; return state;
} }
- (void) setRender3DFragmentSamplingHack:(BOOL)state
{
pthread_mutex_lock(self.mutexProducer);
CommonSettings.GFX3D_TXTHack = state ? true : false;
pthread_mutex_unlock(self.mutexProducer);
}
- (BOOL) render3DFragmentSamplingHack
{
pthread_mutex_lock(self.mutexProducer);
const BOOL state = CommonSettings.GFX3D_TXTHack ? YES : NO;
pthread_mutex_unlock(self.mutexProducer);
return state;
}
- (void) setLayerMainGPU:(BOOL)gpuState - (void) setLayerMainGPU:(BOOL)gpuState
{ {
pthread_mutex_lock(self.mutexProducer); pthread_mutex_lock(self.mutexProducer);

View File

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2011 Roger Manuel Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2013 DeSmuME team Copyright (C) 2011-2014 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2011 Roger Manuel Copyright (C) 2011 Roger Manuel
Copyright (C) 2011-2013 DeSmuME team Copyright (C) 2011-2014 DeSmuME team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -971,30 +971,7 @@
const float gapScalar = *(float *)[displayGapScalarData bytes]; const float gapScalar = *(float *)[displayGapScalarData bytes];
[(id<CocoaDSDisplayVideoDelegate>)delegate doDisplayGapChanged:gapScalar]; [(id<CocoaDSDisplayVideoDelegate>)delegate doDisplayGapChanged:gapScalar];
} }
/*
- (void) handleChangeBilinearOutput:(NSData *)bilinearStateData
{
if (delegate == nil || ![delegate respondsToSelector:@selector(doBilinearOutputChanged:)])
{
return;
}
const BOOL theState = *(BOOL *)[bilinearStateData bytes];
[(id<CocoaDSDisplayVideoDelegate>)delegate doBilinearOutputChanged:theState];
[self handleEmuFrameProcessed:self.frameData attributes:self.frameAttributesData];
}
- (void) handleChangeVerticalSync:(NSData *)verticalSyncStateData
{
if (delegate == nil || ![delegate respondsToSelector:@selector(doVerticalSyncChanged:)])
{
return;
}
const BOOL theState = *(BOOL *)[verticalSyncStateData bytes];
[(id<CocoaDSDisplayVideoDelegate>)delegate doVerticalSyncChanged:theState];
}
*/
- (void) handleChangeVideoFilter:(NSData *)videoFilterTypeIdData - (void) handleChangeVideoFilter:(NSData *)videoFilterTypeIdData
{ {
if (delegate == nil || ![delegate respondsToSelector:@selector(doVideoFilterChanged:)]) if (delegate == nil || ![delegate respondsToSelector:@selector(doVideoFilterChanged:)])

File diff suppressed because it is too large Load Diff

View File

@ -1081,8 +1081,6 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
// Set the video filter source size now since the proper size is needed on initialization. // Set the video filter source size now since the proper size is needed on initialization.
// If we don't do this, new windows could draw incorrectly. // If we don't do this, new windows could draw incorrectly.
//const NSSize vfSrcSize = NSMakeSize(GPU_DISPLAY_WIDTH, ([self displayMode] == DS_DISPLAY_TYPE_DUAL) ? GPU_DISPLAY_HEIGHT * 2 : GPU_DISPLAY_HEIGHT);
//[[cdsVideoOutput vf] setSourceSize:vfSrcSize];
[CocoaDSUtil messageSendOneWayWithInteger:[cdsVideoOutput receivePort] msgID:MESSAGE_CHANGE_VIDEO_FILTER integerValue:[self videoFilterType]]; [CocoaDSUtil messageSendOneWayWithInteger:[cdsVideoOutput receivePort] msgID:MESSAGE_CHANGE_VIDEO_FILTER integerValue:[self videoFilterType]];
// Add the video thread to the output list. // Add the video thread to the output list.
@ -1785,7 +1783,7 @@ static std::tr1::unordered_map<NSScreen *, DisplayWindowController *> _screenMap
{ {
CGLLockContext(cglDisplayContext); CGLLockContext(cglDisplayContext);
CGLSetCurrentContext(cglDisplayContext); CGLSetCurrentContext(cglDisplayContext);
oglv->RespondToVideoFilterChangeOGL((const VideoFilterTypeID)videoFilterTypeID); oglv->SetVideoFilterOGL((const VideoFilterTypeID)videoFilterTypeID);
CGLUnlockContext(cglDisplayContext); CGLUnlockContext(cglDisplayContext);
} }

View File

@ -139,16 +139,6 @@ class AudioSampleBlockGenerator;
@property (assign) NSInteger frameJumpFramesForward; @property (assign) NSInteger frameJumpFramesForward;
@property (assign) NSInteger frameJumpToFrame; @property (assign) NSInteger frameJumpToFrame;
@property (assign) NSInteger render3DRenderingEngine;
@property (assign) BOOL render3DHighPrecisionColorInterpolation;
@property (assign) BOOL render3DEdgeMarking;
@property (assign) BOOL render3DFog;
@property (assign) BOOL render3DTextures;
@property (assign) NSInteger render3DDepthComparisonThreshold;
@property (assign) NSInteger render3DThreads;
@property (assign) BOOL render3DLineHack;
@property (assign) BOOL render3DMultisample;
@property (retain) DisplayWindowController *mainWindow; @property (retain) DisplayWindowController *mainWindow;
@property (readonly) NSMutableArray *windowList; @property (readonly) NSMutableArray *windowList;

View File

@ -85,16 +85,6 @@
@synthesize frameJumpFramesForward; @synthesize frameJumpFramesForward;
@synthesize frameJumpToFrame; @synthesize frameJumpToFrame;
@dynamic render3DRenderingEngine;
@dynamic render3DHighPrecisionColorInterpolation;
@dynamic render3DEdgeMarking;
@dynamic render3DFog;
@dynamic render3DTextures;
@dynamic render3DDepthComparisonThreshold;
@dynamic render3DThreads;
@dynamic render3DLineHack;
@dynamic render3DMultisample;
@synthesize mainWindow; @synthesize mainWindow;
@synthesize windowList; @synthesize windowList;
@ -318,124 +308,6 @@
return currentVolumeValue; return currentVolumeValue;
} }
- (void) setRender3DRenderingEngine:(NSInteger)engineID
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DRenderingEngine:engineID];
}
- (NSInteger) render3DRenderingEngine
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DRenderingEngine];
}
- (void) setRender3DHighPrecisionColorInterpolation:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DHighPrecisionColorInterpolation:theState];
}
- (BOOL) render3DHighPrecisionColorInterpolation
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DHighPrecisionColorInterpolation];
}
- (void) setRender3DEdgeMarking:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DEdgeMarking:theState];
}
- (BOOL) render3DEdgeMarking
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DEdgeMarking];
}
- (void) setRender3DFog:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DFog:theState];
}
- (BOOL) render3DFog
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DFog];
}
- (void) setRender3DTextures:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DTextures:theState];
}
- (BOOL) render3DTextures
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DTextures];
}
- (void) setRender3DDepthComparisonThreshold:(NSInteger)threshold
{
if (threshold < 0)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DDepthComparisonThreshold:(NSUInteger)threshold];
}
- (NSInteger) render3DDepthComparisonThreshold
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DDepthComparisonThreshold];
}
- (void) setRender3DThreads:(NSInteger)threadCount
{
if (threadCount < 0)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DThreads:(NSUInteger)threadCount];
}
- (NSInteger) render3DThreads
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DThreads];
}
- (void) setRender3DLineHack:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DLineHack:theState];
}
- (BOOL) render3DLineHack
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DLineHack];
}
- (void) setRender3DMultisample:(BOOL)theState
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsGPU setRender3DMultisample:theState];
}
- (BOOL) render3DMultisample
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
return [cdsCore.cdsGPU render3DMultisample];
}
#pragma mark IBActions #pragma mark IBActions
- (IBAction) newDisplayWindow:(id)sender - (IBAction) newDisplayWindow:(id)sender
@ -1019,15 +891,16 @@
// Force end of editing of any text fields. // Force end of editing of any text fields.
[[(NSControl *)sender window] makeFirstResponder:nil]; [[(NSControl *)sender window] makeFirstResponder:nil];
[[NSUserDefaults standardUserDefaults] setInteger:[cdsCore.cdsGPU render3DRenderingEngine] forKey:@"Render3D_RenderingEngine"]; [[NSUserDefaults standardUserDefaults] setInteger:[[cdsCore cdsGPU] render3DRenderingEngine] forKey:@"Render3D_RenderingEngine"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DHighPrecisionColorInterpolation] forKey:@"Render3D_HighPrecisionColorInterpolation"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DHighPrecisionColorInterpolation] forKey:@"Render3D_HighPrecisionColorInterpolation"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DEdgeMarking] forKey:@"Render3D_EdgeMarking"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DEdgeMarking] forKey:@"Render3D_EdgeMarking"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DFog] forKey:@"Render3D_Fog"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DFog] forKey:@"Render3D_Fog"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DTextures] forKey:@"Render3D_Textures"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DTextures] forKey:@"Render3D_Textures"];
[[NSUserDefaults standardUserDefaults] setInteger:[cdsCore.cdsGPU render3DDepthComparisonThreshold] forKey:@"Render3D_DepthComparisonThreshold"]; [[NSUserDefaults standardUserDefaults] setInteger:[[cdsCore cdsGPU] render3DDepthComparisonThreshold] forKey:@"Render3D_DepthComparisonThreshold"];
[[NSUserDefaults standardUserDefaults] setInteger:[cdsCore.cdsGPU render3DThreads] forKey:@"Render3D_Threads"]; [[NSUserDefaults standardUserDefaults] setInteger:[[cdsCore cdsGPU] render3DThreads] forKey:@"Render3D_Threads"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DLineHack] forKey:@"Render3D_LineHack"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DLineHack] forKey:@"Render3D_LineHack"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore.cdsGPU render3DMultisample] forKey:@"Render3D_Multisample"]; [[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DMultisample] forKey:@"Render3D_Multisample"];
[[NSUserDefaults standardUserDefaults] setBool:[[cdsCore cdsGPU] render3DFragmentSamplingHack] forKey:@"Render3D_FragmentSamplingHack"];
} }
- (IBAction) writeDefaultsEmulationSettings:(id)sender - (IBAction) writeDefaultsEmulationSettings:(id)sender
@ -2177,15 +2050,17 @@
[[self cdsSpeaker] setSpuSyncMethod:[[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMethod"]]; [[self cdsSpeaker] setSpuSyncMethod:[[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMethod"]];
// Set the 3D rendering options per user preferences. // Set the 3D rendering options per user preferences.
[self setRender3DThreads:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_Threads"]]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[self setRender3DRenderingEngine:[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_RenderingEngine"]]; [[cdsCore cdsGPU] setRender3DThreads:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_Threads"]];
[self setRender3DHighPrecisionColorInterpolation:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_HighPrecisionColorInterpolation"]]; [[cdsCore cdsGPU] setRender3DRenderingEngine:[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_RenderingEngine"]];
[self setRender3DEdgeMarking:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_EdgeMarking"]]; [[cdsCore cdsGPU] setRender3DHighPrecisionColorInterpolation:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_HighPrecisionColorInterpolation"]];
[self setRender3DFog:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Fog"]]; [[cdsCore cdsGPU] setRender3DEdgeMarking:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_EdgeMarking"]];
[self setRender3DTextures:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Textures"]]; [[cdsCore cdsGPU] setRender3DFog:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Fog"]];
[self setRender3DDepthComparisonThreshold:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_DepthComparisonThreshold"]]; [[cdsCore cdsGPU] setRender3DTextures:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Textures"]];
[self setRender3DLineHack:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_LineHack"]]; [[cdsCore cdsGPU] setRender3DDepthComparisonThreshold:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_DepthComparisonThreshold"]];
[self setRender3DMultisample:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Multisample"]]; [[cdsCore cdsGPU] setRender3DLineHack:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_LineHack"]];
[[cdsCore cdsGPU] setRender3DMultisample:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Multisample"]];
[[cdsCore cdsGPU] setRender3DFragmentSamplingHack:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_FragmentSamplingHack"]];
} }
#pragma mark NSUserInterfaceValidations Protocol #pragma mark NSUserInterfaceValidations Protocol
@ -2466,7 +2341,8 @@
- (void)controlTextDidEndEditing:(NSNotification *)aNotification - (void)controlTextDidEndEditing:(NSNotification *)aNotification
{ {
[self setRender3DDepthComparisonThreshold:[(NSNumber *)[aNotification object] integerValue]]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[[cdsCore cdsGPU] setRender3DDepthComparisonThreshold:[(NSNumber *)[aNotification object] integerValue]];
} }
@end @end