This commit is contained in:
Adam Nemecek 2020-09-25 19:11:46 -07:00
parent 645c121dda
commit db1870e7fc
18 changed files with 95 additions and 99 deletions

View File

@ -154,7 +154,7 @@ impl<B: hal::Backend> CommandAllocator<B> {
pending: Vec::new(), pending: Vec::new(),
}, },
); );
Ok(CommandAllocator { Ok(Self {
queue_family, queue_family,
internal_thread_id, internal_thread_id,
inner: Mutex::new(Inner { pools }), inner: Mutex::new(Inner { pools }),

View File

@ -93,7 +93,7 @@ impl RenderBundleEncoder {
base: Option<BasePass<RenderCommand>>, base: Option<BasePass<RenderCommand>>,
) -> Result<Self, CreateRenderBundleError> { ) -> Result<Self, CreateRenderBundleError> {
span!(_guard, INFO, "RenderBundleEncoder::new"); span!(_guard, INFO, "RenderBundleEncoder::new");
Ok(RenderBundleEncoder { Ok(Self {
base: base.unwrap_or_else(BasePass::new), base: base.unwrap_or_else(BasePass::new),
parent_id, parent_id,
context: RenderPassContext { context: RenderPassContext {
@ -330,7 +330,7 @@ struct IndexState {
impl IndexState { impl IndexState {
fn new() -> Self { fn new() -> Self {
IndexState { Self {
buffer: None, buffer: None,
format: wgt::IndexFormat::default(), format: wgt::IndexFormat::default(),
range: 0..0, range: 0..0,
@ -385,7 +385,7 @@ struct VertexState {
impl VertexState { impl VertexState {
fn new() -> Self { fn new() -> Self {
VertexState { Self {
buffer: None, buffer: None,
range: 0..0, range: 0..0,
stride: 0, stride: 0,
@ -424,7 +424,7 @@ struct BindState {
impl BindState { impl BindState {
fn new() -> Self { fn new() -> Self {
BindState { Self {
bind_group: None, bind_group: None,
dynamic_offsets: 0..0, dynamic_offsets: 0..0,
is_dirty: false, is_dirty: false,

View File

@ -70,7 +70,7 @@ pub struct ComputePass {
impl ComputePass { impl ComputePass {
pub fn new(parent_id: id::CommandEncoderId) -> Self { pub fn new(parent_id: id::CommandEncoderId) -> Self {
ComputePass { Self {
base: BasePass::new(), base: BasePass::new(),
parent_id, parent_id,
} }

View File

@ -128,7 +128,7 @@ pub struct BasePass<C> {
impl<C: Clone> BasePass<C> { impl<C: Clone> BasePass<C> {
fn new() -> Self { fn new() -> Self {
BasePass { Self {
commands: Vec::new(), commands: Vec::new(),
dynamic_offsets: Vec::new(), dynamic_offsets: Vec::new(),
string_data: Vec::new(), string_data: Vec::new(),
@ -138,7 +138,7 @@ impl<C: Clone> BasePass<C> {
#[cfg(feature = "trace")] #[cfg(feature = "trace")]
fn from_ref(base: BasePassRef<C>) -> Self { fn from_ref(base: BasePassRef<C>) -> Self {
BasePass { Self {
commands: base.commands.to_vec(), commands: base.commands.to_vec(),
dynamic_offsets: base.dynamic_offsets.to_vec(), dynamic_offsets: base.dynamic_offsets.to_vec(),
string_data: base.string_data.to_vec(), string_data: base.string_data.to_vec(),

View File

@ -152,7 +152,7 @@ pub struct RenderPass {
impl RenderPass { impl RenderPass {
pub fn new(parent_id: id::CommandEncoderId, desc: RenderPassDescriptor) -> Self { pub fn new(parent_id: id::CommandEncoderId, desc: RenderPassDescriptor) -> Self {
RenderPass { Self {
base: BasePass::new(), base: BasePass::new(),
parent_id, parent_id,
color_targets: desc.color_attachments.iter().cloned().collect(), color_targets: desc.color_attachments.iter().cloned().collect(),

View File

@ -100,7 +100,7 @@ struct NonReferencedResources<B: hal::Backend> {
impl<B: hal::Backend> NonReferencedResources<B> { impl<B: hal::Backend> NonReferencedResources<B> {
fn new() -> Self { fn new() -> Self {
NonReferencedResources { Self {
buffers: Vec::new(), buffers: Vec::new(),
images: Vec::new(), images: Vec::new(),
image_views: Vec::new(), image_views: Vec::new(),
@ -225,7 +225,7 @@ pub(crate) struct LifetimeTracker<B: hal::Backend> {
impl<B: hal::Backend> LifetimeTracker<B> { impl<B: hal::Backend> LifetimeTracker<B> {
pub fn new() -> Self { pub fn new() -> Self {
LifetimeTracker { Self {
mapped: Vec::new(), mapped: Vec::new(),
future_suspected_buffers: Vec::new(), future_suspected_buffers: Vec::new(),
future_suspected_textures: Vec::new(), future_suspected_textures: Vec::new(),

View File

@ -272,7 +272,7 @@ impl<B: GfxBackend> Device<B> {
None => (), None => (),
} }
Ok(Device { Ok(Self {
raw, raw,
adapter_id, adapter_id,
cmd_allocator, cmd_allocator,
@ -923,8 +923,8 @@ pub enum DeviceError {
impl From<hal::device::OomOrDeviceLost> for DeviceError { impl From<hal::device::OomOrDeviceLost> for DeviceError {
fn from(err: hal::device::OomOrDeviceLost) -> Self { fn from(err: hal::device::OomOrDeviceLost) -> Self {
match err { match err {
hal::device::OomOrDeviceLost::OutOfMemory(_) => DeviceError::OutOfMemory, hal::device::OomOrDeviceLost::OutOfMemory(_) => Self::OutOfMemory,
hal::device::OomOrDeviceLost::DeviceLost(_) => DeviceError::Lost, hal::device::OomOrDeviceLost::DeviceLost(_) => Self::Lost,
} }
} }
} }
@ -934,14 +934,14 @@ impl DeviceError {
match err { match err {
gfx_memory::HeapsError::AllocationError(hal::device::AllocationError::OutOfMemory( gfx_memory::HeapsError::AllocationError(hal::device::AllocationError::OutOfMemory(
_, _,
)) => DeviceError::OutOfMemory, )) => Self::OutOfMemory,
_ => panic!("Unable to allocate memory: {:?}", err), _ => panic!("Unable to allocate memory: {:?}", err),
} }
} }
fn from_bind(err: hal::device::BindError) -> Self { fn from_bind(err: hal::device::BindError) -> Self {
match err { match err {
hal::device::BindError::OutOfMemory(_) => DeviceError::OutOfMemory, hal::device::BindError::OutOfMemory(_) => Self::OutOfMemory,
_ => panic!("failed to bind memory: {}", err), _ => panic!("failed to bind memory: {}", err),
} }
} }

View File

@ -37,7 +37,7 @@ pub(crate) struct PendingWrites<B: hal::Backend> {
impl<B: hal::Backend> PendingWrites<B> { impl<B: hal::Backend> PendingWrites<B> {
pub fn new() -> Self { pub fn new() -> Self {
PendingWrites { Self {
command_buffer: None, command_buffer: None,
temp_buffers: Vec::new(), temp_buffers: Vec::new(),
} }

View File

@ -154,7 +154,7 @@ impl Trace {
tracing::info!("Tracing into '{:?}'", path); tracing::info!("Tracing into '{:?}'", path);
let mut file = std::fs::File::create(path.join(FILE_NAME))?; let mut file = std::fs::File::create(path.join(FILE_NAME))?;
file.write_all(b"[\n")?; file.write_all(b"[\n")?;
Ok(Trace { Ok(Self {
path: path.to_path_buf(), path: path.to_path_buf(),
file, file,
config: ron::ser::PrettyConfig::default(), config: ron::ser::PrettyConfig::default(),

View File

@ -36,7 +36,7 @@ pub struct IdentityManager {
impl Default for IdentityManager { impl Default for IdentityManager {
fn default() -> Self { fn default() -> Self {
IdentityManager { Self {
free: Default::default(), free: Default::default(),
epochs: Default::default(), epochs: Default::default(),
} }
@ -45,7 +45,7 @@ impl Default for IdentityManager {
impl IdentityManager { impl IdentityManager {
pub fn from_index(min_index: u32) -> Self { pub fn from_index(min_index: u32) -> Self {
IdentityManager { Self {
free: (0..min_index).collect(), free: (0..min_index).collect(),
epochs: vec![1; min_index as usize], epochs: vec![1; min_index as usize],
} }
@ -292,7 +292,7 @@ impl<'a, T> Token<'a, T> {
assert_ne!(old, 0, "Root token was dropped"); assert_ne!(old, 0, "Root token was dropped");
active.set(old + 1); active.set(old + 1);
}); });
Token { level: PhantomData } Self { level: PhantomData }
} }
} }
@ -303,7 +303,7 @@ impl Token<'static, Root> {
assert_eq!(0, active.replace(1), "Root token is already active"); assert_eq!(0, active.replace(1), "Root token is already active");
}); });
Token { level: PhantomData } Self { level: PhantomData }
} }
} }
@ -381,7 +381,7 @@ pub struct Registry<T, I: TypedId, F: IdentityHandlerFactory<I>> {
impl<T, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F> { impl<T, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F> {
fn new(backend: Backend, factory: &F, kind: &'static str) -> Self { fn new(backend: Backend, factory: &F, kind: &'static str) -> Self {
Registry { Self {
identity: factory.spawn(0), identity: factory.spawn(0),
data: RwLock::new(Storage { data: RwLock::new(Storage {
map: Vec::new(), map: Vec::new(),
@ -393,7 +393,7 @@ impl<T, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F> {
} }
fn without_backend(factory: &F, kind: &'static str) -> Self { fn without_backend(factory: &F, kind: &'static str) -> Self {
Registry { Self {
identity: factory.spawn(1), identity: factory.spawn(1),
data: RwLock::new(Storage { data: RwLock::new(Storage {
map: Vec::new(), map: Vec::new(),
@ -508,7 +508,7 @@ pub struct Hub<B: hal::Backend, F: GlobalIdentityHandlerFactory> {
impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> { impl<B: GfxBackend, F: GlobalIdentityHandlerFactory> Hub<B, F> {
fn new(factory: &F) -> Self { fn new(factory: &F) -> Self {
Hub { Self {
adapters: Registry::new(B::VARIANT, factory, "Adapter"), adapters: Registry::new(B::VARIANT, factory, "Adapter"),
devices: Registry::new(B::VARIANT, factory, "Device"), devices: Registry::new(B::VARIANT, factory, "Device"),
swap_chains: Registry::new(B::VARIANT, factory, "SwapChain"), swap_chains: Registry::new(B::VARIANT, factory, "SwapChain"),
@ -668,7 +668,7 @@ pub struct Hubs<F: GlobalIdentityHandlerFactory> {
impl<F: GlobalIdentityHandlerFactory> Hubs<F> { impl<F: GlobalIdentityHandlerFactory> Hubs<F> {
fn new(factory: &F) -> Self { fn new(factory: &F) -> Self {
Hubs { Self {
#[cfg(vulkan)] #[cfg(vulkan)]
vulkan: Hub::new(factory), vulkan: Hub::new(factory),
#[cfg(metal)] #[cfg(metal)]
@ -691,7 +691,7 @@ pub struct Global<G: GlobalIdentityHandlerFactory> {
impl<G: GlobalIdentityHandlerFactory> Global<G> { impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn new(name: &str, factory: G, backends: wgt::BackendBit) -> Self { pub fn new(name: &str, factory: G, backends: wgt::BackendBit) -> Self {
span!(_guard, INFO, "Global::new"); span!(_guard, INFO, "Global::new");
Global { Self {
instance: Instance::new(name, 1, backends), instance: Instance::new(name, 1, backends),
surfaces: Registry::without_backend(&factory, "Surface"), surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory), hubs: Hubs::new(&factory),

View File

@ -39,7 +39,7 @@ enum SerialId {
impl<T> From<Id<T>> for SerialId { impl<T> From<Id<T>> for SerialId {
fn from(id: Id<T>) -> Self { fn from(id: Id<T>) -> Self {
let (index, epoch, backend) = id.unzip(); let (index, epoch, backend) = id.unzip();
SerialId::Id(index, epoch, backend) Self::Id(index, epoch, backend)
} }
} }
#[cfg(feature = "replay")] #[cfg(feature = "replay")]

View File

@ -50,7 +50,7 @@ impl Instance {
None None
} }
}; };
Instance { Self {
#[cfg(vulkan)] #[cfg(vulkan)]
vulkan: map((Backend::Vulkan, gfx_backend_vulkan::Instance::create)), vulkan: map((Backend::Vulkan, gfx_backend_vulkan::Instance::create)),
#[cfg(metal)] #[cfg(metal)]
@ -200,7 +200,7 @@ impl<B: hal::Backend> Adapter<B> {
.max(MIN_PUSH_CONSTANT_SIZE), // As an extension, the default is always 0, so define a separate minimum. .max(MIN_PUSH_CONSTANT_SIZE), // As an extension, the default is always 0, so define a separate minimum.
}; };
Adapter { Self {
raw, raw,
features, features,
limits, limits,
@ -235,7 +235,7 @@ impl AdapterInfo {
device_type, device_type,
} = adapter_info; } = adapter_info;
AdapterInfo { Self {
name, name,
vendor, vendor,
device, device,
@ -302,8 +302,8 @@ pub enum AdapterInputs<'a, I> {
impl<I: Clone> AdapterInputs<'_, I> { impl<I: Clone> AdapterInputs<'_, I> {
fn find(&self, b: Backend) -> Option<I> { fn find(&self, b: Backend) -> Option<I> {
match *self { match *self {
AdapterInputs::IdSet(ids, ref fun) => ids.iter().find(|id| fun(id) == b).cloned(), Self::IdSet(ids, ref fun) => ids.iter().find(|id| fun(id) == b).cloned(),
AdapterInputs::Mask(bits, ref fun) => { Self::Mask(bits, ref fun) => {
if bits.contains(b.into()) { if bits.contains(b.into()) {
Some(fun(b)) Some(fun(b))
} else { } else {

View File

@ -96,7 +96,7 @@ impl Clone for RefCount {
fn clone(&self) -> Self { fn clone(&self) -> Self {
let old_size = unsafe { self.0.as_ref() }.fetch_add(1, Ordering::AcqRel); let old_size = unsafe { self.0.as_ref() }.fetch_add(1, Ordering::AcqRel);
assert!(old_size < Self::MAX); assert!(old_size < Self::MAX);
RefCount(self.0) Self(self.0)
} }
} }
@ -142,7 +142,7 @@ impl MultiRefCount {
fn new() -> Self { fn new() -> Self {
let bx = Box::new(AtomicUsize::new(1)); let bx = Box::new(AtomicUsize::new(1));
let ptr = Box::into_raw(bx); let ptr = Box::into_raw(bx);
MultiRefCount(unsafe { ptr::NonNull::new_unchecked(ptr) }) Self(unsafe { ptr::NonNull::new_unchecked(ptr) })
} }
fn inc(&self) { fn inc(&self) {
@ -169,7 +169,7 @@ struct LifeGuard {
impl LifeGuard { impl LifeGuard {
fn new() -> Self { fn new() -> Self {
let bx = Box::new(AtomicUsize::new(1)); let bx = Box::new(AtomicUsize::new(1));
LifeGuard { Self {
ref_count: ptr::NonNull::new(Box::into_raw(bx)).map(RefCount), ref_count: ptr::NonNull::new(Box::into_raw(bx)).map(RefCount),
submission_index: AtomicUsize::new(0), submission_index: AtomicUsize::new(0),
} }

View File

@ -26,7 +26,7 @@ impl PendingTransition<BufferState> {
impl Default for BufferState { impl Default for BufferState {
fn default() -> Self { fn default() -> Self {
BufferState { Self {
first: None, first: None,
last: BufferUse::empty(), last: BufferUse::empty(),
} }

View File

@ -32,7 +32,7 @@ pub struct Unit<U> {
impl<U: Copy> Unit<U> { impl<U: Copy> Unit<U> {
/// Create a new unit from a given usage. /// Create a new unit from a given usage.
fn new(usage: U) -> Self { fn new(usage: U) -> Self {
Unit { Self {
first: None, first: None,
last: usage, last: usage,
} }
@ -199,7 +199,7 @@ impl<S: ResourceState + fmt::Debug> fmt::Debug for ResourceTracker<S> {
impl<S: ResourceState> ResourceTracker<S> { impl<S: ResourceState> ResourceTracker<S> {
/// Create a new empty tracker. /// Create a new empty tracker.
pub fn new(backend: wgt::Backend) -> Self { pub fn new(backend: wgt::Backend) -> Self {
ResourceTracker { Self {
map: FastHashMap::default(), map: FastHashMap::default(),
temp: Vec::new(), temp: Vec::new(),
backend, backend,
@ -514,7 +514,7 @@ pub(crate) struct TrackerSet {
impl TrackerSet { impl TrackerSet {
/// Create an empty set. /// Create an empty set.
pub fn new(backend: wgt::Backend) -> Self { pub fn new(backend: wgt::Backend) -> Self {
TrackerSet { Self {
buffers: ResourceTracker::new(backend), buffers: ResourceTracker::new(backend),
textures: ResourceTracker::new(backend), textures: ResourceTracker::new(backend),
views: ResourceTracker::new(backend), views: ResourceTracker::new(backend),

View File

@ -18,13 +18,13 @@ pub struct RangedStates<I, T> {
impl<I: Copy + PartialOrd, T: Copy + PartialEq> RangedStates<I, T> { impl<I: Copy + PartialOrd, T: Copy + PartialEq> RangedStates<I, T> {
pub fn empty() -> Self { pub fn empty() -> Self {
RangedStates { Self {
ranges: SmallVec::new(), ranges: SmallVec::new(),
} }
} }
pub fn from_range(range: Range<I>, value: T) -> Self { pub fn from_range(range: Range<I>, value: T) -> Self {
RangedStates { Self {
ranges: iter::once((range, value)).collect(), ranges: iter::once((range, value)).collect(),
} }
} }
@ -32,7 +32,7 @@ impl<I: Copy + PartialOrd, T: Copy + PartialEq> RangedStates<I, T> {
/// Construct a new instance from a slice of ranges. /// Construct a new instance from a slice of ranges.
#[cfg(test)] #[cfg(test)]
pub fn from_slice(values: &[(Range<I>, T)]) -> Self { pub fn from_slice(values: &[(Range<I>, T)]) -> Self {
RangedStates { Self {
ranges: values.iter().cloned().collect(), ranges: values.iter().cloned().collect(),
} }
} }

View File

@ -45,7 +45,7 @@ impl PendingTransition<TextureState> {
impl TextureState { impl TextureState {
pub fn new(mip_level_count: hal::image::Level, array_layer_count: hal::image::Layer) -> Self { pub fn new(mip_level_count: hal::image::Level, array_layer_count: hal::image::Layer) -> Self {
TextureState { Self {
mips: iter::repeat_with(|| { mips: iter::repeat_with(|| {
PlaneStates::from_range(0..array_layer_count, Unit::new(TextureUse::UNINITIALIZED)) PlaneStates::from_range(0..array_layer_count, Unit::new(TextureUse::UNINITIALIZED))
}) })

View File

@ -66,8 +66,8 @@ pub enum PowerPreference {
} }
impl Default for PowerPreference { impl Default for PowerPreference {
fn default() -> PowerPreference { fn default() -> Self {
PowerPreference::Default Self::Default
} }
} }
@ -106,7 +106,7 @@ bitflags::bitflags! {
impl From<Backend> for BackendBit { impl From<Backend> for BackendBit {
fn from(backend: Backend) -> Self { fn from(backend: Backend) -> Self {
BackendBit::from_bits(1 << backend as u32).unwrap() Self::from_bits(1 << backend as u32).unwrap()
} }
} }
@ -364,7 +364,7 @@ pub struct Limits {
impl Default for Limits { impl Default for Limits {
fn default() -> Self { fn default() -> Self {
Limits { Self {
max_bind_groups: 4, max_bind_groups: 4,
max_dynamic_uniform_buffers_per_pipeline_layout: 8, max_dynamic_uniform_buffers_per_pipeline_layout: 8,
max_dynamic_storage_buffers_per_pipeline_layout: 4, max_dynamic_storage_buffers_per_pipeline_layout: 4,
@ -476,7 +476,7 @@ pub enum BlendOperation {
impl Default for BlendOperation { impl Default for BlendOperation {
fn default() -> Self { fn default() -> Self {
BlendOperation::Add Self::Add
} }
} }
@ -513,7 +513,7 @@ impl BlendDescriptor {
impl Default for BlendDescriptor { impl Default for BlendDescriptor {
fn default() -> Self { fn default() -> Self {
BlendDescriptor::REPLACE Self::REPLACE
} }
} }
@ -536,7 +536,7 @@ pub struct ColorStateDescriptor {
impl From<TextureFormat> for ColorStateDescriptor { impl From<TextureFormat> for ColorStateDescriptor {
fn from(format: TextureFormat) -> Self { fn from(format: TextureFormat) -> Self {
ColorStateDescriptor { Self {
format, format,
alpha_blend: BlendDescriptor::REPLACE, alpha_blend: BlendDescriptor::REPLACE,
color_blend: BlendDescriptor::REPLACE, color_blend: BlendDescriptor::REPLACE,
@ -589,7 +589,7 @@ pub enum FrontFace {
impl Default for FrontFace { impl Default for FrontFace {
fn default() -> Self { fn default() -> Self {
FrontFace::Ccw Self::Ccw
} }
} }
@ -609,7 +609,7 @@ pub enum CullMode {
impl Default for CullMode { impl Default for CullMode {
fn default() -> Self { fn default() -> Self {
CullMode::None Self::None
} }
} }
@ -629,7 +629,7 @@ pub enum PolygonMode {
impl Default for PolygonMode { impl Default for PolygonMode {
fn default() -> Self { fn default() -> Self {
PolygonMode::Fill Self::Fill
} }
} }
@ -874,7 +874,7 @@ bitflags::bitflags! {
impl Default for ColorWrite { impl Default for ColorWrite {
fn default() -> Self { fn default() -> Self {
ColorWrite::ALL Self::ALL
} }
} }
@ -946,7 +946,7 @@ pub enum IndexFormat {
impl Default for IndexFormat { impl Default for IndexFormat {
fn default() -> Self { fn default() -> Self {
IndexFormat::Uint32 Self::Uint32
} }
} }
@ -976,7 +976,7 @@ pub enum StencilOperation {
impl Default for StencilOperation { impl Default for StencilOperation {
fn default() -> Self { fn default() -> Self {
StencilOperation::Keep Self::Keep
} }
} }
@ -1009,7 +1009,7 @@ impl StencilStateFaceDescriptor {
impl Default for StencilStateFaceDescriptor { impl Default for StencilStateFaceDescriptor {
fn default() -> Self { fn default() -> Self {
StencilStateFaceDescriptor::IGNORE Self::IGNORE
} }
} }
@ -1040,7 +1040,7 @@ pub enum CompareFunction {
impl CompareFunction { impl CompareFunction {
pub fn needs_ref_value(self) -> bool { pub fn needs_ref_value(self) -> bool {
match self { match self {
CompareFunction::Never | CompareFunction::Always => false, Self::Never | Self::Always => false,
_ => true, _ => true,
} }
} }
@ -1145,32 +1145,29 @@ pub enum VertexFormat {
impl VertexFormat { impl VertexFormat {
pub fn size(&self) -> u64 { pub fn size(&self) -> u64 {
match self { match self {
VertexFormat::Uchar2 Self::Uchar2 | Self::Char2 | Self::Uchar2Norm | Self::Char2Norm => 2,
| VertexFormat::Char2 Self::Uchar4
| VertexFormat::Uchar2Norm | Self::Char4
| VertexFormat::Char2Norm => 2, | Self::Uchar4Norm
VertexFormat::Uchar4 | Self::Char4Norm
| VertexFormat::Char4 | Self::Ushort2
| VertexFormat::Uchar4Norm | Self::Short2
| VertexFormat::Char4Norm | Self::Ushort2Norm
| VertexFormat::Ushort2 | Self::Short2Norm
| VertexFormat::Short2 | Self::Half2
| VertexFormat::Ushort2Norm | Self::Float
| VertexFormat::Short2Norm | Self::Uint
| VertexFormat::Half2 | Self::Int => 4,
| VertexFormat::Float Self::Ushort4
| VertexFormat::Uint | Self::Short4
| VertexFormat::Int => 4, | Self::Ushort4Norm
VertexFormat::Ushort4 | Self::Short4Norm
| VertexFormat::Short4 | Self::Half4
| VertexFormat::Ushort4Norm | Self::Float2
| VertexFormat::Short4Norm | Self::Uint2
| VertexFormat::Half4 | Self::Int2 => 8,
| VertexFormat::Float2 Self::Float3 | Self::Uint3 | Self::Int3 => 12,
| VertexFormat::Uint2 Self::Float4 | Self::Uint4 | Self::Int4 => 16,
| VertexFormat::Int2 => 8,
VertexFormat::Float3 | VertexFormat::Uint3 | VertexFormat::Int3 => 12,
VertexFormat::Float4 | VertexFormat::Uint4 | VertexFormat::Int4 => 16,
} }
} }
} }
@ -1357,37 +1354,37 @@ pub struct Color {
} }
impl Color { impl Color {
pub const TRANSPARENT: Self = Color { pub const TRANSPARENT: Self = Self {
r: 0.0, r: 0.0,
g: 0.0, g: 0.0,
b: 0.0, b: 0.0,
a: 0.0, a: 0.0,
}; };
pub const BLACK: Self = Color { pub const BLACK: Self = Self {
r: 0.0, r: 0.0,
g: 0.0, g: 0.0,
b: 0.0, b: 0.0,
a: 1.0, a: 1.0,
}; };
pub const WHITE: Self = Color { pub const WHITE: Self = Self {
r: 1.0, r: 1.0,
g: 1.0, g: 1.0,
b: 1.0, b: 1.0,
a: 1.0, a: 1.0,
}; };
pub const RED: Self = Color { pub const RED: Self = Self {
r: 1.0, r: 1.0,
g: 0.0, g: 0.0,
b: 0.0, b: 0.0,
a: 1.0, a: 1.0,
}; };
pub const GREEN: Self = Color { pub const GREEN: Self = Self {
r: 0.0, r: 0.0,
g: 1.0, g: 1.0,
b: 0.0, b: 0.0,
a: 1.0, a: 1.0,
}; };
pub const BLUE: Self = Color { pub const BLUE: Self = Self {
r: 0.0, r: 0.0,
g: 0.0, g: 0.0,
b: 1.0, b: 1.0,
@ -1421,12 +1418,12 @@ pub struct Origin3d {
} }
impl Origin3d { impl Origin3d {
pub const ZERO: Self = Origin3d { x: 0, y: 0, z: 0 }; pub const ZERO: Self = Self { x: 0, y: 0, z: 0 };
} }
impl Default for Origin3d { impl Default for Origin3d {
fn default() -> Self { fn default() -> Self {
Origin3d::ZERO Self::ZERO
} }
} }
@ -1443,7 +1440,7 @@ pub struct Extent3d {
impl Default for Extent3d { impl Default for Extent3d {
fn default() -> Self { fn default() -> Self {
Extent3d { Self {
width: 1, width: 1,
height: 1, height: 1,
depth: 1, depth: 1,
@ -1504,7 +1501,7 @@ pub enum TextureAspect {
impl Default for TextureAspect { impl Default for TextureAspect {
fn default() -> Self { fn default() -> Self {
TextureAspect::All Self::All
} }
} }
@ -1539,7 +1536,7 @@ pub enum AddressMode {
impl Default for AddressMode { impl Default for AddressMode {
fn default() -> Self { fn default() -> Self {
AddressMode::ClampToEdge Self::ClampToEdge
} }
} }
@ -1561,7 +1558,7 @@ pub enum FilterMode {
impl Default for FilterMode { impl Default for FilterMode {
fn default() -> Self { fn default() -> Self {
FilterMode::Nearest Self::Nearest
} }
} }
@ -1832,8 +1829,7 @@ pub enum BindingType {
impl BindingType { impl BindingType {
pub fn has_dynamic_offset(&self) -> bool { pub fn has_dynamic_offset(&self) -> bool {
match *self { match *self {
BindingType::UniformBuffer { dynamic, .. } Self::UniformBuffer { dynamic, .. } | Self::StorageBuffer { dynamic, .. } => dynamic,
| BindingType::StorageBuffer { dynamic, .. } => dynamic,
_ => false, _ => false,
} }
} }