pub struct GpuDevice { /* private fields */ }Expand description
Implementations§
Source§impl GpuDevice
impl GpuDevice
Sourcepub async fn is_gpu_available() -> bool
pub async fn is_gpu_available() -> bool
Check if GPU is available without creating a device
This is useful for tests to skip gracefully when GPU is not available.
Sourcepub async fn new() -> Result<Self, GpuDeviceError>
pub async fn new() -> Result<Self, GpuDeviceError>
Initialize GPU device with default settings
§Errors
Returns GpuDeviceError if:
- No compatible GPU adapter found
- Device request fails
- Required features not supported
Sourcepub async fn new_with_backend(
backends: Backends,
) -> Result<Self, GpuDeviceError>
pub async fn new_with_backend( backends: Backends, ) -> Result<Self, GpuDeviceError>
Initialize GPU device with specific backend
§Errors
Returns GpuDeviceError if device initialization fails
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check if GPU is available
Sourcepub fn info(&self) -> AdapterInfo
pub fn info(&self) -> AdapterInfo
Get adapter info (GPU name, backend, etc.)
Sourcepub fn create_buffer_init(
&self,
label: &str,
contents: &[u8],
usage: BufferUsages,
) -> Result<Buffer, GpuDeviceError>
pub fn create_buffer_init( &self, label: &str, contents: &[u8], usage: BufferUsages, ) -> Result<Buffer, GpuDeviceError>
Create GPU buffer with initial data
§Errors
Returns error if buffer creation fails (typically won’t happen with wgpu)
Sourcepub fn create_buffer(
&self,
label: &str,
size: u64,
usage: BufferUsages,
) -> Result<Buffer, GpuDeviceError>
pub fn create_buffer( &self, label: &str, size: u64, usage: BufferUsages, ) -> Result<Buffer, GpuDeviceError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GpuDevice
impl !UnwindSafe for GpuDevice
impl Freeze for GpuDevice
impl Send for GpuDevice
impl Sync for GpuDevice
impl Unpin for GpuDevice
impl UnsafeUnpin for GpuDevice
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more