VkResult radv_GetSwapchainImagesKHR(
VkDevice device,
- VkSwapchainKHR _swapchain,
+ VkSwapchainKHR swapchain,
uint32_t* pSwapchainImageCount,
VkImage* pSwapchainImages)
{
- RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
-
- return swapchain->get_images(swapchain, pSwapchainImageCount,
+ return wsi_common_get_images(swapchain,
+ pSwapchainImageCount,
pSwapchainImages);
}
VkResult anv_GetSwapchainImagesKHR(
VkDevice device,
- VkSwapchainKHR _swapchain,
+ VkSwapchainKHR swapchain,
uint32_t* pSwapchainImageCount,
VkImage* pSwapchainImages)
{
- ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
-
- return swapchain->get_images(swapchain, pSwapchainImageCount,
+ return wsi_common_get_images(swapchain,
+ pSwapchainImageCount,
pSwapchainImages);
}
return chain->wsi->QueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE);
}
+VkResult
+wsi_common_get_images(VkSwapchainKHR _swapchain,
+ uint32_t *pSwapchainImageCount,
+ VkImage *pSwapchainImages)
+{
+ WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+ VK_OUTARRAY_MAKE(images, pSwapchainImages, pSwapchainImageCount);
+
+ for (uint32_t i = 0; i < swapchain->image_count; i++) {
+ vk_outarray_append(&images, image) {
+ *image = swapchain->get_wsi_image(swapchain, i)->image;
+ }
+ }
+
+ return vk_outarray_status(&images);
+}
+
VkResult
wsi_common_queue_present(const struct wsi_device *wsi,
VkDevice device,
VkResult (*destroy)(struct wsi_swapchain *swapchain,
const VkAllocationCallbacks *pAllocator);
- VkResult (*get_images)(struct wsi_swapchain *swapchain,
- uint32_t *pCount, VkImage *pSwapchainImages);
+ struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,
+ uint32_t image_index);
VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
uint64_t timeout, VkSemaphore semaphore,
uint32_t *image_index);
void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
+VkResult
+wsi_common_get_images(VkSwapchainKHR _swapchain,
+ uint32_t *pSwapchainImageCount,
+ VkImage *pSwapchainImages);
+
VkResult
wsi_common_queue_present(const struct wsi_device *wsi,
VkDevice device_h,
struct wsi_wl_image images[0];
};
-static VkResult
-wsi_wl_swapchain_get_images(struct wsi_swapchain *wsi_chain,
- uint32_t *pCount, VkImage *pSwapchainImages)
+static struct wsi_image *
+wsi_wl_swapchain_get_wsi_image(struct wsi_swapchain *wsi_chain,
+ uint32_t image_index)
{
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
- uint32_t ret_count;
- VkResult result;
-
- if (pSwapchainImages == NULL) {
- *pCount = chain->base.image_count;
- return VK_SUCCESS;
- }
-
- result = VK_SUCCESS;
- ret_count = chain->base.image_count;
- if (chain->base.image_count > *pCount) {
- ret_count = *pCount;
- result = VK_INCOMPLETE;
- }
-
- for (uint32_t i = 0; i < ret_count; i++)
- pSwapchainImages[i] = chain->images[i].base.image;
-
- return result;
+ return &chain->images[image_index].base;
}
static VkResult
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
chain->base.destroy = wsi_wl_swapchain_destroy;
- chain->base.get_images = wsi_wl_swapchain_get_images;
+ chain->base.get_wsi_image = wsi_wl_swapchain_get_wsi_image;
chain->base.acquire_next_image = wsi_wl_swapchain_acquire_next_image;
chain->base.queue_present = wsi_wl_swapchain_queue_present;
chain->base.present_mode = pCreateInfo->presentMode;
struct x11_image images[0];
};
-static VkResult
-x11_get_images(struct wsi_swapchain *anv_chain,
- uint32_t* pCount, VkImage *pSwapchainImages)
+static struct wsi_image *
+x11_get_wsi_image(struct wsi_swapchain *wsi_chain, uint32_t image_index)
{
- struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
- uint32_t ret_count;
- VkResult result;
-
- if (pSwapchainImages == NULL) {
- *pCount = chain->base.image_count;
- return VK_SUCCESS;
- }
-
- result = VK_SUCCESS;
- ret_count = chain->base.image_count;
- if (chain->base.image_count > *pCount) {
- ret_count = *pCount;
- result = VK_INCOMPLETE;
- }
-
- for (uint32_t i = 0; i < ret_count; i++)
- pSwapchainImages[i] = chain->images[i].base.image;
-
- return result;
+ struct x11_swapchain *chain = (struct x11_swapchain *)wsi_chain;
+ return &chain->images[image_index].base;
}
static VkResult
goto fail_alloc;
chain->base.destroy = x11_swapchain_destroy;
- chain->base.get_images = x11_get_images;
+ chain->base.get_wsi_image = x11_get_wsi_image;
chain->base.acquire_next_image = x11_acquire_next_image;
chain->base.queue_present = x11_queue_present;
chain->base.present_mode = pCreateInfo->presentMode;