diff options
| author | Scott Mansell <phiren@gmail.com> | 2016-02-15 14:27:54 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2016-03-23 12:29:35 +1300 |
| commit | 51dc779b7c6d20de599b0ed832481db2befd8b1b (patch) | |
| tree | d88480bbbe8c794c141ca1be86f82651bf03fd48 /Source/Core/VideoBackends/Software/EfbInterface.cpp | |
| parent | 3ff56aa192f952cb6ad2e9c662d4a368efd21e6f (diff) | |
Implement Dithering for video software
Diffstat (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Software/EfbInterface.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index 943ce78b06..9d8af4f88b 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -391,6 +391,20 @@ namespace EfbInterface } } + static void Dither(u16 x, u16 y, u8 *color) + { + // No blending for RGB8 mode + if (!bpmem.blendmode.dither || bpmem.zcontrol.pixel_format != PEControl::PixelFormat::RGBA6_Z24) + return; + + // Flipper uses a standard 2x2 Bayer Matrix for 6 bit dithering + static const u8 dither[2][2] = {{0, 2}, {3, 1}}; + + // Only the color channels are dithered? + for (int i = BLU_C; i <= RED_C; i++) + color[i] = ((color[i] - (color[i] >> 6)) + dither[y & 1][x & 1]) & 0xfc; + } + void BlendTev(u16 x, u16 y, u8 *color) { u32 dstClr; @@ -421,6 +435,7 @@ namespace EfbInterface if (bpmem.blendmode.colorupdate) { + Dither(x, y, dstClrPtr); if (bpmem.blendmode.alphaupdate) SetPixelAlphaColor(offset, dstClrPtr); else |
