diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN index 4eab88507..6d9520ee8 100644 --- a/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN +++ b/crates/metal2vulkan-validation/fixtures/public/engine/TOOLCHAIN @@ -94,6 +94,7 @@ fixture fbl_fetch_blend8: metal: Apple metal version 32023.921 (metalfe-32023.92 fixture fbl_fetch_blend8_safe: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture fbl_fetch_dual: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture fc_float_gate: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) +fixture fc_half_gate: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture fc_ushort3_half3: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118) fixture fca_fragment_absent_inputs: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) fixture fca_kernel_absent_builtin: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425) diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.air.ll b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.air.ll new file mode 100644 index 000000000..b9e64999d --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.air.ll @@ -0,0 +1,66 @@ +; Generated by scripts/regen-air-fixtures from fc_half_gate.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" + +@_Z1s.MTL_FC_INIT_0_Dh = linkonce_odr hidden local_unnamed_addr addrspace(2) externally_initialized constant half undef, section "air.fc_initializer", align 2 +@__metal_implicit_fc_pred_0 = internal addrspace(2) global half 0xH0000, align 2 +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }] +@llvm.compiler.used = appending global [1 x i8*] [i8* addrspacecast (i8 addrspace(2)* bitcast (half addrspace(2)* @__metal_implicit_fc_pred_0 to i8 addrspace(2)*) to i8*)], section "llvm.metadata" + +; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn +define <{ <4 x float>, i32 }> @fch_gated_sample_mask() local_unnamed_addr #0 { + ret <{ <4 x float>, i32 }> <{ <4 x float> , i32 0 }> +} + +; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn +declare half @air.normalize_function_constant_predicate.f16(half) local_unnamed_addr #1 + +; Function Attrs: mustprogress nofree nosync nounwind willreturn +define internal void @_GLOBAL__sub_I__() #2 section "air.static_init" { + %1 = load half, half addrspace(2)* @_Z1s.MTL_FC_INIT_0_Dh, align 2, !tbaa !22 + %2 = tail call half @air.normalize_function_constant_predicate.f16(half %1) #3 + store half %2, half addrspace(2)* @__metal_implicit_fc_pred_0, align 2 + ret void +} + +attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +attributes #1 = { mustprogress nofree nosync nounwind readnone willreturn } +attributes #2 = { mustprogress nofree nosync nounwind willreturn "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +attributes #3 = { nounwind readnone willreturn } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.fragment = !{!9} +!air.compile_options = !{!15, !16, !17} +!air.function_constants = !{!18} +!llvm.ident = !{!19} +!air.version = !{!20} +!air.language_version = !{!21} + +!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 = !{<{ <4 x float>, i32 }> ()* @fch_gated_sample_mask, !10, !14} +!10 = !{!11, !12} +!11 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4", !"air.arg_name", !"color"} +!12 = !{!"air.function_constant", !13, !"air.sample_mask", !"air.arg_type_name", !"uint", !"air.arg_name", !"mask"} +!13 = !{half addrspace(2)* @__metal_implicit_fc_pred_0, !"half", !"s"} +!14 = !{} +!15 = !{!"air.compile.denorms_disable"} +!16 = !{!"air.compile.fast_math_disable"} +!17 = !{!"air.compile.framebuffer_fetch_enable"} +!18 = !{half addrspace(2)* @_Z1s.MTL_FC_INIT_0_Dh, !"half", !"s", i32 0} +!19 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!20 = !{i32 2, i32 8, i32 0} +!21 = !{!"Metal", i32 4, i32 0, i32 0} +!22 = !{!23, !23, i64 0} +!23 = !{!"half", !24, i64 0} +!24 = !{!"omnipotent char", !25, i64 0} +!25 = !{!"Simple C++ TBAA"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.ll b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.ll new file mode 100644 index 000000000..1fb7c0453 --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.ll @@ -0,0 +1,66 @@ +; Generated by scripts/regen-air-fixtures from fc_half_gate.metal (llvm-dis of fc_half_gate.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" + +@_Z1s.MTL_FC_INIT_0_Dh = linkonce_odr hidden local_unnamed_addr addrspace(2) externally_initialized constant half undef, section "air.fc_initializer", align 2 +@__metal_implicit_fc_pred_0 = internal addrspace(2) global half 0xH0000, align 2 +@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I__, ptr null }] +@llvm.compiler.used = appending global [1 x ptr] [ptr addrspacecast (ptr addrspace(2) @__metal_implicit_fc_pred_0 to ptr)], section "llvm.metadata" + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) +define <{ <4 x float>, i32 }> @fch_gated_sample_mask() local_unnamed_addr #0 { + ret <{ <4 x float>, i32 }> <{ <4 x float> , i32 0 }> +} + +; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) +declare half @air.normalize_function_constant_predicate.f16(half) local_unnamed_addr #1 + +; Function Attrs: mustprogress nofree nosync nounwind willreturn +define internal void @_GLOBAL__sub_I__() #2 section "air.static_init" { + %1 = load half, ptr addrspace(2) @_Z1s.MTL_FC_INIT_0_Dh, align 2, !tbaa !22 + %2 = tail call half @air.normalize_function_constant_predicate.f16(half %1) #3 + store half %2, ptr addrspace(2) @__metal_implicit_fc_pred_0, align 2 + ret void +} + +attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) } +attributes #2 = { mustprogress nofree nosync nounwind willreturn "frame-pointer"="all" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +attributes #3 = { nounwind willreturn memory(none) } + +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} +!air.fragment = !{!9} +!air.compile_options = !{!15, !16, !17} +!air.function_constants = !{!18} +!llvm.ident = !{!19} +!air.version = !{!20} +!air.language_version = !{!21} + +!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 @fch_gated_sample_mask, !10, !14} +!10 = !{!11, !12} +!11 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4", !"air.arg_name", !"color"} +!12 = !{!"air.function_constant", !13, !"air.sample_mask", !"air.arg_type_name", !"uint", !"air.arg_name", !"mask"} +!13 = !{ptr addrspace(2) @__metal_implicit_fc_pred_0, !"half", !"s"} +!14 = !{} +!15 = !{!"air.compile.denorms_disable"} +!16 = !{!"air.compile.fast_math_disable"} +!17 = !{!"air.compile.framebuffer_fetch_enable"} +!18 = !{ptr addrspace(2) @_Z1s.MTL_FC_INIT_0_Dh, !"half", !"s", i32 0} +!19 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"} +!20 = !{i32 2, i32 8, i32 0} +!21 = !{!"Metal", i32 4, i32 0, i32 0} +!22 = !{!23, !23, i64 0} +!23 = !{!"half", !24, i64 0} +!24 = !{!"omnipotent char", !25, i64 0} +!25 = !{!"Simple C++ TBAA"} diff --git a/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.metal b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.metal new file mode 100644 index 000000000..6db94fb5d --- /dev/null +++ b/crates/metal2vulkan-validation/fixtures/public/engine/fc_half_gate.metal @@ -0,0 +1,31 @@ +// Owned fixture: a function constant of type half that gates an output, the half form of +// fc_float_gate. Metal compiles `[[function_constant(s)]]` for a half `s` into a half predicate +// global that the static initializer writes from +// `air.normalize_function_constant_predicate.f16(s)`; the output is present where that predicate +// is non-zero. The cases over this entry ask Metal which values of `s` keep it: 1.5, +0.0, -0.0, +// a quiet NaN, and none. +// +// `fch_gated_sample_mask` always writes a colour and a sample mask of 0 to an output struct whose +// mask member the constant gates. Where the mask is an output the pixel is not covered and keeps +// the target's initial bytes; where it is not, the pixel takes the colour. The written values do +// not depend on `s`, so the target shows the presence itself. +// +// Precise maths, as fc_float_gate. Loop-free. +// metal-fast-math: off +#include +using namespace metal; + +constant half s [[function_constant(0)]]; + +struct FchMasked { + float4 color [[color(0)]]; + uint mask [[sample_mask, function_constant(s)]]; +}; + +fragment FchMasked fch_gated_sample_mask() +{ + FchMasked out; + out.color = float4(0.25, 0.5, 0.75, 1.0); + out.mask = 0u; + return out; +} diff --git a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv index 6029ffcd2..66d06d8de 100644 --- a/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv +++ b/crates/metal2vulkan/tests/public_fixture_expectations_engine.tsv @@ -862,6 +862,8 @@ engine/fc_float_gate.air.ll fcf_gated_argument ok ok ok ok ok ok ok ok ok ok ok engine/fc_float_gate.air.ll fcf_gated_sample_mask ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/fc_float_gate.ll fcf_gated_argument ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/fc_float_gate.ll fcf_gated_sample_mask ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/fc_half_gate.air.ll fch_gated_sample_mask ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok +engine/fc_half_gate.ll fch_gated_sample_mask ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/fc_ushort3_half3.air.ll fc_ushort3_half3 ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/fc_ushort3_half3.ll fc_ushort3_half3 ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok engine/fca_fragment_absent_inputs.air.ll fca_fragment_absent_inputs ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok