mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-12-06 20:53:40 +01:00
VideoCommon: Rename TexDecoder_DecodeTexel width parameter
All existing callers pass the width minus one, and passing the width without subtracting one gives incorrect results. Let's call the parameter image_width_minus_1, like TextureSampler.cpp already calls it.
This commit is contained in:
1 parent
e6f3ae1762
commit
fbab471d1a
2 files changed
+23
-23
No files matched your search
@@ -358,7 +358,7 @@ static inline u32 DecodePixel_Paletted(u16 pixel, TLUTFormat tlutfmt)
|
||||
}
|
||||
}
|
||||
|
||||
void TexDecoder_DecodeTexel(u8* dst, std::span<const u8> src, int s, int t, int imageWidth,
|
||||
void TexDecoder_DecodeTexel(u8* dst, std::span<const u8> src, int s, int t, int image_width_minus_1,
|
||||
TextureFormat texformat, std::span<const u8> tlut_, TLUTFormat tlutfmt)
|
||||
{
|
||||
/* General formula for computing texture offset
|
||||
@@ -378,7 +378,7 @@ void TexDecoder_DecodeTexel(u8* dst, std::span<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> 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<const u8> src_ar,
|
||||
std::span<const u8> src_gb, int s, int t, int imageWidth)
|
||||
std::span<const u8> 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<const u8> 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;
|
||||
|
||||
Reference in new issue
Block a user