Mesa (staging/20.0): st/mesa: Treat vertex inputs absent in inputMapping as zero in mesa_to_tgsi

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 27 18:08:05 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 373c5360e4c215fb26468e7958edccb2a8a6b439
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=373c5360e4c215fb26468e7958edccb2a8a6b439

Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date:   Thu Apr 23 12:41:34 2020 +0300

st/mesa: Treat vertex inputs absent in inputMapping as zero in mesa_to_tgsi

After updating vertex inputs being read based on optimized NIR, they may go out
of sync with inputs in mesa IR. Which is translated to TGSI and used together
with NIR if draw doesn't have llvm.

It's much easier to treat such inputs as zero because there is no pass to
entirely get rid of them and they don't contribute to shader's output.

Fixes: d684fb37bfbc47d098158cb03c0672119a4469fe
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2815
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4705>
(cherry picked from commit eeab9c93db84e5759145891e8fdde66a5cdcf917)

---

 .pick_status.json                        | 2 +-
 src/mesa/state_tracker/st_mesa_to_tgsi.c | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 1bffc7a352e..13209f509ce 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -364,7 +364,7 @@
         "description": "st/mesa: Treat vertex inputs absent in inputMapping as zero in mesa_to_tgsi",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "d684fb37bfbc47d098158cb03c0672119a4469fe"
     },
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 03a2dee6778..6aeef378ae3 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -140,8 +140,12 @@ src_register(struct st_translate *t,
          return t->constants[index];
 
    case PROGRAM_INPUT:
-      assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
-      return t->inputs[t->inputMapping[index]];
+      if (t->inputMapping[index] < ARRAY_SIZE(t->inputs))
+         return t->inputs[t->inputMapping[index]];
+      else {
+         assert(t->procType == PIPE_SHADER_VERTEX);
+         return ureg_DECL_constant(t->ureg, 0);
+      }
 
    case PROGRAM_OUTPUT:
       assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));



More information about the mesa-commit mailing list