bgfx: bgfx native formats colour channels don't match bimg::imageConvert
Description It looks like when fixing inconsistencies between renderers in #2029 and #1932, the channels of RGBA4 and RGB5A1 have the red and blue channels reversed.
The result of having this discrepancy is that platforms where this format is emulated will have a different colour ordering than those that natively support them.
I modified an example to draw different RGBA formats to better visualize this. First row has the native formats that bgfx uses and below are the same formats but they’ve been converted to RGBA8 using bimg::imageConvert
.
I also tried out RGB10A2 because I suspected that it also suffers from inconsistencies. It seems to only have R&B inverted on Vulkan
To Reproduce
- Checkout my branch
git clone https://github.com/bwrsandman/bgfx.git -b pixelformats-example
- Compile the 47-pixelformats example
- Run the 47-pixelformats example with different renderers
- See mismatch
Expected behavior The top row and bottom row should match for different formats. The color wheel starts red at degree 0, green at -60 degrees and blue at 60. Alpha interpolates between 1 in the centre and 0 at the edge.
Screenshots
Vulkan on Linux
OpenGL on Linux
Vulkan on Windows
OpenGL on Windows
Direct3D9 on Windows
Direct3D11 on Windows
Direct3D12 on Windows
Metal on OSX
WebGPU
Additional context
For the Metal on OSX, I removed two lines that force software conversion in order to show the native interpretation.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (15 by maintainers)
Also if you’re interested to make this 47-pixelformats example, it would be good to be something similar to this: https://floooh.github.io/sokol-html5/pixelformats-sapp.html
Where you also display other
BGFX_CAPS_FORMAT_TEXTURE_*
features.