[Mesa-dev] [PATCH] glsl: produce a linker error for a subroutine uniform with no functions.

Timothy Arceri timothy.arceri at collabora.com
Mon May 16 23:55:13 UTC 2016


On Fri, 2016-05-06 at 11:38 +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> If a subroutine uniform is declared with no functions backing it,
> that isn't legal, so we should fail to link.
> 
> Fixes:
> GL43-CTS.shader_subroutine.subroutine_uniform_wo_matching_subroutines
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/glsl/linker.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/compiler/glsl/linker.cpp
> b/src/compiler/glsl/linker.cpp
> index 9c72478..daf9016 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -3056,6 +3056,10 @@ link_calculate_subroutine_compat(struct
> gl_shader_program *prog)
>              continue;
>  
>           count = 0;
> +         if (sh->NumSubroutineFunctions == 0) {
> +            linker_error(prog, "subroutine uniform %s defined but no
> valid functions found\n", uni->type->name);
> +            continue;
> +         }

This will work if there are 0 functions defined but not if there is a
function of a different type to the one we are looking for.

Shouldn't we just check if count is 0 after the following for loop?



>           for (unsigned f = 0; f < sh->NumSubroutineFunctions; f++) {
>              struct gl_subroutine_function *fn = &sh-
> >SubroutineFunctions[f];
>              for (int k = 0; k < fn->num_compat_types; k++) {


More information about the mesa-dev mailing list