Skip to content

Commit ddec160

Browse files
SYNC POINT: resolve merge conflicts
2 parents aac68c8 + a44dbd8 commit ddec160

6 files changed

Lines changed: 46 additions & 3 deletions

File tree

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 [#????](https://github.com/gfx-rs/wgpu/pull/????).
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

naga/src/back/msl/writer.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7190,10 +7190,19 @@ template <typename A>
71907190
};
71917191
let resolved = options.resolve_local_binding(binding, out_mode)?;
71927192
write!(self.out, "{}{} {}", back::INDENT, ty_name, name)?;
7193+
let binding_attr_comes_before_array = matches!(
7194+
resolved,
7195+
super::ResolvedBinding::BuiltIn(crate::BuiltIn::ClipDistances)
7196+
);
7197+
if binding_attr_comes_before_array {
7198+
resolved.try_fmt(&mut self.out)?;
7199+
}
71937200
if let Some(array_len) = array_len {
71947201
write!(self.out, " [{array_len}]")?;
71957202
}
7196-
resolved.try_fmt(&mut self.out)?;
7203+
if !binding_attr_comes_before_array {
7204+
resolved.try_fmt(&mut self.out)?;
7205+
}
71977206
writeln!(self.out, ";")?;
71987207
}
71997208

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)