mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/ir: Introduce a helper for validating LABEL registers.
This commit is contained in:
parent
92d1ba9188
commit
ce638b9cca
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
@ -6231,6 +6231,41 @@ static void vsir_validate_temp_register(struct validation_context *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
static void vsir_validate_label_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 LABEL 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 LABEL register.", reg->data_type);
|
||||
|
||||
if (reg->dimension != VSIR_DIMENSION_NONE)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION,
|
||||
"Invalid dimension %#x for a LABEL register.", reg->dimension);
|
||||
|
||||
if (reg->idx_count != 1)
|
||||
{
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
|
||||
"Invalid index count %u for a LABEL 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 LABEL register.");
|
||||
|
||||
/* Index == 0 is invalid, but it is temporarily allowed
|
||||
* for intermediate stages. Once we support validation
|
||||
* dialects we can selectively check for that. */
|
||||
if (reg->idx[0].offset > ctx->program->block_count)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
|
||||
"LABEL register index %u exceeds the maximum count %u.",
|
||||
reg->idx[0].offset, ctx->program->block_count);
|
||||
}
|
||||
|
||||
static void vsir_validate_ssa_register(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
@ -6331,40 +6366,12 @@ static void vsir_validate_register(struct validation_context *ctx,
|
||||
vsir_validate_temp_register(ctx, reg);
|
||||
break;
|
||||
|
||||
case VKD3DSPR_SSA:
|
||||
vsir_validate_ssa_register(ctx, reg);
|
||||
case VKD3DSPR_LABEL:
|
||||
vsir_validate_label_register(ctx, reg);
|
||||
break;
|
||||
|
||||
case VKD3DSPR_LABEL:
|
||||
if (reg->precision != VKD3D_SHADER_REGISTER_PRECISION_DEFAULT)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_PRECISION, "Invalid precision %#x for a LABEL 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 LABEL register.",
|
||||
reg->data_type);
|
||||
|
||||
if (reg->dimension != VSIR_DIMENSION_NONE)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION, "Invalid dimension %#x for a LABEL register.",
|
||||
reg->dimension);
|
||||
|
||||
if (reg->idx_count != 1)
|
||||
{
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT, "Invalid index count %u for a LABEL 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 LABEL register.");
|
||||
|
||||
/* Index == 0 is invalid, but it is temporarily allowed
|
||||
* for intermediate stages. Once we support validation
|
||||
* dialects we can selectively check for that. */
|
||||
if (reg->idx[0].offset > ctx->program->block_count)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
|
||||
"LABEL register index %u exceeds the maximum count %u.",
|
||||
reg->idx[0].offset, ctx->program->block_count);
|
||||
case VKD3DSPR_SSA:
|
||||
vsir_validate_ssa_register(ctx, reg);
|
||||
break;
|
||||
|
||||
case VKD3DSPR_NULL:
|
||||
|
Loading…
Reference in New Issue
Block a user