pub struct Texture2DBufferInfo {
pub bytes_per_row_unpadded: u32,
pub bytes_per_row_padded: u32,
pub buffer_size_unpadded: BufferAddress,
pub buffer_size_padded: BufferAddress,
}Expand description
Utility for dealing with buffers containing raw 2D texture data.
Fields§
§bytes_per_row_unpadded: u32How many bytes per row contain actual data.
bytes_per_row_padded: u32How many bytes per row are required to be allocated in total.
Padding bytes are always at the end of a row.
buffer_size_unpadded: BufferAddressSize required for an unpadded buffer.
buffer_size_padded: BufferAddressSize required for a padded buffer as it is read/written from/to the GPU.
Implementations§
Source§impl Texture2DBufferInfo
impl Texture2DBufferInfo
Sourcepub fn new(format: TextureFormat, extent: Extent3d) -> Self
pub fn new(format: TextureFormat, extent: Extent3d) -> Self
Retrieves 2D texture buffer info for a given format & texture size.
If a single buffer is not possible for all aspects of the texture format, all sizes will be zero.
pub fn from_texture(texture: &Texture) -> Self
pub fn num_rows(&self) -> u32
Sourcepub fn remove_padding<'a>(&self, buffer: &'a [u8]) -> Cow<'a, [u8]>
pub fn remove_padding<'a>(&self, buffer: &'a [u8]) -> Cow<'a, [u8]>
Removes the padding from a buffer containing gpu texture data.
The passed in buffer is to be expected to be exactly of size Texture2DBufferInfo::buffer_size_padded.
Note that if you’re passing in gpu data, there no alignment guarantees on the returned slice,
do NOT convert it using bytemuck. Use Texture2DBufferInfo::remove_padding_and_convert instead.
Sourcepub fn remove_padding_and_convert<T: Pod>(&self, buffer: &[u8]) -> Vec<T>
pub fn remove_padding_and_convert<T: Pod>(&self, buffer: &[u8]) -> Vec<T>
Removes the padding from a buffer containing gpu texture data and remove convert to a given type.
The passed in buffer is to be expected to be exactly of size Texture2DBufferInfo::buffer_size_padded.
The unpadded row size is expected to be a multiple of the size of the target type. (Which means that, while uncommon, it technically doesn’t need to be as big as a block in the pixel - this can be useful for e.g. packing wide bitfields)
Trait Implementations§
Source§impl Clone for Texture2DBufferInfo
impl Clone for Texture2DBufferInfo
Source§fn clone(&self) -> Texture2DBufferInfo
fn clone(&self) -> Texture2DBufferInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Texture2DBufferInfo
impl RefUnwindSafe for Texture2DBufferInfo
impl Send for Texture2DBufferInfo
impl Sync for Texture2DBufferInfo
impl Unpin for Texture2DBufferInfo
impl UnsafeUnpin for Texture2DBufferInfo
impl UnwindSafe for Texture2DBufferInfo
Blanket Implementations§
impl<T> Allocation for T
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
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>
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>
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