diff options
author | Eric Anholt <eric@anholt.net> | 2016-11-16 16:57:45 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2016-11-16 19:45:01 -0800 |
commit | 45c022f2b06967196516f0616a9e4959ddcd14da (patch) | |
tree | e2b86f3964f067f66788f18c9e33f9fa9e4c91a9 | |
parent | 7130260d1212d84d046c67682cb4eed95c852657 (diff) |
vc4: Add support for ETC1 textures if the kernel is new enough.
The kernel changes for exposing the param have now been merged, so we can
expose it here.
-rw-r--r-- | src/gallium/drivers/vc4/vc4_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_screen.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_screen.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_simulator.c | 1 |
4 files changed, 18 insertions, 5 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h index db9e82d2a22..e59b1d28287 100644 --- a/src/gallium/drivers/vc4/vc4_context.h +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -39,6 +39,10 @@ #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 diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 82b50775cb4..9f852f0326d 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -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; diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h index 83bb5aacfcf..572d62d6ac1 100644 --- a/src/gallium/drivers/vc4/vc4_screen.h +++ b/src/gallium/drivers/vc4/vc4_screen.h @@ -30,6 +30,10 @@ #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; }; diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c index 82ffaab834c..815898329b3 100644 --- a/src/gallium/drivers/vc4/vc4_simulator.c +++ b/src/gallium/drivers/vc4/vc4_simulator.c @@ -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; |