summaryrefslogtreecommitdiffstats
path: root/src/glsl/link_uniforms.cpp
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2013-11-22 15:53:52 -0800
committerFrancisco Jerez <currojerez@riseup.net>2014-02-12 18:44:06 +0100
commitc318a677dd20a5a9d891f0891363b4811aa7b04f (patch)
tree6be8103ae464960247afd85ec3362ce3a8b774a0 /src/glsl/link_uniforms.cpp
parente51158f2e77155bcfc6ba5f42d1cf9b9c9810930 (diff)
downloadexternal_mesa3d-c318a677dd20a5a9d891f0891363b4811aa7b04f.zip
external_mesa3d-c318a677dd20a5a9d891f0891363b4811aa7b04f.tar.gz
external_mesa3d-c318a677dd20a5a9d891f0891363b4811aa7b04f.tar.bz2
glsl/linker: Assign image uniform indices.
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r--src/glsl/link_uniforms.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 79f8404..3a3f935 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -380,6 +380,7 @@ public:
this->shader_samplers_used = 0;
this->shader_shadow_samplers = 0;
this->next_sampler = 0;
+ this->next_image = 0;
memset(this->targets, 0, sizeof(this->targets));
}
@@ -476,6 +477,24 @@ private:
}
}
+ void handle_images(const glsl_type *base_type,
+ struct gl_uniform_storage *uniform)
+ {
+ if (base_type->is_image()) {
+ uniform->image[shader_type].index = this->next_image;
+ uniform->image[shader_type].active = true;
+
+ /* Increment the image index by 1 for non-arrays and by the
+ * number of array elements for arrays.
+ */
+ this->next_image += MAX2(1, uniform->array_elements);
+
+ } else {
+ uniform->image[shader_type].index = ~0;
+ uniform->image[shader_type].active = false;
+ }
+ }
+
virtual void visit_field(const glsl_type *type, const char *name,
bool row_major)
{
@@ -511,8 +530,9 @@ private:
base_type = type;
}
- /* This assigns sampler uniforms to sampler units. */
+ /* This assigns uniform indices to sampler and image uniforms. */
handle_samplers(base_type, &this->uniforms[id]);
+ handle_images(base_type, &this->uniforms[id]);
/* If there is already storage associated with this uniform, it means
* that it was set while processing an earlier shader stage. For
@@ -570,6 +590,7 @@ private:
struct gl_uniform_storage *uniforms;
unsigned next_sampler;
+ unsigned next_image;
public:
union gl_constant_value *values;
@@ -773,6 +794,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
* types cannot have initializers."
*/
memset(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
+ memset(sh->ImageUnits, 0, sizeof(sh->ImageUnits));
link_update_uniform_buffer_variables(sh);