venus: implement VK_EXT_map_memory_placed

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38706>
This commit is contained in:
Yiwei Zhang 2025-11-28 00:22:23 -08:00 committed by Marge Bot
parent 8adfdc3304
commit a6ade961b2
4 changed files with 27 additions and 2 deletions

View file

@ -716,7 +716,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_swapchain_colorspace DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn)
VK_EXT_depth_clamp_zero_one DONE (anv, nvk, panvk, pvr, radv, tu, v3dv/vc7+, vn)
VK_INTEL_shader_integer_functions2 DONE (anv, hasvk, radv)
VK_EXT_map_memory_placed DONE (anv, hk, nvk, pvr, radv, tu)
VK_EXT_map_memory_placed DONE (anv, hk, nvk, pvr, radv, tu, vn)
VK_MESA_image_alignment_control DONE (anv, nvk, radv)
VK_EXT_legacy_dithering DONE (anv, tu, vn)
VK_QCOM_fragment_density_map_offset DONE (tu)

View file

@ -328,6 +328,11 @@ vn_device_fix_create_info(const struct vn_device *dev,
block_exts[block_count++] = VK_KHR_MAP_MEMORY_2_EXTENSION_NAME;
}
if (app_exts->EXT_map_memory_placed) {
/* see vn_physical_device_get_native_extensions */
block_exts[block_count++] = VK_EXT_MAP_MEMORY_PLACED_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

@ -436,6 +436,7 @@ vn_MapMemory2(VkDevice device,
const VkDeviceSize size = pMemoryMapInfo->size;
const struct vk_device_memory *mem_vk = &mem->base.vk;
const bool need_bo = !mem->base_bo;
void *placed_addr = NULL;
void *ptr = NULL;
VkResult result;
@ -457,7 +458,14 @@ vn_MapMemory2(VkDevice device,
return vn_error(dev->instance, result);
}
ptr = vn_renderer_bo_map(dev->renderer, mem->base_bo, NULL);
if (pMemoryMapInfo->flags & VK_MEMORY_MAP_PLACED_BIT_EXT) {
const VkMemoryMapPlacedInfoEXT *placed_info = vk_find_struct_const(
pMemoryMapInfo->pNext, MEMORY_MAP_PLACED_INFO_EXT);
assert(placed_info != NULL);
placed_addr = placed_info->pPlacedAddress;
}
ptr = vn_renderer_bo_map(dev->renderer, mem->base_bo, placed_addr);
if (!ptr) {
/* vn_renderer_bo_map implies a roundtrip on success, but not here. */
if (need_bo) {

View file

@ -14,6 +14,7 @@
#include "git_sha1.h"
#include "util/mesa-sha1.h"
#include "util/os_misc.h"
#include "venus-protocol/vn_protocol_driver_device.h"
#include "vk_android.h"
#include "vk_common_entrypoints.h"
@ -411,6 +412,11 @@ vn_physical_device_init_features(struct vn_physical_device *physical_dev)
*/
feats->deviceMemoryReport = true;
/* VK_EXT_map_memory_placed */
feats->memoryMapPlaced = true;
feats->memoryMapRangePlaced = false;
feats->memoryUnmapReserve = true;
#ifdef VN_USE_WSI_PLATFORM
feats->presentId = true;
feats->presentId2 = true;
@ -838,6 +844,11 @@ vn_physical_device_init_properties(struct vn_physical_device *physical_dev)
/* initialize native properties */
/* VK_EXT_map_memory_placed */
uint64_t os_page_size = 4096;
os_get_page_size(&os_page_size);
props->minPlacedMemoryMapAlignment = os_page_size;
/* VK_EXT_physical_device_drm */
VN_SET_VK_PROPS(props, &renderer_info->drm.props);
@ -1180,6 +1191,7 @@ vn_physical_device_get_native_extensions(
exts->KHR_deferred_host_operations =
physical_dev->ray_tracing && renderer_exts->KHR_acceleration_structure;
exts->KHR_map_memory2 = true;
exts->EXT_map_memory_placed = true;
exts->EXT_physical_device_drm = true;
/* use common implementation */
exts->EXT_tooling_info = true;