}
static VkResult
-tpl_get_surface_capabilities(VkIcdSurfaceWayland *sfc,
+tpl_get_surface_capabilities(VkIcdSurfaceBase *sfc,
VkSurfaceCapabilitiesKHR *caps)
{
tpl_display_t *display;
int min, max;
tpl_result_t res;
+ tpl_handle_t native_window;
- display = vk_get_tpl_display(sfc->display);
+ display = vk_get_tpl_display(sfc);
VK_CHECK(display, return VK_ERROR_DEVICE_LOST, "vk_get_tpl_display() failed.\n");
- res = tpl_display_query_supported_buffer_count_from_native_window(display, sfc->surface, &min, &max);
+ native_window = vk_get_tpl_native_window(sfc);
+ res = tpl_display_query_supported_buffer_count_from_native_window(display, native_window,
+ &min, &max);
VK_CHECK(res == TPL_ERROR_NONE, return VK_ERROR_DEVICE_LOST,
"tpl_display_query_native_window_supported_buffer_count() failed.\n");
+
/* TODO: Hard-coded. */
caps->minImageCount = min;
caps->maxImageCount = max;
VkSurfaceCapabilitiesKHR *caps)
{
switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+ case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
case VK_ICD_WSI_PLATFORM_WAYLAND:
- return tpl_get_surface_capabilities((VkIcdSurfaceWayland *)
+ return tpl_get_surface_capabilities((VkIcdSurfaceBase *)
(uintptr_t)surface, caps);
case VK_ICD_WSI_PLATFORM_DISPLAY:
return tdm_get_surface_capabilities((VkIcdSurfaceDisplay *)
};
static VkResult
-tpl_get_surface_formats(VkIcdSurfaceWayland *sfc,
+tpl_get_surface_formats(VkIcdSurfaceBase *sfc,
uint32_t *format_count,
VkSurfaceFormatKHR *formats)
{
VkSurfaceFormatKHR *formats)
{
switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+ case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
case VK_ICD_WSI_PLATFORM_WAYLAND:
- return tpl_get_surface_formats((VkIcdSurfaceWayland *)
+ return tpl_get_surface_formats((VkIcdSurfaceBase *)
(uintptr_t)surface, format_count, formats);
case VK_ICD_WSI_PLATFORM_DISPLAY:
return tdm_get_surface_formats((VkIcdSurfaceDisplay *)
}
static VkResult
-tpl_get_surface_present_modes(VkIcdSurfaceWayland *sfc,
+tpl_get_surface_present_modes(VkIcdSurfaceBase *sfc,
uint32_t *mode_count,
VkPresentModeKHR *modes)
{
tpl_display_t *display;
tpl_result_t res;
+ tpl_handle_t native_window;
int tpl_support_modes;
uint32_t support_mode_cnt = 0;
- VK_CHECK(sfc->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND, return VK_ERROR_DEVICE_LOST,
- "Not supported platform surface.\n");
-
- display = vk_get_tpl_display(sfc->display);
+ display = vk_get_tpl_display(sfc);
VK_CHECK(display, return VK_ERROR_DEVICE_LOST, "vk_get_tpl_display() failed.\n");
- res = tpl_display_query_supported_present_modes_from_native_window(display, sfc->surface,
+ native_window = vk_get_tpl_native_window(sfc);
+ res = tpl_display_query_supported_present_modes_from_native_window(display, native_window,
&tpl_support_modes);
tpl_object_unreference((tpl_object_t *)display);
VK_CHECK(res == TPL_ERROR_NONE, return VK_ERROR_DEVICE_LOST,
VkPresentModeKHR *modes)
{
switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+ case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
case VK_ICD_WSI_PLATFORM_WAYLAND:
- return tpl_get_surface_present_modes((VkIcdSurfaceWayland *)
+ return tpl_get_surface_present_modes((VkIcdSurfaceBase *)
(uintptr_t)surface, mode_count, modes);
case VK_ICD_WSI_PLATFORM_DISPLAY:
return tdm_get_surface_present_modes((VkIcdSurfaceDisplay *)
tbm_format format)
{
tpl_result_t res;
- VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)(uintptr_t)info->surface;
+ VkIcdSurfaceBase *surface = (VkIcdSurfaceBase *)(uintptr_t)info->surface;
vk_swapchain_tpl_t *swapchain_tpl;
+ tpl_handle_t native_window;
int tpl_present_mode;
VkResult error = VK_ERROR_DEVICE_LOST;
/* Don't check NULL for display and window. There might be default ones for some systems. */
- swapchain_tpl->tpl_display = vk_get_tpl_display(surface->display);
+ swapchain_tpl->tpl_display = vk_get_tpl_display(surface);
VK_CHECK(swapchain_tpl->tpl_display, goto error, "vk_get_tpl_display() failed.\n");
+ native_window = vk_get_tpl_native_window(surface);
swapchain_tpl->tpl_surface = tpl_surface_create(swapchain_tpl->tpl_display,
- surface->surface,
+ native_window,
TPL_SURFACE_TYPE_WINDOW, format);
VK_CHECK(swapchain_tpl->tpl_surface, goto error, "tpl_surface_create() failed.\n");
void
vk_free(const VkAllocationCallbacks *allocator, void *mem);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
static inline tpl_display_t *
-vk_get_tpl_display(tpl_handle_t native_dpy)
+vk_get_tpl_display(VkIcdSurfaceBase *sfc)
{
- tpl_display_t *display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI, native_dpy);
+ tpl_backend_type_t type = TPL_BACKEND_UNKNOWN;
+ tpl_handle_t native_dpy = NULL;
+
+ switch (sfc->platform) {
+ case VK_ICD_WSI_PLATFORM_WAYLAND:
+ type = TPL_BACKEND_WAYLAND_VULKAN_WSI;
+ native_dpy = ((VkIcdSurfaceWayland *)(uintptr_t)sfc)->display;
+ break;
+ case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+ type = TPL_BACKEND_TBM;
+ native_dpy = ((vk_tbm_queue_surface_t *)(uintptr_t)sfc)->bufmgr;
+ break;
+ default:
+ return NULL;
+ }
+
+ tpl_display_t *display = tpl_display_create(type, native_dpy);
if (display == NULL) {
display = tpl_display_get(native_dpy);
tpl_object_reference((tpl_object_t *)display);
return display;
};
+static inline tpl_handle_t
+vk_get_tpl_native_window(VkIcdSurfaceBase *sfc)
+{
+ switch (sfc->platform) {
+ case VK_ICD_WSI_PLATFORM_WAYLAND:
+ return ((VkIcdSurfaceWayland *)(uintptr_t)sfc)->surface;
+ case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+ return ((vk_tbm_queue_surface_t *)(uintptr_t)sfc)->tbm_queue;
+ default:
+ return NULL;
+ }
+ return NULL;
+}
+#pragma GCC diagnostic pop
+
VkResult
swapchain_tpl_init(VkDevice device, const VkSwapchainCreateInfoKHR *info,
vk_swapchain_t *chain, tbm_format format);