mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-08 22:05:37 +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,19 +915,20 @@ namespace ASTCC {
|
||||||
|
|
||||||
// Read the texel weight data..
|
// Read the texel weight data..
|
||||||
uint8 texelWeightData[16];
|
uint8 texelWeightData[16];
|
||||||
memset(texelWeightData, 0, sizeof(texelWeightData));
|
memcpy(texelWeightData, inBuf, sizeof(texelWeightData));
|
||||||
FasTC::BitStream texelWeightStream (texelWeightData, 16*8, 0);
|
|
||||||
|
|
||||||
int32 texelWeightBits = weightParams.GetPackedBitSize();
|
// Reverse everything
|
||||||
while(texelWeightBits > 0) {
|
for(uint32 i = 0; i < 8; i++) {
|
||||||
uint32 nb = std::min(texelWeightBits, 8);
|
// Taken from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64Bits
|
||||||
uint32 b = strm.ReadBits(nb);
|
#define REVERSE_BYTE(b) (((b) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32
|
||||||
texelWeightStream.WriteBits(b, nb);
|
unsigned char a = REVERSE_BYTE(texelWeightData[i]);
|
||||||
texelWeightBits -= 8;
|
unsigned char b = REVERSE_BYTE(texelWeightData[15 - i]);
|
||||||
|
#undef REVERSE_BYTE
|
||||||
|
|
||||||
|
texelWeightData[i] = b;
|
||||||
|
texelWeightData[15-i] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(strm.GetBitsRead() == 128);
|
|
||||||
|
|
||||||
// Decode both color data and texel weight data
|
// Decode both color data and texel weight data
|
||||||
uint32 colorValues[32]; // Four values, two endpoints, four maximum paritions
|
uint32 colorValues[32]; // Four values, two endpoints, four maximum paritions
|
||||||
DecodeColorValues(colorValues, colorEndpointData, colorEndpointMode,
|
DecodeColorValues(colorValues, colorEndpointData, colorEndpointMode,
|
||||||
|
|
Loading…
Reference in a new issue