Mesa (master): freedreno: Use explicit *_NONE enum for undefined formats

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 26 18:53:24 UTC 2020


Module: Mesa
Branch: master
Commit: e369b8931c675a6e86715c682723b085e45e0ee5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e369b8931c675a6e86715c682723b085e45e0ee5

Author: Kristian H. Kristensen <hoegsberg at google.com>
Date:   Fri May 22 13:36:38 2020 -0700

freedreno: Use explicit *_NONE enum for undefined formats

This adds RB, VFMT and TFMT NONE values for a3xx-a5xx and FMT6_NONE
for a6xx.  Use those values instead of open coded (enum xxx) ~0 or
sometimes even ~0, which triggers out-of-enum range warnings.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5173>

---

 src/freedreno/registers/a3xx.xml                  |  6 ++++++
 src/freedreno/registers/a4xx.xml                  |  6 ++++++
 src/freedreno/registers/a5xx.xml                  |  6 ++++++
 src/freedreno/registers/a6xx.xml                  |  4 ++++
 src/freedreno/vulkan/tu_formats.c                 |  4 +---
 src/gallium/drivers/freedreno/a2xx/fd2_util.h     |  3 ++-
 src/gallium/drivers/freedreno/a3xx/fd3_emit.c     |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_format.c   | 12 +++++-------
 src/gallium/drivers/freedreno/a3xx/fd3_resource.c |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_screen.c   | 10 +++++-----
 src/gallium/drivers/freedreno/a4xx/fd4_emit.c     |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_format.c   |  6 ++----
 src/gallium/drivers/freedreno/a5xx/fd5_blitter.c  |  2 +-
 src/gallium/drivers/freedreno/a5xx/fd5_emit.c     |  2 +-
 src/gallium/drivers/freedreno/a5xx/fd5_format.c   | 12 +++++-------
 src/gallium/drivers/freedreno/a5xx/fd5_screen.c   | 10 +++++-----
 src/gallium/drivers/freedreno/a6xx/fd6_blitter.c  |  2 +-
 src/gallium/drivers/freedreno/a6xx/fd6_emit.c     |  2 +-
 src/gallium/drivers/freedreno/a6xx/fd6_format.c   |  8 +++-----
 src/gallium/drivers/freedreno/a6xx/fd6_screen.c   | 10 +++++-----
 20 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/src/freedreno/registers/a3xx.xml b/src/freedreno/registers/a3xx.xml
index 6c92d442dad..5cfa1fe9ea9 100644
--- a/src/freedreno/registers/a3xx.xml
+++ b/src/freedreno/registers/a3xx.xml
@@ -91,6 +91,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="VFMT_2_10_10_10_UNORM" value="0x3d"/>
 	<value name="VFMT_2_10_10_10_SINT" value="0x3e"/>
 	<value name="VFMT_2_10_10_10_SNORM" value="0x3f"/>
+
+	<value name="VFMT_NONE" value="0xff"/>
 </enum>
 
 <enum name="a3xx_tex_fmt">
@@ -210,6 +212,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="TFMT_ETC2_RGBA8" value="0x74"/>
 	<value name="TFMT_ETC2_RGB8A1" value="0x75"/>
 	<value name="TFMT_ETC2_RGB8" value="0x76"/>
+
+	<value name="TFMT_NONE" value="0xff"/>
 </enum>
 
 <enum name="a3xx_tex_fetchsize">
@@ -278,6 +282,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="RB_R32_UINT"	    value="0x38"/>
 	<value name="RB_R32G32_UINT"	    value="0x39"/>
 	<value name="RB_R32G32B32A32_UINT"  value="0x3b"/>
+
+	<value name="RB_NONE"               value="0xff"/>
 </enum>
 
 <enum name="a3xx_cp_perfcounter_select">
diff --git a/src/freedreno/registers/a4xx.xml b/src/freedreno/registers/a4xx.xml
index 1c2c48c5e50..284e491c886 100644
--- a/src/freedreno/registers/a4xx.xml
+++ b/src/freedreno/registers/a4xx.xml
@@ -56,6 +56,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="RB4_R32G32B32A32_FLOAT" value="0x3c"/>
 	<value name="RB4_R32G32B32A32_UINT" value="0x3d"/>
 	<value name="RB4_R32G32B32A32_SINT" value="0x3e"/>
+
+	<value name="RB4_NONE" value="0xff"/>
 </enum>
 
 <enum name="a4xx_tile_mode">
@@ -135,6 +137,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="VFMT4_2_10_10_10_UNORM" value="0x3d"/>
 	<value name="VFMT4_2_10_10_10_SINT" value="0x3e"/>
 	<value name="VFMT4_2_10_10_10_SNORM" value="0x3f"/>
