[Mesa-dev] [PATCH] glsl: Fix function return typechecking

Tapani Pälli tapani.palli at intel.com
Thu Feb 21 09:43:55 UTC 2019



On 2/21/19 11:35 AM, Tapani Pälli wrote:
> Hi;
> 
> On 2/11/19 6:46 PM, Oscar Blumberg wrote:
>> apply_implicit_conversion only converts and check base types but we
>> need actual type equality for function returns, otherwise you can
>> return a vec2 from a function declared as returning a float.
> 
> Do you have some test shader that hits this condition? It seems to me 
> that currently we will error out correctly if one tries to return vec2 
> from function declared as returning a float.

Ah forget that, I can see it can happen with ARB_shading_language_420pack!

Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

>> ---
>>   src/compiler/glsl/ast_to_hir.cpp | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/compiler/glsl/ast_to_hir.cpp 
>> b/src/compiler/glsl/ast_to_hir.cpp
>> index 620153e6a34..6bf2910954f 100644
>> --- a/src/compiler/glsl/ast_to_hir.cpp
>> +++ b/src/compiler/glsl/ast_to_hir.cpp
>> @@ -6248,7 +6248,8 @@ ast_jump_statement::hir(exec_list *instructions,
>>               if (state->has_420pack()) {
>>                  if 
>> (!apply_implicit_conversion(state->current_function->return_type,
>> -                                              ret, state)) {
>> +                                              ret, state)
>> +                   || (ret->type != 
>> state->current_function->return_type)) {
>>                     _mesa_glsl_error(& loc, state,
>>                                      "could not implicitly convert 
>> return value "
>>                                      "to %s, in function `%s'",
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list