Expand description
Windowing system interoperability
Screen presentation (fullscreen or window) of images requires two objects:
Surfaceis the host abstraction of the native screenSwapchainis the device abstraction for a surface, containing multiple presentable images
§Window
// DOC TODO
§Surface
// DOC TODO
§Swapchain
The most interesting part of a swapchain are the contained presentable images/backbuffers. Presentable images are specialized images, which can be presented on the screen. They are 2D color images with optionally associated depth-stencil images.
The common steps for presentation of a frame are acquisition and presentation:
let acquisition_semaphore = device.create_semaphore().unwrap();
let render_semaphore = device.create_semaphore().unwrap();
let (frame, suboptimal) = swapchain.acquire_image(!0, Some(&acquisition_semaphore), None).unwrap();
// render the scene..
// `render_semaphore` will be signalled once rendering has been finished
swapchain.present(&mut present_queue, 0, &[render_semaphore]);Queues need to synchronize with the presentation engine, usually done via signalling a semaphore once a frame is available for rendering and waiting on a separate semaphore until scene rendering has finished.
§Recreation
DOC TODO
Structs§
- Composite
Alpha Mode - Specifies how the alpha channel of the images should be handled during compositing.
- Extent2D
- An extent describes the size of a rectangle, such as
a window or texture. It is not used for referring to a
sub-rectangle; for that see
command::Rect. - Present
Mode - Specifies the mode regulating how a swapchain presents frames.
- Suboptimal
- Marker value returned if the swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully.
- Surface
Capabilities - Describes information about what a
Surface’s properties are. Fetch this withsurface.compatibility(device). - Swapchain
Config - Contains all the data necessary to create a new
Swapchain: color, depth, and number of images.
Enums§
- Acquire
Error - Error on acquiring the next image from a swapchain.
- Creation
Error - Error occurred during swapchain creation.
- Init
Error - Error occurred during surface creation.
- Present
Error - Error on acquiring the next image from a swapchain.
Traits§
- Presentation
Surface - A surface trait that exposes the ability to present images on the associtated swap chain.
- Surface
- A
Surfaceabstracts the surface of a native window. - Swapchain
- The
Swapchainis the backend representation of the surface. It consists of multiple buffers, which will be presented on the surface.
Type Aliases§
- Swap
Image Index - Index of an image in the swapchain.