i965/vs: Fix the trivial register allocator's failure path.
authorEric Anholt <eric@anholt.net>
Thu, 11 Aug 2011 16:17:18 +0000 (09:17 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 16 Aug 2011 20:04:43 +0000 (13:04 -0700)
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp

index 350d544aba313140b43baff812730863d10528e0..27160fb40d4913f3f074dc22a6944b0199b887f9 100644 (file)
@@ -561,6 +561,9 @@ vec4_visitor::run()
    setup_payload();
    reg_allocate();
 
+   if (failed)
+      return false;
+
    brw_set_access_mode(p, BRW_ALIGN_16);
 
    generate_code();
index 1bfd84d76e8690c7dd14893f651955d23969aa90..d5fd21d99a4ff51daae3dfe641c4db420101a2f7 100644 (file)
@@ -39,7 +39,6 @@ assign(int *reg_hw_locations, reg *reg)
 void
 vec4_visitor::reg_allocate_trivial()
 {
-   int last_grf = 0;
    int hw_reg_mapping[this->virtual_grf_count];
    bool virtual_grf_used[this->virtual_grf_count];
    int i;
@@ -84,9 +83,9 @@ vec4_visitor::reg_allocate_trivial()
       assign(hw_reg_mapping, &inst->src[2]);
    }
 
-   if (last_grf >= BRW_MAX_GRF) {
+   if (prog_data->total_grf > BRW_MAX_GRF) {
       fail("Ran out of regs on trivial allocator (%d/%d)\n",
-          last_grf, BRW_MAX_GRF);
+          prog_data->total_grf, BRW_MAX_GRF);
    }
 }