Mesa (main): nir: apply interpolated input intrinsics setting when lowering clipdist
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 22 20:39:50 UTC 2021
Module: Mesa
Branch: main
Commit: 3b5b4b5d45eff268ae9a054a2deb42f0703825c6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b5b4b5d45eff268ae9a054a2deb42f0703825c6
Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date: Sun Nov 21 03:12:51 2021 -0500
nir: apply interpolated input intrinsics setting when lowering clipdist
For drivers that use this in fragment shaders, load_input is going to
produce incorrect results (flat-shaded values).
Fixes clipping tests on a4xx.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13900>
---
src/compiler/nir/nir_lower_clip.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index 5a9438bf386..bb0543df4ca 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -115,10 +115,23 @@ load_clipdist_input(nir_builder *b, nir_variable *in, int location_offset,
.num_slots = 1,
};
- nir_ssa_def *load =
- nir_load_input(b, 4, 32, nir_imm_int(b, 0),
- .base = in->data.driver_location + location_offset,
- .io_semantics = semantics);
+ nir_ssa_def *load;
+ if (b->shader->options->use_interpolated_input_intrinsics) {
+ /* TODO: use sample when per-sample shading? */
+ nir_ssa_def *barycentric = nir_load_barycentric(
+ b, nir_intrinsic_load_barycentric_pixel, INTERP_MODE_NONE);
+ load = nir_load_interpolated_input(
+ b, 4, 32, barycentric, nir_imm_int(b, 0),
+ .base = in->data.driver_location + location_offset,
+ .dest_type = nir_type_float32,
+ .io_semantics = semantics);
+
+ } else {
+ load = nir_load_input(b, 4, 32, nir_imm_int(b, 0),
+ .base = in->data.driver_location + location_offset,
+ .dest_type = nir_type_float32,
+ .io_semantics = semantics);
+ }
val[0] = nir_channel(b, load, 0);
val[1] = nir_channel(b, load, 1);
More information about the mesa-commit
mailing list