Skip to content

Commit d2a27e0

Browse files
bors[bot]a1phyr
andauthored
Merge #1604
1604: Upgrade `arrayvec` to 0.7 r=kvark a=a1phyr Upgrade `arrayvec` to version 0.7 (using const generics). Co-authored-by: Benoît du Garreau <[email protected]>
2 parents 2efccb2 + e7269e7 commit d2a27e0

File tree

20 files changed

+50
-46
lines changed

20 files changed

+50
-46
lines changed

Cargo.lock

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

wgpu-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ replay = ["serde", "wgt/replay", "arrayvec/serde", "naga/deserialize"]
2121
serial-pass = ["serde", "wgt/serde", "arrayvec/serde"]
2222

2323
[dependencies]
24-
arrayvec = "0.5"
24+
arrayvec = "0.7"
2525
bitflags = "1.0"
2626
copyless = "0.1"
2727
fxhash = "0.2"

wgpu-core/src/binding_model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ pub struct PipelineLayout<A: hal::Api> {
496496
pub(crate) raw: A::PipelineLayout,
497497
pub(crate) device_id: Stored<DeviceId>,
498498
pub(crate) life_guard: LifeGuard,
499-
pub(crate) bind_group_layout_ids: ArrayVec<[Valid<BindGroupLayoutId>; hal::MAX_BIND_GROUPS]>,
500-
pub(crate) push_constant_ranges: ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT]>,
499+
pub(crate) bind_group_layout_ids: ArrayVec<Valid<BindGroupLayoutId>, { hal::MAX_BIND_GROUPS }>,
500+
pub(crate) push_constant_ranges: ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT }>,
501501
}
502502

