Rename Features::superset_of to is_superset_of, add is_superset_of to extensions (#1625)

This commit is contained in:
Rua 2021-06-28 11:07:54 +02:00 committed by GitHub
parent 9b667128d7
commit aee11063d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 37 additions and 31 deletions

View File

@ -36,7 +36,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
// The Vulkan specs guarantee that a compliant implementation must provide at least one queue
// that supports compute operations.

View File

@ -63,7 +63,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -117,7 +117,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
Some(
p.queue_families()

View File

@ -64,7 +64,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -38,7 +38,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -51,7 +51,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -54,7 +54,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -33,7 +33,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -79,7 +79,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -76,7 +76,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -98,7 +98,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics())

View File

@ -75,9 +75,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| {
p.supported_extensions().intersection(&device_extensions) == device_extensions
})
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -65,10 +65,10 @@ fn main() {
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| {
p.supported_extensions().intersection(&device_extensions) == device_extensions
p.supported_extensions().is_superset_of(&device_extensions)
})
.filter(|&p| {
p.supported_features().superset_of(&features)
p.supported_features().is_superset_of(&features)
})
.filter(|&p| {
// This example renders to two layers of the framebuffer using the multiview

View File

@ -49,7 +49,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -49,7 +49,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -29,7 +29,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -76,7 +76,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -30,7 +30,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -29,7 +29,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_compute())

View File

@ -56,7 +56,7 @@ fn main() {
..DeviceExtensions::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -155,8 +155,8 @@ fn main() {
..Features::none()
};
let (physical_device, queue_family) = PhysicalDevice::enumerate(&instance)
.filter(|&p| p.supported_extensions().intersection(&device_extensions) == device_extensions)
.filter(|&p| p.supported_features().superset_of(&features))
.filter(|&p| p.supported_extensions().is_superset_of(&device_extensions))
.filter(|&p| p.supported_features().is_superset_of(&features))
.filter_map(|p| {
p.queue_families()
.find(|&q| q.supports_graphics() && surface.is_supported(q).unwrap_or(false))

View File

@ -82,7 +82,7 @@ fn main() {
// Some devices may not support the extensions or features that your application, or
// report properties and limits that are not sufficient for your application. These
// should be filtered out here.
p.supported_extensions().intersection(&device_extensions) == device_extensions
p.supported_extensions().is_superset_of(&device_extensions)
})
.filter_map(|p| {
// For each physical device, we try to find a suitable queue family that will execute

View File

@ -43,11 +43,11 @@ macro_rules! features {
/// .. Features::none()
/// };
///
/// if !physical_device.supported_features().superset_of(&minimal_features) {
/// if !physical_device.supported_features().is_superset_of(&minimal_features) {
/// panic!("The physical device is not good enough for this application.");
/// }
///
/// assert!(optimal_features.superset_of(&minimal_features));
/// assert!(optimal_features.is_superset_of(&minimal_features));
/// let features_to_request = optimal_features.intersection(physical_device.supported_features());
/// ```
///
@ -130,7 +130,7 @@ macro_rules! features {
///
/// That is, for each feature of the parameter that is true, the corresponding value
/// in self is true as well.
pub fn superset_of(&self, other: &Features) -> bool {
pub fn is_superset_of(&self, other: &Features) -> bool {
$((self.$member == true || other.$member == false))&&+
}

View File

@ -985,7 +985,7 @@ mod tests {
let features = Features::all();
// In the unlikely situation where the device supports everything, we ignore the test.
if physical.supported_features().superset_of(&features) {
if physical.supported_features().is_superset_of(&features) {
return;
}

View File

@ -50,6 +50,14 @@ macro_rules! extensions {
}
}
/// Returns true if `self` is a superset of the parameter.
///
/// That is, for each extension of the parameter that is true, the corresponding value
/// in self is true as well.
pub fn is_superset_of(&self, other: &$sname) -> bool {
$((self.$member == true || other.$member == false))&&+
}
/// Returns the union of this list and another list.
#[inline]
pub const fn union(&self, other: &$sname) -> $sname {

View File

@ -57,7 +57,7 @@ macro_rules! gfx_dev_and_queue {
};
// If the physical device doesn't support the requested features, just return.
if !physical.supported_features().superset_of(&features) {
if !physical.supported_features().is_superset_of(&features) {
return;
}