diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 0c4c81c36a1..2220e2e1478 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -1425,6 +1425,11 @@ radv_GetImageMemoryRequirements2(VkDevice _device, const VkImageMemoryRequiremen pMemoryRequirements->memoryRequirements.memoryTypeBits = ((1u << pdev->memory_properties.memoryTypeCount) - 1u) & ~pdev->memory_types_32bit; + if (image->vk.usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT) { + /* Only expose host visible memory types for images that need to be mapped on the CPU. */ + pMemoryRequirements->memoryRequirements.memoryTypeBits &= pdev->memory_types_host_visible; + } + pMemoryRequirements->memoryRequirements.size = size; pMemoryRequirements->memoryRequirements.alignment = alignment; diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index 3ff1dc4d409..0d2294e1573 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -490,6 +490,8 @@ radv_physical_device_init_mem_types(struct radv_physical_device *pdev) for (unsigned i = 0; i < type_count; ++i) { if (pdev->memory_flags[i] & RADEON_FLAG_32BIT) pdev->memory_types_32bit |= BITFIELD_BIT(i); + if (pdev->memory_flags[i] & RADEON_FLAG_CPU_ACCESS) + pdev->memory_types_host_visible |= BITFIELD_BIT(i); } } diff --git a/src/amd/vulkan/radv_physical_device.h b/src/amd/vulkan/radv_physical_device.h index c9dd68e86ab..32f589bccdb 100644 --- a/src/amd/vulkan/radv_physical_device.h +++ b/src/amd/vulkan/radv_physical_device.h @@ -145,6 +145,9 @@ struct radv_physical_device { /* Bitmask of memory types that use the 32-bit address space. */ uint32_t memory_types_32bit; + /* Bitmask of memory types that are host-visible. */ + uint32_t memory_types_host_visible; + #ifndef _WIN32 int available_nodes; drmPciBusInfo bus_info;