nir: Fix printing of ~0 .locations.
authorEric Anholt <eric@anholt.net>
Thu, 19 Dec 2019 00:46:41 +0000 (16:46 -0800)
committerMarge Bot <eric+marge@anholt.net>
Thu, 16 Jan 2020 23:29:10 +0000 (23:29 +0000)
I kept wondering what "429" meant in variable declarations, when it was
just a truncated ~0 snprintf.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3423>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3423>

src/compiler/nir/nir_print.c

index 5d81d3424f7741b75c13d3ab0b93fd6ecb94d6c6..aa9ee670a70788d3d8d513ce1697aeec08a3cbf0 100644 (file)
@@ -562,8 +562,12 @@ print_var_decl(nir_variable *var, print_state *state)
       }
 
       if (!loc) {
-         snprintf(buf, sizeof(buf), "%u", var->data.location);
-         loc = buf;
+         if (var->data.location == ~0) {
+            loc = "~0";
+         } else {
+            snprintf(buf, sizeof(buf), "%u", var->data.location);
+            loc = buf;
+         }
       }
 
       /* For shader I/O vars that have been split to components or packed,