소스 검색

gl_state_tracker: Implement dirty flags for polygon offsets

ReinUsesLisp 6 년 전
부모
커밋
9e46953580

+ 7 - 2
src/video_core/renderer_opengl/gl_rasterizer.cpp

@@ -1249,9 +1249,14 @@ void RasterizerOpenGL::SyncPointState() {
 }
 }
 
 
 void RasterizerOpenGL::SyncPolygonOffset() {
 void RasterizerOpenGL::SyncPolygonOffset() {
-    auto& maxwell3d = system.GPU().Maxwell3D();
-    const auto& regs = maxwell3d.regs;
+    auto& gpu = system.GPU().Maxwell3D();
+    auto& flags = gpu.dirty.flags;
+    if (!flags[Dirty::PolygonOffset]) {
+        return;
+    }
+    flags[Dirty::PolygonOffset] = false;
 
 
+    const auto& regs = gpu.regs;
     oglEnable(GL_POLYGON_OFFSET_FILL, regs.polygon_offset_fill_enable);
     oglEnable(GL_POLYGON_OFFSET_FILL, regs.polygon_offset_fill_enable);
     oglEnable(GL_POLYGON_OFFSET_LINE, regs.polygon_offset_line_enable);
     oglEnable(GL_POLYGON_OFFSET_LINE, regs.polygon_offset_line_enable);
     oglEnable(GL_POLYGON_OFFSET_POINT, regs.polygon_offset_point_enable);
     oglEnable(GL_POLYGON_OFFSET_POINT, regs.polygon_offset_point_enable);

+ 11 - 0
src/video_core/renderer_opengl/gl_state_tracker.cpp

@@ -168,6 +168,16 @@ void SetupDirtyPrimitiveRestart(Tables& tables) {
     FillBlock(tables[0], OFF(primitive_restart), NUM(primitive_restart), PrimitiveRestart);
     FillBlock(tables[0], OFF(primitive_restart), NUM(primitive_restart), PrimitiveRestart);
 }
 }
 
 
+void SetupDirtyPolygonOffset(Tables& tables) {
+    auto& table = tables[0];
+    table[OFF(polygon_offset_fill_enable)] = PolygonOffset;
+    table[OFF(polygon_offset_line_enable)] = PolygonOffset;
+    table[OFF(polygon_offset_point_enable)] = PolygonOffset;
+    table[OFF(polygon_offset_factor)] = PolygonOffset;
+    table[OFF(polygon_offset_units)] = PolygonOffset;
+    table[OFF(polygon_offset_clamp)] = PolygonOffset;
+}
+
 void SetupDirtyMisc(Tables& tables) {
 void SetupDirtyMisc(Tables& tables) {
     auto& table = tables[0];
     auto& table = tables[0];
 
 
@@ -197,6 +207,7 @@ void StateTracker::Initialize() {
     SetupDirtyStencilTest(tables);
     SetupDirtyStencilTest(tables);
     SetupDirtyBlend(tables);
     SetupDirtyBlend(tables);
     SetupDirtyPrimitiveRestart(tables);
     SetupDirtyPrimitiveRestart(tables);
+    SetupDirtyPolygonOffset(tables);
     SetupDirtyMisc(tables);
     SetupDirtyMisc(tables);
 
 
     auto& store = dirty.on_write_stores;
     auto& store = dirty.on_write_stores;

+ 5 - 0
src/video_core/renderer_opengl/gl_state_tracker.h

@@ -140,6 +140,11 @@ public:
         flags[OpenGL::Dirty::StencilTest] = true;
         flags[OpenGL::Dirty::StencilTest] = true;
     }
     }
 
 
+    void NotifyPolygonOffset() {
+        auto& flags = system.GPU().Maxwell3D().dirty.flags;
+        flags[OpenGL::Dirty::PolygonOffset] = true;
+    }
+
 private:
 private:
     Core::System& system;
     Core::System& system;
 };
 };

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

@@ -586,6 +586,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
     state_tracker.NotifyCullTest();
     state_tracker.NotifyCullTest();
     state_tracker.NotifyDepthTest();
     state_tracker.NotifyDepthTest();
     state_tracker.NotifyStencilTest();
     state_tracker.NotifyStencilTest();
+    state_tracker.NotifyPolygonOffset();
 
 
     program_manager.UseVertexShader(vertex_program.handle);
     program_manager.UseVertexShader(vertex_program.handle);
     program_manager.UseGeometryShader(0);
     program_manager.UseGeometryShader(0);