mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/ir: Validate register types.
This commit is contained in:
parent
b09cfbda90
commit
585e60ad3b
Notes:
Alexandre Julliard
2023-09-22 22:46:19 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/317
@ -1322,12 +1322,39 @@ static void VKD3D_PRINTF_FUNC(3, 4) validator_error(struct validation_context *c
|
||||
vkd3d_string_buffer_cleanup(&buf);
|
||||
}
|
||||
|
||||
static void vsir_validate_register(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_register *reg)
|
||||
{
|
||||
if (reg->type >= VKD3DSPR_COUNT)
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE, "Invalid register type %#x.",
|
||||
reg->type);
|
||||
}
|
||||
|
||||
static void vsir_validate_dst_param(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_dst_param *dst)
|
||||
{
|
||||
vsir_validate_register(ctx, &dst->reg);
|
||||
}
|
||||
|
||||
static void vsir_validate_src_param(struct validation_context *ctx,
|
||||
const struct vkd3d_shader_src_param *src)
|
||||
{
|
||||
vsir_validate_register(ctx, &src->reg);
|
||||
}
|
||||
|
||||
static void vsir_validate_instruction(struct validation_context *ctx)
|
||||
{
|
||||
const struct vkd3d_shader_instruction *instruction = &ctx->parser->instructions.elements[ctx->instruction_idx];
|
||||
size_t i;
|
||||
|
||||
ctx->parser->location = instruction->location;
|
||||
|
||||
for (i = 0; i < instruction->dst_count; ++i)
|
||||
vsir_validate_dst_param(ctx, &instruction->dst[i]);
|
||||
|
||||
for (i = 0; i < instruction->src_count; ++i)
|
||||
vsir_validate_src_param(ctx, &instruction->src[i]);
|
||||
|
||||
if (instruction->handler_idx >= VKD3DSIH_INVALID)
|
||||
{
|
||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER, "Invalid instruction handler %#x.",
|
||||
|
@ -184,6 +184,7 @@ enum vkd3d_shader_error
|
||||
|
||||
VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED = 9000,
|
||||
VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER = 9001,
|
||||
VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE = 9002,
|
||||
};
|
||||
|
||||
enum vkd3d_shader_opcode
|
||||
|
Loading…
x
Reference in New Issue
Block a user