ntt: Separate image and sampler handling

Use nir_foreach_image_variable for images so we survive the coming
refactor where they get their own mode.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4743>
This commit is contained in:
Jason Ekstrand 2021-09-29 18:20:46 -05:00 committed by Marge Bot
parent 12b3ffe400
commit d84fd86af1
2 changed files with 22 additions and 18 deletions

View File

@ -471,8 +471,6 @@ static void
ntt_setup_uniforms(struct ntt_compile *c)
{
nir_foreach_uniform_variable(var, c->s) {
int image_count = glsl_type_get_image_count(var->type);
if (glsl_type_is_sampler(glsl_without_array(var->type))) {
/* Don't use this size for the check for samplers -- arrays of structs
* containing samplers should be ignored, and just the separate lowered
@ -490,20 +488,6 @@ ntt_setup_uniforms(struct ntt_compile *c)
target, ret_type, ret_type, ret_type, ret_type);
ureg_DECL_sampler(c->ureg, var->data.binding + i);
}
} else if (image_count) {
const struct glsl_type *itype = glsl_without_array(var->type);
enum tgsi_texture_type tex_type =
tgsi_texture_type_from_sampler_dim(glsl_get_sampler_dim(itype),
glsl_sampler_type_is_array(itype), false);
for (int i = 0; i < image_count; i++) {
c->images[var->data.binding] = ureg_DECL_image(c->ureg,
var->data.binding + i,
tex_type,
var->data.image.format,
!(var->data.access & ACCESS_NON_WRITEABLE),
false);
}
} else if (glsl_contains_atomic(var->type)) {
uint32_t offset = var->data.offset / 4;
uint32_t size = glsl_atomic_size(var->type) / 4;
@ -515,6 +499,23 @@ ntt_setup_uniforms(struct ntt_compile *c)
*/
}
nir_foreach_image_variable(var, c->s) {
int image_count = glsl_type_get_image_count(var->type);
const struct glsl_type *itype = glsl_without_array(var->type);
enum tgsi_texture_type tex_type =
tgsi_texture_type_from_sampler_dim(glsl_get_sampler_dim(itype),
glsl_sampler_type_is_array(itype), false);
for (int i = 0; i < image_count; i++) {
c->images[var->data.binding] = ureg_DECL_image(c->ureg,
var->data.binding + i,
tex_type,
var->data.image.format,
!(var->data.access & ACCESS_NON_WRITEABLE),
false);
}
}
c->first_ubo = ~0;
unsigned ubo_sizes[PIPE_MAX_CONSTANT_BUFFERS] = {0};

View File

@ -784,11 +784,14 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
info->indirect_files |= 1 << TGSI_FILE_OUTPUT;
}
uint32_t sampler_mask = 0, image_mask = 0;
uint32_t sampler_mask = 0;
nir_foreach_uniform_variable(var, nir) {
uint32_t sampler_count = glsl_type_get_sampler_count(var->type);
uint32_t image_count = glsl_type_get_image_count(var->type);
sampler_mask |= ((1ull << sampler_count) - 1) << var->data.binding;
}
uint32_t image_mask = 0;
nir_foreach_image_variable(var, nir) {
uint32_t image_count = glsl_type_get_image_count(var->type);
image_mask |= ((1ull << image_count) - 1) << var->data.binding;
}
info->num_outputs = num_outputs;