From: Giovanni Mascellani gmascellani@codeweavers.com
--- libs/vkd3d-shader/ir.c | 29 ++++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 2 ++ 2 files changed, 31 insertions(+)
diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 70961718a..897a1c7aa 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -1554,6 +1554,24 @@ static void vsir_validate_src_param(struct validation_context *ctx, src->modifiers); }
+static void vsir_validate_dst_count(struct validation_context *ctx, + const struct vkd3d_shader_instruction *instruction, unsigned int count) +{ + if (instruction->dst_count != count) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DEST_COUNT, + "Invalid destination count %u for an instruction of type %#x, expected %u.", + instruction->dst_count, instruction->handler_idx, count); +} + +static void vsir_validate_src_count(struct validation_context *ctx, + const struct vkd3d_shader_instruction *instruction, unsigned int count) +{ + if (instruction->src_count != count) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SOURCE_COUNT, + "Invalid source count %u for an instruction of type %#x, expected %u.", + instruction->src_count, instruction->handler_idx, count); +} + static void vsir_validate_instruction(struct validation_context *ctx) { const struct vkd3d_shader_instruction *instruction = &ctx->parser->instructions.elements[ctx->instruction_idx]; @@ -1572,6 +1590,17 @@ static void vsir_validate_instruction(struct validation_context *ctx) validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER, "Invalid instruction handler %#x.", instruction->handler_idx); } + + switch (instruction->handler_idx) + { + case VKD3DSIH_DCL_TEMPS: + vsir_validate_dst_count(ctx, instruction, 0); + vsir_validate_src_count(ctx, instruction, 0); + break; + + default: + break; + } }
void vsir_validate(struct vkd3d_shader_parser *parser) diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index a9d6bd747..ffeb0716a 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -202,6 +202,8 @@ enum vkd3d_shader_error VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE = 9008, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION = 9009, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT = 9010, + VKD3D_SHADER_ERROR_VSIR_INVALID_DEST_COUNT = 9011, + VKD3D_SHADER_ERROR_VSIR_INVALID_SOURCE_COUNT = 9012, };
enum vkd3d_shader_opcode