zink: fix dynamic bo lowering for ssbo stores
there are no piglit tests for this, so naturally it would not have worked fixes KHR-GL46.compute_shader.resources-max Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9113>
This commit is contained in:
parent
3955dd077b
commit
bc8e770856
|
@ -45,12 +45,10 @@ static nir_ssa_def *
|
|||
recursive_generate_bo_ssa_def(nir_builder *b, nir_intrinsic_instr *instr, nir_ssa_def *index, unsigned start, unsigned end)
|
||||
{
|
||||
if (start == end - 1) {
|
||||
/* block index src is 1 for this op */
|
||||
unsigned block_idx = instr->intrinsic == nir_intrinsic_store_ssbo;
|
||||
nir_intrinsic_instr *new_instr = nir_intrinsic_instr_create(b->shader, instr->intrinsic);
|
||||
new_instr->src[block_idx] = nir_src_for_ssa(nir_imm_int(b, start));
|
||||
new_instr->src[0] = nir_src_for_ssa(nir_imm_int(b, start));
|
||||
for (unsigned i = 0; i < nir_intrinsic_infos[instr->intrinsic].num_srcs; i++) {
|
||||
if (i != block_idx)
|
||||
if (i)
|
||||
nir_src_copy(&new_instr->src[i], &instr->src[i], &new_instr->instr);
|
||||
}
|
||||
if (instr->intrinsic != nir_intrinsic_load_ubo_vec4) {
|
||||
|
@ -59,10 +57,9 @@ recursive_generate_bo_ssa_def(nir_builder *b, nir_intrinsic_instr *instr, nir_ss
|
|||
nir_intrinsic_set_range(new_instr, nir_intrinsic_range(instr));
|
||||
}
|
||||
new_instr->num_components = instr->num_components;
|
||||
if (instr->intrinsic != nir_intrinsic_store_ssbo)
|
||||
nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
|
||||
nir_dest_num_components(instr->dest),
|
||||
nir_dest_bit_size(instr->dest), NULL);
|
||||
nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
|
||||
nir_dest_num_components(instr->dest),
|
||||
nir_dest_bit_size(instr->dest), NULL);
|
||||
nir_builder_instr_insert(b, &new_instr->instr);
|
||||
return &new_instr->dest.ssa;
|
||||
}
|
||||
|
@ -75,6 +72,24 @@ recursive_generate_bo_ssa_def(nir_builder *b, nir_intrinsic_instr *instr, nir_ss
|
|||
);
|
||||
}
|
||||
|
||||
static void
|
||||
generate_store_ssbo_ssa_def(nir_builder *b, nir_intrinsic_instr *instr, nir_ssa_def *index, unsigned start, unsigned end)
|
||||
{
|
||||
if (start == end - 1) {
|
||||
nir_intrinsic_instr *new_instr = nir_instr_as_intrinsic(nir_instr_clone(b->shader, &instr->instr));
|
||||
new_instr->src[1] = nir_src_for_ssa(nir_imm_int(b, start));
|
||||
nir_builder_instr_insert(b, &new_instr->instr);
|
||||
} else {
|
||||
int mid = start + (end - start) / 2;
|
||||
nir_ssa_def *mid_idx = nir_imm_int(b, mid);
|
||||
nir_push_if(b, nir_ilt(b, index, mid_idx));
|
||||
generate_store_ssbo_ssa_def(b, instr, index, start, mid);
|
||||
nir_push_else(b, NULL);
|
||||
generate_store_ssbo_ssa_def(b, instr, index, mid, end);
|
||||
nir_pop_if(b, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_dynamic_bo_access_instr(nir_intrinsic_instr *instr, nir_builder *b)
|
||||
{
|
||||
|
@ -105,18 +120,20 @@ lower_dynamic_bo_access_instr(nir_intrinsic_instr *instr, nir_builder *b)
|
|||
last_idx = first_idx + b->shader->info.num_ubos;
|
||||
}
|
||||
|
||||
/* now create the composite dest with a bcsel chain based on the original value */
|
||||
nir_ssa_def *new_dest = recursive_generate_bo_ssa_def(b, instr,
|
||||
instr->src[block_idx].ssa,
|
||||
first_idx, last_idx);
|
||||
if (instr->intrinsic != nir_intrinsic_store_ssbo) {
|
||||
/* now create the composite dest with a bcsel chain based on the original value */
|
||||
nir_ssa_def *new_dest = recursive_generate_bo_ssa_def(b, instr,
|
||||
instr->src[block_idx].ssa,
|
||||
first_idx, last_idx);
|
||||
|
||||
if (instr->intrinsic != nir_intrinsic_store_ssbo)
|
||||
/* now use the composite dest in all cases where the original dest (from the dynamic index)
|
||||
* was used and remove the dynamically-indexed load_*bo instruction
|
||||
*/
|
||||
nir_ssa_def_rewrite_uses_after(&instr->dest.ssa, nir_src_for_ssa(new_dest), &instr->instr);
|
||||
|
||||
} else
|
||||
generate_store_ssbo_ssa_def(b, instr, instr->src[block_idx].ssa, first_idx, last_idx);
|
||||
nir_instr_remove(&instr->instr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue