Skip to content

Commit

Permalink
allow descriptor bindings with update_after_bind or partially_bound t…
Browse files Browse the repository at this point in the history
…o be unbound on recording a draw/dispatch command
  • Loading branch information
Firestar99 committed Jun 19, 2024
1 parent 2a33769 commit e333733
Showing 1 changed file with 103 additions and 97 deletions.
200 changes: 103 additions & 97 deletions vulkano/src/command_buffer/commands/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
DrawMeshTasksIndirectCommand, RecordingCommandBuffer, ResourceInCommand, SubpassContents,
},
descriptor_set::{
layout::DescriptorType, DescriptorBindingResources, DescriptorBufferInfo,
DescriptorImageViewInfo,
layout::{DescriptorBindingFlags, DescriptorType},
DescriptorBindingResources, DescriptorBufferInfo, DescriptorImageViewInfo,
},
device::{DeviceOwned, QueueFlags},
format::{FormatFeatures, NumericType},
Expand Down Expand Up @@ -2146,101 +2146,107 @@ impl RecordingCommandBuffer {
Ok(())
};

let set_resources = descriptor_set_state
.descriptor_sets
.get(&set_num)
.ok_or_else(|| {
Box::new(ValidationError {
problem: format!(
"the currently bound pipeline accesses descriptor set {set_num}, but \
no descriptor set was previously bound"
)
.into(),
// vuids?
..Default::default()
})
})?
.resources();

let binding_resources = set_resources.binding(binding_num).unwrap();

match binding_resources {
DescriptorBindingResources::None(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_none,
)?;
}
DescriptorBindingResources::Buffer(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_buffer,
)?;
}
DescriptorBindingResources::BufferView(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_buffer_view,
)?;
}
DescriptorBindingResources::ImageView(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_image_view,
)?;
}
DescriptorBindingResources::ImageViewSampler(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_image_view_sampler,
)?;
}
DescriptorBindingResources::Sampler(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_sampler,
)?;
}
// Spec:
// Descriptor bindings with descriptor type of
// VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK can be undefined when
// the descriptor set is consumed; though values in that block will be undefined.
//
// TODO: We *may* still want to validate this?
DescriptorBindingResources::InlineUniformBlock => (),
DescriptorBindingResources::AccelerationStructure(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_acceleration_structure,
)?;
let flags_skip_binding_validation =
DescriptorBindingFlags::UPDATE_AFTER_BIND | DescriptorBindingFlags::PARTIALLY_BOUND;
let requires_binding_validation =
(layout_binding.binding_flags & flags_skip_binding_validation).is_empty();
if requires_binding_validation {
let set_resources = descriptor_set_state
.descriptor_sets
.get(&set_num)
.ok_or_else(|| {
Box::new(ValidationError {
problem: format!(
"the currently bound pipeline accesses descriptor set {set_num}, \
but no descriptor set was previously bound"
)
.into(),
// vuids?
..Default::default()
})
})?
.resources();

let binding_resources = set_resources.binding(binding_num).unwrap();

match binding_resources {
DescriptorBindingResources::None(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_none,
)?;
}
DescriptorBindingResources::Buffer(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_buffer,
)?;
}
DescriptorBindingResources::BufferView(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_buffer_view,
)?;
}
DescriptorBindingResources::ImageView(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_image_view,
)?;
}
DescriptorBindingResources::ImageViewSampler(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_image_view_sampler,
)?;
}
DescriptorBindingResources::Sampler(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_sampler,
)?;
}
// Spec:
// Descriptor bindings with descriptor type of
// VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK can be undefined when the descriptor
// set is consumed; though values in that block will be undefined.
//
// TODO: We *may* still want to validate this?
DescriptorBindingResources::InlineUniformBlock => (),
DescriptorBindingResources::AccelerationStructure(elements) => {
validate_resources(
vuid_type,
set_num,
binding_num,
binding_reqs,
elements,
check_acceleration_structure,
)?;
}
}
}
}
Expand Down

0 comments on commit e333733

Please sign in to comment.