diff options
author | Kenneth Graunke <[email protected]> | 2018-12-27 01:27:44 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-21 10:26:11 -0800 |
commit | 7e35333c731385b9ee5eba47fa5b8a60a96534af (patch) | |
tree | d3e4a3cda9815a682f6392f1930f0f4d74b1208c /src/gallium/drivers | |
parent | bc3bb2864503d85d5ccdbe552178a57ab9bf20b2 (diff) |
iris: Don't make duplicate system values
We were relying on CSE/GVN/etc to coalesce all intrinsics that load the
same value, but that's a bad idea. We might have a couple intrinsics
that reload the same value. If so, we only want to set up the uniform
on the first one we see.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/iris/iris_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_program.c | 29 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 7c5faee668f..ad7cfdb7b90 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -46,6 +46,7 @@ struct blorp_params; #define IRIS_MAX_ABOS 16 #define IRIS_MAX_SSBOS 16 #define IRIS_MAX_VIEWPORTS 16 +#define IRIS_MAX_CLIP_PLANES 8 /** * Dirty flags. When state changes, we flag some combination of these diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 95c56a11748..b8929be9b72 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -601,6 +601,10 @@ iris_setup_uniforms(const struct brw_compiler *compiler, rzalloc_array(mem_ctx, enum brw_param_builtin, IRIS_MAX_SYSTEM_VALUES); unsigned num_system_values = 0; + unsigned patch_vert_idx = -1; + unsigned ucp_idx[IRIS_MAX_CLIP_PLANES]; + memset(ucp_idx, -1, sizeof(ucp_idx)); + nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_builder b; @@ -616,30 +620,41 @@ iris_setup_uniforms(const struct brw_compiler *compiler, continue; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - - unsigned idx = num_system_values; + nir_ssa_def *offset; switch (intrin->intrinsic) { case nir_intrinsic_load_user_clip_plane: { unsigned ucp = nir_intrinsic_ucp_id(intrin); + + if (ucp_idx[ucp] == -1) { + ucp_idx[ucp] = num_system_values; + num_system_values += 4; + } + for (int i = 0; i < 4; i++) { - system_values[num_system_values++] = + system_values[ucp_idx[ucp] + i] = BRW_PARAM_BUILTIN_CLIP_PLANE(ucp, i); } + + b.cursor = nir_before_instr(instr); + offset = nir_imm_int(&b, ucp_idx[ucp] * sizeof(uint32_t)); break; } case nir_intrinsic_load_patch_vertices_in: - system_values[num_system_values++] = + if (patch_vert_idx == -1) + patch_vert_idx = num_system_values++; + + system_values[patch_vert_idx] = BRW_PARAM_BUILTIN_PATCH_VERTICES_IN; + + b.cursor = nir_before_instr(instr); + offset = nir_imm_int(&b, patch_vert_idx * sizeof(uint32_t)); break; default: continue; } - b.cursor = nir_before_instr(instr); - unsigned comps = nir_intrinsic_dest_components(intrin); - nir_ssa_def *offset = nir_imm_int(&b, idx * sizeof(uint32_t)); nir_intrinsic_instr *load = nir_intrinsic_instr_create(nir, nir_intrinsic_load_ubo); |