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

  1. Checkout my branch git clone https://github.com/bwrsandman/bgfx.git -b pixelformats-example
  2. Compile the 47-pixelformats example
  3. Run the 47-pixelformats example with different renderers
  4. 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 image

OpenGL on Linux image

Vulkan on Windows image

OpenGL on Windows image

Direct3D9 on Windows image

Direct3D11 on Windows image

Direct3D12 on Windows image

Metal on OSX Screen Shot 2022-08-18 at 3 48 51 PM

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)

Most upvoted comments

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.