This avoids having to know the toplevel API name.
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
#include "anv_wsi.h"
#include "vk_format_info.h"
+
+static const struct anv_wsi_callbacks anv_wsi_cbs = {
+ .get_phys_device_format_properties = anv_GetPhysicalDeviceFormatProperties,
+};
+
VkResult
anv_init_wsi(struct anv_physical_device *physical_device)
{
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
result = anv_wl_init_wsi(&physical_device->wsi_device, &physical_device->instance->alloc,
- anv_physical_device_to_handle(physical_device));
+ anv_physical_device_to_handle(physical_device),
+ &anv_wsi_cbs);
if (result != VK_SUCCESS) {
#ifdef VK_USE_PLATFORM_XCB_KHR
anv_x11_finish_wsi(&physical_device->wsi_device, &physical_device->instance->alloc);
ANV_DEFINE_NONDISP_HANDLE_CASTS(_VkIcdSurfaceBase, VkSurfaceKHR)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_swapchain, VkSwapchainKHR)
+struct anv_wsi_callbacks {
+ void (*get_phys_device_format_properties)(VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkFormatProperties *pFormatProperties);
+};
+
VkResult anv_x11_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
void anv_x11_finish_wsi(struct anv_wsi_device *wsi_device,
VkResult anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
- VkPhysicalDevice physical_device);
+ VkPhysicalDevice physical_device,
+ const struct anv_wsi_callbacks *cbs);
void anv_wl_finish_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc);
#endif /* ANV_WSI_H */
#define MIN_NUM_IMAGES 2
+struct wsi_wayland;
+
struct wsi_wl_display {
- VkPhysicalDevice physical_device;
struct wl_display * display;
struct wl_drm * drm;
+ struct wsi_wayland *wsi_wl;
/* Vector of VkFormats supported */
struct u_vector formats;
pthread_mutex_t mutex;
/* Hash table of wl_display -> wsi_wl_display mappings */
struct hash_table * displays;
+
+ const struct anv_wsi_callbacks *cbs;
};
static void
/* Don't add formats that aren't renderable. */
VkFormatProperties props;
- anv_GetPhysicalDeviceFormatProperties(
- display->physical_device, format, &props);
+
+ display->wsi_wl->cbs->get_phys_device_format_properties(display->wsi_wl->physical_device,
+ format, &props);
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
return;
memset(display, 0, sizeof(*display));
display->display = wl_display;
- display->physical_device = wsi->physical_device;
+ display->wsi_wl = wsi;
if (!u_vector_init(&display->formats, sizeof(VkFormat), 8))
goto fail;
VkResult
anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
const VkAllocationCallbacks *alloc,
- VkPhysicalDevice physical_device)
+ VkPhysicalDevice physical_device,
+ const struct anv_wsi_callbacks *cbs)
{
struct wsi_wayland *wsi;
VkResult result;
wsi->physical_device = physical_device;
wsi->alloc = alloc;
+ wsi->cbs = cbs;
int ret = pthread_mutex_init(&wsi->mutex, NULL);
if (ret != 0) {
if (ret == ENOMEM) {