diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index 877e0b781..8a543602d 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -309,6 +309,7 @@ fixture rfs_async_copy: metal: Apple metal version 32023.921 (metalfe-32023.921. fixture rfs_imageblock_cover: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture rfs_kernel_lod: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture rgbx_sample_half: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) +fixture rlm_runtime_limits: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture row_lockstep_tree: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture rrp_mirror_clamp: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture rrp_swizzled_storage: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.air.ll new file mode 100644 index 000000000..630a77a6c --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.air.ll @@ -0,0 +1,146 @@ +; Generated by scripts/regen-air-fixtures from rlm_runtime_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_v29-apple-macosx27.0.0" + +%struct.BufferMember = type { %"struct.metal::texture_buffer" } +%"struct.metal::texture_buffer" = type { %struct._texture_buffer_1d_t addrspace(1)* } +%struct._texture_buffer_1d_t = type opaque +%struct._sampler_t = type opaque +%struct.TextureMember = type { %"struct.metal::texture2d" } +%"struct.metal::texture2d" = type { %struct._texture_2d_t addrspace(1)* } +%struct._texture_2d_t = type opaque + +; Function Attrs: mustprogress nounwind willreturn +define void @rlm_fence_acq_rel(i32 addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %0, i32 addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = zext i32 %2 to i64 + %5 = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 %4 + %6 = load i32, i32 addrspace(1)* %5, align 4, !tbaa !32, !alias.scope !36, !noalias !39 + %7 = add i32 %6, 1 + %8 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %4 + store i32 %7, i32 addrspace(1)* %8, align 4, !tbaa !32, !alias.scope !39, !noalias !36 + tail call void @air.atomic.fence(i32 1, i32 4, i32 2) #5 + %9 = load i32, i32 addrspace(1)* %5, align 4, !tbaa !32, !alias.scope !36, !noalias !39 + %10 = shl i32 %9, 1 + %11 = add i32 %2, 8 + %12 = zext i32 %11 to i64 + %13 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %12 + store i32 %10, i32 addrspace(1)* %13, align 4, !tbaa !32, !alias.scope !39, !noalias !36 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @rlm_member_texture_buffer(%struct.BufferMember addrspace(1)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, <4 x float> addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = getelementptr inbounds %struct.BufferMember, %struct.BufferMember addrspace(1)* %0, i64 0, i32 0, i32 0 + %5 = load %struct._texture_buffer_1d_t addrspace(1)*, %struct._texture_buffer_1d_t addrspace(1)* addrspace(1)* %4, align 8, !tbaa !41, !alias.scope !44, !noalias !47 + %6 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #6 + %7 = tail call { <4 x float>, i8 } @air.read_texture_buffer_1d.v4f32(%struct._texture_buffer_1d_t addrspace(1)* nocapture readonly %5, %struct._sampler_t addrspace(2)* %6, i32 %2, i32 1) #7 + %8 = extractvalue { <4 x float>, i8 } %7, 0 + %9 = zext i32 %2 to i64 + %10 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %1, i64 %9 + store <4 x float> %8, <4 x float> addrspace(1)* %10, align 16, !tbaa !49, !alias.scope !47, !noalias !44 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @rlm_member_texture(%struct.TextureMember addrspace(1)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, <4 x float> addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = insertelement <2 x i32> , i32 %2, i64 0 + %5 = getelementptr inbounds %struct.TextureMember, %struct.TextureMember addrspace(1)* %0, i64 0, i32 0, i32 0 + %6 = load %struct._texture_2d_t addrspace(1)*, %struct._texture_2d_t addrspace(1)* addrspace(1)* %5, align 8, !tbaa !51, !alias.scope !54, !noalias !57 + %7 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #6 + %8 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(%struct._texture_2d_t addrspace(1)* nocapture readonly %6, %struct._sampler_t addrspace(2)* %7, <2 x i32> %4, <2 x i32> zeroinitializer, i32 0, i32 0) #7 + %9 = extractvalue { <4 x float>, i8 } %8, 0 + %10 = zext i32 %2 to i64 + %11 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %1, i64 %10 + store <4 x float> %9, <4 x float> addrspace(1)* %11, align 16, !tbaa !49, !alias.scope !57, !noalias !54 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.atomic.fence(i32, i32, i32) local_unnamed_addr #2 + +; Function Attrs: inaccessiblememonly mustprogress nofree nounwind readonly willreturn +declare %struct._sampler_t addrspace(2)* @air.get_read_sampler() local_unnamed_addr #3 + +; Function Attrs: argmemonly mustprogress nofree nounwind readonly willreturn +declare { <4 x float>, i8 } @air.read_texture_buffer_1d.v4f32(%struct._texture_buffer_1d_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, i32, i32) local_unnamed_addr #4 + +; Function Attrs: argmemonly mustprogress nofree nounwind readonly willreturn +declare { <4 x float>, i8 } @air.read_texture_2d.v4f32(%struct._texture_2d_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, <2 x i32>, <2 x i32>, i32, i32) local_unnamed_addr #4 + +attributes #0 = { 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 #1 = { mustprogress nofree nounwind 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 #2 = { mustprogress nounwind willreturn } +attributes #3 = { inaccessiblememonly mustprogress nofree nounwind readonly willreturn } +attributes #4 = { argmemonly mustprogress nofree nounwind readonly willreturn } +attributes #5 = { nounwind willreturn } +attributes #6 = { inaccessiblememonly nounwind readonly willreturn } +attributes #7 = { argmemonly nounwind readonly willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !15, !21} +!air.compile_options = !{!26, !27, !28} +!llvm.ident = !{!29} +!air.version = !{!30} +!air.language_version = !{!31} + +!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 (i32 addrspace(1)*, i32 addrspace(1)*, i32)* @rlm_fence_acq_rel, !10, !11} +!10 = !{} +!11 = !{!12, !13, !14} +!12 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"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", !"in"} +!13 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, 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"} +!14 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!15 = !{void (%struct.BufferMember addrspace(1)*, <4 x float> addrspace(1)*, i32)* @rlm_member_texture_buffer, !10, !16} +!16 = !{!17, !20, !14} +!17 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !18, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"BufferMember", !"air.arg_name", !"members"} +!18 = !{i32 0, i32 8, i32 0, !"texture_buffer", !"texels", !"air.indirect_argument", !19} +!19 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture_buffer", !"air.arg_name", !"texels"} +!20 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"out"} +!21 = !{void (%struct.TextureMember addrspace(1)*, <4 x float> addrspace(1)*, i32)* @rlm_member_texture, !10, !22} +!22 = !{!23, !20, !14} +!23 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !24, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"TextureMember", !"air.arg_name", !"members"} +!24 = !{i32 0, i32 8, i32 0, !"texture2d", !"texels", !"air.indirect_argument", !25} +!25 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d", !"air.arg_name", !"texels"} +!26 = !{!"air.compile.denorms_disable"} +!27 = !{!"air.compile.fast_math_enable"} +!28 = !{!"air.compile.framebuffer_fetch_enable"} +!29 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!30 = !{i32 2, i32 9, i32 0} +!31 = !{!"Metal", i32 4, i32 1, i32 0} +!32 = !{!33, !33, i64 0} +!33 = !{!"int", !34, i64 0} +!34 = !{!"omnipotent char", !35, i64 0} +!35 = !{!"Simple C++ TBAA"} +!36 = !{!37} +!37 = distinct !{!37, !38, !"air-alias-scope-arg(0)"} +!38 = distinct !{!38, !"air-alias-scopes(rlm_fence_acq_rel)"} +!39 = !{!40} +!40 = distinct !{!40, !38, !"air-alias-scope-arg(1)"} +!41 = !{!42, !43, i64 0} +!42 = !{!"_ZTSN5metal14texture_bufferIfLNS_6accessE1ELNS_16memory_coherenceE0EvEE", !43, i64 0} +!43 = !{!"__metal_texture_buffer_1d_t", !34, i64 0} +!44 = !{!45} +!45 = distinct !{!45, !46, !"air-alias-scope-arg(0)"} +!46 = distinct !{!46, !"air-alias-scopes(rlm_member_texture_buffer)"} +!47 = !{!48} +!48 = distinct !{!48, !46, !"air-alias-scope-arg(1)"} +!49 = !{!50, !50, i64 0} +!50 = !{!"float", !34, i64 0} +!51 = !{!52, !53, i64 0} +!52 = !{!"_ZTSN5metal9texture2dIfLNS_6accessE0ELNS_16memory_coherenceE0EvEE", !53, i64 0} +!53 = !{!"__metal_texture_2d_t", !34, i64 0} +!54 = !{!55} +!55 = distinct !{!55, !56, !"air-alias-scope-arg(0)"} +!56 = distinct !{!56, !"air-alias-scopes(rlm_member_texture)"} +!57 = !{!58} +!58 = distinct !{!58, !56, !"air-alias-scope-arg(1)"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.ll b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.ll new file mode 100644 index 000000000..f6b6946ac --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.ll @@ -0,0 +1,143 @@ +; Generated by scripts/regen-air-fixtures from rlm_runtime_limits.metal (llvm-dis of rlm_runtime_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_v29-apple-macosx27.0.0" + +%struct.BufferMember = type { %"struct.metal::texture_buffer" } +%"struct.metal::texture_buffer" = type { ptr addrspace(1) } +%struct.TextureMember = type { %"struct.metal::texture2d" } +%"struct.metal::texture2d" = type { ptr addrspace(1) } + +; Function Attrs: mustprogress nounwind willreturn +define void @rlm_fence_acq_rel(ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #0 { + %4 = zext i32 %2 to i64 + %5 = getelementptr inbounds i32, ptr addrspace(1) %0, i64 %4 + %6 = load i32, ptr addrspace(1) %5, align 4, !tbaa !32, !alias.scope !36, !noalias !39 + %7 = add i32 %6, 1 + %8 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %4 + store i32 %7, ptr addrspace(1) %8, align 4, !tbaa !32, !alias.scope !39, !noalias !36 + tail call void @air.atomic.fence(i32 1, i32 4, i32 2) #5 + %9 = load i32, ptr addrspace(1) %5, align 4, !tbaa !32, !alias.scope !36, !noalias !39 + %10 = shl i32 %9, 1 + %11 = add i32 %2, 8 + %12 = zext i32 %11 to i64 + %13 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %12 + store i32 %10, ptr addrspace(1) %13, align 4, !tbaa !32, !alias.scope !39, !noalias !36 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @rlm_member_texture_buffer(ptr addrspace(1) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = getelementptr inbounds %struct.BufferMember, ptr addrspace(1) %0, i64 0, i32 0, i32 0 + %5 = load ptr addrspace(1), ptr addrspace(1) %4, align 8, !tbaa !41, !alias.scope !44, !noalias !47 + %6 = tail call ptr addrspace(2) @air.get_read_sampler() #6 + %7 = tail call { <4 x float>, i8 } @air.read_texture_buffer_1d.v4f32(ptr addrspace(1) readonly captures(none) %5, ptr addrspace(2) %6, i32 %2, i32 1) #7 + %8 = extractvalue { <4 x float>, i8 } %7, 0 + %9 = zext i32 %2 to i64 + %10 = getelementptr inbounds <4 x float>, ptr addrspace(1) %1, i64 %9 + store <4 x float> %8, ptr addrspace(1) %10, align 16, !tbaa !49, !alias.scope !47, !noalias !44 + ret void +} + +; Function Attrs: mustprogress nofree nounwind willreturn +define void @rlm_member_texture(ptr addrspace(1) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #1 { + %4 = insertelement <2 x i32> , i32 %2, i64 0 + %5 = getelementptr inbounds %struct.TextureMember, ptr addrspace(1) %0, i64 0, i32 0, i32 0 + %6 = load ptr addrspace(1), ptr addrspace(1) %5, align 8, !tbaa !51, !alias.scope !54, !noalias !57 + %7 = tail call ptr addrspace(2) @air.get_read_sampler() #6 + %8 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(ptr addrspace(1) readonly captures(none) %6, ptr addrspace(2) %7, <2 x i32> %4, <2 x i32> zeroinitializer, i32 0, i32 0) #7 + %9 = extractvalue { <4 x float>, i8 } %8, 0 + %10 = zext i32 %2 to i64 + %11 = getelementptr inbounds <4 x float>, ptr addrspace(1) %1, i64 %10 + store <4 x float> %9, ptr addrspace(1) %11, align 16, !tbaa !49, !alias.scope !57, !noalias !54 + ret void +} + +; Function Attrs: mustprogress nounwind willreturn +declare void @air.atomic.fence(i32, i32, i32) local_unnamed_addr #2 + +; Function Attrs: mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) +declare ptr addrspace(2) @air.get_read_sampler() local_unnamed_addr #3 + +; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read) +declare { <4 x float>, i8 } @air.read_texture_buffer_1d.v4f32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), i32, i32) local_unnamed_addr #4 + +; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read) +declare { <4 x float>, i8 } @air.read_texture_2d.v4f32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), <2 x i32>, <2 x i32>, i32, i32) local_unnamed_addr #4 + +attributes #0 = { 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 #1 = { mustprogress nofree nounwind 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 #2 = { mustprogress nounwind willreturn } +attributes #3 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) } +attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) } +attributes #5 = { nounwind willreturn } +attributes #6 = { nounwind willreturn memory(inaccessiblemem: read) } +attributes #7 = { nounwind willreturn memory(argmem: read) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.kernel = !{!9, !15, !21} +!air.compile_options = !{!26, !27, !28} +!llvm.ident = !{!29} +!air.version = !{!30} +!air.language_version = !{!31} + +!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 @rlm_fence_acq_rel, !10, !11} +!10 = !{} +!11 = !{!12, !13, !14} +!12 = !{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"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", !"in"} +!13 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, 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"} +!14 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"} +!15 = !{ptr @rlm_member_texture_buffer, !10, !16} +!16 = !{!17, !20, !14} +!17 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !18, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"BufferMember", !"air.arg_name", !"members"} +!18 = !{i32 0, i32 8, i32 0, !"texture_buffer", !"texels", !"air.indirect_argument", !19} +!19 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture_buffer", !"air.arg_name", !"texels"} +!20 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"out"} +!21 = !{ptr @rlm_member_texture, !10, !22} +!22 = !{!23, !20, !14} +!23 = !{i32 0, !"air.indirect_buffer", !"air.buffer_size", i32 8, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !24, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"TextureMember", !"air.arg_name", !"members"} +!24 = !{i32 0, i32 8, i32 0, !"texture2d", !"texels", !"air.indirect_argument", !25} +!25 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d", !"air.arg_name", !"texels"} +!26 = !{!"air.compile.denorms_disable"} +!27 = !{!"air.compile.fast_math_enable"} +!28 = !{!"air.compile.framebuffer_fetch_enable"} +!29 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!30 = !{i32 2, i32 9, i32 0} +!31 = !{!"Metal", i32 4, i32 1, i32 0} +!32 = !{!33, !33, i64 0} +!33 = !{!"int", !34, i64 0} +!34 = !{!"omnipotent char", !35, i64 0} +!35 = !{!"Simple C++ TBAA"} +!36 = !{!37} +!37 = distinct !{!37, !38, !"air-alias-scope-arg(0)"} +!38 = distinct !{!38, !"air-alias-scopes(rlm_fence_acq_rel)"} +!39 = !{!40} +!40 = distinct !{!40, !38, !"air-alias-scope-arg(1)"} +!41 = !{!42, !43, i64 0} +!42 = !{!"_ZTSN5metal14texture_bufferIfLNS_6accessE1ELNS_16memory_coherenceE0EvEE", !43, i64 0} +!43 = !{!"__metal_texture_buffer_1d_t", !34, i64 0} +!44 = !{!45} +!45 = distinct !{!45, !46, !"air-alias-scope-arg(0)"} +!46 = distinct !{!46, !"air-alias-scopes(rlm_member_texture_buffer)"} +!47 = !{!48} +!48 = distinct !{!48, !46, !"air-alias-scope-arg(1)"} +!49 = !{!50, !50, i64 0} +!50 = !{!"float", !34, i64 0} +!51 = !{!52, !53, i64 0} +!52 = !{!"_ZTSN5metal9texture2dIfLNS_6accessE0ELNS_16memory_coherenceE0EvEE", !53, i64 0} +!53 = !{!"__metal_texture_2d_t", !34, i64 0} +!54 = !{!55} +!55 = distinct !{!55, !56, !"air-alias-scope-arg(0)"} +!56 = distinct !{!56, !"air-alias-scopes(rlm_member_texture)"} +!57 = !{!58} +!58 = distinct !{!58, !56, !"air-alias-scope-arg(1)"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.metal b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.metal new file mode 100644 index 000000000..d4f661262 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/rlm_runtime_limits.metal @@ -0,0 +1,45 @@ +// metal-std: metal4.1 +// metal-macos-min: 27.0 +// Owned fixture: shapes of the validation requirements whose limit is the runtime's typed refusal +// (`Limit::Runtime`), each beside the same shape without it, so a device test holds the refusal +// both ways: the runtime refuses the first of a pair at its pipeline's make and makes the second. +// +// * rlm_fence_acq_rel: a4_device_fence's two stores, out[t] = in[t] + 1 and out[t + 8] = 2 in[t] +// for eight threads, around a device-scope fence of `acq_rel` order, which the translator +// orders without the execution status word; a4_device_fence's `seq_cst` fence is the shape +// `seq_cst_fence` names. +// * rlm_member_texture_buffer: thread t reads texel t of a texture buffer an argument buffer +// holds, the shape `texture_buffer_member` names; rlm_member_texture: the same read of a 2D +// texture the argument buffer holds, texel (t, 0). +// +// Loop-free. +#include +using namespace metal; + +kernel void rlm_fence_acq_rel(device const uint *in [[buffer(0)]], + device uint *out [[buffer(1)]], + uint t [[thread_position_in_grid]]) { + out[t] = in[t] + 1u; + atomic_thread_fence(mem_flags::mem_device, memory_order_acq_rel, thread_scope_device); + out[t + 8u] = in[t] * 2u; +} + +struct BufferMember { + texture_buffer texels [[id(0)]]; +}; + +struct TextureMember { + texture2d texels [[id(0)]]; +}; + +kernel void rlm_member_texture_buffer(device const BufferMember &members [[buffer(0)]], + device float4 *out [[buffer(1)]], + uint t [[thread_position_in_grid]]) { + out[t] = members.texels.read(t); +} + +kernel void rlm_member_texture(device const TextureMember &members [[buffer(0)]], + device float4 *out [[buffer(1)]], + uint t [[thread_position_in_grid]]) { + out[t] = members.texels.read(uint2(t, 0u)); +} diff --git a/crates/metal2vulkan-validation/src/bin/corpus-triage.rs b/crates/metal2vulkan-validation/src/bin/corpus-triage.rs index 3d7860c8a..8c7d80011 100644 --- a/crates/metal2vulkan-validation/src/bin/corpus-triage.rs +++ b/crates/metal2vulkan-validation/src/bin/corpus-triage.rs @@ -596,9 +596,10 @@ fn audit_authoring_capabilities( } println!("{}", cases.report_line()); // The census covers indexed rows, one per entry of every module. Rows Metal itself cannot build - // are closed without a reference and counted apart. + // are closed without a reference, and rows the runtime refuses, typed, without a candidate + // run; each is counted apart. println!( - "authoring-capability-summary\tselected={}\ttotal={}\tclassified={}\tremaining={}\tunresolved={}\tindex_select_ms={}\tclassify_cache_ms={}\tsource_shards_opened={}\tsource_bytes_read={}\trepair_shards_scanned={}\trepair_bytes_scanned={}\tmetal_refused={}", + "authoring-capability-summary\tselected={}\ttotal={}\tclassified={}\tremaining={}\tunresolved={}\tindex_select_ms={}\tclassify_cache_ms={}\tsource_shards_opened={}\tsource_bytes_read={}\trepair_shards_scanned={}\trepair_bytes_scanned={}\tmetal_refused={}\truntime_refused={}", selected, summary.total_sources, summary.classified_sources, @@ -611,6 +612,7 @@ fn audit_authoring_capabilities( read_stats.repair_shards_scanned, read_stats.repair_bytes_scanned, summary.metal_refused_sources, + summary.runtime_refused_sources, ); // Each requirement with the executors it stops and whose limit it is; a tooling requirement // makes its rows unresolved. @@ -626,11 +628,12 @@ fn audit_authoring_capabilities( requirement.limit() ); } - // An executor's tooling gaps keep the census open; Metal's own refusals are closed. + // An executor's tooling gaps keep the census open; Metal's own refusals and the runtime's + // typed ones are closed. for (executor, stops) in &summary.executor_stops { println!( - "authoring-executor-stops\t{executor}\t{}\ttooling_gap={}\tmetal_refused={}", - stops.sources, stops.tooling_gap, stops.metal_refused, + "authoring-executor-stops\t{executor}\t{}\ttooling_gap={}\tmetal_refused={}\truntime_refused={}", + stops.sources, stops.tooling_gap, stops.metal_refused, stops.runtime_refused, ); } // Authorable, not unresolved: these rows' cases do not evidence the named effect. diff --git a/crates/metal2vulkan-validation/src/candidate/platform.rs b/crates/metal2vulkan-validation/src/candidate/platform.rs index b34318004..286455bb3 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform.rs @@ -27,6 +27,8 @@ pub use device::{requested_leg, run_robustness_off}; pub use profiles::{requested_restriction, restrict_devices_to}; pub use render::execute_engine_render; pub use runtime::execute_runtime; +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd), target_os = "linux"))] +pub use runtime::{make_kernel, on_runtime_device}; pub use runtime_probe::probe_runtime; /// Whether the profiles layer can present committed profile `stem` ([`profiles::presentable`]). diff --git a/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs b/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs index d5df4b319..3fbbe8b8f 100644 --- a/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs +++ b/crates/metal2vulkan-validation/src/candidate/platform/runtime.rs @@ -130,12 +130,38 @@ fn on_device( case: &ComputeCase, kernel: &RuntimeKernel<'_>, ) -> Result { + opened(device_type, |device, identity, environment| { + let result = run( + device, + device_type, + case_id, + case, + kernel, + identity, + environment, + ); + let refused_on = matches!(result, Err(ExecutorError::NotSupported(_))).then(|| RefusedOn { + environment: environment.clone(), + translator_fingerprint: runtime_fingerprint(), + artifact: None, + }); + RunAttempt { result, refused_on } + }) +} + +/// `body` on the runtime's device of `device_type`, with the identity and environment a row +/// records of it, every object of it gone before this returns, and the device torn down. `Err` +/// where no device of the kind opens under the layer. +fn opened( + device_type: DeviceType, + body: impl FnOnce(&rt::Device, &Identity, &serde_json::Value) -> T, +) -> Result { if device_type == DeviceType::Gpu { crate::gpu::tripwire::refuse_if_tripped()?; } let instance = rt::Instance::new(&[]).map_err(|error| format!("the runtime's instance: {error}"))?; - let attempt = { + let value = { let (physical, identity) = select(&instance, device_type)?; let (entry, vk_instance) = instance.raw(); // SAFETY: `physical` is one of the instance's physical devices, and the instance is live. @@ -150,21 +176,7 @@ fn on_device( let environment = environment(&identity, &tools); let device = metal2vulkan_runtime::Device::new(&physical, rt::DeviceOptions::default()) .map_err(|error| format!("the runtime's device on {}: {error}", identity.device))?; - let result = run( - &device, - device_type, - case_id, - case, - kernel, - &identity, - &environment, - ); - let refused_on = matches!(result, Err(ExecutorError::NotSupported(_))).then(|| RefusedOn { - environment: environment.clone(), - translator_fingerprint: runtime_fingerprint(), - artifact: None, - }); - RunAttempt { result, refused_on } + body(&device, &identity, &environment) }; if !instance.wait_until_devices_torn_down(TEARDOWN) { return Err(format!( @@ -172,7 +184,51 @@ fn on_device( TEARDOWN.as_secs() )); } - Ok(attempt) + Ok(value) +} + +/// `body` on the runtime's device of `device_type` under the validation layer, as a run opens it +/// ([`execute_runtime`]): what a device test needs of the runtime's answer to one call, beside a +/// run. `Err` where no device of the kind opens, or where the layer reported a message. +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd), target_os = "linux"))] +pub fn on_runtime_device( + device_type: DeviceType, + body: impl FnOnce(&rt::Device) -> T, +) -> Result { + let log = std::env::temp_dir().join(format!( + "metal2vulkan-validation-runtime-{}.log", + std::process::id() + )); + let _ = std::fs::remove_file(&log); + validate_process(&log); + let value = opened(device_type, |device, _, _| body(device)); + let messages = std::fs::read_to_string(&log); + let _ = std::fs::remove_file(&log); + match messages { + Ok(messages) if !messages.trim().is_empty() => Err(format!( + "{VALIDATION_LAYER} reported messages: {}", + crate::engine::bounded_detail(&messages) + )), + _ => value, + } +} + +/// The make of `entry`'s compute pipeline state from `bitcode` on `device`, as a run makes it +/// ([`make`]) with no constant and no linked function: the runtime's typed refusal as the +/// product's ([`product_refusal`]). +#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd), target_os = "linux"))] +pub fn make_kernel( + device: &rt::Device, + bitcode: &[u8], + entry: &str, +) -> Result { + let function = Library::from_air(bitcode) + .and_then(|library| library.function(entry)) + .map_err(|error| product_refusal(&error))?; + let descriptor = ComputePipelineDescriptor::new(StageSource::Function( + FunctionDescriptor::new(function).with_specialized(true), + )); + make(device, &descriptor) } /// What a row records of the device that ran it. diff --git a/crates/metal2vulkan-validation/src/candidate/tests/engine_compute.rs b/crates/metal2vulkan-validation/src/candidate/tests/engine_compute.rs index 6e4f6ffa6..61eec88b4 100644 --- a/crates/metal2vulkan-validation/src/candidate/tests/engine_compute.rs +++ b/crates/metal2vulkan-validation/src/candidate/tests/engine_compute.rs @@ -632,3 +632,87 @@ fn a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says() { "{error}" ); } + +/// The other way of [`a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says`]: +/// the owned fixture `rlm_runtime_limits`'s `rlm_fence_acq_rel` holds the same two stores around a +/// device-scope fence of `acq_rel` order, which carries no `ToolingRequirement::SeqCstFence`, and +/// the runtime makes and runs it: its words are the stores'. +#[cfg(target_os = "linux")] +#[test] +fn a_fence_of_another_order_is_made_through_the_runtime() { + let bitcode = llvm_assemble(&engine_dir().join("rlm_runtime_limits.ll")).unwrap(); + let threads = Dispatch::Threads { + threads: [8, 1, 1], + threads_per_group: [8, 1, 1], + }; + let input = (0..8u32).map(|t| t * 3 + 1).collect::>(); + let mut fence = case( + "rlm_fence_acq_rel", + input.iter().flat_map(|word| word.to_le_bytes()).collect(), + threads, + ); + fence.buffers.insert(1, vec![0; 64]); + fence.output = ComputeOutput::Buffer { + binding: 1, + offset: 0, + length: 64, + }; + let output = run_on_runtime(&fence, &bitcode, &[]).unwrap().output; + let expected = input + .iter() + .map(|word| word + 1) + .chain(input.iter().map(|word| word * 2)) + .flat_map(u32::to_le_bytes) + .collect::>(); + assert_eq!(output, expected); +} + +/// `ToolingRequirement::TextureBufferMember`'s limit at the texture, both ways: the runtime makes +/// no texture buffer, so `new_texture` refuses one, typed (`Gap::TextureBuffer`), where it makes a +/// 2D texture of the same format and width. The day the runtime makes one, this fails. +#[cfg(target_os = "linux")] +#[test] +fn a_texture_buffer_is_refused_where_a_2d_texture_is_made() { + use metal2vulkan_runtime as rt; + platform::on_runtime_device(crate::gpu::TEST_DEVICE, |device| { + let made = |texture_type| { + let descriptor = + rt::TextureDescriptor::new(texture_type, rt::PixelFormat::RGBA32Float, 16, 1); + device.new_texture(&descriptor, None).map(drop) + }; + let refused = made(rt::TextureType::TextureBuffer); + assert!( + matches!(refused, Err(rt::Error::Unsupported(rt::Gap::TextureBuffer))), + "{refused:?}" + ); + made(rt::TextureType::Type2D).unwrap(); + }) + .unwrap(); +} + +/// `ToolingRequirement::TextureBufferMember`'s limit at the pipeline, both ways: the runtime's +/// identity domains hold no texture buffer among an argument buffer's textures, so the make of +/// `rlm_runtime_limits`'s `rlm_member_texture_buffer`, which reads one, is refused, typed +/// (`Unsupported{IdentityDomains}`), where the same read of a 2D texture the argument buffer holds, +/// `rlm_member_texture`, is made. The day the runtime makes the first, this fails. +#[cfg(target_os = "linux")] +#[test] +fn a_texture_buffer_member_is_refused_at_the_make_where_a_2d_member_is_made() { + use crate::check::admission::NotSupported; + use metal2vulkan::error::{Feature, Unsupported}; + let bitcode = llvm_assemble(&engine_dir().join("rlm_runtime_limits.ll")).unwrap(); + let identity_domains = crate::engine::Outcome::from(&metal2vulkan::error::Error::from( + Unsupported::not_implemented(Feature::IdentityDomains), + )); + platform::on_runtime_device(crate::gpu::TEST_DEVICE, |device| { + match platform::make_kernel(device, &bitcode, "rlm_member_texture_buffer") { + Err(ExecutorError::NotSupported(NotSupported::Product { outcome, .. })) => { + assert_eq!(outcome, identity_domains) + } + Err(error) => panic!("not the identity domains' refusal: {error}"), + Ok(_) => panic!("the runtime made a texture buffer member's pipeline"), + } + platform::make_kernel(device, &bitcode, "rlm_member_texture").unwrap(); + }) + .unwrap(); +} diff --git a/crates/metal2vulkan-validation/src/requirement.rs b/crates/metal2vulkan-validation/src/requirement.rs index efbbd9a42..c60efa00b 100644 --- a/crates/metal2vulkan-validation/src/requirement.rs +++ b/crates/metal2vulkan-validation/src/requirement.rs @@ -40,6 +40,15 @@ pub enum Limit { /// every executor (no case can be qualified), and its rows are classified and closed without a /// reference: the census counts them apart and never as unresolved. Metal, + /// `metal2vulkan-runtime` answers the structure with a typed refusal, or offers no call for it + /// and the consumer refuses it itself (its README's known gaps): the Metal oracle runs it, the + /// engine's candidate refuses it, typed, and its rows are classified and closed without a + /// candidate run, counted apart and never as unresolved. A device test holds each such + /// requirement to the refusal both ways on lavapipe where the runtime has a call for it: the + /// shape the requirement's check accepts gets the named refusal, and the same shape without it + /// is made. The day the runtime builds the shape that test fails, and the limit goes back to + /// [`Limit::Tooling`] while the executor's support is built. + Runtime, } impl Limit { @@ -47,6 +56,7 @@ impl Limit { match self { Self::Tooling => "tooling", Self::Metal => "metal", + Self::Runtime => "runtime", } } } @@ -77,11 +87,15 @@ pub enum ToolingRequirement { KernelStageInputLiteral, /// A texture buffer that is no entry parameter of its own: one an argument buffer holds, or an /// element of a texture-handle array (`executor_contract`). The engine's candidate runs - /// neither. It reaches an argument buffer's textures through the binder's planned heap, which - /// makes no texture buffer a member, so a handle naming one misses. No case runs a - /// texture-buffer array on it, and the runtime makes no texture buffer - /// (`metal2vulkan_runtime::Gap::TextureBuffer`). The Metal oracle makes and binds both, - /// so a case of either stays Metal-qualified ([`Self::qualifies_on_metal`]). + /// neither. The runtime makes no texture buffer (`metal2vulkan_runtime::Gap::TextureBuffer` + /// at `new_texture`), and its identity domains hold no texture buffer among an argument + /// buffer's textures, so it refuses such a function's pipeline at its make + /// (`Unsupported{IdentityDomains}`): the limit is the runtime's ([`Limit::Runtime`]), held + /// both ways by the device tests + /// `candidate::tests::engine_compute::a_texture_buffer_is_refused_where_a_2d_texture_is_made` + /// and `..::a_texture_buffer_member_is_refused_at_the_make_where_a_2d_member_is_made`. The + /// Metal oracle makes and binds both, so a case of either stays Metal-qualified + /// ([`Self::qualifies_on_metal`]). TextureBufferMember, StorageTextureFormatLiteral, ImplicitImageblockLiteral, @@ -131,7 +145,12 @@ pub enum ToolingRequirement { /// executing device raises it, never a source's structure, so no census row carries it. DepthOutsideUnitRange, /// An object or mesh function's row or case (`executor_contract::mesh`), or a case that runs a - /// pipeline template of one: the engine's candidate draws no mesh render pipeline. The Metal + /// pipeline template of one: the engine's candidate draws no mesh render pipeline. The runtime + /// has no mesh call: it makes no mesh render pipeline state and records no mesh draw, and the + /// consumer refuses mesh pipelines itself (`crates/metal2vulkan-runtime/README.md`, its known + /// gaps), so the limit is the runtime's ([`Limit::Runtime`]) with no call to hold a device + /// test to; that README sentence is its guard. When a guest uses a mesh pipeline it is built + /// natively with its call, and the limit goes back to [`Limit::Tooling`] then. The Metal /// oracle draws it, so a case of it stays Metal-qualified ([`Self::qualifies_on_metal`]), and /// the authored compile census still compiles an object or mesh case's pipeline /// (`engine::prepare_compile`). @@ -148,9 +167,11 @@ pub enum ToolingRequirement { /// memory scope is the device. The translator orders such a fence with the command buffer's /// other ones through an atomic on its execution status word, which the runtime's identity /// domains do not reach: the runtime refuses the pipeline (`Unsupported{IdentityDomains}`, - /// naming the `ExecutionStatusAddress` encoder value), so the engine's candidate does not run - /// the case. The Metal oracle runs it, so a case of it stays Metal-qualified - /// ([`Self::qualifies_on_metal`]). + /// naming the `ExecutionStatusAddress` encoder value), so the limit is the runtime's + /// ([`Limit::Runtime`]) and the engine's candidate does not run the case. The device tests + /// `candidate::tests::engine_compute::a_seq_cst_fence_is_refused_through_the_runtime_as_its_requirement_says` + /// and `..::a_fence_of_another_order_is_made_through_the_runtime` hold it both ways. The Metal + /// oracle runs it, so a case of it stays Metal-qualified ([`Self::qualifies_on_metal`]). SeqCstFence, } @@ -290,10 +311,14 @@ impl ToolingRequirement { /// Whose limit this requirement records. Every requirement is this crate's tooling's except /// [`ToolingRequirement::KernelMinLodClamp`], which Apple's compiler cannot build a pipeline - /// for. + /// for, and [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::TextureBufferMember`] + /// and [`ToolingRequirement::MeshRenderPipeline`], which the runtime refuses. pub const fn limit(self) -> Limit { match self { Self::KernelMinLodClamp => Limit::Metal, + Self::SeqCstFence | Self::TextureBufferMember | Self::MeshRenderPipeline => { + Limit::Runtime + } _ => Limit::Tooling, } } @@ -306,7 +331,8 @@ impl ToolingRequirement { /// Whether a row carrying this requirement keeps the authoring-capability census open: it is /// a tooling gap ([`Limit::Tooling`]), and every requirement stops an executor the census /// closes on. A [`Limit::Metal`] requirement closes its row without a reference: no tooling - /// can give Metal an answer its compiler cannot build. + /// can give Metal an answer its compiler cannot build. A [`Limit::Runtime`] requirement closes + /// its row without a candidate run: the product refuses the structure, typed. pub fn blocks_closure(self) -> bool { self.limit() == Limit::Tooling } @@ -420,9 +446,9 @@ mod tests { } /// The mesh render pipeline's requirements: a stage nothing generates stops both executors - /// (`mesh_companion`), and the engine's candidate draws none (`mesh_render_pipeline`), whose - /// cases stay Metal-qualified. Both are this crate's gaps, never Metal's, which keep the census - /// open. + /// (`mesh_companion`), this crate's gap, which keeps the census open; and the engine's + /// candidate draws none (`mesh_render_pipeline`), whose cases stay Metal-qualified, the + /// runtime's limit (it has no mesh call), which closes its rows. #[test] fn mesh_requirements_stop_the_executors_that_do_not_draw_them_yet() { let requirement = ToolingRequirement::MeshCompanion; @@ -432,7 +458,8 @@ mod tests { assert!(!requirement.qualifies_on_metal(), "{requirement}"); let requirement = ToolingRequirement::MeshRenderPipeline; assert_eq!(requirement.stops(), [Executor::EngineCandidate]); - assert!(requirement.blocks_closure(), "{requirement}"); + assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}"); + assert!(!requirement.blocks_closure(), "{requirement}"); assert!(requirement.qualifies_on_metal(), "{requirement}"); assert_eq!( ToolingRequirement::ALL @@ -448,14 +475,14 @@ mod tests { } /// A texture buffer an argument buffer or a texture-handle array holds: a case expresses it - /// and the Metal oracle runs it, so its cases stay Metal-qualified; the engine's candidate runs - /// none, a tooling gap that keeps the census open. + /// and the Metal oracle runs it, so its cases stay Metal-qualified; the runtime refuses it, so + /// the engine's candidate runs none, the runtime's limit, which closes its rows. #[test] fn a_texture_buffer_member_stops_only_the_candidate() { let requirement = ToolingRequirement::TextureBufferMember; assert_eq!(requirement.stops(), [Executor::EngineCandidate]); - assert_eq!(requirement.limit(), Limit::Tooling, "{requirement}"); - assert!(requirement.blocks_closure(), "{requirement}"); + assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}"); + assert!(!requirement.blocks_closure(), "{requirement}"); assert!(requirement.qualifies_on_metal(), "{requirement}"); assert!("texture_buffer_literal" .parse::() @@ -463,14 +490,14 @@ mod tests { } /// A sequentially consistent fence: the Metal oracle runs it, so its cases stay - /// Metal-qualified; the runtime refuses it, so the engine's candidate runs none, a tooling gap - /// that keeps the census open. + /// Metal-qualified; the runtime refuses it, so the engine's candidate runs none, the runtime's + /// limit, which closes its rows. #[test] fn a_seq_cst_fence_stops_only_the_candidate() { let requirement = ToolingRequirement::SeqCstFence; assert_eq!(requirement.stops(), [Executor::EngineCandidate]); - assert_eq!(requirement.limit(), Limit::Tooling, "{requirement}"); - assert!(requirement.blocks_closure(), "{requirement}"); + assert_eq!(requirement.limit(), Limit::Runtime, "{requirement}"); + assert!(!requirement.blocks_closure(), "{requirement}"); assert!(requirement.qualifies_on_metal(), "{requirement}"); assert_eq!("seq_cst_fence".parse(), Ok(requirement)); } @@ -478,7 +505,7 @@ mod tests { /// Every requirement stops some executor, and an executor's name is as stable as a /// requirement's. A requirement that stops the Metal oracle stops every executor: when Metal /// cannot run a case, no candidate has an observation to be compared with. Only a tooling gap - /// keeps the census open. + /// keeps the census open; the runtime's limit stops the candidate alone. #[test] fn every_requirement_stops_an_executor_and_a_metal_stop_is_an_authoring_stop() { for requirement in ToolingRequirement::ALL { @@ -498,6 +525,11 @@ mod tests { assert_eq!(stops, Executor::ALL, "{requirement}"); assert!(!requirement.blocks_closure(), "{requirement}"); } + Limit::Runtime => { + assert_eq!(stops, [Executor::EngineCandidate], "{requirement}"); + assert!(requirement.qualifies_on_metal(), "{requirement}"); + assert!(!requirement.blocks_closure(), "{requirement}"); + } Limit::Tooling => assert!(requirement.blocks_closure(), "{requirement}"), } } @@ -508,6 +540,17 @@ mod tests { .collect::>(), [ToolingRequirement::KernelMinLodClamp] ); + assert_eq!( + ToolingRequirement::ALL + .into_iter() + .filter(|requirement| requirement.limit() == Limit::Runtime) + .collect::>(), + [ + ToolingRequirement::TextureBufferMember, + ToolingRequirement::MeshRenderPipeline, + ToolingRequirement::SeqCstFence + ] + ); for executor in Executor::ALL { assert_eq!( serde_json::to_string(&executor).unwrap(), diff --git a/crates/metal2vulkan-validation/src/triage.rs b/crates/metal2vulkan-validation/src/triage.rs index 1c5d64595..a7264eb48 100644 --- a/crates/metal2vulkan-validation/src/triage.rs +++ b/crates/metal2vulkan-validation/src/triage.rs @@ -14,7 +14,7 @@ use std::path::Path; /// bumps it says what changed; this comment keeps no history. macro_rules! analyzer_version { () => { - "structural-triage-v84" + "structural-triage-v85" }; } @@ -168,6 +168,10 @@ pub struct AuthoringCapabilitySummary { /// [`Limit::Metal`]): closed without a Metal reference, and unresolved only when a tooling gap /// of their own keeps them open. pub metal_refused_sources: usize, + /// Classified sources the runtime refuses, typed (a requirement whose limit is + /// [`Limit::Runtime`]): closed without a candidate run, and unresolved only when a tooling gap + /// of their own keeps them open. + pub runtime_refused_sources: usize, pub requirements: BTreeMap, /// The classified sources each executor cannot run, and whose limit stops it (an executor that /// no requirement stops is absent). @@ -189,6 +193,9 @@ pub struct ExecutorStops { /// Those with a requirement whose limit is Metal's own ([`Limit::Metal`]): closed without a /// reference, unless a tooling gap of their own keeps them open. pub metal_refused: usize, + /// Those with a requirement whose limit is the runtime's typed refusal ([`Limit::Runtime`]): + /// closed without a candidate run, unless a tooling gap of their own keeps them open. + pub runtime_refused: usize, } impl AuthoringCapabilitySummary { @@ -389,24 +396,29 @@ pub fn authoring_capability_summary(index: &Path) -> Result(0), + ) + .map_err(|error| format!("count sources {what}: {error}")) + }; + let metal_refused_sources = limited(Limit::Metal, "Metal cannot build")?; + let runtime_refused_sources = limited(Limit::Runtime, "the runtime refuses")?; let mut executor_stops = BTreeMap::new(); for executor in Executor::ALL { let stopping = |limit: Option| { @@ -426,11 +438,13 @@ pub fn authoring_capability_summary(index: &Path) -> Result Result Result SourceRow { diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 9c97c603f..35b063b8c 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -373,7 +373,7 @@ worker under the 20-second and 500-MiB ceilings, resumable in bounded batches (` | Audit | What it answers | |---|---| -| `authoring-capabilities [--reclassify-all]` | For every indexed AIR identity, whether a case can express and both executors can run its structure (`ToolingRequirement`s). Closed only when `classified == total`, `remaining == 0` and `unresolved == 0`; a warm rerun reads no source shard | +| `authoring-capabilities [--reclassify-all]` | For every indexed AIR identity, whether a case can express and both executors can run its structure (`ToolingRequirement`s). Closed only when `classified == total`, `remaining == 0` and `unresolved == 0`; a warm rerun reads no source shard. A row Metal cannot build (`metal_refused`) or the runtime refuses, typed (`runtime_refused`: a requirement whose limit is `Limit::Runtime`, each held both ways by a lavapipe device test where the runtime has a call for it, mesh pipelines by the runtime README's known gap) is closed without that executor's run and counted apart; a tooling gap of its own still keeps it open | | `translation --profile P...` | Each row translated for each committed profile, recorded as a typed outcome class under the current product fingerprint (`--current-fingerprint`, `--retry-failures`, `--hash-file PATH` select rows). A fragment function of more colors than the profile draws at once is translated as its render pipeline's color groups, one module a group, each checked by L3. It fails when a row breaks a ceiling | | `budgets --profile P...` | The budget gates from recorded rows: no row above 20 s or 500 MiB, no stopped worker, and each row's ledger peak at least 0.7 of its allocator peak | | `specialization --profile P...` | Rows translated under planned function-constant value sets and the pipeline inputs their AIR states, not only with none |