mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 02:20:11 +01:00
freedreno/drm: Add BO metadata support
This will be used as a back-channel between vk and gallium to communicate image layout metadata. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25945>
This commit is contained in:
parent
b8df7069d3
commit
32fa9bed12
4 changed files with 59 additions and 0 deletions
|
|
@ -602,6 +602,22 @@ fd_bo_is_cached(struct fd_bo *bo)
|
|||
return !!(bo->alloc_flags & FD_BO_CACHED_COHERENT);
|
||||
}
|
||||
|
||||
void
|
||||
fd_bo_set_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size)
|
||||
{
|
||||
if (!bo->funcs->set_metadata)
|
||||
return;
|
||||
bo->funcs->set_metadata(bo, metadata, metadata_size);
|
||||
}
|
||||
|
||||
int
|
||||
fd_bo_get_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size)
|
||||
{
|
||||
if (!bo->funcs->get_metadata)
|
||||
return -ENOSYS;
|
||||
return bo->funcs->get_metadata(bo, metadata, metadata_size);
|
||||
}
|
||||
|
||||
void *
|
||||
fd_bo_map_os_mmap(struct fd_bo *bo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -309,6 +309,8 @@ void fd_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len);
|
|||
bool fd_bo_prefer_upload(struct fd_bo *bo, unsigned len);
|
||||
int fd_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op);
|
||||
bool fd_bo_is_cached(struct fd_bo *bo);
|
||||
void fd_bo_set_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size);
|
||||
int fd_bo_get_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
|
|
|||
|
|
@ -455,6 +455,9 @@ struct fd_bo_funcs {
|
|||
* Optional, if upload is supported, should upload be preferred?
|
||||
*/
|
||||
bool (*prefer_upload)(struct fd_bo *bo, unsigned len);
|
||||
|
||||
void (*set_metadata)(struct fd_bo *bo, void *metadata, uint32_t metadata_size);
|
||||
int (*get_metadata)(struct fd_bo *bo, void *metadata, uint32_t metadata_size);
|
||||
};
|
||||
|
||||
void fd_bo_add_fence(struct fd_bo *bo, struct fd_fence *fence);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,42 @@ msm_bo_set_name(struct fd_bo *bo, const char *fmt, va_list ap)
|
|||
drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
|
||||
}
|
||||
|
||||
static void
|
||||
msm_bo_set_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size)
|
||||
{
|
||||
struct drm_msm_gem_info req = {
|
||||
.handle = bo->handle,
|
||||
.info = MSM_INFO_SET_METADATA,
|
||||
.value = (uintptr_t)(void *)metadata,
|
||||
.len = metadata_size,
|
||||
};
|
||||
|
||||
int ret = drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
|
||||
if (ret) {
|
||||
mesa_logw_once("Failed to set BO metadata with DRM_MSM_GEM_INFO: %d",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
msm_bo_get_metadata(struct fd_bo *bo, void *metadata, uint32_t metadata_size)
|
||||
{
|
||||
struct drm_msm_gem_info req = {
|
||||
.handle = bo->handle,
|
||||
.info = MSM_INFO_GET_METADATA,
|
||||
.value = (uintptr_t)(void *)metadata,
|
||||
.len = metadata_size,
|
||||
};
|
||||
|
||||
int ret = drmCommandWrite(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
|
||||
if (ret) {
|
||||
mesa_logw_once("Failed to get BO metadata with DRM_MSM_GEM_INFO: %d",
|
||||
ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct fd_bo_funcs funcs = {
|
||||
.offset = msm_bo_offset,
|
||||
.map = fd_bo_map_os_mmap,
|
||||
|
|
@ -143,6 +179,8 @@ static const struct fd_bo_funcs funcs = {
|
|||
.madvise = msm_bo_madvise,
|
||||
.iova = msm_bo_iova,
|
||||
.set_name = msm_bo_set_name,
|
||||
.set_metadata = msm_bo_set_metadata,
|
||||
.get_metadata = msm_bo_get_metadata,
|
||||
.dmabuf = fd_bo_dmabuf_drm,
|
||||
.destroy = fd_bo_fini_common,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue