ntt: add option to lower SSBO bindings to buffer index

When a shader uses SSBOs in various shader stages, then we have to track
the binding locations in order to be able to properly bind these SSBOs.

Therefore add a flag that enables adding the start index of the bindings to
the SSBO index.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21586>
This commit is contained in:
Gert Wollny
2023-02-27 17:15:45 +01:00
committed by Marge Bot
parent 1247b23f28
commit 99416624e5
2 changed files with 20 additions and 8 deletions

View File

@@ -109,6 +109,7 @@ struct ntt_compile {
uint64_t centroid_inputs;
uint32_t first_ubo;
uint32_t first_ssbo;
struct ureg_src images[PIPE_MAX_SHADER_IMAGES];
};
@@ -1049,13 +1050,22 @@ ntt_setup_uniforms(struct ntt_compile *c)
ureg_DECL_constant2D(c->ureg, 0, DIV_ROUND_UP(ubo_sizes[i], 16) - 1, i);
}
for (int i = 0; i < c->s->info.num_ssbos; i++) {
/* XXX: nv50 uses the atomic flag to set caching for (lowered) atomic
* counters
*/
bool atomic = false;
ureg_DECL_buffer(c->ureg, i, atomic);
}
if (c->options->lower_ssbo_bindings) {
c->first_ssbo = 255;
nir_foreach_variable_with_modes(var, c->s, nir_var_mem_ssbo) {
if (c->first_ssbo > var->data.binding)
c->first_ssbo = var->data.binding;
}
} else
c->first_ssbo = 0;
/* XXX: nv50 uses the atomic flag to set caching for (lowered) atomic
* counters
*/
bool atomic = false;
for (int i = 0; i < c->s->info.num_ssbos; ++i)
ureg_DECL_buffer(c->ureg, c->first_ssbo + i, atomic);
}
static void
@@ -1886,7 +1896,8 @@ ntt_emit_mem(struct ntt_compile *c, nir_intrinsic_instr *instr,
struct ureg_src memory;
switch (mode) {
case nir_var_mem_ssbo:
memory = ntt_ureg_src_indirect(c, ureg_src_register(TGSI_FILE_BUFFER, 0),
memory = ntt_ureg_src_indirect(c, ureg_src_register(TGSI_FILE_BUFFER,
c->first_ssbo),
instr->src[is_store ? 1 : 0], 2);
next_src = 1;
break;