aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_screen.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2017-06-05 14:50:26 -0700
committerEric Anholt <[email protected]>2017-07-12 10:58:33 -0700
commit84ed8b67c56b323cd834d463151e1a3c0430c53e (patch)
tree5b59af4b319a15d2617ae598fb90fcdce952d53f /src/gallium/drivers/vc4/vc4_screen.c
parentbb466a996ffcd328d7f4b543a202291913800979 (diff)
vc4: Set shareable BOs as T tiled if possible
X11 and GL compositor performance on VC4 has been terrible because of our SHARED-usage buffers all being forced to linear. This swaps SHARED && !LINEAR buffers over to being tiled. This is an expected win for all GL compositors during rendering (a full copy of each shared texture per draw call), allows X11 to be used with decent performance without a GL compositor, and improves X11 windowed swapbuffers performance as well. It also halves the memory usage of shared buffers that get textured from. The only cost should be idle systems with a scanout-only buffer that isn't flagged as LINEAR, in which case the memory bandwidth cost of scanout goes up ~25%. This implements the EGL_EXT_image_dma_buf_import_modifiers extension, supporting the VC4 T_TILED modifier. v2: Added modifier support to resource creation/import, and advertisement (by daniels). v3: Fix old-kernel fallback path, fix compiler error and warnings, and comment touchups (by anholt). Reviewed-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_screen.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_screen.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index 07395487d77..f3b47ca8903 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -35,6 +35,7 @@
#include "util/ralloc.h"
#include <xf86drm.h>
+#include "drm_fourcc.h"
#include "vc4_drm.h"
#include "vc4_screen.h"
#include "vc4_context.h"
@@ -534,6 +535,34 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
return retval == usage;
}
+static void
+vc4_screen_query_dmabuf_modifiers(struct pipe_screen *pscreen,
+ enum pipe_format format, int max,
+ uint64_t *modifiers,
+ unsigned int *external_only,
+ int *count)
+{
+ if (!modifiers) {
+ *count = 2;
+ return;
+ }
+
+ *count = MIN2(max, 2);
+
+ /* We support both modifiers (tiled and linear) for all sampler
+ * formats.
+ */
+ modifiers[0] = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED;
+ if (external_only)
+ external_only[0] = false;
+ if (max < 2)
+ return;
+
+ modifiers[1] = DRM_FORMAT_MOD_LINEAR;
+ if (external_only)
+ external_only[1] = false;
+}
+
#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
static unsigned handle_hash(void *key)
@@ -666,6 +695,7 @@ vc4_screen_create(int fd, struct renderonly *ro)
pscreen->get_vendor = vc4_screen_get_vendor;
pscreen->get_device_vendor = vc4_screen_get_vendor;
pscreen->get_compiler_options = vc4_screen_get_compiler_options;
+ pscreen->query_dmabuf_modifiers = vc4_screen_query_dmabuf_modifiers;
return pscreen;