mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
venus: track prime blit dst buffer memory in the wsi image
This is to prepare for handling implicit fence from the compositor. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34516>
This commit is contained in:
parent
fef64b7e7d
commit
5535184539
4 changed files with 36 additions and 1 deletions
|
|
@ -48,6 +48,11 @@ struct vn_buffer {
|
||||||
struct vn_object_base base;
|
struct vn_object_base base;
|
||||||
|
|
||||||
struct vn_buffer_memory_requirements requirements;
|
struct vn_buffer_memory_requirements requirements;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
/* buffer is prime blit dst */
|
||||||
|
struct vn_device_memory *mem;
|
||||||
|
} wsi;
|
||||||
};
|
};
|
||||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_buffer,
|
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_buffer,
|
||||||
base.vk,
|
base.vk,
|
||||||
|
|
|
||||||
|
|
@ -1481,6 +1481,19 @@ vn_CmdCopyImageToBuffer(VkCommandBuffer commandBuffer,
|
||||||
uint32_t regionCount,
|
uint32_t regionCount,
|
||||||
const VkBufferImageCopy *pRegions)
|
const VkBufferImageCopy *pRegions)
|
||||||
{
|
{
|
||||||
|
struct vn_image *img = vn_image_from_handle(srcImage);
|
||||||
|
struct vn_buffer *buf = vn_buffer_from_handle(dstBuffer);
|
||||||
|
|
||||||
|
/* The prime blit dst buffer is internal to common wsi layer. Only the
|
||||||
|
* corresponding wsi image can blit to it.
|
||||||
|
*/
|
||||||
|
if (buf->wsi.mem) {
|
||||||
|
assert(img->wsi.is_wsi);
|
||||||
|
assert(img->wsi.is_prime_blit_src);
|
||||||
|
assert(!img->wsi.blit_mem);
|
||||||
|
img->wsi.blit_mem = buf->wsi.mem;
|
||||||
|
}
|
||||||
|
|
||||||
VN_CMD_ENQUEUE(vkCmdCopyImageToBuffer, commandBuffer, srcImage,
|
VN_CMD_ENQUEUE(vkCmdCopyImageToBuffer, commandBuffer, srcImage,
|
||||||
srcImageLayout, dstBuffer, regionCount, pRegions);
|
srcImageLayout, dstBuffer, regionCount, pRegions);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,14 +363,18 @@ vn_AllocateMemory(VkDevice device,
|
||||||
|
|
||||||
const VkImportMemoryFdInfoKHR *import_fd_info = NULL;
|
const VkImportMemoryFdInfoKHR *import_fd_info = NULL;
|
||||||
const VkMemoryDedicatedAllocateInfo *dedicated_info = NULL;
|
const VkMemoryDedicatedAllocateInfo *dedicated_info = NULL;
|
||||||
|
const struct wsi_memory_allocate_info *wsi_info = NULL;
|
||||||
vk_foreach_struct_const(pnext, pAllocateInfo->pNext) {
|
vk_foreach_struct_const(pnext, pAllocateInfo->pNext) {
|
||||||
switch (pnext->sType) {
|
switch ((uint32_t)pnext->sType) {
|
||||||
case VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR:
|
case VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR:
|
||||||
import_fd_info = (const void *)pnext;
|
import_fd_info = (const void *)pnext;
|
||||||
break;
|
break;
|
||||||
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
|
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
|
||||||
dedicated_info = (const void *)pnext;
|
dedicated_info = (const void *)pnext;
|
||||||
break;
|
break;
|
||||||
|
case VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA:
|
||||||
|
wsi_info = (const void *)pnext;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -391,6 +395,16 @@ vn_AllocateMemory(VkDevice device,
|
||||||
import_fd_info->fd);
|
import_fd_info->fd);
|
||||||
} else {
|
} else {
|
||||||
result = vn_device_memory_alloc(dev, mem, pAllocateInfo);
|
result = vn_device_memory_alloc(dev, mem, pAllocateInfo);
|
||||||
|
|
||||||
|
/* track prime blit dst buffer memory */
|
||||||
|
if (wsi_info && result == VK_SUCCESS) {
|
||||||
|
assert(dedicated_info);
|
||||||
|
if (dedicated_info->buffer != VK_NULL_HANDLE) {
|
||||||
|
struct vn_buffer *buf =
|
||||||
|
vn_buffer_from_handle(dedicated_info->buffer);
|
||||||
|
buf->wsi.mem = mem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vn_device_memory_emit_report(dev, mem, /* is_alloc */ true, result);
|
vn_device_memory_emit_report(dev, mem, /* is_alloc */ true, result);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ struct vn_image {
|
||||||
|
|
||||||
struct vn_device_memory *memory;
|
struct vn_device_memory *memory;
|
||||||
|
|
||||||
|
/* memory backing the prime blit dst buffer */
|
||||||
|
struct vn_device_memory *blit_mem;
|
||||||
|
|
||||||
/* For VK_ANDROID_native_buffer, the WSI image owns the memory. */
|
/* For VK_ANDROID_native_buffer, the WSI image owns the memory. */
|
||||||
bool memory_owned;
|
bool memory_owned;
|
||||||
} wsi;
|
} wsi;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue