mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-21 06:01:43 +00:00
c/direct: Use common init swapchain function.
Simplify and add error messages.
This commit is contained in:
parent
77207ed585
commit
bf49a421ba
|
@ -260,3 +260,30 @@ comp_window_direct_acquire_xlib_display(struct comp_window *w,
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
comp_window_direct_init_swapchain(struct comp_window *w,
|
||||||
|
Display *dpy,
|
||||||
|
VkDisplayKHR display,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height)
|
||||||
|
{
|
||||||
|
VkResult ret;
|
||||||
|
ret = comp_window_direct_acquire_xlib_display(w, dpy, display);
|
||||||
|
|
||||||
|
if (ret != VK_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = comp_window_direct_create_surface(w, display, width, height);
|
||||||
|
if (ret != VK_SUCCESS) {
|
||||||
|
COMP_ERROR(w->c, "Failed to create surface!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vk_swapchain_create(
|
||||||
|
&w->swapchain, width, height, w->c->settings.color_format,
|
||||||
|
w->c->settings.color_space, w->c->settings.present_mode);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,13 @@ comp_window_direct_acquire_xlib_display(struct comp_window *w,
|
||||||
Display *dpy,
|
Display *dpy,
|
||||||
VkDisplayKHR display);
|
VkDisplayKHR display);
|
||||||
|
|
||||||
|
bool
|
||||||
|
comp_window_direct_init_swapchain(struct comp_window *w,
|
||||||
|
Display *dpy,
|
||||||
|
VkDisplayKHR display,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -250,33 +250,15 @@ comp_window_direct_nvidia_init_swapchain(struct comp_window *w,
|
||||||
struct comp_window_direct_nvidia *w_direct =
|
struct comp_window_direct_nvidia *w_direct =
|
||||||
(struct comp_window_direct_nvidia *)w;
|
(struct comp_window_direct_nvidia *)w;
|
||||||
|
|
||||||
struct comp_window_direct_nvidia_display *nvd =
|
struct comp_window_direct_nvidia_display *d =
|
||||||
comp_window_direct_nvidia_current_display(w_direct);
|
comp_window_direct_nvidia_current_display(w_direct);
|
||||||
|
if (!d) {
|
||||||
VkResult ret = VK_ERROR_INCOMPATIBLE_DISPLAY_KHR;
|
COMP_ERROR(w->c, "NVIDIA could not find any HMDs.");
|
||||||
|
|
||||||
VkDisplayKHR _display = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
if (nvd) {
|
|
||||||
COMP_DEBUG(w->c, "Will use display: %s", nvd->name);
|
|
||||||
ret = comp_window_direct_acquire_xlib_display(w, w_direct->dpy,
|
|
||||||
nvd->display);
|
|
||||||
_display = nvd->display;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != VK_SUCCESS) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = comp_window_direct_create_surface(w, _display, width, height);
|
|
||||||
if (ret != VK_SUCCESS) {
|
|
||||||
COMP_ERROR(w->c, "Failed to create surface!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk_swapchain_create(
|
COMP_DEBUG(w->c, "Will use display: %s", d->name);
|
||||||
&w->swapchain, width, height, w->c->settings.color_format,
|
|
||||||
w->c->settings.color_space, w->c->settings.present_mode);
|
|
||||||
|
|
||||||
return true;
|
return comp_window_direct_init_swapchain(w, w_direct->dpy, d->display,
|
||||||
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,40 +241,23 @@ comp_window_direct_randr_init_swapchain(struct comp_window *w,
|
||||||
struct comp_window_direct_randr_display *d =
|
struct comp_window_direct_randr_display *d =
|
||||||
comp_window_direct_randr_current_display(w_direct);
|
comp_window_direct_randr_current_display(w_direct);
|
||||||
|
|
||||||
VkResult ret = VK_ERROR_INCOMPATIBLE_DISPLAY_KHR;
|
if (!d) {
|
||||||
VkDisplayKHR _display = VK_NULL_HANDLE;
|
COMP_ERROR(w->c, "RandR could not find any HMDs.");
|
||||||
if (d) {
|
return false;
|
||||||
COMP_DEBUG(
|
}
|
||||||
w->c, "Will use display: %s %dx%d@%.2f", d->name,
|
|
||||||
|
COMP_DEBUG(w->c, "Will use display: %s %dx%d@%.2f", d->name,
|
||||||
d->primary_mode.width, d->primary_mode.height,
|
d->primary_mode.width, d->primary_mode.height,
|
||||||
(double)d->primary_mode.dot_clock /
|
(double)d->primary_mode.dot_clock /
|
||||||
(d->primary_mode.htotal * d->primary_mode.vtotal));
|
(d->primary_mode.htotal * d->primary_mode.vtotal));
|
||||||
|
|
||||||
d->display =
|
d->display = comp_window_direct_randr_get_output(w_direct, d->output);
|
||||||
comp_window_direct_randr_get_output(w_direct, d->output);
|
|
||||||
if (d->display == VK_NULL_HANDLE) {
|
if (d->display == VK_NULL_HANDLE) {
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
|
||||||
}
|
|
||||||
ret = comp_window_direct_acquire_xlib_display(w, w_direct->dpy,
|
|
||||||
d->display);
|
|
||||||
_display = d->display;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != VK_SUCCESS) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = comp_window_direct_create_surface(w, _display, width, height);
|
|
||||||
if (ret != VK_SUCCESS) {
|
|
||||||
COMP_ERROR(w->c, "Failed to create surface!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk_swapchain_create(
|
return comp_window_direct_init_swapchain(w, w_direct->dpy, d->display,
|
||||||
&w->swapchain, width, height, w->c->settings.color_format,
|
width, height);
|
||||||
w->c->settings.color_space, w->c->settings.present_mode);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkDisplayKHR
|
static VkDisplayKHR
|
||||||
|
|
Loading…
Reference in a new issue