mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
etnaviv: make use of nir_lower_tex_shadow
Also force the texture filter to nearest when the lowering is used. This enables the GL_ARB_shadow extension for all GPU models. Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14308>
This commit is contained in:
parent
e5f9cdac1f
commit
be5b0e08fa
6 changed files with 50 additions and 5 deletions
|
|
@ -1118,6 +1118,12 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
|
|||
NIR_PASS_V(s, nir_lower_vars_to_ssa);
|
||||
NIR_PASS_V(s, nir_lower_indirect_derefs, nir_var_all, UINT32_MAX);
|
||||
NIR_PASS_V(s, nir_lower_tex, &(struct nir_lower_tex_options) { .lower_txp = ~0u });
|
||||
|
||||
if (v->key.has_sample_tex_compare)
|
||||
NIR_PASS_V(s, nir_lower_tex_shadow, v->key.num_texture_states,
|
||||
v->key.tex_compare_func,
|
||||
v->key.tex_swizzle);
|
||||
|
||||
NIR_PASS_V(s, nir_lower_alu_to_scalar, etna_alu_to_scalar_filter_cb, specs);
|
||||
nir_lower_idiv_options idiv_options = {
|
||||
.imprecise_32bit_lowering = true,
|
||||
|
|
|
|||
|
|
@ -212,6 +212,26 @@ etna_get_fs(struct etna_context *ctx, struct etna_shader_key key)
|
|||
{
|
||||
const struct etna_shader_variant *old = ctx->shader.fs;
|
||||
|
||||
/* update the key if we need to run nir_lower_sample_tex_compare(..). */
|
||||
if (ctx->screen->specs.halti < 2 &&
|
||||
(ctx->dirty & (ETNA_DIRTY_SAMPLERS | ETNA_DIRTY_SAMPLER_VIEWS))) {
|
||||
|
||||
for (unsigned int i = 0; i < ctx->num_fragment_sampler_views; i++) {
|
||||
if (ctx->sampler[i]->compare_mode == PIPE_TEX_COMPARE_NONE)
|
||||
continue;
|
||||
|
||||
key.has_sample_tex_compare = 1;
|
||||
key.num_texture_states = ctx->num_fragment_sampler_views;
|
||||
|
||||
key.tex_swizzle[i].swizzle_r = ctx->sampler_view[i]->swizzle_r;
|
||||
key.tex_swizzle[i].swizzle_g = ctx->sampler_view[i]->swizzle_g;
|
||||
key.tex_swizzle[i].swizzle_b = ctx->sampler_view[i]->swizzle_b;
|
||||
key.tex_swizzle[i].swizzle_a = ctx->sampler_view[i]->swizzle_a;
|
||||
|
||||
key.tex_compare_func[i] = ctx->sampler[i]->compare_func;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->shader.fs = etna_shader_variant(ctx->shader.bind_fs, key, &ctx->debug);
|
||||
|
||||
if (!ctx->shader.fs)
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
|||
|
||||
/* Texturing. */
|
||||
case PIPE_CAP_TEXTURE_SHADOW_MAP:
|
||||
return !DBG_ENABLED(ETNA_DBG_TGSI) && screen->specs.halti >= 2;
|
||||
return !DBG_ENABLED(ETNA_DBG_TGSI);
|
||||
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
|
||||
case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: /* TODO: verify */
|
||||
return screen->specs.max_texture_size;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#define H_ETNAVIV_SHADER
|
||||
|
||||
#include "mesa/main/config.h"
|
||||
#include "nir.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/disk_cache.h"
|
||||
|
||||
|
|
@ -50,17 +51,25 @@ struct etna_shader_key
|
|||
/* do we need to replace glTexCoord.xy ? */
|
||||
unsigned sprite_coord_enable : MAX_TEXTURE_COORD_UNITS;
|
||||
unsigned sprite_coord_yinvert : 1;
|
||||
/* do we need to lower sample_tex_compare */
|
||||
unsigned has_sample_tex_compare : 1;
|
||||
};
|
||||
uint32_t global;
|
||||
};
|
||||
|
||||
int num_texture_states;
|
||||
nir_lower_tex_shadow_swizzle tex_swizzle[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
enum compare_func tex_compare_func[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
};
|
||||
|
||||
static inline bool
|
||||
etna_shader_key_equal(struct etna_shader_key *a, struct etna_shader_key *b)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(struct etna_shader_key) <= sizeof(a->global));
|
||||
|
||||
return a->global == b->global;
|
||||
/* slow-path if we need to check tex_{swizzle,compare_func} */
|
||||
if (unlikely(a->has_sample_tex_compare || b->has_sample_tex_compare))
|
||||
return memcmp(a, b, sizeof(struct etna_shader_key)) == 0;
|
||||
else
|
||||
return a->global == b->global;
|
||||
}
|
||||
|
||||
struct etna_shader {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,16 @@ etna_create_sampler_state_state(struct pipe_context *pipe,
|
|||
COND(ss->compare_mode, VIVS_NTE_SAMPLER_BASELOD_COMPARE_ENABLE) |
|
||||
VIVS_NTE_SAMPLER_BASELOD_COMPARE_FUNC(translate_texture_compare(ss->compare_func));
|
||||
|
||||
/* force nearest filting for nir_lower_sample_tex_compare(..) */
|
||||
if ((ctx->screen->specs.halti < 2) && ss->compare_mode) {
|
||||
cs->config0 &= ~VIVS_TE_SAMPLER_CONFIG0_MIN__MASK;
|
||||
cs->config0 &= ~VIVS_TE_SAMPLER_CONFIG0_MAG__MASK;
|
||||
|
||||
cs->config0 |=
|
||||
VIVS_TE_SAMPLER_CONFIG0_MIN(TEXTURE_FILTER_NEAREST) |
|
||||
VIVS_TE_SAMPLER_CONFIG0_MAG(TEXTURE_FILTER_NEAREST);
|
||||
}
|
||||
|
||||
return cs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ etnaviv_compiler = executable(
|
|||
link_with : [libgallium, libetnaviv, libetnaviv_drm],
|
||||
build_by_default : with_tools.contains('etnaviv'),
|
||||
install : with_tools.contains('etnaviv'),
|
||||
dependencies : [idep_mesautil, dep_libdrm],
|
||||
dependencies : [idep_mesautil, dep_libdrm, idep_nir],
|
||||
)
|
||||
|
||||
driver_etnaviv = declare_dependency(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue