Skip to main content

is_gpu_buffer_available

Function is_gpu_buffer_available 

Source
pub fn is_gpu_buffer_available() -> bool
Expand description

Portable probe for the platform’s native zero-copy GPU buffer allocator (DMA-BUF on Linux, IOSurface on macOS/iOS, AHardwareBuffer on Android, D3D11 textures on Windows). Returns false on platforms with no equivalent. Use this when writing cross-platform code that cares whether the Dma tensor variant will work, not which underlying mechanism is used.

On Windows the Dma variant is image-formatted: true here means Tensor::image can serve TensorMemory::DmaBuf, not Tensor::new.

§Ordering on Windows

This probe creates the process D3D11 device, because the only honest answer to “can this host allocate one” is to try. A host that must supply its own device calls d3d11::use_external_device before this probe or any allocation: the device is cached on first creation and installing one afterwards is refused.