summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-02-08 17:42:07 -0800
committerJason Ekstrand <[email protected]>2016-02-09 10:29:05 -0800
commit209820739bd3869b6c9464737525b4efae33b535 (patch)
treed02c0d9228233735ca3a123805064bf70ae7c1b2 /src/compiler/nir
parentde6c9c5f2e1e975d06e4d27cefc6af9ae53d75a7 (diff)
nir/spirv: Set the vtn_mode and interface type for sampler parameters
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/spirv/vtn_cfg.c21
1 files 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;
}