summaryrefslogtreecommitdiffstats
path: root/src/broadcom
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-03-19 11:39:58 -0700
committerEric Anholt <[email protected]>2019-03-21 14:20:50 -0700
commit320e96baced8093c6af11d86a216d83cee1eeb30 (patch)
treeccd26e9344f16640e17212171a4d4d558139da46 /src/broadcom
parentc36d2793ec79a8cee75953acbc87b621fbd25e49 (diff)
v3d: Move constant offsets to UBO addresses into the main uniform stream.
We'd end up with the constant offset in the uniform stream anyway, since they're bigger than small immediates. Avoids the extra uniforms and adds in the shader in favor of just adding once on the CPU. shader-db: total instructions in shared programs: 6496865 -> 6494851 (-0.03%) total uniforms in shared programs: 2119511 -> 2117243 (-0.11%)
Diffstat (limited to 'src/broadcom')
-rw-r--r--src/broadcom/compiler/nir_to_vir.c20
-rw-r--r--src/broadcom/compiler/v3d_compiler.h1
-rw-r--r--src/broadcom/compiler/vir_dump.c4
3 files changed, 16 insertions, 9 deletions
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index e2407f787c7..846a2a704af 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -219,6 +219,10 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
}
}
+ uint32_t const_offset = 0;
+ if (nir_src_is_const(instr->src[offset_src]))
+ const_offset = nir_src_as_uint(instr->src[offset_src]);
+
/* Make sure we won't exceed the 16-entry TMU fifo if each thread is
* storing at the same time.
*/
@@ -227,8 +231,6 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
struct qreg offset;
if (instr->intrinsic == nir_intrinsic_load_uniform) {
- offset = vir_uniform(c, QUNIFORM_UBO_ADDR, 0);
-
/* Find what variable in the default uniform block this
* uniform load is coming from.
*/
@@ -252,16 +254,19 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
c->next_ubo_dst_offset += range->size;
}
- base = base - range->src_offset + range->dst_offset;
+ const_offset += base - range->src_offset + range->dst_offset;
- if (base != 0)
- offset = vir_ADD(c, offset, vir_uniform_ui(c, base));
+ offset = vir_uniform(c, QUNIFORM_UBO_ADDR,
+ v3d_unit_data_create(0, const_offset));
+ const_offset = 0;
} else if (instr->intrinsic == nir_intrinsic_load_ubo) {
+ uint32_t index = nir_src_as_uint(instr->src[0]) + 1;
/* Note that QUNIFORM_UBO_ADDR takes a UBO index shifted up by
* 1 (0 is gallium's constant buffer 0).
*/
offset = vir_uniform(c, QUNIFORM_UBO_ADDR,
- nir_src_as_uint(instr->src[0]) + 1);
+ v3d_unit_data_create(index, const_offset));
+ const_offset = 0;
} else if (is_shared) {
/* Shared variables have no buffer index, and all start from a
* common base that we set up at the start of dispatch
@@ -295,8 +300,7 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
dest = vir_reg(QFILE_MAGIC, V3D_QPU_WADDR_TMUAU);
struct qinst *tmu;
- if (nir_src_is_const(instr->src[offset_src]) &&
- nir_src_as_uint(instr->src[offset_src]) == 0) {
+ if (nir_src_is_const(instr->src[offset_src]) && const_offset == 0) {
tmu = vir_MOV_dest(c, dest, offset);
} else {
tmu = vir_ADD_dest(c, dest,
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index 81307e0996f..d8d916fb14b 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -283,6 +283,7 @@ enum quniform_contents {
static inline uint32_t v3d_unit_data_create(uint32_t unit, uint32_t value)
{
+ assert(value < (1 << 24));
return unit << 24 | value;
}
diff --git a/src/broadcom/compiler/vir_dump.c b/src/broadcom/compiler/vir_dump.c
index be98539b0be..e8a2879fbe2 100644
--- a/src/broadcom/compiler/vir_dump.c
+++ b/src/broadcom/compiler/vir_dump.c
@@ -99,7 +99,9 @@ vir_dump_uniform(enum quniform_contents contents,
break;
case QUNIFORM_UBO_ADDR:
- fprintf(stderr, "ubo[%d]", data);
+ fprintf(stderr, "ubo[%d]+0x%x",
+ v3d_unit_data_get_unit(data),
+ v3d_unit_data_get_offset(data));
break;
case QUNIFORM_SSBO_OFFSET: