aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/gl_nir_lower_samplers_as_deref.c18
-rw-r--r--src/compiler/shader_info.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
index dde858f9cfc..a0a5f018ad7 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
@@ -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;
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 4510ce33fb6..19a963d62f3 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -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;