Mesa (master): glsl: emit row_major matrix' s SSBO stores only for components in writemask

Samuel Iglesias Gonsálvez samuelig at kemper.freedesktop.org
Fri Oct 2 06:35:13 UTC 2015


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

Author: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
Date:   Wed Sep 30 15:03:15 2015 +0200

glsl: emit row_major matrix's SSBO stores only for components in writemask

When writing to a column of a row-major matrix, each component of the
vector is stored to non-consecutive memory addresses, so we generate
one instruction per component.

This patch skips the disabled components in the writemask, saving some
store instructions plus avoid storing wrong data on each disabled
component.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/glsl/lower_ubo_reference.cpp |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index e581306..247620e 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -754,6 +754,12 @@ lower_ubo_reference_visitor::emit_access(bool is_write,
             add(base_offset,
                 new(mem_ctx) ir_constant(deref_offset + i * matrix_stride));
          if (is_write) {
+            /* If the component is not in the writemask, then don't
+             * store any value.
+             */
+            if (!((1 << i) & write_mask))
+               continue;
+
             base_ir->insert_after(ssbo_store(swizzle(deref, i, 1), chan_offset, 1));
          } else {
             if (!this->is_shader_storage) {




More information about the mesa-commit mailing list