Upgrade arrayvec to 0.7

This commit is contained in:
Benoît du Garreau 2021-07-05 22:45:48 +02:00
parent 118cf2cdba
commit e7269e72f3
20 changed files with 50 additions and 46 deletions

4
Cargo.lock generated
View File

@ -59,9 +59,9 @@ dependencies = [
[[package]]
name = "arrayvec"
version = "0.5.2"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd"
dependencies = [
"serde",
]

View File

@ -21,7 +21,7 @@ replay = ["serde", "wgt/replay", "arrayvec/serde", "naga/deserialize"]
serial-pass = ["serde", "wgt/serde", "arrayvec/serde"]
[dependencies]
arrayvec = "0.5"
arrayvec = "0.7"
bitflags = "1.0"
copyless = "0.1"
fxhash = "0.2"

View File

@ -496,8 +496,8 @@ pub struct PipelineLayout<A: hal::Api> {
pub(crate) raw: A::PipelineLayout,
pub(crate) device_id: Stored<DeviceId>,
pub(crate) life_guard: LifeGuard,
pub(crate) bind_group_layout_ids: ArrayVec<[Valid<BindGroupLayoutId>; hal::MAX_BIND_GROUPS]>,
pub(crate) push_constant_ranges: ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT]>,
pub(crate) bind_group_layout_ids: ArrayVec<Valid<BindGroupLayoutId>, { hal::MAX_BIND_GROUPS }>,
pub(crate) push_constant_ranges: ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT }>,
}
impl<A: hal::Api> PipelineLayout<A> {

View File

@ -228,13 +228,13 @@ struct PushConstantChange {
/// to every possible value.
pub fn compute_nonoverlapping_ranges(
ranges: &[wgt::PushConstantRange],
) -> ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT * 2]> {
) -> ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT * 2 }> {
if ranges.is_empty() {
return ArrayVec::new();
}
debug_assert!(ranges.len() <= SHADER_STAGE_COUNT);
let mut breaks: ArrayVec<[PushConstantChange; SHADER_STAGE_COUNT * 2]> = ArrayVec::new();
let mut breaks: ArrayVec<PushConstantChange, { SHADER_STAGE_COUNT * 2 }> = ArrayVec::new();
for range in ranges {
breaks.push(PushConstantChange {
stages: range.stages,

View File

@ -906,7 +906,7 @@ impl BindState {
#[derive(Debug)]
struct PushConstantState {
ranges: ArrayVec<[wgt::PushConstantRange; SHADER_STAGE_COUNT]>,
ranges: ArrayVec<wgt::PushConstantRange, { SHADER_STAGE_COUNT }>,
is_dirty: bool,
}
impl PushConstantState {
@ -944,8 +944,8 @@ struct VertexLimitState {
struct State {
trackers: TrackerSet,
index: IndexState,
vertex: ArrayVec<[VertexState; hal::MAX_VERTEX_BUFFERS]>,
bind: ArrayVec<[BindState; hal::MAX_BIND_GROUPS]>,
vertex: ArrayVec<VertexState, { hal::MAX_VERTEX_BUFFERS }>,
bind: ArrayVec<BindState, { hal::MAX_BIND_GROUPS }>,
push_constant_ranges: PushConstantState,
raw_dynamic_offsets: Vec<wgt::DynamicOffset>,
flat_dynamic_offsets: Vec<wgt::DynamicOffset>,

View File

@ -154,7 +154,7 @@ pub struct RenderPassDescriptor<'a> {
pub struct RenderPass {
base: BasePass<RenderCommand>,
parent_id: id::CommandEncoderId,
color_targets: ArrayVec<[RenderPassColorAttachment; hal::MAX_COLOR_TARGETS]>,
color_targets: ArrayVec<RenderPassColorAttachment, { hal::MAX_COLOR_TARGETS }>,
depth_stencil_target: Option<RenderPassDepthStencilAttachment>,
}
@ -277,7 +277,7 @@ impl VertexBufferState {
#[derive(Debug, Default)]
struct VertexState {
inputs: ArrayVec<[VertexBufferState; hal::MAX_VERTEX_BUFFERS]>,
inputs: ArrayVec<VertexBufferState, { hal::MAX_VERTEX_BUFFERS }>,
/// Length of the shortest vertex rate vertex buffer
vertex_limit: u32,
/// Buffer slot which the shortest vertex rate vertex buffer is bound to
@ -495,7 +495,7 @@ struct RenderAttachment<'a> {
new_use: hal::TextureUses,
}
type AttachmentDataVec<T> = ArrayVec<[T; hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1]>;
type AttachmentDataVec<T> = ArrayVec<T, { hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1 }>;
struct RenderPassInfo<'a, A: hal::Api> {
context: RenderPassContext,
@ -552,7 +552,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
Ok(())
};
let mut colors = ArrayVec::<[hal::ColorAttachment<A>; hal::MAX_COLOR_TARGETS]>::new();
let mut colors = ArrayVec::<hal::ColorAttachment<A>, { hal::MAX_COLOR_TARGETS }>::new();
let mut depth_stencil = None;
if let Some(at) = depth_stencil_attachment {

View File

@ -45,8 +45,8 @@ pub enum HostMap {
#[derive(Clone, Debug, Hash, PartialEq)]
#[cfg_attr(feature = "serial-pass", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct AttachmentData<T> {
pub colors: ArrayVec<[T; hal::MAX_COLOR_TARGETS]>,
pub resolves: ArrayVec<[T; hal::MAX_COLOR_TARGETS]>,
pub colors: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
pub resolves: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
pub depth_stencil: Option<T>,
}
impl<T: PartialEq> Eq for AttachmentData<T> {}
@ -70,8 +70,8 @@ pub(crate) struct RenderPassContext {
pub enum RenderPassCompatibilityError {
#[error("Incompatible color attachment: {0:?} != {1:?}")]
IncompatibleColorAttachment(
ArrayVec<[TextureFormat; hal::MAX_COLOR_TARGETS]>,
ArrayVec<[TextureFormat; hal::MAX_COLOR_TARGETS]>,
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
),
#[error("Incompatible depth-stencil attachment: {0:?} != {1:?}")]
IncompatibleDepthStencilAttachment(Option<TextureFormat>, Option<TextureFormat>),
@ -962,7 +962,7 @@ impl<A: HalApi> Device<A> {
fn get_introspection_bind_group_layouts<'a>(
pipeline_layout: &binding_model::PipelineLayout<A>,
bgl_guard: &'a Storage<binding_model::BindGroupLayout<A>, id::BindGroupLayoutId>,
) -> ArrayVec<[&'a binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]> {
) -> ArrayVec<&'a binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }> {
pipeline_layout
.bind_group_layout_ids
.iter()
@ -1690,7 +1690,7 @@ impl<A: HalApi> Device<A> {
&self,
self_id: id::DeviceId,
implicit_context: Option<ImplicitPipelineContext>,
mut derived_group_layouts: ArrayVec<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>,
mut derived_group_layouts: ArrayVec<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>,
bgl_guard: &mut Storage<binding_model::BindGroupLayout<A>, id::BindGroupLayoutId>,
pipeline_layout_guard: &mut Storage<binding_model::PipelineLayout<A>, id::PipelineLayoutId>,
) -> Result<id::PipelineLayoutId, pipeline::ImplicitLayoutError> {
@ -1757,7 +1757,7 @@ impl<A: HalApi> Device<A> {
self.require_downlevel_flags(wgt::DownlevelFlags::COMPUTE_SHADERS)?;
let mut derived_group_layouts =
ArrayVec::<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>::new();
ArrayVec::<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>::new();
let io = validation::StageIo::default();
let (shader_module_guard, _) = hub.shader_modules.read(&mut token);
@ -1869,7 +1869,7 @@ impl<A: HalApi> Device<A> {
}
let mut derived_group_layouts =
ArrayVec::<[binding_model::BindEntryMap; hal::MAX_BIND_GROUPS]>::new();
ArrayVec::<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>::new();
let color_targets = desc
.fragment
@ -2446,7 +2446,7 @@ pub struct MissingDownlevelFlags(pub wgt::DownlevelFlags);
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
pub struct ImplicitPipelineContext {
pub root_id: id::PipelineLayoutId,
pub group_ids: ArrayVec<[id::BindGroupLayoutId; hal::MAX_BIND_GROUPS]>,
pub group_ids: ArrayVec<id::BindGroupLayoutId, { hal::MAX_BIND_GROUPS }>,
}
pub struct ImplicitPipelineIds<'a, G: GlobalIdentityHandlerFactory> {

View File

@ -14,6 +14,9 @@
clippy::needless_lifetimes,
// No need for defaults in the internal types.
clippy::new_without_default,
// For some reason `rustc` can warn about these in const generics even
// though they are required.
unused_braces,
)]
#![warn(
trivial_casts,

View File

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

View File

@ -25,7 +25,7 @@ thiserror = "1"
wgt = { package = "wgpu-types", path = "../wgpu-types" }
# backends common
arrayvec = "0.5"
arrayvec = "0.7"
fxhash = "0.2.1"
log = "0.4"
# backend: Metal

View File

@ -15,15 +15,15 @@ pub(super) struct State {
index_format: wgt::IndexFormat,
index_offset: wgt::BufferAddress,
vertex_buffers: [(super::VertexBufferDesc, super::BufferBinding); crate::MAX_VERTEX_BUFFERS],
vertex_attributes: ArrayVec<[super::AttributeDesc; super::MAX_VERTEX_ATTRIBUTES]>,
color_targets: ArrayVec<[super::ColorTargetDesc; crate::MAX_COLOR_TARGETS]>,
vertex_attributes: ArrayVec<super::AttributeDesc, { super::MAX_VERTEX_ATTRIBUTES }>,
color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_TARGETS }>,
stencil: super::StencilState,
depth_bias: wgt::DepthBiasState,
samplers: [Option<glow::Sampler>; super::MAX_SAMPLERS],
texture_slots: [TextureSlotDesc; super::MAX_TEXTURE_SLOTS],
render_size: wgt::Extent3d,
resolve_attachments: ArrayVec<[(u32, super::TextureView); crate::MAX_COLOR_TARGETS]>,
invalidate_attachments: ArrayVec<[u32; crate::MAX_COLOR_TARGETS + 2]>,
resolve_attachments: ArrayVec<(u32, super::TextureView), { crate::MAX_COLOR_TARGETS }>,
invalidate_attachments: ArrayVec<u32, { crate::MAX_COLOR_TARGETS + 2 }>,
has_pass_label: bool,
instance_vbuf_mask: usize,
dirty_vbuf_mask: usize,

View File

@ -176,7 +176,7 @@ impl super::Device {
let mut name_binding_map = NameBindingMap::default();
let mut sampler_map = [None; super::MAX_TEXTURE_SLOTS];
let mut has_stages = wgt::ShaderStages::empty();
let mut shaders_to_delete = arrayvec::ArrayVec::<[_; 3]>::new();
let mut shaders_to_delete = arrayvec::ArrayVec::<_, 3>::new();
for (naga_stage, stage) in shaders {
has_stages |= map_naga_stage(naga_stage);

View File

@ -469,7 +469,7 @@ struct PrimitiveState {
clamp_depth: bool,
}
type InvalidatedAttachments = arrayvec::ArrayVec<[u32; crate::MAX_COLOR_TARGETS + 2]>;
type InvalidatedAttachments = arrayvec::ArrayVec<u32, { crate::MAX_COLOR_TARGETS + 2 }>;
#[derive(Debug)]
enum Command {

View File

@ -576,7 +576,7 @@ impl super::Queue {
C::SetDrawColorBuffers(count) => {
let indices = (0..count as u32)
.map(|i| glow::COLOR_ATTACHMENT0 + i)
.collect::<ArrayVec<[_; crate::MAX_COLOR_TARGETS]>>();
.collect::<ArrayVec<_, { crate::MAX_COLOR_TARGETS }>>();
gl.draw_buffers(&indices);
for draw_buffer in 0..count as u32 {
gl.disable_draw_buffer(glow::BLEND, draw_buffer);

View File

@ -504,7 +504,7 @@ struct PushConstantsInfo {
#[derive(Debug)]
pub struct PipelineLayout {
naga_options: naga::back::msl::Options,
bind_group_infos: ArrayVec<[BindGroupLayoutInfo; crate::MAX_BIND_GROUPS]>,
bind_group_infos: ArrayVec<BindGroupLayoutInfo, { crate::MAX_BIND_GROUPS }>,
push_constants_infos: MultiStageData<Option<PushConstantsInfo>>,
total_counters: MultiStageResourceCounters,
}

View File

@ -348,8 +348,9 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
// render
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
let mut vk_clear_values = ArrayVec::<[vk::ClearValue; super::MAX_TOTAL_ATTACHMENTS]>::new();
let mut vk_image_views = ArrayVec::<[vk::ImageView; super::MAX_TOTAL_ATTACHMENTS]>::new();
let mut vk_clear_values =
ArrayVec::<vk::ClearValue, { super::MAX_TOTAL_ATTACHMENTS }>::new();
let mut vk_image_views = ArrayVec::<vk::ImageView, { super::MAX_TOTAL_ATTACHMENTS }>::new();
let mut rp_key = super::RenderPassKey::default();
let mut fb_key = super::FramebufferKey {
attachments: ArrayVec::default(),

View File

@ -169,13 +169,13 @@ impl super::DeviceShared {
.attachments
.iter()
.map(|at| at.raw)
.collect::<ArrayVec<[_; super::MAX_TOTAL_ATTACHMENTS]>>();
.collect::<ArrayVec<_, { super::MAX_TOTAL_ATTACHMENTS }>>();
let vk_view_formats = e
.key()
.attachments
.iter()
.map(|at| self.private_caps.map_texture_format(at.view_format))
.collect::<ArrayVec<[_; super::MAX_TOTAL_ATTACHMENTS]>>();
.collect::<ArrayVec<_, { super::MAX_TOTAL_ATTACHMENTS }>>();
let vk_image_infos = e
.key()
.attachments
@ -191,7 +191,7 @@ impl super::DeviceShared {
.view_formats(&vk_view_formats[i..i + 1])
.build()
})
.collect::<ArrayVec<[_; super::MAX_TOTAL_ATTACHMENTS]>>();
.collect::<ArrayVec<_, { super::MAX_TOTAL_ATTACHMENTS }>>();
let mut vk_attachment_info = vk::FramebufferAttachmentsCreateInfo::builder()
.attachment_image_infos(&vk_image_infos)
@ -377,7 +377,7 @@ impl
ty,
descriptor_count: count,
})
.collect::<ArrayVec<[_; 8]>>();
.collect::<ArrayVec<_, 8>>();
let mut vk_flags = vk::DescriptorPoolCreateFlags::empty();
if flags.contains(gpu_descriptor::DescriptorPoolCreateFlags::FREE_DESCRIPTOR_SET) {
@ -1121,7 +1121,7 @@ impl crate::Device<super::Api> for super::Device {
sample_count: desc.multisample.count,
..Default::default()
};
let mut stages = ArrayVec::<[_; 2]>::new();
let mut stages = ArrayVec::<_, 2>::new();
let mut vertex_buffers = Vec::with_capacity(desc.vertex_buffers.len());
let mut vertex_attributes = Vec::new();

View File

@ -195,7 +195,7 @@ struct DepthStencilAttachmentKey {
#[derive(Clone, Eq, Default, Hash, PartialEq)]
struct RenderPassKey {
colors: ArrayVec<[ColorAttachmentKey; crate::MAX_COLOR_TARGETS]>,
colors: ArrayVec<ColorAttachmentKey, { crate::MAX_COLOR_TARGETS }>,
depth_stencil: Option<DepthStencilAttachmentKey>,
sample_count: u32,
}
@ -211,7 +211,7 @@ struct FramebufferAttachment {
#[derive(Clone, Eq, Hash, PartialEq)]
struct FramebufferKey {
attachments: ArrayVec<[FramebufferAttachment; MAX_TOTAL_ATTACHMENTS]>,
attachments: ArrayVec<FramebufferAttachment, { MAX_TOTAL_ATTACHMENTS }>,
extent: wgt::Extent3d,
sample_count: u32,
}

View File

@ -47,7 +47,7 @@ package = "wgpu-hal"
path = "../wgpu-hal"
[dependencies]
arrayvec = "0.5"
arrayvec = "0.7"
log = "0.4"
parking_lot = "0.11"
raw-window-handle = "0.3"

View File

@ -1001,7 +1001,7 @@ impl crate::Context for Context {
.bind_group_layouts
.iter()
.map(|bgl| bgl.id)
.collect::<ArrayVec<[_; hal::MAX_BIND_GROUPS]>>();
.collect::<ArrayVec<_, { hal::MAX_BIND_GROUPS }>>();
let descriptor = wgc::binding_model::PipelineLayoutDescriptor {
label: desc.label.map(Borrowed),
bind_group_layouts: Borrowed(&temp_layouts),
@ -1033,7 +1033,7 @@ impl crate::Context for Context {
) -> Self::RenderPipelineId {
use wgc::pipeline as pipe;
let vertex_buffers: ArrayVec<[_; hal::MAX_VERTEX_BUFFERS]> = desc
let vertex_buffers: ArrayVec<_, { hal::MAX_VERTEX_BUFFERS }> = desc
.vertex
.buffers
.iter()
@ -1768,7 +1768,7 @@ impl crate::Context for Context {
resolve_target: ca.resolve_target.map(|rt| rt.id),
channel: map_pass_channel(Some(&ca.ops)),
})
.collect::<ArrayVec<[_; hal::MAX_COLOR_TARGETS]>>();
.collect::<ArrayVec<_, { hal::MAX_COLOR_TARGETS }>>();
let depth_stencil = desc.depth_stencil_attachment.as_ref().map(|dsa| {
wgc::command::RenderPassDepthStencilAttachment {