mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[naga] Use HandleVec
in Layouter
.
Change `naga::proc::layouter::Layouter::layouts` to be a `HandleVec`, not a `Vec`.
This commit is contained in:
parent
9f0a7cb184
commit
afc8e38fc1
@ -1,4 +1,4 @@
|
||||
use crate::arena::Handle;
|
||||
use crate::arena::{Handle, HandleVec};
|
||||
use std::{fmt::Display, num::NonZeroU32, ops};
|
||||
|
||||
/// A newtype struct where its only valid values are powers of 2
|
||||
@ -108,17 +108,15 @@ impl TypeLayout {
|
||||
///
|
||||
/// [WGSL §4.3.7, "Memory Layout"](https://gpuweb.github.io/gpuweb/wgsl/#memory-layouts)
|
||||
#[derive(Debug, Default)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||
pub struct Layouter {
|
||||
/// Layouts for types in an arena, indexed by `Handle` index.
|
||||
layouts: Vec<TypeLayout>,
|
||||
/// Layouts for types in an arena.
|
||||
layouts: HandleVec<crate::Type, TypeLayout>,
|
||||
}
|
||||
|
||||
impl ops::Index<Handle<crate::Type>> for Layouter {
|
||||
type Output = TypeLayout;
|
||||
fn index(&self, handle: Handle<crate::Type>) -> &TypeLayout {
|
||||
&self.layouts[handle.index()]
|
||||
&self.layouts[handle]
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +241,7 @@ impl Layouter {
|
||||
},
|
||||
};
|
||||
debug_assert!(size <= layout.size);
|
||||
self.layouts.push(layout);
|
||||
self.layouts.insert(ty_handle, layout);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user