freedreno: Add layout metadata support
Add support to use layout metadata to communicate modifier between exporter and importer. This is required because EXT_external_objects does not have modifier support, so when importing a memobj we must use a back-channel to communicate the modifier with the exporter. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25945>
This commit is contained in:
@@ -1108,6 +1108,13 @@ fd_resource_get_handle(struct pipe_screen *pscreen, struct pipe_context *pctx,
|
||||
|
||||
handle->modifier = fd_resource_modifier(rsc);
|
||||
|
||||
if (prsc->target != PIPE_BUFFER) {
|
||||
struct fdl_metadata metadata = {
|
||||
.modifier = handle->modifier,
|
||||
};
|
||||
fd_bo_set_metadata(rsc->bo, &metadata, sizeof(metadata));
|
||||
}
|
||||
|
||||
DBG("%" PRSC_FMT ", modifier=%" PRIx64, PRSC_ARGS(prsc), handle->modifier);
|
||||
|
||||
bool ret = fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout,
|
||||
@@ -1661,14 +1668,20 @@ fd_resource_from_memobj(struct pipe_screen *pscreen,
|
||||
struct fd_memory_object *memobj = fd_memory_object(pmemobj);
|
||||
struct pipe_resource *prsc;
|
||||
struct fd_resource *rsc;
|
||||
struct fdl_metadata metadata;
|
||||
uint32_t size;
|
||||
|
||||
assert(memobj->bo);
|
||||
assert(offset == 0);
|
||||
|
||||
/* We shouldn't get a scanout buffer here. */
|
||||
assert(!(tmpl->bind & PIPE_BIND_SCANOUT));
|
||||
|
||||
uint64_t modifiers = DRM_FORMAT_MOD_INVALID;
|
||||
if (tmpl->bind & PIPE_BIND_LINEAR) {
|
||||
if (pmemobj->dedicated &&
|
||||
!fd_bo_get_metadata(memobj->bo, &metadata, sizeof(metadata))) {
|
||||
modifiers = metadata.modifier;
|
||||
} else if (tmpl->bind & PIPE_BIND_LINEAR) {
|
||||
modifiers = DRM_FORMAT_MOD_LINEAR;
|
||||
} else if (is_a6xx(screen) && tmpl->width0 >= FDL_MIN_UBWC_WIDTH) {
|
||||
modifiers = DRM_FORMAT_MOD_QCOM_COMPRESSED;
|
||||
|
||||
Reference in New Issue
Block a user