From 936adff58b3a12e32e1fb42010e5fbc5ad98e38a Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 12 Sep 2024 11:51:41 +0200 Subject: [PATCH] vkd3d-shader/ir: Introduce a helper for validating DCL_INPUT_PRIMITIVE. --- libs/vkd3d-shader/ir.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 677557d5..feeae3db 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6208,6 +6208,15 @@ static void vsir_validate_dcl_hs_max_tessfactor(struct validation_context *ctx, instruction->declaration.max_tessellation_factor); } +static void vsir_validate_dcl_input_primitive(struct validation_context *ctx, + const struct vkd3d_shader_instruction *instruction) +{ + if (instruction->declaration.primitive_type.type == VKD3D_PT_UNDEFINED + || instruction->declaration.primitive_type.type >= VKD3D_PT_COUNT) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_GS, "GS input primitive %u is invalid.", + instruction->declaration.primitive_type.type); +} + static void vsir_validate_dcl_temps(struct validation_context *ctx, const struct vkd3d_shader_instruction *instruction) { @@ -6446,6 +6455,7 @@ static const struct vsir_validator_instruction_desc vsir_validator_instructions[ { [VKD3DSIH_BRANCH] = {0, ~0u, vsir_validate_branch}, [VKD3DSIH_DCL_HS_MAX_TESSFACTOR] = {0, 0, vsir_validate_dcl_hs_max_tessfactor}, + [VKD3DSIH_DCL_INPUT_PRIMITIVE] = {0, 0, vsir_validate_dcl_input_primitive}, [VKD3DSIH_DCL_TEMPS] = {0, 0, vsir_validate_dcl_temps}, [VKD3DSIH_ELSE] = {0, 0, vsir_validate_else}, [VKD3DSIH_ENDIF] = {0, 0, vsir_validate_endif}, @@ -6504,13 +6514,6 @@ static void vsir_validate_instruction(struct validation_context *ctx) ctx->dcl_temps_found = false; return; - case VKD3DSIH_DCL_INPUT_PRIMITIVE: - if (instruction->declaration.primitive_type.type == VKD3D_PT_UNDEFINED - || instruction->declaration.primitive_type.type >= VKD3D_PT_COUNT) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_GS, "GS input primitive %u is invalid.", - instruction->declaration.primitive_type.type); - return; - case VKD3DSIH_DCL_VERTICES_OUT: if (instruction->declaration.count > 1024) validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_GS, "GS output vertex count %u is invalid.",