-static VkResult
-radv_wsi_image_create(VkDevice device_h,
- const VkSwapchainCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks* pAllocator,
- bool needs_linear_copy,
- bool linear,
- VkImage *image_p,
- VkDeviceMemory *memory_p,
- uint32_t *size,
- uint32_t *offset,
- uint32_t *row_pitch, int *fd_p)
-{
- VkResult result = VK_SUCCESS;
- struct radeon_surf *surface;
- VkImage image_h;
- struct radv_image *image;
- int fd;
-
- result = radv_image_create(device_h,
- &(struct radv_image_create_info) {
- .vk_info =
- &(VkImageCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
- .imageType = VK_IMAGE_TYPE_2D,
- .format = pCreateInfo->imageFormat,
- .extent = {
- .width = pCreateInfo->imageExtent.width,
- .height = pCreateInfo->imageExtent.height,
- .depth = 1
- },
- .mipLevels = 1,
- .arrayLayers = 1,
- .samples = 1,
- /* FIXME: Need a way to use X tiling to allow scanout */
- .tiling = linear ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL,
- .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
- .flags = 0,
- },
- .scanout = true},
- NULL,
- &image_h);
- if (result != VK_SUCCESS)
- return result;
-
- image = radv_image_from_handle(image_h);
-
- VkDeviceMemory memory_h;
-
- const VkDedicatedAllocationMemoryAllocateInfoNV ded_alloc = {
- .sType = VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV,
- .pNext = NULL,
- .buffer = VK_NULL_HANDLE,
- .image = image_h
- };
-
- result = radv_AllocateMemory(device_h,
- &(VkMemoryAllocateInfo) {
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- .pNext = &ded_alloc,
- .allocationSize = image->size,
- .memoryTypeIndex = linear ? 1 : 0,
- },
- NULL /* XXX: pAllocator */,
- &memory_h);
- if (result != VK_SUCCESS)
- goto fail_create_image;
-
- radv_BindImageMemory(device_h, image_h, memory_h, 0);
-
- /*
- * return the fd for the image in the no copy mode,
- * or the fd for the linear image if a copy is required.
- */
- if (!needs_linear_copy || (needs_linear_copy && linear)) {
- RADV_FROM_HANDLE(radv_device, device, device_h);
- RADV_FROM_HANDLE(radv_device_memory, memory, memory_h);
- if (!radv_get_memory_fd(device, memory, &fd))
- goto fail_alloc_memory;
- *fd_p = fd;
- }
-
- surface = &image->surface;
-
- *image_p = image_h;
- *memory_p = memory_h;
- *size = image->size;
- *offset = image->offset;
- *row_pitch = surface->level[0].pitch_bytes;
- return VK_SUCCESS;
- fail_alloc_memory:
- radv_FreeMemory(device_h, memory_h, pAllocator);
-
-fail_create_image:
- radv_DestroyImage(device_h, image_h, pAllocator);
-
- return result;
-}
-
-static void
-radv_wsi_image_free(VkDevice device,
- const VkAllocationCallbacks* pAllocator,
- VkImage image_h,
- VkDeviceMemory memory_h)
-{
- radv_DestroyImage(device, image_h, pAllocator);
-
- radv_FreeMemory(device, memory_h, pAllocator);
-}
-
-static const struct wsi_image_fns radv_wsi_image_fns = {
- .create_wsi_image = radv_wsi_image_create,
- .free_wsi_image = radv_wsi_image_free,
-};
-
-#define NUM_PRIME_POOLS RADV_QUEUE_TRANSFER
-static void
-radv_wsi_free_prime_command_buffers(struct radv_device *device,
- struct wsi_swapchain *swapchain)