+
+	<value name="VFMT4_NONE" value="0xff"/>
 </enum>
 
 <enum name="a4xx_tex_fmt">
@@ -260,6 +264,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="TFMT4_ASTC_12x10"            value="0x7b"/>
 	<value name="TFMT4_ASTC_12x12"            value="0x7c"/>
 	<!-- 0x7d .. 0x7f -->
+
+	<value name="TFMT4_NONE"                  value="0xff"/>
 </enum>
 
 <enum name="a4xx_tex_fetchsize">
diff --git a/src/freedreno/registers/a5xx.xml b/src/freedreno/registers/a5xx.xml
index c5fdb662b8b..f954a7bd8ad 100644
--- a/src/freedreno/registers/a5xx.xml
+++ b/src/freedreno/registers/a5xx.xml
@@ -51,6 +51,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value value="0x82" name="RB5_R32G32B32A32_FLOAT"/>
 	<value value="0x83" name="RB5_R32G32B32A32_UINT"/>
 	<value value="0x84" name="RB5_R32G32B32A32_SINT"/>
+
+	<value value="0xff" name="RB5_NONE"/>
 </enum>
 
 <enum name="a5xx_tile_mode">
@@ -138,6 +140,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value value="0x83" name="VFMT5_32_32_32_32_UINT"/>
 	<value value="0x84" name="VFMT5_32_32_32_32_SINT"/>
 	<value value="0x85" name="VFMT5_32_32_32_32_FIXED"/>
+
+	<value value="0xff" name="VFMT5_NONE"/>
 </enum>
 
 <enum name="a5xx_tex_fmt">
@@ -224,6 +228,8 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value value="0xcc" name="TFMT5_ASTC_10x10"/>
 	<value value="0xcd" name="TFMT5_ASTC_12x10"/>
 	<value value="0xce" name="TFMT5_ASTC_12x12"/>
+
+	<value value="0xff" name="TFMT5_NONE"/>
 </enum>
 
 <enum name="a5xx_tex_fetchsize">
diff --git a/src/freedreno/registers/a6xx.xml b/src/freedreno/registers/a6xx.xml
index 92cabb15c25..a718b24149f 100644
--- a/src/freedreno/registers/a6xx.xml
+++ b/src/freedreno/registers/a6xx.xml
@@ -152,6 +152,10 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 
 	<!-- same as X8Z24_UNORM but for sampling stencil (integer, 2nd channel) -->
 	<value value="0xea" name="FMT6_S8Z24_UINT"/>
+
+	<!-- Not a hw enum, used internally in driver -->
+	<value value="0xff" name="FMT6_NONE"/>
+
 </enum>
 
 <enum name="a6xx_tex_fetchsize">
diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c
index a7d2d31bd6d..11c9d05ca30 100644
--- a/src/freedreno/vulkan/tu_formats.c
+++ b/src/freedreno/vulkan/tu_formats.c
@@ -32,8 +32,6 @@
 #include "vk_util.h"
 #include "drm-uapi/drm_fourcc.h"
 
