From 2d452842ed95aeef4e46b3dc17be88933ce88dfd Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sun, 13 Oct 2024 22:54:49 +0200 Subject: [PATCH] vkd3d-shader/ir: Introduce a helper for validating MISCTYPE registers. --- libs/vkd3d-shader/ir.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index b034e081..45951344 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6260,6 +6260,26 @@ static void vsir_validate_rastout_register(struct validation_context *ctx, "Invalid offset for a RASTOUT register."); } +static void vsir_validate_misctype_register(struct validation_context *ctx, + const struct vkd3d_shader_register *reg) +{ + if (reg->idx_count != 1) + { + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, + "Invalid index count %u for a MISCTYPE register.", + reg->idx_count); + return; + } + + if (reg->idx[0].rel_addr) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, + "Non-NULL relative address for a MISCTYPE register."); + + if (reg->idx[0].offset >= 2) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, + "Invalid offset for a MISCTYPE register."); +} + static void vsir_validate_label_register(struct validation_context *ctx, const struct vkd3d_shader_register *reg) { @@ -6490,6 +6510,10 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_register_without_indices(ctx, reg); break; + case VKD3DSPR_MISCTYPE: + vsir_validate_misctype_register(ctx, reg); + break; + case VKD3DSPR_LABEL: vsir_validate_label_register(ctx, reg); break; @@ -6530,24 +6554,6 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_ssa_register(ctx, reg); break; - case VKD3DSPR_MISCTYPE: - if (reg->idx_count != 1) - { - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, - "Invalid index count %u for a MISCTYPE register.", - reg->idx_count); - break; - } - - if (reg->idx[0].rel_addr) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, - "Non-NULL relative address for a MISCTYPE register."); - - if (reg->idx[0].offset >= 2) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, - "Invalid offset for a MISCTYPE register."); - break; - default: break; }