summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/tests
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-08-19 15:17:58 -0700
committerEric Anholt <[email protected]>2019-10-17 21:07:29 +0000
commit75c601b6cf63c077dbfbb5f2f64f683dcf5524b4 (patch)
tree1862ee5f747d8f7b4b1e501a75c74984926bafba /src/mesa/main/tests
parentd77c77936b3956e8925504ad980acbff74422e7c (diff)
mesa: Refactor the entirety of _mesa_format_matches_format_and_type().
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 match RGB/BGR unorm8 array formats on BE - 2101010 formats incorrectly matching with swapBytes set. - UINT/SINT byte formats failed to match with swapBytes set. 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. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/tests')
-rw-r--r--src/mesa/main/tests/mesa_formats.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/mesa/main/tests/mesa_formats.cpp b/src/mesa/main/tests/mesa_formats.cpp
index e4f95163c28..b7f036bb3c2 100644
--- a/src/mesa/main/tests/mesa_formats.cpp
+++ b/src/mesa/main/tests/mesa_formats.cpp
@@ -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);
}
}
@@ -138,6 +131,16 @@ TEST(MesaFormatsTest, FormatSanity)
}
}
+TEST(MesaFormatsTest, IntensityToRed)
+{
+ EXPECT_EQ(_mesa_get_intensity_format_red(MESA_FORMAT_I_UNORM8),
+ MESA_FORMAT_R_UNORM8);
+ EXPECT_EQ(_mesa_get_intensity_format_red(MESA_FORMAT_I_SINT32),
+ MESA_FORMAT_R_SINT32);
+ EXPECT_EQ(_mesa_get_intensity_format_red(MESA_FORMAT_R8G8B8A8_UNORM),
+ MESA_FORMAT_R8G8B8A8_UNORM);
+}
+
static mesa_format fffat_wrap(GLenum format, GLenum type)
{
uint32_t f = _mesa_format_from_format_and_type(format, type);
@@ -159,3 +162,19 @@ TEST(MesaFormatsTest, FormatFromFormatAndType)
EXPECT_TRUE(_mesa_format_is_mesa_array_format(_mesa_format_from_format_and_type(GL_DEPTH_COMPONENT,
GL_BYTE)));
}
+
+TEST(MesaFormatsTest, FormatMatchesFormatAndType)
+{
+ EXPECT_TRUE(_mesa_format_matches_format_and_type(MESA_FORMAT_RGBA_UNORM16,
+ GL_RGBA,
+ GL_UNSIGNED_SHORT, false,
+ NULL));
+ EXPECT_TRUE(_mesa_format_matches_format_and_type(MESA_FORMAT_S_UINT8,
+ GL_STENCIL_INDEX,
+ GL_UNSIGNED_BYTE, false,
+ NULL));
+ EXPECT_TRUE(_mesa_format_matches_format_and_type(MESA_FORMAT_Z_UNORM16,
+ GL_DEPTH_COMPONENT,
+ GL_UNSIGNED_SHORT, false,
+ NULL));
+}