mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 07:45:49 +01:00
Make sure to clear the MSBs of channels that have zero depth that get converted to higher depth values
This commit is contained in:
parent
77bb7488cc
commit
f5e0aa4f9f
@ -112,9 +112,11 @@ namespace PVRTCC {
|
||||
assert(newDepth <= 8);
|
||||
assert(oldDepth <= 8);
|
||||
|
||||
if(oldDepth == newDepth || oldDepth == 0) {
|
||||
if(oldDepth == newDepth) {
|
||||
// Do nothing
|
||||
return val;
|
||||
} else if(oldDepth == 0 && newDepth != 0) {
|
||||
return (1 << newDepth) - 1;
|
||||
} else if(newDepth > oldDepth) {
|
||||
uint8 bitsLeft = newDepth;
|
||||
uint8 ret = 0;
|
||||
|
@ -153,6 +153,19 @@ TEST(Pixel, ChangeChannelBitDepth) {
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 0), 0xFF);
|
||||
}
|
||||
|
||||
TEST(Pixel, ChangeChannelBitDepthFromZero) {
|
||||
uint8 val = 0x43;
|
||||
uint8 depth = 0;
|
||||
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 8), 0xFF);
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 7), 0x7F);
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 6), 0x3F);
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 2), 0x03);
|
||||
|
||||
// Shouldn't change it...
|
||||
EXPECT_EQ(PVRTCC::Pixel::ChangeBitDepth(val, depth, 0), 0x43);
|
||||
}
|
||||
|
||||
TEST(Pixel, ChangePixelBitDepth) {
|
||||
const uint8 bits[4] = { 0x86, 0xC0, 0x0, 0x0 };
|
||||
const uint8 depth[4] = {7, 3, 0, 0};
|
||||
|
Loading…
Reference in New Issue
Block a user