mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 23:30:10 +01:00
zink: add a pipe_screen::finalize_nir hook
moves some of the always-run passes into the base nir Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9888>
This commit is contained in:
parent
193c02e0cf
commit
b47815c772
3 changed files with 24 additions and 11 deletions
|
|
@ -794,12 +794,6 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
ret->shader_id = p_atomic_inc_return(&screen->shader_id);
|
||||
ret->programs = _mesa_pointer_set_create(NULL);
|
||||
|
||||
if (!screen->info.feats.features.shaderImageGatherExtended) {
|
||||
nir_lower_tex_options tex_opts = {};
|
||||
tex_opts.lower_tg4_offsets = true;
|
||||
NIR_PASS_V(nir, nir_lower_tex, &tex_opts);
|
||||
}
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_VERTEX)
|
||||
create_vs_pushconst(nir);
|
||||
else if (nir->info.stage == MESA_SHADER_TESS_CTRL ||
|
||||
|
|
@ -809,11 +803,8 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
} else if (nir->info.stage == MESA_SHADER_KERNEL)
|
||||
create_cs_pushconst(nir);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 16);
|
||||
if (nir->info.stage < MESA_SHADER_FRAGMENT)
|
||||
have_psiz = check_psiz(nir);
|
||||
if (nir->info.stage == MESA_SHADER_GEOMETRY)
|
||||
NIR_PASS_V(nir, nir_lower_gs_intrinsics, nir_lower_gs_intrinsics_per_stream);
|
||||
NIR_PASS_V(nir, lower_basevertex);
|
||||
NIR_PASS_V(nir, lower_work_dim);
|
||||
NIR_PASS_V(nir, nir_lower_regs_to_ssa);
|
||||
|
|
@ -823,8 +814,6 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
NIR_PASS_V(nir, lower_discard_if);
|
||||
NIR_PASS_V(nir, nir_lower_fragcolor);
|
||||
NIR_PASS_V(nir, lower_64bit_vertex_attribs);
|
||||
if (nir->info.num_ubos || nir->info.num_ssbos)
|
||||
NIR_PASS_V(nir, nir_lower_dynamic_bo_access);
|
||||
NIR_PASS_V(nir, unbreak_bos);
|
||||
|
||||
if (zink_debug & ZINK_DEBUG_NIR) {
|
||||
|
|
@ -896,6 +885,26 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize)
|
||||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
nir_shader *nir = nirptr;
|
||||
|
||||
if (!screen->info.feats.features.shaderImageGatherExtended) {
|
||||
nir_lower_tex_options tex_opts = {};
|
||||
tex_opts.lower_tg4_offsets = true;
|
||||
NIR_PASS_V(nir, nir_lower_tex, &tex_opts);
|
||||
}
|
||||
NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 16);
|
||||
if (nir->info.stage == MESA_SHADER_GEOMETRY)
|
||||
NIR_PASS_V(nir, nir_lower_gs_intrinsics, nir_lower_gs_intrinsics_per_stream);
|
||||
optimize_nir(nir);
|
||||
if (nir->info.num_ubos || nir->info.num_ssbos)
|
||||
NIR_PASS_V(nir, nir_lower_dynamic_bo_access);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
}
|
||||
|
||||
void
|
||||
zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ struct zink_shader *
|
|||
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);
|
||||
|
||||
void
|
||||
zink_shader_free(struct zink_context *ctx, struct zink_shader *shader);
|
||||
|
||||
|
|
|
|||
|
|
@ -1463,6 +1463,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
|
|||
screen->base.context_create = zink_context_create;
|
||||
screen->base.flush_frontbuffer = zink_flush_frontbuffer;
|
||||
screen->base.destroy = zink_destroy_screen;
|
||||
screen->base.finalize_nir = zink_shader_finalize;
|
||||
|
||||
if (!zink_screen_resource_init(&screen->base))
|
||||
goto fail;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue