Commit 95927c41 authored by Neil Roberts's avatar Neil Roberts

glsl: Store the precision for a function return type

The precision for a function return type is now stored in
ir_function_signature. This will later be useful to implement mediump
to float16 lowering. In the meantime it is also useful to catch errors
where a function is redeclared with a different precision.
Reviewed-by: Timothy Arceri's avatarTimothy Arceri <tarceri@itsqueeze.com>
parent 3a7e92da
Pipeline #61091 passed with stages
in 23 minutes and 2 seconds
......@@ -6015,6 +6015,19 @@ ast_function::hir(exec_list *instructions,
name);
}
/* Get the precision for the return type */
unsigned return_precision;
if (state->es_shader) {
YYLTYPE loc = this->get_location();
return_precision =
select_gles_precision(this->return_type->qualifier.precision,
return_type,
state,
&loc);
} else {
return_precision = GLSL_PRECISION_NONE;
}
/* Create an ir_function if one doesn't already exist. */
f = state->symbols->get_function(name);
......@@ -6085,6 +6098,13 @@ ast_function::hir(exec_list *instructions,
"match prototype", name);
}
if (sig->return_precision != return_precision) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state, "function `%s' return type precision "
"doesn't match prototype", name);
}
if (sig->is_defined) {
if (is_definition) {
YYLTYPE loc = this->get_location();
......@@ -6129,6 +6149,7 @@ ast_function::hir(exec_list *instructions,
*/
if (sig == NULL) {
sig = new(ctx) ir_function_signature(return_type);
sig->return_precision = return_precision;
f->add_signature(sig);
}
......
......@@ -1804,6 +1804,7 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type,
builtin_available_predicate b)
: ir_instruction(ir_type_function_signature),
return_type(return_type), is_defined(false),
return_precision(GLSL_PRECISION_NONE),
intrinsic_id(ir_intrinsic_invalid), builtin_avail(b), _function(NULL)
{
this->origin = NULL;
......
......@@ -1222,7 +1222,7 @@ public:
/**
* Function return type.
*
* \note This discards the optional precision qualifier.
* \note The precision qualifier is stored separately in return_precision.
*/
const struct glsl_type *return_type;
......@@ -1237,6 +1237,13 @@ public:
/** Whether or not this function has a body (which may be empty). */
unsigned is_defined:1;
/*
* Precision qualifier for the return type.
*
* See the comment for ir_variable_data::precision for more details.
*/
unsigned return_precision:2;
/** Whether or not this function signature is a built-in. */
bool is_builtin() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment