Mesa (master): i965/fs: Conditionalize constant-index UBO load code and add comments.
Eric Anholt
anholt at kemper.freedesktop.org
Wed Dec 5 01:13:09 UTC 2012
Module: Mesa
Branch: master
Commit: 67d9e7b5816a7643220c854ea1ed330f8363a3e0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=67d9e7b5816a7643220c854ea1ed330f8363a3e0
Author: Eric Anholt <eric at anholt.net>
Date: Thu Nov 8 15:55:36 2012 -0800
i965/fs: Conditionalize constant-index UBO load code and add comments.
I wanted to separate this step for easier reviewing when I add the
variable-index case next.
---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 61 ++++++++++++++------------
1 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 7a91353..9fe1b86 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -551,38 +551,43 @@ fs_visitor::visit(ir_expression *ir)
break;
case ir_binop_ubo_load:
+ /* This IR node takes a constant uniform block and a constant or
+ * variable byte offset within the block and loads a vector from that.
+ */
ir_constant *uniform_block = ir->operands[0]->as_constant();
- ir_constant *offset = ir->operands[1]->as_constant();
-
- fs_reg packed_consts = fs_reg(this, glsl_type::float_type);
- packed_consts.type = result.type;
+ ir_constant *const_offset = ir->operands[1]->as_constant();
fs_reg surf_index = fs_reg((unsigned)SURF_INDEX_WM_UBO(uniform_block->value.u[0]));
- fs_inst *pull = emit(fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD,
- packed_consts,
- surf_index,
- fs_reg(offset->value.u[0])));
- pull->base_mrf = 14;
- pull->mlen = 1;
-
- packed_consts.smear = offset->value.u[0] % 16 / 4;
- for (int i = 0; i < ir->type->vector_elements; i++) {
- /* UBO bools are any nonzero value. We consider bools to be
- * values with the low bit set to 1. Convert them using CMP.
- */
- if (ir->type->base_type == GLSL_TYPE_BOOL) {
- emit(CMP(result, packed_consts, fs_reg(0u), BRW_CONDITIONAL_NZ));
- } else {
- emit(MOV(result, packed_consts));
+ if (const_offset) {
+ fs_reg packed_consts = fs_reg(this, glsl_type::float_type);
+ packed_consts.type = result.type;
+ fs_inst *pull = emit(fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD,
+ packed_consts,
+ surf_index,
+ fs_reg(const_offset->value.u[0])));
+ pull->base_mrf = 14;
+ pull->mlen = 1;
+
+ packed_consts.smear = const_offset->value.u[0] % 16 / 4;
+ for (int i = 0; i < ir->type->vector_elements; i++) {
+ /* UBO bools are any nonzero value. We consider bools to be
+ * values with the low bit set to 1. Convert them using CMP.
+ */
+ if (ir->type->base_type == GLSL_TYPE_BOOL) {
+ emit(CMP(result, packed_consts, fs_reg(0u), BRW_CONDITIONAL_NZ));
+ } else {
+ emit(MOV(result, packed_consts));
+ }
+
+ packed_consts.smear++;
+ result.reg_offset++;
+
+ /* The std140 packing rules don't allow vectors to cross 16-byte
+ * boundaries, and a reg is 32 bytes.
+ */
+ assert(packed_consts.smear < 8);
}
-
- packed_consts.smear++;
- result.reg_offset++;
-
- /* The std140 packing rules don't allow vectors to cross 16-byte
- * boundaries, and a reg is 32 bytes.
- */
- assert(packed_consts.smear < 8);
}
+
result.reg_offset = 0;
break;
}
More information about the mesa-commit
mailing list