From cf7fade580f53a0e4b2bd3f4b089eef46be15dae Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Tue, 22 Oct 2024 03:00:08 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Store the thread group size in the vsir program. --- libs/vkd3d-shader/hlsl_codegen.c | 7 +++++++ libs/vkd3d-shader/tpf.c | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 6e1b2b43..395ba211 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -7557,6 +7557,13 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl generate_vsir_signature(ctx, program, entry_func); if (version.type == VKD3D_SHADER_TYPE_HULL) generate_vsir_signature(ctx, program, ctx->patch_constant_func); + + if (version.type == VKD3D_SHADER_TYPE_COMPUTE) + { + program->thread_group_size.x = ctx->thread_count[0]; + program->thread_group_size.y = ctx->thread_count[1]; + program->thread_group_size.z = ctx->thread_count[2]; + } } static struct hlsl_ir_jump *loop_unrolling_find_jump(struct hlsl_block *block, struct hlsl_ir_node *stop_point, diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 5c1b1763..ac029724 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4962,15 +4962,13 @@ static void write_sm4_dcl_indexable_temp(const struct tpf_compiler *tpf, uint32_ write_sm4_instruction(tpf, &instr); } -static void write_sm4_dcl_thread_group(const struct tpf_compiler *tpf, const uint32_t thread_count[3]) +static void tpf_dcl_thread_group(const struct tpf_compiler *tpf, const struct vsir_thread_group_size *group_size) { struct sm4_instruction instr = { .opcode = VKD3D_SM5_OP_DCL_THREAD_GROUP, - .idx[0] = thread_count[0], - .idx[1] = thread_count[1], - .idx[2] = thread_count[2], + .idx = {group_size->x, group_size->y, group_size->z}, .idx_count = 3, }; @@ -6544,7 +6542,7 @@ static void tpf_write_shader_function(struct tpf_compiler *tpf, struct hlsl_ir_f } if (tpf->program->shader_version.type == VKD3D_SHADER_TYPE_COMPUTE) - write_sm4_dcl_thread_group(tpf, ctx->thread_count); + tpf_dcl_thread_group(tpf, &tpf->program->thread_group_size); if (temp_count) write_sm4_dcl_temps(tpf, temp_count);