From 86c4269a24e2aff3ddbb83a2c38e19ee419279bd Mon Sep 17 00:00:00 2001 From: atlas Date: Mon, 2 Dec 2024 23:39:08 -0500 Subject: [PATCH] Move TextureDataOrder to wgpu-types --- wgpu-types/src/lib.rs | 26 ++++++++++++++++++++++++++ wgpu/src/util/device.rs | 30 ++---------------------------- wgpu/src/util/mod.rs | 6 ++++-- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 21c52c24ec..8fff731bd2 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1893,6 +1893,32 @@ 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. + #[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`]( diff --git a/wgpu/src/util/device.rs b/wgpu/src/util/device.rs index 3abff00bb7..9e087cb7a2 100644 --- a/wgpu/src/util/device.rs +++ b/wgpu/src/util/device.rs @@ -1,3 +1,5 @@ +use wgt::TextureDataOrder; + /// Describes a [Buffer](crate::Buffer) when allocating. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct BufferInitDescriptor<'a> { @@ -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. diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs index 11148179b4..9a1e643761 100644 --- a/wgpu/src/util/mod.rs +++ b/wgpu/src/util/mod.rs @@ -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. ///