diff options
author | Francisco Jerez <[email protected]> | 2013-11-22 15:53:52 -0800 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2014-02-12 18:44:06 +0100 |
commit | c318a677dd20a5a9d891f0891363b4811aa7b04f (patch) | |
tree | 6be8103ae464960247afd85ec3362ce3a8b774a0 /src/glsl | |
parent | e51158f2e77155bcfc6ba5f42d1cf9b9c9810930 (diff) |
glsl/linker: Assign image uniform indices.
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 79f84046249..3a3f93554d2 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); |