GBA Video: Mark framebuffer as dirty if the output texture changes

This commit is contained in:
Vicki Pfau 2022-07-13 19:34:16 -07:00
parent 8997eda005
commit 004f317aba
3 changed files with 7 additions and 0 deletions

View File

@ -155,6 +155,7 @@ struct GBAVideoGLRenderer {
GLuint vbo;
GLuint outputTex;
bool outputTexDirty;
GLuint paletteTex;
uint16_t shadowPalette[GBA_VIDEO_VERTICAL_PIXELS][512];

View File

@ -446,6 +446,7 @@ static void _GBACoreSetVideoGLTex(struct mCore* core, unsigned texid) {
#ifdef BUILD_GLES3
struct GBACore* gbacore = (struct GBACore*) core;
gbacore->glRenderer.outputTex = texid;
gbacore->glRenderer.outputTexDirty = true;
#else
UNUSED(core);
UNUSED(texid);

View File

@ -779,6 +779,7 @@ static void _initFramebuffers(struct GBAVideoGLRenderer* glRenderer) {
glBindFramebuffer(GL_FRAMEBUFFER, glRenderer->fbo[GBA_GL_FBO_OUTPUT]);
_initFramebufferTexture(glRenderer->outputTex, GL_RGB, GL_COLOR_ATTACHMENT0, glRenderer->scale);
glRenderer->outputTexDirty = false;
int i;
for (i = 0; i < 4; ++i) {
@ -1678,6 +1679,10 @@ static void GBAVideoGLRendererWriteBLDCNT(struct GBAVideoGLRenderer* renderer, u
void _finalizeLayers(struct GBAVideoGLRenderer* renderer) {
const GLuint* uniforms = renderer->finalizeShader.uniforms;
glBindFramebuffer(GL_FRAMEBUFFER, renderer->fbo[GBA_GL_FBO_OUTPUT]);
if (renderer->outputTexDirty) {
_initFramebufferTexture(renderer->outputTex, GL_RGB, GL_COLOR_ATTACHMENT0, renderer->scale);
renderer->outputTexDirty = false;
}
glViewport(0, 0, GBA_VIDEO_HORIZONTAL_PIXELS * renderer->scale, GBA_VIDEO_VERTICAL_PIXELS * renderer->scale);
glScissor(0, 0, GBA_VIDEO_HORIZONTAL_PIXELS * renderer->scale, GBA_VIDEO_VERTICAL_PIXELS * renderer->scale);
if (GBARegisterDISPCNTIsForcedBlank(renderer->dispcnt)) {