pub struct Presenter<'window> { /* private fields */ }Expand description
Runtime-borrowing presentation session.
Construction creates and owns the SDL3 Vulkan surface, then records whether the Runtime’s retained graphics queue can present to that exact surface. Swapchain acquire/present is intentionally the next lifecycle phase rather than a fabricated method on this real surface session.
Implementations§
Source§impl<'window> Presenter<'window>
impl<'window> Presenter<'window>
Sourcepub fn new(runtime: &Runtime, window: &'window SdlWindow) -> Result<Self>
pub fn new(runtime: &Runtime, window: &'window SdlWindow) -> Result<Self>
Create a presentation session for one SDL3 window.
The Runtime must have been built using RuntimeRequirements::presentation()
and window.required_instance_extensions().
Sourcepub fn has_transparent_composition(&self) -> bool
pub fn has_transparent_composition(&self) -> bool
Whether the active swapchain negotiated premultiplied client-frame alpha.
Sourcepub fn has_graphics(&self) -> bool
pub fn has_graphics(&self) -> bool
Return whether the Runtime retained a graphics-capable queue.
A surface can exist without this capability; swapchain allocation will require a graphics queue that can also present to this exact surface.
Sourcepub fn supports_swapchain(&self) -> bool
pub fn supports_swapchain(&self) -> bool
Return whether the selected device enabled VK_KHR_swapchain.
Sourcepub fn has_present(&self) -> bool
pub fn has_present(&self) -> bool
Return whether any queue family can present to this surface.
True when the graphics queue can present directly (same-family path) or when a distinct present-capable family was found during surface creation.
Sourcepub fn capabilities(&self) -> Result<PresentationCapabilities>
pub fn capabilities(&self) -> Result<PresentationCapabilities>
Query the exact surface capabilities before swapchain allocation.
Sourcepub fn swapchain_extent(&self, window: &SdlWindow) -> Result<Option<[u32; 2]>>
pub fn swapchain_extent(&self, window: &SdlWindow) -> Result<Option<[u32; 2]>>
Select the currently valid drawable extent for a future swapchain.
Sourcepub fn can_create_swapchain(&self, window: &SdlWindow) -> Result<bool>
pub fn can_create_swapchain(&self, window: &SdlWindow) -> Result<bool>
Validate whether a swapchain can be allocated at the current drawable size.
false is the normal minimized-window state; unsupported WSI capability
remains an error rather than being hidden behind a fallback.
Sourcepub fn init_swapchain(&mut self, window: &SdlWindow) -> Result<bool>
pub fn init_swapchain(&mut self, window: &SdlWindow) -> Result<bool>
Allocate the negotiated swapchain for the current drawable extent.
Sourcepub fn wait_presentation_idle(&mut self) -> Result<()>
pub fn wait_presentation_idle(&mut self) -> Result<()>
Wait for submitted WSI work before retiring or replacing swapchain resources.
Sourcepub fn close_swapchain(&mut self) -> Result<()>
pub fn close_swapchain(&mut self) -> Result<()>
Explicitly retire the current swapchain after its submitted WSI work completes.
Sourcepub fn recreate_swapchain(&mut self, window: &SdlWindow) -> Result<bool>
pub fn recreate_swapchain(&mut self, window: &SdlWindow) -> Result<bool>
Retire the old swapchain and allocate one for the current drawable extent.
Sourcepub fn notify_pixel_size_changed(&mut self, width: u32, height: u32)
pub fn notify_pixel_size_changed(&mut self, width: u32, height: u32)
Record SDL’s pixel-size change for explicit swapchain retirement/recreation.
The caller must recreate only after all presentation work using the old images has completed; this notification itself never submits or waits.
pub fn needs_swapchain_recreate(&self) -> bool
pub fn has_swapchain(&self) -> bool
Sourcepub fn swapchain_image_count(&self) -> usize
pub fn swapchain_image_count(&self) -> usize
Return the number of owned swapchain image views.
Sourcepub fn frames_in_flight(&self) -> usize
pub fn frames_in_flight(&self) -> usize
Number of independent WSI frame slots owned by this Presenter.
Sourcepub fn present_empty_frame(&mut self) -> Result<bool>
pub fn present_empty_frame(&mut self) -> Result<bool>
Acquire, transition, submit, and present one empty WSI frame.
Returns true when the surface became suboptimal and should be recreated.
Sourcepub fn present_clear_frame(&mut self, color: Color) -> Result<bool>
pub fn present_clear_frame(&mut self, color: Color) -> Result<bool>
Acquire, clear with a linear RGBA color, submit, and present one WSI frame.
Sourcepub fn present_texture(&mut self, texture: &Texture) -> Result<bool>
pub fn present_texture(&mut self, texture: &Texture) -> Result<bool>
Scale and present one native image-backed Texture.
Sourcepub fn present_compose(
&mut self,
compose_image: Image,
compose_width: u32,
compose_height: u32,
record: impl FnOnce(&Device, CommandBuffer) -> Result<()>,
) -> Result<bool>
pub fn present_compose( &mut self, compose_image: Image, compose_width: u32, compose_height: u32, record: impl FnOnce(&Device, CommandBuffer) -> Result<()>, ) -> Result<bool>
Compose the UI layer and present it directly to the swapchain.
record draws the UI raster pass into compose_image as a color
attachment. The swapchain blit and present run in the same submission
— no host readback, no extra queue round-trip.
Sourcepub fn swapchain_extent_px(&self) -> Option<[u32; 2]>
pub fn swapchain_extent_px(&self) -> Option<[u32; 2]>
Return the current swapchain image extent, or None when none is allocated.