summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r--src/gallium/drivers/vc4/vc4_resource.c38
-rw-r--r--src/gallium/drivers/vc4/vc4_resource.h1
-rw-r--r--src/gallium/drivers/vc4/vc4_screen.c12
-rw-r--r--src/gallium/drivers/vc4/vc4_screen.h5
4 files changed, 54 insertions, 2 deletions
diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index db7faf7ce3b..5aaa31d6e67 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -371,9 +371,14 @@ static void
vc4_resource_destroy(struct pipe_screen *pscreen,
struct pipe_resource *prsc)
{
+ struct vc4_screen *screen = vc4_screen(pscreen);
struct vc4_resource *rsc = vc4_resource(prsc);
pipe_resource_reference(&rsc->shadow_parent, NULL);
vc4_bo_unreference(&rsc->bo);
+
+ if (rsc->scanout)
+ renderonly_scanout_destroy(rsc->scanout, screen->ro);
+
free(rsc);
}
@@ -384,6 +389,7 @@ vc4_resource_get_handle(struct pipe_screen *pscreen,
struct winsys_handle *whandle,
unsigned usage)
{
+ struct vc4_screen *screen = vc4_screen(pscreen);
struct vc4_resource *rsc = vc4_resource(prsc);
whandle->stride = rsc->slices[0].stride;
@@ -396,11 +402,23 @@ vc4_resource_get_handle(struct pipe_screen *pscreen,
switch (whandle->type) {
case DRM_API_HANDLE_TYPE_SHARED:
+ if (screen->ro) {
+ /* This could probably be supported, assuming that a
+ * control node was used for pl111.
+ */
+ fprintf(stderr, "flink unsupported with pl111\n");
+ return FALSE;
+ }
+
return vc4_bo_flink(rsc->bo, &whandle->handle);
case DRM_API_HANDLE_TYPE_KMS:
+ if (screen->ro && renderonly_get_handle(rsc->scanout, whandle))
+ return TRUE;
whandle->handle = rsc->bo->handle;
return TRUE;
case DRM_API_HANDLE_TYPE_FD:
+ /* FDs are cross-device, so we can export directly from vc4.
+ */
whandle->handle = vc4_bo_get_dmabuf(rsc->bo);
return whandle->handle != -1;
}
@@ -553,6 +571,7 @@ struct pipe_resource *
vc4_resource_create(struct pipe_screen *pscreen,
const struct pipe_resource *tmpl)
{
+ struct vc4_screen *screen = vc4_screen(pscreen);
struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl);
struct pipe_resource *prsc = &rsc->base;
@@ -577,6 +596,13 @@ vc4_resource_create(struct pipe_screen *pscreen,
if (!vc4_resource_bo_alloc(rsc))
goto fail;
+ if (screen->ro && tmpl->bind & PIPE_BIND_SCANOUT) {
+ rsc->scanout =
+ renderonly_scanout_for_resource(prsc, screen->ro);
+ if (!rsc->scanout)
+ goto fail;
+ }
+
return prsc;
fail:
vc4_resource_destroy(pscreen, prsc);
@@ -646,6 +672,18 @@ vc4_resource_from_handle(struct pipe_screen *pscreen,
rsc->vc4_format = get_resource_texture_format(prsc);
+ if (screen->ro) {
+ /* Make sure that renderonly has a handle to our buffer in the
+ * display's fd, so that a later renderonly_get_handle()
+ * returns correct handles or GEM names.
+ */
+ rsc->scanout =
+ renderonly_create_gpu_import_for_resource(prsc,
+ screen->ro);
+ if (!rsc->scanout)
+ goto fail;
+ }
+
if (miptree_debug) {
fprintf(stderr,
"rsc import %p (format %d), %dx%d: "
diff --git a/src/gallium/drivers/vc4/vc4_resource.h b/src/gallium/drivers/vc4/vc4_resource.h
index 877db513ace..32e73dddb34 100644
--- a/src/gallium/drivers/vc4/vc4_resource.h
+++ b/src/gallium/drivers/vc4/vc4_resource.h
@@ -54,6 +54,7 @@ struct vc4_surface {
struct vc4_resource {
struct pipe_resource base;
struct vc4_bo *bo;
+ struct renderonly_scanout *scanout;
struct vc4_resource_slice slices[VC4_MAX_MIP_LEVELS];
uint32_t cube_map_stride;
int cpp;
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index b87aaf73f94..6b35abb10eb 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -100,6 +100,7 @@ vc4_screen_destroy(struct pipe_screen *pscreen)
util_hash_table_destroy(screen->bo_handles);
vc4_bufmgr_destroy(pscreen);
slab_destroy_parent(&screen->transfer_pool);
+ free(screen->ro);
#if USE_VC4_SIMULATOR
vc4_simulator_destroy(screen);
@@ -605,7 +606,7 @@ vc4_get_chip_info(struct vc4_screen *screen)
}
struct pipe_screen *
-vc4_screen_create(int fd)
+vc4_screen_create(int fd, struct renderonly *ro)
{
struct vc4_screen *screen = rzalloc(NULL, struct vc4_screen);
struct pipe_screen *pscreen;
@@ -620,6 +621,15 @@ vc4_screen_create(int fd)
pscreen->is_format_supported = vc4_screen_is_format_supported;
screen->fd = fd;
+ if (ro) {
+ screen->ro = renderonly_dup(ro);
+ if (!screen->ro) {
+ fprintf(stderr, "Failed to dup renderonly object\n");
+ ralloc_free(screen);
+ return NULL;
+ }
+ }
+
list_inithead(&screen->bo_cache.time_list);
(void) mtx_init(&screen->bo_handles_mutex, mtx_plain);
screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h
index 0f80ffb3463..295633db469 100644
--- a/src/gallium/drivers/vc4/vc4_screen.h
+++ b/src/gallium/drivers/vc4/vc4_screen.h
@@ -25,6 +25,7 @@
#define VC4_SCREEN_H
#include "pipe/p_screen.h"
+#include "renderonly/renderonly.h"
#include "os/os_thread.h"
#include "state_tracker/drm_driver.h"
#include "util/list.h"
@@ -55,6 +56,8 @@ struct vc4_simulator_file;
struct vc4_screen {
struct pipe_screen base;
+ struct renderonly *ro;
+
int fd;
int v3d_ver;
@@ -101,7 +104,7 @@ vc4_screen(struct pipe_screen *screen)
return (struct vc4_screen *)screen;
}
-struct pipe_screen *vc4_screen_create(int fd);
+struct pipe_screen *vc4_screen_create(int fd, struct renderonly *ro);
const void *
vc4_screen_get_compiler_options(struct pipe_screen *pscreen,