mesa/st: simplify some UBO index logic
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 17 Aug 2017 11:03:03 +0000 (21:03 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 22 Aug 2017 03:32:21 +0000 (13:32 +1000)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index f4f3092fe02e1119bfe768cfa13816a163c4c2b9..9688400ed4fb87179f78aea2eedbe95e43ddf048 100644 (file)
@@ -2161,7 +2161,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
       ir_constant *const_uniform_block = ir->operands[0]->as_constant();
       ir_constant *const_offset_ir = ir->operands[1]->as_constant();
       unsigned const_offset = const_offset_ir ? const_offset_ir->value.u[0] : 0;
-      unsigned const_block = const_uniform_block ? const_uniform_block->value.u[0] + 1 : 0;
+      unsigned const_block = const_uniform_block ? const_uniform_block->value.u[0] + 1 : 1;
       st_src_reg index_reg = get_temp(glsl_type::uint_type);
       st_src_reg cbuf;
 
@@ -2171,6 +2171,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
       cbuf.reladdr = NULL;
       cbuf.negate = 0;
       cbuf.abs = 0;
+      cbuf.index2D = const_block;
 
       assert(ir->type->is_vector() || ir->type->is_scalar());
 
@@ -2217,13 +2218,11 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
       if (const_uniform_block) {
          /* Constant constant buffer */
          cbuf.reladdr2 = NULL;
-         cbuf.index2D = const_block;
          cbuf.has_index2 = true;
       }
       else {
          /* Relative/variable constant buffer */
          cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
-         cbuf.index2D = 1;
          memcpy(cbuf.reladdr2, &op[0], sizeof(st_src_reg));
          cbuf.has_index2 = true;
       }