the WSI code should be now be clean for sharing.
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
uint32_t eu_total;
uint32_t subslice_total;
- struct anv_wsi_device wsi_device;
+ struct wsi_device wsi_device;
};
struct anv_instance {
#include "wsi_common.h"
#include "vk_format_info.h"
-static const struct anv_wsi_callbacks anv_wsi_cbs = {
+static const struct wsi_callbacks wsi_cbs = {
.get_phys_device_format_properties = anv_GetPhysicalDeviceFormatProperties,
};
memset(physical_device->wsi_device.wsi, 0, sizeof(physical_device->wsi_device.wsi));
#ifdef VK_USE_PLATFORM_XCB_KHR
- result = anv_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
+ result = wsi_x11_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
if (result != VK_SUCCESS)
return result;
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- result = anv_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
+ result = wsi_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
anv_physical_device_to_handle(physical_device),
- &anv_wsi_cbs);
+ &wsi_cbs);
if (result != VK_SUCCESS) {
#ifdef VK_USE_PLATFORM_XCB_KHR
- anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
+ wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
#endif
return result;
}
anv_finish_wsi(struct anv_physical_device *physical_device)
{
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
- anv_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
+ wsi_wl_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
- anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
+ wsi_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
#endif
}
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
+ struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_support(surface, &device->wsi_device,
&device->instance->alloc,
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
+ struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_capabilities(surface, pSurfaceCapabilities);
}
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
+ struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_formats(surface, &device->wsi_device, pSurfaceFormatCount,
pSurfaceFormats);
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
- struct anv_wsi_interface *iface = device->wsi_device.wsi[surface->platform];
+ struct wsi_interface *iface = device->wsi_device.wsi[surface->platform];
return iface->get_present_modes(surface, pPresentModeCount,
pPresentModes);
anv_FreeMemory(device, memory_h, pAllocator);
}
-static const struct anv_wsi_image_fns anv_wsi_image_fns = {
+static const struct wsi_image_fns anv_wsi_image_fns = {
.create_wsi_image = x11_anv_wsi_image_create,
.free_wsi_image = x11_anv_wsi_image_free,
};
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, pCreateInfo->surface);
- struct anv_wsi_interface *iface =
+ struct wsi_interface *iface =
device->instance->physicalDevice.wsi_device.wsi[surface->platform];
- struct anv_swapchain *swapchain;
+ struct wsi_swapchain *swapchain;
const VkAllocationCallbacks *alloc;
if (pAllocator)
for (unsigned i = 0; i < ARRAY_SIZE(swapchain->fences); i++)
swapchain->fences[i] = VK_NULL_HANDLE;
- *pSwapchain = anv_swapchain_to_handle(swapchain);
+ *pSwapchain = wsi_swapchain_to_handle(swapchain);
return VK_SUCCESS;
}
const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
+ ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
const VkAllocationCallbacks *alloc;
if (pAllocator)
uint32_t* pSwapchainImageCount,
VkImage* pSwapchainImages)
{
- ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
+ ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
return swapchain->get_images(swapchain, pSwapchainImageCount,
pSwapchainImages);
VkFence fence,
uint32_t* pImageIndex)
{
- ANV_FROM_HANDLE(anv_swapchain, swapchain, _swapchain);
+ ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
return swapchain->acquire_next_image(swapchain, timeout, semaphore,
pImageIndex);
VkResult result;
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
- ANV_FROM_HANDLE(anv_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
+ ANV_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
assert(anv_device_from_handle(swapchain->device) == queue->device);
#include "vk_format_info.h"
#include <util/hash_table.h>
-#include "anv_private.h"
#include "wsi_common_wayland.h"
+#include "anv_private.h"
VkBool32 anv_GetPhysicalDeviceWaylandPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
else
alloc = &instance->alloc;
- return anv_create_wl_surface(alloc, pCreateInfo, pSurface);
+ return wsi_create_wl_surface(alloc, pCreateInfo, pSurface);
}
#include <xcb/dri3.h>
#include <xcb/present.h>
-#include "anv_private.h"
#include "wsi_common_x11.h"
-
-#include "vk_format_info.h"
-#include "util/hash_table.h"
+#include "anv_private.h"
VkBool32 anv_GetPhysicalDeviceXcbPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- return anv_get_physical_device_xcb_presentation_support(
+ return wsi_get_physical_device_xcb_presentation_support(
&device->wsi_device,
&device->instance->alloc,
queueFamilyIndex, connection, visual_id);
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
- return anv_get_physical_device_xcb_presentation_support(
+ return wsi_get_physical_device_xcb_presentation_support(
&device->wsi_device,
&device->instance->alloc,
queueFamilyIndex, XGetXCBConnection(dpy), visualID);
else
alloc = &instance->alloc;
- return anv_create_xcb_surface(alloc, pCreateInfo, pSurface);
+ return wsi_create_xcb_surface(alloc, pCreateInfo, pSurface);
}
VkResult anv_CreateXlibSurfaceKHR(
else
alloc = &instance->alloc;
- return anv_create_xlib_surface(alloc, pCreateInfo, pSurface);
+ return wsi_create_xlib_surface(alloc, pCreateInfo, pSurface);
}
#include <vulkan/vulkan.h>
#include <vulkan/vk_icd.h>
-struct anv_wsi_device;
-struct anv_wsi_image_fns {
+struct wsi_device;
+struct wsi_image_fns {
VkResult (*create_wsi_image)(VkDevice device_h,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDeviceMemory memory_h);
};
-struct anv_swapchain {
+struct wsi_swapchain {
VkDevice device;
VkAllocationCallbacks alloc;
- const struct anv_wsi_image_fns *image_fns;
+ const struct wsi_image_fns *image_fns;
VkFence fences[3];
- VkResult (*destroy)(struct anv_swapchain *swapchain,
+ VkResult (*destroy)(struct wsi_swapchain *swapchain,
const VkAllocationCallbacks *pAllocator);
- VkResult (*get_images)(struct anv_swapchain *swapchain,
+ VkResult (*get_images)(struct wsi_swapchain *swapchain,
uint32_t *pCount, VkImage *pSwapchainImages);
- VkResult (*acquire_next_image)(struct anv_swapchain *swap_chain,
+ VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
uint64_t timeout, VkSemaphore semaphore,
uint32_t *image_index);
- VkResult (*queue_present)(struct anv_swapchain *swap_chain,
+ VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
uint32_t image_index);
};
-struct anv_wsi_interface {
+struct wsi_interface {
VkResult (*get_support)(VkIcdSurfaceBase *surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
VkBool32* pSupported);
VkResult (*get_capabilities)(VkIcdSurfaceBase *surface,
VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
VkResult (*get_formats)(VkIcdSurfaceBase *surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats);
VkResult (*get_present_modes)(VkIcdSurfaceBase *surface,
VkPresentModeKHR* pPresentModes);
VkResult (*create_swapchain)(VkIcdSurfaceBase *surface,
VkDevice device,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
- const struct anv_wsi_image_fns *image_fns,
- struct anv_swapchain **swapchain);
+ const struct wsi_image_fns *image_fns,
+ struct wsi_swapchain **swapchain);
};
#define VK_ICD_WSI_PLATFORM_MAX 5
-struct anv_wsi_device {
- struct anv_wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
+struct wsi_device {
+ struct wsi_interface * wsi[VK_ICD_WSI_PLATFORM_MAX];
};
-struct anv_wsi_callbacks {
+struct wsi_callbacks {
void (*get_phys_device_format_properties)(VkPhysicalDevice physicalDevice,
VkFormat format,
VkFormatProperties *pFormatProperties);
}
WSI_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
-WSI_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
-VkResult anv_x11_init_wsi(struct anv_wsi_device *wsi_device,
+WSI_DEFINE_NONDISP_HANDLE_CASTS(wsi_swapchain, VkSwapchainKHR)
+
+VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
-void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
+void wsi_x11_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
-VkResult anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
+VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
VkPhysicalDevice physical_device,
- const struct anv_wsi_callbacks *cbs);
-void anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
+ const struct wsi_callbacks *cbs);
+void wsi_wl_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
+
#endif
};
struct wsi_wayland {
- struct anv_wsi_interface base;
+ struct wsi_interface base;
const VkAllocationCallbacks *alloc;
VkPhysicalDevice physical_device;
/* Hash table of wl_display -> wsi_wl_display mappings */
struct hash_table * displays;
- const struct anv_wsi_callbacks *cbs;
+ const struct wsi_callbacks *cbs;
};
static void
}
static struct wsi_wl_display *
-wsi_wl_get_display(struct anv_wsi_device *wsi_device,
+wsi_wl_get_display(struct wsi_device *wsi_device,
struct wl_display *wl_display)
{
struct wsi_wayland *wsi =
}
VkBool32
-wsi_wl_get_presentation_support(struct anv_wsi_device *wsi_device,
+wsi_wl_get_presentation_support(struct wsi_device *wsi_device,
struct wl_display *wl_display)
{
return wsi_wl_get_display(wsi_device, wl_display) != NULL;
static VkResult
wsi_wl_surface_get_support(VkIcdSurfaceBase *surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
VkBool32* pSupported)
static VkResult
wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
uint32_t* pSurfaceFormatCount,
VkSurfaceFormatKHR* pSurfaceFormats)
{
return VK_SUCCESS;
}
-VkResult anv_create_wl_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_wl_surface(const VkAllocationCallbacks *pAllocator,
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface)
{
};
struct wsi_wl_swapchain {
- struct anv_swapchain base;
+ struct wsi_swapchain base;
struct wsi_wl_display * display;
struct wl_event_queue * queue;
};
static VkResult
-wsi_wl_swapchain_get_images(struct anv_swapchain *anv_chain,
+wsi_wl_swapchain_get_images(struct wsi_swapchain *wsi_chain,
uint32_t *pCount, VkImage *pSwapchainImages)
{
- struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
+ struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
if (pSwapchainImages == NULL) {
*pCount = chain->image_count;
}
static VkResult
-wsi_wl_swapchain_acquire_next_image(struct anv_swapchain *anv_chain,
+wsi_wl_swapchain_acquire_next_image(struct wsi_swapchain *wsi_chain,
uint64_t timeout,
VkSemaphore semaphore,
uint32_t *image_index)
{
- struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
+ struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
int ret = wl_display_dispatch_queue_pending(chain->display->display,
chain->queue);
};
static VkResult
-wsi_wl_swapchain_queue_present(struct anv_swapchain *anv_chain,
+wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain,
uint32_t image_index)
{
- struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
+ struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
if (chain->present_mode == VK_PRESENT_MODE_FIFO_KHR) {
while (!chain->fifo_ready) {
}
static VkResult
-wsi_wl_swapchain_destroy(struct anv_swapchain *anv_chain,
+wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
const VkAllocationCallbacks *pAllocator)
{
- struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)anv_chain;
+ struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
for (uint32_t i = 0; i < chain->image_count; i++) {
if (chain->images[i].buffer)
static VkResult
wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
VkDevice device,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
- const struct anv_wsi_image_fns *image_fns,
- struct anv_swapchain **swapchain_out)
+ const struct wsi_image_fns *image_fns,
+ struct wsi_swapchain **swapchain_out)
{
VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)icd_surface;
struct wsi_wl_swapchain *chain;
}
VkResult
-anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
+wsi_wl_init_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
VkPhysicalDevice physical_device,
- const struct anv_wsi_callbacks *cbs)
+ const struct wsi_callbacks *cbs)
{
struct wsi_wayland *wsi;
VkResult result;
}
void
-anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
+wsi_wl_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc)
{
struct wsi_wayland *wsi =
#include "wsi_common.h"
VkBool32
-wsi_wl_get_presentation_support(struct anv_wsi_device *wsi_device,
+wsi_wl_get_presentation_support(struct wsi_device *wsi_device,
struct wl_display *wl_display);
-VkResult anv_create_wl_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_wl_surface(const VkAllocationCallbacks *pAllocator,
const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface);
#endif
};
struct wsi_x11 {
- struct anv_wsi_interface base;
+ struct wsi_interface base;
pthread_mutex_t mutex;
/* Hash table of xcb_connection -> wsi_x11_connection mappings */
}
static struct wsi_x11_connection *
-wsi_x11_get_connection(struct anv_wsi_device *wsi_dev,
+wsi_x11_get_connection(struct wsi_device *wsi_dev,
const VkAllocationCallbacks *alloc,
xcb_connection_t *conn)
{
return (all_mask & ~rgb_mask) != 0;
}
-VkBool32 anv_get_physical_device_xcb_presentation_support(
- struct anv_wsi_device *wsi_device,
+VkBool32 wsi_get_physical_device_xcb_presentation_support(
+ struct wsi_device *wsi_device,
VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
xcb_connection_t* connection,
static VkResult
x11_surface_get_support(VkIcdSurfaceBase *icd_surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
VkBool32* pSupported)
static VkResult
x11_surface_get_formats(VkIcdSurfaceBase *surface,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
uint32_t *pSurfaceFormatCount,
VkSurfaceFormatKHR *pSurfaceFormats)
{
return VK_SUCCESS;
}
-VkResult anv_create_xcb_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_xcb_surface(const VkAllocationCallbacks *pAllocator,
const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface)
{
return VK_SUCCESS;
}
-VkResult anv_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface)
{
};
struct x11_swapchain {
- struct anv_swapchain base;
+ struct wsi_swapchain base;
xcb_connection_t * conn;
xcb_window_t window;
};
static VkResult
-x11_get_images(struct anv_swapchain *anv_chain,
+x11_get_images(struct wsi_swapchain *anv_chain,
uint32_t* pCount, VkImage *pSwapchainImages)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
}
static VkResult
-x11_acquire_next_image(struct anv_swapchain *anv_chain,
+x11_acquire_next_image(struct wsi_swapchain *anv_chain,
uint64_t timeout,
VkSemaphore semaphore,
uint32_t *image_index)
}
static VkResult
-x11_queue_present(struct anv_swapchain *anv_chain,
+x11_queue_present(struct wsi_swapchain *anv_chain,
uint32_t image_index)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
}
static VkResult
-x11_swapchain_destroy(struct anv_swapchain *anv_chain,
+x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
const VkAllocationCallbacks *pAllocator)
{
struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
static VkResult
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
VkDevice device,
- struct anv_wsi_device *wsi_device,
+ struct wsi_device *wsi_device,
const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks* pAllocator,
- const struct anv_wsi_image_fns *image_fns,
- struct anv_swapchain **swapchain_out)
+ const struct wsi_image_fns *image_fns,
+ struct wsi_swapchain **swapchain_out)
{
struct x11_swapchain *chain;
xcb_void_cookie_t cookie;
}
VkResult
-anv_x11_init_wsi(struct anv_wsi_device *wsi_device,
+wsi_x11_init_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc)
{
struct wsi_x11 *wsi;
}
void
-anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
+wsi_x11_finish_wsi(struct wsi_device *wsi_device,
const VkAllocationCallbacks *alloc)
{
struct wsi_x11 *wsi =
#include "wsi_common.h"
-VkBool32 anv_get_physical_device_xcb_presentation_support(
- struct anv_wsi_device *wsi_device,
+VkBool32 wsi_get_physical_device_xcb_presentation_support(
+ struct wsi_device *wsi_device,
VkAllocationCallbacks *alloc,
uint32_t queueFamilyIndex,
xcb_connection_t* connection,
xcb_visualid_t visual_id);
-VkResult anv_create_xcb_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_xcb_surface(const VkAllocationCallbacks *pAllocator,
const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface);
-VkResult anv_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
+VkResult wsi_create_xlib_surface(const VkAllocationCallbacks *pAllocator,
const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
VkSurfaceKHR *pSurface);
#endif