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

Author: Iago Toral Quiroga <[email protected]>
Date:   Thu Oct 22 10:40:57 2020 +0200

v3d/compiler: fix BGRA vertex attributes for vec2/float size.

We don't natively support BGRA format, instead we handle these
as RGBA and we lower the loads to swap components R and B.

However, the driver emits VPM loads based on the size of the
input variables so when we have a vec2 or float BGRA input,
it would only emit VPM loads for components 0 and 1, which is
not correct since we emit a load of component 2 to swap with
component 0.

v2: handle GL legacy vertex inputs gracefully.

Fixes:
dEQP-VK.draw.output_location.array.b8g8r8a8-unorm-highp-output-vec2
dEQP-VK.draw.output_location.array.b8g8r8a8-unorm-mediump-output-vec2

Reviewed-by: Alejandro PiƱeiro <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7271>

---

 src/broadcom/compiler/nir_to_vir.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/broadcom/compiler/nir_to_vir.c 
b/src/broadcom/compiler/nir_to_vir.c
index e0de0744150..2bd88741919 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1595,6 +1595,10 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
          * components and unused ones DCEed.  The vertex fetcher will load
          * from the start of the attribute to the number of components we
          * declare we need in c->vattr_sizes[].
+         *
+         * BGRA vertex attributes are a bit special: since we implement these
+         * as RGBA swapping R/B components we always need at least 3 components
+         * if component 0 is read.
          */
         nir_foreach_shader_in_variable(var, c->s) {
                 /* No VS attribute array support. */
@@ -1606,6 +1610,16 @@ 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 */
+                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]);
+                        }
+                }
         }
 
         unsigned num_components = 0;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to