-#define FMT6_x -1
-
 #define TU6_FMT(vkfmt, hwfmt, swapfmt, valid) \
    [VK_FORMAT_##vkfmt] = {                   \
       .fmt = FMT6_##hwfmt,                     \
@@ -45,7 +43,7 @@
 #define TU6_xTC(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_TEXTURE | FMT_COLOR)
 #define TU6_Vxx(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_VERTEX)
 #define TU6_xTx(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_TEXTURE)
-#define TU6_xxx(vk, fmt, swap) TU6_FMT(vk, x, WZYX, false)
+#define TU6_xxx(vk, fmt, swap) TU6_FMT(vk, NONE, WZYX, 0)
 
 static const struct tu_native_format tu6_format_table[] = {
    TU6_xxx(UNDEFINED,                  x,                 x),    /* 0 */
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_util.h b/src/gallium/drivers/freedreno/a2xx/fd2_util.h
index cf945b14475..b87ef412c4a 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_util.h
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_util.h
@@ -32,7 +32,8 @@
 #include "a2xx.xml.h"
 
 struct surface_format {
-#define FMT_INVALID 0x7f
+/* If enum is a signed type, 0x7f is out of range. Cast it to avoid warnings. */
+#define FMT_INVALID ((enum a2xx_sq_surfaceformat) 0x7f)
 	enum a2xx_sq_surfaceformat format : 7;
 	enum sq_tex_sign sign : 2;
 	enum sq_tex_num_format num_format : 1;
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 2761358a48f..f86d4712c9a 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -441,7 +441,7 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd3_emit *emit)
 				continue;
 #endif
 
-			debug_assert(fmt != ~0);
+			debug_assert(fmt != VFMT_NONE);
 
 			OUT_PKT0(ring, REG_A3XX_VFD_FETCH(j), 2);
 			OUT_RING(ring, A3XX_VFD_FETCH_INSTR_0_FETCHSIZE(fs - 1) |
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.c b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
index b5a5bb1bffc..58df9714f0a 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_format.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
@@ -39,8 +39,6 @@ struct fd3_format {
 	boolean present;
 };
 
-#define RB_NONE ~0
-
 /* vertex + texture */
 #define VT(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
@@ -55,7 +53,7 @@ struct fd3_format {
 #define _T(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
-		.vtx = ~0, \
+		.vtx = VFMT_NONE, \
 		.tex = TFMT_ ## fmt, \
 		.rb = RB_ ## rbfmt, \
 		.swap = swapfmt \
@@ -66,7 +64,7 @@ struct fd3_format {
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
 		.vtx = VFMT_ ## fmt, \
-		.tex = ~0, \
+		.tex = TFMT_NONE, \
 		.rb = RB_ ## rbfmt, \
 		.swap = swapfmt \
 	}
@@ -295,7 +293,7 @@ enum a3xx_vtx_fmt
 fd3_pipe2vtx(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return VFMT_NONE;
 	return formats[format].vtx;
 }
 
@@ -303,7 +301,7 @@ enum a3xx_tex_fmt
 fd3_pipe2tex(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return TFMT_NONE;
 	return formats[format].tex;
 }
 
@@ -311,7 +309,7 @@ enum a3xx_color_fmt
 fd3_pipe2color(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return RB_NONE;
 	return formats[format].rb;
 }
 
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
index 0a58c16abc6..49a7e0babec 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
@@ -116,7 +116,7 @@ ok_format(enum pipe_format pfmt)
 {
 	enum a3xx_color_fmt fmt = fd3_pipe2color(pfmt);
 
-	if (fmt == ~0)
+	if (fmt == RB_NONE)
 		return false;
 
 	switch (pfmt) {
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
index bdf8eaa0698..772426c82f3 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
@@ -56,12 +56,12 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen,
 		return false;
 
 	if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
-			(fd3_pipe2vtx(format) != (enum a3xx_vtx_fmt)~0)) {
+			(fd3_pipe2vtx(format) != VFMT_NONE)) {
 		retval |= PIPE_BIND_VERTEX_BUFFER;
 	}
 
 	if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
-			(fd3_pipe2tex(format) != (enum a3xx_tex_fmt)~0)) {
+			(fd3_pipe2tex(format) != TFMT_NONE)) {
 		retval |= PIPE_BIND_SAMPLER_VIEW;
 	}
 
@@ -70,8 +70,8 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen,
 				PIPE_BIND_SCANOUT |
 				PIPE_BIND_SHARED |
 				PIPE_BIND_BLENDABLE)) &&
-			(fd3_pipe2color(format) != (enum a3xx_color_fmt)~0) &&
-			(fd3_pipe2tex(format) != (enum a3xx_tex_fmt)~0)) {
+			(fd3_pipe2color(format) != RB_NONE) &&
+			(fd3_pipe2tex(format) != TFMT_NONE)) {
 		retval |= usage & (PIPE_BIND_RENDER_TARGET |
 				PIPE_BIND_DISPLAY_TARGET |
 				PIPE_BIND_SCANOUT |
@@ -82,7 +82,7 @@ fd3_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
 			(fd_pipe2depth(format) != (enum adreno_rb_depth_format)~0) &&
-			(fd3_pipe2tex(format) != (enum a3xx_tex_fmt)~0)) {
+			(fd3_pipe2tex(format) != TFMT_NONE)) {
 		retval |= PIPE_BIND_DEPTH_STENCIL;
 	}
 
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
index 0aff8fe3e2f..6f94733e9ad 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
@@ -437,7 +437,7 @@ fd4_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd4_emit *emit)
 			uint32_t fs = util_format_get_blocksize(pfmt);
 			uint32_t off = vb->buffer_offset + elem->src_offset;
 			uint32_t size = fd_bo_size(rsc->bo) - off;
-			debug_assert(fmt != ~0);
+			debug_assert(fmt != VFMT4_NONE);
 
 #ifdef DEBUG
 			/* see dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.bind_vertex_buffer_offset_near_wrap_10
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_format.c b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
index a9768acb07b..c41015857d6 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_format.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_format.c
@@ -42,8 +42,6 @@ struct fd4_format {
 	boolean present;
 };
 
-#define RB4_NONE ~0
-
 /* vertex + texture */
 #define VT(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
@@ -58,7 +56,7 @@ struct fd4_format {
 #define _T(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
-		.vtx = ~0, \
+		.vtx = VFMT4_NONE, \
 		.tex = TFMT4_ ## fmt, \
 		.rb = RB4_ ## rbfmt, \
 		.swap = swapfmt \
@@ -69,7 +67,7 @@ struct fd4_format {
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
 		.vtx = VFMT4_ ## fmt, \
-		.tex = ~0, \
+		.tex = TFMT4_NONE, \
 		.rb = RB4_ ## rbfmt, \
 		.swap = swapfmt \
 	}
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
index 7c00c3edb42..a1d846c68c5 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
@@ -72,7 +72,7 @@ ok_format(enum pipe_format fmt)
 		break;
 	}
 
-	if (fd5_pipe2color(fmt) == ~0)
+	if (fd5_pipe2color(fmt) == RB5_NONE)
 		return false;
 
 	return true;
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index ac8a5f59df0..3670cba0aae 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -492,7 +492,7 @@ fd5_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd5_emit *emit)
 			bool isint = util_format_is_pure_integer(pfmt);
 			uint32_t off = vb->buffer_offset + elem->src_offset;
 			uint32_t size = fd_bo_size(rsc->bo) - off;
