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: GpuQueueImplementations§
Source§impl GpuDevice
impl GpuDevice
Sourcepub fn new(width: u32, height: u32, format: SwapchainFormat) -> Self
pub fn new(width: u32, height: u32, format: SwapchainFormat) -> Self
Initializes a hardware GPU device for the active platform.
Sourcepub fn create_buffer(
&self,
size: usize,
usage: GpuBufferUsage,
) -> GpuBufferHandle
pub fn create_buffer( &self, size: usize, usage: GpuBufferUsage, ) -> GpuBufferHandle
Allocates a new VRAM buffer.
Sourcepub fn create_buffer_with_location(
&self,
size: usize,
usage: GpuBufferUsage,
location: GpuMemoryLocation,
) -> GpuBufferHandle
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).
Sourcepub fn create_staging_buffer(&self, size: usize) -> GpuBufferHandle
pub fn create_staging_buffer(&self, size: usize) -> GpuBufferHandle
Allocates a new staging ring buffer for DMA transfers.
Sourcepub fn create_texture(
&self,
width: u32,
height: u32,
format: SwapchainFormat,
is_depth: bool,
) -> GpuTextureHandle
pub fn create_texture( &self, width: u32, height: u32, format: SwapchainFormat, is_depth: bool, ) -> GpuTextureHandle
Allocates a new 2D GPU texture.
Sourcepub fn create_command_encoder(&self) -> GpuCommandEncoder
pub fn create_command_encoder(&self) -> GpuCommandEncoder
Creates a command encoder for submitting GPU commands.
Sourcepub fn copy_buffer_to_buffer(
&self,
src: &GpuBufferHandle,
src_offset: usize,
dst: &mut GpuBufferHandle,
dst_offset: usize,
size: usize,
) -> Result<(), PresentError>
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.
Sourcepub fn copy_buffer_to_texture(
&self,
src: &GpuBufferHandle,
src_offset: usize,
dst: &mut GpuTextureHandle,
) -> Result<(), PresentError>
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.
Sourcepub fn copy_texture_to_buffer(
&self,
src: &GpuTextureHandle,
dst: &mut GpuBufferHandle,
dst_offset: usize,
) -> Result<(), PresentError>
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.
Sourcepub fn readback_texture(&self, texture: &GpuTextureHandle) -> Vec<u8> ⓘ
pub fn readback_texture(&self, texture: &GpuTextureHandle) -> Vec<u8> ⓘ
Reads back RGBA pixel bytes from a GPU texture.
Sourcepub fn readback_swapchain(&self) -> Vec<u8> ⓘ
pub fn readback_swapchain(&self) -> Vec<u8> ⓘ
Reads back swapchain color buffer pixels into CPU memory.
Sourcepub fn readback_depth(&self) -> Vec<f32>
pub fn readback_depth(&self) -> Vec<f32>
Reads back 32-bit floating-point depth buffer values into CPU memory.
Sourcepub fn resize(&mut self, width: u32, height: u32) -> Result<(), PresentError>
pub fn resize(&mut self, width: u32, height: u32) -> Result<(), PresentError>
Resizes the hardware swapchain and depth attachments.
Sourcepub fn submit(&mut self, encoder: GpuCommandEncoder)
pub fn submit(&mut self, encoder: GpuCommandEncoder)
Submits recorded commands and advances the swapchain frame.