spirv: handle gl_SampleMask
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 24 Jan 2017 10:49:40 +0000 (11:49 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Wed, 25 Jan 2017 07:08:16 +0000 (08:08 +0100)
SPIR-V maps both gl_SampleMask and gl_SampleMaskIn to the same
builtin (SampleMask). The only way to tell which one we are dealing with
is to check if it is an input or an output.

Fixes:
dEQP-VK.pipeline.multisample_shader_builtin.sample_mask.write.*

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/compiler/spirv/vtn_variables.c

index d55f81e5d34ba2694bea5106cbfb9e5725174ee1..4d1ec789cc36ae1ec0683bab9052011bd85ffd09 100644 (file)
@@ -975,8 +975,12 @@ vtn_get_builtin_location(struct vtn_builder *b,
       set_mode_system_value(mode);
       break;
    case SpvBuiltInSampleMask:
-      *location = SYSTEM_VALUE_SAMPLE_MASK_IN; /* XXX out? */
-      set_mode_system_value(mode);
+      if (*mode == nir_var_shader_out) {
+         *location = FRAG_RESULT_SAMPLE_MASK;
+      } else {
+         *location = SYSTEM_VALUE_SAMPLE_MASK_IN;
+         set_mode_system_value(mode);
+      }
       break;
    case SpvBuiltInFragDepth:
       *location = FRAG_RESULT_DEPTH;