mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-07 01:25:36 +00:00
Reverse the bits of the ASTC block in order to read the texel weight data...
This commit is contained in:
parent
1269ab1314
commit
a8514ba9b3
|
@ -915,18 +915,19 @@ namespace ASTCC {
|
|||
|
||||
// Read the texel weight data..
|
||||
uint8 texelWeightData[16];
|
||||
memset(texelWeightData, 0, sizeof(texelWeightData));
|
||||
FasTC::BitStream texelWeightStream (texelWeightData, 16*8, 0);
|
||||
memcpy(texelWeightData, inBuf, sizeof(texelWeightData));
|
||||
|
||||
int32 texelWeightBits = weightParams.GetPackedBitSize();
|
||||
while(texelWeightBits > 0) {
|
||||
uint32 nb = std::min(texelWeightBits, 8);
|
||||
uint32 b = strm.ReadBits(nb);
|
||||
texelWeightStream.WriteBits(b, nb);
|
||||
texelWeightBits -= 8;
|
||||
}
|
||||
// Reverse everything
|
||||
for(uint32 i = 0; i < 8; i++) {
|
||||
// Taken from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64Bits
|
||||
#define REVERSE_BYTE(b) (((b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32
|
||||
unsigned char a = REVERSE_BYTE(texelWeightData[i]);
|
||||
unsigned char b = REVERSE_BYTE(texelWeightData[15 - i]);
|
||||
#undef REVERSE_BYTE
|
||||
|
||||
assert(strm.GetBitsRead() == 128);
|
||||
texelWeightData[i] = b;
|
||||
texelWeightData[15-i] = a;
|
||||
}
|
||||
|
||||
// Decode both color data and texel weight data
|
||||
uint32 colorValues[32]; // Four values, two endpoints, four maximum paritions
|
||||
|
|
Loading…
Reference in a new issue