From 2f15b30e30d1f6fe8bb2eab938f9e58e89ba7fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 30 Oct 2018 15:22:52 +0100 Subject: [PATCH] vkd3d-shader: Require shader signature elements for shader inputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/spirv.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 4fc25ee4..dee561ac 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3206,6 +3206,13 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi reg_idx = reg->idx[0].offset; } + if (!(signature_element = vkd3d_find_signature_element_for_reg(compiler->input_signature, + NULL, reg_idx, dst->write_mask))) + { + FIXME("No signature element for shader input, ignoring shader input.\n"); + return 0; + } + builtin = get_spirv_builtin_for_sysval(compiler, sysval); component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask); @@ -3217,9 +3224,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi } else { - signature_element = vkd3d_find_signature_element_for_reg(compiler->input_signature, - NULL, reg_idx, dst->write_mask); - component_type = signature_element ? signature_element->component_type : VKD3D_TYPE_FLOAT; + component_type = signature_element->component_type; input_component_count = component_count; } assert(component_count <= input_component_count); @@ -4187,18 +4192,18 @@ static void vkd3d_dxbc_compiler_emit_dcl_input_ps(struct vkd3d_dxbc_compiler *co { uint32_t input_id; - input_id = vkd3d_dxbc_compiler_emit_input(compiler, &instruction->declaration.dst, VKD3D_SIV_NONE); - vkd3d_dxbc_compiler_emit_interpolation_decorations(compiler, input_id, instruction->flags); + if ((input_id = vkd3d_dxbc_compiler_emit_input(compiler, &instruction->declaration.dst, VKD3D_SIV_NONE))) + vkd3d_dxbc_compiler_emit_interpolation_decorations(compiler, input_id, instruction->flags); } static void vkd3d_dxbc_compiler_emit_dcl_input_ps_sysval(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { + const struct vkd3d_shader_register_semantic *semantic = &instruction->declaration.register_semantic; uint32_t input_id; - input_id = vkd3d_dxbc_compiler_emit_input(compiler, &instruction->declaration.register_semantic.reg, - instruction->declaration.register_semantic.sysval_semantic); - if (!instruction->declaration.register_semantic.sysval_semantic) + input_id = vkd3d_dxbc_compiler_emit_input(compiler, &semantic->reg, semantic->sysval_semantic); + if (input_id && !semantic->sysval_semantic) vkd3d_dxbc_compiler_emit_interpolation_decorations(compiler, input_id, instruction->flags); }