[Mesa-dev] [PATCH v2 1/2] mesa: Map program UBOs and SSBOs to Interface Blocks

Iago Toral itoral at igalia.com
Mon Jan 4 00:27:02 PST 2016


On Thu, 2015-12-31 at 11:20 -0800, Jordan Justen wrote:
> v2:
>  * Fill UboInterfaceBlockIndex and SsboInterfaceBlockIndex in
>    split_ubos_and_ssbos (Iago)
> 
> Cc: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> Cc: Iago Toral <itoral at igalia.com>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

> ---
>  src/glsl/linker.cpp                 | 30 +++++++++++++++++++++++++-----
>  src/glsl/standalone_scaffolding.cpp |  5 +++++
>  src/mesa/main/mtypes.h              |  7 +++++++
>  3 files changed, 37 insertions(+), 5 deletions(-)
> 
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index a6e81b4..367ae26 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -3942,8 +3942,10 @@ split_ubos_and_ssbos(void *mem_ctx,
>                       unsigned num_blocks,
>                       struct gl_uniform_block ***ubos,
>                       unsigned *num_ubos,
> +                     unsigned **ubo_interface_block_indices,
>                       struct gl_uniform_block ***ssbos,
> -                     unsigned *num_ssbos)
> +                     unsigned *num_ssbos,
> +                     unsigned **ssbo_interface_block_indices)
>  {
>     unsigned num_ubo_blocks = 0;
>     unsigned num_ssbo_blocks = 0;
> @@ -3961,11 +3963,25 @@ split_ubos_and_ssbos(void *mem_ctx,
>     *ssbos = ralloc_array(mem_ctx, gl_uniform_block *, num_ssbo_blocks);
>     *num_ssbos = 0;
>  
> +   if (ubo_interface_block_indices)
> +      *ubo_interface_block_indices =
> +         ralloc_array(mem_ctx, unsigned, num_ubo_blocks);
> +
> +   if (ssbo_interface_block_indices)
> +      *ssbo_interface_block_indices =
> +         ralloc_array(mem_ctx, unsigned, num_ssbo_blocks);
> +
>     for (unsigned i = 0; i < num_blocks; i++) {
>        if (blocks[i].IsShaderStorage) {
> -         (*ssbos)[(*num_ssbos)++] = &blocks[i];
> +         (*ssbos)[*num_ssbos] = &blocks[i];
> +         if (ssbo_interface_block_indices)
> +            (*ssbo_interface_block_indices)[*num_ssbos] = i;
> +         (*num_ssbos)++;
>        } else {
> -         (*ubos)[(*num_ubos)++] = &blocks[i];
> +         (*ubos)[*num_ubos] = &blocks[i];
> +         if (ubo_interface_block_indices)
> +            (*ubo_interface_block_indices)[*num_ubos] = i;
> +         (*num_ubos)++;
>        }
>     }
>  
> @@ -4577,8 +4593,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
>                                sh->NumBufferInterfaceBlocks,
>                                &sh->UniformBlocks,
>                                &sh->NumUniformBlocks,
> +                              NULL,
>                                &sh->ShaderStorageBlocks,
> -                              &sh->NumShaderStorageBlocks);
> +                              &sh->NumShaderStorageBlocks,
> +                              NULL);
>        }
>     }
>  
> @@ -4587,8 +4605,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
>                          prog->NumBufferInterfaceBlocks,
>                          &prog->UniformBlocks,
>                          &prog->NumUniformBlocks,
> +                        &prog->UboInterfaceBlockIndex,
>                          &prog->ShaderStorageBlocks,
> -                        &prog->NumShaderStorageBlocks);
> +                        &prog->NumShaderStorageBlocks,
> +                        &prog->SsboInterfaceBlockIndex);
>  
>     /* FINISHME: Assign fragment shader output locations. */
>  
> diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
> index e350f70..d5d214b 100644
> --- a/src/glsl/standalone_scaffolding.cpp
> +++ b/src/glsl/standalone_scaffolding.cpp
> @@ -124,6 +124,11 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
>        shProg->InterfaceBlockStageIndex[i] = NULL;
>     }
>  
> +   ralloc_free(shProg->UboInterfaceBlockIndex);
> +   shProg->UboInterfaceBlockIndex = NULL;
> +   ralloc_free(shProg->SsboInterfaceBlockIndex);
> +   shProg->SsboInterfaceBlockIndex = NULL;
> +
>     ralloc_free(shProg->AtomicBuffers);
>     shProg->AtomicBuffers = NULL;
>     shProg->NumAtomicBuffers = 0;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 5b9fce8..6eff56d 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2736,6 +2736,13 @@ struct gl_shader_program
>     int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
>  
>     /**
> +    * Indices into the BufferInterfaceBlocks[] array for Uniform Buffer
> +    * Objects and Shader Storage Buffer Objects.
> +    */
> +   unsigned *UboInterfaceBlockIndex;
> +   unsigned *SsboInterfaceBlockIndex;
> +
> +   /**
>      * Map of active uniform names to locations
>      *
>      * Maps any active uniform that is not an array element to a location.




More information about the mesa-dev mailing list