diff options
author | Timothy Arceri <[email protected]> | 2020-01-07 13:43:05 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2020-01-10 00:41:20 +0000 |
commit | 726e8f24c6eefe5b2d77fe0dbfd9d7c89fc224f4 (patch) | |
tree | 3cfaea34315a1ecfacb6a5fc4dfb8a623bc54736 /src/compiler/glsl/linker_util.cpp | |
parent | c60d0bd92f1a141d48e8c3db66b3b257ee890c23 (diff) |
glsl: move calculate_subroutine_compat() to shared linker code
We will make use of this in the nir linker in the following patch.
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/compiler/glsl/linker_util.cpp')
-rw-r--r-- | src/compiler/glsl/linker_util.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/compiler/glsl/linker_util.cpp b/src/compiler/glsl/linker_util.cpp index bd4043df2db..80c9f2872f9 100644 --- a/src/compiler/glsl/linker_util.cpp +++ b/src/compiler/glsl/linker_util.cpp @@ -22,6 +22,7 @@ * */ #include "main/mtypes.h" +#include "glsl_types.h" #include "linker_util.h" #include "util/bitscan.h" #include "util/set.h" @@ -250,3 +251,39 @@ link_util_check_uniform_resources(struct gl_context *ctx, } } } + +void +link_util_calculate_subroutine_compat(struct gl_shader_program *prog) +{ + unsigned mask = prog->data->linked_stages; + while (mask) { + const int i = u_bit_scan(&mask); + struct gl_program *p = prog->_LinkedShaders[i]->Program; + + for (unsigned j = 0; j < p->sh.NumSubroutineUniformRemapTable; j++) { + if (p->sh.SubroutineUniformRemapTable[j] == INACTIVE_UNIFORM_EXPLICIT_LOCATION) + continue; + + struct gl_uniform_storage *uni = p->sh.SubroutineUniformRemapTable[j]; + + if (!uni) + continue; + + int count = 0; + if (p->sh.NumSubroutineFunctions == 0) { + linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name); + continue; + } + for (unsigned f = 0; f < p->sh.NumSubroutineFunctions; f++) { + struct gl_subroutine_function *fn = &p->sh.SubroutineFunctions[f]; + for (int k = 0; k < fn->num_compat_types; k++) { + if (fn->types[k] == uni->type) { + count++; + break; + } + } + } + uni->num_compatible_subroutines = count; + } + } +} |