nir/glsl: gather bitmask of images used by program
In a similar fashion as commit f5c7df4dc9
does for textures.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4080>
This commit is contained in:
@@ -118,6 +118,21 @@ remove_struct_derefs_prep(nir_deref_instr **p, char **name,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
record_images_used(struct shader_info *info,
|
||||
nir_deref_instr *deref)
|
||||
{
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
|
||||
/* Structs have been lowered already, so get_aoa_size is sufficient. */
|
||||
const unsigned size =
|
||||
glsl_type_is_array(var->type) ? glsl_get_aoa_size(var->type) : 1;
|
||||
unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding;
|
||||
|
||||
info->images_used |= mask;
|
||||
}
|
||||
|
||||
|
||||
static nir_deref_instr *
|
||||
lower_deref(nir_builder *b, struct lower_samplers_as_deref_state *state,
|
||||
nir_deref_instr *deref)
|
||||
@@ -286,6 +301,9 @@ lower_intrinsic(nir_intrinsic_instr *instr,
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
nir_deref_instr *deref =
|
||||
lower_deref(b, state, nir_src_as_deref(instr->src[0]));
|
||||
|
||||
record_images_used(&state->shader->info, deref);
|
||||
|
||||
/* don't lower bindless: */
|
||||
if (!deref)
|
||||
return false;
|
||||
|
@@ -140,6 +140,9 @@ typedef struct shader_info {
|
||||
/** Bitfield of which textures are used by texelFetch() */
|
||||
uint32_t textures_used_by_txf;
|
||||
|
||||
/** Bitfield of which images are used */
|
||||
uint32_t images_used;
|
||||
|
||||
/* SPV_KHR_float_controls: execution mode for floating point ops */
|
||||
uint16_t float_controls_execution_mode;
|
||||
|
||||
|
@@ -889,6 +889,7 @@ st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir,
|
||||
if (prog) {
|
||||
prog->info.textures_used = nir->info.textures_used;
|
||||
prog->info.textures_used_by_txf = nir->info.textures_used_by_txf;
|
||||
prog->info.images_used = nir->info.images_used;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user