From: Samuel Pitoiset Date: Mon, 20 Mar 2023 17:49:25 +0000 (+0100) Subject: radv: implement VK_KHR_map_memory2 X-Git-Tag: upstream/23.3.3~11290 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb5701eed99751d99db138497465879bf6dd8b37;p=platform%2Fupstream%2Fmesa.git radv: implement VK_KHR_map_memory2 Signed-off-by: Samuel Pitoiset Part-of: --- diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 60cd053..e1e76e7 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -1,4 +1,4 @@ VK_EXT_pipeline_library_group_handles on RADV VK_EXT_image_sliced_view_of_3d on RADV/GFX10+ -VK_KHR_map_memory2 on ANV +VK_KHR_map_memory2 on ANV and RADV fullyCoveredFragmentShaderInputVariable on RADV/GFX9+ diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index 01ac5b4..855dac6 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -480,7 +480,7 @@ radv_device_init_null_accel_struct(struct radv_device *device) return result; void *data; - result = radv_MapMemory(_device, memory, 0, size, 0, &data); + result = vk_common_MapMemory(_device, memory, 0, size, 0, &data); if (result != VK_SUCCESS) return result; @@ -512,7 +512,7 @@ radv_device_init_null_accel_struct(struct radv_device *device) memcpy((uint8_t *)data + bvh_offset, &root, sizeof(struct radv_bvh_box32_node)); - radv_UnmapMemory(_device, memory); + vk_common_UnmapMemory(_device, memory); VkAccelerationStructureCreateInfoKHR create_info = { .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR, diff --git a/src/amd/vulkan/radv_device_memory.c b/src/amd/vulkan/radv_device_memory.c index d97897d..ebb0374 100644 --- a/src/amd/vulkan/radv_device_memory.c +++ b/src/amd/vulkan/radv_device_memory.c @@ -302,11 +302,10 @@ radv_FreeMemory(VkDevice _device, VkDeviceMemory _mem, const VkAllocationCallbac } VKAPI_ATTR VkResult VKAPI_CALL -radv_MapMemory(VkDevice _device, VkDeviceMemory _memory, VkDeviceSize offset, VkDeviceSize size, - VkMemoryMapFlags flags, void **ppData) +radv_MapMemory2KHR(VkDevice _device, const VkMemoryMapInfoKHR *pMemoryMapInfo, void **ppData) { RADV_FROM_HANDLE(radv_device, device, _device); - RADV_FROM_HANDLE(radv_device_memory, mem, _memory); + RADV_FROM_HANDLE(radv_device_memory, mem, pMemoryMapInfo->memory); if (mem->user_ptr) *ppData = mem->user_ptr; @@ -315,22 +314,24 @@ radv_MapMemory(VkDevice _device, VkDeviceMemory _memory, VkDeviceSize offset, Vk if (*ppData) { vk_rmv_log_cpu_map(&device->vk, mem->bo->va, false); - *ppData = (uint8_t *)*ppData + offset; + *ppData = (uint8_t *)*ppData + pMemoryMapInfo->offset; return VK_SUCCESS; } return vk_error(device, VK_ERROR_MEMORY_MAP_FAILED); } -VKAPI_ATTR void VKAPI_CALL -radv_UnmapMemory(VkDevice _device, VkDeviceMemory _memory) +VKAPI_ATTR VkResult VKAPI_CALL +radv_UnmapMemory2KHR(VkDevice _device, const VkMemoryUnmapInfoKHR *pMemoryUnmapInfo) { RADV_FROM_HANDLE(radv_device, device, _device); - RADV_FROM_HANDLE(radv_device_memory, mem, _memory); + RADV_FROM_HANDLE(radv_device_memory, mem, pMemoryUnmapInfo->memory); vk_rmv_log_cpu_map(&device->vk, mem->bo->va, true); if (mem->user_ptr == NULL) device->ws->buffer_unmap(mem->bo); + + return VK_SUCCESS; } VKAPI_ATTR VkResult VKAPI_CALL diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index 9871a2b..4631eb1 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -445,6 +445,7 @@ radv_physical_device_get_supported_extensions(const struct radv_physical_device .KHR_maintenance2 = true, .KHR_maintenance3 = true, .KHR_maintenance4 = true, + .KHR_map_memory2 = true, .KHR_multiview = true, .KHR_performance_query = radv_perf_query_supported(device), .KHR_pipeline_executable_properties = true, diff --git a/src/amd/vulkan/radv_rra.c b/src/amd/vulkan/radv_rra.c index 8249178..fc31431 100644 --- a/src/amd/vulkan/radv_rra.c +++ b/src/amd/vulkan/radv_rra.c @@ -1019,7 +1019,7 @@ rra_copy_context_init(struct rra_copy_context *ctx) goto fail_buffer; result = - radv_MapMemory(ctx->device, ctx->memory, 0, VK_WHOLE_SIZE, 0, (void **)&ctx->mapped_data); + vk_common_MapMemory(ctx->device, ctx->memory, 0, VK_WHOLE_SIZE, 0, (void **)&ctx->mapped_data); if (result != VK_SUCCESS) goto fail_memory; @@ -1046,7 +1046,7 @@ rra_copy_context_finish(struct rra_copy_context *ctx) vk_common_DestroyCommandPool(ctx->device, ctx->pool, NULL); radv_DestroyBuffer(ctx->device, ctx->buffer, NULL); - radv_UnmapMemory(ctx->device, ctx->memory); + vk_common_UnmapMemory(ctx->device, ctx->memory); radv_FreeMemory(ctx->device, ctx->memory, NULL); } @@ -1059,7 +1059,7 @@ rra_map_accel_struct_data(struct rra_copy_context *ctx, uint32_t i) if (data->memory) { void *mapped_data; - radv_MapMemory(ctx->device, data->memory, 0, VK_WHOLE_SIZE, 0, &mapped_data); + vk_common_MapMemory(ctx->device, data->memory, 0, VK_WHOLE_SIZE, 0, &mapped_data); return mapped_data; } @@ -1116,7 +1116,7 @@ rra_unmap_accel_struct_data(struct rra_copy_context *ctx, uint32_t i) struct radv_rra_accel_struct_data *data = ctx->entries[i]->data; if (data->memory) - radv_UnmapMemory(ctx->device, data->memory); + vk_common_UnmapMemory(ctx->device, data->memory); } VkResult