mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-28 00:59:12 +01:00
Add Limits::or_worse_values_from (#8870)
This commit is contained in:
2 files changed
+26
-2
No files matched your search
@@ -45,6 +45,7 @@ Bottom level categories:
|
||||
|
||||
- Added support for cooperative load/store operations in shaders. Currently only WGSL on the input and SPIR-V, METAL, and WGSL on the output are supported. By @kvark in [#8251](https://github.com/gfx-rs/wgpu/issues/8251).
|
||||
- Added support for obtaining `AdapterInfo` from `Device`. By @sagudev in [#8807](https://github.com/gfx-rs/wgpu/pull/8807).
|
||||
- Added `Limits::or_worse_values_from`. By @atlv24 in [#8870](https://github.com/gfx-rs/wgpu/pull/8870).
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@@ -717,8 +717,7 @@ impl Limits {
|
||||
///
|
||||
/// This function is not for clamping requests for values beyond the
|
||||
/// supported limits. For that purpose the desired function would be
|
||||
/// `or_worse_values_from` (which doesn't exist, but could be added if
|
||||
/// needed).
|
||||
/// `or_worse_values_from`.
|
||||
#[must_use]
|
||||
pub fn or_better_values_from(mut self, other: &Self) -> Self {
|
||||
macro_rules! or_better_value_from {
|
||||
@@ -737,6 +736,30 @@ impl Limits {
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// For each limit in `other` that is worse than the value in `self`,
|
||||
/// replace the value in `self` with the value from `other`.
|
||||
///
|
||||
/// This function is for clamping requests for values beyond the
|
||||
/// supported limits.
|
||||
#[must_use]
|
||||
pub fn or_worse_values_from(mut self, other: &Self) -> Self {
|
||||
macro_rules! or_worse_value_from {
|
||||
($name:ident, $ordering:expr) => {
|
||||
match $ordering {
|
||||
// Limits that are maximum values (most of them)
|
||||
Ordering::Less => self.$name = self.$name.min(other.$name),
|
||||
// Limits that are minimum values
|
||||
Ordering::Greater => self.$name = self.$name.max(other.$name),
|
||||
Ordering::Equal => unreachable!(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
with_limits!(or_worse_value_from);
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the sets of additional limits on an adapter,
|
||||
|
||||
Reference in new issue
Block a user