vkd3d-shader/ir: Validate that signatures are sensible for shader type.

This commit is contained in:
Giovanni Mascellani 2024-10-14 18:15:43 +02:00 committed by Henri Verbeet
parent 859b911b3a
commit 7f834f57e5
Notes: Henri Verbeet 2024-10-15 17:05:01 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1181

View File

@ -6942,11 +6942,23 @@ static void vsir_validate_signature_element(struct validation_context *ctx,
idx, signature_type_name, element->interpolation_mode); idx, signature_type_name, element->interpolation_mode);
} }
static const unsigned int allowed_signature_phases[] =
{
[SIGNATURE_TYPE_INPUT] = PS_BIT | VS_BIT | GS_BIT | HS_BIT | DS_BIT,
[SIGNATURE_TYPE_OUTPUT] = PS_BIT | VS_BIT | GS_BIT | HS_BIT | DS_BIT,
[SIGNATURE_TYPE_PATCH_CONSTANT] = HS_BIT | DS_BIT,
};
static void vsir_validate_signature(struct validation_context *ctx, static void vsir_validate_signature(struct validation_context *ctx,
const struct shader_signature *signature, enum vsir_signature_type signature_type) const struct shader_signature *signature, enum vsir_signature_type signature_type)
{ {
unsigned int i; unsigned int i;
if (signature->element_count != 0 && !(allowed_signature_phases[signature_type]
& (1u << ctx->program->shader_version.type)))
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SIGNATURE,
"Unexpected %s signature.", signature_type_names[signature_type]);
for (i = 0; i < signature->element_count; ++i) for (i = 0; i < signature->element_count; ++i)
vsir_validate_signature_element(ctx, signature, signature_type, i); vsir_validate_signature_element(ctx, signature, signature_type, i);
} }