[PATCH 3/3] etnaviv: Check extended format availability on GPU

Wladimir J. van der Laan laanwj at gmail.com
Tue May 16 08:42:00 UTC 2017


Current information shows that both extended texture/render formats
and texture swizzling were introduced with the HALTI0 feature bit,
available on GC2000/GC3000.
---
 src/gallium/drivers/etnaviv/etnaviv_format.c | 12 ++++++++++++
 src/gallium/drivers/etnaviv/etnaviv_format.h |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 21 ++++++++++++++++++---
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c b/src/gallium/drivers/etnaviv/etnaviv_format.c
index 23bb6c1..dbedda3 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_format.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
@@ -293,6 +293,18 @@ translate_texture_format_swiz(enum pipe_format fmt, unsigned char tex_swz[4])
    return true;
 }
 
+bool
+translate_texture_format_needs_swiz(enum pipe_format fmt)
+{
+   if (!formats[fmt].present)
+      return false;
+
+   return formats[fmt].tex_swz[0] != 0 ||
+          formats[fmt].tex_swz[1] != 1 ||
+          formats[fmt].tex_swz[2] != 2 ||
+          formats[fmt].tex_swz[3] != 3;
+}
+
 uint32_t
 translate_rs_format(enum pipe_format fmt)
 {
diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.h b/src/gallium/drivers/etnaviv/etnaviv_format.h
index ce75161..9e60d64 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_format.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_format.h
@@ -50,4 +50,7 @@ translate_vertex_format_type(enum pipe_format fmt);
 bool
 translate_texture_format_swiz(enum pipe_format fmt, unsigned char tex_swz[4]);
 
+bool
+translate_texture_format_needs_swiz(enum pipe_format fmt);
+
 #endif /* ETNAVIV_FORMAT_H_ */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index a92cfd4..80d62aa 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -459,6 +459,12 @@ gpu_supports_texure_format(struct etna_screen *screen, uint32_t fmt)
    return true;
 }
 
+static bool
+gpu_supports_extended_texure_format(struct etna_screen *screen, uint32_t fmt_ext)
+{
+   return VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
+}
+
 static boolean
 etna_screen_is_format_supported(struct pipe_screen *pscreen,
                                 enum pipe_format format,
@@ -499,9 +505,18 @@ etna_screen_is_format_supported(struct pipe_screen *pscreen,
 
    if (usage & PIPE_BIND_SAMPLER_VIEW) {
       uint32_t fmt = translate_texture_format(format);
-
-      if (!gpu_supports_texure_format(screen, fmt))
-         fmt = ETNA_NO_MATCH;
+      uint32_t fmt_ext = translate_texture_format_ext(format);
+
+      /* extended and swizzled texture formats are only supported with HALTI0 */
+      if (fmt_ext || translate_texture_format_needs_swiz(format)) {
+         /* fmt will be 0 for extended formats, which is ok as it is only compared
+          * against ETNA_NO_MATCH below */
+         if (!gpu_supports_extended_texure_format(screen, fmt_ext))
+            fmt = ETNA_NO_MATCH;
+      } else {
+         if (!gpu_supports_texure_format(screen, fmt))
+            fmt = ETNA_NO_MATCH;
+      }
 
       if (sample_count < 2 && fmt != ETNA_NO_MATCH)
          allowed |= PIPE_BIND_SAMPLER_VIEW;
-- 
2.7.4



More information about the etnaviv mailing list