lod_bias = &tex->src[i].src;
lod_bias_idx = i;
break;
+ case nir_tex_src_comparator:
+ break;
default:
assert(0);
break;
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,
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;
{
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) {
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;
}
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
/* 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;
*/
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;
}
}
}
}
+ 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);
}
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;
};
}
}
+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