Remove remaining old error types, other cleanup (#2281)

* Remove remaining old error types, other cleanup

* Fix

* Add and fix or_fun_call lints

* Update vulkano/src/query.rs

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>

* Fix slightly borked context messages

---------

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>
This commit is contained in:
Rua 2023-08-09 21:19:38 +02:00 committed by GitHub
parent c8b50b11fc
commit c0379fce96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 1323 additions and 1909 deletions

View File

@ -817,10 +817,7 @@ impl TypeStruct {
members.push(Member { ident, ty, offset }); members.push(Member { ident, ty, offset });
} }
Ok(TypeStruct { Ok(TypeStruct { ident, members })
ident,
members,
})
} }
fn size(&self) -> Option<usize> { fn size(&self) -> Option<usize> {

View File

@ -291,7 +291,7 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
let ident = format_ident!("{}", ext_name); let ident = format_ident!("{}", ext_name);
quote! { instance_extensions.#ident } quote! { instance_extensions.#ident }
})); }));
let required_for = format!("`Format::{}`", name); let required_for = format!("is `Format::{}`", name);
let requires_one_of_items = (api_version.iter().map(|(major, minor)| { let requires_one_of_items = (api_version.iter().map(|(major, minor)| {
let version = format_ident!("V{}_{}", major, minor); let version = format_ident!("V{}_{}", major, minor);
quote! { quote! {
@ -317,12 +317,13 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
quote! { quote! {
if !(#(#condition_items)||*) { if !(#(#condition_items)||*) {
return Err(crate::RequirementNotMet { return Err(Box::new(crate::ValidationError {
required_for: #required_for, problem: #required_for.into(),
requires_one_of: crate::RequiresOneOf(&[ requires_one_of: crate::RequiresOneOf(&[
#(#requires_one_of_items)* #(#requires_one_of_items)*
]), ]),
}); ..Default::default()
}));
} }
} }
}, },
@ -482,7 +483,7 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
pub(crate) fn validate_device( pub(crate) fn validate_device(
self, self,
#[allow(unused_variables)] device: &crate::device::Device, #[allow(unused_variables)] device: &crate::device::Device,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
device.api_version(), device.api_version(),
device.enabled_features(), device.enabled_features(),
@ -495,7 +496,7 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
pub(crate) fn validate_physical_device( pub(crate) fn validate_physical_device(
self, self,
#[allow(unused_variables)] physical_device: &crate::device::physical::PhysicalDevice, #[allow(unused_variables)] physical_device: &crate::device::physical::PhysicalDevice,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
physical_device.api_version(), physical_device.api_version(),
physical_device.supported_features(), physical_device.supported_features(),
@ -511,7 +512,7 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
#[allow(unused_variables)] device_features: &crate::device::Features, #[allow(unused_variables)] device_features: &crate::device::Features,
#[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions, #[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions,
#[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions, #[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
match self { match self {
#(#validate_device_items)* #(#validate_device_items)*
} }

View File

@ -378,18 +378,14 @@ impl AccelerationStructureCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
create_flags create_flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("create_flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAccelerationStructureCreateInfoKHR-createFlags-parameter"])
context: "create_flags".into(), })?;
vuids: &["VUID-VkAccelerationStructureCreateInfoKHR-createFlags-parameter"],
..ValidationError::from_requirement(err)
})?;
ty.validate_device(device).map_err(|err| ValidationError { ty.validate_device(device).map_err(|err| {
context: "ty".into(), err.add_context("ty")
vuids: &["VUID-VkAccelerationStructureCreateInfoKHR-type-parameter"], .set_vuids(&["VUID-VkAccelerationStructureCreateInfoKHR-type-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if !buffer if !buffer
@ -513,13 +509,10 @@ impl AccelerationStructureBuildGeometryInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
let max_geometry_count = device let max_geometry_count = device
.physical_device() .physical_device()
@ -1009,23 +1002,16 @@ impl AccelerationStructureGeometryTrianglesData {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
vertex_format vertex_format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("vertex_format").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter",
context: "vertex_format".into(), ])
vuids: &[ })?;
"VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter",
],
..ValidationError::from_requirement(err)
})?;
if unsafe { if unsafe {
!device !device
@ -1127,13 +1113,10 @@ impl AccelerationStructureGeometryAabbsData {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if stride % 8 != 0 { if stride % 8 != 0 {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1199,13 +1182,10 @@ impl AccelerationStructureGeometryInstancesData {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkAccelerationStructureGeometryKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -1402,12 +1382,10 @@ impl CopyAccelerationStructureInfo {
assert_eq!(device, src.device().as_ref()); assert_eq!(device, src.device().as_ref());
assert_eq!(device, dst.device().as_ref()); assert_eq!(device, dst.device().as_ref());
mode.validate_device(device) mode.validate_device(device).map_err(|err| {
.map_err(|err| ValidationError { err.add_context("mode")
context: "mode".into(), .set_vuids(&["VUID-VkCopyAccelerationStructureInfoKHR-mode-parameter"])
vuids: &["VUID-VkCopyAccelerationStructureInfoKHR-mode-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
mode, mode,
@ -1485,12 +1463,10 @@ impl CopyAccelerationStructureToMemoryInfo {
assert_eq!(device, src.device().as_ref()); assert_eq!(device, src.device().as_ref());
assert_eq!(device, dst.device().as_ref()); assert_eq!(device, dst.device().as_ref());
mode.validate_device(device) mode.validate_device(device).map_err(|err| {
.map_err(|err| ValidationError { err.add_context("mode")
context: "mode".into(), .set_vuids(&["VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-parameter"])
vuids: &["VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
if !matches!(mode, CopyAccelerationStructureMode::Serialize) { if !matches!(mode, CopyAccelerationStructureMode::Serialize) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1555,12 +1531,10 @@ impl CopyMemoryToAccelerationStructureInfo {
assert_eq!(device, src.device().as_ref()); assert_eq!(device, src.device().as_ref());
assert_eq!(device, dst.device().as_ref()); assert_eq!(device, dst.device().as_ref());
mode.validate_device(device) mode.validate_device(device).map_err(|err| {
.map_err(|err| ValidationError { err.add_context("mode")
context: "mode".into(), .set_vuids(&["VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-parameter"])
vuids: &["VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
if !matches!(mode, CopyAccelerationStructureMode::Deserialize) { if !matches!(mode, CopyAccelerationStructureMode::Deserialize) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -912,18 +912,16 @@ impl ExternalBufferInfo {
flags flags
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "flags".into(), err.add_context("flags")
vuids: &["VUID-VkPhysicalDeviceExternalBufferInfo-flags-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceExternalBufferInfo-flags-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
usage usage
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "usage".into(), err.add_context("usage")
vuids: &["VUID-VkPhysicalDeviceExternalBufferInfo-usage-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceExternalBufferInfo-usage-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if usage.is_empty() { if usage.is_empty() {
@ -937,10 +935,9 @@ impl ExternalBufferInfo {
handle_type handle_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "handle_type".into(), err.add_context("handle_type")
vuids: &["VUID-VkPhysicalDeviceExternalBufferInfo-handleType-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceExternalBufferInfo-handleType-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
Ok(()) Ok(())

View File

@ -340,12 +340,12 @@ where
}; };
} }
let mapped_ptr = let mapped_ptr = self.mapped_ptr().ok_or_else(|| {
self.mapped_ptr() HostAccessError::ValidationError(Box::new(ValidationError {
.ok_or(HostAccessError::ValidationError(ValidationError { problem: "the memory of this subbuffer is not host-visible".into(),
problem: "the memory of this subbuffer is not host-visible".into(), ..Default::default()
..Default::default() }))
}))?; })?;
// SAFETY: `Subbuffer` guarantees that its contents are laid out correctly for `T`. // SAFETY: `Subbuffer` guarantees that its contents are laid out correctly for `T`.
let data = unsafe { &*T::from_ffi(mapped_ptr.as_ptr(), self.size as usize) }; let data = unsafe { &*T::from_ffi(mapped_ptr.as_ptr(), self.size as usize) };
@ -415,12 +415,12 @@ where
}; };
} }
let mapped_ptr = let mapped_ptr = self.mapped_ptr().ok_or_else(|| {
self.mapped_ptr() HostAccessError::ValidationError(Box::new(ValidationError {
.ok_or(HostAccessError::ValidationError(ValidationError { problem: "the memory of this subbuffer is not host-visible".into(),
problem: "the memory of this subbuffer is not host-visible".into(), ..Default::default()
..Default::default() }))
}))?; })?;
// SAFETY: `Subbuffer` guarantees that its contents are laid out correctly for `T`. // SAFETY: `Subbuffer` guarantees that its contents are laid out correctly for `T`.
let data = unsafe { &mut *T::from_ffi(mapped_ptr.as_ptr(), self.size as usize) }; let data = unsafe { &mut *T::from_ffi(mapped_ptr.as_ptr(), self.size as usize) };

View File

@ -674,21 +674,15 @@ impl BufferCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkBufferCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
usage usage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("usage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferCreateInfo-usage-parameter"])
context: "usage".into(), })?;
vuids: &["VUID-VkBufferCreateInfo-usage-parameter"],
..ValidationError::from_requirement(err)
})?;
if usage.is_empty() { if usage.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -819,10 +813,9 @@ impl BufferCreateInfo {
external_memory_handle_types external_memory_handle_types
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "external_memory_handle_types".into(), err.add_context("external_memory_handle_types")
vuids: &["VUID-VkExternalMemoryBufferCreateInfo-handleTypes-parameter"], .set_vuids(&["VUID-VkExternalMemoryBufferCreateInfo-handleTypes-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
// TODO: // TODO:

View File

@ -439,13 +439,10 @@ impl BufferViewCreateInfo {
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> { pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
let Self { format, _ne: _ } = self; let Self { format, _ne: _ } = self;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferViewCreateInfo-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkBufferViewCreateInfo-format-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -482,10 +482,9 @@ where
) -> Result<(), Box<ValidationError>> { ) -> Result<(), Box<ValidationError>> {
pipeline_bind_point pipeline_bind_point
.validate_device(self.device()) .validate_device(self.device())
.map_err(|err| ValidationError { .map_err(|err| {
context: "pipeline_bind_point".into(), err.add_context("pipeline_bind_point")
vuids: &["VUID-vkCmdBindDescriptorSets-pipelineBindPoint-parameter"], .set_vuids(&["VUID-vkCmdBindDescriptorSets-pipelineBindPoint-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
let queue_family_properties = self.queue_family_properties(); let queue_family_properties = self.queue_family_properties();
@ -1185,10 +1184,9 @@ where
pipeline_bind_point pipeline_bind_point
.validate_device(self.device()) .validate_device(self.device())
.map_err(|err| ValidationError { .map_err(|err| {
context: "pipeline_bind_point".into(), err.add_context("pipeline_bind_point")
vuids: &["VUID-vkCmdPushDescriptorSetKHR-pipelineBindPoint-parameter"], .set_vuids(&["VUID-vkCmdPushDescriptorSetKHR-pipelineBindPoint-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
let queue_family_properties = self.queue_family_properties(); let queue_family_properties = self.queue_family_properties();

View File

@ -703,13 +703,10 @@ impl ClearColorImageInfo {
_ne: _, _ne: _,
} = self; } = self;
image_layout image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdClearColorImage-imageLayout-parameter"])
context: "image_layout".into(), })?;
vuids: &["VUID-vkCmdClearColorImage-imageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-vkCmdClearColorImage-commonparent // VUID-vkCmdClearColorImage-commonparent
assert_eq!(device, image.device().as_ref()); assert_eq!(device, image.device().as_ref());
@ -885,13 +882,10 @@ impl ClearDepthStencilImageInfo {
_ne: _, _ne: _,
} = self; } = self;
image_layout image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdClearDepthStencilImage-imageLayout-parameter"])
context: "image_layout".into(), })?;
vuids: &["VUID-vkCmdClearDepthStencilImage-imageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-vkCmdClearDepthStencilImage-commonparent // VUID-vkCmdClearDepthStencilImage-commonparent
assert_eq!(device, image.device().as_ref()); assert_eq!(device, image.device().as_ref());

View File

@ -2514,21 +2514,15 @@ impl CopyImageInfo {
_ne: _, _ne: _,
} = self; } = self;
src_image_layout src_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCopyImageInfo2-srcImageLayout-parameter"])
context: "src_image_layout".into(), })?;
vuids: &["VUID-VkCopyImageInfo2-srcImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_image_layout dst_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCopyImageInfo2-dstImageLayout-parameter"])
context: "dst_image_layout".into(), })?;
vuids: &["VUID-VkCopyImageInfo2-dstImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkCopyImageInfo2-commonparent // VUID-VkCopyImageInfo2-commonparent
assert_eq!(device, src_image.device().as_ref()); assert_eq!(device, src_image.device().as_ref());
@ -3878,13 +3872,10 @@ impl CopyBufferToImageInfo {
_ne: _, _ne: _,
} = self; } = self;
dst_image_layout dst_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCopyBufferToImageInfo2-dstImageLayout-parameter"])
context: "dst_image_layout".into(), })?;
vuids: &["VUID-VkCopyBufferToImageInfo2-dstImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkCopyBufferToImageInfo2-commonparent // VUID-VkCopyBufferToImageInfo2-commonparent
assert_eq!(device, src_buffer.device().as_ref()); assert_eq!(device, src_buffer.device().as_ref());
@ -4490,13 +4481,10 @@ impl CopyImageToBufferInfo {
_ne: _, _ne: _,
} = self; } = self;
src_image_layout src_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCopyImageToBufferInfo2-srcImageLayout-parameter"])
context: "src_image_layout".into(), })?;
vuids: &["VUID-VkCopyImageToBufferInfo2-srcImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkCopyImageToBufferInfo2-commonparent // VUID-VkCopyImageToBufferInfo2-commonparent
assert_eq!(device, src_image.device().as_ref()); assert_eq!(device, src_image.device().as_ref());
@ -5308,29 +5296,20 @@ impl BlitImageInfo {
_ne: _, _ne: _,
} = self; } = self;
src_image_layout src_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBlitImageInfo2-srcImageLayout-parameter"])
context: "src_image_layout".into(), })?;
vuids: &["VUID-VkBlitImageInfo2-srcImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_image_layout dst_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBlitImageInfo2-dstImageLayout-parameter"])
context: "dst_image_layout".into(), })?;
vuids: &["VUID-VkBlitImageInfo2-dstImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
filter filter.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("filter")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBlitImageInfo2-filter-parameter"])
context: "filter".into(), })?;
vuids: &["VUID-VkBlitImageInfo2-filter-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkBlitImageInfo2-commonparent // VUID-VkBlitImageInfo2-commonparent
assert_eq!(device, src_image.device().as_ref()); assert_eq!(device, src_image.device().as_ref());
@ -6221,21 +6200,15 @@ impl ResolveImageInfo {
_ne: _, _ne: _,
} = self; } = self;
src_image_layout src_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkResolveImageInfo2-srcImageLayout-parameter"])
context: "src_image_layout".into(), })?;
vuids: &["VUID-VkResolveImageInfo2-srcImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_image_layout dst_image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkResolveImageInfo2-dstImageLayout-parameter"])
context: "dst_image_layout".into(), })?;
vuids: &["VUID-VkResolveImageInfo2-dstImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkResolveImageInfo2-commonparent // VUID-VkResolveImageInfo2-commonparent
assert_eq!(device, src_image.device().as_ref()); assert_eq!(device, src_image.device().as_ref());

View File

@ -1312,13 +1312,10 @@ where
})); }));
} }
cull_mode cull_mode.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("cull_mode")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetCullMode-cullMode-parameter"])
context: "cull_mode".into(), })?;
vuids: &["VUID-vkCmdSetCullMode-cullMode-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -1611,13 +1608,10 @@ where
})); }));
} }
compare_op compare_op.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("compare_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetDepthCompareOp-depthCompareOp-parameter"])
context: "compare_op".into(), })?;
vuids: &["VUID-vkCmdSetDepthCompareOp-depthCompareOp-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -1863,12 +1857,10 @@ where
})); }));
} }
face.validate_device(self.device()) face.validate_device(self.device()).map_err(|err| {
.map_err(|err| ValidationError { err.add_context("face")
context: "face".into(), .set_vuids(&["VUID-vkCmdSetFrontFace-frontFace-parameter"])
vuids: &["VUID-vkCmdSetFrontFace-frontFace-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2028,13 +2020,10 @@ where
})); }));
} }
logic_op logic_op.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("logic_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetLogicOpEXT-logicOp-parameter"])
context: "logic_op".into(), })?;
vuids: &["VUID-vkCmdSetLogicOpEXT-logicOp-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2214,13 +2203,10 @@ where
})); }));
} }
topology topology.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("topology")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetPrimitiveTopology-primitiveTopology-parameter"])
context: "topology".into(), })?;
vuids: &["VUID-vkCmdSetPrimitiveTopology-primitiveTopology-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID? // VUID?
// Since these requirements exist for fixed state when creating the pipeline, // Since these requirements exist for fixed state when creating the pipeline,
@ -2561,13 +2547,10 @@ where
})); }));
} }
faces faces.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("faces")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilCompareMask-faceMask-parameter"])
context: "faces".into(), })?;
vuids: &["VUID-vkCmdSetStencilCompareMask-faceMask-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2632,45 +2615,32 @@ where
})); }));
} }
faces faces.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("faces")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilOp-faceMask-parameter"])
context: "faces".into(), })?;
vuids: &["VUID-vkCmdSetStencilOp-faceMask-parameter"],
..ValidationError::from_requirement(err)
})?;
fail_op fail_op.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("fail_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilOp-failOp-parameter"])
context: "fail_op".into(), })?;
vuids: &["VUID-vkCmdSetStencilOp-failOp-parameter"],
..ValidationError::from_requirement(err)
})?;
pass_op pass_op.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("pass_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilOp-passOp-parameter"])
context: "pass_op".into(), })?;
vuids: &["VUID-vkCmdSetStencilOp-passOp-parameter"],
..ValidationError::from_requirement(err)
})?;
depth_fail_op depth_fail_op
.validate_device(self.device()) .validate_device(self.device())
.map_err(|err| ValidationError { .map_err(|err| {
context: "depth_fail_op".into(), err.add_context("depth_fail_op")
vuids: &["VUID-vkCmdSetStencilOp-depthFailOp-parameter"], .set_vuids(&["VUID-vkCmdSetStencilOp-depthFailOp-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
compare_op compare_op.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("compare_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilOp-compareOp-parameter"])
context: "compare_op".into(), })?;
vuids: &["VUID-vkCmdSetStencilOp-compareOp-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2738,13 +2708,10 @@ where
})); }));
} }
faces faces.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("faces")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilReference-faceMask-parameter"])
context: "faces".into(), })?;
vuids: &["VUID-vkCmdSetStencilReference-faceMask-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2844,13 +2811,10 @@ where
})); }));
} }
faces faces.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("faces")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdSetStencilWriteMask-faceMask-parameter"])
context: "faces".into(), })?;
vuids: &["VUID-vkCmdSetStencilWriteMask-faceMask-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -83,11 +83,13 @@ where
.builder_state .builder_state
.pipeline_compute .pipeline_compute
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no compute pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDispatch-None-08606"], problem: "no compute pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDispatch-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::Dispatch; const VUID_TYPE: VUIDType = VUIDType::Dispatch;
@ -153,11 +155,13 @@ where
.builder_state .builder_state
.pipeline_compute .pipeline_compute
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no compute pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDispatchIndirect-None-08606"], problem: "no compute pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDispatchIndirect-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::DispatchIndirect; const VUID_TYPE: VUIDType = VUIDType::DispatchIndirect;
@ -229,25 +233,25 @@ where
self.inner self.inner
.validate_draw(vertex_count, instance_count, first_vertex, first_instance)?; .validate_draw(vertex_count, instance_count, first_vertex, first_instance)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdDraw-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdDraw-renderpass"], })?;
..Default::default()
}))?;
let pipeline = self let pipeline = self
.builder_state .builder_state
.pipeline_graphics .pipeline_graphics
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no graphics pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDraw-None-08606"], problem: "no graphics pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDraw-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::Draw; const VUID_TYPE: VUIDType = VUIDType::Draw;
@ -406,25 +410,25 @@ where
self.inner self.inner
.validate_draw_indirect(indirect_buffer, draw_count, stride)?; .validate_draw_indirect(indirect_buffer, draw_count, stride)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdDrawIndirect-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdDrawIndirect-renderpass"], })?;
..Default::default()
}))?;
let pipeline = self let pipeline = self
.builder_state .builder_state
.pipeline_graphics .pipeline_graphics
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no graphics pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDrawIndirect-None-08606"], problem: "no graphics pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDrawIndirect-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::DrawIndirect; const VUID_TYPE: VUIDType = VUIDType::DrawIndirect;
@ -534,25 +538,25 @@ where
first_instance, first_instance,
)?; )?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdDrawIndexed-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdDrawIndexed-renderpass"], })?;
..Default::default()
}))?;
let pipeline = self let pipeline = self
.builder_state .builder_state
.pipeline_graphics .pipeline_graphics
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no graphics pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDrawIndexed-None-08606"], problem: "no graphics pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDrawIndexed-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::DrawIndexed; const VUID_TYPE: VUIDType = VUIDType::DrawIndexed;
@ -562,15 +566,13 @@ where
self.validate_pipeline_graphics_render_pass(VUID_TYPE, pipeline, render_pass_state)?; self.validate_pipeline_graphics_render_pass(VUID_TYPE, pipeline, render_pass_state)?;
self.validate_pipeline_graphics_vertex_buffers(VUID_TYPE, pipeline)?; self.validate_pipeline_graphics_vertex_buffers(VUID_TYPE, pipeline)?;
let index_buffer = let index_buffer = self.builder_state.index_buffer.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.index_buffer problem: "no index buffer is currently bound".into(),
.as_ref() vuids: &["VUID-vkCmdDrawIndexed-None-07312"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "no index buffer is currently bound".into(), })
vuids: &["VUID-vkCmdDrawIndexed-None-07312"], })?;
..Default::default()
}))?;
let index_buffer_bytes = index_buffer.as_bytes(); let index_buffer_bytes = index_buffer.as_bytes();
@ -736,25 +738,25 @@ where
self.inner self.inner
.validate_draw_indexed_indirect(indirect_buffer, draw_count, stride)?; .validate_draw_indexed_indirect(indirect_buffer, draw_count, stride)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdDrawIndexedIndirect-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdDrawIndexedIndirect-renderpass"], })?;
..Default::default()
}))?;
let pipeline = self let pipeline = self
.builder_state .builder_state
.pipeline_graphics .pipeline_graphics
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "no graphics pipeline is currently bound".into(), Box::new(ValidationError {
vuids: &["VUID-vkCmdDrawIndexedIndirect-None-08606"], problem: "no graphics pipeline is currently bound".into(),
..Default::default() vuids: &["VUID-vkCmdDrawIndexedIndirect-None-08606"],
}))? ..Default::default()
})
})?
.as_ref(); .as_ref();
const VUID_TYPE: VUIDType = VUIDType::DrawIndexedIndirect; const VUID_TYPE: VUIDType = VUIDType::DrawIndexedIndirect;
@ -764,15 +766,13 @@ where
self.validate_pipeline_graphics_render_pass(VUID_TYPE, pipeline, render_pass_state)?; self.validate_pipeline_graphics_render_pass(VUID_TYPE, pipeline, render_pass_state)?;
self.validate_pipeline_graphics_vertex_buffers(VUID_TYPE, pipeline)?; self.validate_pipeline_graphics_vertex_buffers(VUID_TYPE, pipeline)?;
let _index_buffer = let _index_buffer = self.builder_state.index_buffer.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.index_buffer problem: "no index buffer is currently bound".into(),
.as_ref() vuids: &["VUID-vkCmdDrawIndexedIndirect-None-07312"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "no index buffer is currently bound".into(), })
vuids: &["VUID-vkCmdDrawIndexedIndirect-None-07312"], })?;
..Default::default()
}))?;
Ok(()) Ok(())
} }
@ -830,7 +830,7 @@ where
let elements_to_check = if let Some(descriptor_count) = binding_reqs.descriptor_count { let elements_to_check = if let Some(descriptor_count) = binding_reqs.descriptor_count {
// The shader has a fixed-sized array, so it will never access more than // The shader has a fixed-sized array, so it will never access more than
// the first `descriptor_count` elements. // the first `descriptor_count` elements.
elements.get(..descriptor_count as usize).ok_or({ elements.get(..descriptor_count as usize).ok_or_else(|| {
// There are less than `descriptor_count` elements in `elements` // There are less than `descriptor_count` elements in `elements`
Box::new(ValidationError { Box::new(ValidationError {
problem: format!( problem: format!(
@ -885,13 +885,15 @@ where
.builder_state .builder_state
.descriptor_sets .descriptor_sets
.get(&pipeline.bind_point()) .get(&pipeline.bind_point())
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "the currently bound pipeline accesses descriptor sets, but no \ Box::new(ValidationError {
problem: "the currently bound pipeline accesses descriptor sets, but no \
descriptor sets were previously bound" descriptor sets were previously bound"
.into(), .into(),
vuids: vuids!(vuid_type, "None-02697"), vuids: vuids!(vuid_type, "None-02697"),
..Default::default() ..Default::default()
}))?; })
})?;
if !pipeline.layout().is_compatible_with( if !pipeline.layout().is_compatible_with(
&descriptor_set_state.pipeline_layout, &descriptor_set_state.pipeline_layout,
@ -1352,15 +1354,17 @@ where
let set_resources = descriptor_set_state let set_resources = descriptor_set_state
.descriptor_sets .descriptor_sets
.get(&set_num) .get(&set_num)
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: format!( Box::new(ValidationError {
"the currently bound pipeline accesses descriptor set {set_num}, but \ problem: format!(
"the currently bound pipeline accesses descriptor set {set_num}, but \
no descriptor set was previously bound" no descriptor set was previously bound"
) )
.into(), .into(),
// vuids? // vuids?
..Default::default() ..Default::default()
}))? })
})?
.resources(); .resources();
let binding_resources = set_resources.binding(binding_num).unwrap(); let binding_resources = set_resources.binding(binding_num).unwrap();
@ -1464,13 +1468,15 @@ where
.builder_state .builder_state
.push_constants_pipeline_layout .push_constants_pipeline_layout
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: "the currently bound pipeline accesses push constants, but no \ Box::new(ValidationError {
problem: "the currently bound pipeline accesses push constants, but no \
push constants were previously set" push constants were previously set"
.into(), .into(),
vuids: vuids!(vuid_type, "maintenance4-06425"), vuids: vuids!(vuid_type, "maintenance4-06425"),
..Default::default() ..Default::default()
}))?; })
})?;
if pipeline_layout.handle() != constants_pipeline_layout.handle() if pipeline_layout.handle() != constants_pipeline_layout.handle()
&& pipeline_layout.push_constant_ranges() && pipeline_layout.push_constant_ranges()

