diff options
author | Ian Romanick <[email protected]> | 2010-08-04 16:27:17 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-08-04 16:47:28 -0700 |
commit | 6235c6a83855fe2818affda3c82e1a245bd0232e (patch) | |
tree | 82bc88da7bea32188660535a78f10956491efb20 /src/glsl/ir_validate.cpp | |
parent | 5a7758efbe14dee026245a4f4f4fb3ccf7b2c23b (diff) |
glsl2: Additional validation of write masks
Diffstat (limited to 'src/glsl/ir_validate.cpp')
-rw-r--r-- | src/glsl/ir_validate.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 89bcd1c4811..701bf21ea61 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -67,6 +67,8 @@ public: virtual ir_visitor_status visit_leave(ir_expression *ir); + virtual ir_visitor_status visit_enter(ir_assignment *ir); + static void validate_ir(ir_instruction *ir, void *data); ir_function *current_function; @@ -320,6 +322,36 @@ ir_validate::visit(ir_variable *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit_enter(ir_assignment *ir) +{ + const ir_dereference *const lhs = ir->lhs; + if (lhs->type->is_scalar() || lhs->type->is_vector()) { + if (ir->write_mask == 0) { + printf("Assignment LHS is %s, but write mask is 0:\n", + lhs->type->is_scalar() ? "scalar" : "vector"); + ir->print(); + abort(); + } + + /* Mask of fields that do not exist in the destination. These should + * not be written by the assignment. + */ + const unsigned invalid_mask = ~((1U << lhs->type->components()) - 1); + + if ((invalid_mask & ir->write_mask) != 0) { + printf("Assignment write mask enables invalid components for " + "type %s:\n", lhs->type->name); + ir->print(); + abort(); + } + } + + this->validate_ir(ir, this->data); + + return visit_continue; +} + void ir_validate::validate_ir(ir_instruction *ir, void *data) { |