vkr: refactor vkr_device_memory to track vkr_device instead

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Yiwei Zhang 3 years ago
parent 0b2e4b2cd8
commit 7fc9dbf3bb
  1. 11
      src/venus/vkr_context.c
  2. 2
      src/venus/vkr_device_memory.c
  3. 2
      src/venus/vkr_device_memory.h

@ -323,7 +323,7 @@ vkr_context_get_blob_locked(struct virgl_context *base,
}
VkResult result = ctx->instance->get_memory_fd(
mem->device,
mem->device->base.handle.device,
&(VkMemoryGetFdInfoKHR){
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
.memory = mem->base.handle.device_memory,
@ -439,20 +439,21 @@ vkr_context_transfer_3d_locked(struct virgl_context *base,
};
void *ptr;
VkDevice dev_handle = mem->device->base.handle.device;
VkResult result =
vkMapMemory(mem->device, range.memory, range.offset, range.size, 0, &ptr);
vkMapMemory(dev_handle, range.memory, range.offset, range.size, 0, &ptr);
if (result != VK_SUCCESS)
return -EINVAL;
if (transfer_mode == VIRGL_TRANSFER_TO_HOST) {
vrend_read_from_iovec(iov, iov_count, range.offset, ptr, range.size);
vkFlushMappedMemoryRanges(mem->device, 1, &range);
vkFlushMappedMemoryRanges(dev_handle, 1, &range);
} else {
vkInvalidateMappedMemoryRanges(mem->device, 1, &range);
vkInvalidateMappedMemoryRanges(dev_handle, 1, &range);
vrend_write_to_iovec(iov, iov_count, range.offset, ptr, range.size);
}
vkUnmapMemory(mem->device, range.memory);
vkUnmapMemory(dev_handle, range.memory);
return 0;
}

@ -137,7 +137,7 @@ vkr_dispatch_vkAllocateMemory(struct vn_dispatch_context *dispatch,
return;
}
mem->device = args->device;
mem->device = dev;
mem->property_flags = property_flags;
mem->valid_fd_types = valid_fd_types;
list_inithead(&mem->exported_head);

@ -11,7 +11,7 @@
struct vkr_device_memory {
struct vkr_object base;
VkDevice device;
struct vkr_device *device;
uint32_t property_flags;
uint32_t valid_fd_types;

Loading…
Cancel
Save