glsl: simplify set_opaque_binding()
While we are at it, update the GLSL spec comment. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -117,7 +117,7 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
|
|||||||
|
|
||||||
const unsigned elements = MAX2(storage->array_elements, 1);
|
const unsigned elements = MAX2(storage->array_elements, 1);
|
||||||
|
|
||||||
/* Section 4.4.4 (Opaque-Uniform Layout Qualifiers) of the GLSL 4.20 spec
|
/* Section 4.4.6 (Opaque-Uniform Layout Qualifiers) of the GLSL 4.50 spec
|
||||||
* says:
|
* says:
|
||||||
*
|
*
|
||||||
* "If the binding identifier is used with an array, the first element
|
* "If the binding identifier is used with an array, the first element
|
||||||
@@ -131,25 +131,24 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
|
|||||||
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
|
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
|
||||||
gl_linked_shader *shader = prog->_LinkedShaders[sh];
|
gl_linked_shader *shader = prog->_LinkedShaders[sh];
|
||||||
|
|
||||||
if (shader) {
|
if (!shader)
|
||||||
if (storage->type->is_sampler() && storage->opaque[sh].active) {
|
continue;
|
||||||
|
if (!storage->opaque[sh].active)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (storage->type->is_sampler()) {
|
||||||
for (unsigned i = 0; i < elements; i++) {
|
for (unsigned i = 0; i < elements; i++) {
|
||||||
const unsigned index = storage->opaque[sh].index + i;
|
const unsigned index = storage->opaque[sh].index + i;
|
||||||
if (index >= ARRAY_SIZE(shader->Program->SamplerUnits))
|
if (index >= ARRAY_SIZE(shader->Program->SamplerUnits))
|
||||||
break;
|
break;
|
||||||
shader->Program->SamplerUnits[index] =
|
shader->Program->SamplerUnits[index] = storage->storage[i].i;
|
||||||
storage->storage[i].i;
|
|
||||||
}
|
}
|
||||||
|
} else if (storage->type->is_image()) {
|
||||||
} else if (storage->type->is_image() &&
|
|
||||||
storage->opaque[sh].active) {
|
|
||||||
for (unsigned i = 0; i < elements; i++) {
|
for (unsigned i = 0; i < elements; i++) {
|
||||||
const unsigned index = storage->opaque[sh].index + i;
|
const unsigned index = storage->opaque[sh].index + i;
|
||||||
if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits))
|
if (index >= ARRAY_SIZE(shader->Program->sh.ImageUnits))
|
||||||
break;
|
break;
|
||||||
shader->Program->sh.ImageUnits[index] =
|
shader->Program->sh.ImageUnits[index] = storage->storage[i].i;
|
||||||
storage->storage[i].i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user