gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 551 forks source link

Added the ability to create a surface directly from a display, allowing to render without a windowing system #3721

Closed Uniformbuffer2 closed 3 years ago

Uniformbuffer2 commented 3 years ago

Hi, i'm writing a Wayland compositor for my master thesis and i would like to present images on screen using only the rendering api, without using directly drm/kms system to reduce the code i have to manage. So i have added to some functions to HAL and to the Vulkan Backend to take advantage of the VK_KHR_display vulkan extension that allow to create a surface directly from a display plane.

It is important to note that the starting function, the Instance::enumerate_available_displays, will return the list of the displays available to be managed by the application. Generally compositors will take the control of every display available on the system when they are actively running, so those monitors will not be returned in the list of the available monitors; if a compositor is currently running, it is very likely that the function will return an empty list. Changing to an empty TTY on Linux will make all the monitors available again to be gathered, so it is suggested to run programs that take advantage of this feature directly from the TTY (including the quad_windowless example).

I have added the quad_windowless example, a slightly modified quad example where the surface initialization is done using the new functions instead of the Winit ones. Since Winit is not used, inputs cannot be gathered from the windowing system, so currently the example present the Gfx logo for 5 seconds and than terminate. To be noticed that, at least on my system, the terminal used to run the example does not return automatically to "text mode", so the monitor will remain black until a TTY change has been made. I will realize a separate component to makes possible to gather inputs to make the quad_windowess example more comparable to the quad one.

Since these functions rely on a Vulkan specific extension, it is possible to take advantage of this ability only from the Vulkan backend currently. Unfortunately, as far as i know, no other apis support such feature, but i have tried to make the HAL interface as general as possible to allow future integrations.

So i would like to know what do you think. Obviously i'm ready to adapt and change stuff if you think there is need of.

Thanks for listening, have a good day!

kvark commented 3 years ago

What is the status of this PR?

Uniformbuffer3 commented 3 years ago

This PR can be closed because the feature has been finalized and merged with #3759.