From: Ian Romanick <ian.d.roman...@intel.com> Just use ir_variable::data.binding... because that's the where the binding is stored for everything else that can use layout(binding=).
No change in the peak ir_variable memory usage in a trimmed apitrace of dota2 on 64-bit. Reduces the peak ir_variable memory usage in a trimmed apitrace of dota2 by 102KiB on 32-bit. Before: IR MEM: variable usage / name / total: 4955496 915817 5871313 After: IR MEM: variable usage / name / total: 4850844 915817 5766661 Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/glsl/ir.cpp | 2 +- src/glsl/ir.h | 3 +-- src/glsl/link_atomics.cpp | 4 +++- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index ba8a839..65541c2 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1546,6 +1546,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->data.has_initializer = false; this->data.location = -1; this->data.location_frac = 0; + this->data.binding = 0; this->warn_extension = NULL; this->constant_value = NULL; this->constant_initializer = NULL; @@ -1561,7 +1562,6 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, this->data.mode = mode; this->data.interpolation = INTERP_QUALIFIER_NONE; this->data.max_array_access = 0; - this->data.atomic.buffer_index = 0; this->data.atomic.offset = 0; this->data.image.read_only = false; this->data.image.write_only = false; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index ef4a12d..93d5aef 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -684,7 +684,7 @@ public: int index; /** - * Initial binding point for a sampler or UBO. + * Initial binding point for a sampler, atomic, or UBO. * * For array types, this represents the binding point for the first element. */ @@ -694,7 +694,6 @@ public: * Location an atomic counter is stored at. */ struct { - unsigned buffer_index; unsigned offset; } atomic; diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp index d92cdb1..8655269 100644 --- a/src/glsl/link_atomics.cpp +++ b/src/glsl/link_atomics.cpp @@ -192,7 +192,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, gl_uniform_storage *const storage = &prog->UniformStorage[id]; mab.Uniforms[j] = id; - var->data.atomic.buffer_index = i; + if (!var->data.explicit_binding) + var->data.binding = i; + storage->atomic_buffer_index = i; storage->offset = var->data.atomic.offset; storage->array_stride = (var->type->is_array() ? diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index dcc8441..f2b34e2 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2278,7 +2278,7 @@ fs_visitor::visit_atomic_counter_intrinsic(ir_call *ir) ir->actual_parameters.get_head()); ir_variable *location = deref->variable_referenced(); unsigned surf_index = (prog_data->base.binding_table.abo_start + - location->data.atomic.buffer_index); + location->data.binding); /* Calculate the surface offset */ fs_reg offset(this, glsl_type::uint_type); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 7bad81c..d72c47c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -2198,7 +2198,7 @@ vec4_visitor::visit_atomic_counter_intrinsic(ir_call *ir) ir->actual_parameters.get_head()); ir_variable *location = deref->variable_referenced(); unsigned surf_index = (prog_data->base.binding_table.abo_start + - location->data.atomic.buffer_index); + location->data.binding); /* Calculate the surface offset */ src_reg offset(this, glsl_type::uint_type); -- 1.8.1.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev