summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-29 23:23:40 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 21:56:42 +0100
commitb910a83a47a2b566a760dbd20ff5902f303044d4 (patch)
tree8b8952cf2132b21bf6a5da304aaeeab9de4bfa8c
parentgl_state_tracker: Implement dirty flags for blending (diff)
downloadyuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar.gz
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar.bz2
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar.lz
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar.xz
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.tar.zst
yuzu-b910a83a47a2b566a760dbd20ff5902f303044d4.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp21
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.cpp9
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.h13
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp2
4 files changed, 38 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index cedfe5db1..6d87b4e29 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -995,12 +995,25 @@ void RasterizerOpenGL::SyncClipCoef() {
}
void RasterizerOpenGL::SyncCullMode() {
- const auto& regs = system.GPU().Maxwell3D().regs;
+ auto& gpu = system.GPU().Maxwell3D();
+ auto& flags = gpu.dirty.flags;
+ const auto& regs = gpu.regs;
- oglEnable(GL_CULL_FACE, regs.cull_test_enabled);
- glCullFace(MaxwellToGL::CullFace(regs.cull_face));
+ if (flags[Dirty::CullTest]) {
+ flags[Dirty::CullTest] = false;
- glFrontFace(MaxwellToGL::FrontFace(regs.front_face));
+ if (regs.cull_test_enabled) {
+ glEnable(GL_CULL_FACE);
+ glCullFace(MaxwellToGL::CullFace(regs.cull_face));
+ } else {
+ glDisable(GL_CULL_FACE);
+ }
+ }
+
+ if (flags[Dirty::FrontFace]) {
+ flags[Dirty::FrontFace] = false;
+ glFrontFace(MaxwellToGL::FrontFace(regs.front_face));
+ }
}
void RasterizerOpenGL::SyncPrimitiveRestart() {
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp
index 2da1b65fc..05bba5d1d 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.cpp
+++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp
@@ -145,7 +145,14 @@ void SetupDirtyBlend(Tables& tables) {
}
void SetupDirtyMisc(Tables& tables) {
- tables[0][OFF(clip_distance_enabled)] = ClipDistances;
+ auto& table = tables[0];
+
+ table[OFF(clip_distance_enabled)] = ClipDistances;
+
+ table[OFF(front_face)] = FrontFace;
+
+ table[OFF(cull_test_enabled)] = CullTest;
+ table[OFF(cull_face)] = CullTest;
}
} // Anonymous namespace
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h
index a9b470eee..1d854f38e 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.h
+++ b/src/video_core/renderer_opengl/gl_state_tracker.h
@@ -56,9 +56,8 @@ enum : u8 {
Shaders,
ClipDistances,
- CullTestEnable,
FrontFace,
- CullFace,
+ CullTest,
PrimitiveRestart,
DepthTest,
StencilTest,
@@ -120,6 +119,16 @@ public:
flags[VideoCommon::Dirty::RenderTargets] = true;
}
+ void NotifyFrontFace() {
+ auto& flags = system.GPU().Maxwell3D().dirty.flags;
+ flags[OpenGL::Dirty::FrontFace] = true;
+ }
+
+ void NotifyCullTest() {
+ auto& flags = system.GPU().Maxwell3D().dirty.flags;
+ flags[OpenGL::Dirty::CullTest] = 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 d81c68077..e21d7e7a3 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -582,6 +582,8 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
state_tracker.NotifyColorMask0();
state_tracker.NotifyBlend0();
state_tracker.NotifyFramebuffer();
+ state_tracker.NotifyFrontFace();
+ state_tracker.NotifyCullTest();
program_manager.UseVertexShader(vertex_program.handle);
program_manager.UseGeometryShader(0);