summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2019-03-05 23:02:40 +1000
committerStenzek <stenzek@gmail.com>2019-04-21 14:28:14 +1000
commitf2a594fad5de59180add789ebebac7ff74f69c32 (patch)
tree5bd6e3acd7ce2822516cc91589056caa475cc3a1 /Source/Core/VideoBackends
parent9577d0641b08b86de19953c6b6d6971d77dc6321 (diff)
OGL: Fix binding error on shutdown
This was occurring if the imgui vertex format was bound on shutdown, which is destroyed before the vertex buffers
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp1
-rw-r--r--Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp6
-rw-r--r--Source/Core/VideoBackends/OGL/ProgramShaderCache.h1
3 files changed, 8 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp
index 50a6276c72..c95e1f8472 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 85084979c3..8832c8e6f0 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 4aeb40a6c9..bc93445c55 100644
--- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.h
+++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.h
@@ -72,6 +72,7 @@ public:
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);