pub struct WgpuContext {
pub device: Device,
pub queue: Queue,
pub surface: Surface<'static>,
pub config: SurfaceConfiguration<Vec<TextureFormat>>,
pub depth_format: TextureFormat,
pub surface_view_format: TextureFormat,
pub msaa_samples: u32,
pub anisotropy_clamp: u16,
pub render_path: RenderPath,
pub pipeline_settings_version: u64,
}Expand description
Core wgpu context holding GPU handles.
This struct owns the fundamental wgpu resources needed for rendering:
device: GPU device for resource creationqueue: Command submission queuesurface: Window surface for presentationconfig: Surface configuration (format, present mode, etc.)
It also manages the depth buffer texture which is recreated on resize.
Fields§
§device: DeviceThe wgpu device for GPU operations
queue: QueueThe command queue for submitting work
surface: Surface<'static>The window surface for presentation
config: SurfaceConfiguration<Vec<TextureFormat>>Surface configuration
depth_format: TextureFormatDepth buffer format
surface_view_format: TextureFormat§msaa_samples: u32§anisotropy_clamp: u16§render_path: RenderPathThe active render path. Stored for runtime branching in the frame graph.
pipeline_settings_version: u64Version counter for pipeline-affecting settings (HDR, MSAA, RenderPath). Incremented when these settings change, used to invalidate L1 pipeline cache.
Implementations§
Source§impl WgpuContext
impl WgpuContext
pub async fn new<W>( window: W, init_config: &RendererInitConfig, settings: &RendererSettings, width: u32, height: u32, ) -> Result<WgpuContext, Error>
pub fn resize(&mut self, width: u32, height: u32)
Sourcepub fn set_vsync(&mut self, vsync: bool)
pub fn set_vsync(&mut self, vsync: bool)
Dynamically reconfigure the surface present mode for VSync toggling.
This is a lightweight operation — only the surface configuration is resubmitted; no GPU resources are destroyed or recreated.
pub fn create_depth_texture( device: &Device, config: &SurfaceConfiguration<Vec<TextureFormat>>, format: TextureFormat, ) -> TextureView
Auto Trait Implementations§
impl !Freeze for WgpuContext
impl !RefUnwindSafe for WgpuContext
impl Send for WgpuContext
impl Sync for WgpuContext
impl Unpin for WgpuContext
impl UnsafeUnpin for WgpuContext
impl !UnwindSafe for WgpuContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.