From e29772f1345edecae5679d259ae2c04786b973b2 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 10 Mar 2023 10:33:05 +0000 Subject: [PATCH] v3dv: split out broadcom_shader_stage_to_gl() calls to improve readability MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is an inline function with a compile-constant switch, so I expect the compiler wouldn't produce any better code like this, but for humans it's easier to read when function calls are not embedded into other function calls. Signed-off-by: Eric Engestrom Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/vulkan/v3dv_pipeline.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 60b30e0..e12bcfb 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -352,6 +352,7 @@ shader_module_compile_to_nir(struct v3dv_device *device, { nir_shader *nir; const nir_shader_compiler_options *nir_options = &v3dv_nir_options; + gl_shader_stage gl_stage = broadcom_shader_stage_to_gl(stage->stage); if (V3D_DBG(DUMP_SPIRV) && stage->module->nir == NULL) @@ -362,7 +363,7 @@ shader_module_compile_to_nir(struct v3dv_device *device, * call it again here. */ VkResult result = vk_shader_module_to_nir(&device->vk, stage->module, - broadcom_shader_stage_to_gl(stage->stage), + gl_stage, stage->entrypoint, stage->spec_info, &default_spirv_options, @@ -370,7 +371,7 @@ shader_module_compile_to_nir(struct v3dv_device *device, NULL, &nir); if (result != VK_SUCCESS) return NULL; - assert(nir->info.stage == broadcom_shader_stage_to_gl(stage->stage)); + assert(nir->info.stage == gl_stage); if (V3D_DBG(SHADERDB) && stage->module->nir == NULL) { char sha1buf[41]; @@ -378,8 +379,7 @@ shader_module_compile_to_nir(struct v3dv_device *device, nir->info.name = ralloc_strdup(nir, sha1buf); } - if (V3D_DBG(NIR) || - v3d_debug_flag_for_shader_stage(broadcom_shader_stage_to_gl(stage->stage))) { + if (V3D_DBG(NIR) || v3d_debug_flag_for_shader_stage(gl_stage)) { fprintf(stderr, "NIR after vk_shader_module_to_nir: %s prog %d NIR:\n", broadcom_shader_stage_name(stage->stage), stage->program_id); @@ -1621,9 +1621,9 @@ pipeline_compile_shader_variant(struct v3dv_pipeline_stage *p_stage, struct v3dv_pipeline *pipeline = p_stage->pipeline; struct v3dv_physical_device *physical_device = pipeline->device->pdevice; const struct v3d_compiler *compiler = physical_device->compiler; + gl_shader_stage gl_stage = broadcom_shader_stage_to_gl(p_stage->stage); - if (V3D_DBG(NIR) || - v3d_debug_flag_for_shader_stage(broadcom_shader_stage_to_gl(p_stage->stage))) { + if (V3D_DBG(NIR) || v3d_debug_flag_for_shader_stage(gl_stage)) { fprintf(stderr, "Just before v3d_compile: %s prog %d NIR:\n", broadcom_shader_stage_name(p_stage->stage), p_stage->program_id); @@ -1634,8 +1634,7 @@ pipeline_compile_shader_variant(struct v3dv_pipeline_stage *p_stage, uint64_t *qpu_insts; uint32_t qpu_insts_size; struct v3d_prog_data *prog_data; - uint32_t prog_data_size = - v3d_prog_data_size(broadcom_shader_stage_to_gl(p_stage->stage)); + uint32_t prog_data_size = v3d_prog_data_size(gl_stage); qpu_insts = v3d_compile(compiler, key, &prog_data, -- 2.7.4