From 8dc9c225d731ac549f4c905490a1035ed69c4a4d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 23 Sep 2023 13:11:25 +1000 Subject: [PATCH] OpenGLDevice: Keep scissor active on present clear And disable depth test if set to always (match DX11). --- src/util/opengl_device.cpp | 7 +++---- src/util/opengl_pipeline.cpp | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/opengl_device.cpp b/src/util/opengl_device.cpp index 9fac10bbd..78dbf2bf1 100644 --- a/src/util/opengl_device.cpp +++ b/src/util/opengl_device.cpp @@ -663,10 +663,6 @@ bool OpenGLDevice::BeginPresent(bool skip_present) } glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glDisable(GL_SCISSOR_TEST); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glEnable(GL_SCISSOR_TEST); const Common::Rectangle window_rc = Common::Rectangle::FromExtents(0, 0, m_window_info.surface_width, m_window_info.surface_height); @@ -675,6 +671,9 @@ bool OpenGLDevice::BeginPresent(bool skip_present) m_last_scissor = window_rc; UpdateViewport(); UpdateScissor(); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); return true; } diff --git a/src/util/opengl_pipeline.cpp b/src/util/opengl_pipeline.cpp index 040a1ea2e..c614557c1 100644 --- a/src/util/opengl_pipeline.cpp +++ b/src/util/opengl_pipeline.cpp @@ -612,7 +612,8 @@ ALWAYS_INLINE static void ApplyDepthState(const GPUPipeline::DepthState& ds) GL_EQUAL, // Equal }}; - (ds.depth_test != GPUPipeline::DepthFunc::Never) ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); + (ds.depth_test != GPUPipeline::DepthFunc::Always || ds.depth_write) ? glEnable(GL_DEPTH_TEST) : + glDisable(GL_DEPTH_TEST); glDepthFunc(func_mapping[static_cast(ds.depth_test.GetValue())]); glDepthMask(ds.depth_write); }