From 45495f54f26b3a3f7dcc1fadaf787e16f6c54c1b Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 9 Jan 2024 22:47:38 +0100 Subject: [PATCH] vkd3d-shader/spirv: Use capability ShaderViewportIndexLayerEXT for decoration ViewportIndex. --- libs/vkd3d-shader/spirv.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index b28f94fb..e837fc2e 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -4270,7 +4270,31 @@ static void spirv_compiler_decorate_builtin(struct spirv_compiler *compiler, } break; case SpvBuiltInViewportIndex: - vkd3d_spirv_enable_capability(builder, SpvCapabilityMultiViewport); + switch (compiler->shader_type) + { + case VKD3D_SHADER_TYPE_PIXEL: + case VKD3D_SHADER_TYPE_GEOMETRY: + vkd3d_spirv_enable_capability(builder, SpvCapabilityMultiViewport); + break; + + case VKD3D_SHADER_TYPE_VERTEX: + case VKD3D_SHADER_TYPE_DOMAIN: + if (!spirv_compiler_is_target_extension_supported(compiler, + VKD3D_SHADER_SPIRV_EXTENSION_EXT_VIEWPORT_INDEX_LAYER)) + { + FIXME("The target environment does not support decoration ViewportIndex.\n"); + spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_UNSUPPORTED_FEATURE, + "Cannot use SV_ViewportArrayIndex. " + "The target environment does not support decoration ViewportIndex."); + } + vkd3d_spirv_enable_capability(builder, SpvCapabilityShaderViewportIndexLayerEXT); + break; + + default: + spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_INVALID_SHADER, + "Invalid use of SV_ViewportArrayIndex."); + break; + } break; case SpvBuiltInSampleId: vkd3d_spirv_enable_capability(builder, SpvCapabilitySampleRateShading);