From 7021a5719368917574206fa5b22cb0b7daae2ba2 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Sun, 13 Oct 2024 22:48:50 +0200 Subject: [PATCH] vkd3d-shader/ir: Introduce a helper for validating UAV registers. --- libs/vkd3d-shader/ir.c | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 5fbf5fbf..3debe3b7 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6330,6 +6330,38 @@ static void vsir_validate_resource_register(struct validation_context *ctx, "Non-NULL relative address for the descriptor index of a RESOURCE register."); } +static void vsir_validate_uav_register(struct validation_context *ctx, + const struct vkd3d_shader_register *reg) +{ + if (reg->precision != VKD3D_SHADER_REGISTER_PRECISION_DEFAULT) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_PRECISION, + "Invalid precision %#x for a UAV register.", + reg->precision); + + if (reg->data_type != VKD3D_DATA_UNUSED) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid data type %#x for a UAV register.", + reg->data_type); + + /* NONE is allowed in counter operations. */ + if (reg->dimension == VSIR_DIMENSION_SCALAR) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION, + "Invalid dimension %#x for a UAV register.", + reg->dimension); + + if (reg->idx_count != 2) + { + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, + "Invalid index count %u for a UAV 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 the descriptor index of a UAV register."); +} + static void vsir_validate_ssa_register(struct validation_context *ctx, const struct vkd3d_shader_register *reg) { @@ -6458,6 +6490,10 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_resource_register(ctx, reg); break; + case VKD3DSPR_UAV: + vsir_validate_uav_register(ctx, reg); + break; + case VKD3DSPR_DEPTHOUTGE: vsir_validate_register_without_indices(ctx, reg); break; @@ -6470,36 +6506,6 @@ static void vsir_validate_register(struct validation_context *ctx, vsir_validate_ssa_register(ctx, reg); break; - case VKD3DSPR_UAV: - if (reg->precision != VKD3D_SHADER_REGISTER_PRECISION_DEFAULT) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_PRECISION, - "Invalid precision %#x for a UAV register.", - reg->precision); - - if (reg->data_type != VKD3D_DATA_UNUSED) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, - "Invalid data type %#x for a UAV register.", - reg->data_type); - - /* NONE is allowed in counter operations. */ - if (reg->dimension == VSIR_DIMENSION_SCALAR) - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION, - "Invalid dimension %#x for a UAV register.", - reg->dimension); - - if (reg->idx_count != 2) - { - validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, - "Invalid index count %u for a UAV 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 the descriptor index of a UAV register."); - break; - case VKD3DSPR_RASTOUT: if (reg->idx_count != 1) {