Mesa (master): v3d/compiler: Fix sorting the gs and fs inputs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 8 07:57:31 UTC 2020


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

Author: Neil Roberts <nroberts at igalia.com>
Date:   Tue Jul  7 02:02:19 2020 +0200

v3d/compiler: Fix sorting the gs and fs inputs

ntq_setup_fs_inputs and ntq_setup_gs_inputs sort the inputs according to
the driver location. This input array is then used to calculate the VPM
offset for the outputs in the previous stage. However, it wasn’t taking
into account variables that are packed into a single varying slot. In
that case they would have the same driver_location and are
distinguished by location_frac.

This patch makes it additionally sort by location_frac when the driver
locations are equal. This can happen when the compiler packs varyings
that are sized less than vec4. Without this fix, when the VPM is used to
transmit data free-form between the stages (such as VS->GS) then it
would end up writing to inconsistent locations.

Fixes dEQP tests such as:
dEQP-GLES31.functional.primitive_bounding_box.lines.global_state.
vertex_geometry_fragment.default_framebuffer_bbox_equal

Fixes: 5d578c27cec ("v3d: add initial compiler plumbing for geometry shaders")

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5787>

---

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

diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index d95361731cb..8f568d4779a 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1460,6 +1460,9 @@ driver_location_compare(const void *in_a, const void *in_b)
         const nir_variable *const *a = in_a;
         const nir_variable *const *b = in_b;
 
+        if ((*a)->data.driver_location == (*b)->data.driver_location)
+                return (*a)->data.location_frac - (*b)->data.location_frac;
+
         return (*a)->data.driver_location - (*b)->data.driver_location;
 }
 



More information about the mesa-commit mailing list