Skip to content

Commit 9940aef

Browse files
committed
Move some types into shared wgpu-types crate
1 parent 40889df commit 9940aef

28 files changed

+735
-633
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ members = [
33
"wgpu-core",
44
"wgpu-native",
55
"wgpu-remote",
6+
"wgpu-types",
67
]

wgpu-core/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ license = "MPL-2.0"
1717
[features]
1818
default = []
1919
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
20+
serde1 = ["wgt/serde"]
2021
#NOTE: glutin feature is not stable, use at your own risk
2122
#glutin = ["gfx-backend-gl/glutin"]
2223

@@ -36,6 +37,11 @@ serde = { version = "1.0", features = ["serde_derive"], optional = true }
3637
smallvec = "1.0"
3738
vec_map = "0.8"
3839

40+
[dependencies.wgt]
41+
path = "../wgpu-types"
42+
package = "wgpu-types"
43+
version = "0.1"
44+
3945
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
4046
gfx-backend-metal = { version = "0.4" }
4147
gfx-backend-vulkan = { version = "0.4", optional = true }

wgpu-core/src/binding_model.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,21 @@
44

55
use crate::{
66
id::{BindGroupLayoutId, BufferId, DeviceId, SamplerId, TextureViewId},
7-
resource::TextureViewDimension,
87
track::{DUMMY_SELECTOR, TrackerSet},
9-
BufferAddress,
108
FastHashMap,
119
LifeGuard,
1210
RefCount,
1311
Stored,
1412
};
1513

14+
use wgt::BufferAddress;
1615
use arrayvec::ArrayVec;
1716
use rendy_descriptor::{DescriptorRanges, DescriptorSet};
1817

1918
#[cfg(feature = "serde")]
2019
use serde::{Deserialize, Serialize};
2120
use std::borrow::Borrow;
2221

23-
pub const MAX_BIND_GROUPS: usize = 4;
24-
25-
bitflags::bitflags! {
26-
#[repr(transparent)]
27-
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
28-
pub struct ShaderStage: u32 {
29-
const NONE = 0;
30-
const VERTEX = 1;
31-
const FRAGMENT = 2;
32-
const COMPUTE = 4;
33-
}
34-
}
35-
3622
#[repr(C)]
3723
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
3824
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -50,9 +36,9 @@ pub enum BindingType {
5036
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5137
pub struct BindGroupLayoutBinding {
5238
pub binding: u32,
53-
pub visibility: ShaderStage,
39+
pub visibility: wgt::ShaderStage,
5440
pub ty: BindingType,
55-
pub texture_dimension: TextureViewDimension,
41+
pub texture_dimension: wgt::TextureViewDimension,
5642
pub multisampled: bool,
5743
pub dynamic: bool,
5844
}
@@ -82,7 +68,7 @@ pub struct PipelineLayoutDescriptor {
8268
#[derive(Debug)]
8369
pub struct PipelineLayout<B: hal::Backend> {
8470
pub(crate) raw: B::PipelineLayout,
85-
pub(crate) bind_group_layout_ids: ArrayVec<[BindGroupLayoutId; MAX_BIND_GROUPS]>,
71+
pub(crate) bind_group_layout_ids: ArrayVec<[BindGroupLayoutId; wgt::MAX_BIND_GROUPS]>,
8672
}
8773

8874
#[repr(C)]

wgpu-core/src/command/compute.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use crate::{
1111
device::{all_buffer_stages, BIND_BUFFER_ALIGNMENT},
1212
hub::{GfxBackend, Global, Token},
1313
id,
14-
resource::BufferUsage,
15-
BufferAddress,
1614
DynamicOffset,
1715
};
1816

17+
use wgt::{BufferAddress, BufferUsage};
1918
use hal::command::CommandBuffer as _;
2019
use peek_poke::{Peek, PeekCopy, Poke};
2120

@@ -222,10 +221,10 @@ pub mod compute_ffi {
222221
};
223222
use crate::{
224223
id,
225-
BufferAddress,
226224
DynamicOffset,
227225
RawString,
228226
};
227+
use wgt::BufferAddress;
229228
use std::{convert::TryInto, slice};
230229

231230
/// # Safety

wgpu-core/src/command/render.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ use crate::{
2020
},
2121
hub::{GfxBackend, Global, Token},
2222
id,
23-
pipeline::{IndexFormat, InputStepMode, PipelineFlags},
24-
resource::{BufferUsage, TextureUsage, TextureViewInner},
23+
pipeline::PipelineFlags,
24+
resource::{TextureUsage, TextureViewInner},
2525
track::TrackerSet,
26-
BufferAddress,
2726
Color,
2827
DynamicOffset,
2928
Stored,
3029
};
3130

31+
use wgt::{BufferAddress, BufferUsage, IndexFormat, InputStepMode};
3232
use arrayvec::ArrayVec;
3333
use hal::command::CommandBuffer as _;
3434
use peek_poke::{Peek, PeekCopy, Poke};
@@ -1166,11 +1166,11 @@ pub mod render_ffi {
11661166
};
11671167
use crate::{
11681168
id,
1169-
BufferAddress,
11701169
Color,
11711170
DynamicOffset,
11721171
RawString,
11731172
};
1173+
use wgt::BufferAddress;
11741174
use std::{convert::TryInto, slice};
11751175

11761176
/// # Safety

wgpu-core/src/command/transfer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use crate::{
77
device::{all_buffer_stages, all_image_stages},
88
hub::{GfxBackend, Global, Token},
99
id::{BufferId, CommandEncoderId, TextureId},
10-
resource::{BufferUsage, TextureUsage},
11-
BufferAddress,
10+
resource::TextureUsage,
1211
Extent3d,
1312
Origin3d,
1413
};
1514

15+
use wgt::{BufferAddress, BufferUsage};
1616
use hal::command::CommandBuffer as _;
1717

1818
use std::iter;

0 commit comments

Comments
 (0)