nir/spirv: Stop using glsl_type for function types
We're going to want the full vtn_type available to us anyway at which point glsl_type isn't really buying us anything. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
This commit is contained in:

committed by
Jason Ekstrand

parent
96f2439858
commit
ca62e849d3
@@ -423,7 +423,6 @@ vtn_type_copy(struct vtn_builder *b, struct vtn_type *src)
|
|||||||
case vtn_base_type_array:
|
case vtn_base_type_array:
|
||||||
case vtn_base_type_image:
|
case vtn_base_type_image:
|
||||||
case vtn_base_type_sampler:
|
case vtn_base_type_sampler:
|
||||||
case vtn_base_type_function:
|
|
||||||
/* Nothing more to do */
|
/* Nothing more to do */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -436,6 +435,11 @@ vtn_type_copy(struct vtn_builder *b, struct vtn_type *src)
|
|||||||
memcpy(dest->offsets, src->offsets,
|
memcpy(dest->offsets, src->offsets,
|
||||||
src->length * sizeof(src->offsets[0]));
|
src->length * sizeof(src->offsets[0]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case vtn_base_type_function:
|
||||||
|
dest->params = ralloc_array(b, struct vtn_type *, src->length);
|
||||||
|
memcpy(dest->params, src->params, src->length * sizeof(src->params[0]));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
@@ -840,18 +844,17 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||||||
|
|
||||||
case SpvOpTypeFunction: {
|
case SpvOpTypeFunction: {
|
||||||
val->type->base_type = vtn_base_type_function;
|
val->type->base_type = vtn_base_type_function;
|
||||||
|
val->type->type = NULL;
|
||||||
|
|
||||||
const struct glsl_type *return_type =
|
val->type->return_type = vtn_value(b, w[2], vtn_value_type_type)->type;
|
||||||
vtn_value(b, w[2], vtn_value_type_type)->type->type;
|
|
||||||
NIR_VLA(struct glsl_function_param, params, count - 3);
|
const unsigned num_params = count - 3;
|
||||||
|
val->type->length = num_params;
|
||||||
|
val->type->params = ralloc_array(b, struct vtn_type *, num_params);
|
||||||
for (unsigned i = 0; i < count - 3; i++) {
|
for (unsigned i = 0; i < count - 3; i++) {
|
||||||
params[i].type = vtn_value(b, w[i + 3], vtn_value_type_type)->type->type;
|
val->type->params[i] =
|
||||||
|
vtn_value(b, w[i + 3], vtn_value_type_type)->type;
|
||||||
/* FIXME: */
|
|
||||||
params[i].in = true;
|
|
||||||
params[i].out = true;
|
|
||||||
}
|
}
|
||||||
val->type->type = glsl_function_type(return_type, params, count - 3);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,36 +41,24 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_function);
|
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_function);
|
||||||
val->func = b->func;
|
val->func = b->func;
|
||||||
|
|
||||||
const struct glsl_type *func_type =
|
const struct vtn_type *func_type =
|
||||||
vtn_value(b, w[4], vtn_value_type_type)->type->type;
|
vtn_value(b, w[4], vtn_value_type_type)->type;
|
||||||
|
|
||||||
assert(glsl_get_function_return_type(func_type) == result_type);
|
assert(func_type->return_type->type == result_type);
|
||||||
|
|
||||||
nir_function *func =
|
nir_function *func =
|
||||||
nir_function_create(b->shader, ralloc_strdup(b->shader, val->name));
|
nir_function_create(b->shader, ralloc_strdup(b->shader, val->name));
|
||||||
|
|
||||||
func->num_params = glsl_get_length(func_type);
|
func->num_params = func_type->length;
|
||||||
func->params = ralloc_array(b->shader, nir_parameter, func->num_params);
|
func->params = ralloc_array(b->shader, nir_parameter, func->num_params);
|
||||||
for (unsigned i = 0; i < func->num_params; i++) {
|
for (unsigned i = 0; i < func->num_params; i++) {
|
||||||
const struct glsl_function_param *param =
|
func->params[i].type = func_type->params[i]->type;
|
||||||
glsl_get_function_param(func_type, i);
|
|
||||||
func->params[i].type = param->type;
|
/* TODO: We could do something smarter here. */
|
||||||
if (param->in) {
|
func->params[i].param_type = nir_parameter_inout;
|
||||||
if (param->out) {
|
|
||||||
func->params[i].param_type = nir_parameter_inout;
|
|
||||||
} else {
|
|
||||||
func->params[i].param_type = nir_parameter_in;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (param->out) {
|
|
||||||
func->params[i].param_type = nir_parameter_out;
|
|
||||||
} else {
|
|
||||||
assert(!"Parameter is neither in nor out");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func->return_type = glsl_get_function_return_type(func_type);
|
func->return_type = func_type->return_type->type;
|
||||||
|
|
||||||
b->func->impl = nir_function_impl_create(func);
|
b->func->impl = nir_function_impl_create(func);
|
||||||
|
|
||||||
|
@@ -271,6 +271,15 @@ struct vtn_type {
|
|||||||
/* Access qualifier for storage images */
|
/* Access qualifier for storage images */
|
||||||
SpvAccessQualifier access_qualifier;
|
SpvAccessQualifier access_qualifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Members for function types */
|
||||||
|
struct {
|
||||||
|
/* For functions, the vtn_type for each parameter */
|
||||||
|
struct vtn_type **params;
|
||||||
|
|
||||||
|
/* Return type for functions */
|
||||||
|
struct vtn_type *return_type;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user