[Mesa-dev,3/3] mesa: Use UBO/SSBO indices during binding

Submitted by Jordan Justen on Oct. 28, 2015, 5:38 a.m.

Details

Message ID 1446010703-2316-3-git-send-email-jordan.l.justen@intel.com
State Accepted
Commit 1d54ac6c9f41df240497e96770415b019ffdc6b3
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Jordan Justen Oct. 28, 2015, 5:38 a.m.
Previously we were treating the binding index for Uniform Buffer
Objects and Shader Storage Buffer Objects as being part of the
combined BufferInterfaceBlocks array.

Fixes ES31-CTS.compute_shader.resource-ubo on i965.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Cc: Iago Toral Quiroga <itoral@igalia.com>
---
 src/mesa/main/uniforms.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 758ca24..47f80ce 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -1002,10 +1002,10 @@  _mesa_UniformBlockBinding(GLuint program,
    if (!shProg)
       return;
 
-   if (uniformBlockIndex >= shProg->NumBufferInterfaceBlocks) {
+   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
       _mesa_error(ctx, GL_INVALID_VALUE,
 		  "glUniformBlockBinding(block index %u >= %u)",
-		  uniformBlockIndex, shProg->NumBufferInterfaceBlocks);
+		  uniformBlockIndex, shProg->NumUniformBlocks);
       return;
    }
 
@@ -1016,17 +1016,22 @@  _mesa_UniformBlockBinding(GLuint program,
       return;
    }
 
