spirv: Builtin Layer is an input for fragment shaders
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 2 Dec 2016 13:16:07 +0000 (14:16 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Sat, 3 Dec 2016 19:50:57 +0000 (20:50 +0100)
This change makes it so we emit a load_input intrinsic when Layer
is read in a fragment shader.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/vtn_variables.c

index 917aa9d84a2753a3984e3e02fb719168ad06b66f..a38d3593f4379baf83d9d54c25a78693196a2648 100644 (file)
@@ -819,7 +819,12 @@ vtn_get_builtin_location(struct vtn_builder *b,
       break;
    case SpvBuiltInLayer:
       *location = VARYING_SLOT_LAYER;
-      *mode = nir_var_shader_out;
+      if (b->shader->stage == MESA_SHADER_FRAGMENT)
+         *mode = nir_var_shader_in;
+      else if (b->shader->stage == MESA_SHADER_GEOMETRY)
+         *mode = nir_var_shader_out;
+      else
+         unreachable("invalid stage for SpvBuiltInLayer");
       break;
    case SpvBuiltInViewportIndex:
       *location = VARYING_SLOT_VIEWPORT;