anv/wsi/wayland: add callback to get device format properties.
This avoids having to know the toplevel API name. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
4392de6771
commit
e0d15fbe1d
|
@ -23,6 +23,11 @@
|
|||
|
||||
#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)
|
||||
{
|
||||
|
@ -38,7 +43,8 @@ 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);
|
||||
|
|
|
@ -89,6 +89,12 @@ struct anv_swapchain {
|
|||
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,
|
||||
|
@ -96,7 +102,8 @@ 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 */
|
||||
|
|
|
@ -31,11 +31,13 @@
|
|||
|
||||
#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;
|
||||
|
||||
|
@ -51,6 +53,8 @@ struct wsi_wayland {
|
|||
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
|
||||
|
@ -64,8 +68,9 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display *display, VkFormat format)
|
|||
|
||||
/* 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;
|
||||
|
||||
|
@ -249,7 +254,7 @@ wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
|
|||
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;
|
||||
|
@ -759,7 +764,8 @@ 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;
|
||||
|
@ -773,6 +779,7 @@ anv_wl_init_wsi(struct anv_wsi_device *wsi_device,
|
|||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue