Cocoa Port:

- Allow the OpenGL 3D renderer to render in HW (allow for SW fallback).
- Remove the depth buffer from the display output context (doesn't need it and never will need it).
This commit is contained in:
rogerman 2012-12-08 01:10:33 +00:00
parent 68fd51ac1f
commit e841a8aa1a
2 changed files with 49 additions and 11 deletions

View File

@ -5112,7 +5112,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSWindowContentMinSize">{256, 408}</string> <string key="NSWindowContentMinSize">{256, 408}</string>
<object class="NSView" key="NSWindowView" id="439893737"> <object class="NSView" key="NSWindowView" id="439893737">
<nil key="NSNextResponder"/> <reference key="NSNextResponder"/>
<int key="NSvFlags">256</int> <int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews"> <object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -5122,10 +5122,11 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSPSMatrix" key="NSDrawMatrix"/> <object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrame">{{0, 24}, {256, 384}}</string> <string key="NSFrame">{{0, 24}, {256, 384}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSViewCanDrawConcurrently">YES</bool> <bool key="NSViewCanDrawConcurrently">YES</bool>
<object class="NSOpenGLPixelFormat" key="NSPixelFormat"> <object class="NSOpenGLPixelFormat" key="NSPixelFormat">
<object class="NSMutableData" key="NSPixelAttributes"> <object class="NSMutableData" key="NSPixelAttributes">
<bytes key="NS.bytes">AAAABQAAAAgAAAAPAAAACwAAAAEAAAAMAAAAEAAAAAA</bytes> <bytes key="NS.bytes">AAAABQAAAAgAAAAYAAAACwAAAAgAAAAAA</bytes>
</object> </object>
</object> </object>
</object> </object>
@ -5135,6 +5136,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSPSMatrix" key="NSDrawMatrix"/> <object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrame">{{2, 3}, {16, 16}}</string> <string key="NSFrame">{{2, 3}, {16, 16}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<int key="NSpiFlags">28938</int> <int key="NSpiFlags">28938</int>
<double key="NSMaxValue">100</double> <double key="NSMaxValue">100</double>
</object> </object>
@ -5143,6 +5145,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">289</int> <int key="NSvFlags">289</int>
<string key="NSFrame">{{180, 3}, {56, 15}}</string> <string key="NSFrame">{{180, 3}, {56, 15}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSSliderCell" key="NSCell" id="918619685"> <object class="NSSliderCell" key="NSCell" id="918619685">
<int key="NSCellFlags">-2079981824</int> <int key="NSCellFlags">-2079981824</int>
@ -5176,6 +5179,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object> </object>
<string key="NSFrame">{{160, 1}, {20, 20}}</string> <string key="NSFrame">{{160, 1}, {20, 20}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="58250235"> <object class="NSImageCell" key="NSCell" id="58250235">
<int key="NSCellFlags">130560</int> <int key="NSCellFlags">130560</int>
@ -5196,6 +5200,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">294</int> <int key="NSvFlags">294</int>
<string key="NSFrame">{{17, 5}, {137, 14}}</string> <string key="NSFrame">{{17, 5}, {137, 14}}</string>
<reference key="NSSuperview" ref="439893737"/> <reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="60380140"> <object class="NSTextFieldCell" key="NSCell" id="60380140">
<int key="NSCellFlags">68288064</int> <int key="NSCellFlags">68288064</int>
@ -5214,6 +5219,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object> </object>
</object> </object>
<string key="NSFrameSize">{256, 408}</string> <string key="NSFrameSize">{256, 408}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object> </object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMinSize">{256, 476}</string> <string key="NSMinSize">{256, 476}</string>
@ -16821,7 +16828,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSButton" id="59471532"> <object class="NSButton" id="59471532">
<reference key="NSNextResponder" ref="887816052"/> <reference key="NSNextResponder" ref="887816052"/>
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 32}, {113, 18}}</string> <string key="NSFrame">{{15, 32}, {113, 18}}</string>
<reference key="NSSuperview" ref="887816052"/> <reference key="NSSuperview" ref="887816052"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>

View File

@ -78,6 +78,7 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
spinlockDisplayOrder = OS_SPINLOCK_INIT; spinlockDisplayOrder = OS_SPINLOCK_INIT;
normalSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2.0); normalSize = NSMakeSize(GPU_DISPLAY_WIDTH, GPU_DISPLAY_HEIGHT * 2.0);
comboScreenGap = (normalSize.height/2.0) * DS_DISPLAY_VERTICAL_GAP_TO_HEIGHT_RATIO;
sendPortDisplay = nil; sendPortDisplay = nil;
cdsController = nil; cdsController = nil;
isHudEnabled = NO; isHudEnabled = NO;
@ -135,6 +136,28 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
return theSize; return theSize;
} }
- (NSSize) normalSizeWithGap
{
OSSpinLockLock(&spinlockNormalSize);
NSSize theSize = normalSize;
OSSpinLockUnlock(&spinlockNormalSize);
NSInteger theType = [self displayType];
if (theType == DS_DISPLAY_TYPE_COMBO)
{
if ([self displayOrientation] == DS_DISPLAY_ORIENTATION_VERTICAL)
{
theSize.height += (theSize.height/2.0) * DS_DISPLAY_VERTICAL_GAP_TO_HEIGHT_RATIO;
}
else
{
theSize.width += (theSize.width/2.0) * DS_DISPLAY_VERTICAL_GAP_TO_HEIGHT_RATIO;
}
}
return theSize;
}
- (void) setGpuStateFlags:(UInt32)flags - (void) setGpuStateFlags:(UInt32)flags
{ {
OSSpinLockLock(&spinlockGpuStateFlags); OSSpinLockLock(&spinlockGpuStateFlags);
@ -413,9 +436,9 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
viewAngle = CLOCKWISE_DEGREES(viewAngle); viewAngle = CLOCKWISE_DEGREES(viewAngle);
} }
NSPoint touchLoc = GetNormalPointFromTransformedPoint(clickLoc, self.normalSize, [[self view] bounds].size, [self scale], viewAngle); NSPoint touchLoc = GetNormalPointFromTransformedPoint(clickLoc, [self normalSizeWithGap], [[self view] bounds].size, [self scale], viewAngle);
// Normalize the y-coordinate to the DS. // Normalize the touch location to the DS.
if ([self displayType] == DS_DISPLAY_TYPE_COMBO) if ([self displayType] == DS_DISPLAY_TYPE_COMBO)
{ {
NSInteger theOrientation = [self displayOrientation]; NSInteger theOrientation = [self displayOrientation];
@ -423,11 +446,11 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
if (theOrientation == DS_DISPLAY_ORIENTATION_VERTICAL && theOrder == DS_DISPLAY_ORDER_TOUCH_FIRST) if (theOrientation == DS_DISPLAY_ORIENTATION_VERTICAL && theOrder == DS_DISPLAY_ORDER_TOUCH_FIRST)
{ {
touchLoc.y -= GPU_DISPLAY_HEIGHT; touchLoc.y -= GPU_DISPLAY_HEIGHT /* + transformedGap */;
} }
else if (theOrientation == DS_DISPLAY_ORIENTATION_HORIZONTAL && theOrder == DS_DISPLAY_ORDER_MAIN_FIRST) else if (theOrientation == DS_DISPLAY_ORIENTATION_HORIZONTAL && theOrder == DS_DISPLAY_ORDER_MAIN_FIRST)
{ {
touchLoc.x -= GPU_DISPLAY_WIDTH; touchLoc.x -= GPU_DISPLAY_WIDTH /* + transformedGap */;
} }
} }
@ -924,11 +947,19 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8, NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)8, NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)8,
NSOpenGLPFAOffScreen, NSOpenGLPFAAccelerated,
(NSOpenGLPixelFormatAttribute)0 (NSOpenGLPixelFormatAttribute)0
}; };
NSOpenGLPixelFormat *tempPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; NSOpenGLPixelFormat *tempPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
if (tempPixelFormat == nil)
{
// Remove the HW rendering requirement and try again. Note that this will
// result in SW rendering, which will cause a substantial speed hit.
attrs[8] = (NSOpenGLPixelFormatAttribute)0;
tempPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
}
NSOpenGLPixelBuffer *tempPixelBuffer = [[NSOpenGLPixelBuffer alloc] NSOpenGLPixelBuffer *tempPixelBuffer = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget:GL_TEXTURE_2D initWithTextureTarget:GL_TEXTURE_2D
textureInternalFormat:GL_RGBA textureInternalFormat:GL_RGBA
@ -987,7 +1018,7 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
CGLSetCurrentContext(cglDisplayContext); CGLSetCurrentContext(cglDisplayContext);
glViewport(0, 0, rect.size.width, rect.size.height); glViewport(0, 0, rect.size.width, rect.size.height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -1019,7 +1050,7 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f); glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
// Set up initial display vertices and store in VBO // Set up initial display vertices and store in VBO
static const GLint vertices[8*2] = {-GPU_DISPLAY_WIDTH/2, GPU_DISPLAY_HEIGHT, // Top display, top left static const GLint vertices[8*2] = {-GPU_DISPLAY_WIDTH/2, GPU_DISPLAY_HEIGHT, // Top display, top left
@ -1123,7 +1154,7 @@ CGLContextObj OSXOpenGLRendererContext = NULL;
GLfloat angleDegrees = (GLfloat)CLOCKWISE_DEGREES([dispViewDelegate rotation]); GLfloat angleDegrees = (GLfloat)CLOCKWISE_DEGREES([dispViewDelegate rotation]);
GLfloat s = (GLfloat)[dispViewDelegate scale]; GLfloat s = (GLfloat)[dispViewDelegate scale];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glBindBuffer(GL_ARRAY_BUFFER, vboTexCoordID); glBindBuffer(GL_ARRAY_BUFFER, vboTexCoordID);
glTexCoordPointer(2, GL_FLOAT, 0, 0); glTexCoordPointer(2, GL_FLOAT, 0, 0);