View File

@ -453,13 +453,10 @@ where
let device = self.device(); let device = self.device();
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdBeginQuery-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-vkCmdBeginQuery-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-vkCmdBeginQuery-commonparent // VUID-vkCmdBeginQuery-commonparent
assert_eq!(device, query_pool.device()); assert_eq!(device, query_pool.device());
@ -673,13 +670,10 @@ where
let device = self.device(); let device = self.device();
stage stage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdWriteTimestamp2-stage-parameter"])
context: "stage".into(), })?;
vuids: &["VUID-vkCmdWriteTimestamp2-stage-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 if !device.enabled_features().synchronization2
&& PipelineStages::from(stage).contains_flags2() && PipelineStages::from(stage).contains_flags2()

View File

@ -176,15 +176,13 @@ where
self.inner self.inner
.validate_next_subpass(subpass_end_info, subpass_begin_info)?; .validate_next_subpass(subpass_end_info, subpass_begin_info)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdNextSubpass2-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdNextSubpass2-renderpass"], })?;
..Default::default()
}))?;
let begin_render_pass_state = match &render_pass_state.render_pass { let begin_render_pass_state = match &render_pass_state.render_pass {
RenderPassStateType::BeginRenderPass(state) => state, RenderPassStateType::BeginRenderPass(state) => state,
@ -279,15 +277,13 @@ where
) -> Result<(), Box<ValidationError>> { ) -> Result<(), Box<ValidationError>> {
self.inner.validate_end_render_pass(subpass_end_info)?; self.inner.validate_end_render_pass(subpass_end_info)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdEndRenderPass2-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdEndRenderPass2-renderpass"], })?;
..Default::default()
}))?;
let begin_render_pass_state = match &render_pass_state.render_pass { let begin_render_pass_state = match &render_pass_state.render_pass {
RenderPassStateType::BeginRenderPass(state) => state, RenderPassStateType::BeginRenderPass(state) => state,
@ -595,18 +591,16 @@ where
fn validate_end_rendering(&self) -> Result<(), Box<ValidationError>> { fn validate_end_rendering(&self) -> Result<(), Box<ValidationError>> {
self.inner.validate_end_rendering()?; self.inner.validate_end_rendering()?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &[
.ok_or(Box::new(ValidationError { "VUID-vkCmdEndRendering-renderpass",
problem: "a render pass instance is not active".into(), "VUID-vkCmdEndRendering-commandBuffer-06162",
vuids: &[ ],
"VUID-vkCmdEndRendering-renderpass", ..Default::default()
"VUID-vkCmdEndRendering-commandBuffer-06162", })
], })?;
..Default::default()
}))?;
match &render_pass_state.render_pass { match &render_pass_state.render_pass {
RenderPassStateType::BeginRenderPass(_) => { RenderPassStateType::BeginRenderPass(_) => {
@ -683,15 +677,13 @@ where
) -> Result<(), Box<ValidationError>> { ) -> Result<(), Box<ValidationError>> {
self.inner.validate_clear_attachments(attachments, rects)?; self.inner.validate_clear_attachments(attachments, rects)?;
let render_pass_state = let render_pass_state = self.builder_state.render_pass.as_ref().ok_or_else(|| {
self.builder_state Box::new(ValidationError {
.render_pass problem: "a render pass instance is not active".into(),
.as_ref() vuids: &["VUID-vkCmdClearAttachments-renderpass"],
.ok_or(Box::new(ValidationError { ..Default::default()
problem: "a render pass instance is not active".into(), })
vuids: &["VUID-vkCmdClearAttachments-renderpass"], })?;
..Default::default()
}))?;
if render_pass_state.contents != SubpassContents::Inline { if render_pass_state.contents != SubpassContents::Inline {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -715,15 +707,17 @@ where
.rendering_info .rendering_info
.color_attachment_formats .color_attachment_formats
.get(color_attachment as usize) .get(color_attachment as usize)
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
context: format!("attachments[{}].color_attachment", clear_index) Box::new(ValidationError {
.into(), context: format!("attachments[{}].color_attachment", clear_index)
problem: "is not less than the number of color attachments in the \ .into(),
problem: "is not less than the number of color attachments in the \
current subpass instance" current subpass instance"
.into(), .into(),
vuids: &["VUID-vkCmdClearAttachments-aspectMask-07271"], vuids: &["VUID-vkCmdClearAttachments-aspectMask-07271"],
..Default::default() ..Default::default()
}))?; })
})?;
if let Some(attachment_format) = attachment_format { if let Some(attachment_format) = attachment_format {
let required_numeric_type = attachment_format let required_numeric_type = attachment_format
@ -2030,13 +2024,10 @@ impl SubpassBeginInfo {
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> { pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
let &Self { contents, _ne: _ } = self; let &Self { contents, _ne: _ } = self;
contents contents.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("contents")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSubpassBeginInfo-contents-parameter"])
context: "contents".into(), })?;
vuids: &["VUID-VkSubpassBeginInfo-contents-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -2251,13 +2242,10 @@ impl RenderingInfo {
let properties = device.physical_device().properties(); let properties = device.physical_device().properties();
contents contents.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("contents")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderingInfo-flags-parameter"])
context: "contents".into(), })?;
vuids: &["VUID-VkRenderingInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if render_area_extent[0] == 0 { if render_area_extent[0] == 0 {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -2916,29 +2904,20 @@ impl RenderingAttachmentInfo {
_ne, _ne,
} = self; } = self;
image_layout image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderingAttachmentInfo-imageLayout-parameter"])
context: "image_layout".into(), })?;
vuids: &["VUID-VkRenderingAttachmentInfo-imageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
load_op load_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("load_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderingAttachmentInfo-loadOp-parameter"])
context: "load_op".into(), })?;
vuids: &["VUID-VkRenderingAttachmentInfo-loadOp-parameter"],
..ValidationError::from_requirement(err)
})?;
store_op store_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("store_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderingAttachmentInfo-storeOp-parameter"])
context: "store_op".into(), })?;
vuids: &["VUID-VkRenderingAttachmentInfo-storeOp-parameter"],
..ValidationError::from_requirement(err)
})?;
if matches!( if matches!(
image_layout, image_layout,
@ -3073,20 +3052,15 @@ impl RenderingAttachmentResolveInfo {
image_layout, image_layout,
} = self; } = self;
mode.validate_device(device) mode.validate_device(device).map_err(|err| {
.map_err(|err| ValidationError { err.add_context("mode")
context: "mode".into(), .set_vuids(&["VUID-VkRenderingAttachmentInfo-resolveMode-parameter"])
vuids: &["VUID-VkRenderingAttachmentInfo-resolveMode-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
image_layout image_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderingAttachmentInfo-resolveImageLayout-parameter"])
context: "image_layout".into(), })?;
vuids: &["VUID-VkRenderingAttachmentInfo-resolveImageLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
if let Some(numeric_format) = image_view.format().numeric_format_color() { if let Some(numeric_format) = image_view.format().numeric_format_color() {
match numeric_format.numeric_type() { match numeric_format.numeric_type() {

View File

@ -107,16 +107,18 @@ where
.inheritance_info() .inheritance_info()
.render_pass .render_pass
.as_ref() .as_ref()
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
problem: format!( Box::new(ValidationError {
"a render pass instance is active, but \ problem: format!(
"a render pass instance is active, but \
`command_buffers[{}].inheritance_info().render_pass` is `None`", `command_buffers[{}].inheritance_info().render_pass` is `None`",
command_buffer_index command_buffer_index
) )
.into(), .into(),
vuids: &["VUID-vkCmdExecuteCommands-pCommandBuffers-00096"], vuids: &["VUID-vkCmdExecuteCommands-pCommandBuffers-00096"],
..Default::default() ..Default::default()
}))?; })
})?;
match (&render_pass_state.render_pass, inheritance_render_pass) { match (&render_pass_state.render_pass, inheritance_render_pass) {
( (
@ -406,17 +408,20 @@ where
let inherited_flags = command_buffer let inherited_flags = command_buffer
.inheritance_info() .inheritance_info()
.occlusion_query .occlusion_query
.ok_or(Box::new(ValidationError { .ok_or_else(|| {
context: format!( Box::new(ValidationError {
"command_buffers[{}].inheritance_info().occlusion_query", context: format!(
command_buffer_index "command_buffers[{}].inheritance_info().occlusion_query",
) command_buffer_index
.into(), )
problem: "is `None`, but an occlusion query is currently active"
.into(), .into(),
vuids: &["VUID-vkCmdExecuteCommands-commandBuffer-00102"], problem:
..Default::default() "is `None`, but an occlusion query is currently active"
}))?; .into(),
vuids: &["VUID-vkCmdExecuteCommands-commandBuffer-00102"],
..Default::default()
})
})?;
if !inherited_flags.contains(state.flags) { if !inherited_flags.contains(state.flags) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -1359,13 +1359,10 @@ where
// VUID-vkCmdResetEvent2-commonparent // VUID-vkCmdResetEvent2-commonparent
assert_eq!(device, event.device()); assert_eq!(device, event.device());
stages stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkCmdResetEvent2-stageMask-parameter"])
context: "stages".into(), })?;
vuids: &["VUID-vkCmdResetEvent2-stageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 { if !device.enabled_features().synchronization2 {
if stages.contains_flags2() { if stages.contains_flags2() {

View File

@ -283,13 +283,10 @@ impl CommandBufferInheritanceInfo {
} }
if let Some(control_flags) = occlusion_query { if let Some(control_flags) = occlusion_query {
control_flags control_flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("occlusion_query")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"])
context: "occlusion_query".into(), })?;
vuids: &["VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().inherited_queries { if !device.enabled_features().inherited_queries {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -318,10 +315,9 @@ impl CommandBufferInheritanceInfo {
query_statistics_flags query_statistics_flags
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "query_statistics_flags".into(), err.add_context("query_statistics_flags")
vuids: &["VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"], .set_vuids(&["VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"])
..ValidationError::from_requirement(err)
})?; })?;
if query_statistics_flags.count() > 0 if query_statistics_flags.count() > 0
@ -534,10 +530,10 @@ impl CommandBufferInheritanceRenderingInfo {
.enumerate() .enumerate()
.flat_map(|(i, f)| f.map(|f| (i, f))) .flat_map(|(i, f)| f.map(|f| (i, f)))
{ {
format.validate_device(device).map_err(|err| ValidationError { format.validate_device(device).map_err(|err| {
context: format!("color_attachment_formats[{}]", index).into(), err.add_context(format!("color_attachment_formats[{}]", index)).set_vuids(
vuids: &["VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-parameter"], &["VUID-VkCommandBufferInheritanceRenderingInfo-pColorAttachmentFormats-parameter"],
..ValidationError::from_requirement(err) )
})?; })?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
@ -567,10 +563,10 @@ impl CommandBufferInheritanceRenderingInfo {
} }
if let Some(format) = depth_attachment_format { if let Some(format) = depth_attachment_format {
format.validate_device(device).map_err(|err| ValidationError { format.validate_device(device).map_err(|err| {
context: "depth_attachment_format".into(), err.add_context("depth_attachment_format").set_vuids(&[
vuids: &["VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-parameter"], "VUID-VkCommandBufferInheritanceRenderingInfo-depthAttachmentFormat-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
@ -614,10 +610,8 @@ impl CommandBufferInheritanceRenderingInfo {
} }
if let Some(format) = stencil_attachment_format { if let Some(format) = stencil_attachment_format {
format.validate_device(device).map_err(|err| ValidationError { format.validate_device(device).map_err(|err| {
context: "stencil_attachment_format".into(), err.add_context("stencil_attachment_format").set_vuids(&["VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-parameter"])
vuids: &["VUID-VkCommandBufferInheritanceRenderingInfo-stencilAttachmentFormat-parameter"],
..ValidationError::from_requirement(err)
})?; })?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
@ -678,12 +672,10 @@ impl CommandBufferInheritanceRenderingInfo {
rasterization_samples rasterization_samples
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "rasterization_samples".into(), err.add_context("rasterization_samples").set_vuids(&[
vuids: &[
"VUID-VkCommandBufferInheritanceRenderingInfo-rasterizationSamples-parameter", "VUID-VkCommandBufferInheritanceRenderingInfo-rasterizationSamples-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
Ok(()) Ok(())

View File

@ -157,13 +157,10 @@ impl CommandPool {
} }
fn validate_reset(&self, flags: CommandPoolResetFlags) -> Result<(), Box<ValidationError>> { fn validate_reset(&self, flags: CommandPoolResetFlags) -> Result<(), Box<ValidationError>> {
flags flags.validate_device(self.device()).map_err(|err| {
.validate_device(self.device()) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkResetCommandPool-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-vkResetCommandPool-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -389,13 +386,10 @@ impl CommandPoolCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkCommandPoolCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkCommandPoolCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if queue_family_index >= device.physical_device().queue_family_properties().len() as u32 { if queue_family_index >= device.physical_device().queue_family_properties().len() as u32 {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -329,13 +329,10 @@ impl DescriptorSetLayoutCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDescriptorSetLayoutCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkDescriptorSetLayoutCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkDescriptorSetLayoutCreateInfo-binding-00279 // VUID-VkDescriptorSetLayoutCreateInfo-binding-00279
// Ensured because it is a map // Ensured because it is a map
@ -620,23 +617,16 @@ impl DescriptorSetLayoutBinding {
_ne: _, _ne: _,
} = self; } = self;
binding_flags binding_flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("binding_flags").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-parameter",
context: "binding_flags".into(), ])
vuids: &[ })?;
"VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-pBindingFlags-parameter",
],
..ValidationError::from_requirement(err)
})?;
descriptor_type descriptor_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("descriptor_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDescriptorSetLayoutBinding-descriptorType-parameter"])
context: "descriptor_type".into(), })?;
vuids: &["VUID-VkDescriptorSetLayoutBinding-descriptorType-parameter"],
..ValidationError::from_requirement(err)
})?;
if descriptor_type == DescriptorType::InlineUniformBlock { if descriptor_type == DescriptorType::InlineUniformBlock {
if !device.enabled_features().inline_uniform_block { if !device.enabled_features().inline_uniform_block {
@ -679,13 +669,10 @@ impl DescriptorSetLayoutBinding {
} }
if descriptor_count != 0 { if descriptor_count != 0 {
stages stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283"])
context: "stages".into(), })?;
vuids: &["VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283"],
..ValidationError::from_requirement(err)
})?;
if descriptor_type == DescriptorType::InputAttachment if descriptor_type == DescriptorType::InputAttachment
&& !(stages.is_empty() || stages == ShaderStages::FRAGMENT) && !(stages.is_empty() || stages == ShaderStages::FRAGMENT)

View File

@ -408,13 +408,10 @@ impl DescriptorPoolCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDescriptorPoolCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkDescriptorPoolCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if max_sets == 0 { if max_sets == 0 {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -436,13 +433,10 @@ impl DescriptorPoolCreateInfo {
// VUID-VkDescriptorPoolCreateInfo-pPoolSizes-parameter // VUID-VkDescriptorPoolCreateInfo-pPoolSizes-parameter
for (&descriptor_type, &pool_size) in pool_sizes.iter() { for (&descriptor_type, &pool_size) in pool_sizes.iter() {
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("pool_sizes")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDescriptorPoolSize-type-parameter"])
context: "pool_sizes".into(), })?;
vuids: &["VUID-VkDescriptorPoolSize-type-parameter"],
..ValidationError::from_requirement(err)
})?;
if pool_size == 0 { if pool_size == 0 {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -119,8 +119,8 @@ use crate::{
instance::{Instance, InstanceOwned, InstanceOwnedDebugWrapper}, instance::{Instance, InstanceOwned, InstanceOwnedDebugWrapper},
macros::{impl_id_counter, vulkan_bitflags}, macros::{impl_id_counter, vulkan_bitflags},
memory::ExternalMemoryHandleType, memory::ExternalMemoryHandleType,
OomError, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, Version, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, Version, VulkanError,
VulkanError, VulkanObject, VulkanObject,
}; };
use ash::vk::Handle; use ash::vk::Handle;
use parking_lot::Mutex; use parking_lot::Mutex;
@ -618,13 +618,10 @@ impl Device {
})); }));
} }
build_type build_type.validate_device(self).map_err(|err| {
.validate_device(self) err.add_context("build_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkGetAccelerationStructureBuildSizesKHR-buildType-parameter"])
context: "build_type".into(), })?;
vuids: &["VUID-vkGetAccelerationStructureBuildSizesKHR-buildType-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-parameter // VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-parameter
build_info build_info
@ -978,13 +975,10 @@ impl Device {
})); }));
} }
handle_type handle_type.validate_device(self).map_err(|err| {
.validate_device(self) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkGetMemoryFdPropertiesKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-vkGetMemoryFdPropertiesKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if handle_type == ExternalMemoryHandleType::OpaqueFd { if handle_type == ExternalMemoryHandleType::OpaqueFd {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1040,7 +1034,7 @@ impl Device {
&self, &self,
object: &T, object: &T,
object_name: Option<&str>, object_name: Option<&str>,
) -> Result<(), OomError> { ) -> Result<(), VulkanError> {
assert!(object.device().handle() == self.handle()); assert!(object.device().handle() == self.handle());
let object_name_vk = object_name.map(|object_name| CString::new(object_name).unwrap()); let object_name_vk = object_name.map(|object_name| CString::new(object_name).unwrap());
@ -1074,7 +1068,7 @@ impl Device {
/// of the device (either explicitly or implicitly, for example with a future's destructor) /// of the device (either explicitly or implicitly, for example with a future's destructor)
/// while this function is waiting. /// while this function is waiting.
#[inline] #[inline]
pub unsafe fn wait_idle(&self) -> Result<(), OomError> { pub unsafe fn wait_idle(&self) -> Result<(), VulkanError> {
let fns = self.fns(); let fns = self.fns();
(fns.v1_0.device_wait_idle)(self.handle) (fns.v1_0.device_wait_idle)(self.handle)
.result() .result()
@ -1289,19 +1283,21 @@ impl DeviceCreateInfo {
physical_device.api_version(), physical_device.api_version(),
physical_device.instance().enabled_extensions(), physical_device.instance().enabled_extensions(),
) )
.map_err(|err| ValidationError { .map_err(|err| {
context: "enabled_extensions".into(), Box::new(ValidationError {
problem: err.to_string().into(), context: "enabled_extensions".into(),
vuids: &["VUID-vkCreateDevice-ppEnabledExtensionNames-01387"], vuids: &["VUID-vkCreateDevice-ppEnabledExtensionNames-01387"],
..Default::default() ..ValidationError::from_error(err)
})
})?; })?;
enabled_features enabled_features
.check_requirements(physical_device.supported_features()) .check_requirements(physical_device.supported_features())
.map_err(|err| ValidationError { .map_err(|err| {
context: "enabled_features".into(), Box::new(ValidationError {
problem: err.to_string().into(), context: "enabled_features".into(),
..Default::default() ..ValidationError::from_error(err)
})
})?; })?;
let mut dependency_extensions = *enabled_extensions; let mut dependency_extensions = *enabled_extensions;
@ -1592,21 +1588,22 @@ impl QueueCreateInfo {
device_extensions, device_extensions,
physical_device.instance().enabled_extensions(), physical_device.instance().enabled_extensions(),
) )
.map_err(|err| ValidationError { .map_err(|err| {
context: "flags".into(), err.add_context("flags")
vuids: &["VUID-VkDeviceQueueCreateInfo-flags-parameter"], .set_vuids(&["VUID-VkDeviceQueueCreateInfo-flags-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
let queue_family_properties = physical_device let queue_family_properties = physical_device
.queue_family_properties() .queue_family_properties()
.get(queue_family_index as usize) .get(queue_family_index as usize)
.ok_or(ValidationError { .ok_or_else(|| {
context: "queue_family_index".into(), Box::new(ValidationError {
problem: "is not less than the number of queue families in the physical device" context: "queue_family_index".into(),
.into(), problem: "is not less than the number of queue families in the physical device"
vuids: &["VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381"], .into(),
..Default::default() vuids: &["VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381"],
..Default::default()
})
})?; })?;
if queues.is_empty() { if queues.is_empty() {
@ -1680,14 +1677,14 @@ pub unsafe trait DeviceOwnedVulkanObject {
/// Assigns a human-readable name to the object for debugging purposes. /// Assigns a human-readable name to the object for debugging purposes.
/// ///
/// If `object_name` is `None`, a previously set object name is removed. /// If `object_name` is `None`, a previously set object name is removed.
fn set_debug_utils_object_name(&self, object_name: Option<&str>) -> Result<(), OomError>; fn set_debug_utils_object_name(&self, object_name: Option<&str>) -> Result<(), VulkanError>;
} }
unsafe impl<T> DeviceOwnedVulkanObject for T unsafe impl<T> DeviceOwnedVulkanObject for T
where where
T: DeviceOwned + VulkanObject, T: DeviceOwned + VulkanObject,
{ {
fn set_debug_utils_object_name(&self, object_name: Option<&str>) -> Result<(), OomError> { fn set_debug_utils_object_name(&self, object_name: Option<&str>) -> Result<(), VulkanError> {
self.device().set_debug_utils_object_name(self, object_name) self.device().set_debug_utils_object_name(self, object_name)
} }
} }

View File

@ -807,13 +807,10 @@ impl PhysicalDevice {
} }
fn validate_format_properties(&self, format: Format) -> Result<(), Box<ValidationError>> { fn validate_format_properties(&self, format: Format) -> Result<(), Box<ValidationError>> {
format format.validate_physical_device(self).map_err(|err| {
.validate_physical_device(self) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }
@ -1509,10 +1506,13 @@ impl PhysicalDevice {
if let Some(present_mode) = present_mode { if let Some(present_mode) = present_mode {
let mut present_modes = unsafe { let mut present_modes = unsafe {
self.surface_present_modes_unchecked(surface) self.surface_present_modes_unchecked(surface)
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_present_modes".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_present_modes` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
@ -1874,10 +1874,13 @@ impl PhysicalDevice {
if let Some(present_mode) = present_mode { if let Some(present_mode) = present_mode {
let mut present_modes = unsafe { let mut present_modes = unsafe {
self.surface_present_modes_unchecked(surface) self.surface_present_modes_unchecked(surface)
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_present_modes".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_present_modes` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };

View File

@ -26,8 +26,8 @@ use crate::{
future::{AccessCheckError, GpuFuture}, future::{AccessCheckError, GpuFuture},
semaphore::SemaphoreState, semaphore::SemaphoreState,
}, },
OomError, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, Version, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, Version, VulkanError,
VulkanError, VulkanObject, VulkanObject,
}; };
use ahash::HashMap; use ahash::HashMap;
use parking_lot::{Mutex, MutexGuard}; use parking_lot::{Mutex, MutexGuard};
@ -193,7 +193,7 @@ impl<'a> QueueGuard<'a> {
/// Just like [`Device::wait_idle`], you shouldn't have to call this function in a typical /// Just like [`Device::wait_idle`], you shouldn't have to call this function in a typical
/// program. /// program.
#[inline] #[inline]
pub fn wait_idle(&mut self) -> Result<(), OomError> { pub fn wait_idle(&mut self) -> Result<(), VulkanError> {
self.state.wait_idle(&self.queue.device, self.queue.handle) self.state.wait_idle(&self.queue.device, self.queue.handle)
} }
@ -1358,7 +1358,7 @@ struct QueueState {
} }
impl QueueState { impl QueueState {
fn wait_idle(&mut self, device: &Device, handle: ash::vk::Queue) -> Result<(), OomError> { fn wait_idle(&mut self, device: &Device, handle: ash::vk::Queue) -> Result<(), VulkanError> {
unsafe { unsafe {
let fns = device.fns(); let fns = device.fns();
(fns.v1_0.queue_wait_idle)(handle) (fns.v1_0.queue_wait_idle)(handle)

View File

@ -1386,13 +1386,10 @@ impl ImageSubresourceLayers {
ref array_layers, ref array_layers,
} = self; } = self;
aspects aspects.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("aspects")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageSubresourceLayers-aspectMask-parameter"])
context: "aspects".into(), })?;
vuids: &["VUID-VkImageSubresourceLayers-aspectMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if aspects.is_empty() { if aspects.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1519,13 +1516,10 @@ impl ImageSubresourceRange {
ref array_layers, ref array_layers,
} = self; } = self;
aspects aspects.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("aspects")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageSubresourceRange-aspectMask-parameter"])
context: "aspects".into(), })?;
vuids: &["VUID-VkImageSubresourceRange-aspectMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if aspects.is_empty() { if aspects.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1749,42 +1743,37 @@ impl ImageFormatInfo {
flags flags
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "flags".into(), err.add_context("flags")
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-flags-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceImageFormatInfo2-flags-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
format format
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "format".into(), err.add_context("format")
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-format-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceImageFormatInfo2-format-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
image_type image_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "image_type".into(), err.add_context("image_type")
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-imageType-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceImageFormatInfo2-imageType-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
tiling tiling
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "tiling".into(), err.add_context("tiling")
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-tiling-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceImageFormatInfo2-tiling-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
usage usage
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "usage".into(), err.add_context("usage")
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceImageFormatInfo2-usage-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if usage.is_empty() { if usage.is_empty() {
@ -1815,10 +1804,9 @@ impl ImageFormatInfo {
stencil_usage stencil_usage
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "stencil_usage".into(), err.add_context("stencil_usage")
vuids: &["VUID-VkImageStencilUsageCreateInfo-stencilUsage-parameter"], .set_vuids(&["VUID-VkImageStencilUsageCreateInfo-stencilUsage-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if stencil_usage.is_empty() { if stencil_usage.is_empty() {
@ -1870,10 +1858,10 @@ impl ImageFormatInfo {
handle_type handle_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "handle_type".into(), err.add_context("handle_type").set_vuids(&[
vuids: &["VUID-VkPhysicalDeviceExternalImageFormatInfo-handleType-parameter"], "VUID-VkPhysicalDeviceExternalImageFormatInfo-handleType-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
} }
@ -1890,12 +1878,10 @@ impl ImageFormatInfo {
image_view_type image_view_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "image_view_type".into(), err.add_context("image_view_type").set_vuids(&[
vuids: &[
"VUID-VkPhysicalDeviceImageViewImageFormatInfoEXT-imageViewType-parameter", "VUID-VkPhysicalDeviceImageViewImageFormatInfoEXT-imageViewType-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
} }
@ -2156,34 +2142,30 @@ impl SparseImageFormatInfo {
format format
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "format".into(), err.add_context("format")
vuids: &["VUID-VkPhysicalDeviceSparseImageFormatInfo2-format-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceSparseImageFormatInfo2-format-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
image_type image_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "image_type".into(), err.add_context("image_type")
vuids: &["VUID-VkPhysicalDeviceSparseImageFormatInfo2-type-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceSparseImageFormatInfo2-type-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
samples samples
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "samples".into(), err.add_context("samples")
vuids: &["VUID-VkPhysicalDeviceSparseImageFormatInfo2-samples-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceSparseImageFormatInfo2-samples-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
usage usage
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "usage".into(), err.add_context("usage")
vuids: &["VUID-VkPhysicalDeviceSparseImageFormatInfo2-usage-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceSparseImageFormatInfo2-usage-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if usage.is_empty() { if usage.is_empty() {
@ -2197,10 +2179,9 @@ impl SparseImageFormatInfo {
tiling tiling
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "tiling".into(), err.add_context("tiling")
vuids: &["VUID-VkPhysicalDeviceSparseImageFormatInfo2-tiling-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceSparseImageFormatInfo2-tiling-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
// VUID-VkPhysicalDeviceSparseImageFormatInfo2-samples-01095 // VUID-VkPhysicalDeviceSparseImageFormatInfo2-samples-01095

View File

@ -814,60 +814,43 @@ impl SamplerCreateInfo {
let properties = device.physical_device().properties(); let properties = device.physical_device().properties();
mag_filter mag_filter.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("mag_filter")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerCreateInfo-magFilter-parameter"])
context: "mag_filter".into(), })?;
vuids: &["VUID-VkSamplerCreateInfo-magFilter-parameter"],
..ValidationError::from_requirement(err)
})?;
min_filter min_filter.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("min_filter")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerCreateInfo-minFilter-parameter"])
context: "min_filter".into(), })?;
vuids: &["VUID-VkSamplerCreateInfo-minFilter-parameter"],
..ValidationError::from_requirement(err)
})?;
mipmap_mode mipmap_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("mipmap_mode")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerCreateInfo-mipmapMode-parameter"])
context: "mipmap_mode".into(), })?;
vuids: &["VUID-VkSamplerCreateInfo-mipmapMode-parameter"],
..ValidationError::from_requirement(err)
})?;
for (index, mode) in address_mode.into_iter().enumerate() { for (index, mode) in address_mode.into_iter().enumerate() {
mode.validate_device(device) mode.validate_device(device).map_err(|err| {
.map_err(|err| ValidationError { err.add_context(format!("address_mode[{}]", index))
context: format!("address_mode[{}]", index).into(), .set_vuids(&[
vuids: &[
"VUID-VkSamplerCreateInfo-addressModeU-parameter", "VUID-VkSamplerCreateInfo-addressModeU-parameter",
"VUID-VkSamplerCreateInfo-addressModeV-parameter", "VUID-VkSamplerCreateInfo-addressModeV-parameter",
"VUID-VkSamplerCreateInfo-addressModeW-parameter", "VUID-VkSamplerCreateInfo-addressModeW-parameter",
], ])
..ValidationError::from_requirement(err) })?;
})?;
} }
if address_mode.contains(&SamplerAddressMode::ClampToBorder) { if address_mode.contains(&SamplerAddressMode::ClampToBorder) {
border_color border_color.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("border_color")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerCreateInfo-addressModeU-01078"])
context: "border_color".into(), })?;
vuids: &["VUID-VkSamplerCreateInfo-addressModeU-01078"],
..ValidationError::from_requirement(err)
})?;
} }
reduction_mode reduction_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("reduction_mode")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerReductionModeCreateInfo-reductionMode-parameter"])
context: "reduction_mode".into(), })?;
vuids: &["VUID-VkSamplerReductionModeCreateInfo-reductionMode-parameter"],
..ValidationError::from_requirement(err)
})?;
if address_mode.contains(&SamplerAddressMode::MirrorClampToEdge) { if address_mode.contains(&SamplerAddressMode::MirrorClampToEdge) {
if !(device.enabled_features().sampler_mirror_clamp_to_edge if !(device.enabled_features().sampler_mirror_clamp_to_edge
@ -964,13 +947,10 @@ impl SamplerCreateInfo {
} }
if let Some(compare_op) = compare { if let Some(compare_op) = compare {
compare_op compare_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("compare")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerCreateInfo-compareEnable-01080"])
context: "compare".into(), })?;
vuids: &["VUID-VkSamplerCreateInfo-compareEnable-01080"],
..ValidationError::from_requirement(err)
})?;
if reduction_mode != SamplerReductionMode::WeightedAverage { if reduction_mode != SamplerReductionMode::WeightedAverage {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1249,28 +1229,24 @@ impl ComponentMapping {
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> { pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
let &Self { r, g, b, a } = self; let &Self { r, g, b, a } = self;
r.validate_device(device).map_err(|err| ValidationError { r.validate_device(device).map_err(|err| {
context: "r".into(), err.add_context("r")
vuids: &["VUID-VkComponentMapping-r-parameter"], .set_vuids(&["VUID-VkComponentMapping-r-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
g.validate_device(device).map_err(|err| ValidationError { g.validate_device(device).map_err(|err| {
context: "g".into(), err.add_context("g")
vuids: &["VUID-VkComponentMapping-g-parameter"], .set_vuids(&["VUID-VkComponentMapping-g-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
b.validate_device(device).map_err(|err| ValidationError { b.validate_device(device).map_err(|err| {
context: "b".into(), err.add_context("b")
vuids: &["VUID-VkComponentMapping-b-parameter"], .set_vuids(&["VUID-VkComponentMapping-b-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
a.validate_device(device).map_err(|err| ValidationError { a.validate_device(device).map_err(|err| {
context: "a".into(), err.add_context("a")
vuids: &["VUID-VkComponentMapping-a-parameter"], .set_vuids(&["VUID-VkComponentMapping-a-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
Ok(()) Ok(())

View File

@ -468,54 +468,39 @@ impl SamplerYcbcrConversionCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerYcbcrConversionCreateInfo-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkSamplerYcbcrConversionCreateInfo-format-parameter"],
..ValidationError::from_requirement(err)
})?;
ycbcr_model ycbcr_model.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("ycbcr_model")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-parameter"])
context: "ycbcr_model".into(), })?;
vuids: &["VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-parameter"],
..ValidationError::from_requirement(err)
})?;
ycbcr_range ycbcr_range.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("ycbcr_range")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrRange-parameter"])
context: "ycbcr_range".into(), })?;
vuids: &["VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrRange-parameter"],
..ValidationError::from_requirement(err)
})?;
component_mapping component_mapping
.validate(device) .validate(device)
.map_err(|err| err.add_context("component_mapping"))?; .map_err(|err| err.add_context("component_mapping"))?;
for (index, offset) in chroma_offset.into_iter().enumerate() { for (index, offset) in chroma_offset.into_iter().enumerate() {
offset offset.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context(format!("chroma_offset[{}]", index))
.map_err(|err| ValidationError { .set_vuids(&[
context: format!("chroma_offset[{}]", index).into(),
vuids: &[
"VUID-VkSamplerYcbcrConversionCreateInfo-xChromaOffset-parameter", "VUID-VkSamplerYcbcrConversionCreateInfo-xChromaOffset-parameter",
"VUID-VkSamplerYcbcrConversionCreateInfo-yChromaOffset-parameter", "VUID-VkSamplerYcbcrConversionCreateInfo-yChromaOffset-parameter",
], ])
..ValidationError::from_requirement(err) })?;
})?;
} }
chroma_filter chroma_filter.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("chroma_filter")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSamplerYcbcrConversionCreateInfo-chromaFilter-parameter"])
context: "chroma_filter".into(), })?;
vuids: &["VUID-VkSamplerYcbcrConversionCreateInfo-chromaFilter-parameter"],
..ValidationError::from_requirement(err)
})?;
if !format if !format
.numeric_format_color() .numeric_format_color()

View File

@ -943,10 +943,12 @@ impl RawImage {
_ne: crate::NonExhaustive(()), _ne: crate::NonExhaustive(()),
}) })
} }
.map_err(|_| ValidationError { .map_err(|_| {
problem: "`PhysicalDevice::image_format_properties` returned an error" Box::new(ValidationError {
.into(), problem: "`PhysicalDevice::image_format_properties` returned an error"
..Default::default() .into(),
..Default::default()
})
})? })?
.unwrap(); .unwrap();
@ -1323,13 +1325,10 @@ impl RawImage {
mip_level: u32, mip_level: u32,
array_layer: u32, array_layer: u32,
) -> Result<(), Box<ValidationError>> { ) -> Result<(), Box<ValidationError>> {
aspect aspect.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("aspect")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageSubresource-aspectMask-parameter"])
context: "aspect".into(), })?;
vuids: &["VUID-VkImageSubresource-aspectMask-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkImageSubresource-aspectMask-requiredbitmask // VUID-VkImageSubresource-aspectMask-requiredbitmask
// VUID-vkGetImageSubresourceLayout-aspectMask-00997 // VUID-vkGetImageSubresourceLayout-aspectMask-00997
@ -1766,45 +1765,30 @@ impl ImageCreateInfo {
let physical_device = device.physical_device(); let physical_device = device.physical_device();
let device_properties = physical_device.properties(); let device_properties = physical_device.properties();
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImageCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkImageCreateInfo-format-parameter"],
..ValidationError::from_requirement(err)
})?;
samples samples.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("samples")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-samples-parameter"])
context: "samples".into(), })?;
vuids: &["VUID-VkImageCreateInfo-samples-parameter"],
..ValidationError::from_requirement(err)
})?;
tiling tiling.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("tiling")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-tiling-parameter"])
context: "tiling".into(), })?;
vuids: &["VUID-VkImageCreateInfo-tiling-parameter"],
..ValidationError::from_requirement(err)
})?;
usage usage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("usage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-usage-parameter"])
context: "usage".into(), })?;
vuids: &["VUID-VkImageCreateInfo-usage-parameter"],
..ValidationError::from_requirement(err)
})?;
if usage.is_empty() { if usage.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1837,13 +1821,10 @@ impl ImageCreateInfo {
let image_create_format_features = let image_create_format_features =
format_properties.format_features(tiling, drm_format_modifiers); format_properties.format_features(tiling, drm_format_modifiers);
initial_layout initial_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("initial_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageCreateInfo-initialLayout-parameter"])
context: "initial_layout".into(), })?;
vuids: &["VUID-VkImageCreateInfo-initialLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
initial_layout, initial_layout,
@ -2215,13 +2196,10 @@ impl ImageCreateInfo {
})); }));
} }
stencil_usage stencil_usage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stencil_usage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageStencilUsageCreateInfo-stencilUsage-parameter"])
context: "stencil_usage".into(), })?;
vuids: &["VUID-VkImageStencilUsageCreateInfo-stencilUsage-parameter"],
..ValidationError::from_requirement(err)
})?;
if stencil_usage.is_empty() { if stencil_usage.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -2523,10 +2501,9 @@ impl ImageCreateInfo {
external_memory_handle_types external_memory_handle_types
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "external_memory_handle_types".into(), err.add_context("external_memory_handle_types")
vuids: &["VUID-VkExternalMemoryImageCreateInfo-handleTypes-parameter"], .set_vuids(&["VUID-VkExternalMemoryImageCreateInfo-handleTypes-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if initial_layout != ImageLayout::Undefined { if initial_layout != ImageLayout::Undefined {
@ -2569,14 +2546,14 @@ impl ImageCreateInfo {
.drm_format_modifier_properties .drm_format_modifier_properties
.iter() .iter()
.find(|properties| properties.drm_format_modifier == drm_format_modifier) .find(|properties| properties.drm_format_modifier == drm_format_modifier)
.ok_or(ValidationError { .ok_or_else(|| Box::new(ValidationError {
problem: "`drm_format_modifiers` has a length of 1, but \ problem: "`drm_format_modifiers` has a length of 1, but \
`drm_format_modifiers[0]` is not one of the modifiers in \ `drm_format_modifiers[0]` is not one of the modifiers in \
`FormatProperties::drm_format_properties`, as returned by \ `FormatProperties::drm_format_properties`, as returned by \
`PhysicalDevice::format_properties` for `format`".into(), `PhysicalDevice::format_properties` for `format`".into(),
vuids: &["VUID-VkImageDrmFormatModifierExplicitCreateInfoEXT-drmFormatModifierPlaneCount-02265"], vuids: &["VUID-VkImageDrmFormatModifierExplicitCreateInfoEXT-drmFormatModifierPlaneCount-02265"],
..Default::default() ..Default::default()
})?; }))?;
if drm_format_modifier_plane_layouts.len() if drm_format_modifier_plane_layouts.len()
!= drm_format_modifier_properties.drm_format_modifier_plane_count as usize != drm_format_modifier_properties.drm_format_modifier_plane_count as usize
@ -2705,14 +2682,17 @@ impl ImageCreateInfo {
), ),
..Default::default() ..Default::default()
}) })
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::image_format_properties".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::image_format_properties` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
let image_format_properties = image_format_properties.ok_or(ValidationError { let image_format_properties = image_format_properties.ok_or_else(|| Box::new(ValidationError {
problem: "the combination of parameters of this image is not \ problem: "the combination of parameters of this image is not \
supported by the physical device, as returned by \ supported by the physical device, as returned by \
`PhysicalDevice::image_format_properties`" `PhysicalDevice::image_format_properties`"
@ -2722,7 +2702,7 @@ impl ImageCreateInfo {
"VUID-VkImageDrmFormatModifierListCreateInfoEXT-pDrmFormatModifiers-02263", "VUID-VkImageDrmFormatModifierListCreateInfoEXT-pDrmFormatModifiers-02263",
], ],
..Default::default() ..Default::default()
})?; }))?;
let ImageFormatProperties { let ImageFormatProperties {
max_extent, max_extent,

View File

@ -931,21 +931,15 @@ impl ImageViewCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
view_type view_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("view_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageViewCreateInfo-viewType-parameter"])
context: "view_type".into(), })?;
vuids: &["VUID-VkImageViewCreateInfo-viewType-parameter"],
..ValidationError::from_requirement(err)
})?;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageViewCreateInfo-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkImageViewCreateInfo-format-parameter"],
..ValidationError::from_requirement(err)
})?;
component_mapping component_mapping
.validate(device) .validate(device)
@ -955,13 +949,10 @@ impl ImageViewCreateInfo {
.validate(device) .validate(device)
.map_err(|err| err.add_context("subresource_range"))?; .map_err(|err| err.add_context("subresource_range"))?;
usage usage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("usage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageViewUsageCreateInfo-usage-parameter"])
context: "usage".into(), })?;
vuids: &["VUID-VkImageViewUsageCreateInfo-usage-parameter"],
..ValidationError::from_requirement(err)
})?;
match view_type { match view_type {
ImageViewType::Dim1d | ImageViewType::Dim2d | ImageViewType::Dim3d => { ImageViewType::Dim1d | ImageViewType::Dim2d | ImageViewType::Dim3d => {

View File

@ -229,10 +229,10 @@ impl DebugUtilsMessengerCreateInfo {
message_severity message_severity
.validate_instance_raw(instance_api_version, instance_extensions) .validate_instance_raw(instance_api_version, instance_extensions)
.map_err(|err| ValidationError { .map_err(|err| {
context: "message_severity".into(), err.add_context("message_severity").set_vuids(&[
vuids: &["VUID-VkDebugUtilsMessengerCreateInfoEXT-messageSeverity-parameter"], "VUID-VkDebugUtilsMessengerCreateInfoEXT-messageSeverity-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
if message_severity.is_empty() { if message_severity.is_empty() {
@ -246,10 +246,9 @@ impl DebugUtilsMessengerCreateInfo {
message_type message_type
.validate_instance_raw(instance_api_version, instance_extensions) .validate_instance_raw(instance_api_version, instance_extensions)
.map_err(|err| ValidationError { .map_err(|err| {
context: "message_type".into(), err.add_context("message_type")
vuids: &["VUID-VkDebugUtilsMessengerCreateInfoEXT-messageType-parameter"], .set_vuids(&["VUID-VkDebugUtilsMessengerCreateInfoEXT-messageType-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if message_type.is_empty() { if message_type.is_empty() {

View File

@ -338,11 +338,12 @@ impl Instance {
enabled_extensions enabled_extensions
.check_requirements(&supported_extensions, api_version) .check_requirements(&supported_extensions, api_version)
.map_err(|err| ValidationError { .map_err(|err| {
context: "create_info.enabled_extensions".into(), Box::new(ValidationError {
problem: err.to_string().into(), context: "create_info.enabled_extensions".into(),
vuids: &["VUID-vkCreateInstance-ppEnabledExtensionNames-01388"], vuids: &["VUID-vkCreateInstance-ppEnabledExtensionNames-01388"],
..Default::default() ..ValidationError::from_error(err)
})
})?; })?;
Ok(()) Ok(())
@ -1051,10 +1052,9 @@ impl InstanceCreateInfo {
flags flags
.validate_instance_raw(api_version, enabled_extensions) .validate_instance_raw(api_version, enabled_extensions)
.map_err(|err| ValidationError { .map_err(|err| {
context: "flags".into(), err.add_context("flags")
vuids: &["VUID-VkInstanceCreateInfo-flags-parameter"], .set_vuids(&["VUID-VkInstanceCreateInfo-flags-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
if !debug_utils_messengers.is_empty() { if !debug_utils_messengers.is_empty() {
@ -1091,12 +1091,11 @@ impl InstanceCreateInfo {
for (index, enabled) in enabled_validation_features.iter().enumerate() { for (index, enabled) in enabled_validation_features.iter().enumerate() {
enabled enabled
.validate_instance_raw(api_version, enabled_extensions) .validate_instance_raw(api_version, enabled_extensions)
.map_err(|err| ValidationError { .map_err(|err| {
context: format!("enabled_validation_features[{}]", index).into(), err.add_context(format!("enabled_validation_features[{}]", index))
vuids: &[ .set_vuids(&[
"VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter", "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
} }
@ -1144,12 +1143,12 @@ impl InstanceCreateInfo {
for (index, disabled) in disabled_validation_features.iter().enumerate() { for (index, disabled) in disabled_validation_features.iter().enumerate() {
disabled disabled
.validate_instance_raw(api_version, enabled_extensions) .validate_instance_raw(api_version, enabled_extensions)
.map_err(|err| ValidationError { .map_err(|err| {
context: format!("disabled_validation_features[{}]", index).into(), err.add_context(format!("disabled_validation_features[{}]", index)).set_vuids(
vuids: &[ &[
"VUID-VkValidationFeaturesEXT-pDisabledValidationFeatures-parameter", "VUID-VkValidationFeaturesEXT-pDisabledValidationFeatures-parameter",
], ],
..ValidationError::from_requirement(err) )
})?; })?;
} }
} }

View File

@ -501,15 +501,6 @@ pub struct ValidationError {
} }
impl ValidationError { impl ValidationError {
fn from_requirement(err: RequirementNotMet) -> Self {
Self {
context: "".into(),
problem: err.required_for.into(),
vuids: &[],
requires_one_of: err.requires_one_of,
}
}
fn from_error<E: Error>(err: E) -> Self { fn from_error<E: Error>(err: E) -> Self {
Self { Self {
context: "".into(), context: "".into(),
@ -528,6 +519,11 @@ impl ValidationError {
self self
} }
fn set_vuids(mut self: Box<Self>, vuids: &'static [&'static str]) -> Box<Self> {
self.vuids = vuids;
self
}
} }
impl Debug for ValidationError { impl Debug for ValidationError {
@ -688,44 +684,6 @@ impl Display for Requires {
} }
} }
#[derive(Clone, Copy, Debug)]
pub(crate) struct RequirementNotMet {
pub(crate) required_for: &'static str,
pub(crate) requires_one_of: RequiresOneOf,
}
/// Error type returned by most Vulkan functions.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum OomError {
/// There is no memory available on the host (ie. the CPU, RAM, etc.).
OutOfHostMemory,
/// There is no memory available on the device (ie. video memory).
OutOfDeviceMemory,
}
impl Error for OomError {}
impl Display for OomError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
let msg = match self {
OomError::OutOfHostMemory => "no memory available on the host",
OomError::OutOfDeviceMemory => "no memory available on the graphical device",
};
write!(f, "{msg}")
}
}
impl From<VulkanError> for OomError {
fn from(err: VulkanError) -> OomError {
match err {
VulkanError::OutOfHostMemory => OomError::OutOfHostMemory,
VulkanError::OutOfDeviceMemory => OomError::OutOfDeviceMemory,
_ => panic!("unexpected error: {:?}", err),
}
}
}
/// A helper type for non-exhaustive structs. /// A helper type for non-exhaustive structs.
/// ///
/// This type cannot be constructed outside Vulkano. Structures with a field of this type can only /// This type cannot be constructed outside Vulkano. Structures with a field of this type can only

View File

@ -21,7 +21,7 @@
pub use crate::fns::EntryFunctions; pub use crate::fns::EntryFunctions;
use crate::{ use crate::{
instance::{InstanceExtensions, LayerProperties}, instance::{InstanceExtensions, LayerProperties},
ExtensionProperties, OomError, SafeDeref, Version, VulkanError, ExtensionProperties, SafeDeref, Version, VulkanError,
}; };
use libloading::{Error as LibloadingError, Library}; use libloading::{Error as LibloadingError, Library};
use std::{ use std::{
@ -233,7 +233,7 @@ impl VulkanLibrary {
/// ``` /// ```
pub fn layer_properties( pub fn layer_properties(
&self, &self,
) -> Result<impl ExactSizeIterator<Item = LayerProperties>, OomError> { ) -> Result<impl ExactSizeIterator<Item = LayerProperties>, VulkanError> {
let fns = self.fns(); let fns = self.fns();
let layer_properties = unsafe { let layer_properties = unsafe {
@ -255,7 +255,7 @@ impl VulkanLibrary {
break properties; break properties;
} }
ash::vk::Result::INCOMPLETE => (), ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()), err => return Err(VulkanError::from(err)),
} }
} }
}; };

View File

@ -330,7 +330,7 @@ macro_rules! vulkan_bitflags {
pub(crate) fn validate_device( pub(crate) fn validate_device(
self, self,
device: &crate::device::Device, device: &crate::device::Device,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
device.api_version(), device.api_version(),
device.enabled_features(), device.enabled_features(),
@ -344,7 +344,7 @@ macro_rules! vulkan_bitflags {
pub(crate) fn validate_physical_device( pub(crate) fn validate_physical_device(
self, self,
physical_device: &crate::device::physical::PhysicalDevice, physical_device: &crate::device::physical::PhysicalDevice,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
physical_device.api_version(), physical_device.api_version(),
physical_device.supported_features(), physical_device.supported_features(),
@ -360,7 +360,7 @@ macro_rules! vulkan_bitflags {
#[allow(unused_variables)] device_features: &crate::device::Features, #[allow(unused_variables)] device_features: &crate::device::Features,
#[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions, #[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions,
#[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions, #[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
$( $(
$( $(
if self.intersects(Self::$flag_name) && ![ if self.intersects(Self::$flag_name) && ![
@ -379,8 +379,8 @@ macro_rules! vulkan_bitflags {
)+)? )+)?
].into_iter().all(|x| x)),* ].into_iter().all(|x| x)),*
].into_iter().any(|x| x) { ].into_iter().any(|x| x) {
return Err(crate::RequirementNotMet { return Err(Box::new(crate::ValidationError {
required_for: concat!("`", stringify!($ty), "::", stringify!($flag_name), "`"), problem: concat!("is `", stringify!($ty), "::", stringify!($flag_name), "`").into(),
requires_one_of: crate::RequiresOneOf(&[ requires_one_of: crate::RequiresOneOf(&[
$(crate::RequiresAllOf(&[ $(crate::RequiresAllOf(&[
$( $(
@ -397,7 +397,8 @@ macro_rules! vulkan_bitflags {
)+)? )+)?
])),* ])),*
]), ]),
}); ..Default::default()
}));
} }
)? )?
)* )*
@ -410,7 +411,7 @@ macro_rules! vulkan_bitflags {
pub(crate) fn validate_instance( pub(crate) fn validate_instance(
self, self,
instance: &crate::instance::Instance, instance: &crate::instance::Instance,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_instance_raw( self.validate_instance_raw(
instance.api_version(), instance.api_version(),
instance.enabled_extensions(), instance.enabled_extensions(),
@ -422,7 +423,7 @@ macro_rules! vulkan_bitflags {
self, self,
#[allow(unused_variables)] instance_api_version: crate::Version, #[allow(unused_variables)] instance_api_version: crate::Version,
#[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions, #[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
$( $(
$( $(
if self.intersects(Self::$flag_name) && ![ if self.intersects(Self::$flag_name) && ![
@ -435,8 +436,8 @@ macro_rules! vulkan_bitflags {
)+)? )+)?
].into_iter().all(|x| x)),* ].into_iter().all(|x| x)),*
].into_iter().any(|x| x) { ].into_iter().any(|x| x) {
return Err(crate::RequirementNotMet { return Err(Box::new(crate::ValidationError {
required_for: concat!("`", stringify!($ty), "::", stringify!($flag_name), "`"), problem: concat!("is `", stringify!($ty), "::", stringify!($flag_name), "`").into(),
requires_one_of: crate::RequiresOneOf(&[ requires_one_of: crate::RequiresOneOf(&[
$(crate::RequiresAllOf(&[ $(crate::RequiresAllOf(&[
$( $(
@ -447,7 +448,8 @@ macro_rules! vulkan_bitflags {
)+)? )+)?
])),* ])),*
]), ]),
}); ..Default::default()
}));
} }
)? )?
)* )*
@ -668,7 +670,7 @@ macro_rules! vulkan_enum {
pub(crate) fn validate_device( pub(crate) fn validate_device(
self, self,
device: &crate::device::Device, device: &crate::device::Device,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
device.api_version(), device.api_version(),
device.enabled_features(), device.enabled_features(),
@ -682,7 +684,7 @@ macro_rules! vulkan_enum {
pub(crate) fn validate_physical_device( pub(crate) fn validate_physical_device(
self, self,
physical_device: &crate::device::physical::PhysicalDevice, physical_device: &crate::device::physical::PhysicalDevice,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_device_raw( self.validate_device_raw(
physical_device.api_version(), physical_device.api_version(),
physical_device.supported_features(), physical_device.supported_features(),
@ -698,7 +700,7 @@ macro_rules! vulkan_enum {
#[allow(unused_variables)] device_features: &crate::device::Features, #[allow(unused_variables)] device_features: &crate::device::Features,
#[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions, #[allow(unused_variables)] device_extensions: &crate::device::DeviceExtensions,
#[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions, #[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
match self { match self {
$( $(
$( $(
@ -719,8 +721,8 @@ macro_rules! vulkan_enum {
)+)? )+)?
].into_iter().all(|x| x)),* ].into_iter().all(|x| x)),*
].into_iter().any(|x| x) { ].into_iter().any(|x| x) {
return Err(crate::RequirementNotMet { return Err(Box::new(crate::ValidationError {
required_for: concat!("`", stringify!($ty), "::", stringify!($flag_name), "`"), problem: concat!("is `", stringify!($ty), "::", stringify!($flag_name), "`").into(),
requires_one_of: crate::RequiresOneOf(&[ requires_one_of: crate::RequiresOneOf(&[
$(crate::RequiresAllOf(&[ $(crate::RequiresAllOf(&[
$( $(
@ -737,7 +739,8 @@ macro_rules! vulkan_enum {
)+)? )+)?
])),* ])),*
]), ]),
}); ..Default::default()
}));
} }
}, },
)? )?
@ -753,7 +756,7 @@ macro_rules! vulkan_enum {
pub(crate) fn validate_instance( pub(crate) fn validate_instance(
self, self,
instance: &crate::instance::Instance, instance: &crate::instance::Instance,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
self.validate_instance_raw( self.validate_instance_raw(
instance.api_version(), instance.api_version(),
instance.enabled_extensions(), instance.enabled_extensions(),
@ -765,7 +768,7 @@ macro_rules! vulkan_enum {
self, self,
#[allow(unused_variables)] instance_api_version: crate::Version, #[allow(unused_variables)] instance_api_version: crate::Version,
#[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions, #[allow(unused_variables)] instance_extensions: &crate::instance::InstanceExtensions,
) -> Result<(), crate::RequirementNotMet> { ) -> Result<(), Box<crate::ValidationError>> {
match self { match self {
$( $(
$( $(
@ -780,8 +783,8 @@ macro_rules! vulkan_enum {
)+)? )+)?
].into_iter().all(|x| x)),* ].into_iter().all(|x| x)),*
].into_iter().any(|x| x) { ].into_iter().any(|x| x) {
return Err(crate::RequirementNotMet { return Err(Box::new(crate::ValidationError {
required_for: concat!("`", stringify!($ty), "::", stringify!($flag_name), "`"), problem: concat!("is `", stringify!($ty), "::", stringify!($flag_name), "`").into(),
requires_one_of: crate::RequiresOneOf(&[ requires_one_of: crate::RequiresOneOf(&[
$(crate::RequiresAllOf(&[ $(crate::RequiresAllOf(&[
$( $(
@ -792,7 +795,8 @@ macro_rules! vulkan_enum {
)+)? )+)?
])),* ])),*
]), ]),
}); ..Default::default()
}));
} }
}, },
)? )?

View File

@ -939,10 +939,7 @@ impl<S: Suballocator> GenericMemoryAllocator<S> {
for (index, export_handle_types) in export_handle_types.iter().enumerate() { for (index, export_handle_types) in export_handle_types.iter().enumerate() {
export_handle_types export_handle_types
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| err.add_context(format!("export_handle_types[{}]", index)))?;
context: format!("export_handle_types[{}]", index).into(),
..ValidationError::from_requirement(err)
})?;
} }
} }

View File

@ -440,13 +440,10 @@ impl DeviceMemory {
&self, &self,
handle_type: ExternalMemoryHandleType, handle_type: ExternalMemoryHandleType,
) -> Result<(), Box<ValidationError>> { ) -> Result<(), Box<ValidationError>> {
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkMemoryGetFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkMemoryGetFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -621,11 +618,13 @@ impl<'d> MemoryAllocateInfo<'d> {
let memory_type = memory_properties let memory_type = memory_properties
.memory_types .memory_types
.get(memory_type_index as usize) .get(memory_type_index as usize)
.ok_or(ValidationError { .ok_or_else(|| {
context: "memory_type_index".into(), Box::new(ValidationError {
problem: "is not less than the number of memory types in the device".into(), context: "memory_type_index".into(),
vuids: &["VUID-vkAllocateMemory-pAllocateInfo-01714"], problem: "is not less than the number of memory types in the device".into(),
..Default::default() vuids: &["VUID-vkAllocateMemory-pAllocateInfo-01714"],
..Default::default()
})
})?; })?;
let memory_heap = &memory_properties.memory_heaps[memory_type.heap_index as usize]; let memory_heap = &memory_properties.memory_heaps[memory_type.heap_index as usize];
@ -733,13 +732,10 @@ impl<'d> MemoryAllocateInfo<'d> {
})); }));
} }
export_handle_types export_handle_types.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("export_handle_types")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkExportMemoryAllocateInfo-handleTypes-parameter"])
context: "export_handle_types".into(), })?;
vuids: &["VUID-VkExportMemoryAllocateInfo-handleTypes-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkMemoryAllocateInfo-pNext-00639 // VUID-VkMemoryAllocateInfo-pNext-00639
// VUID-VkExportMemoryAllocateInfo-handleTypes-00656 // VUID-VkExportMemoryAllocateInfo-handleTypes-00656
@ -869,13 +865,10 @@ impl MemoryImportInfo {
#[cfg(unix)] #[cfg(unix)]
{ {
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportMemoryFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportMemoryFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
match handle_type { match handle_type {
ExternalMemoryHandleType::OpaqueFd => { ExternalMemoryHandleType::OpaqueFd => {
@ -929,13 +922,11 @@ impl MemoryImportInfo {
#[cfg(windows)] #[cfg(windows)]
{ {
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkImportMemoryWin32HandleInfoKHR-handleType-parameter",
context: "handle_type".into(), ])
vuids: &["VUID-VkImportMemoryWin32HandleInfoKHR-handleType-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
match handle_type { match handle_type {
ExternalMemoryHandleType::OpaqueWin32 ExternalMemoryHandleType::OpaqueWin32

View File

@ -365,13 +365,10 @@ impl PipelineCacheCreateInfo {
_ne, _ne,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineCacheCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkPipelineCacheCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -163,7 +163,7 @@ impl ComputePipeline {
let mut output = MaybeUninit::uninit(); let mut output = MaybeUninit::uninit();
(fns.v1_0.create_compute_pipelines)( (fns.v1_0.create_compute_pipelines)(
device.handle(), device.handle(),
cache.as_ref().map_or(Default::default(), |c| c.handle()), cache.as_ref().map_or_else(Default::default, |c| c.handle()),
1, 1,
&create_infos_vk, &create_infos_vk,
ptr::null(), ptr::null(),
@ -320,13 +320,10 @@ impl ComputePipelineCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkComputePipelineCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkComputePipelineCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
stage stage
.validate(device) .validate(device)
@ -359,15 +356,17 @@ impl ComputePipelineCreateInfo {
.map(|(k, v)| (*k, v)), .map(|(k, v)| (*k, v)),
entry_point_info.push_constant_requirements.as_ref(), entry_point_info.push_constant_requirements.as_ref(),
) )
.map_err(|err| ValidationError { .map_err(|err| {
context: "stage.entry_point".into(), Box::new(ValidationError {
vuids: &[ context: "stage.entry_point".into(),
"VUID-VkComputePipelineCreateInfo-layout-07987", vuids: &[
"VUID-VkComputePipelineCreateInfo-layout-07988", "VUID-VkComputePipelineCreateInfo-layout-07987",
"VUID-VkComputePipelineCreateInfo-layout-07990", "VUID-VkComputePipelineCreateInfo-layout-07988",
"VUID-VkComputePipelineCreateInfo-layout-07991", "VUID-VkComputePipelineCreateInfo-layout-07990",
], "VUID-VkComputePipelineCreateInfo-layout-07991",
..ValidationError::from_error(err) ],
..ValidationError::from_error(err)
})
})?; })?;
// TODO: // TODO:

View File

@ -154,13 +154,10 @@ impl ColorBlendState {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkPipelineColorBlendStateCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if let Some(logic_op) = logic_op { if let Some(logic_op) = logic_op {
if !device.enabled_features().logic_op { if !device.enabled_features().logic_op {
@ -175,17 +172,11 @@ impl ColorBlendState {
} }
match logic_op { match logic_op {
StateMode::Fixed(logic_op) => { StateMode::Fixed(logic_op) => logic_op.validate_device(device).map_err(|err| {
logic_op err.add_context("logic_op").set_vuids(&[
.validate_device(device) "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607",
.map_err(|err| ValidationError { ])
context: "logic_op".into(), })?,
vuids: &[
"VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607",
],
..ValidationError::from_requirement(err)
})?
}
StateMode::Dynamic => { StateMode::Dynamic => {
if !device.enabled_features().extended_dynamic_state2_logic_op { if !device.enabled_features().extended_dynamic_state2_logic_op {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -471,51 +462,45 @@ impl AttachmentBlend {
src_color_blend_factor src_color_blend_factor
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "src_color_blend_factor".into(), err.add_context("src_color_blend_factor").set_vuids(&[
vuids: &["VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"], "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
dst_color_blend_factor dst_color_blend_factor
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "dst_color_blend_factor".into(), err.add_context("dst_color_blend_factor").set_vuids(&[
vuids: &["VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"], "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
color_blend_op color_blend_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("color_blend_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"])
context: "color_blend_op".into(), })?;
vuids: &["VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"],
..ValidationError::from_requirement(err)
})?;
src_alpha_blend_factor src_alpha_blend_factor
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "src_alpha_blend_factor".into(), err.add_context("src_alpha_blend_factor").set_vuids(&[
vuids: &["VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"], "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
dst_alpha_blend_factor dst_alpha_blend_factor
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "dst_alpha_blend_factor".into(), err.add_context("dst_alpha_blend_factor").set_vuids(&[
vuids: &["VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"], "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
alpha_blend_op alpha_blend_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("alpha_blend_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"])
context: "alpha_blend_op".into(), })?;
vuids: &["VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().dual_src_blend { if !device.enabled_features().dual_src_blend {
if matches!( if matches!(

View File

@ -96,13 +96,10 @@ impl DepthStencilState {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkPipelineDepthStencilStateCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if let Some(depth_state) = depth { if let Some(depth_state) = depth {
depth_state depth_state
@ -243,15 +240,11 @@ impl DepthState {
match compare_op { match compare_op {
StateMode::Fixed(compare_op) => { StateMode::Fixed(compare_op) => {
compare_op compare_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("compare_op").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter",
context: "compare_op".into(), ])
vuids: &[ })?;
"VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter",
],
..ValidationError::from_requirement(err)
})?;
} }
StateMode::Dynamic => { StateMode::Dynamic => {
if !(device.api_version() >= Version::V1_3 if !(device.api_version() >= Version::V1_3
@ -568,37 +561,25 @@ impl StencilOps {
compare_op, compare_op,
} = self; } = self;
fail_op fail_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("fail_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkStencilOpState-failOp-parameter"])
context: "fail_op".into(), })?;
vuids: &["VUID-VkStencilOpState-failOp-parameter"],
..ValidationError::from_requirement(err)
})?;
pass_op pass_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("pass_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkStencilOpState-passOp-parameter"])
context: "pass_op".into(), })?;
vuids: &["VUID-VkStencilOpState-passOp-parameter"],
..ValidationError::from_requirement(err)
})?;
depth_fail_op depth_fail_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("depth_fail_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkStencilOpState-depthFailOp-parameter"])
context: "depth_fail_op".into(), })?;
vuids: &["VUID-VkStencilOpState-depthFailOp-parameter"],
..ValidationError::from_requirement(err)
})?;
compare_op compare_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("compare_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkStencilOpState-compareOp-parameter"])
context: "compare_op".into(), })?;
vuids: &["VUID-VkStencilOpState-compareOp-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -55,10 +55,10 @@ impl DiscardRectangleState {
let properties = device.physical_device().properties(); let properties = device.physical_device().properties();
mode.validate_device(device).map_err(|err| ValidationError { mode.validate_device(device).map_err(|err| {
context: "mode".into(), err.add_context("mode").set_vuids(&[
vuids: &["VUID-VkPipelineDiscardRectangleStateCreateInfoEXT-discardRectangleMode-parameter"], "VUID-VkPipelineDiscardRectangleStateCreateInfoEXT-discardRectangleMode-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
let discard_rectangle_count = match rectangles { let discard_rectangle_count = match rectangles {

View File

@ -93,13 +93,11 @@ impl InputAssemblyState {
match topology { match topology {
PartialStateMode::Fixed(topology) => { PartialStateMode::Fixed(topology) => {
topology topology.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("topology").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter",
context: "topology".into(), ])
vuids: &["VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
match topology { match topology {
PrimitiveTopology::TriangleFan => { PrimitiveTopology::TriangleFan => {
@ -156,10 +154,10 @@ impl InputAssemblyState {
topology_class topology_class
.example() .example()
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "topology".into(), err.add_context("topology").set_vuids(&[
vuids: &["VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"], "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter",
..ValidationError::from_requirement(err) ])
})?; })?;
if !(device.api_version() >= Version::V1_3 if !(device.api_version() >= Version::V1_3

View File

@ -1900,13 +1900,10 @@ impl GraphicsPipelineCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkGraphicsPipelineCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkGraphicsPipelineCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
/* /*
Gather shader stages Gather shader stages
@ -2436,10 +2433,12 @@ impl GraphicsPipelineCreateInfo {
.map(|(k, v)| (*k, v)), .map(|(k, v)| (*k, v)),
entry_point_info.push_constant_requirements.as_ref(), entry_point_info.push_constant_requirements.as_ref(),
) )
.map_err(|err| ValidationError { .map_err(|err| {
context: format!("stages[{}].entry_point", stage_index).into(), Box::new(ValidationError {
vuids: &["VUID-VkGraphicsPipelineCreateInfo-layout-00756"], context: format!("stages[{}].entry_point", stage_index).into(),
..ValidationError::from_error(err) vuids: &["VUID-VkGraphicsPipelineCreateInfo-layout-00756"],
..ValidationError::from_error(err)
})
})?; })?;
} }

View File

@ -87,12 +87,10 @@ impl MultisampleState {
rasterization_samples rasterization_samples
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "rasterization_samples".into(), err.add_context("rasterization_samples").set_vuids(&[
vuids: &[
"VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter", "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
if let Some(min_sample_shading) = sample_shading { if let Some(min_sample_shading) = sample_shading {

View File

@ -156,21 +156,14 @@ impl RasterizationState {
let properties = device.physical_device().properties(); let properties = device.physical_device().properties();
polygon_mode polygon_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("polygon_mode")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-parameter"])
context: "polygon_mode".into(), })?;
vuids: &["VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-parameter"],
..ValidationError::from_requirement(err)
})?;
line_rasterization_mode line_rasterization_mode
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| err.add_context("line_rasterization_mode").set_vuids(&["VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-parameter"]))?;
context: "line_rasterization_mode".into(),
vuids: &["VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-parameter"],
..ValidationError::from_requirement(err)
})?;
if depth_clamp_enable && !device.enabled_features().depth_clamp { if depth_clamp_enable && !device.enabled_features().depth_clamp {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -234,13 +227,11 @@ impl RasterizationState {
match cull_mode { match cull_mode {
StateMode::Fixed(cull_mode) => { StateMode::Fixed(cull_mode) => {
cull_mode cull_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("cull_mode").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkPipelineRasterizationStateCreateInfo-cullMode-parameter",
context: "cull_mode".into(), ])
vuids: &["VUID-VkPipelineRasterizationStateCreateInfo-cullMode-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
} }
StateMode::Dynamic => { StateMode::Dynamic => {
if !(device.api_version() >= Version::V1_3 if !(device.api_version() >= Version::V1_3
@ -262,13 +253,11 @@ impl RasterizationState {
match front_face { match front_face {
StateMode::Fixed(front_face) => { StateMode::Fixed(front_face) => {
front_face front_face.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("front_face").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkPipelineRasterizationStateCreateInfo-frontFace-parameter",
context: "front_face".into(), ])
vuids: &["VUID-VkPipelineRasterizationStateCreateInfo-frontFace-parameter"], })?;
..ValidationError::from_requirement(err)
})?;
} }
StateMode::Dynamic => { StateMode::Dynamic => {
if !(device.api_version() >= Version::V1_3 if !(device.api_version() >= Version::V1_3

View File

@ -185,13 +185,10 @@ impl PipelineRenderingCreateInfo {
{ {
let attachment_index = attachment_index as u32; let attachment_index = attachment_index as u32;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context(format!("color_attachment_formats[{}]", attachment_index))
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"])
context: format!("color_attachment_formats[{}]", attachment_index).into(), })?;
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"],
..ValidationError::from_requirement(err)
})?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -217,13 +214,10 @@ impl PipelineRenderingCreateInfo {
} }
if let Some(format) = depth_attachment_format { if let Some(format) = depth_attachment_format {
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("depth_attachment_format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkGraphicsPipelineCreateInfo-renderPass-06583"])
context: "depth_attachment_format".into(), })?;
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06583"],
..ValidationError::from_requirement(err)
})?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -258,13 +252,10 @@ impl PipelineRenderingCreateInfo {
} }
if let Some(format) = stencil_attachment_format { if let Some(format) = stencil_attachment_format {
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stencil_attachment_format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkGraphicsPipelineCreateInfo-renderPass-06584"])
context: "stencil_attachment_format".into(), })?;
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06584"],
..ValidationError::from_requirement(err)
})?;
if format == Format::UNDEFINED { if format == Format::UNDEFINED {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -112,15 +112,11 @@ impl TessellationState {
} }
}; };
domain_origin domain_origin.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("domain_origin").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkPipelineTessellationDomainOriginStateCreateInfo-domainOrigin-parameter",
context: "domain_origin".into(), ])
vuids: &[ })?;
"VUID-VkPipelineTessellationDomainOriginStateCreateInfo-domainOrigin-parameter",
],
..ValidationError::from_requirement(err)
})?;
if domain_origin != TessellationDomainOrigin::UpperLeft if domain_origin != TessellationDomainOrigin::UpperLeft
&& !(device.api_version() >= Version::V1_1 && !(device.api_version() >= Version::V1_1

View File

@ -243,14 +243,16 @@ impl VertexInputState {
})); }));
} }
let binding_desc = bindings.get(&binding).ok_or(ValidationError { let binding_desc = bindings.get(&binding).ok_or_else(|| {
problem: format!( Box::new(ValidationError {
"`attributes[{}].binding` is not present in `bindings`", problem: format!(
binding "`attributes[{}].binding` is not present in `bindings`",
) binding
.into(), )
vuids: &["VUID-VkPipelineVertexInputStateCreateInfo-binding-00615"], .into(),
..Default::default() vuids: &["VUID-VkPipelineVertexInputStateCreateInfo-binding-00615"],
..Default::default()
})
})?; })?;
if device.enabled_extensions().khr_portability_subset if device.enabled_extensions().khr_portability_subset
@ -438,13 +440,10 @@ impl VertexInputAttributeDescription {
let properties = device.physical_device().properties(); let properties = device.physical_device().properties();
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkVertexInputAttributeDescription-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkVertexInputAttributeDescription-format-parameter"],
..ValidationError::from_requirement(err)
})?;
if binding > properties.max_vertex_input_bindings { if binding > properties.max_vertex_input_bindings {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -457,13 +457,10 @@ impl PipelineLayoutCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineLayoutCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkPipelineLayoutCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if set_layouts.len() > properties.max_bound_descriptor_sets as usize { if set_layouts.len() > properties.max_bound_descriptor_sets as usize {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -819,13 +816,10 @@ impl PushConstantRange {
size, size,
} = self; } = self;
stages stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPushConstantRange-stageFlags-parameter"])
context: "stages".into(), })?;
vuids: &["VUID-VkPushConstantRange-stageFlags-parameter"],
..ValidationError::from_requirement(err)
})?;
if stages.is_empty() { if stages.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {

View File

@ -344,24 +344,18 @@ impl PipelineShaderStageCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineShaderStageCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkPipelineShaderStageCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
let entry_point_info = entry_point.info(); let entry_point_info = entry_point.info();
let stage_enum = ShaderStage::from(&entry_point_info.execution); let stage_enum = ShaderStage::from(&entry_point_info.execution);
stage_enum stage_enum.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("entry_point.info().execution")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkPipelineShaderStageCreateInfo-stage-parameter"])
context: "entry_point.info().execution".into(), })?;
vuids: &["VUID-VkPipelineShaderStageCreateInfo-stage-parameter"],
..ValidationError::from_requirement(err)
})?;
// VUID-VkPipelineShaderStageCreateInfo-pName-00707 // VUID-VkPipelineShaderStageCreateInfo-pName-00707
// Guaranteed by definition of `EntryPoint`. // Guaranteed by definition of `EntryPoint`.

View File

@ -18,8 +18,8 @@ use crate::{
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
instance::InstanceOwnedDebugWrapper, instance::InstanceOwnedDebugWrapper,
macros::{impl_id_counter, vulkan_bitflags}, macros::{impl_id_counter, vulkan_bitflags},
DeviceSize, RequirementNotMet, Requires, RequiresAllOf, RequiresOneOf, Validated, DeviceSize, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, VulkanError,
ValidationError, VulkanError, VulkanObject, VulkanObject,
}; };
use std::{ use std::{
ffi::c_void, ffi::c_void,
@ -183,13 +183,10 @@ impl QueryPool {
where where
T: QueryResultElement, T: QueryResultElement,
{ {
flags flags.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-vkGetQueryPoolResults-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-vkGetQueryPoolResults-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if destination.is_empty() { if destination.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -363,13 +360,10 @@ impl QueryPoolCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
query_type query_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("query_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkQueryPoolCreateInfo-queryType-parameter"])
context: "query_type".into(), })?;
vuids: &["VUID-VkQueryPoolCreateInfo-queryType-parameter"],
..ValidationError::from_requirement(err)
})?;
match query_type { match query_type {
QueryType::PipelineStatistics(flags) => { QueryType::PipelineStatistics(flags) => {
@ -384,13 +378,10 @@ impl QueryPoolCreateInfo {
})); }));
} }
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("query_type.flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkQueryPoolCreateInfo-queryType-00792"])
context: "query_type.flags".into(), })?;
vuids: &["VUID-VkQueryPoolCreateInfo-queryType-00792"],
..ValidationError::from_requirement(err)
})?;
} }
QueryType::Occlusion QueryType::Occlusion
| QueryType::Timestamp | QueryType::Timestamp
@ -508,50 +499,55 @@ impl QueryType {
} }
} }
pub(crate) fn validate_device(&self, device: &Device) -> Result<(), RequirementNotMet> { pub(crate) fn validate_device(&self, device: &Device) -> Result<(), Box<ValidationError>> {
match self { match self {
QueryType::Occlusion => (), QueryType::Occlusion => (),
QueryType::PipelineStatistics(_) => (), QueryType::PipelineStatistics(_) => (),
QueryType::Timestamp => (), QueryType::Timestamp => (),
QueryType::AccelerationStructureCompactedSize => { QueryType::AccelerationStructureCompactedSize => {
if !device.enabled_extensions().khr_acceleration_structure { if !device.enabled_extensions().khr_acceleration_structure {
return Err(crate::RequirementNotMet { return Err(Box::new(ValidationError {
required_for: "QueryType::AccelerationStructureCompactedSize", problem: "is `QueryType::AccelerationStructureCompactedSize`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[ requires_one_of: RequiresOneOf(&[RequiresAllOf(&[
Requires::DeviceExtension("khr_acceleration_structure"), Requires::DeviceExtension("khr_acceleration_structure"),
])]), ])]),
}); ..Default::default()
}));
} }
} }
QueryType::AccelerationStructureSerializationSize => { QueryType::AccelerationStructureSerializationSize => {
if !device.enabled_extensions().khr_acceleration_structure { if !device.enabled_extensions().khr_acceleration_structure {
return Err(crate::RequirementNotMet { return Err(Box::new(ValidationError {
required_for: "QueryType::AccelerationStructureSerializationSize", problem: "is `QueryType::AccelerationStructureSerializationSize`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[ requires_one_of: RequiresOneOf(&[RequiresAllOf(&[
Requires::DeviceExtension("khr_acceleration_structure"), Requires::DeviceExtension("khr_acceleration_structure"),
])]), ])]),
}); ..Default::default()
}));
} }
} }
QueryType::AccelerationStructureSerializationBottomLevelPointers => { QueryType::AccelerationStructureSerializationBottomLevelPointers => {
if !device.enabled_extensions().khr_ray_tracing_maintenance1 { if !device.enabled_extensions().khr_ray_tracing_maintenance1 {
return Err(crate::RequirementNotMet { return Err(Box::new(ValidationError {
required_for: problem:
"QueryType::AccelerationStructureSerializationBottomLevelPointers", "is `QueryType::AccelerationStructureSerializationBottomLevelPointers`"
.into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[ requires_one_of: RequiresOneOf(&[RequiresAllOf(&[
Requires::DeviceExtension("khr_ray_tracing_maintenance1"), Requires::DeviceExtension("khr_ray_tracing_maintenance1"),
])]), ])]),
}); ..Default::default()
}));
} }
} }
QueryType::AccelerationStructureSize => { QueryType::AccelerationStructureSize => {
if !device.enabled_extensions().khr_ray_tracing_maintenance1 { if !device.enabled_extensions().khr_ray_tracing_maintenance1 {
return Err(crate::RequirementNotMet { return Err(Box::new(ValidationError {
required_for: "QueryType::AccelerationStructureSize", problem: "is `QueryType::AccelerationStructureSize`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[ requires_one_of: RequiresOneOf(&[RequiresAllOf(&[
Requires::DeviceExtension("khr_ray_tracing_maintenance1"), Requires::DeviceExtension("khr_ray_tracing_maintenance1"),
])]), ])]),
}); ..Default::default()
}));
} }
} }
} }

View File

@ -523,13 +523,10 @@ impl FramebufferCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkFramebufferCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkFramebufferCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
for (index, image_view) in attachments.iter().enumerate() { for (index, image_view) in attachments.iter().enumerate() {
assert_eq!(device, image_view.device().as_ref()); assert_eq!(device, image_view.device().as_ref());

View File

@ -834,13 +834,10 @@ impl RenderPassCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkRenderPassCreateInfo2-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkRenderPassCreateInfo2-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
let mut attachment_potential_format_features = let mut attachment_potential_format_features =
vec![FormatFeatures::empty(); attachments.len()]; vec![FormatFeatures::empty(); attachments.len()];
@ -934,19 +931,18 @@ impl RenderPassCreateInfo {
_ne: _, _ne: _,
} = color_attachment; } = color_attachment;
let attachment_desc = let attachment_desc = attachments.get(attachment as usize).ok_or_else(|| {
attachments Box::new(ValidationError {
.get(attachment as usize) problem: format!(
.ok_or_else(|| ValidationError { "`subpasses[{0}].color_attachments[{1}].attachment` \
problem: format!(
"`subpasses[{0}].color_attachments[{1}].attachment` \
is not less than the length of `attachments`", is not less than the length of `attachments`",
subpass_index, ref_index subpass_index, ref_index
) )
.into(), .into(),
vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"], vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"],
..Default::default() ..Default::default()
})?; })
})?;
let is_first_use = !replace(&mut attachment_is_used[attachment as usize], true); let is_first_use = !replace(&mut attachment_is_used[attachment as usize], true);
@ -1023,15 +1019,17 @@ impl RenderPassCreateInfo {
let resolve_attachment_desc = attachments let resolve_attachment_desc = attachments
.get(resolve_attachment as usize) .get(resolve_attachment as usize)
.ok_or_else(|| ValidationError { .ok_or_else(|| {
problem: format!( Box::new(ValidationError {
problem: format!(
"`subpasses[{0}].color_resolve_attachments[{1}].attachment` is \ "`subpasses[{0}].color_resolve_attachments[{1}].attachment` is \
not less than the length of `attachments`", not less than the length of `attachments`",
subpass_index, ref_index subpass_index, ref_index
) )
.into(), .into(),
vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"], vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"],
..Default::default() ..Default::default()
})
})?; })?;
let is_first_use = let is_first_use =
@ -1135,19 +1133,18 @@ impl RenderPassCreateInfo {
_ne: _, _ne: _,
} = depth_stencil_attachment; } = depth_stencil_attachment;
let attachment_desc = let attachment_desc = attachments.get(attachment as usize).ok_or_else(|| {
attachments Box::new(ValidationError {
.get(attachment as usize) problem: format!(
.ok_or_else(|| ValidationError { "`subpasses[{}].depth_stencil_attachment.attachment` \
problem: format!(
"`subpasses[{}].depth_stencil_attachment.attachment` \
is not less than the length of `attachments`", is not less than the length of `attachments`",
subpass_index, subpass_index,
) )
.into(), .into(),
vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"], vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"],
..Default::default() ..Default::default()
})?; })
})?;
let format = attachment_desc.format; let format = attachment_desc.format;
@ -1247,15 +1244,17 @@ impl RenderPassCreateInfo {
let resolve_attachment_desc = attachments let resolve_attachment_desc = attachments
.get(resolve_attachment as usize) .get(resolve_attachment as usize)
.ok_or_else(|| ValidationError { .ok_or_else(|| {
problem: format!( Box::new(ValidationError {
problem: format!(
"`subpasses[{}].depth_stencil_resolve_attachment.attachment` is \ "`subpasses[{}].depth_stencil_resolve_attachment.attachment` is \
not less than the length of `attachments`", not less than the length of `attachments`",
subpass_index, subpass_index,
) )
.into(), .into(),
vuids: &["VUID-VkRenderPassCreateInfo2-pSubpasses-06473"], vuids: &["VUID-VkRenderPassCreateInfo2-pSubpasses-06473"],
..Default::default() ..Default::default()
})
})?; })?;
let resolve_format = resolve_attachment_desc.format; let resolve_format = resolve_attachment_desc.format;
@ -1391,19 +1390,18 @@ impl RenderPassCreateInfo {
_ne: _, _ne: _,
} = input_attachment; } = input_attachment;
let attachment_desc = let attachment_desc = attachments.get(attachment as usize).ok_or_else(|| {
attachments Box::new(ValidationError {
.get(attachment as usize) problem: format!(
.ok_or_else(|| ValidationError { "`subpasses[{}].input_attachments[{}].attachment` \
problem: format!(
"`subpasses[{}].input_attachments[{}].attachment` \
is not less than the length of `attachments`", is not less than the length of `attachments`",
subpass_index, ref_index subpass_index, ref_index
) )
.into(), .into(),
vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"], vuids: &["VUID-VkRenderPassCreateInfo2-attachment-03051"],
..Default::default() ..Default::default()
})?; })
})?;
let format_aspects = attachment_desc.format.aspects(); let format_aspects = attachment_desc.format.aspects();
let is_first_use = !replace(&mut attachment_is_used[attachment as usize], true); let is_first_use = !replace(&mut attachment_is_used[attachment as usize], true);
@ -1614,12 +1612,12 @@ impl RenderPassCreateInfo {
correlated_view_masks.iter().try_fold(0, |total, &mask| { correlated_view_masks.iter().try_fold(0, |total, &mask| {
if total & mask != 0 { if total & mask != 0 {
Err(ValidationError { Err(Box::new(ValidationError {
context: "correlated_view_masks".into(), context: "correlated_view_masks".into(),
problem: "the bit masks overlap with each other".into(), problem: "the bit masks overlap with each other".into(),
vuids: &["VUID-VkRenderPassCreateInfo2-pCorrelatedViewMasks-03056"], vuids: &["VUID-VkRenderPassCreateInfo2-pCorrelatedViewMasks-03056"],
..Default::default() ..Default::default()
}) }))
} else { } else {
Ok(total | mask) Ok(total | mask)
} }
@ -1757,61 +1755,40 @@ impl AttachmentDescription {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
format format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-format-parameter"])
context: "format".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-format-parameter"],
..ValidationError::from_requirement(err)
})?;
samples samples.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("samples")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-samples-parameter"])
context: "samples".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-samples-parameter"],
..ValidationError::from_requirement(err)
})?;
load_op load_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("load_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-loadOp-parameter"])
context: "load_op".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-loadOp-parameter"],
..ValidationError::from_requirement(err)
})?;
store_op store_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("store_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-storeOp-parameter"])
context: "store_op".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-storeOp-parameter"],
..ValidationError::from_requirement(err)
})?;
initial_layout initial_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("initial_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-initialLayout-parameter"])
context: "initial_layout".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-initialLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
final_layout final_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("final_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-finalLayout-parameter"])
context: "final_layout".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-finalLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
if matches!( if matches!(
final_layout, final_layout,
@ -1866,23 +1843,17 @@ impl AttachmentDescription {
} }
if let Some(stencil_load_op) = stencil_load_op { if let Some(stencil_load_op) = stencil_load_op {
stencil_load_op stencil_load_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stencil_load_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-stencilLoadOp-parameter"])
context: "stencil_load_op".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-stencilLoadOp-parameter"],
..ValidationError::from_requirement(err)
})?;
} }
if let Some(stencil_store_op) = stencil_store_op { if let Some(stencil_store_op) = stencil_store_op {
stencil_store_op stencil_store_op.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stencil_store_op")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentDescription2-stencilStoreOp-parameter"])
context: "stencil_store_op".into(), })?;
vuids: &["VUID-VkAttachmentDescription2-stencilStoreOp-parameter"],
..ValidationError::from_requirement(err)
})?;
} }
if stencil_initial_layout.is_some() != stencil_final_layout.is_some() { if stencil_initial_layout.is_some() != stencil_final_layout.is_some() {
@ -1908,12 +1879,10 @@ impl AttachmentDescription {
stencil_initial_layout stencil_initial_layout
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "stencil_initial_layout".into(), err.add_context("stencil_initial_layout").set_vuids(&[
vuids: &[
"VUID-VkAttachmentDescriptionStencilLayout-stencilInitialLayout-parameter", "VUID-VkAttachmentDescriptionStencilLayout-stencilInitialLayout-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
if matches!( if matches!(
@ -1951,12 +1920,10 @@ impl AttachmentDescription {
stencil_final_layout stencil_final_layout
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "stencil_final_layout".into(), err.add_context("stencil_final_layout").set_vuids(&[
vuids: &[
"VUID-VkAttachmentDescriptionStencilLayout-stencilFinalLayout-parameter", "VUID-VkAttachmentDescriptionStencilLayout-stencilFinalLayout-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
if matches!( if matches!(
@ -2375,13 +2342,10 @@ impl SubpassDescription {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSubpassDescription2-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkSubpassDescription2-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if color_attachments.len() as u32 > properties.max_color_attachments { if color_attachments.len() as u32 > properties.max_color_attachments {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -2859,11 +2823,7 @@ impl SubpassDescription {
depth_resolve_mode depth_resolve_mode
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| err.add_context("depth_resolve_mode"))?;
context: "depth_resolve_mode".into(),
// vuids?
..ValidationError::from_requirement(err)
})?;
if !properties if !properties
.supported_depth_resolve_modes .supported_depth_resolve_modes
@ -2892,11 +2852,7 @@ impl SubpassDescription {
stencil_resolve_mode stencil_resolve_mode
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| err.add_context("stencil_resolve_mode"))?;
context: "stencil_resolve_mode".into(),
// vuids?
..ValidationError::from_requirement(err)
})?;
if !properties if !properties
.supported_stencil_resolve_modes .supported_stencil_resolve_modes
@ -3176,13 +3132,10 @@ impl AttachmentReference {
_ne, _ne,
} = self; } = self;
layout layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentReference2-layout-parameter"])
context: "layout".into(), })?;
vuids: &["VUID-VkAttachmentReference2-layout-parameter"],
..ValidationError::from_requirement(err)
})?;
if matches!( if matches!(
layout, layout,
@ -3229,13 +3182,10 @@ impl AttachmentReference {
})); }));
} }
stencil_layout stencil_layout.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("stencil_layout")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkAttachmentReferenceStencilLayout-stencilLayout-parameter"])
context: "stencil_layout".into(), })?;
vuids: &["VUID-VkAttachmentReferenceStencilLayout-stencilLayout-parameter"],
..ValidationError::from_requirement(err)
})?;
if matches!( if matches!(
stencil_layout, stencil_layout,
@ -3283,11 +3233,7 @@ impl AttachmentReference {
aspects aspects
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| err.add_context("aspects"))?;
context: "aspects".into(),
// vuids?
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -672,18 +672,13 @@ where
) { ) {
Ok(_) => (), Ok(_) => (),
Err(AccessCheckError::Unknown) => { Err(AccessCheckError::Unknown) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(
problem: AccessError::SwapchainImageNotAcquired.to_string().into(), AccessError::SwapchainImageNotAcquired,
..Default::default() ))
})
.into()); .into());
} }
Err(AccessCheckError::Denied(err)) => { Err(AccessCheckError::Denied(err)) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(err)).into());
problem: err.to_string().into(),
..Default::default()
})
.into());
} }
} }

View File

@ -29,8 +29,7 @@
#![allow(unused_variables)] // TODO: this module isn't finished #![allow(unused_variables)] // TODO: this module isn't finished
use crate::{ use crate::{
device::physical::PhysicalDevice, swapchain::SurfaceTransforms, OomError, VulkanError, device::physical::PhysicalDevice, swapchain::SurfaceTransforms, VulkanError, VulkanObject,
VulkanObject,
}; };
use std::{ use std::{
ffi::CStr, ffi::CStr,
@ -56,7 +55,7 @@ impl DisplayPlane {
/// See the docs of enumerate(). /// See the docs of enumerate().
pub fn enumerate_raw( pub fn enumerate_raw(
physical_device: Arc<PhysicalDevice>, physical_device: Arc<PhysicalDevice>,
) -> Result<IntoIter<DisplayPlane>, OomError> { ) -> Result<IntoIter<DisplayPlane>, VulkanError> {
let fns = physical_device.instance().fns(); let fns = physical_device.instance().fns();
assert!(physical_device.instance().enabled_extensions().khr_display); // TODO: return error instead assert!(physical_device.instance().enabled_extensions().khr_display); // TODO: return error instead
@ -88,7 +87,7 @@ impl DisplayPlane {
break properties; break properties;
} }
ash::vk::Result::INCOMPLETE => (), ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()), err => return Err(VulkanError::from(err)),
} }
} }
}; };
@ -189,7 +188,7 @@ impl Display {
/// See the docs of enumerate(). /// See the docs of enumerate().
pub fn enumerate_raw( pub fn enumerate_raw(
physical_device: Arc<PhysicalDevice>, physical_device: Arc<PhysicalDevice>,
) -> Result<IntoIter<Display>, OomError> { ) -> Result<IntoIter<Display>, VulkanError> {
let fns = physical_device.instance().fns(); let fns = physical_device.instance().fns();
assert!(physical_device.instance().enabled_extensions().khr_display); // TODO: return error instead assert!(physical_device.instance().enabled_extensions().khr_display); // TODO: return error instead
@ -217,7 +216,7 @@ impl Display {
break properties; break properties;
} }
ash::vk::Result::INCOMPLETE => (), ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()), err => return Err(VulkanError::from(err)),
} }
} }
}; };
@ -295,7 +294,7 @@ impl Display {
} }
/// See the docs of display_modes(). /// See the docs of display_modes().
pub fn display_modes_raw(&self) -> Result<IntoIter<DisplayMode>, OomError> { pub fn display_modes_raw(&self) -> Result<IntoIter<DisplayMode>, VulkanError> {
let fns = self.physical_device.instance().fns(); let fns = self.physical_device.instance().fns();
let mode_properties = unsafe { let mode_properties = unsafe {
@ -324,7 +323,7 @@ impl Display {
break properties; break properties;
} }
ash::vk::Result::INCOMPLETE => (), ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()), err => return Err(VulkanError::from(err)),
} }
} }
}; };
@ -371,7 +370,7 @@ pub struct DisplayMode {
} }
impl DisplayMode { impl DisplayMode {
/*pub fn new(display: &Display) -> Result<Arc<DisplayMode>, OomError> { /*pub fn new(display: &Display) -> Result<Arc<DisplayMode>, VulkanError> {
let fns = instance.fns(); let fns = instance.fns();
assert!(device.instance().enabled_extensions().khr_display); // TODO: return error instead assert!(device.instance().enabled_extensions().khr_display); // TODO: return error instead

View File

@ -589,10 +589,13 @@ impl Swapchain {
..Default::default() ..Default::default()
}, },
) )
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_capabilities".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_capabilities` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
let surface_formats = unsafe { let surface_formats = unsafe {
@ -608,20 +611,26 @@ impl Swapchain {
..Default::default() ..Default::default()
}, },
) )
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_formats".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_formats` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
let surface_present_modes: SmallVec<[_; PresentMode::COUNT]> = unsafe { let surface_present_modes: SmallVec<[_; PresentMode::COUNT]> = unsafe {
device device
.physical_device() .physical_device()
.surface_present_modes_unchecked(surface) .surface_present_modes_unchecked(surface)
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_present_modes".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_present_modes` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
.collect() .collect()
}; };
@ -814,10 +823,13 @@ impl Swapchain {
..Default::default() ..Default::default()
}, },
) )
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::surface_capabilities".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::surface_capabilities` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
@ -1729,37 +1741,25 @@ impl SwapchainCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
image_format image_format.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_format")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-imageFormat-parameter"])
context: "image_format".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageFormat-parameter"],
..ValidationError::from_requirement(err)
})?;
image_color_space image_color_space.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_color_space")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-imageColorSpace-parameter"])
context: "image_color_space".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageColorSpace-parameter"],
..ValidationError::from_requirement(err)
})?;
image_usage image_usage.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("image_usage")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-imageUsage-parameter"])
context: "image_usage".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageUsage-parameter"],
..ValidationError::from_requirement(err)
})?;
if image_usage.is_empty() { if image_usage.is_empty() {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1770,29 +1770,20 @@ impl SwapchainCreateInfo {
})); }));
} }
pre_transform pre_transform.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("pre_transform")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-preTransform-parameter"])
context: "pre_transform".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-preTransform-parameter"],
..ValidationError::from_requirement(err)
})?;
composite_alpha composite_alpha.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("composite_alpha")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-compositeAlpha-parameter"])
context: "composite_alpha".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-compositeAlpha-parameter"],
..ValidationError::from_requirement(err)
})?;
present_mode present_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("present_mode")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSwapchainCreateInfoKHR-presentMode-parameter"])
context: "present_mode".into(), })?;
vuids: &["VUID-VkSwapchainCreateInfoKHR-presentMode-parameter"],
..ValidationError::from_requirement(err)
})?;
if image_extent.contains(&0) { if image_extent.contains(&0) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1868,10 +1859,13 @@ impl SwapchainCreateInfo {
usage: image_usage, usage: image_usage,
..Default::default() ..Default::default()
}) })
.map_err(|_err| ValidationError { .map_err(|_err| {
context: "PhysicalDevice::image_format_properties".into(), Box::new(ValidationError {
problem: "returned an error".into(), problem: "`PhysicalDevice::image_format_properties` \
..Default::default() returned an error"
.into(),
..Default::default()
})
})? })?
}; };
@ -1898,15 +1892,12 @@ impl SwapchainCreateInfo {
} }
for (index, &present_mode) in present_modes.iter().enumerate() { for (index, &present_mode) in present_modes.iter().enumerate() {
present_mode present_mode.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context(format!("present_modes[{}]", index))
.map_err(|err| ValidationError { .set_vuids(&[
context: format!("present_modes[{}]", index).into(),
vuids: &[
"VUID-VkSwapchainPresentModesCreateInfoEXT-pPresentModes-parameter", "VUID-VkSwapchainPresentModesCreateInfoEXT-pPresentModes-parameter",
], ])
..ValidationError::from_requirement(err) })?;
})?;
} }
if !present_modes.contains(&present_mode) { if !present_modes.contains(&present_mode) {
@ -1931,15 +1922,11 @@ impl SwapchainCreateInfo {
})); }));
} }
scaling_behavior scaling_behavior.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("scaling_behavior").set_vuids(&[
.map_err(|err| ValidationError { "VUID-VkSwapchainPresentScalingCreateInfoEXT-scalingBehavior-parameter",
context: "scaling_behavior".into(), ])
vuids: &[ })?;
"VUID-VkSwapchainPresentScalingCreateInfoEXT-scalingBehavior-parameter",
],
..ValidationError::from_requirement(err)
})?;
// VUID-VkSwapchainPresentScalingCreateInfoEXT-scalingBehavior-07767 // VUID-VkSwapchainPresentScalingCreateInfoEXT-scalingBehavior-07767
// Ensured by the use of an enum. // Ensured by the use of an enum.
@ -1958,16 +1945,13 @@ impl SwapchainCreateInfo {
} }
for (axis_index, present_gravity) in present_gravity.into_iter().enumerate() { for (axis_index, present_gravity) in present_gravity.into_iter().enumerate() {
present_gravity present_gravity.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context(format!("present_gravity[{}]", axis_index))
.map_err(|err| ValidationError { .set_vuids(&[
context: format!("present_gravity[{}]", axis_index).into(),
vuids: &[
"VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityX-parameter", "VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityX-parameter",
"VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityY-parameter", "VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityY-parameter",
], ])
..ValidationError::from_requirement(err) })?;
})?;
} }
// VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityX-07765 // VUID-VkSwapchainPresentScalingCreateInfoEXT-presentGravityX-07765
@ -1993,12 +1977,10 @@ impl SwapchainCreateInfo {
full_screen_exclusive full_screen_exclusive
.validate_device(device) .validate_device(device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "full_screen_exclusive".into(), err.add_context("full_screen_exclusive").set_vuids(&[
vuids: &[
"VUID-VkSurfaceFullScreenExclusiveInfoEXT-fullScreenExclusive-parameter", "VUID-VkSurfaceFullScreenExclusiveInfoEXT-fullScreenExclusive-parameter",
], ])
..ValidationError::from_requirement(err)
})?; })?;
} }

View File

@ -1882,10 +1882,9 @@ impl SurfaceInfo {
present_mode present_mode
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "present_mode".into(), err.add_context("present_mode")
vuids: &["VUID-VkSurfacePresentModeEXT-presentMode-parameter"], .set_vuids(&["VUID-VkSurfacePresentModeEXT-presentMode-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
} }

View File

@ -326,13 +326,10 @@ impl EventCreateInfo {
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> { pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
let &Self { flags, _ne: _ } = self; let &Self { flags, _ne: _ } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkEventCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkEventCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
Ok(()) Ok(())
} }

View File

@ -574,13 +574,10 @@ impl Fence {
})); }));
} }
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkFenceGetFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkFenceGetFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -728,13 +725,10 @@ impl Fence {
})); }));
} }
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkFenceGetWin32HandleInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkFenceGetWin32HandleInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -1151,13 +1145,10 @@ impl FenceCreateInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkFenceCreateInfo-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkFenceCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
if !export_handle_types.is_empty() { if !export_handle_types.is_empty() {
if !(device.api_version() >= Version::V1_1 if !(device.api_version() >= Version::V1_1
@ -1174,13 +1165,10 @@ impl FenceCreateInfo {
})); }));
} }
export_handle_types export_handle_types.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("export_handle_types")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkExportFenceCreateInfo-handleTypes-parameter"])
context: "export_handle_types".into(), })?;
vuids: &["VUID-VkExportFenceCreateInfo-handleTypes-parameter"],
..ValidationError::from_requirement(err)
})?;
for handle_type in export_handle_types.into_iter() { for handle_type in export_handle_types.into_iter() {
let external_fence_properties = unsafe { let external_fence_properties = unsafe {
@ -1344,21 +1332,15 @@ impl ImportFenceFdInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportFenceFdInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImportFenceFdInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportFenceFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportFenceFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -1435,21 +1417,15 @@ impl ImportFenceWin32HandleInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportFenceWin32HandleInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImportFenceWin32HandleInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportFenceWin32HandleInfoKHR-handleType-01457"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -1513,10 +1489,9 @@ impl ExternalFenceInfo {
handle_type handle_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "handle_type".into(), err.add_context("handle_type")
vuids: &["VUID-VkPhysicalDeviceExternalFenceInfo-handleType-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceExternalFenceInfo-handleType-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
Ok(()) Ok(())

View File

@ -335,20 +335,13 @@ where
) { ) {
Ok(_) => (), Ok(_) => (),
Err(AccessCheckError::Unknown) => { Err(AccessCheckError::Unknown) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(
problem: AccessError::SwapchainImageNotAcquired AccessError::SwapchainImageNotAcquired,
.to_string() ))
.into(),
..Default::default()
})
.into()); .into());
} }
Err(AccessCheckError::Denied(err)) => { Err(AccessCheckError::Denied(err)) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(err)).into());
problem: err.to_string().into(),
..Default::default()
})
.into());
} }
} }
} }

View File

@ -163,20 +163,13 @@ where
) { ) {
Ok(_) => (), Ok(_) => (),
Err(AccessCheckError::Unknown) => { Err(AccessCheckError::Unknown) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(
problem: AccessError::SwapchainImageNotAcquired AccessError::SwapchainImageNotAcquired,
.to_string() ))
.into(),
..Default::default()
})
.into()); .into());
} }
Err(AccessCheckError::Denied(err)) => { Err(AccessCheckError::Denied(err)) => {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError::from_error(err)).into());
problem: err.to_string().into(),
..Default::default()
})
.into());
} }
} }
} }

View File

@ -104,7 +104,7 @@ pub(crate) enum CurrentAccess {
pub enum HostAccessError { pub enum HostAccessError {
AccessConflict(AccessConflict), AccessConflict(AccessConflict),
Invalidate(VulkanError), Invalidate(VulkanError),
ValidationError(ValidationError), ValidationError(Box<ValidationError>),
} }
impl Error for HostAccessError { impl Error for HostAccessError {

View File

@ -1774,13 +1774,10 @@ impl DependencyInfo {
_ne: _, _ne: _,
} = self; } = self;
dependency_flags dependency_flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dependency_flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkDependencyInfo-dependencyFlags-parameter"])
context: "dependency_flags".into(), })?;
vuids: &["VUID-VkDependencyInfo-dependencyFlags-parameter"],
..ValidationError::from_requirement(err)
})?;
for (barrier_index, memory_barrier) in memory_barriers.iter().enumerate() { for (barrier_index, memory_barrier) in memory_barriers.iter().enumerate() {
memory_barrier memory_barrier
@ -1911,37 +1908,25 @@ impl MemoryBarrier {
_ne: _, _ne: _,
} = self; } = self;
src_stages src_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkMemoryBarrier2-srcStageMask-parameter"])
context: "src_stages".into(), })?;
vuids: &["VUID-VkMemoryBarrier2-srcStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_stages dst_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkMemoryBarrier2-dstStageMask-parameter"])
context: "dst_stages".into(), })?;
vuids: &["VUID-VkMemoryBarrier2-dstStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
src_access src_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkMemoryBarrier2-srcAccessMask-parameter"])
context: "src_access".into(), })?;
vuids: &["VUID-VkMemoryBarrier2-srcAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_access dst_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkMemoryBarrier2-dstAccessMask-parameter"])
context: "dst_access".into(), })?;
vuids: &["VUID-VkMemoryBarrier2-dstAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 { if !device.enabled_features().synchronization2 {
if src_stages.contains_flags2() { if src_stages.contains_flags2() {
@ -2439,37 +2424,25 @@ impl BufferMemoryBarrier {
_ne, _ne,
} = self; } = self;
src_stages src_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferMemoryBarrier2-srcStageMask-parameter"])
context: "src_stages".into(), })?;
vuids: &["VUID-VkBufferMemoryBarrier2-srcStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_stages dst_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferMemoryBarrier2-dstStageMask-parameter"])
context: "dst_stages".into(), })?;
vuids: &["VUID-VkBufferMemoryBarrier2-dstStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
src_access src_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferMemoryBarrier2-srcAccessMask-parameter"])
context: "src_access".into(), })?;
vuids: &["VUID-VkBufferMemoryBarrier2-srcAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_access dst_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkBufferMemoryBarrier2-dstAccessMask-parameter"])
context: "dst_access".into(), })?;
vuids: &["VUID-VkBufferMemoryBarrier2-dstAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 { if !device.enabled_features().synchronization2 {
if src_stages.contains_flags2() { if src_stages.contains_flags2() {
@ -3124,37 +3097,25 @@ impl ImageMemoryBarrier {
_ne, _ne,
} = self; } = self;
src_stages src_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageMemoryBarrier2-srcStageMask-parameter"])
context: "src_stages".into(), })?;
vuids: &["VUID-VkImageMemoryBarrier2-srcStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_stages dst_stages.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_stages")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageMemoryBarrier2-dstStageMask-parameter"])
context: "dst_stages".into(), })?;
vuids: &["VUID-VkImageMemoryBarrier2-dstStageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
src_access src_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("src_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageMemoryBarrier2-srcAccessMask-parameter"])
context: "src_access".into(), })?;
vuids: &["VUID-VkImageMemoryBarrier2-srcAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
dst_access dst_access.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("dst_access")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImageMemoryBarrier2-dstAccessMask-parameter"])
context: "dst_access".into(), })?;
vuids: &["VUID-VkImageMemoryBarrier2-dstAccessMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 { if !device.enabled_features().synchronization2 {
if src_stages.contains_flags2() { if src_stages.contains_flags2() {

View File

@ -196,13 +196,10 @@ impl Semaphore {
})); }));
} }
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSemaphoreGetFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkSemaphoreGetFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -367,13 +364,10 @@ impl Semaphore {
})); }));
} }
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkSemaphoreGetWin32HandleInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -543,13 +537,10 @@ impl Semaphore {
})); }));
} }
handle_type handle_type.validate_device(&self.device).map_err(|err| {
.validate_device(&self.device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkSemaphoreGetZirconHandleInfoFUCHSIA-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!(handle_type, ExternalSemaphoreHandleType::ZirconEvent) { if !matches!(handle_type, ExternalSemaphoreHandleType::ZirconEvent) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1183,13 +1174,10 @@ impl SemaphoreCreateInfo {
})); }));
} }
export_handle_types export_handle_types.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("export_handle_types")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkExportSemaphoreCreateInfo-handleTypes-parameter"])
context: "export_handle_types".into(), })?;
vuids: &["VUID-VkExportSemaphoreCreateInfo-handleTypes-parameter"],
..ValidationError::from_requirement(err)
})?;
for handle_type in export_handle_types.into_iter() { for handle_type in export_handle_types.into_iter() {
let external_semaphore_properties = unsafe { let external_semaphore_properties = unsafe {
@ -1363,21 +1351,15 @@ impl ImportSemaphoreFdInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreFdInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImportSemaphoreFdInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreFdInfoKHR-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportSemaphoreFdInfoKHR-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -1456,21 +1438,15 @@ impl ImportSemaphoreWin32HandleInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreWin32HandleInfoKHR-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImportSemaphoreWin32HandleInfoKHR-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportSemaphoreWin32HandleInfoKHR-handleType-01140"],
..ValidationError::from_requirement(err)
})?;
if !matches!( if !matches!(
handle_type, handle_type,
@ -1551,21 +1527,15 @@ impl ImportSemaphoreZirconHandleInfo {
_ne: _, _ne: _,
} = self; } = self;
flags flags.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("flags")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-flags-parameter"])
context: "flags".into(), })?;
vuids: &["VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
handle_type handle_type.validate_device(device).map_err(|err| {
.validate_device(device) err.add_context("handle_type")
.map_err(|err| ValidationError { .set_vuids(&["VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-handleType-parameter"])
context: "handle_type".into(), })?;
vuids: &["VUID-VkImportSemaphoreZirconHandleInfoFUCHSIA-handleType-parameter"],
..ValidationError::from_requirement(err)
})?;
if !matches!(handle_type, ExternalSemaphoreHandleType::ZirconEvent) { if !matches!(handle_type, ExternalSemaphoreHandleType::ZirconEvent) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
@ -1626,10 +1596,9 @@ impl ExternalSemaphoreInfo {
handle_type handle_type
.validate_physical_device(physical_device) .validate_physical_device(physical_device)
.map_err(|err| ValidationError { .map_err(|err| {
context: "handle_type".into(), err.add_context("handle_type")
vuids: &["VUID-VkPhysicalDeviceExternalSemaphoreInfo-handleType-parameter"], .set_vuids(&["VUID-VkPhysicalDeviceExternalSemaphoreInfo-handleType-parameter"])
..ValidationError::from_requirement(err)
})?; })?;
Ok(()) Ok(())