[Mesa-dev] [PATCH 1/8] glsl: Make ir_validate check the type of ir_discard::condition.

Kenneth Graunke kenneth at whitecape.org
Tue Feb 24 02:19:38 PST 2015


Copy and pasted from the ir_if::condition handling, plus a NULL check.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ir_validate.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Piglit tested on Haswell, with and without NIR.  I touch tested classic
swrast (I ran a few discard tests), and have not tested TGSI based
drivers.  I did verify that st_glsl_to_tgsi has code that supposedly
handles ir_discard::condition, however.

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 6678894..7a7688c 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -61,6 +61,7 @@ public:
    virtual ir_visitor_status visit(ir_variable *v);
    virtual ir_visitor_status visit(ir_dereference_variable *ir);
 
+   virtual ir_visitor_status visit_enter(ir_discard *ir);
    virtual ir_visitor_status visit_enter(ir_if *ir);
 
    virtual ir_visitor_status visit_enter(ir_function *ir);
@@ -133,6 +134,20 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
 }
 
 ir_visitor_status
+ir_validate::visit_enter(ir_discard *ir)
+{
+   if (ir->condition && ir->condition->type != glsl_type::bool_type) {
+      printf("ir_discard condition %s type instead of bool.\n",
+	     ir->condition->type->name);
+      ir->print();
+      printf("\n");
+      abort();
+   }
+
+   return visit_continue;
+}
+
+ir_visitor_status
 ir_validate::visit_enter(ir_if *ir)
 {
    if (ir->condition->type != glsl_type::bool_type) {
-- 
2.2.2



More information about the mesa-dev mailing list