mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 16:31:11 +01:00
* Implements #9176 : `[[max_total_threads_per_threadgroup]]` MSL attribute * introduced `DownlevelFlags::MSL2_1`
This commit is contained in:
22 files changed
+43
-21
No files matched your search
@@ -7275,6 +7275,15 @@ template <typename A>
|
||||
}
|
||||
}
|
||||
|
||||
// https://web.archive.org/web/20181029003926/https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
|
||||
if ep.stage == crate::ShaderStage::Compute && options.lang_version >= (2, 1) {
|
||||
let total_threads =
|
||||
ep.workgroup_size[0] * ep.workgroup_size[1] * ep.workgroup_size[2];
|
||||
write!(
|
||||
self.out,
|
||||
"[[max_total_threads_per_threadgroup({total_threads})]] "
|
||||
)?;
|
||||
}
|
||||
// Write the entry point function's name, and begin its argument list.
|
||||
writeln!(self.out, "{em_str} {result_type_name} {fun_name}(")?;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ void function(
|
||||
|
||||
struct main_Input {
|
||||
};
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
uint param [[simdgroups_per_threadgroup]]
|
||||
, uint param_1 [[simdgroup_index_in_threadgroup]]
|
||||
, uint param_2 [[threads_per_simdgroup]]
|
||||
|
||||
@@ -36,7 +36,7 @@ struct RayIntersection {
|
||||
metal::float4x3 world_to_object;
|
||||
};
|
||||
|
||||
kernel void main_candidate(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_candidate(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
) {
|
||||
_RayQuery rq_1 = {};
|
||||
|
||||
@@ -14,7 +14,7 @@ struct Struct {
|
||||
|
||||
struct cs_mainInput {
|
||||
};
|
||||
kernel void cs_main(
|
||||
[[max_total_threads_per_threadgroup(2)]] kernel void cs_main(
|
||||
metal::uint3 id [[thread_position_in_threadgroup]]
|
||||
, device metal::atomic_float& storage_atomic_scalar [[user(fake0)]]
|
||||
, device type_2& storage_atomic_arr [[user(fake0)]]
|
||||
|
||||
@@ -14,7 +14,7 @@ struct Struct {
|
||||
|
||||
struct cs_mainInput {
|
||||
};
|
||||
kernel void cs_main(
|
||||
[[max_total_threads_per_threadgroup(2)]] kernel void cs_main(
|
||||
metal::uint3 id [[thread_position_in_threadgroup]]
|
||||
, device metal::atomic_ulong& storage_atomic_scalar [[user(fake0)]]
|
||||
, device type_2& storage_atomic_arr [[user(fake0)]]
|
||||
|
||||
@@ -7,7 +7,7 @@ using metal::uint;
|
||||
|
||||
struct cs_mainInput {
|
||||
};
|
||||
kernel void cs_main(
|
||||
[[max_total_threads_per_threadgroup(2)]] kernel void cs_main(
|
||||
metal::uint3 id [[thread_position_in_threadgroup]]
|
||||
, metal::texture2d<ulong, metal::access::read_write> image [[user(fake0)]]
|
||||
) {
|
||||
|
||||
@@ -7,7 +7,7 @@ using metal::uint;
|
||||
|
||||
struct cs_mainInput {
|
||||
};
|
||||
kernel void cs_main(
|
||||
[[max_total_threads_per_threadgroup(2)]] kernel void cs_main(
|
||||
metal::uint3 id [[thread_position_in_threadgroup]]
|
||||
, metal::texture2d<uint, metal::access::read_write> image_u [[user(fake0)]]
|
||||
, metal::texture2d<int, metal::access::read_write> image_s [[user(fake0)]]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using metal::uint;
|
||||
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
) {
|
||||
int i = 0;
|
||||
metal::int2 i2_ = metal::int2(0);
|
||||
|
||||
@@ -22,7 +22,7 @@ metal::simdgroup_float8x8 NagaCooperativeMultiplyAdd(const thread metal::simdgro
|
||||
}
|
||||
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(64)]] kernel void main_(
|
||||
device type_3& ext [[user(fake0)]]
|
||||
, constant _mslBufferSizes& _buffer_sizes [[user(fake0)]]
|
||||
) {
|
||||
|
||||
@@ -26,7 +26,7 @@ uint test_packed_integer_dot_product(
|
||||
return c_8_;
|
||||
}
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
) {
|
||||
uint _e0 = test_packed_integer_dot_product();
|
||||
return;
|
||||
|
||||
@@ -220,7 +220,7 @@ ulong uint64_function(
|
||||
return _e144;
|
||||
}
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
constant UniformCompatible& input_uniform [[user(fake0)]]
|
||||
, device UniformCompatible const& input_storage [[user(fake0)]]
|
||||
, device StorageCompatible const& input_arrays [[user(fake0)]]
|
||||
|
||||
@@ -69,7 +69,7 @@ fragment fragment_Output fragment_(
|
||||
|
||||
struct computeInput {
|
||||
};
|
||||
kernel void compute(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void compute(
|
||||
metal::uint3 global_id [[thread_position_in_grid]]
|
||||
, metal::uint3 local_id [[thread_position_in_threadgroup]]
|
||||
, uint local_index [[thread_index_in_threadgroup]]
|
||||
|
||||
@@ -14,7 +14,7 @@ struct Data {
|
||||
type_1 values;
|
||||
};
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
coherent device Data& coherent_buf [[user(fake0)]]
|
||||
, device Data const& plain_buf [[user(fake0)]]
|
||||
, constant _mslBufferSizes& _buffer_sizes [[user(fake0)]]
|
||||
|
||||
@@ -23,7 +23,7 @@ struct RayDesc {
|
||||
};
|
||||
constant float o = 2.0;
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
) {
|
||||
_RayQuery rq = {};
|
||||
|
||||
@@ -76,7 +76,7 @@ metal::float3 get_torus_normal(
|
||||
return metal::normalize(world_point - world_point_on_guiding_line);
|
||||
}
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
, device Output& output [[user(fake0)]]
|
||||
) {
|
||||
@@ -90,7 +90,7 @@ kernel void main_(
|
||||
}
|
||||
|
||||
|
||||
kernel void main_candidate(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_candidate(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
) {
|
||||
_RayQuery rq = {};
|
||||
|
||||
@@ -76,7 +76,7 @@ metal::float3 get_torus_normal(
|
||||
return metal::normalize(world_point - world_point_on_guiding_line);
|
||||
}
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
, device Output& output [[user(fake0)]]
|
||||
) {
|
||||
@@ -90,7 +90,7 @@ kernel void main_(
|
||||
}
|
||||
|
||||
|
||||
kernel void main_candidate(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_candidate(
|
||||
metal::raytracing::instance_acceleration_structure acc_struct [[user(fake0)]]
|
||||
) {
|
||||
_RayQuery rq = {};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
using metal::uint;
|
||||
|
||||
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
) {
|
||||
metal::simdgroup_barrier(metal::mem_flags::mem_threadgroup);
|
||||
return;
|
||||
|
||||
@@ -11,7 +11,7 @@ struct Structure {
|
||||
|
||||
struct main_Input {
|
||||
};
|
||||
kernel void main_(
|
||||
[[max_total_threads_per_threadgroup(1)]] kernel void main_(
|
||||
uint num_subgroups [[simdgroups_per_threadgroup]]
|
||||
, uint subgroup_size [[threads_per_simdgroup]]
|
||||
, uint subgroup_id [[simdgroup_index_in_threadgroup]]
|
||||
|
||||
@@ -383,7 +383,8 @@ impl super::Adapter {
|
||||
let mut downlevel_flags = wgt::DownlevelFlags::empty()
|
||||
| wgt::DownlevelFlags::NON_POWER_OF_TWO_MIPMAPPED_TEXTURES
|
||||
| wgt::DownlevelFlags::COMPARISON_SAMPLERS
|
||||
| wgt::DownlevelFlags::SHADER_F16_IN_F32;
|
||||
| wgt::DownlevelFlags::SHADER_F16_IN_F32
|
||||
| wgt::DownlevelFlags::MSL2_1;
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES,
|
||||
supports_cube_array,
|
||||
|
||||
@@ -933,6 +933,9 @@ impl super::CapabilitiesQuery {
|
||||
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6
|
||||
// These are older checks but still hold true; no entry in this table supports
|
||||
// more than 1024 threads.
|
||||
// **Note:** this is used to emit the `[[max_total_threads_per_threadgroup]]`
|
||||
// attribute. This is how we guarantee that compute dispatches will always run
|
||||
// and not silently fail due to hardware register pressure or occupancy limits.
|
||||
max_threads_per_group: if Self::supports_any(
|
||||
device,
|
||||
&[
|
||||
@@ -1243,6 +1246,11 @@ impl super::CapabilitiesQuery {
|
||||
.flags
|
||||
.set(wgt::DownlevelFlags::ANISOTROPIC_FILTERING, true);
|
||||
|
||||
downlevel.flags.set(
|
||||
wgt::DownlevelFlags::MSL2_1,
|
||||
self.msl_version >= MTLLanguageVersion::Version2_1,
|
||||
);
|
||||
|
||||
let limits = crate::auxil::adjust_raw_limits(wgt::Limits {
|
||||
//
|
||||
// WebGPU LIMITS:
|
||||
|
||||
@@ -673,7 +673,8 @@ impl PhysicalDeviceFeatures {
|
||||
| Df::VIEW_FORMATS
|
||||
| Df::UNRESTRICTED_EXTERNAL_TEXTURE_COPIES
|
||||
| Df::NONBLOCKING_QUERY_RESOLVE
|
||||
| Df::SHADER_F16_IN_F32;
|
||||
| Df::SHADER_F16_IN_F32
|
||||
| Df::MSL2_1;
|
||||
|
||||
dl_flags.set(
|
||||
Df::SURFACE_VIEW_FORMATS,
|
||||
|
||||
@@ -1042,6 +1042,9 @@ bitflags::bitflags! {
|
||||
///
|
||||
/// Not supported by Vulkan on Mesa when [`Features::SHADER_F16`] is absent.
|
||||
const SHADER_F16_IN_F32 = 1 << 23;
|
||||
|
||||
/// Supports features introduced in MSL 2.1.
|
||||
const MSL2_1 = 1 << 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user