Module: vkd3d Branch: master Commit: 0f4bda9c9d5b4d301ac96c7168c1ab1928fa0c59 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/0f4bda9c9d5b4d301ac96c7168c1ab...
Author: Giovanni Mascellani gmascellani@codeweavers.com Date: Mon Nov 6 23:11:03 2023 +0100
vkd3d-shader/ir: Keep track of hull shader phases.
---
libs/vkd3d-shader/ir.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 72ba057d..f8f56efd 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -1472,6 +1472,7 @@ struct validation_context struct vkd3d_shader_parser *parser; size_t instruction_idx; bool dcl_temps_found; + enum vkd3d_shader_opcode phase;
enum vkd3d_shader_opcode *blocks; size_t depth; @@ -1620,6 +1621,32 @@ static void vsir_validate_instruction(struct validation_context *ctx) instruction->handler_idx); }
+ switch (instruction->handler_idx) + { + case VKD3DSIH_HS_DECLS: + case VKD3DSIH_HS_CONTROL_POINT_PHASE: + case VKD3DSIH_HS_FORK_PHASE: + case VKD3DSIH_HS_JOIN_PHASE: + vsir_validate_dst_count(ctx, instruction, 0); + vsir_validate_src_count(ctx, instruction, 0); + if (ctx->parser->shader_version.type != VKD3D_SHADER_TYPE_HULL) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER, "Phase instruction %#x is only valid in a hull shader.", + instruction->handler_idx); + if (ctx->depth != 0) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INSTRUCTION_NESTING, "Phase instruction %#x must appear to top level.", + instruction->handler_idx); + ctx->phase = instruction->handler_idx; + return; + + default: + break; + } + + if (ctx->parser->shader_version.type == VKD3D_SHADER_TYPE_HULL && + ctx->phase == VKD3DSIH_INVALID) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_HANDLER, "Instruction %#x appear before any phase instruction in a hull shader.", + instruction->handler_idx); + switch (instruction->handler_idx) { case VKD3DSIH_DCL_TEMPS: @@ -1720,7 +1747,11 @@ static void vsir_validate_instruction(struct validation_context *ctx)
void vsir_validate(struct vkd3d_shader_parser *parser) { - struct validation_context ctx = { .parser = parser }; + struct validation_context ctx = + { + .parser = parser, + .phase = VKD3DSIH_INVALID, + };
if (!(parser->config_flags & VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION)) return;