Skip to main content

ComputeBackend

Trait ComputeBackend 

Source
pub trait ComputeBackend: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn gpu_info(&self) -> &GpuInfo;
    fn decompress_tiles(
        &self,
        tiles: &[CompressedTile],
        cancel: &AtomicBool,
    ) -> Result<Vec<Vec<u8>>>;
    fn decompress_tiles_gdeflate(
        &self,
        tiles: &[CompressedTile],
        cancel: &AtomicBool,
    ) -> Result<Vec<Vec<u8>>>;
    fn release(&self);
}
Expand description

Abstraction over GPU compute backends (wgpu, CUDA).

All methods that can fail return crush_core::error::Result so the engine can decide whether to fall back to CPU.

Required Methods§

Source

fn name(&self) -> &str

Backend display name (e.g. “wgpu-Vulkan”, “CUDA”).

Source

fn gpu_info(&self) -> &GpuInfo

Information about the GPU selected by this backend.

Source

fn decompress_tiles( &self, tiles: &[CompressedTile], cancel: &AtomicBool, ) -> Result<Vec<Vec<u8>>>

Decompress a batch of compressed tiles on the GPU.

Returns one Vec<u8> per input tile in the same order.

§Cancellation

Implementations should check cancel between tile batches and return CrushError::Cancelled when set.

§Errors

May return any GPU error variant wrapped in a CrushError.

Source

fn decompress_tiles_gdeflate( &self, tiles: &[CompressedTile], cancel: &AtomicBool, ) -> Result<Vec<Vec<u8>>>

Decompress a batch of GDeflate-encoded tiles on the GPU.

Returns one Vec<u8> per input tile in the same order. The output is already in the correct byte order (no de-interleaving).

§Cancellation

Implementations should check cancel between tile dispatches and return CrushError::Cancelled when set.

§Errors

May return any GPU error variant wrapped in a CrushError.

Source

fn release(&self)

Release GPU resources held by this backend.

Implementors§