From 504f4223c25efb8ae450258a9845dea6a67d5280 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 11 Sep 2024 16:58:55 +0200 Subject: [PATCH] vkd3d-shader/ir: Introduce a helper for validating LABEL. --- libs/vkd3d-shader/ir.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 1515ec19..940d49c1 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6229,6 +6229,15 @@ static void vsir_validate_ifc(struct validation_context *ctx, const struct vkd3d vsir_validator_push_block(ctx, VKD3DSIH_IF); } +static void vsir_validate_label(struct validation_context *ctx, const struct vkd3d_shader_instruction *instruction) +{ + vsir_validate_cf_type(ctx, instruction, VSIR_CF_BLOCKS); + if (instruction->src_count >= 1 && !vsir_register_is_label(&instruction->src[0].reg)) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE, + "Invalid register of type %#x in a LABEL instruction, expected LABEL.", + instruction->src[0].reg.type); +} + static void vsir_validate_loop(struct validation_context *ctx, const struct vkd3d_shader_instruction *instruction) { vsir_validate_cf_type(ctx, instruction, VSIR_CF_STRUCTURED); @@ -6269,6 +6278,7 @@ static const struct vsir_validator_instruction_desc vsir_validator_instructions[ [VKD3DSIH_ENDSWITCH] = {0, 0, vsir_validate_endswitch}, [VKD3DSIH_IF] = {0, 1, vsir_validate_if}, [VKD3DSIH_IFC] = {0, 2, vsir_validate_ifc}, + [VKD3DSIH_LABEL] = {0, 1, vsir_validate_label}, [VKD3DSIH_LOOP] = {0, ~0u, vsir_validate_loop}, [VKD3DSIH_REP] = {0, 1, vsir_validate_rep}, [VKD3DSIH_RET] = {0, 0, vsir_validate_ret}, @@ -6435,16 +6445,6 @@ static void vsir_validate_instruction(struct validation_context *ctx) switch (instruction->opcode) { - case VKD3DSIH_LABEL: - vsir_validate_cf_type(ctx, instruction, VSIR_CF_BLOCKS); - vsir_validate_dst_count(ctx, instruction, 0); - vsir_validate_src_count(ctx, instruction, 1); - if (instruction->src_count >= 1 && !vsir_register_is_label(&instruction->src[0].reg)) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE, - "Invalid register of type %#x in a LABEL instruction, expected LABEL.", - instruction->src[0].reg.type); - break; - case VKD3DSIH_BRANCH: vsir_validate_cf_type(ctx, instruction, VSIR_CF_BLOCKS); vsir_validate_dst_count(ctx, instruction, 0);