aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/spirv/spirv_to_nir.c4
-rw-r--r--src/compiler/spirv/vtn_cfg.c56
-rw-r--r--src/compiler/spirv/vtn_variables.c2
3 files changed, 34 insertions, 28 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 462b0494f96..1743d8915a1 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -185,10 +185,6 @@ vtn_ssa_value(struct vtn_builder *b, uint32_t value_id)
case vtn_value_type_ssa:
return val->ssa;
- case vtn_value_type_pointer:
- /* This is needed for function parameters */
- return vtn_variable_load(b, val->pointer);
-
default:
unreachable("Invalid type for an SSA value");
}
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index c1677b49aaa..df54b3c4851 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -65,6 +65,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
func->return_type = func_type->return_type->type;
b->func->impl = nir_function_impl_create(func);
+ b->nb.cursor = nir_before_cf_list(&b->func->impl->body);
b->func_param_idx = 0;
break;
@@ -77,40 +78,47 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvOpFunctionParameter: {
struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
- if (type->base_type == vtn_base_type_pointer) {
- type = type->deref;
- assert(type->base_type != vtn_base_type_pointer);
- }
assert(b->func_param_idx < b->func->impl->num_params);
nir_variable *param = b->func->impl->params[b->func_param_idx++];
- assert(type->type == param->type);
+ if (type->base_type == vtn_base_type_pointer) {
+ struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable);
+ vtn_var->type = type->deref;
+ vtn_var->var = param;
+
+ assert(vtn_var->type->type == param->type);
+
+ struct vtn_type *without_array = vtn_var->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;
+ }
- struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable);
- vtn_var->type = type;
- vtn_var->var = param;
+ struct vtn_value *val =
+ vtn_push_value(b, w[2], vtn_value_type_pointer);
- struct vtn_type *without_array = type;
- while(glsl_type_is_array(without_array->type))
- without_array = without_array->array_element;
+ /* Name the parameter so it shows up nicely in NIR */
+ param->name = ralloc_strdup(param, val->name);
- 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;
+ val->pointer = vtn_pointer_for_variable(b, vtn_var, type);
} else {
- vtn_var->mode = vtn_variable_mode_param;
- }
+ /* We're a regular SSA value. */
+ struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_ssa);
- struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
+ /* Name the parameter so it shows up nicely in NIR */
+ param->name = ralloc_strdup(param, val->name);
- /* Name the parameter so it shows up nicely in NIR */
- param->name = ralloc_strdup(param, val->name);
-
- val->pointer = vtn_pointer_for_variable(b, vtn_var, NULL);
+ val->ssa = vtn_local_load(b, nir_deref_var_create(b, param));
+ }
break;
}
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 1ff7427ffb9..5af27bfdb11 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -233,6 +233,8 @@ vtn_pointer_for_variable(struct vtn_builder *b,
pointer->mode = var->mode;
pointer->type = var->type;
+ assert(ptr_type->base_type == vtn_base_type_pointer);
+ assert(ptr_type->deref->type == var->type->type);
pointer->ptr_type = ptr_type;
pointer->var = var;