diff --git a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp index 50a6276c7205..c95e1f84728d 100644 --- a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp @@ -80,6 +80,7 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl) GLVertexFormat::~GLVertexFormat() { + ProgramShaderCache::InvalidateVertexFormatIfBound(VAO); glDeleteVertexArrays(1, &VAO); } } // namespace OGL diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 85084979c36d..8832c8e6f0ee 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -494,6 +494,12 @@ void ProgramShaderCache::InvalidateVertexFormat() s_last_VAO = 0; } +void ProgramShaderCache::InvalidateVertexFormatIfBound(GLuint vao) +{ + if (s_last_VAO == vao) + s_last_VAO = 0; +} + void ProgramShaderCache::InvalidateLastProgram() { CurrentProgram = 0; diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.h b/Source/Core/VideoBackends/OGL/ProgramShaderCache.h index 4aeb40a6c979..bc93445c55e5 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.h +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.h @@ -72,6 +72,7 @@ class ProgramShaderCache static void BindVertexFormat(const GLVertexFormat* vertex_format); static bool IsValidVertexFormatBound(); static void InvalidateVertexFormat(); + static void InvalidateVertexFormatIfBound(GLuint vao); static void InvalidateLastProgram(); static bool CompileComputeShader(SHADER& shader, const std::string& code);