pub struct GpuBuffer {
pub id: u64,
pub usage: BufferUsage,
pub label: Option<String>,
/* private fields */
}Expand description
A logical GPU buffer (CPU-side descriptor; no actual WGPU resource here).
Fields§
§id: u64Unique identifier assigned by the pool.
usage: BufferUsageIntended usage.
label: Option<String>Debug label shown in GPU profiling tools.
Implementations§
Source§impl GpuBuffer
impl GpuBuffer
Sourcepub fn new(id: u64, usage: BufferUsage, size: usize) -> Self
pub fn new(id: u64, usage: BufferUsage, size: usize) -> Self
Creates a new GPU buffer descriptor.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Creates a buffer with a debug label.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Returns the buffer size in bytes.
Sourcepub fn map(&mut self) -> Result<(), String>
pub fn map(&mut self) -> Result<(), String>
Simulates mapping the buffer for CPU access.
Returns an error string if the buffer usage does not allow mapping.
Sourcepub fn aligned_size(&self) -> usize
pub fn aligned_size(&self) -> usize
Returns the size in 4-byte aligned units (useful for uniform offsets).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuBuffer
impl RefUnwindSafe for GpuBuffer
impl Send for GpuBuffer
impl Sync for GpuBuffer
impl Unpin for GpuBuffer
impl UnsafeUnpin for GpuBuffer
impl UnwindSafe for GpuBuffer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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