Skip to main content

State

Struct State 

Source
pub struct State { /* private fields */ }

Implementations§

Source§

impl State

Source

pub async fn new<T: WindowSize>(builder: StateBuilder<T>) -> Result<Self>

Tries to create a new State from a StateBuilder

returns either the newly created state or an error if requesting an adapter or device fails.

Source

pub fn create_pipeline_layout( &self, bind_group_layouts: &[&BindGroupLayout], push_constant_ranges: &[PushConstantRange], ) -> PipelineLayout

Creates a new pipeline layout from its bind group layouts and its push constant ranges

Source

pub fn create_pipeline(&self, builder: PipelineBuilder<'_>) -> RenderPipeline

Helper method to create a pipeline from its builder

Source

pub fn create_shader(&self, src: ShaderSource<'_>) -> ShaderModule

Creates a shader module from its src

Source

pub fn resize(&self, size: impl Into<(u32, u32)>) -> bool

Returns whether the resizing succeeded or not

Source

pub fn render<F: FnOnce(&TextureView, CommandEncoder, &State) -> CommandEncoder>( &self, callback: F, surface_view_desc: &TextureViewDescriptor<'_>, ) -> Result<(), SurfaceError>

Initiates the rendering process, the passed callback gets called once all the required state is set up and once it ran, all the required steps to proceed get executed.

Source

pub fn create_render_pass<'a>( &self, encoder: &'a mut CommandEncoder, color_attachments: &'a [Option<RenderPassColorAttachment<'a>>], depth_stencil_attachment: Option<RenderPassDepthStencilAttachment<'a>>, ) -> RenderPass<'a>

Helper method to create a render pass in the encoder

Source

pub fn size(&self) -> (u32, u32)

Returns the size defined in the config

Source

pub fn format(&self) -> TextureFormat

Returns the format defined in the config

Source

pub fn try_update_present_mode(&self, present_mode: PresentMode) -> bool

Tries to update the present mode of the surface. Returns whether update succeeded or not

Source

pub fn update_present_mode(&self, present_mode: PresentMode)

Updates the present mode of the surface Note: this function will wait until the render call has finished

Source

pub const fn device(&self) -> &Device

Returns a reference to the device

Source

pub const fn queue(&self) -> &Queue

Returns a reference to the queue

Source

pub const fn surface(&self) -> &Surface

Returns a reference to the surface

Source

pub const fn adapter(&self) -> &Adapter

Returns a reference to the adapter which can be used to acquire information

Source

pub fn create_buffer<T: Pod>( &self, content: &[T], usage: BufferUsages, ) -> Buffer

Helper method to create a buffer from its content and usage

Source

pub fn create_texture(&self, builder: TextureBuilder<'_>) -> Texture

Helper method to create a texture from its builder

Source

pub fn create_bind_group_layout( &self, entries: &[BindGroupLayoutEntry], ) -> BindGroupLayout

Helper method to create a BindGroupLayoutEntry from its entries

Source

pub fn create_bind_group( &self, layout: &BindGroupLayout, entries: &[BindGroupEntry<'_>], ) -> BindGroup

Helper method to create a BindGroup from its layout and entries

Source

pub fn write_buffer<T: Pod>( &self, buffer: &Buffer, offset: BufferAddress, data: &[T], )

Helper method to write data to a buffer at a specific offset

Source

pub fn create_depth_texture(&self, format: TextureFormat) -> Texture

Helper method to create a depth texture from its format

Auto Trait Implementations§

§

impl !Freeze for State

§

impl !RefUnwindSafe for State

§

impl !UnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>