From 209820739bd3869b6c9464737525b4efae33b535 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 8 Feb 2016 17:42:07 -0800 Subject: [PATCH] nir/spirv: Set the vtn_mode and interface type for sampler parameters --- src/compiler/nir/spirv/vtn_cfg.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/spirv/vtn_cfg.c b/src/compiler/nir/spirv/vtn_cfg.c index 144aac315e5..6a43ef8b2dd 100644 --- a/src/compiler/nir/spirv/vtn_cfg.c +++ b/src/compiler/nir/spirv/vtn_cfg.c @@ -87,19 +87,36 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode, struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_access_chain); + struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type; + assert(b->func_param_idx < b->func->impl->num_params); nir_variable *param = b->func->impl->params[b->func_param_idx++]; + assert(param->type == type->type); + /* Name the parameter so it shows up nicely in NIR */ param->name = ralloc_strdup(param, val->name); struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable); - vtn_var->mode = vtn_variable_mode_param; - vtn_var->type = vtn_value(b, w[1], vtn_value_type_type)->type; + vtn_var->type = type; vtn_var->var = param; vtn_var->chain.var = vtn_var; vtn_var->chain.length = 0; + struct vtn_type *without_array = type; + while(glsl_type_is_array(without_array->type)) + without_array = without_array->array_element; + + if (glsl_type_is_image(without_array->type)) { + vtn_var->mode = vtn_variable_mode_image; + param->interface_type = without_array->type; + } else if (glsl_type_is_sampler(without_array->type)) { + vtn_var->mode = vtn_variable_mode_sampler; + param->interface_type = without_array->type; + } else { + vtn_var->mode = vtn_variable_mode_param; + } + val->access_chain = &vtn_var->chain; break; } -- 2.30.2