diff --git a/CHANGELOG.md b/CHANGELOG.md index 7563f540a..5bb839df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -155,6 +155,7 @@ By @sagudev in [#10307](https://github.com/gfx-rs/wgpu/pull/10307). #### Metal +- Support `Features::SHADER_EARLY_DEPTH_TEST` on Metal. Naga's MSL backend now emits `[[early_fragment_tests]]` for `@early_depth_test(force)`, `depth(greater)`/`depth(less)` for `@early_depth_test(greater_equal/less_equal)`, and discards the depth output for `@early_depth_test(unchanged)` and `@early_depth_test(force)`. By @DouglasDwyer in [#10625](https://github.com/gfx-rs/wgpu/pull/10625). - Fix Naga's Metal backend crashing when a storage texture was used as a function argument. By @ErichDonGubler in [#9867](https://github.com/gfx-rs/wgpu/pull/9867). - Fix `max_task_workgroup_count` being misreported on pre-Apple7 devices. By @inner-daemons in [#10065](https://github.com/gfx-rs/wgpu/pull/10065). - The value of the `max_binding_array_sampler_elements_per_shader_stage` on Apple7, Apple8, and Mac2 hardware is reduced from 1024 to 996, to match the latest Metal documentation. By @andyleiserson in [#10649](https://github.com/gfx-rs/wgpu/pull/10649). diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index a704036fb..d1a80c9a7 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -182,6 +182,9 @@ enum ResolvedBinding { }, Resource(BindTarget), Payload, + /// A fragment shader's depth output, qualified by how it may differ from + /// the depth calculated by the rasterizer. + ConservativeDepth(crate::ConservativeDepth), } #[derive(Copy, Clone)] @@ -714,6 +717,15 @@ impl ResolvedBinding { write!(out, "{name}")?; } Self::Attribute(index) => write!(out, "attribute({index})")?, + Self::ConservativeDepth(conservative) => { + use crate::ConservativeDepth as Cd; + let qualifier = match conservative { + Cd::GreaterEqual => "greater", + Cd::LessEqual => "less", + Cd::Unchanged => "any", + }; + write!(out, "depth({qualifier})")? + } Self::Color { location, blend_src, @@ -847,7 +859,7 @@ pub fn supported_capabilities() -> crate::valid::Capabilities { // No CULL_DISTANCE | Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS | Caps::MULTIVIEW - // No EARLY_DEPTH_TEST + | Caps::EARLY_DEPTH_TEST | Caps::MULTISAMPLED_SHADING | Caps::RAY_QUERY | Caps::DUAL_SOURCE_BLENDING diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 575fc6c8d..a64f934e0 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -630,6 +630,55 @@ impl crate::Scalar { } } +/// Returns `true` if `binding` is the depth that a fragment shader writes. +const fn is_frag_depth(binding: Option<&crate::Binding>) -> bool { + matches!( + binding, + Some(crate::Binding::BuiltIn(crate::BuiltIn::FragDepth)) + ) +} + +/// Returns `true` if the depth that a fragment shader writes is the only thing that +/// `entry_point` returns. +fn only_writes_frag_depth(module: &crate::ir::Module, entry_point: &crate::ir::EntryPoint) -> bool { + entry_point + .function + .result + .as_ref() + .is_some_and(|result| match module.types[result.ty].inner { + crate::TypeInner::Struct { ref members, .. } if result.binding.is_none() => members + .iter() + .all(|member| is_frag_depth(member.binding.as_ref())), + _ => is_frag_depth(result.binding.as_ref()), + }) +} + +/// Returns `true` if the depth that `entry_point` writes must be discarded. +/// +/// MSL has no way to specify that depth is unchanged, and it does not allow functions that +/// force early fragment tests to output depth. Discarding the depth has the same effect +/// as either of those, and keeps early depth tests enabled. +fn discards_frag_depth(entry_point: &crate::ir::EntryPoint) -> bool { + entry_point.stage == crate::ShaderStage::Fragment + && matches!( + entry_point.early_depth_test, + Some( + crate::EarlyDepthTest::Force + | crate::EarlyDepthTest::Allow { + conservative: crate::ConservativeDepth::Unchanged + } + ) + ) +} + +/// Returns `true` if `entry_point` has nothing to return once its depth is discarded. +fn only_writes_discarded_depth( + module: &crate::ir::Module, + entry_point: &crate::ir::EntryPoint, +) -> bool { + discards_frag_depth(entry_point) && only_writes_frag_depth(module, entry_point) +} + const fn separate(need_separator: bool) -> &'static str { if need_separator { "," @@ -3661,6 +3710,15 @@ impl Writer { result_struct: Option<&str>, context: &ExpressionContext, ) -> BackendResult { + let entry_point = match context.origin { + FunctionOrigin::EntryPoint(index) => Some(&context.module.entry_points[index as usize]), + FunctionOrigin::Handle(_) => None, + }; + if entry_point.is_some_and(|ep| only_writes_discarded_depth(context.module, ep)) { + writeln!(self.out, "{level}return;")?; + return Ok(()); + } + match result_struct { Some(struct_name) => { let mut has_point_size = false; @@ -3685,6 +3743,12 @@ impl Writer { } } + if entry_point.is_some_and(discards_frag_depth) + && is_frag_depth(member.binding.as_ref()) + { + continue; + } + let comma = if is_first { "" } else { "," }; is_first = false; let name = &self.names[&NameKey::StructMember(result_ty, index as u32)]; @@ -7523,7 +7587,10 @@ template let stage_out_name = self.namer.call(&format!("{fun_name}Output")); let result_member_name = self.namer.call("member"); let result_type_name = match fun.result { - Some(ref result) if ep.stage != crate::ShaderStage::Task => { + Some(ref result) + if ep.stage != crate::ShaderStage::Task + && !only_writes_discarded_depth(module, ep) => + { let mut result_members = Vec::new(); if let crate::TypeInner::Struct { ref members, .. } = module.types[result.ty].inner @@ -7564,6 +7631,10 @@ template } } + if discards_frag_depth(ep) && is_frag_depth(Some(binding)) { + continue; + } + let array_len = match module.types[ty].inner { crate::TypeInner::Array { size: crate::ArraySize::Constant(size), @@ -7571,7 +7642,16 @@ template } => Some(size), _ => None, }; - let resolved = options.resolve_local_binding(binding, out_mode)?; + let resolved = match ( + options.resolve_local_binding(binding, out_mode)?, + ep.early_depth_test, + ) { + ( + super::ResolvedBinding::BuiltIn(crate::BuiltIn::FragDepth), + Some(crate::EarlyDepthTest::Allow { conservative }), + ) => super::ResolvedBinding::ConservativeDepth(conservative), + (resolved, _) => resolved, + }; write!(self.out, "{}{} {}", back::INDENT, ty_name, name)?; resolved.try_fmt(&mut self.out)?; if let Some(array_len) = array_len { @@ -7658,6 +7738,17 @@ template )?; } + if ep.stage == crate::ShaderStage::Fragment + && ep.early_depth_test == Some(crate::EarlyDepthTest::Force) + { + if options.lang_version < (1, 2) { + return Err(Error::UnsupportedAttribute( + "early_fragment_tests".to_string(), + )); + } + write!(self.out, "[[early_fragment_tests]] ")?; + } + // Write the entry point function's name, and begin its argument list. if let Some(em_str) = em_str { write!(self.out, "{em_str} ")?; diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-greater.toml b/naga/tests/in/wgsl/early-depth-test-conservative-greater.toml new file mode 100644 index 000000000..15b30d27a --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-greater.toml @@ -0,0 +1,2 @@ +capabilities = "EARLY_DEPTH_TEST" +targets = "METAL" diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-greater.wgsl b/naga/tests/in/wgsl/early-depth-test-conservative-greater.wgsl new file mode 100644 index 000000000..b1477df94 --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-greater.wgsl @@ -0,0 +1,5 @@ +@fragment +@early_depth_test(greater_equal) +fn main(@builtin(position) pos: vec4) -> @builtin(frag_depth) f32 { + return pos.z + 0.1; +} diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-struct.toml b/naga/tests/in/wgsl/early-depth-test-conservative-struct.toml new file mode 100644 index 000000000..15b30d27a --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-struct.toml @@ -0,0 +1,2 @@ +capabilities = "EARLY_DEPTH_TEST" +targets = "METAL" diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-struct.wgsl b/naga/tests/in/wgsl/early-depth-test-conservative-struct.wgsl new file mode 100644 index 000000000..6e18f0eea --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-struct.wgsl @@ -0,0 +1,32 @@ +struct Output { + @location(0) color: vec4, + @builtin(frag_depth) depth: f32, +} + +@fragment +@early_depth_test(less_equal) +fn agree_first(@builtin(position) pos: vec4) -> Output { + return Output(vec4(0.4, 0.3, 0.2, 0.1), pos.z - 0.1); +} + +@fragment +@early_depth_test(less_equal) +fn agree_second(@builtin(position) pos: vec4) -> Output { + return Output(vec4(0.1, 0.2, 0.3, 0.4), pos.z - 0.2); +} + +struct DisagreeingOutput { + @location(0) color: vec4, + @builtin(frag_depth) depth: f32, +} + +@fragment +@early_depth_test(greater_equal) +fn disagree_conservative(@builtin(position) pos: vec4) -> DisagreeingOutput { + return DisagreeingOutput(vec4(0.4, 0.3, 0.2, 0.1), pos.z + 0.1); +} + +@fragment +fn disagree_unrestricted(@builtin(position) pos: vec4) -> DisagreeingOutput { + return DisagreeingOutput(vec4(0.1, 0.2, 0.3, 0.4), pos.z * 2.0); +} diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.toml b/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.toml new file mode 100644 index 000000000..15b30d27a --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.toml @@ -0,0 +1,2 @@ +capabilities = "EARLY_DEPTH_TEST" +targets = "METAL" diff --git a/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.wgsl b/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.wgsl new file mode 100644 index 000000000..1799e2c87 --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-conservative-unchanged.wgsl @@ -0,0 +1,5 @@ +@fragment +@early_depth_test(unchanged) +fn main(@builtin(position) pos: vec4) -> @builtin(frag_depth) f32 { + return pos.z; +} diff --git a/naga/tests/in/wgsl/early-depth-test-conservative.toml b/naga/tests/in/wgsl/early-depth-test-conservative.toml index 56f14a551..e57237ae4 100644 --- a/naga/tests/in/wgsl/early-depth-test-conservative.toml +++ b/naga/tests/in/wgsl/early-depth-test-conservative.toml @@ -1,5 +1,5 @@ capabilities = "EARLY_DEPTH_TEST" -targets = "SPIRV | GLSL" +targets = "SPIRV | GLSL | METAL" [glsl] version.Desktop = 420 diff --git a/naga/tests/in/wgsl/early-depth-test-force-depth.toml b/naga/tests/in/wgsl/early-depth-test-force-depth.toml new file mode 100644 index 000000000..d71516b57 --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-force-depth.toml @@ -0,0 +1,5 @@ +capabilities = "EARLY_DEPTH_TEST" +targets = "METAL" + +[msl] +lang_version = [1, 2] diff --git a/naga/tests/in/wgsl/early-depth-test-force-depth.wgsl b/naga/tests/in/wgsl/early-depth-test-force-depth.wgsl new file mode 100644 index 000000000..1b13c8502 --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-force-depth.wgsl @@ -0,0 +1,16 @@ +struct ColorAndDepth { + @location(0) color: vec4, + @builtin(frag_depth) depth: f32, +} + +@fragment +@early_depth_test(force) +fn only_depth(@builtin(position) pos: vec4) -> @builtin(frag_depth) f32 { + return pos.z; +} + +@fragment +@early_depth_test(force) +fn color_and_depth(@builtin(position) pos: vec4) -> ColorAndDepth { + return ColorAndDepth(vec4(0.4, 0.3, 0.2, 0.1), pos.z); +} diff --git a/naga/tests/in/wgsl/early-depth-test-force.toml b/naga/tests/in/wgsl/early-depth-test-force.toml index 119e9011a..8b4b4f2e4 100644 --- a/naga/tests/in/wgsl/early-depth-test-force.toml +++ b/naga/tests/in/wgsl/early-depth-test-force.toml @@ -1,2 +1,5 @@ capabilities = "EARLY_DEPTH_TEST" -targets = "SPIRV | GLSL" +targets = "SPIRV | GLSL | METAL" + +[msl] +lang_version = [1, 2] diff --git a/naga/tests/in/wgsl/early-depth-test-unchanged-struct.toml b/naga/tests/in/wgsl/early-depth-test-unchanged-struct.toml new file mode 100644 index 000000000..15b30d27a --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-unchanged-struct.toml @@ -0,0 +1,2 @@ +capabilities = "EARLY_DEPTH_TEST" +targets = "METAL" diff --git a/naga/tests/in/wgsl/early-depth-test-unchanged-struct.wgsl b/naga/tests/in/wgsl/early-depth-test-unchanged-struct.wgsl new file mode 100644 index 000000000..d21592231 --- /dev/null +++ b/naga/tests/in/wgsl/early-depth-test-unchanged-struct.wgsl @@ -0,0 +1,25 @@ +struct ColorAndDepth { + @location(0) color: vec4, + @builtin(frag_depth) depth: f32, +} + +struct OnlyDepth { + @builtin(frag_depth) depth: f32, +} + +@fragment +@early_depth_test(unchanged) +fn color_and_depth(@builtin(position) pos: vec4) -> ColorAndDepth { + return ColorAndDepth(vec4(0.4, 0.3, 0.2, 0.1), pos.z); +} + +@fragment +@early_depth_test(unchanged) +fn only_depth(@builtin(position) pos: vec4) -> OnlyDepth { + return OnlyDepth(pos.z); +} + +@fragment +fn unrestricted(@builtin(position) pos: vec4) -> ColorAndDepth { + return ColorAndDepth(vec4(0.1, 0.2, 0.3, 0.4), pos.z * 2.0); +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-conservative-greater.metal b/naga/tests/out/msl/wgsl-early-depth-test-conservative-greater.metal new file mode 100644 index 000000000..7b542923c --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-conservative-greater.metal @@ -0,0 +1,17 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + + +struct main_Input { +}; +struct main_Output { + float member [[depth(greater)]]; +}; +fragment main_Output main_( + metal::float4 pos [[position]] +) { + return main_Output { pos.z + 0.1 }; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-conservative-struct.metal b/naga/tests/out/msl/wgsl-early-depth-test-conservative-struct.metal new file mode 100644 index 000000000..64b19098e --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-conservative-struct.metal @@ -0,0 +1,71 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct Output { + metal::float4 color; + float depth; + char _pad2[12]; +}; +struct DisagreeingOutput { + metal::float4 color; + float depth; + char _pad2[12]; +}; + +struct agree_firstInput { +}; +struct agree_firstOutput { + metal::float4 color [[color(0)]]; + float depth [[depth(less)]]; +}; +fragment agree_firstOutput agree_first( + metal::float4 pos [[position]] +) { + const auto _tmp = Output {metal::float4(0.4, 0.3, 0.2, 0.1), pos.z - 0.1}; + return agree_firstOutput { _tmp.color, _tmp.depth }; +} + + +struct agree_secondInput { +}; +struct agree_secondOutput { + metal::float4 color [[color(0)]]; + float depth [[depth(less)]]; +}; +fragment agree_secondOutput agree_second( + metal::float4 pos_1 [[position]] +) { + const auto _tmp_1 = Output {metal::float4(0.1, 0.2, 0.3, 0.4), pos_1.z - 0.2}; + return agree_secondOutput { _tmp_1.color, _tmp_1.depth }; +} + + +struct disagree_conservativeInput { +}; +struct disagree_conservativeOutput { + metal::float4 color [[color(0)]]; + float depth [[depth(greater)]]; +}; +fragment disagree_conservativeOutput disagree_conservative( + metal::float4 pos_2 [[position]] +) { + const auto _tmp_2 = DisagreeingOutput {metal::float4(0.4, 0.3, 0.2, 0.1), pos_2.z + 0.1}; + return disagree_conservativeOutput { _tmp_2.color, _tmp_2.depth }; +} + + +struct disagree_unrestrictedInput { +}; +struct disagree_unrestrictedOutput { + metal::float4 color [[color(0)]]; + float depth [[depth(any)]]; +}; +fragment disagree_unrestrictedOutput disagree_unrestricted( + metal::float4 pos_3 [[position]] +) { + const auto _tmp_3 = DisagreeingOutput {metal::float4(0.1, 0.2, 0.3, 0.4), pos_3.z * 2.0}; + return disagree_unrestrictedOutput { _tmp_3.color, _tmp_3.depth }; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-conservative-unchanged.metal b/naga/tests/out/msl/wgsl-early-depth-test-conservative-unchanged.metal new file mode 100644 index 000000000..83c7f548a --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-conservative-unchanged.metal @@ -0,0 +1,14 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + + +struct main_Input { +}; +fragment void main_( + metal::float4 pos [[position]] +) { + return; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-conservative.metal b/naga/tests/out/msl/wgsl-early-depth-test-conservative.metal new file mode 100644 index 000000000..4c3d84df9 --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-conservative.metal @@ -0,0 +1,17 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + + +struct main_Input { +}; +struct main_Output { + float member [[depth(less)]]; +}; +fragment main_Output main_( + metal::float4 pos [[position]] +) { + return main_Output { pos.z - 0.1 }; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-force-depth.metal b/naga/tests/out/msl/wgsl-early-depth-test-force-depth.metal new file mode 100644 index 000000000..90715e1b9 --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-force-depth.metal @@ -0,0 +1,32 @@ +// language: metal1.2 +#include +#include + +using metal::uint; + +struct ColorAndDepth { + metal::float4 color; + float depth; + char _pad2[12]; +}; + +struct only_depthInput { +}; +[[early_fragment_tests]] fragment void only_depth( + metal::float4 pos [[position]] +) { + return; +} + + +struct color_and_depthInput { +}; +struct color_and_depthOutput { + metal::float4 color [[color(0)]]; +}; +[[early_fragment_tests]] fragment color_and_depthOutput color_and_depth( + metal::float4 pos_1 [[position]] +) { + const auto _tmp = ColorAndDepth {metal::float4(0.4, 0.3, 0.2, 0.1), pos_1.z}; + return color_and_depthOutput { _tmp.color }; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-force.metal b/naga/tests/out/msl/wgsl-early-depth-test-force.metal new file mode 100644 index 000000000..ca0bc750c --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-force.metal @@ -0,0 +1,14 @@ +// language: metal1.2 +#include +#include + +using metal::uint; + + +struct main_Output { + metal::float4 member [[color(0)]]; +}; +[[early_fragment_tests]] fragment main_Output main_( +) { + return main_Output { metal::float4(0.4, 0.3, 0.2, 0.1) }; +} diff --git a/naga/tests/out/msl/wgsl-early-depth-test-unchanged-struct.metal b/naga/tests/out/msl/wgsl-early-depth-test-unchanged-struct.metal new file mode 100644 index 000000000..58d917f36 --- /dev/null +++ b/naga/tests/out/msl/wgsl-early-depth-test-unchanged-struct.metal @@ -0,0 +1,49 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct ColorAndDepth { + metal::float4 color; + float depth; + char _pad2[12]; +}; +struct OnlyDepth { + float depth; +}; + +struct color_and_depthInput { +}; +struct color_and_depthOutput { + metal::float4 color [[color(0)]]; +}; +fragment color_and_depthOutput color_and_depth( + metal::float4 pos [[position]] +) { + const auto _tmp = ColorAndDepth {metal::float4(0.4, 0.3, 0.2, 0.1), pos.z}; + return color_and_depthOutput { _tmp.color }; +} + + +struct only_depthInput { +}; +fragment void only_depth( + metal::float4 pos_1 [[position]] +) { + return; +} + + +struct unrestrictedInput { +}; +struct unrestrictedOutput { + metal::float4 color [[color(0)]]; + float depth [[depth(any)]]; +}; +fragment unrestrictedOutput unrestricted( + metal::float4 pos_2 [[position]] +) { + const auto _tmp_1 = ColorAndDepth {metal::float4(0.1, 0.2, 0.3, 0.4), pos_2.z * 2.0}; + return unrestrictedOutput { _tmp_1.color, _tmp_1.depth }; +} diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 6fbd4af8b..50eec24c9 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -1286,6 +1286,10 @@ impl super::CapabilitiesQuery { F::DUAL_SOURCE_BLENDING, self.msl_version >= MTLLanguageVersion::Version1_2 && self.dual_source_blending, ); + features.set( + F::SHADER_EARLY_DEPTH_TEST, + MTLLanguageVersion::Version1_2 <= self.msl_version, + ); features.set(F::TEXTURE_COMPRESSION_ASTC, self.format_astc); features.set(F::TEXTURE_COMPRESSION_ASTC_HDR, self.format_astc_hdr); features.set(F::TEXTURE_COMPRESSION_ASTC_SLICED_3D, self.format_astc_3d); diff --git a/wgpu-types/src/features.rs b/wgpu-types/src/features.rs index f98959f16..61ac26917 100644 --- a/wgpu-types/src/features.rs +++ b/wgpu-types/src/features.rs @@ -807,6 +807,8 @@ features! { /// /// - `layout(early_fragment_tests) in;` (GLSL) /// + /// - `[[early_fragment_tests]]` (MSL 1.2+) + /// /// 2. Provide a conservative depth specifier that allows an additional early /// depth test under certain conditions: /// @@ -814,10 +816,13 @@ features! { /// /// - `layout(depth_) out float gl_FragDepth;` (GLSL) /// + /// - `[[depth(greater/less)]]` (MSL, any version) + /// /// See [`EarlyDepthTest`] for more details. /// /// Supported platforms: /// - Vulkan + /// - Metal (with MSL 1.2+) /// - GLES 3.1+ /// /// This is a native only feature.