From f0ee4c059566f0741b757db944de8a3be195e805 Mon Sep 17 00:00:00 2001
From: wwylele <wwylele@gmail.com>
Date: Fri, 1 Jun 2018 01:27:46 +0300
Subject: [PATCH] gl_rasterizer: reset texture state context after every draw

---
 src/video_core/renderer_opengl/gl_rasterizer.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 278a8a118..b19c04f6f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -786,6 +786,13 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
 
     vertex_batch.clear();
 
+    // Reset textures in rasterizer state context because the rasterizer cache might delete them
+    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,