summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-04-03 12:44:33 +1000
committerTimothy Arceri <[email protected]>2016-04-06 09:56:24 +1000
commitf1293b2f9bc3a45c71941931edb5148d7b5f5a27 (patch)
treeba998230fc2b04bf8d130b6d7704650dbba09e83 /src/mesa/main
parent506b561ba7e3df2a7759dded684fae84bf459f65 (diff)
glsl: fully split apart buffer block arrays
With this change we create the UBO and SSBO arrays separately from the beginning rather than putting them into a combined array and splitting it apart later. A bug is with UBO and SSBO stage reference querying is also fixed as we now use the block index to lookup the references in the separate arrays not the combined buffer block array. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h50
-rw-r--r--src/mesa/main/shader_query.cpp7
-rw-r--r--src/mesa/main/shaderapi.c2
-rw-r--r--src/mesa/main/shaderobj.c10
-rw-r--r--src/mesa/main/uniforms.c8
5 files changed, 19 insertions, 58 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b2060c282f4..dc73278424b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2295,30 +2295,6 @@ struct gl_shader
*/
unsigned num_combined_uniform_components;
- /**
- * This shader's uniform/ssbo block information.
- *
- * These fields are only set post-linking.
- *
- * BufferInterfaceBlocks is a list containing both UBOs and SSBOs. This is
- * useful during the linking process so that we don't have to handle SSBOs
- * specifically.
- *
- * UniformBlocks is a list of UBOs. This is useful for backends that need
- * or prefer to see separate index spaces for UBOS and SSBOs like the GL
- * API specifies.
- *
- * ShaderStorageBlocks is a list of SSBOs. This is useful for backends that
- * need or prefer to see separate index spaces for UBOS and SSBOs like the
- * GL API specifies.
- *
- * UniformBlocks and ShaderStorageBlocks only have pointers into
- * BufferInterfaceBlocks so the actual resource information is not
- * duplicated.
- */
- unsigned NumBufferInterfaceBlocks;
- struct gl_uniform_block **BufferInterfaceBlocks;
-
unsigned NumUniformBlocks;
struct gl_uniform_block **UniformBlocks;
@@ -2804,33 +2780,11 @@ struct gl_shader_program
*/
unsigned LastClipDistanceArraySize;
- /**
- * This shader's uniform/ssbo block information.
- *
- * BufferInterfaceBlocks is a list containing both UBOs and SSBOs. This is
- * useful during the linking process so that we don't have to handle SSBOs
- * specifically.
- *
- * UniformBlocks is a list of UBOs. This is useful for backends that need
- * or prefer to see separate index spaces for UBOS and SSBOs like the GL
- * API specifies.
- *
- * ShaderStorageBlocks is a list of SSBOs. This is useful for backends that
- * need or prefer to see separate index spaces for UBOS and SSBOs like the
- * GL API specifies.
- *
- * UniformBlocks and ShaderStorageBlocks only have pointers into
- * BufferInterfaceBlocks so the actual resource information is not
- * duplicated and are only set after linking.
- */
- unsigned NumBufferInterfaceBlocks;
- struct gl_uniform_block *BufferInterfaceBlocks;
-
unsigned NumUniformBlocks;
- struct gl_uniform_block **UniformBlocks;
+ struct gl_uniform_block *UniformBlocks;
unsigned NumShaderStorageBlocks;
- struct gl_uniform_block **ShaderStorageBlocks;
+ struct gl_uniform_block *ShaderStorageBlocks;
/**
* Map of active uniform names to locations
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4ef6a81204e..2c1a6ee3505 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -925,8 +925,11 @@ is_resource_referenced(struct gl_shader_program *shProg,
if (res->Type == GL_ATOMIC_COUNTER_BUFFER)
return RESOURCE_ATC(res)->StageReferences[stage];
- if (res->Type == GL_UNIFORM_BLOCK || res->Type == GL_SHADER_STORAGE_BLOCK)
- return shProg->BufferInterfaceBlocks[index].stageref & (1 << stage);
+ if (res->Type == GL_UNIFORM_BLOCK)
+ return shProg->UniformBlocks[index].stageref & (1 << stage);
+
+ if (res->Type == GL_SHADER_STORAGE_BLOCK)
+ return shProg->ShaderStorageBlocks[index].stageref & (1 << stage);
return res->StageReferences & (1 << stage);
}
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index ba2607221d9..b28b5ce5457 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -727,7 +727,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
for (i = 0; i < shProg->NumUniformBlocks; i++) {
/* Add one for the terminating NUL character.
*/
- const GLint len = strlen(shProg->UniformBlocks[i]->Name) + 1;
+ const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
if (len > max_len)
max_len = len;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 8b9166ceecb..274cb129b07 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -292,9 +292,13 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
ralloc_free(shProg->InfoLog);
shProg->InfoLog = ralloc_strdup(shProg, "");
- ralloc_free(shProg->BufferInterfaceBlocks);
- shProg->BufferInterfaceBlocks = NULL;
- shProg->NumBufferInterfaceBlocks = 0;
+ ralloc_free(shProg->UniformBlocks);
+ shProg->UniformBlocks = NULL;
+ shProg->NumUniformBlocks = 0;
+
+ ralloc_free(shProg->ShaderStorageBlocks);
+ shProg->ShaderStorageBlocks = NULL;
+ shProg->NumShaderStorageBlocks = 0;
ralloc_free(shProg->AtomicBuffers);
shProg->AtomicBuffers = NULL;
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 7dcbdccf442..a9308d09f69 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -1016,13 +1016,13 @@ _mesa_UniformBlockBinding(GLuint program,
return;
}
- if (shProg->UniformBlocks[uniformBlockIndex]->Binding !=
+ if (shProg->UniformBlocks[uniformBlockIndex].Binding !=
uniformBlockBinding) {
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
- shProg->UniformBlocks[uniformBlockIndex]->Binding = uniformBlockBinding;
+ shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
}
}
@@ -1059,13 +1059,13 @@ _mesa_ShaderStorageBlockBinding(GLuint program,
return;
}
- if (shProg->ShaderStorageBlocks[shaderStorageBlockIndex]->Binding !=
+ if (shProg->ShaderStorageBlocks[shaderStorageBlockIndex].Binding !=
shaderStorageBlockBinding) {
FLUSH_VERTICES(ctx, 0);
ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
- shProg->ShaderStorageBlocks[shaderStorageBlockIndex]->Binding =
+ shProg->ShaderStorageBlocks[shaderStorageBlockIndex].Binding =
shaderStorageBlockBinding;
}
}