From 08e072015a372e618dbb20095a691e9410ff1e9f Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 1 Feb 2021 11:48:02 +0100 Subject: [PATCH] gallium/st: lower rectangle textures if not supported Signed-off-by: Christian Gmeiner Reviewed-by: Eric Anholt Part-of: --- src/mesa/state_tracker/st_context.c | 2 ++ src/mesa/state_tracker/st_context.h | 1 + src/mesa/state_tracker/st_glsl_to_nir.cpp | 8 ++++++++ src/mesa/state_tracker/st_nir_builtins.c | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 6268e897f98..1bb65e2e17e 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -728,6 +728,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, screen->get_param(screen, PIPE_CAP_CONDITIONAL_RENDER); st->lower_texcoord_replace = !screen->get_param(screen, PIPE_CAP_POINT_SPRITE); + st->lower_rect_tex = + !screen->get_param(screen, PIPE_CAP_TEXRECT); st->allow_st_finalize_nir_twice = screen->finalize_nir != NULL; st->has_hw_atomics = diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 63657e95c29..fe0a0859137 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -161,6 +161,7 @@ struct st_context boolean prefer_real_buffer_in_constbuf0; boolean has_conditional_render; boolean lower_texcoord_replace; + boolean lower_rect_tex; /* There are consequences for drivers wanting to call st_finalize_nir * twice, once before shader caching and once after lowering for shader diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 4626f5de96f..4708c59f907 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -1026,6 +1026,14 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, NIR_PASS_V(nir, nir_split_var_copies); NIR_PASS_V(nir, nir_lower_var_copies); + if (st->lower_rect_tex) { + struct nir_lower_tex_options opts = { 0 }; + + opts.lower_rect = true; + + NIR_PASS_V(nir, nir_lower_tex, &opts); + } + st_nir_assign_varying_locations(st, nir); st_nir_assign_uniform_locations(st->ctx, prog, nir); diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c index 6e1989a9889..71e5f205ce4 100644 --- a/src/mesa/state_tracker/st_nir_builtins.c +++ b/src/mesa/state_tracker/st_nir_builtins.c @@ -53,6 +53,11 @@ st_nir_finish_builtin_shader(struct st_context *st, NIR_PASS_V(nir, nir_lower_io_to_scalar_early, mask); } + if (st->lower_rect_tex) { + const struct nir_lower_tex_options opts = { .lower_rect = true, }; + NIR_PASS_V(nir, nir_lower_tex, &opts); + } + nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)); st_nir_assign_vs_in_locations(nir);