Add new flag that will simplify the GL path

This commit is contained in:
Henrik Rydgård
2026-05-14 22:20:35 +02:00
parent 8dc3e8ed14
commit 85de7fdc50
8 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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.
+2 -2
View File
@@ -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");
}
+5
View File
@@ -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;
}
+1
View File
@@ -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),
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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);