vkd3d-shader/ir: Pass a struct vsir_program to shader_parser_get_dst_params().

This commit is contained in:
Henri Verbeet 2024-01-24 14:07:20 +01:00 committed by Alexandre Julliard
parent ced8543952
commit 47ec24ebad
Notes: Alexandre Julliard 2024-02-01 00:31:27 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/614
5 changed files with 16 additions and 14 deletions

View File

@ -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))

View File

@ -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,

View File

@ -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;

View File

@ -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");

View File

@ -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)
{