SEMANTICS 2103: a merged draw finds its command's slot tables before any entry hook reads one
A merged draw replay's functions read their command's slot table where other functions read a
RootTableAddress push field. The vertex function takes the table of the command its corner falls
in; the fragment function takes the table of the command its vertex wrote. That lookup ran in
stage_io::emit_entry, after access::dynamic::emit_entry, which reads each wide buffer parameter's
root entry at entry from that same table. So a merged function that loads a pointer from a buffer
read its table before the lookup had found it. An argument buffer holding a constant pointer is
one such case. The compile failed on the Internal Invariant "a merged draw's fragment slot table
read before its entry" (or the vertex's "slot table read before its entry"), and the execution of
a GPU-encoded indirect command buffer went to the host step. In the consumer's own game-shaped
program that step cost 32-48 ms a frame on the M3 (MoltenVK) and on Iris Xe (ANV), both logging the
invariant.
The lookup is now a hook of its own, stage_io::emit_draw_entry. It runs after the push fields,
specializations and dispatch values and before the access family's hook, and covers the captured
index of the de-indexed and private list forms, a merged vertex's command and a merged fragment's
table. The pulled attribute fetch stays in stage_io::emit_entry, after both.
New owned fixture: engine/icb_merged_arguments (MSL of our own). It has a [[stage_in]] vertex
function over vertex buffers 0..2, and a fragment function whose buffer 0 is an argument buffer of
two textures and a constant pointer. Two kernels encode indexed triangle draws with resets, one
binding the commands' own buffers and one binding none.
Verified (icbinherit, ebbcdad70a on 73caf92102, msi lavapipe):
- pipeline::compile::tests::a_merged_fragment_reads_its_argument_buffer_through_its_command_s_table
compiles the state's merged replay variant on moltenvk-m3, amd-rdna3-radv and lavapipe.
- It fails at the fixture commit with exactly the invariant (27480).
- With the fix, 82/82 merged and replay tests in metal2vulkan --lib pass (27488).
- The fixture's golden_hashes, engine-inventory and air_input rows are re-blessed on development.
SEMANTICS_VERSION 2102 -> 2103.
This commit is contained in:
1 parent
53f3dd2764
commit
a522b478f3
9 files changed
+831
-21
No files matched your search
@@ -154,6 +154,7 @@ fixture icb_copy_encode: metal: Apple metal version 32023.921 (metalfe-32023.921
|
||||
fixture icb_depth_indexed_encode: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture icb_imageblock_encode: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture icb_imageblock_template: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture icb_merged_arguments: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture icb_merged_attributes: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture icb_merged_draws: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture icb_merged_indexed: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
; Generated by scripts/regen-air-fixtures from icb_merged_arguments.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.IcaCommands = type { %"struct.metal::command_buffer" }
|
||||
%"struct.metal::command_buffer" = type { %struct._command_buffer_t addrspace(1)* }
|
||||
%struct._command_buffer_t = type opaque
|
||||
%struct.IcaDraw = type { i32, i32, i32, i32, i32 }
|
||||
%struct.IcaArguments = type { %"struct.metal::texture2d", %"struct.metal::texture2d", i32 addrspace(2)* }
|
||||
%"struct.metal::texture2d" = type { %struct._texture_2d_t addrspace(1)* }
|
||||
%struct._texture_2d_t = type opaque
|
||||
%struct._sampler_t = type opaque
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
define void @ica_own(%struct.IcaCommands addrspace(1)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, %struct.IcaDraw addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %1, <2 x float> addrspace(1)* noundef "air-buffer-no-alias" %2, i32 addrspace(1)* noundef "air-buffer-no-alias" %3, <4 x float> addrspace(2)* noundef "air-buffer-no-alias" %4, %struct.IcaArguments addrspace(2)* noundef "air-buffer-no-alias" %5, i32 addrspace(2)* noundef "air-buffer-no-alias" %6, i32 addrspace(1)* noundef "air-buffer-no-alias" %7, i32 noundef %8) local_unnamed_addr #0 {
|
||||
%10 = getelementptr inbounds %struct.IcaCommands, %struct.IcaCommands addrspace(1)* %0, i64 0, i32 0, i32 0
|
||||
%11 = load %struct._command_buffer_t addrspace(1)*, %struct._command_buffer_t addrspace(1)* addrspace(1)* %10, align 8, !tbaa.struct !56, !alias.scope !61, !noalias !64
|
||||
%12 = zext i32 %8 to i64
|
||||
%13 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %12, i32 1
|
||||
%14 = load i32, i32 addrspace(1)* %13, align 4, !tbaa.struct !72, !alias.scope !75, !noalias !76
|
||||
%15 = icmp eq i32 %14, 0
|
||||
br i1 %15, label %16, label %17
|
||||
|
||||
16: ; preds = %9
|
||||
tail call void @air.reset_render_command(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8) #7
|
||||
br label %34
|
||||
|
||||
17: ; preds = %9
|
||||
%18 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %12, i32 4
|
||||
%19 = load i32, i32 addrspace(1)* %18, align 4, !tbaa.struct !77, !alias.scope !75, !noalias !76
|
||||
%20 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %12, i32 3
|
||||
%21 = load i32, i32 addrspace(1)* %20, align 4, !tbaa.struct !78, !alias.scope !75, !noalias !76
|
||||
%22 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %12, i32 2
|
||||
%23 = load i32, i32 addrspace(1)* %22, align 4, !tbaa.struct !79, !alias.scope !75, !noalias !76
|
||||
%24 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %12, i32 0
|
||||
%25 = load i32, i32 addrspace(1)* %24, align 4, !tbaa.struct !80, !alias.scope !75, !noalias !76
|
||||
%26 = bitcast <2 x float> addrspace(1)* %2 to i8 addrspace(1)*
|
||||
tail call void @air.set_vertex_buffer_render_command.p1i8(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i8 addrspace(1)* %26, i64 -1, i32 0) #7
|
||||
%27 = bitcast i32 addrspace(1)* %3 to i8 addrspace(1)*
|
||||
tail call void @air.set_vertex_buffer_render_command.p1i8(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i8 addrspace(1)* %27, i64 -1, i32 1) #7
|
||||
%28 = bitcast <4 x float> addrspace(2)* %4 to i8 addrspace(2)*
|
||||
tail call void @air.set_vertex_buffer_render_command.p2i8(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i8 addrspace(2)* %28, i64 -1, i32 2) #7
|
||||
%29 = bitcast %struct.IcaArguments addrspace(2)* %5 to i8 addrspace(2)*
|
||||
tail call void @air.set_fragment_buffer_render_command.p2i8(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i8 addrspace(2)* %29, i32 0) #7
|
||||
%30 = getelementptr inbounds i32, i32 addrspace(2)* %6, i64 %12
|
||||
%31 = bitcast i32 addrspace(2)* %30 to i8 addrspace(2)*
|
||||
tail call void @air.set_fragment_buffer_render_command.p2i8(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i8 addrspace(2)* %31, i32 1) #7
|
||||
%32 = zext i32 %25 to i64
|
||||
%33 = getelementptr inbounds i32, i32 addrspace(1)* %7, i64 %32
|
||||
tail call void @air.draw_indexed_primitives_render_command.p1i32(%struct._command_buffer_t addrspace(1)* nocapture %11, i32 %8, i32 3, i32 %14, i32 addrspace(1)* %33, i32 %23, i32 %21, i32 %19) #7
|
||||
br label %34
|
||||
|
||||
34: ; preds = %17, %16
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
define void @ica_inherited(%struct.IcaCommands addrspace(1)* nocapture noundef readonly align 8 dereferenceable(8) "air-buffer-no-alias" %0, %struct.IcaDraw addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %1, i32 addrspace(1)* noundef "air-buffer-no-alias" %2, i32 noundef %3) local_unnamed_addr #0 {
|
||||
%5 = getelementptr inbounds %struct.IcaCommands, %struct.IcaCommands addrspace(1)* %0, i64 0, i32 0, i32 0
|
||||
%6 = load %struct._command_buffer_t addrspace(1)*, %struct._command_buffer_t addrspace(1)* addrspace(1)* %5, align 8, !tbaa.struct !56, !alias.scope !81, !noalias !84
|
||||
%7 = zext i32 %3 to i64
|
||||
%8 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %7, i32 1
|
||||
%9 = load i32, i32 addrspace(1)* %8, align 4, !tbaa.struct !72, !alias.scope !87, !noalias !88
|
||||
%10 = icmp eq i32 %9, 0
|
||||
br i1 %10, label %11, label %12
|
||||
|
||||
11: ; preds = %4
|
||||
tail call void @air.reset_render_command(%struct._command_buffer_t addrspace(1)* nocapture %6, i32 %3) #7
|
||||
br label %23
|
||||
|
||||
12: ; preds = %4
|
||||
%13 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %7, i32 4
|
||||
%14 = load i32, i32 addrspace(1)* %13, align 4, !tbaa.struct !77, !alias.scope !87, !noalias !88
|
||||
%15 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %7, i32 3
|
||||
%16 = load i32, i32 addrspace(1)* %15, align 4, !tbaa.struct !78, !alias.scope !87, !noalias !88
|
||||
%17 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %7, i32 2
|
||||
%18 = load i32, i32 addrspace(1)* %17, align 4, !tbaa.struct !79, !alias.scope !87, !noalias !88
|
||||
%19 = getelementptr inbounds %struct.IcaDraw, %struct.IcaDraw addrspace(1)* %1, i64 %7, i32 0
|
||||
%20 = load i32, i32 addrspace(1)* %19, align 4, !tbaa.struct !80, !alias.scope !87, !noalias !88
|
||||
%21 = zext i32 %20 to i64
|
||||
%22 = getelementptr inbounds i32, i32 addrspace(1)* %2, i64 %21
|
||||
tail call void @air.draw_indexed_primitives_render_command.p1i32(%struct._command_buffer_t addrspace(1)* nocapture %6, i32 %3, i32 3, i32 %9, i32 addrspace(1)* %22, i32 %18, i32 %16, i32 %14) #7
|
||||
br label %23
|
||||
|
||||
23: ; preds = %12, %11
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
define <{ <4 x float>, <4 x i32> }> @ica_vertex(<2 x float> %0, i32 %1, i32 noundef %2, i32 noundef %3, <4 x float> addrspace(2)* nocapture noundef readonly align 16 dereferenceable(16) "air-buffer-no-alias" %4) local_unnamed_addr #1 {
|
||||
%6 = tail call fast float @air.convert.f.f32.u.i32(i32 %3) #8
|
||||
%7 = load <4 x float>, <4 x float> addrspace(2)* %4, align 16, !alias.scope !89
|
||||
%8 = extractelement <4 x float> %7, i64 2
|
||||
%9 = fmul fast float %8, %6
|
||||
%10 = insertelement <2 x float> <float 0.000000e+00, float poison>, float %9, i64 1
|
||||
%11 = fadd fast <2 x float> %10, %0
|
||||
%12 = extractelement <2 x float> %11, i64 0
|
||||
%13 = fmul fast float %12, 2.000000e+00
|
||||
%14 = extractelement <4 x float> %7, i64 0
|
||||
%15 = fdiv fast float %13, %14
|
||||
%16 = fadd fast float %15, -1.000000e+00
|
||||
%17 = extractelement <2 x float> %11, i64 1
|
||||
%18 = fmul fast float %17, 2.000000e+00
|
||||
%19 = extractelement <4 x float> %7, i64 1
|
||||
%20 = fdiv fast float %18, %19
|
||||
%21 = fsub fast float 1.000000e+00, %20
|
||||
%22 = insertelement <4 x float> <float poison, float poison, float 0.000000e+00, float 1.000000e+00>, float %16, i64 0
|
||||
%23 = insertelement <4 x float> %22, float %21, i64 1
|
||||
%24 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 0>, i32 %1, i64 0
|
||||
%25 = insertelement <4 x i32> %24, i32 %2, i64 1
|
||||
%26 = insertelement <4 x i32> %25, i32 %3, i64 2
|
||||
%27 = insertvalue <{ <4 x float>, <4 x i32> }> undef, <4 x float> %23, 0
|
||||
%28 = insertvalue <{ <4 x float>, <4 x i32> }> %27, <4 x i32> %26, 1
|
||||
ret <{ <4 x float>, <4 x i32> }> %28
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind readonly willreturn
|
||||
define <4 x i32> @ica_fragment(<4 x float> %0, <4 x i32> %1, %struct.IcaArguments addrspace(2)* nocapture noundef readonly align 8 dereferenceable(24) "air-buffer-no-alias" %2, i32 addrspace(2)* nocapture noundef readonly align 4 dereferenceable(4) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = extractelement <4 x i32> %1, i64 0
|
||||
%6 = and i32 %5, 3
|
||||
%7 = insertelement <2 x i32> <i32 poison, i32 0>, i32 %6, i64 0
|
||||
%8 = getelementptr inbounds %struct.IcaArguments, %struct.IcaArguments addrspace(2)* %2, i64 0, i32 0, i32 0
|
||||
%9 = load %struct._texture_2d_t addrspace(1)*, %struct._texture_2d_t addrspace(1)* addrspace(2)* %8, align 8, !tbaa !92, !alias.scope !95, !noalias !98
|
||||
%10 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #9
|
||||
%11 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(%struct._texture_2d_t addrspace(1)* nocapture readonly %9, %struct._sampler_t addrspace(2)* %10, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 0) #10
|
||||
%12 = extractvalue { <4 x float>, i8 } %11, 0
|
||||
%13 = extractelement <4 x float> %12, i64 0
|
||||
%14 = fmul fast float %13, 2.550000e+02
|
||||
%15 = tail call fast float @air.fast_round.f32(float %14) #8
|
||||
%16 = tail call i32 @air.convert.u.i32.f.f32(float %15) #8
|
||||
%17 = getelementptr inbounds %struct.IcaArguments, %struct.IcaArguments addrspace(2)* %2, i64 0, i32 1, i32 0
|
||||
%18 = load %struct._texture_2d_t addrspace(1)*, %struct._texture_2d_t addrspace(1)* addrspace(2)* %17, align 8, !tbaa !92, !alias.scope !95, !noalias !98
|
||||
%19 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(%struct._texture_2d_t addrspace(1)* nocapture readonly %18, %struct._sampler_t addrspace(2)* %10, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 0) #10
|
||||
%20 = extractvalue { <4 x float>, i8 } %19, 0
|
||||
%21 = extractelement <4 x float> %20, i64 0
|
||||
%22 = fmul fast float %21, 2.550000e+02
|
||||
%23 = tail call fast float @air.fast_round.f32(float %22) #8
|
||||
%24 = tail call i32 @air.convert.u.i32.f.f32(float %23) #8
|
||||
%25 = shl i32 %24, 8
|
||||
%26 = or i32 %25, %16
|
||||
%27 = insertelement <4 x i32> %1, i32 %26, i64 1
|
||||
%28 = getelementptr inbounds %struct.IcaArguments, %struct.IcaArguments addrspace(2)* %2, i64 0, i32 2
|
||||
%29 = load i32 addrspace(2)*, i32 addrspace(2)* addrspace(2)* %28, align 8, !tbaa !100, !alias.scope !95, !noalias !98
|
||||
%30 = zext i32 %6 to i64
|
||||
%31 = getelementptr inbounds i32, i32 addrspace(2)* %29, i64 %30
|
||||
%32 = load i32, i32 addrspace(2)* %31, align 4, !tbaa !73
|
||||
%33 = insertelement <4 x i32> %27, i32 %32, i64 2
|
||||
%34 = load i32, i32 addrspace(2)* %3, align 4, !tbaa !73, !alias.scope !98, !noalias !95
|
||||
%35 = extractelement <4 x i32> %1, i64 2
|
||||
%36 = add i32 %34, %35
|
||||
%37 = insertelement <4 x i32> %33, i32 %36, i64 3
|
||||
ret <4 x i32> %37
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
declare i32 @air.convert.u.i32.f.f32(float) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.reset_render_command(%struct._command_buffer_t addrspace(1)* nocapture, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
declare float @air.fast_round.f32(float) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_vertex_buffer_render_command.p1i8(%struct._command_buffer_t addrspace(1)* nocapture, i32, i8 addrspace(1)*, i64, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_vertex_buffer_render_command.p2i8(%struct._command_buffer_t addrspace(1)* nocapture, i32, i8 addrspace(2)*, i64, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_fragment_buffer_render_command.p2i8(%struct._command_buffer_t addrspace(1)* nocapture, i32, i8 addrspace(2)*, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.draw_indexed_primitives_render_command.p1i32(%struct._command_buffer_t addrspace(1)* nocapture, i32, i32, i32, i32 addrspace(1)*, i32, i32, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: inaccessiblememonly mustprogress nofree nounwind readonly willreturn
|
||||
declare %struct._sampler_t addrspace(2)* @air.get_read_sampler() local_unnamed_addr #5
|
||||
|
||||
; 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 #6
|
||||
|
||||
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 nosync nounwind readnone willreturn "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="64" "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 nosync nounwind readnone willreturn }
|
||||
attributes #3 = { mustprogress nofree nounwind readonly 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 = { mustprogress nounwind willreturn }
|
||||
attributes #5 = { inaccessiblememonly mustprogress nofree nounwind readonly willreturn }
|
||||
attributes #6 = { argmemonly mustprogress nofree nounwind readonly willreturn }
|
||||
attributes #7 = { nounwind willreturn }
|
||||
attributes #8 = { nounwind readnone willreturn }
|
||||
attributes #9 = { inaccessiblememonly nounwind readonly willreturn }
|
||||
attributes #10 = { argmemonly nounwind readonly willreturn }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||
!air.kernel = !{!9, !28}
|
||||
!air.vertex = !{!32}
|
||||
!air.fragment = !{!42}
|
||||
!air.compile_options = !{!50, !51, !52}
|
||||
!llvm.ident = !{!53}
|
||||
!air.version = !{!54}
|
||||
!air.language_version = !{!55}
|
||||
|
||||
!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.IcaCommands addrspace(1)*, %struct.IcaDraw addrspace(1)*, <2 x float> addrspace(1)*, i32 addrspace(1)*, <4 x float> addrspace(2)*, %struct.IcaArguments addrspace(2)*, i32 addrspace(2)*, i32 addrspace(1)*, i32)* @ica_own, !10, !11}
|
||||
!10 = !{}
|
||||
!11 = !{!12, !15, !17, !18, !19, !20, !25, !26, !27}
|
||||
!12 = !{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", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaCommands", !"air.arg_name", !"encoder"}
|
||||
!13 = !{i32 0, i32 8, i32 0, !"command_buffer", !"commands", !"air.indirect_argument", !14}
|
||||
!14 = !{i32 0, !"air.command_buffer", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"command_buffer", !"air.arg_name", !"commands"}
|
||||
!15 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !16, !"air.arg_type_size", i32 20, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"IcaDraw", !"air.arg_name", !"draws"}
|
||||
!16 = !{i32 0, i32 4, i32 0, !"uint", !"first", i32 4, i32 4, i32 0, !"uint", !"count", i32 8, i32 4, i32 0, !"uint", !"instances", i32 12, i32 4, i32 0, !"uint", !"base_vertex", i32 16, i32 4, i32 0, !"uint", !"base_instance"}
|
||||
!17 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"float2", !"air.arg_name", !"xy"}
|
||||
!18 = !{i32 3, !"air.buffer", !"air.location_index", i32 3, 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", !"marks"}
|
||||
!19 = !{i32 4, !"air.buffer", !"air.location_index", i32 4, 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", !"float4", !"air.arg_name", !"frame"}
|
||||
!20 = !{i32 5, !"air.indirect_buffer", !"air.location_index", i32 5, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !21, !"air.arg_type_size", i32 24, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaArguments", !"air.arg_name", !"arguments"}
|
||||
!21 = !{i32 0, i32 8, i32 0, !"texture2d<float, sample>", !"first", !"air.indirect_argument", !22, i32 8, i32 8, i32 0, !"texture2d<float, sample>", !"second", !"air.indirect_argument", !23, i32 16, i32 8, i32 0, !"uint", !"words", !"air.indirect_argument", !24}
|
||||
!22 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<float, sample>", !"air.arg_name", !"first"}
|
||||
!23 = !{i32 1, !"air.texture", !"air.location_index", i32 1, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<float, sample>", !"air.arg_name", !"second"}
|
||||
!24 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"words"}
|
||||
!25 = !{i32 6, !"air.buffer", !"air.location_index", i32 6, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"tints"}
|
||||
!26 = !{i32 7, !"air.buffer", !"air.location_index", i32 7, 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", !"indices"}
|
||||
!27 = !{i32 8, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"}
|
||||
!28 = !{void (%struct.IcaCommands addrspace(1)*, %struct.IcaDraw addrspace(1)*, i32 addrspace(1)*, i32)* @ica_inherited, !10, !29}
|
||||
!29 = !{!12, !15, !30, !31}
|
||||
!30 = !{i32 2, !"air.buffer", !"air.location_index", i32 7, 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", !"indices"}
|
||||
!31 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"}
|
||||
!32 = !{<{ <4 x float>, <4 x i32> }> (<2 x float>, i32, i32, i32, <4 x float> addrspace(2)*)* @ica_vertex, !33, !36}
|
||||
!33 = !{!34, !35}
|
||||
!34 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!35 = !{!"air.vertex_output", !"generated(3idsDv4_j)", !"air.arg_type_name", !"uint4", !"air.arg_name", !"ids"}
|
||||
!36 = !{!37, !38, !39, !40, !41}
|
||||
!37 = !{i32 0, !"air.vertex_input", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"float2", !"air.arg_name", !"xy"}
|
||||
!38 = !{i32 1, !"air.vertex_input", !"air.location_index", i32 1, i32 1, !"air.arg_type_name", !"uint", !"air.arg_name", !"mark"}
|
||||
!39 = !{i32 2, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"vid"}
|
||||
!40 = !{i32 3, !"air.instance_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"iid"}
|
||||
!41 = !{i32 4, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 2, 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", !"float4", !"air.arg_name", !"frame"}
|
||||
!42 = !{<4 x i32> (<4 x float>, <4 x i32>, %struct.IcaArguments addrspace(2)*, i32 addrspace(2)*)* @ica_fragment, !43, !45}
|
||||
!43 = !{!44}
|
||||
!44 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"}
|
||||
!45 = !{!46, !47, !48, !49}
|
||||
!46 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position", !"air.arg_unused"}
|
||||
!47 = !{i32 1, !"air.fragment_input", !"generated(3idsDv4_j)", !"air.flat", !"air.arg_type_name", !"uint4", !"air.arg_name", !"ids"}
|
||||
!48 = !{i32 2, !"air.indirect_buffer", !"air.buffer_size", i32 24, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !21, !"air.arg_type_size", i32 24, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaArguments", !"air.arg_name", !"arguments"}
|
||||
!49 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"tint"}
|
||||
!50 = !{!"air.compile.denorms_disable"}
|
||||
!51 = !{!"air.compile.fast_math_enable"}
|
||||
!52 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!53 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!54 = !{i32 2, i32 8, i32 0}
|
||||
!55 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!56 = !{i64 0, i64 8, !57}
|
||||
!57 = !{!58, !58, i64 0}
|
||||
!58 = !{!"__metal_command_buffer_t", !59, i64 0}
|
||||
!59 = !{!"omnipotent char", !60, i64 0}
|
||||
!60 = !{!"Simple C++ TBAA"}
|
||||
!61 = !{!62}
|
||||
!62 = distinct !{!62, !63, !"air-alias-scope-arg(0)"}
|
||||
!63 = distinct !{!63, !"air-alias-scopes(ica_own)"}
|
||||
!64 = !{!65, !66, !67, !68, !69, !70, !71}
|
||||
!65 = distinct !{!65, !63, !"air-alias-scope-arg(1)"}
|
||||
!66 = distinct !{!66, !63, !"air-alias-scope-arg(2)"}
|
||||
!67 = distinct !{!67, !63, !"air-alias-scope-arg(3)"}
|
||||
!68 = distinct !{!68, !63, !"air-alias-scope-arg(4)"}
|
||||
!69 = distinct !{!69, !63, !"air-alias-scope-arg(5)"}
|
||||
!70 = distinct !{!70, !63, !"air-alias-scope-arg(6)"}
|
||||
!71 = distinct !{!71, !63, !"air-alias-scope-arg(7)"}
|
||||
!72 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73, i64 12, i64 4, !73}
|
||||
!73 = !{!74, !74, i64 0}
|
||||
!74 = !{!"int", !59, i64 0}
|
||||
!75 = !{!65}
|
||||
!76 = !{!62, !66, !67, !68, !69, !70, !71}
|
||||
!77 = !{i64 0, i64 4, !73}
|
||||
!78 = !{i64 0, i64 4, !73, i64 4, i64 4, !73}
|
||||
!79 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73}
|
||||
!80 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73, i64 12, i64 4, !73, i64 16, i64 4, !73}
|
||||
!81 = !{!82}
|
||||
!82 = distinct !{!82, !83, !"air-alias-scope-arg(0)"}
|
||||
!83 = distinct !{!83, !"air-alias-scopes(ica_inherited)"}
|
||||
!84 = !{!85, !86}
|
||||
!85 = distinct !{!85, !83, !"air-alias-scope-arg(1)"}
|
||||
!86 = distinct !{!86, !83, !"air-alias-scope-arg(2)"}
|
||||
!87 = !{!85}
|
||||
!88 = !{!82, !86}
|
||||
!89 = !{!90}
|
||||
!90 = distinct !{!90, !91, !"air-alias-scope-arg(4)"}
|
||||
!91 = distinct !{!91, !"air-alias-scopes(ica_vertex)"}
|
||||
!92 = !{!93, !94, i64 0}
|
||||
!93 = !{!"_ZTSN5metal9texture2dIfLNS_6accessE0ELNS_16memory_coherenceE0EvEE", !94, i64 0}
|
||||
!94 = !{!"__metal_texture_2d_t", !59, i64 0}
|
||||
!95 = !{!96}
|
||||
!96 = distinct !{!96, !97, !"air-alias-scope-arg(2)"}
|
||||
!97 = distinct !{!97, !"air-alias-scopes(ica_fragment)"}
|
||||
!98 = !{!99}
|
||||
!99 = distinct !{!99, !97, !"air-alias-scope-arg(3)"}
|
||||
!100 = !{!101, !102, i64 16}
|
||||
!101 = !{!"_ZTS12IcaArguments", !93, i64 0, !93, i64 8, !102, i64 16}
|
||||
!102 = !{!"any pointer", !59, i64 0}
|
||||
@@ -0,0 +1,307 @@
|
||||
; Generated by scripts/regen-air-fixtures from icb_merged_arguments.metal (llvm-dis of icb_merged_arguments.air). Do not edit.
|
||||
; ModuleID = '<stdin>'
|
||||
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.IcaCommands = type { %"struct.metal::command_buffer" }
|
||||
%"struct.metal::command_buffer" = type { ptr addrspace(1) }
|
||||
%struct.IcaDraw = type { i32, i32, i32, i32, i32 }
|
||||
%struct.IcaArguments = type { %"struct.metal::texture2d", %"struct.metal::texture2d", ptr addrspace(2) }
|
||||
%"struct.metal::texture2d" = type { ptr addrspace(1) }
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
define void @ica_own(ptr addrspace(1) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(1) noundef "air-buffer-no-alias" %2, ptr addrspace(1) noundef "air-buffer-no-alias" %3, ptr addrspace(2) noundef "air-buffer-no-alias" %4, ptr addrspace(2) noundef "air-buffer-no-alias" %5, ptr addrspace(2) noundef "air-buffer-no-alias" %6, ptr addrspace(1) noundef "air-buffer-no-alias" %7, i32 noundef %8) local_unnamed_addr #0 {
|
||||
%10 = getelementptr inbounds %struct.IcaCommands, ptr addrspace(1) %0, i64 0, i32 0, i32 0
|
||||
%11 = load ptr addrspace(1), ptr addrspace(1) %10, align 8, !tbaa.struct !56, !alias.scope !61, !noalias !64
|
||||
%12 = zext i32 %8 to i64
|
||||
%13 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %12, i32 1
|
||||
%14 = load i32, ptr addrspace(1) %13, align 4, !tbaa.struct !72, !alias.scope !75, !noalias !76
|
||||
%15 = icmp eq i32 %14, 0
|
||||
br i1 %15, label %16, label %17
|
||||
|
||||
16: ; preds = %9
|
||||
tail call void @air.reset_render_command(ptr addrspace(1) captures(none) %11, i32 %8) #7
|
||||
br label %34
|
||||
|
||||
17: ; preds = %9
|
||||
%18 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %12, i32 4
|
||||
%19 = load i32, ptr addrspace(1) %18, align 4, !tbaa.struct !77, !alias.scope !75, !noalias !76
|
||||
%20 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %12, i32 3
|
||||
%21 = load i32, ptr addrspace(1) %20, align 4, !tbaa.struct !78, !alias.scope !75, !noalias !76
|
||||
%22 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %12, i32 2
|
||||
%23 = load i32, ptr addrspace(1) %22, align 4, !tbaa.struct !79, !alias.scope !75, !noalias !76
|
||||
%24 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %12, i32 0
|
||||
%25 = load i32, ptr addrspace(1) %24, align 4, !tbaa.struct !80, !alias.scope !75, !noalias !76
|
||||
%26 = bitcast ptr addrspace(1) %2 to ptr addrspace(1)
|
||||
tail call void @air.set_vertex_buffer_render_command.p1i8(ptr addrspace(1) captures(none) %11, i32 %8, ptr addrspace(1) %26, i64 -1, i32 0) #7
|
||||
%27 = bitcast ptr addrspace(1) %3 to ptr addrspace(1)
|
||||
tail call void @air.set_vertex_buffer_render_command.p1i8(ptr addrspace(1) captures(none) %11, i32 %8, ptr addrspace(1) %27, i64 -1, i32 1) #7
|
||||
%28 = bitcast ptr addrspace(2) %4 to ptr addrspace(2)
|
||||
tail call void @air.set_vertex_buffer_render_command.p2i8(ptr addrspace(1) captures(none) %11, i32 %8, ptr addrspace(2) %28, i64 -1, i32 2) #7
|
||||
%29 = bitcast ptr addrspace(2) %5 to ptr addrspace(2)
|
||||
tail call void @air.set_fragment_buffer_render_command.p2i8(ptr addrspace(1) captures(none) %11, i32 %8, ptr addrspace(2) %29, i32 0) #7
|
||||
%30 = getelementptr inbounds i32, ptr addrspace(2) %6, i64 %12
|
||||
%31 = bitcast ptr addrspace(2) %30 to ptr addrspace(2)
|
||||
tail call void @air.set_fragment_buffer_render_command.p2i8(ptr addrspace(1) captures(none) %11, i32 %8, ptr addrspace(2) %31, i32 1) #7
|
||||
%32 = zext i32 %25 to i64
|
||||
%33 = getelementptr inbounds i32, ptr addrspace(1) %7, i64 %32
|
||||
tail call void @air.draw_indexed_primitives_render_command.p1i32(ptr addrspace(1) captures(none) %11, i32 %8, i32 3, i32 %14, ptr addrspace(1) %33, i32 %23, i32 %21, i32 %19) #7
|
||||
br label %34
|
||||
|
||||
34: ; preds = %17, %16
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
define void @ica_inherited(ptr addrspace(1) noundef readonly align 8 captures(none) dereferenceable(8) "air-buffer-no-alias" %0, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(1) noundef "air-buffer-no-alias" %2, i32 noundef %3) local_unnamed_addr #0 {
|
||||
%5 = getelementptr inbounds %struct.IcaCommands, ptr addrspace(1) %0, i64 0, i32 0, i32 0
|
||||
%6 = load ptr addrspace(1), ptr addrspace(1) %5, align 8, !tbaa.struct !56, !alias.scope !81, !noalias !84
|
||||
%7 = zext i32 %3 to i64
|
||||
%8 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %7, i32 1
|
||||
%9 = load i32, ptr addrspace(1) %8, align 4, !tbaa.struct !72, !alias.scope !87, !noalias !88
|
||||
%10 = icmp eq i32 %9, 0
|
||||
br i1 %10, label %11, label %12
|
||||
|
||||
11: ; preds = %4
|
||||
tail call void @air.reset_render_command(ptr addrspace(1) captures(none) %6, i32 %3) #7
|
||||
br label %23
|
||||
|
||||
12: ; preds = %4
|
||||
%13 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %7, i32 4
|
||||
%14 = load i32, ptr addrspace(1) %13, align 4, !tbaa.struct !77, !alias.scope !87, !noalias !88
|
||||
%15 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %7, i32 3
|
||||
%16 = load i32, ptr addrspace(1) %15, align 4, !tbaa.struct !78, !alias.scope !87, !noalias !88
|
||||
%17 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %7, i32 2
|
||||
%18 = load i32, ptr addrspace(1) %17, align 4, !tbaa.struct !79, !alias.scope !87, !noalias !88
|
||||
%19 = getelementptr inbounds %struct.IcaDraw, ptr addrspace(1) %1, i64 %7, i32 0
|
||||
%20 = load i32, ptr addrspace(1) %19, align 4, !tbaa.struct !80, !alias.scope !87, !noalias !88
|
||||
%21 = zext i32 %20 to i64
|
||||
%22 = getelementptr inbounds i32, ptr addrspace(1) %2, i64 %21
|
||||
tail call void @air.draw_indexed_primitives_render_command.p1i32(ptr addrspace(1) captures(none) %6, i32 %3, i32 3, i32 %9, ptr addrspace(1) %22, i32 %18, i32 %16, i32 %14) #7
|
||||
br label %23
|
||||
|
||||
23: ; preds = %12, %11
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
define <{ <4 x float>, <4 x i32> }> @ica_vertex(<2 x float> %0, i32 %1, i32 noundef %2, i32 noundef %3, ptr addrspace(2) noundef readonly align 16 captures(none) dereferenceable(16) "air-buffer-no-alias" %4) local_unnamed_addr #1 {
|
||||
%6 = tail call fast float @air.convert.f.f32.u.i32(i32 %3) #8
|
||||
%7 = load <4 x float>, ptr addrspace(2) %4, align 16, !alias.scope !89
|
||||
%8 = extractelement <4 x float> %7, i64 2
|
||||
%9 = fmul fast float %8, %6
|
||||
%10 = insertelement <2 x float> <float 0.000000e+00, float poison>, float %9, i64 1
|
||||
%11 = fadd fast <2 x float> %10, %0
|
||||
%12 = extractelement <2 x float> %11, i64 0
|
||||
%13 = fmul fast float %12, 2.000000e+00
|
||||
%14 = extractelement <4 x float> %7, i64 0
|
||||
%15 = fdiv fast float %13, %14
|
||||
%16 = fadd fast float %15, -1.000000e+00
|
||||
%17 = extractelement <2 x float> %11, i64 1
|
||||
%18 = fmul fast float %17, 2.000000e+00
|
||||
%19 = extractelement <4 x float> %7, i64 1
|
||||
%20 = fdiv fast float %18, %19
|
||||
%21 = fsub fast float 1.000000e+00, %20
|
||||
%22 = insertelement <4 x float> <float poison, float poison, float 0.000000e+00, float 1.000000e+00>, float %16, i64 0
|
||||
%23 = insertelement <4 x float> %22, float %21, i64 1
|
||||
%24 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 0>, i32 %1, i64 0
|
||||
%25 = insertelement <4 x i32> %24, i32 %2, i64 1
|
||||
%26 = insertelement <4 x i32> %25, i32 %3, i64 2
|
||||
%27 = insertvalue <{ <4 x float>, <4 x i32> }> undef, <4 x float> %23, 0
|
||||
%28 = insertvalue <{ <4 x float>, <4 x i32> }> %27, <4 x i32> %26, 1
|
||||
ret <{ <4 x float>, <4 x i32> }> %28
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
|
||||
define <4 x i32> @ica_fragment(<4 x float> %0, <4 x i32> %1, ptr addrspace(2) noundef readonly align 8 captures(none) dereferenceable(24) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(4) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = extractelement <4 x i32> %1, i64 0
|
||||
%6 = and i32 %5, 3
|
||||
%7 = insertelement <2 x i32> <i32 poison, i32 0>, i32 %6, i64 0
|
||||
%8 = getelementptr inbounds %struct.IcaArguments, ptr addrspace(2) %2, i64 0, i32 0, i32 0
|
||||
%9 = load ptr addrspace(1), ptr addrspace(2) %8, align 8, !tbaa !92, !alias.scope !95, !noalias !98
|
||||
%10 = tail call ptr addrspace(2) @air.get_read_sampler() #9
|
||||
%11 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(ptr addrspace(1) readonly captures(none) %9, ptr addrspace(2) %10, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 0) #10
|
||||
%12 = extractvalue { <4 x float>, i8 } %11, 0
|
||||
%13 = extractelement <4 x float> %12, i64 0
|
||||
%14 = fmul fast float %13, 2.550000e+02
|
||||
%15 = tail call fast float @air.fast_round.f32(float %14) #8
|
||||
%16 = tail call i32 @air.convert.u.i32.f.f32(float %15) #8
|
||||
%17 = getelementptr inbounds %struct.IcaArguments, ptr addrspace(2) %2, i64 0, i32 1, i32 0
|
||||
%18 = load ptr addrspace(1), ptr addrspace(2) %17, align 8, !tbaa !92, !alias.scope !95, !noalias !98
|
||||
%19 = tail call { <4 x float>, i8 } @air.read_texture_2d.v4f32(ptr addrspace(1) readonly captures(none) %18, ptr addrspace(2) %10, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 0) #10
|
||||
%20 = extractvalue { <4 x float>, i8 } %19, 0
|
||||
%21 = extractelement <4 x float> %20, i64 0
|
||||
%22 = fmul fast float %21, 2.550000e+02
|
||||
%23 = tail call fast float @air.fast_round.f32(float %22) #8
|
||||
%24 = tail call i32 @air.convert.u.i32.f.f32(float %23) #8
|
||||
%25 = shl i32 %24, 8
|
||||
%26 = or i32 %25, %16
|
||||
%27 = insertelement <4 x i32> %1, i32 %26, i64 1
|
||||
%28 = getelementptr inbounds %struct.IcaArguments, ptr addrspace(2) %2, i64 0, i32 2
|
||||
%29 = load ptr addrspace(2), ptr addrspace(2) %28, align 8, !tbaa !100, !alias.scope !95, !noalias !98
|
||||
%30 = zext i32 %6 to i64
|
||||
%31 = getelementptr inbounds i32, ptr addrspace(2) %29, i64 %30
|
||||
%32 = load i32, ptr addrspace(2) %31, align 4, !tbaa !73
|
||||
%33 = insertelement <4 x i32> %27, i32 %32, i64 2
|
||||
%34 = load i32, ptr addrspace(2) %3, align 4, !tbaa !73, !alias.scope !98, !noalias !95
|
||||
%35 = extractelement <4 x i32> %1, i64 2
|
||||
%36 = add i32 %34, %35
|
||||
%37 = insertelement <4 x i32> %33, i32 %36, i64 3
|
||||
ret <4 x i32> %37
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
declare i32 @air.convert.u.i32.f.f32(float) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.reset_render_command(ptr addrspace(1) captures(none), i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
declare float @air.fast_round.f32(float) local_unnamed_addr #2
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_vertex_buffer_render_command.p1i8(ptr addrspace(1) captures(none), i32, ptr addrspace(1), i64, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_vertex_buffer_render_command.p2i8(ptr addrspace(1) captures(none), i32, ptr addrspace(2), i64, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.set_fragment_buffer_render_command.p2i8(ptr addrspace(1) captures(none), i32, ptr addrspace(2), i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nounwind willreturn
|
||||
declare void @air.draw_indexed_primitives_render_command.p1i32(ptr addrspace(1) captures(none), i32, i32, i32, ptr addrspace(1), i32, i32, i32) local_unnamed_addr #4
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn memory(inaccessiblemem: read)
|
||||
declare ptr addrspace(2) @air.get_read_sampler() local_unnamed_addr #5
|
||||
|
||||
; 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 #6
|
||||
|
||||
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 nosync nounwind willreturn memory(none) "approx-func-fp-math"="true" "frame-pointer"="all" "min-legal-vector-width"="64" "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 nosync nounwind willreturn memory(none) }
|
||||
attributes #3 = { mustprogress nofree nounwind willreturn memory(read) "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 = { mustprogress nounwind willreturn }
|
||||
attributes #5 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) }
|
||||
attributes #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) }
|
||||
attributes #7 = { nounwind willreturn }
|
||||
attributes #8 = { nounwind willreturn memory(none) }
|
||||
attributes #9 = { nounwind willreturn memory(inaccessiblemem: read) }
|
||||
attributes #10 = { nounwind willreturn memory(argmem: read) }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||
!air.kernel = !{!9, !28}
|
||||
!air.vertex = !{!32}
|
||||
!air.fragment = !{!42}
|
||||
!air.compile_options = !{!50, !51, !52}
|
||||
!llvm.ident = !{!53}
|
||||
!air.version = !{!54}
|
||||
!air.language_version = !{!55}
|
||||
|
||||
!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 @ica_own, !10, !11}
|
||||
!10 = !{}
|
||||
!11 = !{!12, !15, !17, !18, !19, !20, !25, !26, !27}
|
||||
!12 = !{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", !13, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaCommands", !"air.arg_name", !"encoder"}
|
||||
!13 = !{i32 0, i32 8, i32 0, !"command_buffer", !"commands", !"air.indirect_argument", !14}
|
||||
!14 = !{i32 0, !"air.command_buffer", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"command_buffer", !"air.arg_name", !"commands"}
|
||||
!15 = !{i32 1, !"air.buffer", !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 1, !"air.struct_type_info", !16, !"air.arg_type_size", i32 20, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"IcaDraw", !"air.arg_name", !"draws"}
|
||||
!16 = !{i32 0, i32 4, i32 0, !"uint", !"first", i32 4, i32 4, i32 0, !"uint", !"count", i32 8, i32 4, i32 0, !"uint", !"instances", i32 12, i32 4, i32 0, !"uint", !"base_vertex", i32 16, i32 4, i32 0, !"uint", !"base_instance"}
|
||||
!17 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 8, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"float2", !"air.arg_name", !"xy"}
|
||||
!18 = !{i32 3, !"air.buffer", !"air.location_index", i32 3, 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", !"marks"}
|
||||
!19 = !{i32 4, !"air.buffer", !"air.location_index", i32 4, 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", !"float4", !"air.arg_name", !"frame"}
|
||||
!20 = !{i32 5, !"air.indirect_buffer", !"air.location_index", i32 5, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !21, !"air.arg_type_size", i32 24, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaArguments", !"air.arg_name", !"arguments"}
|
||||
!21 = !{i32 0, i32 8, i32 0, !"texture2d<float, sample>", !"first", !"air.indirect_argument", !22, i32 8, i32 8, i32 0, !"texture2d<float, sample>", !"second", !"air.indirect_argument", !23, i32 16, i32 8, i32 0, !"uint", !"words", !"air.indirect_argument", !24}
|
||||
!22 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<float, sample>", !"air.arg_name", !"first"}
|
||||
!23 = !{i32 1, !"air.texture", !"air.location_index", i32 1, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<float, sample>", !"air.arg_name", !"second"}
|
||||
!24 = !{i32 2, !"air.buffer", !"air.location_index", i32 2, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"words"}
|
||||
!25 = !{i32 6, !"air.buffer", !"air.location_index", i32 6, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"tints"}
|
||||
!26 = !{i32 7, !"air.buffer", !"air.location_index", i32 7, 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", !"indices"}
|
||||
!27 = !{i32 8, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"}
|
||||
!28 = !{ptr @ica_inherited, !10, !29}
|
||||
!29 = !{!12, !15, !30, !31}
|
||||
!30 = !{i32 2, !"air.buffer", !"air.location_index", i32 7, 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", !"indices"}
|
||||
!31 = !{i32 3, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"tid"}
|
||||
!32 = !{ptr @ica_vertex, !33, !36}
|
||||
!33 = !{!34, !35}
|
||||
!34 = !{!"air.position", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!35 = !{!"air.vertex_output", !"generated(3idsDv4_j)", !"air.arg_type_name", !"uint4", !"air.arg_name", !"ids"}
|
||||
!36 = !{!37, !38, !39, !40, !41}
|
||||
!37 = !{i32 0, !"air.vertex_input", !"air.location_index", i32 0, i32 1, !"air.arg_type_name", !"float2", !"air.arg_name", !"xy"}
|
||||
!38 = !{i32 1, !"air.vertex_input", !"air.location_index", i32 1, i32 1, !"air.arg_type_name", !"uint", !"air.arg_name", !"mark"}
|
||||
!39 = !{i32 2, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"vid"}
|
||||
!40 = !{i32 3, !"air.instance_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"iid"}
|
||||
!41 = !{i32 4, !"air.buffer", !"air.buffer_size", i32 16, !"air.location_index", i32 2, 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", !"float4", !"air.arg_name", !"frame"}
|
||||
!42 = !{ptr @ica_fragment, !43, !45}
|
||||
!43 = !{!44}
|
||||
!44 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"}
|
||||
!45 = !{!46, !47, !48, !49}
|
||||
!46 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position", !"air.arg_unused"}
|
||||
!47 = !{i32 1, !"air.fragment_input", !"generated(3idsDv4_j)", !"air.flat", !"air.arg_type_name", !"uint4", !"air.arg_name", !"ids"}
|
||||
!48 = !{i32 2, !"air.indirect_buffer", !"air.buffer_size", i32 24, !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !21, !"air.arg_type_size", i32 24, !"air.arg_type_align_size", i32 8, !"air.arg_type_name", !"IcaArguments", !"air.arg_name", !"arguments"}
|
||||
!49 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"tint"}
|
||||
!50 = !{!"air.compile.denorms_disable"}
|
||||
!51 = !{!"air.compile.fast_math_enable"}
|
||||
!52 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!53 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!54 = !{i32 2, i32 8, i32 0}
|
||||
!55 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!56 = !{i64 0, i64 8, !57}
|
||||
!57 = !{!58, !58, i64 0}
|
||||
!58 = !{!"__metal_command_buffer_t", !59, i64 0}
|
||||
!59 = !{!"omnipotent char", !60, i64 0}
|
||||
!60 = !{!"Simple C++ TBAA"}
|
||||
!61 = !{!62}
|
||||
!62 = distinct !{!62, !63, !"air-alias-scope-arg(0)"}
|
||||
!63 = distinct !{!63, !"air-alias-scopes(ica_own)"}
|
||||
!64 = !{!65, !66, !67, !68, !69, !70, !71}
|
||||
!65 = distinct !{!65, !63, !"air-alias-scope-arg(1)"}
|
||||
!66 = distinct !{!66, !63, !"air-alias-scope-arg(2)"}
|
||||
!67 = distinct !{!67, !63, !"air-alias-scope-arg(3)"}
|
||||
!68 = distinct !{!68, !63, !"air-alias-scope-arg(4)"}
|
||||
!69 = distinct !{!69, !63, !"air-alias-scope-arg(5)"}
|
||||
!70 = distinct !{!70, !63, !"air-alias-scope-arg(6)"}
|
||||
!71 = distinct !{!71, !63, !"air-alias-scope-arg(7)"}
|
||||
!72 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73, i64 12, i64 4, !73}
|
||||
!73 = !{!74, !74, i64 0}
|
||||
!74 = !{!"int", !59, i64 0}
|
||||
!75 = !{!65}
|
||||
!76 = !{!62, !66, !67, !68, !69, !70, !71}
|
||||
!77 = !{i64 0, i64 4, !73}
|
||||
!78 = !{i64 0, i64 4, !73, i64 4, i64 4, !73}
|
||||
!79 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73}
|
||||
!80 = !{i64 0, i64 4, !73, i64 4, i64 4, !73, i64 8, i64 4, !73, i64 12, i64 4, !73, i64 16, i64 4, !73}
|
||||
!81 = !{!82}
|
||||
!82 = distinct !{!82, !83, !"air-alias-scope-arg(0)"}
|
||||
!83 = distinct !{!83, !"air-alias-scopes(ica_inherited)"}
|
||||
!84 = !{!85, !86}
|
||||
!85 = distinct !{!85, !83, !"air-alias-scope-arg(1)"}
|
||||
!86 = distinct !{!86, !83, !"air-alias-scope-arg(2)"}
|
||||
!87 = !{!85}
|
||||
!88 = !{!82, !86}
|
||||
!89 = !{!90}
|
||||
!90 = distinct !{!90, !91, !"air-alias-scope-arg(4)"}
|
||||
!91 = distinct !{!91, !"air-alias-scopes(ica_vertex)"}
|
||||
!92 = !{!93, !94, i64 0}
|
||||
!93 = !{!"_ZTSN5metal9texture2dIfLNS_6accessE0ELNS_16memory_coherenceE0EvEE", !94, i64 0}
|
||||
!94 = !{!"__metal_texture_2d_t", !59, i64 0}
|
||||
!95 = !{!96}
|
||||
!96 = distinct !{!96, !97, !"air-alias-scope-arg(2)"}
|
||||
!97 = distinct !{!97, !"air-alias-scopes(ica_fragment)"}
|
||||
!98 = !{!99}
|
||||
!99 = distinct !{!99, !97, !"air-alias-scope-arg(3)"}
|
||||
!100 = !{!101, !102, i64 16}
|
||||
!101 = !{!"_ZTS12IcaArguments", !93, i64 0, !93, i64 8, !102, i64 16}
|
||||
!102 = !{!"any pointer", !59, i64 0}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Owned fixture: indexed draws of triangles that a kernel encodes into an indirect command buffer
|
||||
// and a render pass executes, under the encoder's pipeline state, whose vertex function fetches
|
||||
// `[[stage_in]]` attributes and whose fragment function reads an argument buffer of two textures
|
||||
// and a constant pointer. Each kernel encodes command `tid` from `draws[tid]` (first index, index
|
||||
// count, instance count, base vertex, base instance), resetting the command where the index count
|
||||
// is 0: `ica_own` binds the command's own buffers (vertex buffer 0 the vertices' pixel positions,
|
||||
// vertex buffer 1 the marks, vertex buffer 2 the frame, fragment buffer 0 the argument buffer and
|
||||
// fragment buffer 1 its own word of `tints`) and `ica_inherited` none, its commands drawing with
|
||||
// the encoder's. The draw is of the 32-bit indices of `indices` from its first index. The case's
|
||||
// vertex descriptor places attribute 0 (a `float2` pixel position) in layout 0 and attribute 1 (a
|
||||
// `uint` mark) in layout 1. Vertex `vid` of instance `iid` lies at its position moved down `iid`
|
||||
// rows of `frame.z` pixels (`frame` is the target's width, height and row stride in pixels) and
|
||||
// carries its mark, `vid` and `iid` flat to the fragment function, which returns the mark, the
|
||||
// texel of each texture at the mark's column (each `RGBA8Unorm` red byte), the word the pointer
|
||||
// reaches at the mark, and its tint plus `iid`. The vertex function writes no memory.
|
||||
// Written for this repository; no third-party source.
|
||||
// Loop-free.
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
struct IcaCommands {
|
||||
command_buffer commands;
|
||||
};
|
||||
|
||||
struct IcaDraw {
|
||||
uint first;
|
||||
uint count;
|
||||
uint instances;
|
||||
uint base_vertex;
|
||||
uint base_instance;
|
||||
};
|
||||
|
||||
struct IcaIn {
|
||||
float2 xy [[attribute(0)]];
|
||||
uint mark [[attribute(1)]];
|
||||
};
|
||||
|
||||
struct IcaOut {
|
||||
float4 position [[position]];
|
||||
uint4 ids [[flat]];
|
||||
};
|
||||
|
||||
struct IcaArguments {
|
||||
texture2d<float> first [[id(0)]];
|
||||
texture2d<float> second [[id(1)]];
|
||||
constant uint *words [[id(2)]];
|
||||
};
|
||||
|
||||
kernel void ica_own(device const IcaCommands &encoder [[buffer(0)]],
|
||||
device const IcaDraw *draws [[buffer(1)]],
|
||||
device const float2 *xy [[buffer(2)]],
|
||||
device const uint *marks [[buffer(3)]],
|
||||
constant float4 *frame [[buffer(4)]],
|
||||
constant IcaArguments *arguments [[buffer(5)]],
|
||||
constant uint *tints [[buffer(6)]],
|
||||
device const uint *indices [[buffer(7)]],
|
||||
uint tid [[thread_position_in_grid]]) {
|
||||
render_command command(encoder.commands, tid);
|
||||
IcaDraw d = draws[tid];
|
||||
if (d.count == 0) {
|
||||
command.reset();
|
||||
return;
|
||||
}
|
||||
command.set_vertex_buffer(xy, 0);
|
||||
command.set_vertex_buffer(marks, 1);
|
||||
command.set_vertex_buffer(frame, 2);
|
||||
command.set_fragment_buffer(arguments, 0);
|
||||
command.set_fragment_buffer(tints + tid, 1);
|
||||
command.draw_indexed_primitives(primitive_type::triangle, d.count, indices + d.first,
|
||||
d.instances, d.base_vertex, d.base_instance);
|
||||
}
|
||||
|
||||
kernel void ica_inherited(device const IcaCommands &encoder [[buffer(0)]],
|
||||
device const IcaDraw *draws [[buffer(1)]],
|
||||
device const uint *indices [[buffer(7)]],
|
||||
uint tid [[thread_position_in_grid]]) {
|
||||
render_command command(encoder.commands, tid);
|
||||
IcaDraw d = draws[tid];
|
||||
if (d.count == 0) {
|
||||
command.reset();
|
||||
return;
|
||||
}
|
||||
command.draw_indexed_primitives(primitive_type::triangle, d.count, indices + d.first,
|
||||
d.instances, d.base_vertex, d.base_instance);
|
||||
}
|
||||
|
||||
vertex IcaOut ica_vertex(IcaIn in [[stage_in]], uint vid [[vertex_id]], uint iid [[instance_id]],
|
||||
constant float4 &frame [[buffer(2)]]) {
|
||||
float2 at = in.xy + float2(0.0, float(iid) * frame.z);
|
||||
IcaOut out;
|
||||
out.position = float4(2.0 * at.x / frame.x - 1.0, 1.0 - 2.0 * at.y / frame.y, 0.0, 1.0);
|
||||
out.ids = uint4(in.mark, vid, iid, 0);
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment uint4 ica_fragment(IcaOut in [[stage_in]],
|
||||
constant IcaArguments &arguments [[buffer(0)]],
|
||||
constant uint &tint [[buffer(1)]]) {
|
||||
uint mark = in.ids.x;
|
||||
uint2 texel = uint2(mark % 4, 0);
|
||||
uint first = uint(round(arguments.first.read(texel).x * 255.0));
|
||||
uint second = uint(round(arguments.second.read(texel).x * 255.0));
|
||||
return uint4(mark, first | (second << 8), arguments.words[mark % 4], tint + in.ids.z);
|
||||
}
|
||||
Vendored
+1
-1
@@ -61,7 +61,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2102;
|
||||
pub const SEMANTICS_VERSION: u32 = 2103;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -499,9 +499,11 @@ pub fn param_value(
|
||||
Ok(Some(fat(fb, [root, at, host, size])?))
|
||||
}
|
||||
|
||||
/// The work before the body (the entry hook): in the function's first block, which dominates
|
||||
/// every block, read the sink's address and each wide buffer parameter's root entry once, so no
|
||||
/// access reads the root table again. The table is read-only to the dispatch: the binder writes
|
||||
/// The work before the body (the entry hook): at entry, in a block that dominates every block of
|
||||
/// the body (the function's first, or the merge of a merged vertex's search, which
|
||||
/// `stage_io::emit_draw_entry` emits before it, as the slot table it reads is its command's), read
|
||||
/// the sink's address and each wide buffer parameter's root entry once, so no access reads the
|
||||
/// root table again. The table is read-only to the dispatch: the binder writes
|
||||
/// it before submission and no lowering stores to it.
|
||||
pub fn emit_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<()> {
|
||||
let dynamic = &cx.plan.families.access.dynamic;
|
||||
|
||||
@@ -210,12 +210,13 @@ pub struct EmitCx<'a> {
|
||||
/// (`sampler::routine`).
|
||||
pub(crate) sampling: crate::lower::sampler::routine::Routines,
|
||||
/// A merged draw's vertex function's command, vertex, instance and slot table, which
|
||||
/// `stage_io::emit_entry` finds before the body (`stage_io::MergedRead`): defined in the
|
||||
/// function's straight-line entry, so every later block of the function may read them.
|
||||
/// `stage_io::emit_draw_entry` finds before the body and before any other hook reads its slot
|
||||
/// table (`stage_io::MergedRead`): defined at entry, where they dominate every later block of
|
||||
/// the function, which may read them.
|
||||
pub(crate) merged_draw: Option<crate::bind::MergedVertex>,
|
||||
/// A merged draw's fragment function's command's fragment slot table, which
|
||||
/// `stage_io::emit_entry` finds before the body (`stage_io::StageIoPlan::merged_fragment`),
|
||||
/// defined in the function's straight-line entry.
|
||||
/// `stage_io::emit_draw_entry` finds before the body and before any other hook reads it
|
||||
/// (`stage_io::StageIoPlan::merged_fragment`), defined in the function's straight-line entry.
|
||||
pub(crate) merged_fragment_table: Option<SValue>,
|
||||
/// The texel of each storage-form color attachment a fragment function reads, by Metal
|
||||
/// color index, at the invocation's pixel (and sample), which `fragment::emit_entry` reads
|
||||
@@ -240,10 +241,10 @@ enum Invariant {
|
||||
/// dominates it ran that test on the same sampler, so it needs none of its own.
|
||||
CubicTested(ValueId),
|
||||
/// An indexed capture form's raw index (`stage_io::read_captured_index`), read at entry
|
||||
/// (`stage_io::emit_entry`): the index buffer is read-only to the draw.
|
||||
/// (`stage_io::emit_draw_entry`): the index buffer is read-only to the draw.
|
||||
CapturedIndex,
|
||||
/// The private list form's base vertex (`stage_io::read_listed_base`), read at entry
|
||||
/// (`stage_io::emit_entry`): the list is read-only to the draw.
|
||||
/// (`stage_io::emit_draw_entry`): the list is read-only to the draw.
|
||||
ListedBase,
|
||||
/// The root table's sink address (`access::dynamic::read_sink_host`), read at entry
|
||||
/// (`access::dynamic::emit_entry`): the root table is read-only to the dispatch.
|
||||
@@ -373,8 +374,8 @@ impl<'a> EmitCx<'a> {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// An indexed capture form's raw index, read once where it dominates: `stage_io::emit_entry`
|
||||
/// reads it in the function's first block, which dominates every block of the function, the
|
||||
/// An indexed capture form's raw index, read once where it dominates:
|
||||
/// `stage_io::emit_draw_entry` reads it in the function's first block, which dominates every block of the function, the
|
||||
/// merge of the restart test it then closes included.
|
||||
pub(crate) fn captured_index(&mut self, fb: &mut FunctionBuilder<'_>) -> BResult<SValue> {
|
||||
let first = fb.entry_block();
|
||||
@@ -532,8 +533,9 @@ impl<'a> EmitCx<'a> {
|
||||
}
|
||||
|
||||
/// Bind AIR value `v` to `x` for the whole function: `x` was emitted by the entry hook
|
||||
/// (`stage_io::emit_entry`) in the function's first block, before the walk, so its definition
|
||||
/// dominates every block and opening a block does not forget it.
|
||||
/// (`stage_io::emit_entry`, `access::dynamic::emit_entry`) before the walk, in a block that
|
||||
/// dominates every block of the body (the function's first, or a merged vertex's search's
|
||||
/// merge, `stage_io::emit_draw_entry`), so opening a block does not forget it.
|
||||
pub fn hold(&mut self, v: ValueId, x: SValue) {
|
||||
if let Some(slot) = self.env.get_mut(v.index()) {
|
||||
*slot = Some(x);
|
||||
@@ -1359,6 +1361,9 @@ pub fn emit_module(e: &Entry, plan: &Plan, m: &mut Meter) -> Result<Emitted, Err
|
||||
// The bound values the function reads as data, right after their fields.
|
||||
.and_then(|()| crate::lower::specialized::emit_entry(&mut em.cx, &mut fb))
|
||||
.and_then(|()| dispatch::emit_entry(&mut em.cx, &mut fb))
|
||||
// What the invocation draws (a merged draw's command and its slot tables) before
|
||||
// any hook reads a slot table.
|
||||
.and_then(|()| stage_io::emit_draw_entry(&mut em.cx, &mut fb))
|
||||
.and_then(|()| access::dynamic::emit_entry(&mut em.cx, &mut fb))
|
||||
.and_then(|()| stage_io::emit_entry(&mut em.cx, &mut fb))
|
||||
.and_then(|()| tessellation::emit_entry(&mut em.cx, &mut fb))
|
||||
|
||||
@@ -1264,13 +1264,14 @@ fn metal_interpolated_constant(
|
||||
fb.convert(ConvOp::Bitcast, r, ft)
|
||||
}
|
||||
|
||||
/// Fetch every pulled attribute in the function's first block, before the walk emits any
|
||||
/// instruction of the body, and hold each value for all its uses. The first block dominates every
|
||||
/// block, and the fetch is straight-line code, so each value is defined in a block every use
|
||||
/// follows; the body's writes, through the source buffer's slot or any other pointer to its memory,
|
||||
/// come after it in program order and never reach it, as Metal's attribute is fetched before its
|
||||
/// function runs.
|
||||
pub fn emit_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<()> {
|
||||
/// Find what the invocation draws, before any entry hook reads a slot table or an index: the
|
||||
/// de-indexed or private list form's raw index (and the private list form's base vertex), and a
|
||||
/// merged draw's command, whose slot table is the stage's `RootTableAddress`
|
||||
/// (`EmitCx::load_push_field`). The access family's entry hook (`access::dynamic::emit_entry`)
|
||||
/// reads a wide buffer parameter's root entry from that table, so this runs before it. A merged
|
||||
/// vertex's search is a loop: the hooks after it emit in its merge block, which dominates every
|
||||
/// block of the body.
|
||||
pub fn emit_draw_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<()> {
|
||||
// The de-indexed or private list form's raw index, read once in the first block, where it
|
||||
// dominates every use, and the private list form's base vertex.
|
||||
if let Some(c) = cx.plan.families.stage_io.captured_index {
|
||||
@@ -1304,6 +1305,16 @@ pub fn emit_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<
|
||||
let table = crate::bind::merged_fragment_table(fb, header, command)?;
|
||||
cx.merged_fragment_table = Some(table);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Fetch every pulled attribute at entry, after [`emit_draw_entry`] found what the invocation
|
||||
/// draws and before the walk emits any instruction of the body, and hold each value for all its
|
||||
/// uses. The block it emits in dominates every block, and the fetch is straight-line code, so each
|
||||
/// value is defined in a block every use follows; the body's writes, through the source buffer's
|
||||
/// slot or any other pointer to its memory, come after it in program order and never reach it, as
|
||||
/// Metal's attribute is fetched before its function runs.
|
||||
pub fn emit_entry(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResult<()> {
|
||||
let pulled: Vec<(u32, fetch::PulledRead)> = cx
|
||||
.plan
|
||||
.families
|
||||
|
||||
@@ -3355,6 +3355,76 @@ fn a_merged_draw_reads_its_command_s_table_from_its_header() {
|
||||
);
|
||||
}
|
||||
|
||||
/// A merged draw replay's functions find their command's slot tables before any entry hook reads
|
||||
/// one: a fragment function that loads a pointer from its argument buffer reads that buffer's
|
||||
/// root entry at entry (`access::dynamic::emit_entry`), from the fragment slot table the command
|
||||
/// its vertex wrote names, and the merged variant of `icb_merged_arguments` (a vertex function
|
||||
/// that fetches `[[stage_in]]` attributes, a fragment function whose argument buffer holds two
|
||||
/// textures and a constant pointer) compiles on each device that has the replay, every stage
|
||||
/// passing L3, its fragment stage reading the header at its `MergedDrawAddress`.
|
||||
#[test]
|
||||
fn a_merged_fragment_reads_its_argument_buffer_through_its_command_s_table() {
|
||||
use crate::cache::VariantKey;
|
||||
use crate::pipeline::sym::{PushField, Stage};
|
||||
let Some(bc) = fixture("icb_merged_arguments") else {
|
||||
return;
|
||||
};
|
||||
let lib = Library::from_air(&bc).expect("library");
|
||||
let function = |name: &str| {
|
||||
StageSource::Function(FunctionDescriptor::new(lib.function(name).expect(name)))
|
||||
};
|
||||
let mut d = RenderPipelineDescriptor::new(function("ica_vertex"));
|
||||
d.fragment = Some(function("ica_fragment"));
|
||||
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(
|
||||
metal::PixelFormat::RGBA32Uint,
|
||||
));
|
||||
let mut input = VertexDescriptor::new();
|
||||
input
|
||||
.layouts
|
||||
.insert(0, VertexBufferLayoutDescriptor::new(Some(8)));
|
||||
input
|
||||
.layouts
|
||||
.insert(1, VertexBufferLayoutDescriptor::new(Some(4)));
|
||||
input.attributes.insert(
|
||||
0,
|
||||
VertexAttributeDescriptor::new(metal::VertexFormat::Float2, 0, 0),
|
||||
);
|
||||
input.attributes.insert(
|
||||
1,
|
||||
VertexAttributeDescriptor::new(metal::VertexFormat::UInt, 0, 1),
|
||||
);
|
||||
d.vertex_descriptor = Some(input);
|
||||
for stem in ["moltenvk-m3", "amd-rdna3-radv", "lavapipe"] {
|
||||
let dev = device(stem);
|
||||
let base = dev
|
||||
.compile_render_variant(&d, &VariantKey::new(), &Budget::standard())
|
||||
.unwrap_or_else(|e| panic!("{stem}: base: {e}"));
|
||||
let layouts = crate::bind::draw_replay_vertex_layouts(&base.vertex_input).expect("layouts");
|
||||
let shape = crate::bind::BindShape {
|
||||
far_vertex_buffers: layouts,
|
||||
..Default::default()
|
||||
};
|
||||
let mut key = base.plan(&dev, &shape).expect("base plan").variant;
|
||||
key.replay_bindings = true;
|
||||
key.merged_draws = true;
|
||||
let merged = dev
|
||||
.compile_render_variant(&d, &key, &Budget::standard())
|
||||
.unwrap_or_else(|e| panic!("{stem}: merged: {e}"));
|
||||
for stage in &merged.stages {
|
||||
l3(&stage.spirv, &merged.requirements, &dev);
|
||||
}
|
||||
let fragment: Vec<PushField> = (merged.interface.push.iter())
|
||||
.filter(|p| p.stage == Stage::Fragment)
|
||||
.flat_map(|p| p.fields.iter().map(|f| f.field))
|
||||
.collect();
|
||||
assert!(
|
||||
fragment.contains(&PushField::MergedDrawAddress)
|
||||
&& !fragment.contains(&PushField::RootTableAddress),
|
||||
"{stem}: {fragment:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A render pipeline compiled as a device-replay variant (`VariantKey::replay_bindings`) reads
|
||||
/// every buffer its vertex function reaches through its root entry (`BufferForm::Psb`), from the
|
||||
/// slot table at the stage's own `RootTableAddress`, and needs no `SlotGuestBase`
|
||||
|
||||
Reference in new issue
Block a user