Validation: a 32-bit float depth texture is filled by a draw through the runtime, and a depth outside [0, 1] is the runtime's limit
The runtime takes no upload of a 32-bit float depth (Gap::FloatDepthUpload, which its own texture and blit tests hold both ways). Kernel and render cases that bind a Depth32Float texture stayed on the executor's own context. Now they run through the runtime: the run fills each such texture by a draw, as a guest fills one. The fill: - The owned fixture depth_fill.metal is regenerated with scripts/regen-air-fixtures on the M3 (m3-max-61107). It holds a fullscreen vertex function and a fragment function that writes depth(any) from a buffer of texels by pixel. - platform::runtime_depth draws one pass per level and slice into the texture's depth attachment, under an always-passing depth test that writes. The texture is made with RenderTarget usage beside its declared usage. DepthOutsideUnitRange becomes the runtime's limit (Limit::Runtime) and qualifies on Metal, as ruled. A draw writes depths clamped to the viewport's [0, 1], so no runtime call puts a NaN, a negative value or a value above 1 where Metal's texel holds it. The case checker now raises the requirement from the case's literals on every device (executor_contract::case_requirements, via depth_range::depth_range_requirement). The literals checked are each Depth32Float texture, each texture-array element, each argument buffer's texture, and the depth attachment's initial depth. The old executor's device-gated check (plan_resources::require_depth_range, which read VK_EXT_depth_range_unrestricted) and its two call sites are deleted. The fill refuses such a depth too, typed, so it never clamps one silently. No source fact carries the requirement, so the source census is unchanged. Of the committed public cases, 7 kernel cases close as runtime-refused (4ac0d4322d, 5d9f284f87, 70064cea52, f04e9b48c8, 59b3a9a43e, 6955da3062, b3d8e09b92). Their Metal rows stay as committed. ENGINE_EXECUTOR_ABI goes to v191. Tests: - Unit: the requirement from each literal kind, and its limit, stops and evidence gap. - The Runtime and qualifies_on_metal lists. - Routing: a Depth32Float texture now routes. - Device: a_float_depth_texture_is_filled_by_a_draw_and_reads_back_as_authored. Both runs read eight depths of a 4x2 texture back exactly, and through the runtime a depth of 2.0 is refused as depth_outside_unit_range. - The device test of the old gate is deleted with the gate.
This commit is contained in:
1 parent
acc706ca47
commit
1687f8fc38
19 files changed
+715
-188
No files matched your search
@@ -54,6 +54,7 @@ fixture coverage_natural: metal: Apple metal version 32023.921 (metalfe-32023.92
|
||||
fixture coverage_outputs: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture dcs_dont_care_split: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture denormal_texels: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture depth_fill: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture device_level: metal: Apple metal version 32023.921 (metalfe-32023.921.6); macosx-sdk: 27.0 (26A425)
|
||||
fixture dfk_dead_fetch: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
fixture dfk_dead_group: metal: Apple metal version 32023.922 (metalfe-32023.922.4); macosx-sdk: 27.2 (26B118)
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
; Generated by scripts/regen-air-fixtures from depth_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._depth_2d_t = type opaque
|
||||
%struct._sampler_t = type opaque
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
|
||||
define <4 x float> @depth_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 <{ float }> @depth_fill_fragment(<4 x float> noundef %0, float addrspace(1)* nocapture noundef readonly "air-buffer-no-alias" %1, i32 addrspace(2)* nocapture noundef readonly align 4 dereferenceable(4) "air-buffer-no-alias" %2) local_unnamed_addr #3 {
|
||||
%4 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%5 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %4) #7
|
||||
%6 = extractelement <2 x i32> %5, i64 1
|
||||
%7 = load i32, i32 addrspace(2)* %2, align 4, !tbaa !33, !alias.scope !37, !noalias !40
|
||||
%8 = mul i32 %6, %7
|
||||
%9 = extractelement <2 x i32> %5, i64 0
|
||||
%10 = add i32 %8, %9
|
||||
%11 = zext i32 %10 to i64
|
||||
%12 = getelementptr inbounds float, float addrspace(1)* %1, i64 %11
|
||||
%13 = load float, float addrspace(1)* %12, align 4, !tbaa !42, !alias.scope !40, !noalias !37
|
||||
%14 = insertvalue <{ float }> undef, float %13, 0
|
||||
ret <{ float }> %14
|
||||
}
|
||||
|
||||
; 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: mustprogress nofree nounwind willreturn
|
||||
define void @depth_fill_read(%struct._depth_2d_t addrspace(1)* nocapture readonly %0, float addrspace(1)* nocapture noundef writeonly "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #4 {
|
||||
%4 = and i32 %2, 3
|
||||
%5 = insertelement <2 x i32> undef, i32 %4, i64 0
|
||||
%6 = lshr i32 %2, 2
|
||||
%7 = insertelement <2 x i32> %5, i32 %6, i64 1
|
||||
%8 = tail call %struct._sampler_t addrspace(2)* @air.get_read_sampler() #8
|
||||
%9 = tail call { float, i8 } @air.read_depth_2d.f32(%struct._depth_2d_t addrspace(1)* nocapture readonly %0, %struct._sampler_t addrspace(2)* %8, i32 1, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 1) #9
|
||||
%10 = extractvalue { float, i8 } %9, 0
|
||||
%11 = zext i32 %2 to i64
|
||||
%12 = getelementptr inbounds float, float addrspace(1)* %1, i64 %11
|
||||
store float %10, float addrspace(1)* %12, align 4, !tbaa !42, !alias.scope !44, !noalias !47
|
||||
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 { float, i8 } @air.read_depth_2d.f32(%struct._depth_2d_t addrspace(1)* nocapture readonly, %struct._sampler_t addrspace(2)*, i32, <2 x 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"="64" "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}
|
||||
!air.kernel = !{!21}
|
||||
!air.compile_options = !{!27, !28, !29}
|
||||
!llvm.ident = !{!30}
|
||||
!air.version = !{!31}
|
||||
!air.language_version = !{!32}
|
||||
|
||||
!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)* @depth_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 = !{<{ float }> (<4 x float>, float addrspace(1)*, i32 addrspace(2)*)* @depth_fill_fragment, !15, !17}
|
||||
!15 = !{!16}
|
||||
!16 = !{!"air.depth", !"air.depth_qualifier", !"air.any", !"air.arg_type_name", !"float", !"air.arg_name", !"depth"}
|
||||
!17 = !{!18, !19, !20}
|
||||
!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!19 = !{i32 1, !"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"}
|
||||
!20 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"width"}
|
||||
!21 = !{void (%struct._depth_2d_t addrspace(1)*, float addrspace(1)*, i32)* @depth_fill_read, !22, !23}
|
||||
!22 = !{}
|
||||
!23 = !{!24, !25, !26}
|
||||
!24 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"depth2d<float, read>", !"air.arg_name", !"depths"}
|
||||
!25 = !{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", !"float", !"air.arg_name", !"out"}
|
||||
!26 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"}
|
||||
!27 = !{!"air.compile.denorms_disable"}
|
||||
!28 = !{!"air.compile.fast_math_disable"}
|
||||
!29 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!30 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!31 = !{i32 2, i32 8, i32 0}
|
||||
!32 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!33 = !{!34, !34, i64 0}
|
||||
!34 = !{!"int", !35, i64 0}
|
||||
!35 = !{!"omnipotent char", !36, i64 0}
|
||||
!36 = !{!"Simple C++ TBAA"}
|
||||
!37 = !{!38}
|
||||
!38 = distinct !{!38, !39, !"air-alias-scope-arg(2)"}
|
||||
!39 = distinct !{!39, !"air-alias-scopes(depth_fill_fragment)"}
|
||||
!40 = !{!41}
|
||||
!41 = distinct !{!41, !39, !"air-alias-scope-arg(1)"}
|
||||
!42 = !{!43, !43, i64 0}
|
||||
!43 = !{!"float", !35, i64 0}
|
||||
!44 = !{!45}
|
||||
!45 = distinct !{!45, !46, !"air-alias-scope-arg(1)"}
|
||||
!46 = distinct !{!46, !"air-alias-scopes(depth_fill_read)"}
|
||||
!47 = !{!48}
|
||||
!48 = distinct !{!48, !46, !"air-alias-scope-textures"}
|
||||
@@ -0,0 +1,136 @@
|
||||
; Generated by scripts/regen-air-fixtures from depth_fill.metal (llvm-dis of depth_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"
|
||||
|
||||
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
|
||||
define <4 x float> @depth_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 <{ float }> @depth_fill_fragment(<4 x float> noundef %0, ptr addrspace(1) noundef readonly captures(none) "air-buffer-no-alias" %1, ptr addrspace(2) noundef readonly align 4 captures(none) dereferenceable(4) "air-buffer-no-alias" %2) local_unnamed_addr #3 {
|
||||
%4 = shufflevector <4 x float> %0, <4 x float> poison, <2 x i32> <i32 0, i32 1>
|
||||
%5 = tail call <2 x i32> @air.convert.u.v2i32.f.v2f32(<2 x float> %4) #7
|
||||
%6 = extractelement <2 x i32> %5, i64 1
|
||||
%7 = load i32, ptr addrspace(2) %2, align 4, !tbaa !33, !alias.scope !37, !noalias !40
|
||||
%8 = mul i32 %6, %7
|
||||
%9 = extractelement <2 x i32> %5, i64 0
|
||||
%10 = add i32 %8, %9
|
||||
%11 = zext i32 %10 to i64
|
||||
%12 = getelementptr inbounds float, ptr addrspace(1) %1, i64 %11
|
||||
%13 = load float, ptr addrspace(1) %12, align 4, !tbaa !42, !alias.scope !40, !noalias !37
|
||||
%14 = insertvalue <{ float }> undef, float %13, 0
|
||||
ret <{ float }> %14
|
||||
}
|
||||
|
||||
; 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 nounwind willreturn
|
||||
define void @depth_fill_read(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(1) noundef writeonly captures(none) "air-buffer-no-alias" %1, i32 noundef %2) local_unnamed_addr #4 {
|
||||
%4 = and i32 %2, 3
|
||||
%5 = insertelement <2 x i32> undef, i32 %4, i64 0
|
||||
%6 = lshr i32 %2, 2
|
||||
%7 = insertelement <2 x i32> %5, i32 %6, i64 1
|
||||
%8 = tail call ptr addrspace(2) @air.get_read_sampler() #8
|
||||
%9 = tail call { float, i8 } @air.read_depth_2d.f32(ptr addrspace(1) readonly captures(none) %0, ptr addrspace(2) %8, i32 1, <2 x i32> %7, <2 x i32> zeroinitializer, i32 0, i32 1) #9
|
||||
%10 = extractvalue { float, i8 } %9, 0
|
||||
%11 = zext i32 %2 to i64
|
||||
%12 = getelementptr inbounds float, ptr addrspace(1) %1, i64 %11
|
||||
store float %10, ptr addrspace(1) %12, align 4, !tbaa !42, !alias.scope !44, !noalias !47
|
||||
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 { float, i8 } @air.read_depth_2d.f32(ptr addrspace(1) readonly captures(none), ptr addrspace(2), i32, <2 x 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"="64" "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}
|
||||
!air.kernel = !{!21}
|
||||
!air.compile_options = !{!27, !28, !29}
|
||||
!llvm.ident = !{!30}
|
||||
!air.version = !{!31}
|
||||
!air.language_version = !{!32}
|
||||
|
||||
!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 @depth_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 @depth_fill_fragment, !15, !17}
|
||||
!15 = !{!16}
|
||||
!16 = !{!"air.depth", !"air.depth_qualifier", !"air.any", !"air.arg_type_name", !"float", !"air.arg_name", !"depth"}
|
||||
!17 = !{!18, !19, !20}
|
||||
!18 = !{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}
|
||||
!19 = !{i32 1, !"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"}
|
||||
!20 = !{i32 2, !"air.buffer", !"air.buffer_size", i32 4, !"air.location_index", i32 1, i32 1, !"air.read", !"air.address_space", i32 2, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"width"}
|
||||
!21 = !{ptr @depth_fill_read, !22, !23}
|
||||
!22 = !{}
|
||||
!23 = !{!24, !25, !26}
|
||||
!24 = !{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.read", !"air.arg_type_name", !"depth2d<float, read>", !"air.arg_name", !"depths"}
|
||||
!25 = !{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", !"float", !"air.arg_name", !"out"}
|
||||
!26 = !{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"}
|
||||
!27 = !{!"air.compile.denorms_disable"}
|
||||
!28 = !{!"air.compile.fast_math_disable"}
|
||||
!29 = !{!"air.compile.framebuffer_fetch_enable"}
|
||||
!30 = !{!"Apple metal version 32023.922 (metalfe-32023.922.4)"}
|
||||
!31 = !{i32 2, i32 8, i32 0}
|
||||
!32 = !{!"Metal", i32 4, i32 0, i32 0}
|
||||
!33 = !{!34, !34, i64 0}
|
||||
!34 = !{!"int", !35, i64 0}
|
||||
!35 = !{!"omnipotent char", !36, i64 0}
|
||||
!36 = !{!"Simple C++ TBAA"}
|
||||
!37 = !{!38}
|
||||
!38 = distinct !{!38, !39, !"air-alias-scope-arg(2)"}
|
||||
!39 = distinct !{!39, !"air-alias-scopes(depth_fill_fragment)"}
|
||||
!40 = !{!41}
|
||||
!41 = distinct !{!41, !39, !"air-alias-scope-arg(1)"}
|
||||
!42 = !{!43, !43, i64 0}
|
||||
!43 = !{!"float", !35, i64 0}
|
||||
!44 = !{!45}
|
||||
!45 = distinct !{!45, !46, !"air-alias-scope-arg(1)"}
|
||||
!46 = distinct !{!46, !"air-alias-scopes(depth_fill_read)"}
|
||||
!47 = !{!48}
|
||||
!48 = distinct !{!48, !46, !"air-alias-scope-textures"}
|
||||
@@ -0,0 +1,37 @@
|
||||
// metal-fast-math: off
|
||||
// Owned fixture: the validation executor's fill of a 32-bit float depth texture through the
|
||||
// runtime, which takes no upload of one (`Gap::FloatDepthUpload`): one draw writes every texel of
|
||||
// one level and slice from a buffer, as a guest fills a depth texture by rendering into it.
|
||||
//
|
||||
// * depth_fill_vertex: one triangle over the whole target, vertex v at clip position
|
||||
// (2 (v << 1 & 2) - 1, 2 (v & 2) - 1, 0, 1).
|
||||
// * depth_fill_fragment: the pixel at (x, y) writes depth texels[y * width + x] under
|
||||
// `depth(any)`, `width` the level's width in texels.
|
||||
// * depth_fill_read: thread t stores texel (t % 4, t / 4) of a 2D depth texture four texels
|
||||
// wide, as the device tests read a filled texture back.
|
||||
//
|
||||
// Loop-free.
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
vertex float4 depth_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);
|
||||
}
|
||||
|
||||
struct DepthFillOut {
|
||||
float depth [[depth(any)]];
|
||||
};
|
||||
|
||||
fragment DepthFillOut depth_fill_fragment(float4 position [[position]],
|
||||
device const float *texels [[buffer(0)]],
|
||||
constant uint &width [[buffer(1)]]) {
|
||||
uint2 pixel = uint2(position.xy);
|
||||
return {texels[pixel.y * width + pixel.x]};
|
||||
}
|
||||
|
||||
kernel void depth_fill_read(depth2d<float, access::read> depths [[texture(0)]],
|
||||
device float *out [[buffer(0)]],
|
||||
uint t [[thread_position_in_grid]]) {
|
||||
out[t] = depths.read(uint2(t % 4, t / 4));
|
||||
}
|
||||
@@ -49,8 +49,7 @@ use crate::case::out_of_bounds::{OutOfBoundsResource, OutOfBoundsTarget};
|
||||
use crate::case::{
|
||||
AccelerationStructureKind, ArgumentBufferSamplerResource, AuthoredCase,
|
||||
ImplicitImageblockCoverage, IntersectionFunctionTableEntry, IntersectionFunctionTableResource,
|
||||
OutputSelection, RateMapLiteral, ResourceRole, SamplerResource, Stage, TextureFormat,
|
||||
TextureType,
|
||||
OutputSelection, RateMapLiteral, ResourceRole, SamplerResource, Stage, TextureType,
|
||||
};
|
||||
use crate::check::admission::{
|
||||
admit, AdmittedCase, ExecutionRequest, ExecutorError, NotSupported, VenueMismatch,
|
||||
@@ -124,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-v190";
|
||||
pub const ENGINE_EXECUTOR_ABI: &str = "vulkan-engine-v191";
|
||||
|
||||
/// 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
|
||||
@@ -1214,9 +1213,9 @@ pub fn runs_through_runtime(authored: &AuthoredCase, case: &ComputeCase) -> bool
|
||||
/// 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`), and not a 32-bit float depth, whose bytes the runtime takes no
|
||||
/// upload of (`Gap::FloatDepthUpload`): a guest fills one by drawing, which a kernel case does
|
||||
/// not, so it stays on the executor's own context too.
|
||||
/// (`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`).
|
||||
fn runtime_texture(texture: &LiteralTexture) -> bool {
|
||||
texture.sample_count == 1
|
||||
&& texture.sparse.is_none()
|
||||
@@ -1224,7 +1223,6 @@ fn runtime_texture(texture: &LiteralTexture) -> bool {
|
||||
texture.texture_type,
|
||||
TextureType::Buffer | TextureType::CubeArray
|
||||
)
|
||||
&& texture.format != TextureFormat::Depth32Float
|
||||
}
|
||||
|
||||
/// The bytes of each buffer a run through the runtime binds, by Metal index, as the Metal oracle
|
||||
|
||||
@@ -2557,10 +2557,10 @@ 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 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, or one it takes no upload of: a 32-bit float depth)
|
||||
/// stays on the executor's own context.
|
||||
/// nothing, a 32-bit float depth among its textures (which the run fills by a draw); 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.
|
||||
#[test]
|
||||
fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
use crate::case::{
|
||||
@@ -2669,6 +2669,7 @@ fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
bytes: vec![0; 64],
|
||||
..texture(TextureType::D2, 1)
|
||||
};
|
||||
assert!(runs_through_runtime(&authored, &textured(depth)));
|
||||
let others = [
|
||||
object,
|
||||
ComputeCase {
|
||||
@@ -2683,7 +2684,6 @@ fn a_plain_kernel_case_and_only_one_runs_through_the_runtime() {
|
||||
textured(sparse),
|
||||
textured(texture(TextureType::Buffer, 1)),
|
||||
textured(texture(TextureType::CubeArray, 1)),
|
||||
textured(depth),
|
||||
member_buffer,
|
||||
];
|
||||
for other in &others {
|
||||
|
||||
@@ -16,6 +16,7 @@ mod plan_resources;
|
||||
mod profiles;
|
||||
mod render;
|
||||
mod runtime;
|
||||
mod runtime_depth;
|
||||
mod runtime_probe;
|
||||
mod runtime_render;
|
||||
mod runtime_textures;
|
||||
|
||||
@@ -293,38 +293,6 @@ struct TextureUse {
|
||||
storage: bool,
|
||||
}
|
||||
|
||||
/// Whether an image of `format` holds 32-bit float depth, which Vulkan takes no value outside
|
||||
/// `[0, 1]` into without `VK_EXT_depth_range_unrestricted`.
|
||||
fn is_float_depth(format: vk::Format) -> bool {
|
||||
matches!(
|
||||
format,
|
||||
vk::Format::D32_SFLOAT | vk::Format::D32_SFLOAT_S8_UINT
|
||||
)
|
||||
}
|
||||
|
||||
/// Refuse to give an image of `format` on `context`'s device the 32-bit float depths `depths` where
|
||||
/// one lies outside `[0, 1]` and the device lacks `VK_EXT_depth_range_unrestricted`
|
||||
/// (`ToolingRequirement::DepthOutsideUnitRange`, `executor_contract::depth_range`): the executor
|
||||
/// uploads a case's bytes as they are, which Vulkan does not take there, and never clamps them
|
||||
/// silently. Before the image is made, so a refused case allocates nothing.
|
||||
pub(super) fn require_depth_range(
|
||||
context: &VulkanContext,
|
||||
format: vk::Format,
|
||||
depths: &[u8],
|
||||
) -> Result<(), ExecutorError> {
|
||||
if !is_float_depth(format) {
|
||||
return Ok(());
|
||||
}
|
||||
let unrestricted = context
|
||||
.enabled
|
||||
.extensions
|
||||
.contains(&metal2vulkan::device::VkExtension::ExtDepthRangeUnrestricted);
|
||||
match crate::executor_contract::depth_range::depth_range_requirement(depths, unrestricted) {
|
||||
Some(requirement) => Err(NotSupported::Requirements([requirement].into()).into()),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a descriptor type reads an image through a sampler or `OpImageFetch` (sampled) rather
|
||||
/// than as a storage image.
|
||||
fn is_storage(ty: vk::DescriptorType) -> bool {
|
||||
@@ -1768,7 +1736,6 @@ fn create_slot_image(
|
||||
let aspect: vk::ImageAspectFlags = metal2vulkan::metal::format::aspects(pixel_format)
|
||||
.ok_or_else(|| format!("{label}: no aspects for {pixel_format:?}"))?
|
||||
.into();
|
||||
require_depth_range(context, format, &texture.bytes)?;
|
||||
let layout = texture_use.views[0].layout;
|
||||
if texture_use.views.iter().any(|view| view.layout != layout) {
|
||||
return Err(not_implemented(format!(
|
||||
|
||||
@@ -1706,9 +1706,6 @@ impl<'a> Targets<'a> {
|
||||
"color and depth/stencil targets of different extents",
|
||||
));
|
||||
}
|
||||
if let Some(depths) = &authored.depth {
|
||||
super::plan_resources::require_depth_range(context, format, depths)?;
|
||||
}
|
||||
targets.depth_stencil = Some(match transfer {
|
||||
AttachmentTransfer::Copy => create_depth_stencil(context, format, authored)?,
|
||||
AttachmentTransfer::PerSample { samples } => {
|
||||
|
||||
@@ -419,6 +419,7 @@ fn run(
|
||||
.collect::<Result<BTreeMap<FieldKey, Placed>, ExecutorError>>()?;
|
||||
let bound = runtime_textures::make(
|
||||
device,
|
||||
device_type,
|
||||
&runtime_textures::Wanted::of_kernel(case, kernel),
|
||||
&mut runtime_textures::Indices::new(),
|
||||
runtime_error,
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
//! The fill of a 32-bit float depth texture a run through the runtime binds
|
||||
//! ([`super::runtime_textures`]). The runtime takes no upload of one
|
||||
//! (`metal2vulkan_runtime::Gap::FloatDepthUpload`), so the run renders the case's depths into it,
|
||||
//! as a guest fills one: one command buffer holds a pass per level and slice, each one draw of the
|
||||
//! owned `depth_fill` pair over the whole level (`fixtures/public/engine/depth_fill.metal`), whose
|
||||
//! fragment writes the depth at each pixel from a buffer of the level's texels under an
|
||||
//! always-passing depth test that writes. A render write is clamped to the viewport's `[0, 1]`, so
|
||||
//! a depth outside it is refused, typed (`ToolingRequirement::DepthOutsideUnitRange`, which the
|
||||
//! case checker raises first): the run never clamps one silently.
|
||||
|
||||
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::gpu::DeviceType;
|
||||
use crate::requirement::ToolingRequirement;
|
||||
use metal2vulkan::library::Library;
|
||||
use metal2vulkan::metal::CompareFunction;
|
||||
use metal2vulkan::pipeline::{FunctionDescriptor, RenderPipelineDescriptor, StageSource};
|
||||
use metal2vulkan_runtime as rt;
|
||||
|
||||
/// The owned fixture's opaque text, which the run assembles (`check::loop_free::assemble`).
|
||||
const DEPTH_FILL: &str = include_str!("../../../fixtures/public/engine/depth_fill.ll");
|
||||
|
||||
/// One level and slice of a depth texture and the depths it is filled with: `width` texels a row,
|
||||
/// rows tightly packed.
|
||||
pub(super) struct Fill {
|
||||
pub(super) texture: rt::Texture,
|
||||
pub(super) level: u32,
|
||||
pub(super) slice: u32,
|
||||
pub(super) width: u32,
|
||||
pub(super) depths: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Render each of `fills` into its level and slice on `device`, as the module documentation
|
||||
/// says; `error` maps the runtime's errors as the run's.
|
||||
pub(super) fn filled(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
fills: &[Fill],
|
||||
error: &impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
) -> Result<(), ExecutorError> {
|
||||
if fills
|
||||
.iter()
|
||||
.any(|fill| holds_depth_outside_unit_range(&fill.depths))
|
||||
{
|
||||
let requirement = ToolingRequirement::DepthOutsideUnitRange;
|
||||
return Err(NotSupported::Requirements([requirement].into()).into());
|
||||
}
|
||||
let state = pipeline(device)?;
|
||||
let written = device.new_depth_stencil_state(&rt::DepthStencilDescriptor {
|
||||
depth_compare_function: CompareFunction::Always,
|
||||
depth_write_enabled: true,
|
||||
..rt::DepthStencilDescriptor::default()
|
||||
});
|
||||
let buffers = fills
|
||||
.iter()
|
||||
.map(|fill| {
|
||||
let texels = Placed::new(device, "a depth fill's texels", &fill.depths)?;
|
||||
let width = Placed::new(device, "a depth fill's width", &fill.width.to_le_bytes())?;
|
||||
Ok((texels, width))
|
||||
})
|
||||
.collect::<Result<Vec<_>, ExecutorError>>()?;
|
||||
let fail = |what: &'static str| move |e: rt::Error| error(what, e);
|
||||
runtime::submitted(
|
||||
device,
|
||||
device_type,
|
||||
"a depth fill through the runtime",
|
||||
|command_buffer| {
|
||||
for (fill, (texels, width)) in fills.iter().zip(&buffers) {
|
||||
let mut pass = rt::RenderPassDescriptor::default();
|
||||
let attachment = &mut pass.depth_attachment;
|
||||
attachment.texture = Some(fill.texture.clone());
|
||||
attachment.level = fill.level;
|
||||
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 depth fill's pass"))?;
|
||||
encoder
|
||||
.set_render_pipeline_state(&state)
|
||||
.map_err(fail("the depth fill's pipeline state"))?;
|
||||
encoder
|
||||
.set_fragment_buffer(Some(&texels.buffer), 0, 0)
|
||||
.map_err(fail("a depth fill's texels"))?;
|
||||
encoder
|
||||
.set_fragment_buffer(Some(&width.buffer), 0, 1)
|
||||
.map_err(fail("a depth fill's width"))?;
|
||||
encoder
|
||||
.set_depth_stencil_state(Some(&written))
|
||||
.map_err(fail("the depth fill's depth-stencil state"))?;
|
||||
encoder
|
||||
.draw_primitives(metal_primitive_type(Primitive::Triangle), 0, 3, 1, 0)
|
||||
.map_err(fail("a depth fill's draw"))?;
|
||||
encoder.end_encoding();
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// The depth fill's pipeline state: the fixture's pair rendering into a `Depth32Float`
|
||||
/// attachment alone, made within the run's ceilings (`runtime::made_within`).
|
||||
fn pipeline(device: &rt::Device) -> Result<rt::RenderPipelineState, ExecutorError> {
|
||||
let bitcode = crate::check::loop_free::assemble(DEPTH_FILL)
|
||||
.map_err(|e| ExecutorError::Failed(format!("the depth fill's module: {e}")))?;
|
||||
let library = Library::from_air(&bitcode).map_err(|e| product_refusal(&e))?;
|
||||
let stage = |entry: &str| {
|
||||
library
|
||||
.function(entry)
|
||||
.map(|function| {
|
||||
StageSource::Function(FunctionDescriptor::new(function).with_specialized(true))
|
||||
})
|
||||
.map_err(|e| product_refusal(&e))
|
||||
};
|
||||
let mut descriptor = RenderPipelineDescriptor::new(stage("depth_fill_vertex")?);
|
||||
descriptor.fragment = Some(stage("depth_fill_fragment")?);
|
||||
descriptor.depth_format = Some(rt::PixelFormat::Depth32Float);
|
||||
descriptor.input_primitive_topology = graphics::topology_class(Primitive::Triangle);
|
||||
runtime::made_within(|numbered| {
|
||||
device.new_render_pipeline_state(&descriptor, |samplers| numbered(samplers))
|
||||
})
|
||||
}
|
||||
@@ -80,7 +80,7 @@ fn run(
|
||||
device.new_render_pipeline_state(&descriptor, |samplers| numbered(samplers))
|
||||
})?;
|
||||
let mut indices = Indices::new();
|
||||
let stages = Stages::make(device, case, draw, &mut indices)?;
|
||||
let stages = Stages::make(device, device_type, (case, draw), &mut indices)?;
|
||||
let vertex_buffers = case
|
||||
.vertex_buffers
|
||||
.iter()
|
||||
@@ -259,8 +259,8 @@ impl Stages {
|
||||
/// holds them) and its textures and samplers, made at the run's next indices.
|
||||
fn make(
|
||||
device: &rt::Device,
|
||||
case: &RenderCase,
|
||||
draw: &RuntimeDraw<'_>,
|
||||
device_type: DeviceType,
|
||||
(case, draw): (&RenderCase, &RuntimeDraw<'_>),
|
||||
indices: &mut Indices,
|
||||
) -> Result<Stages, ExecutorError> {
|
||||
let no_usages = BTreeMap::new();
|
||||
@@ -293,7 +293,8 @@ impl Stages {
|
||||
},
|
||||
member_usages: &no_member_usages,
|
||||
};
|
||||
let bound = runtime_textures::make(device, &wanted, indices, runtime_error)?;
|
||||
let bound =
|
||||
runtime_textures::make(device, device_type, &wanted, indices, runtime_error)?;
|
||||
stages.push((stage, placed, bound));
|
||||
}
|
||||
Ok(Stages { stages })
|
||||
|
||||
@@ -7,17 +7,20 @@
|
||||
//! argument-buffer member (`RuntimeKernel::texture_usages`, `RuntimeKernel::member_usages`), at an
|
||||
//! 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). Each sampler is the oracle's descriptor of it (`engine::resources::sampler_descriptor`,
|
||||
//! 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`,
|
||||
//! `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
|
||||
//! program writes one into an argument buffer. A texture output is read back as the oracle reads
|
||||
//! it (`getBytes:`): the selected region of level 0, slice by slice.
|
||||
|
||||
use super::runtime_depth;
|
||||
use crate::candidate::engine::argument_buffers::FieldKey;
|
||||
use crate::candidate::engine::{resources, ComputeCase, RuntimeKernel};
|
||||
use crate::case::{ArgumentBufferSamplerResource, SamplerResource};
|
||||
use crate::case::{ArgumentBufferSamplerResource, SamplerResource, TextureFormat};
|
||||
use crate::check::admission::ExecutorError;
|
||||
use crate::gpu::DeviceType;
|
||||
use crate::literal::LiteralTexture;
|
||||
use metal2vulkan::metal::TextureUsage;
|
||||
use metal2vulkan_runtime as rt;
|
||||
@@ -136,12 +139,14 @@ pub(super) fn texture_indices(
|
||||
/// the runtime's errors as the run's.
|
||||
pub(super) fn make(
|
||||
device: &rt::Device,
|
||||
device_type: DeviceType,
|
||||
wanted: &Wanted<'_>,
|
||||
indices: &mut Indices,
|
||||
error: impl Fn(&str, rt::Error) -> ExecutorError,
|
||||
) -> 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 textures = BTreeMap::new();
|
||||
for ((&binding, texture), index) in wanted.textures.iter().zip(&mut at) {
|
||||
let usage = wanted
|
||||
@@ -153,7 +158,7 @@ pub(super) fn make(
|
||||
})?;
|
||||
textures.insert(
|
||||
binding,
|
||||
made_texture(device, texture, usage, index, &error)?,
|
||||
made_texture(device, texture, usage, index, &error, &mut fills)?,
|
||||
);
|
||||
}
|
||||
let mut members = BTreeMap::new();
|
||||
@@ -164,7 +169,11 @@ pub(super) fn make(
|
||||
key.0, key.1
|
||||
))
|
||||
})?;
|
||||
members.insert(key, made_texture(device, texture, usage, index, &error)?);
|
||||
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)?;
|
||||
}
|
||||
let mut samplers = BTreeMap::new();
|
||||
for (&binding, sampler) in wanted.samplers {
|
||||
@@ -190,13 +199,15 @@ pub(super) fn make(
|
||||
})
|
||||
}
|
||||
|
||||
/// `texture` made with `usage` at `index`, every level's slices written from its bytes.
|
||||
/// `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`).
|
||||
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>,
|
||||
) -> Result<rt::Texture, ExecutorError> {
|
||||
let what = format!("texture {}", texture.binding);
|
||||
let layout = texture.layout().map_err(ExecutorError::Failed)?;
|
||||
@@ -210,7 +221,12 @@ 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;
|
||||
descriptor.usage = usage;
|
||||
// A 32-bit float depth is filled by a draw, which renders into the texture (`runtime_depth`).
|
||||
let depth = texture.format == TextureFormat::Depth32Float;
|
||||
descriptor.usage = match depth {
|
||||
true => usage | rt::TextureUsage::RENDER_TARGET,
|
||||
false => usage,
|
||||
};
|
||||
descriptor.storage_mode = rt::StorageMode::Shared;
|
||||
let made = device
|
||||
.new_texture(&descriptor, Some(index))
|
||||
@@ -236,13 +252,24 @@ fn made_texture(
|
||||
.take(span.slice_count as usize)
|
||||
.enumerate()
|
||||
{
|
||||
let slice = span.base_slice + slice as u32;
|
||||
if depth {
|
||||
fills.push(runtime_depth::Fill {
|
||||
texture: made.clone(),
|
||||
level,
|
||||
slice,
|
||||
width: span.size[0],
|
||||
depths: chunk.to_vec(),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
made.replace_region(
|
||||
rt::Region {
|
||||
origin: [0, 0, 0],
|
||||
size: span.size,
|
||||
},
|
||||
level,
|
||||
span.base_slice + slice as u32,
|
||||
slice,
|
||||
chunk.into(),
|
||||
rows.row as u64,
|
||||
rows.image as u64,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The engine compute candidate with textures, texture buffers, texture arrays, and samplers,
|
||||
//! bound or in an argument buffer, and with buffers in an argument buffer, on a device: the owned
|
||||
//! `texture_ops`, `sampling`, `msf_mip_levels`, `selected_member_texture`,
|
||||
//! `argument_sampler_sample` and `ob2_loaded_pointer` kernels and the public
|
||||
//! `argument_sampler_sample`, `ob2_loaded_pointer` and `depth_fill_read` kernels and the public
|
||||
//! `texture_array_width` kernel, planned by the binder and executed on the executor's own context
|
||||
//! under `VK_LAYER_KHRONOS_validation`, against expectations derived from their MSL; the cases
|
||||
//! the runtime makes run through it too on Linux ([`runs`]). `G-linux`'s `m2v_cpu_icd` step runs
|
||||
@@ -469,74 +469,6 @@ fn depth_and_multisampled_textures_read_their_authored_texels() {
|
||||
assert_eq!(run.output, floats(&[0.375, 14.0]));
|
||||
}
|
||||
|
||||
/// A depth texture whose texel lies outside `[0, 1]` (2.0, which Metal's `Depth32Float` texel
|
||||
/// keeps): where the opened device enabled `VK_EXT_depth_range_unrestricted`, the run reads it as
|
||||
/// authored; elsewhere the executor neither copies it (Vulkan takes no such copied depth,
|
||||
/// `VUID-vkCmdCopyBufferToImage-pRegions-07931`) nor clamps it, and refuses the case typed
|
||||
/// before any image is made (`ToolingRequirement::DepthOutsideUnitRange`).
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[test]
|
||||
fn a_depth_outside_the_unit_range_runs_only_where_the_device_takes_it() {
|
||||
use crate::check::admission::{ExecutorError, NotSupported};
|
||||
use crate::requirement::ToolingRequirement;
|
||||
let samples: Vec<u8> = (0..4i32)
|
||||
.flat_map(|sample| [sample, 7 * sample, -sample, 1])
|
||||
.flat_map(i32::to_le_bytes)
|
||||
.collect();
|
||||
let mut multisampled = texture(
|
||||
1,
|
||||
TextureType::D2Multisample,
|
||||
TextureFormat::Rgba32Sint,
|
||||
[1, 1, 1],
|
||||
samples,
|
||||
);
|
||||
multisampled.sample_count = 4;
|
||||
let case = kernel(
|
||||
"depth_ms",
|
||||
vec![
|
||||
texture(
|
||||
0,
|
||||
TextureType::D2,
|
||||
TextureFormat::Depth32Float,
|
||||
[1, 1, 1],
|
||||
floats(&[2.0]),
|
||||
),
|
||||
multisampled,
|
||||
],
|
||||
vec![0xab; 8],
|
||||
[1, 1, 1],
|
||||
buffer_output(8),
|
||||
);
|
||||
let unrestricted = crate::candidate::platform::opened_worker_device(crate::gpu::TEST_DEVICE)
|
||||
.unwrap_or_else(|error| panic!("open the lane's device: {error:?}"))
|
||||
.device()
|
||||
.profile()
|
||||
.enabled()
|
||||
.extensions
|
||||
.contains(&metal2vulkan::device::VkExtension::ExtDepthRangeUnrestricted);
|
||||
let ran = run(&case, &fixture("texture_ops.ll"));
|
||||
eprintln!(
|
||||
"DEPTH-RANGE-CASE unrestricted {unrestricted}: {}",
|
||||
match &ran {
|
||||
Ok(run) => format!("ran, output {:02x?}", run.output),
|
||||
Err(error) => error.to_string(),
|
||||
}
|
||||
);
|
||||
match (ran, unrestricted) {
|
||||
(Ok(run), true) => assert_eq!(run.output, floats(&[2.0, 14.0])),
|
||||
(Err(ExecutorError::NotSupported(NotSupported::Requirements(requirements))), false) => {
|
||||
assert_eq!(
|
||||
requirements,
|
||||
[ToolingRequirement::DepthOutsideUnitRange].into()
|
||||
)
|
||||
}
|
||||
(other, unrestricted) => panic!(
|
||||
"a depth of 2.0 runs where the device enabled the extension ({unrestricted}) and is \
|
||||
refused as depth_outside_unit_range elsewhere: {other:?}"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// A sample count the device's image format properties do not allow is refused typed before any
|
||||
/// image is created, never created as invalid usage (`VUID-VkImageCreateInfo-samples-02258`):
|
||||
/// the CPU ICDs the gate runs allow no 2-sample images (lavapipe allows 1, 4, and 8).
|
||||
@@ -811,3 +743,66 @@ fn an_argument_buffer_buffer_is_the_buffer_at_its_field() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A 32-bit float depth texture, which the runtime takes no upload of (`Gap::FloatDepthUpload`):
|
||||
/// through the runtime the run fills it by a draw of the owned `depth_fill` pair, and on both runs
|
||||
/// `depth_fill_read` reads every depth back as authored, row 1 below row 0. A depth outside
|
||||
/// `[0, 1]`, which a draw would clamp, is refused through the runtime as the requirement the case
|
||||
/// checker raises from the case's literals (`ToolingRequirement::DepthOutsideUnitRange`).
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[test]
|
||||
fn a_float_depth_texture_is_filled_by_a_draw_and_reads_back_as_authored() {
|
||||
let depths = [
|
||||
0.0f32,
|
||||
0.25,
|
||||
0.5,
|
||||
1.0,
|
||||
0.123_456_79,
|
||||
0.75,
|
||||
1.0e-3,
|
||||
0.999_999_9,
|
||||
];
|
||||
let case = |values: &[f32]| {
|
||||
let depth = LiteralTexture {
|
||||
role: ResourceRole::Input,
|
||||
..texture(
|
||||
0,
|
||||
TextureType::D2,
|
||||
TextureFormat::Depth32Float,
|
||||
[4, 2, 1],
|
||||
floats(values),
|
||||
)
|
||||
};
|
||||
kernel(
|
||||
"depth_fill_read",
|
||||
vec![depth],
|
||||
vec![0xab; 32],
|
||||
[8, 1, 1],
|
||||
buffer_output(32),
|
||||
)
|
||||
};
|
||||
let bitcode = fixture("depth_fill.ll");
|
||||
for (name, run) in runs() {
|
||||
let ran = run(&case(&depths), &bitcode).unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(ran.output, floats(&depths), "{name}");
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
use crate::check::admission::NotSupported;
|
||||
use crate::requirement::ToolingRequirement;
|
||||
let mut outside = depths;
|
||||
outside[5] = 2.0;
|
||||
match super::engine_compute::run_through_runtime(&case(&outside), &bitcode) {
|
||||
Err(ExecutorError::NotSupported(NotSupported::Requirements(requirements))) => {
|
||||
assert_eq!(
|
||||
requirements,
|
||||
[ToolingRequirement::DepthOutsideUnitRange].into()
|
||||
)
|
||||
}
|
||||
other => panic!(
|
||||
"a depth of 2.0 through the runtime is refused as depth_outside_unit_range: \
|
||||
{other:?}"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -777,7 +777,9 @@ pub fn engine_source_requirements(reflection: &ShaderInterface) -> BTreeSet<Tool
|
||||
/// engine's candidate refuses before it maps a case. The source's families are
|
||||
/// [`engine_source_requirements`]'s and an object function's threadgroup memory
|
||||
/// ([`mesh::mesh_requirements`]); each of them a case authors is also named here, so a case that
|
||||
/// was checked against an older reflection is refused all the same.
|
||||
/// was checked against an older reflection is refused all the same. A depth outside `[0, 1]` the
|
||||
/// case gives a depth image is the runtime's limit on every device
|
||||
/// ([`depth_range::depth_range_requirement`]).
|
||||
pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|
||||
let render = matches!(case.stage, Stage::Vertex | Stage::Fragment);
|
||||
let drawn = render || case.stage.is_mesh_pipeline_stage();
|
||||
@@ -825,6 +827,7 @@ pub fn case_requirements(case: &AuthoredCase) -> BTreeSet<ToolingRequirement> {
|
||||
]
|
||||
.into_iter()
|
||||
.filter_map(|(present, requirement)| present.then_some(requirement))
|
||||
.chain(depth_range::depth_range_requirement(case))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
//! The 32-bit float depths a case gives a depth image, and whether the engine's candidate can put
|
||||
//! them there as Metal holds them: Metal's `Depth32Float` texel holds any `float`, and Vulkan takes
|
||||
//! no depth outside `[0, 1]` into a depth image without `VK_EXT_depth_range_unrestricted`
|
||||
//! (`VUID-vkCmdCopyBufferToImage-pRegions-07931` for a copy; a render write is clamped to the
|
||||
//! viewport's depth range). On a device without the extension, a case whose depth texels or
|
||||
//! initial depth hold such a value stops the candidate
|
||||
//! ([`ToolingRequirement::DepthOutsideUnitRange`]): its executor neither copies the value as it is
|
||||
//! (an invalid copy) nor clamps it silently (an answer that is not the case's). The Metal oracle
|
||||
//! runs every such case, and a device with the extension takes every value.
|
||||
//! them there as Metal holds them: Metal's `Depth32Float` texel holds any `float`, and the runtime
|
||||
//! takes no upload of a 32-bit float depth (`metal2vulkan_runtime::Gap::FloatDepthUpload`), so
|
||||
//! the candidate fills one by a draw, which writes depths clamped to the viewport's `[0, 1]`. A
|
||||
//! case whose depth texels or initial depth hold a value outside it stops the candidate on every
|
||||
//! device ([`ToolingRequirement::DepthOutsideUnitRange`], the runtime's limit): it neither uploads
|
||||
//! the value nor clamps it silently (an answer that is not the case's). The Metal oracle runs every
|
||||
//! such case.
|
||||
|
||||
use crate::case::{AuthoredCase, TextureFormat};
|
||||
use crate::requirement::ToolingRequirement;
|
||||
use base64::Engine as _;
|
||||
|
||||
/// Whether the 32-bit float depth `bits` lies in `[0, 1]`: `-0.0` and the positive denormals do,
|
||||
/// a NaN of either sign, a negative value (a negative denormal included) and a value above 1.0
|
||||
@@ -29,14 +30,39 @@ pub fn holds_depth_outside_unit_range(depths: &[u8]) -> bool {
|
||||
.any(|word| !in_unit_range(u32::from_le_bytes(*word)))
|
||||
}
|
||||
|
||||
/// The requirement that stops the engine's candidate from giving a depth image `depths` on a
|
||||
/// device that enabled `VK_EXT_depth_range_unrestricted` (`unrestricted`) or not: none where it
|
||||
/// did, or where every depth lies in `[0, 1]`.
|
||||
pub fn depth_range_requirement(depths: &[u8], unrestricted: bool) -> Option<ToolingRequirement> {
|
||||
(!unrestricted && holds_depth_outside_unit_range(depths))
|
||||
/// The requirement `case` raises by the depths it gives depth images, on every device: each
|
||||
/// `Depth32Float` texture's texels (a texture-array element's and an argument buffer's texture's
|
||||
/// among them) and its depth attachment's initial depth. None where every depth lies in `[0, 1]`.
|
||||
pub fn depth_range_requirement(case: &AuthoredCase) -> Option<ToolingRequirement> {
|
||||
let depth = TextureFormat::Depth32Float;
|
||||
let textures = (case.textures.iter())
|
||||
.filter(|texture| texture.format == depth)
|
||||
.map(|texture| decoded(&texture.bytes_b64, &texture.initial_bytes_b64));
|
||||
let elements = (case.texture_arrays.iter())
|
||||
.filter(|array| array.format == depth)
|
||||
.flat_map(|array| &array.elements)
|
||||
.map(|element| decoded(&element.bytes_b64, &element.initial_bytes_b64));
|
||||
let members = (case.argument_buffer_textures.iter())
|
||||
.filter(|texture| texture.format == depth)
|
||||
.map(|texture| decoded(&texture.bytes_b64, &texture.initial_bytes_b64));
|
||||
let attachment =
|
||||
(case.depth_stencil.iter()).map(|attachment| decoded(&attachment.initial_depth_b64, &None));
|
||||
textures
|
||||
.chain(elements)
|
||||
.chain(members)
|
||||
.chain(attachment)
|
||||
.any(|depths| holds_depth_outside_unit_range(&depths))
|
||||
.then_some(ToolingRequirement::DepthOutsideUnitRange)
|
||||
}
|
||||
|
||||
/// The bytes a literal states (`bytes`, else `initial`), none where neither decodes: the case's
|
||||
/// own check refuses those.
|
||||
fn decoded(bytes: &Option<String>, initial: &Option<String>) -> Vec<u8> {
|
||||
(bytes.as_ref().or(initial.as_ref()))
|
||||
.and_then(|b64| base64::engine::general_purpose::STANDARD.decode(b64).ok())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -79,46 +105,105 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A case whose depths all lie in `[0, 1]` runs on every device; one with a single depth
|
||||
/// outside it stops the candidate where the device lacks the extension, and only there. A
|
||||
/// trailing partial word is no depth.
|
||||
/// A case whose depths all lie in `[0, 1]` raises nothing; one depth outside it, in a
|
||||
/// `Depth32Float` texture, a texture-array element, an argument buffer's texture or the depth
|
||||
/// attachment's initial depth, raises the requirement. A texture of another format holds no
|
||||
/// depth, and a trailing partial word is none.
|
||||
#[test]
|
||||
fn a_depth_outside_the_unit_range_stops_the_candidate_only_without_the_extension() {
|
||||
fn a_depth_outside_the_unit_range_anywhere_a_case_gives_one_raises_the_requirement() {
|
||||
use crate::case::{
|
||||
ArgumentBufferTextureResource, DepthStencilResource, ResourceRole, TextureArrayElement,
|
||||
TextureArrayResource, TextureResource, TextureType,
|
||||
};
|
||||
let b64 = |bytes: &[u8]| base64::engine::general_purpose::STANDARD.encode(bytes);
|
||||
let inside = words(&[0, 0x8000_0000, 0x3f80_0000, 0x0000_0001]);
|
||||
assert_eq!(depth_range_requirement(&inside, false), None);
|
||||
assert_eq!(depth_range_requirement(&inside, true), None);
|
||||
let outside = words(&[0x3f00_0000, 0x4000_0000, 0, 0]);
|
||||
let mut partial = inside.clone();
|
||||
partial.extend([0xff, 0xff, 0xff]);
|
||||
assert_eq!(depth_range_requirement(&partial, false), None);
|
||||
for outside in [0x7fc0_0000, 0xbf00_0000, 0x4000_0000, 0x8000_0001] {
|
||||
let depths = words(&[0x3f00_0000, outside, 0]);
|
||||
let texture = |format, bytes: &[u8]| TextureResource {
|
||||
binding: 0,
|
||||
role: ResourceRole::Input,
|
||||
texture_type: TextureType::D2,
|
||||
format,
|
||||
dimensions: [2, 2, 1],
|
||||
sample_count: 1,
|
||||
bytes_b64: Some(b64(bytes)),
|
||||
initial_bytes_b64: None,
|
||||
sparse: None,
|
||||
mip_levels: 1,
|
||||
};
|
||||
let case = |textures| AuthoredCase {
|
||||
textures,
|
||||
..crate::case::vector_function_constant_test_case("11".repeat(32), "main".into())
|
||||
};
|
||||
let depth = TextureFormat::Depth32Float;
|
||||
for clean in [
|
||||
case(vec![texture(depth, &inside)]),
|
||||
case(vec![texture(depth, &partial)]),
|
||||
case(vec![texture(TextureFormat::R32Float, &outside)]),
|
||||
] {
|
||||
assert_eq!(
|
||||
depth_range_requirement(&depths, false),
|
||||
Some(ToolingRequirement::DepthOutsideUnitRange),
|
||||
"{outside:#010x}"
|
||||
);
|
||||
assert_eq!(
|
||||
depth_range_requirement(&depths, true),
|
||||
depth_range_requirement(&clean),
|
||||
None,
|
||||
"{outside:#010x}"
|
||||
"{:?}",
|
||||
clean.textures
|
||||
);
|
||||
}
|
||||
let required = Some(ToolingRequirement::DepthOutsideUnitRange);
|
||||
assert_eq!(
|
||||
depth_range_requirement(&case(vec![texture(depth, &outside)])),
|
||||
required
|
||||
);
|
||||
let mut array = case(Vec::new());
|
||||
array.texture_arrays = vec![TextureArrayResource {
|
||||
binding: 0,
|
||||
role: ResourceRole::Input,
|
||||
texture_type: TextureType::D2,
|
||||
format: depth,
|
||||
sample_count: 1,
|
||||
overrides_texture_at_base: false,
|
||||
elements: vec![TextureArrayElement {
|
||||
dimensions: [2, 2, 1],
|
||||
bytes_b64: None,
|
||||
initial_bytes_b64: Some(b64(&outside)),
|
||||
}],
|
||||
}];
|
||||
assert_eq!(depth_range_requirement(&array), required);
|
||||
let mut member = case(Vec::new());
|
||||
member.argument_buffer_textures = vec![ArgumentBufferTextureResource {
|
||||
buffer_binding: 0,
|
||||
field_offset: 0,
|
||||
role: ResourceRole::Input,
|
||||
texture_type: TextureType::D2,
|
||||
format: depth,
|
||||
dimensions: [2, 2, 1],
|
||||
sample_count: 1,
|
||||
bytes_b64: Some(b64(&outside)),
|
||||
initial_bytes_b64: None,
|
||||
}];
|
||||
assert_eq!(depth_range_requirement(&member), required);
|
||||
let mut attachment = case(Vec::new());
|
||||
attachment.depth_stencil = Some(DepthStencilResource {
|
||||
dimensions: [2, 2],
|
||||
initial_depth_b64: Some(b64(&outside)),
|
||||
initial_stencil_b64: None,
|
||||
state: None,
|
||||
});
|
||||
assert_eq!(depth_range_requirement(&attachment), required);
|
||||
}
|
||||
|
||||
/// The requirement stops the engine's candidate alone: the Metal oracle holds every `float`
|
||||
/// in a `Depth32Float` texel, so it qualifies the case, and the candidate's run on a device
|
||||
/// with the extension is compared with it. It is a gap of this crate's executor, never Metal's.
|
||||
/// in a `Depth32Float` texel, so it qualifies the case, and the runtime puts no such depth in
|
||||
/// an image, the runtime's limit, which closes its rows.
|
||||
#[test]
|
||||
fn a_depth_outside_the_unit_range_stops_the_candidate_and_never_the_oracle() {
|
||||
let requirement = ToolingRequirement::DepthOutsideUnitRange;
|
||||
assert_eq!(requirement.stops(), [Executor::EngineCandidate]);
|
||||
assert!(!requirement.stops_executor(Executor::MetalOracle));
|
||||
assert_eq!(requirement.limit(), Limit::Tooling);
|
||||
assert_eq!(requirement.limit(), Limit::Runtime);
|
||||
assert!(requirement.qualifies_on_metal());
|
||||
assert!(!requirement.blocks_closure());
|
||||
assert_eq!(requirement.as_str(), "depth_outside_unit_range");
|
||||
let gap = super::super::evidence_gap(&[requirement].into()).unwrap();
|
||||
assert!(
|
||||
gap.contains("engine_candidate: depth_outside_unit_range"),
|
||||
"{gap}"
|
||||
);
|
||||
assert_eq!(super::super::evidence_gap(&[requirement].into()), None);
|
||||
}
|
||||
}
|
||||
@@ -138,13 +138,18 @@ pub enum ToolingRequirement {
|
||||
/// (`companion::MeshStages`).
|
||||
MeshCompanion,
|
||||
/// A case gives a 32-bit float depth image a depth outside `[0, 1]`
|
||||
/// (`executor_contract::depth_range`): a `Depth32Float` texture's texels or a depth
|
||||
/// attachment's initial depth holds a NaN, a negative value other than `-0.0`, or a value
|
||||
/// above 1.0, which Metal's texel keeps. Vulkan takes no such value into a depth image without
|
||||
/// `VK_EXT_depth_range_unrestricted` (`VUID-vkCmdCopyBufferToImage-pRegions-07931`), so on a
|
||||
/// device without the extension the engine's candidate cannot put the case's depths where
|
||||
/// Metal holds them and stops there; on a device with it, it runs. A case's data on the
|
||||
/// executing device raises it, never a source's structure, so no census row carries it.
|
||||
/// (`executor_contract::depth_range`): a `Depth32Float` texture's texels (a texture-array
|
||||
/// element's or an argument buffer's texture's among them) or a depth attachment's initial
|
||||
/// depth holds a NaN, a negative value other than `-0.0`, or a value above 1.0, which Metal's
|
||||
/// texel keeps. The runtime takes no upload of a 32-bit float depth on any device
|
||||
/// (`metal2vulkan_runtime::Gap::FloatDepthUpload`, which its own texture and blit tests hold
|
||||
/// both ways), and a draw, the one way a guest fills such a texture through it, writes depths
|
||||
/// clamped to the viewport's `[0, 1]`: no call of the runtime puts such a value where Metal
|
||||
/// holds it, so the limit is the runtime's ([`Limit::Runtime`]) and the engine's candidate
|
||||
/// does not run the case. The case checker raises it from the case's literals on every device
|
||||
/// (`executor_contract::case_requirements`), never a source's structure, so no census row
|
||||
/// carries it. The Metal oracle runs it, so a case of it stays Metal-qualified
|
||||
/// ([`Self::qualifies_on_metal`]).
|
||||
DepthOutsideUnitRange,
|
||||
/// An object or mesh function's row or case (`executor_contract::mesh`), or a case that runs a
|
||||
/// pipeline template of one: the engine's candidate draws no mesh render pipeline. The runtime
|
||||
@@ -257,8 +262,7 @@ impl ToolingRequirement {
|
||||
/// implement yet (`candidate::engine`), each of which the Metal oracle runs, and
|
||||
/// rasterization-rate map data a case can author only as bytes, which hold one
|
||||
/// implementation's private layout where the engine's module decodes this crate's, and a
|
||||
/// depth outside `[0, 1]` a case gives a depth image, which its executor raises only on a
|
||||
/// device without `VK_EXT_depth_range_unrestricted`
|
||||
/// depth outside `[0, 1]` a case gives a depth image, which the runtime puts nowhere
|
||||
/// ([`ToolingRequirement::DepthOutsideUnitRange`]), and a mesh render pipeline or a replayed
|
||||
/// template it does not draw or replay ([`ToolingRequirement::MeshRenderPipeline`],
|
||||
/// [`ToolingRequirement::ReplayedTemplateResources`]), and a texture buffer an argument
|
||||
@@ -302,25 +306,30 @@ impl ToolingRequirement {
|
||||
/// and its observation is evidence for a candidate that runs the family again, so the checker
|
||||
/// accepts it with no candidate (`executor_contract::evidence_gap`), and the engine's candidate
|
||||
/// refuses it, typed. Only [`ToolingRequirement::MeshRenderPipeline`],
|
||||
/// [`ToolingRequirement::TextureBufferMember`] and [`ToolingRequirement::SeqCstFence`]: their
|
||||
/// cases are qualified on Metal.
|
||||
/// [`ToolingRequirement::TextureBufferMember`], [`ToolingRequirement::DepthOutsideUnitRange`]
|
||||
/// and [`ToolingRequirement::SeqCstFence`]: their cases are qualified on Metal.
|
||||
pub const fn qualifies_on_metal(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::MeshRenderPipeline | Self::TextureBufferMember | Self::SeqCstFence
|
||||
Self::MeshRenderPipeline
|
||||
| Self::TextureBufferMember
|
||||
| Self::DepthOutsideUnitRange
|
||||
| Self::SeqCstFence
|
||||
)
|
||||
}
|
||||
|
||||
/// Whose limit this requirement records. Every requirement is this crate's tooling's except
|
||||
/// [`ToolingRequirement::KernelMinLodClamp`], which Apple's compiler cannot build a pipeline
|
||||
/// for, and [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::TextureBufferMember`]
|
||||
/// and [`ToolingRequirement::MeshRenderPipeline`], which the runtime refuses.
|
||||
/// for, and [`ToolingRequirement::SeqCstFence`], [`ToolingRequirement::TextureBufferMember`],
|
||||
/// [`ToolingRequirement::DepthOutsideUnitRange`] and
|
||||
/// [`ToolingRequirement::MeshRenderPipeline`], which the runtime refuses.
|
||||
pub const fn limit(self) -> Limit {
|
||||
match self {
|
||||
Self::KernelMinLodClamp => Limit::Metal,
|
||||
Self::SeqCstFence | Self::TextureBufferMember | Self::MeshRenderPipeline => {
|
||||
Limit::Runtime
|
||||
}
|
||||
Self::SeqCstFence
|
||||
| Self::TextureBufferMember
|
||||
| Self::DepthOutsideUnitRange
|
||||
| Self::MeshRenderPipeline => Limit::Runtime,
|
||||
_ => Limit::Tooling,
|
||||
}
|
||||
}
|
||||
@@ -470,6 +479,7 @@ mod tests {
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
ToolingRequirement::TextureBufferMember,
|
||||
ToolingRequirement::DepthOutsideUnitRange,
|
||||
ToolingRequirement::MeshRenderPipeline,
|
||||
ToolingRequirement::SeqCstFence
|
||||
]
|
||||
@@ -549,6 +559,7 @@ mod tests {
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
ToolingRequirement::TextureBufferMember,
|
||||
ToolingRequirement::DepthOutsideUnitRange,
|
||||
ToolingRequirement::MeshRenderPipeline,
|
||||
ToolingRequirement::SeqCstFence
|
||||
]
|
||||
|
||||
@@ -1952,9 +1952,8 @@ entry:
|
||||
),
|
||||
(
|
||||
"src/executor_contract/depth_range.rs",
|
||||
"the executors' depth-range rule over a case's depth bytes and the device's \
|
||||
VK_EXT_depth_range_unrestricted; classification reads no depth and opens no \
|
||||
device",
|
||||
"the case checker's depth-range rule over a case's depth bytes; classification \
|
||||
reads no depth",
|
||||
),
|
||||
(
|
||||
"src/executor_contract/render_target_array.rs",
|
||||
|
||||
+5
-2
@@ -464,8 +464,11 @@ cargo run -p metal2vulkan-validation --release --bin corpus-moltenvk -- \
|
||||
as the Metal oracle makes it, Shared and written with `replace_region`, at an index the run
|
||||
grants. An argument buffer holds each member's `gpuAddress` or `gpuResourceID` at its field, as
|
||||
a program writes them, and each member buffer and texture is used for reading and writing
|
||||
(`use_resource`). A multisampled, sparse, texture-buffer or cube-array texture, or a 32-bit
|
||||
float depth (which the runtime takes no upload of), keeps the case on the executor's own
|
||||
(`use_resource`). A 32-bit float depth texture, which the runtime takes no upload of, is filled
|
||||
by a draw of the owned `depth_fill` pair, one pass per level and slice, as a guest fills one; a
|
||||
case that gives a depth image a depth outside `[0, 1]`, which a draw clamps, carries
|
||||
`depth_outside_unit_range`, the runtime's limit on every device, and runs on Metal alone. A
|
||||
multisampled, 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
|
||||
|
||||
Reference in new issue
Block a user