Skip to content

WIP: mesa: Remove a ton of format code from _mesa_format_and_type_matches().

Emma Anholt requested to merge anholt/mesa:format-and-type into master

This function was difficult to implement for new formats due to the combination of endianness and swapbytes support. Since it's mostly used for fast paths, bugs in it were often missed during testing.

Just reimplement it on top of the recent _mesa_format_from_format_and_type() which can give us a canonical MESA_FORMAT for a format and type enum (while respecting endianness).

Fixes:

  • R4G4B4A4_UNORM, B4G4R4_UINT, R4G4B4A4_UINT incorrectly matched with swapBytes (you can't just reverse the channels if the channels aren't bytes)
  • A4R4G4B4_UNORM and A4R4G4B4_UINT missing BGRA/4444_REV matches
  • failing to RGB/BGR unorm8 array formats on BE
  • 2101010 formats incorrectly matching with swapBytes set.
  • UINT/SINT byte formats failed to match with swapBytes set.
  • YCBCR (packed afaik) was looking at endianness when it shouldn't.

XXX: Note that previously MESA_FORMAT_I_* would match GL_RED/type, while now it doesn't (since RED/type goes through the array format path and turns into MESA_FORMAT_R*).

Merge request reports