Commit ef157de8 authored by Emma Anholt's avatar Emma Anholt
Browse files

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

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*).

This deletes the part of tests/mesa_formats.cpp that called
_mesa_format_matches_format_and_type() to make sure it didn't
assertion fail, as it now would assertion fail due to the fact that we
were passing an invalid format (GL_RG) for most types.
parent 13955034
Pipeline #57605 passed with stages
in 13 minutes and 37 seconds
This diff is collapsed.
......@@ -3569,6 +3569,9 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
break;
}
if (format == GL_STENCIL_INDEX && type == GL_UNSIGNED_BYTE)
return MESA_FORMAT_S_UINT8;
/* Extract array format swizzle information from the OpenGL format */
if (is_array_format)
is_array_format = get_swizzle_from_gl_format(format, swizzle);
......
......@@ -50,18 +50,11 @@ TEST(MesaFormatsTest, FormatTypeAndComps)
*/
if (!_mesa_is_format_compressed(f)) {
GLenum datatype = 0;
GLenum error = 0;
GLuint comps = 0;
/* If the datatype is zero, the format was not handled */
_mesa_uncompressed_format_to_type_and_comps(f, &datatype, &comps);
EXPECT_NE(datatype, (GLenum)0);
/* If the error isn't NO_ERROR, the format was not handled.
* Use an arbitrary GLenum format. */
_mesa_format_matches_format_and_type(f, GL_RG, datatype,
GL_FALSE, &error);
EXPECT_EQ((GLenum)GL_NO_ERROR, error);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment