aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorTapani Pälli <[email protected]>2020-02-19 08:33:04 +0200
committerMarge Bot <[email protected]>2020-03-16 10:34:21 +0000
commit5910c938a293c03337911ca3c067b4ecf4b406ee (patch)
tree5b98278386212836a29eccd3f4615a20e2f70f04 /src/compiler
parent51b1b102bd619b6a802807bde5f5228c1dabd1d7 (diff)
nir/glsl: gather bitmask of images used by program
In a similar fashion as commit f5c7df4dc95 does for textures. Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4080>
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;