diff options
author | Mike Blumenkrantz <[email protected]> | 2019-04-30 14:51:52 -0400 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-05-07 13:36:08 -0700 |
commit | ddd716e746767d2ec8599c0ad623c582ba46e5d1 (patch) | |
tree | c933b95920931a95f5643db80ee65e9a8f86a1d5 /src/gallium/drivers/iris | |
parent | 748f603390bdfec129bc73d3d2608db20f1571ae (diff) |
iris: support dmabuf imports with offsets
this adds support for imports where the image data begins at an offset
from the start of the buffer, as used in h/x264
fixes kwg/mesa#47
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris')
-rw-r--r-- | src/gallium/drivers/iris/iris_blit.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_resource.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_resource.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_state.c | 11 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/gallium/drivers/iris/iris_blit.c b/src/gallium/drivers/iris/iris_blit.c index 67283307ae6..0ee2046481b 100644 --- a/src/gallium/drivers/iris/iris_blit.c +++ b/src/gallium/drivers/iris/iris_blit.c @@ -246,7 +246,7 @@ iris_blorp_surf_for_resource(struct iris_vtable *vtbl, .surf = &res->surf, .addr = (struct blorp_address) { .buffer = res->bo, - .offset = 0, // XXX: ??? + .offset = res->offset, .reloc_flags = is_render_target ? EXEC_OBJECT_WRITE : 0, .mocs = vtbl->mocs(res->bo), }, diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index fd50139defc..971e7adda7e 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -759,12 +759,6 @@ iris_resource_from_handle(struct pipe_screen *pscreen, if (!res) return NULL; - if (whandle->offset != 0) { - dbg_printf("Attempt to import unsupported winsys offset %u\n", - whandle->offset); - goto fail; - } - switch (whandle->type) { case WINSYS_HANDLE_TYPE_FD: res->bo = iris_bo_import_dmabuf(bufmgr, whandle->handle); @@ -779,6 +773,8 @@ iris_resource_from_handle(struct pipe_screen *pscreen, if (!res->bo) return NULL; + res->offset = whandle->offset; + uint64_t modifier = whandle->modifier; if (modifier == DRM_FORMAT_MOD_INVALID) { modifier = tiling_to_modifier(res->bo->tiling_mode); diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index 7cb6767b2f9..79b15056b09 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -68,6 +68,9 @@ struct iris_resource { /** Backing storage for the resource */ struct iris_bo *bo; + /** offset at which data starts in the BO */ + uint64_t offset; + /** * A bitfield of PIPE_BIND_* indicating how this resource was bound * in the past. Only meaningful for PIPE_BUFFER; used for flushing. diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 1d8f61847ff..bee212222bf 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1724,7 +1724,7 @@ fill_surface_state(struct isl_device *isl_dev, .surf = &res->surf, .view = view, .mocs = mocs(res->bo), - .address = res->bo->gtt_offset, + .address = res->bo->gtt_offset + res->offset, }; if (aux_usage != ISL_AUX_USAGE_NONE) { @@ -2505,7 +2505,7 @@ iris_set_framebuffer_state(struct pipe_context *ctx, view.usage |= ISL_SURF_USAGE_DEPTH_BIT; info.depth_surf = &zres->surf; - info.depth_address = zres->bo->gtt_offset; + info.depth_address = zres->bo->gtt_offset + zres->offset; info.mocs = mocs(zres->bo); view.format = zres->surf.format; @@ -2520,7 +2520,7 @@ iris_set_framebuffer_state(struct pipe_context *ctx, if (stencil_res) { view.usage |= ISL_SURF_USAGE_STENCIL_BIT; info.stencil_surf = &stencil_res->surf; - info.stencil_address = stencil_res->bo->gtt_offset; + info.stencil_address = stencil_res->bo->gtt_offset + stencil_res->offset; if (!zres) { view.format = stencil_res->surf.format; info.mocs = mocs(stencil_res->bo); @@ -2592,8 +2592,9 @@ upload_ubo_ssbo_surf_state(struct iris_context *ice, surf_state->offset += iris_bo_offset_from_base_address(surf_bo); isl_buffer_fill_state(&screen->isl_dev, map, - .address = res->bo->gtt_offset + buf->buffer_offset, - .size_B = buf->buffer_size, + .address = res->bo->gtt_offset + res->offset + + buf->buffer_offset, + .size_B = buf->buffer_size - res->offset, .format = ssbo ? ISL_FORMAT_RAW : ISL_FORMAT_R32G32B32A32_FLOAT, .swizzle = ISL_SWIZZLE_IDENTITY, |