diff options
| author | hthh <hthh@hh.ht> | 2017-01-14 01:41:44 +1100 |
|---|---|---|
| committer | hthh <hthh@hh.ht> | 2017-01-14 10:52:35 +1100 |
| commit | 5d4e4aa561dc7de12cd54f35a98adcccd85bb5d3 (patch) | |
| tree | 65866e0ad230ce00daa9739ccf6be06f1e0ce07e /Source/Core/VideoCommon/TextureDecoder_Generic.cpp | |
| parent | 0b6e5765ddda6a437d9ae999bc8d8f59cb5e76fc (diff) | |
TextureDecoder: Fix off-by-one errors in CMPR
Diffstat (limited to 'Source/Core/VideoCommon/TextureDecoder_Generic.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureDecoder_Generic.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Source/Core/VideoCommon/TextureDecoder_Generic.cpp b/Source/Core/VideoCommon/TextureDecoder_Generic.cpp index bb48d1aca8..114b9b8207 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Generic.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Generic.cpp @@ -170,20 +170,17 @@ static void DecodeDXTBlock(u32* dst, const DXTBlock* src, int pitch) if (c1 > c2) { // Approximation of x/3: 3/8 (1/2 - 1/8) - int blue3 = ((blue2 - blue1) >> 1) - ((blue2 - blue1) >> 3); - int green3 = ((green2 - green1) >> 1) - ((green2 - green1) >> 3); - int red3 = ((red2 - red1) >> 1) - ((red2 - red1) >> 3); - colors[2] = MakeRGBA(red1 + red3, green1 + green3, blue1 + blue3, 255); - colors[3] = MakeRGBA(red2 - red3, green2 - green3, blue2 - blue3, 255); + colors[2] = + MakeRGBA(DXTBlend(red2, red1), DXTBlend(green2, green1), DXTBlend(blue2, blue1), 255); + colors[3] = + MakeRGBA(DXTBlend(red1, red2), DXTBlend(green1, green2), DXTBlend(blue1, blue2), 255); } else { // color[3] is the same as color[2] (average of both colors), but transparent. // This differs from DXT1 where color[3] is transparent black. - colors[2] = - MakeRGBA((red1 + red2 + 1) / 2, (green1 + green2 + 1) / 2, (blue1 + blue2 + 1) / 2, 255); - colors[3] = - MakeRGBA((red1 + red2 + 1) / 2, (green1 + green2 + 1) / 2, (blue1 + blue2 + 1) / 2, 0); + colors[2] = MakeRGBA((red1 + red2) / 2, (green1 + green2) / 2, (blue1 + blue2) / 2, 255); + colors[3] = MakeRGBA((red1 + red2) / 2, (green1 + green2) / 2, (blue1 + blue2) / 2, 0); } for (int y = 0; y < 4; y++) |
