From 85de7fdc50e5ea754f16aada03e32bd9cddacb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 14 May 2026 22:20:35 +0200 Subject: [PATCH] Add new flag that will simplify the GL path --- Common/Math/lin/matrix4x4.cpp | 2 +- Common/Math/lin/matrix4x4.h | 2 +- Common/System/Display.cpp | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 4 ++-- GPU/GLES/GPU_GLES.cpp | 5 +++++ GPU/GPUState.h | 1 + Windows/GEDebugger/SimpleGLWindow.cpp | 4 ++-- Windows/GEDebugger/VertexPreview.cpp | 4 ++-- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Common/Math/lin/matrix4x4.cpp b/Common/Math/lin/matrix4x4.cpp index e341210cee..44a689ff7c 100644 --- a/Common/Math/lin/matrix4x4.cpp +++ b/Common/Math/lin/matrix4x4.cpp @@ -43,7 +43,7 @@ void Matrix4x4::setViewFrame(const Vec3 &pos, const Vec3 &vRight, const Vec3 &vV ww = 1.0f; } -void Matrix4x4::setOrtho(float left, float right, float bottom, float top, float near, float far) { +void Matrix4x4::setOrthoGL(float left, float right, float bottom, float top, float near, float far) { empty(); xx = 2.0f / (right - left); yy = 2.0f / (top - bottom); diff --git a/Common/Math/lin/matrix4x4.h b/Common/Math/lin/matrix4x4.h index 575b6a61d4..eec4212583 100644 --- a/Common/Math/lin/matrix4x4.h +++ b/Common/Math/lin/matrix4x4.h @@ -87,7 +87,7 @@ public: ww = 1.0f; } - void setOrtho(float left, float right, float bottom, float top, float near, float far); + void setOrthoGL(float left, float right, float bottom, float top, float near, float far); void setOrthoD3D(float left, float right, float bottom, float top, float near, float far); void setOrthoVulkan(float left, float right, float top, float bottom, float near, float far); diff --git a/Common/System/Display.cpp b/Common/System/Display.cpp index aae1776a57..0356a1cba1 100644 --- a/Common/System/Display.cpp +++ b/Common/System/Display.cpp @@ -138,7 +138,7 @@ Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordC break; case CoordConvention::OpenGL: default: - ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); + ortho.setOrthoGL(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); break; } // Compensate for rotated display if needed. diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 18bc85c092..dc4c41fc94 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -3185,9 +3185,9 @@ bool GetOutputFramebuffer(Draw::DrawContext *draw, GPUDebugBuffer &buffer) { if (fmt != Draw::DataFormat::B8G8R8A8_UNORM) fmt = Draw::DataFormat::R8G8B8A8_UNORM; - bool flipped = g_Config.iGPUBackend == (int)GPUBackend::OPENGL; + bool flipY = g_Config.iGPUBackend == (int)GPUBackend::OPENGL; - buffer.Allocate(w, h, fmt == Draw::DataFormat::R8G8B8A8_UNORM ? GPU_DBG_FORMAT_8888 : GPU_DBG_FORMAT_8888_BGRA, flipped); + buffer.Allocate(w, h, fmt == Draw::DataFormat::R8G8B8A8_UNORM ? GPU_DBG_FORMAT_8888 : GPU_DBG_FORMAT_8888_BGRA, flipY); buffer.SetIsBackbuffer(true); return draw->CopyFramebufferToMemory(nullptr, Draw::Aspect::COLOR_BIT, 0, 0, w, h, fmt, buffer.GetData(), w, Draw::ReadbackMode::BLOCK, "GetOutputFramebuffer"); } diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 307ad5e122..65bd18c706 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -190,6 +190,11 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_ROUND_DEPTH_TO_16BIT; } } + + if (!g_Config.bSkipBufferEffects) { + features |= GPU_USE_BUFFERED_FLIP; + } + return features; } diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 627a4c05c8..fabc602d5a 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -480,6 +480,7 @@ enum { GPU_USE_CLIP_DISTANCE = FLAG_BIT(24), GPU_USE_CULL_DISTANCE = FLAG_BIT(25), GPU_USE_SHADER_BLENDING = FLAG_BIT(26), // This is set to false when skip buffer effects is enabled and GPU_USE_FRAMEBUFFER_FETCH is not. + GPU_USE_BUFFERED_FLIP = FLAG_BIT(27), // We use a flip hack to pretend the coordinate system is right-side-up, except if buffered rendering is off. // VR flags (reserved or in-use) GPU_USE_VIRTUAL_REALITY = FLAG_BIT(29), diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index 08060967ce..a1bc6178ca 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -237,7 +237,7 @@ void SimpleGLWindow::DrawChecker() { const GLubyte indices[4] = {0,1,3,2}; Matrix4x4 ortho; - ortho.setOrtho(0, (float)w_, (float)h_, 0, -1, 1); + ortho.setOrthoGL(0, (float)w_, (float)h_, 0, -1, 1); glUniformMatrix4fv(drawProgram_->u_viewproj, 1, GL_FALSE, ortho.getReadPtr()); if (vao_) { glBufferData(GL_ARRAY_BUFFER, sizeof(pos) + sizeof(texCoords), nullptr, GL_DYNAMIC_DRAW); @@ -429,7 +429,7 @@ void SimpleGLWindow::Redraw(bool andSwap) { const float *texCoords = tflipped_ ? texCoordsFlipped : texCoordsNormal; Matrix4x4 ortho; - ortho.setOrtho(0, (float)w_, (float)h_, 0, -1, 1); + ortho.setOrthoGL(0, (float)w_, (float)h_, 0, -1, 1); glUniformMatrix4fv(drawProgram_->u_viewproj, 1, GL_FALSE, ortho.getReadPtr()); if (vao_) { glBufferData(GL_ARRAY_BUFFER, sizeof(pos) + sizeof(texCoordsNormal), nullptr, GL_DYNAMIC_DRAW); diff --git a/Windows/GEDebugger/VertexPreview.cpp b/Windows/GEDebugger/VertexPreview.cpp index eaf4fdc503..87304666c3 100644 --- a/Windows/GEDebugger/VertexPreview.cpp +++ b/Windows/GEDebugger/VertexPreview.cpp @@ -153,7 +153,7 @@ void CGEDebugger::UpdatePrimPreview(u32 op, int which) { }; Lin::Matrix4x4 ortho; - ortho.setOrtho(-(float)gstate_c.curRTOffsetX, (primaryWindow->TexWidth() - (int)gstate_c.curRTOffsetX) * scale[0], primaryWindow->TexHeight() * scale[1], 0, -1, 1); + ortho.setOrthoGL(-(float)gstate_c.curRTOffsetX, (primaryWindow->TexWidth() - (int)gstate_c.curRTOffsetX) * scale[0], primaryWindow->TexHeight() * scale[1], 0, -1, 1); glUniformMatrix4fv(previewProgram->u_viewproj, 1, GL_FALSE, ortho.getReadPtr()); if (previewVao != 0) { glBindVertexArray(previewVao); @@ -216,7 +216,7 @@ void CGEDebugger::UpdatePrimPreview(u32 op, int which) { } Lin::Matrix4x4 ortho; - ortho.setOrtho(0.0f - (float)gstate_c.curTextureXOffset * invRealTexWidth, 1.0f - (float)gstate_c.curTextureXOffset * invRealTexWidth, 1.0f - (float)gstate_c.curTextureYOffset * invRealTexHeight, 0.0f - (float)gstate_c.curTextureYOffset * invRealTexHeight, -1.0f, 1.0f); + ortho.setOrthoGL(0.0f - (float)gstate_c.curTextureXOffset * invRealTexWidth, 1.0f - (float)gstate_c.curTextureXOffset * invRealTexWidth, 1.0f - (float)gstate_c.curTextureYOffset * invRealTexHeight, 0.0f - (float)gstate_c.curTextureYOffset * invRealTexHeight, -1.0f, 1.0f); glUniformMatrix4fv(texPreviewProgram->u_viewproj, 1, GL_FALSE, ortho.getReadPtr()); if (texPreviewVao != 0) { glBindVertexArray(texPreviewVao);