Mesa (18.1): spirv: Apply OriginUpperLeft to FragCoord

Dylan Baker dbaker at kemper.freedesktop.org
Fri May 4 16:38:39 UTC 2018


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

Author: Neil Roberts <nroberts at igalia.com>
Date:   Wed May  2 18:10:00 2018 +0200

spirv: Apply OriginUpperLeft to FragCoord

This behaviour was changed in 1e5b09f42f694687ac. The commit message
for that says it is just a “tidy up” so my assumption is that the
behaviour change was a mistake. It’s a little hard to decipher looking
at the diff, but the previous code before that patch was:

  if (builtin == SpvBuiltInFragCoord || builtin == SpvBuiltInSamplePosition)
     nir_var->data.origin_upper_left = b->origin_upper_left;

  if (builtin == SpvBuiltInFragCoord)
     nir_var->data.pixel_center_integer = b->pixel_center_integer;

After the patch the code was:

  case SpvBuiltInSamplePosition:
     nir_var->data.origin_upper_left = b->origin_upper_left;
     /* fallthrough */
  case SpvBuiltInFragCoord:
     nir_var->data.pixel_center_integer = b->pixel_center_integer;
     break;

Before the patch origin_upper_left affected both builtins and
pixel_center_integer only affected FragCoord. After the patch
origin_upper_left only affects SamplePosition and pixel_center_integer
affects both variables.

This patch tries to restore the previous behaviour by changing the
code to:

  case SpvBuiltInFragCoord:
     nir_var->data.pixel_center_integer = b->pixel_center_integer;
     /* fallthrough */
  case SpvBuiltInSamplePosition:
     nir_var->data.origin_upper_left = b->origin_upper_left;
     break;

This change will be important for ARB_gl_spirv which is meant to
support OriginLowerLeft.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Fixes: 1e5b09f42f694687ac "spirv: Tidy some repeated if checks..."
(cherry picked from commit e17d0ccbbddac455e4c47f5adc2333a531fedd3e)

---

 src/compiler/spirv/vtn_variables.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 9679ff6526..fd8ab7f247 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1419,11 +1419,11 @@ apply_var_decoration(struct vtn_builder *b, nir_variable *nir_var,
       case SpvBuiltInTessLevelInner:
          nir_var->data.compact = true;
          break;
-      case SpvBuiltInSamplePosition:
-         nir_var->data.origin_upper_left = b->origin_upper_left;
-         /* fallthrough */
       case SpvBuiltInFragCoord:
          nir_var->data.pixel_center_integer = b->pixel_center_integer;
+         /* fallthrough */
+      case SpvBuiltInSamplePosition:
+         nir_var->data.origin_upper_left = b->origin_upper_left;
          break;
       default:
          break;




More information about the mesa-commit mailing list