spirv: Add SpvCapabilityShaderViewportIndexLayerEXT
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 5 Mar 2018 21:58:11 +0000 (13:58 -0800)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Wed, 7 Mar 2018 06:04:20 +0000 (07:04 +0100)
This capability allows gl_ViewportIndex and gl_Layer to also be used
as outputs in Vertex and Tesselation shaders.

v2: Make conditional to the capability, add gl_Layer, add tesselation
    shaders. (Iago)

v3: Don't export to tesselation control shader.

v4: Add Reviewd-by tag.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/compiler/shader_info.h
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_variables.c

index e7fd7dbe62de2c63b0abc76d0d7373c744204fca..2fcbde74bee7ef876628b5c7a59d9cef013697f6 100644 (file)
@@ -43,6 +43,7 @@ struct spirv_supported_capabilities {
    bool multiview;
    bool variable_pointers;
    bool storage_16bit;
+   bool shader_viewport_index_layer;
 };
 
 typedef struct shader_info {
index c6df764682eca465a7cb8d659af4c546a12a7943..fdb2993db51d55a73f8b429447c4dd08ad8104b0 100644 (file)
@@ -3203,6 +3203,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          spv_check_supported(storage_16bit, cap);
          break;
 
+      case SpvCapabilityShaderViewportIndexLayerEXT:
+         spv_check_supported(shader_viewport_index_layer, cap);
+         break;
+
       default:
          vtn_fail("Unhandled capability");
       }
index 7e8a090addee8212688ab2b744415d74aead991a..11d2aabac8c530486e54caab1967c82767e76800 100644 (file)
@@ -1187,6 +1187,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
          *mode = nir_var_shader_in;
       else if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
          *mode = nir_var_shader_out;
+      else if (b->options && b->options->caps.shader_viewport_index_layer &&
+               (b->shader->info.stage == MESA_SHADER_VERTEX ||
+                b->shader->info.stage == MESA_SHADER_TESS_EVAL))
+         *mode = nir_var_shader_out;
       else
          vtn_fail("invalid stage for SpvBuiltInLayer");
       break;
@@ -1194,6 +1198,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
       *location = VARYING_SLOT_VIEWPORT;
       if (b->shader->info.stage == MESA_SHADER_GEOMETRY)
          *mode = nir_var_shader_out;
+      else if (b->options && b->options->caps.shader_viewport_index_layer &&
+               (b->shader->info.stage == MESA_SHADER_VERTEX ||
+                b->shader->info.stage == MESA_SHADER_TESS_EVAL))
+         *mode = nir_var_shader_out;
       else if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
          *mode = nir_var_shader_in;
       else