From 536ab16bc1e92889c896c1ab251a567bec2fcfd6 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 1 Feb 2023 10:52:57 -0800 Subject: [PATCH] spirv2dxil: Move shader model into runtime conf struct We'll want to use it to control the shape of the nir that we generate Part-of: --- src/microsoft/spirv_to_dxil/spirv2dxil.c | 8 ++++---- src/microsoft/spirv_to_dxil/spirv_to_dxil.c | 3 +-- src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 4 +++- src/microsoft/vulkan/dzn_pipeline.c | 3 +++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/microsoft/spirv_to_dxil/spirv2dxil.c b/src/microsoft/spirv_to_dxil/spirv2dxil.c index 0619111d77c..b7976639ae0 100644 --- a/src/microsoft/spirv_to_dxil/spirv2dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv2dxil.c @@ -75,7 +75,6 @@ struct shader { bool validate = false, debug = false; enum dxil_validator_version val_ver = DXIL_VALIDATOR_1_4; -enum dxil_shader_model shader_model = SHADER_MODEL_6_2; struct nir_shader_compiler_options nir_options; @@ -187,6 +186,7 @@ main(int argc, char **argv) conf.runtime_data_cbv.base_shader_register = 0; conf.runtime_data_cbv.register_space = 31; conf.zero_based_vertex_instance_id = true; + conf.shader_model_max = SHADER_MODEL_6_2; bool any_shaders = false; while ((ch = getopt_long(argc, argv, "-s:e:o:m:x:vd", long_options, NULL)) != @@ -213,8 +213,8 @@ main(int argc, char **argv) debug = true; break; case 'm': - shader_model = SHADER_MODEL_6_0 + atoi(optarg); - nir_options.lower_helper_invocation = shader_model < SHADER_MODEL_6_6; + conf.shader_model_max = SHADER_MODEL_6_0 + atoi(optarg); + nir_options.lower_helper_invocation = conf.shader_model_max < SHADER_MODEL_6_6; break; case 'x': val_ver = DXIL_VALIDATOR_1_0 + atoi(optarg); @@ -250,7 +250,7 @@ main(int argc, char **argv) struct nir_to_dxil_options opts = { .environment = DXIL_ENVIRONMENT_VULKAN, - .shader_model_max = shader_model, + .shader_model_max = conf.shader_model_max, .validator_version_max = val_ver, }; diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c index 9daccf07400..76cf6b007ec 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c @@ -46,7 +46,6 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, struct dxil_spirv_specialization *specializations, unsigned int num_specializations, dxil_spirv_shader_stage stage, const char *entry_point_name, - enum dxil_shader_model shader_model_max, enum dxil_validator_version validator_version_max, const struct dxil_spirv_debug_options *dgb_opts, const struct dxil_spirv_runtime_conf *conf, @@ -60,7 +59,7 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, struct nir_to_dxil_options opts = { .environment = DXIL_ENVIRONMENT_VULKAN, - .shader_model_max = shader_model_max, + .shader_model_max = conf->shader_model_max, .validator_version_max = validator_version_max, }; diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index 8b487fae2f8..cb82e463942 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -174,6 +174,9 @@ struct dxil_spirv_runtime_conf { bool lower_view_index; // View index also needs to be forwarded to RT layer output bool lower_view_index_to_rt_layer; + + // Affects which features can be used by the shader + enum dxil_shader_model shader_model_max; }; struct dxil_spirv_debug_options { @@ -204,7 +207,6 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, struct dxil_spirv_specialization *specializations, unsigned int num_specializations, dxil_spirv_shader_stage stage, const char *entry_point_name, - enum dxil_shader_model shader_model_max, enum dxil_validator_version validator_version_max, const struct dxil_spirv_debug_options *debug_options, const struct dxil_spirv_runtime_conf *conf, diff --git a/src/microsoft/vulkan/dzn_pipeline.c b/src/microsoft/vulkan/dzn_pipeline.c index 4d34f5f4ee3..c19ff493da9 100644 --- a/src/microsoft/vulkan/dzn_pipeline.c +++ b/src/microsoft/vulkan/dzn_pipeline.c @@ -215,6 +215,8 @@ dzn_pipeline_get_nir_shader(struct dzn_device *device, return VK_SUCCESS; } + struct dzn_physical_device *pdev = + container_of(device->vk.physical, struct dzn_physical_device, vk); VK_FROM_HANDLE(vk_shader_module, module, stage_info->module); const struct spirv_to_nir_options *spirv_opts = dxil_spirv_nir_get_spirv_options(); @@ -245,6 +247,7 @@ dzn_pipeline_get_nir_shader(struct dzn_device *device, .force_sample_rate_shading = options->force_sample_rate_shading, .lower_view_index = options->lower_view_index, .lower_view_index_to_rt_layer = options->lower_view_index_to_rt_layer, + .shader_model_max = dzn_get_shader_model(pdev), }; bool requires_runtime_data;