Skip to content

Commit

Permalink
OGL: Fix binding error on shutdown
Browse files Browse the repository at this point in the history
This was occurring if the imgui vertex format was bound on shutdown,
which is destroyed before the vertex buffers
  • Loading branch information
stenzek committed Apr 21, 2019
1 parent 9577d06 commit f2a594f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp
Expand Up @@ -80,6 +80,7 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)

GLVertexFormat::~GLVertexFormat()
{
ProgramShaderCache::InvalidateVertexFormatIfBound(VAO);
glDeleteVertexArrays(1, &VAO);
}
} // namespace OGL
6 changes: 6 additions & 0 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.h
Expand Up @@ -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);
Expand Down

0 comments on commit f2a594f

Please sign in to comment.