From 16efb7c0c6fb5dbc96db9cb4c14c0e1907c896fd Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 9 Oct 2024 11:36:06 +0200 Subject: [PATCH] vkd3d-shader: Ignore the patch constant signature when it doesn't make sense. --- libs/vkd3d-shader/dxil.c | 15 +++++++++++++++ libs/vkd3d-shader/tpf.c | 15 +++++++++++++++ libs/vkd3d-shader/vkd3d_shader_main.c | 2 ++ 3 files changed, 32 insertions(+) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index c66b0593..5db9d6da 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -10315,6 +10315,21 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, struct vsir_pro sm6->ptr = &sm6->start[1]; sm6->bitpos = 2; + switch (program->shader_version.type) + { + case VKD3D_SHADER_TYPE_HULL: + case VKD3D_SHADER_TYPE_DOMAIN: + break; + + default: + if (program->patch_constant_signature.element_count != 0) + { + WARN("The patch constant signature only makes sense for Hull and Domain Shaders, ignoring it.\n"); + shader_signature_cleanup(&program->patch_constant_signature); + } + break; + } + input_signature = &program->input_signature; output_signature = &program->output_signature; patch_constant_signature = &program->patch_constant_signature; diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 89b3f56d..b097aa7f 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2914,6 +2914,21 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL) uninvert_used_masks(&program->patch_constant_signature); + switch (program->shader_version.type) + { + case VKD3D_SHADER_TYPE_HULL: + case VKD3D_SHADER_TYPE_DOMAIN: + break; + + default: + if (program->patch_constant_signature.element_count != 0) + { + WARN("The patch constant signature only makes sense for Hull and Domain Shaders, ignoring it.\n"); + shader_signature_cleanup(&program->patch_constant_signature); + } + break; + } + if (!shader_sm4_parser_validate_signature(&sm4, &program->input_signature, sm4.input_register_masks, "Input") || !shader_sm4_parser_validate_signature(&sm4, &program->output_signature, diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index de483203..a996aaa1 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1846,6 +1846,8 @@ void shader_signature_cleanup(struct shader_signature *signature) } vkd3d_free(signature->elements); signature->elements = NULL; + signature->elements_capacity = 0; + signature->element_count = 0; } int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,