From 5f2dbd45f20b0c676d7140101c493351c121c728 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 10 Aug 2021 12:27:59 -0700 Subject: [PATCH] gallium: Remove "optimize" parameter from pipe_screen::finalize_nir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As part of adding support for inline uniforms in Iris, I was going to add a finalize_nir hook. I went looking to see how other drivers use the "optimize" parameter, and I discovered that *nobody* uses it at all. v2: Fix typo in commit message. Noticed by Mike. Reviewed-By: Mike Blumenkrantz Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/driver_ddebug/dd_screen.c | 4 ++-- src/gallium/auxiliary/driver_noop/noop_pipe.c | 4 ++-- src/gallium/auxiliary/driver_rbug/rbug_screen.c | 4 ++-- src/gallium/auxiliary/driver_trace/tr_screen.c | 4 ++-- src/gallium/auxiliary/nir/tgsi_to_nir.c | 2 +- src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 2 +- src/gallium/drivers/llvmpipe/lp_screen.c | 3 +-- src/gallium/drivers/llvmpipe/lp_state_cs.c | 2 +- src/gallium/drivers/radeonsi/si_shader.h | 2 +- src/gallium/drivers/radeonsi/si_shader_nir.c | 2 +- src/gallium/drivers/radeonsi/si_shaderlib_nir.c | 2 +- src/gallium/drivers/zink/zink_compiler.c | 2 +- src/gallium/drivers/zink/zink_compiler.h | 2 +- src/gallium/frontends/lavapipe/lvp_pipeline.c | 2 +- src/gallium/include/pipe/p_screen.h | 5 +---- src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 +- src/mesa/state_tracker/st_nir_builtins.c | 2 +- src/mesa/state_tracker/st_program.c | 2 +- 18 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/driver_ddebug/dd_screen.c b/src/gallium/auxiliary/driver_ddebug/dd_screen.c index dadcde63a13..7c5deb7dc14 100644 --- a/src/gallium/auxiliary/driver_ddebug/dd_screen.c +++ b/src/gallium/auxiliary/driver_ddebug/dd_screen.c @@ -415,11 +415,11 @@ dd_screen_memobj_destroy(struct pipe_screen *_screen, */ static void -dd_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize) +dd_screen_finalize_nir(struct pipe_screen *_screen, void *nir) { struct pipe_screen *screen = dd_screen(_screen)->screen; - screen->finalize_nir(screen, nir, optimize); + screen->finalize_nir(screen, nir); } static void diff --git a/src/gallium/auxiliary/driver_noop/noop_pipe.c b/src/gallium/auxiliary/driver_noop/noop_pipe.c index a4dcb340aac..2413a1ccbcc 100644 --- a/src/gallium/auxiliary/driver_noop/noop_pipe.c +++ b/src/gallium/auxiliary/driver_noop/noop_pipe.c @@ -599,11 +599,11 @@ static const void *noop_get_compiler_options(struct pipe_screen *pscreen, return screen->get_compiler_options(screen, ir, shader); } -static void noop_finalize_nir(struct pipe_screen *pscreen, void *nir, bool optimize) +static void noop_finalize_nir(struct pipe_screen *pscreen, void *nir) { struct pipe_screen *screen = ((struct noop_pipe_screen*)pscreen)->oscreen; - screen->finalize_nir(screen, nir, optimize); + screen->finalize_nir(screen, nir); } static bool noop_check_resource_capability(struct pipe_screen *screen, diff --git a/src/gallium/auxiliary/driver_rbug/rbug_screen.c b/src/gallium/auxiliary/driver_rbug/rbug_screen.c index 25d0fcf0ece..6adb5cf8a94 100644 --- a/src/gallium/auxiliary/driver_rbug/rbug_screen.c +++ b/src/gallium/auxiliary/driver_rbug/rbug_screen.c @@ -411,11 +411,11 @@ rbug_screen_fence_get_fd(struct pipe_screen *_screen, } static void -rbug_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize) +rbug_screen_finalize_nir(struct pipe_screen *_screen, void *nir) { struct pipe_screen *screen = rbug_screen(_screen)->screen; - screen->finalize_nir(screen, nir, optimize); + screen->finalize_nir(screen, nir); } bool diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c index ae5a2afab18..9856dbca82a 100644 --- a/src/gallium/auxiliary/driver_trace/tr_screen.c +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c @@ -920,11 +920,11 @@ trace_screen_get_timestamp(struct pipe_screen *_screen) } static void -trace_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize) +trace_screen_finalize_nir(struct pipe_screen *_screen, void *nir) { struct pipe_screen *screen = trace_screen(_screen)->screen; - screen->finalize_nir(screen, nir, optimize); + screen->finalize_nir(screen, nir); } static void diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index 29f110e9f5e..7454c6d21da 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -2483,7 +2483,7 @@ ttn_finalize_nir(struct ttn_compile *c, struct pipe_screen *screen) NIR_PASS_V(nir, nir_lower_samplers); if (screen->finalize_nir) { - screen->finalize_nir(screen, nir, true); + screen->finalize_nir(screen, nir); } else { ttn_optimize_nir(nir); nir_shader_gather_info(nir, c->build.impl); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index d3674c24a87..ee24f1192e4 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -461,7 +461,7 @@ ir3_fixup_shader_state(struct pipe_context *pctx, struct ir3_shader_key *key) } static void -ir3_screen_finalize_nir(struct pipe_screen *pscreen, void *nir, bool optimize) +ir3_screen_finalize_nir(struct pipe_screen *pscreen, void *nir) { struct fd_screen *screen = fd_screen(pscreen); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 7622a28425e..811ad3597b5 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -606,8 +606,7 @@ static const struct nir_shader_compiler_options gallivm_nir_options = { static void llvmpipe_finalize_nir(struct pipe_screen *screen, - void *nirptr, - bool optimize) + void *nirptr) { struct nir_shader *nir = (struct nir_shader *)nirptr; lp_build_opt_nir(nir); diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index af590b53811..e11b67b01f0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -456,7 +456,7 @@ llvmpipe_create_compute_state(struct pipe_context *pipe, shader->base.ir.nir = nir_deserialize(NULL, pipe->screen->get_compiler_options(pipe->screen, PIPE_SHADER_IR_NIR, PIPE_SHADER_COMPUTE), &reader); shader->base.type = PIPE_SHADER_IR_NIR; - pipe->screen->finalize_nir(pipe->screen, shader->base.ir.nir, false); + pipe->screen->finalize_nir(pipe->screen, shader->base.ir.nir); shader->req_local_mem += ((struct nir_shader *)shader->base.ir.nir)->info.shared_size; } else if (templ->ir_type == PIPE_SHADER_IR_NIR) { shader->base.ir.nir = (struct nir_shader *)templ->prog; diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 9cdf8aded1e..04a831665ac 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -888,7 +888,7 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen, void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *info); void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first); void si_nir_late_opts(nir_shader *nir); -void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize); +void si_finalize_nir(struct pipe_screen *screen, void *nirptr); /* si_state_shaders.c */ void gfx9_get_gs_info(struct si_shader_selector *es, struct si_shader_selector *gs, diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 044c1ffeb99..6a40ec7b85d 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -903,7 +903,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir) NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); } -void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize) +void si_finalize_nir(struct pipe_screen *screen, void *nirptr) { struct si_screen *sscreen = (struct si_screen *)screen; struct nir_shader *nir = (struct nir_shader *)nirptr; diff --git a/src/gallium/drivers/radeonsi/si_shaderlib_nir.c b/src/gallium/drivers/radeonsi/si_shaderlib_nir.c index 27f765769e7..4ca1490c7b4 100644 --- a/src/gallium/drivers/radeonsi/si_shaderlib_nir.c +++ b/src/gallium/drivers/radeonsi/si_shaderlib_nir.c @@ -33,7 +33,7 @@ static void *create_nir_cs(struct si_context *sctx, nir_builder *b) struct pipe_compute_state state = {0}; state.ir_type = PIPE_SHADER_IR_NIR; state.prog = b->shader; - sctx->b.screen->finalize_nir(sctx->b.screen, (void*)state.prog, false); + sctx->b.screen->finalize_nir(sctx->b.screen, (void*)state.prog); return sctx->b.create_compute_state(&sctx->b, &state); } diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 19a27335925..461943803b2 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -1043,7 +1043,7 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, } void -zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize) +zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr) { struct zink_screen *screen = zink_screen(pscreen); nir_shader *nir = nirptr; diff --git a/src/gallium/drivers/zink/zink_compiler.h b/src/gallium/drivers/zink/zink_compiler.h index 855fc1ea277..2addb6bc827 100644 --- a/src/gallium/drivers/zink/zink_compiler.h +++ b/src/gallium/drivers/zink/zink_compiler.h @@ -104,7 +104,7 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, const struct pipe_stream_output_info *so_info); void -zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize); +zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr); void zink_shader_free(struct zink_context *ctx, struct zink_shader *shader); diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index 8be8701d9df..94002b8c451 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -686,7 +686,7 @@ lvp_pipeline_compile(struct lvp_pipeline *pipeline, gl_shader_stage stage) { struct lvp_device *device = pipeline->device; - device->physical_device->pscreen->finalize_nir(device->physical_device->pscreen, pipeline->pipeline_nir[stage], true); + device->physical_device->pscreen->finalize_nir(device->physical_device->pscreen, pipeline->pipeline_nir[stage]); if (stage == MESA_SHADER_COMPUTE) { struct pipe_compute_state shstate = {0}; shstate.prog = (void *)pipeline->pipeline_nir[MESA_SHADER_COMPUTE]; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 7accb591f09..b81cf0aad34 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -520,11 +520,8 @@ struct pipe_screen { * * gallium frontends should call this before passing shaders to drivers, * and ideally also before shader caching. - * - * \param optimize Whether the input shader hasn't been optimized and - * should be. */ - void (*finalize_nir)(struct pipe_screen *screen, void *nir, bool optimize); + void (*finalize_nir)(struct pipe_screen *screen, void *nir); /*Separated memory/resource allocations interfaces for Vulkan */ diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 5f4419358aa..b989ad8c0b3 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -1069,7 +1069,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, NIR_PASS_V(nir, gl_nir_lower_images, false); if (finalize_by_driver && screen->finalize_nir) - screen->finalize_nir(screen, nir, false); + screen->finalize_nir(screen, nir); } } /* extern "C" */ diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c index 71e5f205ce4..e28b63544a0 100644 --- a/src/mesa/state_tracker/st_nir_builtins.c +++ b/src/mesa/state_tracker/st_nir_builtins.c @@ -69,7 +69,7 @@ st_nir_finish_builtin_shader(struct st_context *st, NIR_PASS_V(nir, gl_nir_lower_images, false); if (screen->finalize_nir) - screen->finalize_nir(screen, nir, true); + screen->finalize_nir(screen, nir); else st_nir_opts(nir); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 25e2eca92b1..c229b36654c 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1512,7 +1512,7 @@ st_create_fp_variant(struct st_context *st, struct pipe_screen *screen = st->screen; if (screen->finalize_nir) - screen->finalize_nir(screen, state.ir.nir, false); + screen->finalize_nir(screen, state.ir.nir); } variant->base.driver_shader = st_create_nir_shader(st, &state);