[Mesa-dev] [PATCH 03/58] glsl: use linked_shaders bitmask to iterate stages for subroutine fields
Emil Velikov
emil.l.velikov at gmail.com
Tue Nov 22 18:49:11 UTC 2016
On 20 November 2016 at 13:28, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> @@ -3134,11 +3134,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
> static void
> link_calculate_subroutine_compat(struct gl_shader_program *prog)
> {
> - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> + unsigned mask = prog->data->linked_stages;
> + while (mask) {
> + const int i = u_bit_scan(&mask);
> struct gl_linked_shader *sh = prog->_LinkedShaders[i];
> - int count;
> - if (!sh)
> - continue;
>
> for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
> if (sh->SubroutineUniformRemapTable[j] == INACTIVE_UNIFORM_EXPLICIT_LOCATION)
> @@ -3150,7 +3149,7 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
> continue;
>
> sh->NumSubroutineUniforms++;
> - count = 0;
> + int count = 0;
Nit: Maybe leave this as-is ?
> if (sh->NumSubroutineFunctions == 0) {
> linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
> continue;
> @@ -3172,7 +3171,9 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
> static void
> check_subroutine_resources(struct gl_shader_program *prog)
> {
> - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> + unsigned mask = prog->data->linked_stages;
> + while (mask) {
> + const int i = u_bit_scan(&mask);
> struct gl_linked_shader *sh = prog->_LinkedShaders[i];
>
> if (sh) {
Fold this "always true" conditional ?
> @@ -3374,7 +3375,9 @@ check_explicit_uniform_locations(struct gl_context *ctx,
> }
>
> unsigned entries_total = 0;
> - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> + unsigned mask = prog->data->linked_stages;
> + while (mask) {
> + const int i = u_bit_scan(&mask);
> struct gl_linked_shader *sh = prog->_LinkedShaders[i];
>
> if (!sh)
Drop this if block.
-Emil
More information about the mesa-dev
mailing list