Mesa (master): etnaviv: add support for NTE
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Mar 20 10:11:02 UTC 2021
Module: Mesa
Branch: master
Commit: 53b51a1037a23eeaa5533bb650880fd0eca878ec
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=53b51a1037a23eeaa5533bb650880fd0eca878ec
Author: Christian Gmeiner <christian.gmeiner at gmail.com>
Date: Sat Dec 12 15:28:48 2020 +0100
etnaviv: add support for NTE
Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Reviewed-by: Lucas Stach <l.stach at pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8103>
---
src/gallium/drivers/etnaviv/etnaviv_screen.c | 12 +-
.../drivers/etnaviv/etnaviv_texture_state.c | 149 +++++++++++++++++++--
2 files changed, 149 insertions(+), 12 deletions(-)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 8943446ba47..66951839017 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -679,9 +679,15 @@ static void
etna_determine_sampler_limits(struct etna_screen *screen)
{
/* vertex and fragment samplers live in one address space */
- screen->specs.vertex_sampler_offset = 8;
- screen->specs.fragment_sampler_count = 8;
- screen->specs.vertex_sampler_count = 4;
+ if (screen->specs.halti >= 1) {
+ screen->specs.vertex_sampler_offset = 16;
+ screen->specs.fragment_sampler_count = 16;
+ screen->specs.vertex_sampler_count = 16;
+ } else {
+ screen->specs.vertex_sampler_offset = 8;
+ screen->specs.fragment_sampler_count = 8;
+ screen->specs.vertex_sampler_count = 4;
+ }
if (screen->model == 0x400)
screen->specs.vertex_sampler_count = 0;
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
index ac2a1d1e967..d5eb3cf0052 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture_state.c
@@ -322,6 +322,138 @@ etna_emit_ts_state(struct etna_context *ctx)
etna_coalesce_end(stream, &coalesce);
}
+static void
+etna_emit_new_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;
+
+ etna_emit_ts_state(ctx);
+
+ etna_coalesce_start(stream, &coalesce);
+
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS | ETNA_DIRTY_SAMPLERS))) {
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ uint32_t val = 0; /* 0 == sampler inactive */
+
+ /* set active samplers to their configuration value (determined by both
+ * the sampler state and sampler view) */
+ if ((1 << x) & active_samplers) {
+ struct etna_sampler_state *ss = etna_sampler_state(ctx->sampler[x]);
+ struct etna_sampler_view *sv = etna_sampler_view(ctx->sampler_view[x]);
+
+ val = (ss->TE_SAMPLER_CONFIG0 & sv->TE_SAMPLER_CONFIG0_MASK) |
+ sv->TE_SAMPLER_CONFIG0;
+ }
+
+ /*10000*/ EMIT_STATE(NTE_SAMPLER_CONFIG0(x), val);
+ }
+ }
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) {
+ struct etna_sampler_state *ss;
+ struct etna_sampler_view *sv;
+
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+ /*10080*/ EMIT_STATE(NTE_SAMPLER_SIZE(x), sv->TE_SAMPLER_SIZE);
+ }
+ }
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ ss = etna_sampler_state(ctx->sampler[x]);
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+ uint32_t TE_SAMPLER_LOG_SIZE = sv->TE_SAMPLER_LOG_SIZE;
+
+ if (texture_use_int_filter(&sv->base, &ss->base, false))
+ TE_SAMPLER_LOG_SIZE |= VIVS_TE_SAMPLER_LOG_SIZE_INT_FILTER;
+
+ /*10100*/ EMIT_STATE(NTE_SAMPLER_LOG_SIZE(x), TE_SAMPLER_LOG_SIZE);
+ }
+ }
+ }
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS | ETNA_DIRTY_SAMPLERS))) {
+ struct etna_sampler_state *ss;
+ struct etna_sampler_view *sv;
+
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ ss = etna_sampler_state(ctx->sampler[x]);
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+
+ unsigned max_lod = MAX2(MIN2(ss->max_lod + sv->min_lod, sv->max_lod), ss->max_lod_min);
+ unsigned min_lod = MIN2(MAX2(ss->min_lod + sv->min_lod, sv->min_lod), max_lod);
+
+ /* min and max lod is determined both by the sampler and the view */
+ /*10180*/ EMIT_STATE(NTE_SAMPLER_LOD_CONFIG(x),
+ ss->TE_SAMPLER_LOD_CONFIG |
+ VIVS_TE_SAMPLER_LOD_CONFIG_MAX(max_lod) |
+ VIVS_TE_SAMPLER_LOD_CONFIG_MIN(min_lod));
+ }
+ }
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) {
+ /* only LOD0 is valid for this register */
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ struct etna_sampler_view *sv = etna_sampler_view(ctx->sampler_view[x]);
+ /*10280*/ EMIT_STATE(NTE_SAMPLER_LINEAR_STRIDE(0, x), sv->TE_SAMPLER_LINEAR_STRIDE);
+ }
+ }
+ }
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ ss = etna_sampler_state(ctx->sampler[x]);
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+
+ /*10300*/ EMIT_STATE(NTE_SAMPLER_3D_CONFIG(x), ss->TE_SAMPLER_3D_CONFIG |
+ sv->TE_SAMPLER_3D_CONFIG);
+ }
+ }
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ ss = etna_sampler_state(ctx->sampler[x]);
+ sv = etna_sampler_view(ctx->sampler_view[x]);
+
+ /*10380*/ EMIT_STATE(NTE_SAMPLER_CONFIG1(x), ss->TE_SAMPLER_CONFIG1 |
+ sv->TE_SAMPLER_CONFIG1 |
+ COND(sv->ts.enable, VIVS_TE_SAMPLER_CONFIG1_USE_TS));
+ }
+ }
+ }
+ if (unlikely(screen->specs.tex_astc && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS)))) {
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ struct etna_sampler_view *sv = etna_sampler_view(ctx->sampler_view[x]);
+ /*10500*/ EMIT_STATE(NTE_SAMPLER_ASTC0(x), sv->TE_SAMPLER_ASTC0);
+ }
+ }
+ }
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) {
+ for (int x = 0; x < VIVS_NTE_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);
+ }
+ }
+ }
+
+ if (unlikely(dirty & (ETNA_DIRTY_SAMPLER_VIEWS))) {
+ for (int x = 0; x < VIVS_NTE_SAMPLER__LEN; ++x) {
+ if ((1 << x) & active_samplers) {
+ for (int y = 0; y < VIVS_NTE_SAMPLER_ADDR_LOD__LEN; ++y) {
+ struct etna_sampler_view *sv = etna_sampler_view(ctx->sampler_view[x]);
+ /*10800*/ EMIT_STATE_RELOC(NTE_SAMPLER_ADDR_LOD(x, y), &sv->TE_SAMPLER_LOD_ADDR[y]);
+ }
+ }
+ }
+ }
+
+ etna_coalesce_end(stream, &coalesce);
+}
+
/* Emit plain (non-descriptor) texture state */
static void
etna_emit_texture_state(struct etna_context *ctx)
@@ -442,14 +574,7 @@ etna_emit_texture_state(struct etna_context *ctx)
}
}
}
- 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);
}
@@ -473,6 +598,12 @@ etna_texture_state_init(struct pipe_context *pctx)
ctx->base.delete_sampler_state = etna_delete_sampler_state_state;
ctx->base.create_sampler_view = etna_create_sampler_view_state;
ctx->base.sampler_view_destroy = etna_sampler_view_state_destroy;
- ctx->emit_texture_state = etna_emit_texture_state;
ctx->ts_for_sampler_view = etna_ts_for_sampler_view_state;
+
+ STATIC_ASSERT(VIVS_TE_SAMPLER_LOD_ADDR__LEN == VIVS_NTE_SAMPLER_ADDR_LOD__LEN);
+
+ if (ctx->screen->specs.halti >= 1)
+ ctx->emit_texture_state = etna_emit_new_texture_state;
+ else
+ ctx->emit_texture_state = etna_emit_texture_state;
}
More information about the mesa-commit
mailing list