mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 01:20:17 +01:00
gallium: add a flag to finalize_nir to allow drivers to skip NIR opts
This could help achieve better compile times. Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38600>
This commit is contained in:
parent
9294448fe1
commit
1f2d129bfa
23 changed files with 40 additions and 28 deletions
|
|
@ -455,11 +455,12 @@ dd_screen_semaphore_create(struct pipe_screen *_screen)
|
|||
*/
|
||||
|
||||
static void
|
||||
dd_screen_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir)
|
||||
dd_screen_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct pipe_screen *screen = dd_screen(_screen)->screen;
|
||||
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, optimize);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -578,11 +578,12 @@ static struct disk_cache *noop_get_disk_shader_cache(struct pipe_screen *pscreen
|
|||
return screen->get_disk_shader_cache(screen);
|
||||
}
|
||||
|
||||
static void noop_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *nir)
|
||||
static void noop_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct pipe_screen *screen = ((struct noop_pipe_screen*)pscreen)->oscreen;
|
||||
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, optimize);
|
||||
}
|
||||
|
||||
static bool noop_check_resource_capability(struct pipe_screen *screen,
|
||||
|
|
|
|||
|
|
@ -1070,11 +1070,12 @@ trace_screen_get_timestamp(struct pipe_screen *_screen)
|
|||
}
|
||||
|
||||
static void
|
||||
trace_screen_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir)
|
||||
trace_screen_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct pipe_screen *screen = trace_screen(_screen)->screen;
|
||||
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, optimize);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -2564,7 +2564,7 @@ ttn_finalize_nir(struct ttn_compile *c, struct pipe_screen *screen)
|
|||
NIR_PASS(_, nir, nir_lower_samplers);
|
||||
|
||||
if (screen->finalize_nir) {
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, true);
|
||||
} else {
|
||||
ttn_optimize_nir(nir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ static nir_def *cs_create_shader(struct vl_compositor *c, struct cs_shader *s)
|
|||
|
||||
static void *cs_create_shader_state(struct vl_compositor *c, struct cs_shader *s)
|
||||
{
|
||||
c->pipe->screen->finalize_nir(c->pipe->screen, s->b.shader);
|
||||
c->pipe->screen->finalize_nir(c->pipe->screen, s->b.shader, true);
|
||||
|
||||
struct pipe_compute_state state = {0};
|
||||
state.ir_type = PIPE_SHADER_IR_NIR;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ create_deint_shader(struct vl_deint_filter *filter, unsigned field)
|
|||
}
|
||||
nir_pop_if(&b, if_curr_field);
|
||||
|
||||
filter->pipe->screen->finalize_nir(filter->pipe->screen, b.shader);
|
||||
filter->pipe->screen->finalize_nir(filter->pipe->screen, b.shader,
|
||||
true);
|
||||
|
||||
struct pipe_compute_state state = {
|
||||
.ir_type = PIPE_SHADER_IR_NIR,
|
||||
|
|
|
|||
|
|
@ -481,7 +481,8 @@ ir3_fixup_shader_state(struct pipe_context *pctx, struct ir3_shader_key *key)
|
|||
}
|
||||
|
||||
static void
|
||||
ir3_screen_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *nir)
|
||||
ir3_screen_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct fd_screen *screen = fd_screen(pscreen);
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,8 @@ i915_optimize_nir(struct nir_shader *s)
|
|||
}
|
||||
|
||||
static void
|
||||
i915_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *s)
|
||||
i915_finalize_nir(struct pipe_screen *pscreen, struct nir_shader *s,
|
||||
bool optimize)
|
||||
{
|
||||
if (s->info.stage == MESA_SHADER_FRAGMENT)
|
||||
i915_optimize_nir(s);
|
||||
|
|
|
|||
|
|
@ -3835,7 +3835,8 @@ iris_bind_cs_state(struct pipe_context *ctx, void *state)
|
|||
}
|
||||
|
||||
static void
|
||||
iris_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir)
|
||||
iris_finalize_nir(struct pipe_screen *_screen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct iris_screen *screen = (struct iris_screen *)_screen;
|
||||
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ static const struct nir_shader_compiler_options gallivm_nir_options = {
|
|||
|
||||
static void
|
||||
llvmpipe_finalize_nir(struct pipe_screen *screen,
|
||||
struct nir_shader *nir)
|
||||
struct nir_shader *nir, bool optimize)
|
||||
{
|
||||
lp_build_opt_nir(nir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <iostream>
|
||||
|
||||
void
|
||||
r600_finalize_nir(pipe_screen *screen, struct nir_shader *nir)
|
||||
r600_finalize_nir(pipe_screen *screen, struct nir_shader *nir, bool optimize)
|
||||
{
|
||||
auto rs = container_of(screen, r600_screen, b.b);
|
||||
r600_finalize_nir_common(nir, rs->b.gfx_level);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void
|
||||
r600_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir);
|
||||
r600_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir, bool optimize);
|
||||
|
||||
int
|
||||
r600_shader_from_nir(struct r600_context *rctx,
|
||||
|
|
|
|||
|
|
@ -923,7 +923,8 @@ void si_lower_mediump_io_option(struct nir_shader *nir);
|
|||
bool si_alu_to_scalar_packed_math_filter(const struct nir_instr *instr, const void *data);
|
||||
void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool has_array_temps);
|
||||
void si_nir_late_opts(struct nir_shader *nir);
|
||||
void si_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir);
|
||||
void si_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir,
|
||||
bool optimize);
|
||||
|
||||
/* si_state_shaders.cpp */
|
||||
unsigned si_shader_num_alloc_param_exports(struct si_shader *shader);
|
||||
|
|
|
|||
|
|
@ -389,7 +389,8 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
|
|||
NIR_PASS(_, nir, nir_lower_fp16_casts, nir_lower_fp16_split_fp64);
|
||||
}
|
||||
|
||||
void si_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir)
|
||||
void si_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir,
|
||||
bool optimize)
|
||||
{
|
||||
struct si_screen *sscreen = (struct si_screen *)screen;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void *si_create_shader_state(struct si_context *sctx, nir_shader *nir)
|
|||
blob_finish(&blob);
|
||||
}
|
||||
|
||||
sctx->b.screen->finalize_nir(sctx->b.screen, nir);
|
||||
sctx->b.screen->finalize_nir(sctx->b.screen, nir, true);
|
||||
return pipe_shader_from_nir(&sctx->b, nir);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6373,7 +6373,7 @@ zink_shader_init(struct zink_screen *screen, struct zink_shader *zs)
|
|||
}
|
||||
|
||||
void
|
||||
zink_shader_finalize(struct pipe_screen *pscreen, struct nir_shader *nir)
|
||||
zink_shader_finalize(struct pipe_screen *pscreen, struct nir_shader *nir, bool optimize)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void
|
|||
zink_shader_init(struct zink_screen *screen, struct zink_shader *zs);
|
||||
|
||||
void
|
||||
zink_shader_finalize(struct pipe_screen *pscreen, struct nir_shader *nir);
|
||||
zink_shader_finalize(struct pipe_screen *pscreen, struct nir_shader *nir, bool optimize);
|
||||
|
||||
void
|
||||
zink_shader_free(struct zink_screen *screen, struct zink_shader *shader);
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ void *
|
|||
lvp_shader_compile(struct lvp_device *device, struct lvp_shader *shader, nir_shader *nir, bool locked)
|
||||
{
|
||||
const struct lvp_physical_device *pdev = lvp_device_physical(device);
|
||||
pdev->pscreen->finalize_nir(pdev->pscreen, nir);
|
||||
pdev->pscreen->finalize_nir(pdev->pscreen, nir, true);
|
||||
|
||||
if (!locked)
|
||||
simple_mtx_lock(&device->queue.lock);
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ impl PipeScreen {
|
|||
pub fn finalize_nir(&self, nir: &NirShader) -> bool {
|
||||
if let Some(func) = self.screen().finalize_nir {
|
||||
unsafe {
|
||||
func(self.pipe(), nir.get_nir().cast());
|
||||
func(self.pipe(), nir.get_nir().cast(), true);
|
||||
}
|
||||
true
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -613,8 +613,11 @@ struct pipe_screen {
|
|||
*
|
||||
* gallium frontends should call this before passing shaders to drivers,
|
||||
* and ideally also before shader caching.
|
||||
*
|
||||
* \param optimize If false, the driver doesn't have to optimize NIR.
|
||||
*/
|
||||
void (*finalize_nir)(struct pipe_screen *screen, struct nir_shader *nir);
|
||||
void (*finalize_nir)(struct pipe_screen *screen, struct nir_shader *nir,
|
||||
bool optimize);
|
||||
|
||||
/*Separated memory/resource allocations interfaces for Vulkan */
|
||||
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
|
|||
st_finalize_nir(st, prog, shader_program, nir, true, false);
|
||||
|
||||
if (screen->finalize_nir)
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, false);
|
||||
}
|
||||
|
||||
if (st->ctx->_Shader->Flags & GLSL_DUMP) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ st_nir_finish_builtin_nir(struct st_context *st, nir_shader *nir)
|
|||
}
|
||||
|
||||
if (screen->finalize_nir) {
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, true);
|
||||
} else {
|
||||
gl_nir_opts(nir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ st_prog_to_nir_postprocess(struct st_context *st, nir_shader *nir,
|
|||
st_finalize_nir(st, prog, NULL, nir, true, false);
|
||||
|
||||
if (screen->finalize_nir)
|
||||
screen->finalize_nir(screen, nir);
|
||||
screen->finalize_nir(screen, nir, false);
|
||||
}
|
||||
|
||||
nir_validate_shader(nir, "after st/glsl finalize_nir");
|
||||
|
|
@ -887,7 +887,7 @@ st_create_common_variant(struct st_context *st,
|
|||
if (finalize || !st->allow_st_finalize_nir_twice || key->is_draw_shader) {
|
||||
struct pipe_screen *screen = st->screen;
|
||||
if (!key->is_draw_shader && screen->finalize_nir)
|
||||
screen->finalize_nir(screen, state.ir.nir);
|
||||
screen->finalize_nir(screen, state.ir.nir, false);
|
||||
|
||||
/* Clip lowering and edgeflags may have introduced new varyings, so
|
||||
* update the inputs_read/outputs_written. However, with
|
||||
|
|
@ -1268,7 +1268,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);
|
||||
screen->finalize_nir(screen, state.ir.nir, false);
|
||||
}
|
||||
|
||||
variant->base.driver_shader = st_create_nir_shader(st, &state);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue