summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_uniforms.cpp2
-rw-r--r--src/mesa/main/mtypes.h15
-rw-r--r--src/mesa/main/shaderobj.c1
-rw-r--r--src/mesa/main/uniforms.h8
4 files changed, 23 insertions, 3 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 010296b6b69..84680bebd9a 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -739,6 +739,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
sizeof(prog->_LinkedShaders[i]->SamplerTargets));
}
+ prog->UniformLocationBaseScale = (1U<<16);
+
#ifndef NDEBUG
for (unsigned i = 0; i < num_user_uniforms; i++) {
assert(uniforms[i].storage != NULL);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 92a70f416d3..cd8650cbc2b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2333,6 +2333,21 @@ struct gl_shader_program
unsigned NumUniformBlocks;
/**
+ * Scale factor for the uniform base location
+ *
+ * This is used to generate locations (returned by \c glGetUniformLocation)
+ * of uniforms. The base location of the uniform is multiplied by this
+ * value, and the array index is added.
+ *
+ * \note
+ * Must be >= 1.
+ *
+ * \sa
+ * _mesa_uniform_merge_location_offset, _mesa_uniform_split_location_offset
+ */
+ unsigned UniformLocationBaseScale;
+
+ /**
* Indices into the _LinkedShaders's UniformBlocks[] array for each stage
* they're used in, or -1.
*
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index a60d8f38a9a..a62ad0413cf 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -283,6 +283,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
ralloc_free(shProg->UniformStorage);
shProg->NumUserUniformStorage = 0;
shProg->UniformStorage = NULL;
+ shProg->UniformLocationBaseScale = 0;
}
if (shProg->UniformHash) {
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index d718b0f12e3..14fe26d5fde 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -272,7 +272,9 @@ static inline GLint
_mesa_uniform_merge_location_offset(const struct gl_shader_program *prog,
unsigned base_location, unsigned offset)
{
- return (base_location << 16) | offset;
+ assert(prog->UniformLocationBaseScale >= 0);
+ assert(offset < prog->UniformLocationBaseScale);
+ return (base_location * prog->UniformLocationBaseScale) + offset;
}
/**
@@ -283,8 +285,8 @@ _mesa_uniform_split_location_offset(const struct gl_shader_program *prog,
GLint location, unsigned *base_location,
unsigned *offset)
{
- *offset = location & 0xffff;
- *base_location = location >> 16;
+ *offset = location % prog->UniformLocationBaseScale;
+ *base_location = location / prog->UniformLocationBaseScale;
}
/*@}*/