radv: add initial support for VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT
When VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT is set we skip NIR linking optimisations and only run over the NIR optimisation loop once similar to the GLSLOptimizeConservatively constant used by some GL drivers. We need to run over the opts at least once to avoid errors in LLVM (e.g. dead vars it can't handle) and also to reduce the time spent compiling the IR in LLVM. With this change the Blacksmith Unity demos compilation times go from 329760 ms -> 299881 ms when using Wine and DXVK. V2: add bit to radv_pipeline_key Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106246
This commit is contained in:
@@ -117,7 +117,7 @@ void radv_DestroyShaderModule(
|
||||
}
|
||||
|
||||
void
|
||||
radv_optimize_nir(struct nir_shader *shader)
|
||||
radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively)
|
||||
{
|
||||
bool progress;
|
||||
|
||||
@@ -149,7 +149,7 @@ radv_optimize_nir(struct nir_shader *shader)
|
||||
if (shader->options->max_unroll_iterations) {
|
||||
NIR_PASS(progress, shader, nir_opt_loop_unroll, 0);
|
||||
}
|
||||
} while (progress);
|
||||
} while (progress && !optimize_conservatively);
|
||||
|
||||
NIR_PASS(progress, shader, nir_opt_shrink_load);
|
||||
NIR_PASS(progress, shader, nir_opt_move_load_ubo);
|
||||
@@ -160,7 +160,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
|
||||
struct radv_shader_module *module,
|
||||
const char *entrypoint_name,
|
||||
gl_shader_stage stage,
|
||||
const VkSpecializationInfo *spec_info)
|
||||
const VkSpecializationInfo *spec_info,
|
||||
const VkPipelineCreateFlags flags)
|
||||
{
|
||||
if (strcmp(entrypoint_name, "main") != 0) {
|
||||
radv_finishme("Multiple shaders per module not really supported");
|
||||
@@ -293,7 +294,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
|
||||
.lower_vote_eq_to_ballot = 1,
|
||||
});
|
||||
|
||||
radv_optimize_nir(nir);
|
||||
if (!(flags & VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT))
|
||||
radv_optimize_nir(nir, false);
|
||||
|
||||
/* Indirect lowering must be called after the radv_optimize_nir() loop
|
||||
* has been called at least once. Otherwise indirect lowering can
|
||||
@@ -301,7 +303,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
|
||||
* considered too large for unrolling.
|
||||
*/
|
||||
ac_lower_indirect_derefs(nir, device->physical_device->rad_info.chip_class);
|
||||
radv_optimize_nir(nir);
|
||||
radv_optimize_nir(nir, flags & VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT);
|
||||
|
||||
return nir;
|
||||
}
|
||||
|
Reference in New Issue
Block a user