From 0f343d32c41efc411fddb1a66a9f11fb68eebf06 Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Wed, 25 Dec 2019 21:00:38 -0300
Subject: [PATCH] gl_state: Remove primitive restart tracking

---
 src/video_core/renderer_opengl/gl_rasterizer.cpp |  4 ++--
 src/video_core/renderer_opengl/gl_state.cpp      | 10 ----------
 src/video_core/renderer_opengl/gl_state.h        |  6 ------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 9d4b351fb4..975cd2f129 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -1029,8 +1029,8 @@ void RasterizerOpenGL::SyncCullMode() {
 void RasterizerOpenGL::SyncPrimitiveRestart() {
     const auto& regs = system.GPU().Maxwell3D().regs;
 
-    state.primitive_restart.enabled = regs.primitive_restart.enabled;
-    state.primitive_restart.index = regs.primitive_restart.index;
+    oglEnable(GL_PRIMITIVE_RESTART, regs.primitive_restart.enabled);
+    glPrimitiveRestartIndex(regs.primitive_restart.index);
 }
 
 void RasterizerOpenGL::SyncDepthTestState() {
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index ddc534eb4c..49a15f82ff 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -197,15 +197,6 @@ void OpenGLState::ApplyDepth() {
     }
 }
 
-void OpenGLState::ApplyPrimitiveRestart() {
-    Enable(GL_PRIMITIVE_RESTART, cur_state.primitive_restart.enabled, primitive_restart.enabled);
-
-    if (cur_state.primitive_restart.index != primitive_restart.index) {
-        cur_state.primitive_restart.index = primitive_restart.index;
-        glPrimitiveRestartIndex(primitive_restart.index);
-    }
-}
-
 void OpenGLState::ApplyStencilTest() {
     Enable(GL_STENCIL_TEST, cur_state.stencil.test_enabled, stencil.test_enabled);
 
@@ -390,7 +381,6 @@ void OpenGLState::Apply() {
     ApplyStencilTest();
     ApplySRgb();
     ApplyDepth();
-    ApplyPrimitiveRestart();
     ApplyBlending();
     ApplyTextures();
     ApplySamplers();
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 958af57714..938222d385 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -37,11 +37,6 @@ public:
         GLenum test_func = GL_LESS;     // GL_DEPTH_FUNC
     } depth;
 
-    struct {
-        bool enabled = false;
-        GLuint index = 0;
-    } primitive_restart; // GL_PRIMITIVE_RESTART
-
     bool rasterizer_discard = false; // GL_RASTERIZER_DISCARD
 
     struct ColorMask {
@@ -143,7 +138,6 @@ public:
     void ApplyRasterizerDiscard();
     void ApplyColorMask();
     void ApplyDepth();
-    void ApplyPrimitiveRestart();
     void ApplyStencilTest();
     void ApplyViewport();
     void ApplyTargetBlending(std::size_t target, bool force);