diff --git a/Source/Core/VideoCommon/TextureDecoder.h b/Source/Core/VideoCommon/TextureDecoder.h index 2296c1bfed..e55c919529 100644 --- a/Source/Core/VideoCommon/TextureDecoder.h +++ b/Source/Core/VideoCommon/TextureDecoder.h @@ -193,12 +193,13 @@ void TexDecoder_Decode(u8* dst, const u8* src, int width, int height, TextureFor const u8* tlut, TLUTFormat tlutfmt); void TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8* src_ar, const u8* src_gb, int width, int height); -void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int imageWidth, +void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int image_width_minus_1, TextureFormat texformat, std::span tlut, TLUTFormat tlutfmt); void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, std::span src_ar, - std::span src_gb, int s, int t, int imageWidth); + std::span src_gb, int s, int t, + int image_width_minus_1); void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, const u8* src_ar, const u8* src_gb, int s, int t, - int imageWidth); + int image_width_minus_1); void TexDecoder_DecodeXFB(u8* dst, const u8* src, u32 width, u32 height, u32 stride); void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center); diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp index 3506514a54..0557b39542 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp @@ -358,7 +358,7 @@ static inline u32 DecodePixel_Paletted(u16 pixel, TLUTFormat tlutfmt) } } -void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int imageWidth, +void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int image_width_minus_1, TextureFormat texformat, std::span tlut_, TLUTFormat tlutfmt) { /* General formula for computing texture offset @@ -378,7 +378,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 3; u16 tBlk = t >> 3; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; u16 blkS = s & 7; u16 blkT = t & 7; @@ -397,7 +397,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 3; u16 tBlk = t >> 3; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; u16 blkS = s & 7; u16 blkT = t & 7; @@ -418,7 +418,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 3; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; u16 blkS = s & 7; u16 blkT = t & 3; @@ -435,7 +435,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 3; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; u16 blkS = s & 7; u16 blkT = t & 3; @@ -451,7 +451,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 3; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; u16 blkS = s & 7; u16 blkT = t & 3; @@ -470,7 +470,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 2) + 1; + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3; u16 blkT = t & 3; @@ -486,7 +486,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 2) + 1; + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3; u16 blkT = t & 3; @@ -503,7 +503,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 2) + 1; + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3; u16 blkT = t & 3; @@ -519,7 +519,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 2) + 1; + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3; u16 blkT = t & 3; @@ -535,7 +535,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = (imageWidth >> 2) + 1; + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base = (tBlk * widthBlks + sBlk) << 5; // shift by 5 is correct u16 blkS = s & 3; u16 blkT = t & 3; @@ -556,7 +556,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int u16 sBlk = sDxt >> 1; u16 tBlk = tDxt >> 1; - u16 widthBlks = (imageWidth >> 3) + 1; + u16 widthBlks = (image_width_minus_1 >> 3) + 1; u32 base = (tBlk * widthBlks + sBlk) << 2; u16 blkS = sDxt & 1; u16 blkT = tDxt & 1; @@ -619,7 +619,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int break; case TextureFormat::XFB: { - size_t offset = (t * imageWidth + (s & (~1))) * 2; + size_t offset = (t * image_width_minus_1 + (s & (~1))) * 2; // We do this one color sample (aka 2 RGB pixles) at a time int Y = int((s & 1) == 0 ? src[offset] : src[offset + 2]) - 16; @@ -633,19 +633,19 @@ void TexDecoder_DecodeTexel(u8* dst, std::span src, int s, int t, int u8 R = std::clamp(int(1.164f * Y + 1.596f * V), 0, 255); u8 G = std::clamp(int(1.164f * Y - 0.392f * U - 0.813f * V), 0, 255); u8 B = std::clamp(int(1.164f * Y + 2.017f * U), 0, 255); - dst[t * imageWidth + s] = 0xff000000 | B << 16 | G << 8 | R; + dst[t * image_width_minus_1 + s] = 0xff000000 | B << 16 | G << 8 | R; } break; } } void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, std::span src_ar, - std::span src_gb, int s, int t, int imageWidth) + std::span src_gb, int s, int t, + int image_width_minus_1) { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = - (imageWidth >> 2) + 1; // TODO: Looks wrong. Shouldn't this be ((imageWidth-1)>>2)+1 ? + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base_ar = (tBlk * widthBlks + sBlk) << 4; u32 base_gb = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3; @@ -662,12 +662,11 @@ void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, std::span src_ar, } void TexDecoder_DecodeTexelRGBA8FromTmem(u8* dst, const u8* src_ar, const u8* src_gb, int s, int t, - int imageWidth) + int image_width_minus_1) { u16 sBlk = s >> 2; u16 tBlk = t >> 2; - u16 widthBlks = - (imageWidth >> 2) + 1; // TODO: Looks wrong. Shouldn't this be ((imageWidth-1)>>2)+1 ? + u16 widthBlks = (image_width_minus_1 >> 2) + 1; u32 base_ar = (tBlk * widthBlks + sBlk) << 4; u32 base_gb = (tBlk * widthBlks + sBlk) << 4; u16 blkS = s & 3;