#[derive(Clone, Debug, Error)] #[non_exhaustive] pubenum SurfaceError { #[error("Surface is invalid")]
Invalid, #[error("Surface is not configured for presentation")]
NotConfigured, #[error(transparent)]
Device(#[from] DeviceError), #[error("Surface image is already acquired")]
AlreadyAcquired, #[error("No surface image is currently acquired to present")]
NothingToPresent, #[error("Texture has been destroyed")]
TextureDestroyed,
}
#[derive(Clone, Debug, Error)] #[non_exhaustive] pubenum ConfigureSurfaceError { #[error(transparent)]
Device(#[from] DeviceError), #[error("Invalid surface")]
InvalidSurface, #[error("The view format {0:?} is not compatible with texture format {1:?}, only changing srgb-ness is allowed.")]
InvalidViewFormat(wgt::TextureFormat, wgt::TextureFormat), #[error(transparent)]
MissingDownlevelFlags(#[from] MissingDownlevelFlags), #[error("The `SurfaceOutput` returned by `get_current_texture` must be dropped before re-configuring via `configure` or retrieving a new texture via `get_current_texture`.")]
PreviousOutputExists, #[error("Failed to wait for GPU to come idle before reconfiguring the Surface")]
GpuWaitTimeout, #[error("Both `Surface` width and height must be non-zero. Wait to recreate the `Surface` until the window has non-zero area.")]
ZeroArea, #[error("`Surface` width and height must be within the maximum supported texture size. Requested was ({width}, {height}), maximum extent for either dimension is {max_texture_dimension_2d}.")]
TooLarge {
width: u32,
height: u32,
max_texture_dimension_2d: u32,
}, #[error("Surface does not support the adapter's queue family")]
UnsupportedQueueFamily, #[error("Requested format {requested:?} is not in list of supported formats: {available:?}")]
UnsupportedFormat {
requested: wgt::TextureFormat,
available: Vec<wgt::TextureFormat>,
}, #[error("Requested present mode {requested:?} is not in the list of supported present modes: {available:?}")]
UnsupportedPresentMode {
requested: wgt::PresentMode,
available: Vec<wgt::PresentMode>,
}, #[error("Requested alpha mode {requested:?} is not in the list of supported alpha modes: {available:?}")]
UnsupportedAlphaMode {
requested: wgt::CompositeAlphaMode,
available: Vec<wgt::CompositeAlphaMode>,
}, #[error("Requested usage {requested:?} is not in the list of supported usages: {available:?}")]
UnsupportedUsage {
requested: wgt::TextureUses,
available: wgt::TextureUses,
},
}
impl From<WaitIdleError> for ConfigureSurfaceError { fn from(e: WaitIdleError) -> Self { match e {
WaitIdleError::Device(d) => ConfigureSurfaceError::Device(d),
WaitIdleError::WrongSubmissionIndex(..) => unreachable!(),
WaitIdleError::Timeout => ConfigureSurfaceError::GpuWaitTimeout,
}
}
}
// If the texture was never rendered to, clear it and transition to // PRESENT state before presenting. // Fixes <https://github.com/gfx-rs/wgpu/issues/6748> self.prepare_surface_texture_for_present(&texture)?;
let device = &self.device;
letmut exclusive_snatch_guard = device.snatchable_lock.write(); let inner = texture.inner.snatch(&mut exclusive_snatch_guard);
drop(exclusive_snatch_guard);
let result = match inner {
None => return Err(SurfaceError::TextureDestroyed),
Some(resource::TextureInner::Surface { raw }) => { let raw_surface = surface.raw(device.backend()).unwrap(); let raw_queue = self.raw(); // [`wgpu_hal::Queue::present`] requires the queue to be synchronized with submit calls and // other present calls. Locking command indices prevents submits which must increment the // submission index, and by `write`ing prevents other present calls. let _command_indices = device.command_indices.write(); unsafe { raw_queue.present(raw_surface, raw) }
}
_ => unreachable!(),
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.