503503
impl<A: hal::Api> PipelineLayout<A> {

wgpu-core/src/command/bind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ struct PushConstantChange {
228228
/// to every possible value.
229229
pub fn compute_nonoverlapping_ranges(
230230
ranges: &[wgt::PushConstantRange],
231-
) -> ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT * 2]> {
231+
) -> ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT * 2 }> {
232232
if ranges.is_empty() {
233233
return ArrayVec::new();
234234
}
235235
debug_assert!(ranges.len() <= SHADER_STAGE_COUNT);
236236

237-
let mut breaks: ArrayVec<[PushConstantChange; SHADER_STAGE_COUNT * 2]> = ArrayVec::new();
237+
let mut breaks: ArrayVec<PushConstantChange, { SHADER_STAGE_COUNT * 2 }> = ArrayVec::new();
238238
for range in ranges {
239239
breaks.push(PushConstantChange {
240240
stages: range.stages,

wgpu-core/src/command/bundle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl BindState {
906906

907907
#[derive(Debug)]
908908
struct PushConstantState {
909-
ranges: ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT]>,
909+
ranges: ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT }>,
910910
is_dirty: bool,
911911
}
912912
impl PushConstantState {
@@ -944,8 +944,8 @@ struct VertexLimitState {
944944
struct State {
945945
trackers: TrackerSet,
946946
index: IndexState,
947-
vertex: ArrayVec<[VertexState; hal::MAX_VERTEX_BUFFERS]>,
948-
bind: ArrayVec<[BindState; hal::MAX_BIND_GROUPS]>,
947+
vertex: ArrayVec<VertexState, { hal::MAX_VERTEX_BUFFERS }>,
948+
bind: ArrayVec<BindState, { hal::MAX_BIND_GROUPS }>,
949949
push_constant_ranges: PushConstantState,
950950
raw_dynamic_offsets: Vec<wgt::DynamicOffset>,
951951
flat_dynamic_offsets: Vec<wgt::DynamicOffset>,

wgpu-core/src/command/render.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub struct RenderPassDescriptor<'a> {
154154
pub struct RenderPass {
155155
base: BasePass<RenderCommand>,
156156
parent_id: id::CommandEncoderId,
157-
color_targets: ArrayVec<[RenderPassColorAttachment; hal::MAX_COLOR_TARGETS]>,
157+
color_targets: ArrayVec<RenderPassColorAttachment, { hal::MAX_COLOR_TARGETS }>,
158158
depth_stencil_target: Option<RenderPassDepthStencilAttachment>,
159159
}
160160

@@ -277,7 +277,7 @@ impl VertexBufferState {
277277

278278
#[derive(Debug, Default)]
279279
struct VertexState {
280-
inputs: ArrayVec<[VertexBufferState; hal::MAX_VERTEX_BUFFERS]>,
280+
inputs: ArrayVec<VertexBufferState, { hal::MAX_VERTEX_BUFFERS }>,
281281
/// Length of the shortest vertex rate vertex buffer
282282
vertex_limit: u32,
283283
/// Buffer slot which the shortest vertex rate vertex buffer is bound to
@@ -495,7 +495,7 @@ struct RenderAttachment<'a> {
495495
new_use: hal::TextureUses,
496496
}
497497

498-
type AttachmentDataVec<T> = ArrayVec<[T; hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1]>;
498+
type AttachmentDataVec<T> = ArrayVec<T, { hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1 }>;
499499

500500
struct RenderPassInfo<'a, A: hal::Api> {
501501
context: RenderPassContext,
@@ -552,7 +552,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
552552
Ok(())
553553
};
554554

555-
let mut colors = ArrayVec::<[hal::ColorAttachment<A>; hal::MAX_COLOR_TARGETS]>::new();
555+
let mut colors = ArrayVec::<hal::ColorAttachment<A>, { hal::MAX_COLOR_TARGETS }>::new();
556556
let mut depth_stencil = None;
557557

558558
if let Some(at) = depth_stencil_attachment {

wgpu-core/src/device/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub enum HostMap {
4545
#[derive(Clone, Debug, Hash, PartialEq)]
4646
#[cfg_attr(feature = "serial-pass", derive(serde::Deserialize, serde::Serialize))]
4747
pub(crate) struct AttachmentData<T> {
48-
pub colors: ArrayVec<[T; hal::MAX_COLOR_TARGETS]>,
49-
pub resolves: ArrayVec<[T; hal::MAX_COLOR_TARGETS]>,
48+
pub colors: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
49+
pub resolves: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
5050
pub depth_stencil: Option<T>,
5151
}
5252
impl<T: PartialEq> Eq for AttachmentData<T> {}
@@ -70,8 +70,8 @@ pub(crate) struct RenderPassContext {
7070
pub enum RenderPassCompatibilityError {
7171
#[error("Incompatible color attachment: {0:?} != {1:?}")]
7272
IncompatibleColorAttachment(
73-
ArrayVec<[TextureFormat; hal::MAX_COLOR_TARGETS]>,
74-
ArrayVec<[TextureFormat; hal::MAX_COLOR_TARGETS]>,
73+
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
74+
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
7575
),
7676
#[error("Incompatible depth-stencil attachment: {0:?} != {1:?}")]
7777
IncompatibleDepthStencilAttachment(Option<TextureFormat>, Option<TextureFormat>),
@@ -962,7 +962,7 @@ impl<A: HalApi> Device<A> {
962962
fn get_introspection_bind_group_layouts<'a>(
963963
pipeline_layout: &binding_model::PipelineLayout<A>,
964964
bgl_guard: &'a Storage<binding_model::BindGroupLayout<A>, id::BindGroupLayoutId>,
965-
) -> ArrayVec<[&'a binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]> {
965+
) -> ArrayVec<&'a binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }> {
966966
pipeline_layout
967967
.bind_group_layout_ids
968968
.iter()
@@ -1690,7 +1690,7 @@ impl<A: HalApi> Device<A> {
16901690
&self,
16911691
self_id: id::DeviceId,
16921692
implicit_context: Option<ImplicitPipelineContext>,
1693-
mut derived_group_layouts: ArrayVec<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>,
1693+
mut derived_group_layouts: ArrayVec<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>,
16941694
bgl_guard: &mut Storage<binding_model::BindGroupLayout<A>, id::BindGroupLayoutId>,
16951695
pipeline_layout_guard: &mut Storage<binding_model::PipelineLayout<A>, id::PipelineLayoutId>,
16961696
) -> Result<id::PipelineLayoutId, pipeline::ImplicitLayoutError> {
@@ -1757,7 +1757,7 @@ impl<A: HalApi> Device<A> {
17571757
self.require_downlevel_flags(wgt::DownlevelFlags::COMPUTE_SHADERS)?;
17581758

17591759
let mut derived_group_layouts =
1760-
ArrayVec::<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>::new();
1760+
ArrayVec::<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>::new();
17611761

17621762
let io = validation::StageIo::default();
17631763
let (shader_module_guard, _) = hub.shader_modules.read(&mut token);
@@ -1869,7 +1869,7 @@ impl<A: HalApi> Device<A> {
18691869
}
18701870

18711871
let mut derived_group_layouts =
1872-
ArrayVec::<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>::new();
1872+
ArrayVec::<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>::new();
18731873

18741874
let color_targets = desc
18751875
.fragment
@@ -2446,7 +2446,7 @@ pub struct MissingDownlevelFlags(pub wgt::DownlevelFlags);
24462446
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
24472447
pub struct ImplicitPipelineContext {
24482448
pub root_id: id::PipelineLayoutId,
2449-
pub group_ids: ArrayVec<[id::BindGroupLayoutId; hal::MAX_BIND_GROUPS]>,
2449+
pub group_ids: ArrayVec<id::BindGroupLayoutId, { hal::MAX_BIND_GROUPS }>,
24502450
}
24512451

24522452
pub struct ImplicitPipelineIds<'a, G: GlobalIdentityHandlerFactory> {

wgpu-core/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
clippy::needless_lifetimes,
1515
// No need for defaults in the internal types.
1616
clippy::new_without_default,
17+
// For some reason `rustc` can warn about these in const generics even
18+
// though they are required.
19+
unused_braces,
1720
)]
1821
#![warn(
1922
trivial_casts,

wgpu-core/src/track/texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct TextureSelector {
1818

1919
#[derive(Clone, Debug, Default, PartialEq)]
2020
pub(crate) struct TextureState {
21-
mips: ArrayVec<[PlaneStates; hal::MAX_MIP_LEVELS as usize]>,
21+
mips: ArrayVec<PlaneStates, { hal::MAX_MIP_LEVELS as usize }>,
2222
/// True if we have the information about all the subresources here
2323
full: bool,
2424
}

wgpu-hal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ thiserror = "1"
2525
wgt = { package = "wgpu-types", path = "../wgpu-types" }
2626

2727
# backends common
28-
arrayvec = "0.5"
28+
arrayvec = "0.7"
2929
fxhash = "0.2.1"
3030
log = "0.4"
3131
# backend: Metal

0 commit comments

Comments
 (0)