pub struct SoftwareContext { /* private fields */ }Expand description
Pure-CPU backend that stores everything in RAM. Useful for tests, CI, headless rendering, and platforms without any GPU API.
Implementations§
Source§impl SoftwareContext
impl SoftwareContext
pub fn new() -> Self
Sourcepub fn command_count(&self) -> usize
pub fn command_count(&self) -> usize
Number of recorded (but not yet cleared) commands.
Sourcepub fn drain_commands(&mut self) -> Vec<GpuCommand>
pub fn drain_commands(&mut self) -> Vec<GpuCommand>
Drain the recorded commands for inspection.
Trait Implementations§
Source§impl BackendContext for SoftwareContext
impl BackendContext for SoftwareContext
Source§fn create_buffer(&mut self, size: usize, usage: BufferUsage) -> BufferHandle
fn create_buffer(&mut self, size: usize, usage: BufferUsage) -> BufferHandle
Create a GPU buffer and return its handle.
Source§fn create_texture(
&mut self,
width: u32,
height: u32,
format: TextureFormat,
) -> TextureHandle
fn create_texture( &mut self, width: u32, height: u32, format: TextureFormat, ) -> TextureHandle
Create a 2-D texture.
Source§fn create_shader(&mut self, source: &str, stage: ShaderStage) -> ShaderHandle
fn create_shader(&mut self, source: &str, stage: ShaderStage) -> ShaderHandle
Compile / upload a shader module.
Source§fn create_pipeline(
&mut self,
_vertex: ShaderHandle,
_fragment: ShaderHandle,
_layout: &PipelineLayout,
) -> PipelineHandle
fn create_pipeline( &mut self, _vertex: ShaderHandle, _fragment: ShaderHandle, _layout: &PipelineLayout, ) -> PipelineHandle
Create a render pipeline (vertex + fragment).
Source§fn create_compute_pipeline(
&mut self,
_shader: ShaderHandle,
_layout: &PipelineLayout,
) -> ComputePipelineHandle
fn create_compute_pipeline( &mut self, _shader: ShaderHandle, _layout: &PipelineLayout, ) -> ComputePipelineHandle
Create a compute pipeline.
Source§fn submit(&mut self, commands: &[GpuCommand])
fn submit(&mut self, commands: &[GpuCommand])
Submit a batch of GPU commands.
Source§fn write_buffer(&mut self, buffer: BufferHandle, data: &[u8])
fn write_buffer(&mut self, buffer: BufferHandle, data: &[u8])
Write raw data into a buffer.
Source§fn read_buffer(&self, buffer: BufferHandle) -> Vec<u8> ⓘ
fn read_buffer(&self, buffer: BufferHandle) -> Vec<u8> ⓘ
Read raw data back from a buffer.
Source§fn write_texture(&mut self, texture: TextureHandle, data: &[u8])
fn write_texture(&mut self, texture: TextureHandle, data: &[u8])
Write raw pixel data into a texture.
Source§fn read_texture(&self, texture: TextureHandle) -> Vec<u8> ⓘ
fn read_texture(&self, texture: TextureHandle) -> Vec<u8> ⓘ
Read raw pixel data from a texture.
Source§fn destroy_buffer(&mut self, buffer: BufferHandle)
fn destroy_buffer(&mut self, buffer: BufferHandle)
Destroy a buffer, freeing its resources.
Source§fn destroy_texture(&mut self, texture: TextureHandle)
fn destroy_texture(&mut self, texture: TextureHandle)
Destroy a texture, freeing its resources.
Auto Trait Implementations§
impl Freeze for SoftwareContext
impl RefUnwindSafe for SoftwareContext
impl Send for SoftwareContext
impl Sync for SoftwareContext
impl Unpin for SoftwareContext
impl UnsafeUnpin for SoftwareContext
impl UnwindSafe for SoftwareContext
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.