[Mesa-dev] [WIP 04/13] mesa: add a storage for inactive/removed uniform variables
Tapani Pälli
tapani.palli at intel.com
Thu Mar 27 23:45:27 PDT 2014
GL_ARB_explicit_uniform_location extension requires driver to reserve
locations for all uniforms (including inactive ones) when they have
explicit location set. Patch adds additional storage structure and a
list of locations reserved by inactive uniforms as part of the shader
program structure.
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
src/mesa/main/mtypes.h | 13 +++++++++++++
src/mesa/main/shaderobj.c | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c8b8fa7..87d69c1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2710,6 +2710,19 @@ struct gl_shader_program
struct gl_uniform_storage **UniformRemapTable;
/**
+ * This list contains explicit locations defined by inactive uniforms that
+ * were removed during the optimization pass (by opt_dead_code). This is
+ * used by linker to be able to still preserve locations for those
+ * uniforms.
+ *
+ * All removed uniforms have common storage 'RemovedUniformStorage' which
+ * is allocated once using ReservedUniformLocations as the ralloc context.
+ */
+ unsigned *ReservedUniformLocations;
+ unsigned NumReservedLocations;
+ struct gl_uniform_storage *RemovedUniformStorage;
+
+ /**
* Size of the gl_ClipDistance array that is output from the last pipeline
* stage before the fragment shader.
*/
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index b0f0bfa..7ec2827 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -287,6 +287,13 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
shProg->UniformStorage = NULL;
}
+ if (shProg->ReservedUniformLocations) {
+ ralloc_free(shProg->ReservedUniformLocations);
+ shProg->NumReservedLocations = 0;
+ shProg->ReservedUniformLocations = NULL;
+ shProg->RemovedUniformStorage = NULL;
+ }
+
if (shProg->UniformRemapTable) {
ralloc_free(shProg->UniformRemapTable);
shProg->NumUniformRemapTable = 0;
--
1.8.3.1
More information about the mesa-dev
mailing list