فهرست منبع

gl_state_tracker: Implement dirty flags for front face and culling

ReinUsesLisp 6 سال پیش
والد
کامیت
b910a83a47

+ 17 - 4
src/video_core/renderer_opengl/gl_rasterizer.cpp

@@ -995,12 +995,25 @@ void RasterizerOpenGL::SyncClipCoef() {
 }
 }
 
 
 void RasterizerOpenGL::SyncCullMode() {
 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() {
 void RasterizerOpenGL::SyncPrimitiveRestart() {

+ 8 - 1
src/video_core/renderer_opengl/gl_state_tracker.cpp

@@ -145,7 +145,14 @@ void SetupDirtyBlend(Tables& tables) {
 }
 }
 
 
 void SetupDirtyMisc(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
 } // Anonymous namespace

+ 11 - 2
src/video_core/renderer_opengl/gl_state_tracker.h

@@ -56,9 +56,8 @@ enum : u8 {
     Shaders,
     Shaders,
     ClipDistances,
     ClipDistances,
 
 
-    CullTestEnable,
     FrontFace,
     FrontFace,
-    CullFace,
+    CullTest,
     PrimitiveRestart,
     PrimitiveRestart,
     DepthTest,
     DepthTest,
     StencilTest,
     StencilTest,
@@ -120,6 +119,16 @@ public:
         flags[VideoCommon::Dirty::RenderTargets] = true;
         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:
 private:
     Core::System& system;
     Core::System& system;
 };
 };

+ 2 - 0
src/video_core/renderer_opengl/renderer_opengl.cpp

@@ -582,6 +582,8 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
     state_tracker.NotifyColorMask0();
     state_tracker.NotifyColorMask0();
     state_tracker.NotifyBlend0();
     state_tracker.NotifyBlend0();
     state_tracker.NotifyFramebuffer();
     state_tracker.NotifyFramebuffer();
+    state_tracker.NotifyFrontFace();
+    state_tracker.NotifyCullTest();
 
 
     program_manager.UseVertexShader(vertex_program.handle);
     program_manager.UseVertexShader(vertex_program.handle);
     program_manager.UseGeometryShader(0);
     program_manager.UseGeometryShader(0);