From caba02d42a545265153a281ed50c3b40d3bec648 Mon Sep 17 00:00:00 2001
From: Markus Wick <markus@selfnet.de>
Date: Mon, 28 May 2018 20:58:44 +0200
Subject: [PATCH] gl_rasterizer: Don't flip the texture bindings.

The state object isn't used anywhere else, so there
is no need to revert the state.
And the comment is just wrong: It doesn't matter
which textures are bound on framebuffer binding, it
only matters at draw time. And we reset all bindings
before the draw call. So let's use gl_state as it is
designed to avoid flipping states.
---
 src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 6f5c5fb12..278a8a118 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -676,6 +676,7 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
                     state.texture_units[texture_index].texture_2d = 0;
                     continue; // Texture unit 0 setup finished. Continue to next unit
                 }
+                state.texture_cube_unit.texture_cube = 0;
             }
 
             texture_samplers[texture_index].SyncWithConfig(texture.config);
@@ -785,13 +786,6 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
 
     vertex_batch.clear();
 
-    // Unbind textures for potential future use as framebuffer attachments
-    for (unsigned texture_index = 0; texture_index < pica_textures.size(); ++texture_index) {
-        state.texture_units[texture_index].texture_2d = 0;
-    }
-    state.texture_cube_unit.texture_cube = 0;
-    state.Apply();
-
     // Mark framebuffer surfaces as dirty
     MathUtil::Rectangle<u32> draw_rect_unscaled{
         draw_rect.left / res_scale, draw_rect.top / res_scale, draw_rect.right / res_scale,