-			debug_assert(fmt != ~0);
+			debug_assert(fmt != VFMT5_NONE);
 
 #ifdef DEBUG
 			/* see dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.bind_vertex_buffer_offset_near_wrap_10
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_format.c b/src/gallium/drivers/freedreno/a5xx/fd5_format.c
index 3686f1633f1..a201b64402f 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_format.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_format.c
@@ -42,8 +42,6 @@ struct fd5_format {
 	boolean present;
 };
 
-#define RB5_NONE ~0
-
 /* vertex + texture */
 #define VT(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
@@ -58,7 +56,7 @@ struct fd5_format {
 #define _T(pipe, fmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
-		.vtx = ~0, \
+		.vtx = VFMT5_NONE, \
 		.tex = TFMT5_ ## fmt, \
 		.rb = RB5_ ## rbfmt, \
 		.swap = swapfmt \
@@ -69,7 +67,7 @@ struct fd5_format {
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
 		.vtx = VFMT5_ ## fmt, \
-		.tex = ~0, \
+		.tex = TFMT5_NONE, \
 		.rb = RB5_ ## rbfmt, \
 		.swap = swapfmt \
 	}
@@ -344,7 +342,7 @@ enum a5xx_vtx_fmt
 fd5_pipe2vtx(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return VFMT5_NONE;
 	return formats[format].vtx;
 }
 
@@ -353,7 +351,7 @@ enum a5xx_tex_fmt
 fd5_pipe2tex(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return TFMT5_NONE;
 	return formats[format].tex;
 }
 
@@ -362,7 +360,7 @@ enum a5xx_color_fmt
 fd5_pipe2color(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return RB5_NONE;
 	return formats[format].rb;
 }
 
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
index 12dcb8a6e80..9a4df4d26fb 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_screen.c
@@ -71,12 +71,12 @@ fd5_screen_is_format_supported(struct pipe_screen *pscreen,
 		return false;
 
 	if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
-			(fd5_pipe2vtx(format) != (enum a5xx_vtx_fmt)~0)) {
+			(fd5_pipe2vtx(format) != VFMT5_NONE)) {
 		retval |= PIPE_BIND_VERTEX_BUFFER;
 	}
 
 	if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
-			(fd5_pipe2tex(format) != (enum a5xx_tex_fmt)~0) &&
+			(fd5_pipe2tex(format) != TFMT5_NONE) &&
 			(target == PIPE_BUFFER ||
 			 util_format_get_blocksize(format) != 12)) {
 		retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
@@ -87,8 +87,8 @@ fd5_screen_is_format_supported(struct pipe_screen *pscreen,
 				PIPE_BIND_SCANOUT |
 				PIPE_BIND_SHARED |
 				PIPE_BIND_COMPUTE_RESOURCE)) &&
