Commit a4f06b35 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋 Committed by Marge Bot

zink: expand ntv array derefs to track image derefs

this is sort of what we should be moving towards for io as well at some point,
the gist of the change here being that when images are deref'd, we need
to be able to do a lookup on the deref store later on in order to get the
image back
Reviewed-by: Erik Faye-Lund 's avatarErik Faye-Lund <>
Part-of: <!8504>
parent 77b6b3eb
......@@ -2714,19 +2714,46 @@ emit_deref_array(struct ntv_context *ctx, nir_deref_instr *deref)
nir_variable *var = nir_deref_instr_get_variable(deref);
SpvStorageClass storage_class = get_storage_class(var);
SpvId base, type;
switch (var->data.mode) {
case nir_var_shader_in:
case nir_var_shader_out:
base = get_src(ctx, &deref->parent);
type = get_glsl_type(ctx, deref->type);
case nir_var_uniform: {
struct hash_entry *he = _mesa_hash_table_search(ctx->vars, var);
base = (SpvId)(intptr_t)he->data;
type = ctx->image_types[var->data.binding];
unreachable("Unsupported nir_variable_mode\n");
SpvId index = get_src(ctx, &deref->arr.index);
SpvId ptr_type = spirv_builder_type_pointer(&ctx->builder,
get_glsl_type(ctx, deref->type));
SpvId result = spirv_builder_emit_access_chain(&ctx->builder,
get_src(ctx, &deref->parent),
&index, 1);
/* uint is a bit of a lie here, it's really just an opaque type */
store_dest(ctx, &deref->dest, result, nir_type_uint);
/* image ops always need to be able to get the variable to check out sampler types and such */
if (glsl_type_is_image(glsl_without_array(var->type))) {
uint32_t *key = ralloc_size(ctx->mem_ctx, sizeof(uint32_t));
*key = result;
_mesa_hash_table_insert(ctx->image_vars, key, var);
static void
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment