Skip to content

Commit

Permalink
Move TextureDataOrder to wgpu-types
Browse files Browse the repository at this point in the history
  • Loading branch information
atlv24 committed Dec 3, 2024
1 parent 02b28e2 commit d8ba712
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
28 changes: 28 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,34 @@ bitflags::bitflags! {
}
}

/// Order in which TextureData is laid out in memory.
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
pub enum TextureDataOrder {
/// The texture is laid out densely in memory as:
///
/// ```text
/// Layer0Mip0 Layer0Mip1 Layer0Mip2
/// Layer1Mip0 Layer1Mip1 Layer1Mip2
/// Layer2Mip0 Layer2Mip1 Layer2Mip2
/// ````
///
/// This is the layout used by dds files.
///
/// This was the previous behavior of [`DeviceExt::create_texture_with_data`].
#[default]
LayerMajor,
/// The texture is laid out densely in memory as:
///
/// ```text
/// Layer0Mip0 Layer1Mip0 Layer2Mip0
/// Layer0Mip1 Layer1Mip1 Layer2Mip1
/// Layer0Mip2 Layer1Mip2 Layer2Mip2
/// ```
///
/// This is the layout used by ktx and ktx2 files.
MipMajor,
}

/// Dimensions of a particular texture view.
///
/// Corresponds to [WebGPU `GPUTextureViewDimension`](
Expand Down
30 changes: 2 additions & 28 deletions wgpu/src/util/device.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use wgt::TextureDataOrder;

/// Describes a [Buffer](crate::Buffer) when allocating.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct BufferInitDescriptor<'a> {
Expand All @@ -10,34 +12,6 @@ pub struct BufferInitDescriptor<'a> {
pub usage: crate::BufferUsages,
}

/// Order in which TextureData is laid out in memory.
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
pub enum TextureDataOrder {
/// The texture is laid out densely in memory as:
///
/// ```text
/// Layer0Mip0 Layer0Mip1 Layer0Mip2
/// Layer1Mip0 Layer1Mip1 Layer1Mip2
/// Layer2Mip0 Layer2Mip1 Layer2Mip2
/// ````
///
/// This is the layout used by dds files.
///
/// This was the previous behavior of [`DeviceExt::create_texture_with_data`].
#[default]
LayerMajor,
/// The texture is laid out densely in memory as:
///
/// ```text
/// Layer0Mip0 Layer1Mip0 Layer2Mip0
/// Layer0Mip1 Layer1Mip1 Layer2Mip1
/// Layer0Mip2 Layer1Mip2 Layer2Mip2
/// ```
///
/// This is the layout used by ktx and ktx2 files.
MipMajor,
}

/// Utility methods not meant to be in the main API.
pub trait DeviceExt {
/// Creates a [Buffer](crate::Buffer) with data to initialize it.
Expand Down
6 changes: 4 additions & 2 deletions wgpu/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ use std::{
};

pub use belt::StagingBelt;
pub use device::{BufferInitDescriptor, DeviceExt, TextureDataOrder};
pub use device::{BufferInitDescriptor, DeviceExt};
pub use encoder::RenderEncoder;
pub use init::*;
pub use wgt::{math::*, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs};
pub use wgt::{
math::*, DispatchIndirectArgs, DrawIndexedIndirectArgs, DrawIndirectArgs, TextureDataOrder,
};

/// Treat the given byte slice as a SPIR-V module.
///
Expand Down

0 comments on commit d8ba712

Please sign in to comment.