summaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-06-05 15:15:07 -0700
committerEric Anholt <[email protected]>2019-06-24 14:23:07 -0700
commit5c4289dd4b3f37bc5b23b24069ee1137a6c1fa32 (patch)
tree534ef272616b73aac2f5d0a2338220ef9907052f /src/freedreno
parent852704976aa9b8ddbdc4fee83b95612f88189668 (diff)
freedreno: Only upload the used part of UBO0 to the constant buffer.
We were pessimistically uploading all of it in case of indirection, but we can just bump that when we encounter indirection. total constlen in shared programs: 2529623 -> 2485933 (-1.73%) Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/ir3/ir3_compiler_nir.c3
-rw-r--r--src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c15
2 files changed, 13 insertions, 5 deletions
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index e453f33fb91..d84c56b0195 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -1262,7 +1262,8 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
* since we don't know in the assembler what the max
* addr reg value can be:
*/
- ctx->so->constlen = MAX2(ctx->so->constlen, ctx->s->num_uniforms);
+ ctx->so->constlen = MAX2(ctx->so->constlen,
+ ctx->so->shader->ubo_state.size / 16);
}
break;
case nir_intrinsic_load_ubo:
diff --git a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
index 46216a6f862..b3191a36c14 100644
--- a/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
+++ b/src/freedreno/ir3/ir3_nir_analyze_ubo_ranges.c
@@ -42,14 +42,22 @@ get_ubo_load_range(nir_intrinsic_instr *instr)
}
static void
-gather_ubo_ranges(nir_intrinsic_instr *instr,
+gather_ubo_ranges(nir_shader *nir, nir_intrinsic_instr *instr,
struct ir3_ubo_analysis_state *state)
{
if (!nir_src_is_const(instr->src[0]))
return;
- if (!nir_src_is_const(instr->src[1]))
+ if (!nir_src_is_const(instr->src[1])) {
+ if (nir_src_as_uint(instr->src[0]) == 0) {
+ /* If this is an indirect on UBO 0, we'll still lower it back to
+ * load_uniform. Set the range to cover all of UBO 0.
+ */
+ state->range[0].end = align(nir->num_uniforms * 16, 16 * 4);
+ }
+
return;
+ }
const struct ir3_ubo_range r = get_ubo_load_range(instr);
const uint32_t block = nir_src_as_uint(instr->src[0]);
@@ -132,7 +140,6 @@ ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader *shader)
struct ir3_ubo_analysis_state *state = &shader->ubo_state;
memset(state, 0, sizeof(*state));
- state->range[0].end = align(nir->num_uniforms * 16, 16 * 4); /* align to 4*vec4 */
nir_foreach_function(function, nir) {
if (function->impl) {
@@ -140,7 +147,7 @@ ir3_nir_analyze_ubo_ranges(nir_shader *nir, struct ir3_shader *shader)
nir_foreach_instr(instr, block) {
if (instr->type == nir_instr_type_intrinsic &&
nir_instr_as_intrinsic(instr)->intrinsic == nir_intrinsic_load_ubo)
- gather_ubo_ranges(nir_instr_as_intrinsic(instr), state);
+ gather_ubo_ranges(nir, nir_instr_as_intrinsic(instr), state);
}
}
}