summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureDecoder_Common.cpp
diff options
context:
space:
mode:
authorMatthew Parlane <parlane@gmail.com>2017-01-17 11:05:42 +1300
committerGitHub <noreply@github.com>2017-01-17 11:05:42 +1300
commited7589cb0f8369a219b30729efdeea08aefe4bb3 (patch)
tree966ab7a527f0fb343df7db0c36f6f7b0213d4d4b /Source/Core/VideoCommon/TextureDecoder_Common.cpp
parent763e086e792d5dfb3c0bf3308ed250a06a978acd (diff)
parent88d52b4d69a4ca4e81c7ac32d2df0c0f826fcc19 (diff)
Merge pull request #4656 from hthh/cmpr-fixes
TextureDecoder: Fix off-by-one errors in CMPR
Diffstat (limited to 'Source/Core/VideoCommon/TextureDecoder_Common.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_Common.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
index cdaba05bc2..7f151b2406 100644
--- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp
@@ -10,6 +10,7 @@
#include "Common/MsgHandler.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/TextureDecoder.h"
+#include "VideoCommon/TextureDecoder_Util.h"
#include "VideoCommon/sfont.inc"
static bool TexFmt_Overlay_Enable = false;
@@ -422,18 +423,6 @@ static inline u32 DecodePixel_Paletted(u16 pixel, TlutFormat tlutfmt)
}
}
-struct DXTBlock
-{
- u16 color1;
- u16 color2;
- u8 lines[4];
-};
-
-static inline u32 MakeRGBA(int r, int g, int b, int a)
-{
- return (a << 24) | (b << 16) | (g << 8) | r;
-}
-
void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth, int texformat,
const u8* tlut_, TlutFormat tlutfmt)
{
@@ -654,11 +643,6 @@ void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth
int red1 = Convert5To8((c1 >> 11) & 0x1F);
int red2 = Convert5To8((c2 >> 11) & 0x1F);
- // 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);
-
u16 ss = s & 3;
u16 tt = t & 3;
@@ -680,20 +664,18 @@ void TexDecoder_DecodeTexel(u8* dst, const u8* src, int s, int t, int imageWidth
color = MakeRGBA(red2, green2, blue2, 255);
break;
case 2:
- color = MakeRGBA(red1 + red3, green1 + green3, blue1 + blue3, 255);
+ color = MakeRGBA(DXTBlend(red2, red1), DXTBlend(green2, green1), DXTBlend(blue2, blue1), 255);
break;
case 3:
- color = MakeRGBA(red2 - red3, green2 - green3, blue2 - blue3, 255);
+ color = MakeRGBA(DXTBlend(red1, red2), DXTBlend(green1, green2), DXTBlend(blue1, blue2), 255);
break;
case 6:
- color =
- MakeRGBA((red1 + red2 + 1) / 2, (green1 + green2 + 1) / 2, (blue1 + blue2 + 1) / 2, 255);
+ color = MakeRGBA((red1 + red2) / 2, (green1 + green2) / 2, (blue1 + blue2) / 2, 255);
break;
case 7:
// color[3] is the same as color[2] (average of both colors), but transparent.
// This differs from DXT1 where color[3] is transparent black.
- color =
- MakeRGBA((red1 + red2 + 1) / 2, (green1 + green2 + 1) / 2, (blue1 + blue2 + 1) / 2, 0);
+ color = MakeRGBA((red1 + red2) / 2, (green1 + green2) / 2, (blue1 + blue2) / 2, 0);
break;
default:
color = 0;