pub struct CpuTexture {
pub pixels: Vec<u8>,
pub size: Extent3D,
pub format: TextureFormat,
pub mip_level_count: u32,
pub sample_count: SampleCount,
pub dimension: TextureDimension,
pub usage: TextureUsage,
}Expand description
A CPU-side representation of a decoded texture, ready to be uploaded to the GPU.
Fields§
§pixels: Vec<u8>The raw pixel data (e.g., in RGBA format)
size: Extent3DThe size of the texture
format: TextureFormatThe format of the pixel data
mip_level_count: u32The number of mip levels
sample_count: SampleCountThe number of samples per pixel
dimension: TextureDimensionThe dimensionality of the texture
usage: TextureUsageThe allowed usages for the future GPU texture
Implementations§
Source§impl CpuTexture
impl CpuTexture
Sourcepub fn from_rgba32f(width: u32, height: u32, rgba: &[f32]) -> Option<Self>
pub fn from_rgba32f(width: u32, height: u32, rgba: &[f32]) -> Option<Self>
Builds an HDR texture from linear f32 RGBA channels, packed to
Rgba16Float.
rgba is row-major, 4 channels per pixel, and must hold exactly
width * height * 4 values. Half-float keeps values above 1.0 (the
point of HDR) while staying filterable on every backend, unlike 32-bit
float. Use for procedurally generated HDR content — an environment map,
a lookup table — that does not come from a decoded file.
Returns None if rgba’s length does not match width * height * 4.
Sourcepub fn to_descriptor<'a>(
&self,
label: Option<Cow<'a, str>>,
) -> TextureDescriptor<'a>
pub fn to_descriptor<'a>( &self, label: Option<Cow<'a, str>>, ) -> TextureDescriptor<'a>
Creates a texture descriptor from this CPU texture data