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:
@@ -109,6 +109,7 @@ struct ntt_compile {
|
|||||||
uint64_t centroid_inputs;
|
uint64_t centroid_inputs;
|
||||||
|
|
||||||
uint32_t first_ubo;
|
uint32_t first_ubo;
|
||||||
|
uint32_t first_ssbo;
|
||||||
|
|
||||||
struct ureg_src images[PIPE_MAX_SHADER_IMAGES];
|
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);
|
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++) {
|
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
|
/* XXX: nv50 uses the atomic flag to set caching for (lowered) atomic
|
||||||
* counters
|
* counters
|
||||||
*/
|
*/
|
||||||
bool atomic = false;
|
bool atomic = false;
|
||||||
ureg_DECL_buffer(c->ureg, i, atomic);
|
for (int i = 0; i < c->s->info.num_ssbos; ++i)
|
||||||
}
|
ureg_DECL_buffer(c->ureg, c->first_ssbo + i, atomic);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1886,7 +1896,8 @@ ntt_emit_mem(struct ntt_compile *c, nir_intrinsic_instr *instr,
|
|||||||
struct ureg_src memory;
|
struct ureg_src memory;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case nir_var_mem_ssbo:
|
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);
|
instr->src[is_store ? 1 : 0], 2);
|
||||||
next_src = 1;
|
next_src = 1;
|
||||||
break;
|
break;
|
||||||
|
@@ -36,6 +36,7 @@ struct nir_to_tgsi_options {
|
|||||||
/* Emit MAX(a,-a) instead of abs src modifier) */
|
/* Emit MAX(a,-a) instead of abs src modifier) */
|
||||||
bool lower_fabs;
|
bool lower_fabs;
|
||||||
bool unoptimized_ra;
|
bool unoptimized_ra;
|
||||||
|
bool lower_ssbo_bindings;
|
||||||
uint32_t ubo_vec4_max;
|
uint32_t ubo_vec4_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user