Skip to main content

GpuDevice

Struct GpuDevice 

Source
pub struct GpuDevice {
    pub backend: GpuBackend,
    pub adapter_name: String,
    pub swapchain_width: u32,
    pub swapchain_height: u32,
    pub swapchain_format: SwapchainFormat,
    pub swapchain_texture: GpuTextureHandle,
    pub depth_texture: GpuTextureHandle,
    pub frame_index: u64,
    pub queue: GpuQueue,
}
Expand description

Hardware GPU Device managing resources, command queues, and swapchain presentation.

Fields§

§backend: GpuBackend§adapter_name: String§swapchain_width: u32§swapchain_height: u32§swapchain_format: SwapchainFormat§swapchain_texture: GpuTextureHandle§depth_texture: GpuTextureHandle§frame_index: u64§queue: GpuQueue

Implementations§

Source§

impl GpuDevice

Source

pub fn new(width: u32, height: u32, format: SwapchainFormat) -> Self

Initializes a hardware GPU device for the active platform.

Source

pub fn create_buffer( &self, size: usize, usage: GpuBufferUsage, ) -> GpuBufferHandle

Allocates a new VRAM buffer.

Source

pub fn create_buffer_with_location( &self, size: usize, usage: GpuBufferUsage, location: GpuMemoryLocation, ) -> GpuBufferHandle

Allocates a new VRAM buffer with explicit memory location (device-local, host-visible, staging).

Source

pub fn create_staging_buffer(&self, size: usize) -> GpuBufferHandle

Allocates a new staging ring buffer for DMA transfers.

Source

pub fn create_texture( &self, width: u32, height: u32, format: SwapchainFormat, is_depth: bool, ) -> GpuTextureHandle

Allocates a new 2D GPU texture.

Source

pub fn create_command_encoder(&self) -> GpuCommandEncoder

Creates a command encoder for submitting GPU commands.

Source

pub fn copy_buffer_to_buffer( &self, src: &GpuBufferHandle, src_offset: usize, dst: &mut GpuBufferHandle, dst_offset: usize, size: usize, ) -> Result<(), PresentError>

Copies data between two GPU VRAM buffers.

Source

pub fn copy_buffer_to_texture( &self, src: &GpuBufferHandle, src_offset: usize, dst: &mut GpuTextureHandle, ) -> Result<(), PresentError>

Copies data from a GPU buffer into a 2D texture.

Source

pub fn copy_texture_to_buffer( &self, src: &GpuTextureHandle, dst: &mut GpuBufferHandle, dst_offset: usize, ) -> Result<(), PresentError>

Copies data from a 2D texture into a GPU staging buffer.

Source

pub fn readback_texture(&self, texture: &GpuTextureHandle) -> Vec<u8> ⓘ

Reads back RGBA pixel bytes from a GPU texture.

Source

pub fn readback_swapchain(&self) -> Vec<u8> ⓘ

Reads back swapchain color buffer pixels into CPU memory.

Source

pub fn readback_depth(&self) -> Vec<f32>

Reads back 32-bit floating-point depth buffer values into CPU memory.

Source

pub fn resize(&mut self, width: u32, height: u32) -> Result<(), PresentError>

Resizes the hardware swapchain and depth attachments.

Source

pub fn submit(&mut self, encoder: GpuCommandEncoder)

Submits recorded commands and advances the swapchain frame.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoInitialState<T> for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,