Mesa (master): glsl: Eliminate ir_variable::data.atomic.buffer_index

Kenneth Graunke kwg at kemper.freedesktop.org
Sat Aug 30 06:38:24 UTC 2014


Module: Mesa
Branch: master
Commit: c0cd5bedf66887e958e140c047afc5bc26160000
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c0cd5bedf66887e958e140c047afc5bc26160000

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Mon Jul 14 15:48:36 2014 -0700

glsl: Eliminate ir_variable::data.atomic.buffer_index

Just use ir_variable::data.binding... because that's the where the
binding is stored for everything else that can use layout(binding=).

Valgrind massif results for a trimmed apitrace of dota2:

                  n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
Before (32-bit): 50 40,564,927,443       69,185,408       63,683,871     5,501,537            0
After  (32-bit): 74 40,580,119,657       69,186,544       63,506,327     5,680,217            0

Before (64-bit): 59 36,822,048,449       96,526,888       89,113,000     7,413,888            0
After  (64-bit): 89 36,822,971,897       96,526,616       88,735,296     7,791,320            0

A real savings of 173KiB on 32-bit and 368KiB on 64-bit.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 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 4a4d304..d09ff9e 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1551,6 +1551,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;
@@ -1566,7 +1567,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 18623b9..535693d 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -727,7 +727,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.
        */
@@ -737,7 +737,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 75699fd..603873a 100644
--- a/src/glsl/link_atomics.cpp
+++ b/src/glsl/link_atomics.cpp
@@ -201,7 +201,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 f2c22bb..c055580 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2572,7 +2572,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 6e48be7..6eeed3c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2294,7 +2294,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);




More information about the mesa-commit mailing list