Validation: multisampled passes and textures run through the runtime
Family H of the executor's move onto metal2vulkan-runtime: a render case of more samples (raster_sample_count), and any case binding a multisampled texture, now runs on the runtime's public API, filled and read back as executor_contract::multisample states for both executors. Metal uploads and copies no multisampled texture, and neither does the runtime. So runtime_multisample fills each slice with one draw of the owned sample_fill fixture (fixtures/public/engine/sample_fill.metal, compiled by scripts/regen-air-fixtures), whose fragment runs once per sample (sample_id) and writes that sample's texel from a buffer: a color texel through an unsigned-integer view of its texel size (the texture made with PixelFormatView usage), so its bits cross unconverted, a Depth32Float one as depth(any) under an always-passing depth test that writes (a depth outside [0, 1] refused as depth_outside_unit_range, as runtime_depth refuses it). A multisampled stencil aspect holds one value in every sample (uniform_stencil), which the case's pass clears it to. After the draw a dispatch of the fixture's sample_read kernels reads every sample, one threadgroup each, as whole words in the attachment layout (unpack_words), unresolved, as the oracle's sample_readback does. runtime_textures makes a multisampled texture Private (Metal keeps none Shared), for rendering and, if color, for views of another format, and fills it by those draws. runtime_render makes each attachment of a multisampled pass a Private Type2DMultisample texture of the pass's samples, with a texture index for its read's view, and reads every sample back for the comparison. engine::runtime_texture no longer keeps a multisampled texture off the runtime, and runs_render_through_runtime takes any sample count. An attachment of both aspects still carries separate_depth_stencil. What moves: of the committed cases, 49 multisampled passes (all public; 2 with both aspects keep the requirement) and 8 cases with a multisampled input texture (7 public kernel cases, 1 private fragment case). ENGINE_EXECUTOR_ABI to vulkan-engine-v197. The new owned fixture adds rows to the golden tables, re-blessed on development. Tests: engine/tests.rs routes a multisampled pass, multisampled depth and stencil attachments and a kernel's multisampled texture through the runtime; engine_render.rs's each_sample_of_a_multisampled_target_holds_its_own_invocation draws sample_rate_mask_in into 4 samples and checks each sample's index, on Linux through the runtime too, bytes equal to the executor's own; engine_textures.rs's depth_and_multisampled_textures_read_their_authored_texels runs through the runtime on Linux. Built and run in the lane's compile job (ids sent with the sha); not yet built when committed.
This commit is contained in:
1 parent
6593e998d1
commit
b0e351ffbc
13 files changed
+1555
-154
No files matched your search
@@ -338,6 +338,7 @@ fixture rvc_draw_bases: metal: Apple metal version 32023.921 (metalfe-32023.921.
|
||||
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)
|
||||
fixture sample_fill: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture sample_rate: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture sampler_table: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture sampling: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
; Generated by scripts/regen-air-fixtures from sample_fill.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.SampleShape = type { i32, i32, i32 }
|
||||
%struct._texture_2d_ms_t = type opaque
|
||||
%struct._sampler_t = type opaque
|
||||
%struct._depth_2d_ms_t = type opaque
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
define <4 x float> @sample_fill_vertex(i32 noundef %0) local_unnamed_addr #0 {
|
||||
%2 = shl i32 %0, 1
|
||||
%3 = and i32 %2, 2
|
||||
%4 = tail call float @air.convert.f.f32.u.i32(i32 %3) #7
|
||||
%5 = insertelement <2 x float> undef, float %4, i64 0
|
||||
%6 = and i32 %0, 2
|
||||
%7 = tail call float @air.convert.f.f32.u.i32(i32 %6) #7
|
||||
%8 = insertelement <2 x float> %5, float %7, i64 1
|
||||
%9 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %8, <2 x float> <float 2.000000e+00, float 2.000000e+00>, <2 x float> <float -1.000000e+00, float -1.000000e+00>)
|
||||
%10 = shufflevector <2 x float> %9, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
|
||||
%11 = shufflevector <4 x float> %10, <4 x float> <float poison, float poison, float 0.000000e+00, float 1.000000e+00>, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
|
||||
ret <4 x float> %11
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn
|
||||
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2
|
||||
|
||||
; Function Attrs: argmemonly mustprogress nofree nosync nounwind readonly willreturn
|
||||
define <4 x i32> @sample_fill_color(<4 x float> noundef %0, i32 noundef %1, <4 x i32> addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %2, %struct.SampleShape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(12) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %5) #7
|
||||
%7 = extractelement <2 x i32> %6, i64 1
|
||||
%8 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %3, i64 0, i32 0
|
||||
%9 = load i32, i32 addrspace(2)* %8, align 4, !tbaa !45, !alias.scope !50, !noalias !53
|
||||
%10 = mul i32 %7, %9
|
||||
%11 = extractelement <2 x i32> %6, i64 0
|
||||
%12 = add i32 %10, %11
|
||||
%13 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %3, i64 0, i32 1
|
||||
%14 = load i32, i32 addrspace(2)* %13, align 4, !tbaa !55, !alias.scope !50, !noalias !53
|
||||
%15 = mul i32 %12, %14
|
||||
%16 = add i32 %15, %1
|
||||
%17 = zext i32 %16 to i64
|
||||
%18 = getelementptr inbounds <4 x i32>, <4 x i32> addrspace(1)* %2, i64 %17
|
||||
%19 = load <4 x i32>, <4 x i32> addrspace(1)* %18, align 16, !tbaa !56, !alias.scope !53, !noalias !50
|
||||
ret <4 x i32> %19
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
declare <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: argmemonly mustprogress nofree nosync nounwind readonly willreturn
|
||||
define <{ float }> @sample_fill_depth(<4 x float> noundef %0, i32 noundef %1, float addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %2, %struct.SampleShape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(12) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %5) #7
|
||||
%7 = extractelement <2 x i32> %6, i64 1
|
||||
%8 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %3, i64 0, i32 0
|
||||
%9 = load i32, i32 addrspace(2)* %8, align 4, !tbaa !45, !alias.scope !57, !noalias !60
|
||||
%10 = mul i32 %7, %9
|
||||
%11 = extractelement <2 x i32> %6, i64 0
|
||||
%12 = add i32 %10, %11
|
||||
%13 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %3, i64 0, i32 1
|
||||
%14 = load i32, i32 addrspace(2)* %13, align 4, !tbaa !55, !alias.scope !57, !noalias !60
|
||||
%15 = mul i32 %12, %14
|
||||
%16 = add i32 %15, %1
|
||||
%17 = zext i32 %16 to i64
|
||||
%18 = getelementptr inbounds float, float addrspace(1)* %2, i64 %17
|
||||
%19 = load float, float addrspace(1)* %18, align 4, !tbaa !62, !alias.scope !60, !noalias !57
|
||||
%20 = insertvalue <{ float }> undef, float %19, 0
|
||||
ret <{ float }> %20
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_color(%struct._texture_2d_ms_t addrspace(1)* nocapture readonly %0, i32 addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, %struct.SampleShape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #8
|
||||
%8 = tail call { <4 x i32>, i8 } @air.read_texture_2d_ms.u.v4i32(%struct._texture_2d_ms_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* %7, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { <4 x i32>, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 0
|
||||
%12 = load i32, i32 addrspace(2)* %11, align 4, !tbaa !45, !alias.scope !64, !noalias !67
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 1
|
||||
%17 = load i32, i32 addrspace(2)* %16, align 4, !tbaa !55, !alias.scope !64, !noalias !67
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 2
|
||||
%21 = load i32, i32 addrspace(2)* %20, align 4, !tbaa !70, !alias.scope !64, !noalias !67
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = extractelement <4 x i32> %9, i64 0
|
||||
%24 = zext i32 %22 to i64
|
||||
%25 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %24
|
||||
store i32 %23, i32 addrspace(1)* %25, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %32
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = extractelement <4 x i32> %9, i64 1
|
||||
%29 = add i32 %22, 1
|
||||
%30 = zext i32 %29 to i64
|
||||
%31 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %30
|
||||
store i32 %28, i32 addrspace(1)* %31, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
br label %32
|
||||
|
||||
32: ; preds = %27, %4
|
||||
%33 = icmp ugt i32 %21, 2
|
||||
br i1 %33, label %34, label %43
|
||||
|
||||
34: ; preds = %32
|
||||
%35 = extractelement <4 x i32> %9, i64 2
|
||||
%36 = add i32 %22, 2
|
||||
%37 = zext i32 %36 to i64
|
||||
%38 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %37
|
||||
store i32 %35, i32 addrspace(1)* %38, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
%39 = extractelement <4 x i32> %9, i64 3
|
||||
%40 = add i32 %22, 3
|
||||
%41 = zext i32 %40 to i64
|
||||
%42 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %41
|
||||
store i32 %39, i32 addrspace(1)* %42, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
br label %43
|
||||
|
||||
43: ; preds = %32, %34
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_depth(%struct._depth_2d_ms_t addrspace(1)* nocapture readonly %0, i32 addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, %struct.SampleShape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #8
|
||||
%8 = tail call { float, i8 } @air.read_depth_2d_ms.f32(%struct._depth_2d_ms_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* %7, i32 1, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { float, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 0
|
||||
%12 = load i32, i32 addrspace(2)* %11, align 4, !tbaa !45, !alias.scope !74, !noalias !77
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 1
|
||||
%17 = load i32, i32 addrspace(2)* %16, align 4, !tbaa !55, !alias.scope !74, !noalias !77
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 2
|
||||
%21 = load i32, i32 addrspace(2)* %20, align 4, !tbaa !70, !alias.scope !74, !noalias !77
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = zext i32 %22 to i64
|
||||
%24 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %23
|
||||
%25 = bitcast i32 addrspace(1)* %24 to float addrspace(1)*
|
||||
store float %9, float addrspace(1)* %25, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %32
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = add i32 %22, 1
|
||||
%29 = zext i32 %28 to i64
|
||||
%30 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %29
|
||||
%31 = bitcast i32 addrspace(1)* %30 to float addrspace(1)*
|
||||
store float %9, float addrspace(1)* %31, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
br label %32
|
||||
|
||||
32: ; preds = %27, %4
|
||||
%33 = icmp ugt i32 %21, 2
|
||||
br i1 %33, label %34, label %43
|
||||
|
||||
34: ; preds = %32
|
||||
%35 = add i32 %22, 2
|
||||
%36 = zext i32 %35 to i64
|
||||
%37 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %36
|
||||
%38 = bitcast i32 addrspace(1)* %37 to float addrspace(1)*
|
||||
store float %9, float addrspace(1)* %38, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
%39 = add i32 %22, 3
|
||||
%40 = zext i32 %39 to i64
|
||||
%41 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %40
|
||||
%42 = bitcast i32 addrspace(1)* %41 to float addrspace(1)*
|
||||
store float %9, float addrspace(1)* %42, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
br label %43
|
||||
|
||||
43: ; preds = %32, %34
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_stencil(%struct._texture_2d_ms_t addrspace(1)* nocapture readonly %0, i32 addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, %struct.SampleShape addrspace(2)* nocapture noundef readonly align 4 dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #8
|
||||
%8 = tail call { <4 x i32>, i8 } @air.read_texture_2d_ms.u.v4i32(%struct._texture_2d_ms_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* %7, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { <4 x i32>, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 0
|
||||
%12 = load i32, i32 addrspace(2)* %11, align 4, !tbaa !45, !alias.scope !82, !noalias !85
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 1
|
||||
%17 = load i32, i32 addrspace(2)* %16, align 4, !tbaa !55, !alias.scope !82, !noalias !85
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, %struct.SampleShape addrspace(2)* %2, i64 0, i32 2
|
||||
%21 = load i32, i32 addrspace(2)* %20, align 4, !tbaa !70, !alias.scope !82, !noalias !85
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = extractelement <4 x i32> %9, i64 0
|
||||
%24 = zext i32 %22 to i64
|
||||
%25 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %24
|
||||
store i32 %23, i32 addrspace(1)* %25, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %31
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = add i32 %22, 1
|
||||
%29 = zext i32 %28 to i64
|
||||
%30 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %29
|
||||
store i32 %23, i32 addrspace(1)* %30, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
br label %31
|
||||
|
||||
31: ; preds = %27, %4
|
||||
%32 = icmp ugt i32 %21, 2
|
||||
br i1 %32, label %33, label %40
|
||||
|
||||
33: ; preds = %31
|
||||
%34 = add i32 %22, 2
|
||||
%35 = zext i32 %34 to i64
|
||||
%36 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %35
|
||||
store i32 %23, i32 addrspace(1)* %36, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
%37 = add i32 %22, 3
|
||||
%38 = zext i32 %37 to i64
|
||||
%39 = getelementptr inbounds i32, i32 addrspace(1)* %1, i64 %38
|
||||
store i32 %23, i32 addrspace(1)* %39, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
br label %40
|
||||
|
||||
40: ; preds = %31, %33
|
||||
ret void
|
||||
}
|
||||
|
||||
; 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 i32>, i8 } @air.read_texture_2d_ms.u.v4i32(%struct._texture_2d_ms_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, <2 x i32>, i32, i32) local_unnamed_addr #6
|
||||
|
||||
; Function Attrs: argmemonly mustprogress nofree nounwind readonly willreturn
|
||||
declare { float, i8 } @air.read_depth_2d_ms.f32(%struct._depth_2d_ms_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, i32, <2 x i32>, i32, i32) local_unnamed_addr #6
|
||||
|
||||
attributes #0 = { mustprogress nofree nosync nounwind readnone willreturn "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #1 = { mustprogress nofree nosync nounwind readnone willreturn }
|
||||
attributes #2 = { mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn }
|
||||
attributes #3 = { argmemonly mustprogress nofree nosync nounwind readonly willreturn "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #4 = { mustprogress nofree nounwind willreturn "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #5 = { inaccessiblememonly mustprogress nofree nounwind readonly willreturn }
|
||||
attributes #6 = { argmemonly mustprogress nofree nounwind readonly willreturn }
|
||||
attributes #7 = { nounwind readnone willreturn }
|
||||
attributes #8 = { inaccessiblememonly nounwind readonly willreturn }
|
||||
attributes #9 = { argmemonly nounwind readonly willreturn }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||
!air.vertex = !{!9}
|
||||
!air.fragment = !{!14, !23}
|
||||
!air.kernel = !{!28, !35, !38}
|
||||
!air.compile_options = !{!39, !40, !41}
|
||||
!llvm.ident = !{!42}
|
||||
!air.version = !{!43}
|
||||
!air.language_version = !{!44}
|
||||
|
||||
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
|
||||
!1 = !{i32 1, !"wchar_size", i32 4}
|
||||
!2 = !{i32 7, !"frame-pointer", i32 2}
|
||||
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
|
||||
!4 = !{i32 7, !"air.max_constant_buffers", i32 31}
|
||||
!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31}
|
||||
!6 = !{i32 7, !"air.max_textures", i32 128}
|
||||
!7 = !{i32 7, !"air.max_read_write_textures", i32 8}
|
||||
!8 = !{i32 7, !"air.max_samplers", i32 16}
|
||||
!9 = !{<4 x float> (i32)* @sample_fill_vertex, !10, !12}
|
||||
!10 = !{!11}
|
||||
!11 = !{!"air.position", !"air.arg_type_name", !"float4"}
|
||||
!12 = !{!13}
|
||||
!13 = !{i32 0, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"vertex_id"}
|
||||
!14 = !{<4 x i32> (<4 x float>, i32, <4 x i32> addrspace(1)*, %struct.SampleShape addrspace(2)*)* @sample_fill_color, !15, !17}
|
||||
!15 = !{!16}
|
||||
!16 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"}
|
||||
!17 = !{!18, !19, !20, !21}
|
||||
!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!19 = !{i32 1, !"air.sample_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"sample"}
|
||||
!20 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"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", !"texels"}
|
||||
!21 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 12, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 12, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"SampleShape", !"air.arg_name", !"shape"}
|
||||
!22 = !{i32 0, i32 4, i32 0, !"uint", !"width", i32 4, i32 4, i32 0, !"uint", !"samples", i32 8, i32 4, i32 0, !"uint", !"words"}
|
||||
!23 = !{<{ float }> (<4 x float>, i32, float addrspace(1)*, %struct.SampleShape addrspace(2)*)* @sample_fill_depth, !24, !26}
|
||||
!24 = !{!25}
|
||||
!25 = !{!"air.depth", !"air.depth_qualifier", !"air.any", !"air.arg_type_name", !"float", !"air.arg_name", !"depth"}
|
||||
!26 = !{!18, !19, !27, !21}
|
||||
!27 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"texels"}
|
||||
!28 = !{void (%struct._texture_2d_ms_t addrspace(1)*, i32 addrspace(1)*, %struct.SampleShape addrspace(2)*, <3 x i32>)* @sample_read_color, !29, !30}
|
||||
!29 = !{}
|
||||
!30 = !{!31, !32, !33, !34}
|
||||
!31 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture2d_ms<uint, read>", !"air.arg_name", !"source"}
|
||||
!32 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"words"}
|
||||
!33 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 12, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 12, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"SampleShape", !"air.arg_name", !"shape"}
|
||||
!34 = !{i32 3, !"air.threadgroup_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"position"}
|
||||
!35 = !{void (%struct._depth_2d_ms_t addrspace(1)*, i32 addrspace(1)*, %struct.SampleShape addrspace(2)*, <3 x i32>)* @sample_read_depth, !29, !36}
|
||||
!36 = !{!37, !32, !33, !34}
|
||||
!37 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"depth2d_ms<float, read>", !"air.arg_name", !"source"}
|
||||
!38 = !{void (%struct._texture_2d_ms_t addrspace(1)*, i32 addrspace(1)*, %struct.SampleShape addrspace(2)*, <3 x i32>)* @sample_read_stencil, !29, !30}
|
||||
!39 = !{!"air.compile.denorms_disable"}
|
||||
!40 = !{!"air.compile.fast_math_disable"}
|
||||
!41 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!42 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!43 = !{i32 2, i32 8, i32 0}
|
||||
!44 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!45 = !{!46, !47, i64 0}
|
||||
!46 = !{!"_ZTS11SampleShape", !47, i64 0, !47, i64 4, !47, i64 8}
|
||||
!47 = !{!"int", !48, i64 0}
|
||||
!48 = !{!"omnipotent char", !49, i64 0}
|
||||
!49 = !{!"Simple C++ TBAA"}
|
||||
!50 = !{!51}
|
||||
!51 = distinct !{!51, !52, !"air-alias-scope-arg(3)"}
|
||||
!52 = distinct !{!52, !"air-alias-scopes(sample_fill_color)"}
|
||||
!53 = !{!54}
|
||||
!54 = distinct !{!54, !52, !"air-alias-scope-arg(2)"}
|
||||
!55 = !{!46, !47, i64 4}
|
||||
!56 = !{!48, !48, i64 0}
|
||||
!57 = !{!58}
|
||||
!58 = distinct !{!58, !59, !"air-alias-scope-arg(3)"}
|
||||
!59 = distinct !{!59, !"air-alias-scopes(sample_fill_depth)"}
|
||||
!60 = !{!61}
|
||||
!61 = distinct !{!61, !59, !"air-alias-scope-arg(2)"}
|
||||
!62 = !{!63, !63, i64 0}
|
||||
!63 = !{!"float", !48, i64 0}
|
||||
!64 = !{!65}
|
||||
!65 = distinct !{!65, !66, !"air-alias-scope-arg(2)"}
|
||||
!66 = distinct !{!66, !"air-alias-scopes(sample_read_color)"}
|
||||
!67 = !{!68, !69}
|
||||
!68 = distinct !{!68, !66, !"air-alias-scope-textures"}
|
||||
!69 = distinct !{!69, !66, !"air-alias-scope-arg(1)"}
|
||||
!70 = !{!46, !47, i64 8}
|
||||
!71 = !{!47, !47, i64 0}
|
||||
!72 = !{!69}
|
||||
!73 = !{!68, !65}
|
||||
!74 = !{!75}
|
||||
!75 = distinct !{!75, !76, !"air-alias-scope-arg(2)"}
|
||||
!76 = distinct !{!76, !"air-alias-scopes(sample_read_depth)"}
|
||||
!77 = !{!78, !79}
|
||||
!78 = distinct !{!78, !76, !"air-alias-scope-textures"}
|
||||
!79 = distinct !{!79, !76, !"air-alias-scope-arg(1)"}
|
||||
!80 = !{!79}
|
||||
!81 = !{!78, !75}
|
||||
!82 = !{!83}
|
||||
!83 = distinct !{!83, !84, !"air-alias-scope-arg(2)"}
|
||||
!84 = distinct !{!84, !"air-alias-scopes(sample_read_stencil)"}
|
||||
!85 = !{!86, !87}
|
||||
!86 = distinct !{!86, !84, !"air-alias-scope-textures"}
|
||||
!87 = distinct !{!87, !84, !"air-alias-scope-arg(1)"}
|
||||
!88 = !{!87}
|
||||
!89 = !{!86, !83}
|
||||
@@ -0,0 +1,357 @@
|
||||
; Generated by scripts/regen-air-fixtures from sample_fill.metal (llvm-dis of sample_fill.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.SampleShape = type { i32, i32, i32 }
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
define <4 x float> @sample_fill_vertex(i32 noundef %0) local_unnamed_addr #0 {
|
||||
%2 = shl i32 %0, 1
|
||||
%3 = and i32 %2, 2
|
||||
%4 = tail call float @air.convert.f.f32.u.i32(i32 %3) #7
|
||||
%5 = insertelement <2 x float> undef, float %4, i64 0
|
||||
%6 = and i32 %0, 2
|
||||
%7 = tail call float @air.convert.f.f32.u.i32(i32 %6) #7
|
||||
%8 = insertelement <2 x float> %5, float %7, i64 1
|
||||
%9 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %8, <2 x float> splat (float 2.000000e+00), <2 x float> splat (float -1.000000e+00))
|
||||
%10 = shufflevector <2 x float> %9, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
|
||||
%11 = shufflevector <4 x float> %10, <4 x float> <float poison, float poison, float 0.000000e+00, float 1.000000e+00>, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
|
||||
ret <4 x float> %11
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
declare float @air.convert.f.f32.u.i32(i32) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
|
||||
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: read)
|
||||
define <4 x i32> @sample_fill_color(<4 x float> noundef %0, i32 noundef %1, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(12) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %5) #7
|
||||
%7 = extractelement <2 x i32> %6, i64 1
|
||||
%8 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %3, i64 0, i32 0
|
||||
%9 = load i32, ptr addrspace(2) %8, align 4, !tbaa !45, !alias.scope !50, !noalias !53
|
||||
%10 = mul i32 %7, %9
|
||||
%11 = extractelement <2 x i32> %6, i64 0
|
||||
%12 = add i32 %10, %11
|
||||
%13 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %3, i64 0, i32 1
|
||||
%14 = load i32, ptr addrspace(2) %13, align 4, !tbaa !55, !alias.scope !50, !noalias !53
|
||||
%15 = mul i32 %12, %14
|
||||
%16 = add i32 %15, %1
|
||||
%17 = zext i32 %16 to i64
|
||||
%18 = getelementptr inbounds <4 x i32>, ptr addrspace(1) %2, i64 %17
|
||||
%19 = load <4 x i32>, ptr addrspace(1) %18, align 16, !tbaa !56, !alias.scope !53, !noalias !50
|
||||
ret <4 x i32> %19
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
declare <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float>) local_unnamed_addr #1
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: read)
|
||||
define <{ float }> @sample_fill_depth(<4 x float> noundef %0, i32 noundef %1, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %2, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(12) "air-buffer-no-alias" %3) local_unnamed_addr #3 {
|
||||
%5 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %5) #7
|
||||
%7 = extractelement <2 x i32> %6, i64 1
|
||||
%8 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %3, i64 0, i32 0
|
||||
%9 = load i32, ptr addrspace(2) %8, align 4, !tbaa !45, !alias.scope !57, !noalias !60
|
||||
%10 = mul i32 %7, %9
|
||||
%11 = extractelement <2 x i32> %6, i64 0
|
||||
%12 = add i32 %10, %11
|
||||
%13 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %3, i64 0, i32 1
|
||||
%14 = load i32, ptr addrspace(2) %13, align 4, !tbaa !55, !alias.scope !57, !noalias !60
|
||||
%15 = mul i32 %12, %14
|
||||
%16 = add i32 %15, %1
|
||||
%17 = zext i32 %16 to i64
|
||||
%18 = getelementptr inbounds float, ptr addrspace(1) %2, i64 %17
|
||||
%19 = load float, ptr addrspace(1) %18, align 4, !tbaa !62, !alias.scope !60, !noalias !57
|
||||
%20 = insertvalue <{ float }> undef, float %19, 0
|
||||
ret <{ float }> %20
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_color(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call ptr addrspace(2) @air.get_read_sampler() #8
|
||||
%8 = tail call { <4 x i32>, i8 } @air.read_texture_2d_ms.u.v4i32(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(2) %7, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { <4 x i32>, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 0
|
||||
%12 = load i32, ptr addrspace(2) %11, align 4, !tbaa !45, !alias.scope !64, !noalias !67
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 1
|
||||
%17 = load i32, ptr addrspace(2) %16, align 4, !tbaa !55, !alias.scope !64, !noalias !67
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 2
|
||||
%21 = load i32, ptr addrspace(2) %20, align 4, !tbaa !70, !alias.scope !64, !noalias !67
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = extractelement <4 x i32> %9, i64 0
|
||||
%24 = zext i32 %22 to i64
|
||||
%25 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %24
|
||||
store i32 %23, ptr addrspace(1) %25, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %32
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = extractelement <4 x i32> %9, i64 1
|
||||
%29 = add i32 %22, 1
|
||||
%30 = zext i32 %29 to i64
|
||||
%31 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %30
|
||||
store i32 %28, ptr addrspace(1) %31, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
br label %32
|
||||
|
||||
32: ; preds = %27, %4
|
||||
%33 = icmp ugt i32 %21, 2
|
||||
br i1 %33, label %34, label %43
|
||||
|
||||
34: ; preds = %32
|
||||
%35 = extractelement <4 x i32> %9, i64 2
|
||||
%36 = add i32 %22, 2
|
||||
%37 = zext i32 %36 to i64
|
||||
%38 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %37
|
||||
store i32 %35, ptr addrspace(1) %38, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
%39 = extractelement <4 x i32> %9, i64 3
|
||||
%40 = add i32 %22, 3
|
||||
%41 = zext i32 %40 to i64
|
||||
%42 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %41
|
||||
store i32 %39, ptr addrspace(1) %42, align 4, !tbaa !71, !alias.scope !72, !noalias !73
|
||||
br label %43
|
||||
|
||||
43: ; preds = %34, %32
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_depth(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call ptr addrspace(2) @air.get_read_sampler() #8
|
||||
%8 = tail call { float, i8 } @air.read_depth_2d_ms.f32(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(2) %7, i32 1, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { float, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 0
|
||||
%12 = load i32, ptr addrspace(2) %11, align 4, !tbaa !45, !alias.scope !74, !noalias !77
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 1
|
||||
%17 = load i32, ptr addrspace(2) %16, align 4, !tbaa !55, !alias.scope !74, !noalias !77
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 2
|
||||
%21 = load i32, ptr addrspace(2) %20, align 4, !tbaa !70, !alias.scope !74, !noalias !77
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = zext i32 %22 to i64
|
||||
%24 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %23
|
||||
%25 = bitcast ptr addrspace(1) %24 to ptr addrspace(1)
|
||||
store float %9, ptr addrspace(1) %25, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %32
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = add i32 %22, 1
|
||||
%29 = zext i32 %28 to i64
|
||||
%30 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %29
|
||||
%31 = bitcast ptr addrspace(1) %30 to ptr addrspace(1)
|
||||
store float %9, ptr addrspace(1) %31, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
br label %32
|
||||
|
||||
32: ; preds = %27, %4
|
||||
%33 = icmp ugt i32 %21, 2
|
||||
br i1 %33, label %34, label %43
|
||||
|
||||
34: ; preds = %32
|
||||
%35 = add i32 %22, 2
|
||||
%36 = zext i32 %35 to i64
|
||||
%37 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %36
|
||||
%38 = bitcast ptr addrspace(1) %37 to ptr addrspace(1)
|
||||
store float %9, ptr addrspace(1) %38, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
%39 = add i32 %22, 3
|
||||
%40 = zext i32 %39 to i64
|
||||
%41 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %40
|
||||
%42 = bitcast ptr addrspace(1) %41 to ptr addrspace(1)
|
||||
store float %9, ptr addrspace(1) %42, align 4, !tbaa !71, !alias.scope !80, !noalias !81
|
||||
br label %43
|
||||
|
||||
43: ; preds = %34, %32
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn
|
||||
define void @sample_read_stencil(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(12) "air-buffer-no-alias" %2, <3 x i32> noundef %3) local_unnamed_addr #4 {
|
||||
%5 = shufflevector <3 x i32> %3, <3 x i32> poison, <2 x i32> <i32 0, i32 1>
|
||||
%6 = extractelement <3 x i32> %3, i64 2
|
||||
%7 = tail call ptr addrspace(2) @air.get_read_sampler() #8
|
||||
%8 = tail call { <4 x i32>, i8 } @air.read_texture_2d_ms.u.v4i32(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(2) %7, <2 x i32> %5, i32 %6, i32 1) #9
|
||||
%9 = extractvalue { <4 x i32>, i8 } %8, 0
|
||||
%10 = extractelement <3 x i32> %3, i64 1
|
||||
%11 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 0
|
||||
%12 = load i32, ptr addrspace(2) %11, align 4, !tbaa !45, !alias.scope !82, !noalias !85
|
||||
%13 = mul i32 %12, %10
|
||||
%14 = extractelement <3 x i32> %3, i64 0
|
||||
%15 = add i32 %13, %14
|
||||
%16 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 1
|
||||
%17 = load i32, ptr addrspace(2) %16, align 4, !tbaa !55, !alias.scope !82, !noalias !85
|
||||
%18 = mul i32 %15, %17
|
||||
%19 = add i32 %18, %6
|
||||
%20 = getelementptr inbounds %struct.SampleShape, ptr addrspace(2) %2, i64 0, i32 2
|
||||
%21 = load i32, ptr addrspace(2) %20, align 4, !tbaa !70, !alias.scope !82, !noalias !85
|
||||
%22 = mul i32 %19, %21
|
||||
%23 = extractelement <4 x i32> %9, i64 0
|
||||
%24 = zext i32 %22 to i64
|
||||
%25 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %24
|
||||
store i32 %23, ptr addrspace(1) %25, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
%26 = icmp ugt i32 %21, 1
|
||||
br i1 %26, label %27, label %31
|
||||
|
||||
27: ; preds = %4
|
||||
%28 = add i32 %22, 1
|
||||
%29 = zext i32 %28 to i64
|
||||
%30 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %29
|
||||
store i32 %23, ptr addrspace(1) %30, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
br label %31
|
||||
|
||||
31: ; preds = %27, %4
|
||||
%32 = icmp ugt i32 %21, 2
|
||||
br i1 %32, label %33, label %40
|
||||
|
||||
33: ; preds = %31
|
||||
%34 = add i32 %22, 2
|
||||
%35 = zext i32 %34 to i64
|
||||
%36 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %35
|
||||
store i32 %23, ptr addrspace(1) %36, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
%37 = add i32 %22, 3
|
||||
%38 = zext i32 %37 to i64
|
||||
%39 = getelementptr inbounds i32, ptr addrspace(1) %1, i64 %38
|
||||
store i32 %23, ptr addrspace(1) %39, align 4, !tbaa !71, !alias.scope !88, !noalias !89
|
||||
br label %40
|
||||
|
||||
40: ; preds = %33, %31
|
||||
ret void
|
||||
}
|
||||
|
||||
; 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 i32>, i8 } @air.read_texture_2d_ms.u.v4i32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), <2 x i32>, i32, i32) local_unnamed_addr #6
|
||||
|
||||
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
|
||||
declare { float, i8 } @air.read_depth_2d_ms.f32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), i32, <2 x i32>, i32, i32) local_unnamed_addr #6
|
||||
|
||||
attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) }
|
||||
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
|
||||
attributes #3 = { mustprogress nofree nosync nounwind willreturn memory(argmem: read) "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #4 = { mustprogress nofree nounwind willreturn "frame-pointer"="all" "min-legal-vector-width"="128" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
attributes #5 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: read) }
|
||||
attributes #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) }
|
||||
attributes #7 = { nounwind willreturn memory(none) }
|
||||
attributes #8 = { nounwind willreturn memory(inaccessiblemem: read) }
|
||||
attributes #9 = { nounwind willreturn memory(argmem: read) }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||
!air.vertex = !{!9}
|
||||
!air.fragment = !{!14, !23}
|
||||
!air.kernel = !{!28, !35, !38}
|
||||
!air.compile_options = !{!39, !40, !41}
|
||||
!llvm.ident = !{!42}
|
||||
!air.version = !{!43}
|
||||
!air.language_version = !{!44}
|
||||
|
||||
!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 27, i32 2]}
|
||||
!1 = !{i32 1, !"wchar_size", i32 4}
|
||||
!2 = !{i32 7, !"frame-pointer", i32 2}
|
||||
!3 = !{i32 7, !"air.max_device_buffers", i32 31}
|
||||
!4 = !{i32 7, !"air.max_constant_buffers", i32 31}
|
||||
!5 = !{i32 7, !"air.max_threadgroup_buffers", i32 31}
|
||||
!6 = !{i32 7, !"air.max_textures", i32 128}
|
||||
!7 = !{i32 7, !"air.max_read_write_textures", i32 8}
|
||||
!8 = !{i32 7, !"air.max_samplers", i32 16}
|
||||
!9 = !{ptr @sample_fill_vertex, !10, !12}
|
||||
!10 = !{!11}
|
||||
!11 = !{!"air.position", !"air.arg_type_name", !"float4"}
|
||||
!12 = !{!13}
|
||||
!13 = !{i32 0, !"air.vertex_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"vertex_id"}
|
||||
!14 = !{ptr @sample_fill_color, !15, !17}
|
||||
!15 = !{!16}
|
||||
!16 = !{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"uint4"}
|
||||
!17 = !{!18, !19, !20, !21}
|
||||
!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!19 = !{i32 1, !"air.sample_id", !"air.arg_type_name", !"uint", !"air.arg_name", !"sample"}
|
||||
!20 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"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", !"texels"}
|
||||
!21 = !{i32 3, !"air.buffer", !"air.buffer_size", i32 12, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 12, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"SampleShape", !"air.arg_name", !"shape"}
|
||||
!22 = !{i32 0, i32 4, i32 0, !"uint", !"width", i32 4, i32 4, i32 0, !"uint", !"samples", i32 8, i32 4, i32 0, !"uint", !"words"}
|
||||
!23 = !{ptr @sample_fill_depth, !24, !26}
|
||||
!24 = !{!25}
|
||||
!25 = !{!"air.depth", !"air.depth_qualifier", !"air.any", !"air.arg_type_name", !"float", !"air.arg_name", !"depth"}
|
||||
!26 = !{!18, !19, !27, !21}
|
||||
!27 = !{i32 2, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"float", !"air.arg_name", !"texels"}
|
||||
!28 = !{ptr @sample_read_color, !29, !30}
|
||||
!29 = !{}
|
||||
!30 = !{!31, !32, !33, !34}
|
||||
!31 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"texture2d_ms<uint, read>", !"air.arg_name", !"source"}
|
||||
!32 = !{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"words"}
|
||||
!33 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 12, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.struct_type_info", !22, !"air.arg_type_size", i32 12, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"SampleShape", !"air.arg_name", !"shape"}
|
||||
!34 = !{i32 3, !"air.threadgroup_position_in_grid", !"air.arg_type_name", !"uint3", !"air.arg_name", !"position"}
|
||||
!35 = !{ptr @sample_read_depth, !29, !36}
|
||||
!36 = !{!37, !32, !33, !34}
|
||||
!37 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"depth2d_ms<float, read>", !"air.arg_name", !"source"}
|
||||
!38 = !{ptr @sample_read_stencil, !29, !30}
|
||||
!39 = !{!"air.compile.denorms_disable"}
|
||||
!40 = !{!"air.compile.fast_math_disable"}
|
||||
!41 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!42 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!43 = !{i32 2, i32 8, i32 0}
|
||||
!44 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!45 = !{!46, !47, i64 0}
|
||||
!46 = !{!"_ZTS11SampleShape", !47, i64 0, !47, i64 4, !47, i64 8}
|
||||
!47 = !{!"int", !48, i64 0}
|
||||
!48 = !{!"omnipotent char", !49, i64 0}
|
||||
!49 = !{!"Simple C++ TBAA"}
|
||||
!50 = !{!51}
|
||||
!51 = distinct !{!51, !52, !"air-alias-scope-arg(3)"}
|
||||
!52 = distinct !{!52, !"air-alias-scopes(sample_fill_color)"}
|
||||
!53 = !{!54}
|
||||
!54 = distinct !{!54, !52, !"air-alias-scope-arg(2)"}
|
||||
!55 = !{!46, !47, i64 4}
|
||||
!56 = !{!48, !48, i64 0}
|
||||
!57 = !{!58}
|
||||
!58 = distinct !{!58, !59, !"air-alias-scope-arg(3)"}
|
||||
!59 = distinct !{!59, !"air-alias-scopes(sample_fill_depth)"}
|
||||
!60 = !{!61}
|
||||
!61 = distinct !{!61, !59, !"air-alias-scope-arg(2)"}
|
||||
!62 = !{!63, !63, i64 0}
|
||||
!63 = !{!"float", !48, i64 0}
|
||||
!64 = !{!65}
|
||||
!65 = distinct !{!65, !66, !"air-alias-scope-arg(2)"}
|
||||
!66 = distinct !{!66, !"air-alias-scopes(sample_read_color)"}
|
||||
!67 = !{!68, !69}
|
||||
!68 = distinct !{!68, !66, !"air-alias-scope-textures"}
|
||||
!69 = distinct !{!69, !66, !"air-alias-scope-arg(1)"}
|
||||
!70 = !{!46, !47, i64 8}
|
||||
!71 = !{!47, !47, i64 0}
|
||||
!72 = !{!69}
|
||||
!73 = !{!68, !65}
|
||||
!74 = !{!75}
|
||||
!75 = distinct !{!75, !76, !"air-alias-scope-arg(2)"}
|
||||
!76 = distinct !{!76, !"air-alias-scopes(sample_read_depth)"}
|
||||
!77 = !{!78, !79}
|
||||
!78 = distinct !{!78, !76, !"air-alias-scope-textures"}
|
||||
!79 = distinct !{!79, !76, !"air-alias-scope-arg(1)"}
|
||||
!80 = !{!79}
|
||||
!81 = !{!78, !75}
|
||||
!82 = !{!83}
|
||||
!83 = distinct !{!83, !84, !"air-alias-scope-arg(2)"}
|
||||
!84 = distinct !{!84, !"air-alias-scopes(sample_read_stencil)"}
|
||||
!85 = !{!86, !87}
|
||||
!86 = distinct !{!86, !84, !"air-alias-scope-textures"}
|
||||
!87 = distinct !{!87, !84, !"air-alias-scope-arg(1)"}
|
||||
!88 = !{!87}
|
||||
!89 = !{!86, !83}
|
||||
@@ -0,0 +1,83 @@
|
||||
// metal-fast-math: off
|
||||
// Owned fixture: the validation executor's per-sample fill and read of a multisampled texture
|
||||
// through the runtime (`executor_contract::multisample`), which uploads and copies no
|
||||
// multisampled texture, as Metal neither: one draw writes every sample of one slice from a
|
||||
// buffer, and one dispatch reads every sample back.
|
||||
//
|
||||
// * sample_fill_vertex: one triangle over the whole target, vertex v at clip position
|
||||
// (2 (v << 1 & 2) - 1, 2 (v & 2) - 1, 0, 1).
|
||||
// * sample_fill_color: sample s of the pixel at (x, y) writes texels[(y * width + x) * samples
|
||||
// + s], through an unsigned-integer view of the attachment's texel size, so the bits cross
|
||||
// unconverted.
|
||||
// * sample_fill_depth: the same, writing depth texels[...] under `depth(any)`.
|
||||
// * sample_read_color, sample_read_depth, sample_read_stencil: the threadgroup at (x, y, s)
|
||||
// reads sample s of pixel (x, y), through an unsigned-integer view, as a bit-cast depth, or as
|
||||
// a stencil value (the first component, Metal leaving the others undefined), and stores its
|
||||
// `words` words at word ((y * width + x) * samples + s) * words.
|
||||
//
|
||||
// Loop-free.
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
struct SampleShape {
|
||||
uint width;
|
||||
uint samples;
|
||||
uint words;
|
||||
};
|
||||
|
||||
vertex float4 sample_fill_vertex(uint vertex_id [[vertex_id]]) {
|
||||
float2 corner = float2((vertex_id << 1) & 2, vertex_id & 2);
|
||||
return float4(corner * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
fragment uint4 sample_fill_color(float4 position [[position]], uint sample [[sample_id]],
|
||||
device const uint4 *texels [[buffer(0)]],
|
||||
constant SampleShape &shape [[buffer(1)]]) {
|
||||
uint2 pixel = uint2(position.xy);
|
||||
return texels[(pixel.y * shape.width + pixel.x) * shape.samples + sample];
|
||||
}
|
||||
|
||||
struct SampleFillDepth {
|
||||
float depth [[depth(any)]];
|
||||
};
|
||||
|
||||
fragment SampleFillDepth sample_fill_depth(float4 position [[position]],
|
||||
uint sample [[sample_id]],
|
||||
device const float *texels [[buffer(0)]],
|
||||
constant SampleShape &shape [[buffer(1)]]) {
|
||||
uint2 pixel = uint2(position.xy);
|
||||
return {texels[(pixel.y * shape.width + pixel.x) * shape.samples + sample]};
|
||||
}
|
||||
|
||||
static void store(uint4 texel, uint3 position, device uint *words, constant SampleShape &shape) {
|
||||
uint base = ((position.y * shape.width + position.x) * shape.samples + position.z) * shape.words;
|
||||
words[base] = texel.x;
|
||||
if (shape.words > 1) {
|
||||
words[base + 1] = texel.y;
|
||||
}
|
||||
if (shape.words > 2) {
|
||||
words[base + 2] = texel.z;
|
||||
words[base + 3] = texel.w;
|
||||
}
|
||||
}
|
||||
|
||||
kernel void sample_read_color(texture2d_ms<uint, access::read> source [[texture(0)]],
|
||||
device uint *words [[buffer(0)]],
|
||||
constant SampleShape &shape [[buffer(1)]],
|
||||
uint3 position [[threadgroup_position_in_grid]]) {
|
||||
store(source.read(position.xy, position.z), position, words, shape);
|
||||
}
|
||||
|
||||
kernel void sample_read_depth(depth2d_ms<float, access::read> source [[texture(0)]],
|
||||
device uint *words [[buffer(0)]],
|
||||
constant SampleShape &shape [[buffer(1)]],
|
||||
uint3 position [[threadgroup_position_in_grid]]) {
|
||||
store(uint4(as_type<uint>(source.read(position.xy, position.z))), position, words, shape);
|
||||
}
|
||||
|
||||
kernel void sample_read_stencil(texture2d_ms<uint, access::read> source [[texture(0)]],
|
||||
device uint *words [[buffer(0)]],
|
||||
constant SampleShape &shape [[buffer(1)]],
|
||||
uint3 position [[threadgroup_position_in_grid]]) {
|
||||
store(uint4(source.read(position.xy, position.z).x), position, words, shape);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ use tables::{function_tables, table_buffers, FunctionTable, TableBuffers};
|
||||
/// how it decides a match. A change no recorded row can observe (a case kind no earlier executor
|
||||
/// ran, or one it refused) needs no bump; its commit says why. The commit that bumps it says what
|
||||
/// changed; this comment keeps no history.
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v196";
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v197";
|
||||
|
||||
/// One kernel case in the terms the binder takes: what this executor supports of an
|
||||
/// [`AuthoredCase`] (buffers, device buffer arrays, argument-buffer buffers and textures, command
|
||||
@@ -1210,15 +1210,15 @@ pub fn runs_through_runtime(authored: &AuthoredCase, case: &ComputeCase) -> bool
|
||||
&& authored.intersection_function_tables.is_empty()
|
||||
}
|
||||
|
||||
/// Whether the runtime makes `texture` as the Metal oracle makes it: one sample and no sparse
|
||||
/// mapping (multisampled and sparse textures stay on the executor's own context), of a type the
|
||||
/// runtime builds, so neither a texture buffer (`Gap::TextureBuffer`) nor a cube array
|
||||
/// (`Gap::CubeArrayTexture`). A 32-bit float depth, whose bytes the runtime takes no upload of
|
||||
/// (`Gap::FloatDepthUpload`), is filled by a draw, as a guest fills one
|
||||
/// (`platform::runtime_depth`).
|
||||
/// Whether the runtime makes `texture` as the Metal oracle makes it: no sparse mapping (a sparse
|
||||
/// texture stays on the executor's own context), of a type the runtime builds, so neither a
|
||||
/// texture buffer (`Gap::TextureBuffer`) nor a cube array (`Gap::CubeArrayTexture`). A 32-bit
|
||||
/// float depth, whose bytes the runtime takes no upload of (`Gap::FloatDepthUpload`), is filled
|
||||
/// by a draw, as a guest fills one (`platform::runtime_depth`), and a multisampled texture, which
|
||||
/// neither Metal nor the runtime uploads, by a draw per slice that writes it sample by sample
|
||||
/// (`platform::runtime_multisample`).
|
||||
fn runtime_texture(texture: &LiteralTexture) -> bool {
|
||||
texture.sample_count == 1
|
||||
&& texture.sparse.is_none()
|
||||
texture.sparse.is_none()
|
||||
&& !matches!(
|
||||
texture.texture_type,
|
||||
TextureType::Buffer | TextureType::CubeArray
|
||||
@@ -1393,11 +1393,12 @@ pub struct RuntimeKernel<'a> {
|
||||
|
||||
/// Whether `case`, mapped from `authored`, draws through the runtime
|
||||
/// (`platform::execute_runtime_render`) in place of the executor's own context: a vertex or
|
||||
/// fragment case of one sample, its own stage's buffers, bound textures the runtime makes
|
||||
/// (`runtime_texture`) and bound samplers, function constants and linked functions, its vertex
|
||||
/// buffers at static strides, its color targets and a depth/stencil attachment of one sample and
|
||||
/// one aspect (a fragment case renders into at least one attachment: the runtime makes no pass
|
||||
/// without one, `Gap::RenderPass`), the encoder's depth-stencil state, cull mode and winding, and
|
||||
/// fragment case of any sample count (`raster_sample_count`; each attachment of more samples
|
||||
/// filled and read back sample by sample, `platform::runtime_multisample`), its own stage's
|
||||
/// buffers, bound textures the runtime makes (`runtime_texture`) and bound samplers, function
|
||||
/// constants and linked functions, its vertex buffers at static strides, its color targets and a
|
||||
/// depth/stencil attachment of one aspect (a fragment case renders into at least one attachment:
|
||||
/// the runtime makes no pass without one, `Gap::RenderPass`), the encoder's depth-stencil state, cull mode and winding, and
|
||||
/// one direct or indexed draw of primitives or one patch draw with no patch or control-point index
|
||||
/// buffer (a post-tessellation vertex function's, its factors bound as the tessellation factor
|
||||
/// buffer), observing a buffer, a texture, a color target, the depth/stencil attachment's aspect
|
||||
@@ -1422,7 +1423,7 @@ pub fn runs_render_through_runtime(authored: &AuthoredCase, case: &graphics::Ren
|
||||
output,
|
||||
companion: _,
|
||||
rate_map_pass,
|
||||
raster_sample_count,
|
||||
raster_sample_count: _,
|
||||
} = case;
|
||||
let bound = |function: &graphics::RenderFunction| {
|
||||
let graphics::StageResources {
|
||||
@@ -1447,13 +1448,12 @@ pub fn runs_render_through_runtime(authored: &AuthoredCase, case: &graphics::Ren
|
||||
// The runtime renders into no separate depth and stencil textures in one pass
|
||||
// (`Gap::RenderPass` of `DepthStencilViews`), which the oracle makes of an attachment of both.
|
||||
let one_aspect = |attachment: &LiteralDepthStencil| {
|
||||
attachment.samples == 1 && (attachment.depth.is_none() || attachment.stencil.is_none())
|
||||
attachment.depth.is_none() || attachment.stencil.is_none()
|
||||
};
|
||||
bound(vertex)
|
||||
&& fragment.as_ref().is_none_or(bound)
|
||||
&& (fragment.is_none() || !color_targets.is_empty() || depth_stencil.is_some())
|
||||
&& vertex_buffers.iter().all(|buffer| !buffer.dynamic)
|
||||
&& color_targets.values().all(|target| target.samples == 1)
|
||||
&& depth_stencil.as_ref().is_none_or(one_aspect)
|
||||
&& *render_target_array_length == 0
|
||||
&& matches!(
|
||||
@@ -1484,7 +1484,6 @@ pub fn runs_render_through_runtime(authored: &AuthoredCase, case: &graphics::Ren
|
||||
| graphics::RenderOutput::Stencil { .. }
|
||||
)
|
||||
&& rate_map_pass.is_none()
|
||||
&& raster_sample_count.is_none()
|
||||
&& authored.intersection_function_tables.is_empty()
|
||||
}
|
||||
|
||||
|
||||
@@ -2557,10 +2557,11 @@ fn plain_kernel() -> ComputeCase {
|
||||
/// The runtime runs a kernel case of buffers, threadgroup memory and constants, bound textures it
|
||||
/// makes and bound samplers, argument buffers of buffers, such textures and samplers, dispatched
|
||||
/// by threads or threadgroups and observing a buffer, a texture, an argument-buffer member or
|
||||
/// nothing, a 32-bit float depth among its textures (which the run fills by a draw) and its
|
||||
/// out-of-bounds targets among them (`platform::runtime_bounds`); a case with anything else (a pipeline state in an argument buffer, an explicit imageblock, an indirect
|
||||
/// dispatch, a texture the runtime does not make: multisampled, sparse, a texture buffer or a cube
|
||||
/// array) stays on the executor's own context.
|
||||
/// nothing, a 32-bit float depth or a multisampled texture among its textures (which the run
|
||||
/// fills by a draw) and its out-of-bounds targets among them (`platform::runtime_bounds`); a case
|
||||
/// with anything else (a pipeline state in an argument buffer, an explicit imageblock, an indirect
|
||||
/// dispatch, a texture the runtime does not make: sparse, a texture buffer or a cube array) stays
|
||||
/// on the executor's own context.
|
||||
#[test]
|
||||
fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
use crate::case::{
|
||||
@@ -2670,6 +2671,10 @@ fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
..texture(TextureType::D2, 1)
|
||||
};
|
||||
assert!(runs_through_runtime(&authored, &textured(depth)));
|
||||
assert!(runs_through_runtime(
|
||||
&authored,
|
||||
&textured(texture(TextureType::D2Multisample, 4))
|
||||
));
|
||||
let bounded = ComputeCase {
|
||||
out_of_bounds: vec![OutOfBoundsTarget {
|
||||
resource: OutOfBoundsResource::Buffer { binding: 0 },
|
||||
@@ -2690,7 +2695,6 @@ fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
dispatch: replay_dispatch([2, 1, 1]),
|
||||
..plain.clone()
|
||||
},
|
||||
textured(texture(TextureType::D2Multisample, 4)),
|
||||
textured(sparse),
|
||||
textured(texture(TextureType::Buffer, 1)),
|
||||
textured(texture(TextureType::CubeArray, 1)),
|
||||
@@ -2701,16 +2705,16 @@ fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The runtime draws a vertex or fragment case of one sample, its own stage's buffers, textures
|
||||
/// and samplers, static vertex strides, color targets, and one direct or indexed draw of
|
||||
/// primitives or one patch draw with no index buffer, observing a buffer, a texture, a color
|
||||
/// The runtime draws a vertex or fragment case of any sample count, its own stage's buffers,
|
||||
/// textures and samplers, static vertex strides, color targets, and one direct or indexed draw
|
||||
/// of primitives or one patch draw with no index buffer, observing a buffer, a texture, a color
|
||||
/// target or nothing; and a rasterization-disabled vertex case, which renders into the oracle's
|
||||
/// sink; a depth/stencil attachment of one sample and one aspect, observed or not; and an
|
||||
/// attribute buffer's out-of-bounds target. A case with anything else (a depth/stencil attachment
|
||||
/// of both aspects or more samples, more samples, layered rendering, a dynamic vertex stride, an
|
||||
/// argument-buffer member, an explicit imageblock, a fragment pass with no attachment, which the
|
||||
/// runtime makes no pass of, a patch draw through a patch index buffer, or an index buffer's
|
||||
/// out-of-bounds target) stays on the executor's own context.
|
||||
/// sink; a depth/stencil attachment of one aspect, of one sample or more, observed or not; and
|
||||
/// an attribute buffer's out-of-bounds target. A case with anything else (a depth/stencil
|
||||
/// attachment of both aspects, layered rendering, a dynamic vertex stride, an argument-buffer
|
||||
/// member, an explicit imageblock, a fragment pass with no attachment, which the runtime makes no
|
||||
/// pass of, a patch draw through a patch index buffer, or an index buffer's out-of-bounds target)
|
||||
/// stays on the executor's own context.
|
||||
#[test]
|
||||
fn a_plain_draw_and_only_one_runs_through_the_runtime() {
|
||||
use super::graphics::tests::two_stage_case;
|
||||
@@ -2812,8 +2816,8 @@ fn a_plain_draw_and_only_one_runs_through_the_runtime() {
|
||||
.argument_buffer_buffers
|
||||
.insert((0, 0), vec![0; 16]);
|
||||
}
|
||||
// A depth/stencil attachment of one sample and one aspect, observed or not, with or without a
|
||||
// color target; one of both aspects or of more samples stays on the executor's own context.
|
||||
// A depth/stencil attachment of one aspect, of one sample or more, observed or not, with or
|
||||
// without a color target; one of both aspects stays on the executor's own context.
|
||||
let depth = LiteralDepthStencil {
|
||||
dimensions: [2, 2],
|
||||
samples: 1,
|
||||
@@ -2825,7 +2829,17 @@ fn a_plain_draw_and_only_one_runs_through_the_runtime() {
|
||||
stencil: Some(vec![0; 4]),
|
||||
..depth.clone()
|
||||
};
|
||||
for attachment in [&depth, &stencil] {
|
||||
let multisampled_depth = LiteralDepthStencil {
|
||||
samples: 4,
|
||||
depth: Some(vec![0; 64]),
|
||||
..depth.clone()
|
||||
};
|
||||
let multisampled_stencil = LiteralDepthStencil {
|
||||
samples: 4,
|
||||
stencil: Some(vec![0; 16]),
|
||||
..stencil.clone()
|
||||
};
|
||||
for attachment in [&depth, &stencil, &multisampled_depth, &multisampled_stencil] {
|
||||
let attached = RenderCase {
|
||||
depth_stencil: Some(attachment.clone()),
|
||||
..plain.clone()
|
||||
@@ -2847,6 +2861,20 @@ fn a_plain_draw_and_only_one_runs_through_the_runtime() {
|
||||
};
|
||||
assert!(runs_render_through_runtime(&authored, &observed));
|
||||
}
|
||||
// A pass of more samples, its color target filled and read back sample by sample.
|
||||
let multisampled = RenderCase {
|
||||
raster_sample_count: Some(4),
|
||||
color_targets: BTreeMap::from([(
|
||||
0,
|
||||
ColorTarget {
|
||||
samples: 4,
|
||||
bytes: vec![0; 64],
|
||||
..target.clone()
|
||||
},
|
||||
)]),
|
||||
..plain.clone()
|
||||
};
|
||||
assert!(runs_render_through_runtime(&authored, &multisampled));
|
||||
let others = [
|
||||
RenderCase {
|
||||
depth_stencil: Some(LiteralDepthStencil {
|
||||
@@ -2855,26 +2883,6 @@ fn a_plain_draw_and_only_one_runs_through_the_runtime() {
|
||||
}),
|
||||
..plain.clone()
|
||||
},
|
||||
RenderCase {
|
||||
depth_stencil: Some(LiteralDepthStencil {
|
||||
samples: 4,
|
||||
depth: Some(vec![0; 64]),
|
||||
..depth.clone()
|
||||
}),
|
||||
..plain.clone()
|
||||
},
|
||||
RenderCase {
|
||||
raster_sample_count: Some(4),
|
||||
color_targets: BTreeMap::from([(
|
||||
0,
|
||||
ColorTarget {
|
||||
samples: 4,
|
||||
bytes: vec![0; 64],
|
||||
..target.clone()
|
||||
},
|
||||
)]),
|
||||
..plain.clone()
|
||||
},
|
||||
RenderCase {
|
||||
render_target_array_length: 1,
|
||||
..plain.clone()
|
||||
|
||||
@@ -18,6 +18,7 @@ mod render;
|
||||
mod runtime;
|
||||
mod runtime_bounds;
|
||||
mod runtime_depth;
|
||||
mod runtime_multisample;
|
||||
mod runtime_probe;
|
||||
mod runtime_render;
|
||||
mod runtime_textures;
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
//! The multisampled textures and attachments of a run through the runtime, filled and read as
|
||||
//! `executor_contract::multisample` says. Metal uploads and copies no multisampled texture, and
|
||||
//! neither does the runtime, so each slice is filled by one draw of the owned `sample_fill`
|
||||
//! fixture (`fixtures/public/engine/sample_fill.metal`) whose fragment runs once per sample
|
||||
//! (`sample_id`) and writes that sample's texel from a buffer: a color texel through an
|
||||
//! unsigned-integer view of its texel size (the texture made with `PixelFormatView` usage), so
|
||||
//! its bits cross unconverted, and a `Depth32Float` one as `depth(any)` under an always-passing
|
||||
//! depth test that writes. A depth outside `[0, 1]` is refused, typed, as `runtime_depth`
|
||||
//! refuses it. A stencil aspect holds one value in every sample (`uniform_stencil`), which the
|
||||
//! case's pass clears it to. After the work, a dispatch of the fixture's kernels reads every
|
||||
//! sample, one threadgroup each: a color texel through the unsigned-integer view, a depth bit-cast,
|
||||
//! a stencil value as its first component, as whole words in the attachment layout
|
||||
//! (`unpack_words`). Nothing is resolved.
|
||||
|
||||
use super::runtime::{self, Placed};
|
||||
use crate::candidate::engine::{graphics, product_refusal};
|
||||
use crate::case::indirect_commands::metal_primitive_type;
|
||||
use crate::case::Primitive;
|
||||
use crate::check::admission::{ExecutorError, NotSupported};
|
||||
use crate::executor_contract::depth_range::holds_depth_outside_unit_range;
|
||||
use crate::executor_contract::multisample::{
|
||||
readback_bytes, unpack_words, ReadbackView, SampleRead,
|
||||
};
|
||||
use crate::gpu::DeviceType;
|
||||
use crate::requirement::ToolingRequirement;
|
||||
use metal2vulkan::library::{Function, Library};
|
||||
use metal2vulkan::metal::CompareFunction;
|
||||
use metal2vulkan::pipeline::{
|
||||
ColorAttachmentDescriptor, ComputePipelineDescriptor, FunctionDescriptor,
|
||||
RenderPipelineDescriptor, StageSource,
|
||||
};
|
||||
use metal2vulkan_runtime as rt;
|
||||
|
||||
/// The owned fixture's opaque text, which the run assembles (`check::loop_free::assemble`).
|
||||
const SAMPLE_FILL: &str = include_str!("../../../fixtures/public/engine/sample_fill.ll");
|
||||
|
||||
/// One slice of a multisampled texture and the texels it is filled with, read as `read` (a color
|
||||
/// view or depth): every sample of each pixel, pixels row-major, as the case's bytes lay them out.
|
||||
pub(super) struct Fill {
|
||||
pub(super) texture: rt::Texture,
|
||||
pub(super) slice: u32,
|
||||
pub(super) read: SampleRead,
|
||||
pub(super) texels: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Render each of `fills` into its slice on `device`, as the module documentation says.
|
||||
pub(super) fn filled(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
fills: &[Fill],
|
||||
error: &impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
) -> Result<(), ExecutorError> {
|
||||
if fills.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let library = library()?;
|
||||
let mut always = rt::DepthStencilDescriptor::default();
|
||||
always.depth_compare_function = CompareFunction::Always;
|
||||
always.depth_write_enabled = true;
|
||||
let written = device.new_depth_stencil_state(&always);
|
||||
let made = fills
|
||||
.iter()
|
||||
.map(|fill| Filling::make(device, &library, fill, error))
|
||||
.collect::<Result<Vec<_>, ExecutorError>>()?;
|
||||
let fail = |what: &'static str| move |e: rt::Error| error(what, e);
|
||||
runtime::submitted(
|
||||
device,
|
||||
device_type,
|
||||
"a multisampled texture's fill through the runtime",
|
||||
|command_buffer| {
|
||||
for (fill, made) in fills.iter().zip(&made) {
|
||||
let mut pass = rt::RenderPassDescriptor::default();
|
||||
match &made.view {
|
||||
Some(view) => {
|
||||
let attachment = &mut pass.color_attachments[0];
|
||||
attachment.texture = Some(view.clone());
|
||||
attachment.slice = fill.slice;
|
||||
attachment.load_action = rt::LoadAction::DontCare;
|
||||
attachment.store_action = rt::StoreAction::Store;
|
||||
}
|
||||
None => {
|
||||
let attachment = &mut pass.depth_attachment;
|
||||
attachment.texture = Some(fill.texture.clone());
|
||||
attachment.slice = fill.slice;
|
||||
attachment.load_action = rt::LoadAction::DontCare;
|
||||
attachment.store_action = rt::StoreAction::Store;
|
||||
}
|
||||
}
|
||||
let mut encoder = command_buffer
|
||||
.render_command_encoder(&pass)
|
||||
.map_err(fail("a multisampled fill's pass"))?;
|
||||
encoder
|
||||
.set_render_pipeline_state(&made.state)
|
||||
.map_err(fail("the multisampled fill's pipeline state"))?;
|
||||
encoder
|
||||
.set_fragment_buffer(Some(&made.texels.buffer), 0, 0)
|
||||
.map_err(fail("a multisampled fill's texels"))?;
|
||||
encoder
|
||||
.set_fragment_buffer(Some(&made.shape.buffer), 0, 1)
|
||||
.map_err(fail("a multisampled fill's shape"))?;
|
||||
if made.view.is_none() {
|
||||
encoder
|
||||
.set_depth_stencil_state(Some(&written))
|
||||
.map_err(fail("the multisampled fill's depth-stencil state"))?;
|
||||
}
|
||||
encoder
|
||||
.draw_primitives(metal_primitive_type(Primitive::Triangle), 0, 3, 1, 0)
|
||||
.map_err(fail("a multisampled fill's draw"))?;
|
||||
encoder.end_encoding();
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// What one fill draws with: its pipeline state, its texels as the fragment reads them, the
|
||||
/// slice's shape, and the color view it renders through (`None` for depth).
|
||||
struct Filling {
|
||||
state: rt::RenderPipelineState,
|
||||
texels: Placed,
|
||||
shape: Placed,
|
||||
view: Option<rt::Texture>,
|
||||
}
|
||||
|
||||
impl Filling {
|
||||
fn make(
|
||||
device: &rt::Device,
|
||||
library: &Library,
|
||||
fill: &Fill,
|
||||
error: &impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
) -> Result<Filling, ExecutorError> {
|
||||
let made = fill.texture.descriptor();
|
||||
let samples = made.sample_count;
|
||||
let shape = Placed::new(
|
||||
device,
|
||||
"a multisampled fill's shape",
|
||||
&shape(made.width, samples, 1),
|
||||
)?;
|
||||
let vertex = stage(library, "sample_fill_vertex")?;
|
||||
let mut descriptor = RenderPipelineDescriptor::new(vertex);
|
||||
descriptor.raster_sample_count = samples;
|
||||
descriptor.input_primitive_topology = graphics::topology_class(Primitive::Triangle);
|
||||
let (texels, view) = match fill.read {
|
||||
SampleRead::Color(reading) => {
|
||||
let format = view_format(reading);
|
||||
descriptor.fragment = Some(stage(library, "sample_fill_color")?);
|
||||
descriptor.color_attachments[0] = Some(ColorAttachmentDescriptor::new(format));
|
||||
let slices = made.array_length.max(1);
|
||||
let view = fill
|
||||
.texture
|
||||
.new_texture_view(format, made.texture_type, 0..1, 0..slices, None)
|
||||
.map_err(|e| error("a multisampled fill's view", e))?;
|
||||
(widened(&fill.texels, reading.texel_bytes())?, Some(view))
|
||||
}
|
||||
SampleRead::Depth => {
|
||||
if holds_depth_outside_unit_range(&fill.texels) {
|
||||
let requirement = ToolingRequirement::DepthOutsideUnitRange;
|
||||
return Err(NotSupported::Requirements([requirement].into()).into());
|
||||
}
|
||||
descriptor.fragment = Some(stage(library, "sample_fill_depth")?);
|
||||
descriptor.depth_format = Some(rt::PixelFormat::Depth32Float);
|
||||
(fill.texels.clone(), None)
|
||||
}
|
||||
SampleRead::Stencil => {
|
||||
return Err(ExecutorError::Failed(
|
||||
"a multisampled stencil aspect is cleared, never filled sample by sample"
|
||||
.into(),
|
||||
))
|
||||
}
|
||||
};
|
||||
let state = runtime::made_within(|numbered| {
|
||||
device.new_render_pipeline_state(&descriptor, |samplers| numbered(samplers))
|
||||
})?;
|
||||
Ok(Filling {
|
||||
state,
|
||||
texels: Placed::new(device, "a multisampled fill's texels", &texels)?,
|
||||
shape,
|
||||
view,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Every sample of the 2D multisampled `texture`, read as `read`, in the attachment layout. A
|
||||
/// color texture is read through a view made at `view_index` of the run's grant; a depth or
|
||||
/// stencil one is bound itself, at its own index (`view_index` then `None`).
|
||||
pub(super) fn read_back(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
texture: &rt::Texture,
|
||||
read: SampleRead,
|
||||
view_index: Option<u32>,
|
||||
error: &impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
) -> Result<Vec<u8>, ExecutorError> {
|
||||
let made = texture.descriptor();
|
||||
let (dimensions, samples) = ([made.width, made.height], made.sample_count);
|
||||
let library = library()?;
|
||||
let entry = match read {
|
||||
SampleRead::Color(_) => "sample_read_color",
|
||||
SampleRead::Depth => "sample_read_depth",
|
||||
SampleRead::Stencil => "sample_read_stencil",
|
||||
};
|
||||
let function = library.function(entry).map_err(|e| product_refusal(&e))?;
|
||||
let descriptor = ComputePipelineDescriptor::new(described(function));
|
||||
let state = runtime::made_within(|numbered| {
|
||||
device.new_compute_pipeline_state(&descriptor, |samplers| numbered(samplers))
|
||||
})?;
|
||||
let view = match read {
|
||||
SampleRead::Color(view) => Some(
|
||||
texture
|
||||
.new_texture_view(
|
||||
view_format(view),
|
||||
made.texture_type,
|
||||
0..1,
|
||||
0..made.array_length.max(1),
|
||||
view_index,
|
||||
)
|
||||
.map_err(|e| error("the multisampled read's view", e))?,
|
||||
),
|
||||
SampleRead::Depth | SampleRead::Stencil => None,
|
||||
};
|
||||
let length = readback_bytes(dimensions, samples, read).map_err(ExecutorError::Failed)?;
|
||||
let words = Placed::new(device, "the multisampled read's words", &vec![0; length])?;
|
||||
let words_each = read.words() as u32;
|
||||
let shape = Placed::new(
|
||||
device,
|
||||
"the multisampled read's shape",
|
||||
&shape(made.width, samples, words_each),
|
||||
)?;
|
||||
let fail = |what: &'static str| move |e: rt::Error| error(what, e);
|
||||
runtime::submitted(
|
||||
device,
|
||||
device_type,
|
||||
"a multisampled texture's read through the runtime",
|
||||
|command_buffer| {
|
||||
let mut encoder = command_buffer
|
||||
.compute_command_encoder(rt::DispatchType::Serial)
|
||||
.map_err(fail("the multisampled read's encoder"))?;
|
||||
encoder
|
||||
.set_compute_pipeline_state(&state)
|
||||
.map_err(fail("the multisampled read's pipeline state"))?;
|
||||
encoder
|
||||
.set_texture(Some(view.as_ref().unwrap_or(texture)), 0)
|
||||
.map_err(fail("the multisampled read's texture"))?;
|
||||
encoder
|
||||
.set_buffer(Some(&words.buffer), 0, 0)
|
||||
.map_err(fail("the multisampled read's words"))?;
|
||||
encoder
|
||||
.set_buffer(Some(&shape.buffer), 0, 1)
|
||||
.map_err(fail("the multisampled read's shape"))?;
|
||||
// One thread per sample, one per threadgroup: no grid edge to guard.
|
||||
encoder
|
||||
.dispatch_threadgroups([made.width, made.height, samples], [1, 1, 1])
|
||||
.map_err(fail("the multisampled read's dispatch"))?;
|
||||
encoder.end_encoding();
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
unpack_words(&words.bytes(), dimensions, samples, read).map_err(ExecutorError::Failed)
|
||||
}
|
||||
|
||||
/// The fixture's library, from its assembled text.
|
||||
fn library() -> Result<Library, ExecutorError> {
|
||||
let bitcode = crate::check::loop_free::assemble(SAMPLE_FILL)
|
||||
.map_err(|e| ExecutorError::Failed(format!("the multisampled fill's module: {e}")))?;
|
||||
Library::from_air(&bitcode).map_err(|e| product_refusal(&e))
|
||||
}
|
||||
|
||||
/// The fixture's function `entry` as a stage.
|
||||
fn stage(library: &Library, entry: &str) -> Result<StageSource, ExecutorError> {
|
||||
let function = library.function(entry).map_err(|e| product_refusal(&e))?;
|
||||
Ok(described(function))
|
||||
}
|
||||
|
||||
/// `function` as a specialized stage source.
|
||||
fn described(function: Function) -> StageSource {
|
||||
StageSource::Function(FunctionDescriptor::new(function).with_specialized(true))
|
||||
}
|
||||
|
||||
/// The fixture's `SampleShape`: the slice's width in pixels, its samples, and the words a read
|
||||
/// writes of each sample.
|
||||
fn shape(width: u32, samples: u32, words: u32) -> Vec<u8> {
|
||||
[width, samples, words]
|
||||
.iter()
|
||||
.flat_map(|word| word.to_le_bytes())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The `uint4` each sample's texel of `texel` bytes is to the fill's fragment: its little-endian
|
||||
/// words, the last zero-extended, then zeros.
|
||||
fn widened(texels: &[u8], texel: usize) -> Result<Vec<u8>, ExecutorError> {
|
||||
if texel == 0 || texels.len() % texel != 0 {
|
||||
return Err(ExecutorError::Failed(format!(
|
||||
"a multisampled fill of {} bytes is no whole number of {texel}-byte texels",
|
||||
texels.len()
|
||||
)));
|
||||
}
|
||||
Ok(texels
|
||||
.chunks_exact(texel)
|
||||
.flat_map(|chunk| {
|
||||
let mut wide = [0u8; 16];
|
||||
wide[..texel].copy_from_slice(chunk);
|
||||
wide
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// The pixel format of `view`.
|
||||
fn view_format(view: ReadbackView) -> rt::PixelFormat {
|
||||
match view {
|
||||
ReadbackView::R8Uint => rt::PixelFormat::R8Uint,
|
||||
ReadbackView::R16Uint => rt::PixelFormat::R16Uint,
|
||||
ReadbackView::R32Uint => rt::PixelFormat::R32Uint,
|
||||
ReadbackView::Rg32Uint => rt::PixelFormat::RG32Uint,
|
||||
ReadbackView::Rgba32Uint => rt::PixelFormat::RGBA32Uint,
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,10 @@
|
||||
//! rasterization is disabled, which no draw writes; the depth/stencil attachment's one aspect as
|
||||
//! the oracle makes it, a Shared `Depth32Float` filled by a draw of the case's depths
|
||||
//! (`runtime_depth`, as the runtime takes no upload of one) or a Shared `Stencil8` written from its
|
||||
//! bytes, loaded and stored by the pass; the oracle's depth-stencil state, stencil
|
||||
//! bytes, loaded and stored by the pass; in a pass of more samples, each attachment a Private
|
||||
//! multisampled texture of the pass's samples, filled and read back sample by sample
|
||||
//! (`runtime_multisample`), a stencil aspect cleared by the pass to its one value; the oracle's
|
||||
//! depth-stencil state, stencil
|
||||
//! references, cull mode and winding; one draw, direct, indexed or of patches (its factors a Shared
|
||||
//! buffer bound as the tessellation factor buffer, as the oracle binds them), in one command
|
||||
//! buffer, waited for under the hang protocol, then read back.
|
||||
@@ -24,6 +27,7 @@
|
||||
use super::runtime::{self, runtime_error, Identity, Placed};
|
||||
use super::runtime_bounds;
|
||||
use super::runtime_depth;
|
||||
use super::runtime_multisample;
|
||||
use super::runtime_textures::{self, Bound, Indices, Wanted};
|
||||
use crate::candidate::engine::graphics::{
|
||||
self, Assembly, ColorTarget, RenderCase, RenderFinals, RenderOutput,
|
||||
@@ -32,6 +36,7 @@ use crate::candidate::engine::{product_refusal, resources, ComputeRun, RunAttemp
|
||||
use crate::case::Stage;
|
||||
use crate::check::admission::{ExecutorError, NotSupported};
|
||||
use crate::coverage::ModuleCensus;
|
||||
use crate::executor_contract::multisample::{sample_read, uniform_stencil, SampleRead};
|
||||
use crate::executor_contract::tessellation;
|
||||
use crate::gpu::DeviceType;
|
||||
use crate::literal::LiteralDepthStencil;
|
||||
@@ -197,8 +202,8 @@ fn run(
|
||||
output => {
|
||||
let finals = RenderFinals {
|
||||
buffers: stages.finals(),
|
||||
targets: targets.finals(case)?,
|
||||
depth_stencil: targets.depth_stencil_finals()?,
|
||||
targets: targets.finals(device, device_type, case)?,
|
||||
depth_stencil: targets.depth_stencil_finals(device, device_type)?,
|
||||
..RenderFinals::default()
|
||||
};
|
||||
graphics::select_render_output(output, &finals).map_err(ExecutorError::Failed)?
|
||||
@@ -388,28 +393,36 @@ impl Stages {
|
||||
}
|
||||
}
|
||||
|
||||
/// The pass's color attachments, by Metal index, and its depth/stencil attachment's aspect.
|
||||
/// The pass's color attachments, by Metal index, and its depth/stencil attachment's aspect; in a
|
||||
/// pass of more samples, the texture index each color attachment's per-sample read binds its view
|
||||
/// at.
|
||||
struct Targets {
|
||||
textures: BTreeMap<u32, rt::Texture>,
|
||||
depth_stencil: Option<DepthStencil>,
|
||||
views: BTreeMap<u32, u32>,
|
||||
_grant: Option<rt::IndexGrant>,
|
||||
}
|
||||
|
||||
/// A depth/stencil attachment of one sample and one aspect, as the oracle makes it (Metal's
|
||||
/// separate `Depth32Float` and `Stencil8`): the runtime renders into no separate depth and stencil
|
||||
/// textures in one pass (`Gap::RenderPass` of `DepthStencilViews`), so a case of both stays on the
|
||||
/// executor's own context (`engine::runs_render_through_runtime`).
|
||||
/// A depth/stencil attachment of one aspect, as the oracle makes it (Metal's separate
|
||||
/// `Depth32Float` and `Stencil8`): the runtime renders into no separate depth and stencil textures
|
||||
/// in one pass (`Gap::RenderPass` of `DepthStencilViews`), so a case of both stays on the
|
||||
/// executor's own context (`engine::runs_render_through_runtime`). A multisampled stencil aspect
|
||||
/// holds one value in every sample, which the pass clears it to (`clear`).
|
||||
struct DepthStencil {
|
||||
texture: rt::Texture,
|
||||
depth: bool,
|
||||
dimensions: [u32; 2],
|
||||
samples: u32,
|
||||
clear: Option<u8>,
|
||||
}
|
||||
|
||||
impl Targets {
|
||||
/// Each color target of `case` as a Shared 2D texture of its format and extent, made for
|
||||
/// rendering at the next of `indices` and written from its bytes; a rasterization-disabled
|
||||
/// draw's one attachment is the oracle's 1x1 `R8Unorm` one at index 0, which no draw writes
|
||||
/// (a case of that draw authors no color target, `RasterizationDisabledRenderTarget`).
|
||||
/// Each color target of `case` as a 2D texture of its format, extent and samples, made for
|
||||
/// rendering at the next of `indices`: of one sample Shared and written from its bytes, of more
|
||||
/// Private and filled sample by sample (`runtime_multisample`), with the next index for its
|
||||
/// read's view. A rasterization-disabled draw's one attachment is the oracle's 1x1 `R8Unorm`
|
||||
/// one at index 0, which no draw writes (a case of that draw authors no color target,
|
||||
/// `RasterizationDisabledRenderTarget`).
|
||||
fn make(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
@@ -419,29 +432,70 @@ impl Targets {
|
||||
if case.fragment.is_none() {
|
||||
let (grant, at) =
|
||||
runtime_textures::texture_indices(device, indices, 1, &runtime_error)?;
|
||||
let sink = attachment(device, SINK, [1, 1], (0, at.start))?;
|
||||
let sink = attachment(device, SINK, [1, 1], 1, (0, at.start))?;
|
||||
return Ok(Targets {
|
||||
textures: BTreeMap::from([(0, sink)]),
|
||||
depth_stencil: None,
|
||||
views: BTreeMap::new(),
|
||||
_grant: grant,
|
||||
});
|
||||
}
|
||||
let (grant, at) = runtime_textures::texture_indices(
|
||||
let aspects = usize::from(
|
||||
case.depth_stencil
|
||||
.as_ref()
|
||||
.is_some_and(|authored| authored.samples > 1),
|
||||
);
|
||||
let viewed = case
|
||||
.color_targets
|
||||
.values()
|
||||
.filter(|target| target.samples > 1)
|
||||
.count();
|
||||
let (grant, mut at) = runtime_textures::texture_indices(
|
||||
device,
|
||||
indices,
|
||||
case.color_targets.len(),
|
||||
case.color_targets.len() + viewed + aspects,
|
||||
&runtime_error,
|
||||
)?;
|
||||
let mut next = || {
|
||||
at.next().ok_or_else(|| {
|
||||
ExecutorError::Failed("the pass's attachments outnumber their indices".into())
|
||||
})
|
||||
};
|
||||
let depth_stencil = case
|
||||
.depth_stencil
|
||||
.as_ref()
|
||||
.map(|authored| DepthStencil::make(device, device_type, authored))
|
||||
.map(|authored| {
|
||||
let at = match authored.samples > 1 {
|
||||
true => Some(next()?),
|
||||
false => None,
|
||||
};
|
||||
DepthStencil::make(device, device_type, authored, at)
|
||||
})
|
||||
.transpose()?;
|
||||
let mut textures = BTreeMap::new();
|
||||
for ((&index, target), at) in case.color_targets.iter().zip(at) {
|
||||
let mut views = BTreeMap::new();
|
||||
let mut fills = Vec::new();
|
||||
for (&index, target) in &case.color_targets {
|
||||
let format = resources::pixel_format(target.format);
|
||||
let [width, height] = target.dimensions;
|
||||
let texture = attachment(device, format, [width, height], (index, at))?;
|
||||
let texture = attachment(
|
||||
device,
|
||||
format,
|
||||
[width, height],
|
||||
target.samples,
|
||||
(index, next()?),
|
||||
)?;
|
||||
if target.samples > 1 {
|
||||
fills.push(runtime_multisample::Fill {
|
||||
texture: texture.clone(),
|
||||
slice: 0,
|
||||
read: sample_read(target.format).map_err(ExecutorError::Failed)?,
|
||||
texels: target.bytes.clone(),
|
||||
});
|
||||
views.insert(index, next()?);
|
||||
textures.insert(index, texture);
|
||||
continue;
|
||||
}
|
||||
let row = width as usize * target.format.bytes_per_pixel();
|
||||
texture
|
||||
.replace_region(
|
||||
@@ -455,14 +509,17 @@ impl Targets {
|
||||
.map_err(|error| runtime_error(&format!("color target {index}"), error))?;
|
||||
textures.insert(index, texture);
|
||||
}
|
||||
runtime_multisample::filled(device, device_type, &fills, &runtime_error)?;
|
||||
Ok(Targets {
|
||||
textures,
|
||||
depth_stencil,
|
||||
views,
|
||||
_grant: grant,
|
||||
})
|
||||
}
|
||||
|
||||
/// The pass: each attachment loaded and stored.
|
||||
/// The pass: each attachment loaded and stored, a multisampled stencil aspect cleared to its
|
||||
/// one value.
|
||||
fn pass(&self) -> rt::RenderPassDescriptor {
|
||||
let mut pass = rt::RenderPassDescriptor::default();
|
||||
for (&index, texture) in &self.textures {
|
||||
@@ -481,7 +538,13 @@ impl Targets {
|
||||
Some(made) => {
|
||||
let attachment = &mut pass.stencil_attachment;
|
||||
attachment.texture = Some(made.texture.clone());
|
||||
attachment.load_action = rt::LoadAction::Load;
|
||||
attachment.load_action = match made.clear {
|
||||
Some(value) => {
|
||||
attachment.clear_stencil = u32::from(value);
|
||||
rt::LoadAction::Clear
|
||||
}
|
||||
None => rt::LoadAction::Load,
|
||||
};
|
||||
attachment.store_action = rt::StoreAction::Store;
|
||||
}
|
||||
None => {}
|
||||
@@ -489,45 +552,95 @@ impl Targets {
|
||||
pass
|
||||
}
|
||||
|
||||
/// The depth/stencil attachment's aspect with its bytes now, where the pass has one.
|
||||
fn depth_stencil_finals(&self) -> Result<Option<LiteralDepthStencil>, ExecutorError> {
|
||||
/// The depth/stencil attachment's aspect with its bytes now, where the pass has one: every
|
||||
/// sample of a multisampled one (`runtime_multisample`).
|
||||
fn depth_stencil_finals(
|
||||
&self,
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
) -> Result<Option<LiteralDepthStencil>, ExecutorError> {
|
||||
let Some(made) = &self.depth_stencil else {
|
||||
return Ok(None);
|
||||
};
|
||||
let [width, height] = made.dimensions;
|
||||
let row = width as usize * if made.depth { 4 } else { 1 };
|
||||
let image = row * height as usize;
|
||||
let mut bytes = vec![0u8; image];
|
||||
made.texture
|
||||
.get_bytes(
|
||||
&mut bytes,
|
||||
row as u64,
|
||||
image as u64,
|
||||
whole([width, height]),
|
||||
0,
|
||||
0,
|
||||
)
|
||||
.map_err(|error| runtime_error("the depth/stencil attachment's read-back", error))?;
|
||||
let bytes = match made.samples {
|
||||
1 => {
|
||||
let row = width as usize * if made.depth { 4 } else { 1 };
|
||||
let image = row * height as usize;
|
||||
let mut bytes = vec![0u8; image];
|
||||
made.texture
|
||||
.get_bytes(
|
||||
&mut bytes,
|
||||
row as u64,
|
||||
image as u64,
|
||||
whole([width, height]),
|
||||
0,
|
||||
0,
|
||||
)
|
||||
.map_err(|error| {
|
||||
runtime_error("the depth/stencil attachment's read-back", error)
|
||||
})?;
|
||||
bytes
|
||||
}
|
||||
_ => {
|
||||
let read = match made.depth {
|
||||
true => SampleRead::Depth,
|
||||
false => SampleRead::Stencil,
|
||||
};
|
||||
runtime_multisample::read_back(
|
||||
device,
|
||||
device_type,
|
||||
&made.texture,
|
||||
read,
|
||||
None,
|
||||
&runtime_error,
|
||||
)?
|
||||
}
|
||||
};
|
||||
let (depth, stencil) = match made.depth {
|
||||
true => (Some(bytes), None),
|
||||
false => (None, Some(bytes)),
|
||||
};
|
||||
Ok(Some(LiteralDepthStencil {
|
||||
dimensions: made.dimensions,
|
||||
samples: 1,
|
||||
samples: made.samples,
|
||||
depth,
|
||||
stencil,
|
||||
}))
|
||||
}
|
||||
|
||||
/// Each authored color target with its bytes now, by Metal index.
|
||||
fn finals(&self, case: &RenderCase) -> Result<BTreeMap<u32, ColorTarget>, ExecutorError> {
|
||||
/// Each authored color target with its bytes now, by Metal index: every sample of a
|
||||
/// multisampled one (`runtime_multisample`).
|
||||
fn finals(
|
||||
&self,
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
case: &RenderCase,
|
||||
) -> Result<BTreeMap<u32, ColorTarget>, ExecutorError> {
|
||||
case.color_targets
|
||||
.iter()
|
||||
.map(|(&index, authored)| {
|
||||
let texture = self.textures.get(&index).ok_or_else(|| {
|
||||
ExecutorError::Failed(format!("color target {index} is not made"))
|
||||
})?;
|
||||
if let Some(&view) = self.views.get(&index) {
|
||||
let read = sample_read(authored.format).map_err(ExecutorError::Failed)?;
|
||||
let bytes = runtime_multisample::read_back(
|
||||
device,
|
||||
device_type,
|
||||
texture,
|
||||
read,
|
||||
Some(view),
|
||||
&runtime_error,
|
||||
)?;
|
||||
return Ok((
|
||||
index,
|
||||
ColorTarget {
|
||||
bytes,
|
||||
..authored.clone()
|
||||
},
|
||||
));
|
||||
}
|
||||
let [width, height] = authored.dimensions;
|
||||
let row = width as usize * authored.format.bytes_per_pixel();
|
||||
let image = row * height as usize;
|
||||
@@ -557,35 +670,62 @@ impl Targets {
|
||||
}
|
||||
|
||||
impl DepthStencil {
|
||||
/// `authored`'s one aspect: a `Depth32Float` filled with its depths by a draw
|
||||
/// (`runtime_depth`), or a `Stencil8` written from its bytes.
|
||||
/// `authored`'s one aspect, at texture index `at` of the run's grant where shaders reach it: of
|
||||
/// one sample, at no index, a `Depth32Float` filled with its depths by a draw (`runtime_depth`)
|
||||
/// or a `Stencil8` written from its bytes; of more, a `Depth32Float` filled sample by sample
|
||||
/// (`runtime_multisample`) or a `Stencil8` the pass clears to its one value
|
||||
/// (`uniform_stencil`).
|
||||
fn make(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
authored: &LiteralDepthStencil,
|
||||
at: Option<u32>,
|
||||
) -> Result<DepthStencil, ExecutorError> {
|
||||
let [width, height] = authored.dimensions;
|
||||
let samples = authored.samples.max(1);
|
||||
let what = "the depth/stencil attachment";
|
||||
let made = |format, depth, clear| {
|
||||
Ok::<_, ExecutorError>(DepthStencil {
|
||||
texture: aspect(device, format, [width, height], samples, at)?,
|
||||
depth,
|
||||
dimensions: authored.dimensions,
|
||||
samples,
|
||||
clear,
|
||||
})
|
||||
};
|
||||
match (&authored.depth, &authored.stencil) {
|
||||
(Some(depths), None) => {
|
||||
let texture = aspect(device, rt::PixelFormat::Depth32Float, [width, height])?;
|
||||
let fill = runtime_depth::Fill {
|
||||
texture: texture.clone(),
|
||||
level: 0,
|
||||
slice: 0,
|
||||
width,
|
||||
depths: depths.clone(),
|
||||
};
|
||||
runtime_depth::filled(device, device_type, &[fill], &runtime_error)?;
|
||||
Ok(DepthStencil {
|
||||
texture,
|
||||
depth: true,
|
||||
dimensions: authored.dimensions,
|
||||
})
|
||||
let made = made(rt::PixelFormat::Depth32Float, true, None)?;
|
||||
match samples {
|
||||
1 => {
|
||||
let fill = runtime_depth::Fill {
|
||||
texture: made.texture.clone(),
|
||||
level: 0,
|
||||
slice: 0,
|
||||
width,
|
||||
depths: depths.clone(),
|
||||
};
|
||||
runtime_depth::filled(device, device_type, &[fill], &runtime_error)?;
|
||||
}
|
||||
_ => {
|
||||
let fill = runtime_multisample::Fill {
|
||||
texture: made.texture.clone(),
|
||||
slice: 0,
|
||||
read: SampleRead::Depth,
|
||||
texels: depths.clone(),
|
||||
};
|
||||
runtime_multisample::filled(device, device_type, &[fill], &runtime_error)?;
|
||||
}
|
||||
}
|
||||
Ok(made)
|
||||
}
|
||||
(None, Some(stencil)) if samples > 1 => {
|
||||
let value = uniform_stencil(stencil).map_err(ExecutorError::Failed)?;
|
||||
made(rt::PixelFormat::Stencil8, false, Some(value))
|
||||
}
|
||||
(None, Some(stencil)) => {
|
||||
let texture = aspect(device, rt::PixelFormat::Stencil8, [width, height])?;
|
||||
texture
|
||||
let made = made(rt::PixelFormat::Stencil8, false, None)?;
|
||||
made.texture
|
||||
.replace_region(
|
||||
whole([width, height]),
|
||||
0,
|
||||
@@ -595,11 +735,7 @@ impl DepthStencil {
|
||||
u64::from(width) * u64::from(height),
|
||||
)
|
||||
.map_err(|error| runtime_error(what, error))?;
|
||||
Ok(DepthStencil {
|
||||
texture,
|
||||
depth: false,
|
||||
dimensions: authored.dimensions,
|
||||
})
|
||||
Ok(made)
|
||||
}
|
||||
_ => Err(ExecutorError::Failed(format!(
|
||||
"{what} through the runtime holds one aspect"
|
||||
@@ -608,37 +744,71 @@ impl DepthStencil {
|
||||
}
|
||||
}
|
||||
|
||||
/// A Shared 2D depth or stencil attachment of `format` and `extent`, at no texture index: shaders
|
||||
/// neither read nor write it, and the runtime gives such a target none (`Refusal::TextureIndex`).
|
||||
/// A 2D depth or stencil attachment of `format`, `extent` and `samples`, at texture index `at` of
|
||||
/// the run's grant where shaders reach it ([`made_attachment`]): one of one sample shaders neither
|
||||
/// read nor write, and the runtime gives such a target no index (`Refusal::TextureIndex`).
|
||||
fn aspect(
|
||||
device: &rt::Device,
|
||||
format: rt::PixelFormat,
|
||||
[width, height]: [u32; 2],
|
||||
extent: [u32; 2],
|
||||
samples: u32,
|
||||
at: Option<u32>,
|
||||
) -> Result<rt::Texture, ExecutorError> {
|
||||
let mut descriptor = rt::TextureDescriptor::new(rt::TextureType::Type2D, format, width, height);
|
||||
descriptor.usage = rt::TextureUsage::RENDER_TARGET;
|
||||
descriptor.storage_mode = rt::StorageMode::Shared;
|
||||
device
|
||||
.new_texture(&descriptor, None)
|
||||
.map_err(|error| runtime_error("the depth/stencil attachment", error))
|
||||
made_attachment(
|
||||
device,
|
||||
format,
|
||||
extent,
|
||||
samples,
|
||||
rt::TextureUsage::empty(),
|
||||
at,
|
||||
)
|
||||
.map_err(|error| runtime_error("the depth/stencil attachment", error))
|
||||
}
|
||||
|
||||
/// A Shared 2D color attachment of `format` and `extent`, color attachment `index`'s, at texture
|
||||
/// index `at` of the run's grant.
|
||||
/// A 2D color attachment of `format`, `extent` and `samples`, color attachment `index`'s, at
|
||||
/// texture index `at` of the run's grant ([`made_attachment`]).
|
||||
fn attachment(
|
||||
device: &rt::Device,
|
||||
format: rt::PixelFormat,
|
||||
[width, height]: [u32; 2],
|
||||
extent: [u32; 2],
|
||||
samples: u32,
|
||||
(index, at): (u32, u32),
|
||||
) -> Result<rt::Texture, ExecutorError> {
|
||||
let mut descriptor = rt::TextureDescriptor::new(rt::TextureType::Type2D, format, width, height);
|
||||
descriptor.usage = rt::TextureUsage::RENDER_TARGET;
|
||||
descriptor.storage_mode = rt::StorageMode::Shared;
|
||||
device
|
||||
.new_texture(&descriptor, Some(at))
|
||||
let viewed = rt::TextureUsage::PIXEL_FORMAT_VIEW;
|
||||
made_attachment(device, format, extent, samples, viewed, Some(at))
|
||||
.map_err(|error| runtime_error(&format!("color target {index}"), error))
|
||||
}
|
||||
|
||||
/// A 2D attachment of `format`, `extent` and `samples` at texture index `at`, if any: of one sample
|
||||
/// Shared, of more a Private multisampled texture (Metal keeps none in shared memory) that a shader
|
||||
/// reads, with `viewed` beside (a color one is viewed in another pixel format), as its per-sample
|
||||
/// fill and read take it.
|
||||
fn made_attachment(
|
||||
device: &rt::Device,
|
||||
format: rt::PixelFormat,
|
||||
[width, height]: [u32; 2],
|
||||
samples: u32,
|
||||
viewed: rt::TextureUsage,
|
||||
at: Option<u32>,
|
||||
) -> Result<rt::Texture, rt::Error> {
|
||||
let multisampled = samples > 1;
|
||||
let texture_type = match multisampled {
|
||||
true => rt::TextureType::Type2DMultisample,
|
||||
false => rt::TextureType::Type2D,
|
||||
};
|
||||
let mut descriptor = rt::TextureDescriptor::new(texture_type, format, width, height);
|
||||
descriptor.sample_count = samples;
|
||||
descriptor.usage = match multisampled {
|
||||
true => rt::TextureUsage::RENDER_TARGET | rt::TextureUsage::SHADER_READ | viewed,
|
||||
false => rt::TextureUsage::RENDER_TARGET,
|
||||
};
|
||||
descriptor.storage_mode = match multisampled {
|
||||
true => rt::StorageMode::Private,
|
||||
false => rt::StorageMode::Shared,
|
||||
};
|
||||
device.new_texture(&descriptor, at)
|
||||
}
|
||||
|
||||
/// The region of a whole 2D level of `extent`.
|
||||
fn whole([width, height]: [u32; 2]) -> rt::Region {
|
||||
rt::Region {
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
//! index of the run's texture grant (the bound textures first, then the members), and every
|
||||
//! level's slices written from the case's bytes before the work (`replaceRegion:`, level 0
|
||||
//! first), but for a 32-bit float depth's, which the run renders (`runtime_depth`), with the
|
||||
//! texture made for rendering too. Each sampler is the oracle's descriptor of it (`engine::resources::sampler_descriptor`,
|
||||
//! texture made for rendering too, and a multisampled texture's, Private as Metal keeps one, which
|
||||
//! the run renders sample by sample (`runtime_multisample`), made for rendering and for views of
|
||||
//! another pixel format too. Each sampler is the oracle's descriptor of it (`engine::resources::sampler_descriptor`,
|
||||
//! `argument_sampler_descriptor`), at an index of the run's sampler grant counted down from its
|
||||
//! top, so it never meets the constexpr samplers the pipeline numbers up from the bottom. A
|
||||
//! member's `gpuResourceID` is the word its owner holds at its field ([`Bound::words`]), as a
|
||||
@@ -16,10 +18,12 @@
|
||||
//! it (`getBytes:`): the selected region of level 0, slice by slice.
|
||||
|
||||
use super::runtime_depth;
|
||||
use super::runtime_multisample;
|
||||
use crate::candidate::engine::argument_buffers::FieldKey;
|
||||
use crate::candidate::engine::{resources, ComputeCase, RuntimeKernel};
|
||||
use crate::case::{ArgumentBufferSamplerResource, SamplerResource, TextureFormat};
|
||||
use crate::check::admission::ExecutorError;
|
||||
use crate::executor_contract::multisample::sample_read;
|
||||
use crate::gpu::DeviceType;
|
||||
use crate::literal::LiteralTexture;
|
||||
use metal2vulkan::metal::TextureUsage;
|
||||
@@ -146,7 +150,7 @@ pub(super) fn make(
|
||||
) -> Result<Bound, ExecutorError> {
|
||||
let count = wanted.textures.len() + wanted.members.len();
|
||||
let (grant, mut at) = texture_indices(device, indices, count, &error)?;
|
||||
let mut fills = Vec::new();
|
||||
let mut fills = Fills::default();
|
||||
let mut textures = BTreeMap::new();
|
||||
for ((&binding, texture), index) in wanted.textures.iter().zip(&mut at) {
|
||||
let usage = wanted
|
||||
@@ -172,9 +176,10 @@ pub(super) fn make(
|
||||
let made = made_texture(device, texture, usage, index, &error, &mut fills)?;
|
||||
members.insert(key, made);
|
||||
}
|
||||
if !fills.is_empty() {
|
||||
runtime_depth::filled(device, device_type, &fills, &error)?;
|
||||
if !fills.depths.is_empty() {
|
||||
runtime_depth::filled(device, device_type, &fills.depths, &error)?;
|
||||
}
|
||||
runtime_multisample::filled(device, device_type, &fills.samples, &error)?;
|
||||
let mut samplers = BTreeMap::new();
|
||||
for (&binding, sampler) in wanted.samplers {
|
||||
let state = device
|
||||
@@ -199,15 +204,23 @@ pub(super) fn make(
|
||||
})
|
||||
}
|
||||
|
||||
/// The draws a run renders into its textures before the work: each 32-bit float depth's level and
|
||||
/// slice (`runtime_depth`) and each multisampled texture's slice (`runtime_multisample`).
|
||||
#[derive(Default)]
|
||||
struct Fills {
|
||||
depths: Vec<runtime_depth::Fill>,
|
||||
samples: Vec<runtime_multisample::Fill>,
|
||||
}
|
||||
|
||||
/// `texture` made with `usage` at `index`, every level's slices written from its bytes; a 32-bit
|
||||
/// float depth's are pushed to `fills` instead, which the run renders (`runtime_depth`).
|
||||
/// float depth's and a multisampled texture's are pushed to `fills` instead, which the run renders.
|
||||
fn made_texture(
|
||||
device: &rt::Device,
|
||||
texture: &LiteralTexture,
|
||||
usage: rt::TextureUsage,
|
||||
index: u32,
|
||||
error: &impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
fills: &mut Vec<runtime_depth::Fill>,
|
||||
fills: &mut Fills,
|
||||
) -> Result<rt::Texture, ExecutorError> {
|
||||
let what = format!("texture {}", texture.binding);
|
||||
let layout = texture.layout().map_err(ExecutorError::Failed)?;
|
||||
@@ -221,16 +234,48 @@ fn made_texture(
|
||||
descriptor.array_length = layout.metal_array_length(texture.texture_type);
|
||||
descriptor.sample_count = layout.sample_count;
|
||||
descriptor.mipmap_level_count = texture.mip_levels;
|
||||
// A 32-bit float depth is filled by a draw, which renders into the texture (`runtime_depth`).
|
||||
// A 32-bit float depth is filled by a draw, which renders into the texture (`runtime_depth`),
|
||||
// and a multisampled texture by a draw per slice, a color one through a view of an
|
||||
// unsigned-integer format (`runtime_multisample`).
|
||||
let depth = texture.format == TextureFormat::Depth32Float;
|
||||
descriptor.usage = match depth {
|
||||
true => usage | rt::TextureUsage::RENDER_TARGET,
|
||||
false => usage,
|
||||
let multisampled = layout.sample_count > 1;
|
||||
descriptor.usage = match (depth, multisampled) {
|
||||
(false, true) => {
|
||||
usage | rt::TextureUsage::RENDER_TARGET | rt::TextureUsage::PIXEL_FORMAT_VIEW
|
||||
}
|
||||
(true, _) => usage | rt::TextureUsage::RENDER_TARGET,
|
||||
(false, false) => usage,
|
||||
};
|
||||
descriptor.storage_mode = match multisampled {
|
||||
true => rt::StorageMode::Private,
|
||||
false => rt::StorageMode::Shared,
|
||||
};
|
||||
descriptor.storage_mode = rt::StorageMode::Shared;
|
||||
let made = device
|
||||
.new_texture(&descriptor, Some(index))
|
||||
.map_err(|e| error(&what, e))?;
|
||||
if multisampled {
|
||||
let read = sample_read(texture.format).map_err(ExecutorError::Failed)?;
|
||||
let slice = layout.width as usize
|
||||
* layout.height as usize
|
||||
* layout.sample_count as usize
|
||||
* texture.format.bytes_per_pixel();
|
||||
let slices = layout.array_layers as usize;
|
||||
if slice == 0 || texture.bytes.len() < slice * slices {
|
||||
return Err(ExecutorError::Failed(format!(
|
||||
"{what} supplies {} bytes, short of its {slices} multisampled slices",
|
||||
texture.bytes.len()
|
||||
)));
|
||||
}
|
||||
for (at, texels) in texture.bytes.chunks_exact(slice).take(slices).enumerate() {
|
||||
fills.samples.push(runtime_multisample::Fill {
|
||||
texture: made.clone(),
|
||||
slice: at as u32,
|
||||
read,
|
||||
texels: texels.to_vec(),
|
||||
});
|
||||
}
|
||||
return Ok(made);
|
||||
}
|
||||
for level in 0..texture.mip_levels {
|
||||
let (dimensions, bytes) = texture.level(level).map_err(ExecutorError::Failed)?;
|
||||
let span = crate::literal::subresource_span(
|
||||
@@ -254,7 +299,7 @@ fn made_texture(
|
||||
{
|
||||
let slice = span.base_slice + slice as u32;
|
||||
if depth {
|
||||
fills.push(runtime_depth::Fill {
|
||||
fills.depths.push(runtime_depth::Fill {
|
||||
texture: made.clone(),
|
||||
level,
|
||||
slice,
|
||||
|
||||
@@ -460,6 +460,55 @@ fn an_observed_vertex_case_draws_into_its_generated_observer() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A pass of 4 samples: `sample_rate_mask_in` runs once per sample (`sample_id`) and writes its
|
||||
/// coverage beside its sample index, so sample `s` of the one pixel holds `(mask, s, 0, 1)` over
|
||||
/// the authored contents, each sample's own. Through the runtime the target is filled and read
|
||||
/// back sample by sample (`platform::runtime_multisample`) and holds the same words.
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[test]
|
||||
fn each_sample_of_a_multisampled_target_holds_its_own_invocation() {
|
||||
let fragment = public("engine/sample_rate.ll");
|
||||
let mut authored = crate::companion::tests::case(
|
||||
Stage::Fragment,
|
||||
"sample_rate_mask_in",
|
||||
TextureFormat::Rgba32Uint,
|
||||
);
|
||||
authored.raster_sample_count = Some(4);
|
||||
authored.render_targets[0].initial_bytes_b64 = b64(&[0xab; 4 * 16]);
|
||||
authored.output = OutputSelection::RenderTarget {
|
||||
index: 0,
|
||||
origin: [0, 0],
|
||||
dimensions: [1, 1],
|
||||
};
|
||||
let (case, companion) = with_companion(&authored, &fragment);
|
||||
let run = run(
|
||||
&case,
|
||||
RenderLibraries {
|
||||
vertex: &companion,
|
||||
fragment: Some(&fragment),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let words: Vec<u32> = run
|
||||
.output
|
||||
.chunks_exact(4)
|
||||
.map(|word| u32::from_le_bytes(word.try_into().unwrap()))
|
||||
.collect();
|
||||
let indices: Vec<[u32; 3]> = words
|
||||
.chunks_exact(4)
|
||||
.map(|sample| [sample[1], sample[2], sample[3]])
|
||||
.collect();
|
||||
assert_eq!(indices, [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1]]);
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
assert!(crate::candidate::engine::runs_render_through_runtime(
|
||||
&authored, &case
|
||||
));
|
||||
let through = run_on_runtime(&case, &fragment, Some(&companion)).unwrap();
|
||||
assert_eq!(through.output, run.output, "through the runtime");
|
||||
}
|
||||
}
|
||||
|
||||
/// A tessellation case drawn through the render executor's patch path: the factor buffer bound
|
||||
/// where the plan's factor write names it, the probe as the evaluation stage, and the case's cull
|
||||
/// mode. `k7_tess_quad_probe` draws patch 0 over the target's left half and patch 1, its mirror
|
||||
|
||||
@@ -432,7 +432,8 @@ fn each_level_of_a_mipmapped_texture_holds_its_own_texels() {
|
||||
}
|
||||
|
||||
/// A depth texture read and a multisampled integer texture read of one sample, which this
|
||||
/// executor initializes per sample.
|
||||
/// executor initializes per sample, and so does a run through the runtime, by a draw that writes
|
||||
/// each sample through an unsigned-integer view (`platform::runtime_multisample`).
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[test]
|
||||
fn depth_and_multisampled_textures_read_their_authored_texels() {
|
||||
@@ -464,9 +465,12 @@ fn depth_and_multisampled_textures_read_their_authored_texels() {
|
||||
[1, 1, 1],
|
||||
buffer_output(8),
|
||||
);
|
||||
let run = run(&case, &fixture("texture_ops.ll")).unwrap();
|
||||
// Sample 2's `.y`.
|
||||
assert_eq!(run.output, floats(&[0.375, 14.0]));
|
||||
let bitcode = fixture("texture_ops.ll");
|
||||
for (name, run) in runs() {
|
||||
let run = run(&case, &bitcode).unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
// Sample 2's `.y`.
|
||||
assert_eq!(run.output, floats(&[0.375, 14.0]), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A sample count the device's image format properties do not allow is refused typed before any
|
||||
|
||||
+13
-5
@@ -478,15 +478,23 @@ cargo run -p metal2vulkan-validation --release --bin corpus-moltenvk -- \
|
||||
buffer's texture array is the descriptor arrays its resource ids' masked indices read
|
||||
(`resource-id:shader`), a read past it a texel of a bound texture or zero. Each buffer target sits
|
||||
between guards of its declared reach in a Shared block of its own, read back after the
|
||||
dispatch. A multisampled, sparse, texture-buffer or cube-array texture keeps the case on the executor's own
|
||||
dispatch. A multisampled texture, which neither Metal nor the runtime uploads, is Private and
|
||||
filled by a draw per slice of the owned `sample_fill` pair, its fragment run once per sample
|
||||
writing that sample's texel from a buffer, a color one through an unsigned-integer view of its
|
||||
texel size so its bits cross unconverted, a depth one under an always-passing depth test that
|
||||
writes. A sparse, texture-buffer or cube-array texture keeps the case on the executor's own
|
||||
context. A pixel format the runtime makes no image of on the device records `not_enabled`, as
|
||||
the executor's own context records a format its query lacks. A vertex or fragment case of one
|
||||
sample draws through the runtime the same way (`engine::runs_render_through_runtime`): its own
|
||||
the executor's own context records a format its query lacks. A vertex or fragment case of any
|
||||
sample count draws through the runtime the same way (`engine::runs_render_through_runtime`): its own
|
||||
stage's buffers, bound textures and samplers, function constants and linked functions, its
|
||||
generated companion, its vertex buffers at static strides, its color targets (Shared 2D
|
||||
textures, loaded and stored by the pass), a depth/stencil attachment of one aspect as the oracle
|
||||
makes it (a Shared `Depth32Float` filled by a draw of its depths, as a 32-bit float depth texture
|
||||
is, or a Shared `Stencil8` written from its bytes, loaded and stored by the pass), the oracle's
|
||||
is, or a Shared `Stencil8` written from its bytes, loaded and stored by the pass; in a pass of
|
||||
more samples each attachment Private and multisampled, filled as a multisampled texture is, a
|
||||
stencil aspect of one value in every sample cleared to it by the pass, and every sample read
|
||||
back after the draw by a dispatch of the pair's kernels, unresolved, in the layout
|
||||
`executor_contract::multisample` states), the oracle's
|
||||
depth-stencil state, cull mode and winding, and one direct or indexed draw of primitives or one
|
||||
patch draw of a post-tessellation vertex function with no patch index buffer (its factors a
|
||||
Shared buffer bound as the tessellation factor buffer at the oracle's offset and instance
|
||||
@@ -496,7 +504,7 @@ cargo run -p metal2vulkan-validation --release --bin corpus-moltenvk -- \
|
||||
runtime device's own translator: the runtime's floor enables no buffer robustness, so a
|
||||
fixed-function vertex fetch past its buffer is checked nowhere and the case is refused as
|
||||
`not_supported{uncontained:unchecked vertex_input}`. A rasterization-disabled vertex case renders
|
||||
into the oracle's 1x1 `R8Unorm` attachment. More samples, layered rendering, a dynamic vertex
|
||||
into the oracle's 1x1 `R8Unorm` attachment. Layered rendering, a dynamic vertex
|
||||
stride, an argument-buffer member, a patch index buffer, an imageblock, a rasterization-rate map, an
|
||||
out-of-bounds target other than an attribute buffer or a fragment pass with no attachment (the
|
||||
runtime makes no pass without one) keeps the case on the executor's own context. An indexed
|
||||
|
||||
Reference in new issue
Block a user