From 296ad630db9607d7a8ec0ab048a3bf403ee05115 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 11 Jan 2023 15:09:33 -0800 Subject: [PATCH] spirv2dxil: Support dispatches with base group indices Part-of: --- src/microsoft/spirv_to_dxil/dxil_spirv_nir.c | 8 ++++++++ src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c index eed5b34..d98062e 100644 --- a/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c +++ b/src/microsoft/spirv_to_dxil/dxil_spirv_nir.c @@ -140,6 +140,10 @@ lower_shader_system_values(struct nir_builder *builder, nir_instr *instr, offset = offsetof(struct dxil_spirv_compute_runtime_data, group_count_x); break; + case nir_intrinsic_load_base_workgroup_id: + offset = + offsetof(struct dxil_spirv_compute_runtime_data, base_group_x); + break; case nir_intrinsic_load_first_vertex: offset = offsetof(struct dxil_spirv_vertex_runtime_data, first_vertex); break; @@ -866,6 +870,10 @@ dxil_spirv_nir_passes(nir_shader *nir, NIR_PASS_V(nir, nir_lower_system_values); + nir_lower_compute_system_values_options compute_options = { + .has_base_workgroup_id = !conf->zero_based_compute_workgroup_id, + }; + NIR_PASS_V(nir, nir_lower_compute_system_values, &compute_options); NIR_PASS_V(nir, dxil_nir_lower_subgroup_id); NIR_PASS_V(nir, dxil_nir_lower_num_subgroups); diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index a95bffa..8b487fa 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -90,6 +90,11 @@ struct dxil_spirv_compute_runtime_data { uint32_t group_count_x; uint32_t group_count_y; uint32_t group_count_z; + uint32_t padding0; + /* Base */ + uint32_t base_group_x; + uint32_t base_group_y; + uint32_t base_group_z; }; #define DXIL_SPIRV_Y_FLIP_MASK BITFIELD_MASK(DXIL_SPIRV_MAX_VIEWPORT) @@ -146,6 +151,8 @@ struct dxil_spirv_runtime_conf { // Set true if vertex and instance ids have already been converted to // zero-based. Otherwise, runtime_data will be required to lower them. bool zero_based_vertex_instance_id; + // Set true if workgroup base is known to be zero + bool zero_based_compute_workgroup_id; struct { // mode != DXIL_SPIRV_YZ_FLIP_NONE only valid on vertex/geometry stages. -- 2.7.4