pub struct State { /* private fields */ }Implementations§
Source§impl State
impl State
Sourcepub async fn new<T: WindowSize>(builder: StateBuilder<T>) -> Result<Self>
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.
Sourcepub fn create_pipeline_layout(
&self,
bind_group_layouts: &[&BindGroupLayout],
push_constant_ranges: &[PushConstantRange],
) -> PipelineLayout
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
Sourcepub fn create_pipeline(&self, builder: PipelineBuilder<'_>) -> RenderPipeline
pub fn create_pipeline(&self, builder: PipelineBuilder<'_>) -> RenderPipeline
Helper method to create a pipeline from its builder
Sourcepub fn create_shader(&self, src: ShaderSource<'_>) -> ShaderModule
pub fn create_shader(&self, src: ShaderSource<'_>) -> ShaderModule
Creates a shader module from its src
Sourcepub fn resize(&self, size: impl Into<(u32, u32)>) -> bool
pub fn resize(&self, size: impl Into<(u32, u32)>) -> bool
Returns whether the resizing succeeded or not
Sourcepub fn render<F: FnOnce(&TextureView, CommandEncoder, &State) -> CommandEncoder>(
&self,
callback: F,
surface_view_desc: &TextureViewDescriptor<'_>,
) -> Result<(), SurfaceError>
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.
Sourcepub fn create_render_pass<'a>(
&self,
encoder: &'a mut CommandEncoder,
color_attachments: &'a [Option<RenderPassColorAttachment<'a>>],
depth_stencil_attachment: Option<RenderPassDepthStencilAttachment<'a>>,
) -> RenderPass<'a>
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
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
Returns the format defined in the config
Sourcepub fn try_update_present_mode(&self, present_mode: PresentMode) -> bool
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
Sourcepub fn update_present_mode(&self, present_mode: PresentMode)
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
Sourcepub const fn adapter(&self) -> &Adapter
pub const fn adapter(&self) -> &Adapter
Returns a reference to the adapter which can be used to acquire information
Sourcepub fn create_buffer<T: Pod>(
&self,
content: &[T],
usage: BufferUsages,
) -> Buffer
pub fn create_buffer<T: Pod>( &self, content: &[T], usage: BufferUsages, ) -> Buffer
Helper method to create a buffer from its content and usage
Sourcepub fn create_texture(&self, builder: TextureBuilder<'_>) -> Texture
pub fn create_texture(&self, builder: TextureBuilder<'_>) -> Texture
Helper method to create a texture from its builder
Sourcepub fn create_bind_group_layout(
&self,
entries: &[BindGroupLayoutEntry],
) -> BindGroupLayout
pub fn create_bind_group_layout( &self, entries: &[BindGroupLayoutEntry], ) -> BindGroupLayout
Helper method to create a BindGroupLayoutEntry from its entries
Sourcepub fn create_bind_group(
&self,
layout: &BindGroupLayout,
entries: &[BindGroupEntry<'_>],
) -> BindGroup
pub fn create_bind_group( &self, layout: &BindGroupLayout, entries: &[BindGroupEntry<'_>], ) -> BindGroup
Helper method to create a BindGroup from its layout and entries
Sourcepub fn write_buffer<T: Pod>(
&self,
buffer: &Buffer,
offset: BufferAddress,
data: &[T],
)
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
Sourcepub fn create_depth_texture(&self, format: TextureFormat) -> Texture
pub fn create_depth_texture(&self, format: TextureFormat) -> Texture
Helper method to create a depth texture from its format