From 6fcbce3b9960a6066cf198d5d2fc25a7e4cf0e7b Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 16 Jun 2020 17:00:31 +0200 Subject: [PATCH] tu: Remove tu_shader_compile_options The only two fields were always true, and I don't think we'd ever have use for them. If we want to disable optimizations then we'd need a different approach, and I don't even know what include_binning_pass was for. Part-of: --- src/freedreno/vulkan/tu_pipeline.c | 77 +++++++++++++++++++++--------- src/freedreno/vulkan/tu_private.h | 13 ----- src/freedreno/vulkan/tu_shader.c | 41 ---------------- 3 files changed, 54 insertions(+), 77 deletions(-) diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index 6953afc5db9..d818f9f807c 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -1950,6 +1950,39 @@ tu_pipeline_create(struct tu_device *dev, return VK_SUCCESS; } +static void +tu_pipeline_shader_key_init(struct ir3_shader_key *key, + const VkGraphicsPipelineCreateInfo *pipeline_info) +{ + bool has_gs = false; + bool msaa = false; + if (pipeline_info) { + for (uint32_t i = 0; i < pipeline_info->stageCount; i++) { + if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) { + has_gs = true; + break; + } + } + + const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState; + const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations = + vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT); + if (!pipeline_info->pRasterizationState->rasterizerDiscardEnable && + (msaa_info->rasterizationSamples > 1 || + /* also set msaa key when sample location is not the default + * since this affects varying interpolation */ + (sample_locations && sample_locations->sampleLocationsEnable))) { + msaa = true; + } + } + + /* TODO: Populate the remaining fields of ir3_shader_key. */ + *key = (struct ir3_shader_key) { + .has_gs = has_gs, + .msaa = msaa, + }; +} + static VkResult tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder) { @@ -1962,8 +1995,8 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder) stage_infos[stage] = &builder->create_info->pStages[i]; } - struct tu_shader_compile_options options; - tu_shader_compile_options_init(&options, builder->create_info); + struct ir3_shader_key key; + tu_pipeline_shader_key_init(&key, builder->create_info); for (gl_shader_stage stage = MESA_SHADER_VERTEX; stage < MESA_SHADER_STAGES; stage++) { @@ -1988,7 +2021,7 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder) bool created; builder->variants[stage] = ir3_shader_get_variant(builder->shaders[stage]->ir3_shader, - &options.key, false, &created); + &key, false, &created); if (!builder->variants[stage]) return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -1997,26 +2030,24 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder) sizeof(uint32_t) * builder->variants[stage]->info.sizedwords; } - if (options.include_binning_pass) { - const struct tu_shader *vs = builder->shaders[MESA_SHADER_VERTEX]; - struct ir3_shader_variant *variant; - - if (vs->ir3_shader->stream_output.num_outputs) { - variant = builder->variants[MESA_SHADER_VERTEX]; - } else { - bool created; - variant = ir3_shader_get_variant(vs->ir3_shader, &options.key, - true, &created); - if (!variant) - return VK_ERROR_OUT_OF_HOST_MEMORY; - } + const struct tu_shader *vs = builder->shaders[MESA_SHADER_VERTEX]; + struct ir3_shader_variant *variant; - builder->binning_vs_offset = builder->shader_total_size; - builder->shader_total_size += - sizeof(uint32_t) * variant->info.sizedwords; - builder->binning_variant = variant; + if (vs->ir3_shader->stream_output.num_outputs) { + variant = builder->variants[MESA_SHADER_VERTEX]; + } else { + bool created; + variant = ir3_shader_get_variant(vs->ir3_shader, &key, + true, &created); + if (!variant) + return VK_ERROR_OUT_OF_HOST_MEMORY; } + builder->binning_vs_offset = builder->shader_total_size; + builder->shader_total_size += + sizeof(uint32_t) * variant->info.sizedwords; + builder->binning_variant = variant; + return VK_SUCCESS; } @@ -2554,8 +2585,8 @@ tu_compute_pipeline_create(VkDevice device, pipeline->layout = layout; - struct tu_shader_compile_options options; - tu_shader_compile_options_init(&options, NULL); + struct ir3_shader_key key; + tu_pipeline_shader_key_init(&key, NULL); struct tu_shader *shader = tu_shader_create(dev, MESA_SHADER_COMPUTE, stage_info, layout, pAllocator); @@ -2566,7 +2597,7 @@ tu_compute_pipeline_create(VkDevice device, bool created; struct ir3_shader_variant *v = - ir3_shader_get_variant(shader->ir3_shader, &options.key, false, &created); + ir3_shader_get_variant(shader->ir3_shader, &key, false, &created); if (!v) goto fail; diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 9dbf4c50e35..2f0bd0c1744 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1098,14 +1098,6 @@ struct tu_shader_module const uint32_t *code[0]; }; -struct tu_shader_compile_options -{ - struct ir3_shader_key key; - - bool optimize; - bool include_binning_pass; -}; - struct tu_push_constant_range { uint32_t lo; @@ -1133,11 +1125,6 @@ tu_shader_destroy(struct tu_device *dev, struct tu_shader *shader, const VkAllocationCallbacks *alloc); -void -tu_shader_compile_options_init( - struct tu_shader_compile_options *options, - const VkGraphicsPipelineCreateInfo *pipeline_info); - struct tu_program_descriptor_linkage { struct ir3_ubo_analysis_state ubo_state; diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c index 1717a8bd1c1..a43280e6a17 100644 --- a/src/freedreno/vulkan/tu_shader.c +++ b/src/freedreno/vulkan/tu_shader.c @@ -657,47 +657,6 @@ tu_shader_destroy(struct tu_device *dev, vk_free2(&dev->alloc, alloc, shader); } -void -tu_shader_compile_options_init( - struct tu_shader_compile_options *options, - const VkGraphicsPipelineCreateInfo *pipeline_info) -{ - bool has_gs = false; - bool msaa = false; - if (pipeline_info) { - for (uint32_t i = 0; i < pipeline_info->stageCount; i++) { - if (pipeline_info->pStages[i].stage == VK_SHADER_STAGE_GEOMETRY_BIT) { - has_gs = true; - break; - } - } - - const VkPipelineMultisampleStateCreateInfo *msaa_info = pipeline_info->pMultisampleState; - const struct VkPipelineSampleLocationsStateCreateInfoEXT *sample_locations = - vk_find_struct_const(msaa_info->pNext, PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT); - if (!pipeline_info->pRasterizationState->rasterizerDiscardEnable && - (msaa_info->rasterizationSamples > 1 || - /* also set msaa key when sample location is not the default - * since this affects varying interpolation */ - (sample_locations && sample_locations->sampleLocationsEnable))) { - msaa = true; - } - } - - *options = (struct tu_shader_compile_options) { - /* TODO: Populate the remaining fields of ir3_shader_key. */ - .key = { - .has_gs = has_gs, - .msaa = msaa, - }, - /* TODO: VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT - * some optimizations need to happen otherwise shader might not compile - */ - .optimize = true, - .include_binning_pass = true, - }; -} - VkResult tu_CreateShaderModule(VkDevice _device, const VkShaderModuleCreateInfo *pCreateInfo, -- 2.30.2