all repos — mgba @ a0af0ce1419eca9cc03f4b7a66638603898f66c7

mGBA Game Boy Advance Emulator

GL: Fix VAO semantics
Vicki Pfau vi@endrift.com
Wed, 22 May 2019 12:21:53 -0700
commit

a0af0ce1419eca9cc03f4b7a66638603898f66c7

parent

eb5a7951010f00548007b549f08d72d2bc3d4940

2 files changed, 6 insertions(+), 10 deletions(-)

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

@@ -571,6 +571,7 @@ glGenVertexArrays(1, &shader->vao);

glBindVertexArray(shader->vao); glBindBuffer(GL_ARRAY_BUFFER, glRenderer->vbo); GLuint positionLocation = glGetAttribLocation(program, "position"); + glEnableVertexAttribArray(positionLocation); glVertexAttribPointer(positionLocation, 2, GL_INT, GL_FALSE, 0, NULL); size_t i;

@@ -1131,12 +1132,12 @@

void GBAVideoGLRendererFinishFrame(struct GBAVideoRenderer* renderer) { struct GBAVideoGLRenderer* glRenderer = (struct GBAVideoGLRenderer*) renderer; _finalizeLayers(glRenderer); + glBindVertexArray(0); glRenderer->firstAffine = -1; glRenderer->bg[2].affine[0].sx = glRenderer->bg[2].refx; glRenderer->bg[2].affine[0].sy = glRenderer->bg[2].refy; glRenderer->bg[3].affine[0].sx = glRenderer->bg[3].refx; glRenderer->bg[3].affine[0].sy = glRenderer->bg[3].refy; - glFlush(); } void GBAVideoGLRendererGetPixels(struct GBAVideoRenderer* renderer, size_t* stride, const void** pixels) {

@@ -1273,7 +1274,6 @@ glUniform1i(uniforms[GBA_GL_FINALIZE_WINDOW], 0);

glUniform1i(uniforms[GBA_GL_FINALIZE_WINDOW], 0); glUniform1i(uniforms[GBA_GL_FINALIZE_BACKDROP], 11); glUniform1i(uniforms[GBA_GL_FINALIZE_BACKDROPFLAGS], 12); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glBindFramebuffer(GL_FRAMEBUFFER, 0); }

@@ -1353,7 +1353,6 @@ glUniform4i(uniforms[GBA_GL_OBJ_MOSAIC], mosaicH, GBAMosaicControlGetObjV(renderer->mosaic) + 1, x, spriteY);

} else { glUniform4i(uniforms[GBA_GL_OBJ_MOSAIC], 0, 0, 0, 0); } - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1399,7 +1398,6 @@ glUniform1i(uniforms[GBA_GL_BG_SCREENBASE], background->screenBase);

glUniform1i(uniforms[GBA_GL_BG_CHARBASE], background->charBase); glUniform1i(uniforms[GBA_GL_BG_SIZE], background->size); glUniform2i(uniforms[GBA_GL_BG_OFFSET], background->x, yBase - y); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1475,7 +1473,6 @@ _prepareTransform(renderer, background, uniforms, y);

glUniform1i(uniforms[GBA_GL_BG_SCREENBASE], background->screenBase); glUniform1i(uniforms[GBA_GL_BG_CHARBASE], background->charBase); glUniform1i(uniforms[GBA_GL_BG_SIZE], background->size); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1490,7 +1487,6 @@ glBindVertexArray(shader->vao);

_prepareTransform(renderer, background, uniforms, y); glUniform1i(uniforms[GBA_GL_BG_CHARBASE], 0); glUniform2i(uniforms[GBA_GL_BG_SIZE], GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1505,7 +1501,6 @@ glBindVertexArray(shader->vao);

_prepareTransform(renderer, background, uniforms, y); glUniform1i(uniforms[GBA_GL_BG_CHARBASE], GBARegisterDISPCNTIsFrameSelect(renderer->dispcnt) ? 0xA000 : 0); glUniform2i(uniforms[GBA_GL_BG_SIZE], GBA_VIDEO_HORIZONTAL_PIXELS, GBA_VIDEO_VERTICAL_PIXELS); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1520,7 +1515,6 @@ glBindVertexArray(shader->vao);

_prepareTransform(renderer, background, uniforms, y); glUniform1i(uniforms[GBA_GL_BG_CHARBASE], GBARegisterDISPCNTIsFrameSelect(renderer->dispcnt) ? 0x5000 : 0); glUniform2i(uniforms[GBA_GL_BG_SIZE], 160, 128); - glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }
M src/platform/opengl/gles2.csrc/platform/opengl/gles2.c

@@ -136,9 +136,11 @@ mGLES2ShaderInit(&context->finalShader, 0, 0, 0, 0, false, 0, 0);

glBindVertexArray(context->initialShader.vao); glBindBuffer(GL_ARRAY_BUFFER, context->vbo); + glEnableVertexAttribArray(context->initialShader.positionLocation); glVertexAttribPointer(context->initialShader.positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glBindVertexArray(context->finalShader.vao); glBindBuffer(GL_ARRAY_BUFFER, context->vbo); + glEnableVertexAttribArray(context->finalShader.positionLocation); glVertexAttribPointer(context->finalShader.positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glBindVertexArray(0);

@@ -303,7 +305,6 @@ glUniformMatrix4fv(uniform->location, 1, GL_FALSE, uniform->value.fmat4x4);

break; } } - glEnableVertexAttribArray(shader->positionLocation); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glBindTexture(GL_TEXTURE_2D, shader->tex); }

@@ -327,6 +328,7 @@ glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);

_drawShader(context, &context->finalShader); glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgram(0); + glBindVertexArray(0); } void mGLES2ContextPostFrame(struct VideoBackend* v, const void* frame) {

@@ -463,8 +465,8 @@ glClear(GL_COLOR_BUFFER_BIT);

glBindVertexArray(context->shaders[i].vao); glBindBuffer(GL_ARRAY_BUFFER, context->vbo); - glVertexAttribPointer(context->shaders[i].positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(context->shaders[i].positionLocation); + glVertexAttribPointer(context->shaders[i].positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); } glBindVertexArray(0); glBindFramebuffer(GL_FRAMEBUFFER, 0);