diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GPU.cpp | 4 | ||||
-rw-r--r-- | src/GPU2D.cpp | 25 | ||||
-rw-r--r-- | src/GPU3D.cpp | 10 | ||||
-rw-r--r-- | src/GPU3D.h | 3 | ||||
-rw-r--r-- | src/GPU3D_OpenGL43.cpp | 118 | ||||
-rw-r--r-- | src/GPU3D_Soft.cpp | 5 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 11 | ||||
-rw-r--r-- | src/libui_sdl/main_shaders.h | 123 |
8 files changed, 219 insertions, 80 deletions
diff --git a/src/GPU.cpp b/src/GPU.cpp index 1d073f5..8142e47 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -254,7 +254,7 @@ void SetDisplaySettings(int topscale, int bottomscale, bool accel) FBScale[0] = accel ? 0 : topscale; int fbsize; - if (accel) fbsize = 256*3 * 192; + if (accel) fbsize = (256*3 + 1) * 192; else fbsize = (256 * 192) << (FBScale[0] * 2); if (Framebuffer[0][0]) delete[] Framebuffer[0][0]; if (Framebuffer[1][0]) delete[] Framebuffer[1][0]; @@ -283,7 +283,7 @@ void SetDisplaySettings(int topscale, int bottomscale, bool accel) FBScale[1] = accel ? 0 : bottomscale; int fbsize; - if (accel) fbsize = 256*3 * 192; + if (accel) fbsize = (256*3 + 1) * 192; else fbsize = (256 * 192) << (FBScale[1] * 2); if (Framebuffer[0][1]) delete[] Framebuffer[0][1]; if (Framebuffer[1][1]) delete[] Framebuffer[1][1]; diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 34c17ff..f80eb85 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -626,7 +626,7 @@ u32 GPU2D::ColorBrightnessDown(u32 val, u32 factor) void GPU2D::DrawScanline(u32 line) { - int stride = Accelerated ? (256*3) : LineStride; + int stride = Accelerated ? (256*3 + 1) : LineStride; u32* dst = &Framebuffer[stride * line]; int n3dline = line; @@ -787,7 +787,17 @@ void GPU2D::DrawScanline(u32 line) DoCapture(line, capwidth); } - if (Accelerated) return; + if (Accelerated) + { + u32 ctl = (BlendCnt & 0x3FFF); + ctl |= ((DispCnt & 0x30000) >> 2); + ctl |= (EVA << 16); + ctl |= (EVB << 21); + ctl |= (EVY << 26); + + dst[256*3] = ctl; + return; + } // master brightness if (dispmode != 0) @@ -1367,6 +1377,13 @@ void GPU2D::DrawScanline_Mode1(u32 line) } } } + else + { + for (int i = 0; i < 256; i++) + { + BGOBJLine[i] |= ((WindowMask[i] & 0x20) << 18); + } + } if (BGMosaicY >= BGMosaicYMax) { @@ -1471,11 +1488,13 @@ void GPU2D::DrawBG_3D() { for (; i < iend; i++) { + int pos = xoff++; + if (!(WindowMask[i] & 0x01)) continue; BGOBJLine[i+512] = BGOBJLine[i+256]; BGOBJLine[i+256] = BGOBJLine[i]; - BGOBJLine[i] = 0x40000000; // 3D-layer placeholder + BGOBJLine[i] = 0x40000000 | pos; // 3D-layer placeholder } } else if (LineScale == 1) diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index 61629a7..ec395ad 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -612,6 +612,11 @@ void SetDisplaySettings(int scale, bool accel) GLRenderer43::SetDisplaySettings(scale, accel); } +int GetScale() +{ + return GLRenderer43::GetScale(); +} + void MatrixLoadIdentity(s32* m) @@ -2441,6 +2446,11 @@ u32* GetLine(int line) return GLRenderer43::GetLine(line); } +void SetupAccelFrame() +{ + GLRenderer43::SetupAccelFrame(); +} + void WriteToGXFIFO(u32 val) { diff --git a/src/GPU3D.h b/src/GPU3D.h index 2fe5bee..10c8966 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -98,6 +98,7 @@ void DoSavestate(Savestate* file); void SetEnabled(bool geometry, bool rendering); void SetDisplaySettings(int scale, bool accel); +int GetScale(); void ExecuteCommand(); @@ -129,6 +130,7 @@ void DeInit(); void Reset(); void SetDisplaySettings(int scale, bool accel); +int GetScale(); void SetupRenderThread(); @@ -147,6 +149,7 @@ void DeInit(); void Reset(); void SetDisplaySettings(int scale, bool accel); +int GetScale(); void VCount144(); void RenderFrame(); diff --git a/src/GPU3D_OpenGL43.cpp b/src/GPU3D_OpenGL43.cpp index 6db9a18..0181192 100644 --- a/src/GPU3D_OpenGL43.cpp +++ b/src/GPU3D_OpenGL43.cpp @@ -100,7 +100,8 @@ int ScaleFactor; bool Accelerated; int ScreenW, ScreenH; -GLuint FramebufferTex[4]; +GLuint FramebufferTex[6]; +int FrontBuffer; GLuint FramebufferID[2], PixelbufferID; u32* Framebuffer = NULL; @@ -262,8 +263,10 @@ bool Init() glGenFramebuffers(2, &FramebufferID[0]); glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); - // color buffer - glGenTextures(4, &FramebufferTex[0]); + glGenTextures(6, &FramebufferTex[0]); + FrontBuffer = 0; + + // color buffers glBindTexture(GL_TEXTURE_2D, FramebufferTex[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -271,33 +274,39 @@ bool Init() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[0], 0); - // depth/stencil buffer glBindTexture(GL_TEXTURE_2D, FramebufferTex[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[1], 0); + + // depth/stencil buffer + glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, FramebufferTex[4], 0); // attribute buffer // R: opaque polyID (for edgemarking) // G: opaque polyID (for shadows, suppressed when rendering translucent polygons) // B: stencil flag - glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]); + glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[2], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, FramebufferTex[5], 0); // downscale framebuffer, for antialiased mode glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[1]); - glBindTexture(GL_TEXTURE_2D, FramebufferTex[3]); + glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[3], 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[2], 0); glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); @@ -330,7 +339,7 @@ bool Init() glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5_A1, 1024, 48, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]); // opaque polyID / shadow bits + glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]); // opaque polyID / shadow bits return true; } @@ -357,11 +366,13 @@ void SetDisplaySettings(int scale, bool accel) glBindTexture(GL_TEXTURE_2D, FramebufferTex[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, FramebufferTex[1]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, FramebufferTex[2]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL); - glBindTexture(GL_TEXTURE_2D, FramebufferTex[3]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW/2, ScreenH/2, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); + glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL); glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID); if (accel) glBufferData(GL_PIXEL_PACK_BUFFER, ScreenW*ScreenH*4, NULL, GL_DYNAMIC_READ); @@ -372,6 +383,11 @@ void SetDisplaySettings(int scale, bool accel) else Framebuffer = new u32[ScreenW*ScreenH]; } +int GetScale() +{ + return ScaleFactor; +} + void SetupPolygon(RendererPolygon* rp, Polygon* polygon) { @@ -756,6 +772,12 @@ void RenderFrame() glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMaski(1, GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + if (Accelerated) + { + int backbuf = FrontBuffer ? 0 : 1; + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, FramebufferTex[backbuf], 0); + } + // clear buffers // TODO: clear bitmap // TODO: check whether 'clear polygon ID' affects translucent polyID @@ -818,15 +840,7 @@ void RenderFrame() glBindBuffer(GL_ARRAY_BUFFER, VertexBufferID); glBufferSubData(GL_ARRAY_BUFFER, 0, NumVertices*7*4, VertexBuffer); - if (!ChunkedRendering) - { - RenderSceneChunk(0, 192); - } - else - { - glEnable(GL_SCISSOR_TEST); - RenderSceneChunk(0, 48); - } + RenderSceneChunk(0, 192); } if (false) @@ -842,63 +856,24 @@ void RenderFrame() glBindFramebuffer(GL_FRAMEBUFFER, FramebufferID[0]); } - glReadBuffer(GL_COLOR_ATTACHMENT0); - glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID); + if (!Accelerated) + { + glReadBuffer(GL_COLOR_ATTACHMENT0); + glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID); - if (!ChunkedRendering) glReadPixels(0, 0, 256<<ScaleFactor, 192<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - else - glReadPixels(0, 0, 256<<ScaleFactor, 48<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + } } u32* GetLine(int line) { int stride = 256 << (ScaleFactor*2); - if (!ChunkedRendering) + if (line == 0) { - if (line == 0) - { - u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); - if (data) memcpy(&Framebuffer[stride*0], data, 4*stride*192); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - } - } - else - { - if (line == 0) - { - u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); - if (data) memcpy(&Framebuffer[stride*0], data, 4*stride*48); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - - if (RenderNumPolygons) RenderSceneChunk(48, 48); - glReadPixels(0, 48<<ScaleFactor, 256<<ScaleFactor, 48<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - } - else if (line == 48) - { - u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); - if (data) memcpy(&Framebuffer[stride*48], data, 4*stride*48); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - - if (RenderNumPolygons) RenderSceneChunk(96, 48); - glReadPixels(0, 96<<ScaleFactor, 256<<ScaleFactor, 48<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - } - else if (line == 96) - { - u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); - if (data) memcpy(&Framebuffer[stride*96], data, 4*stride*48); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - - if (RenderNumPolygons) RenderSceneChunk(144, 48); - glReadPixels(0, 144<<ScaleFactor, 256<<ScaleFactor, 48<<ScaleFactor, GL_BGRA, GL_UNSIGNED_BYTE, NULL); - } - else if (line == 144) - { - u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); - if (data) memcpy(&Framebuffer[stride*144], data, 4*stride*48); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); - } + u8* data = (u8*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); + if (data) memcpy(&Framebuffer[stride*0], data, 4*stride*192); + glUnmapBuffer(GL_PIXEL_PACK_BUFFER); } u64* ptr = (u64*)&Framebuffer[stride * line]; @@ -915,7 +890,8 @@ u32* GetLine(int line) void SetupAccelFrame() { - // + glBindTexture(GL_TEXTURE_2D, FramebufferTex[FrontBuffer]); + FrontBuffer = FrontBuffer ? 0 : 1; } } diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 20283d3..23e45c2 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -143,6 +143,11 @@ void SetDisplaySettings(int scale, bool accel) printf("SOFT RENDERER SCALE FACTOR: TODO!!!\n"); } +int GetScale() +{ + return 0; +} + // Notes on the interpolator: diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index b77d67f..9cdb610 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -104,6 +104,7 @@ GLuint GL_ScreenShader[3]; struct { float uScreenSize[2]; + u32 u3DScale; u32 uFilterMode; } GL_ShaderConfig; @@ -217,6 +218,7 @@ void GLDrawing_DrawScreen() GL_ShaderConfig.uScreenSize[0] = WindowWidth; GL_ShaderConfig.uScreenSize[1] = WindowHeight; + GL_ShaderConfig.u3DScale = 1 << GPU3D::GetScale(); glBindBuffer(GL_UNIFORM_BUFFER, GL_ShaderConfigUBO); void* unibuf = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY); @@ -342,7 +344,7 @@ void GLDrawing_DrawScreen() OpenGL_UseShaderProgram(GL_ScreenShader); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); @@ -353,11 +355,14 @@ void GLDrawing_DrawScreen() GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][0]); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 768, 256<<ScreenScale[1], 192<<ScreenScale[1], GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]);*/ - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256*3, 192, GL_RGBA_INTEGER, + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256*3 + 1, 192, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][0]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 768, 256*3, 192, GL_RGBA_INTEGER, + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 768, 256*3 + 1, 192, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]); + glActiveTexture(GL_TEXTURE1); + GPU3D::SetupAccelFrame(); + glBindBuffer(GL_ARRAY_BUFFER, GL_ScreenVertexBufferID); glBindVertexArray(GL_ScreenVertexArrayID); glDrawArrays(GL_TRIANGLES, 0, 4*3); diff --git a/src/libui_sdl/main_shaders.h b/src/libui_sdl/main_shaders.h index dcf79d9..b602013 100644 --- a/src/libui_sdl/main_shaders.h +++ b/src/libui_sdl/main_shaders.h @@ -24,6 +24,7 @@ const char* kScreenVS = R"(#version 420 layout(std140, binding=0) uniform uConfig { vec2 uScreenSize; + uint u3DScale; uint uFilterMode; }; @@ -50,10 +51,12 @@ const char* kScreenFS = R"(#version 420 layout(std140, binding=0) uniform uConfig { vec2 uScreenSize; + uint u3DScale; uint uFilterMode; }; layout(binding=0) uniform usampler2D ScreenTex; +layout(binding=1) uniform sampler2D _3DTex; smooth in vec2 fTexcoord; @@ -63,9 +66,127 @@ void main() { uvec4 pixel = texelFetch(ScreenTex, ivec2(fTexcoord), 0); + // bit0-13: BLDCNT + // bit14-15: DISPCNT display mode + // bit16-20: EVA + // bit21-25: EVB + // bit26-30: EVY + uvec4 ctl = texelFetch(ScreenTex, ivec2(256*3, int(fTexcoord.y)), 0); + uint dispmode = (ctl.g >> 6) & 0x3; + + if (dispmode == 1) + { + uint eva = ctl.b & 0x1F; + uint evb = (ctl.b >> 5) | ((ctl.a & 0x03) << 3); + uint evy = ctl.a >> 2; + + uvec4 top = pixel; + uvec4 mid = texelFetch(ScreenTex, ivec2(fTexcoord) + ivec2(256,0), 0); + uvec4 bot = texelFetch(ScreenTex, ivec2(fTexcoord) + ivec2(512,0), 0); + + uint winmask = top.b >> 7; + + if ((top.a & 0x40) != 0) + { + float xpos = top.r + fract(fTexcoord.x); + uvec4 _3dpix = uvec4(texelFetch(_3DTex, ivec2(vec2(xpos, fTexcoord.y)*u3DScale), 0).bgra + * vec4(63,63,63,31)); + + if (_3dpix.a > 0) { top = _3dpix; top.a |= 0x40; bot = mid; } + else top = mid; + } + else if ((mid.a & 0x40) != 0) + { + float xpos = mid.r + fract(fTexcoord.x); + uvec4 _3dpix = uvec4(texelFetch(_3DTex, ivec2(vec2(xpos, fTexcoord.y)*u3DScale), 0).bgra + * vec4(63,63,63,31)); + + if (_3dpix.a > 0) { bot = _3dpix; bot.a |= 0x40; } + } + else + { + // conditional texture fetch no good for performance, apparently + //texelFetch(_3DTex, ivec2(0, fTexcoord.y*2), 0); + bot = mid; + } + + top.b &= 0x3F; + bot.b &= 0x3F; + + uint target2; + if ((bot.a & 0x80) != 0) target2 = 0x10; + else if ((bot.a & 0x40) != 0) target2 = 0x01; + else target2 = bot.a; + bool t2pass = ((ctl.g & target2) != 0); + + uint coloreffect = 0; + + if ((top.a & 0x80) != 0 && t2pass) + { + // sprite blending + + coloreffect = 1; + + if ((top.a & 0x40) != 0) + { + eva = top.a & 0x1F; + evb = 16 - eva; + } + } + else if ((top.a & 0x40) != 0 && t2pass) + { + // 3D layer blending + + coloreffect = 4; + eva = (top.a & 0x1F) + 1; + evb = 32 - eva; + } + else + { + if ((top.a & 0x80) != 0) top.a = 0x10; + else if ((top.a & 0x40) != 0) top.a = 0x01; + + if ((ctl.r & top.a) != 0 && winmask != 0) + { + uint effect = ctl.r >> 6; + if ((effect != 1) || t2pass) coloreffect = effect; + } + } + + if (coloreffect == 0) + { + pixel = top; + } + else if (coloreffect == 1) + { + pixel = ((top * eva) + (bot * evb)) >> 4; + pixel = min(pixel, 0x3F); + } + else if (coloreffect == 2) + { + pixel = top; + pixel += ((uvec4(0x3F,0x3F,0x3F,0) - pixel) * evy) >> 4; + } + else if (coloreffect == 3) + { + pixel = top; + pixel -= (pixel * evy) >> 4; + } + else + { + pixel = ((top * eva) + (bot * evb)) >> 5; + if (eva <= 16) pixel += uvec4(1,1,1,0); + pixel = min(pixel, 0x3F); + } + } + + pixel.rgb <<= 2; + pixel.rgb |= (pixel.rgb >> 6); + // TODO: filters - oColor = vec4(vec3(pixel.bgr) / 255.0, 1.0); + oColor = vec4(vec3(pixel.rgb) / 255.0, 1.0); + //oColor = texelFetch(_3DTex, ivec2(fTexcoord*4), 0).bgra; } )"; |