diff options
| author | Matthew Parlane <parlane@gmail.com> | 2016-05-03 22:41:39 +1200 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2016-05-03 22:41:39 +1200 |
| commit | 1634948b6ee468deef9033fc1b69df3ba69be538 (patch) | |
| tree | d7291b83ab2887f85914ddcff5ddd34df652dcc3 /Source/Core/VideoBackends/Software/EfbInterface.cpp | |
| parent | c32ba0fc0671df6a2570880d75573c43dd34fef1 (diff) | |
| parent | 51dc779b7c6d20de599b0ed832481db2befd8b1b (diff) | |
Merge pull request #3742 from phire/dither
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 |
