vkd3d-shader/ir: Introduce a helper for validating registers without indices.

This commit is contained in:
Giovanni Mascellani 2024-10-13 22:42:25 +02:00 committed by Henri Verbeet
parent ce638b9cca
commit 52761e689b
Notes: Henri Verbeet 2024-10-14 15:46:02 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1176

View File

@ -6180,6 +6180,15 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c
ctx->status = VKD3D_ERROR_INVALID_SHADER;
}
static void vsir_validate_register_without_indices(struct validation_context *ctx,
const struct vkd3d_shader_register *reg)
{
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
"Invalid index count %u for a register of type %#x.",
reg->idx_count, reg->type);
}
static void vsir_validate_temp_register(struct validation_context *ctx,
const struct vkd3d_shader_register *reg)
{
@ -6366,30 +6375,36 @@ static void vsir_validate_register(struct validation_context *ctx,
vsir_validate_temp_register(ctx, reg);
break;
case VKD3DSPR_DEPTHOUT:
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_LABEL:
vsir_validate_label_register(ctx, reg);
break;
case VKD3DSPR_SSA:
vsir_validate_ssa_register(ctx, reg);
break;
case VKD3DSPR_NULL:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, "Invalid index count %u for a NULL register.",
reg->idx_count);
break;
case VKD3DSPR_IMMCONST:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, "Invalid index count %u for a IMMCONST register.",
reg->idx_count);
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_IMMCONST64:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, "Invalid index count %u for a IMMCONST64 register.",
reg->idx_count);
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_NULL:
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_DEPTHOUTGE:
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_DEPTHOUTLE:
vsir_validate_register_without_indices(ctx, reg);
break;
case VKD3DSPR_SSA:
vsir_validate_ssa_register(ctx, reg);
break;
case VKD3DSPR_SAMPLER:
@ -6480,27 +6495,6 @@ static void vsir_validate_register(struct validation_context *ctx,
"Non-NULL relative address for the descriptor index of a UAV register.");
break;
case VKD3DSPR_DEPTHOUT:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
"Invalid index count %u for a DEPTHOUT register.",
reg->idx_count);
break;
case VKD3DSPR_DEPTHOUTGE:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
"Invalid index count %u for a DEPTHOUTGE register.",
reg->idx_count);
break;
case VKD3DSPR_DEPTHOUTLE:
if (reg->idx_count != 0)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
"Invalid index count %u for a DEPTHOUTLE register.",
reg->idx_count);
break;
case VKD3DSPR_RASTOUT:
if (reg->idx_count != 1)
{