-			(fd5_pipe2color(format) != (enum a5xx_color_fmt)~0) &&
-			(fd5_pipe2tex(format) != (enum a5xx_tex_fmt)~0)) {
+			(fd5_pipe2color(format) != RB5_NONE) &&
+			(fd5_pipe2tex(format) != TFMT5_NONE)) {
 		retval |= usage & (PIPE_BIND_RENDER_TARGET |
 				PIPE_BIND_DISPLAY_TARGET |
 				PIPE_BIND_SCANOUT |
@@ -103,7 +103,7 @@ fd5_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
 			(fd5_pipe2depth(format) != (enum a5xx_depth_format)~0) &&
-			(fd5_pipe2tex(format) != (enum a5xx_tex_fmt)~0)) {
+			(fd5_pipe2tex(format) != TFMT5_NONE)) {
 		retval |= PIPE_BIND_DEPTH_STENCIL;
 	}
 
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
index 9b5231d55e3..7bf9679e93d 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
@@ -77,7 +77,7 @@ ok_format(enum pipe_format pfmt)
 		break;
 	}
 
-	if (fmt == ~0)
+	if (fmt == FMT6_NONE)
 		return false;
 
 	if (fd6_ifmt(fmt) == 0)
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c
index 52a44c67535..23941873edb 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c
@@ -608,7 +608,7 @@ build_vbo_state(struct fd6_emit *emit, const struct ir3_shader_variant *vp)
 		enum pipe_format pfmt = elem->src_format;
 		enum a6xx_format fmt = fd6_pipe2vtx(pfmt);
 		bool isint = util_format_is_pure_integer(pfmt);
-		debug_assert(fmt != ~0);
+		debug_assert(fmt != FMT6_NONE);
 
 		OUT_RING(ring, A6XX_VFD_DECODE_INSTR_IDX(j) |
 				A6XX_VFD_DECODE_INSTR_FORMAT(fmt) |
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_format.c b/src/gallium/drivers/freedreno/a6xx/fd6_format.c
index fbb1fb960a8..0cd7b397a34 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_format.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_format.c
@@ -44,8 +44,6 @@ struct fd6_format {
 	boolean present;
 };
 
-#define FMT6_NONE ~0
-
 #define FMT(pipe, vtxfmt, texfmt, rbfmt, swapfmt) \
 	[PIPE_FORMAT_ ## pipe] = { \
 		.present = 1, \
@@ -341,7 +339,7 @@ enum a6xx_format
 fd6_pipe2vtx(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return FMT6_NONE;
 	return formats[format].vtx;
 }
 
@@ -350,7 +348,7 @@ enum a6xx_format
 fd6_pipe2tex(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return FMT6_NONE;
 	return formats[format].tex;
 }
 
@@ -359,7 +357,7 @@ enum a6xx_format
 fd6_pipe2color(enum pipe_format format)
 {
 	if (!formats[format].present)
-		return ~0;
+		return FMT6_NONE;
 	return formats[format].rb;
 }
 
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c
index 20383d4ff48..bb467112ed0 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c
@@ -77,12 +77,12 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
 		return false;
 
 	if ((usage & PIPE_BIND_VERTEX_BUFFER) &&
-			(fd6_pipe2vtx(format) != (enum a6xx_format)~0)) {
+			(fd6_pipe2vtx(format) != FMT6_NONE)) {
 		retval |= PIPE_BIND_VERTEX_BUFFER;
 	}
 
 	if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
-			(fd6_pipe2tex(format) != (enum a6xx_format)~0) &&
+			(fd6_pipe2tex(format) != FMT6_NONE) &&
 			(target == PIPE_BUFFER ||
 			 util_format_get_blocksize(format) != 12)) {
 		retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
@@ -93,8 +93,8 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
 				PIPE_BIND_SCANOUT |
 				PIPE_BIND_SHARED |
 				PIPE_BIND_COMPUTE_RESOURCE)) &&
-			(fd6_pipe2color(format) != (enum a6xx_format)~0) &&
-			(fd6_pipe2tex(format) != (enum a6xx_format)~0)) {
+			(fd6_pipe2color(format) != FMT6_NONE) &&
+			(fd6_pipe2tex(format) != FMT6_NONE)) {
 		retval |= usage & (PIPE_BIND_RENDER_TARGET |
 				PIPE_BIND_DISPLAY_TARGET |
 				PIPE_BIND_SCANOUT |
@@ -109,7 +109,7 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
 
 	if ((usage & PIPE_BIND_DEPTH_STENCIL) &&
 			(fd6_pipe2depth(format) != (enum a6xx_depth_format)~0) &&
-			(fd6_pipe2tex(format) != (enum a6xx_format)~0)) {
+			(fd6_pipe2tex(format) != FMT6_NONE)) {
 		retval |= PIPE_BIND_DEPTH_STENCIL;
 	}
 



More information about the mesa-commit mailing list