summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-30 02:56:21 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 21:56:42 +0100
commit40a2c57df5459ff965f1ea507bbca0e36ab17c94 (patch)
tree264b74193808efb987305fae4743109d2db33eb4 /src
parentgl_state_tracker: Implement dirty flags for front face and culling (diff)
downloadyuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar.gz
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar.bz2
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar.lz
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar.xz
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.tar.zst
yuzu-40a2c57df5459ff965f1ea507bbca0e36ab17c94.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp20
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.h8
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
4 files changed, 31 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 6d87b4e29..d747e29ad 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -1024,13 +1024,23 @@ void RasterizerOpenGL::SyncPrimitiveRestart() {
}
void RasterizerOpenGL::SyncDepthTestState() {
- const auto& regs = system.GPU().Maxwell3D().regs;
+ auto& gpu = system.GPU().Maxwell3D();
+ auto& flags = gpu.dirty.flags;
- glDepthMask(regs.depth_write_enabled ? GL_TRUE : GL_FALSE);
+ const auto& regs = gpu.regs;
+ if (flags[Dirty::DepthMask]) {
+ flags[Dirty::DepthMask] = false;
+ glDepthMask(regs.depth_write_enabled ? GL_TRUE : GL_FALSE);
+ }
- oglEnable(GL_DEPTH_TEST, regs.depth_test_enable);
- if (regs.depth_test_enable) {
- glDepthFunc(MaxwellToGL::ComparisonOp(regs.depth_test_func));
+ if (flags[Dirty::DepthTest]) {
+ flags[Dirty::DepthTest] = false;
+ if (regs.depth_test_enable) {
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(MaxwellToGL::ComparisonOp(regs.depth_test_func));
+ } else {
+ glDisable(GL_DEPTH_TEST);
+ }
}
}
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp
index 05bba5d1d..999440656 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.cpp
+++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp
@@ -129,6 +129,13 @@ void SetupDirtyShaders(Tables& tables) {
Shaders);
}
+void SetupDirtyDepthTest(Tables& tables) {
+ auto& table = tables[0];
+ table[OFF(depth_test_enable)] = DepthTest;
+ table[OFF(depth_write_enabled)] = DepthMask;
+ table[OFF(depth_test_func)] = DepthTest;
+}
+
void SetupDirtyBlend(Tables& tables) {
FillBlock(tables[0], OFF(blend_color), NUM(blend_color), BlendColor);
@@ -169,6 +176,7 @@ void StateTracker::Initialize() {
SetupDirtyVertexArrays(tables);
SetupDirtyVertexFormat(tables);
SetupDirtyShaders(tables);
+ SetupDirtyDepthTest(tables);
SetupDirtyBlend(tables);
SetupDirtyMisc(tables);
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h
index 1d854f38e..dd6cfe02a 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.h
+++ b/src/video_core/renderer_opengl/gl_state_tracker.h
@@ -58,8 +58,9 @@ enum : u8 {
FrontFace,
CullTest,
- PrimitiveRestart,
+ DepthMask,
DepthTest,
+ PrimitiveRestart,
StencilTest,
ColorMask,
PolygonOffset,
@@ -129,6 +130,11 @@ public:
flags[OpenGL::Dirty::CullTest] = true;
}
+ void NotifyDepthTest() {
+ auto& flags = system.GPU().Maxwell3D().dirty.flags;
+ flags[OpenGL::Dirty::DepthTest] = true;
+ }
+
private:
Core::System& system;
};
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index e21d7e7a3..8fa4ecb28 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -584,6 +584,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
state_tracker.NotifyFramebuffer();
state_tracker.NotifyFrontFace();
state_tracker.NotifyCullTest();
+ state_tracker.NotifyDepthTest();
program_manager.UseVertexShader(vertex_program.handle);
program_manager.UseGeometryShader(0);