From 343a365c97e91a38ce56c91ee54f86b00d82043b Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Tue, 12 Mar 2024 19:28:59 +0100 Subject: [PATCH 1/5] vkd3d-shader/ir: Pass a struct vsir_program to instruction_array_lower_texkills(). --- libs/vkd3d-shader/ir.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 759c89957d..317fb1c6c5 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -94,9 +94,8 @@ static bool vsir_instruction_init_with_params(struct vsir_program *program, return true; } -static enum vkd3d_result instruction_array_lower_texkills(struct vkd3d_shader_parser *parser) +static enum vkd3d_result vsir_program_lower_texkills(struct vsir_program *program) { - struct vsir_program *program = &parser->program; struct vkd3d_shader_instruction_array *instructions = &program->instructions; struct vkd3d_shader_instruction *texkill_ins, *ins; unsigned int components_read = 3 + (program->shader_version.major >= 2); @@ -3906,25 +3905,25 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, const struct vkd3d_shader_compile_info *compile_info) { - struct vkd3d_shader_instruction_array *instructions = &parser->program.instructions; + struct vsir_program *program = &parser->program; enum vkd3d_result result = VKD3D_OK; - remove_dcl_temps(&parser->program); + remove_dcl_temps(program); - if ((result = instruction_array_lower_texkills(parser)) < 0) + if ((result = vsir_program_lower_texkills(program)) < 0) return result; - if (parser->program.shader_version.major >= 6) + if (program->shader_version.major >= 6) { struct vsir_cfg cfg; - if ((result = lower_switch_to_if_ladder(&parser->program)) < 0) + if ((result = lower_switch_to_if_ladder(program)) < 0) return result; if ((result = materialize_ssas_to_temps(parser)) < 0) return result; - if ((result = vsir_cfg_init(&cfg, &parser->program, parser->message_context)) < 0) + if ((result = vsir_cfg_init(&cfg, program, parser->message_context)) < 0) return result; vsir_cfg_compute_dominators(&cfg); @@ -3957,29 +3956,29 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, } else { - if (parser->program.shader_version.type != VKD3D_SHADER_TYPE_PIXEL) + if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL) { if ((result = remap_output_signature(parser, compile_info)) < 0) return result; } - if (parser->program.shader_version.type == VKD3D_SHADER_TYPE_HULL) + if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL) { - if ((result = instruction_array_flatten_hull_shader_phases(instructions)) < 0) + if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0) return result; - if ((result = instruction_array_normalise_hull_shader_control_point_io(instructions, - &parser->program.input_signature)) < 0) + if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions, + &program->input_signature)) < 0) return result; } if ((result = shader_normalise_io_registers(parser)) < 0) return result; - if ((result = instruction_array_normalise_flat_constants(&parser->program)) < 0) + if ((result = instruction_array_normalise_flat_constants(program)) < 0) return result; - remove_dead_code(&parser->program); + remove_dead_code(program); if ((result = normalise_combined_samplers(parser)) < 0) return result; @@ -3989,7 +3988,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, return result; if (TRACE_ON()) - vkd3d_shader_trace(&parser->program); + vkd3d_shader_trace(program); if (!parser->failed && (result = vsir_validate(parser)) < 0) return result; -- GitLab From 76791913d0b64a65087b6fcc0831d17b5a3942f2 Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Tue, 12 Mar 2024 19:45:24 +0100 Subject: [PATCH 2/5] vkd3d-shader/ir: Pass a struct vsir_program to materialize_ssas_to_temps_process_reg(). --- libs/vkd3d-shader/ir.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 317fb1c6c5..1a138abdd4 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -2665,33 +2665,36 @@ fail: return VKD3D_ERROR_OUT_OF_MEMORY; } -static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src); +static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program, + struct vkd3d_shader_src_param *src); /* This is idempotent: it can be safely applied more than once on the * same register. */ -static void materialize_ssas_to_temps_process_reg(struct vkd3d_shader_parser *parser, struct vkd3d_shader_register *reg) +static void materialize_ssas_to_temps_process_reg(struct vsir_program *program, struct vkd3d_shader_register *reg) { unsigned int i; if (reg->type == VKD3DSPR_SSA) { reg->type = VKD3DSPR_TEMP; - reg->idx[0].offset += parser->program.temp_count; + reg->idx[0].offset += program->temp_count; } for (i = 0; i < reg->idx_count; ++i) if (reg->idx[i].rel_addr) - materialize_ssas_to_temps_process_src_param(parser, reg->idx[i].rel_addr); + materialize_ssas_to_temps_process_src_param(program, reg->idx[i].rel_addr); } -static void materialize_ssas_to_temps_process_dst_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_dst_param *dst) +static void materialize_ssas_to_temps_process_dst_param(struct vsir_program *program, + struct vkd3d_shader_dst_param *dst) { - materialize_ssas_to_temps_process_reg(parser, &dst->reg); + materialize_ssas_to_temps_process_reg(program, &dst->reg); } -static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src) +static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program, + struct vkd3d_shader_src_param *src) { - materialize_ssas_to_temps_process_reg(parser, &src->reg); + materialize_ssas_to_temps_process_reg(program, &src->reg); } static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_source(struct vkd3d_shader_instruction *ins, @@ -2726,7 +2729,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser src = instruction->src; dst[0] = *dest; - materialize_ssas_to_temps_process_dst_param(parser, &dst[0]); + materialize_ssas_to_temps_process_dst_param(&parser->program, &dst[0]); assert(dst[0].write_mask == VKD3DSP_WRITEMASK_0); assert(dst[0].modifiers == 0); @@ -2738,13 +2741,13 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser src[1 + invert] = *source; memset(&src[2 - invert], 0, sizeof(src[2 - invert])); src[2 - invert].reg = dst[0].reg; - materialize_ssas_to_temps_process_src_param(parser, &src[1]); - materialize_ssas_to_temps_process_src_param(parser, &src[2]); + materialize_ssas_to_temps_process_src_param(&parser->program, &src[1]); + materialize_ssas_to_temps_process_src_param(&parser->program, &src[2]); } else { src[0] = *source; - materialize_ssas_to_temps_process_src_param(parser, &src[0]); + materialize_ssas_to_temps_process_src_param(&parser->program, &src[0]); } return true; @@ -2800,10 +2803,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p size_t j; for (j = 0; j < ins->dst_count; ++j) - materialize_ssas_to_temps_process_dst_param(parser, &ins->dst[j]); + materialize_ssas_to_temps_process_dst_param(&parser->program, &ins->dst[j]); for (j = 0; j < ins->src_count; ++j) - materialize_ssas_to_temps_process_src_param(parser, &ins->src[j]); + materialize_ssas_to_temps_process_src_param(&parser->program, &ins->src[j]); switch (ins->handler_idx) { -- GitLab From c3f3cb5ef99ac4083d03f8db2ea6e6b341b6465f Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Tue, 12 Mar 2024 19:40:45 +0100 Subject: [PATCH 3/5] vkd3d-shader/ir: Pass a struct vsir_program to materialize_ssas_to_temps(). --- libs/vkd3d-shader/ir.c | 65 ++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 1a138abdd4..a2130a892f 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -2713,7 +2713,7 @@ static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_so vkd3d_unreachable(); } -static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser *parser, +static bool materialize_ssas_to_temps_synthesize_mov(struct vsir_program *program, struct vkd3d_shader_instruction *instruction, const struct vkd3d_shader_location *loc, const struct vkd3d_shader_dst_param *dest, const struct vkd3d_shader_src_param *cond, const struct vkd3d_shader_src_param *source, bool invert) @@ -2721,7 +2721,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser struct vkd3d_shader_src_param *src; struct vkd3d_shader_dst_param *dst; - if (!vsir_instruction_init_with_params(&parser->program, instruction, loc, + if (!vsir_instruction_init_with_params(program, instruction, loc, cond ? VKD3DSIH_MOVC : VKD3DSIH_MOV, 1, cond ? 3 : 1)) return false; @@ -2729,7 +2729,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser src = instruction->src; dst[0] = *dest; - materialize_ssas_to_temps_process_dst_param(&parser->program, &dst[0]); + materialize_ssas_to_temps_process_dst_param(program, &dst[0]); assert(dst[0].write_mask == VKD3DSP_WRITEMASK_0); assert(dst[0].modifiers == 0); @@ -2741,19 +2741,19 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser src[1 + invert] = *source; memset(&src[2 - invert], 0, sizeof(src[2 - invert])); src[2 - invert].reg = dst[0].reg; - materialize_ssas_to_temps_process_src_param(&parser->program, &src[1]); - materialize_ssas_to_temps_process_src_param(&parser->program, &src[2]); + materialize_ssas_to_temps_process_src_param(program, &src[1]); + materialize_ssas_to_temps_process_src_param(program, &src[2]); } else { src[0] = *source; - materialize_ssas_to_temps_process_src_param(&parser->program, &src[0]); + materialize_ssas_to_temps_process_src_param(program, &src[0]); } return true; } -static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *parser) +static enum vkd3d_result vsir_program_materialise_ssas_to_temps(struct vsir_program *program) { struct vkd3d_shader_instruction *instructions = NULL; struct materialize_ssas_to_temps_block_data @@ -2764,18 +2764,18 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p size_t ins_capacity = 0, ins_count = 0, i; unsigned int current_label = 0; - if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count)) + if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count)) goto fail; - if (!(block_index = vkd3d_calloc(parser->program.block_count, sizeof(*block_index)))) + if (!(block_index = vkd3d_calloc(program->block_count, sizeof(*block_index)))) { ERR("Failed to allocate block index.\n"); goto fail; } - for (i = 0; i < parser->program.instructions.count; ++i) + for (i = 0; i < program->instructions.count; ++i) { - struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i]; + struct vkd3d_shader_instruction *ins = &program->instructions.elements[i]; switch (ins->handler_idx) { @@ -2797,16 +2797,16 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p } } - for (i = 0; i < parser->program.instructions.count; ++i) + for (i = 0; i < program->instructions.count; ++i) { - struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i]; + struct vkd3d_shader_instruction *ins = &program->instructions.elements[i]; size_t j; for (j = 0; j < ins->dst_count; ++j) - materialize_ssas_to_temps_process_dst_param(&parser->program, &ins->dst[j]); + materialize_ssas_to_temps_process_dst_param(program, &ins->dst[j]); for (j = 0; j < ins->src_count; ++j) - materialize_ssas_to_temps_process_src_param(&parser->program, &ins->src[j]); + materialize_ssas_to_temps_process_src_param(program, &ins->src[j]); switch (ins->handler_idx) { @@ -2827,9 +2827,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p { const struct vkd3d_shader_src_param *source; - source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label); - if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location, - &parser->program.instructions.elements[j].dst[0], NULL, source, false)) + source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j], + current_label); + if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count], + &ins->location, &program->instructions.elements[j].dst[0], NULL, source, false)) goto fail; ++ins_count; @@ -2849,9 +2850,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p { const struct vkd3d_shader_src_param *source; - source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label); - if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location, - &parser->program.instructions.elements[j].dst[0], cond, source, false)) + source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j], + current_label); + if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count], + &ins->location, &program->instructions.elements[j].dst[0], cond, source, false)) goto fail; ++ins_count; @@ -2861,9 +2863,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p { const struct vkd3d_shader_src_param *source; - source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label); - if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location, - &parser->program.instructions.elements[j].dst[0], cond, source, true)) + source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j], + current_label); + if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count], + &ins->location, &program->instructions.elements[j].dst[0], cond, source, true)) goto fail; ++ins_count; @@ -2885,13 +2888,13 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p instructions[ins_count++] = *ins; } - vkd3d_free(parser->program.instructions.elements); + vkd3d_free(program->instructions.elements); vkd3d_free(block_index); - parser->program.instructions.elements = instructions; - parser->program.instructions.capacity = ins_capacity; - parser->program.instructions.count = ins_count; - parser->program.temp_count += parser->program.ssa_count; - parser->program.ssa_count = 0; + program->instructions.elements = instructions; + program->instructions.capacity = ins_capacity; + program->instructions.count = ins_count; + program->temp_count += program->ssa_count; + program->ssa_count = 0; return VKD3D_OK; @@ -3923,7 +3926,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, if ((result = lower_switch_to_if_ladder(program)) < 0) return result; - if ((result = materialize_ssas_to_temps(parser)) < 0) + if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0) return result; if ((result = vsir_cfg_init(&cfg, program, parser->message_context)) < 0) -- GitLab From 0edf6d25f37e770ce3606a627cc9bdb4875890a7 Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Tue, 12 Mar 2024 20:24:14 +0100 Subject: [PATCH 4/5] vkd3d-shader/ir: Pass a struct vsir_program to simple_structurizer_run(). --- libs/vkd3d-shader/ir.c | 49 ++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index a2130a892f..6005759714 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -2905,20 +2905,20 @@ fail: return VKD3D_ERROR_OUT_OF_MEMORY; } -static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *parser) +static enum vkd3d_result vsir_program_structurise(struct vsir_program *program) { - const unsigned int block_temp_idx = parser->program.temp_count; + const unsigned int block_temp_idx = program->temp_count; struct vkd3d_shader_instruction *instructions = NULL; const struct vkd3d_shader_location no_loc = {0}; size_t ins_capacity = 0, ins_count = 0, i; bool first_label_found = false; - if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count)) + if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count)) goto fail; - for (i = 0; i < parser->program.instructions.count; ++i) + for (i = 0; i < program->instructions.count; ++i) { - struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i]; + struct vkd3d_shader_instruction *ins = &program->instructions.elements[i]; switch (ins->handler_idx) { @@ -2934,23 +2934,27 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par { first_label_found = true; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1)) goto fail; dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx); src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0])); ins_count++; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0)) goto fail; ins_count++; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1)) goto fail; src_param_init_temp_uint(&instructions[ins_count].src[0], block_temp_idx); ins_count++; } - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1)) goto fail; src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0])); ins_count++; @@ -2962,7 +2966,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par if (vsir_register_is_label(&ins->src[0].reg)) { - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1)) goto fail; dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx); src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0])); @@ -2970,7 +2975,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par } else { - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3)) goto fail; dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx); instructions[ins_count].src[0] = ins->src[0]; @@ -2979,7 +2985,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par ins_count++; } - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0)) + if (!vsir_instruction_init_with_params(program, + &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0)) goto fail; ins_count++; break; @@ -2999,23 +3006,23 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par if (!reserve_instructions(&instructions, &ins_capacity, ins_count + 3)) goto fail; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0)) + if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0)) goto fail; ins_count++; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0)) + if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0)) goto fail; ins_count++; - if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0)) + if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0)) goto fail; ins_count++; - vkd3d_free(parser->program.instructions.elements); - parser->program.instructions.elements = instructions; - parser->program.instructions.capacity = ins_capacity; - parser->program.instructions.count = ins_count; - parser->program.temp_count += 1; + vkd3d_free(program->instructions.elements); + program->instructions.elements = instructions; + program->instructions.capacity = ins_capacity; + program->instructions.count = ins_count; + program->temp_count += 1; return VKD3D_OK; @@ -3952,7 +3959,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, return result; } - if ((result = simple_structurizer_run(parser)) < 0) + if ((result = vsir_program_structurise(program)) < 0) { vsir_cfg_cleanup(&cfg); return result; -- GitLab From 5f1f7ababb6a435a9219d04d7c5c9ea38e9b7e21 Mon Sep 17 00:00:00 2001 From: Henri Verbeet <hverbeet@codeweavers.com> Date: Tue, 12 Mar 2024 21:02:13 +0100 Subject: [PATCH 5/5] vkd3d-shader/ir: Pass a struct vsir_program to remap_output_signature(). --- libs/vkd3d-shader/ir.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 6005759714..0dd31af919 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -229,10 +229,11 @@ static const struct vkd3d_shader_varying_map *find_varying_map( return NULL; } -static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *parser, - const struct vkd3d_shader_compile_info *compile_info) +static enum vkd3d_result vsir_program_remap_output_signature(struct vsir_program *program, + const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context) { - struct shader_signature *signature = &parser->program.output_signature; + const struct vkd3d_shader_location location = {.source_name = compile_info->source_name}; + struct shader_signature *signature = &program->output_signature; const struct vkd3d_shader_varying_map_info *varying_map; unsigned int i; @@ -254,7 +255,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars * location with a different mask. */ if (input_mask && input_mask != e->mask) { - vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, "Aborting due to not yet implemented feature: " "Output mask %#x does not match input mask %#x.", e->mask, input_mask); @@ -271,7 +272,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars { if (varying_map->varying_map[i].output_signature_index >= signature->element_count) { - vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, "Aborting due to not yet implemented feature: " "The next stage consumes varyings not written by this stage."); return VKD3D_ERROR_NOT_IMPLEMENTED; @@ -3918,6 +3919,7 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, const struct vkd3d_shader_compile_info *compile_info) { + struct vkd3d_shader_message_context *message_context = parser->message_context; struct vsir_program *program = &parser->program; enum vkd3d_result result = VKD3D_OK; @@ -3936,7 +3938,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0) return result; - if ((result = vsir_cfg_init(&cfg, program, parser->message_context)) < 0) + if ((result = vsir_cfg_init(&cfg, program, message_context)) < 0) return result; vsir_cfg_compute_dominators(&cfg); @@ -3971,7 +3973,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser, { if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL) { - if ((result = remap_output_signature(parser, compile_info)) < 0) + if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0) return result; } -- GitLab