vkd3d-shader/ir: Validate source parameters.

This commit is contained in:
Giovanni Mascellani 2023-08-29 22:23:02 +02:00 committed by Alexandre Julliard
parent 603170106c
commit 34b1c0fe5d
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
2 changed files with 10 additions and 0 deletions

View File

@ -1364,6 +1364,14 @@ static void vsir_validate_src_param(struct validation_context *ctx,
const struct vkd3d_shader_src_param *src) const struct vkd3d_shader_src_param *src)
{ {
vsir_validate_register(ctx, &src->reg); vsir_validate_register(ctx, &src->reg);
if (src->swizzle & ~0x03030303u)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SWIZZLE, "Source has invalid swizzle %#x.",
src->swizzle);
if (src->modifiers >= VKD3DSPSM_COUNT)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_MODIFIERS, "Source has invalid modifiers %#x.",
src->modifiers);
} }
static void vsir_validate_instruction(struct validation_context *ctx) static void vsir_validate_instruction(struct validation_context *ctx)

View File

@ -188,6 +188,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_VSIR_INVALID_WRITE_MASK = 9003, VKD3D_SHADER_ERROR_VSIR_INVALID_WRITE_MASK = 9003,
VKD3D_SHADER_ERROR_VSIR_INVALID_MODIFIERS = 9004, VKD3D_SHADER_ERROR_VSIR_INVALID_MODIFIERS = 9004,
VKD3D_SHADER_ERROR_VSIR_INVALID_SHIFT = 9005, VKD3D_SHADER_ERROR_VSIR_INVALID_SHIFT = 9005,
VKD3D_SHADER_ERROR_VSIR_INVALID_SWIZZLE = 9006,
}; };
enum vkd3d_shader_opcode enum vkd3d_shader_opcode
@ -590,6 +591,7 @@ enum vkd3d_shader_src_modifier
VKD3DSPSM_ABS = 11, VKD3DSPSM_ABS = 11,
VKD3DSPSM_ABSNEG = 12, VKD3DSPSM_ABSNEG = 12,
VKD3DSPSM_NOT = 13, VKD3DSPSM_NOT = 13,
VKD3DSPSM_COUNT,
}; };
#define VKD3DSP_WRITEMASK_0 0x1u /* .x r */ #define VKD3DSP_WRITEMASK_0 0x1u /* .x r */