Cocoa Port: Do some minor code cleanup.

This commit is contained in:
rogerman 2017-12-11 16:17:02 -08:00
parent cd2f75e43a
commit 1ea95cdde4
5 changed files with 33 additions and 14 deletions

View File

@ -4818,6 +4818,8 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
return OGLERROR_BEGINGL_FAILED;
}
glFinish();
const size_t newFramebufferColorSizeBytes = w * h * sizeof(FragmentColor);
if (this->isPBOSupported)
@ -4825,10 +4827,16 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
if (this->_mappedFramebuffer != NULL)
{
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);
glFinish();
}
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, newFramebufferColorSizeBytes, NULL, GL_STREAM_READ_ARB);
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
if (this->_mappedFramebuffer != NULL)
{
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
glFinish();
}
}
if (this->isShaderSupported && this->isFBOSupported && this->isVBOSupported)
@ -4902,6 +4910,7 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
oglrender_framebufferDidResizeCallback(w, h);
}
glFinish();
ENDGL();
return OGLERROR_NOERR;

View File

@ -1994,15 +1994,22 @@ Render3DError OpenGLRenderer_3_2::SetFramebufferSize(size_t w, size_t h)
return OGLERROR_BEGINGL_FAILED;
}
const size_t newFramebufferColorSizeBytes = w * h * sizeof(FragmentColor);
glFinish();
if (this->_mappedFramebuffer != NULL)
{
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glFinish();
}
const size_t newFramebufferColorSizeBytes = w * h * sizeof(FragmentColor);
glBufferData(GL_PIXEL_PACK_BUFFER, newFramebufferColorSizeBytes, NULL, GL_STREAM_READ);
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (this->_mappedFramebuffer != NULL)
{
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
glFinish();
}
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FinalColor);
glBindTexture(GL_TEXTURE_2D, OGLRef.texFinalColorID);
@ -2065,6 +2072,7 @@ Render3DError OpenGLRenderer_3_2::SetFramebufferSize(size_t w, size_t h)
oglrender_framebufferDidResizeCallback(w, h);
}
glFinish();
ENDGL();
return OGLERROR_NOERR;

View File

@ -104,7 +104,6 @@ typedef std::map<CGDirectDisplayID, int64_t> DisplayLinkFlushTimeLimitMap;
UInt32 gpuStateFlags;
uint8_t _gpuScale;
BOOL isCPUCoreCountAuto;
BOOL _needRestoreFrameLock;
BOOL _needRestoreRender3DLock;
OSSpinLock spinlockGpuState;

View File

@ -30,10 +30,10 @@
#endif
#include <OpenGL/OpenGL.h>
#include "userinterface/MacOGLDisplayView.h"
#import "userinterface/MacOGLDisplayView.h"
#ifdef ENABLE_APPLE_METAL
#include "userinterface/MacMetalDisplayView.h"
#import "userinterface/MacMetalDisplayView.h"
#endif
#ifdef BOOL
@ -149,7 +149,6 @@ public:
GPUSTATE_SUB_OBJ_MASK;
isCPUCoreCountAuto = NO;
_needRestoreFrameLock = NO;
_needRestoreRender3DLock = NO;
SetOpenGLRendererFunctions(&OSXOpenGLRendererInit,
@ -865,18 +864,21 @@ public:
gpuEvent->FramebufferLock();
#ifdef ENABLE_SHARED_FETCH_OBJECT
const u8 bufferIndex = GPU->GetDisplayInfo().bufferIndex;
semaphore_wait([[self sharedData] semaphoreFramebufferAtIndex:bufferIndex]);
semaphore_wait([[self sharedData] semaphoreFramebufferAtIndex:0]);
semaphore_wait([[self sharedData] semaphoreFramebufferAtIndex:1]);
#endif
GPU->ClearWithColor(colorBGRA5551);
#ifdef ENABLE_SHARED_FETCH_OBJECT
semaphore_signal([[self sharedData] semaphoreFramebufferAtIndex:bufferIndex]);
semaphore_signal([[self sharedData] semaphoreFramebufferAtIndex:1]);
semaphore_signal([[self sharedData] semaphoreFramebufferAtIndex:0]);
#endif
gpuEvent->FramebufferUnlock();
#ifdef ENABLE_SHARED_FETCH_OBJECT
const u8 bufferIndex = GPU->GetDisplayInfo().bufferIndex;
[[self sharedData] signalFetchAtIndex:bufferIndex message:MESSAGE_FETCH_AND_PUSH_VIDEO];
#endif
}

View File

@ -1121,8 +1121,8 @@ static void* RunCoreThread(void *arg)
NSMutableArray *cdsOutputList = [cdsCore cdsOutputList];
const NDSFrameInfo &ndsFrameInfo = execControl->GetNDSFrameInfo();
double startTime = 0;
double frameTime = 0; // The amount of time that is expected for the frame to run.
double startTime = 0.0;
double frameTime = 0.0; // The amount of time that is expected for the frame to run.
const double standardNDSFrameTime = execControl->CalculateFrameAbsoluteTime(1.0);
double executionSpeedAverage = 0.0;
@ -1302,7 +1302,8 @@ static void* RunCoreThread(void *arg)
}
}
const double currentExecutionSpeed = standardNDSFrameTime / (execControl->GetCurrentAbsoluteTime() - startTime);
const double endTime = execControl->GetCurrentAbsoluteTime();
const double currentExecutionSpeed = standardNDSFrameTime / (endTime - startTime);
executionSpeedAverage += currentExecutionSpeed;
executionSpeedAverageFramesCollected += 1.0;