all repos — mgba @ 71b6066d4f6aecc85dc1dafc92cecaf6154f8f4a

mGBA Game Boy Advance Emulator

GBA Video: Fix some GL handle leaks
Vicki Pfau vi@endrift.com
Sat, 18 May 2019 01:09:29 -0700
commit

71b6066d4f6aecc85dc1dafc92cecaf6154f8f4a

parent

43180dca1df957a9e82f08edbf02cd19b00248e8

1 files changed, 22 insertions(+), 1 deletions(-)

jump to
M src/gba/renderers/gl.csrc/gba/renderers/gl.c

@@ -390,7 +390,7 @@

renderer->scale = 1; } -void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVideoGLShader* shader, const char** shaderBuffer, int shaderBufferLines, GLuint vs, const struct GBAVideoGLUniform* uniforms, char* log) { +static void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVideoGLShader* shader, const char** shaderBuffer, int shaderBufferLines, GLuint vs, const struct GBAVideoGLUniform* uniforms, char* log) { GLuint program = glCreateProgram(); shader->program = program;

@@ -424,6 +424,11 @@ size_t i;

for (i = 0; uniforms[i].name; ++i) { shader->uniforms[uniforms[i].type] = glGetUniformLocation(program, uniforms[i].name); } +} + +static void _deleteShader(struct GBAVideoGLShader* shader) { + glDeleteProgram(shader->program); + glDeleteVertexArrays(1, &shader->vao); } static void _initFramebufferTexture(GLuint tex, GLenum format, GLenum attachment, int scale) {

@@ -564,6 +569,22 @@ glDeleteFramebuffers(GBA_GL_FBO_MAX, glRenderer->fbo);

glDeleteTextures(GBA_GL_TEX_MAX, glRenderer->layers); glDeleteTextures(1, &glRenderer->paletteTex); glDeleteTextures(1, &glRenderer->vramTex); + + _deleteShader(&glRenderer->bgShader[0]); + _deleteShader(&glRenderer->bgShader[1]); + _deleteShader(&glRenderer->bgShader[2]); + _deleteShader(&glRenderer->bgShader[3]); + _deleteShader(&glRenderer->objShader[0]); + _deleteShader(&glRenderer->objShader[1]); + _deleteShader(&glRenderer->finalizeShader); + + int i; + for (i = 0; i < 4; ++i) { + struct GBAVideoGLBackground* bg = &glRenderer->bg[i]; + glDeleteFramebuffers(1, &bg->fbo); + glDeleteTextures(1, &bg->tex); + glDeleteTextures(1, &bg->flags); + } } void GBAVideoGLRendererReset(struct GBAVideoRenderer* renderer) {