mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 00:11:11 +01:00
Add support for gaps in bind group layouts & update relevant validation (#9034)
* [wgpu-core] add support for optional BG & BGL entries * [wgpu] allow gaps in bind group layouts And allow unbinding in the web backend. * adapt tests * add changelog entry * [wgpu] remove generic from `PipelineLayoutDescriptor`
This commit is contained in:
1 parent
aad2a00f4d
commit
e114d2f0a7
90 files changed
+567
-397
No files matched your search
@@ -35,7 +35,7 @@ pub struct PipelineLayoutDescriptor<'a> {
|
||||
pub label: Label<'a>,
|
||||
/// Bind groups that this pipeline uses. The first entry will provide all the bindings for
|
||||
/// "set = 0", second entry will provide all the bindings for "set = 1" etc.
|
||||
pub bind_group_layouts: &'a [&'a BindGroupLayout],
|
||||
pub bind_group_layouts: &'a [Option<&'a BindGroupLayout>],
|
||||
/// The number of bytes of immediate data that are allocated for use
|
||||
/// in the shader. The `var<immediate>`s in the shader attached to
|
||||
/// this pipeline must be equal or smaller than this size.
|
||||
|
||||
+14
-19
@@ -2129,10 +2129,14 @@ impl dispatch::DeviceInterface for WebDevice {
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<'_>,
|
||||
) -> dispatch::DispatchPipelineLayout {
|
||||
let null = wasm_bindgen::JsValue::NULL;
|
||||
let temp_layouts = desc
|
||||
.bind_group_layouts
|
||||
.iter()
|
||||
.map(|bgl| &bgl.inner.as_webgpu().inner)
|
||||
.map(|bgl| match bgl {
|
||||
Some(bgl) => bgl.inner.as_webgpu().inner.as_ref(),
|
||||
None => &null,
|
||||
})
|
||||
.collect::<js_sys::Array>();
|
||||
let mapped_desc = webgpu_sys::GpuPipelineLayoutDescriptor::new(&temp_layouts);
|
||||
if let Some(label) = desc.label {
|
||||
@@ -3315,18 +3319,15 @@ impl dispatch::ComputePassInterface for WebComputePassEncoder {
|
||||
bind_group: Option<&dispatch::DispatchBindGroup>,
|
||||
offsets: &[crate::DynamicOffset],
|
||||
) {
|
||||
let Some(bind_group) = bind_group else {
|
||||
return;
|
||||
};
|
||||
let bind_group = &bind_group.as_webgpu().inner;
|
||||
let bind_group = bind_group.map(|bind_group| &bind_group.as_webgpu().inner);
|
||||
|
||||
if offsets.is_empty() {
|
||||
self.inner.set_bind_group(index, Some(bind_group));
|
||||
self.inner.set_bind_group(index, bind_group);
|
||||
} else {
|
||||
self.inner
|
||||
.set_bind_group_with_u32_slice_and_f64_and_dynamic_offsets_data_length(
|
||||
index,
|
||||
Some(bind_group),
|
||||
bind_group,
|
||||
offsets,
|
||||
0f64,
|
||||
offsets.len() as u32,
|
||||
@@ -3402,18 +3403,15 @@ impl dispatch::RenderPassInterface for WebRenderPassEncoder {
|
||||
bind_group: Option<&dispatch::DispatchBindGroup>,
|
||||
offsets: &[crate::DynamicOffset],
|
||||
) {
|
||||
let Some(bind_group) = bind_group else {
|
||||
return;
|
||||
};
|
||||
let bind_group = &bind_group.as_webgpu().inner;
|
||||
let bind_group = bind_group.map(|bind_group| &bind_group.as_webgpu().inner);
|
||||
|
||||
if offsets.is_empty() {
|
||||
self.inner.set_bind_group(index, Some(bind_group));
|
||||
self.inner.set_bind_group(index, bind_group);
|
||||
} else {
|
||||
self.inner
|
||||
.set_bind_group_with_u32_slice_and_f64_and_dynamic_offsets_data_length(
|
||||
index,
|
||||
Some(bind_group),
|
||||
bind_group,
|
||||
offsets,
|
||||
0f64,
|
||||
offsets.len() as u32,
|
||||
@@ -3696,18 +3694,15 @@ impl dispatch::RenderBundleEncoderInterface for WebRenderBundleEncoder {
|
||||
bind_group: Option<&dispatch::DispatchBindGroup>,
|
||||
offsets: &[crate::DynamicOffset],
|
||||
) {
|
||||
let Some(bind_group) = bind_group else {
|
||||
return;
|
||||
};
|
||||
let bind_group = &bind_group.as_webgpu().inner;
|
||||
let bind_group = bind_group.map(|bind_group| &bind_group.as_webgpu().inner);
|
||||
|
||||
if offsets.is_empty() {
|
||||
self.inner.set_bind_group(index, Some(bind_group));
|
||||
self.inner.set_bind_group(index, bind_group);
|
||||
} else {
|
||||
self.inner
|
||||
.set_bind_group_with_u32_slice_and_f64_and_dynamic_offsets_data_length(
|
||||
index,
|
||||
Some(bind_group),
|
||||
bind_group,
|
||||
offsets,
|
||||
0f64,
|
||||
offsets.len() as u32,
|
||||
|
||||
@@ -1283,7 +1283,7 @@ impl dispatch::DeviceInterface for CoreDevice {
|
||||
let temp_layouts = desc
|
||||
.bind_group_layouts
|
||||
.iter()
|
||||
.map(|bgl| bgl.inner.as_core().id)
|
||||
.map(|bgl| bgl.map(|bgl| bgl.inner.as_core().id))
|
||||
.collect::<ArrayVec<_, { wgc::MAX_BIND_GROUPS }>>();
|
||||
let descriptor = wgc::binding_model::PipelineLayoutDescriptor {
|
||||
label: desc.label.map(Borrowed),
|
||||
|
||||
@@ -93,7 +93,7 @@ impl<'a> TextureBlitterBuilder<'a> {
|
||||
.device
|
||||
.create_pipeline_layout(&PipelineLayoutDescriptor {
|
||||
label: Some("wgpu::util::TextureBlitter::pipeline_layout"),
|
||||
bind_group_layouts: &[&bind_group_layout],
|
||||
bind_group_layouts: &[Some(&bind_group_layout)],
|
||||
immediate_size: 0,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user