<div dir="auto"><div>Hi..</div><div dir="auto"><br></div><div dir="auto">First quick review send from my smartphone...<br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">Am 01.11.2017 6:19 nachm. schrieb "Wladimir J. van der Laan" <<a href="mailto:laanwj@gmail.com">laanwj@gmail.com</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">Add ASTC texture support for hardware that supports this<br>
(currently only GC3000 on i.MX6qp is known to have this).<br>
<br>
</div>Signed-off-by: Wladimir J. van der Laan <<a href="mailto:laanwj@gmail.com">laanwj@gmail.com</a>><br>
---<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_emit.c     |  8 +++++++<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_format.c   | 30 ++++++++++++++++++++++++++<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_format.h   |  1 +<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_internal.h |  2 ++<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_screen.c   |  6 ++++++<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.c  | 11 ++++++++--<br>
 src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.h  |  1 +<br>
 7 files changed, 57 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_emit.c b/src/gallium/drivers/etnaviv/<wbr>etnaviv_emit.c<br>
index 5397aa3..d313af6 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_emit.c<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_emit.c<br>
@@ -703,6 +703,14 @@ etna_emit_state(struct etna_context *ctx)<br>
          /*03828*/ EMIT_STATE(GL_VARYING_<wbr>COMPONENT_USE(x), ctx->shader_state.GL_VARYING_<wbr>COMPONENT_USE[x]);<br>
       }<br>
    }<br>
+   if (unlikely(ctx->specs.tex_astc && (dirty & (ETNA_DIRTY_SAMPLER_VIEWS)))) {<br>
+      for (int x = 0; x < VIVS_TE_SAMPLER__LEN; ++x) {<br>
+         if ((1 << x) & active_samplers) {<br>
+            struct etna_sampler_view *sv = etna_sampler_view(ctx-><wbr>sampler_view[x]);<br>
+            /*10500*/ EMIT_STATE(NTE_SAMPLER_ASTC0(<wbr>x), sv->TE_SAMPLER_ASTC0);<br>
+         }<br>
+      }<br>
+   }<br>
    etna_coalesce_end(stream, &coalesce);<br>
    /* end only EMIT_STATE */<br>
