[Mesa-dev] [PATCH 5/7] glsl: store stage reference in gl_uniform_block

Kenneth Graunke kenneth at whitecape.org
Sat Apr 2 04:51:15 UTC 2016


On Saturday, April 2, 2016 3:03:56 PM PDT Timothy Arceri wrote:
> This allows us to simplify the code and drop InterfaceBlockStageIndex
> which is a per stage array of integers the size of all blocks in the
> program combined including duplicates across stages. Adding a stage
> ref per block will use less memory.
> ---
>  src/compiler/glsl/linker.cpp                 | 20 ++++++++++----------
>  src/compiler/glsl/standalone_scaffolding.cpp |  5 -----
>  src/mesa/main/mtypes.h                       | 13 +++----------
>  src/mesa/main/shader_query.cpp               |  2 +-
>  src/mesa/main/shaderobj.c                    |  4 ----
>  5 files changed, 14 insertions(+), 30 deletions(-)
> 
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index 1f2b77f..b8b9100 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -1174,6 +1174,8 @@ cross_validate_uniforms(struct gl_shader_program 
*prog)
>  static bool
>  interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
>  {
> +   int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
> +
>     unsigned max_num_uniform_blocks = 0;
>     for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
>        if (prog->_LinkedShaders[i])
> @@ -1183,10 +1185,10 @@ interstage_cross_validate_uniform_blocks(struct 
gl_shader_program *prog)
>     for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
>        struct gl_shader *sh = prog->_LinkedShaders[i];
>  
> -      prog->InterfaceBlockStageIndex[i] = ralloc_array(prog, int,
> -                                                       
max_num_uniform_blocks);
> +      InterfaceBlockStageIndex[i] = ralloc_array(prog, int,
> +                                                 max_num_uniform_blocks);

It looks like you're still ralloc'ing this off of the gl_shader_program,
so it'll stick around for the lifetime of the program, even though it's
now a temporary array.
sense to ralloc it off the program and have it live forever.

You could ralloc_free it later in this function.  Or, you could just use
new and delete [] and not bother with ralloc.  *shrug*

With that fixed somehow, this is:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160401/f750090a/attachment-0001.sig>


More information about the mesa-dev mailing list