#[non_exhaustive]pub struct HostConfig {
pub sample_count: u32,
pub redraw_interval: Option<Duration>,
pub low_latency_present: bool,
pub app_id: Option<String>,
pub color_preferences: ColorPreferences,
pub external_wakeup: Option<WakeupHook>,
}Expand description
Configuration for the optional native winit + wgpu host.
#[non_exhaustive]: build it from HostConfig::default() and the with_* methods,
not as a struct literal, so an option added in a later release is
not a breaking change.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sample_count: u32MSAA sample count used for Damascene’s SDF surfaces. The default is 4, matching the demo and validation app paths.
redraw_interval: Option<Duration>Optional fixed redraw cadence for apps with external live data
sources such as audio meters. Animation-driven redraws still
come from Runner::prepare().needs_redraw; this is only for
host-owned clocks.
low_latency_present: boolPrefer the lowest-latency wgpu present mode the surface
advertises (Mailbox, falling back to Fifo). Default is
Fifo, which is vsync-locked and conservative on power.
Why this exists: with Fifo, every submit queues a frame for
the next vsync; if the app submits faster than the display
refresh, the compositor pulls the oldest queued frame at
each vsync. On Wayland/Mesa during an interactive resize this
shows up as the window content trailing the cursor in slow
motion — by the time the latest size we rendered reaches the
screen, several more compositor configure events have
arrived. Mailbox replaces the pending frame on each submit,
so the next vsync always shows the most recent render.
Cost: with Mailbox, render cadence is no longer naturally
vsync-bounded — an animation that calls request_redraw from
prepare.needs_redraw will render at GPU speed. Pair this
with redraw_interval (or accept the cycles) if that’s not
what you want.
app_id: Option<String>Stable identifier used by the windowing system / compositor / desktop services to group windows under this application.
- Wayland: sets
xdg_toplevel.app_id. Should match the basename of the.desktopfile the app ships (reverse-DNS by convention, e.g.com.example.MyApp). - X11: sets both fields of
WM_CLASSto the same value. - Windows / macOS / mobile: ignored.
When None, windowing-system defaults apply — typically the
process name on Wayland, which several compositors render as
a generic placeholder (e.g. surface-transient) in their
config UIs and XDG-portal-backed system dialogs.
color_preferences: ColorPreferencesApp’s color-space preferences.
Mostly advisory. We never attach an image description to the
surface — per wp_color_management_v1 a surface has a single
color-management owner, and for an accelerated client that is the
wgpu/Vulkan WSI, not us. We do read the compositor’s color-management
state (for the Color Management showcase page) and, on a genuinely
HDR output, select an extended-range float swapchain (Rgba16Float →
scRGB via the WSI) so >1.0 values reach the display; SDR outputs
stay on the 8-bit sRGB baseline. The default is
ColorPreferences::sdr_only().
external_wakeup: Option<WakeupHook>Hook invoked once with a Wakeup handle for the host loop,
just before the loop starts. See
HostConfig::with_external_wakeup.
Implementations§
Source§impl HostConfig
impl HostConfig
pub fn with_redraw_interval(self, interval: Duration) -> HostConfig
pub fn with_sample_count(self, sample_count: u32) -> HostConfig
pub fn with_low_latency_present(self, low_latency_present: bool) -> HostConfig
pub fn with_app_id(self, app_id: impl Into<String>) -> HostConfig
pub fn with_color_preferences( self, color_preferences: ColorPreferences, ) -> HostConfig
Sourcepub fn with_external_wakeup(
self,
hook: impl Fn(Wakeup) + Send + Sync + 'static,
) -> HostConfig
pub fn with_external_wakeup( self, hook: impl Fn(Wakeup) + Send + Sync + 'static, ) -> HostConfig
Register a hook that receives a Wakeup handle for the host
loop. The hook runs once on the UI thread, just before the
event loop starts; hand the handle to whatever owns your
event-class data source.
This is the push-driven complement to
with_redraw_interval: instead of
the host polling on a fixed clock, app code schedules a frame
exactly when something changed, and the idle app renders at
0 fps. The two compose — a fixed cadence for meter-class data
and pushed wakes for event-class data don’t conflict — but most
apps with conditional meters are better served by
redraw_within on the meter widget plus this hook for events.
use damascene_winit_wgpu::HostConfig;
let (tx, rx) = std::sync::mpsc::channel();
let config = HostConfig::default().with_external_wakeup(move |wakeup| {
let _ = tx.send(wakeup);
});
// A backend thread receives the handle and pokes the UI per event:
std::thread::spawn(move || {
let wakeup = rx.recv().unwrap();
// for each interesting backend event:
wakeup.wake();
});Trait Implementations§
Source§impl Clone for HostConfig
impl Clone for HostConfig
Source§fn clone(&self) -> HostConfig
fn clone(&self) -> HostConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HostConfig
impl Debug for HostConfig
Source§impl Default for HostConfig
impl Default for HostConfig
Source§fn default() -> HostConfig
fn default() -> HostConfig
Auto Trait Implementations§
impl !RefUnwindSafe for HostConfig
impl !UnwindSafe for HostConfig
impl Forget for HostConfig
impl Freeze for HostConfig
impl Move for HostConfig
impl Send for HostConfig
impl Sync for HostConfig
impl Unpin for HostConfig
impl UnsafeUnpin for HostConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.