<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.c b/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.c<br>
index 987f6a8..3dd212f 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.c<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.c<br>
@@ -246,6 +246,36 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {<br>
    _T(ETC2_RG11_UNORM, EXT_RG11_EAC | EXT_FORMAT,                      SWIZ(X, Y, Z, W), NONE),<br>
    _T(ETC2_RG11_SNORM, EXT_SIGNED_RG11_EAC | EXT_FORMAT,               SWIZ(X, Y, Z, W), NONE),<br>
<br>
+   _T(ASTC_4x4,        ASTC_RGBA_4x4 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_5x4,        ASTC_RGBA_5x4 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_5x5,        ASTC_RGBA_5x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_6x5,        ASTC_RGBA_6x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_6x6,        ASTC_RGBA_6x6 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x5,        ASTC_RGBA_8x5 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x6,        ASTC_RGBA_8x6 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x8,        ASTC_RGBA_8x8 | ASTC_FORMAT,                    SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x5,       ASTC_RGBA_10x5 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x6,       ASTC_RGBA_10x6 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x8,       ASTC_RGBA_10x8 | ASTC_FORMAT,                   SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x10,      ASTC_RGBA_10x10 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_12x10,      ASTC_RGBA_12x10 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_12x12,      ASTC_RGBA_12x12 | ASTC_FORMAT,                  SWIZ(X, Y, Z, W), NONE),<br>
+<br>
+   _T(ASTC_4x4_SRGB,   ASTC_SRGB8_ALPHA8_4x4 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_5x4_SRGB,   ASTC_SRGB8_ALPHA8_5x4 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_5x5_SRGB,   ASTC_SRGB8_ALPHA8_5x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_6x5_SRGB,   ASTC_SRGB8_ALPHA8_6x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_6x6_SRGB,   ASTC_SRGB8_ALPHA8_6x6 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x5_SRGB,   ASTC_SRGB8_ALPHA8_8x5 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x6_SRGB,   ASTC_SRGB8_ALPHA8_8x6 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_8x8_SRGB,   ASTC_SRGB8_ALPHA8_8x8 | ASTC_FORMAT,            SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x5_SRGB,  ASTC_SRGB8_ALPHA8_10x5 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x6_SRGB,  ASTC_SRGB8_ALPHA8_10x6 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x8_SRGB,  ASTC_SRGB8_ALPHA8_10x8 | ASTC_FORMAT,           SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_10x10_SRGB, ASTC_SRGB8_ALPHA8_10x10 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_12x10_SRGB, ASTC_SRGB8_ALPHA8_12x10 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE),<br>
+   _T(ASTC_12x12_SRGB, ASTC_SRGB8_ALPHA8_12x12 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE),<br>
+<br>
    /* YUV */<br>
    _T(YUYV, YUY2, SWIZ(X, Y, Z, W), YUY2),<br>
    _T(UYVY, UYVY, SWIZ(X, Y, Z, W), NONE),<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.h b/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.h<br>
index 543e309..1672d67 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.h<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_format.h<br>
@@ -32,6 +32,7 @@<br>
<br>
 #define ETNA_NO_MATCH (~0)<br>
 #define EXT_FORMAT (1 << 31)<br>
+#define ASTC_FORMAT (1 << 30)</blockquote></div></div></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
 uint32_t<br>
 translate_texture_format(enum pipe_format fmt);<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_internal.h b/src/gallium/drivers/etnaviv/<wbr>etnaviv_internal.h<br>
index 896bbf5..707a1e0 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_internal.h<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_internal.h<br>
@@ -80,6 +80,8 @@ struct etna_specs {<br>
    unsigned has_unified_uniforms : 1;<br>
    /* can load shader instructions from memory */<br>
    unsigned has_icache : 1;<br>
+   /* ASTC texture support (and has associated states) */<br>
+   unsigned tex_astc : 1;<br>
    /* can use any kind of wrapping mode on npot textures */<br>
    unsigned npot_tex_any_wrap;<br>
    /* number of bits per TS tile */<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_screen.c b/src/gallium/drivers/etnaviv/<wbr>etnaviv_screen.c<br>
index 68973be..72af71c 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_screen.c<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_screen.c<br>
@@ -499,6 +499,10 @@ gpu_supports_texure_format(<wbr>struct etna_screen *screen, uint32_t fmt,<br>
          supported = VIV_FEATURE(screen, chipMinorFeatures2, HALTI1);<br>
    }<br>
<br>
+   if (fmt & ASTC_FORMAT) {<br>
+      supported = screen->specs.tex_astc;<br>
+   }<br>
+<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I would love to see a new format helper (util_format_is_astc(..) and not even start thinking about adding a new format bit (ASTC_FORMAT).</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    if (!supported)<br>
       return false;<br>
<br>
@@ -788,6 +792,8 @@ etna_get_specs(struct etna_screen *screen)<br>
    if (screen->specs.single_buffer)<br>
       DBG("etnaviv: Single buffer mode enabled with %d pixel pipes\n", screen->specs.pixel_pipes);<br>
<br>
+   screen->specs.tex_astc = VIV_FEATURE(screen, chipMinorFeatures4, TEXTURE_ASTC);<br>
+<br>
    return true;<br>
<br>
 fail:<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.c b/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.c<br>
index 597390a..34529c6 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.c<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.c<br>
@@ -173,6 +173,7 @@ etna_create_sampler_view(<wbr>struct pipe_context *pctx, struct pipe_resource *prsc,<br>
    struct etna_context *ctx = etna_context(pctx);<br>
    const uint32_t format = translate_texture_format(so-><wbr>format);<br>
    const bool ext = !!(format & EXT_FORMAT);<br>
+   const bool astc = !!(format & ASTC_FORMAT);<br>
    const uint32_t swiz = get_texture_swiz(so->format, so->swizzle_r,<br>
                                           so->swizzle_g, so->swizzle_b,<br>
                                           so->swizzle_a);<br>
@@ -207,7 +208,7 @@ etna_create_sampler_view(<wbr>struct pipe_context *pctx, struct pipe_resource *prsc,<br>
    sv->base.context = pctx;<br>
<br>
    /* merged with sampler state */<br>
-   sv->TE_SAMPLER_CONFIG0 = COND(!ext, VIVS_TE_SAMPLER_CONFIG0_<wbr>FORMAT(format));<br>
+   sv->TE_SAMPLER_CONFIG0 = COND(!ext && !astc, VIVS_TE_SAMPLER_CONFIG0_<wbr>FORMAT(format));<br>
    sv->TE_SAMPLER_CONFIG0_MASK = 0xffffffff;<br>
<br>
    switch (sv->base.target) {<br>
@@ -231,13 +232,19 @@ etna_create_sampler_view(<wbr>struct pipe_context *pctx, struct pipe_resource *prsc,<br>
    }<br>
<br>
    sv->TE_SAMPLER_CONFIG1 = COND(ext, VIVS_TE_SAMPLER_CONFIG1_<wbr>FORMAT_EXT(format)) |<br>
+                            COND(astc, VIVS_TE_SAMPLER_CONFIG1_<wbr>FORMAT_EXT(TEXTURE_FORMAT_EXT_<wbr>ASTC)) |<br>
                             VIVS_TE_SAMPLER_CONFIG1_<wbr>HALIGN(res->halign) | swiz;<br>
+   sv->TE_SAMPLER_ASTC0 = COND(astc, VIVS_NTE_SAMPLER_ASTC0_ASTC_<wbr>FORMAT(format)) |<br>
+                          VIVS_NTE_SAMPLER_ASTC0_UNK8(<wbr>0xc) |<br>
+                          VIVS_NTE_SAMPLER_ASTC0_UNK16(<wbr>0xc) |<br>
+                          VIVS_NTE_SAMPLER_ASTC0_UNK24(<wbr>0xc);<br>
    sv->TE_SAMPLER_SIZE = VIVS_TE_SAMPLER_SIZE_WIDTH(<wbr>res->base.width0) |<br>
                          VIVS_TE_SAMPLER_SIZE_HEIGHT(<wbr>res->base.height0);<br>
    sv->TE_SAMPLER_LOG_SIZE =<br>
       VIVS_TE_SAMPLER_LOG_SIZE_<wbr>WIDTH(etna_log2_fixp55(res-><wbr>base.width0)) |<br>
       VIVS_TE_SAMPLER_LOG_SIZE_<wbr>HEIGHT(etna_log2_fixp55(res-><wbr>base.height0)) |<br>
-      COND(util_format_is_srgb(so-><wbr>format), VIVS_TE_SAMPLER_LOG_SIZE_SRGB)<wbr>;<br>
+      COND(util_format_is_srgb(so-><wbr>format) && !astc, VIVS_TE_SAMPLER_LOG_SIZE_SRGB) |<br>
+      COND(astc, VIVS_TE_SAMPLER_LOG_SIZE_ASTC)<wbr>;<br>
<br>
    /* Set up levels-of-detail */<br>
    for (int lod = 0; lod <= res->base.last_level; ++lod) {<br>
diff --git a/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.h b/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.h<br>
index a7a67fc..eafaae2 100644<br>
--- a/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.h<br>
+++ b/src/gallium/drivers/etnaviv/<wbr>etnaviv_texture.h<br>
@@ -59,6 +59,7 @@ struct etna_sampler_view {<br>
    uint32_t TE_SAMPLER_CONFIG1;<br>
    uint32_t TE_SAMPLER_SIZE;<br>
    uint32_t TE_SAMPLER_LOG_SIZE;<br>
+   uint32_t TE_SAMPLER_ASTC0;<br>
    struct etna_reloc TE_SAMPLER_LOD_ADDR[VIVS_TE_<wbr>SAMPLER_LOD_ADDR__LEN];<br>
    unsigned min_lod, max_lod; /* 5.5 fixp */<br>
 };<br>
<font color="#888888">--<br>
2.7.4<br>
<br>
</font></blockquote></div><br></div><div class="gmail_extra" dir="auto">Greets</div><div class="gmail_extra" dir="auto">--</div><div class="gmail_extra" dir="auto">Christian</div></div></div>