mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
etnaviv: implement texture comparator
Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
This commit is contained in:
parent
686e9fa0fb
commit
c877142fca
6 changed files with 51 additions and 5 deletions
|
|
@ -152,6 +152,8 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v)
|
|||
lod_bias = &tex->src[i].src;
|
||||
lod_bias_idx = i;
|
||||
break;
|
||||
case nir_tex_src_comparator:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
|
@ -493,7 +495,7 @@ etna_emit_alu(struct etna_compile *c, nir_op op, struct etna_inst_dst dst,
|
|||
static void
|
||||
etna_emit_tex(struct etna_compile *c, nir_texop op, unsigned texid, unsigned dst_swiz,
|
||||
struct etna_inst_dst dst, struct etna_inst_src coord,
|
||||
struct etna_inst_src lod_bias)
|
||||
struct etna_inst_src lod_bias, struct etna_inst_src compare)
|
||||
{
|
||||
struct etna_inst inst = {
|
||||
.dst = dst,
|
||||
|
|
@ -505,6 +507,9 @@ etna_emit_tex(struct etna_compile *c, nir_texop op, unsigned texid, unsigned dst
|
|||
if (lod_bias.use)
|
||||
inst.src[1] = lod_bias;
|
||||
|
||||
if (compare.use)
|
||||
inst.src[2] = compare;
|
||||
|
||||
switch (op) {
|
||||
case nir_texop_tex: inst.opcode = INST_OPCODE_TEXLD; break;
|
||||
case nir_texop_txb: inst.opcode = INST_OPCODE_TEXLDB; break;
|
||||
|
|
|
|||
|
|
@ -1054,8 +1054,7 @@ emit_tex(struct state *state, nir_tex_instr * tex)
|
|||
{
|
||||
unsigned dst_swiz;
|
||||
hw_dst dst = ra_dest(state, &tex->dest, &dst_swiz);
|
||||
nir_src *coord = NULL;
|
||||
nir_src *lod_bias = NULL;
|
||||
nir_src *coord = NULL, *lod_bias = NULL, *compare = NULL;
|
||||
|
||||
for (unsigned i = 0; i < tex->num_srcs; i++) {
|
||||
switch (tex->src[i].src_type) {
|
||||
|
|
@ -1067,6 +1066,9 @@ emit_tex(struct state *state, nir_tex_instr * tex)
|
|||
assert(!lod_bias);
|
||||
lod_bias = &tex->src[i].src;
|
||||
break;
|
||||
case nir_tex_src_comparator:
|
||||
compare = &tex->src[i].src;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
|
@ -1074,7 +1076,8 @@ emit_tex(struct state *state, nir_tex_instr * tex)
|
|||
}
|
||||
|
||||
emit(tex, tex->op, tex->sampler_index, dst_swiz, dst, get_src(state, coord),
|
||||
lod_bias ? get_src(state, lod_bias) : SRC_DISABLE);
|
||||
lod_bias ? get_src(state, lod_bias) : SRC_DISABLE,
|
||||
compare ? get_src(state, compare) : SRC_DISABLE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
|||
|
||||
/* Texturing. */
|
||||
case PIPE_CAP_TEXTURE_SHADOW_MAP:
|
||||
return 0;
|
||||
return DBG_ENABLED(ETNA_DBG_NIR) && screen->specs.halti >= 2;
|
||||
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
|
||||
case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: /* TODO: verify */
|
||||
return screen->specs.max_texture_size;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ etna_create_sampler_state_state(struct pipe_context *pipe,
|
|||
*/
|
||||
cs->max_lod_min = (ss->min_img_filter != ss->mag_img_filter) ? 1 : 0;
|
||||
|
||||
cs->NTE_SAMPLER_BASELOD =
|
||||
COND(ss->compare_mode, VIVS_NTE_SAMPLER_BASELOD_COMPARE_ENABLE) |
|
||||
VIVS_NTE_SAMPLER_BASELOD_COMPARE_FUNC(translate_texture_compare(ss->compare_func));
|
||||
|
||||
return cs;
|
||||
}
|
||||
|
||||
|
|
@ -365,6 +369,14 @@ etna_emit_texture_state(struct etna_context *ctx)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (unlikely(ctx->specs.halti >= 1 && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS)))) {
|
||||
for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {
|
||||
if ((1 << x) & active_samplers) {
|
||||
struct etna_sampler_state *ss = etna_sampler_state(ctx->sampler[x]);
|
||||
/*10700*/ EMIT_STATE(NTE_SAMPLER_BASELOD(x), ss->NTE_SAMPLER_BASELOD);
|
||||
}
|
||||
}
|
||||
}
|
||||
etna_coalesce_end(stream, &coalesce);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ struct etna_sampler_state {
|
|||
uint32_t TE_SAMPLER_CONFIG1;
|
||||
uint32_t TE_SAMPLER_LOD_CONFIG;
|
||||
uint32_t TE_SAMPLER_3D_CONFIG;
|
||||
uint32_t NTE_SAMPLER_BASELOD;
|
||||
unsigned min_lod, max_lod, max_lod_min;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -497,4 +497,29 @@ translate_texture_target(unsigned target)
|
|||
}
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
translate_texture_compare(enum pipe_compare_func compare_func)
|
||||
{
|
||||
switch (compare_func) {
|
||||
case PIPE_FUNC_NEVER:
|
||||
return TEXTURE_COMPARE_FUNC_NEVER;
|
||||
case PIPE_FUNC_LESS:
|
||||
return TEXTURE_COMPARE_FUNC_LESS;
|
||||
case PIPE_FUNC_EQUAL:
|
||||
return TEXTURE_COMPARE_FUNC_EQUAL;
|
||||
case PIPE_FUNC_LEQUAL:
|
||||
return TEXTURE_COMPARE_FUNC_LEQUAL;
|
||||
case PIPE_FUNC_GREATER:
|
||||
return TEXTURE_COMPARE_FUNC_GREATER;
|
||||
case PIPE_FUNC_NOTEQUAL:
|
||||
return TEXTURE_COMPARE_FUNC_NOTEQUAL;
|
||||
case PIPE_FUNC_GEQUAL:
|
||||
return TEXTURE_COMPARE_FUNC_GEQUAL;
|
||||
case PIPE_FUNC_ALWAYS:
|
||||
return TEXTURE_COMPARE_FUNC_ALWAYS;
|
||||
default:
|
||||
unreachable("Invalid compare func");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue