From 47ec24ebada14bc19ddb8ee49a88f37b2721ca75 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 24 Jan 2024 14:07:20 +0100 Subject: [PATCH] vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_dst_params(). --- libs/vkd3d-shader/d3dbc.c | 5 +++-- libs/vkd3d-shader/dxil.c | 9 +++++---- libs/vkd3d-shader/ir.c | 2 +- libs/vkd3d-shader/tpf.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 12 ++++++------ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index a4ca7aa2..6499a59e 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1089,6 +1089,7 @@ static void shader_sm1_read_instruction(struct vkd3d_shader_sm1_parser *sm1, str { struct vkd3d_shader_src_param *src_params, *predicate; const struct vkd3d_sm1_opcode_info *opcode_info; + struct vsir_program *program = &sm1->p.program; struct vkd3d_shader_dst_param *dst_param; const uint32_t **ptr = &sm1->ptr; uint32_t opcode_token; @@ -1111,7 +1112,7 @@ static void shader_sm1_read_instruction(struct vkd3d_shader_sm1_parser *sm1, str vkd3d_shader_parser_error(&sm1->p, VKD3D_SHADER_ERROR_D3DBC_INVALID_OPCODE, "Invalid opcode %#x (token 0x%08x, shader version %u.%u).", opcode_token & VKD3D_SM1_OPCODE_MASK, opcode_token, - sm1->p.program.shader_version.major, sm1->p.program.shader_version.minor); + program->shader_version.major, program->shader_version.minor); goto fail; } @@ -1123,7 +1124,7 @@ static void shader_sm1_read_instruction(struct vkd3d_shader_sm1_parser *sm1, str predicated = !!(opcode_token & VKD3D_SM1_INSTRUCTION_PREDICATED); ins->predicate = predicate = predicated ? shader_parser_get_src_params(&sm1->p, 1) : NULL; ins->dst_count = opcode_info->dst_count; - ins->dst = dst_param = shader_parser_get_dst_params(&sm1->p, ins->dst_count); + ins->dst = dst_param = vsir_program_get_dst_params(program, ins->dst_count); ins->src_count = opcode_info->src_count; ins->src = src_params = shader_parser_get_src_params(&sm1->p, ins->src_count); if ((!predicate && predicated) || (!src_params && ins->src_count) || (!dst_param && ins->dst_count)) diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 3e1ba391..2718f94f 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -2108,8 +2108,9 @@ static struct vkd3d_shader_src_param *instruction_src_params_alloc(struct vkd3d_ static struct vkd3d_shader_dst_param *instruction_dst_params_alloc(struct vkd3d_shader_instruction *ins, unsigned int count, struct sm6_parser *sm6) { - struct vkd3d_shader_dst_param *params = shader_parser_get_dst_params(&sm6->p, count); - if (!params) + struct vkd3d_shader_dst_param *params; + + if (!(params = vsir_program_get_dst_params(&sm6->p.program, count))) { ERR("Failed to allocate dst params.\n"); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, @@ -7311,8 +7312,8 @@ static enum vkd3d_result sm6_parser_init(struct sm6_parser *sm6, const uint32_t return ret; } - if (!(sm6->output_params = shader_parser_get_dst_params(&sm6->p, output_signature->element_count)) - || !(sm6->input_params = shader_parser_get_dst_params(&sm6->p, input_signature->element_count))) + if (!(sm6->output_params = vsir_program_get_dst_params(&sm6->p.program, output_signature->element_count)) + || !(sm6->input_params = vsir_program_get_dst_params(&sm6->p.program, input_signature->element_count))) { ERR("Failed to allocate input/output parameters.\n"); vkd3d_shader_parser_error(&sm6->p, VKD3D_SHADER_ERROR_DXIL_OUT_OF_MEMORY, diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 56e8d974..2d388b85 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -74,7 +74,7 @@ static bool vsir_instruction_init_with_params(struct vkd3d_shader_parser *parser ins->dst_count = dst_count; ins->src_count = src_count; - if (!(ins->dst = shader_parser_get_dst_params(parser, ins->dst_count))) + if (!(ins->dst = vsir_program_get_dst_params(&parser->program, ins->dst_count))) { ERR("Failed to allocate %u destination parameters.\n", dst_count); return false; diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index e9fd39b8..ed56a347 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2444,7 +2444,7 @@ static void shader_sm4_read_instruction(struct vkd3d_shader_sm4_parser *sm4, str precise = (opcode_token & VKD3D_SM5_PRECISE_MASK) >> VKD3D_SM5_PRECISE_SHIFT; ins->flags |= precise << VKD3DSI_PRECISE_SHIFT; - ins->dst = dst_params = shader_parser_get_dst_params(&sm4->p, ins->dst_count); + ins->dst = dst_params = vsir_program_get_dst_params(&sm4->p.program, ins->dst_count); if (!dst_params && ins->dst_count) { ERR("Failed to allocate dst parameters.\n"); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index e5f706e9..55dc499d 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1287,6 +1287,12 @@ struct vsir_program bool vsir_program_init(struct vsir_program *program, const struct vkd3d_shader_version *version, unsigned int reserve); void vsir_program_cleanup(struct vsir_program *program); +static inline struct vkd3d_shader_dst_param *vsir_program_get_dst_params( + struct vsir_program *program, unsigned int count) +{ + return shader_dst_param_allocator_get(&program->instructions.dst_params, count); +} + struct vkd3d_shader_parser { struct vkd3d_shader_message_context *message_context; @@ -1314,12 +1320,6 @@ bool vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser, enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4); -static inline struct vkd3d_shader_dst_param *shader_parser_get_dst_params( - struct vkd3d_shader_parser *parser, unsigned int count) -{ - return shader_dst_param_allocator_get(&parser->program.instructions.dst_params, count); -} - static inline struct vkd3d_shader_src_param *shader_parser_get_src_params( struct vkd3d_shader_parser *parser, unsigned int count) {