summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_resource.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2017-05-08 15:57:21 -0700
committerEric Anholt <[email protected]>2017-06-15 11:41:22 -0700
commit7029ec05e2c7cb9f9fe34070161be7d190a7581e (patch)
treefda95b737e0b06f14ab932fde759598a57fa1c82 /src/gallium/drivers/vc4/vc4_resource.c
parent7a171913052bacfee4c68f6fbd2b5d67e001dbae (diff)
gallium: Add renderonly-based support for pl111+vc4.
This follows the model of imx (display) and etnaviv (render): pl111 is a display-only device, so when asked to do GL for it, we see if we have a vc4 renderer, make the vc4 screen, and have vc4 call back to pl111 to do scanout allocations. The difference from etnaviv is that we share the same BO between vc4 and pl111, rather than having a vc4 bo and a pl11 bo and copies between the two. The only mismatch between their requirements is that vc4 requires 4-pixel (at 32bpp) stride alignment, while pl111 requires that stride match width. The kernel will reject any modesets to an incorrect stride, so the 3D driver doesn't need to worry about that. v2: Rebase on Android rework, drop unused include. v3: Fix another Android bug, from Rob Herring's build-testing. Reviewed-by: Christian Gmeiner <[email protected]>
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_resource.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_resource.c38
1 files changed, 38 insertions, 0 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: "