venus: support VK_KHR_map_memory2

This is purely on the driver side.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33594>
This commit is contained in:
Yiwei Zhang 2025-02-17 00:15:15 -08:00 committed by Marge Bot
parent f69a0201da
commit 696ee859ef
5 changed files with 28 additions and 13 deletions

View file

@ -518,7 +518,7 @@ Vulkan 1.4 -- all DONE: anv, lvp, nvk, radv/gfx8+, tu/a7xx+
VK_KHR_load_store_op_none DONE (anv, lvp, nvk, radv, tu, v3dv, vn)
VK_KHR_maintenance5 DONE (anv, lvp, nvk, radv, tu, v3dv, vn)
VK_KHR_maintenance6 DONE (anv, lvp, nvk, radv, tu)
VK_KHR_map_memory2 DONE (anv, lvp, nvk, panvk, radv, tu)
VK_KHR_map_memory2 DONE (anv, lvp, nvk, panvk, radv, tu, vn)
VK_KHR_push_descriptor DONE (anv, hasvk, lvp, nvk, panvk, radv, tu, vn)
VK_KHR_shader_expect_assume DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn)
VK_KHR_shader_float_controls2 DONE (anv, lvp, nvk, radv, tu, vn)

View file

@ -355,6 +355,11 @@ vn_device_fix_create_info(const struct vn_device *dev,
VK_EXT_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXTENSION_NAME;
}
if (app_exts->KHR_map_memory2) {
/* see vn_physical_device_get_native_extensions */
block_exts[block_count++] = VK_KHR_MAP_MEMORY_2_EXTENSION_NAME;
}
if (app_exts->EXT_device_memory_report) {
/* see vn_physical_device_get_native_extensions */
block_exts[block_count++] = VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME;

View file

@ -434,16 +434,16 @@ vn_GetDeviceMemoryOpaqueCaptureAddress(
}
VkResult
vn_MapMemory(VkDevice device,
VkDeviceMemory memory,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
void **ppData)
vn_MapMemory2(VkDevice device,
const VkMemoryMapInfo *pMemoryMapInfo,
void **ppData)
{
VN_TRACE_FUNC();
struct vn_device *dev = vn_device_from_handle(device);
struct vn_device_memory *mem = vn_device_memory_from_handle(memory);
struct vn_device_memory *mem =
vn_device_memory_from_handle(pMemoryMapInfo->memory);
const VkDeviceSize offset = pMemoryMapInfo->offset;
const VkDeviceSize size = pMemoryMapInfo->size;
const struct vk_device_memory *mem_vk = &mem->base.base;
const bool need_bo = !mem->base_bo;
void *ptr = NULL;
@ -489,9 +489,10 @@ vn_MapMemory(VkDevice device,
return VK_SUCCESS;
}
void
vn_UnmapMemory(VkDevice device, VkDeviceMemory memory)
VkResult
vn_UnmapMemory2(VkDevice device, const VkMemoryUnmapInfo *pMemoryUnmapInfo)
{
return VK_SUCCESS;
}
VkResult

View file

@ -99,8 +99,12 @@ vn_feedback_buffer_create(struct vn_device *dev,
if (result != VK_SUCCESS)
goto out_free_memory;
result = vn_MapMemory(dev_handle, fb_buf->mem_handle, 0, VK_WHOLE_SIZE, 0,
&fb_buf->data);
const VkMemoryMapInfo map_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_MAP_INFO,
.memory = fb_buf->mem_handle,
.size = VK_WHOLE_SIZE,
};
result = vn_MapMemory2(dev_handle, &map_info, &fb_buf->data);
if (result != VK_SUCCESS)
goto out_free_memory;
@ -127,7 +131,11 @@ vn_feedback_buffer_destroy(struct vn_device *dev,
{
VkDevice dev_handle = vn_device_to_handle(dev);
vn_UnmapMemory(dev_handle, fb_buf->mem_handle);
const VkMemoryUnmapInfo unmap_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO,
.memory = fb_buf->mem_handle,
};
vn_UnmapMemory2(dev_handle, &unmap_info);
vn_FreeMemory(dev_handle, fb_buf->mem_handle, alloc);
vn_DestroyBuffer(dev_handle, fb_buf->buf_handle, alloc);
vk_free(alloc, fb_buf);

View file

@ -1011,6 +1011,7 @@ vn_physical_device_get_native_extensions(
physical_dev->renderer_extensions.EXT_pci_bus_info;
#endif
exts->KHR_map_memory2 = true;
exts->EXT_physical_device_drm = true;
/* use common implementation */
exts->EXT_tooling_info = true;