Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swizzle issues #244

Open
carlschissler opened this issue Apr 7, 2023 · 2 comments
Open

Swizzle issues #244

carlschissler opened this issue Apr 7, 2023 · 2 comments

Comments

@carlschissler
Copy link

First, there is a bug in how swizzling is handled in CompressTexture() in compress.cpp. The code snippet around line 388 that has the comment "GPUOpen issue # 59 fix", is misplaced inside the if() statement that checks to see if the options are provided. This prevents swizzling from being activated unless the user provides a pointer to CMP_CompressOptions, which most people won't. The swizzling check should be moved outside the if(), so that it is always executed.

Second, swizzling is not even implemented in several buffer formats. For instance, RGB-888 data (no alpha) is not swizzled. This means that if I try to compress RGB data to DXT1, for example, that the resulting texture comes out with red and blue channels swapped because the internal system expects BGR ordering, and swizzling is not there to fix it. This means that the only way to compress 8-bit RGB data is to manually swizzle it before passing to the API.

It's simple to add the swizzling to CCodecBuffer_RGB888::ReadBlockRGBA(), by just checking the m_bSwizzle member and reversing the bytes if true:

if ( m_bSwizzle )
{
for(i = 0; i < dwWidth; i++) {
*pDestData++ = pSrcData[2];
*pDestData++ = pSrcData[1];
*pDestData++ = pSrcData[0];
*pDestData++ = 0xff;
pSrcData += nChannelCount;
}
}
else
{
for(i = 0; i < dwWidth; i++) {
*pDestData++ = *pSrcData++;
*pDestData++ = *pSrcData++;
*pDestData++ = *pSrcData++;
*pDestData++ = 0xff;
}
}

I can't believe how many bugs/problems I've found with this code, just in basic usage. It seems like only certain special code paths are tested, and everything else is full of bugs and issues.

@Lucodivo
Copy link
Contributor

Lucodivo commented Sep 18, 2023

Same issue also documented here. #247

@Lucodivo
Copy link
Contributor

Using the Compressinator SDK, I am experiencing this bug when converting textures from both of the following scenarios:
CMP_FORMAT_RGB_888 to CMP_FORMAT_ETC2_RGB
CMP_FORMAT_RGBA_8888 to CMP_FORMAT_ETC2_RGBA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants