From 79dccc9d0518848fb96a9d55fd7c3cacc9d5ecf6 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 10 Jul 2021 13:23:12 +1000 Subject: [PATCH] GPU/SW: Fix regression with non-transparent triangles --- src/core/gpu_sw_backend.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/gpu_sw_backend.cpp b/src/core/gpu_sw_backend.cpp index 238800bb6..0f3dd0f58 100644 --- a/src/core/gpu_sw_backend.cpp +++ b/src/core/gpu_sw_backend.cpp @@ -147,15 +147,16 @@ void ALWAYS_INLINE_RELEASE GPU_SW_Backend::ShadePixel(const GPUBackendDrawComman const u32 dither_y = (dithering_enable) ? (y & 3u) : 2u; const u32 dither_x = (dithering_enable) ? (x & 3u) : 3u; + // Non-textured transparent polygons don't set bit 15, but are treated as transparent. color.bits = (ZeroExtend16(s_dither_lut[dither_y][dither_x][color_r]) << 0) | (ZeroExtend16(s_dither_lut[dither_y][dither_x][color_g]) << 5) | - (ZeroExtend16(s_dither_lut[dither_y][dither_x][color_b]) << 10) | 0x8000u; + (ZeroExtend16(s_dither_lut[dither_y][dither_x][color_b]) << 10) | (transparency_enable ? 0x8000u : 0); } const VRAMPixel bg_color{GetPixel(static_cast(x), static_cast(y))}; if constexpr (transparency_enable) { - if (color.bits & 0x8000u) + if (color.bits & 0x8000u || !texture_enable) { // Based on blargg's efficient 15bpp pixel math. u32 bg_bits = ZeroExtend32(bg_color.bits); @@ -204,6 +205,10 @@ void ALWAYS_INLINE_RELEASE GPU_SW_Backend::ShadePixel(const GPUBackendDrawComman } break; } + + // See above. + if constexpr (!texture_enable) + color.bits &= ~0x8000u; } }