diff options
author | Francisco Jerez <[email protected]> | 2013-11-23 21:56:56 -0800 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2014-02-12 18:44:06 +0100 |
commit | 212122543b5eb69613853bf03f0c4fd5494c06a0 (patch) | |
tree | 8a5a3f67040ab7bb9ae44f59f37d43422bbcd447 /src | |
parent | c318a677dd20a5a9d891f0891363b4811aa7b04f (diff) |
glsl/linker: Propagate image uniform access qualifiers to the driver.
Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 3a3f93554d2..1cf376d5d29 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -757,6 +757,40 @@ link_assign_uniform_block_offsets(struct gl_shader *shader) } } +/** + * Scan the program for image uniforms and store image unit access + * information into the gl_shader data structure. + */ +static void +link_set_image_access_qualifiers(struct gl_shader_program *prog) +{ + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { + gl_shader *sh = prog->_LinkedShaders[i]; + + if (sh == NULL) + continue; + + foreach_list(node, sh->ir) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); + + if (var && var->data.mode == ir_var_uniform && + var->type->contains_image()) { + unsigned id; + bool found = prog->UniformHash->get(id, var->name); + assert(found); + const gl_uniform_storage *storage = &prog->UniformStorage[id]; + const unsigned index = storage->image[i].index; + const GLenum access = (var->data.image.read_only ? GL_READ_ONLY : + var->data.image.write_only ? GL_WRITE_ONLY : + GL_READ_WRITE); + + for (unsigned j = 0; j < MAX2(1, storage->array_elements); ++j) + sh->ImageAccess[index + j] = access; + } + } + } +} + void link_assign_uniform_locations(struct gl_shader_program *prog) { @@ -901,6 +935,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) prog->NumUserUniformStorage = num_user_uniforms; prog->UniformStorage = uniforms; + link_set_image_access_qualifiers(prog); link_set_uniform_initializers(prog); return; |