mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-03-03 21:26:36 +00:00
c/main: Remove vk field from comp_target_swapchain
This commit is contained in:
parent
d60ae941f1
commit
f4c1ebe90c
|
@ -16,7 +16,8 @@
|
|||
|
||||
#include "util/u_misc.h"
|
||||
|
||||
#include "comp_target_swapchain.h"
|
||||
#include "main/comp_compositor.h"
|
||||
#include "main/comp_target_swapchain.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -77,6 +78,12 @@ _check_surface_present_mode(struct vk_bundle *vk,
|
|||
*
|
||||
*/
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_target_swapchain *cts)
|
||||
{
|
||||
return &cts->base.c->vk;
|
||||
}
|
||||
|
||||
void
|
||||
comp_target_swapchain_create_images(struct comp_target *ct,
|
||||
uint32_t width,
|
||||
|
@ -86,6 +93,7 @@ comp_target_swapchain_create_images(struct comp_target *ct,
|
|||
VkPresentModeKHR present_mode)
|
||||
{
|
||||
struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
VkBool32 supported;
|
||||
VkResult ret;
|
||||
|
||||
|
@ -102,16 +110,16 @@ comp_target_swapchain_create_images(struct comp_target *ct,
|
|||
|
||||
|
||||
// Sanity check.
|
||||
cts->vk->vkGetPhysicalDeviceSurfaceSupportKHR(
|
||||
cts->vk->physical_device, 0, cts->surface.handle, &supported);
|
||||
vk->vkGetPhysicalDeviceSurfaceSupportKHR(
|
||||
vk->physical_device, 0, cts->surface.handle, &supported);
|
||||
if (!supported) {
|
||||
VK_ERROR(cts->vk,
|
||||
VK_ERROR(vk,
|
||||
"vkGetPhysicalDeviceSurfaceSupportKHR: "
|
||||
"surface not supported!");
|
||||
}
|
||||
|
||||
// More sanity checks.
|
||||
if (!_check_surface_present_mode(cts->vk, cts->surface.handle,
|
||||
if (!_check_surface_present_mode(vk, cts->surface.handle,
|
||||
cts->present_mode)) {
|
||||
// Free old.
|
||||
comp_target_swapchain_destroy_old(cts, old_swapchain_handle);
|
||||
|
@ -128,11 +136,10 @@ comp_target_swapchain_create_images(struct comp_target *ct,
|
|||
|
||||
// Get the caps first.
|
||||
VkSurfaceCapabilitiesKHR surface_caps;
|
||||
ret = cts->vk->vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
cts->vk->physical_device, cts->surface.handle, &surface_caps);
|
||||
ret = vk->vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
vk->physical_device, cts->surface.handle, &surface_caps);
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(cts->vk,
|
||||
"vkGetPhysicalDeviceSurfaceCapabilitiesKHR: %s",
|
||||
VK_ERROR(vk, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR: %s",
|
||||
vk_result_string(ret));
|
||||
|
||||
// Free old.
|
||||
|
@ -167,15 +174,14 @@ comp_target_swapchain_create_images(struct comp_target *ct,
|
|||
.oldSwapchain = old_swapchain_handle,
|
||||
};
|
||||
|
||||
ret = cts->vk->vkCreateSwapchainKHR(cts->vk->device, &swapchain_info,
|
||||
NULL, &cts->swapchain.handle);
|
||||
ret = vk->vkCreateSwapchainKHR(vk->device, &swapchain_info, NULL,
|
||||
&cts->swapchain.handle);
|
||||
|
||||
// Always destroy the old.
|
||||
comp_target_swapchain_destroy_old(cts, old_swapchain_handle);
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(cts->vk, "vkCreateSwapchainKHR: %s",
|
||||
vk_result_string(ret));
|
||||
VK_ERROR(vk, "vkCreateSwapchainKHR: %s", vk_result_string(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,6 +203,8 @@ comp_target_swapchain_select_extent(struct comp_target_swapchain *cts,
|
|||
uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
// If width (and height) equals the special value 0xFFFFFFFF,
|
||||
// the size of the surface will be set by the swapchain
|
||||
if (caps.currentExtent.width == (uint32_t)-1) {
|
||||
|
@ -209,7 +217,7 @@ comp_target_swapchain_select_extent(struct comp_target_swapchain *cts,
|
|||
|
||||
if (caps.currentExtent.width != width ||
|
||||
caps.currentExtent.height != height) {
|
||||
VK_DEBUG(cts->vk,
|
||||
VK_DEBUG(vk,
|
||||
"Using swap chain extent dimensions %dx%d instead of "
|
||||
"requested %dx%d.",
|
||||
caps.currentExtent.width, caps.currentExtent.height,
|
||||
|
@ -223,8 +231,10 @@ static void
|
|||
comp_target_swapchain_destroy_old(struct comp_target_swapchain *cts,
|
||||
VkSwapchainKHR old)
|
||||
{
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
if (old != VK_NULL_HANDLE) {
|
||||
cts->vk->vkDestroySwapchainKHR(cts->vk->device, old, NULL);
|
||||
vk->vkDestroySwapchainKHR(vk->device, old, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,14 +244,16 @@ comp_target_swapchain_acquire_next_image(struct comp_target *ct,
|
|||
uint32_t *out_index)
|
||||
{
|
||||
struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
return cts->vk->vkAcquireNextImageKHR( //
|
||||
cts->vk->device, // device
|
||||
cts->swapchain.handle, // timeout
|
||||
UINT64_MAX, // timeout
|
||||
semaphore, // semaphore
|
||||
VK_NULL_HANDLE, // fence
|
||||
out_index); // pImageIndex
|
||||
|
||||
return vk->vkAcquireNextImageKHR( //
|
||||
vk->device, // device
|
||||
cts->swapchain.handle, // timeout
|
||||
UINT64_MAX, // timeout
|
||||
semaphore, // semaphore
|
||||
VK_NULL_HANDLE, // fence
|
||||
out_index); // pImageIndex
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
@ -251,6 +263,7 @@ comp_target_swapchain_present(struct comp_target *ct,
|
|||
VkSemaphore semaphore)
|
||||
{
|
||||
struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
VkPresentInfoKHR presentInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||
|
@ -261,7 +274,7 @@ comp_target_swapchain_present(struct comp_target *ct,
|
|||
.pImageIndices = &index,
|
||||
};
|
||||
|
||||
return cts->vk->vkQueuePresentKHR(queue, &presentInfo);
|
||||
return vk->vkQueuePresentKHR(queue, &presentInfo);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -269,17 +282,19 @@ _find_surface_format(struct comp_target_swapchain *cts,
|
|||
VkSurfaceKHR surface,
|
||||
VkSurfaceFormatKHR *format)
|
||||
{
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
uint32_t num_formats;
|
||||
VkSurfaceFormatKHR *formats = NULL;
|
||||
cts->vk->vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
cts->vk->physical_device, surface, &num_formats, NULL);
|
||||
|
||||
vk->vkGetPhysicalDeviceSurfaceFormatsKHR(vk->physical_device, surface,
|
||||
&num_formats, NULL);
|
||||
|
||||
if (num_formats != 0) {
|
||||
formats = U_TYPED_ARRAY_CALLOC(VkSurfaceFormatKHR, num_formats);
|
||||
cts->vk->vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
cts->vk->physical_device, surface, &num_formats, formats);
|
||||
vk->vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
vk->physical_device, surface, &num_formats, formats);
|
||||
} else {
|
||||
VK_ERROR(cts->vk, "Could not enumerate surface formats.");
|
||||
VK_ERROR(vk, "Could not enumerate surface formats.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -331,7 +346,7 @@ _find_surface_format(struct comp_target_swapchain *cts,
|
|||
// maybe we only have 10/12 bpc or 15/16bpp format. return the
|
||||
// first one we have, at least its in the right color space.
|
||||
*format = formats_for_colorspace[0];
|
||||
VK_ERROR(cts->vk, "Returning unknown color format");
|
||||
VK_ERROR(vk, "Returning unknown color format");
|
||||
goto cleanup;
|
||||
|
||||
} else {
|
||||
|
@ -344,7 +359,7 @@ _find_surface_format(struct comp_target_swapchain *cts,
|
|||
preferred_color_formats[j]) {
|
||||
*format = formats_for_colorspace[i];
|
||||
VK_ERROR(
|
||||
cts->vk,
|
||||
vk,
|
||||
"Returning known-wrong color "
|
||||
"space! Color shift may occur.");
|
||||
goto cleanup;
|
||||
|
@ -355,13 +370,13 @@ _find_surface_format(struct comp_target_swapchain *cts,
|
|||
// we have. we know its the wrong colorspace, and its not on our
|
||||
// list of preferred formats, but its something.
|
||||
*format = formats[0];
|
||||
VK_ERROR(cts->vk,
|
||||
VK_ERROR(vk,
|
||||
"Returning fallback format! cue up some Kenny "
|
||||
"Loggins, cos we're in the DANGER ZONE!");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VK_ERROR(cts->vk, "We should not be here");
|
||||
VK_ERROR(vk, "We should not be here");
|
||||
goto error;
|
||||
|
||||
cleanup:
|
||||
|
@ -415,13 +430,15 @@ comp_target_swapchain_destroy_image_views(struct comp_target_swapchain *cts)
|
|||
return;
|
||||
}
|
||||
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
for (uint32_t i = 0; i < cts->base.num_images; i++) {
|
||||
if (cts->base.images[i].view == VK_NULL_HANDLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cts->vk->vkDestroyImageView(cts->vk->device,
|
||||
cts->base.images[i].view, NULL);
|
||||
vk->vkDestroyImageView(vk->device, cts->base.images[i].view,
|
||||
NULL);
|
||||
cts->base.images[i].view = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
|
@ -432,20 +449,22 @@ comp_target_swapchain_destroy_image_views(struct comp_target_swapchain *cts)
|
|||
static void
|
||||
comp_target_swapchain_create_image_views(struct comp_target_swapchain *cts)
|
||||
{
|
||||
cts->vk->vkGetSwapchainImagesKHR( //
|
||||
cts->vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
&cts->base.num_images, // pSwapchainImageCount
|
||||
NULL); // pSwapchainImages
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
vk->vkGetSwapchainImagesKHR( //
|
||||
vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
&cts->base.num_images, // pSwapchainImageCount
|
||||
NULL); // pSwapchainImages
|
||||
assert(cts->base.num_images > 0);
|
||||
VK_DEBUG(cts->vk, "Creating %d image views.", cts->base.num_images);
|
||||
VK_DEBUG(vk, "Creating %d image views.", cts->base.num_images);
|
||||
|
||||
VkImage *images = U_TYPED_ARRAY_CALLOC(VkImage, cts->base.num_images);
|
||||
cts->vk->vkGetSwapchainImagesKHR( //
|
||||
cts->vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
&cts->base.num_images, // pSwapchainImageCount
|
||||
images); // pSwapchainImages
|
||||
vk->vkGetSwapchainImagesKHR( //
|
||||
vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
&cts->base.num_images, // pSwapchainImageCount
|
||||
images); // pSwapchainImages
|
||||
|
||||
comp_target_swapchain_destroy_image_views(cts);
|
||||
|
||||
|
@ -462,7 +481,7 @@ comp_target_swapchain_create_image_views(struct comp_target_swapchain *cts)
|
|||
|
||||
for (uint32_t i = 0; i < cts->base.num_images; i++) {
|
||||
cts->base.images[i].handle = images[i];
|
||||
vk_create_view(cts->vk, cts->base.images[i].handle,
|
||||
vk_create_view(vk, cts->base.images[i].handle,
|
||||
cts->surface.format.format, subresource_range,
|
||||
&cts->base.images[i].view);
|
||||
}
|
||||
|
@ -473,21 +492,23 @@ comp_target_swapchain_create_image_views(struct comp_target_swapchain *cts)
|
|||
void
|
||||
comp_target_swapchain_cleanup(struct comp_target_swapchain *cts)
|
||||
{
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
comp_target_swapchain_destroy_image_views(cts);
|
||||
|
||||
if (cts->swapchain.handle != VK_NULL_HANDLE) {
|
||||
cts->vk->vkDestroySwapchainKHR( //
|
||||
cts->vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
NULL); //
|
||||
vk->vkDestroySwapchainKHR( //
|
||||
vk->device, // device
|
||||
cts->swapchain.handle, // swapchain
|
||||
NULL); //
|
||||
cts->swapchain.handle = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (cts->surface.handle != VK_NULL_HANDLE) {
|
||||
cts->vk->vkDestroySurfaceKHR( //
|
||||
cts->vk->instance, // instance
|
||||
cts->surface.handle, // surface
|
||||
NULL); //
|
||||
vk->vkDestroySurfaceKHR( //
|
||||
vk->instance, // instance
|
||||
cts->surface.handle, // surface
|
||||
NULL); //
|
||||
cts->swapchain.handle = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
@ -499,10 +520,3 @@ comp_target_swapchain_init_set_fnptrs(struct comp_target_swapchain *cts)
|
|||
cts->base.acquire = comp_target_swapchain_acquire_next_image;
|
||||
cts->base.present = comp_target_swapchain_present;
|
||||
}
|
||||
|
||||
void
|
||||
comp_target_swapchain_init_post_vulkan(struct comp_target_swapchain *cts,
|
||||
struct vk_bundle *vk)
|
||||
{
|
||||
cts->vk = vk;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ struct comp_target_swapchain
|
|||
//! Base target.
|
||||
struct comp_target base;
|
||||
|
||||
struct vk_bundle *vk;
|
||||
|
||||
struct
|
||||
{
|
||||
VkSwapchainKHR handle;
|
||||
|
@ -72,15 +70,6 @@ struct comp_target_swapchain
|
|||
void
|
||||
comp_target_swapchain_init_set_fnptrs(struct comp_target_swapchain *cts);
|
||||
|
||||
/*!
|
||||
* Initialize the given @ref comp_target_swapchain, does not allocate.
|
||||
*
|
||||
* @ingroup comp_main
|
||||
*/
|
||||
void
|
||||
comp_target_swapchain_init_post_vulkan(struct comp_target_swapchain *cts,
|
||||
struct vk_bundle *vk);
|
||||
|
||||
/*!
|
||||
* See comp_target::create_images.
|
||||
*
|
||||
|
|
|
@ -47,6 +47,12 @@ struct comp_window_android
|
|||
*
|
||||
*/
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_window_android *cwa)
|
||||
{
|
||||
return &cwa->base.base.c->vk;
|
||||
}
|
||||
|
||||
static bool
|
||||
comp_window_android_init(struct comp_target *ct)
|
||||
{
|
||||
|
@ -78,8 +84,9 @@ static VkResult
|
|||
comp_window_android_create_surface(struct comp_window_android *w,
|
||||
VkSurfaceKHR *vk_surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
struct vk_bundle *vk = get_vk(w);
|
||||
VkResult ret;
|
||||
|
||||
w->custom_surface = android_custom_surface_async_start(
|
||||
android_globals_get_vm(), android_globals_get_activity());
|
||||
if (w->custom_surface == NULL) {
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
|
||||
#include "util/u_misc.h"
|
||||
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_target_swapchain *cts)
|
||||
{
|
||||
return &cts->base.c->vk;
|
||||
}
|
||||
|
||||
static int
|
||||
choose_best_vk_mode_auto(struct comp_target *ct,
|
||||
VkDisplayModePropertiesKHR *mode_properties,
|
||||
|
@ -79,7 +86,7 @@ VkDisplayModeKHR
|
|||
comp_window_direct_get_primary_display_mode(struct comp_target_swapchain *cts,
|
||||
VkDisplayKHR display)
|
||||
{
|
||||
struct vk_bundle *vk = cts->vk;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
struct comp_target *ct = &cts->base;
|
||||
uint32_t mode_count;
|
||||
VkResult ret;
|
||||
|
@ -171,12 +178,12 @@ comp_window_direct_create_surface(struct comp_target_swapchain *cts,
|
|||
uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
struct vk_bundle *vk = cts->vk;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
|
||||
// Get plane properties
|
||||
uint32_t plane_property_count;
|
||||
VkResult ret = vk->vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
|
||||
cts->vk->physical_device, &plane_property_count, NULL);
|
||||
vk->physical_device, &plane_property_count, NULL);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(cts->base.c,
|
||||
"vkGetPhysicalDeviceDisplayPlanePropertiesKHR: %s",
|
||||
|
@ -191,7 +198,7 @@ comp_window_direct_create_surface(struct comp_target_swapchain *cts,
|
|||
VkDisplayPlanePropertiesKHR, plane_property_count);
|
||||
|
||||
ret = vk->vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
|
||||
cts->vk->physical_device, &plane_property_count, plane_properties);
|
||||
vk->physical_device, &plane_property_count, plane_properties);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(cts->base.c,
|
||||
"vkGetPhysicalDeviceDisplayPlanePropertiesKHR: %s",
|
||||
|
@ -206,8 +213,8 @@ comp_window_direct_create_surface(struct comp_target_swapchain *cts,
|
|||
comp_window_direct_get_primary_display_mode(cts, display);
|
||||
|
||||
VkDisplayPlaneCapabilitiesKHR plane_caps;
|
||||
vk->vkGetDisplayPlaneCapabilitiesKHR(
|
||||
cts->vk->physical_device, display_mode, plane_index, &plane_caps);
|
||||
vk->vkGetDisplayPlaneCapabilitiesKHR(vk->physical_device, display_mode,
|
||||
plane_index, &plane_caps);
|
||||
|
||||
VkDisplaySurfaceCreateInfoKHR surface_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR,
|
||||
|
@ -250,11 +257,10 @@ comp_window_direct_acquire_xlib_display(struct comp_target_swapchain *cts,
|
|||
Display *dpy,
|
||||
VkDisplayKHR display)
|
||||
{
|
||||
struct vk_bundle *vk = cts->vk;
|
||||
struct vk_bundle *vk = get_vk(cts);
|
||||
VkResult ret;
|
||||
|
||||
ret =
|
||||
vk->vkAcquireXlibDisplayEXT(cts->vk->physical_device, dpy, display);
|
||||
ret = vk->vkAcquireXlibDisplayEXT(vk->physical_device, dpy, display);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(cts->base.c,
|
||||
"vkAcquireXlibDisplayEXT: %s (0x%016" PRIx64 ")",
|
||||
|
@ -278,8 +284,6 @@ comp_window_direct_init_swapchain(struct comp_target_swapchain *cts,
|
|||
uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
comp_target_swapchain_init_post_vulkan(cts, &cts->base.c->vk);
|
||||
|
||||
VkResult ret;
|
||||
ret = comp_window_direct_acquire_xlib_display(cts, dpy, display);
|
||||
|
||||
|
|
|
@ -256,8 +256,6 @@ comp_window_direct_nvidia_init_swapchain(struct comp_target *ct,
|
|||
struct comp_window_direct_nvidia *w_direct =
|
||||
(struct comp_window_direct_nvidia *)ct;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w_direct->base, &ct->c->vk);
|
||||
|
||||
struct comp_window_direct_nvidia_display *d =
|
||||
comp_window_direct_nvidia_current_display(w_direct);
|
||||
if (!d) {
|
||||
|
|
|
@ -92,6 +92,12 @@ comp_window_direct_randr_get_outputs(struct comp_window_direct_randr *w);
|
|||
*
|
||||
*/
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_window_direct_randr *cwdr)
|
||||
{
|
||||
return &cwdr->base.base.c->vk;
|
||||
}
|
||||
|
||||
static void
|
||||
_flush(struct comp_target *ct)
|
||||
{
|
||||
|
@ -132,7 +138,7 @@ comp_window_direct_randr_destroy(struct comp_target *ct)
|
|||
|
||||
comp_target_swapchain_cleanup(&w_direct->base);
|
||||
|
||||
struct vk_bundle *vk = w_direct->base.vk;
|
||||
struct vk_bundle *vk = get_vk(w_direct);
|
||||
|
||||
for (uint32_t i = 0; i < w_direct->num_displays; i++) {
|
||||
struct comp_window_direct_randr_display *d =
|
||||
|
@ -251,8 +257,6 @@ comp_window_direct_randr_init_swapchain(struct comp_target *ct,
|
|||
struct comp_window_direct_randr *w_direct =
|
||||
(struct comp_window_direct_randr *)ct;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w_direct->base, &ct->c->vk);
|
||||
|
||||
struct comp_window_direct_randr_display *d =
|
||||
comp_window_direct_randr_current_display(w_direct);
|
||||
|
||||
|
@ -279,12 +283,12 @@ static VkDisplayKHR
|
|||
comp_window_direct_randr_get_output(struct comp_window_direct_randr *w,
|
||||
RROutput output)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
struct vk_bundle *vk = get_vk(w);
|
||||
VkResult ret;
|
||||
|
||||
VkDisplayKHR display;
|
||||
ret = vk->vkGetRandROutputDisplayEXT(w->base.vk->physical_device,
|
||||
w->dpy, output, &display);
|
||||
ret = vk->vkGetRandROutputDisplayEXT(vk->physical_device, w->dpy,
|
||||
output, &display);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(w->base.base.c, "vkGetRandROutputDisplayEXT: %s",
|
||||
vk_result_string(ret));
|
||||
|
|
|
@ -97,6 +97,12 @@ comp_window_wayland_configure(struct comp_window_wayland *w,
|
|||
*
|
||||
*/
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_window_wayland *cww)
|
||||
{
|
||||
return &cww->base.base.c->vk;
|
||||
}
|
||||
|
||||
struct comp_target *
|
||||
comp_window_wayland_create(struct comp_compositor *c)
|
||||
{
|
||||
|
@ -204,8 +210,6 @@ comp_window_wayland_init_swapchain(struct comp_target *ct,
|
|||
(struct comp_window_wayland *)ct;
|
||||
VkResult ret;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w_wayland->base, &ct->c->vk);
|
||||
|
||||
ret = comp_window_wayland_create_surface(
|
||||
w_wayland, &w_wayland->base.surface.handle);
|
||||
if (ret != VK_SUCCESS) {
|
||||
|
@ -223,7 +227,7 @@ static VkResult
|
|||
comp_window_wayland_create_surface(struct comp_window_wayland *w,
|
||||
VkSurfaceKHR *vk_surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
struct vk_bundle *vk = get_vk(w);
|
||||
VkResult ret;
|
||||
|
||||
VkWaylandSurfaceCreateInfoKHR surface_info = {
|
||||
|
|
|
@ -122,6 +122,12 @@ comp_window_xcb_update_window_title(struct comp_target *ct, const char *title);
|
|||
*
|
||||
*/
|
||||
|
||||
static inline struct vk_bundle *
|
||||
get_vk(struct comp_window_xcb *cwx)
|
||||
{
|
||||
return &cwx->base.base.c->vk;
|
||||
}
|
||||
|
||||
struct comp_target *
|
||||
comp_window_xcb_create(struct comp_compositor *c)
|
||||
{
|
||||
|
@ -133,8 +139,7 @@ comp_window_xcb_create(struct comp_compositor *c)
|
|||
w->base.base.destroy = comp_window_xcb_destroy;
|
||||
w->base.base.flush = comp_window_xcb_flush;
|
||||
w->base.base.init_pre_vulkan = comp_window_xcb_init;
|
||||
w->base.base.init_post_vulkan =
|
||||
comp_window_xcb_init_swapchain;
|
||||
w->base.base.init_post_vulkan = comp_window_xcb_init_swapchain;
|
||||
w->base.base.set_title = comp_window_xcb_update_window_title;
|
||||
w->base.base.c = c;
|
||||
|
||||
|
@ -162,15 +167,15 @@ comp_window_xcb_destroy(struct comp_target *ct)
|
|||
static void
|
||||
comp_window_xcb_list_screens(struct comp_window_xcb *w, xcb_screen_t *screen)
|
||||
{
|
||||
COMP_DEBUG(w->base.base.c, "Screen 0 %dx%d",
|
||||
screen->width_in_pixels, screen->height_in_pixels);
|
||||
COMP_DEBUG(w->base.base.c, "Screen 0 %dx%d", screen->width_in_pixels,
|
||||
screen->height_in_pixels);
|
||||
comp_window_xcb_get_randr_outputs(w);
|
||||
|
||||
for (uint16_t i = 0; i < w->num_displays; i++) {
|
||||
struct comp_window_xcb_display *d = &w->displays[i];
|
||||
COMP_DEBUG(w->base.base.c, "%d: %s %dx%d [%d, %d]", i,
|
||||
d->name, d->size.width, d->size.height,
|
||||
d->position.x, d->position.y);
|
||||
COMP_DEBUG(w->base.base.c, "%d: %s %dx%d [%d, %d]", i, d->name,
|
||||
d->size.width, d->size.height, d->position.x,
|
||||
d->position.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,8 +253,6 @@ comp_window_xcb_init_swapchain(struct comp_target *ct,
|
|||
struct comp_window_xcb *w_xcb = (struct comp_window_xcb *)ct;
|
||||
VkResult ret;
|
||||
|
||||
comp_target_swapchain_init_post_vulkan(&w_xcb->base, &ct->c->vk);
|
||||
|
||||
ret =
|
||||
comp_window_xcb_create_surface(w_xcb, &w_xcb->base.surface.handle);
|
||||
if (ret != VK_SUCCESS) {
|
||||
|
@ -303,8 +306,7 @@ comp_window_xcb_get_randr_outputs(struct comp_window_xcb *w)
|
|||
w->num_displays =
|
||||
xcb_randr_get_screen_resources_outputs_length(resources_reply);
|
||||
if (w->num_displays < 1)
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"Failed to retrieve randr outputs");
|
||||
COMP_ERROR(w->base.base.c, "Failed to retrieve randr outputs");
|
||||
|
||||
w->displays =
|
||||
calloc(w->num_displays, sizeof(struct comp_window_xcb_display));
|
||||
|
@ -394,7 +396,7 @@ comp_window_xcb_get_atom(struct comp_window_xcb *w, const char *name)
|
|||
static VkResult
|
||||
comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface)
|
||||
{
|
||||
struct vk_bundle *vk = w->base.vk;
|
||||
struct vk_bundle *vk = get_vk(w);
|
||||
VkResult ret;
|
||||
|
||||
VkXcbSurfaceCreateInfoKHR surface_info = {
|
||||
|
@ -406,8 +408,8 @@ comp_window_xcb_create_surface(struct comp_window_xcb *w, VkSurfaceKHR *surface)
|
|||
ret = vk->vkCreateXcbSurfaceKHR(vk->instance, &surface_info, NULL,
|
||||
surface);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(w->base.base.c,
|
||||
"vkCreateXcbSurfaceKHR: %s", vk_result_string(ret));
|
||||
COMP_ERROR(w->base.base.c, "vkCreateXcbSurfaceKHR: %s",
|
||||
vk_result_string(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue