From: Jason Ekstrand Date: Tue, 9 Feb 2016 01:42:07 +0000 (-0800) Subject: nir/spirv: Set the vtn_mode and interface type for sampler parameters X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=209820739bd3869b6c9464737525b4efae33b535;p=mesa.git nir/spirv: Set the vtn_mode and interface type for sampler parameters --- 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; }