-   if (shProg->BufferInterfaceBlocks[uniformBlockIndex].Binding !=
+   if (shProg->UniformBlocks[uniformBlockIndex]->Binding !=
        uniformBlockBinding) {
       int i;
 
       FLUSH_VERTICES(ctx, 0);
       ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
 
-      shProg->BufferInterfaceBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
+      const int interface_block_index =
+         shProg->UboInterfaceBlockIndex[uniformBlockIndex];
+
+      shProg->BufferInterfaceBlocks[interface_block_index].Binding =
+         uniformBlockBinding;
 
       for (i = 0; i < MESA_SHADER_STAGES; i++) {
-	 int stage_index = shProg->InterfaceBlockStageIndex[i][uniformBlockIndex];
+	 int stage_index =
+            shProg->InterfaceBlockStageIndex[i][interface_block_index];
 
 	 if (stage_index != -1) {
 	    struct gl_shader *sh = shProg->_LinkedShaders[i];
@@ -1054,10 +1059,10 @@  _mesa_ShaderStorageBlockBinding(GLuint program,
    if (!shProg)
       return;
 
-   if (shaderStorageBlockIndex >= shProg->NumBufferInterfaceBlocks) {
+   if (shaderStorageBlockIndex >= shProg->NumShaderStorageBlocks) {
       _mesa_error(ctx, GL_INVALID_VALUE,
 		  "glShaderStorageBlockBinding(block index %u >= %u)",
-		  shaderStorageBlockIndex, shProg->NumBufferInterfaceBlocks);
+		  shaderStorageBlockIndex, shProg->NumShaderStorageBlocks);
       return;
    }
 
@@ -1069,17 +1074,22 @@  _mesa_ShaderStorageBlockBinding(GLuint program,
       return;
    }
 
-   if (shProg->BufferInterfaceBlocks[shaderStorageBlockIndex].Binding !=
+   if (shProg->ShaderStorageBlocks[shaderStorageBlockIndex]->Binding !=
        shaderStorageBlockBinding) {
       int i;
 
       FLUSH_VERTICES(ctx, 0);
       ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
 
-      shProg->BufferInterfaceBlocks[shaderStorageBlockIndex].Binding = shaderStorageBlockBinding;
+      const int interface_block_index =
+         shProg->SsboInterfaceBlockIndex[shaderStorageBlockIndex];
+
+      shProg->BufferInterfaceBlocks[interface_block_index].Binding =
+         shaderStorageBlockBinding;
 
       for (i = 0; i < MESA_SHADER_STAGES; i++) {
-	 int stage_index = shProg->InterfaceBlockStageIndex[i][shaderStorageBlockIndex];
+	 int stage_index =
+            shProg->InterfaceBlockStageIndex[i][interface_block_index];
 
 	 if (stage_index != -1) {
 	    struct gl_shader *sh = shProg->_LinkedShaders[i];

Comments

On Tue, 2015-10-27 at 22:38 -0700, Jordan Justen wrote:
> Previously we were treating the binding index for Uniform Buffer
> Objects and Shader Storage Buffer Objects as being part of the
> combined BufferInterfaceBlocks array.
> 
> Fixes ES31-CTS.compute_shader.resource-ubo on i965.
> 
> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
> Cc: Iago Toral Quiroga <itoral@igalia.com>
> ---
>  src/mesa/main/uniforms.c | 30 ++++++++++++++++++++----------
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
> index 758ca24..47f80ce 100644
> --- a/src/mesa/main/uniforms.c
> +++ b/src/mesa/main/uniforms.c
> @@ -1002,10 +1002,10 @@ _mesa_UniformBlockBinding(GLuint program,
>     if (!shProg)
>        return;
>  
> -   if (uniformBlockIndex >= shProg->NumBufferInterfaceBlocks) {
> +   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
>  		  "glUniformBlockBinding(block index %u >= %u)",
> -		  uniformBlockIndex, shProg->NumBufferInterfaceBlocks);
> +		  uniformBlockIndex, shProg->NumUniformBlocks);
>        return;
>     }
>  
> @@ -1016,17 +1016,22 @@ _mesa_UniformBlockBinding(GLuint program,
>        return;
>     }
>  
> -   if (shProg->BufferInterfaceBlocks[uniformBlockIndex].Binding !=
> +   if (shProg->UniformBlocks[uniformBlockIndex]->Binding !=
>         uniformBlockBinding) {
>        int i;
>  
>        FLUSH_VERTICES(ctx, 0);
>        ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
>  
> -      shProg->BufferInterfaceBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
> +      const int interface_block_index =
> +         shProg->UboInterfaceBlockIndex[uniformBlockIndex];
> +
> +      shProg->BufferInterfaceBlocks[interface_block_index].Binding =
> +         uniformBlockBinding;

FWIW, here you could just do:
shProg->UniformBlocks[uniformBlockIndex]->Binding = uniformBlockBinding;

since shProg->UniformBlocks holds pointers into the appropriate places
in shProg->BufferInterfaceBlocks.

>        for (i = 0; i < MESA_SHADER_STAGES; i++) {
> -	 int stage_index = shProg->InterfaceBlockStageIndex[i][uniformBlockIndex];
> +	 int stage_index =
> +            shProg->InterfaceBlockStageIndex[i][interface_block_index];

However, we still need this and so we still need to have the index in
the interface block space, so either way:

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

>  	 if (stage_index != -1) {
>  	    struct gl_shader *sh = shProg->_LinkedShaders[i];
> @@ -1054,10 +1059,10 @@ _mesa_ShaderStorageBlockBinding(GLuint program,
>     if (!shProg)
>        return;
>  
> -   if (shaderStorageBlockIndex >= shProg->NumBufferInterfaceBlocks) {
> +   if (shaderStorageBlockIndex >= shProg->NumShaderStorageBlocks) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
>  		  "glShaderStorageBlockBinding(block index %u >= %u)",
> -		  shaderStorageBlockIndex, shProg->NumBufferInterfaceBlocks);
> +		  shaderStorageBlockIndex, shProg->NumShaderStorageBlocks);
>        return;
>     }
>  
> @@ -1069,17 +1074,22 @@ _mesa_ShaderStorageBlockBinding(GLuint program,
>        return;
>     }
>  
> -   if (shProg->BufferInterfaceBlocks[shaderStorageBlockIndex].Binding !=
> +   if (shProg->ShaderStorageBlocks[shaderStorageBlockIndex]->Binding !=
>         shaderStorageBlockBinding) {
>        int i;
>  
>        FLUSH_VERTICES(ctx, 0);
>        ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
>  
> -      shProg->BufferInterfaceBlocks[shaderStorageBlockIndex].Binding = shaderStorageBlockBinding;
> +      const int interface_block_index =
> +         shProg->SsboInterfaceBlockIndex[shaderStorageBlockIndex];
> +
> +      shProg->BufferInterfaceBlocks[interface_block_index].Binding =
> +         shaderStorageBlockBinding;
>  
>        for (i = 0; i < MESA_SHADER_STAGES; i++) {
> -	 int stage_index = shProg->InterfaceBlockStageIndex[i][shaderStorageBlockIndex];
> +	 int stage_index =
> +            shProg->InterfaceBlockStageIndex[i][interface_block_index];
>  
>  	 if (stage_index != -1) {
>  	    struct gl_shader *sh = shProg->_LinkedShaders[i];