From 15d8591a261a712d874f00b5179ad194857218c7 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sun, 13 Oct 2024 22:53:06 +0200 Subject: [PATCH] vkd3d-shader/ir: Introduce a helper for validating RASTOUT 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 3debe3b7..b034e081 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6240,6 +6240,26 @@ static void vsir_validate_temp_register(struct validation_context *ctx, } } +static void vsir_validate_rastout_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 RASTOUT 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 RASTOUT register."); + + if (reg->idx[0].offset >= 3) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, + "Invalid offset for a RASTOUT register."); +} + static void vsir_validate_label_register(struct validation_context *ctx, const struct vkd3d_shader_register *reg) { @@ -6462,6 +6482,10 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_temp_register(ctx, reg); break; + case VKD3DSPR_RASTOUT: + vsir_validate_rastout_register(ctx, reg); + break; + case VKD3DSPR_DEPTHOUT: vsir_validate_register_without_indices(ctx, reg); break; @@ -6506,24 +6530,6 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_ssa_register(ctx, reg); break; - case VKD3DSPR_RASTOUT: - if (reg->idx_count != 1) - { - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, - "Invalid index count %u for a RASTOUT 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 RASTOUT register."); - - if (reg->idx[0].offset >= 3) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, - "Invalid offset for a RASTOUT register."); - break; - case VKD3DSPR_MISCTYPE: if (reg->idx_count != 1) {