Mesa (master): v3d/compiler: extend swapping R/B support to all vertex attributes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 5 12:53:15 UTC 2020


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

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Fri Oct 16 11:27:42 2020 +0200

v3d/compiler: extend swapping R/B support to all vertex attributes

So far the support for R/B swapping in vertex attributes were for the
generic attributes.

But there are cases like glSecondaryColorPointer() supporting BGRA
formats that require the R/B swapping to be also allowed in the
non-generic vertex attributes (in this case, in the COLOR1 attribute).

v2:
 - Don't split line (Iago)

Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7196>

---

 src/broadcom/compiler/nir_to_vir.c       | 10 +++-------
 src/broadcom/compiler/v3d_compiler.h     |  2 +-
 src/broadcom/compiler/v3d_nir_lower_io.c |  5 ++---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 2bd88741919..0a961cb41d1 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1611,14 +1611,10 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
                 c->vattr_sizes[loc] = MAX2(c->vattr_sizes[loc],
                                            start_component + num_components);
 
-                /* Handle BGRA user inputs */
+                /* Handle BGRA inputs */
                 if (start_component == 0 &&
-                    var->data.location >= VERT_ATTRIB_GENERIC0) {
-                        int32_t idx = var->data.location - VERT_ATTRIB_GENERIC0;
-                        if (c->vs_key->va_swap_rb_mask & (1 << idx)) {
-                                c->vattr_sizes[loc] =
-                                        MAX2(3, c->vattr_sizes[loc]);
-                        }
+                    c->vs_key->va_swap_rb_mask & (1 << var->data.location)) {
+                        c->vattr_sizes[loc] = MAX2(3, c->vattr_sizes[loc]);
                 }
         }
 
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index 8d78bb4f183..6e176491428 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -418,7 +418,7 @@ struct v3d_vs_key {
          * vertex attributes. Since the hardware doesn't provide any
          * means to swizzle vertex attributes we need to do it in the shader.
          */
-        uint16_t va_swap_rb_mask;
+        uint32_t va_swap_rb_mask;
 
         bool is_coord;
         bool per_vertex_point_size;
diff --git a/src/broadcom/compiler/v3d_nir_lower_io.c b/src/broadcom/compiler/v3d_nir_lower_io.c
index 520a8e608a8..7d8fa4667d6 100644
--- a/src/broadcom/compiler/v3d_nir_lower_io.c
+++ b/src/broadcom/compiler/v3d_nir_lower_io.c
@@ -332,9 +332,8 @@ v3d_nir_lower_vertex_input(struct v3d_compile *c, nir_builder *b,
         if (!c->vs_key->va_swap_rb_mask)
                 return;
 
-        const uint32_t location =
-           nir_intrinsic_io_semantics(instr).location - VERT_ATTRIB_GENERIC0;
-        assert(location < V3D_MAX_VS_INPUTS / 4);
+        const uint32_t location = nir_intrinsic_io_semantics(instr).location;
+
         if (!(c->vs_key->va_swap_rb_mask & (1 << location)))
                 return;
 



More information about the mesa-commit mailing list