nir/spirv: Set the vtn_mode and interface type for sampler parameters
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 9 Feb 2016 01:42:07 +0000 (17:42 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 9 Feb 2016 18:29:05 +0000 (10:29 -0800)
src/compiler/nir/spirv/vtn_cfg.c

index 144aac315e501f239b7bbb07c0e4bfb4e45eb530..6a43ef8b2dd92853c0ac6921cdee6736f78f67d9 100644 (file)
@@ -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;
    }