[Mesa-dev] [PATCH] glsl: move uniform block validation to link_uniform_blocks.cpp
Eduardo Lima Mitev
elima at igalia.com
Wed Apr 27 05:31:50 UTC 2016
Reviewed-by: Eduardo Lima Mitev <elima at igalia.com>
Thanks!
On 04/27/2016 05:20 AM, Timothy Arceri wrote:
> ---
> src/compiler/glsl/link_uniform_blocks.cpp | 53 +++++++++++++++++++++++++++++++
> src/compiler/glsl/link_uniforms.cpp | 53 -------------------------------
> 2 files changed, 53 insertions(+), 53 deletions(-)
>
> diff --git a/src/compiler/glsl/link_uniform_blocks.cpp b/src/compiler/glsl/link_uniform_blocks.cpp
> index 58f22fd..ac415b5 100644
> --- a/src/compiler/glsl/link_uniform_blocks.cpp
> +++ b/src/compiler/glsl/link_uniform_blocks.cpp
> @@ -500,3 +500,56 @@ link_uniform_blocks_are_compatible(const gl_uniform_block *a,
>
> return true;
> }
> +
> +/**
> + * Merges a uniform block into an array of uniform blocks that may or
> + * may not already contain a copy of it.
> + *
> + * Returns the index of the new block in the array.
> + */
> +int
> +link_cross_validate_uniform_block(void *mem_ctx,
> + struct gl_uniform_block **linked_blocks,
> + unsigned int *num_linked_blocks,
> + struct gl_uniform_block *new_block)
> +{
> + for (unsigned int i = 0; i < *num_linked_blocks; i++) {
> + struct gl_uniform_block *old_block = &(*linked_blocks)[i];
> +
> + if (strcmp(old_block->Name, new_block->Name) == 0)
> + return link_uniform_blocks_are_compatible(old_block, new_block)
> + ? i : -1;
> + }
> +
> + *linked_blocks = reralloc(mem_ctx, *linked_blocks,
> + struct gl_uniform_block,
> + *num_linked_blocks + 1);
> + int linked_block_index = (*num_linked_blocks)++;
> + struct gl_uniform_block *linked_block = &(*linked_blocks)[linked_block_index];
> +
> + memcpy(linked_block, new_block, sizeof(*new_block));
> + linked_block->Uniforms = ralloc_array(*linked_blocks,
> + struct gl_uniform_buffer_variable,
> + linked_block->NumUniforms);
> +
> + memcpy(linked_block->Uniforms,
> + new_block->Uniforms,
> + sizeof(*linked_block->Uniforms) * linked_block->NumUniforms);
> +
> + linked_block->Name = ralloc_strdup(*linked_blocks, linked_block->Name);
> +
> + for (unsigned int i = 0; i < linked_block->NumUniforms; i++) {
> + struct gl_uniform_buffer_variable *ubo_var =
> + &linked_block->Uniforms[i];
> +
> + if (ubo_var->Name == ubo_var->IndexName) {
> + ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
> + ubo_var->IndexName = ubo_var->Name;
> + } else {
> + ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
> + ubo_var->IndexName = ralloc_strdup(*linked_blocks, ubo_var->IndexName);
> + }
> + }
> +
> + return linked_block_index;
> +}
> diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
> index 43a455b..8c27030 100644
> --- a/src/compiler/glsl/link_uniforms.cpp
> +++ b/src/compiler/glsl/link_uniforms.cpp
> @@ -875,59 +875,6 @@ public:
> };
>
> /**
> - * Merges a uniform block into an array of uniform blocks that may or
> - * may not already contain a copy of it.
> - *
> - * Returns the index of the new block in the array.
> - */
> -int
> -link_cross_validate_uniform_block(void *mem_ctx,
> - struct gl_uniform_block **linked_blocks,
> - unsigned int *num_linked_blocks,
> - struct gl_uniform_block *new_block)
> -{
> - for (unsigned int i = 0; i < *num_linked_blocks; i++) {
> - struct gl_uniform_block *old_block = &(*linked_blocks)[i];
> -
> - if (strcmp(old_block->Name, new_block->Name) == 0)
> - return link_uniform_blocks_are_compatible(old_block, new_block)
> - ? i : -1;
> - }
> -
> - *linked_blocks = reralloc(mem_ctx, *linked_blocks,
> - struct gl_uniform_block,
> - *num_linked_blocks + 1);
> - int linked_block_index = (*num_linked_blocks)++;
> - struct gl_uniform_block *linked_block = &(*linked_blocks)[linked_block_index];
> -
> - memcpy(linked_block, new_block, sizeof(*new_block));
> - linked_block->Uniforms = ralloc_array(*linked_blocks,
> - struct gl_uniform_buffer_variable,
> - linked_block->NumUniforms);
> -
> - memcpy(linked_block->Uniforms,
> - new_block->Uniforms,
> - sizeof(*linked_block->Uniforms) * linked_block->NumUniforms);
> -
> - linked_block->Name = ralloc_strdup(*linked_blocks, linked_block->Name);
> -
> - for (unsigned int i = 0; i < linked_block->NumUniforms; i++) {
> - struct gl_uniform_buffer_variable *ubo_var =
> - &linked_block->Uniforms[i];
> -
> - if (ubo_var->Name == ubo_var->IndexName) {
> - ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
> - ubo_var->IndexName = ubo_var->Name;
> - } else {
> - ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
> - ubo_var->IndexName = ralloc_strdup(*linked_blocks, ubo_var->IndexName);
> - }
> - }
> -
> - return linked_block_index;
> -}
> -
> -/**
> * Walks the IR and update the references to uniform blocks in the
> * ir_variables to point at linked shader's list (previously, they
> * would point at the uniform block list in one of the pre-linked
>
More information about the mesa-dev
mailing list