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

2015-10-28 Thread Iago Toral
On Tue, 2015-10-27 at 22:38 -0700, Jordan Justen wrote:
> Signed-off-by: Jordan Justen 
> Cc: Samuel Iglesias Gonsálvez 
> Cc: Iago Toral Quiroga 
> ---
>  src/glsl/linker.cpp | 14 ++
>  src/glsl/standalone_scaffolding.cpp |  5 +
>  src/mesa/main/mtypes.h  |  7 +++
>  3 files changed, 26 insertions(+)
> 
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 3db2fd3..d925393 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -4448,6 +4448,20 @@ link_shaders(struct gl_context *ctx, struct 
> gl_shader_program *prog)
>  >ShaderStorageBlocks,
>  >NumShaderStorageBlocks);
>  
> +   prog->UboInterfaceBlockIndex =
> +  ralloc_array(prog, int, prog->NumUniformBlocks);
> +   prog->SsboInterfaceBlockIndex =
> +  ralloc_array(prog, int, prog->NumShaderStorageBlocks);
> +   for (unsigned i = 0, u = 0, s = 0;
> +i < prog->NumBufferInterfaceBlocks;
> +i++) {
> +  if (prog->BufferInterfaceBlocks[i].IsShaderStorage) {
> + prog->SsboInterfaceBlockIndex[s++] = i;
> +  } else {
> + prog->UboInterfaceBlockIndex[u++] = i;
> +  }
> +   }

This loop is pretty much the same we have in split_ubos_and_ssbos and
the functionality implements seems to belong in that function too, so
maybe it would be better if we merged this loop in that function. I am
thinking that we could pass two more arguments to split_ubos_and_ssbos
that would be NULL in the first call (the one we do in the loop for all
shader stages) and in the last call we do outside the loop for the
shader program, we pass >UboInterfaceBlockIndex and
>SsboInterfaceBlockIndex to get these setup.

What do you think?

> /* FINISHME: Assign fragment shader output locations. */
>  
>  done:
> diff --git a/src/glsl/standalone_scaffolding.cpp 
> b/src/glsl/standalone_scaffolding.cpp
> index fe1d820..5c76295 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 cce959e..c1cbe96 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2725,6 +2725,13 @@ struct gl_shader_program
> int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
>  
> /**
> +* Indices into the BufferInterfaceBlocks[] array for Uniform Buffer
> +* Objects and Shader Storage Buffer Objects.
> +*/
> +   int *UboInterfaceBlockIndex;
> +   int *SsboInterfaceBlockIndex;
> +
> +   /**
>  * Map of active uniform names to locations
>  *
>  * Maps any active uniform that is not an array element to a location.


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2015-10-27 Thread Jordan Justen
Signed-off-by: Jordan Justen 
Cc: Samuel Iglesias Gonsálvez 
Cc: Iago Toral Quiroga 
---
 src/glsl/linker.cpp | 14 ++
 src/glsl/standalone_scaffolding.cpp |  5 +
 src/mesa/main/mtypes.h  |  7 +++
 3 files changed, 26 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3db2fd3..d925393 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -4448,6 +4448,20 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
 >ShaderStorageBlocks,
 >NumShaderStorageBlocks);
 
+   prog->UboInterfaceBlockIndex =
+  ralloc_array(prog, int, prog->NumUniformBlocks);
+   prog->SsboInterfaceBlockIndex =
+  ralloc_array(prog, int, prog->NumShaderStorageBlocks);
+   for (unsigned i = 0, u = 0, s = 0;
+i < prog->NumBufferInterfaceBlocks;
+i++) {
+  if (prog->BufferInterfaceBlocks[i].IsShaderStorage) {
+ prog->SsboInterfaceBlockIndex[s++] = i;
+  } else {
+ prog->UboInterfaceBlockIndex[u++] = i;
+  }
+   }
+
/* FINISHME: Assign fragment shader output locations. */
 
 done:
diff --git a/src/glsl/standalone_scaffolding.cpp 
b/src/glsl/standalone_scaffolding.cpp
index fe1d820..5c76295 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 cce959e..c1cbe96 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2725,6 +2725,13 @@ struct gl_shader_program
int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
 
/**
+* Indices into the BufferInterfaceBlocks[] array for Uniform Buffer
+* Objects and Shader Storage Buffer Objects.
+*/
+   int *UboInterfaceBlockIndex;
+   int *SsboInterfaceBlockIndex;
+
+   /**
 * Map of active uniform names to locations
 *
 * Maps any active uniform that is not an array element to a location.
-- 
2.5.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev