mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[deno] Implement nullable vertex buffer layouts
This commit is contained in:
parent
27e7408f16
commit
2db1d71f1b
@ -680,29 +680,26 @@ impl GPUDevice {
|
||||
.buffers
|
||||
.into_iter()
|
||||
.map(|b| {
|
||||
let layout = b.into_option().ok_or_else(|| {
|
||||
JsErrorBox::type_error(
|
||||
"Nullable GPUVertexBufferLayouts are currently not supported",
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(wgpu_core::pipeline::VertexBufferLayout {
|
||||
array_stride: layout.array_stride,
|
||||
step_mode: layout.step_mode.into(),
|
||||
attributes: Cow::Owned(
|
||||
layout
|
||||
.attributes
|
||||
.into_iter()
|
||||
.map(|attr| wgpu_types::VertexAttribute {
|
||||
format: attr.format.into(),
|
||||
offset: attr.offset,
|
||||
shader_location: attr.shader_location,
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
})
|
||||
b.into_option().map_or_else(
|
||||
wgpu_core::pipeline::VertexBufferLayout::default,
|
||||
|layout| wgpu_core::pipeline::VertexBufferLayout {
|
||||
array_stride: layout.array_stride,
|
||||
step_mode: layout.step_mode.into(),
|
||||
attributes: Cow::Owned(
|
||||
layout
|
||||
.attributes
|
||||
.into_iter()
|
||||
.map(|attr| wgpu_types::VertexAttribute {
|
||||
format: attr.format.into(),
|
||||
offset: attr.offset,
|
||||
shader_location: attr.shader_location,
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect::<Result<_, JsErrorBox>>()?,
|
||||
.collect(),
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
@ -371,6 +371,17 @@ pub struct VertexBufferLayout<'a> {
|
||||
pub attributes: Cow<'a, [wgt::VertexAttribute]>,
|
||||
}
|
||||
|
||||
/// A null vertex buffer layout that may be placed in unused slots.
|
||||
impl Default for VertexBufferLayout<'_> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
array_stride: Default::default(),
|
||||
step_mode: Default::default(),
|
||||
attributes: Cow::Borrowed(&[]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the vertex process in a render pipeline.
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user