#include "drm-uapi/drm_fourcc.h"
+struct etna_sampler_state {
+ struct pipe_sampler_state base;
+
+ /* sampler offset +4*sampler, interleave when committing state */
+ uint32_t TE_SAMPLER_CONFIG0;
+ 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 struct etna_sampler_state *
+etna_sampler_state(struct pipe_sampler_state *samp)
+{
+ return (struct etna_sampler_state *)samp;
+}
+
+struct etna_sampler_view {
+ struct pipe_sampler_view base;
+
+ /* sampler offset +4*sampler, interleave when committing state */
+ uint32_t TE_SAMPLER_CONFIG0;
+ uint32_t TE_SAMPLER_CONFIG0_MASK;
+ uint32_t TE_SAMPLER_CONFIG1;
+ uint32_t TE_SAMPLER_3D_CONFIG;
+ uint32_t TE_SAMPLER_SIZE;
+ uint32_t TE_SAMPLER_LOG_SIZE;
+ uint32_t TE_SAMPLER_ASTC0;
+ uint32_t TE_SAMPLER_LINEAR_STRIDE[VIVS_TE_SAMPLER_LINEAR_STRIDE__LEN];
+ struct etna_reloc TE_SAMPLER_LOD_ADDR[VIVS_TE_SAMPLER_LOD_ADDR__LEN];
+ unsigned min_lod, max_lod; /* 5.5 fixp */
+
+ struct etna_sampler_ts ts;
+};
+
+static inline struct etna_sampler_view *
+etna_sampler_view(struct pipe_sampler_view *view)
+{
+ return (struct etna_sampler_view *)view;
+}
+
static void *
etna_create_sampler_state_state(struct pipe_context *pipe,
const struct pipe_sampler_state *ss)
*/
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;
}
{
struct etna_sampler_view *sv = CALLOC_STRUCT(etna_sampler_view);
struct etna_context *ctx = etna_context(pctx);
+ struct etna_screen *screen = ctx->screen;
const uint32_t format = translate_texture_format(so->format);
const bool ext = !!(format & EXT_FORMAT);
const bool astc = !!(format & ASTC_FORMAT);
+ const bool srgb = util_format_is_srgb(so->format);
const uint32_t swiz = get_texture_swiz(so->format, so->swizzle_r,
so->swizzle_g, so->swizzle_b,
so->swizzle_a);
break;
}
- if (res->addressing_mode == ETNA_ADDRESSING_MODE_LINEAR) {
+ if (res->layout == ETNA_LAYOUT_LINEAR && !util_format_is_compressed(so->format)) {
sv->TE_SAMPLER_CONFIG0 |= VIVS_TE_SAMPLER_CONFIG0_ADDRESSING_MODE(TEXTURE_ADDRESSING_MODE_LINEAR);
for (int lod = 0; lod <= res->base.last_level; ++lod)
COND(is_array, VIVS_TE_SAMPLER_CONFIG1_TEXTURE_ARRAY) |
VIVS_TE_SAMPLER_CONFIG1_HALIGN(res->halign) | swiz;
sv->TE_SAMPLER_ASTC0 = COND(astc, VIVS_NTE_SAMPLER_ASTC0_ASTC_FORMAT(format)) |
+ COND(astc && srgb, VIVS_NTE_SAMPLER_ASTC0_ASTC_SRGB) |
VIVS_NTE_SAMPLER_ASTC0_UNK8(0xc) |
VIVS_NTE_SAMPLER_ASTC0_UNK16(0xc) |
VIVS_NTE_SAMPLER_ASTC0_UNK24(0xc);
VIVS_TE_SAMPLER_LOG_SIZE_WIDTH(etna_log2_fixp55(res->base.width0)) |
VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(base_height)) |
COND(util_format_is_srgb(so->format) && !astc, VIVS_TE_SAMPLER_LOG_SIZE_SRGB) |
- COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC);
+ COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC) |
+ COND(texture_use_int_filter(so, false), VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER);
sv->TE_SAMPLER_3D_CONFIG =
VIVS_TE_SAMPLER_3D_CONFIG_DEPTH(base_depth) |
VIVS_TE_SAMPLER_3D_CONFIG_LOG_DEPTH(etna_log2_fixp55(base_depth));
/* Workaround for npot textures -- it appears that only CLAMP_TO_EDGE is
* supported when the appropriate capability is not set. */
- if (!ctx->specs.npot_tex_any_wrap &&
+ if (!screen->specs.npot_tex_any_wrap &&
(!util_is_power_of_two_or_zero(res->base.width0) ||
!util_is_power_of_two_or_zero(res->base.height0))) {
sv->TE_SAMPLER_CONFIG0_MASK = ~(VIVS_TE_SAMPLER_CONFIG0_UWRAP__MASK |
etna_emit_texture_state(struct etna_context *ctx)
{
struct etna_cmd_stream *stream = ctx->stream;
+ struct etna_screen *screen = ctx->screen;
uint32_t active_samplers = active_samplers_bits(ctx);
uint32_t dirty = ctx->dirty;
struct etna_coalesce coalesce;
}
}
}
- if (unlikely(ctx->specs.tex_astc && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS)))) {
+ if (unlikely(screen->specs.tex_astc && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS)))) {
for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {
if ((1 << x) & active_samplers) {
struct etna_sampler_view *sv = etna_sampler_view(ctx->sampler_view[x]);
}
}
}
+ if (unlikely(screen->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);
}