[Mesa-dev] [PATCH 06/11] mesa/st: simplify some UBO index logic
Timothy Arceri
tarceri at itsqueeze.com
Thu Aug 17 11:03:03 UTC 2017
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f4f3092fe0..9688400ed4 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2154,30 +2154,31 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
break;
}
assert(!"GLSL 1.30 features unsupported");
break;
case ir_binop_ubo_load: {
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;
cbuf.type = ir->type->base_type;
cbuf.file = PROGRAM_CONSTANT;
cbuf.index = 0;
cbuf.reladdr = NULL;
cbuf.negate = 0;
cbuf.abs = 0;
+ cbuf.index2D = const_block;
assert(ir->type->is_vector() || ir->type->is_scalar());
if (const_offset_ir) {
/* Constant index into constant buffer */
cbuf.reladdr = NULL;
cbuf.index = const_offset / 16;
}
else {
ir_expression *offset_expr = ir->operands[1]->as_expression();
@@ -2210,27 +2211,25 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
/* Relative/variable index into constant buffer */
emit_asm(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), offset,
st_src_reg_for_int(4));
cbuf.reladdr = ralloc(mem_ctx, st_src_reg);
memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
}
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;
}
cbuf.swizzle = swizzle_for_size(ir->type->vector_elements);
if (glsl_base_type_is_64bit(cbuf.type))
cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 8,
const_offset % 16 / 8,
const_offset % 16 / 8,
const_offset % 16 / 8);
--
2.13.4
More information about the mesa-dev
mailing list