mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
lavapipe: handle drm image imports
this creates the unbacked image with the metadata expected for use with imports, then applies the import offset when binding memory Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27805>
This commit is contained in:
parent
bd4f69a0fe
commit
d6cb3c5793
3 changed files with 29 additions and 4 deletions
|
|
@ -2186,7 +2186,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_BindImageMemory2(VkDevice _device,
|
|||
VkResult fail = VK_SUCCESS;
|
||||
for (unsigned plane = 0; plane < image->plane_count; plane++) {
|
||||
result = lvp_image_plane_bind(device, &image->planes[plane],
|
||||
mem, bind_info->memoryOffset, &offset_B);
|
||||
mem, bind_info->memoryOffset + image->offset, &offset_B);
|
||||
if (status)
|
||||
*status->pResult = res;
|
||||
if (result != VK_SUCCESS)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "util/u_inlines.h"
|
||||
#include "util/u_surface.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "frontend/winsys_handle.h"
|
||||
|
||||
static VkResult
|
||||
lvp_image_create(VkDevice _device,
|
||||
|
|
@ -132,9 +133,32 @@ lvp_image_create(VkDevice _device,
|
|||
template.last_level = pCreateInfo->mipLevels - 1;
|
||||
template.nr_samples = pCreateInfo->samples;
|
||||
template.nr_storage_samples = pCreateInfo->samples;
|
||||
image->planes[p].bo = device->pscreen->resource_create_unbacked(device->pscreen,
|
||||
&template,
|
||||
&image->planes[p].size);
|
||||
|
||||
#ifdef HAVE_LIBDRM
|
||||
if (modinfo && pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
|
||||
struct winsys_handle whandle;
|
||||
whandle.type = WINSYS_HANDLE_TYPE_UNBACKED;
|
||||
whandle.layer = 0;
|
||||
whandle.plane = p;
|
||||
whandle.handle = 0;
|
||||
whandle.stride = layouts[p].rowPitch;
|
||||
whandle.array_stride = layouts[p].arrayPitch;
|
||||
whandle.image_stride = layouts[p].depthPitch;
|
||||
image->offset = layouts[p].offset;
|
||||
whandle.format = pCreateInfo->format;
|
||||
whandle.modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
image->planes[p].bo = device->pscreen->resource_from_handle(device->pscreen,
|
||||
&template,
|
||||
&whandle,
|
||||
PIPE_HANDLE_USAGE_EXPLICIT_FLUSH);
|
||||
image->planes[p].size = whandle.size;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
image->planes[p].bo = device->pscreen->resource_create_unbacked(device->pscreen,
|
||||
&template,
|
||||
&image->planes[p].size);
|
||||
}
|
||||
if (!image->planes[p].bo)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
|
|
|
|||
|
|
@ -271,6 +271,7 @@ struct lvp_image_plane {
|
|||
|
||||
struct lvp_image {
|
||||
struct vk_image vk;
|
||||
VkDeviceSize offset;
|
||||
VkDeviceSize size;
|
||||
uint32_t alignment;
|
||||
bool disjoint;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue