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 IF.
This commit is contained in:
parent
35fe5b48c8
commit
af687c9522
Notes:
Henri Verbeet
2024-09-13 16:05:51 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1067
@ -6147,6 +6147,16 @@ static void vsir_validate_cf_type(struct validation_context *ctx,
|
|||||||
instruction->opcode, name_from_cf_type(ctx->program->cf_type));
|
instruction->opcode, name_from_cf_type(ctx->program->cf_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vsir_validator_push_block(struct validation_context *ctx, enum vkd3d_shader_opcode opcode)
|
||||||
|
{
|
||||||
|
if (!vkd3d_array_reserve((void **)&ctx->blocks, &ctx->blocks_capacity, ctx->depth + 1, sizeof(*ctx->blocks)))
|
||||||
|
{
|
||||||
|
ctx->status = VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->blocks[ctx->depth++] = opcode;
|
||||||
|
}
|
||||||
|
|
||||||
static void vsir_validate_dcl_temps(struct validation_context *ctx,
|
static void vsir_validate_dcl_temps(struct validation_context *ctx,
|
||||||
const struct vkd3d_shader_instruction *instruction)
|
const struct vkd3d_shader_instruction *instruction)
|
||||||
{
|
{
|
||||||
@ -6160,6 +6170,12 @@ static void vsir_validate_dcl_temps(struct validation_context *ctx,
|
|||||||
ctx->dcl_temps_found = true;
|
ctx->dcl_temps_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vsir_validate_if(struct validation_context *ctx, const struct vkd3d_shader_instruction *instruction)
|
||||||
|
{
|
||||||
|
vsir_validate_cf_type(ctx, instruction, VSIR_CF_STRUCTURED);
|
||||||
|
vsir_validator_push_block(ctx, VKD3DSIH_IF);
|
||||||
|
}
|
||||||
|
|
||||||
struct vsir_validator_instruction_desc
|
struct vsir_validator_instruction_desc
|
||||||
{
|
{
|
||||||
unsigned int dst_param_count;
|
unsigned int dst_param_count;
|
||||||
@ -6170,6 +6186,7 @@ struct vsir_validator_instruction_desc
|
|||||||
static const struct vsir_validator_instruction_desc vsir_validator_instructions[] =
|
static const struct vsir_validator_instruction_desc vsir_validator_instructions[] =
|
||||||
{
|
{
|
||||||
[VKD3DSIH_DCL_TEMPS] = {0, 0, vsir_validate_dcl_temps},
|
[VKD3DSIH_DCL_TEMPS] = {0, 0, vsir_validate_dcl_temps},
|
||||||
|
[VKD3DSIH_IF] = {0, 1, vsir_validate_if},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void vsir_validate_instruction(struct validation_context *ctx)
|
static void vsir_validate_instruction(struct validation_context *ctx)
|
||||||
@ -6332,15 +6349,6 @@ static void vsir_validate_instruction(struct validation_context *ctx)
|
|||||||
|
|
||||||
switch (instruction->opcode)
|
switch (instruction->opcode)
|
||||||
{
|
{
|
||||||
case VKD3DSIH_IF:
|
|
||||||
vsir_validate_cf_type(ctx, instruction, VSIR_CF_STRUCTURED);
|
|
||||||
vsir_validate_dst_count(ctx, instruction, 0);
|
|
||||||
vsir_validate_src_count(ctx, instruction, 1);
|
|
||||||
if (!vkd3d_array_reserve((void **)&ctx->blocks, &ctx->blocks_capacity, ctx->depth + 1, sizeof(*ctx->blocks)))
|
|
||||||
return;
|
|
||||||
ctx->blocks[ctx->depth++] = instruction->opcode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VKD3DSIH_IFC:
|
case VKD3DSIH_IFC:
|
||||||
vsir_validate_cf_type(ctx, instruction, VSIR_CF_STRUCTURED);
|
vsir_validate_cf_type(ctx, instruction, VSIR_CF_STRUCTURED);
|
||||||
vsir_validate_dst_count(ctx, instruction, 0);
|
vsir_validate_dst_count(ctx, instruction, 0);
|
||||||
@ -6608,7 +6616,8 @@ enum vkd3d_result vsir_program_validate(struct vsir_program *program, uint64_t c
|
|||||||
if (!(ctx.ssas = vkd3d_calloc(ctx.program->ssa_count, sizeof(*ctx.ssas))))
|
if (!(ctx.ssas = vkd3d_calloc(ctx.program->ssa_count, sizeof(*ctx.ssas))))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
for (ctx.instruction_idx = 0; ctx.instruction_idx < program->instructions.count; ++ctx.instruction_idx)
|
for (ctx.instruction_idx = 0; ctx.instruction_idx < program->instructions.count
|
||||||
|
&& ctx.status != VKD3D_ERROR_OUT_OF_MEMORY; ++ctx.instruction_idx)
|
||||||
vsir_validate_instruction(&ctx);
|
vsir_validate_instruction(&ctx);
|
||||||
|
|
||||||
ctx.invalid_instruction_idx = true;
|
ctx.invalid_instruction_idx = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user