Fixtures: the post-tessellation draw-bases function moves to a fixture of its own, tess_draw_bases

engine/rvc_draw_bases.ll is the public source of four committed cases,
which check its hash. Regenerating it to add draw_bases_after_tessellation
(and under a newer metal) failed all four in
committed_public_cases_check (lavapipe's host, job m3-max-80338). The
fixture goes back to the AIR its cases check, and the function moves,
unchanged, to engine/tess_draw_bases, regenerated by
scripts/regen-air-fixtures on the Apple M3 Max (job m3-max-80403; one
fixture of 584 regenerated, Apple metal 32023.922, macOS SDK 27.2). The
fixture README gains its row and rvc_draw_bases's row is as before.

The translator test the_base_instance_after_tessellation_is_the_patch_input_or_the_push_lane
reads base_instance_after_tessellation from rvc_draw_bases and
draw_bases_after_tessellation from tess_draw_bases, and the runtime's
every_device_reads_a_patch_draw_s_base_instance_after_tessellation draws it
from there. The engine inventory's new row is tess_draw_bases's, in place
of rvc_draw_bases's draw_bases_after_tessellation, for the landing bless.
This commit is contained in:
Anees Iqbal committed 2026-12-02 14:41:35 -08:00
1 parent e93d7e6b1b
commit 8a2f155883
10 files changed
+212 -124

No files matched your search

@@ -24,7 +24,7 @@
//! where the kernel offers the counter (Linux), with the build profile and the validation
//! layer the device tests load: a patch draw that changes nothing records what a plain draw
//! records.
//! - the owned fixture `engine/rvc_draw_bases.ll`'s `draw_bases_after_tessellation`, its state's
//! - the owned fixture `engine/tess_draw_bases.ll`'s `draw_bases_after_tessellation`, its state's
//! rasterization disabled: each patch of each instance of a draw from a base instance of 3,
//! direct and indirect, writes its patch id, its instance id and the draw's base instance.
//! - the owned fixture `engine/tess_primitive_ids.ll`: a fragment function's `[[primitive_id]]`
@@ -578,7 +578,7 @@ BUFFER_META"#;
}
/// A post-tessellation function reads the draw's `[[base_instance]]` beside its
/// `[[instance_id]]` (the owned fixture `engine/rvc_draw_bases.ll`'s
/// `[[instance_id]]` (the owned fixture `engine/tess_draw_bases.ll`'s
/// `draw_bases_after_tessellation`, its state's rasterization disabled): two triangle patches
/// of two instances from base instance 3, drawn directly and from
/// `MTLDrawPatchIndirectArguments`, every factor 1. Each patch `pid` of instance `iid` writes
@@ -587,7 +587,7 @@ BUFFER_META"#;
/// written.
#[test]
fn every_device_reads_a_patch_draw_s_base_instance_after_tessellation() {
let Some(engine) = library(&engine_dir().join("rvc_draw_bases.ll")) else {
let Some(engine) = library(&engine_dir().join("tess_draw_bases.ll")) else {
return;
};
let mut d = RenderPipelineDescriptor::new(StageSource::Function(FunctionDescriptor::new(
@@ -106,6 +106,7 @@ threadgroup's threads); an authored case that executes a loop declares it
| `k7_tess_quad_domain` | `k7_tess_quad_domain` | a quad patch's domain points with rasterization disabled: each marks the word of cell `(rint(u * grid.x), rint(v * grid.y))` in a 65 x 65 grid (`grid` a per-patch attribute) and stores its coordinates after the grid; every store is idempotent | the set of marked cells, which is the tessellator's set of points: each edge's and the inside grid's segment count and placement under the case's factors and partition mode. The cases observe the marks only; the coordinates are there for diagnosis (partition-mode and edge-and-inside cases) |
| `k7_tess_triangle_domain` | `k7_tess_triangle_domain` | the same for a triangle patch, the cell of the first two barycentric coordinates, all three stored after the grid | as `k7_tess_quad_domain` (fractional-partition and edge-and-inside cases) |
| `tess_rendered_patches` | `tess_rendered_patches`, `tess_rendered_patches_fragment` | a triangle patch drawn into a colour target: three control points through the vertex descriptor (a clip-space `float2` each), each domain point at its barycentric blend of them, and a per-patch colour passed flat, which the fragment function writes | a pixel says which patch covers it, if any: culled factors, which patch's factors and attributes a draw read, and the winding a cull mode sees (the conformance case `tessellation-rendered-patches`) |
| `tess_draw_bases` | `draw_bases_after_tessellation` | a rasterization-disabled post-tessellation function (triangle patches of three control points, no stage-in) whose patch `pid` of instance `iid` writes `pid`, `iid` and `[[base_instance]]` to slot `(iid % 4) * 8 + pid % 8` | after tessellation each patch of each instance reads the draw's `baseInstance` and an instance id that includes it (an Apple M3 Max, two patches of two instances from base instance 3); the runtime's `every_device_reads_a_patch_draw_s_base_instance_after_tessellation` draws it |
| `tess_primitive_ids` | `tess_primitive_ids`, `tess_primitive_ids_fragment` | a triangle patch of three control points with no stage-in, placing patch `pid` of instance `iid` in its own tile of an 8x8 target (column `pid % 4`, two pixels wide; row `iid % 2`, four high) and passing `pid` and `iid` flat; a fragment function writing `[[primitive_id]]`, `pid`, `iid` and 1 | a fragment's `[[primitive_id]]` behind a post-tessellation function is its patch's position in the draw, patch start included, the same in every instance and for every triangle of the patch (an Apple M3 Max, every factor 4); the runtime's `every_device_reads_a_patch_s_position_as_its_fragments_primitive_id` draws it |
| `nil_slots` | `nil_vertex`, `nil_post_tess`, `nil_fragment` | a plain draw and a triangle patch draw whose vertex, post-tessellation and fragment functions each read and query the width, height and levels of texture slot 0 (which they also sample) and of an argument buffer's four textures, writing one record each: texture slot 0 bound to nil, IDs of 0, of a granted index no texture took, of a texture that went, and of a live texture; the post-tessellation function also records its three control points and its patch's tint | every command buffer completes, and the live texture's texel and size, the control points, the tint and the stage words are exact in every stage of both draws (the runtime's device test `every_stage_runs_its_live_work_beside_texture_slots_that_hold_no_texture`); what a member function of a nil texture returns is undefined (Metal Shading Language, section 6.13.18) and not held |
| `exf_fetch_blend` | `exf_fetch_blend` | programmable blending, `(float4(position.xy, 1, -0.5) + dst) / 2` over the color attachment it reads (one rounded sum, nothing contracts) | after `n` instances of the fullscreen triangle each pixel holds the blend applied `n` times in order (overlapping-fragment ordering cases) |
@@ -263,7 +264,7 @@ threadgroup's threads); an authored case that executes a loop declares it
| `nan_dot`, `nan_dot_fast` | `nan_dot`, `nan_dot_fast` | `dot` on two, three and four `float` and `half` lanes, and `dot(float2(a, b), float2(b, c))` and `dot(float2(a, b), float2(b, a))`, over near-cancellations, signed zeros, the smallest normals and denormal operands clear of the tininess edge, without fast math and under the default fast math | Metal's fused chain `fma(x[n-1], y[n-1], ... fma(x[1], y[1], x[0] * y[0]))`, `half` rounding each step to `half`, the same in both modes (cases `dot-of-two-to-four-float-and-half-lanes`, and `...-under-fast-math`) |
| `rrp_mirror_clamp` | `rrp_mc_sample`, `rrp_mc_gather`, `rrp_mc_compare` | samples, gathers and depth comparisons of a `texture2d<float>` or `depth2d<float>` through the runtime sampler at slot 0, with no texel offset and with offsets -3, 2, -7 and 5 on `s`; each lane reads its coordinate (a comparison's reference in `.z`) from buffer 0 and writes five results to buffer 1 | the texels Metal reads through a `MirrorClampToEdge` axis with pixel and normalized coordinates (measured on an M4: each tap's index mirrored once and clamped, the offset placed as on a repeating axis); no authored case, the runtime lane's `mirror_clamp` test checks it on each device |
| `rrp_swizzled_storage` | `rrp_sw_read_f`, `rrp_sw_rwread_f`, `rrp_sw_write_f`, `rrp_sw_rwwrite_f`, `rrp_sw_rwread_u`, `rrp_sw_write_u`, `rrp_sw_atomic_u` | reads, writes and an atomic add of a `texture2d` through `access::read`, `access::write` and `access::read_write` at slot 0; a read writes texel (0, 0) to buffer 0, a write stores buffer 1's value at its thread's texel, the atomic adds 5 to texel (0, 0) and writes the value it held to buffer 0 | what Metal reads and stores through a swizzled view bound for writing, and through a texture whose declared usage the access skips (measured on an M4); no authored case |
| `rvc_draw_bases` | `draw_bases_in_a_vertex_function`, `narrow_draw_bases_in_a_vertex_function`, `base_instance_after_tessellation`, `draw_bases_after_tessellation` | `[[base_vertex]]` and `[[base_instance]]` read as `uint` and as `ushort` in a vertex function, rasterization-disabled points each writing its `vid`, `iid` and the two bases to slot `(iid % 4) * 8 + vid % 8`; `[[base_instance]]` after tessellation; and a rasterization-disabled post-tessellation function whose patch `pid` of instance `iid` writes `pid`, `iid` and `[[base_instance]]` to slot `(iid % 4) * 8 + pid % 8` | Metal's base vertex is the draw's `vertexStart` without an index buffer and its `baseVertex` with one, its base instance the draw's `baseInstance`, a `ushort` the low 16 bits (cases `draw-bases-of-a-draw-from-vertex-start-0xfffffffa-and-base-instance-7`, `draw-bases-of-an-indexed-draw-with-base-vertex-minus-3-and-base-instance-2` and their `ushort-` forms); the runtime lane's `draw_bases` test draws them directly, indirectly and from an indirect command buffer; after tessellation, each patch of each instance reads the draw's `baseInstance` and an instance id that includes it (an Apple M3 Max, two patches of two instances from base instance 3), which the runtime's `every_device_reads_a_patch_draw_s_base_instance_after_tessellation` checks |
| `rvc_draw_bases` | `draw_bases_in_a_vertex_function`, `narrow_draw_bases_in_a_vertex_function`, `base_instance_after_tessellation` | `[[base_vertex]]` and `[[base_instance]]` read as `uint` and as `ushort` in a vertex function, rasterization-disabled points each writing its `vid`, `iid` and the two bases to slot `(iid % 4) * 8 + vid % 8`; and `[[base_instance]]` after tessellation | Metal's base vertex is the draw's `vertexStart` without an index buffer and its `baseVertex` with one, its base instance the draw's `baseInstance`, a `ushort` the low 16 bits (cases `draw-bases-of-a-draw-from-vertex-start-0xfffffffa-and-base-instance-7`, `draw-bases-of-an-indexed-draw-with-base-vertex-minus-3-and-base-instance-2` and their `ushort-` forms); the runtime lane's `draw_bases` test draws them directly, indirectly and from an indirect command buffer |
| `rvc_load_before_store_loop` | `load_before_a_loop_that_stores_over_it` | one thread loads a word before a loop, reads it once in each iteration, and the loop stores over the element it was loaded from (slots, element and trip count from buffers) | every iteration reads the word loaded before the loop: `values` ends as 42, 21, 35, 49 (case `every-iteration-reads-the-word-loaded-before-the-loop-not-the-loops-own-stores`; a loop that read the element again would end as 336, 42, 280, 2352) |
| `rvc_simd_vertex` | `simd_functions_in_a_vertex_function` | `simd_sum`, `simd_shuffle`, `simd_shuffle_xor` and `simd_ballot` in a vertex function, forty rasterization-disabled points | Metal runs them there; on an M4 vertices 0 to 31 form one simdgroup and 32 to 39 another (case `simd-sum-shuffle-shuffle-xor-and-ballot-in-a-vertex-function`); a device needs subgroup operations in the vertex stage |
| `rvc_simd_vertex_fill` | `simd_shuffle_and_fill_down_in_a_vertex_function` | `simd_shuffle_and_fill_down` with a modulo of 32 in a vertex function | Metal's compiler takes this form there and refuses the form without a modulo in a vertex function |
@@ -353,7 +353,7 @@ fixture rt6_viewports: metal: Apple metal version 32023.921 (metalfe-32023.921.6
fixture rt_instance_count: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rtl_cube_grad_fragment: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rtl_lockstep: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rvc_draw_bases: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture rvc_draw_bases: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rvc_load_before_store_loop: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rvc_simd_vertex: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture rvc_simd_vertex_fill: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
@@ -395,6 +395,7 @@ fixture tail_argument_cube_gradient: metal: Apple metal version 32023.921 (metal
fixture tail_argument_samplers: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture tail_argument_sparse_samples: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture tail_cases: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
fixture tess_draw_bases: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture tess_primitive_ids: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture tess_rendered_patches: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
fixture tgp_composite: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
@@ -16,7 +16,7 @@ define void @draw_bases_in_a_vertex_function(i32 noundef %0, i32 noundef %1, i32
%13 = or i32 %11, %12
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %4, i64 %14
store <4 x i32> %9, <4 x i32> addrspace(1)* %15, align 16, !tbaa !40, !alias.scope !43
store <4 x i32> %9, <4 x i32> addrspace(1)* %15, align 16, !tbaa !35, !alias.scope !38
ret void
}
@@ -34,7 +34,7 @@ define void @narrow_draw_bases_in_a_vertex_function(i32 noundef %0, i32 noundef
%15 = or i32 %13, %14
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %4, i64 %16
store <4 x i32> %11, <4 x i32> addrspace(1)* %17, align 16, !tbaa !40, !alias.scope !46
store <4 x i32> %11, <4 x i32> addrspace(1)* %17, align 16, !tbaa !35, !alias.scope !41
ret void
}
@@ -52,34 +52,19 @@ define <4 x float> @base_instance_after_tessellation(i32 noundef %0, i32 noundef
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #2
; Function Attrs: argmemonly mustprogress nofree norecurse nosync nounwind willreturn writeonly
define void @draw_bases_after_tessellation(i32 noundef %0, i32 noundef %1, i32 noundef %2, <4 x i32> addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %3) local_unnamed_addr #0 {
%5 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 1>, i32 %0, i64 0
%6 = insertelement <4 x i32> %5, i32 %1, i64 1
%7 = insertelement <4 x i32> %6, i32 %2, i64 2
%8 = shl i32 %1, 3
%9 = and i32 %8, 24
%10 = and i32 %0, 7
%11 = or i32 %9, %10
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %3, i64 %12
store <4 x i32> %7, <4 x i32> addrspace(1)* %13, align 16, !tbaa !40, !alias.scope !49
ret void
}
attributes #0 = { argmemonly mustprogress nofree norecurse nosync nounwind willreturn writeonly "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"="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 nofree nosync nounwind readnone willreturn }
attributes #3 = { nounwind readnone willreturn }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.vertex = !{!9, !17, !21, !29}
!air.compile_options = !{!34, !35, !36}
!llvm.ident = !{!37}
!air.version = !{!38}
!air.language_version = !{!39}
!air.vertex = !{!9, !17, !21}
!air.compile_options = !{!29, !30, !31}
!llvm.ident = !{!32}
!air.version = !{!33}
!air.language_version = !{!34}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"frame-pointer", i32 2}
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
@@ -108,26 +93,18 @@ attributes #3 = { nounwind readnone willreturn }
!26 = !{i32 1, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!27 = !{i32 2, !"air.position_in_patch", !"air.arg_type_name", !"float3", !"air.arg_name", !"coord"}
!28 = !{!"air.patch", !"triangle", !"air.patch_control_point", i32 3}
!29 = !{void (i32, i32, i32, <4 x i32> addrspace(1)*)* @draw_bases_after_tessellation, !10, !30, !28}
!30 = !{!31, !13, !32, !33}
!31 = !{i32 0, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!32 = !{i32 2, !"air.base_instance", !"air.arg_type_name", !"uint", !"air.arg_name", !"base_instance"}
!33 = !{i32 3, !"air.buffer", !"air.location_index", i32 0, 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", !"uint4", !"air.arg_name", !"out"}
!34 = !{!"air.compile.denorms_disable"}
!35 = !{!"air.compile.fast_math_enable"}
!36 = !{!"air.compile.framebuffer_fetch_enable"}
!37 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!38 = !{i32 2, i32 8, i32 0}
!39 = !{!"Metal", i32 4, i32 0, i32 0}
!40 = !{!41, !41, i64 0}
!41 = !{!"omnipotent char", !42, i64 0}
!42 = !{!"Simple C++ TBAA"}
!43 = !{!44}
!44 = distinct !{!44, !45, !"air-alias-scope-arg(4)"}
!45 = distinct !{!45, !"air-alias-scopes(draw_bases_in_a_vertex_function)"}
!46 = !{!47}
!47 = distinct !{!47, !48, !"air-alias-scope-arg(4)"}
!48 = distinct !{!48, !"air-alias-scopes(narrow_draw_bases_in_a_vertex_function)"}
!49 = !{!50}
!50 = distinct !{!50, !51, !"air-alias-scope-arg(3)"}
!51 = distinct !{!51, !"air-alias-scopes(draw_bases_after_tessellation)"}
!29 = !{!"air.compile.denorms_disable"}
!30 = !{!"air.compile.fast_math_enable"}
!31 = !{!"air.compile.framebuffer_fetch_enable"}
!32 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"}
!33 = !{i32 2, i32 8, i32 0}
!34 = !{!"Metal", i32 4, i32 0, i32 0}
!35 = !{!36, !36, i64 0}
!36 = !{!"omnipotent char", !37, i64 0}
!37 = !{!"Simple C++ TBAA"}
!38 = !{!39}
!39 = distinct !{!39, !40, !"air-alias-scope-arg(4)"}
!40 = distinct !{!40, !"air-alias-scopes(draw_bases_in_a_vertex_function)"}
!41 = !{!42}
!42 = distinct !{!42, !43, !"air-alias-scope-arg(4)"}
!43 = distinct !{!43, !"air-alias-scopes(narrow_draw_bases_in_a_vertex_function)"}
@@ -16,7 +16,7 @@ define void @draw_bases_in_a_vertex_function(i32 noundef %0, i32 noundef %1, i32
%13 = or i32 %11, %12
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %4, i64 %14
store <4 x i32> %9, ptr addrspace(1) %15, align 16, !tbaa !40, !alias.scope !43
store <4 x i32> %9, ptr addrspace(1) %15, align 16, !tbaa !35, !alias.scope !38
ret void
}
@@ -34,7 +34,7 @@ define void @narrow_draw_bases_in_a_vertex_function(i32 noundef %0, i32 noundef
%15 = or i32 %13, %14
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %4, i64 %16
store <4 x i32> %11, ptr addrspace(1) %17, align 16, !tbaa !40, !alias.scope !46
store <4 x i32> %11, ptr addrspace(1) %17, align 16, !tbaa !35, !alias.scope !41
ret void
}
@@ -52,34 +52,19 @@ define <4 x float> @base_instance_after_tessellation(i32 noundef %0, i32 noundef
; 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 norecurse nosync nounwind willreturn memory(argmem: write)
define void @draw_bases_after_tessellation(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %3) local_unnamed_addr #0 {
%5 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 1>, i32 %0, i64 0
%6 = insertelement <4 x i32> %5, i32 %1, i64 1
%7 = insertelement <4 x i32> %6, i32 %2, i64 2
%8 = shl i32 %1, 3
%9 = and i32 %8, 24
%10 = and i32 %0, 7
%11 = or i32 %9, %10
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %3, i64 %12
store <4 x i32> %7, ptr addrspace(1) %13, align 16, !tbaa !40, !alias.scope !49
ret void
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) "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"="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 nofree nosync nounwind willreturn memory(none) }
attributes #3 = { nounwind willreturn memory(none) }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.vertex = !{!9, !17, !21, !29}
!air.compile_options = !{!34, !35, !36}
!llvm.ident = !{!37}
!air.version = !{!38}
!air.language_version = !{!39}
!air.vertex = !{!9, !17, !21}
!air.compile_options = !{!29, !30, !31}
!llvm.ident = !{!32}
!air.version = !{!33}
!air.language_version = !{!34}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 0]}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"frame-pointer", i32 2}
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
@@ -108,26 +93,18 @@ attributes #3 = { nounwind willreturn memory(none) }
!26 = !{i32 1, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!27 = !{i32 2, !"air.position_in_patch", !"air.arg_type_name", !"float3", !"air.arg_name", !"coord"}
!28 = !{!"air.patch", !"triangle", !"air.patch_control_point", i32 3}
!29 = !{ptr @draw_bases_after_tessellation, !10, !30, !28}
!30 = !{!31, !13, !32, !33}
!31 = !{i32 0, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!32 = !{i32 2, !"air.base_instance", !"air.arg_type_name", !"uint", !"air.arg_name", !"base_instance"}
!33 = !{i32 3, !"air.buffer", !"air.location_index", i32 0, 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", !"uint4", !"air.arg_name", !"out"}
!34 = !{!"air.compile.denorms_disable"}
!35 = !{!"air.compile.fast_math_enable"}
!36 = !{!"air.compile.framebuffer_fetch_enable"}
!37 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!38 = !{i32 2, i32 8, i32 0}
!39 = !{!"Metal", i32 4, i32 0, i32 0}
!40 = !{!41, !41, i64 0}
!41 = !{!"omnipotent char", !42, i64 0}
!42 = !{!"Simple C++ TBAA"}
!43 = !{!44}
!44 = distinct !{!44, !45, !"air-alias-scope-arg(4)"}
!45 = distinct !{!45, !"air-alias-scopes(draw_bases_in_a_vertex_function)"}
!46 = !{!47}
!47 = distinct !{!47, !48, !"air-alias-scope-arg(4)"}
!48 = distinct !{!48, !"air-alias-scopes(narrow_draw_bases_in_a_vertex_function)"}
!49 = !{!50}
!50 = distinct !{!50, !51, !"air-alias-scope-arg(3)"}
!51 = distinct !{!51, !"air-alias-scopes(draw_bases_after_tessellation)"}
!29 = !{!"air.compile.denorms_disable"}
!30 = !{!"air.compile.fast_math_enable"}
!31 = !{!"air.compile.framebuffer_fetch_enable"}
!32 = !{!"Apple metal version 32023.921 (metalfe-32023.921.6)"}
!33 = !{i32 2, i32 8, i32 0}
!34 = !{!"Metal", i32 4, i32 0, i32 0}
!35 = !{!36, !36, i64 0}
!36 = !{!"omnipotent char", !37, i64 0}
!37 = !{!"Simple C++ TBAA"}
!38 = !{!39}
!39 = distinct !{!39, !40, !"air-alias-scope-arg(4)"}
!40 = distinct !{!40, !"air-alias-scopes(draw_bases_in_a_vertex_function)"}
!41 = !{!42}
!42 = distinct !{!42, !43, !"air-alias-scope-arg(4)"}
!43 = distinct !{!43, !"air-alias-scopes(narrow_draw_bases_in_a_vertex_function)"}
@@ -4,11 +4,9 @@
// each vertex of up to eight consecutive ones and each instance of up to four consecutive ones
// lands in a slot of its own. Metal's base vertex is the draw's `vertexStart` without an index
// buffer and its `baseVertex` with one; its base instance is the draw's `baseInstance`. The narrow
// entry reads both as `ushort`, their low 16 bits. The post-tessellation entries read
// entry reads both as `ushort`, their low 16 bits. The post-tessellation entry reads
// `[[base_instance]]`, which Metal also allows there (and refuses `[[base_vertex]]`, as it
// refuses both in mesh and object functions); the rasterization-disabled one writes `pid`, `iid`
// and `[[base_instance]]` to out[(iid % 4) * 8 + pid % 8], for each patch of each instance.
// Loop-free.
// refuses both in mesh and object functions). Loop-free.
#include <metal_stdlib>
using namespace metal;
@@ -35,11 +33,3 @@ vertex float4 base_instance_after_tessellation(uint base_instance [[base_instanc
{
return float4(coord.xy, float(base_instance), float(pid) + 1.0f);
}
[[patch(triangle, 3)]]
vertex void draw_bases_after_tessellation(uint pid [[patch_id]], uint iid [[instance_id]],
uint base_instance [[base_instance]],
device uint4 *out [[buffer(0)]])
{
out[(iid % 4) * 8 + pid % 8] = uint4(pid, iid, base_instance, 1u);
}
@@ -0,0 +1,59 @@
; Generated by scripts/regen-air-fixtures from tess_draw_bases.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"
; Function Attrs: argmemonly mustprogress nofree norecurse nosync nounwind willreturn writeonly
define void @draw_bases_after_tessellation(i32 noundef %0, i32 noundef %1, i32 noundef %2, <4 x i32> addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %3) local_unnamed_addr #0 {
%5 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 1>, i32 %0, i64 0
%6 = insertelement <4 x i32> %5, i32 %1, i64 1
%7 = insertelement <4 x i32> %6, i32 %2, i64 2
%8 = shl i32 %1, 3
%9 = and i32 %8, 24
%10 = and i32 %0, 7
%11 = or i32 %9, %10
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %3, i64 %12
store <4 x i32> %7, <4 x i32> addrspace(1)* %13, align 16, !tbaa !23, !alias.scope !26
ret void
}
attributes #0 = { argmemonly mustprogress nofree norecurse nosync nounwind willreturn writeonly "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" }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.vertex = !{!9}
!air.compile_options = !{!17, !18, !19}
!llvm.ident = !{!20}
!air.version = !{!21}
!air.language_version = !{!22}
!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, i32, i32, <4 x i32> addrspace(1)*)* @draw_bases_after_tessellation, !10, !11, !16}
!10 = !{}
!11 = !{!12, !13, !14, !15}
!12 = !{i32 0, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!13 = !{i32 1, !"air.instance_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"iid"}
!14 = !{i32 2, !"air.base_instance", !"air.arg_type_name", !"uint", !"air.arg_name", !"base_instance"}
!15 = !{i32 3, !"air.buffer", !"air.location_index", i32 0, 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", !"uint4", !"air.arg_name", !"out"}
!16 = !{!"air.patch", !"triangle", !"air.patch_control_point", i32 3}
!17 = !{!"air.compile.denorms_disable"}
!18 = !{!"air.compile.fast_math_enable"}
!19 = !{!"air.compile.framebuffer_fetch_enable"}
!20 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!21 = !{i32 2, i32 8, i32 0}
!22 = !{!"Metal", i32 4, i32 0, i32 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"omnipotent char", !25, i64 0}
!25 = !{!"Simple C++ TBAA"}
!26 = !{!27}
!27 = distinct !{!27, !28, !"air-alias-scope-arg(3)"}
!28 = distinct !{!28, !"air-alias-scopes(draw_bases_after_tessellation)"}
@@ -0,0 +1,59 @@
; Generated by scripts/regen-air-fixtures from tess_draw_bases.metal (llvm-dis of tess_draw_bases.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"
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
define void @draw_bases_after_tessellation(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %3) local_unnamed_addr #0 {
%5 = insertelement <4 x i32> <i32 poison, i32 poison, i32 poison, i32 1>, i32 %0, i64 0
%6 = insertelement <4 x i32> %5, i32 %1, i64 1
%7 = insertelement <4 x i32> %6, i32 %2, i64 2
%8 = shl i32 %1, 3
%9 = and i32 %8, 24
%10 = and i32 %0, 7
%11 = or i32 %9, %10
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %3, i64 %12
store <4 x i32> %7, ptr addrspace(1) %13, align 16, !tbaa !23, !alias.scope !26
ret void
}
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) "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" }
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!air.vertex = !{!9}
!air.compile_options = !{!17, !18, !19}
!llvm.ident = !{!20}
!air.version = !{!21}
!air.language_version = !{!22}
!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 @draw_bases_after_tessellation, !10, !11, !16}
!10 = !{}
!11 = !{!12, !13, !14, !15}
!12 = !{i32 0, !"air.patch_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"pid"}
!13 = !{i32 1, !"air.instance_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"iid"}
!14 = !{i32 2, !"air.base_instance", !"air.arg_type_name", !"uint", !"air.arg_name", !"base_instance"}
!15 = !{i32 3, !"air.buffer", !"air.location_index", i32 0, 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", !"uint4", !"air.arg_name", !"out"}
!16 = !{!"air.patch", !"triangle", !"air.patch_control_point", i32 3}
!17 = !{!"air.compile.denorms_disable"}
!18 = !{!"air.compile.fast_math_enable"}
!19 = !{!"air.compile.framebuffer_fetch_enable"}
!20 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
!21 = !{i32 2, i32 8, i32 0}
!22 = !{!"Metal", i32 4, i32 0, i32 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"omnipotent char", !25, i64 0}
!25 = !{!"Simple C++ TBAA"}
!26 = !{!27}
!27 = distinct !{!27, !28, !"air-alias-scope-arg(3)"}
!28 = distinct !{!28, !"air-alias-scopes(draw_bases_after_tessellation)"}
@@ -0,0 +1,17 @@
// Owned fixture (written for this repository): a draw's base instance after tessellation. A
// rasterization-disabled post-tessellation vertex function (triangle patches of three control
// points, no stage-in): patch `pid` of instance `iid` writes `pid`, `iid`, `[[base_instance]]` and
// 1 to the four words of out[(iid % 4) * 8 + pid % 8], so each patch of up to eight consecutive
// ones and each instance of up to four consecutive ones lands in a slot of its own. Metal allows
// `[[base_instance]]` there (and refuses `[[base_vertex]]`); its instance id includes the draw's
// base instance. Loop-free.
#include <metal_stdlib>
using namespace metal;
[[patch(triangle, 3)]]
vertex void draw_bases_after_tessellation(uint pid [[patch_id]], uint iid [[instance_id]],
uint base_instance [[base_instance]],
device uint4 *out [[buffer(0)]])
{
out[(iid % 4) * 8 + pid % 8] = uint4(pid, iid, base_instance, 1u);
}
@@ -2,19 +2,19 @@
//!
//! The owned fixture `engine/rvc_draw_bases` reads `[[base_vertex]]` and `[[base_instance]]`
//! as `uint` (`draw_bases_in_a_vertex_function`) and as `ushort`
//! (`narrow_draw_bases_in_a_vertex_function`) in a vertex function, and `[[base_instance]]` in
//! post-tessellation vertex functions (`base_instance_after_tessellation`, and
//! `draw_bases_after_tessellation`, which stores it). On every committed profile that compiles
//! it, each module passes L3 (`spirv-val` and requirements within the profile), and reads the
//! bases from Vulkan's `BaseVertex` and `BaseInstance` with `shaderDrawParameters` and from
//! `PushField::BaseVertexInstance` without it; an evaluation shader, which has no `BaseInstance`,
//! reads the base-instance patch input the control stage writes with `shaderDrawParameters` and
//! the push field without it. On the CPU interpreter, each vertex of a draw from a large first
//! vertex and instance reads the draw's bases, the narrow entry their low 16 bits. No GPU is
//! used; the runtime's device test
//! (`narrow_draw_bases_in_a_vertex_function`) in a vertex function, and `[[base_instance]]` in a
//! post-tessellation vertex function (`base_instance_after_tessellation`); the owned fixture
//! `engine/tess_draw_bases`'s `draw_bases_after_tessellation` stores it after tessellation. On
//! every committed profile that compiles them, each module passes L3 (`spirv-val` and
//! requirements within the profile), and reads the bases from Vulkan's `BaseVertex` and
//! `BaseInstance` with `shaderDrawParameters` and from `PushField::BaseVertexInstance` without it;
//! an evaluation shader, which has no `BaseInstance`, reads the base-instance patch input the
//! control stage writes with `shaderDrawParameters` and the push field without it. On the CPU
//! interpreter, each vertex of a draw from a large first vertex and instance reads the draw's
//! bases, the narrow entry their low 16 bits. No GPU is used; the runtime's device test
//! `every_device_reads_a_patch_draw_s_base_instance_after_tessellation` draws the stored form.
//!
//! `llvm-as` assembles the fixture; a missing tool skips visibly.
//! `llvm-as` assembles the fixtures; a missing tool skips visibly.
use std::sync::Arc;
@@ -42,13 +42,17 @@ const TESSELLATED: &str = "base_instance_after_tessellation";
const TESSELLATED_STORES: &str = "draw_bases_after_tessellation";
fn fixture() -> Option<Vec<u8>> {
match llvm_assemble(&engine_dir().join("rvc_draw_bases.ll")) {
assemble("rvc_draw_bases")
}
fn assemble(stem: &str) -> Option<Vec<u8>> {
match llvm_assemble(&engine_dir().join(format!("{stem}.ll"))) {
Ok(b) => Some(b),
Err(AssembleError::Missing(why)) => {
eprintln!("SKIPPED: {why}");
None
}
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected rvc_draw_bases.ll: {why}"),
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected {stem}.ll: {why}"),
}
}
@@ -231,6 +235,9 @@ fn each_vertex_reads_its_draw_s_bases() {
#[test]
fn the_base_instance_after_tessellation_is_the_patch_input_or_the_push_lane() {
let Some(bc) = fixture() else { return };
let Some(stores) = assemble("tess_draw_bases") else {
return;
};
let (mut carried, mut pushed) = (0, 0);
let mut profiles = committed_profiles().expect("committed profiles");
profiles.push((
@@ -247,9 +254,9 @@ fn the_base_instance_after_tessellation_is_the_patch_input_or_the_push_lane() {
continue;
}
let draw = p.fields().draw_parameters;
for entry in [TESSELLATED, TESSELLATED_STORES] {
for (bc, entry) in [(&bc, TESSELLATED), (&stores, TESSELLATED_STORES)] {
let what = format!("{stem} {entry}");
let a = match compile(&bc, entry, &p) {
let a = match compile(bc, entry, &p) {
Ok(a) => a,
Err(Error::Unsupported(u))
if entry == TESSELLATED_STORES