mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-03 13:01:55 +01:00
Merge pull request #10713 from hrydgard/windows-gl-vsync-fix
Fix VSync on Windows. Should fix #10711
This commit is contained in:
3 files changed
+31
-6
No files matched your search
@@ -332,8 +332,6 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) {
|
||||
|
||||
hRC = m_hrc;
|
||||
|
||||
SwapInterval(0);
|
||||
|
||||
if (g_Config.bGfxDebugOutput) {
|
||||
if (wglewIsSupported("GL_KHR_debug") == 1) {
|
||||
glGetError();
|
||||
@@ -375,16 +373,21 @@ bool WindowsGLContext::InitFromRenderThread(std::string *error_message) {
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
SetGPUBackend(GPUBackend::OPENGL);
|
||||
bool success = draw_->CreatePresets(); // if we get this far, there will always be a GLSL compiler capable of compiling these.
|
||||
renderManager_->SetSwapFunction([&]() {::SwapBuffers(hDC); });
|
||||
assert(success);
|
||||
renderManager_->SetSwapFunction([&]() {::SwapBuffers(hDC); });
|
||||
if (wglSwapIntervalEXT) {
|
||||
// glew loads wglSwapIntervalEXT if available
|
||||
renderManager_->SetSwapIntervalFunction([&](int interval) {
|
||||
wglSwapIntervalEXT(interval);
|
||||
});
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
return true; // Success
|
||||
}
|
||||
|
||||
void WindowsGLContext::SwapInterval(int interval) {
|
||||
// glew loads wglSwapIntervalEXT if available
|
||||
if (wglSwapIntervalEXT)
|
||||
wglSwapIntervalEXT(interval);
|
||||
// Delegate to the render manager to make sure it's done on the right thread.
|
||||
renderManager_->SwapInterval(interval);
|
||||
}
|
||||
|
||||
void WindowsGLContext::Shutdown() {
|
||||
|
||||
@@ -436,6 +436,12 @@ void GLRenderManager::EndSubmitFrame(int frame) {
|
||||
Submit(frame, true);
|
||||
|
||||
if (!frameData.skipSwap) {
|
||||
if (swapIntervalChanged_) {
|
||||
swapIntervalChanged_ = false;
|
||||
if (swapIntervalFunction_) {
|
||||
swapIntervalFunction_(swapInterval_);
|
||||
}
|
||||
}
|
||||
if (swapFunction_) {
|
||||
swapFunction_();
|
||||
}
|
||||
|
||||
@@ -682,6 +682,7 @@ public:
|
||||
void RegisterPushBuffer(int frame, GLPushBuffer *buffer) {
|
||||
frameData_[frame].activePushBuffers.insert(buffer);
|
||||
}
|
||||
|
||||
void UnregisterPushBuffer(int frame, GLPushBuffer *buffer) {
|
||||
auto iter = frameData_[frame].activePushBuffers.find(buffer);
|
||||
_assert_(iter != frameData_[frame].activePushBuffers.end());
|
||||
@@ -692,6 +693,17 @@ public:
|
||||
swapFunction_ = swapFunction;
|
||||
}
|
||||
|
||||
void SetSwapIntervalFunction(std::function<void(int)> swapIntervalFunction) {
|
||||
swapIntervalFunction_ = swapIntervalFunction;
|
||||
}
|
||||
|
||||
void SwapInterval(int interval) {
|
||||
if (interval != swapInterval_) {
|
||||
swapInterval_ = interval;
|
||||
swapIntervalChanged_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void StopThread();
|
||||
|
||||
bool SawOutOfMemory() {
|
||||
@@ -765,8 +777,12 @@ private:
|
||||
int curFrame_ = 0;
|
||||
|
||||
std::function<void()> swapFunction_;
|
||||
std::function<void(int)> swapIntervalFunction_;
|
||||
GLBufferStrategy bufferStrategy_ = GLBufferStrategy::SUBDATA;
|
||||
|
||||
int swapInterval_ = 0;
|
||||
bool swapIntervalChanged_ = true;
|
||||
|
||||
int targetWidth_ = 0;
|
||||
int targetHeight_ = 0;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user