int dup_fd = -1;
uint64_t alloc_size = 0;
uint32_t mem_type_bits = 0;
+ bool force_unmappable = false;
VkResult result = VK_SUCCESS;
handle = AHardwareBuffer_getNativeHandle(ahb);
}
alloc_size = mem_req.size;
+
+ /* XXX Workaround before we use cross-domain backend in minigbm. The
+ * blob_mem allocated from virgl backend can have a queried guest mappable
+ * size smaller than the size returned from image memory requirement.
+ */
+ force_unmappable = true;
}
if (dedicated_info && dedicated_info->buffer != VK_NULL_HANDLE) {
.allocationSize = alloc_size,
.memoryTypeIndex = alloc_info->memoryTypeIndex,
};
- result =
- vn_device_memory_import_dma_buf(dev, mem, &local_alloc_info, dup_fd);
+ result = vn_device_memory_import_dma_buf(dev, mem, &local_alloc_info,
+ force_unmappable, dup_fd);
if (result != VK_SUCCESS) {
close(dup_fd);
return result;
vn_device_memory_import_dma_buf(struct vn_device *dev,
struct vn_device_memory *mem,
const VkMemoryAllocateInfo *alloc_info,
+ bool force_unmappable,
int fd)
{
VkDevice device = vn_device_to_handle(dev);
VkDeviceMemory memory = vn_device_memory_to_handle(mem);
const VkPhysicalDeviceMemoryProperties *mem_props =
&dev->physical_device->memory_properties.memoryProperties;
- const VkMemoryType *mem_type =
- &mem_props->memoryTypes[alloc_info->memoryTypeIndex];
+ VkMemoryPropertyFlags mem_flags =
+ mem_props->memoryTypes[alloc_info->memoryTypeIndex].propertyFlags;
struct vn_renderer_bo *bo;
VkResult result = VK_SUCCESS;
- result = vn_renderer_bo_create_from_dma_buf(dev->renderer,
- alloc_info->allocationSize, fd,
- mem_type->propertyFlags, &bo);
+ if (force_unmappable)
+ mem_flags &= ~VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
+
+ result = vn_renderer_bo_create_from_dma_buf(
+ dev->renderer, alloc_info->allocationSize, fd, mem_flags, &bo);
if (result != VK_SUCCESS)
return result;
} else if (export_ahb) {
result = vn_android_device_allocate_ahb(dev, mem, pAllocateInfo, alloc);
} else if (import_fd_info) {
- result = vn_device_memory_import_dma_buf(dev, mem, pAllocateInfo,
+ result = vn_device_memory_import_dma_buf(dev, mem, pAllocateInfo, false,
import_fd_info->fd);
} else if (export_info) {
result = vn_device_memory_alloc(dev, mem, pAllocateInfo, true,