Mesa (master): i965: Replace incorrect use of GLboolean with enum brw_compression.

Kenneth Graunke kwg at kemper.freedesktop.org
Tue Oct 11 17:25:59 UTC 2011


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Oct  7 12:32:52 2011 -0700

i965: Replace incorrect use of GLboolean with enum brw_compression.

brw_set_compression_control took a GLboolean as an argument, then
promptly used a switch statement to compare it with various enumeration
values.  Clearly it's not actually a boolean.

Introduce a new enumeration type, enum brw_compression, and use that.

Found by converting GLboolean to bool; clang then gave warnings about
switching on a boolean and ultimately duplicated case errors.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/drivers/dri/i965/brw_defines.h |    8 +++++---
 src/mesa/drivers/dri/i965/brw_eu.c      |    4 +++-
 src/mesa/drivers/dri/i965/brw_eu.h      |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index a111630..21a115b 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -486,9 +486,11 @@
 #define BRW_CHANNEL_Z     2
 #define BRW_CHANNEL_W     3
 
-#define BRW_COMPRESSION_NONE          0
-#define BRW_COMPRESSION_2NDHALF       1
-#define BRW_COMPRESSION_COMPRESSED    2
+enum brw_compression {
+   BRW_COMPRESSION_NONE       = 0,
+   BRW_COMPRESSION_2NDHALF    = 1,
+   BRW_COMPRESSION_COMPRESSED = 2,
+};
 
 #define GEN6_COMPRESSION_1Q		0
 #define GEN6_COMPRESSION_2Q		1
diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
index 0e04af9..b5a858b 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -99,7 +99,9 @@ void brw_set_access_mode( struct brw_compile *p, GLuint access_mode )
    p->current->header.access_mode = access_mode;
 }
 
-void brw_set_compression_control( struct brw_compile *p, GLboolean compression_control )
+void
+brw_set_compression_control(struct brw_compile *p,
+			    enum brw_compression compression_control)
 {
    p->compressed = (compression_control == BRW_COMPRESSION_COMPRESSED);
 
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 31334ce..8b2222b 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -790,7 +790,7 @@ void brw_push_insn_state( struct brw_compile *p );
 void brw_set_mask_control( struct brw_compile *p, GLuint value );
 void brw_set_saturate( struct brw_compile *p, GLuint value );
 void brw_set_access_mode( struct brw_compile *p, GLuint access_mode );
-void brw_set_compression_control( struct brw_compile *p, GLboolean control );
+void brw_set_compression_control(struct brw_compile *p, enum brw_compression c);
 void brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value );
 void brw_set_predicate_control( struct brw_compile *p, GLuint pc );
 void brw_set_predicate_inverse(struct brw_compile *p, bool predicate_inverse);




More information about the mesa-commit mailing list