Don't we need to feed this through vkd3d_shader_spirv_extension?
I think we'll need an extension check and corresponding vkd3d and wined3d (see "viewport_array_index_any_shader") code, yes.
@@ -4284,7 +4286,21 @@ static void spirv_compiler_decorate_builtin(struct spirv_compiler *compiler, spirv_compiler_emit_execution_mode(compiler, SpvExecutionModeDepthReplacing, NULL, 0); break; case SpvBuiltInLayer: - vkd3d_spirv_enable_capability(builder, SpvCapabilityGeometry); + switch (compiler->shader_type) + { + case VKD3D_SHADER_TYPE_PIXEL: + case VKD3D_SHADER_TYPE_GEOMETRY: + vkd3d_spirv_enable_capability(builder, SpvCapabilityGeometry); + break; + + case VKD3D_SHADER_TYPE_VERTEX: + vkd3d_spirv_enable_capability(builder, SpvCapabilityShaderViewportIndexLayerEXT); + break; + + default: + FIXME("Unhandled use of a Layer builtin in a shader of type %u.\n", compiler->shader_type); + break;
We should use spirv_compiler_error() there instead of FIXME.