all repos — mgba @ 06cc738b008cb0017965b14013c3039bdd430df8

mGBA Game Boy Advance Emulator

GBA Video: Fix VAOs on Nvidia
Vicki Pfau vi@endrift.com
Tue, 14 May 2019 23:33:54 -0700
commit

06cc738b008cb0017965b14013c3039bdd430df8

parent

3797e1e5f6b001fa1cb2855304c752d81ef25ff6

2 files changed, 17 insertions(+), 5 deletions(-)

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

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

glBindBuffer(GL_ARRAY_BUFFER, glRenderer->vbo); GLuint positionLocation = glGetAttribLocation(program, "position"); glVertexAttribPointer(positionLocation, 2, GL_INT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(positionLocation); size_t i; for (i = 0; uniforms[i].name; ++i) {

@@ -1084,6 +1083,7 @@ glUniform1i(uniforms[GBA_GL_COMPOSITE_OLDLAYERFLAGS], 3);

glUniform1i(uniforms[GBA_GL_COMPOSITE_OLDOLDFLAGS], 4); glUniform1i(uniforms[GBA_GL_COMPOSITE_WINDOW], 5); glDrawBuffers(4, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }); + glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1113,6 +1113,7 @@ glUniform1i(uniforms[GBA_GL_FINALIZE_LAYER], 0);

glUniform1i(uniforms[GBA_GL_FINALIZE_LAYERFLAGS], 1); glUniform1i(uniforms[GBA_GL_FINALIZE_OLDLAYER], 2); glUniform1i(uniforms[GBA_GL_FINALIZE_OLDFLAGS], 3); + glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glBindFramebuffer(GL_FRAMEBUFFER, 0); }

@@ -1185,6 +1186,7 @@ } else {

glUniform3f(uniforms[GBA_GL_OBJ_OBJWIN], 0, 0, 0); glDrawBuffers(2, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }); } + glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 }); }

@@ -1221,6 +1223,7 @@ glUniform4i(uniforms[GBA_GL_BG_INFLAGS], (background->priority << 3) + (background->index << 1) + 1,

background->target1 | (background->target2 * 2) | (renderer->blendEffect * 4), renderer->blendEffect == BLEND_ALPHA ? renderer->blda : renderer->bldy, renderer->bldb); glDrawBuffers(2, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }); + glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 });

@@ -1277,6 +1280,7 @@ background->affine[0].dx, background->affine[0].dy,

}); } glDrawBuffers(2, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }); + glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawBuffers(1, (GLenum[]) { GL_COLOR_ATTACHMENT0 });
M src/platform/opengl/gles2.csrc/platform/opengl/gles2.c

@@ -135,6 +135,15 @@ uniforms[3].max.fvec3[1] = 1.0f;

uniforms[3].max.fvec3[2] = 1.0f; mGLES2ShaderInit(&context->initialShader, _vertexShader, _fragmentShader, -1, -1, false, uniforms, 4); mGLES2ShaderInit(&context->finalShader, 0, 0, 0, 0, false, 0, 0); + + glBindVertexArray(context->initialShader.vao); + glBindBuffer(GL_ARRAY_BUFFER, context->vbo); + glVertexAttribPointer(context->initialShader.positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); + glBindVertexArray(context->finalShader.vao); + glBindBuffer(GL_ARRAY_BUFFER, context->vbo); + glVertexAttribPointer(context->finalShader.positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); + glBindVertexArray(0); + glDeleteFramebuffers(1, &context->finalShader.fbo); glDeleteTextures(1, &context->finalShader.tex); context->finalShader.fbo = 0;

@@ -296,6 +305,7 @@ 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); }

@@ -426,10 +436,6 @@ shader->uniforms[i].location = glGetUniformLocation(shader->program, shader->uniforms[i].name);

} glGenVertexArrays(1, &shader->vao); - glBindVertexArray(shader->vao); - glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(shader->positionLocation); - glBindVertexArray(0); glBindFramebuffer(GL_FRAMEBUFFER, 0); }

@@ -458,6 +464,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); } glBindVertexArray(0); glBindFramebuffer(GL_FRAMEBUFFER, 0);