-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Bug Description
I was attempting to load a 3D lookup texture with color information previously created using bimg::imageCreate and bimg::imageWriteKtx. However when loading it with bgfx::createTexture, only the first slice of the 3D texture was correct, the rest was all random color values.
The same behavior was also observable using the texture viewer tool in bgfx.
The garbage values change every time the texture is loaded (both in my code as well as the texture viewer), indicating it is reading uninitialized memory as image data.
Reproduce
Create a 3D KTX texture with RGB8 format and load it with texture viewer tool.
If it helps I can attach the LUT texture I'm using.
The bug appearing both in my code and in the texture viewer might make it seem like the texture file is the issue, but i checked it in hex viewer and the file itself is fine.
I tracked down the issue to the 3D texture creation code in the DirectX 11 backend (renderer_d3d11.cpp: TextureD3D11::create). There the image data will be converted to BGRA8 format before passing it to DirectX. However even if it is a 3D texture, only the first slice will be converted with bimg::imageDecodeToBgra8. The rest of the memory stays uninitialized.
Changing the texture format to BGRA8 fixed the problem for me. However I'm still posting this here since it might become an issue for someone else.
I'm using BGFX API version 127 (which is a bit dated to be fair) with DirectX 11 backend.
Best regards