Skip to content

Store the precision qualifier for the return type in the function signature

Neil Roberts requested to merge nroberts/mesa:function-return-precision into master

The precision qualifiers from GLSL ES do not form part of the glsl_type. Instead they are stored out-of-band in various places. For example for variables they are stored in ir_variable_data and for struct members they are stored in glsl_struct_field. The return type of a function is stored in ir_function_signature which previously didn’t have a place to store the precision. This patch adds that in.

This will eventually be useful when we want to take advantage of the mediump information to lower to float16 types (see MR1043). However I thought it might make sense as a separate MR because this patch is not specific to that approach to lowering. Rather it just extends the existing support for tracking precision qualifiers.

The patch additionally adds a compile check to verify that multiple declarations of the same function have the same return precision in addition to checking the return type. I think this is backed up by the following quote from GLSL ES 3.20 spec:

Only a precision qualifier is allowed on the return type of a function. […] If a function name is declared twice with the same parameter types, then the return types and all qualifiers must also match, and it is the same function being declared.

Merge request reports