Mesa (master): spirv: Add an option for making FragCoord a sysval

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 8 12:29:18 UTC 2019


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Mon May 13 15:32:26 2019 +0200

spirv: Add an option for making FragCoord a sysval

On AMD, FragCoord should be a sysval because it is handled separately
from all the other inputs. We were already doing this in radeonsi, but
we weren't doing it with radv. It'll be much more annoying to handle
VARYING_SLOT_POS in fragment shaders when we let NIR lower FS inputs for
us, so here we add an option so that radv can get it as a system value.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/compiler/spirv/nir_spirv.h     | 5 +++++
 src/compiler/spirv/vtn_variables.c | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index c4381bdf62e..d427a9a1973 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -70,6 +70,11 @@ struct spirv_to_nir_options {
    /* Whether or not to lower all UBO/SSBO access to offsets up-front. */
    bool lower_ubo_ssbo_access_to_offsets;
 
+   /* Whether to make FragCoord to a system value, the same as
+    * GLSLFragCoordIsSysVal in GLSL.
+    */
+   bool frag_coord_is_sysval;
+
    struct spirv_supported_capabilities caps;
 
    /* Address format for various kinds of pointers. */
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index b7ec2edd06c..d2d684f11bb 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1295,8 +1295,13 @@ vtn_get_builtin_location(struct vtn_builder *b,
       set_mode_system_value(b, mode);
       break;
    case SpvBuiltInFragCoord:
-      *location = VARYING_SLOT_POS;
       vtn_assert(*mode == nir_var_shader_in);
+      if (b->options && b->options->frag_coord_is_sysval) {
+         *mode = nir_var_system_value;
+         *location = SYSTEM_VALUE_FRAG_COORD;
+      } else {
+         *location = VARYING_SLOT_POS;
+      }
       break;
    case SpvBuiltInPointCoord:
       *location = VARYING_SLOT_PNTC;




More information about the mesa-commit mailing list