i965: Add var->location != -1 assertions.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 1 Dec 2014 21:44:04 +0000 (13:44 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 4 Dec 2014 01:45:16 +0000 (17:45 -0800)
We shouldn't receive variables with invalid locations set - adding these
assertions should help catch problems before they cause crashes later.

Inspired by similar code in st_glsl_to_tgsi.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index cc12e482be9a7f29437201da2e477c36921b03d2..62ef8537e4a072f5dfd4e58beb40ff45ea9d8183 100644 (file)
@@ -57,6 +57,7 @@ fs_visitor::visit(ir_variable *ir)
       return;
 
    if (ir->data.mode == ir_var_shader_in) {
+      assert(ir->data.location != -1);
       if (!strcmp(ir->name, "gl_FragCoord")) {
         reg = emit_fragcoord_interpolation(ir);
       } else if (!strcmp(ir->name, "gl_FrontFacing")) {
index 61af3258cec46f33ca4c3330a0f247b0fc977fc0..ded7b8cee5e9a515e1f2d4f19078417c8f9a4730 100644 (file)
@@ -1020,10 +1020,12 @@ vec4_visitor::visit(ir_variable *ir)
 
    switch (ir->data.mode) {
    case ir_var_shader_in:
+      assert(ir->data.location != -1);
       reg = new(mem_ctx) dst_reg(ATTR, ir->data.location);
       break;
 
    case ir_var_shader_out:
+      assert(ir->data.location != -1);
       reg = new(mem_ctx) dst_reg(this, ir->type);
 
       for (int i = 0; i < type_size(ir->type); i++) {