mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-19 21:10:30 +01:00
venus: track prime blit dst buffer memory in the wsi image
This is to prepare for handling WSI implicit acquire fence. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39401>
This commit is contained in:
parent
c6a4b8e9c7
commit
eb709cba47
6 changed files with 61 additions and 0 deletions
|
|
@ -44,6 +44,11 @@ struct vn_buffer {
|
|||
struct vn_object_base base;
|
||||
|
||||
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,
|
||||
base.vk,
|
||||
|
|
|
|||
|
|
@ -1480,6 +1480,18 @@ vn_CmdCopyImageToBuffer(VkCommandBuffer commandBuffer,
|
|||
uint32_t regionCount,
|
||||
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_prime_blit_src);
|
||||
assert(!img->wsi.blit_mem);
|
||||
img->wsi.blit_mem = buf->wsi.mem;
|
||||
}
|
||||
|
||||
VN_CMD_ENQUEUE(vkCmdCopyImageToBuffer, commandBuffer, srcImage,
|
||||
srcImageLayout, dstBuffer, regionCount, pRegions);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,6 +378,8 @@ vn_AllocateMemory(VkDevice device,
|
|||
import_fd_info->fd);
|
||||
} else {
|
||||
result = vn_device_memory_alloc(dev, mem, pAllocateInfo);
|
||||
if (result == VK_SUCCESS)
|
||||
vn_wsi_memory_info_init(mem, pAllocateInfo);
|
||||
}
|
||||
|
||||
vn_device_memory_emit_report(dev, mem, /* is_alloc */ true, result);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ struct vn_image {
|
|||
|
||||
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. */
|
||||
bool memory_owned;
|
||||
} wsi;
|
||||
|
|
|
|||
|
|
@ -216,6 +216,35 @@ vn_wsi_create_image(struct vn_device *dev,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
vn_wsi_memory_info_init(struct vn_device_memory *mem,
|
||||
const VkMemoryAllocateInfo *alloc_info)
|
||||
{
|
||||
const VkMemoryDedicatedAllocateInfo *dedicated_info = NULL;
|
||||
const struct wsi_memory_allocate_info *wsi_info = NULL;
|
||||
|
||||
vk_foreach_struct_const(pnext, alloc_info->pNext) {
|
||||
switch ((uint32_t)pnext->sType) {
|
||||
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
|
||||
dedicated_info = (const void *)pnext;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA:
|
||||
wsi_info = (const void *)pnext;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* wsi always uses dedicated allocation */
|
||||
assert(dedicated_info || !wsi_info);
|
||||
|
||||
if (wsi_info && dedicated_info->buffer != VK_NULL_HANDLE) {
|
||||
struct vn_buffer *buf = vn_buffer_from_handle(dedicated_info->buffer);
|
||||
buf->wsi.mem = mem;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
vn_modifier_plane_count(struct vn_physical_device *physical_dev,
|
||||
VkFormat format,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ vn_wsi_create_image(struct vn_device *dev,
|
|||
const VkAllocationCallbacks *alloc,
|
||||
struct vn_image **out_img);
|
||||
|
||||
void
|
||||
vn_wsi_memory_info_init(struct vn_device_memory *mem,
|
||||
const VkMemoryAllocateInfo *alloc_info);
|
||||
|
||||
bool
|
||||
vn_wsi_validate_image_format_info(
|
||||
struct vn_physical_device *physical_dev,
|
||||
|
|
@ -67,6 +71,12 @@ vn_wsi_create_image(struct vn_device *dev,
|
|||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
static inline void
|
||||
vn_wsi_memory_info_init(struct vn_device_memory *mem,
|
||||
const VkMemoryAllocateInfo *alloc_info)
|
||||
{
|
||||
}
|
||||
|
||||
static inline bool
|
||||
vn_wsi_validate_image_format_info(struct vn_physical_device *physical_dev,
|
||||
const VkPhysicalDeviceImageFormatInfo2 *info)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue