mirror of https://github.com/mgba-emu/mgba.git
GBA Video: Slightly optimize frame compositing
This commit is contained in:
parent
d4e30b74ff
commit
ab1d825e30
|
@ -585,9 +585,6 @@ static const char* const _finalize =
|
|||
"out vec4 color;\n"
|
||||
|
||||
"void composite(vec4 pixel, ivec4 flags, inout vec4 topPixel, inout ivec4 topFlags, inout vec4 bottomPixel, inout ivec4 bottomFlags) {\n"
|
||||
" if (pixel.a == 0.) {\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
" if (flags.x >= topFlags.x) {\n"
|
||||
" if (flags.x >= bottomFlags.x) {\n"
|
||||
" return;\n"
|
||||
|
@ -607,32 +604,43 @@ static const char* const _finalize =
|
|||
" vec4 bottomPixel = topPixel;\n"
|
||||
" ivec4 topFlags = ivec4(texelFetch(backdropFlags, ivec2(0, texCoord.y), 0));\n"
|
||||
" ivec4 bottomFlags = topFlags;\n"
|
||||
" ivec4 windowFlags = texelFetch(window, ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec2 coord = ivec2(texCoord * float(scale));\n"
|
||||
" ivec4 windowFlags = texelFetch(window, coord, 0);\n"
|
||||
" int layerWindow = windowFlags.x;\n"
|
||||
" if ((layerWindow & 16) != 0) {\n"
|
||||
" vec4 pix = texelFetch(layers[4], ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[4], ivec2(texCoord * float(scale)), 0));\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" vec4 pix = texelFetch(layers[4], coord, 0);\n"
|
||||
" if (pix.a != 0.) {\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[4], coord, 0));\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" if ((layerWindow & 1) != 0) {\n"
|
||||
" vec4 pix = texelFetch(layers[0], ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[0], ivec2(texCoord * float(scale)), 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" vec4 pix = texelFetch(layers[0], coord, 0);\n"
|
||||
" if (pix.a != 0.) {\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[0], coord, 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" if ((layerWindow & 2) != 0) {\n"
|
||||
" vec4 pix = texelFetch(layers[1], ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[1], ivec2(texCoord * float(scale)), 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" vec4 pix = texelFetch(layers[1], coord, 0);\n"
|
||||
" if (pix.a != 0.) {\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[1], coord, 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" if ((layerWindow & 4) != 0) {\n"
|
||||
" vec4 pix = texelFetch(layers[2], ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[2], ivec2(texCoord * float(scale)), 0).xyz.xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" vec4 pix = texelFetch(layers[2], coord, 0);\n"
|
||||
" if (pix.a != 0.) {\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[2], coord, 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" if ((layerWindow & 8) != 0) {\n"
|
||||
" vec4 pix = texelFetch(layers[3], ivec2(texCoord * float(scale)), 0);\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[3], ivec2(texCoord * float(scale)), 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" vec4 pix = texelFetch(layers[3], coord, 0);\n"
|
||||
" if (pix.a != 0.) {\n"
|
||||
" ivec4 inflags = ivec4(texelFetch(flags[3], coord, 0).xyz, 0);\n"
|
||||
" composite(pix, inflags, topPixel, topFlags, bottomPixel, bottomFlags);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" if ((layerWindow & 32) == 0) {\n"
|
||||
" topFlags.y &= ~1;\n"
|
||||
|
|
Loading…
Reference in New Issue