diff options
author | Timothy Arceri <[email protected]> | 2015-09-30 11:00:02 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2015-10-05 10:53:24 +1100 |
commit | 763cd8c080353482cb41da578cb3d6f7892a0c9f (patch) | |
tree | dff9ba9c0e6a4ebc0e706d578fe5313bc1cbda4f /src/glsl/link_uniforms.cpp | |
parent | b85757bc72350df609f50e000512bc80d07f1497 (diff) |
glsl: reduce memory footprint of uniform_storage struct
The uniform will only be of a single type so store the data for
opaque types in a single array.
Cc: Francisco Jerez <[email protected]>
Cc: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 740b0a46aee..0642ddc4bf5 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -566,7 +566,7 @@ private: struct gl_uniform_storage *uniform, const char *name) { if (base_type->is_sampler()) { - uniform->sampler[shader_type].active = true; + uniform->opaque[shader_type].active = true; /* Handle multiple samplers inside struct arrays */ if (this->record_array_count > 1) { @@ -586,8 +586,8 @@ private: /* In this case, we've already seen this uniform so we just use * the next sampler index recorded the last time we visited. */ - uniform->sampler[shader_type].index = index; - index = inner_array_size + uniform->sampler[shader_type].index; + uniform->opaque[shader_type].index = index; + index = inner_array_size + uniform->opaque[shader_type].index; this->record_next_sampler->put(index, name_copy); ralloc_free(name_copy); @@ -605,13 +605,13 @@ private: * structs. This allows the offset to be easily calculated for * indirect indexing. */ - uniform->sampler[shader_type].index = this->next_sampler; + uniform->opaque[shader_type].index = this->next_sampler; this->next_sampler += inner_array_size * this->record_array_count; /* Store the next index for future passes over the struct array */ - index = uniform->sampler[shader_type].index + inner_array_size; + index = uniform->opaque[shader_type].index + inner_array_size; this->record_next_sampler->put(index, name_copy); ralloc_free(name_copy); } @@ -619,22 +619,19 @@ private: /* Increment the sampler by 1 for non-arrays and by the number of * array elements for arrays. */ - uniform->sampler[shader_type].index = this->next_sampler; + uniform->opaque[shader_type].index = this->next_sampler; this->next_sampler += MAX2(1, uniform->array_elements); } const gl_texture_index target = base_type->sampler_index(); const unsigned shadow = base_type->sampler_shadow; - for (unsigned i = uniform->sampler[shader_type].index; + for (unsigned i = uniform->opaque[shader_type].index; i < MIN2(this->next_sampler, MAX_SAMPLERS); i++) { this->targets[i] = target; this->shader_samplers_used |= 1U << i; this->shader_shadow_samplers |= shadow << i; } - } else { - uniform->sampler[shader_type].index = ~0; - uniform->sampler[shader_type].active = false; } } @@ -642,17 +639,14 @@ private: struct gl_uniform_storage *uniform) { if (base_type->is_image()) { - uniform->image[shader_type].index = this->next_image; - uniform->image[shader_type].active = true; + uniform->opaque[shader_type].index = this->next_image; + uniform->opaque[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; } } @@ -660,17 +654,14 @@ private: struct gl_uniform_storage *uniform) { if (base_type->is_subroutine()) { - uniform->subroutine[shader_type].index = this->next_subroutine; - uniform->subroutine[shader_type].active = true; + uniform->opaque[shader_type].index = this->next_subroutine; + uniform->opaque[shader_type].active = true; /* Increment the subroutine index by 1 for non-arrays and by the * number of array elements for arrays. */ this->next_subroutine += MAX2(1, uniform->array_elements); - } else { - uniform->subroutine[shader_type].index = ~0; - uniform->subroutine[shader_type].active = false; } } @@ -738,6 +729,10 @@ private: base_type = type; } + /* Initialise opaque data */ + this->uniforms[id].opaque[shader_type].index = ~0; + this->uniforms[id].opaque[shader_type].active = false; + /* This assigns uniform indices to sampler and image uniforms. */ handle_samplers(base_type, &this->uniforms[id], name); handle_images(base_type, &this->uniforms[id]); @@ -1029,7 +1024,7 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog) assert(found); (void) found; const gl_uniform_storage *storage = &prog->UniformStorage[id]; - const unsigned index = storage->image[i].index; + const unsigned index = storage->opaque[i].index; const GLenum access = (var->data.image_read_only ? GL_READ_ONLY : var->data.image_write_only ? GL_WRITE_ONLY : GL_READ_WRITE); @@ -1238,7 +1233,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog, if (!sh) continue; - if (!uniforms[i].subroutine[j].active) + if (!uniforms[i].opaque[j].active) continue; /* How many new entries for this uniform? */ @@ -1268,7 +1263,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog, if (!sh) continue; - if (!uniforms[i].subroutine[j].active) + if (!uniforms[i].opaque[j].active) continue; sh->SubroutineUniformRemapTable = |