Skip to content

Commit

Permalink
metal: Set preserveInvariance for shader options
Browse files Browse the repository at this point in the history
This enables invariance for metal, for stable vertex positions, which
are useful for depth prepass and similiar things.
  • Loading branch information
scoopr authored and kvark committed Jan 12, 2022
1 parent 16edd91 commit 99b3a6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,11 @@ impl super::PrivateCapabilities {
supports_depth_clip_control: device
.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1)
|| os_is_mac,
supports_preserve_invariance: if os_is_mac {
Self::version_at_least(major, minor, 11, 0)
} else {
Self::version_at_least(major, minor, 13, 0)
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/src/metal/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ impl super::Device {
let options = mtl::CompileOptions::new();
options.set_language_version(self.shared.private_caps.msl_version);

if self.shared.private_caps.supports_preserve_invariance {
options.set_preserve_invariance(true);
}

let library = self
.shared
.device
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct PrivateCapabilities {
supports_arrays_of_textures_write: bool,
supports_mutability: bool,
supports_depth_clip_control: bool,
supports_preserve_invariance: bool,
}

#[derive(Clone, Debug)]
Expand Down

0 comments on commit 99b3a6e

Please sign in to comment.