Skip to content

Commit 3c13b5e

Browse files
fix(metal): unconditionally enable CLIP_DISTANCES
1 parent cc1a10f commit 3c13b5e

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Bottom level categories:
4242

4343
## Unreleased
4444

45+
### Added/New Features
46+
47+
#### Metal
48+
49+
- Unconditionally enable `Features::CLIP_DISTANCES`. By @ErichDonGubler in [#9270](https://github.com/gfx-rs/wgpu/pull/9270).
50+
4551
### Changes
4652

4753
#### General

naga/src/back/msl/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ pub fn supported_capabilities() -> crate::valid::Capabilities {
841841
// No BUFFER_BINDING_ARRAY
842842
| Caps::STORAGE_TEXTURE_BINDING_ARRAY
843843
| Caps::STORAGE_BUFFER_BINDING_ARRAY
844-
| Caps::CLIP_DISTANCES // CLIP_DISTANCES isn't supported by metal backend? But is supported by MSL writer
844+
| Caps::CLIP_DISTANCES
845845
// No CULL_DISTANCE
846846
| Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS
847847
| Caps::MULTIVIEW
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
capabilities = "CLIP_DISTANCES"
2-
targets = "SPIRV | GLSL | WGSL"
2+
targets = "SPIRV | GLSL | WGSL | METAL"
33

44
[glsl]
55
version.Desktop = 330
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// language: metal1.0
2+
#include <metal_stdlib>
3+
#include <simd/simd.h>
4+
5+
using metal::uint;
6+
7+
struct type_2 {
8+
float inner[1];
9+
};
10+
struct VertexOutput {
11+
metal::float4 position;
12+
type_2 clip_distances;
13+
char _pad2[12];
14+
};
15+
16+
struct main_Output {
17+
metal::float4 position [[position]];
18+
float clip_distances [[clip_distance]] [1];
19+
};
20+
vertex main_Output main_(
21+
) {
22+
VertexOutput out = {};
23+
out.clip_distances.inner[0] = 0.5;
24+
VertexOutput _e4 = out;
25+
const auto _tmp = _e4;
26+
return main_Output { _tmp.position, {_tmp.clip_distances.inner[0]} };
27+
}

wgpu-hal/src/metal/adapter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ impl super::CapabilitiesQuery {
10941094
self.timestamp_query_support
10951095
.contains(TimestampQuerySupport::INSIDE_WGPU_PASSES),
10961096
);
1097+
features.set(F::CLIP_DISTANCES, true);
10971098
features.set(
10981099
F::DUAL_SOURCE_BLENDING,
10991100
self.msl_version >= MTLLanguageVersion::Version1_2 && self.dual_source_blending,

0 commit comments

Comments
 (0)