vc4: Add support for ETC1 textures if the kernel is new enough.
authorEric Anholt <eric@anholt.net>
Thu, 17 Nov 2016 00:57:45 +0000 (16:57 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 17 Nov 2016 03:45:01 +0000 (19:45 -0800)
The kernel changes for exposing the param have now been merged, so we can
expose it here.

src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/drivers/vc4/vc4_screen.h
src/gallium/drivers/vc4/vc4_simulator.c

index db9e82d2a229e50a7ebb480fbd34431dde6b7852..e59b1d282871379f297c815a00146349c3ef7793 100644 (file)
 #include "vc4_cl.h"
 #include "vc4_qir.h"
 
+#ifndef DRM_VC4_PARAM_SUPPORTS_ETC1
+#define DRM_VC4_PARAM_SUPPORTS_ETC1            4
+#endif
+
 #ifdef USE_VC4_SIMULATOR
 #define using_vc4_simulator true
 #else
index 82b50775cb42446d73eb7d7626c689bbebb16058..9f852f0326d0ea81a518d543d92a3812b10e427e 100644 (file)
@@ -418,6 +418,7 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
                                unsigned sample_count,
                                unsigned usage)
 {
+        struct vc4_screen *screen = vc4_screen(pscreen);
         unsigned retval = 0;
 
         if (sample_count > 1 && sample_count != VC4_MAX_SAMPLES)
@@ -488,7 +489,7 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
 
         if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
             vc4_tex_format_supported(format) &&
-            format != PIPE_FORMAT_ETC1_RGB8) {
+            (format != PIPE_FORMAT_ETC1_RGB8 || screen->has_etc1)) {
                 retval |= PIPE_BIND_SAMPLER_VIEW;
         }
 
@@ -529,10 +530,10 @@ static int handle_compare(void *key1, void *key2)
 }
 
 static bool
-vc4_supports_branches(struct vc4_screen *screen)
+vc4_has_feature(struct vc4_screen *screen, uint32_t feature)
 {
         struct drm_vc4_get_param p = {
-                .param = DRM_VC4_PARAM_SUPPORTS_BRANCHES,
+                .param = feature,
         };
         int ret = vc4_ioctl(screen->fd, DRM_IOCTL_VC4_GET_PARAM, &p);
 
@@ -609,8 +610,10 @@ vc4_screen_create(int fd)
         pipe_mutex_init(screen->bo_handles_mutex);
         screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
 
-        if (vc4_supports_branches(screen))
-                screen->has_control_flow = true;
+        screen->has_control_flow =
+                vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_BRANCHES);
+        screen->has_etc1 =
+                vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_ETC1);
 
         if (!vc4_get_chip_info(screen))
                 goto fail;
index 83bb5aacfcf8f0fedc9f053c87d4d4897d818021..572d62d6ac1278d13bd3bc519eb47f98af8b02d8 100644 (file)
 #include "util/list.h"
 #include "util/slab.h"
 
+#ifndef DRM_VC4_PARAM_SUPPORTS_ETC1
+#define DRM_VC4_PARAM_SUPPORTS_ETC1            4
+#endif
+
 struct vc4_bo;
 
 #define VC4_DEBUG_CL        0x0001
@@ -85,6 +89,7 @@ struct vc4_screen {
         uint32_t bo_size;
         uint32_t bo_count;
         bool has_control_flow;
+        bool has_etc1;
 
         struct vc4_simulator_file *sim_file;
 };
index 82ffaab834ca0060bab8e8104ec78055abc0b261..815898329b32dd18763bba5162cbb6921d631f8e 100644 (file)
@@ -612,6 +612,7 @@ vc4_simulator_get_param_ioctl(int fd, struct drm_vc4_get_param *args)
 {
         switch (args->param) {
         case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
+        case DRM_VC4_PARAM_SUPPORTS_ETC1:
                 args->value = true;
                 return 0;