diff options
author | Jonathan Marek <[email protected]> | 2019-01-16 10:22:53 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2019-01-26 10:47:21 -0500 |
commit | 41ddf1d1506e4a1394ab784d805d1df78b1892e1 (patch) | |
tree | b546fe3b3299e8d2ac589294d23e8cd9088c65f3 /src/gallium/drivers/freedreno/freedreno_resource.c | |
parent | cd79b5e0c2cc0035719348592bac97dce6ce1d73 (diff) |
freedreno: add renderonly scanout
This allows creating a fd_screen with a renderonly object which will be
used to allocated scanout resources.
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
[slight tweak to fix uninitialized 'prsc' in debug print]
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_resource.c')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index ca48fc9cee1..11319a44bb7 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -663,6 +663,9 @@ fd_resource_destroy(struct pipe_screen *pscreen, fd_bc_invalidate_resource(rsc, true); if (rsc->bo) fd_bo_del(rsc->bo); + if (rsc->scanout) + renderonly_scanout_destroy(rsc->scanout, fd_screen(pscreen)->ro); + util_range_destroy(&rsc->valid_buffer_range); FREE(rsc); } @@ -688,7 +691,7 @@ fd_resource_get_handle(struct pipe_screen *pscreen, handle->modifier = fd_resource_modifier(rsc); - return fd_screen_bo_get_handle(pscreen, rsc->bo, + return fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout, rsc->slices[0].pitch * rsc->cpp, handle); } @@ -845,11 +848,37 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen, const uint64_t *modifiers, int count) { struct fd_screen *screen = fd_screen(pscreen); - struct fd_resource *rsc = CALLOC_STRUCT(fd_resource); - struct pipe_resource *prsc = &rsc->base; + struct fd_resource *rsc; + struct pipe_resource *prsc; enum pipe_format format = tmpl->format; uint32_t size; + if (screen->ro && (tmpl->bind & PIPE_BIND_SCANOUT)) { + struct pipe_resource scanout_templat = *tmpl; + struct renderonly_scanout *scanout; + struct winsys_handle handle; + + scanout = renderonly_scanout_for_resource(&scanout_templat, + screen->ro, &handle); + if (!scanout) + return NULL; + + renderonly_scanout_destroy(scanout, screen->ro); + + assert(handle.type == WINSYS_HANDLE_TYPE_FD); + rsc = fd_resource(pscreen->resource_from_handle(pscreen, tmpl, + &handle, + PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)); + close(handle.handle); + if (!rsc) + return NULL; + + return &rsc->base; + } + + rsc = CALLOC_STRUCT(fd_resource); + prsc = &rsc->base; + DBG("%p: target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, " "nr_samples=%u, usage=%u, bind=%x, flags=%x", prsc, tmpl->target, util_format_name(format), @@ -1050,6 +1079,12 @@ fd_resource_from_handle(struct pipe_screen *pscreen, assert(rsc->cpp); + if (screen->ro) { + rsc->scanout = + renderonly_create_gpu_import_for_resource(prsc, screen->ro, NULL); + /* failure is expected in some cases.. */ + } + return prsc; fail: |