all repos — mgba @ c5ae273a3a786a00dbe470fac01885819e86e958

mGBA Game Boy Advance Emulator

GBA Video: Move all window bits to x
Vicki Pfau vi@endrift.com
Sat, 18 May 2019 14:00:34 -0700
commit

c5ae273a3a786a00dbe470fac01885819e86e958

parent

3abee66ae6fd1b572448d2ad241f2f531e1fe4fc

1 files changed, 12 insertions(+), 10 deletions(-)

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

@@ -13,6 +13,8 @@ #include <mgba/internal/gba/io.h>

#include <mgba/internal/gba/renderers/cache-set.h> #include <mgba-util/memory.h> +#define FLAG_CONST "const vec4 flagCoeff = vec4(64., 32., 16., 16.);\n" + static void GBAVideoGLRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoGLRendererDeinit(struct GBAVideoRenderer* renderer); static void GBAVideoGLRendererReset(struct GBAVideoRenderer* renderer);

@@ -116,7 +118,7 @@ "uniform ivec2 offset;\n"

"uniform ivec4 inflags;\n" "out vec4 color;\n" "out vec4 flags;\n" - "const vec4 flagCoeff = vec4(32., 32., 16., 16.);\n" + FLAG_CONST "vec4 renderTile(int tile, int paletteId, ivec2 localCoord);\n"

@@ -185,7 +187,7 @@ "uniform ivec2[4] transform;\n"

"uniform vec2 range;\n" "out vec4 color;\n" "out vec4 flags;\n" - "const vec4 flagCoeff = vec4(32., 32., 16., 16.);\n" + FLAG_CONST "precision highp float;\n" "precision highp int;\n"

@@ -254,7 +256,7 @@ "uniform vec4 objwin;\n"

"out vec4 color;\n" "out vec4 flags;\n" "out vec3 window;\n" - "const vec4 flagCoeff = vec4(32., 32., 16., 16.);\n" + FLAG_CONST "vec4 renderTile(int tile, int paletteId, ivec2 localCoord);\n"

@@ -292,7 +294,7 @@ "uniform sampler2D flags[5];\n"

"uniform sampler2D window;\n" "uniform vec4 backdrop;\n" "uniform vec4 backdropFlags;\n" - "const vec4 flagCoeff = vec4(32., 32., 16., 16.);\n" + FLAG_CONST "out vec4 color;\n" "void composite(vec4 pixel, ivec4 flags, inout vec4 topPixel, inout ivec4 topFlags, inout vec4 bottomPixel, inout ivec4 bottomFlags) {\n"

@@ -315,7 +317,7 @@ "}\n"

"void main() {\n" " vec4 windowFlags = texelFetch(window, ivec2(texCoord * scale), 0);\n" - " int layerWindow = int(windowFlags.x * 32) | int(windowFlags.y * 512);\n" + " int layerWindow = int(windowFlags.x * 128);\n" " vec4 topPixel = backdrop;\n" " vec4 bottomPixel = backdrop;\n" " ivec4 topFlags = ivec4(backdropFlags * flagCoeff);\n"

@@ -1085,7 +1087,7 @@ glUniform1iv(uniforms[GBA_GL_FINALIZE_LAYERS], 5, (GLint[]) { 3, 5, 7, 9, 1 });

glUniform1iv(uniforms[GBA_GL_FINALIZE_FLAGS], 5, (GLint[]) { 4, 6, 8, 10, 2 }); glUniform1i(uniforms[GBA_GL_FINALIZE_WINDOW], 0); glUniform4f(uniforms[GBA_GL_FINALIZE_BACKDROP], ((backdrop >> 16) & 0xFF) / 256., ((backdrop >> 8) & 0xFF) / 256., (backdrop & 0xFF) / 256., 0.f); - glUniform4f(uniforms[GBA_GL_FINALIZE_BACKDROPFLAGS], 1, (renderer->target1Bd | (renderer->target2Bd * 2) | (renderer->blendEffect * 4)) / 32.f, renderer->blda / 16.f, renderer->bldb / 16.f); + glUniform4f(uniforms[GBA_GL_FINALIZE_BACKDROPFLAGS], 1, (renderer->target1Bd | (renderer->target2Bd * 2) | (renderer->blendEffect * 4)) / 64.f, renderer->blda / 16.f, renderer->bldb / 16.f); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glBindFramebuffer(GL_FRAMEBUFFER, 0);

@@ -1152,8 +1154,8 @@ glUniformMatrix2fv(uniforms[GBA_GL_OBJ_TRANSFORM], 1, GL_FALSE, (GLfloat[]) { 1.f, 0, 0, 1.f });

} glUniform4i(uniforms[GBA_GL_OBJ_DIMS], width, height, totalWidth, totalHeight); if (GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_OBJWIN) { - int window = ~renderer->objwin & 0xFF; - glUniform4f(uniforms[GBA_GL_OBJ_OBJWIN], 1, (window & 0xF) / 32.f, (window >> 4) / 32.f, renderer->bldy / 16.f); + int window = ~renderer->objwin & 0x3F; + glUniform4f(uniforms[GBA_GL_OBJ_OBJWIN], 1, window / 128.f, 0, renderer->bldy / 16.f); glDrawBuffers(3, (GLenum[]) { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }); } else { glUniform4f(uniforms[GBA_GL_OBJ_OBJWIN], 0, 0, 0, 0);

@@ -1322,8 +1324,8 @@ }

} static void _clearWindow(GBAWindowControl window, int bldy) { - window = ~window & 0xFF; - glClearColor((window & 0xF) / 32.f, (window >> 4) / 32.f, bldy / 16.f, 0); + window = ~window & 0x3F; + glClearColor(window / 128.f, 0, bldy / 16.f, 0); } void GBAVideoGLRendererDrawWindow(struct GBAVideoGLRenderer* renderer, int y) {