From 0f289cdac44df2c980a19e8669b0f7b2d410c1b5 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 5 Nov 2026 19:57:19 -0800 Subject: [PATCH] Commit the regenerated fixture companions, and record how Metal runs an amplified mesh draw What: the .ll and .air.ll companions of mesh_partial_barrier, compute_thread_limit and mesh_pipeline_limits, and their TOOLCHAIN lines (regen-air-fixtures on the M3 Max, job m3-max-2677). probes/ mesh_amplification.m records its answers: under an amplification count of 2 the object function runs once (8 threads) and the mesh threadgroups it launches run once per amplification (16 threads, ids 0 and 1, a count of 2), each into its view mapping's slice. FAST-PATHS.md's known gap for a mesh pipeline's amplification says what an exact form must do and why neither built draw form is one. Why: the tests and cases read the fixtures; the gap stays open with the measured semantics written down. Verified: the probe ran on the M3 Max (job m3-max-2677). (cherry picked from commit bb5a45dd26d89d5af72e755ad4ac976975007d8b) --- .../probes/mesh_amplification.m | 10 + .../fixtures/public/engine/TOOLCHAIN | 3 + .../public/engine/compute_thread_limit.air.ll | 109 +++++ .../public/engine/compute_thread_limit.ll | 109 +++++ .../public/engine/mesh_partial_barrier.air.ll | 399 ++++++++++++++++++ .../public/engine/mesh_partial_barrier.ll | 395 +++++++++++++++++ .../public/engine/mesh_pipeline_limits.air.ll | 162 +++++++ .../public/engine/mesh_pipeline_limits.ll | 160 +++++++ docs/FAST-PATHS.md | 7 +- 9 files changed, 1352 insertions(+), 2 deletions(-) create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.air.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.air.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.air.ll create mode 100644 crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.ll diff --git a/crates/metal2vulkan-conformance/probes/mesh_amplification.m b/crates/metal2vulkan-conformance/probes/mesh_amplification.m index 2133645c9..61fbef3f1 100644 --- a/crates/metal2vulkan-conformance/probes/mesh_amplification.m +++ b/crates/metal2vulkan-conformance/probes/mesh_amplification.m @@ -15,6 +15,16 @@ // mesh threadgroup draws one triangle over every pixel, its fragment writing // (amplification id + 1, object threadgroup + 1, primitive data, 7). The probe prints the words, // and each slice's texel (0, 0) and how many texels of it were drawn. `--cases` lists the cases. +// +// Measured on an M3 Max under macOS 27.0.1 (supportsVertexAmplificationCount:2 answers 1), both +// command buffers completed with no error: +// - `plain`: 8 object threads, 8 mesh threads, amplification ids summing to 0, a count of 1, 2 +// mesh threadgroups of amplification 0; slice 0 drawn whole (texel (1, 2, 1, 7)), slice 1 not. +// - `amplified-2`: 8 object threads, 16 mesh threads, ids summing to 8, a count of 2, 2 mesh +// threadgroups of each amplification; slice 0 drawn whole by amplification 0 (1, 2, 2, 7) and +// slice 1 by amplification 1 (2, 2, 2, 7). The object function runs once for the draw, and the +// mesh threadgroups it launches run once per amplification, each reading its own id and +// rendering into its own view mapping's slice. #import #import #include diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index 45f18d6e8..ddf6de7bb 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -41,6 +41,7 @@ fixture cfit_tile_imageblock: metal: Apple metal version 32023.921 (metalfe-3202 fixture cfit_tile_memory: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture color_groups: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture color_groups_fetch: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) +fixture compute_thread_limit: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture con_fetch_coverage: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture coverage_loop: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture coverage_natural: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) @@ -186,6 +187,8 @@ fixture mesh_object_grid: metal: Apple metal version 32023.921 (metalfe-32023.92 fixture mesh_object_memory: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture mesh_order: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture mesh_outputs: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) +fixture mesh_partial_barrier: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) +fixture mesh_pipeline_limits: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture mip_level_sampling: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture mli_memoryless_step: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture mlo_half_trig_inf: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.air.ll new file mode 100644 index 000000000..2b3a5d1d4 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.air.ll @@ -0,0 +1,109 @@ +; Generated by scripts/regen-air-fixtures from compute_thread_limit.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%"struct.metal::_atomic" = type { i32 } + +; Function Attrs: mustprogress nounwind willreturn +define void @compute_thread_limit_plain(%"struct.metal::_atomic" addrspace(1)* nocapture noundef "air-buffer-no-alias" %0, <3 x i32> noundef %1, <3 x i32> noundef %2, i32 noundef %3) local_unnamed_addr #0 { + %5 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 0, i32 0 + %6 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %5, i32 1, i32 0, i32 2, i1 true) #3 + %7 = extractelement <3 x i32> %2, i64 0 + %8 = or i32 %7, %3 + %9 = extractelement <3 x i32> %2, i64 1 + %10 = or i32 %8, %9 + %11 = extractelement <3 x i32> %2, i64 2 + %12 = or i32 %10, %11 + %13 = icmp eq i32 %12, 0 + br i1 %13, label %14, label %21 + +14: ; preds = %4 + %15 = extractelement <3 x i32> %1, i64 0 + %16 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 1, i32 0 + %17 = extractelement <3 x i32> %1, i64 1 + %18 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 2, i32 0 + %19 = extractelement <3 x i32> %1, i64 2 + %20 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 3, i32 0 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %16, i32 %15, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %18, i32 %17, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %20, i32 %19, i32 0, i32 2, i1 true) #3 + br label %21 + +21: ; preds = %4, %14 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @compute_thread_limit_64(%"struct.metal::_atomic" addrspace(1)* nocapture noundef "air-buffer-no-alias" %0, <3 x i32> noundef %1, <3 x i32> noundef %2, i32 noundef %3) local_unnamed_addr #1 { + %5 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 0, i32 0 + %6 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %5, i32 1, i32 0, i32 2, i1 true) #3 + %7 = extractelement <3 x i32> %2, i64 0 + %8 = or i32 %7, %3 + %9 = extractelement <3 x i32> %2, i64 1 + %10 = or i32 %8, %9 + %11 = extractelement <3 x i32> %2, i64 2 + %12 = or i32 %10, %11 + %13 = icmp eq i32 %12, 0 + br i1 %13, label %14, label %21 + +14: ; preds = %4 + %15 = extractelement <3 x i32> %1, i64 0 + %16 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 1, i32 0 + %17 = extractelement <3 x i32> %1, i64 1 + %18 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 2, i32 0 + %19 = extractelement <3 x i32> %1, i64 2 + %20 = getelementptr inbounds %"struct.metal::_atomic", %"struct.metal::_atomic" addrspace(1)* %0, i64 3, i32 0 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %16, i32 %15, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %18, i32 %17, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture %20, i32 %19, i32 0, i32 2, i1 true) #3 + br label %21 + +21: ; preds = %4, %14 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture, i32, i32, i32, i1) local_unnamed_addr #2 + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.atomic.global.store.i32(i32 addrspace(1)* nocapture, i32, i32, i32, i1) local_unnamed_addr #2 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nounwind willreturn } +attributes #3 = { nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !17} +!air.compile_options = !{!19, !20, !21} +!llvm.ident = !{!22} +!air.version = !{!23} +!air.language_version = !{!24} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{void (%"struct.metal::_atomic" addrspace(1)*, <3 x i32>, <3 x i32>, i32)* @compute_thread_limit_plain, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15, !16} +!12 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.struct_type_info", !13, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"metal::_atomic", !"air.arg_name", !"out"} +!13 = !{i32 0, i32 4, i32 0, !"uint", !"__s"} +!14 = !{i32 1, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!15 = !{i32 2, !"air.threadgroup_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"group"} +!16 = !{i32 3, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!17 = !{void (%"struct.metal::_atomic" addrspace(1)*, <3 x i32>, <3 x i32>, i32)* @compute_thread_limit_64, !10, !11, !18} +!18 = !{!"air.max_work_group_size", i32 64} +!19 = !{!"air.compile.denorms_disable"} +!20 = !{!"air.compile.fast_math_enable"} +!21 = !{!"air.compile.framebuffer_fetch_enable"} +!22 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!23 = !{i32 2, i32 8, i32 0} +!24 = !{!"Metal", i32 4, i32 0, i32 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.ll b/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.ll new file mode 100644 index 000000000..14f97918c --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/compute_thread_limit.ll @@ -0,0 +1,109 @@ +; Generated by scripts/regen-air-fixtures from compute_thread_limit.metal (llvm-dis of compute_thread_limit.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%"struct.metal::_atomic" = type { i32 } + +; Function Attrs: mustprogress nounwind willreturn +define void @compute_thread_limit_plain(ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %0, <3 x i32> noundef %1, <3 x i32> noundef %2, i32 noundef %3) local_unnamed_addr #0 { + %5 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 0, i32 0 + %6 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %5, i32 1, i32 0, i32 2, i1 true) #3 + %7 = extractelement <3 x i32> %2, i64 0 + %8 = or i32 %7, %3 + %9 = extractelement <3 x i32> %2, i64 1 + %10 = or i32 %8, %9 + %11 = extractelement <3 x i32> %2, i64 2 + %12 = or i32 %10, %11 + %13 = icmp eq i32 %12, 0 + br i1 %13, label %14, label %21 + +14: ; preds = %4 + %15 = extractelement <3 x i32> %1, i64 0 + %16 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 1, i32 0 + %17 = extractelement <3 x i32> %1, i64 1 + %18 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 2, i32 0 + %19 = extractelement <3 x i32> %1, i64 2 + %20 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 3, i32 0 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %16, i32 %15, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %18, i32 %17, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %20, i32 %19, i32 0, i32 2, i1 true) #3 + br label %21 + +21: ; preds = %14, %4 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @compute_thread_limit_64(ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %0, <3 x i32> noundef %1, <3 x i32> noundef %2, i32 noundef %3) local_unnamed_addr #1 { + %5 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 0, i32 0 + %6 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %5, i32 1, i32 0, i32 2, i1 true) #3 + %7 = extractelement <3 x i32> %2, i64 0 + %8 = or i32 %7, %3 + %9 = extractelement <3 x i32> %2, i64 1 + %10 = or i32 %8, %9 + %11 = extractelement <3 x i32> %2, i64 2 + %12 = or i32 %10, %11 + %13 = icmp eq i32 %12, 0 + br i1 %13, label %14, label %21 + +14: ; preds = %4 + %15 = extractelement <3 x i32> %1, i64 0 + %16 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 1, i32 0 + %17 = extractelement <3 x i32> %1, i64 1 + %18 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 2, i32 0 + %19 = extractelement <3 x i32> %1, i64 2 + %20 = getelementptr inbounds %"struct.metal::_atomic", ptr addrspace(1) %0, i64 3, i32 0 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %16, i32 %15, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %18, i32 %17, i32 0, i32 2, i1 true) #3 + tail call void @air.atomic.global.store.i32(ptr addrspace(1) captures(none) %20, i32 %19, i32 0, i32 2, i1 true) #3 + br label %21 + +21: ; preds = %14, %4 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none), i32, i32, i32, i1) local_unnamed_addr #2 + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.atomic.global.store.i32(ptr addrspace(1) captures(none), i32, i32, i32, i1) local_unnamed_addr #2 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nounwind willreturn } +attributes #3 = { nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !17} +!air.compile_options = !{!19, !20, !21} +!llvm.ident = !{!22} +!air.version = !{!23} +!air.language_version = !{!24} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @compute_thread_limit_plain, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15, !16} +!12 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.struct_type_info", !13, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"metal::_atomic", !"air.arg_name", !"out"} +!13 = !{i32 0, i32 4, i32 0, !"uint", !"__s"} +!14 = !{i32 1, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!15 = !{i32 2, !"air.threadgroup_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"group"} +!16 = !{i32 3, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!17 = !{ptr @compute_thread_limit_64, !10, !11, !18} +!18 = !{!"air.max_work_group_size", i32 64} +!19 = !{!"air.compile.denorms_disable"} +!20 = !{!"air.compile.fast_math_enable"} +!21 = !{!"air.compile.framebuffer_fetch_enable"} +!22 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!23 = !{i32 2, i32 8, i32 0} +!24 = !{!"Metal", i32 4, i32 0, i32 0} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.air.ll new file mode 100644 index 000000000..1a4b8db78 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.air.ll @@ -0,0 +1,399 @@ +; Generated by scripts/regen-air-fixtures from mesh_partial_barrier.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.PartialPayload = type { i32 } +%struct._mesh_grid_properties_t = type opaque +%struct._mesh_t = type opaque + +@_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 + +; Function Attrs: convergent mustprogress nounwind +define void @mesh_partial_barrier_uniform(%struct.PartialPayload addrspace(6)* nocapture noundef readnone align 4 dereferenceable(4) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 addrspace(1)* nocapture noundef "air-buffer-no-alias" %2, <4 x i32> addrspace(2)* nocapture noundef readonly align 16 dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #0 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %2, i32 1, i32 0, i32 2, i1 true) #8 + %15 = mul i32 %4, 3 + %16 = add i32 %15, 1 + %17 = zext i32 %4 to i64 + %18 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %17 + store i32 %16, i32 addrspace(3)* %18, align 4, !tbaa !45 + %19 = load <4 x i32>, <4 x i32> addrspace(2)* %3, align 16, !alias.scope !49, !noalias !52 + %20 = extractelement <4 x i32> %19, i64 0 + %21 = icmp eq i32 %20, 0 + br i1 %21, label %27, label %22 + +22: ; preds = %8 + %23 = add i32 %4, 1 + %24 = urem i32 %23, %13 + %25 = zext i32 %24 to i64 + %26 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %25 + br label %52 + +27: ; preds = %52, %8 + %28 = phi i32 [ 0, %8 ], [ %56, %52 ] + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %29 = extractelement <3 x i32> %6, i64 0 + %30 = extractelement <3 x i32> %7, i64 0 + %31 = extractelement <3 x i32> %6, i64 1 + %32 = mul i32 %30, %31 + %33 = add i32 %32, %29 + %34 = shl i32 %33, 1 + %35 = add i32 %34, 4 + %36 = add i32 %4, 2 + %37 = urem i32 %36, %13 + %38 = zext i32 %37 to i64 + %39 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %38 + %40 = load i32, i32 addrspace(3)* %39, align 4, !tbaa !45 + %41 = add i32 %40, %28 + %42 = zext i32 %35 to i64 + %43 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %42 + store i32 %41, i32 addrspace(1)* %43, align 4, !tbaa !45, !alias.scope !52, !noalias !49 + %44 = shl i32 %10, 8 + %45 = shl i32 %4, 16 + %46 = or i32 %9, %45 + %47 = or i32 %46, %44 + %48 = add i32 %34, 5 + %49 = zext i32 %48 to i64 + %50 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %49 + store i32 %47, i32 addrspace(1)* %50, align 4, !tbaa !45, !alias.scope !52, !noalias !49 + %51 = icmp eq i32 %4, 0 + br i1 %51, label %60, label %61 + +52: ; preds = %22, %52 + %53 = phi i32 [ 0, %22 ], [ %56, %52 ] + %54 = phi i32 [ 0, %22 ], [ %58, %52 ] + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %55 = load i32, i32 addrspace(3)* %26, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %56 = add i32 %55, %53 + %57 = add i32 %55, 100 + store i32 %57, i32 addrspace(3)* %18, align 4, !tbaa !45 + %58 = add nuw i32 %54, 1 + %59 = icmp eq i32 %58, %20 + br i1 %59, label %27, label %52, !llvm.loop !54 + +60: ; preds = %27 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> zeroinitializer) #10 + br label %61 + +61: ; preds = %60, %27 + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_early_return(%struct.PartialPayload addrspace(6)* nocapture noundef readnone align 4 dereferenceable(4) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 addrspace(1)* nocapture noundef "air-buffer-no-alias" %2, <4 x i32> addrspace(2)* nocapture noundef readonly align 16 dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #1 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = load <4 x i32>, <4 x i32> addrspace(2)* %3, align 16, !alias.scope !56, !noalias !59 + %15 = extractelement <4 x i32> %14, i64 1 + %16 = tail call i32 @air.min.u.i32(i32 %15, i32 %13) #11 + %17 = extractelement <3 x i32> %6, i64 0 + %18 = extractelement <3 x i32> %7, i64 0 + %19 = extractelement <3 x i32> %6, i64 1 + %20 = mul i32 %18, %19 + %21 = add i32 %20, %17 + %22 = shl i32 %21, 1 + %23 = add i32 %22, 4 + %24 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %2, i32 1, i32 0, i32 2, i1 true) #8 + %25 = icmp eq i32 %4, 0 + br i1 %25, label %26, label %27 + +26: ; preds = %8 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> zeroinitializer) #10 + br label %27 + +27: ; preds = %26, %8 + %28 = icmp ugt i32 %16, %4 + br i1 %28, label %40, label %29 + +29: ; preds = %27 + %30 = or i32 %4, -536870912 + %31 = zext i32 %23 to i64 + %32 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %31 + store i32 %30, i32 addrspace(1)* %32, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + %33 = shl i32 %10, 8 + %34 = shl i32 %4, 16 + %35 = or i32 %9, %34 + %36 = or i32 %35, %33 + %37 = add i32 %22, 5 + %38 = zext i32 %37 to i64 + %39 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %38 + store i32 %36, i32 addrspace(1)* %39, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + br label %59 + +40: ; preds = %27 + %41 = mul i32 %4, 3 + %42 = add i32 %41, 1 + %43 = zext i32 %4 to i64 + %44 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %43 + store i32 %42, i32 addrspace(3)* %44, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %45 = add nuw i32 %4, 1 + %46 = urem i32 %45, %16 + %47 = zext i32 %46 to i64 + %48 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %47 + %49 = load i32, i32 addrspace(3)* %48, align 4, !tbaa !45 + %50 = zext i32 %23 to i64 + %51 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %50 + store i32 %49, i32 addrspace(1)* %51, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + %52 = shl i32 %10, 8 + %53 = shl i32 %4, 16 + %54 = or i32 %9, %53 + %55 = or i32 %54, %52 + %56 = add i32 %22, 5 + %57 = zext i32 %56 to i64 + %58 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %57 + store i32 %55, i32 addrspace(1)* %58, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + br label %59 + +59: ; preds = %40, %29 + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_if(%struct.PartialPayload addrspace(6)* nocapture noundef readnone align 4 dereferenceable(4) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 addrspace(1)* nocapture noundef "air-buffer-no-alias" %2, <4 x i32> addrspace(2)* nocapture noundef readonly align 16 dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #1 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = load <4 x i32>, <4 x i32> addrspace(2)* %3, align 16, !alias.scope !61, !noalias !64 + %15 = extractelement <4 x i32> %14, i64 1 + %16 = tail call i32 @air.min.u.i32(i32 %15, i32 %13) #11 + %17 = extractelement <3 x i32> %6, i64 0 + %18 = extractelement <3 x i32> %7, i64 0 + %19 = extractelement <3 x i32> %6, i64 1 + %20 = mul i32 %18, %19 + %21 = add i32 %20, %17 + %22 = shl i32 %21, 1 + %23 = add i32 %22, 4 + %24 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %2, i32 1, i32 0, i32 2, i1 true) #8 + %25 = icmp ugt i32 %16, %4 + br i1 %25, label %26, label %38 + +26: ; preds = %8 + %27 = mul i32 %4, 5 + %28 = add i32 %27, 2 + %29 = zext i32 %4 to i64 + %30 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %29 + store i32 %28, i32 addrspace(3)* %30, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %31 = add nuw i32 %4, 1 + %32 = urem i32 %31, %16 + %33 = zext i32 %32 to i64 + %34 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %33 + %35 = load i32, i32 addrspace(3)* %34, align 4, !tbaa !45 + %36 = zext i32 %23 to i64 + %37 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %36 + store i32 %35, i32 addrspace(1)* %37, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + br label %42 + +38: ; preds = %8 + %39 = or i32 %4, -520093696 + %40 = zext i32 %23 to i64 + %41 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %40 + store i32 %39, i32 addrspace(1)* %41, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + br label %42 + +42: ; preds = %38, %26 + %43 = shl i32 %10, 8 + %44 = shl i32 %4, 16 + %45 = or i32 %9, %44 + %46 = or i32 %45, %43 + %47 = add i32 %22, 5 + %48 = zext i32 %47 to i64 + %49 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %48 + store i32 %46, i32 addrspace(1)* %49, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + %50 = icmp eq i32 %4, 0 + br i1 %50, label %51, label %52 + +51: ; preds = %42 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> zeroinitializer) #10 + br label %52 + +52: ; preds = %51, %42 + ret void +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn +define void @mesh_partial_barrier_mesh(%struct._mesh_t addrspace(7)* nocapture %0) local_unnamed_addr #2 { + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_mesh_early_return(%struct._mesh_t addrspace(7)* %0, i32 addrspace(1)* nocapture noundef "air-buffer-no-alias" %1, <4 x i32> addrspace(2)* nocapture noundef readonly align 16 dereferenceable(16) "air-buffer-no-alias" %2, i32 noundef %3, <3 x i32> noundef %4) local_unnamed_addr #1 { + %6 = extractelement <3 x i32> %4, i64 0 + %7 = extractelement <3 x i32> %4, i64 1 + %8 = mul i32 %6, %7 + %9 = extractelement <3 x i32> %4, i64 2 + %10 = mul i32 %8, %9 + %11 = load <4 x i32>, <4 x i32> addrspace(2)* %2, align 16, !alias.scope !66, !noalias !69 + %12 = extractelement <4 x i32> %11, i64 1 + %13 = tail call i32 @air.min.u.i32(i32 %12, i32 %10) #11 + %14 = tail call i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture %1, i32 1, i32 0, i32 2, i1 true) #8 + %15 = icmp eq i32 %3, 0 + br i1 %15, label %16, label %17 + +16: ; preds = %5 + tail call void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture %0, i32 0) #10 + br label %17 + +17: ; preds = %16, %5 + %18 = icmp ugt i32 %13, %3 + br i1 %18, label %24, label %19 + +19: ; preds = %17 + %20 = or i32 %3, -536870912 + %21 = add i32 %3, 4 + %22 = zext i32 %21 to i64 + %23 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %22 + store i32 %20, i32 addrspace(1)* %23, align 4, !tbaa !45, !alias.scope !69, !noalias !66 + br label %37 + +24: ; preds = %17 + %25 = mul i32 %3, 7 + %26 = add i32 %25, 3 + %27 = zext i32 %3 to i64 + %28 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words, i64 0, i64 %27 + store i32 %26, i32 addrspace(3)* %28, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %29 = add nuw i32 %3, 1 + %30 = urem i32 %29, %13 + %31 = zext i32 %30 to i64 + %32 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* @_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words, i64 0, i64 %31 + %33 = load i32, i32 addrspace(3)* %32, align 4, !tbaa !45 + %34 = add i32 %3, 4 + %35 = zext i32 %34 to i64 + %36 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %35 + store i32 %33, i32 addrspace(1)* %36, align 4, !tbaa !45, !alias.scope !69, !noalias !66 + br label %37 + +37: ; preds = %24, %19 + ret void +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn +define <4 x i32> @mesh_partial_barrier_fragment() local_unnamed_addr #3 { + ret <4 x i32> +} + +; Function Attrs: convergent mustprogress nounwind willreturn +declare void @air.wg.barrier(i32, i32) local_unnamed_addr #4 + +; Function Attrs: argmemonly mustprogress nounwind willreturn +declare void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture, <3 x i32>) local_unnamed_addr #5 + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +declare i32 @air.min.u.i32(i32, i32) local_unnamed_addr #6 + +; Function Attrs: mustprogress nounwind willreturn +declare i32 @air.atomic.global.add.u.i32(i32 addrspace(1)* nocapture, i32, i32, i32, i1) local_unnamed_addr #7 + +; Function Attrs: argmemonly mustprogress nounwind willreturn +declare void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture, i32) local_unnamed_addr #5 + +attributes #0 = { convergent mustprogress nounwind "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { convergent mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nofree norecurse nosync nounwind readnone willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { mustprogress nofree norecurse nosync nounwind readnone willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #4 = { convergent mustprogress nounwind willreturn } +attributes #5 = { argmemonly mustprogress nounwind willreturn } +attributes #6 = { mustprogress nofree nosync nounwind readnone willreturn } +attributes #7 = { mustprogress nounwind willreturn } +attributes #8 = { nounwind willreturn } +attributes #9 = { convergent nounwind willreturn } +attributes #10 = { argmemonly nounwind willreturn } +attributes #11 = { nounwind readnone willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.object = !{!9, !21, !22} +!air.mesh = !{!23, !29} +!air.fragment = !{!36} +!air.compile_options = !{!39, !40, !41} +!llvm.ident = !{!42} +!air.version = !{!43} +!air.language_version = !{!44} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{void (%struct.PartialPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32 addrspace(1)*, <4 x i32> addrspace(2)*, i32, <3 x i32>, <3 x i32>, <3 x i32>)* @mesh_partial_barrier_uniform, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15, !16, !17, !18, !19, !20} +!12 = !{i32 0, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"PartialPayload", !"air.arg_name", !"payload", !"air.arg_unused"} +!13 = !{i32 0, i32 4, i32 0, !"uint", !"unused"} +!14 = !{i32 1, !"air.mesh_grid_properties", !"air.arg_type_name", !"mesh_grid_properties", !"air.arg_name", !"grid"} +!15 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"} +!16 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"uint4", !"air.arg_name", !"ctl"} +!17 = !{i32 4, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!18 = !{i32 5, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!19 = !{i32 6, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"pos"} +!20 = !{i32 7, !"air.threads_per_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tpg"} +!21 = !{void (%struct.PartialPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32 addrspace(1)*, <4 x i32> addrspace(2)*, i32, <3 x i32>, <3 x i32>, <3 x i32>)* @mesh_partial_barrier_early_return, !10, !11} +!22 = !{void (%struct.PartialPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32 addrspace(1)*, <4 x i32> addrspace(2)*, i32, <3 x i32>, <3 x i32>, <3 x i32>)* @mesh_partial_barrier_if, !10, !11} +!23 = !{void (%struct._mesh_t addrspace(7)*)* @mesh_partial_barrier_mesh, !10, !24} +!24 = !{!25} +!25 = !{i32 0, !"air.mesh", !26, !"air.arg_type_name", !"mesh", !"air.arg_name", !"output", !"air.arg_unused"} +!26 = !{!"air.mesh_type_info", !27, !10, i32 3, i32 1, !"air.triangle"} +!27 = !{!28} +!28 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!29 = !{void (%struct._mesh_t addrspace(7)*, i32 addrspace(1)*, <4 x i32> addrspace(2)*, i32, <3 x i32>)* @mesh_partial_barrier_mesh_early_return, !10, !30} +!30 = !{!31, !32, !33, !34, !35} +!31 = !{i32 0, !"air.mesh", !26, !"air.arg_type_name", !"mesh", !"air.arg_name", !"output"} +!32 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"} +!33 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"uint4", !"air.arg_name", !"ctl"} +!34 = !{i32 3, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!35 = !{i32 4, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!36 = !{<4 x i32> ()* @mesh_partial_barrier_fragment, !37, !10} +!37 = !{!38} +!38 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"} +!39 = !{!"air.compile.denorms_disable"} +!40 = !{!"air.compile.fast_math_enable"} +!41 = !{!"air.compile.framebuffer_fetch_enable"} +!42 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!43 = !{i32 2, i32 8, i32 0} +!44 = !{!"Metal", i32 4, i32 0, i32 0} +!45 = !{!46, !46, i64 0} +!46 = !{!"int", !47, i64 0} +!47 = !{!"omnipotent char", !48, i64 0} +!48 = !{!"Simple C++ TBAA"} +!49 = !{!50} +!50 = distinct !{!50, !51, !"air-alias-scope-arg(3)"} +!51 = distinct !{!51, !"air-alias-scopes(mesh_partial_barrier_uniform)"} +!52 = !{!53} +!53 = distinct !{!53, !51, !"air-alias-scope-arg(2)"} +!54 = distinct !{!54, !55} +!55 = !{!"llvm.loop.mustprogress"} +!56 = !{!57} +!57 = distinct !{!57, !58, !"air-alias-scope-arg(3)"} +!58 = distinct !{!58, !"air-alias-scopes(mesh_partial_barrier_early_return)"} +!59 = !{!60} +!60 = distinct !{!60, !58, !"air-alias-scope-arg(2)"} +!61 = !{!62} +!62 = distinct !{!62, !63, !"air-alias-scope-arg(3)"} +!63 = distinct !{!63, !"air-alias-scopes(mesh_partial_barrier_if)"} +!64 = !{!65} +!65 = distinct !{!65, !63, !"air-alias-scope-arg(2)"} +!66 = !{!67} +!67 = distinct !{!67, !68, !"air-alias-scope-arg(2)"} +!68 = distinct !{!68, !"air-alias-scopes(mesh_partial_barrier_mesh_early_return)"} +!69 = !{!70} +!70 = distinct !{!70, !68, !"air-alias-scope-arg(1)"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.ll b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.ll new file mode 100644 index 000000000..45cb073b3 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_partial_barrier.ll @@ -0,0 +1,395 @@ +; Generated by scripts/regen-air-fixtures from mesh_partial_barrier.metal (llvm-dis of mesh_partial_barrier.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +@_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 +@_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words = internal unnamed_addr addrspace(3) global [64 x i32] undef, align 4 + +; Function Attrs: convergent mustprogress nounwind +define void @mesh_partial_barrier_uniform(ptr addrspace(6) noundef readnone align 4 captures(none) dereferenceable(4) %0, ptr addrspace(3) %1, ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 16 captures(none) dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #0 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %2, i32 1, i32 0, i32 2, i1 true) #8 + %15 = mul i32 %4, 3 + %16 = add i32 %15, 1 + %17 = zext i32 %4 to i64 + %18 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %17 + store i32 %16, ptr addrspace(3) %18, align 4, !tbaa !45 + %19 = load <4 x i32>, ptr addrspace(2) %3, align 16, !alias.scope !49, !noalias !52 + %20 = extractelement <4 x i32> %19, i64 0 + %21 = icmp eq i32 %20, 0 + br i1 %21, label %27, label %22 + +22: ; preds = %8 + %23 = add i32 %4, 1 + %24 = urem i32 %23, %13 + %25 = zext i32 %24 to i64 + %26 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %25 + br label %52 + +27: ; preds = %52, %8 + %28 = phi i32 [ 0, %8 ], [ %56, %52 ] + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %29 = extractelement <3 x i32> %6, i64 0 + %30 = extractelement <3 x i32> %7, i64 0 + %31 = extractelement <3 x i32> %6, i64 1 + %32 = mul i32 %30, %31 + %33 = add i32 %32, %29 + %34 = shl i32 %33, 1 + %35 = add i32 %34, 4 + %36 = add i32 %4, 2 + %37 = urem i32 %36, %13 + %38 = zext i32 %37 to i64 + %39 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ28mesh_partial_barrier_uniformRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %38 + %40 = load i32, ptr addrspace(3) %39, align 4, !tbaa !45 + %41 = add i32 %40, %28 + %42 = zext i32 %35 to i64 + %43 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %42 + store i32 %41, ptr addrspace(1) %43, align 4, !tbaa !45, !alias.scope !52, !noalias !49 + %44 = shl i32 %10, 8 + %45 = shl i32 %4, 16 + %46 = or i32 %9, %45 + %47 = or i32 %46, %44 + %48 = add i32 %34, 5 + %49 = zext i32 %48 to i64 + %50 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %49 + store i32 %47, ptr addrspace(1) %50, align 4, !tbaa !45, !alias.scope !52, !noalias !49 + %51 = icmp eq i32 %4, 0 + br i1 %51, label %60, label %61 + +52: ; preds = %52, %22 + %53 = phi i32 [ 0, %22 ], [ %56, %52 ] + %54 = phi i32 [ 0, %22 ], [ %58, %52 ] + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %55 = load i32, ptr addrspace(3) %26, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %56 = add i32 %55, %53 + %57 = add i32 %55, 100 + store i32 %57, ptr addrspace(3) %18, align 4, !tbaa !45 + %58 = add nuw i32 %54, 1 + %59 = icmp eq i32 %58, %20 + br i1 %59, label %27, label %52, !llvm.loop !54 + +60: ; preds = %27 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> zeroinitializer) #10 + br label %61 + +61: ; preds = %60, %27 + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_early_return(ptr addrspace(6) noundef readnone align 4 captures(none) dereferenceable(4) %0, ptr addrspace(3) %1, ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 16 captures(none) dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #1 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = load <4 x i32>, ptr addrspace(2) %3, align 16, !alias.scope !56, !noalias !59 + %15 = extractelement <4 x i32> %14, i64 1 + %16 = tail call i32 @air.min.u.i32(i32 %15, i32 %13) #11 + %17 = extractelement <3 x i32> %6, i64 0 + %18 = extractelement <3 x i32> %7, i64 0 + %19 = extractelement <3 x i32> %6, i64 1 + %20 = mul i32 %18, %19 + %21 = add i32 %20, %17 + %22 = shl i32 %21, 1 + %23 = add i32 %22, 4 + %24 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %2, i32 1, i32 0, i32 2, i1 true) #8 + %25 = icmp eq i32 %4, 0 + br i1 %25, label %26, label %27 + +26: ; preds = %8 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> zeroinitializer) #10 + br label %27 + +27: ; preds = %26, %8 + %28 = icmp ugt i32 %16, %4 + br i1 %28, label %40, label %29 + +29: ; preds = %27 + %30 = or i32 %4, -536870912 + %31 = zext i32 %23 to i64 + %32 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %31 + store i32 %30, ptr addrspace(1) %32, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + %33 = shl i32 %10, 8 + %34 = shl i32 %4, 16 + %35 = or i32 %9, %34 + %36 = or i32 %35, %33 + %37 = add i32 %22, 5 + %38 = zext i32 %37 to i64 + %39 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %38 + store i32 %36, ptr addrspace(1) %39, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + br label %59 + +40: ; preds = %27 + %41 = mul i32 %4, 3 + %42 = add i32 %41, 1 + %43 = zext i32 %4 to i64 + %44 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %43 + store i32 %42, ptr addrspace(3) %44, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %45 = add nuw i32 %4, 1 + %46 = urem i32 %45, %16 + %47 = zext i32 %46 to i64 + %48 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ33mesh_partial_barrier_early_returnRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %47 + %49 = load i32, ptr addrspace(3) %48, align 4, !tbaa !45 + %50 = zext i32 %23 to i64 + %51 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %50 + store i32 %49, ptr addrspace(1) %51, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + %52 = shl i32 %10, 8 + %53 = shl i32 %4, 16 + %54 = or i32 %9, %53 + %55 = or i32 %54, %52 + %56 = add i32 %22, 5 + %57 = zext i32 %56 to i64 + %58 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %57 + store i32 %55, ptr addrspace(1) %58, align 4, !tbaa !45, !alias.scope !59, !noalias !56 + br label %59 + +59: ; preds = %40, %29 + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_if(ptr addrspace(6) noundef readnone align 4 captures(none) dereferenceable(4) %0, ptr addrspace(3) %1, ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 16 captures(none) dereferenceable(16) "air-buffer-no-alias" %3, i32 noundef %4, <3 x i32> noundef %5, <3 x i32> noundef %6, <3 x i32> noundef %7) local_unnamed_addr #1 { + %9 = extractelement <3 x i32> %5, i64 0 + %10 = extractelement <3 x i32> %5, i64 1 + %11 = mul i32 %9, %10 + %12 = extractelement <3 x i32> %5, i64 2 + %13 = mul i32 %11, %12 + %14 = load <4 x i32>, ptr addrspace(2) %3, align 16, !alias.scope !61, !noalias !64 + %15 = extractelement <4 x i32> %14, i64 1 + %16 = tail call i32 @air.min.u.i32(i32 %15, i32 %13) #11 + %17 = extractelement <3 x i32> %6, i64 0 + %18 = extractelement <3 x i32> %7, i64 0 + %19 = extractelement <3 x i32> %6, i64 1 + %20 = mul i32 %18, %19 + %21 = add i32 %20, %17 + %22 = shl i32 %21, 1 + %23 = add i32 %22, 4 + %24 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %2, i32 1, i32 0, i32 2, i1 true) #8 + %25 = icmp ugt i32 %16, %4 + br i1 %25, label %26, label %38 + +26: ; preds = %8 + %27 = mul i32 %4, 5 + %28 = add i32 %27, 2 + %29 = zext i32 %4 to i64 + %30 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %29 + store i32 %28, ptr addrspace(3) %30, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %31 = add nuw i32 %4, 1 + %32 = urem i32 %31, %16 + %33 = zext i32 %32 to i64 + %34 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ23mesh_partial_barrier_ifRU13MTLobjectdata14PartialPayloadN5metal20mesh_grid_propertiesEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jS9_S9_E5words, i64 0, i64 %33 + %35 = load i32, ptr addrspace(3) %34, align 4, !tbaa !45 + %36 = zext i32 %23 to i64 + %37 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %36 + store i32 %35, ptr addrspace(1) %37, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + br label %42 + +38: ; preds = %8 + %39 = or i32 %4, -520093696 + %40 = zext i32 %23 to i64 + %41 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %40 + store i32 %39, ptr addrspace(1) %41, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + br label %42 + +42: ; preds = %38, %26 + %43 = shl i32 %10, 8 + %44 = shl i32 %4, 16 + %45 = or i32 %9, %44 + %46 = or i32 %45, %43 + %47 = add i32 %22, 5 + %48 = zext i32 %47 to i64 + %49 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %48 + store i32 %46, ptr addrspace(1) %49, align 4, !tbaa !45, !alias.scope !64, !noalias !61 + %50 = icmp eq i32 %4, 0 + br i1 %50, label %51, label %52 + +51: ; preds = %42 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> zeroinitializer) #10 + br label %52 + +52: ; preds = %51, %42 + ret void +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) +define void @mesh_partial_barrier_mesh(ptr addrspace(7) captures(none) %0) local_unnamed_addr #2 { + ret void +} + +; Function Attrs: convergent mustprogress nounwind willreturn +define void @mesh_partial_barrier_mesh_early_return(ptr addrspace(7) %0, ptr addrspace(1) noundef captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 16 captures(none) dereferenceable(16) "air-buffer-no-alias" %2, i32 noundef %3, <3 x i32> noundef %4) local_unnamed_addr #1 { + %6 = extractelement <3 x i32> %4, i64 0 + %7 = extractelement <3 x i32> %4, i64 1 + %8 = mul i32 %6, %7 + %9 = extractelement <3 x i32> %4, i64 2 + %10 = mul i32 %8, %9 + %11 = load <4 x i32>, ptr addrspace(2) %2, align 16, !alias.scope !66, !noalias !69 + %12 = extractelement <4 x i32> %11, i64 1 + %13 = tail call i32 @air.min.u.i32(i32 %12, i32 %10) #11 + %14 = tail call i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none) %1, i32 1, i32 0, i32 2, i1 true) #8 + %15 = icmp eq i32 %3, 0 + br i1 %15, label %16, label %17 + +16: ; preds = %5 + tail call void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none) %0, i32 0) #10 + br label %17 + +17: ; preds = %16, %5 + %18 = icmp ugt i32 %13, %3 + br i1 %18, label %24, label %19 + +19: ; preds = %17 + %20 = or i32 %3, -536870912 + %21 = add i32 %3, 4 + %22 = zext i32 %21 to i64 + %23 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %22 + store i32 %20, ptr addrspace(1) %23, align 4, !tbaa !45, !alias.scope !69, !noalias !66 + br label %37 + +24: ; preds = %17 + %25 = mul i32 %3, 7 + %26 = add i32 %25, 3 + %27 = zext i32 %3 to i64 + %28 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words, i64 0, i64 %27 + store i32 %26, ptr addrspace(3) %28, align 4, !tbaa !45 + tail call void @air.wg.barrier(i32 2, i32 1) #9 + %29 = add nuw i32 %3, 1 + %30 = urem i32 %29, %13 + %31 = zext i32 %30 to i64 + %32 = getelementptr inbounds [64 x i32], ptr addrspace(3) @_ZZ38mesh_partial_barrier_mesh_early_returnN5metal4meshI13PartialVertexvLj3ELj1ELNS_8topologyE2EEEPU9MTLdevicejRU11MTLconstantKDv4_jjDv3_jE5words, i64 0, i64 %31 + %33 = load i32, ptr addrspace(3) %32, align 4, !tbaa !45 + %34 = add i32 %3, 4 + %35 = zext i32 %34 to i64 + %36 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %35 + store i32 %33, ptr addrspace(1) %36, align 4, !tbaa !45, !alias.scope !69, !noalias !66 + br label %37 + +37: ; preds = %24, %19 + ret void +} + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) +define <4 x i32> @mesh_partial_barrier_fragment() local_unnamed_addr #3 { + ret <4 x i32> splat (i32 1) +} + +; Function Attrs: convergent mustprogress nounwind willreturn +declare void @air.wg.barrier(i32, i32) local_unnamed_addr #4 + +; Function Attrs: mustprogress nounwind willreturn memory(argmem: readwrite) +declare void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none), <3 x i32>) local_unnamed_addr #5 + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +declare i32 @air.min.u.i32(i32, i32) local_unnamed_addr #6 + +; Function Attrs: mustprogress nounwind willreturn +declare i32 @air.atomic.global.add.u.i32(ptr addrspace(1) captures(none), i32, i32, i32, i1) local_unnamed_addr #7 + +; Function Attrs: mustprogress nounwind willreturn memory(argmem: readwrite) +declare void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none), i32) local_unnamed_addr #5 + +attributes #0 = { convergent mustprogress nounwind "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { convergent mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #4 = { convergent mustprogress nounwind willreturn } +attributes #5 = { mustprogress nounwind willreturn memory(argmem: readwrite) } +attributes #6 = { mustprogress nofree nosync nounwind willreturn memory(none) } +attributes #7 = { mustprogress nounwind willreturn } +attributes #8 = { nounwind willreturn } +attributes #9 = { convergent nounwind willreturn } +attributes #10 = { nounwind willreturn memory(argmem: readwrite) } +attributes #11 = { nounwind willreturn memory(none) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.object = !{!9, !21, !22} +!air.mesh = !{!23, !29} +!air.fragment = !{!36} +!air.compile_options = !{!39, !40, !41} +!llvm.ident = !{!42} +!air.version = !{!43} +!air.language_version = !{!44} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @mesh_partial_barrier_uniform, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15, !16, !17, !18, !19, !20} +!12 = !{i32 0, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"PartialPayload", !"air.arg_name", !"payload", !"air.arg_unused"} +!13 = !{i32 0, i32 4, i32 0, !"uint", !"unused"} +!14 = !{i32 1, !"air.mesh_grid_properties", !"air.arg_type_name", !"mesh_grid_properties", !"air.arg_name", !"grid"} +!15 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"} +!16 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"uint4", !"air.arg_name", !"ctl"} +!17 = !{i32 4, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!18 = !{i32 5, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!19 = !{i32 6, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"pos"} +!20 = !{i32 7, !"air.threads_per_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tpg"} +!21 = !{ptr @mesh_partial_barrier_early_return, !10, !11} +!22 = !{ptr @mesh_partial_barrier_if, !10, !11} +!23 = !{ptr @mesh_partial_barrier_mesh, !10, !24} +!24 = !{!25} +!25 = !{i32 0, !"air.mesh", !26, !"air.arg_type_name", !"mesh", !"air.arg_name", !"output", !"air.arg_unused"} +!26 = !{!"air.mesh_type_info", !27, !10, i32 3, i32 1, !"air.triangle"} +!27 = !{!28} +!28 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!29 = !{ptr @mesh_partial_barrier_mesh_early_return, !10, !30} +!30 = !{!31, !32, !33, !34, !35} +!31 = !{i32 0, !"air.mesh", !26, !"air.arg_type_name", !"mesh", !"air.arg_name", !"output"} +!32 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"} +!33 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"uint4", !"air.arg_name", !"ctl"} +!34 = !{i32 3, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"} +!35 = !{i32 4, !"air.threads_per_threadgroup", !"air.arg_type_name", !"uint3", !"air.arg_name", !"tptg"} +!36 = !{ptr @mesh_partial_barrier_fragment, !37, !10} +!37 = !{!38} +!38 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"} +!39 = !{!"air.compile.denorms_disable"} +!40 = !{!"air.compile.fast_math_enable"} +!41 = !{!"air.compile.framebuffer_fetch_enable"} +!42 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!43 = !{i32 2, i32 8, i32 0} +!44 = !{!"Metal", i32 4, i32 0, i32 0} +!45 = !{!46, !46, i64 0} +!46 = !{!"int", !47, i64 0} +!47 = !{!"omnipotent char", !48, i64 0} +!48 = !{!"Simple C++ TBAA"} +!49 = !{!50} +!50 = distinct !{!50, !51, !"air-alias-scope-arg(3)"} +!51 = distinct !{!51, !"air-alias-scopes(mesh_partial_barrier_uniform)"} +!52 = !{!53} +!53 = distinct !{!53, !51, !"air-alias-scope-arg(2)"} +!54 = distinct !{!54, !55} +!55 = !{!"llvm.loop.mustprogress"} +!56 = !{!57} +!57 = distinct !{!57, !58, !"air-alias-scope-arg(3)"} +!58 = distinct !{!58, !"air-alias-scopes(mesh_partial_barrier_early_return)"} +!59 = !{!60} +!60 = distinct !{!60, !58, !"air-alias-scope-arg(2)"} +!61 = !{!62} +!62 = distinct !{!62, !63, !"air-alias-scope-arg(3)"} +!63 = distinct !{!63, !"air-alias-scopes(mesh_partial_barrier_if)"} +!64 = !{!65} +!65 = distinct !{!65, !63, !"air-alias-scope-arg(2)"} +!66 = !{!67} +!67 = distinct !{!67, !68, !"air-alias-scope-arg(2)"} +!68 = distinct !{!68, !"air-alias-scopes(mesh_partial_barrier_mesh_early_return)"} +!69 = !{!70} +!70 = distinct !{!70, !68, !"air-alias-scope-arg(1)"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.air.ll new file mode 100644 index 000000000..7e2298ab4 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.air.ll @@ -0,0 +1,162 @@ +; Generated by scripts/regen-air-fixtures from mesh_pipeline_limits.metal (typed pointers; xcrun metal-as reassembles it). Do not edit. +; ModuleID = '-' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.LimitsPayload = type { [4 x i32] } +%struct._mesh_grid_properties_t = type opaque +%struct._mesh_t = type opaque + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object(%struct.LimitsPayload addrspace(6)* nocapture noundef writeonly align 4 dereferenceable(16) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, %struct.LimitsPayload addrspace(6)* %0, i64 0, i32 0, i64 0 + store i32 1, i32 addrspace(6)* %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> ) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object_64(%struct.LimitsPayload addrspace(6)* nocapture noundef writeonly align 4 dereferenceable(16) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, %struct.LimitsPayload addrspace(6)* %0, i64 0, i32 0, i64 0 + store i32 1, i32 addrspace(6)* %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> ) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object_grid_4(%struct.LimitsPayload addrspace(6)* nocapture noundef writeonly align 4 dereferenceable(16) %0, %struct._mesh_grid_properties_t addrspace(3)* %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, %struct.LimitsPayload addrspace(6)* %0, i64 0, i32 0, i64 0 + store i32 1, i32 addrspace(6)* %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture %1, <3 x i32> ) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh(%struct._mesh_t addrspace(7)* %0, %struct.LimitsPayload addrspace(6)* nocapture noundef readonly align 4 dereferenceable(16) %1, i32 noundef %2) local_unnamed_addr #2 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %9 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, %struct.LimitsPayload addrspace(6)* %1, i64 0, i32 0, i64 0 + %7 = load i32, i32 addrspace(6)* %6, align 4, !tbaa !37 + %8 = add i32 %7, -1 + tail call void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture %0, i32 %8) #5 + br label %9 + +9: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh_64(%struct._mesh_t addrspace(7)* %0, %struct.LimitsPayload addrspace(6)* nocapture noundef readonly align 4 dereferenceable(16) %1, i32 noundef %2) local_unnamed_addr #3 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %9 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, %struct.LimitsPayload addrspace(6)* %1, i64 0, i32 0, i64 0 + %7 = load i32, i32 addrspace(6)* %6, align 4, !tbaa !37 + %8 = add i32 %7, -1 + tail call void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture %0, i32 %8) #5 + br label %9 + +9: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh_alone(%struct._mesh_t addrspace(7)* %0, i32 noundef %1) local_unnamed_addr #2 { + %3 = icmp eq i32 %1, 0 + br i1 %3, label %4, label %5 + +4: ; preds = %2 + tail call void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture %0, i32 0) #5 + br label %5 + +5: ; preds = %4, %2 + ret void +} + +; Function Attrs: argmemonly mustprogress nounwind willreturn +declare void @air.set_threadgroups_per_grid_mesh_properties(%struct._mesh_grid_properties_t addrspace(3)* nocapture, <3 x i32>) local_unnamed_addr #4 + +; Function Attrs: argmemonly mustprogress nounwind willreturn +declare void @air.set_primitive_count_mesh(%struct._mesh_t addrspace(7)* nocapture, i32) local_unnamed_addr #4 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #4 = { argmemonly mustprogress nounwind willreturn } +attributes #5 = { argmemonly nounwind willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.object = !{!9, !16, !18} +!air.mesh = !{!20, !27, !28} +!air.compile_options = !{!31, !32, !33} +!llvm.ident = !{!34} +!air.version = !{!35} +!air.language_version = !{!36} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{void (%struct.LimitsPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32)* @mesh_pipeline_limits_object, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15} +!12 = !{i32 0, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"LimitsPayload", !"air.arg_name", !"p"} +!13 = !{i32 0, i32 4, i32 4, !"uint", !"v"} +!14 = !{i32 1, !"air.mesh_grid_properties", !"air.arg_type_name", !"mesh_grid_properties", !"air.arg_name", !"g"} +!15 = !{i32 2, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!16 = !{void (%struct.LimitsPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32)* @mesh_pipeline_limits_object_64, !10, !11, !17} +!17 = !{!"air.max_work_group_size", i32 64} +!18 = !{void (%struct.LimitsPayload addrspace(6)*, %struct._mesh_grid_properties_t addrspace(3)*, i32)* @mesh_pipeline_limits_object_grid_4, !10, !11, !19} +!19 = !{!"air.max_mesh_work_groups", i32 4} +!20 = !{void (%struct._mesh_t addrspace(7)*, %struct.LimitsPayload addrspace(6)*, i32)* @mesh_pipeline_limits_mesh, !10, !21} +!21 = !{!22, !26, !15} +!22 = !{i32 0, !"air.mesh", !23, !"air.arg_type_name", !"mesh", !"air.arg_name", !"out"} +!23 = !{!"air.mesh_type_info", !24, !10, i32 3, i32 1, !"air.triangle"} +!24 = !{!25} +!25 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!26 = !{i32 1, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"LimitsPayload", !"air.arg_name", !"p"} +!27 = !{void (%struct._mesh_t addrspace(7)*, %struct.LimitsPayload addrspace(6)*, i32)* @mesh_pipeline_limits_mesh_64, !10, !21, !17} +!28 = !{void (%struct._mesh_t addrspace(7)*, i32)* @mesh_pipeline_limits_mesh_alone, !10, !29} +!29 = !{!22, !30} +!30 = !{i32 1, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!31 = !{!"air.compile.denorms_disable"} +!32 = !{!"air.compile.fast_math_enable"} +!33 = !{!"air.compile.framebuffer_fetch_enable"} +!34 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!35 = !{i32 2, i32 8, i32 0} +!36 = !{!"Metal", i32 4, i32 0, i32 0} +!37 = !{!38, !38, i64 0} +!38 = !{!"int", !39, i64 0} +!39 = !{!"omnipotent char", !40, i64 0} +!40 = !{!"Simple C++ TBAA"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.ll b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.ll new file mode 100644 index 000000000..f07cb72ef --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/mesh_pipeline_limits.ll @@ -0,0 +1,160 @@ +; Generated by scripts/regen-air-fixtures from mesh_pipeline_limits.metal (llvm-dis of mesh_pipeline_limits.air). Do not edit. +; ModuleID = '' +source_filename = "-" +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32" +target triple = "air64_v28-apple-macosx26.0.0" + +%struct.LimitsPayload = type { [4 x i32] } + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object(ptr addrspace(6) noundef writeonly align 4 captures(none) dereferenceable(16) %0, ptr addrspace(3) %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, ptr addrspace(6) %0, i64 0, i32 0, i64 0 + store i32 1, ptr addrspace(6) %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> splat (i32 1)) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object_64(ptr addrspace(6) noundef writeonly align 4 captures(none) dereferenceable(16) %0, ptr addrspace(3) %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, ptr addrspace(6) %0, i64 0, i32 0, i64 0 + store i32 1, ptr addrspace(6) %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> splat (i32 1)) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_object_grid_4(ptr addrspace(6) noundef writeonly align 4 captures(none) dereferenceable(16) %0, ptr addrspace(3) %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %7 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, ptr addrspace(6) %0, i64 0, i32 0, i64 0 + store i32 1, ptr addrspace(6) %6, align 4, !tbaa !37 + tail call void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none) %1, <3 x i32> splat (i32 1)) #5 + br label %7 + +7: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh(ptr addrspace(7) %0, ptr addrspace(6) noundef readonly align 4 captures(none) dereferenceable(16) %1, i32 noundef %2) local_unnamed_addr #2 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %9 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, ptr addrspace(6) %1, i64 0, i32 0, i64 0 + %7 = load i32, ptr addrspace(6) %6, align 4, !tbaa !37 + %8 = add i32 %7, -1 + tail call void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none) %0, i32 %8) #5 + br label %9 + +9: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh_64(ptr addrspace(7) %0, ptr addrspace(6) noundef readonly align 4 captures(none) dereferenceable(16) %1, i32 noundef %2) local_unnamed_addr #3 { + %4 = icmp eq i32 %2, 0 + br i1 %4, label %5, label %9 + +5: ; preds = %3 + %6 = getelementptr inbounds %struct.LimitsPayload, ptr addrspace(6) %1, i64 0, i32 0, i64 0 + %7 = load i32, ptr addrspace(6) %6, align 4, !tbaa !37 + %8 = add i32 %7, -1 + tail call void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none) %0, i32 %8) #5 + br label %9 + +9: ; preds = %5, %3 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +define void @mesh_pipeline_limits_mesh_alone(ptr addrspace(7) %0, i32 noundef %1) local_unnamed_addr #2 { + %3 = icmp eq i32 %1, 0 + br i1 %3, label %4, label %5 + +4: ; preds = %2 + tail call void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none) %0, i32 0) #5 + br label %5 + +5: ; preds = %4, %2 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn memory(argmem: readwrite) +declare void @air.set_threadgroups_per_grid_mesh_properties(ptr addrspace(3) captures(none), <3 x i32>) local_unnamed_addr #4 + +; Function Attrs: mustprogress nounwind willreturn memory(argmem: readwrite) +declare void @air.set_primitive_count_mesh(ptr addrspace(7) captures(none), i32) local_unnamed_addr #4 + +attributes #0 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #1 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="96" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #2 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #3 = { mustprogress nounwind willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "max-work-group-size"="64" "min-legal-vector-width"="0" "no-builtins" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="true" } +attributes #4 = { mustprogress nounwind willreturn memory(argmem: readwrite) } +attributes #5 = { nounwind willreturn memory(argmem: readwrite) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.object = !{!9, !16, !18} +!air.mesh = !{!20, !27, !28} +!air.compile_options = !{!31, !32, !33} +!llvm.ident = !{!34} +!air.version = !{!35} +!air.language_version = !{!36} + +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"frame-pointer", i32 2} +!3 = !{i32 7, !"air.max_device_buffers", i32 31} +!4 = !{i32 7, !"air.max_constant_buffers", i32 31} +!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31} +!6 = !{i32 7, !"air.max_textures", i32 128} +!7 = !{i32 7, !"air.max_read_write_textures", i32 8} +!8 = !{i32 7, !"air.max_samplers", i32 16} +!9 = !{ptr @mesh_pipeline_limits_object, !10, !11} +!10 = !{} +!11 = !{!12, !14, !15} +!12 = !{i32 0, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"LimitsPayload", !"air.arg_name", !"p"} +!13 = !{i32 0, i32 4, i32 4, !"uint", !"v"} +!14 = !{i32 1, !"air.mesh_grid_properties", !"air.arg_type_name", !"mesh_grid_properties", !"air.arg_name", !"g"} +!15 = !{i32 2, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!16 = !{ptr @mesh_pipeline_limits_object_64, !10, !11, !17} +!17 = !{!"air.max_work_group_size", i32 64} +!18 = !{ptr @mesh_pipeline_limits_object_grid_4, !10, !11, !19} +!19 = !{!"air.max_mesh_work_groups", i32 4} +!20 = !{ptr @mesh_pipeline_limits_mesh, !10, !21} +!21 = !{!22, !26, !15} +!22 = !{i32 0, !"air.mesh", !23, !"air.arg_type_name", !"mesh", !"air.arg_name", !"out"} +!23 = !{!"air.mesh_type_info", !24, !10, i32 3, i32 1, !"air.triangle"} +!24 = !{!25} +!25 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"} +!26 = !{i32 1, !"air.payload", !"air.struct_type_info", !13, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"LimitsPayload", !"air.arg_name", !"p"} +!27 = !{ptr @mesh_pipeline_limits_mesh_64, !10, !21, !17} +!28 = !{ptr @mesh_pipeline_limits_mesh_alone, !10, !29} +!29 = !{!22, !30} +!30 = !{i32 1, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!31 = !{!"air.compile.denorms_disable"} +!32 = !{!"air.compile.fast_math_enable"} +!33 = !{!"air.compile.framebuffer_fetch_enable"} +!34 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!35 = !{i32 2, i32 8, i32 0} +!36 = !{!"Metal", i32 4, i32 0, i32 0} +!37 = !{!38, !38, i64 0} +!38 = !{!"int", !39, i64 0} +!39 = !{!"omnipotent char", !40, i64 0} +!40 = !{!"Simple C++ TBAA"} diff --git a/docs/FAST-PATHS.md b/docs/FAST-PATHS.md index 2a466bed6..ee6496b04 100644 --- a/docs/FAST-PATHS.md +++ b/docs/FAST-PATHS.md @@ -682,8 +682,11 @@ driver's. Each is open work. pass every grid Metal runs). - **A mesh render pipeline's vertex amplification.** A mesh descriptor's `maxVertexAmplificationCount` above 1, which Metal makes, is refused - (`Unsupported{VertexAmplification, NotImplemented}`): no form runs an object or mesh function's - draw once per view, natively (`multiviewMeshShader`) or emulated. + (`Unsupported{VertexAmplification, NotImplemented}`). An M3 Max runs the object function once + for the draw and each mesh threadgroup once per amplification (`mesh_amplification.m`). No + form is built: a draw per amplification runs the object function again, and Vulkan multiview + may invoke a task shader once per view; an exact form runs the object stage once and the mesh + stage per amplification. - **An object threadgroup that sets a mesh grid Metal launches nothing for keeps its own writes.** On the M3 Max such a threadgroup's device writes (an atomic add before the set) do not land either, while the draw's other threadgroups run; the runtime runs the threadgroup and launches