GPUOpen-Tools / compressonator

Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs
1.3k stars 198 forks source link

Mipmap levels 2x2 are broken when generating BC1 textures #315

Open aerofly opened 7 months ago

aerofly commented 7 months ago

Hello,

the current code when generating the mipmap level 2x2 for DXT1 textures is broken. The error is in the function

bool CCodecBuffer_RGB888::ReadBlockRGBA(CMP_DWORD x, CMP_DWORD y, CMP_BYTE w, CMP_BYTE h, CMP_BYTE block[])

and this line

CMP_BYTE* pDestData = (CMP_BYTE*)&pdwBlock[j * dwWidth];

It should actually be

CMP_BYTE* pDestData = (CMP_BYTE*)&pdwBlock[j * w];

Otherwise the pixels are not properly duplicated into the 4x4 block. Some other ReadBlockRGBA functions also have this small issue.

This issue is probably also causing this

Can you confirm if this is actually a bug and if my fix is working properly?