mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
i965/fs: Use a single instance of the pull_constant_loc[] array.
Now that we don't renumber uniform registers, assign_constant_locations and move_uniform_array_access_to_pull_constants use the same names. So, they can share a single copy of the pull_constant_loc[] array. This simplifies the code considerably. assign_constant_locations() doesn't need to walk through pull_params[] to rediscover reladdr demotions; it just has that information in pull_constant_loc[]. We also only need to rewrite the instruction stream once, instead of twice. Even better, we now have a single array describing the layout of all pull parameters, which we can pass to the SIMD16 program. This actually hurts a few shaders in Serious Sam 3, and one in KWin: total instructions in shared programs: 1841957 -> 1842035 (0.00%) instructions in affected programs: 1165 -> 1243 (6.70%) Comparing dump_instructions() before and after the pull constant transformations with and without this patch, it appears that there is a uniform array with variable indexing (reladdr) and constant indexing (of array element 0). Previously, we uploaded array element 0 as both a pull constant (for reladdr) /and/ a push constant. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
542f2e47f2
commit
229319e0f0
2 changed files with 6 additions and 28 deletions
|
|
@ -1786,10 +1786,6 @@ fs_visitor::move_uniform_array_access_to_pull_constants()
|
|||
}
|
||||
}
|
||||
}
|
||||
demote_pull_constants(true);
|
||||
|
||||
ralloc_free(pull_constant_loc);
|
||||
pull_constant_loc = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1836,9 +1832,6 @@ fs_visitor::assign_constant_locations()
|
|||
unsigned int num_push_constants = 0;
|
||||
|
||||
push_constant_loc = ralloc_array(mem_ctx, int, uniforms);
|
||||
pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
|
||||
for (unsigned int i = 0; i < uniforms; i++)
|
||||
pull_constant_loc[i] = -1;
|
||||
|
||||
for (unsigned int i = 0; i < uniforms; i++) {
|
||||
if (!is_live[i] || pull_constant_loc[i] != -1) {
|
||||
|
|
@ -1858,20 +1851,9 @@ fs_visitor::assign_constant_locations()
|
|||
/* Demote to a pull constant. */
|
||||
push_constant_loc[i] = -1;
|
||||
|
||||
/* If our constant is already being uploaded for reladdr purposes,
|
||||
* reuse it.
|
||||
*/
|
||||
for (unsigned int j = 0; j < stage_prog_data->nr_pull_params; j++) {
|
||||
if (stage_prog_data->pull_param[j] == stage_prog_data->param[i]) {
|
||||
pull_constant_loc[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pull_constant_loc[i] == -1) {
|
||||
int pull_index = stage_prog_data->nr_pull_params++;
|
||||
stage_prog_data->pull_param[pull_index] = stage_prog_data->param[i];
|
||||
pull_constant_loc[i] = pull_index;
|
||||
}
|
||||
int pull_index = stage_prog_data->nr_pull_params++;
|
||||
stage_prog_data->pull_param[pull_index] = stage_prog_data->param[i];
|
||||
pull_constant_loc[i] = pull_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1890,8 +1872,6 @@ fs_visitor::assign_constant_locations()
|
|||
assert(remapped <= i);
|
||||
stage_prog_data->param[remapped] = stage_prog_data->param[i];
|
||||
}
|
||||
|
||||
demote_pull_constants(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1899,7 +1879,7 @@ fs_visitor::assign_constant_locations()
|
|||
* or VARYING_PULL_CONSTANT_LOAD instructions which load values into VGRFs.
|
||||
*/
|
||||
void
|
||||
fs_visitor::demote_pull_constants(bool reladdr_only)
|
||||
fs_visitor::demote_pull_constants()
|
||||
{
|
||||
foreach_list(node, &this->instructions) {
|
||||
fs_inst *inst = (fs_inst *)node;
|
||||
|
|
@ -1920,9 +1900,6 @@ fs_visitor::demote_pull_constants(bool reladdr_only)
|
|||
fs_reg surf_index(stage_prog_data->binding_table.pull_constants_start);
|
||||
fs_reg dst = fs_reg(this, glsl_type::float_type);
|
||||
|
||||
if (reladdr_only != (inst->src[i].reladdr != NULL))
|
||||
continue;
|
||||
|
||||
/* Generate a pull load into dst. */
|
||||
if (inst->src[i].reladdr) {
|
||||
exec_list list = VARYING_PULL_CONSTANT_LOAD(dst,
|
||||
|
|
@ -3382,6 +3359,7 @@ fs_visitor::run()
|
|||
|
||||
move_uniform_array_access_to_pull_constants();
|
||||
assign_constant_locations();
|
||||
demote_pull_constants();
|
||||
|
||||
opt_drop_redundant_mov_to_flags();
|
||||
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ public:
|
|||
void compact_virtual_grfs();
|
||||
void move_uniform_array_access_to_pull_constants();
|
||||
void assign_constant_locations();
|
||||
void demote_pull_constants(bool reladdr_only);
|
||||
void demote_pull_constants();
|
||||
void invalidate_live_intervals();
|
||||
void calculate_live_intervals();
|
||||
void calculate_register_pressure();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue