mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-28 09:09:19 +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
@@ -2514,6 +2514,12 @@ impl super::Adapter {
|
||||
|
||||
let drop_guard = crate::DropGuard::from_option(drop_callback);
|
||||
|
||||
let empty_descriptor_set_layout = unsafe {
|
||||
raw_device
|
||||
.create_descriptor_set_layout(&vk::DescriptorSetLayoutCreateInfo::default(), None)
|
||||
.map_err(super::map_host_device_oom_err)?
|
||||
};
|
||||
|
||||
let shared = Arc::new(super::DeviceShared {
|
||||
raw: raw_device,
|
||||
family_index,
|
||||
@@ -2544,6 +2550,7 @@ impl super::Adapter {
|
||||
|
||||
texture_identity_factory: super::ResourceIdentityFactory::new(),
|
||||
texture_view_identity_factory: super::ResourceIdentityFactory::new(),
|
||||
empty_descriptor_set_layout,
|
||||
});
|
||||
|
||||
let relay_semaphores = super::RelaySemaphores::new(&shared)?;
|
||||
|
||||
@@ -1420,7 +1420,19 @@ impl crate::Device for super::Device {
|
||||
let vk_set_layouts = desc
|
||||
.bind_group_layouts
|
||||
.iter()
|
||||
.map(|bgl| bgl.raw)
|
||||
.map(|bgl| match bgl {
|
||||
Some(bgl) => bgl.raw,
|
||||
None => {
|
||||
// `VUID-VkPipelineLayoutCreateInfo-pSetLayouts-parameter`
|
||||
// says `VK_NULL_HANDLE` is allowed but
|
||||
// `VUID-VkPipelineLayoutCreateInfo-graphicsPipelineLibrary-06753`
|
||||
// says it's not, unless the `graphicsPipelineLibrary`
|
||||
// feature is enabled.
|
||||
//
|
||||
// We use an empty descriptor set layout to work around this.
|
||||
self.shared.empty_descriptor_set_layout
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let vk_immediates_ranges: Option<vk::PushConstantRange> = if desc.immediate_size != 0 {
|
||||
Some(vk::PushConstantRange {
|
||||
@@ -1452,7 +1464,11 @@ impl crate::Device for super::Device {
|
||||
}
|
||||
|
||||
let mut binding_map = BTreeMap::new();
|
||||
for (group, &layout) in desc.bind_group_layouts.iter().enumerate() {
|
||||
for (group, layout) in desc.bind_group_layouts.iter().enumerate() {
|
||||
let Some(layout) = layout else {
|
||||
continue;
|
||||
};
|
||||
|
||||
for &(binding, binding_info) in &layout.binding_map {
|
||||
binding_map.insert(
|
||||
naga::ResourceBinding {
|
||||
|
||||
@@ -495,6 +495,8 @@ struct DeviceShared {
|
||||
/// As above, for texture views.
|
||||
texture_view_identity_factory: ResourceIdentityFactory<vk::ImageView>,
|
||||
|
||||
empty_descriptor_set_layout: vk::DescriptorSetLayout,
|
||||
|
||||
// The `drop_guard` field must be the last field of this struct so it is dropped last.
|
||||
// Do not add new fields after it.
|
||||
drop_guard: Option<crate::DropGuard>,
|
||||
@@ -505,6 +507,10 @@ impl Drop for DeviceShared {
|
||||
for &raw in self.render_passes.lock().values() {
|
||||
unsafe { self.raw.destroy_render_pass(raw, None) };
|
||||
}
|
||||
unsafe {
|
||||
self.raw
|
||||
.destroy_descriptor_set_layout(self.empty_descriptor_set_layout, None)
|
||||
};
|
||||
if self.drop_guard.is_none() {
|
||||
unsafe { self.raw.destroy_device(None) };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user