mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
lavapipe: enable dmabuf import for planar drm formats
Like e.g. NV12. This just requires some minor fixes around offset
handling.
(cherry picked from commit 0b6340fd94)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40092>
This commit is contained in:
parent
499a74569f
commit
a163dec3ff
3 changed files with 8 additions and 15 deletions
|
|
@ -564,7 +564,7 @@
|
|||
"description": "lavapipe: enable dmabuf import for planar drm formats",
|
||||
"nominated": false,
|
||||
"nomination_type": 0,
|
||||
"resolution": 4,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -2425,13 +2425,15 @@ lvp_image_plane_bind(struct lvp_device *device,
|
|||
struct lvp_image_plane *plane,
|
||||
struct lvp_device_memory *mem,
|
||||
VkDeviceSize memory_offset,
|
||||
VkDeviceSize *plane_offset)
|
||||
VkDeviceSize *min_plane_offset)
|
||||
{
|
||||
VkDeviceSize plane_offset = MAX2(plane->plane_offset, *min_plane_offset);
|
||||
|
||||
if (!device->pscreen->resource_bind_backing(device->pscreen,
|
||||
plane->bo,
|
||||
mem->pmem,
|
||||
0, 0,
|
||||
memory_offset + *plane_offset)) {
|
||||
memory_offset + plane_offset)) {
|
||||
/* This is probably caused by the texture being too large, so let's
|
||||
* report this as the *closest* allowed error-code. It's not ideal,
|
||||
* but it's unlikely that anyone will care too much.
|
||||
|
|
@ -2440,8 +2442,8 @@ lvp_image_plane_bind(struct lvp_device *device,
|
|||
}
|
||||
plane->pmem = mem->pmem;
|
||||
plane->memory_offset = memory_offset;
|
||||
plane->plane_offset = *plane_offset;
|
||||
*plane_offset += plane->size;
|
||||
plane->plane_offset = plane_offset;
|
||||
*min_plane_offset = plane_offset + plane->size;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ lvp_image_create(VkDevice _device,
|
|||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
|
||||
|
||||
#ifdef HAVE_LIBDRM
|
||||
unsigned num_layouts = 1;
|
||||
enum pipe_format pipe_format = lvp_vk_format_to_pipe_format(pCreateInfo->format);
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT *modinfo = (void*)vk_find_struct_const(pCreateInfo->pNext,
|
||||
IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT);
|
||||
|
|
@ -55,17 +54,9 @@ lvp_image_create(VkDevice _device,
|
|||
if (modinfo && pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
|
||||
assert(modinfo->drmFormatModifier == DRM_FORMAT_MOD_LINEAR);
|
||||
assert(modinfo->drmFormatModifierPlaneCount == util_format_get_num_planes(pipe_format));
|
||||
num_layouts = modinfo->drmFormatModifierPlaneCount;
|
||||
layouts = modinfo->pPlaneLayouts;
|
||||
}
|
||||
|
||||
/* planar not supported yet */
|
||||
assert(num_layouts == 1);
|
||||
if (num_layouts > 1) {
|
||||
mesa_loge("lavapipe: planar drm formats are not supported");
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
|
||||
modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
#endif
|
||||
|
||||
|
|
@ -174,7 +165,7 @@ lvp_image_create(VkDevice _device,
|
|||
whandle.stride = layouts[p].rowPitch;
|
||||
whandle.array_stride = layouts[p].arrayPitch;
|
||||
whandle.image_stride = layouts[p].depthPitch;
|
||||
image->offset = layouts[p].offset;
|
||||
image->planes[p].plane_offset = layouts[p].offset;
|
||||
whandle.format = pCreateInfo->format;
|
||||
whandle.modifier = modifier;
|
||||
image->planes[p].bo = device->pscreen->resource_from_handle(device->pscreen,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue