Path: blob/21.2-virgl/src/vulkan/wsi/wsi_common_private.h
7355 views
/*1* Copyright © 2017 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/22#ifndef WSI_COMMON_PRIVATE_H23#define WSI_COMMON_PRIVATE_H2425#include "wsi_common.h"26#include "vulkan/util/vk_object.h"2728struct wsi_image {29VkImage image;30VkDeviceMemory memory;3132struct {33VkBuffer buffer;34VkDeviceMemory memory;35VkCommandBuffer *blit_cmd_buffers;36} prime;3738uint64_t drm_modifier;39int num_planes;40uint32_t sizes[4];41uint32_t offsets[4];42uint32_t row_pitches[4];43int fds[4];44};4546struct wsi_swapchain {47struct vk_object_base base;4849const struct wsi_device *wsi;5051VkDevice device;52VkAllocationCallbacks alloc;53VkFence* fences;54VkPresentModeKHR present_mode;55uint32_t image_count;5657bool use_prime_blit;5859/* Command pools, one per queue family */60VkCommandPool *cmd_pools;6162VkResult (*destroy)(struct wsi_swapchain *swapchain,63const VkAllocationCallbacks *pAllocator);64struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,65uint32_t image_index);66VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,67const VkAcquireNextImageInfoKHR *info,68uint32_t *image_index);69VkResult (*queue_present)(struct wsi_swapchain *swap_chain,70uint32_t image_index,71const VkPresentRegionKHR *damage);72};7374bool75wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd);7677VkResult78wsi_swapchain_init(const struct wsi_device *wsi,79struct wsi_swapchain *chain,80VkDevice device,81const VkSwapchainCreateInfoKHR *pCreateInfo,82const VkAllocationCallbacks *pAllocator);8384enum VkPresentModeKHR85wsi_swapchain_get_present_mode(struct wsi_device *wsi,86const VkSwapchainCreateInfoKHR *pCreateInfo);8788void wsi_swapchain_finish(struct wsi_swapchain *chain);8990VkResult91wsi_create_native_image(const struct wsi_swapchain *chain,92const VkSwapchainCreateInfoKHR *pCreateInfo,93uint32_t num_modifier_lists,94const uint32_t *num_modifiers,95const uint64_t *const *modifiers,96struct wsi_image *image);9798VkResult99wsi_create_prime_image(const struct wsi_swapchain *chain,100const VkSwapchainCreateInfoKHR *pCreateInfo,101bool use_modifier,102struct wsi_image *image);103104void105wsi_destroy_image(const struct wsi_swapchain *chain,106struct wsi_image *image);107108109struct wsi_interface {110VkResult (*get_support)(VkIcdSurfaceBase *surface,111struct wsi_device *wsi_device,112uint32_t queueFamilyIndex,113VkBool32* pSupported);114VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,115struct wsi_device *wsi_device,116const void *info_next,117VkSurfaceCapabilities2KHR* pSurfaceCapabilities);118VkResult (*get_formats)(VkIcdSurfaceBase *surface,119struct wsi_device *wsi_device,120uint32_t* pSurfaceFormatCount,121VkSurfaceFormatKHR* pSurfaceFormats);122VkResult (*get_formats2)(VkIcdSurfaceBase *surface,123struct wsi_device *wsi_device,124const void *info_next,125uint32_t* pSurfaceFormatCount,126VkSurfaceFormat2KHR* pSurfaceFormats);127VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,128uint32_t* pPresentModeCount,129VkPresentModeKHR* pPresentModes);130VkResult (*get_present_rectangles)(VkIcdSurfaceBase *surface,131struct wsi_device *wsi_device,132uint32_t* pRectCount,133VkRect2D* pRects);134VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,135VkDevice device,136struct wsi_device *wsi_device,137const VkSwapchainCreateInfoKHR* pCreateInfo,138const VkAllocationCallbacks* pAllocator,139struct wsi_swapchain **swapchain);140};141142VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,143const VkAllocationCallbacks *alloc,144const struct driOptionCache *dri_options);145void wsi_x11_finish_wsi(struct wsi_device *wsi_device,146const VkAllocationCallbacks *alloc);147VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,148const VkAllocationCallbacks *alloc,149VkPhysicalDevice physical_device);150void wsi_wl_finish_wsi(struct wsi_device *wsi_device,151const VkAllocationCallbacks *alloc);152VkResult wsi_win32_init_wsi(struct wsi_device *wsi_device,153const VkAllocationCallbacks *alloc,154VkPhysicalDevice physical_device);155void wsi_win32_finish_wsi(struct wsi_device *wsi_device,156const VkAllocationCallbacks *alloc);157158159VkResult160wsi_display_init_wsi(struct wsi_device *wsi_device,161const VkAllocationCallbacks *alloc,162int display_fd);163164void165wsi_display_finish_wsi(struct wsi_device *wsi_device,166const VkAllocationCallbacks *alloc);167168VK_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, base, VkSwapchainKHR,169VK_OBJECT_TYPE_SWAPCHAIN_KHR)170171#endif /* WSI_COMMON_PRIVATE_H */172173174