pub trait DeviceBackend {
Show 18 methods
// Required methods
fn api_name(&self) -> &str;
fn stats(&self) -> GpuStats;
fn reset_stats(&mut self);
fn create_pipeline(
&mut self,
vertex_source: &[u8],
fragment_source: &[u8],
vertex_attrs: &[VertexAttr],
texture_locations: &[(u32, String)],
options: PipelineOptions,
) -> Result<u64, String>;
fn create_vertex_buffer(
&mut self,
attrs: &[VertexAttr],
step_mode: VertexStepMode,
) -> Result<u64, String>;
fn create_index_buffer(
&mut self,
format: IndexFormat,
) -> Result<u64, String>;
fn create_uniform_buffer(
&mut self,
slot: u32,
name: &str,
) -> Result<u64, String>;
fn set_buffer_data(&mut self, buffer: u64, data: &[u8]);
fn render(&mut self, commands: &[Commands], target: Option<u64>);
fn clean(&mut self, to_clean: &[ResourceId]);
fn set_size(&mut self, width: u32, height: u32);
fn set_dpi(&mut self, scale_factor: f64);
fn create_texture(
&mut self,
source: TextureSourceKind,
info: TextureInfo,
) -> Result<(u64, TextureInfo), String>;
fn create_render_texture(
&mut self,
texture_id: u64,
info: &TextureInfo,
) -> Result<u64, String>;
fn update_texture(
&mut self,
texture: u64,
source: TextureUpdaterSourceKind<'_>,
opts: TextureUpdate,
) -> Result<(), String>;
fn read_pixels(
&mut self,
texture: u64,
bytes: &mut [u8],
opts: &TextureRead,
) -> Result<(), String>;
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
// Provided method
fn limits(&self) -> Limits { ... }
}Expand description
Represents a the implementation graphics backend like glow, wgpu or another
Required Methods§
Sourcefn reset_stats(&mut self)
fn reset_stats(&mut self)
Reset the GPU stats
Sourcefn create_pipeline(
&mut self,
vertex_source: &[u8],
fragment_source: &[u8],
vertex_attrs: &[VertexAttr],
texture_locations: &[(u32, String)],
options: PipelineOptions,
) -> Result<u64, String>
fn create_pipeline( &mut self, vertex_source: &[u8], fragment_source: &[u8], vertex_attrs: &[VertexAttr], texture_locations: &[(u32, String)], options: PipelineOptions, ) -> Result<u64, String>
Create a new pipeline and returns the id
Sourcefn create_vertex_buffer(
&mut self,
attrs: &[VertexAttr],
step_mode: VertexStepMode,
) -> Result<u64, String>
fn create_vertex_buffer( &mut self, attrs: &[VertexAttr], step_mode: VertexStepMode, ) -> Result<u64, String>
Create a new vertex buffer object and returns the id
Sourcefn create_index_buffer(&mut self, format: IndexFormat) -> Result<u64, String>
fn create_index_buffer(&mut self, format: IndexFormat) -> Result<u64, String>
Create a new index buffer object and returns the id
Sourcefn create_uniform_buffer(
&mut self,
slot: u32,
name: &str,
) -> Result<u64, String>
fn create_uniform_buffer( &mut self, slot: u32, name: &str, ) -> Result<u64, String>
Create a new uniform buffer and returns the id
Sourcefn set_buffer_data(&mut self, buffer: u64, data: &[u8])
fn set_buffer_data(&mut self, buffer: u64, data: &[u8])
Upload to the GPU the buffer data slice
Sourcefn render(&mut self, commands: &[Commands], target: Option<u64>)
fn render(&mut self, commands: &[Commands], target: Option<u64>)
Create a new renderer using the size of the graphics
Sourcefn clean(&mut self, to_clean: &[ResourceId])
fn clean(&mut self, to_clean: &[ResourceId])
Clean all the dropped resources
Sourcefn create_texture(
&mut self,
source: TextureSourceKind,
info: TextureInfo,
) -> Result<(u64, TextureInfo), String>
fn create_texture( &mut self, source: TextureSourceKind, info: TextureInfo, ) -> Result<(u64, TextureInfo), String>
Create a new texture and returns the id
Sourcefn create_render_texture(
&mut self,
texture_id: u64,
info: &TextureInfo,
) -> Result<u64, String>
fn create_render_texture( &mut self, texture_id: u64, info: &TextureInfo, ) -> Result<u64, String>
Create a new render target and returns the id
Sourcefn update_texture(
&mut self,
texture: u64,
source: TextureUpdaterSourceKind<'_>,
opts: TextureUpdate,
) -> Result<(), String>
fn update_texture( &mut self, texture: u64, source: TextureUpdaterSourceKind<'_>, opts: TextureUpdate, ) -> Result<(), String>
Update texture data
Sourcefn read_pixels(
&mut self,
texture: u64,
bytes: &mut [u8],
opts: &TextureRead,
) -> Result<(), String>
fn read_pixels( &mut self, texture: u64, bytes: &mut [u8], opts: &TextureRead, ) -> Result<(), String>
Read texture pixels