upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorTomgamer <tomanhorak22@gmail.com>2026-11-22 16:32:05 +0100
committerTomgamer <tomanhorak22@gmail.com>2026-11-22 16:32:05 +0100
commiteb35aed2e7e8ea1d4a11fd4e42ab80d853f05169 (patch)
tree22bd0e6fa6363235d1feedc1c9be678ab63bee4b /runtime
parent759a90c42e58886153f67dcd2d5d41c44face012 (diff)
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
Merge origin/main into shader-309-wave64-lds-limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/CMakeLists.txt120
-rw-r--r--runtime/README.md8
-rw-r--r--runtime/shims/d3d12_com.cpp63
-rw-r--r--runtime/shims/d3d12_com.h6
-rw-r--r--runtime/shims/d3d12_vulkan_device.cpp451
-rw-r--r--runtime/shims/d3d12_xs_device.cpp188
-rw-r--r--runtime/shims/d3d12_xs_device.h32
-rw-r--r--runtime/shims/dxgi_com.cpp71
-rw-r--r--runtime/shims/file_system.cpp4
-rw-r--r--runtime/shims/process.cpp40
-rw-r--r--runtime/shims/xgameruntime.cpp261
-rw-r--r--runtime/src/base_reservation.h151
-rw-r--r--runtime/src/command_list.h36
-rw-r--r--runtime/src/descriptor_table.h24
-rw-r--r--runtime/src/main.cpp5
-rw-r--r--runtime/src/pe_loader.cpp8
-rw-r--r--runtime/src/vulkan13_features.h127
-rw-r--r--runtime/src/vulkan_backend.h78
-rw-r--r--runtime/src/vulkan_bindless.h80
-rw-r--r--runtime/src/vulkan_present.h34
-rw-r--r--runtime/src/vulkan_replay.h231
-rw-r--r--runtime/src/xdxr_build.comp87
-rw-r--r--runtime/src/xdxr_build.h94
-rw-r--r--runtime/src/xdxr_build.inc7493
-rw-r--r--runtime/test/allocator_proxy_test.cpp382
-rw-r--r--runtime/test/bindless_sizing_test.cpp31
-rw-r--r--runtime/test/bink_audio_test.cpp2
-rw-r--r--runtime/test/check_d3d12_trace.py2
-rw-r--r--runtime/test/check_texture_readback_sync.cmake3
-rw-r--r--runtime/test/check_vk_pipeline_cli.cmake34
-rw-r--r--runtime/test/d3d12_buffer_uav_test.cpp699
-rw-r--r--runtime/test/d3d12_compute_test.cpp183
-rw-r--r--runtime/test/d3d12_copy_compare.h25
-rw-r--r--runtime/test/d3d12_descriptor_test.cpp77
-rw-r--r--runtime/test/d3d12_draw_test.cpp3
-rw-r--r--runtime/test/d3d12_gcl8_test.cpp4
-rw-r--r--runtime/test/d3d12_m2_textured_test.cpp24
-rw-r--r--runtime/test/d3d12_m4_compute_test.cpp395
-rw-r--r--runtime/test/d3d12_pipeline_library_test.cpp316
-rw-r--r--runtime/test/d3d12_present_test.cpp13
-rw-r--r--runtime/test/d3d12_translated_draw_test.cpp26
-rw-r--r--runtime/test/d3d12_typeless_rtv_test.cpp249
-rw-r--r--runtime/test/d3d12_vulkan_device_test.cpp673
-rw-r--r--runtime/test/d3d12_xdxr_rt_test.cpp157
-rw-r--r--runtime/test/descriptor_table_test.cpp51
-rw-r--r--runtime/test/device_proxy_test.cpp41
-rw-r--r--runtime/test/dxgi_swapchain_test.cpp227
-rw-r--r--runtime/test/file_system_test.cpp11
-rw-r--r--runtime/test/fixtures/tiny_gdk_load.cpp21
-rw-r--r--runtime/test/fsr_dispatch_test.cpp4
-rw-r--r--runtime/test/glsl/cs_user_data.comp14
-rw-r--r--runtime/test/process_cmdline_test.cpp70
-rw-r--r--runtime/test/shader_library_corpus_test.cpp159
-rw-r--r--runtime/test/shaders/build.py45
-rw-r--r--runtime/test/shaders/check.py84
-rw-r--r--runtime/test/shaders/cs_buf_counter.asm40
-rw-r--r--runtime/test/shaders/cs_buf_typed.asm63
-rw-r--r--runtime/test/shaders/cs_lds_b64_cmpst.asm132
-rw-r--r--runtime/test/shaders/cs_m4_fill.asm51
-rw-r--r--runtime/test/shaders/cs_m4_indirect.asm28
-rw-r--r--runtime/test/shaders/cs_tbuffer_store.asm275
-rw-r--r--runtime/test/shaders/ps_imgatomic.asm44
-rw-r--r--runtime/test/shaders/ps_m2_uoff.asm5
-rw-r--r--runtime/test/shaders/ps_mandelbrot.asm46
-rw-r--r--runtime/test/shaders/ps_scc_logic32.asm44
-rw-r--r--runtime/test/shaders/ps_scc_logic64.asm49
-rw-r--r--runtime/test/shaders/vs_w64_a_skip.asm45
-rw-r--r--runtime/test/shaders/vs_w64_b_ballot_atomic.asm42
-rw-r--r--runtime/test/shaders/vs_w64_b_readlane_uniform.asm33
-rw-r--r--runtime/test/shaders/vs_w64_b_waterfall.asm35
-rw-r--r--runtime/test/shaders/vs_w64_c_bcnt_export.asm23
-rw-r--r--runtime/test/shaders/vs_w64_c_lane_id.asm21
-rw-r--r--runtime/test/shaders/vs_w64_c_readlane.asm23
-rw-r--r--runtime/test/shaders/w64_graphics.py98
-rw-r--r--runtime/test/typeless_rtv_test.cpp24
-rw-r--r--runtime/test/vk_bc_zero_init_test.cpp388
-rw-r--r--runtime/test/vk_bindless_test.cpp181
-rw-r--r--runtime/test/vk_descriptor_bench.cpp42
-rw-r--r--runtime/test/vk_harness.cpp23
-rw-r--r--runtime/test/vk_overlapping_occlusion_test.cpp74
-rw-r--r--runtime/test/vk_pipeline_check.cpp335
-rw-r--r--runtime/test/vk_presenter_sync_test.cpp62
-rw-r--r--runtime/test/vk_test_device.h84
-rw-r--r--runtime/test/vk_xdxr_build_test.cpp183
-rw-r--r--runtime/test/xgameruntime_test.cpp158
-rw-r--r--runtime/test/xs_proxy_mock_test.cpp93
86 files changed, 12552 insertions, 3909 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 6f135558a..01e188e47 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -394,10 +394,20 @@ if(BUILD_TESTING)
394 set_target_properties(tiny_game PROPERTIES 394 set_target_properties(tiny_game PROPERTIES
395 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/fixtures/game/$<CONFIG>" 395 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/fixtures/game/$<CONFIG>"
396 ) 396 )
397 # The same game with no .reloc, at the default EXE base, as RT-22 asks about the real one: it can only run at
398 # 0x140000000, which arm64 Wine on macOS uses for itself (src/base_reservation.h).
399 add_executable(tiny_game_fixed test/fixtures/tiny_game.cpp)
400 target_link_libraries(tiny_game_fixed PRIVATE xgameruntime_stub)
401 target_compile_definitions(tiny_game_fixed PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)
402 target_compile_options(tiny_game_fixed PRIVATE /W4 /permissive- /utf-8 /EHsc)
403 target_link_options(tiny_game_fixed PRIVATE /FIXED /DYNAMICBASE:NO /BASE:0x140000000)
404 set_target_properties(tiny_game_fixed PROPERTIES
405 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/fixtures/game/$<CONFIG>"
406 )
397 add_executable(tiny_game_exit_code_test test/tiny_game_exit_code_test.cpp) 407 add_executable(tiny_game_exit_code_test test/tiny_game_exit_code_test.cpp)
398 target_compile_definitions(tiny_game_exit_code_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) 408 target_compile_definitions(tiny_game_exit_code_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
399 target_compile_options(tiny_game_exit_code_test PRIVATE /W4 /permissive- /utf-8) 409 target_compile_options(tiny_game_exit_code_test PRIVATE /W4 /permissive- /utf-8)
400 add_dependencies(tiny_game_exit_code_test gta6rt tiny_game) 410 add_dependencies(tiny_game_exit_code_test gta6rt tiny_game tiny_game_fixed)
401 add_test(NAME pe_loader COMMAND pe_loader_test "$<TARGET_FILE:tiny_dll>" "$<TARGET_FILE:tiny_exe>") 411 add_test(NAME pe_loader COMMAND pe_loader_test "$<TARGET_FILE:tiny_dll>" "$<TARGET_FILE:tiny_exe>")
402 412
403 # Synthetic, hand-built images through Loader::load: range checks, wrapping RVAs, import-table termination and 413 # Synthetic, hand-built images through Loader::load: range checks, wrapping RVAs, import-table termination and
@@ -499,6 +509,11 @@ if(BUILD_TESTING)
499 add_test(NAME descriptor_table COMMAND descriptor_table_test) 509 add_test(NAME descriptor_table COMMAND descriptor_table_test)
500 add_executable(shader_library_test test/shader_library_test.cpp) 510 add_executable(shader_library_test test/shader_library_test.cpp)
501 add_test(NAME shader_library COMMAND shader_library_test) 511 add_test(NAME shader_library COMMAND shader_library_test)
512 # Optional: skips unless LEONIDA_SHADERS names a translated work folder (<work>/shaders/spirv).
513 add_executable(shader_library_corpus_test test/shader_library_corpus_test.cpp)
514 add_test(NAME shader_library_corpus COMMAND shader_library_corpus_test)
515 # Reads all 26,503 containers and modules: about 9 minutes from a hard disk.
516 set_tests_properties(shader_library_corpus PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 3600)
502 if(WIN32) 517 if(WIN32)
503 # Optional: skips unless LEONIDA_GAME_DIR and LEONIDA_MOVIE are set. 518 # Optional: skips unless LEONIDA_GAME_DIR and LEONIDA_MOVIE are set.
504 add_executable(bink_decode_test 519 add_executable(bink_decode_test
@@ -595,6 +610,11 @@ if(BUILD_TESTING)
595 add_test(NAME run_tiny_game COMMAND gta6rt --run $<TARGET_FILE:tiny_game> -- hello 42) 610 add_test(NAME run_tiny_game COMMAND gta6rt --run $<TARGET_FILE:tiny_game> -- hello 42)
596 add_test(NAME run_tiny_game_exit_code COMMAND tiny_game_exit_code_test 611 add_test(NAME run_tiny_game_exit_code COMMAND tiny_game_exit_code_test
597 "$<TARGET_FILE:gta6rt>" "$<TARGET_FILE:tiny_game>") 612 "$<TARGET_FILE:gta6rt>" "$<TARGET_FILE:tiny_game>")
613 # Without relocations it can only run at 0x140000000 (base_reservation.h), so passing means it got there; the
614 # game's exact exit code comes back through the relaunch.
615 add_test(NAME run_tiny_game_fixed COMMAND gta6rt --run $<TARGET_FILE:tiny_game_fixed> -- hello 42)
616 add_test(NAME run_tiny_game_fixed_exit_code COMMAND tiny_game_exit_code_test
617 "$<TARGET_FILE:gta6rt>" "$<TARGET_FILE:tiny_game_fixed>")
598 # Two modes at once are refused before anything is mapped (#886). The stand-in game's own arguments are passed, 618 # Two modes at once are refused before anything is mapped (#886). The stand-in game's own arguments are passed,
599 # so a gta6rt that ignored the conflict would run it, print "running" and exit 0. 619 # so a gta6rt that ignored the conflict would run it, print "running" and exit 0.
600 foreach(modes "dry-run;run" "dry-run;init" "init;run") 620 foreach(modes "dry-run;run" "dry-run;init" "init;run")
@@ -677,6 +697,11 @@ if(TARGET Vulkan::Headers)
677 endif() 697 endif()
678 endforeach() 698 endforeach()
679 if(BUILD_TESTING) 699 if(BUILD_TESTING)
700 add_test(NAME vk_pipeline_check_cli COMMAND "${CMAKE_COMMAND}"
701 "-DTOOL=$<TARGET_FILE:vk_pipeline_check>"
702 "-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/vk_pipeline_check_cli_input"
703 "-DRUNNER=${CMAKE_CROSSCOMPILING_EMULATOR}"
704 -P "${CMAKE_CURRENT_SOURCE_DIR}/test/check_vk_pipeline_cli.cmake")
680 add_test(NAME depth24_convert COMMAND depth24_convert_test) 705 add_test(NAME depth24_convert COMMAND depth24_convert_test)
681 set_tests_properties(depth24_convert PROPERTIES SKIP_RETURN_CODE 77) 706 set_tests_properties(depth24_convert PROPERTIES SKIP_RETURN_CODE 77)
682 # The XDXR BVH builder: the GPU writes every case, then tools/xdxr_bvh.py validates and traces them. 707 # The XDXR BVH builder: the GPU writes every case, then tools/xdxr_bvh.py validates and traces them.
@@ -753,6 +778,19 @@ if(TARGET Vulkan::Headers)
753 if(BUILD_TESTING) 778 if(BUILD_TESTING)
754 add_test(NAME vk_device_pick COMMAND vk_device_pick_test) 779 add_test(NAME vk_device_pick COMMAND vk_device_pick_test)
755 endif() 780 endif()
781 # Committed BC* texture zero-initialization via vk.zero_buffer or vk.copy_scratch (D3D-220).
782 add_executable(vk_bc_zero_init_test test/vk_bc_zero_init_test.cpp)
783 target_link_libraries(vk_bc_zero_init_test PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS})
784 if(WIN32)
785 target_compile_definitions(vk_bc_zero_init_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
786 endif()
787 if(MSVC)
788 target_compile_options(vk_bc_zero_init_test PRIVATE /W4 /permissive- /utf-8)
789 endif()
790 if(BUILD_TESTING)
791 add_test(NAME vk_bc_zero_init COMMAND vk_bc_zero_init_test)
792 set_tests_properties(vk_bc_zero_init PROPERTIES SKIP_RETURN_CODE 77)
793 endif()
756 # CPU-only: the bindless set's array sizes from synthetic device limits. 794 # CPU-only: the bindless set's array sizes from synthetic device limits.
757 add_executable(bindless_sizing_test test/bindless_sizing_test.cpp) 795 add_executable(bindless_sizing_test test/bindless_sizing_test.cpp)
758 target_link_libraries(bindless_sizing_test PRIVATE Vulkan::Headers) 796 target_link_libraries(bindless_sizing_test PRIVATE Vulkan::Headers)
@@ -819,7 +857,7 @@ if(TARGET Vulkan::Headers)
819 ${_stubs_header} 857 ${_stubs_header}
820 ID3D12GraphicsCommandList8 ID3D12CommandQueue ID3D12CommandAllocator ID3D12Fence1 858 ID3D12GraphicsCommandList8 ID3D12CommandQueue ID3D12CommandAllocator ID3D12Fence1
821 ID3D12Device11 ID3D12DescriptorHeap ID3D12Heap ID3D12Resource ID3D12QueryHeap ID3D12RootSignature 859 ID3D12Device11 ID3D12DescriptorHeap ID3D12Heap ID3D12Resource ID3D12QueryHeap ID3D12RootSignature
822 ID3D12PipelineState ID3D12CommandSignature 860 ID3D12PipelineState ID3D12CommandSignature ID3D12PipelineLibrary1
823 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/gen_d3d12_stubs.py ${LEONIDA_D3D12_HEADER} 861 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/gen_d3d12_stubs.py ${LEONIDA_D3D12_HEADER}
824 COMMENT "Generating D3D12 COM stubs" 862 COMMENT "Generating D3D12 COM stubs"
825 VERBATIM) 863 VERBATIM)
@@ -961,6 +999,14 @@ if(TARGET Vulkan::Headers)
961 target_compile_options(queue_proxy_test PRIVATE /W4 /permissive- /utf-8) 999 target_compile_options(queue_proxy_test PRIVATE /W4 /permissive- /utf-8)
962 add_test(NAME queue_proxy COMMAND queue_proxy_test) 1000 add_test(NAME queue_proxy COMMAND queue_proxy_test)
963 set_tests_properties(queue_proxy PROPERTIES SKIP_RETURN_CODE 77) 1001 set_tests_properties(queue_proxy PROPERTIES SKIP_RETURN_CODE 77)
1002 # Xbox-ABI command allocator proxies (device slot 9) on the Vulkan device, and the unwrapped PC allocator on the
1003 # host runtime: forwarding, refused tail, guard region, lists and GPU copies on the proxy. 77: no device at all.
1004 add_executable(allocator_proxy_test test/allocator_proxy_test.cpp)
1005 target_link_libraries(allocator_proxy_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
1006 target_compile_definitions(allocator_proxy_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
1007 target_compile_options(allocator_proxy_test PRIVATE /W4 /permissive- /utf-8)
1008 add_test(NAME allocator_proxy COMMAND allocator_proxy_test)
1009 set_tests_properties(allocator_proxy PROPERTIES SKIP_RETURN_CODE 77)
964 # The countdown behind those event-backed waits, with no GPU: the full unsigned count, no wrap past zero. 1010 # The countdown behind those event-backed waits, with no GPU: the full unsigned count, no wrap past zero.
965 add_executable(d3d12_fence_waiter_test test/d3d12_fence_waiter_test.cpp) 1011 add_executable(d3d12_fence_waiter_test test/d3d12_fence_waiter_test.cpp)
966 target_compile_definitions(d3d12_fence_waiter_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) 1012 target_compile_definitions(d3d12_fence_waiter_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
@@ -1176,8 +1222,65 @@ if(TARGET Vulkan::Headers)
1176 target_compile_options(d3d12_m3_frame_test PRIVATE /W4 /permissive- /utf-8) 1222 target_compile_options(d3d12_m3_frame_test PRIVATE /W4 /permissive- /utf-8)
1177 add_test(NAME d3d12_m3_frame COMMAND d3d12_m3_frame_test) 1223 add_test(NAME d3d12_m3_frame COMMAND d3d12_m3_frame_test)
1178 set_tests_properties(d3d12_m3_frame PROPERTIES SKIP_RETURN_CODE 77) 1224 set_tests_properties(d3d12_m3_frame PROPERTIES SKIP_RETURN_CODE 77)
1225
1226 # M4 (synthetic part): compute PSOs, a UAV table (structured and raw buffers, an R32_UINT storage image), an indirect
1227 # dispatch from arguments a first dispatch wrote, and a copy queue that streams the input in and reads the results
1228 # back across queue fences. cs_m4_fill.asm and cs_m4_indirect.asm go through the same build; build.py publishes
1229 # their synthetic FSSM programs (the compute header and the words their "fssm-data" comments give), which the
1230 # test wraps in shader containers.
1231 set(LEONIDA_M4_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/m4_shaders)
1232 set(LEONIDA_M4_FILES ${LEONIDA_M4_DIR}/spirv/index.json ${LEONIDA_M4_DIR}/fssm/cs_m4_fill.fssm
1233 ${LEONIDA_M4_DIR}/fssm/cs_m4_indirect.fssm)
1234 add_custom_command(
1235 OUTPUT ${LEONIDA_M4_FILES}
1236 COMMAND ${CMAKE_COMMAND} -E remove_directory ${LEONIDA_M4_DIR}
1237 COMMAND ${CMAKE_COMMAND} -E env "LLVM_MC=${LEONIDA_LLVM_MC}" "LEONIDA_SPIRV_TOOLS=${LEONIDA_SPIRV_TOOLS_NATIVE}"
1238 $<TARGET_FILE:Python3::Interpreter> -I ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/build.py
1239 ${LEONIDA_M4_DIR} cs_m4_fill cs_m4_indirect
1240 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/build.py
1241 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/compute_fixture.py
1242 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/cs_m4_fill.asm
1243 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/cs_m4_indirect.asm
1244 ${CMAKE_CURRENT_SOURCE_DIR}/../tools/rdna2spirv.py
1245 COMMENT "Translating cs_m4_fill and cs_m4_indirect for the compute test"
1246 VERBATIM)
1247 add_executable(d3d12_m4_compute_test test/d3d12_m4_compute_test.cpp shims/d3d12_xs_device.cpp ${LEONIDA_M4_FILES})
1248 target_link_libraries(d3d12_m4_compute_test PRIVATE gta6rt_d3d12_com)
1249 target_compile_definitions(d3d12_m4_compute_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX
1250 LEONIDA_TEST_M4_DIR="${LEONIDA_M4_DIR}")
1251 target_compile_options(d3d12_m4_compute_test PRIVATE /W4 /permissive- /utf-8)
1252 add_test(NAME d3d12_m4_compute COMMAND d3d12_m4_compute_test)
1253 set_tests_properties(d3d12_m4_compute PROPERTIES SKIP_RETURN_CODE 77)
1254
1255 # Typed buffer UAVs and UAV counters: cs_buf_typed.asm writes typed views through V#s with a FORMAT, and
1256 # cs_buf_counter.asm appends to and consumes from a structured view whose counter is the second V# of its slot;
1257 # the test also compares typed-buffer and counter clears with the host runtime on the layer's adapter.
1258 set(LEONIDA_BUFFER_UAV_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/buffer_uav_shaders)
1259 set(LEONIDA_BUFFER_UAV_FILES ${LEONIDA_BUFFER_UAV_DIR}/spirv/index.json
1260 ${LEONIDA_BUFFER_UAV_DIR}/fssm/cs_buf_typed.fssm
1261 ${LEONIDA_BUFFER_UAV_DIR}/fssm/cs_buf_counter.fssm)
1262 add_custom_command(
1263 OUTPUT ${LEONIDA_BUFFER_UAV_FILES}
1264 COMMAND ${CMAKE_COMMAND} -E remove_directory ${LEONIDA_BUFFER_UAV_DIR}
1265 COMMAND ${CMAKE_COMMAND} -E env "LLVM_MC=${LEONIDA_LLVM_MC}" "LEONIDA_SPIRV_TOOLS=${LEONIDA_SPIRV_TOOLS_NATIVE}"
1266 $<TARGET_FILE:Python3::Interpreter> -I ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/build.py
1267 ${LEONIDA_BUFFER_UAV_DIR} cs_buf_typed cs_buf_counter
1268 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/build.py
1269 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/compute_fixture.py
1270 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/cs_buf_typed.asm
1271 ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/cs_buf_counter.asm
1272 ${CMAKE_CURRENT_SOURCE_DIR}/../tools/rdna2spirv.py
1273 COMMENT "Translating cs_buf_typed and cs_buf_counter for the buffer UAV test"
1274 VERBATIM)
1275 add_executable(d3d12_buffer_uav_test test/d3d12_buffer_uav_test.cpp shims/d3d12_xs_device.cpp ${LEONIDA_BUFFER_UAV_FILES})
1276 target_link_libraries(d3d12_buffer_uav_test PRIVATE gta6rt_d3d12_com)
1277 target_compile_definitions(d3d12_buffer_uav_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX
1278 LEONIDA_TEST_BUFFER_UAV_DIR="${LEONIDA_BUFFER_UAV_DIR}")
1279 target_compile_options(d3d12_buffer_uav_test PRIVATE /W4 /permissive- /utf-8)
1280 add_test(NAME d3d12_buffer_uav COMMAND d3d12_buffer_uav_test)
1281 set_tests_properties(d3d12_buffer_uav PROPERTIES SKIP_RETURN_CODE 77)
1179 else() 1282 else()
1180 message(STATUS "llvm-mc (set LLVM_MC) or the SDK's spirv-as/spirv-val not found: d3d12_translated_draw_test, d3d12_m2_textured_test and d3d12_m3_frame_test are not built") 1283 message(STATUS "llvm-mc (set LLVM_MC) or the SDK's spirv-as/spirv-val not found: d3d12_translated_draw_test, d3d12_m2_textured_test, d3d12_m3_frame_test, d3d12_m4_compute_test and d3d12_buffer_uav_test are not built")
1181 endif() 1284 endif()
1182 # ID3D12Resource::GetHeapProperties and ID3D12DescriptorHeap::GetDesc (node masks, resolved heap flags) against the 1285 # ID3D12Resource::GetHeapProperties and ID3D12DescriptorHeap::GetDesc (node masks, resolved heap flags) against the
1183 # host runtime and WARP; run explicitly on a Vulkan GPU. 1286 # host runtime and WARP; run explicitly on a Vulkan GPU.
@@ -1191,6 +1294,7 @@ if(TARGET Vulkan::Headers)
1191 target_compile_definitions(d3d12_indirect_zero_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) 1294 target_compile_definitions(d3d12_indirect_zero_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
1192 target_compile_options(d3d12_indirect_zero_test PRIVATE /W4 /permissive- /utf-8) 1295 target_compile_options(d3d12_indirect_zero_test PRIVATE /W4 /permissive- /utf-8)
1193 add_test(NAME d3d12_indirect_zero COMMAND d3d12_indirect_zero_test) 1296 add_test(NAME d3d12_indirect_zero COMMAND d3d12_indirect_zero_test)
1297 set_tests_properties(d3d12_indirect_zero PROPERTIES SKIP_RETURN_CODE 77)
1194 set_tests_properties(d3d12_node_mask PROPERTIES SKIP_RETURN_CODE 77) 1298 set_tests_properties(d3d12_node_mask PROPERTIES SKIP_RETURN_CODE 77)
1195 set_tests_properties(d3d12_indirect_zero PROPERTIES SKIP_RETURN_CODE 77) 1299 set_tests_properties(d3d12_indirect_zero PROPERTIES SKIP_RETURN_CODE 77)
1196 1300
@@ -1332,6 +1436,16 @@ if(TARGET Vulkan::Headers)
1332 target_compile_options(d3d12_set0_compute_test PRIVATE /W4 /permissive- /utf-8) 1436 target_compile_options(d3d12_set0_compute_test PRIVATE /W4 /permissive- /utf-8)
1333 add_test(NAME d3d12_set0_compute COMMAND d3d12_set0_compute_test) 1437 add_test(NAME d3d12_set0_compute COMMAND d3d12_set0_compute_test)
1334 set_tests_properties(d3d12_set0_compute PROPERTIES SKIP_RETURN_CODE 77) 1438 set_tests_properties(d3d12_set0_compute PROPERTIES SKIP_RETURN_CODE 77)
1439 add_executable(d3d12_pipeline_library_test test/d3d12_pipeline_library_test.cpp
1440 ${LEONIDA_TEST_CS} ${LEONIDA_TEST_VS} ${LEONIDA_TEST_PS})
1441 target_link_libraries(d3d12_pipeline_library_test PRIVATE gta6rt_d3d12_com)
1442 target_compile_definitions(d3d12_pipeline_library_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX
1443 LEONIDA_TEST_CS_SPV="${LEONIDA_TEST_CS}"
1444 LEONIDA_TEST_VS_SPV="${LEONIDA_TEST_VS}"
1445 LEONIDA_TEST_PS_SPV="${LEONIDA_TEST_PS}")
1446 target_compile_options(d3d12_pipeline_library_test PRIVATE /W4 /permissive- /utf-8)
1447 add_test(NAME d3d12_pipeline_library COMMAND d3d12_pipeline_library_test)
1448 set_tests_properties(d3d12_pipeline_library PROPERTIES SKIP_RETURN_CODE 77)
1335 else() 1449 else()
1336 message(STATUS "glslangValidator not found: d3d12_compute_test, d3d12_draw_test and d3d12_set0_compute_test are not built") 1450 message(STATUS "glslangValidator not found: d3d12_compute_test, d3d12_draw_test and d3d12_set0_compute_test are not built")
1337 endif() 1451 endif()
diff --git a/runtime/README.md b/runtime/README.md
index 1375ced25..7060f4368 100644
--- a/runtime/README.md
+++ b/runtime/README.md
@@ -235,6 +235,14 @@ The PE-loader and Bink-decode tests that need the retail package are optional: w
235`LEONIDA_GAME_DIR` (and, for Bink, `LEONIDA_MOVIE`) is unset they print `SKIP` and exit 0. They read 235`LEONIDA_GAME_DIR` (and, for Bink, `LEONIDA_MOVIE`) is unset they print `SKIP` and exit 0. They read
236the files in place and never copy or commit game data. 236the files in place and never copy or commit game data.
237 237
238`shader_library_corpus_test` runs the D3D12 layer's shader lookup (`src/shader_library.h`) over a work folder
239that `make_game.py --stages shaders` built from your copy. With `LEONIDA_SHADERS=<work>/shaders/spirv` it takes
240every container in `<work>/shaders/dxbc` (or `LEONIDA_SHADER_DXBC`), inflates its FSSM program and looks it up
241under the stage its DXIL program header names. Each container has to find its own `index.json` entry and a
242readable `.spv`, every entry has to be reached, and in containers with more than one 0x0D payload no earlier
243payload may be the indexed program. Without `LEONIDA_SHADERS` it prints `SKIP` (CTest reports it as skipped).
244It prints counts only; on the 1.0.2.1 corpus all 26,503 containers resolve.
245
238## Current limits 246## Current limits
239 247
240`gta6rt --run <exe> [-- args]` runs an executable's entry point inside the runtime (`shims/process.cpp` gives it its 248`gta6rt --run <exe> [-- args]` runs an executable's entry point inside the runtime (`shims/process.cpp` gives it its
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp
index 7e428735d..55c6f86a8 100644
--- a/runtime/shims/d3d12_com.cpp
+++ b/runtime/shims/d3d12_com.cpp
@@ -113,8 +113,9 @@ class CommandAllocator final
113 : public Child<CommandAllocator, ID3D12CommandAllocatorStubs, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable, 113 : public Child<CommandAllocator, ID3D12CommandAllocatorStubs, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable,
114 ID3D12CommandAllocator> { 114 ID3D12CommandAllocator> {
115public: 115public:
116 // {7d0e6b51-34a2-4f0c-9a61-0c5b2e8f4a10} 116 // {7d0e6b51-34a2-4f0c-9a61-0c5b2e8f4a10}, public in d3d12_xs_device.h: the device proxy's slot 9 wraps an allocator
117 static constexpr GUID kTag{0x7d0e6b51, 0x34a2, 0x4f0c, {0x9a, 0x61, 0x0c, 0x5b, 0x2e, 0x8f, 0x4a, 0x10}}; 117 // in an Xbox-ABI allocator proxy only when it answers this tag, because from() below resolves such a proxy.
118 static constexpr GUID kTag = d3d12_xs::kLeonidaCommandAllocatorTag;
118 explicit CommandAllocator(D3D12_COMMAND_LIST_TYPE type) : type_(type) {} 119 explicit CommandAllocator(D3D12_COMMAND_LIST_TYPE type) : type_(type) {}
119 // Lists own their recorded commands, so there is nothing to free. As on the PC runtime (D3D-51, measured by 120 // Lists own their recorded commands, so there is nothing to free. As on the PC runtime (D3D-51, measured by
120 // d3d12_vulkan_device_test): E_FAIL while a list is recording into this allocator, and S_OK while its lists are 121 // d3d12_vulkan_device_test): E_FAIL while a list is recording into this allocator, and S_OK while its lists are
@@ -124,7 +125,12 @@ public:
124 // The one list that is recording into this allocator, or null. D3D12 allows one at a time. 125 // The one list that is recording into this allocator, or null. D3D12 allows one at a time.
125 const void* recording() const { return recording_; } 126 const void* recording() const { return recording_; }
126 void set_recording(const void* list) { recording_ = list; } 127 void set_recording(const void* list) { recording_ = list; }
127 static CommandAllocator* from(IUnknown* object) { return Child::from<CommandAllocator>(object); } 128 // An allocator proxy (the title's allocator from device slot 9) stands for the allocator behind it, so every
129 // list method that takes an allocator (CreateCommandList, Reset) resolves it here.
130 static CommandAllocator* from(IUnknown* object) {
131 if (ID3D12CommandAllocator* real = d3d12_xs::allocator_proxy_real_allocator(object)) object = real;
132 return Child::from<CommandAllocator>(object);
133 }
128 134
129private: 135private:
130 D3D12_COMMAND_LIST_TYPE type_; 136 D3D12_COMMAND_LIST_TYPE type_;
@@ -214,10 +220,14 @@ public:
214 bind_root(compute_, signature); 220 bind_root(compute_, signature);
215 } 221 }
216 void STDMETHODCALLTYPE SetGraphicsRootSignature(ID3D12RootSignature* signature) override { 222 void STDMETHODCALLTYPE SetGraphicsRootSignature(ID3D12RootSignature* signature) override {
223 d3d12_trace::record("ID3D12GraphicsCommandList::SetGraphicsRootSignature");
217 bind_root(graphics_, signature); 224 bind_root(graphics_, signature);
218 } 225 }
219 226
220 void STDMETHODCALLTYPE SetPipelineState(ID3D12PipelineState* state) override { set_pipeline(state); } 227 void STDMETHODCALLTYPE SetPipelineState(ID3D12PipelineState* state) override {
228 d3d12_trace::record("ID3D12GraphicsCommandList::SetPipelineState");
229 set_pipeline(state);
230 }
221 231
222 // The bound heaps matter to direct heap indexing, which is still open (section 3.4); tables carry their VAs. 232 // The bound heaps matter to direct heap indexing, which is still open (section 3.4); tables carry their VAs.
223 void STDMETHODCALLTYPE SetDescriptorHeaps(UINT, ID3D12DescriptorHeap* const*) override {} 233 void STDMETHODCALLTYPE SetDescriptorHeaps(UINT, ID3D12DescriptorHeap* const*) override {}
@@ -591,12 +601,17 @@ public:
591 cmd.argument_offset = argument_buffer_offset; 601 cmd.argument_offset = argument_buffer_offset;
592 cmd.count_buffer = count_buffer ? resource_id(count_buffer) : 0; 602 cmd.count_buffer = count_buffer ? resource_id(count_buffer) : 0;
593 cmd.count_offset = count_buffer ? count_buffer_offset : 0; 603 cmd.count_offset = count_buffer ? count_buffer_offset : 0;
604 if (kind == leonida::IndirectKind::dispatch && max_command_count) { // the pipeline and root arguments a Dispatch would record
605 if (!compute_pipeline_ || !compute_.layout) return check(false);
606 cmd.pipeline = compute_pipeline_;
607 cmd.user_data = compute_.data;
608 }
594 check(list_.execute_indirect(cmd)); 609 check(list_.execute_indirect(cmd));
595 } 610 }
596 611
597 void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure( 612 void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure(
598 const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC* desc, UINT, 613 const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC* desc, UINT postbuild_count,
599 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC*) override { 614 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC* postbuild) override {
600 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc) return check(false); 615 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc) return check(false);
601 const auto& in = desc->Inputs; 616 const auto& in = desc->Inputs;
602 leonida::BuildAccelerationStructure cmd{}; 617 leonida::BuildAccelerationStructure cmd{};
@@ -650,7 +665,38 @@ public:
650 cmd.triangles.push_back(t); 665 cmd.triangles.push_back(t);
651 } 666 }
652 } 667 }
653 check(list_.build_acceleration_structure(cmd)); 668 const std::uint64_t built = cmd.dst_va;
669 const bool recorded = list_.build_acceleration_structure(std::move(cmd));
670 check(recorded);
671 if (!recorded) return;
672 // The postbuild values of the structure just built, after it (D3D12 orders them after the build).
673 for (UINT i = 0; postbuild && i < postbuild_count; ++i) {
674 leonida::AccelerationStructurePostbuild info{};
675 info.dest_va = postbuild[i].DestBuffer;
676 info.type = static_cast<std::uint32_t>(postbuild[i].InfoType);
677 info.sources = {built};
678 const bool ok = list_.acceleration_structure_postbuild(std::move(info));
679 check(ok);
680 if (!ok) return;
681 }
682 }
683
684 void STDMETHODCALLTYPE EmitRaytracingAccelerationStructurePostbuildInfo(
685 const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC* desc, UINT count,
686 const D3D12_GPU_VIRTUAL_ADDRESS* sources) override {
687 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE || !desc || !count || !sources) return check(false);
688 leonida::AccelerationStructurePostbuild info{};
689 info.dest_va = desc->DestBuffer;
690 info.type = static_cast<std::uint32_t>(desc->InfoType);
691 info.sources.assign(sources, sources + count);
692 check(list_.acceleration_structure_postbuild(std::move(info)));
693 }
694
695 void STDMETHODCALLTYPE CopyRaytracingAccelerationStructure(D3D12_GPU_VIRTUAL_ADDRESS dest,
696 D3D12_GPU_VIRTUAL_ADDRESS source,
697 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode) override {
698 if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false);
699 check(list_.copy_acceleration_structure({dest, source, static_cast<std::uint32_t>(mode)}));
654 } 700 }
655 701
656 static GraphicsCommandList* from(IUnknown* object) { return Child::from<GraphicsCommandList>(object); } 702 static GraphicsCommandList* from(IUnknown* object) { return Child::from<GraphicsCommandList>(object); }
@@ -1251,7 +1297,8 @@ HRESULT create_command_list(D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator
1251 if (!command_allocator || command_allocator->type() != type) return E_INVALIDARG; 1297 if (!command_allocator || command_allocator->type() != type) return E_INVALIDARG;
1252 // A list is created open, so the allocator must be free: E_INVALIDARG as on the PC runtime (D3D-51). 1298 // A list is created open, so the allocator must be free: E_INVALIDARG as on the PC runtime (D3D-51).
1253 if (command_allocator->recording()) return E_INVALIDARG; 1299 if (command_allocator->recording()) return E_INVALIDARG;
1254 if (type != D3D12_COMMAND_LIST_TYPE_DIRECT && type != D3D12_COMMAND_LIST_TYPE_BUNDLE) 1300 if (type != D3D12_COMMAND_LIST_TYPE_DIRECT && type != D3D12_COMMAND_LIST_TYPE_BUNDLE &&
1301 type != D3D12_COMMAND_LIST_TYPE_COMPUTE && type != D3D12_COMMAND_LIST_TYPE_COPY)
1255 stub("create_command_list(non-direct type)"); 1302 stub("create_command_list(non-direct type)");
1256 auto* object = new GraphicsCommandList(type); // created open, as D3D12 does 1303 auto* object = new GraphicsCommandList(type); // created open, as D3D12 does
1257 object->record_into(command_allocator); 1304 object->record_into(command_allocator);
diff --git a/runtime/shims/d3d12_com.h b/runtime/shims/d3d12_com.h
index 2e1f2d3c5..b3b397be0 100644
--- a/runtime/shims/d3d12_com.h
+++ b/runtime/shims/d3d12_com.h
@@ -273,6 +273,12 @@ inline constexpr UINT descriptor_size = 32;
273// ExecuteCommandLists returns void; this is what the last call on the queue did. 273// ExecuteCommandLists returns void; this is what the last call on the queue did.
274leonida::ReplayResult last_execute_result(ID3D12CommandQueue* queue); 274leonida::ReplayResult last_execute_result(ID3D12CommandQueue* queue);
275 275
276// True when the current thread or process token has SeIncreaseBasePriorityPrivilege enabled (or the test override
277// forces it), which D3D12 requires for D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME.
278bool has_global_realtime_privilege();
279// Test override for has_global_realtime_privilege(): -1 queries the token (default), 0 forces denied, 1 forces granted.
280void set_global_realtime_privilege_override_for_test(int state);
281
276// The front/back stencil references last recorded by ID3D12GraphicsCommandList8::OMSetFrontAndBackStencilRef on 282// The front/back stencil references last recorded by ID3D12GraphicsCommandList8::OMSetFrontAndBackStencilRef on
277// `list`. The values are kept for the future pipeline path, which is what would apply them. False when `list` is 283// `list`. The values are kept for the future pipeline path, which is what would apply them. False when `list` is
278// not one of this module's command lists. 284// not one of this module's command lists.
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp
index 5cb39d0d6..af7e7aa5c 100644
--- a/runtime/shims/d3d12_vulkan_device.cpp
+++ b/runtime/shims/d3d12_vulkan_device.cpp
@@ -15,15 +15,19 @@
15#include "d3d12_xs_device.h" 15#include "d3d12_xs_device.h"
16#include "dxgi_com.h" 16#include "dxgi_com.h"
17#include "../src/gfx10_descriptors.h" 17#include "../src/gfx10_descriptors.h"
18#include "../src/uav_clear.h"
18#include "../src/vulkan_bindless.h" 19#include "../src/vulkan_bindless.h"
19#include "../src/vulkan_memory.h" 20#include "../src/vulkan_memory.h"
20#include "../src/resource_tiling.h" 21#include "../src/resource_tiling.h"
21#include "../src/shader_library.h" 22#include "../src/shader_library.h"
22#include "../src/vulkan_present.h" 23#include "../src/vulkan_present.h"
23#include "../src/vulkan_device_filter.h" 24#include "../src/vulkan_device_filter.h"
25#include "../src/vulkan13_features.h"
24 26
25#include <vulkan/vulkan_win32.h> 27#include <vulkan/vulkan_win32.h>
26 28#ifdef _MSC_VER
29#pragma comment(lib, "advapi32.lib")
30#endif
27 31
28#include <algorithm> 32#include <algorithm>
29#include <atomic> 33#include <atomic>
@@ -59,6 +63,8 @@ static_assert(sizeof(leonida::TargetView) <= kDescriptorSize);
59constexpr D3D_SHADER_MODEL kHighestShaderModel = D3D_SHADER_MODEL_6_0; 63constexpr D3D_SHADER_MODEL kHighestShaderModel = D3D_SHADER_MODEL_6_0;
60constexpr D3D_ROOT_SIGNATURE_VERSION kHighestRootSignatureVersion = D3D_ROOT_SIGNATURE_VERSION_1_1; 64constexpr D3D_ROOT_SIGNATURE_VERSION kHighestRootSignatureVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
61 65
66std::atomic<int> g_global_realtime_privilege_override{-1};
67
62void log_once(const char* what, int value) { 68void log_once(const char* what, int value) {
63 static std::mutex mutex; 69 static std::mutex mutex;
64 static std::set<std::pair<std::string, int>> seen; 70 static std::set<std::pair<std::string, int>> seen;
@@ -1060,6 +1066,21 @@ const char* heap_properties_refusal(const D3D12_HEAP_PROPERTIES& heap) {
1060 return nullptr; 1066 return nullptr;
1061} 1067}
1062 1068
1069// Why the host would refuse this CreateHeap/CreateHeap1 description, or null if these checks pass (D3D-238). A probe
1070// on an RX 5700 and WARP refuses an alignment other than 0, 64 KiB and 4 MiB, the heap properties above (a type of 0,
1071// a custom heap without a CPU page property), and a heap that denies buffers and both kinds of texture.
1072const char* heap_desc_refusal(const D3D12_HEAP_DESC& desc) {
1073 if (!desc.SizeInBytes) return "zero size";
1074 if (desc.Alignment && desc.Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT &&
1075 desc.Alignment != D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT)
1076 return "alignment (0, 64 KiB or 4 MiB)";
1077 if (const char* why = heap_properties_refusal(desc.Properties)) return why;
1078 constexpr UINT deny_all = D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES |
1079 D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES;
1080 if ((UINT(desc.Flags) & deny_all) == deny_all) return "heap flags denying every resource kind";
1081 return nullptr;
1082}
1083
1063// Why the host would refuse this committed resource, or null if these checks pass. The flag and format tables were 1084// Why the host would refuse this committed resource, or null if these checks pass. The flag and format tables were
1064// measured on an RX 9070 XT, an integrated Radeon and WARP, which agree on all of them. Cross-adapter resources 1085// measured on an RX 9070 XT, an integrated Radeon and WARP, which agree on all of them. Cross-adapter resources
1065// (valid there only as a row-major texture on a SHARED | SHARED_CROSS_ADAPTER heap) are refused: this layer has no 1086// (valid there only as a row-major texture on a SHARED | SHARED_CROSS_ADAPTER heap) are refused: this layer has no
@@ -1355,6 +1376,10 @@ public:
1355 binding.size = desc_.Width; 1376 binding.size = desc_.Width;
1356 binding.buffer = device_.arena.buffer; 1377 binding.buffer = device_.arena.buffer;
1357 binding.buffer_offset = va_; 1378 binding.buffer_offset = va_;
1379 binding.va = va_;
1380 binding.host_readable = (heap_.Type == D3D12_HEAP_TYPE_READBACK ||
1381 (heap_.Type == D3D12_HEAP_TYPE_CUSTOM &&
1382 heap_.CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK));
1358 device_.context->add_resource(id(), binding); 1383 device_.context->add_resource(id(), binding);
1359 return S_OK; 1384 return S_OK;
1360 } 1385 }
@@ -1460,8 +1485,9 @@ public:
1460 D3D12_RESOURCE_DESC STDMETHODCALLTYPE GetDesc() override { 1485 D3D12_RESOURCE_DESC STDMETHODCALLTYPE GetDesc() override {
1461 D3D12_RESOURCE_DESC desc = desc_; 1486 D3D12_RESOURCE_DESC desc = desc_;
1462 if (!desc.Alignment) { 1487 if (!desc.Alignment) {
1463 desc.Alignment = desc.SampleDesc.Count > 1 ? D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT 1488 desc.Alignment = (desc.SampleDesc.Count > 1 && !is_tiled_layout(desc.Layout))
1464 : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; 1489 ? D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT
1490 : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
1465 } 1491 }
1466 return desc; 1492 return desc;
1467 } 1493 }
@@ -1937,6 +1963,7 @@ public:
1937 bool reserved() const { return reserved_; } 1963 bool reserved() const { return reserved_; }
1938 VkDeviceSize offset() const { return offset_; } 1964 VkDeviceSize offset() const { return offset_; }
1939 UINT64 bytes() const { return desc_.SizeInBytes; } 1965 UINT64 bytes() const { return desc_.SizeInBytes; }
1966 UINT64 alignment() const { return desc_.Alignment ? desc_.Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; }
1940 const D3D12_HEAP_PROPERTIES& properties() const { return desc_.Properties; } 1967 const D3D12_HEAP_PROPERTIES& properties() const { return desc_.Properties; }
1941 D3D12_HEAP_FLAGS flags() const { return desc_.Flags; } 1968 D3D12_HEAP_FLAGS flags() const { return desc_.Flags; }
1942 1969
@@ -2616,6 +2643,99 @@ struct TextureView {
2616 float min_lod = 0.0f; 2643 float min_lod = 0.0f;
2617}; 2644};
2618 2645
2646// In-memory pipeline library (docs/d3d12_vulkan.md sections 3.6 and 4). D3D12 cached blobs are driver-specific
2647// and ignored across runs; Serialize writes a versioned header so CreatePipelineLibrary recognizes our own blobs
2648// and returns D3D12_ERROR_DRIVER_VERSION_MISMATCH for foreign or corrupt ones.
2649class PipelineLibrary final
2650 : public Child<PipelineLibrary, ID3D12PipelineLibrary1Stubs, ID3D12Object, ID3D12DeviceChild, ID3D12Pageable,
2651 ID3D12PipelineLibrary, ID3D12PipelineLibrary1> {
2652public:
2653 // {6e2a9d41-7b5f-4c83-8e14-2a9d6f3c5b10}
2654 static constexpr GUID kTag{0x6e2a9d41, 0x7b5f, 0x4c83, {0x8e, 0x14, 0x2a, 0x9d, 0x6f, 0x3c, 0x5b, 0x10}};
2655
2656 struct Header {
2657 std::uint32_t magic;
2658 std::uint32_t version;
2659 std::uint32_t count;
2660 std::uint32_t reserved;
2661 };
2662 static constexpr std::uint32_t kMagic = 0x314C504Cu; // "LPL1"
2663 static constexpr std::uint32_t kVersion = 1;
2664
2665 ~PipelineLibrary() override {
2666 std::lock_guard lock(mutex_);
2667 for (auto& [name, pso] : entries_)
2668 if (pso) pso->Release();
2669 entries_.clear();
2670 }
2671
2672 static bool valid_blob(const void* data, SIZE_T size) {
2673 if (!data || size < sizeof(Header)) return false;
2674 Header h{};
2675 std::memcpy(&h, data, sizeof(h));
2676 return h.magic == kMagic && h.version == kVersion && h.reserved == 0;
2677 }
2678
2679 HRESULT STDMETHODCALLTYPE StorePipeline(LPCWSTR name, ID3D12PipelineState* pipeline) override {
2680 if (!name || !*name || !pipeline) return E_INVALIDARG;
2681 if (!PipelineState::from<PipelineState>(pipeline)) return E_INVALIDARG;
2682 std::lock_guard lock(mutex_);
2683 auto [it, inserted] = entries_.emplace(name, pipeline);
2684 if (!inserted) return E_INVALIDARG;
2685 pipeline->AddRef();
2686 return S_OK;
2687 }
2688
2689 HRESULT STDMETHODCALLTYPE LoadGraphicsPipeline(LPCWSTR name, const D3D12_GRAPHICS_PIPELINE_STATE_DESC* desc,
2690 REFIID riid, void** out) override {
2691 if (!out) return E_POINTER;
2692 *out = nullptr;
2693 if (!name || !*name || !desc) return E_INVALIDARG;
2694 return load_entry(name, false, true, riid, out);
2695 }
2696
2697 HRESULT STDMETHODCALLTYPE LoadComputePipeline(LPCWSTR name, const D3D12_COMPUTE_PIPELINE_STATE_DESC* desc,
2698 REFIID riid, void** out) override {
2699 if (!out) return E_POINTER;
2700 *out = nullptr;
2701 if (!name || !*name || !desc) return E_INVALIDARG;
2702 return load_entry(name, true, false, riid, out);
2703 }
2704
2705 HRESULT STDMETHODCALLTYPE LoadPipeline(LPCWSTR name, const D3D12_PIPELINE_STATE_STREAM_DESC* desc,
2706 REFIID riid, void** out) override {
2707 if (!out) return E_POINTER;
2708 *out = nullptr;
2709 if (!name || !*name || !desc || !desc->SizeInBytes || !desc->pPipelineStateSubobjectStream) return E_INVALIDARG;
2710 return load_entry(name, false, false, riid, out);
2711 }
2712
2713 SIZE_T STDMETHODCALLTYPE GetSerializedSize() override { return sizeof(Header); }
2714
2715 HRESULT STDMETHODCALLTYPE Serialize(void* data, SIZE_T size) override {
2716 if (!data || size < sizeof(Header)) return E_INVALIDARG;
2717 std::lock_guard lock(mutex_);
2718 const Header h{kMagic, kVersion, static_cast<std::uint32_t>(entries_.size()), 0};
2719 std::memcpy(data, &h, sizeof(h));
2720 return S_OK;
2721 }
2722
2723private:
2724 HRESULT load_entry(LPCWSTR name, bool require_compute, bool require_graphics, REFIID riid, void** out) {
2725 std::lock_guard lock(mutex_);
2726 const auto it = entries_.find(name);
2727 if (it == entries_.end()) return E_INVALIDARG;
2728 PipelineState* ps = PipelineState::from<PipelineState>(it->second);
2729 if (!ps) return E_INVALIDARG;
2730 if (require_compute && !ps->compute()) return E_INVALIDARG;
2731 if (require_graphics && !ps->graphics()) return E_INVALIDARG;
2732 return it->second->QueryInterface(riid, out);
2733 }
2734
2735 std::mutex mutex_;
2736 std::unordered_map<std::wstring, ID3D12PipelineState*> entries_;
2737};
2738
2619// The T# of a view: what the shader gets to know about it, in the structure the console's shaders read. 2739// The T# of a view: what the shader gets to know about it, in the structure the console's shaders read.
2620// False (with a log) for a view set 0 cannot show yet. 2740// False (with a log) for a view set 0 cannot show yet.
2621bool image_descriptor(const Resource& resource, const TextureView& view, leonida::gfx10::Image& out) { 2741bool image_descriptor(const Resource& resource, const TextureView& view, leonida::gfx10::Image& out) {
@@ -2646,7 +2766,7 @@ bool image_descriptor(const Resource& resource, const TextureView& view, leonida
2646 const auto dimension = line ? D3D12_RESOURCE_DIMENSION_TEXTURE1D : 2766 const auto dimension = line ? D3D12_RESOURCE_DIMENSION_TEXTURE1D :
2647 view.type == g::ImageType::image_3d ? D3D12_RESOURCE_DIMENSION_TEXTURE3D : 2767 view.type == g::ImageType::image_3d ? D3D12_RESOURCE_DIMENSION_TEXTURE3D :
2648 D3D12_RESOURCE_DIMENSION_TEXTURE2D; 2768 D3D12_RESOURCE_DIMENSION_TEXTURE2D;
2649 if (desc.Dimension != dimension || (line && desc.DepthOrArraySize != 1) || msaa != (desc.SampleDesc.Count > 1)) { 2769 if (desc.Dimension != dimension || (line && view.layer_count != 1) || msaa != (desc.SampleDesc.Count > 1)) {
2650 log_once("view type incompatible with texture dimension or sample count; view type", int(view.type)); 2770 log_once("view type incompatible with texture dimension or sample count; view type", int(view.type));
2651 return false; 2771 return false;
2652 } 2772 }
@@ -3094,7 +3214,19 @@ public:
3094 get_properties(state_.info.physical, &properties); 3214 get_properties(state_.info.physical, &properties);
3095 features.ms_samples = {VK_SAMPLE_COUNT_4_BIT, state_.ms_fallback_samples(VK_FORMAT_R32_UINT), 3215 features.ms_samples = {VK_SAMPLE_COUNT_4_BIT, state_.ms_fallback_samples(VK_FORMAT_R32_UINT),
3096 state_.ms_fallback_samples(VK_FORMAT_R32_SINT)}; 3216 state_.ms_fallback_samples(VK_FORMAT_R32_SINT)};
3097 if (!leonida::bindless::size_bindings(features, properties.properties.limits, v11, indexed)) 3217 // Past maxPerSetDescriptors, ask the driver about the grown layout (D3D-219: Intel's Xe-LP reports 6159).
3218 const auto layout_support = reinterpret_cast<PFN_vkGetDescriptorSetLayoutSupport>(
3219 get_device(state_.info.device, "vkGetDescriptorSetLayoutSupport"));
3220 std::function<bool(const leonida::BindlessFeatures&)> layout_supported;
3221 if (layout_support)
3222 layout_supported = [&](const leonida::BindlessFeatures& candidate) {
3223 const leonida::bindless::SetLayout layout(candidate);
3224 VkDescriptorSetLayoutSupport support{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT};
3225 layout_support(state_.info.device, &layout.info, &support);
3226 return support.supported == VK_TRUE;
3227 };
3228 if (!leonida::bindless::size_bindings(features, properties.properties.limits, v11, indexed,
3229 layout_supported))
3098 std::fprintf(stderr, "[rt] d3d12: the device's descriptor limits are below the bindless set's default " 3230 std::fprintf(stderr, "[rt] d3d12: the device's descriptor limits are below the bindless set's default "
3099 "sizes; it holds less\n"); 3231 "sizes; it holds less\n");
3100 } 3232 }
@@ -3379,8 +3511,8 @@ public:
3379 log_once("CreateCommandQueue refused (type, priority, flags or node mask), type", desc->Type); 3511 log_once("CreateCommandQueue refused (type, priority, flags or node mask), type", desc->Type);
3380 return d3d12_trace::result(method, E_INVALIDARG); 3512 return d3d12_trace::result(method, E_INVALIDARG);
3381 } 3513 }
3382 // Global realtime priority needs a privilege the host grants only on request; without it, this answer. 3514 // Global realtime priority needs SeIncreaseBasePriorityPrivilege enabled in the token; without it, this answer.
3383 if (desc->Priority == D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME) { 3515 if (desc->Priority == D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME && !has_global_realtime_privilege()) {
3384 log_once("CreateCommandQueue refused (global realtime priority), type", desc->Type); 3516 log_once("CreateCommandQueue refused (global realtime priority), type", desc->Type);
3385 return d3d12_trace::result(method, DXGI_ERROR_ACCESS_DENIED); 3517 return d3d12_trace::result(method, DXGI_ERROR_ACCESS_DENIED);
3386 } 3518 }
@@ -3513,7 +3645,7 @@ public:
3513 auto& vk = state_.context->vk; 3645 auto& vk = state_.context->vk;
3514 if (desc && state_.context->xdxr_acceleration_structures()) { 3646 if (desc && state_.context->xdxr_acceleration_structures()) {
3515 // XDXR records: the layout depends only on the triangle or instance count (xdxr_build.h), so the sizes 3647 // XDXR records: the layout depends only on the triangle or instance count (xdxr_build.h), so the sizes
3516 // are exact. An update rebuilds the structure, so it needs the same scratch. 3648 // are exact. An update refits (no sort); the build's scratch size covers it.
3517 leonida::BuildAccelerationStructure build{}; 3649 leonida::BuildAccelerationStructure build{};
3518 build.is_tlas = desc->Type == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL; 3650 build.is_tlas = desc->Type == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL;
3519 if (build.is_tlas) { 3651 if (build.is_tlas) {
@@ -3676,7 +3808,7 @@ public:
3676 return hand_out(signature, riid, out); 3808 return hand_out(signature, riid, out);
3677 } 3809 }
3678 3810
3679 // PC slot 11; the Xbox ABI reaches it through device slot 62 (the proxy forwards). 3811 // PC slot 11; the Xbox ABI reaches it through device slots 62 and 67 (the proxy forwards).
3680 HRESULT STDMETHODCALLTYPE CreateComputePipelineState(const D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, REFIID riid, 3812 HRESULT STDMETHODCALLTYPE CreateComputePipelineState(const D3D12_COMPUTE_PIPELINE_STATE_DESC* desc, REFIID riid,
3681 void** out) override { 3813 void** out) override {
3682 if (!out) return E_POINTER; 3814 if (!out) return E_POINTER;
@@ -3705,6 +3837,19 @@ public:
3705 return hand_out(pipeline, riid, out); 3837 return hand_out(pipeline, riid, out);
3706 } 3838 }
3707 3839
3840 // Device1: in-memory pipeline library (docs/d3d12_vulkan.md sections 3.6 and 4).
3841 HRESULT STDMETHODCALLTYPE CreatePipelineLibrary(const void* blob, SIZE_T size, REFIID riid, void** out) override {
3842 constexpr auto method = "ID3D12Device1::CreatePipelineLibrary";
3843 if (out) *out = nullptr;
3844 if (size > 0 && !blob) return d3d12_trace::result(method, E_INVALIDARG);
3845 if (size > 0 && !PipelineLibrary::valid_blob(blob, size))
3846 return d3d12_trace::result(method, D3D12_ERROR_DRIVER_VERSION_MISMATCH);
3847 if (!out) return d3d12_trace::result(method, S_FALSE);
3848 auto* lib = new PipelineLibrary();
3849 lib->attach_device(identity());
3850 return d3d12_trace::result(method, hand_out(lib, riid, out));
3851 }
3852
3708 UINT STDMETHODCALLTYPE GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE) override { 3853 UINT STDMETHODCALLTYPE GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE) override {
3709 return kDescriptorSize; 3854 return kDescriptorSize;
3710 } 3855 }
@@ -3763,13 +3908,16 @@ public:
3763 r->allows_view_format(vulkan_format(requested, false).format)); 3908 r->allows_view_format(vulkan_format(requested, false).format));
3764 if (typeless_rgba8 || (requested != rd.Format && listed && 3909 if (typeless_rgba8 || (requested != rd.Format && listed &&
3765 rd.Format == DXGI_FORMAT_R8G8B8A8_UNORM)) { 3910 rd.Format == DXGI_FORMAT_R8G8B8A8_UNORM)) {
3766 const bool plain = desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2D; 3911 const bool msaa = rd.SampleDesc.Count > 1;
3767 const bool array = desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2DARRAY; 3912 const bool plain = !msaa && desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2D;
3913 const bool array = !msaa && desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
3914 const bool ms = msaa && desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2DMS;
3915 const bool ms_array = msaa && desc && desc->ViewDimension == D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY;
3768 const UINT plane = plain ? desc->Texture2D.PlaneSlice : 3916 const UINT plane = plain ? desc->Texture2D.PlaneSlice :
3769 array ? desc->Texture2DArray.PlaneSlice : 0; 3917 array ? desc->Texture2DArray.PlaneSlice : 0;
3770 // Subtraction keeps malformed layer ranges from overflowing during validation. 3918 // Subtraction keeps malformed layer ranges from overflowing during validation.
3771 if ((!plain && !array) || rd.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || 3919 if ((!plain && !array && !ms && !ms_array) || rd.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D ||
3772 rd.SampleDesc.Count != 1 || plane || !view.resource || view.mip >= rd.MipLevels || 3920 plane || !view.resource || view.mip >= rd.MipLevels ||
3773 !view.layer_count || view.first_layer >= rd.DepthOrArraySize || 3921 !view.layer_count || view.first_layer >= rd.DepthOrArraySize ||
3774 view.layer_count > rd.DepthOrArraySize - view.first_layer || 3922 view.layer_count > rd.DepthOrArraySize - view.first_layer ||
3775 !(rd.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)) { 3923 !(rd.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)) {
@@ -3862,6 +4010,24 @@ public:
3862 std::size_t(count) * kDescriptorSize); 4010 std::size_t(count) * kDescriptorSize);
3863 } 4011 }
3864 4012
4013 // A constant-buffer view is a 16-byte GFX10 raw buffer V# in the first half of the slot (zeros in the rest).
4014 // A null description, zero address, or zero size leaves the whole slot zeroed (null V#: reads return 0).
4015 void STDMETHODCALLTYPE CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_VIEW_DESC* desc,
4016 D3D12_CPU_DESCRIPTOR_HANDLE destination) override {
4017 d3d12_trace::record("ID3D12Device::CreateConstantBufferView");
4018 if (!destination.ptr) return;
4019 std::memset(reinterpret_cast<void*>(destination.ptr), 0, kDescriptorSize);
4020 if (!desc || !desc->BufferLocation || !desc->SizeInBytes) return;
4021 leonida::gfx10::Buffer buffer{};
4022 buffer.address = desc->BufferLocation;
4023 buffer.stride = 0;
4024 buffer.num_records = desc->SizeInBytes;
4025 buffer.format = leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT);
4026 buffer.oob_select = leonida::gfx10::OobSelect::raw;
4027 const leonida::gfx10::BufferWords words = leonida::gfx10::encode(buffer);
4028 std::memcpy(reinterpret_cast<void*>(destination.ptr), words.data(), sizeof(words));
4029 }
4030
3865 // A shader-resource view of a texture is a T# in the slot (docs section 3.4): the shader loads those eight 4031 // A shader-resource view of a texture is a T# in the slot (docs section 3.4): the shader loads those eight
3866 // dwords through its descriptor table and finds the image by them. A slot left as zeros is a null descriptor: 4032 // dwords through its descriptor table and finds the image by them. A slot left as zeros is a null descriptor:
3867 // nothing is registered for it, so the shader gets the fallback image. Buffer views are not implemented. 4033 // nothing is registered for it, so the shader gets the fallback image. Buffer views are not implemented.
@@ -3885,9 +4051,10 @@ public:
3885 TextureView view{}; 4051 TextureView view{};
3886 if (!desc) { 4052 if (!desc) {
3887 const bool array = r->desc().DepthOrArraySize > 1; 4053 const bool array = r->desc().DepthOrArraySize > 1;
3888 if (r->desc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE1D && !array) 4054 if (r->desc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE1D && !array) {
3889 view.type = ImageType::image_1d; 4055 view.type = ImageType::image_1d;
3890 else if (r->desc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D) 4056 view.layer_count = 1;
4057 } else if (r->desc().Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3891 view.type = ImageType::image_3d; 4058 view.type = ImageType::image_3d;
3892 else if (r->desc().SampleDesc.Count > 1) 4059 else if (r->desc().SampleDesc.Count > 1)
3893 view.type = array ? ImageType::image_2d_msaa_array : ImageType::image_2d_msaa; 4060 view.type = array ? ImageType::image_2d_msaa_array : ImageType::image_2d_msaa;
@@ -3901,6 +4068,7 @@ public:
3901 view.type = ImageType::image_1d; 4068 view.type = ImageType::image_1d;
3902 view.first_mip = desc->Texture1D.MostDetailedMip; 4069 view.first_mip = desc->Texture1D.MostDetailedMip;
3903 view.mip_count = desc->Texture1D.MipLevels; 4070 view.mip_count = desc->Texture1D.MipLevels;
4071 view.layer_count = 1;
3904 view.min_lod = desc->Texture1D.ResourceMinLODClamp; 4072 view.min_lod = desc->Texture1D.ResourceMinLODClamp;
3905 break; 4073 break;
3906 case D3D12_SRV_DIMENSION_TEXTURE3D: 4074 case D3D12_SRV_DIMENSION_TEXTURE3D:
@@ -3957,6 +4125,95 @@ public:
3957 write_image_descriptor(*r, view, destination, false); 4125 write_image_descriptor(*r, view, destination, false);
3958 } 4126 }
3959 4127
4128 // An unordered-access view of a buffer is a V# in the slot (docs section 3.4): the shader loads those four dwords
4129 // through its descriptor table and reaches the bytes by the console VA in them. A structured view (format
4130 // UNKNOWN and a stride) is `stride` and a record count, a raw one (R32_TYPELESS with the RAW flag) is a byte count,
4131 // a typed one (any other format) is the format's GFX10_FORMAT code with the element size as the stride and an
4132 // element count: the V# a buffer_load_format / buffer_store_format / buffer_atomic reads (OOB_SELECT 1, so the
4133 // index is checked against NUM_RECORDS, docs/buffer_bounds.md). A slot left as zeros is a null descriptor.
4134 // A UAV counter (docs section 3.4, "UAV counters") is a second, raw V# of 4 bytes in the slot's upper 16 bytes: the
4135 // counter resource's address plus CounterOffsetInBytes. Append and consume are atomics a shader does on it.
4136 void write_buffer_uav(ID3D12Resource* resource, ID3D12Resource* counter, const D3D12_UNORDERED_ACCESS_VIEW_DESC* desc,
4137 D3D12_CPU_DESCRIPTOR_HANDLE destination) {
4138 namespace g = leonida::gfx10;
4139 const D3D12_RESOURCE_DESC& rd = Resource::from<Resource>(resource)->desc();
4140 if (!(rd.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) {
4141 log_once("unordered-access view of a buffer created without ALLOW_UNORDERED_ACCESS; flags", int(rd.Flags));
4142 return;
4143 }
4144 if (!desc || desc->ViewDimension != D3D12_UAV_DIMENSION_BUFFER) {
4145 log_once("unordered-access view of a buffer needs a buffer view description; dimension",
4146 desc ? int(desc->ViewDimension) : -1);
4147 return;
4148 }
4149 const D3D12_BUFFER_UAV& view = desc->Buffer;
4150 const bool structured = desc->Format == DXGI_FORMAT_UNKNOWN;
4151 const bool raw = desc->Format == DXGI_FORMAT_R32_TYPELESS && (view.Flags & D3D12_BUFFER_UAV_FLAG_RAW);
4152 const bool typed = !structured && !raw;
4153 std::uint32_t format_code = 0, element_bytes = 0;
4154 g::Swizzle channels = g::identity_swizzle;
4155 if (typed) {
4156 // D3D12: a typed view has no RAW flag; its format is one of the typed-UAV formats the layer can name.
4157 const Format mapped = vulkan_format(desc->Format, false);
4158 const auto* layout = mapped.format != VK_FORMAT_UNDEFINED && !mapped.typeless && !mapped.rgb96 &&
4159 !(view.Flags & D3D12_BUFFER_UAV_FLAG_RAW)
4160 ? leonida::uav_clear::layout(mapped.format)
4161 : nullptr;
4162 format_code = layout ? g::format_from_vulkan(mapped.format) : 0;
4163 if (!format_code || format_code >= 128) { // the V#'s FORMAT is 7 bits
4164 log_once("typed buffer unordered-access view format not supported; format", int(desc->Format));
4165 return;
4166 }
4167 element_bytes = layout->bytes;
4168 channels = g::format_swizzle(mapped.format);
4169 }
4170 const UINT64 unit = structured ? view.StructureByteStride : typed ? element_bytes : 4;
4171 if (!unit || unit > 0x3fff || view.FirstElement > rd.Width / unit ||
4172 (UINT64(view.FirstElement) + view.NumElements) > rd.Width / unit ||
4173 UINT64(view.NumElements) * (structured || typed ? 1 : 4) > ~0u) {
4174 log_once("unordered-access view of a buffer outside the resource or with a bad stride; elements",
4175 int(view.NumElements));
4176 return;
4177 }
4178 // D3D12: a counter belongs to a structured view and sits in a buffer that allows unordered access, 4096-byte
4179 // aligned with room for its 4 bytes; with no counter resource the offset is 0.
4180 if (counter || view.CounterOffsetInBytes) {
4181 const Resource* c = counter ? Resource::from<Resource>(counter) : nullptr;
4182 const bool valid = c && !c->image() && structured &&
4183 (c->desc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) &&
4184 !(view.CounterOffsetInBytes % D3D12_UAV_COUNTER_PLACEMENT_ALIGNMENT) &&
4185 UINT64(view.CounterOffsetInBytes) + 4 <= c->desc().Width;
4186 if (!valid) {
4187 log_once("unordered-access view counter refused (a structured view, a buffer that allows unordered "
4188 "access, a 4096-aligned offset inside it); offset",
4189 int(view.CounterOffsetInBytes));
4190 return;
4191 }
4192 }
4193 const UINT64 va = resource->GetGPUVirtualAddress();
4194 const UINT64 counter_va = counter ? counter->GetGPUVirtualAddress() : 0;
4195 if (!va || (counter && !counter_va)) return;
4196 g::Buffer buffer{};
4197 buffer.address = va + view.FirstElement * unit;
4198 buffer.stride = structured || typed ? std::uint32_t(unit) : 0;
4199 buffer.num_records = std::uint32_t(structured || typed ? view.NumElements : UINT64(view.NumElements) * 4);
4200 buffer.format = format_code;
4201 buffer.swizzle = channels;
4202 buffer.oob_select = typed ? g::OobSelect::structured
4203 : structured ? g::OobSelect::structured_with_offset : g::OobSelect::raw;
4204 const g::BufferWords words = g::encode(buffer);
4205 std::memcpy(reinterpret_cast<void*>(destination.ptr), words.data(), sizeof(words));
4206 if (counter) {
4207 g::Buffer counter_buffer{};
4208 counter_buffer.address = counter_va + view.CounterOffsetInBytes;
4209 counter_buffer.num_records = 4;
4210 counter_buffer.oob_select = g::OobSelect::raw;
4211 const g::BufferWords counter_words = g::encode(counter_buffer);
4212 std::memcpy(reinterpret_cast<char*>(destination.ptr) + sizeof(words), counter_words.data(),
4213 sizeof(counter_words));
4214 }
4215 }
4216
3960 // An unordered-access view of a texture is a T# too, of one mip; set 0 also holds it as a storage image. 4217 // An unordered-access view of a texture is a T# too, of one mip; set 0 also holds it as a storage image.
3961 void STDMETHODCALLTYPE CreateUnorderedAccessView(ID3D12Resource* resource, ID3D12Resource* counter, 4218 void STDMETHODCALLTYPE CreateUnorderedAccessView(ID3D12Resource* resource, ID3D12Resource* counter,
3962 const D3D12_UNORDERED_ACCESS_VIEW_DESC* desc, 4219 const D3D12_UNORDERED_ACCESS_VIEW_DESC* desc,
@@ -3969,7 +4226,11 @@ public:
3969 if (resource) stub("ID3D12Device::CreateUnorderedAccessView(resource from another device)"); 4226 if (resource) stub("ID3D12Device::CreateUnorderedAccessView(resource from another device)");
3970 return; 4227 return;
3971 } 4228 }
3972 if (!r->image() || counter) return stub("ID3D12Device::CreateUnorderedAccessView(buffer)"); 4229 if (!r->image()) return write_buffer_uav(resource, counter, desc, destination);
4230 if (counter) {
4231 log_once("unordered-access view of a texture with a counter resource; dimension", int(r->desc().Dimension));
4232 return;
4233 }
3973 if (!(r->desc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) { 4234 if (!(r->desc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) {
3974 log_once("unordered-access view of a texture created without ALLOW_UNORDERED_ACCESS; flags", 4235 log_once("unordered-access view of a texture created without ALLOW_UNORDERED_ACCESS; flags",
3975 int(r->desc().Flags)); 4236 int(r->desc().Flags));
@@ -4005,6 +4266,7 @@ public:
4005 return; 4266 return;
4006 } 4267 }
4007 write_image_descriptor(*r, view, destination, true); 4268 write_image_descriptor(*r, view, destination, true);
4269 state_.context->note_storage_image(r->id());
4008 } 4270 }
4009 4271
4010 // A sampler is an S# in the first 16 bytes of the slot; the shader finds the sampler by those four dwords. 4272 // A sampler is an S# in the first 16 bytes of the slot; the shader finds the sampler by those four dwords.
@@ -4238,7 +4500,11 @@ public:
4238 // 64 KiB-aligned offset is simply that offset into the arena, and its console VA is the heap's place plus it. 4500 // 64 KiB-aligned offset is simply that offset into the arena, and its console VA is the heap's place plus it.
4239 HRESULT STDMETHODCALLTYPE CreateHeap(const D3D12_HEAP_DESC* desc, REFIID riid, void** out) override { 4501 HRESULT STDMETHODCALLTYPE CreateHeap(const D3D12_HEAP_DESC* desc, REFIID riid, void** out) override {
4240 if (out) *out = nullptr; 4502 if (out) *out = nullptr;
4241 if (!desc || !desc->SizeInBytes) return E_INVALIDARG; 4503 if (!desc) return E_INVALIDARG;
4504 if (const char* why = heap_desc_refusal(*desc)) {
4505 log_once((std::string("CreateHeap refused (") + why + "), heap type").c_str(), int(desc->Properties.Type));
4506 return E_INVALIDARG;
4507 }
4242 if (!state_.arena.mapped) { 4508 if (!state_.arena.mapped) {
4243 log_once("heaps need the GPU address arena (bufferDeviceAddress); heap size in KiB:", 4509 log_once("heaps need the GPU address arena (bufferDeviceAddress); heap size in KiB:",
4244 int(desc->SizeInBytes / 1024)); 4510 int(desc->SizeInBytes / 1024));
@@ -4258,6 +4524,18 @@ public:
4258 return hand_out(heap, riid, out); 4524 return hand_out(heap, riid, out);
4259 } 4525 }
4260 4526
4527 // Device4: CreateHeap with a protected session, which is refused as CreateCommittedResource1 refuses one. The host
4528 // gives the same answers as CreateHeap for the D3D-238 descriptions.
4529 HRESULT STDMETHODCALLTYPE CreateHeap1(const D3D12_HEAP_DESC* desc, ID3D12ProtectedResourceSession* session,
4530 REFIID riid, void** out) override {
4531 if (out) *out = nullptr;
4532 if (session) {
4533 log_once("protected resource session refused (not supported) by CreateHeap1", 1);
4534 return E_INVALIDARG;
4535 }
4536 return CreateHeap(desc, riid, out);
4537 }
4538
4261 HRESULT STDMETHODCALLTYPE CreatePlacedResource(ID3D12Heap* heap_interface, UINT64 heap_offset, 4539 HRESULT STDMETHODCALLTYPE CreatePlacedResource(ID3D12Heap* heap_interface, UINT64 heap_offset,
4262 const D3D12_RESOURCE_DESC* desc, D3D12_RESOURCE_STATES, 4540 const D3D12_RESOURCE_DESC* desc, D3D12_RESOURCE_STATES,
4263 const D3D12_CLEAR_VALUE*, REFIID riid, void** out) override { 4541 const D3D12_CLEAR_VALUE*, REFIID riid, void** out) override {
@@ -4310,26 +4588,35 @@ public:
4310 return E_INVALIDARG; 4588 return E_INVALIDARG;
4311 } 4589 }
4312 const bool tiled = is_tiled_layout(desc->Layout); 4590 const bool tiled = is_tiled_layout(desc->Layout);
4591 const bool msaa = desc->SampleDesc.Count > 1;
4313 if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { 4592 if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) {
4593 if (heap->flags() & D3D12_HEAP_FLAG_DENY_BUFFERS) return E_INVALIDARG;
4314 if (desc->Layout != D3D12_TEXTURE_LAYOUT_ROW_MAJOR) return E_INVALIDARG; 4594 if (desc->Layout != D3D12_TEXTURE_LAYOUT_ROW_MAJOR) return E_INVALIDARG;
4315 if (desc->Width > heap->bytes() || heap_offset > heap->bytes() - desc->Width) return E_INVALIDARG; 4595 if (desc->Width > heap->bytes() || heap_offset > heap->bytes() - desc->Width) return E_INVALIDARG;
4316 } else if (heap_offset >= heap->bytes()) { 4596 } else {
4317 return E_INVALIDARG;
4318 }
4319 if (tiled) {
4320 if (heap->properties().Type == D3D12_HEAP_TYPE_UPLOAD || 4597 if (heap->properties().Type == D3D12_HEAP_TYPE_UPLOAD ||
4321 heap->properties().Type == D3D12_HEAP_TYPE_READBACK) 4598 heap->properties().Type == D3D12_HEAP_TYPE_READBACK)
4322 return E_INVALIDARG; 4599 return E_INVALIDARG;
4323 if (desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D && 4600 const bool rt_ds = (desc->Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET |
4324 desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D) 4601 D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)) != 0;
4325 return E_INVALIDARG; 4602 if (rt_ds && (heap->flags() & D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES)) return E_INVALIDARG;
4326 const D3D12_RESOURCE_ALLOCATION_INFO alloc = allocation(*desc); 4603 if (!rt_ds && (heap->flags() & D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES)) return E_INVALIDARG;
4327 if (alloc.SizeInBytes == UINT64_MAX || alloc.SizeInBytes > heap->bytes() || 4604 if (tiled || msaa) {
4328 heap_offset > heap->bytes() - alloc.SizeInBytes) 4605 if (tiled && desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D &&
4606 desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D)
4607 return E_INVALIDARG;
4608 if (msaa && desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) return E_INVALIDARG;
4609 const D3D12_RESOURCE_ALLOCATION_INFO alloc = allocation(*desc);
4610 if (alloc.SizeInBytes == UINT64_MAX || heap->alignment() < alloc.Alignment ||
4611 heap_offset % alloc.Alignment || alloc.SizeInBytes > heap->bytes() ||
4612 heap_offset > heap->bytes() - alloc.SizeInBytes)
4613 return E_INVALIDARG;
4614 if (tiled && static_cast<UINT>(desc->Layout) == kXboxTiledLayout) {
4615 log_once("placed resource with the Xbox tiled layout, as 64KB_UNDEFINED_SWIZZLE; dimension",
4616 int(desc->Dimension));
4617 }
4618 } else if (heap_offset >= heap->bytes()) {
4329 return E_INVALIDARG; 4619 return E_INVALIDARG;
4330 if (static_cast<UINT>(desc->Layout) == kXboxTiledLayout) {
4331 log_once("placed resource with the Xbox tiled layout, as 64KB_UNDEFINED_SWIZZLE; dimension",
4332 int(desc->Dimension));
4333 } 4620 }
4334 } 4621 }
4335 // Only buffers are addressable, as in D3D12: a placed texture keeps a null VA and its own Vulkan image. 4622 // Only buffers are addressable, as in D3D12: a placed texture keeps a null VA and its own Vulkan image.
@@ -4341,8 +4628,6 @@ public:
4341 hr = resource->create_placed_buffer(); 4628 hr = resource->create_placed_buffer();
4342 } else if (!tiled && desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) { 4629 } else if (!tiled && desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) {
4343 log_once("placed resource dimension not supported:", int(desc->Dimension)); 4630 log_once("placed resource dimension not supported:", int(desc->Dimension));
4344 } else if (desc->SampleDesc.Count > 1) {
4345 log_once("multisampled placed resource not supported; samples", int(desc->SampleDesc.Count));
4346 } else { 4631 } else {
4347 hr = S_OK; 4632 hr = S_OK;
4348 const Format format = state_.texture_format(*desc); 4633 const Format format = state_.texture_format(*desc);
@@ -5109,21 +5394,19 @@ private:
5109 D3D12_RESOURCE_DESC resolved = desc; 5394 D3D12_RESOURCE_DESC resolved = desc;
5110 if (!resolved.MipLevels) resolved.MipLevels = full; 5395 if (!resolved.MipLevels) resolved.MipLevels = full;
5111 if (resolved.MipLevels > full) return kInvalidAllocation; 5396 if (resolved.MipLevels > full) return kInvalidAllocation;
5112 if (samples > 1 && (volume || one_d || resolved.MipLevels != 1 || 5397 const bool depth_stencil = desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
5398 if (samples > 1 && (volume || one_d || resolved.MipLevels != 1 || !(desc.Flags & attachment) ||
5399 (desc.Flags & attachment) == attachment ||
5113 (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS))) 5400 (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)))
5114 return kInvalidAllocation; 5401 return kInvalidAllocation;
5115 // The PC runtime: simultaneous access only single-sampled and without depth-stencil, and no volume depth. 5402 // The PC runtime: simultaneous access only single-sampled and without depth-stencil, and no volume depth.
5116 const bool depth_stencil = desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
5117 if (((desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) && (depth_stencil || samples > 1)) || 5403 if (((desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) && (depth_stencil || samples > 1)) ||
5118 (volume && depth_stencil)) 5404 (volume && depth_stencil))
5119 return kInvalidAllocation; 5405 return kInvalidAllocation;
5120 const bool tiled = is_tiled_layout(desc.Layout); 5406 const bool tiled = is_tiled_layout(desc.Layout);
5121 if (tiled) { 5407 if (tiled) {
5122 if (one_d) return kInvalidAllocation; 5408 if (one_d || (samples > 1 && samples != 4)) return kInvalidAllocation;
5123 if (desc.Alignment && desc.Alignment != align_64k) return kInvalidAllocation; 5409 if (desc.Alignment && desc.Alignment != align_64k) return kInvalidAllocation;
5124 // Tiled MSAA is 4x single-mip 2D attachment only (measured on RTX 5070 Ti and WARP).
5125 if (samples > 1 && (samples != 4 || !(desc.Flags & attachment) || (desc.Flags & attachment) == attachment))
5126 return kInvalidAllocation;
5127 } else if (desc.Layout != D3D12_TEXTURE_LAYOUT_UNKNOWN) { 5410 } else if (desc.Layout != D3D12_TEXTURE_LAYOUT_UNKNOWN) {
5128 log_once("GetResourceAllocationInfo layout as UNKNOWN:", desc.Layout); 5411 log_once("GetResourceAllocationInfo layout as UNKNOWN:", desc.Layout);
5129 } 5412 }
@@ -5186,12 +5469,10 @@ private:
5186 if (!image_descriptor(resource, view, image)) return; 5469 if (!image_descriptor(resource, view, image)) return;
5187 const leonida::gfx10::ImageWords words = leonida::gfx10::encode(image); 5470 const leonida::gfx10::ImageWords words = leonida::gfx10::encode(image);
5188 const bool registered = state_.bind_image(words, image, resource.image(), resource.format(), 5471 const bool registered = state_.bind_image(words, image, resource.image(), resource.format(),
5189 resource.aspects(), storage, false, 5472 resource.aspects(), storage, resource.has_view_format_list(),
5190 resource.r9g9b9e5_as_r32_uint()); 5473 resource.r9g9b9e5_as_r32_uint());
5191 if (leonida::gfx10::multisampled(image.type) && !registered) return; 5474 if (leonida::gfx10::multisampled(image.type) && !registered) return;
5192 std::memcpy(reinterpret_cast<void*>(destination.ptr), words.data(), sizeof(words)); 5475 std::memcpy(reinterpret_cast<void*>(destination.ptr), words.data(), sizeof(words));
5193 state_.bind_image(words, image, resource.image(), resource.format(), resource.aspects(), storage,
5194 resource.has_view_format_list(), resource.r9g9b9e5_as_r32_uint());
5195 } 5476 }
5196 5477
5197 // Shared by CreateCommittedResource and CreateCommittedResource3. A castable-format list is only meaningful on 5478 // Shared by CreateCommittedResource and CreateCommittedResource3. A castable-format list is only meaningful on
@@ -5741,7 +6022,8 @@ HRESULT create_dxgi_factory(ID3D12Device* device, REFIID riid, void** out) {
5741 i.queue_family, riid, out); 6022 i.queue_family, riid, out);
5742} 6023}
5743 6024
5744// Creates its own Vulkan 1.3 instance and device. LEONIDA_VK_VALIDATION=1 adds VK_LAYER_KHRONOS_validation. 6025// Creates its own Vulkan instance and a Vulkan 1.3 device, or a 1.2 device with VK_KHR_dynamic_rendering and
6026// VK_KHR_synchronization2 (vulkan13_features.h). LEONIDA_VK_VALIDATION=1 adds VK_LAYER_KHRONOS_validation.
5745HRESULT create_vulkan_device_standalone(REFIID riid, void** out) { 6027HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
5746 if (!out) return E_POINTER; 6028 if (!out) return E_POINTER;
5747 *out = nullptr; 6029 *out = nullptr;
@@ -5854,22 +6136,21 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
5854 bool chosen_bc = false; 6136 bool chosen_bc = false;
5855 VkPhysicalDeviceFeatures chosen_features{}; 6137 VkPhysicalDeviceFeatures chosen_features{};
5856 VkPhysicalDeviceVulkan12Features chosen12{}; 6138 VkPhysicalDeviceVulkan12Features chosen12{};
5857 VkPhysicalDeviceVulkan13Features chosen13{};
5858 bool chosen_draw_params = false; 6139 bool chosen_draw_params = false;
6140 leonida::Vulkan13Features v13, candidate13;
5859 for (VkPhysicalDevice candidate : physicals) { 6141 for (VkPhysicalDevice candidate : physicals) {
5860 VkPhysicalDeviceProperties props{}; 6142 VkPhysicalDeviceProperties props{};
5861 vkGetPhysicalDeviceProperties(candidate, &props); 6143 vkGetPhysicalDeviceProperties(candidate, &props);
5862 if (props.apiVersion < VK_API_VERSION_1_3 || !leonida::vulkan_device_wanted(props.deviceName)) continue; 6144 if (!leonida::vulkan_device_wanted(props.deviceName)) continue;
5863 VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; 6145 candidate13.query(candidate, props.apiVersion, vkGetPhysicalDeviceFeatures2, vkEnumerateDeviceExtensionProperties);
5864 VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &f13}; 6146 if (!candidate13.usable()) continue;
6147 VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES};
5865 VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &f11}; 6148 VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &f11};
5866 VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f12}; 6149 VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f12};
5867 vkGetPhysicalDeviceFeatures2(candidate, &features); 6150 vkGetPhysicalDeviceFeatures2(candidate, &features);
5868 const bool bc = features.features.textureCompressionBC; 6151 const bool bc = features.features.textureCompressionBC;
5869 const bool draw_params = f11.shaderDrawParameters; 6152 const bool draw_params = f11.shaderDrawParameters;
5870 if (!f13.dynamicRendering || !f13.synchronization2 || !f12.timelineSemaphore || 6153 if (!f12.timelineSemaphore || !f12.separateDepthStencilLayouts || !f12.bufferDeviceAddress) continue;
5871 !f12.separateDepthStencilLayouts || !f12.bufferDeviceAddress)
5872 continue;
5873 std::uint32_t family_count = 0; 6154 std::uint32_t family_count = 0;
5874 vkGetPhysicalDeviceQueueFamilyProperties(candidate, &family_count, nullptr); 6155 vkGetPhysicalDeviceQueueFamilyProperties(candidate, &family_count, nullptr);
5875 std::vector<VkQueueFamilyProperties> families(family_count); 6156 std::vector<VkQueueFamilyProperties> families(family_count);
@@ -5883,18 +6164,22 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
5883 chosen_bc = bc; 6164 chosen_bc = bc;
5884 chosen_features = features.features; 6165 chosen_features = features.features;
5885 chosen12 = f12; 6166 chosen12 = f12;
5886 chosen13 = f13;
5887 chosen_draw_params = draw_params; 6167 chosen_draw_params = draw_params;
6168 v13.choose(candidate13);
5888 } 6169 }
5889 break; 6170 break;
5890 } 6171 }
5891 } 6172 }
5892 if (!info.physical) 6173 if (!info.physical)
5893 return fail(leonida::vulkan_device_filter().empty() 6174 return fail(leonida::vulkan_device_filter().empty()
5894 ? "no Vulkan 1.3 GPU with dynamicRendering, synchronization2, timelineSemaphore and " 6175 ? "no Vulkan 1.3 GPU (or 1.2 with VK_KHR_dynamic_rendering and VK_KHR_synchronization2) with "
5895 "separateDepthStencilLayouts" 6176 "dynamicRendering, synchronization2, timelineSemaphore and separateDepthStencilLayouts"
5896 : "no GPU named by LEONIDA_VK_DEVICE has Vulkan 1.3 with dynamicRendering, synchronization2, " 6177 : "no GPU named by LEONIDA_VK_DEVICE has Vulkan 1.3 (or 1.2 with VK_KHR_dynamic_rendering and "
5897 "timelineSemaphore and separateDepthStencilLayouts"); 6178 "VK_KHR_synchronization2) with dynamicRendering, synchronization2, timelineSemaphore and "
6179 "separateDepthStencilLayouts");
6180 if (!v13.core)
6181 std::fprintf(stderr, "[rt] d3d12: Vulkan 1.2 device: dynamicRendering and synchronization2 through their KHR "
6182 "extensions\n");
5898 6183
5899 // VK_EXT_conditional_rendering for SetPredication, VK_KHR_swapchain for DXGI presentation, and optional 6184 // VK_EXT_conditional_rendering for SetPredication, VK_KHR_swapchain for DXGI presentation, and optional
5900 // VK_KHR_acceleration_structure + VK_KHR_ray_query for hardware BVH builds (BLAS + TLAS). 6185 // VK_KHR_acceleration_structure + VK_KHR_ray_query for hardware BVH builds (BLAS + TLAS).
@@ -5964,17 +6249,13 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
5964 ext_chain = &enable_conditional; 6249 ext_chain = &enable_conditional;
5965 } 6250 }
5966 6251
5967 VkPhysicalDeviceVulkan13Features enable13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, ext_chain};
5968 enable13.dynamicRendering = VK_TRUE;
5969 enable13.synchronization2 = VK_TRUE;
5970 // Subgroup size control: a pipeline stage asks for the size its shader was translated for (src/subgroup_size.h). 6252 // Subgroup size control: a pipeline stage asks for the size its shader was translated for (src/subgroup_size.h).
5971 enable13.subgroupSizeControl = chosen13.subgroupSizeControl; 6253 leonida::query_subgroup_size_caps(vkGetPhysicalDeviceProperties2, info.physical, v13.subgroup_size_control,
5972 enable13.computeFullSubgroups = chosen13.computeFullSubgroups; 6254 v13.compute_full_subgroups, info.subgroup);
5973 leonida::query_subgroup_size_caps(vkGetPhysicalDeviceProperties2, info.physical, chosen13.subgroupSizeControl,
5974 chosen13.computeFullSubgroups, info.subgroup);
5975 // Translated vertex shaders read BaseVertex / BaseInstance (SPIR-V DrawParameters) to give v0 / v3 the 6255 // Translated vertex shaders read BaseVertex / BaseInstance (SPIR-V DrawParameters) to give v0 / v3 the
5976 // hardware's zero-based vertex and instance ids (docs/design.md, Inputs and outputs). 6256 // hardware's zero-based vertex and instance ids (docs/design.md, Inputs and outputs).
5977 VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &enable13}; 6257 VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
6258 v13.enable(ext_chain)};
5978 enable11.shaderDrawParameters = chosen_draw_params ? VK_TRUE : VK_FALSE; 6259 enable11.shaderDrawParameters = chosen_draw_params ? VK_TRUE : VK_FALSE;
5979 if (!chosen_draw_params) std::fprintf(stderr, "[rt] d3d12: the GPU has no shaderDrawParameters\n"); 6260 if (!chosen_draw_params) std::fprintf(stderr, "[rt] d3d12: the GPU has no shaderDrawParameters\n");
5980 VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; 6261 VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11};
@@ -6047,8 +6328,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6047 vkGetPhysicalDeviceFeatures2(info.physical, &query); 6328 vkGetPhysicalDeviceFeatures2(info.physical, &query);
6048 info.image_view_min_lod = min_lod.minLod == VK_TRUE; 6329 info.image_view_min_lod = min_lod.minLod == VK_TRUE;
6049 if (info.image_view_min_lod) { 6330 if (info.image_view_min_lod) {
6050 min_lod.pNext = enable13.pNext; 6331 min_lod.pNext = *v13.next();
6051 enable13.pNext = &min_lod; 6332 *v13.next() = &min_lod;
6052 } 6333 }
6053 } 6334 }
6054 VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT}; 6335 VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT};
@@ -6059,8 +6340,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6059 const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; 6340 const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME;
6060 info.host_image_copy = has_host_image_copy && host_copy.hostImageCopy; 6341 info.host_image_copy = has_host_image_copy && host_copy.hostImageCopy;
6061 if (info.host_image_copy) { 6342 if (info.host_image_copy) {
6062 host_copy.pNext = enable13.pNext; // after the conditional rendering features, if any 6343 host_copy.pNext = *v13.next(); // after the conditional rendering features, if any
6063 enable13.pNext = &host_copy; 6344 *v13.next() = &host_copy;
6064 } else { 6345 } else {
6065 std::fprintf(stderr, "[rt] d3d12: no VK_EXT_host_image_copy; CPU texture copies use a staging submit\n"); 6346 std::fprintf(stderr, "[rt] d3d12: no VK_EXT_host_image_copy; CPU texture copies use a staging submit\n");
6066 } 6347 }
@@ -6077,8 +6358,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6077 vkGetPhysicalDeviceFeatures2(info.physical, &query); 6358 vkGetPhysicalDeviceFeatures2(info.physical, &query);
6078 info.shader_fma = shader_fma.shaderFmaFloat32 == VK_TRUE; 6359 info.shader_fma = shader_fma.shaderFmaFloat32 == VK_TRUE;
6079 if (info.shader_fma) { 6360 if (info.shader_fma) {
6080 shader_fma.pNext = enable13.pNext; 6361 shader_fma.pNext = *v13.next();
6081 enable13.pNext = &shader_fma; 6362 *v13.next() = &shader_fma;
6082 } 6363 }
6083 } 6364 }
6084#endif 6365#endif
@@ -6113,9 +6394,10 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6113 // Switching a vsync swapchain to IMMEDIATE or FIFO_RELAXED per present (PresentX's ImmediateThresholdPercent): 6394 // Switching a vsync swapchain to IMMEDIATE or FIFO_RELAXED per present (PresentX's ImmediateThresholdPercent):
6114 // the KHR extension (promoted from the EXT one, same structures) with the surface extension of the same name 6395 // the KHR extension (promoted from the EXT one, same structures) with the surface extension of the same name
6115 // on the instance, else the EXT one. Only enabled where the instance has the surface half and the GPU the feature. 6396 // on the instance, else the EXT one. Only enabled where the instance has the surface half and the GPU the feature.
6397 const char* swapchain_m1_name = nullptr;
6398#if defined(VK_KHR_swapchain_maintenance1)
6116 VkPhysicalDeviceSwapchainMaintenance1FeaturesKHR swapchain_m1{ 6399 VkPhysicalDeviceSwapchainMaintenance1FeaturesKHR swapchain_m1{
6117 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_KHR}; 6400 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_KHR};
6118 const char* swapchain_m1_name = nullptr;
6119 if (has_swapchain && instance_has_surface) { 6401 if (has_swapchain && instance_has_surface) {
6120 const auto device_has = [&](const char* name) { 6402 const auto device_has = [&](const char* name) {
6121 return std::any_of(extensions.begin(), extensions.end(), 6403 return std::any_of(extensions.begin(), extensions.end(),
@@ -6129,13 +6411,14 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6129 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; 6411 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1};
6130 vkGetPhysicalDeviceFeatures2(info.physical, &query); 6412 vkGetPhysicalDeviceFeatures2(info.physical, &query);
6131 if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { 6413 if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) {
6132 swapchain_m1.pNext = enable13.pNext; 6414 swapchain_m1.pNext = *v13.next();
6133 enable13.pNext = &swapchain_m1; 6415 *v13.next() = &swapchain_m1;
6134 } else { 6416 } else {
6135 swapchain_m1_name = nullptr; 6417 swapchain_m1_name = nullptr;
6136 } 6418 }
6137 } 6419 }
6138 } 6420 }
6421#endif
6139 info.swapchain_maintenance1 = swapchain_m1_name != nullptr; 6422 info.swapchain_maintenance1 = swapchain_m1_name != nullptr;
6140 6423
6141 VkDeviceCreateInfo device_info{VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, &enable12}; 6424 VkDeviceCreateInfo device_info{VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, &enable12};
@@ -6143,6 +6426,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6143 device_info.pQueueCreateInfos = &queue_info; 6426 device_info.pQueueCreateInfos = &queue_info;
6144 device_info.pEnabledFeatures = &enable; 6427 device_info.pEnabledFeatures = &enable;
6145 std::vector<const char*> device_extensions; 6428 std::vector<const char*> device_extensions;
6429 v13.add_extensions(device_extensions);
6146 if (info.image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); 6430 if (info.image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME);
6147 if (info.conditional_rendering) device_extensions.push_back(conditional_extension); 6431 if (info.conditional_rendering) device_extensions.push_back(conditional_extension);
6148 if (info.host_image_copy) device_extensions.push_back(host_image_copy_name); 6432 if (info.host_image_copy) device_extensions.push_back(host_image_copy_name);
@@ -6196,4 +6480,29 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out) {
6196 return hand_out(device, riid, out); 6480 return hand_out(device, riid, out);
6197} 6481}
6198 6482
6483bool has_global_realtime_privilege() {
6484 const int override_state = g_global_realtime_privilege_override.load(std::memory_order_relaxed);
6485 if (override_state >= 0) return override_state != 0;
6486 HANDLE token = nullptr;
6487 if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &token) &&
6488 !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
6489 return false;
6490 LUID luid{};
6491 BOOL enabled = FALSE;
6492 if (LookupPrivilegeValueW(nullptr, L"SeIncreaseBasePriorityPrivilege", &luid)) {
6493 PRIVILEGE_SET set{};
6494 set.PrivilegeCount = 1;
6495 set.Control = PRIVILEGE_SET_ALL_NECESSARY;
6496 set.Privilege[0].Luid = luid;
6497 set.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
6498 if (!PrivilegeCheck(token, &set, &enabled)) enabled = FALSE;
6499 }
6500 CloseHandle(token);
6501 return enabled != FALSE;
6502}
6503
6504void set_global_realtime_privilege_override_for_test(int state) {
6505 g_global_realtime_privilege_override.store(state, std::memory_order_relaxed);
6506}
6507
6199} // namespace rt::d3d12 6508} // namespace rt::d3d12
diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp
index 57cd292c7..65a4f3995 100644
--- a/runtime/shims/d3d12_xs_device.cpp
+++ b/runtime/shims/d3d12_xs_device.cpp
@@ -388,18 +388,29 @@ HRESULT create_heap_proxy(ID3D12DescriptorHeap* real, DeviceProxy* device, REFII
388// 388//
389// QueryInterface answers only the interfaces the proxy models (the base chain and its own interface, Fence1 when 389// QueryInterface answers only the interfaces the proxy models (the base chain and its own interface, Fence1 when
390// the real fence has it), like the device and heap proxies, so the COM identity holds and no real object leaks to 390// the real fence has it), like the device and heap proxies, so the COM identity holds and no real object leaks to
391// the title. Leonida's own code reaches the real object through queue_proxy_real_queue / fence_proxy_real_fence. 391// the title. Leonida's own code reaches the real object through queue_proxy_real_queue / fence_proxy_real_fence /
392// allocator_proxy_real_allocator.
393//
394// Command allocators (device slot 9) are the third kind: their public chain is 9 slots (Reset at 8). Slot 9 wraps
395// only an allocator that answers kLeonidaCommandAllocatorTag, because a list takes the title's allocator in
396// CreateCommandList and Reset and only the Vulkan layer's lists resolve a proxy there (CommandAllocator::from);
397// a PC runtime allocator is handed out unchanged until a command-list proxy unwraps it at Reset.
392 398
393enum class ChildKind { queue, fence }; 399enum class ChildKind { queue, fence, allocator };
394 400
395constexpr unsigned kQueueSlots = 128; // the table: 19 public slots plus a refused tail 401constexpr unsigned kQueueSlots = 128; // the table: 19 public slots plus a refused tail
396constexpr unsigned kFenceSlots = 64; // the table: 12 public slots plus a refused tail 402constexpr unsigned kFenceSlots = 64; // the table: 12 public slots plus a refused tail
397constexpr unsigned kQueuePublicSlots = 19; // ID3D12CommandQueue 403constexpr unsigned kQueuePublicSlots = 19; // ID3D12CommandQueue
398constexpr unsigned kFencePublicSlots = 11; // ID3D12Fence 404constexpr unsigned kFencePublicSlots = 11; // ID3D12Fence
399constexpr unsigned kFence1PublicSlots = 12; // ID3D12Fence1 405constexpr unsigned kFence1PublicSlots = 12; // ID3D12Fence1
406constexpr unsigned kAllocatorSlots = 64; // the table: 9 public slots plus a refused tail
407constexpr unsigned kAllocatorPublicSlots = 9; // ID3D12CommandAllocator: the base chain and Reset (slot 8)
400constexpr SIZE_T kTableRegion = 64 * 1024; // one allocation granule: the table page plus 15 never-committed pages 408constexpr SIZE_T kTableRegion = 64 * 1024; // one allocation granule: the table page plus 15 never-committed pages
401static_assert(kQueueSlots > kQueuePublicSlots && kFenceSlots > kFence1PublicSlots, "the tables need a tail"); 409static_assert(kQueueSlots > kQueuePublicSlots && kFenceSlots > kFence1PublicSlots &&
402static_assert(kQueueSlots * sizeof(void*) <= 4096 && kFenceSlots * sizeof(void*) <= 4096, 410 kAllocatorSlots > kAllocatorPublicSlots,
411 "the tables need a tail");
412static_assert(kQueueSlots * sizeof(void*) <= 4096 && kFenceSlots * sizeof(void*) <= 4096 &&
413 kAllocatorSlots * sizeof(void*) <= 4096,
403 "a table must fit in the first page of its reservation"); 414 "a table must fit in the first page of its reservation");
404 415
405constexpr unsigned kQueueSignal = 14, kQueueWait = 15; // (ID3D12Fence*, UINT64) 416constexpr unsigned kQueueSignal = 14, kQueueWait = 15; // (ID3D12Fence*, UINT64)
@@ -415,7 +426,9 @@ struct ChildProxy {
415 426
416template <ChildKind K> 427template <ChildKind K>
417struct ChildStats { 428struct ChildStats {
418 static constexpr unsigned kSlots = K == ChildKind::queue ? kQueueSlots : kFenceSlots; 429 static constexpr unsigned kSlots = K == ChildKind::queue ? kQueueSlots
430 : K == ChildKind::fence ? kFenceSlots
431 : kAllocatorSlots;
419 static inline std::atomic<std::uint64_t> hits[kSlots]; 432 static inline std::atomic<std::uint64_t> hits[kSlots];
420 static inline std::atomic<bool> first[kSlots]; 433 static inline std::atomic<bool> first[kSlots];
421 static inline std::atomic<bool> beyond_warned[kSlots]; 434 static inline std::atomic<bool> beyond_warned[kSlots];
@@ -426,7 +439,7 @@ struct ChildStats {
426 439
427template <ChildKind K> 440template <ChildKind K>
428constexpr const char* child_kind_name() { 441constexpr const char* child_kind_name() {
429 return K == ChildKind::queue ? "queue" : "fence"; 442 return K == ChildKind::queue ? "queue" : K == ChildKind::fence ? "fence" : "allocator";
430} 443}
431 444
432template <ChildKind K> 445template <ChildKind K>
@@ -441,8 +454,10 @@ const char* child_public_name(unsigned slot) {
441 if (slot < 8) return object[slot]; 454 if (slot < 8) return object[slot];
442 if constexpr (K == ChildKind::queue) { 455 if constexpr (K == ChildKind::queue) {
443 if (slot < kQueuePublicSlots) return queue[slot - 8]; 456 if (slot < kQueuePublicSlots) return queue[slot - 8];
444 } else { 457 } else if constexpr (K == ChildKind::fence) {
445 if (slot < kFence1PublicSlots) return fence[slot - 8]; 458 if (slot < kFence1PublicSlots) return fence[slot - 8];
459 } else {
460 if (slot == 8) return "Reset";
446 } 461 }
447 return nullptr; 462 return nullptr;
448} 463}
@@ -454,7 +469,9 @@ template <ChildKind K>
454const char* child_trace_name(unsigned slot) { 469const char* child_trace_name(unsigned slot) {
455 static const auto names = [] { 470 static const auto names = [] {
456 static char storage[ChildStats<K>::kSlots][64]; 471 static char storage[ChildStats<K>::kSlots][64];
457 const char* iface = K == ChildKind::queue ? "XboxID3D12CommandQueue" : "XboxID3D12Fence"; 472 const char* iface = K == ChildKind::queue ? "XboxID3D12CommandQueue"
473 : K == ChildKind::fence ? "XboxID3D12Fence"
474 : "XboxID3D12CommandAllocator";
458 for (unsigned s = 0; s < ChildStats<K>::kSlots; ++s) { 475 for (unsigned s = 0; s < ChildStats<K>::kSlots; ++s) {
459 const char* method = child_public_name<K>(s); 476 const char* method = child_public_name<K>(s);
460 if (method) 477 if (method)
@@ -528,8 +545,10 @@ bool is_child_iid(const IID& iid) {
528 return true; 545 return true;
529 if constexpr (K == ChildKind::queue) { 546 if constexpr (K == ChildKind::queue) {
530 return IsEqualIID(iid, __uuidof(ID3D12CommandQueue)); 547 return IsEqualIID(iid, __uuidof(ID3D12CommandQueue));
531 } else { 548 } else if constexpr (K == ChildKind::fence) {
532 return IsEqualIID(iid, __uuidof(ID3D12Fence)) || IsEqualIID(iid, __uuidof(ID3D12Fence1)); 549 return IsEqualIID(iid, __uuidof(ID3D12Fence)) || IsEqualIID(iid, __uuidof(ID3D12Fence1));
550 } else {
551 return IsEqualIID(iid, __uuidof(ID3D12CommandAllocator));
533 } 552 }
534} 553}
535 554
@@ -608,7 +627,8 @@ IUnknown* proxy_real_object(const void* object) {
608 void* const vtable = *reinterpret_cast<void* const*>(object); 627 void* const vtable = *reinterpret_cast<void* const*>(object);
609 if (vtable == reinterpret_cast<void*>(get_heap_vtable())) return static_cast<const HeapProxy*>(object)->real; 628 if (vtable == reinterpret_cast<void*>(get_heap_vtable())) return static_cast<const HeapProxy*>(object)->real;
610 if (vtable == reinterpret_cast<void*>(get_child_vtable<ChildKind::queue>()) || 629 if (vtable == reinterpret_cast<void*>(get_child_vtable<ChildKind::queue>()) ||
611 vtable == reinterpret_cast<void*>(get_child_vtable<ChildKind::fence>())) 630 vtable == reinterpret_cast<void*>(get_child_vtable<ChildKind::fence>()) ||
631 vtable == reinterpret_cast<void*>(get_child_vtable<ChildKind::allocator>()))
612 return static_cast<const ChildProxy*>(object)->real; 632 return static_cast<const ChildProxy*>(object)->real;
613 return nullptr; 633 return nullptr;
614} 634}
@@ -685,6 +705,7 @@ LONG CALLBACK table_overrun_handler(EXCEPTION_POINTERS* info) {
685 const auto address = static_cast<std::uintptr_t>(record->ExceptionInformation[1]); 705 const auto address = static_cast<std::uintptr_t>(record->ExceptionInformation[1]);
686 report_table_overrun<ChildKind::queue>(address); 706 report_table_overrun<ChildKind::queue>(address);
687 report_table_overrun<ChildKind::fence>(address); 707 report_table_overrun<ChildKind::fence>(address);
708 report_table_overrun<ChildKind::allocator>(address);
688 } 709 }
689 return EXCEPTION_CONTINUE_SEARCH; // diagnostics only: the fault goes on to the title's handlers or the crash 710 return EXCEPTION_CONTINUE_SEARCH; // diagnostics only: the fault goes on to the title's handlers or the crash
690} 711}
@@ -803,8 +824,10 @@ HRESULT wrap_child(IUnknown* created, DeviceProxy* device, const IID* riid, void
803 proxy->real_vtable = *reinterpret_cast<void***>(created); 824 proxy->real_vtable = *reinterpret_cast<void***>(created);
804 if constexpr (K == ChildKind::queue) { 825 if constexpr (K == ChildKind::queue) {
805 proxy->slot_count = kQueuePublicSlots; 826 proxy->slot_count = kQueuePublicSlots;
806 } else { 827 } else if constexpr (K == ChildKind::fence) {
807 proxy->slot_count = supports_iid(created, __uuidof(ID3D12Fence1)) ? kFence1PublicSlots : kFencePublicSlots; 828 proxy->slot_count = supports_iid(created, __uuidof(ID3D12Fence1)) ? kFence1PublicSlots : kFencePublicSlots;
829 } else {
830 proxy->slot_count = kAllocatorPublicSlots;
808 } 831 }
809 proxy->refs.store(1, std::memory_order_relaxed); 832 proxy->refs.store(1, std::memory_order_relaxed);
810 proxy_add_ref(device); // the object keeps its Xbox-ABI device alive for GetDevice 833 proxy_add_ref(device); // the object keeps its Xbox-ABI device alive for GetDevice
@@ -894,6 +917,43 @@ HRESULT proxy_create_fence(DeviceProxy* self, std::uint64_t initial_value, std::
894 return wrap_child<ChildKind::fence>(static_cast<IUnknown*>(created), self, riid, out); 917 return wrap_child<ChildKind::fence>(static_cast<IUnknown*>(created), self, riid, out);
895} 918}
896 919
920// True when `allocator` is one whose consumers resolve allocator proxies: Leonida's own Vulkan-layer allocator,
921// whose lists (CreateCommandList, Reset) find the real allocator through allocator_proxy_real_allocator. A PC
922// runtime allocator does not answer the tag, and its lists would take a proxy for their own allocator.
923bool resolves_allocator_proxies(IUnknown* allocator) {
924 void* found = nullptr;
925 if (FAILED(allocator->QueryInterface(kLeonidaCommandAllocatorTag, &found)) || !found) return false;
926 static_cast<IUnknown*>(found)->Release(); // the implementation pointer starts with its IUnknown chain
927 return true;
928}
929
930// Device slot 9: CreateCommandAllocator(type, riid, out). An allocator proxy where the list side resolves it (see
931// resolves_allocator_proxies); any other allocator goes back unchanged, logged once, so the host runtime's lists
932// never see a proxy. Null output and null IID as slot 8.
933HRESULT proxy_create_command_allocator(DeviceProxy* self, std::uint64_t type, const IID* riid, void** out) {
934 note_slot(9);
935 if (out) *out = nullptr; // as slot 8
936 if (!riid) return E_POINTER;
937 const auto list_type = static_cast<D3D12_COMMAND_LIST_TYPE>(static_cast<std::uint32_t>(type));
938#pragma warning(suppress : 6387) // the caller's null output, on purpose (see slot 8)
939 if (!out) return self->real->CreateCommandAllocator(list_type, *riid, nullptr);
940 void* created = nullptr;
941 const HRESULT hr = self->real->CreateCommandAllocator(list_type, __uuidof(ID3D12CommandAllocator), &created);
942 if (FAILED(hr)) return hr;
943 if (!created) return E_FAIL;
944 auto* allocator = static_cast<IUnknown*>(created);
945 if (!resolves_allocator_proxies(allocator)) {
946 static std::atomic<bool> logged{false};
947 if (!logged.exchange(true, std::memory_order_relaxed))
948 std::fprintf(stderr, "[rt] d3d12_xs: allocators of this device are not wrapped: its command lists "
949 "cannot resolve an allocator proxy\n");
950 const HRESULT asked = allocator->QueryInterface(*riid, out);
951 allocator->Release();
952 return asked;
953 }
954 return wrap_child<ChildKind::allocator>(allocator, self, riid, out);
955}
956
897// Device slot 32: OpenSharedHandle(handle, riid, out). The object is opened as asked; when it is a fence (whatever 957// Device slot 32: OpenSharedHandle(handle, riid, out). The object is opened as asked; when it is a fence (whatever
898// interface was asked for, IUnknown included) the title gets a fence proxy, anything else (heaps, resources) is 958// interface was asked for, IUnknown included) the title gets a fence proxy, anything else (heaps, resources) is
899// returned unchanged. 959// returned unchanged.
@@ -981,6 +1041,61 @@ HRESULT proxy_create_compute_pipeline_state(DeviceProxy* self, const D3D12_COMPU
981 return self->real->CreateComputePipelineState(desc, *riid, out); 1041 return self->real->CreateComputePipelineState(desc, *riid, out);
982} 1042}
983 1043
1044// The Xbox slot 67 creates a compute pipeline from native GPU code: (desc, riid, out), named
1045// DeserializeComputePipelineStateX in amd_fidelityfx_upscaler_xbox.dll's messages (call at RVA 0x56d9). The desc
1046// passes the root signature at +0x00, followed by pointer/size pairs for the shader's FSPX entries (docs/fspx.md):
1047// kind 0 (dispatch state) at +0x08/+0x10, kind 1 at +0x18/+0x20, kind 6 (the RDNA2 program) at +0x28/+0x30, and
1048// kind 7 (records) at +0x38/+0x40. Translates the console description to a standard D3D12_COMPUTE_PIPELINE_STATE_DESC
1049// with CS bytecode pointing at kind 6 and routes it to CreateComputePipelineState on the PC device (slot 11), which
1050// on the Vulkan device resolves through the translator. The PC slot 67 is CreateProtectedResourceSession1.
1051HRESULT proxy_create_compute_pipeline_from_native_code(DeviceProxy* self, const void* desc,
1052 const IID* riid, void** out) {
1053 note_slot(67);
1054 if (!out) return E_POINTER;
1055 *out = nullptr;
1056 if (!desc) return E_INVALIDARG;
1057 if (!riid) return E_POINTER;
1058
1059 // FSPX description layout (docs/fspx.md §How the DLL reads it):
1060 struct XboxNativeComputePipelineStateDesc {
1061 ID3D12RootSignature* root_signature; // +0x00
1062 const void* kind0; // +0x08: dispatch state
1063 std::uint64_t kind0_size; // +0x10: 28 bytes
1064 const void* kind1; // +0x18: unknown
1065 std::uint64_t kind1_size; // +0x20: 20 bytes
1066 const void* kind6; // +0x28: RDNA2 program code
1067 std::uint64_t kind6_size; // +0x30: program size in bytes
1068 const void* kind7; // +0x38: resource/hash records
1069 std::uint64_t kind7_size; // +0x40: records size in bytes
1070 };
1071 const auto* xbox_desc = static_cast<const XboxNativeComputePipelineStateDesc*>(desc);
1072
1073 if (xbox_desc->kind0 || xbox_desc->kind0_size || xbox_desc->kind1 || xbox_desc->kind1_size ||
1074 xbox_desc->kind7 || xbox_desc->kind7_size) {
1075 static std::atomic<bool> logged{false};
1076 if (!logged.exchange(true, std::memory_order_relaxed)) {
1077 std::fprintf(stderr,
1078 "[rt] d3d12_xs: slot 67 FSPX metadata: kind0 0x%llx (%llu B), kind1 0x%llx (%llu B), kind7 0x%llx (%llu B)\n",
1079 static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(xbox_desc->kind0)),
1080 static_cast<unsigned long long>(xbox_desc->kind0_size),
1081 static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(xbox_desc->kind1)),
1082 static_cast<unsigned long long>(xbox_desc->kind1_size),
1083 static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(xbox_desc->kind7)),
1084 static_cast<unsigned long long>(xbox_desc->kind7_size));
1085 }
1086 }
1087
1088 D3D12_COMPUTE_PIPELINE_STATE_DESC pc_desc{};
1089 pc_desc.pRootSignature = xbox_desc->root_signature;
1090 pc_desc.CS.pShaderBytecode = xbox_desc->kind6;
1091 pc_desc.CS.BytecodeLength = static_cast<SIZE_T>(xbox_desc->kind6_size);
1092 pc_desc.NodeMask = 0;
1093 pc_desc.CachedPSO = {nullptr, 0};
1094 pc_desc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
1095
1096 return self->real->CreateComputePipelineState(&pc_desc, *riid, out);
1097}
1098
984HRESULT proxy_create_resource(DeviceProxy* self, const D3D12_HEAP_PROPERTIES* heap_properties, 1099HRESULT proxy_create_resource(DeviceProxy* self, const D3D12_HEAP_PROPERTIES* heap_properties,
985 D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC* xbox_desc, 1100 D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC* xbox_desc,
986 D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE* clear_value, 1101 D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE* clear_value,
@@ -1024,6 +1139,9 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64
1024 } else if constexpr (Slot == 8) { 1139 } else if constexpr (Slot == 8) {
1025 return hr_to_u64(proxy_create_command_queue(self, reinterpret_cast<const D3D12_COMMAND_QUEUE_DESC*>(a1), 1140 return hr_to_u64(proxy_create_command_queue(self, reinterpret_cast<const D3D12_COMMAND_QUEUE_DESC*>(a1),
1026 reinterpret_cast<const IID*>(a2), reinterpret_cast<void**>(a3))); 1141 reinterpret_cast<const IID*>(a2), reinterpret_cast<void**>(a3)));
1142 } else if constexpr (Slot == 9) {
1143 return hr_to_u64(proxy_create_command_allocator(self, a1, reinterpret_cast<const IID*>(a2),
1144 reinterpret_cast<void**>(a3)));
1027 } else if constexpr (Slot == 36) { 1145 } else if constexpr (Slot == 36) {
1028 return hr_to_u64(proxy_create_fence(self, a1, a2, reinterpret_cast<const IID*>(a3), 1146 return hr_to_u64(proxy_create_fence(self, a1, a2, reinterpret_cast<const IID*>(a3),
1029 reinterpret_cast<void**>(a4))); 1147 reinterpret_cast<void**>(a4)));
@@ -1044,18 +1162,9 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64
1044 self, reinterpret_cast<const D3D12_COMPUTE_PIPELINE_STATE_DESC*>(a1), a2, a3, 1162 self, reinterpret_cast<const D3D12_COMPUTE_PIPELINE_STATE_DESC*>(a1), a2, a3,
1045 reinterpret_cast<const IID*>(a4), reinterpret_cast<void**>(a5))); 1163 reinterpret_cast<const IID*>(a4), reinterpret_cast<void**>(a5)));
1046 } else if constexpr (Slot == 67) { 1164 } else if constexpr (Slot == 67) {
1047 // Measured in amd_fidelityfx_upscaler_xbox.dll (call at RVA 0x56d9): (desc, riid, out), named 1165 return hr_to_u64(proxy_create_compute_pipeline_from_native_code(
1048 // DeserializeComputePipelineStateX in the DLL's own messages. The desc is the root signature at +0x00, then 1166 self, reinterpret_cast<const void*>(a1), reinterpret_cast<const IID*>(a2),
1049 // pointer/size pairs for the shader's FSPX entries, with the native RDNA2 program at +0x28 (docs/fspx.md); 1167 reinterpret_cast<void**>(a3)));
1050 // the DLL falls back to slot 62 when it fails. The PC device's slot 67 is CreateProtectedResourceSession1, a
1051 // different method, so it is refused here, not forwarded.
1052 note_slot(67);
1053 static std::atomic<bool> logged{false};
1054 if (!logged.exchange(true, std::memory_order_relaxed))
1055 std::fprintf(stderr,
1056 "[rt] d3d12_xs: device slot 67 (Xbox DeserializeComputePipelineStateX) -> E_NOTIMPL\n");
1057 if (a3) *reinterpret_cast<void**>(a3) = nullptr;
1058 return hr_to_u64(E_NOTIMPL);
1059 } else if constexpr (Slot == 76) { 1168 } else if constexpr (Slot == 76) {
1060 return hr_to_u64(proxy_create_resource( 1169 return hr_to_u64(proxy_create_resource(
1061 self, reinterpret_cast<const D3D12_HEAP_PROPERTIES*>(a1), 1170 self, reinterpret_cast<const D3D12_HEAP_PROPERTIES*>(a1),
@@ -1186,13 +1295,19 @@ ID3D12Device* device_proxy_real_device(const void* device) {
1186} 1295}
1187 1296
1188bool device_slot_overridden(unsigned slot) { 1297bool device_slot_overridden(unsigned slot) {
1189 return slot <= 2 || slot == 8 || slot == 14 || slot == 31 || slot == 32 || slot == 34 || slot == 35 || 1298 return slot <= 2 || slot == 8 || slot == 9 || slot == 14 || slot == 31 || slot == 32 || slot == 34 || slot == 35 ||
1190 slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 || slot == 67 || 1299 slot == 36 || slot == 45 || slot == 46 || slot == 50 || slot == 62 || slot == 67 ||
1191 slot == 75 || slot == 76; 1300 slot == 75 || slot == 76;
1192} 1301}
1193 1302
1194bool is_queue_proxy(const void* queue) { return is_child_proxy<ChildKind::queue>(queue); } 1303bool is_queue_proxy(const void* queue) { return is_child_proxy<ChildKind::queue>(queue); }
1195bool is_fence_proxy(const void* fence) { return is_child_proxy<ChildKind::fence>(fence); } 1304bool is_fence_proxy(const void* fence) { return is_child_proxy<ChildKind::fence>(fence); }
1305bool is_allocator_proxy(const void* allocator) { return is_child_proxy<ChildKind::allocator>(allocator); }
1306
1307ID3D12CommandAllocator* allocator_proxy_real_allocator(const void* allocator) {
1308 if (!is_allocator_proxy(allocator)) return nullptr;
1309 return reinterpret_cast<ID3D12CommandAllocator*>(static_cast<const ChildProxy*>(allocator)->real);
1310}
1196 1311
1197ID3D12CommandQueue* queue_proxy_real_queue(const void* queue) { 1312ID3D12CommandQueue* queue_proxy_real_queue(const void* queue) {
1198 if (!is_queue_proxy(queue)) return nullptr; 1313 if (!is_queue_proxy(queue)) return nullptr;
@@ -1214,9 +1329,13 @@ unsigned fence_proxy_slot_count(const void* fence) {
1214 1329
1215unsigned queue_proxy_table_size() { return kQueueSlots; } 1330unsigned queue_proxy_table_size() { return kQueueSlots; }
1216unsigned fence_proxy_table_size() { return kFenceSlots; } 1331unsigned fence_proxy_table_size() { return kFenceSlots; }
1332unsigned allocator_proxy_table_size() { return kAllocatorSlots; }
1333unsigned allocator_proxy_slot_count(const void* allocator) {
1334 return is_allocator_proxy(allocator) ? static_cast<const ChildProxy*>(allocator)->slot_count : 0;
1335}
1217 1336
1218unsigned long command_object_proxy_ref_count(const void* object) { 1337unsigned long command_object_proxy_ref_count(const void* object) {
1219 if (!is_queue_proxy(object) && !is_fence_proxy(object)) return 0; 1338 if (!is_queue_proxy(object) && !is_fence_proxy(object) && !is_allocator_proxy(object)) return 0;
1220 return static_cast<const ChildProxy*>(object)->refs.load(std::memory_order_relaxed); 1339 return static_cast<const ChildProxy*>(object)->refs.load(std::memory_order_relaxed);
1221} 1340}
1222 1341
@@ -1251,8 +1370,24 @@ std::uint64_t fence_table_overruns() {
1251bool command_object_tables_guarded() { 1370bool command_object_tables_guarded() {
1252 get_child_vtable<ChildKind::queue>(); 1371 get_child_vtable<ChildKind::queue>();
1253 get_child_vtable<ChildKind::fence>(); 1372 get_child_vtable<ChildKind::fence>();
1373 get_child_vtable<ChildKind::allocator>();
1254 return ChildStats<ChildKind::queue>::table_end.load(std::memory_order_acquire) && 1374 return ChildStats<ChildKind::queue>::table_end.load(std::memory_order_acquire) &&
1255 ChildStats<ChildKind::fence>::table_end.load(std::memory_order_acquire); 1375 ChildStats<ChildKind::fence>::table_end.load(std::memory_order_acquire) &&
1376 ChildStats<ChildKind::allocator>::table_end.load(std::memory_order_acquire);
1377}
1378
1379std::uint64_t allocator_slot_hits(unsigned slot) {
1380 using S = ChildStats<ChildKind::allocator>;
1381 return slot < S::kSlots ? S::hits[slot].load(std::memory_order_relaxed) : 0;
1382}
1383
1384bool allocator_slot_first_call_seen(unsigned slot) {
1385 using S = ChildStats<ChildKind::allocator>;
1386 return slot < S::kSlots && S::first[slot].load(std::memory_order_relaxed);
1387}
1388
1389std::uint64_t allocator_table_overruns() {
1390 return ChildStats<ChildKind::allocator>::overruns.load(std::memory_order_relaxed);
1256} 1391}
1257 1392
1258bool heap_slot_overridden(unsigned slot) { 1393bool heap_slot_overridden(unsigned slot) {
@@ -1292,6 +1427,7 @@ void reset_device_proxy_stats() {
1292 } 1427 }
1293 reset_child_stats<ChildKind::queue>(); 1428 reset_child_stats<ChildKind::queue>();
1294 reset_child_stats<ChildKind::fence>(); 1429 reset_child_stats<ChildKind::fence>();
1430 reset_child_stats<ChildKind::allocator>();
1295} 1431}
1296 1432
1297} // namespace rt::d3d12_xs 1433} // namespace rt::d3d12_xs
diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h
index 510560516..12ac5a78f 100644
--- a/runtime/shims/d3d12_xs_device.h
+++ b/runtime/shims/d3d12_xs_device.h
@@ -3,6 +3,9 @@
3// Measured Xbox device deviations used here (vtable indices, x64): 3// Measured Xbox device deviations used here (vtable indices, x64):
4// slot 62 CreateComputePipelineState(desc, w2, w3, iid, out): two words (0 from XboxBvhBuilder, meaning unknown) 4// slot 62 CreateComputePipelineState(desc, w2, w3, iid, out): two words (0 from XboxBvhBuilder, meaning unknown)
5// before the IID. The PC slot 62 is CreateStateObject. 5// before the IID. The PC slot 62 is CreateStateObject.
6// slot 67 CreateComputePipelineState from native code (desc, iid, out): converts the Xbox native-code desc
7// (+0x00 root signature, +0x28 code, +0x30 size) to D3D12_COMPUTE_PIPELINE_STATE_DESC and forwards
8// to PC CreateComputePipelineState (slot 11). The PC slot 67 is CreateProtectedResourceSession1.
6// slot 76 resource creation -> PC CreateCommittedResource (PC slot 27), with the Xbox layout word ignored. 9// slot 76 resource creation -> PC CreateCommittedResource (PC slot 27), with the Xbox layout word ignored.
7// The measured slots 9/10 (GetCPU/GPUDescriptorHandleForHeapStart) are ID3D12DescriptorHeap methods, not device 10// The measured slots 9/10 (GetCPU/GPUDescriptorHandleForHeapStart) are ID3D12DescriptorHeap methods, not device
8// methods: the PC device's 9/10 are CreateCommandAllocator/CreateGraphicsPipelineState and are forwarded unchanged. 11// methods: the PC device's 9/10 are CreateCommandAllocator/CreateGraphicsPipelineState and are forwarded unchanged.
@@ -57,8 +60,9 @@ unsigned device_proxy_slot_count(const void* device);
57ID3D12Device* device_proxy_real_device(const void* device); 60ID3D12Device* device_proxy_real_device(const void* device);
58 61
59// True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue 62// True for slots the proxy handles itself rather than forwarding verbatim: IUnknown (0-2), 8 and 75 (queue
60// proxies), 14, 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 62, 67 and 76. 63// proxies), 9 (allocator proxies), 14, 31/34/35/45/46/50 (proxies unwrapped), 32 and 36 (fence proxies), 62, 67
61// Slots 9 and 10 are intentionally false; the handle conversion is on the heap proxy. 64// and 76. Slot 10 is intentionally false: the measured 9/10 handle conversion is on the heap proxy, and device
65// slot 9 is CreateCommandAllocator, which the proxy handles for the allocator proxy.
62bool device_slot_overridden(unsigned slot); 66bool device_slot_overridden(unsigned slot);
63 67
64// Queue and fence proxies created by device slots 8/75 and 36. The real_* accessors return the wrapped object 68// Queue and fence proxies created by device slots 8/75 and 36. The real_* accessors return the wrapped object
@@ -72,7 +76,7 @@ unsigned queue_proxy_slot_count(const void* queue);
72unsigned fence_proxy_slot_count(const void* fence); 76unsigned fence_proxy_slot_count(const void* fence);
73unsigned queue_proxy_table_size(); 77unsigned queue_proxy_table_size();
74unsigned fence_proxy_table_size(); 78unsigned fence_proxy_table_size();
75// Live references on a queue or fence proxy (0 for anything else). Test helper. 79// Live references on a queue, fence or allocator proxy (0 for anything else). Test helper.
76unsigned long command_object_proxy_ref_count(const void* object); 80unsigned long command_object_proxy_ref_count(const void* object);
77// Per-slot call counters and first-call flags, shared by all queue proxies and all fence proxies. 81// Per-slot call counters and first-call flags, shared by all queue proxies and all fence proxies.
78std::uint64_t queue_slot_hits(unsigned slot); 82std::uint64_t queue_slot_hits(unsigned slot);
@@ -82,8 +86,28 @@ bool fence_slot_first_call_seen(unsigned slot);
82// Vtable reads past a queue or fence proxy table that faulted in its guard region (counted by the fault logger). 86// Vtable reads past a queue or fence proxy table that faulted in its guard region (counted by the fault logger).
83std::uint64_t queue_table_overruns(); 87std::uint64_t queue_table_overruns();
84std::uint64_t fence_table_overruns(); 88std::uint64_t fence_table_overruns();
85// True when both tables sit in front of their guard region (false only if the reservation failed). 89// True when the queue, fence and allocator tables sit in front of their guard regions (false only if a reservation
90// or the fault logger failed).
86bool command_object_tables_guarded(); 91bool command_object_tables_guarded();
92
93// Command allocator proxies (device slot 9): the public chain (9 slots: the base chain and Reset) is forwarded, a
94// slot past it up to the end of the table (64 slots) is logged and refused with E_NOTIMPL, and a read past the
95// table faults in a guard region, as for queues and fences. The console allocator's extra methods are not
96// measured and not guessed. Slot 9 wraps only an allocator that answers kLeonidaCommandAllocatorTag, Leonida's
97// own Vulkan-layer allocator: its command lists resolve the proxy (CreateCommandList, Reset). A PC runtime
98// allocator goes back unchanged, because the PC runtime's lists would take a proxy for their own allocator; a
99// command-list proxy that unwraps at Reset is what lets the host backend wrap allocators too.
100// {7d0e6b51-34a2-4f0c-9a61-0c5b2e8f4a10}: the Vulkan layer's CommandAllocator answers it with its implementation.
101inline constexpr GUID kLeonidaCommandAllocatorTag{
102 0x7d0e6b51, 0x34a2, 0x4f0c, {0x9a, 0x61, 0x0c, 0x5b, 0x2e, 0x8f, 0x4a, 0x10}};
103bool is_allocator_proxy(const void* allocator);
104// The wrapped allocator (no reference added), or null when `allocator` is not an allocator proxy.
105ID3D12CommandAllocator* allocator_proxy_real_allocator(const void* allocator);
106unsigned allocator_proxy_slot_count(const void* allocator);
107unsigned allocator_proxy_table_size();
108std::uint64_t allocator_slot_hits(unsigned slot);
109bool allocator_slot_first_call_seen(unsigned slot);
110std::uint64_t allocator_table_overruns();
87// Heap slots 0-2, 7 (GetDevice -> device proxy) and 9/10 (handle conversion). 111// Heap slots 0-2, 7 (GetDevice -> device proxy) and 9/10 (handle conversion).
88bool heap_slot_overridden(unsigned slot); 112bool heap_slot_overridden(unsigned slot);
89 113
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp
index 17449fefc..caf09cee7 100644
--- a/runtime/shims/dxgi_com.cpp
+++ b/runtime/shims/dxgi_com.cpp
@@ -22,12 +22,14 @@ void stub(const char* method) {
22 if (seen.insert(method).second) std::fprintf(stderr, "[rt] dxgi: unimplemented %s\n", method); 22 if (seen.insert(method).second) std::fprintf(stderr, "[rt] dxgi: unimplemented %s\n", method);
23} 23}
24 24
25bool valid_flip_buffer_count(UINT count) {
26 return count >= 2 && count <= DXGI_MAX_SWAP_CHAIN_BUFFERS;
27}
28
25VkFormat dxgi_to_vk_format(DXGI_FORMAT fmt) { 29VkFormat dxgi_to_vk_format(DXGI_FORMAT fmt) {
26 switch (fmt) { 30 switch (fmt) {
27 case DXGI_FORMAT_B8G8R8A8_UNORM: return VK_FORMAT_B8G8R8A8_UNORM; 31 case DXGI_FORMAT_B8G8R8A8_UNORM: return VK_FORMAT_B8G8R8A8_UNORM;
28 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
29 case DXGI_FORMAT_R8G8B8A8_UNORM: return VK_FORMAT_R8G8B8A8_UNORM; 32 case DXGI_FORMAT_R8G8B8A8_UNORM: return VK_FORMAT_R8G8B8A8_UNORM;
30 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
31 case DXGI_FORMAT_R10G10B10A2_UNORM: return VK_FORMAT_A2B10G10R10_UNORM_PACK32; 33 case DXGI_FORMAT_R10G10B10A2_UNORM: return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
32 case DXGI_FORMAT_R16G16B16A16_FLOAT: return VK_FORMAT_R16G16B16A16_SFLOAT; 34 case DXGI_FORMAT_R16G16B16A16_FLOAT: return VK_FORMAT_R16G16B16A16_SFLOAT;
33 default: return VK_FORMAT_UNDEFINED; 35 default: return VK_FORMAT_UNDEFINED;
@@ -122,20 +124,14 @@ public:
122 if (parent_) parent_->Release(); 124 if (parent_) parent_->Release();
123 } 125 }
124 126
125 bool init(HWND hwnd, const DXGI_SWAP_CHAIN_DESC1& desc) { 127 bool init(HWND hwnd, const DXGI_SWAP_CHAIN_DESC1& desc, VkFormat vk_fmt) {
126 hwnd_ = hwnd; 128 hwnd_ = hwnd;
127 flags_ = desc.Flags; 129 flags_ = desc.Flags;
128 const VkExtent2D size = size_or_client(desc.Width, desc.Height, {256u, 256u}); 130 const VkExtent2D size = size_or_client(desc.Width, desc.Height, {256u, 256u});
129 const std::uint32_t w = size.width; 131 const std::uint32_t w = size.width;
130 const std::uint32_t h = size.height; 132 const std::uint32_t h = size.height;
131 const std::uint32_t count = desc.BufferCount ? desc.BufferCount : 2u;
132 VkFormat vk_fmt = VK_FORMAT_UNDEFINED;
133 if (desc.Format != DXGI_FORMAT_UNKNOWN) {
134 vk_fmt = dxgi_to_vk_format(desc.Format);
135 if (vk_fmt == VK_FORMAT_UNDEFINED) return false;
136 }
137 const bool allow_tearing = (flags_ & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) != 0; 133 const bool allow_tearing = (flags_ & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) != 0;
138 if (!swapchain_.create(hwnd, w, h, vk_fmt, count, allow_tearing)) return false; 134 if (!swapchain_.create(hwnd, w, h, vk_fmt, desc.BufferCount, allow_tearing)) return false;
139 if (flags_ & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) { 135 if (flags_ & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) {
140 // DXGI: waitable swapchains default to maximum frame latency 1. 136 // DXGI: waitable swapchains default to maximum frame latency 1.
141 max_frame_latency_.store(1, std::memory_order_relaxed); 137 max_frame_latency_.store(1, std::memory_order_relaxed);
@@ -234,11 +230,15 @@ public:
234 } 230 }
235 231
236 HRESULT STDMETHODCALLTYPE ResizeBuffers(UINT count, UINT width, UINT height, DXGI_FORMAT fmt, UINT flags) override { 232 HRESULT STDMETHODCALLTYPE ResizeBuffers(UINT count, UINT width, UINT height, DXGI_FORMAT fmt, UINT flags) override {
233 if (count != 0 && !valid_flip_buffer_count(count)) return E_INVALIDARG;
237 VkFormat vk_fmt = VK_FORMAT_UNDEFINED; 234 VkFormat vk_fmt = VK_FORMAT_UNDEFINED;
238 if (fmt != DXGI_FORMAT_UNKNOWN) { 235 if (fmt != DXGI_FORMAT_UNKNOWN) {
239 vk_fmt = dxgi_to_vk_format(fmt); 236 vk_fmt = dxgi_to_vk_format(fmt);
240 if (vk_fmt == VK_FORMAT_UNDEFINED) return DXGI_ERROR_UNSUPPORTED; 237 if (vk_fmt == VK_FORMAT_UNDEFINED) return E_INVALIDARG;
241 } 238 }
239 constexpr UINT creation_only_flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT |
240 DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
241 if ((flags & creation_only_flags) != (flags_ & creation_only_flags)) return E_INVALIDARG;
242 // DXGI refuses to resize while the app still holds a back buffer reference. 242 // DXGI refuses to resize while the app still holds a back buffer reference.
243 for (auto* bb : buffers_) 243 for (auto* bb : buffers_)
244 if (bb->held_by_app()) return DXGI_ERROR_INVALID_CALL; 244 if (bb->held_by_app()) return DXGI_ERROR_INVALID_CALL;
@@ -246,8 +246,7 @@ public:
246 const VkExtent2D size = size_or_client(width, height, swapchain_.extent()); 246 const VkExtent2D size = size_or_client(width, height, swapchain_.extent());
247 const std::uint32_t w = size.width; 247 const std::uint32_t w = size.width;
248 const std::uint32_t h = size.height; 248 const std::uint32_t h = size.height;
249 const UINT waitable_bit = flags_ & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; 249 const UINT next_flags = flags ? flags : flags_;
250 const UINT next_flags = (flags ? flags : flags_) | waitable_bit;
251 const bool allow_tearing = (next_flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) != 0; 250 const bool allow_tearing = (next_flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) != 0;
252 if (!swapchain_.resize(w, h, vk_fmt, count, allow_tearing)) return E_FAIL; 251 if (!swapchain_.resize(w, h, vk_fmt, count, allow_tearing)) return E_FAIL;
253 statistics_disjoint_.store(true, std::memory_order_relaxed); 252 statistics_disjoint_.store(true, std::memory_order_relaxed);
@@ -782,24 +781,57 @@ public:
782 if (!out) return E_POINTER; 781 if (!out) return E_POINTER;
783 *out = nullptr; 782 *out = nullptr;
784 if (!hwnd || !desc) return E_INVALIDARG; 783 if (!hwnd || !desc) return E_INVALIDARG;
784 if (!valid_flip_buffer_count(desc->BufferCount)) return DXGI_ERROR_INVALID_CALL;
785 const VkFormat vk_fmt = dxgi_to_vk_format(desc->Format);
786 if (vk_fmt == VK_FORMAT_UNDEFINED) return DXGI_ERROR_INVALID_CALL;
785 auto* sc = new SwapChain(this, device, context_, gipa_, instance_, physical_, gdpa_, queue_, queue_family_); 787 auto* sc = new SwapChain(this, device, context_, gipa_, instance_, physical_, gdpa_, queue_, queue_family_);
786 if (!sc->init(hwnd, *desc)) { 788 if (!sc->init(hwnd, *desc, vk_fmt)) {
787 sc->Release(); 789 sc->Release();
788 return E_FAIL; 790 return E_FAIL;
789 } 791 }
790 *out = static_cast<IDXGISwapChain1*>(sc); 792 *out = static_cast<IDXGISwapChain1*>(sc);
791 return S_OK; 793 return S_OK;
792 } 794 }
793 HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow(IUnknown*, IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, 795 HRESULT STDMETHODCALLTYPE CreateSwapChainForCoreWindow(IUnknown* device, IUnknown* window,
794 IDXGIOutput*, IDXGISwapChain1**) override { 796 const DXGI_SWAP_CHAIN_DESC1* desc,
795 return E_NOTIMPL; 797 IDXGIOutput* restrict_to_output,
798 IDXGISwapChain1** out) override {
799 if (!out) return E_POINTER;
800 *out = nullptr;
801 if (!device || !window || !desc) return E_INVALIDARG;
802 // UWP / Game Core Scarlett titles present to an ICoreWindow. Extract the underlying
803 // Win32 HWND via ICoreWindowInterop.
804 static constexpr GUID kIID_ICoreWindowInterop = {
805 0x45D64A29, 0xA63E, 0x4CB6, {0xB4, 0x98, 0x57, 0x81, 0xD2, 0x98, 0xCB, 0x4F}};
806 struct ICoreWindowInterop : public IUnknown {
807 virtual HRESULT STDMETHODCALLTYPE get_WindowHandle(HWND* hwnd) = 0;
808 virtual HRESULT STDMETHODCALLTYPE put_MessageHandled(unsigned char value) = 0;
809 };
810 ICoreWindowInterop* interop = nullptr;
811 if (FAILED(window->QueryInterface(kIID_ICoreWindowInterop, reinterpret_cast<void**>(&interop))) || !interop) {
812 return DXGI_ERROR_INVALID_CALL;
813 }
814 HWND hwnd = nullptr;
815 const HRESULT hr = interop->get_WindowHandle(&hwnd);
816 interop->Release();
817 if (FAILED(hr) || !hwnd) return DXGI_ERROR_INVALID_CALL;
818 return CreateSwapChainForHwnd(device, hwnd, desc, nullptr, restrict_to_output, out);
796 } 819 }
797 HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid(HANDLE, LUID*) override { return E_NOTIMPL; } 820 HRESULT STDMETHODCALLTYPE GetSharedResourceAdapterLuid(HANDLE, LUID*) override { return E_NOTIMPL; }
798 HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; } 821 HRESULT STDMETHODCALLTYPE RegisterStereoStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; }
799 HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; } 822 HRESULT STDMETHODCALLTYPE RegisterStereoStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; }
800 void STDMETHODCALLTYPE UnregisterStereoStatus(DWORD) override {} 823 void STDMETHODCALLTYPE UnregisterStereoStatus(DWORD) override {}
801 HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow(HWND, UINT, DWORD*) override { return E_NOTIMPL; } 824 HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusWindow(HWND hwnd, UINT msg, DWORD* cookie) override {
802 HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent(HANDLE, DWORD*) override { return E_NOTIMPL; } 825 (void)msg;
826 if (!hwnd || !cookie) return DXGI_ERROR_INVALID_CALL;
827 *cookie = next_occlusion_cookie_.fetch_add(1, std::memory_order_relaxed);
828 return S_OK;
829 }
830 HRESULT STDMETHODCALLTYPE RegisterOcclusionStatusEvent(HANDLE event, DWORD* cookie) override {
831 if (!event || !cookie) return DXGI_ERROR_INVALID_CALL;
832 *cookie = next_occlusion_cookie_.fetch_add(1, std::memory_order_relaxed);
833 return S_OK;
834 }
803 void STDMETHODCALLTYPE UnregisterOcclusionStatus(DWORD) override {} 835 void STDMETHODCALLTYPE UnregisterOcclusionStatus(DWORD) override {}
804 HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition(IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, IDXGIOutput*, 836 HRESULT STDMETHODCALLTYPE CreateSwapChainForComposition(IUnknown*, const DXGI_SWAP_CHAIN_DESC1*, IDXGIOutput*,
805 IDXGISwapChain1**) override { 837 IDXGISwapChain1**) override {
@@ -885,6 +917,7 @@ private:
885 HWND assoc_hwnd_ = nullptr; 917 HWND assoc_hwnd_ = nullptr;
886 mutable std::once_flag tearing_once_; 918 mutable std::once_flag tearing_once_;
887 bool tearing_supported_ = false; 919 bool tearing_supported_ = false;
920 std::atomic<DWORD> next_occlusion_cookie_{1};
888}; 921};
889 922
890} // namespace 923} // namespace
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp
index 38c3194fe..f0ae08811 100644
--- a/runtime/shims/file_system.cpp
+++ b/runtime/shims/file_system.cpp
@@ -142,7 +142,9 @@ std::filesystem::path marker(const std::filesystem::path& overlay, const std::ve
142bool deleted(const std::filesystem::path& overlay, const std::vector<std::wstring>& parts) { 142bool deleted(const std::filesystem::path& overlay, const std::vector<std::wstring>& parts) {
143 if (overlay.empty() || parts.empty()) return false; 143 if (overlay.empty() || parts.empty()) return false;
144 std::error_code ec; 144 std::error_code ec;
145 return std::filesystem::exists(marker(overlay, parts), ec); 145 // Only regular files are deletion markers; parent directories inside .gta6rt-deleted/ exist only to hold markers
146 // for nested deleted files and must not hide the corresponding ancestor directories in the package.
147 return std::filesystem::is_regular_file(marker(overlay, parts), ec);
146} 148}
147 149
148Target read_target(const std::wstring& path) { 150Target read_target(const std::wstring& path) {
diff --git a/runtime/shims/process.cpp b/runtime/shims/process.cpp
index c0070782f..d3f76a684 100644
--- a/runtime/shims/process.cpp
+++ b/runtime/shims/process.cpp
@@ -9,6 +9,10 @@
9// process-wide atexit table also holds gta6rt's own). 9// process-wide atexit table also holds gta6rt's own).
10// Covered CRTs: the Universal CRT (api-ms-win-crt-runtime-l1-1-0.dll / ucrtbase.dll, what MSVC links; ucrtbased.dll in Debug) and 10// Covered CRTs: the Universal CRT (api-ms-win-crt-runtime-l1-1-0.dll / ucrtbase.dll, what MSVC links; ucrtbased.dll in Debug) and
11// msvcrt.dll (MinGW). Calls made inside host DLLs, not through the game's imports, are not seen here. 11// msvcrt.dll (MinGW). Calls made inside host DLLs, not through the game's imports, are not seen here.
12// The loader matches imports by exact DLL name, so GetCommandLineA/W and ExitProcess are served under every name a
13// title can import them by: kernel32.dll (the classic import libraries), kernelbase.dll, and the API sets that the
14// umbrella libraries a GDK title links (OneCore_apiset.lib, mincore.lib) bind them to. The retail package's own DLLs
15// import ExitProcess from api-ms-win-core-processthreads-l1-1-0.dll.
12#include <windows.h> 16#include <windows.h>
13 17
14#include <atomic> 18#include <atomic>
@@ -16,6 +20,7 @@
16#include <cstdlib> 20#include <cstdlib>
17#include <cstring> 21#include <cstring>
18#include <string> 22#include <string>
23#include <type_traits>
19#include <vector> 24#include <vector>
20 25
21#include "process_shim.h" 26#include "process_shim.h"
@@ -107,6 +112,24 @@ wchar_t** __cdecl game_p_wcmdln_storage() {
107 return &p; 112 return &p;
108} 113}
109 114
115// What the UCRT's _get_narrow/_get_wide_winmain_command_line return, and the CRT's WinMain startup passes as
116// lpCmdLine: the command line after the program name and the blanks that follow it. The program name ends at the
117// first character up to ' ' outside quotes, the UCRT's own scan. The comparison is unsigned, so a non-ASCII byte of
118// the narrow line is part of the name; a DBCS trail byte is never '"' or a blank, so it needs no lead-byte step.
119template <typename C>
120C* after_program_name(C* p) {
121 using U = std::make_unsigned_t<C>;
122 bool quoted = false;
123 while (U(*p) > U(' ') || (*p && quoted)) {
124 if (*p == C('"')) quoted = !quoted;
125 ++p;
126 }
127 while (*p && U(*p) <= U(' ')) ++p;
128 return p;
129}
130char* __cdecl game_get_narrow_winmain_command_line() { return after_program_name(g_cmdline.data()); }
131wchar_t* __cdecl game_get_wide_winmain_command_line() { return after_program_name(g_wcmdline.data()); }
132
110// msvcrt.dll: int __getmainargs(int* argc, char*** argv, char*** env, int expand, void* startinfo) 133// msvcrt.dll: int __getmainargs(int* argc, char*** argv, char*** env, int expand, void* startinfo)
111int __cdecl game_getmainargs(int* argc, char*** argv, char*** env, int, void*) { 134int __cdecl game_getmainargs(int* argc, char*** argv, char*** env, int, void*) {
112 *argc = g_argc; 135 *argc = g_argc;
@@ -197,7 +220,13 @@ using namespace rt::process;
197 {dll, "_configure_narrow_argv", reinterpret_cast<void*>(&game_configure_argv)}, \ 220 {dll, "_configure_narrow_argv", reinterpret_cast<void*>(&game_configure_argv)}, \
198 {dll, "_configure_wide_argv", reinterpret_cast<void*>(&game_configure_argv)}, \ 221 {dll, "_configure_wide_argv", reinterpret_cast<void*>(&game_configure_argv)}, \
199 {dll, "__p__acmdln", reinterpret_cast<void*>(&game_p_acmdln_storage)}, \ 222 {dll, "__p__acmdln", reinterpret_cast<void*>(&game_p_acmdln_storage)}, \
200 {dll, "__p__wcmdln", reinterpret_cast<void*>(&game_p_wcmdln_storage)} 223 {dll, "__p__wcmdln", reinterpret_cast<void*>(&game_p_wcmdln_storage)}, \
224 {dll, "_get_narrow_winmain_command_line", reinterpret_cast<void*>(&game_get_narrow_winmain_command_line)}, \
225 {dll, "_get_wide_winmain_command_line", reinterpret_cast<void*>(&game_get_wide_winmain_command_line)}
226#define EXIT_PROCESS(dll) {dll, "ExitProcess", reinterpret_cast<void*>(&game_exit_process)}
227#define COMMAND_LINE(dll) \
228 {dll, "GetCommandLineA", reinterpret_cast<void*>(&game_get_command_line_a)}, \
229 {dll, "GetCommandLineW", reinterpret_cast<void*>(&game_get_command_line_w)}
201} // namespace 230} // namespace
202 231
203SHIM_TABLE(process, 232SHIM_TABLE(process,
@@ -209,7 +238,10 @@ SHIM_TABLE(process,
209 {"msvcrt.dll", "abort", reinterpret_cast<void*>(&game_abort)}, 238 {"msvcrt.dll", "abort", reinterpret_cast<void*>(&game_abort)},
210 {"msvcrt.dll", "__getmainargs", reinterpret_cast<void*>(&game_getmainargs)}, 239 {"msvcrt.dll", "__getmainargs", reinterpret_cast<void*>(&game_getmainargs)},
211 {"msvcrt.dll", "__wgetmainargs", reinterpret_cast<void*>(&game_wgetmainargs)}, 240 {"msvcrt.dll", "__wgetmainargs", reinterpret_cast<void*>(&game_wgetmainargs)},
212 {"kernel32.dll", "ExitProcess", reinterpret_cast<void*>(&game_exit_process)}, 241 EXIT_PROCESS("kernel32.dll"),
213 {"kernel32.dll", "GetCommandLineA", reinterpret_cast<void*>(&game_get_command_line_a)}, 242 EXIT_PROCESS("kernelbase.dll"),
214 {"kernel32.dll", "GetCommandLineW", reinterpret_cast<void*>(&game_get_command_line_w)}, 243 EXIT_PROCESS("api-ms-win-core-processthreads-l1-1-0.dll"),
244 COMMAND_LINE("kernel32.dll"),
245 COMMAND_LINE("kernelbase.dll"),
246 COMMAND_LINE("api-ms-win-core-processenvironment-l1-1-0.dll"),
215); 247);
diff --git a/runtime/shims/xgameruntime.cpp b/runtime/shims/xgameruntime.cpp
index 8135589b9..46aec5af7 100644
--- a/runtime/shims/xgameruntime.cpp
+++ b/runtime/shims/xgameruntime.cpp
@@ -16,6 +16,7 @@
16#include <cstdio> 16#include <cstdio>
17#include <cstdlib> 17#include <cstdlib>
18#include <cstring> 18#include <cstring>
19#include <iterator>
19 20
20#include <XAsync.h> 21#include <XAsync.h>
21#include <XAsyncProvider.h> 22#include <XAsyncProvider.h>
@@ -35,9 +36,9 @@ std::atomic<int> g_runtime_refs{0};
35// "xgameruntime.dll" and GetProcAddress these five names (measured in the package's libHttpClient.GDK.dll and 36// "xgameruntime.dll" and GetProcAddress these five names (measured in the package's libHttpClient.GDK.dll and
36// XCurl.dll, docs/runtime_imports.md). Signatures, the options struct and the error for an unknown class follow 37// XCurl.dll, docs/runtime_imports.md). Signatures, the options struct and the error for an unknown class follow
37// xodus-gaming/xgameruntime-docs (GPL-3.0; facts only, nothing copied): InitializeApiImplEx2 is the one 38// xodus-gaming/xgameruntime-docs (GPL-3.0; facts only, nothing copied): InitializeApiImplEx2 is the one
38// XGameRuntimeInitialize[WithOptions] calls, and QueryApiImpl hands out the runtime's COM classes. The classes' 39// XGameRuntimeInitialize[WithOptions] calls, and QueryApiImpl hands out the runtime's COM classes. XThreadingImpl and
39// method layouts are not known yet, so QueryApiImpl logs each class and interface id it is asked for and refuses 40// XErrorImpl are served (their layouts are measured, below); for any other class QueryApiImpl logs the class and
40// them; the first boot with the executable then lists the interfaces to implement. 41// interface id and refuses it, so the first boot with the executable lists the interfaces to implement next.
41 42
42struct ApiImplOptions { // InitializeApiImplEx2's fourth argument 43struct ApiImplOptions { // InitializeApiImplEx2's fourth argument
43 uint32_t unknown; // documented as always 1 44 uint32_t unknown; // documented as always 1
@@ -85,8 +86,149 @@ void print_guid(char (&out)[40], const GUID* g) {
85 g->Data4[6], g->Data4[7]); 86 g->Data4[6], g->Data4[7]);
86} 87}
87 88
89// ---- The runtime classes QueryApiImpl hands out ----
90//
91// xgameruntime.lib's thunk for each function asks QueryApiImpl for the class (passing the class id as the interface
92// id too), calls one slot of the object's vtable with the function's own arguments after `this`, and Releases it.
93// The slot order is xgameruntime-docs' "Layout" list after IUnknown's three slots, and it is measured: the thunks
94// statically linked into the package's libHttpClient.GDK.dll and XCurl.dll (disassembled, their code not run)
95// call IXThreadingImpl slots 3-7 and 9-30, each with the argument shape of the documented function in that
96// position (XAsyncBegin's five arguments at slot 7, XTaskQueueCreate's two modes and a handle pointer at 12,
97// XTaskQueueTerminate's bool at 22, XThreadSetTimeSensitive's bool at 27, ...), and IXErrorImpl slot 3 with an
98// HRESULT and a pointer. docs/runtime_imports.md has the table. Each function is served by the implementation the
99// named export already uses (third_party/xtaskqueue), so the two ways in behave the same.
100
101constexpr GUID kThreadingClass = {0x073b7dcb, 0x1fcf, 0x4030, {0x94, 0xbe, 0xe3, 0xc9, 0xeb, 0x62, 0x34, 0x28}};
102constexpr GUID kErrorClass = {0x8ca467f7, 0x22e8, 0x4096, {0x84, 0x56, 0xbb, 0x8a, 0xa1, 0x3f, 0x79, 0xd8}};
103
104// A function's arguments after `this`, forwarded unchanged (x64 has one calling convention).
105// Specialised on the function's exact type, so a noexcept function matches only one form.
106template <auto F, class T = decltype(F)> struct Method;
107template <auto F, class R, class... A> struct Method<F, R (*)(A...)> {
108 static R STDMETHODCALLTYPE call(void*, A... a) { return F(a...); }
109};
110template <auto F, class R, class... A> struct Method<F, R (*)(A...) noexcept> {
111 static R STDMETHODCALLTYPE call(void*, A... a) noexcept { return F(a...); }
112};
113
114constexpr GUID kIUnknown = {0x00000000, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
115
116// The runtime's objects are process-wide singletons: AddRef/Release count but never free.
117struct RuntimeObject {
118 const void* const* vtable;
119 const GUID* class_id;
120 std::atomic<long> refs{1};
121};
122
123HRESULT STDMETHODCALLTYPE object_query_interface(void* self, REFIID iid, void** out) {
124 if (!out) return E_POINTER;
125 auto* o = static_cast<RuntimeObject*>(self);
126 if (iid == kIUnknown || iid == *o->class_id) {
127 o->refs.fetch_add(1);
128 *out = self;
129 return S_OK;
130 }
131 *out = nullptr;
132 return E_NOINTERFACE;
133}
134ULONG STDMETHODCALLTYPE object_add_ref(void* self) { return static_cast<ULONG>(static_cast<RuntimeObject*>(self)->refs.fetch_add(1) + 1); }
135ULONG STDMETHODCALLTYPE object_release(void* self) {
136 long prev = static_cast<RuntimeObject*>(self)->refs.load();
137 while (prev > 1 && !static_cast<RuntimeObject*>(self)->refs.compare_exchange_weak(prev, prev - 1)) {}
138 return static_cast<ULONG>(prev > 1 ? prev - 1 : 1); // the singleton's own reference stays
139}
140
141// A private slot whose signature isn't public: logged once, answers 0 (S_OK / false / nothing to do).
142template <int Slot> uint64_t STDMETHODCALLTYPE private_slot(void*) {
143 static std::atomic<bool> s_logged{false};
144 if (!s_logged.exchange(true))
145 std::fprintf(stderr, "[rt] xgameruntime: XThreadingImpl private slot %d called; answering 0\n", Slot);
146 return 0;
147}
148
149// XThreadSetTimeSensitive / XThreadIsTimeSensitive / XThreadAssertNotTimeSensitive. The flag is per thread, as in
150// the GDK; nothing is enforced offline (a time-sensitive thread may still block).
151thread_local bool t_time_sensitive = false;
152HRESULT STDMETHODCALLTYPE thread_set_time_sensitive(void*, bool value) {
153 t_time_sensitive = value;
154 return S_OK;
155}
156void STDMETHODCALLTYPE thread_assert_not_time_sensitive(void*) {}
157bool STDMETHODCALLTYPE thread_is_time_sensitive(void*) { return t_time_sensitive; }
158
159#define XM(fn) reinterpret_cast<const void*>(&Method<&fn>::call)
160const void* const kThreadingVtable[] = {
161 reinterpret_cast<const void*>(&object_query_interface), reinterpret_cast<const void*>(&object_add_ref),
162 reinterpret_cast<const void*>(&object_release),
163 XM(XAsyncGetStatus), // 3
164 XM(XAsyncGetResultSize), // 4
165 XM(XAsyncCancel), // 5
166 XM(XAsyncRun), // 6
167 XM(XAsyncBegin), // 7
168 reinterpret_cast<const void*>(&private_slot<8>), // 8 XAsyncBeginAlloc (private, not called by the package)
169 XM(XAsyncSchedule), // 9
170 XM(XAsyncComplete), // 10
171 XM(XAsyncGetResult), // 11
172 XM(XTaskQueueCreate), // 12
173 XM(XTaskQueueCreateComposite), // 13
174 XM(XTaskQueueGetPort), // 14
175 XM(XTaskQueueDuplicateHandle), // 15
176 XM(XTaskQueueDispatch), // 16
177 XM(XTaskQueueCloseHandle), // 17
178 XM(XTaskQueueSubmitCallback), // 18
179 XM(XTaskQueueSubmitDelayedCallback), // 19
180 XM(XTaskQueueRegisterWaiter), // 20
181 XM(XTaskQueueUnregisterWaiter), // 21
182 XM(XTaskQueueTerminate), // 22
183 XM(XTaskQueueRegisterMonitor), // 23
184 XM(XTaskQueueUnregisterMonitor), // 24
185 XM(XTaskQueueGetCurrentProcessTaskQueue), // 25
186 XM(XTaskQueueSetCurrentProcessTaskQueue), // 26
187 reinterpret_cast<const void*>(&thread_set_time_sensitive), // 27
188 reinterpret_cast<const void*>(&private_slot<28>), // 28 XTaskQueueIsEmpty (private; no arguments)
189 reinterpret_cast<const void*>(&thread_assert_not_time_sensitive), // 29
190 reinterpret_cast<const void*>(&thread_is_time_sensitive), // 30
191};
192#undef XM
193static_assert(std::size(kThreadingVtable) == 31, "IUnknown + IXThreadingImpl's 28 methods");
194
195// IXErrorImpl: XErrorReport(HRESULT, const char*) at slot 3 (the docs' "_unknown_"; XCurl calls it with an HRESULT
196// and a string), XErrorSetCallback(XErrorCallback*, void*) and XErrorSetOptions(options, options). Offline, a report
197// is logged and handed to the callback the title set, if any.
198using XErrorCallback = bool(CALLBACK*)(HRESULT hr, const char* message, void* context);
199std::atomic<XErrorCallback> g_error_callback{nullptr};
200std::atomic<void*> g_error_context{nullptr};
201
202void STDMETHODCALLTYPE error_report(void*, HRESULT hr, const char* message) {
203 static std::atomic<int> s_logged{0};
204 if (s_logged.fetch_add(1) < 64)
205 std::fprintf(stderr, "[rt] xgameruntime: XErrorReport(0x%08lx, %s)\n", static_cast<unsigned long>(hr),
206 message ? message : "(null)");
207 if (XErrorCallback cb = g_error_callback.load()) cb(hr, message, g_error_context.load());
208}
209void STDMETHODCALLTYPE error_set_callback(void*, XErrorCallback callback, void* context) {
210 g_error_context = context;
211 g_error_callback = callback;
212}
213HRESULT STDMETHODCALLTYPE error_set_options(void*, uint32_t, uint32_t) { return S_OK; }
214
215const void* const kErrorVtable[] = {
216 reinterpret_cast<const void*>(&object_query_interface), reinterpret_cast<const void*>(&object_add_ref),
217 reinterpret_cast<const void*>(&object_release),
218 reinterpret_cast<const void*>(&error_report), // 3
219 reinterpret_cast<const void*>(&error_set_callback), // 4
220 reinterpret_cast<const void*>(&error_set_options), // 5
221};
222
223RuntimeObject g_threading{kThreadingVtable, &kThreadingClass};
224RuntimeObject g_error{kErrorVtable, &kErrorClass};
225
88HRESULT WINAPI QueryApiImpl(const GUID* class_id, REFIID interface_id, void** out) { 226HRESULT WINAPI QueryApiImpl(const GUID* class_id, REFIID interface_id, void** out) {
89 if (out) *out = nullptr; 227 if (out) *out = nullptr;
228 if (class_id && out) {
229 for (RuntimeObject* o : {&g_threading, &g_error})
230 if (*class_id == *o->class_id) return object_query_interface(o, interface_id, out);
231 }
90 char cls[40], iid[40]; 232 char cls[40], iid[40];
91 print_guid(cls, class_id); 233 print_guid(cls, class_id);
92 print_guid(iid, &interface_id); 234 print_guid(iid, &interface_id);
@@ -156,6 +298,115 @@ uint64_t __stdcall XSystemGetAppMemoryUsage() {
156 return 0; 298 return 0;
157} 299}
158 300
301// XVersion: 4-part version structure from GDK XGameRuntimeTypes.h (8 bytes)
302struct XVersion {
303 union {
304 struct {
305 uint16_t major;
306 uint16_t minor;
307 uint16_t build;
308 uint16_t revision;
309 };
310 uint64_t Value;
311 };
312};
313static_assert(sizeof(XVersion) == 8, "XVersion must be 8 bytes");
314
315// XSystemAnalyticsInfo: hardware and OS version telemetry (144 bytes)
316struct XSystemAnalyticsInfo {
317 XVersion osVersion;
318 XVersion hostingOsVersion;
319 char family[64];
320 char form[64];
321};
322static_assert(sizeof(XSystemAnalyticsInfo) == 144, "XSystemAnalyticsInfo must be 144 bytes");
323
324// XSystemAnalyticsInfo XSystemGetAnalyticsInfo()
325// Returned by value per Microsoft GDK specification.
326XSystemAnalyticsInfo __stdcall XSystemGetAnalyticsInfo() {
327 XSystemAnalyticsInfo info{};
328 info.osVersion = {10, 0, 22000, 0};
329 info.hostingOsVersion = {10, 0, 22000, 0};
330 std::strncpy(info.family, "Xbox", sizeof(info.family) - 1);
331
332 const uint32_t dt = XSystemGetDeviceType();
333 if (dt == static_cast<uint32_t>(XSystemDeviceType::XboxScarlettLockhart)) {
334 std::strncpy(info.form, "Xbox Series S", sizeof(info.form) - 1);
335 } else {
336 std::strncpy(info.form, "Xbox Series X", sizeof(info.form) - 1);
337 }
338
339 char form_override[64];
340 const DWORD n = GetEnvironmentVariableA("LEONIDA_ANALYTICS_FORM", form_override, sizeof(form_override));
341 if (n > 0 && n < sizeof(form_override)) {
342 std::strncpy(info.form, form_override, sizeof(info.form) - 1);
343 }
344 return info;
345}
346
347// ---- XPackage ----
348
349constexpr size_t XPACKAGE_IDENTIFIER_MAX_LENGTH = 33;
350constexpr char kDefaultPackageIdentifier[XPACKAGE_IDENTIFIER_MAX_LENGTH] = "LeonidaPackageIdentifier00000000";
351static_assert(sizeof(kDefaultPackageIdentifier) == XPACKAGE_IDENTIFIER_MAX_LENGTH,
352 "default package identifier must match XPACKAGE_IDENTIFIER_MAX_LENGTH");
353
354// HRESULT XPackageGetCurrentProcessPackageIdentifier(size_t bufferSize, char* buffer).
355// Retrieves the package identifier string for the current process.
356HRESULT __stdcall XPackageGetCurrentProcessPackageIdentifier(size_t bufferSize, char* buffer) {
357 if (!buffer || bufferSize == 0) return E_INVALIDARG;
358
359 char id[XPACKAGE_IDENTIFIER_MAX_LENGTH] = {};
360 const DWORD n = GetEnvironmentVariableA("LEONIDA_PACKAGE_ID", id, sizeof(id));
361 const char* selected = (n > 0 && n < sizeof(id)) ? id : kDefaultPackageIdentifier;
362 const size_t len = std::strlen(selected);
363
364 if (bufferSize < len + 1) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
365 std::memcpy(buffer, selected, len + 1);
366 return S_OK;
367}
368
369// HRESULT XPackageGetMountPath(XPackageMountHandle mount, size_t pathSize, char* path).
370// Retrieves the installed filesystem path for the mounted package.
371// Reads LEONIDA_GAME_DIR when set, otherwise falls back to the current module's directory.
372HRESULT __stdcall XPackageGetMountPath(void* /*mount*/, size_t pathSize, char* path) {
373 if (!path || pathSize == 0) return E_INVALIDARG;
374
375 char buf[MAX_PATH] = {};
376 const DWORD n = GetEnvironmentVariableA("LEONIDA_GAME_DIR", buf, sizeof(buf));
377 if (n == 0 || n >= sizeof(buf)) {
378 const DWORD mod_len = GetModuleFileNameA(nullptr, buf, sizeof(buf));
379 if (mod_len > 0 && mod_len < sizeof(buf)) {
380 char* slash = std::strrchr(buf, '\\');
381 char* fslash = std::strrchr(buf, '/');
382 char* last = slash > fslash ? slash : fslash;
383 if (last) {
384 *last = '\0';
385 } else {
386 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
387 }
388 } else {
389 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
390 }
391 }
392
393 const size_t len = std::strlen(buf);
394 if (pathSize < len + 1) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
395 std::memcpy(path, buf, len + 1);
396 return S_OK;
397}
398
399// bool XPackageIsPackagedProcess().
400// Returns true on Xbox Series console. LEONIDA_PACKAGED=0 overrides it.
401bool __stdcall XPackageIsPackagedProcess() {
402 char s[16];
403 const DWORD n = GetEnvironmentVariableA("LEONIDA_PACKAGED", s, sizeof(s));
404 if (n > 0 && n < sizeof(s)) {
405 if (std::atoi(s) == 0) return false;
406 }
407 return true;
408}
409
159#define XGR(name) {"xgameruntime.dll", #name, reinterpret_cast<void*>(&name)} 410#define XGR(name) {"xgameruntime.dll", #name, reinterpret_cast<void*>(&name)}
160 411
161} // namespace 412} // namespace
@@ -173,6 +424,10 @@ SHIM_TABLE(xgameruntime,
173 XGR(XSystemGetConsoleId), 424 XGR(XSystemGetConsoleId),
174 XGR(XSystemGetAppMemoryUsageLimit), 425 XGR(XSystemGetAppMemoryUsageLimit),
175 XGR(XSystemGetAppMemoryUsage), 426 XGR(XSystemGetAppMemoryUsage),
427 XGR(XSystemGetAnalyticsInfo),
428 XGR(XPackageGetCurrentProcessPackageIdentifier),
429 XGR(XPackageGetMountPath),
430 XGR(XPackageIsPackagedProcess),
176 // XTaskQueue (third_party/xtaskqueue) 431 // XTaskQueue (third_party/xtaskqueue)
177 XGR(XTaskQueueCreate), 432 XGR(XTaskQueueCreate),
178 XGR(XTaskQueueCreateComposite), 433 XGR(XTaskQueueCreateComposite),
diff --git a/runtime/src/base_reservation.h b/runtime/src/base_reservation.h
new file mode 100644
index 000000000..bf4946895
--- /dev/null
+++ b/runtime/src/base_reservation.h
@@ -0,0 +1,151 @@
1#pragma once
2
3// Keeping a relocation-less game image's preferred range free until the loader maps it there.
4//
5// An EXE without a .reloc directory can only run at its ImageBase (0x140000000 by default). Windows and x86-64 Wine
6// leave that range alone, but arm64 Wine on macOS (CrossOver's arm64 bottles, whose x86-64 code runs under FEX) puts
7// its own start-up allocations at 0x100000000 and up, over that range, before gta6rt's first line runs. So gta6rt
8// starts itself again, suspended, reserves [ImageBase, ImageBase + SizeOfImage) in that child before any of its code
9// runs, and resumes it; the child's loader then commits the image inside the reservation (commit_reserved), so
10// nothing else can take the range in between. The child is told by LEONIDA_BASE_RESERVED=<base>:<size> (hex), which
11// also stops it from starting itself again. Measured on CrossOver Preview 20260821 (arm64 bottle, M2 Max): in a
12// suspended child 0x140000000-0x170000000 is free and reservable; macOS maps its own regions above that (the arm64
13// shared region starts at 0x180000000), so a range there can't be had either way.
14//
15// Nothing changes where the range is free at start-up (Windows, x86-64 Wine) or where the image has relocations.
16
17#include <windows.h>
18
19#include <cstdint>
20#include <cstdio>
21#include <cstdlib>
22#include <cwchar>
23#include <filesystem>
24#include <fstream>
25#include <optional>
26#include <string>
27#include <vector>
28
29namespace rt::base_reservation {
30
31inline constexpr wchar_t kVariable[] = L"LEONIDA_BASE_RESERVED";
32
33struct Range {
34 std::uint64_t base = 0;
35 std::uint64_t size = 0;
36};
37
38// The range this process was started with (LEONIDA_BASE_RESERVED), if any.
39inline std::optional<Range> inherited() {
40 wchar_t value[64] = {};
41 const DWORD length = GetEnvironmentVariableW(kVariable, value, 64);
42 if (!length || length >= 64) return std::nullopt;
43 Range r{};
44 if (std::swscanf(value, L"%llx:%llx", reinterpret_cast<unsigned long long*>(&r.base),
45 reinterpret_cast<unsigned long long*>(&r.size)) != 2 ||
46 !r.size)
47 return std::nullopt;
48 return r;
49}
50
51// Commits [base, base + size) for the loader when it lies inside the reservation this process was started with and
52// that reservation is still in place; returns null otherwise (the caller then allocates as usual). The reservation
53// is the allocation, so VirtualFree(base, 0, MEM_RELEASE) frees it as it frees any image.
54inline void* commit_reserved(std::uint64_t base, std::uint64_t size) {
55 const auto r = inherited();
56 if (!r || base != r->base || size > r->size) return nullptr;
57 MEMORY_BASIC_INFORMATION info{};
58 if (!VirtualQuery(reinterpret_cast<void*>(base), &info, sizeof info) || info.State != MEM_RESERVE ||
59 reinterpret_cast<std::uint64_t>(info.AllocationBase) != base)
60 return nullptr;
61 return VirtualAlloc(reinterpret_cast<void*>(base), static_cast<SIZE_T>(size), MEM_COMMIT, PAGE_READWRITE);
62}
63
64// The preferred range of `image` when it has no relocations and that range is not free in this process; nullopt
65// when the image can be mapped as it is (or is not a readable PE32+, which the loader reports itself).
66inline std::optional<Range> needed(const std::filesystem::path& image) {
67 std::ifstream file(image, std::ios::binary);
68 IMAGE_DOS_HEADER dos{};
69 if (!file.read(reinterpret_cast<char*>(&dos), sizeof dos) || dos.e_magic != IMAGE_DOS_SIGNATURE || dos.e_lfanew < 0)
70 return std::nullopt;
71 IMAGE_NT_HEADERS64 nt{};
72 if (!file.seekg(dos.e_lfanew) || !file.read(reinterpret_cast<char*>(&nt), sizeof nt) ||
73 nt.Signature != IMAGE_NT_SIGNATURE || nt.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC ||
74 !nt.OptionalHeader.SizeOfImage)
75 return std::nullopt;
76 const auto& oh = nt.OptionalHeader;
77 if (oh.NumberOfRvaAndSizes > IMAGE_DIRECTORY_ENTRY_BASERELOC &&
78 oh.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size)
79 return std::nullopt; // relocatable: the loader moves it if the base is taken
80 const Range r{oh.ImageBase, (static_cast<std::uint64_t>(oh.SizeOfImage) + 0xffff) & ~std::uint64_t{0xffff}};
81 for (std::uint64_t at = r.base; at < r.base + r.size;) {
82 MEMORY_BASIC_INFORMATION info{};
83 if (!VirtualQuery(reinterpret_cast<void*>(at), &info, sizeof info)) return r;
84 if (info.State != MEM_FREE) return r;
85 at = reinterpret_cast<std::uint64_t>(info.BaseAddress) + info.RegionSize;
86 }
87 return std::nullopt;
88}
89
90// Runs this program again with the same command line, suspended, reserves `r` in the new process, resumes it and
91// returns its exit code. On failure prints why and returns 1 (the child, if any, is ended unrun).
92inline int relaunch(const Range& r) {
93 wchar_t self[MAX_PATH * 4] = {};
94 if (!GetModuleFileNameW(nullptr, self, MAX_PATH * 4)) {
95 std::fprintf(stderr, "error: GetModuleFileName failed (%lu)\n", GetLastError());
96 return 1;
97 }
98 wchar_t marker[64];
99 std::swprintf(marker, 64, L"%llx:%llx", static_cast<unsigned long long>(r.base),
100 static_cast<unsigned long long>(r.size));
101 // Inherited by the child: it tells it to commit inside the reservation and not to relaunch again.
102 if (!SetEnvironmentVariableW(kVariable, marker)) {
103 std::fprintf(stderr, "error: setting %ls failed (%lu)\n", kVariable, GetLastError());
104 return 1;
105 }
106 std::wstring command_line = GetCommandLineW();
107 STARTUPINFOW startup{sizeof startup};
108 startup.dwFlags = STARTF_USESTDHANDLES;
109 startup.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
110 startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
111 startup.hStdError = GetStdHandle(STD_ERROR_HANDLE);
112 for (HANDLE h : {startup.hStdInput, startup.hStdOutput, startup.hStdError})
113 if (h && h != INVALID_HANDLE_VALUE) SetHandleInformation(h, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
114 PROCESS_INFORMATION process{};
115 std::fflush(stdout);
116 std::fflush(stderr);
117 if (!CreateProcessW(self, command_line.data(), nullptr, nullptr, TRUE, CREATE_SUSPENDED, nullptr, nullptr,
118 &startup, &process)) {
119 std::fprintf(stderr, "error: starting gta6rt again to reserve the image range failed (%lu)\n", GetLastError());
120 return 1;
121 }
122 const auto abandon = [&process] { // the child never ran: end it and release its handles
123 TerminateProcess(process.hProcess, 1);
124 CloseHandle(process.hThread);
125 CloseHandle(process.hProcess);
126 };
127 if (!VirtualAllocEx(process.hProcess, reinterpret_cast<void*>(r.base), static_cast<SIZE_T>(r.size), MEM_RESERVE,
128 PAGE_NOACCESS)) {
129 const DWORD error = GetLastError();
130 abandon();
131 std::fprintf(stderr,
132 "error: the image has no relocations and its range %#llx-%#llx is taken, also in a new "
133 "process (VirtualAllocEx %lu)\n",
134 static_cast<unsigned long long>(r.base), static_cast<unsigned long long>(r.base + r.size), error);
135 return 1;
136 }
137 if (ResumeThread(process.hThread) == static_cast<DWORD>(-1)) { // still suspended: the wait would never end
138 const DWORD error = GetLastError();
139 abandon();
140 std::fprintf(stderr, "error: resuming the relaunched gta6rt failed (%lu)\n", error);
141 return 1;
142 }
143 WaitForSingleObject(process.hProcess, INFINITE);
144 DWORD code = 1;
145 GetExitCodeProcess(process.hProcess, &code);
146 CloseHandle(process.hThread);
147 CloseHandle(process.hProcess);
148 return static_cast<int>(code);
149}
150
151} // namespace rt::base_reservation
diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h
index 9c74994e1..07520c2e3 100644
--- a/runtime/src/command_list.h
+++ b/runtime/src/command_list.h
@@ -565,6 +565,11 @@ struct ExecuteIndirect {
565 std::uint64_t argument_offset = 0; 565 std::uint64_t argument_offset = 0;
566 ResourceId count_buffer = 0; // 0: fixed max_count; non-zero: vkCmdDraw*IndirectCount 566 ResourceId count_buffer = 0; // 0: fixed max_count; non-zero: vkCmdDraw*IndirectCount
567 std::uint64_t count_offset = 0; 567 std::uint64_t count_offset = 0;
568 // kind == dispatch: the compute pipeline and root arguments in effect, as Dispatch records them, so the dispatches
569 // run that pipeline with those arguments whatever the command buffer had bound. A pipeline of 0 leaves the binding
570 // as it is.
571 std::uintptr_t pipeline = 0;
572 std::array<std::uint32_t, 32> user_data{};
568}; 573};
569 574
570// Triangle geometry descriptor for a BLAS build (ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure). 575// Triangle geometry descriptor for a BLAS build (ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure).
@@ -594,11 +599,29 @@ struct BuildAccelerationStructure {
594 std::vector<RtTriangleGeometry> triangles; 599 std::vector<RtTriangleGeometry> triangles;
595}; 600};
596 601
602// CopyRaytracingAccelerationStructure. `mode` is D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE; replay supports
603// CLONE (0) and COMPACT (1) for XDXR structures.
604struct CopyAccelerationStructure {
605 std::uint64_t dst_va = 0;
606 std::uint64_t src_va = 0;
607 std::uint32_t mode = 0;
608};
609
610// EmitRaytracingAccelerationStructurePostbuildInfo, and each postbuild desc of BuildRaytracingAccelerationStructure:
611// one value per source, consecutively from `dest_va`. `type` is D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE;
612// replay supports COMPACTED_SIZE (0) and CURRENT_SIZE (3), 8 bytes each.
613struct AccelerationStructurePostbuild {
614 std::uint64_t dest_va = 0;
615 std::uint32_t type = 0;
616 std::vector<std::uint64_t> sources;
617};
618
597using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier, 619using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier,
598 TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture, 620 TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture,
599 CopyResource, ResolveSubresource, Predication, ClearUnorderedAccess, DiscardResource, 621 CopyResource, ResolveSubresource, Predication, ClearUnorderedAccess, DiscardResource,
600 WriteImmediate, AtomicCopyBuffer, BeginQuery, EndQuery, ResolveQueries, DebugMarker, 622 WriteImmediate, AtomicCopyBuffer, BeginQuery, EndQuery, ResolveQueries, DebugMarker,
601 ExecuteIndirect, BuildAccelerationStructure, Dispatch, Draw>; 623 ExecuteIndirect, BuildAccelerationStructure, Dispatch, Draw, CopyAccelerationStructure,
624 AccelerationStructurePostbuild>;
602 625
603class CommandList { 626class CommandList {
604public: 627public:
@@ -809,6 +832,17 @@ public:
809 if (!build.dst_va || !build.scratch_va) return false; 832 if (!build.dst_va || !build.scratch_va) return false;
810 return append(std::move(build)); 833 return append(std::move(build));
811 } 834 }
835 // D3D12: acceleration structures are 256-byte aligned, postbuild destinations 8-byte aligned.
836 bool copy_acceleration_structure(CopyAccelerationStructure copy) {
837 if (!copy.dst_va || !copy.src_va || copy.dst_va % 256 || copy.src_va % 256) return false;
838 return append(copy);
839 }
840 bool acceleration_structure_postbuild(AccelerationStructurePostbuild info) {
841 if (!info.dest_va || info.dest_va % 8 || info.sources.empty()) return false;
842 for (const auto va : info.sources)
843 if (!va || va % 256) return false;
844 return append(std::move(info));
845 }
812 bool close() { 846 bool close() {
813 if (closed_) return false; 847 if (closed_) return false;
814 closed_ = true; 848 closed_ = true;
diff --git a/runtime/src/descriptor_table.h b/runtime/src/descriptor_table.h
index 59f96fd4f..2b5b111f7 100644
--- a/runtime/src/descriptor_table.h
+++ b/runtime/src/descriptor_table.h
@@ -129,7 +129,10 @@ public:
129 } 129 }
130 130
131 // Erases a key from the table. Returns true if the key was found and erased, false otherwise. 131 // Erases a key from the table. Returns true if the key was found and erased, false otherwise.
132 // Backward-shifts downstream entries in the probe cluster so probe chains remain intact and compact. 132 // Only the key's own slot changes (it becomes empty): no other entry moves. Every lookup, here and in the
133 // shaders (rdna2spirv.py desc_probe), compares all kDescriptorProbes slots and never stops at an empty one, so
134 // a hole breaks no probe chain and inserts reuse it. Keeping the other entries in place is what lets the GPU
135 // copy of the table take an erase while shaders still probe it (BindlessSet::flush_needs_idle).
133 bool erase(const std::uint32_t key[8]) { 136 bool erase(const std::uint32_t key[8]) {
134 std::lock_guard lock(mutex_); 137 std::lock_guard lock(mutex_);
135 return erase_locked(key); 138 return erase_locked(key);
@@ -321,24 +324,9 @@ private:
321 } 324 }
322 if (!found) return false; 325 if (!found) return false;
323 326
324 // Backward-shift entries in the probe cluster to maintain probe chains 327 // No backward shift: see erase().
325 std::uint32_t i = found_slot; 328 entries_[found_slot] = DescriptorEntry{};
326 std::uint32_t j = i;
327 mark(found_slot); 329 mark(found_slot);
328 while (true) {
329 j = (j + 1) & mask_;
330 if (entries_[j].pad != kSlotOccupiedMarker) break;
331 const std::uint32_t r = hash_descriptor_key(entries_[j].key);
332 const std::uint32_t dist_r_to_i = (i - r) & mask_;
333 const std::uint32_t dist_r_to_j = (j - r) & mask_;
334 if (dist_r_to_i < dist_r_to_j && dist_r_to_i < kDescriptorProbes) {
335 entries_[i] = entries_[j];
336 mark(i);
337 i = j;
338 }
339 }
340 entries_[i] = DescriptorEntry{};
341 mark(i);
342 --occupied_count_; 330 --occupied_count_;
343 return true; 331 return true;
344 } 332 }
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index 7d3491653..560f68349 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -23,6 +23,7 @@
23#include <string> 23#include <string>
24#include <vector> 24#include <vector>
25 25
26#include "base_reservation.h"
26#include "pe_loader.h" 27#include "pe_loader.h"
27#include "../shims/d3d12_trace.h" 28#include "../shims/d3d12_trace.h"
28#include "../shims/file_system.h" 29#include "../shims/file_system.h"
@@ -73,6 +74,10 @@ int wmain(int argc, wchar_t** argv) {
73 // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. 74 // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point.
74 if (dry_run + init + run != 1) return usage(); 75 if (dry_run + init + run != 1) return usage();
75 if (game_dir.empty()) game_dir = image.parent_path(); 76 if (game_dir.empty()) game_dir = image.parent_path();
77 // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new
78 // process that has the range reserved from the start (base_reservation.h); that process does not do this again.
79 if (!rt::base_reservation::inherited())
80 if (const auto range = rt::base_reservation::needed(image)) return rt::base_reservation::relaunch(*range);
76 // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package. 81 // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package.
77 if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; 82 if (overlay_dir.empty()) overlay_dir = game_dir / "overlay";
78 rt::fs::configure(game_dir, overlay_dir); 83 rt::fs::configure(game_dir, overlay_dir);
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index 1ab9c7801..387051756 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -14,6 +14,7 @@
14#include <vector> 14#include <vector>
15 15
16#include "../shims/shims.h" 16#include "../shims/shims.h"
17#include "base_reservation.h"
17 18
18namespace rt { 19namespace rt {
19 20
@@ -506,8 +507,11 @@ Module& Loader::map_image(const std::filesystem::path& path) {
506 by_name_[lower(m->name)] = m; 507 by_name_[lower(m->name)] = m;
507 order_.push_back(m); 508 order_.push_back(m);
508 509
509 m->base = static_cast<uint8_t*>( 510 // Inside the range gta6rt reserved for this image before the process started (base_reservation.h), else as usual.
510 VirtualAlloc(reinterpret_cast<void*>(oh.ImageBase), oh.SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); 511 m->base = static_cast<uint8_t*>(base_reservation::commit_reserved(oh.ImageBase, oh.SizeOfImage));
512 if (!m->base)
513 m->base = static_cast<uint8_t*>(VirtualAlloc(reinterpret_cast<void*>(oh.ImageBase), oh.SizeOfImage,
514 MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE));
511 if (!m->base) { 515 if (!m->base) {
512 const auto relocs = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC); 516 const auto relocs = directory(nt, IMAGE_DIRECTORY_ENTRY_BASERELOC);
513 if (!relocs.Size) 517 if (!relocs.Size)
diff --git a/runtime/src/vulkan13_features.h b/runtime/src/vulkan13_features.h
new file mode 100644
index 000000000..2057d953b
--- /dev/null
+++ b/runtime/src/vulkan13_features.h
@@ -0,0 +1,127 @@
1#pragma once
2
3// dynamicRendering and synchronization2, the two Vulkan 1.3 features the D3D12 layer needs, on a Vulkan 1.3 device
4// or on a Vulkan 1.2 device through VK_KHR_dynamic_rendering and VK_KHR_synchronization2. CrossOver's MoltenVK on
5// macOS is such a 1.2 device (1.2.10: Vulkan 1.2 with both extensions); the extension structs, functions and
6// behaviour are the core ones under another name, so the rest of the layer does not see the difference.
7//
8// leonida::Vulkan13Features v13;
9// v13.query(physical, props.apiVersion, get_features2, enumerate_extensions); // per candidate
10// if (!v13.usable()) continue;
11// enable12.pNext = v13.enable(chain); // chain: what came after VkPhysicalDeviceVulkan13Features
12// ... v13.next() is where later feature structs go (it used to be enable13.pNext)
13// v13.add_extensions(device_extensions);
14// fn = leonida::device_proc_or_khr(get_device_proc, device, "vkCmdPipelineBarrier2");
15
16#include <vulkan/vulkan.h>
17
18#include <cstdint>
19#include <cstring>
20#include <string>
21#include <vector>
22
23namespace leonida {
24
25class Vulkan13Features {
26public:
27 Vulkan13Features() = default;
28 Vulkan13Features(const Vulkan13Features&) = delete; // enable() links pointers into this object
29 Vulkan13Features& operator=(const Vulkan13Features&) = delete;
30
31 bool core = false; // a Vulkan 1.3 device: the features are core
32 bool dynamic_rendering = false; // supported, as a core feature or through VK_KHR_dynamic_rendering
33 bool synchronization2 = false; // supported, as a core feature or through VK_KHR_synchronization2
34 // Optional 1.3 core features, enabled where supported; on a 1.2 device they stay off (no required subgroup size).
35 bool subgroup_size_control = false;
36 bool compute_full_subgroups = false;
37
38 bool usable() const { return dynamic_rendering && synchronization2; }
39
40 // Fills the flags above for one physical device. A device older than 1.2 never qualifies.
41 void query(VkPhysicalDevice physical, std::uint32_t api_version, PFN_vkGetPhysicalDeviceFeatures2 features2,
42 PFN_vkEnumerateDeviceExtensionProperties enumerate_extensions) {
43 core = api_version >= VK_API_VERSION_1_3;
44 dynamic_rendering = synchronization2 = subgroup_size_control = compute_full_subgroups = false;
45 if (!features2) return;
46 if (core) {
47 VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES};
48 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &f13};
49 features2(physical, &query);
50 dynamic_rendering = f13.dynamicRendering == VK_TRUE;
51 synchronization2 = f13.synchronization2 == VK_TRUE;
52 subgroup_size_control = f13.subgroupSizeControl == VK_TRUE;
53 compute_full_subgroups = f13.computeFullSubgroups == VK_TRUE;
54 return;
55 }
56 if (api_version < VK_API_VERSION_1_2 || !enumerate_extensions) return;
57 std::uint32_t count = 0;
58 enumerate_extensions(physical, nullptr, &count, nullptr);
59 std::vector<VkExtensionProperties> extensions(count);
60 enumerate_extensions(physical, nullptr, &count, extensions.data());
61 bool has_dynamic_rendering = false, has_synchronization2 = false;
62 for (const auto& e : extensions) {
63 has_dynamic_rendering |= std::strcmp(e.extensionName, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME) == 0;
64 has_synchronization2 |= std::strcmp(e.extensionName, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME) == 0;
65 }
66 if (!has_dynamic_rendering || !has_synchronization2) return;
67 VkPhysicalDeviceSynchronization2FeaturesKHR sync2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR};
68 VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering{
69 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR, &sync2};
70 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &rendering};
71 features2(physical, &query);
72 dynamic_rendering = rendering.dynamicRendering == VK_TRUE;
73 synchronization2 = sync2.synchronization2 == VK_TRUE;
74 }
75
76 // Copies the flags of the device query() chose (a later query() for another candidate overwrites them).
77 void choose(const Vulkan13Features& from) {
78 core = from.core;
79 dynamic_rendering = from.dynamic_rendering;
80 synchronization2 = from.synchronization2;
81 subgroup_size_control = from.subgroup_size_control;
82 compute_full_subgroups = from.compute_full_subgroups;
83 }
84
85 // The structs that enable both features, ahead of `chain`; returns their head for VkPhysicalDeviceVulkan12Features'
86 // pNext. Call once, after query() or choose().
87 void* enable(void* chain) {
88 if (core) {
89 enable13_.pNext = chain;
90 enable13_.dynamicRendering = VK_TRUE;
91 enable13_.synchronization2 = VK_TRUE;
92 enable13_.subgroupSizeControl = subgroup_size_control ? VK_TRUE : VK_FALSE;
93 enable13_.computeFullSubgroups = compute_full_subgroups ? VK_TRUE : VK_FALSE;
94 return &enable13_;
95 }
96 sync2_.pNext = chain;
97 sync2_.synchronization2 = VK_TRUE;
98 rendering_.pNext = &sync2_;
99 rendering_.dynamicRendering = VK_TRUE;
100 return &rendering_;
101 }
102
103 // Where a feature struct goes to follow these: insert with `s.pNext = *next(); *next() = &s;`.
104 void** next() { return core ? &enable13_.pNext : &sync2_.pNext; }
105
106 // The device extensions a 1.2 device needs for both features; none on 1.3.
107 void add_extensions(std::vector<const char*>& extensions) const {
108 if (core) return;
109 extensions.push_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
110 extensions.push_back(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
111 }
112
113private:
114 VkPhysicalDeviceVulkan13Features enable13_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES};
115 VkPhysicalDeviceDynamicRenderingFeaturesKHR rendering_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR};
116 VkPhysicalDeviceSynchronization2FeaturesKHR sync2_{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR};
117};
118
119// A device function by its core name, or by its KHR name where the core one is null: a Vulkan 1.2 device returns
120// null for Vulkan 1.3 core names (vkCmdPipelineBarrier2, vkCmdBeginRendering, ...) and serves the enabled
121// extension's vkCmdPipelineBarrier2KHR and the like, which have the same signatures.
122inline PFN_vkVoidFunction device_proc_or_khr(PFN_vkGetDeviceProcAddr get, VkDevice device, const char* name) {
123 if (const PFN_vkVoidFunction function = get(device, name)) return function;
124 return get(device, (std::string(name) + "KHR").c_str());
125}
126
127} // namespace leonida
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index 73232109e..8683ae2de 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -3,7 +3,8 @@
3// The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker, 3// The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker,
4// image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in 4// image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in
5// shims/d3d12_com.cpp are thin wrappers over these. Needs Vulkan 1.2 timeline semaphores; rectangle clears and 5// shims/d3d12_com.cpp are thin wrappers over these. Needs Vulkan 1.2 timeline semaphores; rectangle clears and
6// enhanced barriers need the Vulkan 1.3 functions (dynamicRendering, synchronization2) to be enabled. 6// enhanced barriers need the Vulkan 1.3 functions (dynamicRendering, synchronization2) to be enabled, as core
7// features or through their KHR extensions on a 1.2 device (vulkan13_features.h).
7 8
8#ifndef VK_NO_PROTOTYPES 9#ifndef VK_NO_PROTOTYPES
9#define VK_NO_PROTOTYPES 10#define VK_NO_PROTOTYPES
@@ -12,6 +13,7 @@
12#include "occlusion_sum_spirv.h" 13#include "occlusion_sum_spirv.h"
13#include "retire_tickets.h" 14#include "retire_tickets.h"
14#include "statistics_sum_spirv.h" 15#include "statistics_sum_spirv.h"
16#include "vulkan13_features.h"
15#include "vulkan_depth24.h" 17#include "vulkan_depth24.h"
16#include "vulkan_scratch.h" 18#include "vulkan_scratch.h"
17#include "vulkan_replay.h" 19#include "vulkan_replay.h"
@@ -27,6 +29,7 @@
27#include <map> 29#include <map>
28#include <memory> 30#include <memory>
29#include <mutex> 31#include <mutex>
32#include <unordered_set>
30#include <shared_mutex> 33#include <shared_mutex>
31#include <span> 34#include <span>
32#include <thread> 35#include <thread>
@@ -84,7 +87,7 @@ struct VulkanDeviceFunctions {
84 // extension is not enabled, and the query functions are optional (a list that uses queries without them is 87 // extension is not enabled, and the query functions are optional (a list that uses queries without them is
85 // unsupported). The compute and descriptor functions are needed for normalized or summed occlusion results. 88 // unsupported). The compute and descriptor functions are needed for normalized or summed occlusion results.
86 bool load(PFN_vkGetDeviceProcAddr get, VkDevice device) { 89 bool load(PFN_vkGetDeviceProcAddr get, VkDevice device) {
87#define LEONIDA_VK_LOAD(name) name = reinterpret_cast<PFN_##name>(get(device, #name)); 90#define LEONIDA_VK_LOAD(name) name = reinterpret_cast<PFN_##name>(leonida::device_proc_or_khr(get, device, #name));
88 LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_LOAD) 91 LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_LOAD)
89#undef LEONIDA_VK_LOAD 92#undef LEONIDA_VK_LOAD
90 return vkCreateCommandPool && vkDestroyCommandPool && vkAllocateCommandBuffers && vkResetCommandBuffer && 93 return vkCreateCommandPool && vkDestroyCommandPool && vkAllocateCommandBuffers && vkResetCommandBuffer &&
@@ -732,15 +735,26 @@ public:
732 const std::uint64_t base = replay_.heap_base; 735 const std::uint64_t base = replay_.heap_base;
733 XdxrLayout layout; 736 XdxrLayout layout;
734 layout.compute(xdxr_elements(b), b.is_tlas); 737 layout.compute(xdxr_elements(b), b.is_tlas);
738 // PERFORM_UPDATE refits the source (the destination itself when no source is given, as D3D12
739 // allows for an in-place update); a full build otherwise.
740 const std::uint64_t from = b.update ? base + (b.src_va ? b.src_va : b.dst_va) : 0;
735 if (b.is_tlas) { 741 if (b.is_tlas) {
736 xdxr_->record_tlas(cb, layout, b.instances_va ? base + b.instances_va : 0, base + b.dst_va, 742 xdxr_->record_tlas(cb, layout, b.instances_va ? base + b.instances_va : 0, base + b.dst_va,
737 base + b.scratch_va, base); 743 base + b.scratch_va, base, from);
738 } else { 744 } else {
739 std::vector<XdxrTriangles> geometries; 745 std::vector<XdxrTriangles> geometries;
740 xdxr_inputs(b, &geometries, base); 746 xdxr_inputs(b, &geometries, base);
741 xdxr_->record_blas(cb, layout, geometries, base + b.dst_va, base + b.scratch_va); 747 xdxr_->record_blas(cb, layout, geometries, base + b.dst_va, base + b.scratch_va, from);
742 } 748 }
743 }; 749 };
750 replay_.xdxr_copy = [this](VkCommandBuffer cb, std::uint64_t src, std::uint64_t dst, std::uint64_t bytes) {
751 const std::uint64_t base = replay_.heap_base;
752 xdxr_->record_copy(cb, base + src, base + dst, bytes);
753 };
754 replay_.xdxr_postbuild = [this](VkCommandBuffer cb, std::uint64_t src, std::uint64_t dest) {
755 const std::uint64_t base = replay_.heap_base;
756 xdxr_->record_postbuild(cb, base + src, base + dest);
757 };
744 } else { 758 } else {
745 xdxr_.reset(); 759 xdxr_.reset();
746 } 760 }
@@ -814,6 +828,15 @@ public:
814 } 828 }
815 } 829 }
816 830
831 // An image that got a storage (unordered-access) view. A shader can write it before any command names it, so the
832 // layer would not know it was used and the first barrier or copy that does would zero-fill it (vulkan_replay.h,
833 // initialize). The next submission therefore moves each such image to GENERAL, the layout its descriptor names,
834 // zero-filled, ahead of its lists. An image already tracked beyond UNDEFINED is left as it is.
835 void note_storage_image(ResourceId id) {
836 std::lock_guard lock(storage_mutex_);
837 storage_pending_.insert(id);
838 }
839
817 void remove_resource(ResourceId id) { 840 void remove_resource(ResourceId id) {
818 VkImage img = VK_NULL_HANDLE; 841 VkImage img = VK_NULL_HANDLE;
819 { 842 {
@@ -1119,6 +1142,14 @@ private:
1119 std::unordered_map<std::uintptr_t, GraphicsPipeline> graphics_pipelines_; 1142 std::unordered_map<std::uintptr_t, GraphicsPipeline> graphics_pipelines_;
1120 std::unordered_map<std::uint64_t, VkAccelerationStructureKHR> acceleration_structures_; 1143 std::unordered_map<std::uint64_t, VkAccelerationStructureKHR> acceleration_structures_;
1121 LayoutTracker tracker_; 1144 LayoutTracker tracker_;
1145 std::mutex storage_mutex_; // a leaf lock: guards storage_pending_ only
1146 std::unordered_set<ResourceId> storage_pending_;
1147 // The last submission that initialized storage images (its queue's progress semaphore and ticket) and a counter
1148 // that says which one: every other queue's next submission waits for it, so no queue uses such an image before
1149 // the zero-fill that put it in GENERAL has run.
1150 VkSemaphore storage_init_semaphore_ = VK_NULL_HANDLE;
1151 std::uint64_t storage_init_value_ = 0;
1152 std::uint64_t storage_init_version_ = 0;
1122 std::map<std::tuple<VkImage, VkImageAspectFlags, std::uint32_t, std::uint32_t, std::uint32_t, VkFormat>, VkImageView> views_; 1153 std::map<std::tuple<VkImage, VkImageAspectFlags, std::uint32_t, std::uint32_t, std::uint32_t, VkFormat>, VkImageView> views_;
1123 std::function<bool(VkCommandBuffer)> bindless_prepare_; 1154 std::function<bool(VkCommandBuffer)> bindless_prepare_;
1124 std::unique_ptr<Depth24Converter> depth24_; 1155 std::unique_ptr<Depth24Converter> depth24_;
@@ -1434,6 +1465,33 @@ public:
1434 return ReplayResult::unsupported; 1465 return ReplayResult::unsupported;
1435 } 1466 }
1436 auto next_tracker = context_.tracker_; 1467 auto next_tracker = context_.tracker_;
1468 // Images with a UAV view are moved to GENERAL (zeroed) by the first submission that can use a shader on them:
1469 // not a copy queue (its family may not clear images), and one whose lists dispatch or draw.
1470 bool runs_shaders = false;
1471 for (const CommandList* list : lists)
1472 for (const auto& command : list->commands())
1473 runs_shaders |= std::holds_alternative<Dispatch>(command) || std::holds_alternative<Draw>(command) ||
1474 std::holds_alternative<ExecuteIndirect>(command);
1475 std::vector<ResourceId> storage_images;
1476 {
1477 std::lock_guard lock(context_.storage_mutex_);
1478 if (context_.storage_init_semaphore_ && context_.storage_init_semaphore_ != progress_ &&
1479 context_.storage_init_version_ != storage_init_seen_) {
1480 waits_.push_back(context_.storage_init_semaphore_);
1481 wait_values_.push_back(context_.storage_init_value_);
1482 storage_init_seen_ = context_.storage_init_version_;
1483 }
1484 if (kind_ != QueueKind::copy && runs_shaders)
1485 storage_images.assign(context_.storage_pending_.begin(), context_.storage_pending_.end());
1486 if (!storage_images.empty()) context_.storage_pending_.clear();
1487 }
1488 for (const ResourceId id : storage_images) {
1489 const ResourceBinding* image = context_.resolve(id);
1490 if (!image || !image->image) continue;
1491 const VkImageSubresourceRange range{image->aspects, 0, image->mip_levels, 0, image->array_layers};
1492 auto pieces = detail::current(&next_tracker, id, range, VK_IMAGE_LAYOUT_UNDEFINED);
1493 detail::initialize(replay, command_buffer, *image, id, pieces, VK_IMAGE_LAYOUT_GENERAL, &next_tracker);
1494 }
1437 bool wrote_readback = false; 1495 bool wrote_readback = false;
1438 VkPipelineStageFlags2 readback_stages = 0; 1496 VkPipelineStageFlags2 readback_stages = 0;
1439 std::uint32_t open_labels = 0; // events may span the lists of one ExecuteCommandLists 1497 std::uint32_t open_labels = 0; // events may span the lists of one ExecuteCommandLists
@@ -1476,6 +1534,17 @@ public:
1476 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1534 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1477 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held 1535 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held
1478 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1536 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);
1537 if (!submitted && !storage_images.empty()) { // not initialized after all: try again with the next submission
1538 std::lock_guard lock(context_.storage_mutex_);
1539 context_.storage_pending_.insert(storage_images.begin(), storage_images.end());
1540 }
1541 if (submitted && !storage_images.empty()) {
1542 std::lock_guard lock(context_.storage_mutex_);
1543 context_.storage_init_semaphore_ = progress_;
1544 context_.storage_init_value_ = submitted_;
1545 ++context_.storage_init_version_;
1546 storage_init_seen_ = context_.storage_init_version_;
1547 }
1479 if (submitted) { 1548 if (submitted) {
1480 context_.tracker_ = std::move(next_tracker); 1549 context_.tracker_ = std::move(next_tracker);
1481 slot->predicate = std::move(batch); 1550 slot->predicate = std::move(batch);
@@ -1627,6 +1696,7 @@ private:
1627 std::uint64_t submitted_ = 0; 1696 std::uint64_t submitted_ = 0;
1628 std::vector<CommandSlot> buffers_; 1697 std::vector<CommandSlot> buffers_;
1629 std::unique_ptr<OcclusionResolve> occlusion_resolve_; 1698 std::unique_ptr<OcclusionResolve> occlusion_resolve_;
1699 std::uint64_t storage_init_seen_ = 0; // the storage_init_version_ this queue has waited for
1630 std::vector<VkSemaphore> waits_; 1700 std::vector<VkSemaphore> waits_;
1631 std::vector<std::uint64_t> wait_values_; 1701 std::vector<std::uint64_t> wait_values_;
1632 std::uint32_t open_labels_ = 0; // queue labels begun and not ended 1702 std::uint32_t open_labels_ = 0; // queue labels begun and not ended
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index c599eb7c2..5f484bf16 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -47,6 +47,7 @@
47#include <array> 47#include <array>
48#include <cstdint> 48#include <cstdint>
49#include <cstring> 49#include <cstring>
50#include <functional>
50#include <unordered_map> 51#include <unordered_map>
51#include <vector> 52#include <vector>
52 53
@@ -162,6 +163,35 @@ constexpr std::uint32_t r32ui_binding(ImageDimension dimension) {
162 return dimension == ImageDimension::dim_2d ? 4 : dimension == ImageDimension::dim_3d ? 7 : no_binding; 163 return dimension == ImageDimension::dim_2d ? 4 : dimension == ImageDimension::dim_3d ? 7 : no_binding;
163} 164}
164 165
166// Set 0's descriptor set layout at features' counts: what create_layout creates and what size_bindings'
167// layout_supported asks vkGetDescriptorSetLayoutSupport about. It points into itself, so it is not copied.
168struct SetLayout {
169 std::array<VkDescriptorSetLayoutBinding, binding_count> entries{};
170 std::array<VkDescriptorBindingFlags, binding_count> flags{};
171 VkDescriptorSetLayoutBindingFlagsCreateInfo flags_info{
172 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO};
173 VkDescriptorSetLayoutCreateInfo info{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO};
174
175 explicit SetLayout(const BindlessFeatures& features) {
176 std::uint32_t count = 0;
177 for (std::uint32_t b = 0; b < binding_count; ++b) {
178 if (!binding_enabled(b, features)) continue;
179 entries[count] = {b, bindings[b].type, features.counts[b], VK_SHADER_STAGE_ALL, nullptr};
180 flags[count] = (features.update_after_bind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0) |
181 (features.partially_bound ? VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT : 0);
182 ++count;
183 }
184 flags_info.bindingCount = count;
185 flags_info.pBindingFlags = flags.data();
186 info.pNext = &flags_info;
187 info.flags = features.update_after_bind ? VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT : 0;
188 info.bindingCount = count;
189 info.pBindings = entries.data();
190 }
191 SetLayout(const SetLayout&) = delete;
192 SetLayout& operator=(const SetLayout&) = delete;
193};
194
165// What size_bindings() grows to where the device's limits allow. At 32-64 bytes a descriptor the whole set is then 195// What size_bindings() grows to where the device's limits allow. At 32-64 bytes a descriptor the whole set is then
166// 3-6 MiB (93793 descriptors on an RTX 5070). 196// 3-6 MiB (93793 descriptors on an RTX 5070).
167inline constexpr std::uint32_t max_2d_images = 65536; 197inline constexpr std::uint32_t max_2d_images = 65536;
@@ -183,10 +213,14 @@ inline constexpr std::uint32_t growth_headroom = 64;
183// what is sure to work (vkGetDescriptorSetLayoutSupport may allow more), so it never shrinks step 1. 213// what is sure to work (vkGetDescriptorSetLayoutSupport may allow more), so it never shrinks step 1.
184// A storage array holds the smaller of the storage count and its dimension's images: add_image never gives a 214// A storage array holds the smaller of the storage count and its dimension's images: add_image never gives a
185// storage view an index past the sampled array. The other bindings keep their default counts. 215// storage view an index past the sampled array. The other bindings keep their default counts.
216// layout_supported, when given, answers vkGetDescriptorSetLayoutSupport for set 0 at the counts in its argument:
217// step 3 then also grows past maxPerSetDescriptors where the device says the layout works (Intel's Xe-LP reports
218// 6159 and supports the full sizes, D3D-219). It is asked only once the sum is above maxPerSetDescriptors.
186// Sets features.counts; returns false when a count is below its default because the device's limits are. 219// Sets features.counts; returns false when a count is below its default because the device's limits are.
187inline bool size_bindings(BindlessFeatures& features, const VkPhysicalDeviceLimits& limits, 220inline bool size_bindings(BindlessFeatures& features, const VkPhysicalDeviceLimits& limits,
188 const VkPhysicalDeviceVulkan11Properties& v11, 221 const VkPhysicalDeviceVulkan11Properties& v11,
189 const VkPhysicalDeviceVulkan12Properties& v12) { 222 const VkPhysicalDeviceVulkan12Properties& v12,
223 const std::function<bool(const BindlessFeatures&)>& layout_supported = {}) {
190 const bool uab = features.update_after_bind; 224 const bool uab = features.update_after_bind;
191 const std::uint32_t sampled_limit = 225 const std::uint32_t sampled_limit =
192 uab ? std::min(v12.maxPerStageDescriptorUpdateAfterBindSampledImages, 226 uab ? std::min(v12.maxPerStageDescriptorUpdateAfterBindSampledImages,
@@ -233,7 +267,8 @@ inline bool size_bindings(BindlessFeatures& features, const VkPhysicalDeviceLimi
233 const auto within = [&](std::uint64_t n, std::uint32_t limit) { return n + headroom <= limit; }; 267 const auto within = [&](std::uint64_t n, std::uint32_t limit) { return n + headroom <= limit; };
234 const std::uint64_t all = sampled + sampler + stored + buffers; 268 const std::uint64_t all = sampled + sampler + stored + buffers;
235 return within(sampled, sampled_limit) && within(sampler, sampler_limit) && within(stored, storage_limit) && 269 return within(sampled, sampled_limit) && within(sampler, sampler_limit) && within(stored, storage_limit) &&
236 within(sampled + stored + buffers, resource_limit) && all <= pool_limit && all <= set_limit; 270 within(sampled + stored + buffers, resource_limit) && all <= pool_limit &&
271 (all <= set_limit || (layout_supported && layout_supported(features)));
237 }; 272 };
238 // Raises n to the largest value up to `high` that fits; leaves it where it is when none does. 273 // Raises n to the largest value up to `high` that fits; leaves it where it is when none does.
239 const auto grow = [&](std::uint32_t& n, std::uint32_t high, std::uint32_t headroom, std::uint64_t set_limit) { 274 const auto grow = [&](std::uint32_t& n, std::uint32_t high, std::uint32_t headroom, std::uint64_t set_limit) {
@@ -400,19 +435,21 @@ public:
400 result == DescriptorTable::InsertResult::added_with_relocation; 435 result == DescriptorTable::InsertResult::added_with_relocation;
401 return true; 436 return true;
402 } 437 }
403 // Erasing compacts the key's probe cluster, so other keys' entries may change slots. 438 // Erasing empties only the key's own slot; no other entry moves (DescriptorTable::erase), so it needs no idle.
439 // The caller erases a key once no submitted work uses it (its texture is gone), like D3D12 requires.
404 bool erase_key(const DescriptorKey& key) { 440 bool erase_key(const DescriptorKey& key) {
405 if (!table_.erase(key)) return false; 441 if (!table_.erase(key)) return false;
406 table_dirty_ = existing_entries_changed_ = true; 442 table_dirty_ = true;
407 return true; 443 return true;
408 } 444 }
409 const DescriptorTable& table() const { return table_; } 445 const DescriptorTable& table() const { return table_; }
410 446
411 // True when the next flush() will change entries a running shader may be probing, or replace the table's 447 // True when the next flush() will change entries a running shader may be probing (a live key's index replaced
412 // buffer: the caller then flushes only once no command buffer that uses the set is still executing. Without 448 // or a live key moved by a relocating insert), or replace the table's buffer: the caller then flushes only once
413 // it the flush only adds entries, and the copy of an entry is not atomic: a shader probing a different key 449 // no command buffer that uses the set is still executing. Without it the flush only adds entries or empties the
414 // could in principle see a torn entry that matches it, which is accepted as vanishingly unlikely because the 450 // slots of erased keys, and the copy of an entry is not atomic: a shader probing a different key could in
415 // added key is new (there is no live key equal to it). 451 // principle see a torn entry that matches it, which is accepted as vanishingly unlikely because the added or
452 // erased key is not live (no running work uses it).
416 bool flush_needs_idle() const { 453 bool flush_needs_idle() const {
417 return table_dirty_ && (existing_entries_changed_ || force_full_upload_ || 454 return table_dirty_ && (existing_entries_changed_ || force_full_upload_ ||
418 table_.size_bytes() > table_buffers_.table.size); 455 table_.size_bytes() > table_buffers_.table.size);
@@ -532,27 +569,12 @@ private:
532 } 569 }
533 570
534 bool create_layout() { 571 bool create_layout() {
535 std::array<VkDescriptorSetLayoutBinding, bindless::bindings.size()> entries{}; 572 const bindless::SetLayout layout(features_);
536 std::array<VkDescriptorBindingFlags, bindless::bindings.size()> flags{}; 573 const std::uint32_t count = layout.info.bindingCount;
537 std::array<VkDescriptorPoolSize, bindless::bindings.size()> sizes{}; 574 std::array<VkDescriptorPoolSize, bindless::bindings.size()> sizes{};
538 std::uint32_t count = 0; 575 for (std::uint32_t i = 0; i < count; ++i)
539 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) { 576 sizes[i] = {layout.entries[i].descriptorType, layout.entries[i].descriptorCount};
540 if (!bindless::binding_enabled(b, features_)) continue; 577 if (vk_.vkCreateDescriptorSetLayout(device_, &layout.info, nullptr, &layout_) != VK_SUCCESS) return false;
541 entries[count] = {b, bindless::bindings[b].type, features_.counts[b], VK_SHADER_STAGE_ALL, nullptr};
542 flags[count] = (features_.update_after_bind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0) |
543 (features_.partially_bound ? VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT : 0);
544 sizes[count] = {bindless::bindings[b].type, features_.counts[b]};
545 ++count;
546 }
547 VkDescriptorSetLayoutBindingFlagsCreateInfo flags_info{
548 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO};
549 flags_info.bindingCount = count;
550 flags_info.pBindingFlags = flags.data();
551 VkDescriptorSetLayoutCreateInfo layout_info{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, &flags_info};
552 layout_info.flags = features_.update_after_bind ? VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT : 0;
553 layout_info.bindingCount = count;
554 layout_info.pBindings = entries.data();
555 if (vk_.vkCreateDescriptorSetLayout(device_, &layout_info, nullptr, &layout_) != VK_SUCCESS) return false;
556 578
557 VkDescriptorPoolCreateInfo pool_info{VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO}; 579 VkDescriptorPoolCreateInfo pool_info{VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO};
558 pool_info.flags = features_.update_after_bind ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0; 580 pool_info.flags = features_.update_after_bind ? VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT : 0;
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h
index 35f1cb556..d9f53baa5 100644
--- a/runtime/src/vulkan_present.h
+++ b/runtime/src/vulkan_present.h
@@ -35,7 +35,6 @@
35#include <cstring> 35#include <cstring>
36#include <functional> 36#include <functional>
37#include <map> 37#include <map>
38#include <optional>
39#include <vector> 38#include <vector>
40 39
41namespace leonida { 40namespace leonida {
@@ -271,25 +270,34 @@ public:
271 270
272 bool recorded = false; 271 bool recorded = false;
273 std::unique_lock tracker_lock(context_.tracker_mutex_, std::defer_lock); 272 std::unique_lock tracker_lock(context_.tracker_mutex_, std::defer_lock);
274 std::optional<LayoutTracker> next_tracker; 273 bool rollback_source = false;
274 VkImageLayout prev_layout = VK_IMAGE_LAYOUT_UNDEFINED;
275 if (binding) { 275 if (binding) {
276 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_ (vulkan_backend.h). 276 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_ (vulkan_backend.h).
277 // Release resource_mutex_ before vkQueueSubmit while keeping tracker_mutex_ held so layout updates 277 // record() only touches subresource 0 (mip 0, layer 0, color) of `source`, so saving that one layout
278 // commit in submission order and roll back if vkQueueSubmit fails. 278 // rolls back a failed submit in O(1) without copying the entire LayoutTracker map.
279 std::shared_lock resource_lock(context_.resource_mutex_); 279 std::shared_lock resource_lock(context_.resource_mutex_);
280 const ResourceBinding* current = context_.resolve(source); 280 const ResourceBinding* current = context_.resolve(source);
281 if (current && current->image && current->aspects == VK_IMAGE_ASPECT_COLOR_BIT) { 281 if (current && current->image && current->aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
282 tracker_lock.lock(); 282 tracker_lock.lock();
283 next_tracker.emplace(context_.tracker_); 283 rollback_source = context_.tracker_.tracked(source);
284 record(frame.commands, *current, source, image, source_rect, *next_tracker); 284 if (rollback_source) prev_layout = context_.tracker_.layout(source, 0);
285 record(frame.commands, *current, source, image, source_rect);
285 recorded = true; 286 recorded = true;
286 } 287 }
287 } else { 288 } else {
288 record_blank(frame.commands, image); 289 record_blank(frame.commands, image);
289 recorded = true; 290 recorded = true;
290 } 291 }
292 const auto rollback = [&] {
293 if (rollback_source)
294 context_.tracker_.set(source, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}, prev_layout);
295 };
291 if (!recorded) return give_back(frame, VK_ERROR_UNKNOWN); // released by another thread since presentable() 296 if (!recorded) return give_back(frame, VK_ERROR_UNKNOWN); // released by another thread since presentable()
292 if (const VkResult reset = vkResetFences_(device, 1, &frame.done); reset != VK_SUCCESS) return stop(reset); 297 if (const VkResult reset = vkResetFences_(device, 1, &frame.done); reset != VK_SUCCESS) {
298 rollback();
299 return stop(reset);
300 }
293 const VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT; 301 const VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
294 VkSubmitInfo submit_info{VK_STRUCTURE_TYPE_SUBMIT_INFO}; 302 VkSubmitInfo submit_info{VK_STRUCTURE_TYPE_SUBMIT_INFO};
295 submit_info.waitSemaphoreCount = 1; 303 submit_info.waitSemaphoreCount = 1;
@@ -322,10 +330,12 @@ public:
322 { 330 {
323 std::lock_guard lock(context_.submit_mutex()); 331 std::lock_guard lock(context_.submit_mutex());
324 submitted = vk.vkQueueSubmit(queue_, 1, &submit_info, frame.done); 332 submitted = vk.vkQueueSubmit(queue_, 1, &submit_info, frame.done);
333 if (submitted != VK_SUCCESS) rollback();
334 // Commit/rollback happened before releasing tracker_mutex_ inside submit_mutex(), preserving submission
335 // order without holding tracker_mutex_ across vkQueuePresentKHR.
336 if (tracker_lock.owns_lock()) tracker_lock.unlock();
325 if (submitted == VK_SUCCESS) result = vkQueuePresentKHR_(queue_, &present); 337 if (submitted == VK_SUCCESS) result = vkQueuePresentKHR_(queue_, &present);
326 } 338 }
327 if (submitted == VK_SUCCESS && next_tracker) context_.tracker_ = std::move(*next_tracker);
328 if (tracker_lock.owns_lock()) tracker_lock.unlock();
329 if (submitted != VK_SUCCESS) return give_back(frame, submitted); 339 if (submitted != VK_SUCCESS) return give_back(frame, submitted);
330 ++frame_index_; 340 ++frame_index_;
331 // Only a present the engine took counts (SUBOPTIMAL is shown too). OUT_OF_DATE was not shown: the swapchain 341 // Only a present the engine took counts (SUBOPTIMAL is shown too). OUT_OF_DATE was not shown: the swapchain
@@ -401,7 +411,7 @@ private:
401 } 411 }
402 412
403 void record(VkCommandBuffer commands, const ResourceBinding& binding, ResourceId source, std::uint32_t image, 413 void record(VkCommandBuffer commands, const ResourceBinding& binding, ResourceId source, std::uint32_t image,
404 const PresentRect* source_rect, LayoutTracker& tracker) { 414 const PresentRect* source_rect) {
405 auto& vk = context_.vk; 415 auto& vk = context_.vk;
406 const ReplayFunctions& fn = context_.replay_; 416 const ReplayFunctions& fn = context_.replay_;
407 vk.vkResetCommandBuffer(commands, 0); 417 vk.vkResetCommandBuffer(commands, 0);
@@ -414,8 +424,8 @@ private:
414 // PRESENT is D3D12's common state: GENERAL for an ordinary texture. A never-written back buffer is 424 // PRESENT is D3D12's common state: GENERAL for an ordinary texture. A never-written back buffer is
415 // zero-filled first, as any committed resource is. 425 // zero-filled first, as any committed resource is.
416 const VkImageLayout common = image_layout(binding, VK_IMAGE_LAYOUT_GENERAL); 426 const VkImageLayout common = image_layout(binding, VK_IMAGE_LAYOUT_GENERAL);
417 auto pieces = detail::current(&tracker, source, range, common); 427 auto pieces = detail::current(&context_.tracker_, source, range, common);
418 detail::initialize(fn, commands, binding, source, pieces, common, &tracker); 428 detail::initialize(fn, commands, binding, source, pieces, common, &context_.tracker_);
419 for (const auto& piece : pieces) 429 for (const auto& piece : pieces)
420 detail::image_barrier(fn, commands, binding, piece.range, piece.layout, 430 detail::image_barrier(fn, commands, binding, piece.range, piece.layout,
421 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_ACCESS_MEMORY_WRITE_BIT, 431 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_ACCESS_MEMORY_WRITE_BIT,
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h
index 887c95b72..2a37f58f5 100644
--- a/runtime/src/vulkan_replay.h
+++ b/runtime/src/vulkan_replay.h
@@ -788,6 +788,10 @@ struct ReplayFunctions {
788 // cannot read while the list is prepared, `xdxr_record` records the build. 788 // cannot read while the list is prepared, `xdxr_record` records the build.
789 std::function<bool(const BuildAccelerationStructure&)> xdxr_check; 789 std::function<bool(const BuildAccelerationStructure&)> xdxr_check;
790 std::function<void(VkCommandBuffer, const BuildAccelerationStructure&)> xdxr_record; 790 std::function<void(VkCommandBuffer, const BuildAccelerationStructure&)> xdxr_record;
791 // CopyRaytracingAccelerationStructure (CLONE, COMPACT) of XDXR structures: `bytes` is the room the destination
792 // resource has; and one postbuild value (COMPACTED_SIZE, CURRENT_SIZE) of the structure at `src` to `dest`.
793 std::function<void(VkCommandBuffer, std::uint64_t src_va, std::uint64_t dst_va, std::uint64_t bytes)> xdxr_copy;
794 std::function<void(VkCommandBuffer, std::uint64_t src_va, std::uint64_t dest_va)> xdxr_postbuild;
791 std::function<VkAccelerationStructureKHR(std::uint64_t)> resolve_acceleration_structure; 795 std::function<VkAccelerationStructureKHR(std::uint64_t)> resolve_acceleration_structure;
792 // Preparation only allocates a slot; capture records the GPU snapshot at the SetPredication command. 796 // Preparation only allocates a slot; capture records the GPU snapshot at the SetPredication command.
793 std::function<bool(VkBuffer, VkDeviceSize, PredicateCapture&)> prepare_predicate; 797 std::function<bool(VkBuffer, VkDeviceSize, PredicateCapture&)> prepare_predicate;
@@ -903,6 +907,7 @@ struct Prepared {
903 VkExtent2D area{}; 907 VkExtent2D area{};
904 std::uint32_t layers = 1; // the fewest layers any bound attachment view has 908 std::uint32_t layers = 1; // the fewest layers any bound attachment view has
905 VkAccelerationStructureKHR accel_dst = VK_NULL_HANDLE; 909 VkAccelerationStructureKHR accel_dst = VK_NULL_HANDLE;
910 std::uint64_t xdxr_bytes = 0; // CopyAccelerationStructure: the most bytes the copy may write
906 VkAccelerationStructureKHR accel_src = VK_NULL_HANDLE; 911 VkAccelerationStructureKHR accel_src = VK_NULL_HANDLE;
907}; 912};
908 913
@@ -972,7 +977,7 @@ inline VkFormat color_view_format(const ResourceBinding& resource, const TargetV
972 } 977 }
973 if (!resource.rgba8_typeless && !resource.castable_view_formats) 978 if (!resource.rgba8_typeless && !resource.castable_view_formats)
974 return format == resource.format ? format : VK_FORMAT_UNDEFINED; 979 return format == resource.format ? format : VK_FORMAT_UNDEFINED;
975 if (resource.format != VK_FORMAT_R8G8B8A8_UNORM || resource.volume || resource.depth != 1 || resource.samples != 1) 980 if (resource.format != VK_FORMAT_R8G8B8A8_UNORM || resource.volume || resource.depth != 1)
976 return VK_FORMAT_UNDEFINED; 981 return VK_FORMAT_UNDEFINED;
977 return format; 982 return format;
978} 983}
@@ -1058,20 +1063,180 @@ inline std::vector<LayoutPiece> current(const LayoutTracker* tracker, ResourceId
1058 return out; 1063 return out;
1059} 1064}
1060 1065
1066// Zero-fills a block-compressed image range via vkCmdCopyBufferToImage from either the device's zero page
1067// (`vk.zero_buffer`) or a zeroed transfer-scratch chunk (`vk.copy_scratch` + `vk.fill_buffer`). Vulkan forbids
1068// vkCmdClearColorImage on BC formats, yet D3D12 committed resources start zeroed unless CREATE_NOT_ZEROED is set
1069// (D3D-220).
1070inline bool zero_compressed_image(const ReplayFunctions& vk, VkCommandBuffer command_buffer,
1071 const ResourceBinding& resource, const VkImageSubresourceRange& range,
1072 VkImageLayout dst_layout) {
1073 const BlockFormat fmt = block_format(resource.format, VK_IMAGE_ASPECT_COLOR_BIT);
1074 if (fmt.block <= 1 || !fmt.bytes || !vk.copy_buffer_to_image) return false;
1075 const std::uint32_t mip_begin = range.baseMipLevel;
1076 const std::uint32_t mip_end =
1077 range.levelCount == VK_REMAINING_MIP_LEVELS ? resource.mip_levels
1078 : std::min(resource.mip_levels, mip_begin + range.levelCount);
1079 const std::uint32_t layer_begin = range.baseArrayLayer;
1080 const std::uint32_t layer_end =
1081 range.layerCount == VK_REMAINING_ARRAY_LAYERS ? resource.array_layers
1082 : std::min(resource.array_layers, layer_begin + range.layerCount);
1083 if (mip_begin >= mip_end || layer_begin >= layer_end) return true;
1084
1085 constexpr VkDeviceSize kMaxChunk = 64u * 1024u;
1086 const std::uint32_t layer_count = layer_end - layer_begin;
1087 VkDeviceSize needed = 0;
1088 for (std::uint32_t mip = mip_begin; mip < mip_end; ++mip) {
1089 const VkExtent2D ext = mip_extent(resource, mip);
1090 const std::uint64_t bx = (std::uint64_t(ext.width) + fmt.block - 1) / fmt.block;
1091 const std::uint64_t by = (std::uint64_t(ext.height) + fmt.block - 1) / fmt.block;
1092 const std::uint64_t mip_d = std::max(1u, resource.depth >> mip);
1093 const std::uint64_t slice_bytes = bx * by * fmt.bytes;
1094 if (slice_bytes >= kMaxChunk || mip_d > kMaxChunk / slice_bytes ||
1095 layer_count > kMaxChunk / (slice_bytes * mip_d)) {
1096 needed = kMaxChunk;
1097 break;
1098 }
1099 needed = std::max<VkDeviceSize>(needed, slice_bytes * mip_d * layer_count);
1100 }
1101 if (!needed) return true;
1102
1103 VkBuffer zero_buf = VK_NULL_HANDLE;
1104 VkDeviceSize zero_off = 0;
1105 VkDeviceSize zero_cap = 0;
1106 if (vk.zero_buffer && vk.zero_size >= fmt.bytes) {
1107 const VkDeviceSize align = fmt.bytes;
1108 const VkDeviceSize pad = (align - (vk.zero_offset % align)) % align;
1109 if (vk.zero_size >= pad + fmt.bytes) {
1110 zero_buf = vk.zero_buffer;
1111 zero_off = vk.zero_offset + pad;
1112 zero_cap = vk.zero_size - pad;
1113 }
1114 }
1115 if (!zero_buf && vk.copy_scratch && vk.fill_buffer) {
1116 // Round up to a multiple of fmt.bytes (8 or 16, always a multiple of 4 for vkCmdFillBuffer).
1117 const VkDeviceSize fill_bytes = ((needed + fmt.bytes - 1) / fmt.bytes) * fmt.bytes;
1118 VkBuffer scratch = VK_NULL_HANDLE;
1119 VkDeviceSize offset = 0;
1120 if (vk.copy_scratch(fill_bytes, scratch, offset)) {
1121 const VkDeviceSize align = fmt.bytes;
1122 const VkDeviceSize pad = (align - (offset % align)) % align;
1123 if (fill_bytes >= pad + fmt.bytes) {
1124 vk.fill_buffer(command_buffer, scratch, offset + pad, fill_bytes - pad, 0);
1125 memory_barrier(vk, command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
1126 VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
1127 zero_buf = scratch;
1128 zero_off = offset + pad;
1129 zero_cap = fill_bytes - pad;
1130 }
1131 }
1132 }
1133 if (!zero_buf || zero_cap < fmt.bytes) return false;
1134
1135 std::vector<VkBufferImageCopy> regions;
1136 for (std::uint32_t mip = mip_begin; mip < mip_end; ++mip) {
1137 const VkExtent2D ext = mip_extent(resource, mip);
1138 const std::uint32_t mip_d = std::max(1u, resource.depth >> mip);
1139 const std::uint64_t bx_total = (std::uint64_t(ext.width) + fmt.block - 1) / fmt.block;
1140 const std::uint64_t by_total = (std::uint64_t(ext.height) + fmt.block - 1) / fmt.block;
1141 const std::uint64_t slice_bytes = bx_total * by_total * fmt.bytes;
1142 if (slice_bytes && slice_bytes <= zero_cap && mip_d <= zero_cap / slice_bytes &&
1143 layer_count <= zero_cap / (slice_bytes * mip_d)) {
1144 VkBufferImageCopy r{};
1145 r.bufferOffset = zero_off;
1146 r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, mip, layer_begin, layer_count};
1147 r.imageExtent = {ext.width, ext.height, mip_d};
1148 regions.push_back(r);
1149 continue;
1150 }
1151 const std::uint64_t row_bytes = bx_total * fmt.bytes;
1152 for (std::uint32_t layer = layer_begin; layer < layer_end; ++layer) {
1153 if (slice_bytes <= zero_cap) {
1154 const std::uint32_t slices_per_copy =
1155 std::max<std::uint32_t>(1u, std::uint32_t(std::min<std::uint64_t>(mip_d, zero_cap / slice_bytes)));
1156 for (std::uint32_t z = 0; z < mip_d; z += slices_per_copy) {
1157 VkBufferImageCopy r{};
1158 r.bufferOffset = zero_off;
1159 r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, mip, layer, 1};
1160 r.imageOffset = {0, 0, std::int32_t(z)};
1161 r.imageExtent = {ext.width, ext.height, std::min(slices_per_copy, mip_d - z)};
1162 regions.push_back(r);
1163 }
1164 } else if (row_bytes <= zero_cap) {
1165 const std::uint32_t rows_per_copy =
1166 std::max<std::uint32_t>(1u, std::uint32_t(std::min<std::uint64_t>(by_total, zero_cap / row_bytes)));
1167 for (std::uint32_t z = 0; z < mip_d; ++z) {
1168 for (std::uint64_t y_blk = 0; y_blk < by_total; y_blk += rows_per_copy) {
1169 const std::uint32_t oy = std::uint32_t(y_blk * fmt.block);
1170 const std::uint32_t eh = std::min<std::uint32_t>(rows_per_copy * fmt.block, ext.height - oy);
1171 VkBufferImageCopy r{};
1172 r.bufferOffset = zero_off;
1173 r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, mip, layer, 1};
1174 r.imageOffset = {0, std::int32_t(oy), std::int32_t(z)};
1175 r.imageExtent = {ext.width, eh, 1};
1176 regions.push_back(r);
1177 }
1178 }
1179 } else {
1180 const std::uint32_t cols_per_copy =
1181 std::max<std::uint32_t>(1u, std::uint32_t(std::min<std::uint64_t>(bx_total, zero_cap / fmt.bytes)));
1182 for (std::uint32_t z = 0; z < mip_d; ++z) {
1183 for (std::uint64_t y_blk = 0; y_blk < by_total; ++y_blk) {
1184 const std::uint32_t oy = std::uint32_t(y_blk * fmt.block);
1185 const std::uint32_t eh = std::min<std::uint32_t>(fmt.block, ext.height - oy);
1186 for (std::uint64_t x_blk = 0; x_blk < bx_total; x_blk += cols_per_copy) {
1187 const std::uint32_t ox = std::uint32_t(x_blk * fmt.block);
1188 const std::uint32_t ew =
1189 std::min<std::uint32_t>(cols_per_copy * fmt.block, ext.width - ox);
1190 VkBufferImageCopy r{};
1191 r.bufferOffset = zero_off;
1192 r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, mip, layer, 1};
1193 r.imageOffset = {std::int32_t(ox), std::int32_t(oy), std::int32_t(z)};
1194 r.imageExtent = {ew, eh, 1};
1195 regions.push_back(r);
1196 }
1197 }
1198 }
1199 }
1200 }
1201 }
1202 if (!regions.empty())
1203 vk.copy_buffer_to_image(command_buffer, zero_buf, resource.image, dst_layout,
1204 std::uint32_t(regions.size()), regions.data());
1205 return true;
1206}
1207
1061// Images registered with the tracker in UNDEFINED have never been used. D3D12 committed resources start zeroed, 1208// Images registered with the tracker in UNDEFINED have never been used. D3D12 committed resources start zeroed,
1062// so each such piece is cleared to zero (colour 0, depth 0, stencil 0) and moved to `layout`, the layout the 1209// so each such piece is zero-filled (clear for uncompressed images, zero-buffer copy for block-compressed formats
1063// operation about to run expects, before that operation; with not_zeroed, or a block-compressed format (which 1210// when a zero page or transfer scratch is available) and moved to `layout`, the layout the operation about to run
1064// Vulkan cannot clear), it is only moved. The tracker records it. 1211// expects; with not_zeroed, it is only moved. The tracker records it.
1065inline void initialize(const ReplayFunctions& vk, VkCommandBuffer command_buffer, const ResourceBinding& resource, 1212inline void initialize(const ReplayFunctions& vk, VkCommandBuffer command_buffer, const ResourceBinding& resource,
1066 ResourceId id, std::vector<LayoutPiece>& pieces, VkImageLayout layout, LayoutTracker* tracker) { 1213 ResourceId id, std::vector<LayoutPiece>& pieces, VkImageLayout layout, LayoutTracker* tracker) {
1067 constexpr VkAccessFlags any_memory = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT; 1214 constexpr VkAccessFlags any_memory = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
1068 for (auto& piece : pieces) { 1215 for (auto& piece : pieces) {
1069 if (piece.layout != VK_IMAGE_LAYOUT_UNDEFINED) continue; 1216 if (piece.layout != VK_IMAGE_LAYOUT_UNDEFINED) continue;
1070 // Vulkan cannot clear block-compressed images; those start undefined (applications upload them first). 1217 const BlockFormat fmt = block_format(resource.format, VK_IMAGE_ASPECT_COLOR_BIT);
1071 const bool compressed = block_format(resource.format, VK_IMAGE_ASPECT_COLOR_BIT).block > 1; 1218 const bool compressed = fmt.block > 1;
1072 if (resource.not_zeroed || compressed) { 1219 if (resource.not_zeroed) {
1073 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, layout, 0, 1220 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, layout, 0,
1074 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, any_memory, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); 1221 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, any_memory, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
1222 } else if (compressed) {
1223 const bool can_zero =
1224 vk.copy_buffer_to_image &&
1225 ((vk.zero_buffer && vk.zero_size >= fmt.bytes) || (vk.copy_scratch && vk.fill_buffer));
1226 if (can_zero) {
1227 const VkImageLayout dst = image_layout(resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
1228 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, dst, 0,
1229 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
1230 VK_PIPELINE_STAGE_TRANSFER_BIT);
1231 const bool zeroed = zero_compressed_image(vk, command_buffer, resource, piece.range, dst);
1232 image_barrier(vk, command_buffer, resource, piece.range, dst, layout,
1233 zeroed ? VK_ACCESS_TRANSFER_WRITE_BIT : 0,
1234 zeroed ? VK_PIPELINE_STAGE_TRANSFER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, any_memory,
1235 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
1236 } else {
1237 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, layout, 0,
1238 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, any_memory, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
1239 }
1075 } else { 1240 } else {
1076 const VkImageLayout dst = image_layout(resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); 1241 const VkImageLayout dst = image_layout(resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
1077 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, dst, 0, 1242 image_barrier(vk, command_buffer, resource, piece.range, VK_IMAGE_LAYOUT_UNDEFINED, dst, 0,
@@ -2232,6 +2397,13 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
2232 (ind->kind == IndirectKind::dispatch && !vk.dispatch_indirect)) 2397 (ind->kind == IndirectKind::dispatch && !vk.dispatch_indirect))
2233 return ReplayResult::unsupported; 2398 return ReplayResult::unsupported;
2234 } 2399 }
2400 if (ind->kind == IndirectKind::dispatch && ind->pipeline) { // the pipeline and root arguments it was recorded
2401 if (!vk.bind_pipeline || !vk.push_constants || !vk.compute_pipeline) return ReplayResult::unsupported;
2402 const ComputePipeline* pipeline = vk.compute_pipeline(ind->pipeline);
2403 if (!pipeline || !pipeline->pipeline) return ReplayResult::unresolved_resource;
2404 if (pipeline->bindless_set && !vk.bind_descriptor_sets) return ReplayResult::unsupported;
2405 p.pipeline = *pipeline;
2406 }
2235 } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) { 2407 } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) {
2236 if (vk.xdxr_check) { 2408 if (vk.xdxr_check) {
2237 if (!vk.xdxr_check(*build)) return ReplayResult::unsupported; 2409 if (!vk.xdxr_check(*build)) return ReplayResult::unsupported;
@@ -2245,6 +2417,29 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun
2245 if (!p.accel_src) return ReplayResult::unresolved_resource; 2417 if (!p.accel_src) return ReplayResult::unresolved_resource;
2246 } 2418 }
2247 } 2419 }
2420 } else if (const auto* copy = std::get_if<CopyAccelerationStructure>(&command)) {
2421 // XDXR only (a KHR copy needs VkAccelerationStructureKHR handles and vkCmdCopyAccelerationStructureKHR);
2422 // the destination's room bounds the copy, as the size is only known to the GPU.
2423 if (!vk.xdxr_copy || !vk.buffer_at || copy->mode > 1) return ReplayResult::unsupported;
2424 std::uint64_t room = ~std::uint64_t(0);
2425 VkBuffer buffer = VK_NULL_HANDLE;
2426 VkDeviceSize offset = 0;
2427 if (!vk.buffer_at(copy->dst_va, room, buffer, offset)) return ReplayResult::unresolved_resource;
2428 std::uint64_t source = ~std::uint64_t(0);
2429 if (!vk.buffer_at(copy->src_va, source, buffer, offset)) return ReplayResult::unresolved_resource;
2430 p.xdxr_bytes = std::min(room, source);
2431 } else if (const auto* info = std::get_if<AccelerationStructurePostbuild>(&command)) {
2432 // The KHR path never wrote postbuild values; it keeps skipping them rather than failing the list.
2433 if (!vk.xdxr_postbuild) {
2434 p.skip = true;
2435 } else {
2436 if (!vk.buffer_at || (info->type != 0 && info->type != 3)) return ReplayResult::unsupported;
2437 std::uint64_t room = 8 * info->sources.size();
2438 VkBuffer buffer = VK_NULL_HANDLE;
2439 VkDeviceSize offset = 0;
2440 if (!vk.buffer_at(info->dest_va, room, buffer, offset)) return ReplayResult::unresolved_resource;
2441 if (room < 8 * info->sources.size()) return ReplayResult::invalid_copy;
2442 }
2248 } else if (const auto* dispatch = std::get_if<Dispatch>(&command)) { 2443 } else if (const auto* dispatch = std::get_if<Dispatch>(&command)) {
2249 if (!vk.bind_pipeline || !vk.push_constants || !vk.dispatch || !vk.compute_pipeline) 2444 if (!vk.bind_pipeline || !vk.push_constants || !vk.dispatch || !vk.compute_pipeline)
2250 return ReplayResult::unsupported; 2445 return ReplayResult::unsupported;
@@ -2953,14 +3148,32 @@ inline void emit(const PreparedList& prepared, VkCommandBuffer command_buffer, c
2953 } else if (ind->kind == IndirectKind::draw_indexed) { 3148 } else if (ind->kind == IndirectKind::draw_indexed) {
2954 vk.draw_indexed_indirect(command_buffer, p.binding.buffer, arguments, ind->max_count, ind->stride); 3149 vk.draw_indexed_indirect(command_buffer, p.binding.buffer, arguments, ind->max_count, ind->stride);
2955 } else if (ind->kind == IndirectKind::dispatch) { 3150 } else if (ind->kind == IndirectKind::dispatch) {
3151 if (ind->pipeline) {
3152 ShaderUserData data{};
3153 std::copy(ind->user_data.begin(), ind->user_data.end(), data.s);
3154 data.heap_base = vk.heap_base;
3155 data.code_base = p.pipeline.code_base;
3156 vk.bind_pipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.pipeline);
3157 if (p.pipeline.bindless_set)
3158 vk.bind_descriptor_sets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.layout, 0,
3159 1, &p.pipeline.bindless_set, 0, nullptr);
3160 vk.push_constants(command_buffer, p.pipeline.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(data),
3161 &data);
3162 }
2956 for (std::uint32_t k = 0; k < ind->max_count; ++k) { 3163 for (std::uint32_t k = 0; k < ind->max_count; ++k) {
2957 vk.dispatch_indirect(command_buffer, p.binding.buffer, 3164 vk.dispatch_indirect(command_buffer, p.binding.buffer,
2958 arguments + VkDeviceSize(k) * ind->stride); 3165 arguments + VkDeviceSize(k) * ind->stride);
2959 } 3166 }
2960 } 3167 }
2961 } 3168 }
2962 } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command); build && vk.xdxr_record) { 3169 } else if (const auto* xdxr_build = std::get_if<BuildAccelerationStructure>(&command);
2963 vk.xdxr_record(command_buffer, *build); 3170 xdxr_build && vk.xdxr_record) {
3171 vk.xdxr_record(command_buffer, *xdxr_build);
3172 } else if (const auto* copy = std::get_if<CopyAccelerationStructure>(&command)) {
3173 vk.xdxr_copy(command_buffer, copy->src_va, copy->dst_va, p.xdxr_bytes);
3174 } else if (const auto* info = std::get_if<AccelerationStructurePostbuild>(&command); info && !p.skip) {
3175 for (std::size_t i = 0; i < info->sources.size(); ++i)
3176 vk.xdxr_postbuild(command_buffer, info->sources[i], info->dest_va + 8 * i);
2964 } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) { 3177 } else if (const auto* build = std::get_if<BuildAccelerationStructure>(&command)) {
2965 // The build's addresses are console VAs into the GPU address arena (heap_base is its device address). 3178 // The build's addresses are console VAs into the GPU address arena (heap_base is its device address).
2966 // A null VA (no index buffer, no transform) stays null: heap_base + 0 would name the arena's zero page. 3179 // A null VA (no index buffer, no transform) stays null: heap_base + 0 would name the arena's zero page.
diff --git a/runtime/src/xdxr_build.comp b/runtime/src/xdxr_build.comp
index 7b5b9d034..908006897 100644
--- a/runtime/src/xdxr_build.comp
+++ b/runtime/src/xdxr_build.comp
@@ -13,8 +13,22 @@
13// MODE_RADIX_* a stable LSD radix sort of the keys with their element indices: 8 passes of 4-bit digits, each 13// MODE_RADIX_* a stable LSD radix sort of the keys with their element indices: 8 passes of 4-bit digits, each
14// a count per tile of RADIX_TILE elements, one exclusive scan, and a scatter (24 dispatches in all, 14// a count per tile of RADIX_TILE elements, one exclusive scan, and a scatter (24 dispatches in all,
15// whatever the count; shared memory only, no subgroup operations) 15// whatever the count; shared memory only, no subgroup operations)
16// MODE_SMALL_SORT up to SMALL_SORT_MAX keys: one workgroup sorts them in shared memory (bitonic, ties by element
17// index, so the order is the stable one), in one dispatch instead of the radix sort's 24, whose
18// fixed latency dominated small builds
16// MODE_LEVEL one thread per BOX32 node of one level: four consecutive entries of the level below 19// MODE_LEVEL one thread per BOX32 node of one level: four consecutive entries of the level below
17// MODE_HEADER one thread: the 64-byte header 20// MODE_HEADER one thread: the 64-byte header
21// An update (D3D12 PERFORM_UPDATE: same topology, new positions or transforms) refits instead: MODE_COPY copies the
22// source structure to the destination when they differ, MODE_TRIANGLES / MODE_INSTANCES rewrite the elements at their
23// slots, MODE_LEVEL with arg2 = 1 recomputes each node's boxes from the children it already points to (the tree's
24// grouping is kept, so there is no Morton pass and no sort), and MODE_HEADER rewrites the bounds.
25// MODE_COPY one thread per word: count words from src0 to dst
26// MODE_COPY_AS CopyRaytracingAccelerationStructure CLONE / COMPACT: the source structure's size comes from its
27// header (totalSizeIn64BNodes), so the copy can follow a build in the same list; at most count
28// words. The records are position-independent (node pointers count from the structure's start, and
29// a TLAS names its BLASes by address), so the bytes are the copy.
30// MODE_POSTBUILD one thread: the 8-byte COMPACTED_SIZE or CURRENT_SIZE of the structure at src0, at dst. A build
31// is already exactly its layout's size, so both are totalSizeIn64BNodes * 64.
18// The tree groups four consecutive children per node in Morton order, level by level, so its shape depends only on 32// The tree groups four consecutive children per node in Morton order, level by level, so its shape depends only on
19// the element count and the layout (xdxr_build.h XdxrLayout) is known when the command is recorded. 33// the element count and the layout (xdxr_build.h XdxrLayout) is known when the command is recorded.
20// 34//
@@ -31,9 +45,11 @@ layout(local_size_x = 64) in;
31layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint w[]; }; 45layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint w[]; };
32 46
33const uint MODE_INIT = 0u, MODE_TRIANGLES = 1u, MODE_INSTANCES = 2u, MODE_MORTON = 3u, MODE_LEVEL = 5u, 47const uint MODE_INIT = 0u, MODE_TRIANGLES = 1u, MODE_INSTANCES = 2u, MODE_MORTON = 3u, MODE_LEVEL = 5u,
34 MODE_HEADER = 6u, MODE_RADIX_COUNT = 7u, MODE_RADIX_SCAN = 8u, MODE_RADIX_SCATTER = 9u; 48 MODE_HEADER = 6u, MODE_RADIX_COUNT = 7u, MODE_RADIX_SCAN = 8u, MODE_RADIX_SCATTER = 9u,
49 MODE_SMALL_SORT = 10u, MODE_COPY = 11u, MODE_COPY_AS = 12u, MODE_POSTBUILD = 13u;
50const uint SMALL_SORT_MAX = 1024u; // xdxr_build.h XdxrLayout::small_sort_max
35const uint RADIX_BITS = 4u, RADIX_BINS = 16u, RADIX_PASSES = 8u; 51const uint RADIX_BITS = 4u, RADIX_BINS = 16u, RADIX_PASSES = 8u;
36const uint RADIX_TILE = 2048u; // elements per workgroup in count and scatter: 32 chunks of 64 52const uint RADIX_TILE = 256u; // elements per workgroup in count and scatter: 4 chunks of 64
37const uint INVALID = 0xffffffffu; 53const uint INVALID = 0xffffffffu;
38const uint TRI0 = 0u, BOX32 = 5u, INSTANCE = 6u; 54const uint TRI0 = 0u, BOX32 = 5u, INSTANCE = 6u;
39const uint REMAP_IDENTITY = 0x09u; 55const uint REMAP_IDENTITY = 0x09u;
@@ -53,7 +69,7 @@ layout(push_constant) uniform Push {
53 uint arg0; // triangles: vertex stride; level: entries in the level below 69 uint arg0; // triangles: vertex stride; level: entries in the level below
54 uint arg1; // triangles: 0 = R32G32B32_FLOAT, 1 = R32G32_FLOAT; level: first node of the level below, 70 uint arg1; // triangles: 0 = R32G32B32_FLOAT, 1 = R32G32_FLOAT; level: first node of the level below,
55 // or INVALID when the level below is the elements 71 // or INVALID when the level below is the elements
56 uint arg2; // triangles: index type (0 none, 1 u16, 2 u32); level: 1 for the root level 72 uint arg2; // triangles: index type (0 none, 1 u16, 2 u32); level: 1 = refit the existing node
57 uint geometry; // triangles: geometry index << 8 | D3D12_RAYTRACING_GEOMETRY_FLAGS 73 uint geometry; // triangles: geometry index << 8 | D3D12_RAYTRACING_GEOMETRY_FLAGS
58 uint elements; // element count N 74 uint elements; // element count N
59 uint sort_size; // N: the keys sorted (one per element) 75 uint sort_size; // N: the keys sorted (one per element)
@@ -254,6 +270,41 @@ void morton(uint i) {
254 store(pc.scratch, keys_off() + 4u * i, key); 270 store(pc.scratch, keys_off() + 4u * i, key);
255 store(pc.scratch, vals_off() + 4u * i, i); 271 store(pc.scratch, vals_off() + 4u * i, i);
256} 272}
273// ---- MODE_SMALL_SORT ----
274// 8 KiB, with the radix arrays below about 12.5 KiB: under the 16 KiB every Vulkan device must allow.
275shared uint small_keys[SMALL_SORT_MAX];
276shared uint small_vals[SMALL_SORT_MAX];
277
278void small_sort(uint t) {
279 uint n = pc.sort_size, p = 1u;
280 while (p < n) p <<= 1;
281 for (uint i = t; i < p; i += 64u) {
282 small_keys[i] = i < n ? load(pc.scratch, keys_off() + 4u * i) : INVALID;
283 small_vals[i] = i < n ? load(pc.scratch, vals_off() + 4u * i) : INVALID;
284 }
285 barrier();
286 for (uint k = 2u; k <= p; k <<= 1) {
287 for (uint j = k >> 1; j > 0u; j >>= 1) {
288 for (uint i = t; i < p; i += 64u) {
289 uint l = i ^ j;
290 if (l > i) {
291 uint ki = small_keys[i], kl = small_keys[l], vi = small_vals[i], vl = small_vals[l];
292 bool greater = ki > kl || (ki == kl && vi > vl);
293 if (greater == ((i & k) == 0u)) {
294 small_keys[i] = kl; small_keys[l] = ki;
295 small_vals[i] = vl; small_vals[l] = vi;
296 }
297 }
298 }
299 barrier();
300 }
301 }
302 for (uint i = t; i < n; i += 64u) {
303 store(pc.scratch, keys_off() + 4u * i, small_keys[i]);
304 store(pc.scratch, vals_off() + 4u * i, small_vals[i]);
305 }
306}
307
257// ---- MODE_RADIX_* ---- 308// ---- MODE_RADIX_* ----
258shared uint radix_hist[RADIX_BINS]; 309shared uint radix_hist[RADIX_BINS];
259shared uint radix_rank[RADIX_BINS][64]; 310shared uint radix_rank[RADIX_BINS][64];
@@ -341,7 +392,22 @@ void build_node(uint n) {
341 uint entry = 4u * n + c; 392 uint entry = 4u * n + c;
342 uint child = INVALID; 393 uint child = INVALID;
343 vec3 lo = vec3(uintBitsToFloat(0x7f800000u)), hi = -lo; // min > max: the box test misses it 394 vec3 lo = vec3(uintBitsToFloat(0x7f800000u)), hi = -lo; // min > max: the box test misses it
344 if (entry < pc.arg0) { 395 if (pc.arg2 == 1u) {
396 // refit: the child this node already has; its new box is in scratch (an element's from MODE_TRIANGLES /
397 // MODE_INSTANCES, a node's from the level below)
398 child = load(pc.dst, o + 4u * c);
399 if (child != INVALID) {
400 uint at = ptr_unit(child) * 64u;
401 if ((child & 7u) == BOX32) {
402 load_box(pc.elements + (at - pc.nodes_off) / 128u, lo, hi);
403 } else {
404 uint e = (at - pc.elements_off) / element_size();
405 load_box(e, lo, hi);
406 if (pc.tlas != 0u) store(pc.dst, pc.elements_off + 128u * e + 116u, me);
407 }
408 if (!box_empty(lo, hi)) { ulo = min(ulo, lo); uhi = max(uhi, hi); }
409 }
410 } else if (entry < pc.arg0) {
345 if (pc.arg1 == INVALID) { 411 if (pc.arg1 == INVALID) {
346 uint e = load(pc.scratch, vals_off() + 4u * entry); 412 uint e = load(pc.scratch, vals_off() + 4u * entry);
347 child = element_ptr(e); 413 child = element_ptr(e);
@@ -389,12 +455,23 @@ void main() {
389 if (pc.mode == MODE_RADIX_COUNT) { radix_count(gl_WorkGroupID.x, gl_LocalInvocationID.x); return; } 455 if (pc.mode == MODE_RADIX_COUNT) { radix_count(gl_WorkGroupID.x, gl_LocalInvocationID.x); return; }
390 if (pc.mode == MODE_RADIX_SCAN) { radix_scan(gl_LocalInvocationID.x); return; } 456 if (pc.mode == MODE_RADIX_SCAN) { radix_scan(gl_LocalInvocationID.x); return; }
391 if (pc.mode == MODE_RADIX_SCATTER) { radix_scatter(gl_WorkGroupID.x, gl_LocalInvocationID.x); return; } 457 if (pc.mode == MODE_RADIX_SCATTER) { radix_scatter(gl_WorkGroupID.x, gl_LocalInvocationID.x); return; }
458 if (pc.mode == MODE_SMALL_SORT) { small_sort(gl_LocalInvocationID.x); return; }
392 if (pc.mode == MODE_HEADER) { 459 if (pc.mode == MODE_HEADER) {
393 if (i == 0u) build_header(); 460 if (i == 0u) build_header();
394 return; 461 return;
395 } 462 }
396 if (i >= pc.count) return; 463 if (i >= pc.count) return;
397 if (pc.mode == MODE_INIT) { 464 if (pc.mode == MODE_POSTBUILD) {
465 if (i == 0u) { store(pc.dst, 0u, load(pc.src0, 4u) * 64u); store(pc.dst, 4u, 0u); }
466 return;
467 }
468 if (pc.mode == MODE_COPY_AS) {
469 if (4u * i < load(pc.src0, 4u) * 64u) store(pc.dst, 4u * i, load(pc.src0, 4u * i));
470 return;
471 }
472 if (pc.mode == MODE_COPY) {
473 store(pc.dst, 4u * i, load(pc.src0, 4u * i));
474 } else if (pc.mode == MODE_INIT) {
398 store(pc.dst, pc.parents_off + 4u * i, INVALID); 475 store(pc.dst, pc.parents_off + 4u * i, INVALID);
399 if (i < 3u) { store(pc.scratch, 4u * i, INVALID); store(pc.scratch, 12u + 4u * i, 0u); } 476 if (i < 3u) { store(pc.scratch, 4u * i, INVALID); store(pc.scratch, 12u + 4u * i, 0u); }
400 } else if (pc.mode == MODE_TRIANGLES) { 477 } else if (pc.mode == MODE_TRIANGLES) {
diff --git a/runtime/src/xdxr_build.h b/runtime/src/xdxr_build.h
index 32ee111cb..6930078a4 100644
--- a/runtime/src/xdxr_build.h
+++ b/runtime/src/xdxr_build.h
@@ -15,6 +15,7 @@
15// device addresses are wider (llvmpipe's are host pointers), the layer must present a narrower window and a bias. 15// device addresses are wider (llvmpipe's are host pointers), the layer must present a narrower window and a bias.
16#pragma once 16#pragma once
17 17
18#include <algorithm>
18#include <cstddef> 19#include <cstddef>
19#include <cstdint> 20#include <cstdint>
20#include <vector> 21#include <vector>
@@ -41,9 +42,10 @@ struct XdxrLayout {
41 std::uint32_t size = 0; // result data size in bytes, a multiple of 64 42 std::uint32_t size = 0; // result data size in bytes, a multiple of 64
42 std::uint32_t parent_entries = 0; // one per 64-byte unit from elements_off on 43 std::uint32_t parent_entries = 0; // one per 64-byte unit from elements_off on
43 std::uint32_t sort_size = 0; // keys the radix sort orders: one per element 44 std::uint32_t sort_size = 0; // keys the radix sort orders: one per element
44 static constexpr std::uint32_t radix_tile = 2048; // xdxr_build.comp RADIX_TILE 45 static constexpr std::uint32_t radix_tile = 256; // xdxr_build.comp RADIX_TILE
45 static constexpr std::uint32_t radix_bins = 16; 46 static constexpr std::uint32_t radix_bins = 16;
46 static constexpr std::uint32_t radix_passes = 8; 47 static constexpr std::uint32_t radix_passes = 8;
48 static constexpr std::uint32_t small_sort_max = 1024; // xdxr_build.comp SMALL_SORT_MAX: one-workgroup sort
47 std::uint64_t scratch = 0; // scratch bytes 49 std::uint64_t scratch = 0; // scratch bytes
48 50
49 // False when the count would overflow the 32-bit offsets of the format. 51 // False when the count would overflow the 32-bit offsets of the format.
@@ -108,11 +110,16 @@ public:
108 110
109 // Records a bottom-level build into `dst` (layout.size bytes) using `scratch` (layout.scratch bytes). `layout` 111 // Records a bottom-level build into `dst` (layout.size bytes) using `scratch` (layout.scratch bytes). `layout`
110 // must come from compute() with the sum of the geometries' triangle counts. 112 // must come from compute() with the sum of the geometries' triangle counts.
113 //
114 // With `update_from` set, an update (D3D12 PERFORM_UPDATE) instead: the structure at `update_from` (the
115 // destination itself, or another one, which is copied first) was built from the same topology, and is refitted
116 // to the new positions. Its tree is kept and only its boxes change, which is valid for any motion and costs no
117 // sort, though a refitted tree traverses more slowly as the geometry moves away from where it was built.
111 bool record_blas(VkCommandBuffer cb, const XdxrLayout& layout, const std::vector<XdxrTriangles>& geometries, 118 bool record_blas(VkCommandBuffer cb, const XdxrLayout& layout, const std::vector<XdxrTriangles>& geometries,
112 std::uint64_t dst, std::uint64_t scratch) { 119 std::uint64_t dst, std::uint64_t scratch, std::uint64_t update_from = 0) {
113 if (!loaded_ || layout.tlas) return false; 120 if (!loaded_ || layout.tlas) return false;
114 Push p = base(layout, dst, scratch); 121 Push p = base(layout, dst, scratch);
115 begin(cb, layout, p); 122 if (update_from) refit_begin(cb, layout, p, update_from); else begin(cb, layout, p);
116 std::uint32_t first = 0; 123 std::uint32_t first = 0;
117 for (std::size_t g = 0; g < geometries.size(); ++g) { 124 for (std::size_t g = 0; g < geometries.size(); ++g) {
118 const auto& geo = geometries[g]; 125 const auto& geo = geometries[g];
@@ -132,17 +139,18 @@ public:
132 first += geo.triangle_count; 139 first += geo.triangle_count;
133 } 140 }
134 if (first != layout.elements) return false; 141 if (first != layout.elements) return false;
135 finish(cb, layout, p); 142 if (update_from) refit_finish(cb, layout, p); else finish(cb, layout, p);
136 return true; 143 return true;
137 } 144 }
138 145
139 // Records a top-level build from `count` D3D12_RAYTRACING_INSTANCE_DESCs at `instances`. 146 // Records a top-level build from `count` D3D12_RAYTRACING_INSTANCE_DESCs at `instances`.
147 // `update_from`: as for record_blas; the instances may move, and name other BLASes.
140 bool record_tlas(VkCommandBuffer cb, const XdxrLayout& layout, std::uint64_t instances, std::uint64_t dst, 148 bool record_tlas(VkCommandBuffer cb, const XdxrLayout& layout, std::uint64_t instances, std::uint64_t dst,
141 std::uint64_t scratch, std::uint64_t bias = 0) { 149 std::uint64_t scratch, std::uint64_t bias = 0, std::uint64_t update_from = 0) {
142 if (!loaded_ || !layout.tlas) return false; 150 if (!loaded_ || !layout.tlas) return false;
143 Push p = base(layout, dst, scratch); 151 Push p = base(layout, dst, scratch);
144 p.bias = split(bias); 152 p.bias = split(bias);
145 begin(cb, layout, p); 153 if (update_from) refit_begin(cb, layout, p, update_from); else begin(cb, layout, p);
146 if (layout.elements) { 154 if (layout.elements) {
147 Push t = p; 155 Push t = p;
148 t.mode = mode_instances; 156 t.mode = mode_instances;
@@ -150,14 +158,48 @@ public:
150 t.src0 = split(instances); 158 t.src0 = split(instances);
151 dispatch(cb, t, t.count); 159 dispatch(cb, t, t.count);
152 } 160 }
153 finish(cb, layout, p); 161 if (update_from) refit_finish(cb, layout, p); else finish(cb, layout, p);
162 return true;
163 }
164
165 // CopyRaytracingAccelerationStructure CLONE or COMPACT: the structure at `src` to `dst`, as many bytes as its
166 // header says, at most `max_bytes` (the room the destination has). The structures are position-independent.
167 bool record_copy(VkCommandBuffer cb, std::uint64_t src, std::uint64_t dst, std::uint64_t max_bytes) {
168 if (!loaded_ || !src || !dst || max_bytes < XdxrLayout::header_size) return false;
169 if (src == dst) return true;
170 vk_.vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_);
171 Push p{};
172 p.mode = mode_copy_as;
173 p.src0 = split(src);
174 p.dst = split(dst);
175 p.count = std::uint32_t(std::min<std::uint64_t>(max_bytes, 0xffffffffull) / 4);
176 dispatch(cb, p, p.count, false);
177 return true;
178 }
179
180 // One postbuild value (COMPACTED_SIZE or CURRENT_SIZE, the same for these builds): 8 bytes at `dst` for the
181 // structure at `src`. A barrier first: a build or copy recorded just before writes the header it reads.
182 bool record_postbuild(VkCommandBuffer cb, std::uint64_t src, std::uint64_t dst) {
183 if (!loaded_ || !src || !dst) return false;
184 VkMemoryBarrier b{VK_STRUCTURE_TYPE_MEMORY_BARRIER, nullptr, VK_ACCESS_SHADER_WRITE_BIT,
185 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT};
186 vk_.vkCmdPipelineBarrier(cb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 1,
187 &b, 0, nullptr, 0, nullptr);
188 vk_.vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_);
189 Push p{};
190 p.mode = mode_postbuild;
191 p.src0 = split(src);
192 p.dst = split(dst);
193 p.count = 1;
194 dispatch(cb, p, 1, false);
154 return true; 195 return true;
155 } 196 }
156 197
157private: 198private:
158 enum : std::uint32_t { 199 enum : std::uint32_t {
159 mode_init = 0, mode_triangles = 1, mode_instances = 2, mode_morton = 3, mode_level = 5, mode_header = 6, 200 mode_init = 0, mode_triangles = 1, mode_instances = 2, mode_morton = 3, mode_level = 5, mode_header = 6,
160 mode_radix_count = 7, mode_radix_scan = 8, mode_radix_scatter = 9 201 mode_radix_count = 7, mode_radix_scan = 8, mode_radix_scatter = 9, mode_small_sort = 10, mode_copy = 11,
202 mode_copy_as = 12, mode_postbuild = 13
161 }; 203 };
162 struct Addr { std::uint32_t lo = 0, hi = 0; }; 204 struct Addr { std::uint32_t lo = 0, hi = 0; };
163 struct Push { // xdxr_build.comp `Push`, std430 push-constant layout 205 struct Push { // xdxr_build.comp `Push`, std430 push-constant layout
@@ -191,6 +233,36 @@ private:
191 dispatch(cb, init, init.count); 233 dispatch(cb, init, init.count);
192 } 234 }
193 235
236 // An update: the source's tree is copied unless it is the destination. Its parent table stays as it is, so there
237 // is no MODE_INIT.
238 void refit_begin(VkCommandBuffer cb, const XdxrLayout& l, const Push& p, std::uint64_t source) {
239 vk_.vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_);
240 const std::uint64_t dst = std::uint64_t(p.dst.hi) << 32 | p.dst.lo;
241 if (source == dst) return;
242 Push c = p;
243 c.mode = mode_copy;
244 c.count = l.size / 4;
245 c.src0 = split(source);
246 dispatch(cb, c, c.count);
247 }
248
249 // Boxes bottom-up through the existing nodes, then the header (its bounds change; nothing else does).
250 void refit_finish(VkCommandBuffer cb, const XdxrLayout& l, const Push& p) {
251 for (std::size_t level = 0; level < l.level_counts.size(); ++level) {
252 Push n = p;
253 n.mode = mode_level;
254 n.count = l.level_counts[level];
255 n.first = l.level_first[level];
256 n.arg2 = 1; // refit: read each node's children from the node
257 dispatch(cb, n, n.count);
258 }
259 Push h = p;
260 h.mode = mode_header;
261 h.count = 1;
262 h.first = l.root();
263 dispatch(cb, h, 1, false);
264 }
265
194 void finish(VkCommandBuffer cb, const XdxrLayout& l, const Push& p) { 266 void finish(VkCommandBuffer cb, const XdxrLayout& l, const Push& p) {
195 Push m = p; 267 Push m = p;
196 m.mode = mode_morton; 268 m.mode = mode_morton;
@@ -198,7 +270,11 @@ private:
198 dispatch(cb, m, m.count); 270 dispatch(cb, m, m.count);
199 // stable LSD radix sort, 4 bits a pass; an even pass count leaves the result where the keys started 271 // stable LSD radix sort, 4 bits a pass; an even pass count leaves the result where the keys started
200 static_assert(XdxrLayout::radix_passes % 2 == 0, "the sorted keys must end in the first buffer"); 272 static_assert(XdxrLayout::radix_passes % 2 == 0, "the sorted keys must end in the first buffer");
201 if (l.sort_size > 1) { 273 if (l.sort_size > 1 && l.sort_size <= XdxrLayout::small_sort_max) {
274 Push s = p;
275 s.mode = mode_small_sort;
276 dispatch(cb, s, 64); // one workgroup, shared memory
277 } else if (l.sort_size > 1) {
202 for (std::uint32_t pass = 0; pass < XdxrLayout::radix_passes; ++pass) { 278 for (std::uint32_t pass = 0; pass < XdxrLayout::radix_passes; ++pass) {
203 Push s = p; 279 Push s = p;
204 s.first = pass; 280 s.first = pass;
diff --git a/runtime/src/xdxr_build.inc b/runtime/src/xdxr_build.inc
index 8a43b04cd..bbc1bb888 100644
--- a/runtime/src/xdxr_build.inc
+++ b/runtime/src/xdxr_build.inc
@@ -1,3441 +1,4092 @@
1{0x07230203,0x00010500,0x000d000b,0x00002b73, 1{0x07230203,0x00010500,0x000d000b,0x000032b4,
20x00000000,0x00020011,0x00000001,0x00020011, 20x00000000,0x00020011,0x00000001,0x00020011,
30x000014e3,0x0006000b,0x00000001,0x4c534c47, 30x000014e3,0x0006000b,0x00000001,0x4c534c47,
40x6474732e,0x3035342e,0x00000000,0x0003000e, 40x6474732e,0x3035342e,0x00000000,0x0003000e,
50x000014e4,0x00000001,0x000d000f,0x00000005, 50x000014e4,0x00000001,0x000f000f,0x00000005,
60x00000004,0x6e69616d,0x00000000,0x000000f9, 60x00000004,0x6e69616d,0x00000000,0x000000fc,
70x000006d4,0x00000740,0x00000789,0x000007e2, 70x000006af,0x000006c4,0x000007a3,0x0000080d,
80x000009e6,0x000009f0,0x000009f1,0x00060010, 80x00000856,0x000008af,0x00000b0e,0x00000b17,
90x00000004,0x00000011,0x00000040,0x00000001, 90x00000b18,0x00060010,0x00000004,0x00000011,
100x00000001,0x00040047,0x00000015,0x00000006, 100x00000040,0x00000001,0x00000001,0x00040047,
110x00000004,0x00030047,0x00000016,0x00000002, 110x00000015,0x00000006,0x00000004,0x00030047,
120x00050048,0x00000016,0x00000000,0x00000023, 120x00000016,0x00000002,0x00050048,0x00000016,
130x00000000,0x00030047,0x000000f7,0x00000002, 130x00000000,0x00000023,0x00000000,0x00030047,
140x00050048,0x000000f7,0x00000000,0x00000023, 140x000000fa,0x00000002,0x00050048,0x000000fa,
150x00000000,0x00050048,0x000000f7,0x00000001, 150x00000000,0x00000023,0x00000000,0x00050048,
160x00000023,0x00000008,0x00050048,0x000000f7, 160x000000fa,0x00000001,0x00000023,0x00000008,
170x00000002,0x00000023,0x00000010,0x00050048, 170x00050048,0x000000fa,0x00000002,0x00000023,
180x000000f7,0x00000003,0x00000023,0x00000018, 180x00000010,0x00050048,0x000000fa,0x00000003,
190x00050048,0x000000f7,0x00000004,0x00000023, 190x00000023,0x00000018,0x00050048,0x000000fa,
200x00000020,0x00050048,0x000000f7,0x00000005, 200x00000004,0x00000023,0x00000020,0x00050048,
210x00000023,0x00000028,0x00050048,0x000000f7, 210x000000fa,0x00000005,0x00000023,0x00000028,
220x00000006,0x00000023,0x00000030,0x00050048, 220x00050048,0x000000fa,0x00000006,0x00000023,
230x000000f7,0x00000007,0x00000023,0x00000034, 230x00000030,0x00050048,0x000000fa,0x00000007,
240x00050048,0x000000f7,0x00000008,0x00000023, 240x00000023,0x00000034,0x00050048,0x000000fa,
250x00000038,0x00050048,0x000000f7,0x00000009, 250x00000008,0x00000023,0x00000038,0x00050048,
260x00000023,0x0000003c,0x00050048,0x000000f7, 260x000000fa,0x00000009,0x00000023,0x0000003c,
270x0000000a,0x00000023,0x00000040,0x00050048, 270x00050048,0x000000fa,0x0000000a,0x00000023,
280x000000f7,0x0000000b,0x00000023,0x00000044, 280x00000040,0x00050048,0x000000fa,0x0000000b,
290x00050048,0x000000f7,0x0000000c,0x00000023, 290x00000023,0x00000044,0x00050048,0x000000fa,
300x00000048,0x00050048,0x000000f7,0x0000000d, 300x0000000c,0x00000023,0x00000048,0x00050048,
310x00000023,0x0000004c,0x00050048,0x000000f7, 310x000000fa,0x0000000d,0x00000023,0x0000004c,
320x0000000e,0x00000023,0x00000050,0x00050048, 320x00050048,0x000000fa,0x0000000e,0x00000023,
330x000000f7,0x0000000f,0x00000023,0x00000054, 330x00000050,0x00050048,0x000000fa,0x0000000f,
340x00050048,0x000000f7,0x00000010,0x00000023, 340x00000023,0x00000054,0x00050048,0x000000fa,
350x00000058,0x00050048,0x000000f7,0x00000011, 350x00000010,0x00000023,0x00000058,0x00050048,
360x00000023,0x0000005c,0x00050048,0x000000f7, 360x000000fa,0x00000011,0x00000023,0x0000005c,
370x00000012,0x00000023,0x00000060,0x00050048, 370x00050048,0x000000fa,0x00000012,0x00000023,
380x000000f7,0x00000013,0x00000023,0x00000064, 380x00000060,0x00050048,0x000000fa,0x00000013,
390x00040047,0x000009e6,0x0000000b,0x0000001c, 390x00000023,0x00000064,0x00040047,0x00000b0e,
400x00040047,0x000009f0,0x0000000b,0x0000001a, 400x0000000b,0x0000001c,0x00040047,0x00000b17,
410x00040047,0x000009f1,0x0000000b,0x0000001b, 410x0000000b,0x0000001a,0x00040047,0x00000b18,
420x00040047,0x00000a6c,0x0000000b,0x00000019, 420x0000000b,0x0000001b,0x00040047,0x00000bf1,
430x00020013,0x00000002,0x00030021,0x00000003, 430x0000000b,0x00000019,0x00020013,0x00000002,
440x00000002,0x00040015,0x00000006,0x00000020, 440x00030021,0x00000003,0x00000002,0x00040015,
450x00000000,0x00040017,0x00000007,0x00000006, 450x00000006,0x00000020,0x00000000,0x00040017,
460x00000002,0x00040020,0x00000009,0x00000007, 460x00000007,0x00000006,0x00000002,0x00040020,
470x00000006,0x00030027,0x00000014,0x000014e5, 470x00000009,0x00000007,0x00000006,0x00030027,
480x0003001d,0x00000015,0x00000006,0x0003001e, 480x00000014,0x000014e5,0x0003001d,0x00000015,
490x00000016,0x00000015,0x00040020,0x00000014, 490x00000006,0x0003001e,0x00000016,0x00000015,
500x000014e5,0x00000016,0x00030016,0x00000027, 500x00040020,0x00000014,0x000014e5,0x00000016,
510x00000020,0x00040020,0x00000028,0x00000007, 510x00030016,0x00000027,0x00000020,0x00040020,
520x00000027,0x00020014,0x0000002f,0x00040017, 520x00000028,0x00000007,0x00000027,0x00020014,
530x0000004b,0x00000027,0x00000003,0x00040020, 530x0000002f,0x00040017,0x0000004b,0x00000027,
540x0000004c,0x00000007,0x0000004b,0x0004002b, 540x00000003,0x00040020,0x0000004c,0x00000007,
550x00000006,0x000000a3,0x00000000,0x0004001e, 550x0000004b,0x0004002b,0x00000006,0x000000a6,
560x000000a8,0x00000006,0x00000006,0x0004002b, 560x00000000,0x0004001e,0x000000ab,0x00000006,
570x00000006,0x000000ad,0x00000001,0x00040015, 570x00000006,0x0004002b,0x00000006,0x000000b0,
580x000000d6,0x00000020,0x00000001,0x0004002b, 580x00000001,0x00040015,0x000000d9,0x00000020,
590x000000d6,0x000000d7,0x00000000,0x00040020, 590x00000001,0x0004002b,0x000000d9,0x000000da,
600x000000d8,0x000014e5,0x00000006,0x0016001e, 600x00000000,0x00040020,0x000000db,0x000014e5,
610x000000f7,0x00000007,0x00000007,0x00000007, 610x00000006,0x0016001e,0x000000fa,0x00000007,
620x00000007,0x00000007,0x00000007,0x00000006, 620x00000007,0x00000007,0x00000007,0x00000007,
630x00000007,0x00000006,0x00000006,0x00000006,
630x00000006,0x00000006,0x00000006,0x00000006, 640x00000006,0x00000006,0x00000006,0x00000006,
640x00000006,0x00000006,0x00000006,0x00000006, 650x00000006,0x00000006,0x00000006,0x00000006,
650x00000006,0x00000006,0x00000006,0x00000006, 660x00000006,0x00000006,0x00000006,0x00040020,
660x00000006,0x00040020,0x000000f8,0x00000009, 670x000000fb,0x00000009,0x000000fa,0x0004003b,
670x000000f7,0x0004003b,0x000000f8,0x000000f9, 680x000000fb,0x000000fc,0x00000009,0x0004002b,
680x00000009,0x0004002b,0x000000d6,0x000000fa, 690x000000d9,0x000000fd,0x0000000e,0x00040020,
690x0000000e,0x00040020,0x000000fb,0x00000009, 700x000000fe,0x00000009,0x00000006,0x0004002b,
700x00000006,0x0004002b,0x00000006,0x000000fe, 710x00000006,0x00000101,0x00000100,0x0004002b,
710x00000800,0x0004002b,0x00000006,0x00000104, 720x00000006,0x00000107,0x00000040,0x0004002b,
720x00000040,0x0004002b,0x00000006,0x00000107, 730x00000006,0x0000010a,0x00000004,0x0004002b,
730x00000004,0x0004002b,0x00000006,0x0000010e, 740x00000006,0x00000111,0x00000008,0x0004002b,
740x00000008,0x0004002b,0x00000006,0x00000115, 750x00000006,0x00000118,0x0000000c,0x0004002b,
750x0000000c,0x0004002b,0x00000006,0x0000011c, 760x00000006,0x0000011f,0x00000010,0x0004002b,
760x00000010,0x0004002b,0x00000006,0x0000012d, 770x00000006,0x00000130,0x80000000,0x0004002b,
770x80000000,0x0004002b,0x00000006,0x00000142, 780x00000006,0x00000145,0x7fffffff,0x0004002b,
780x7fffffff,0x0004002b,0x00000006,0x0000014d, 790x00000006,0x00000150,0x00000018,0x0004002b,
790x00000018,0x0004002b,0x000000d6,0x00000151, 800x000000d9,0x00000154,0x00000001,0x00040020,
800x00000001,0x00040020,0x00000153,0x00000009, 810x00000156,0x00000009,0x00000007,0x0004002b,
810x00000007,0x0004002b,0x00000006,0x0000016d, 820x00000006,0x00000170,0x00000002,0x0004002b,
820x00000002,0x0004002b,0x00000006,0x00000186, 830x00000006,0x00000189,0x00000014,0x0004002b,
830x00000014,0x0004002b,0x00000027,0x000001ea, 840x00000027,0x000001ed,0x3f000000,0x0004002b,
840x3f000000,0x0004002b,0x000000d6,0x00000202, 850x000000d9,0x00000205,0x00000002,0x0004002b,
850x00000002,0x0004002b,0x000000d6,0x0000020a, 860x000000d9,0x0000020d,0x00000003,0x0004002b,
860x00000003,0x0004002b,0x000000d6,0x00000212, 870x000000d9,0x00000215,0x00000004,0x0004002b,
870x00000004,0x0004002b,0x000000d6,0x0000021a, 880x000000d9,0x0000021d,0x00000005,0x0004002b,
880x00000005,0x0004002b,0x000000d6,0x00000221, 890x000000d9,0x00000224,0x00000013,0x0004002b,
890x00000013,0x0004002b,0x00000006,0x00000225, 900x00000006,0x00000228,0x00000080,0x0004002b,
900x00000080,0x0004002b,0x000000d6,0x00000229, 910x000000d9,0x0000022c,0x0000000f,0x0004002b,
910x0000000f,0x0004002b,0x000000d6,0x00000230, 920x000000d9,0x00000233,0x00000006,0x0004002b,
920x00000006,0x0004002b,0x00000006,0x00000236, 930x00000006,0x00000239,0x00000006,0x0004002b,
930x00000006,0x0004002b,0x000000d6,0x0000023b, 940x000000d9,0x0000023e,0x00000010,0x0004002b,
940x00000010,0x0004002b,0x00000006,0x00000243, 950x00000006,0x00000246,0x00000005,0x0004002b,
950x00000005,0x0004002b,0x000000d6,0x0000024d, 960x000000d9,0x00000250,0x00000009,0x0004002b,
960x00000009,0x0004002b,0x000000d6,0x00000263, 970x000000d9,0x00000266,0x0000000a,0x0004002b,
970x0000000a,0x0004002b,0x00000027,0x0000026a, 980x00000027,0x0000026d,0x00000000,0x0004002b,
980x00000000,0x0004002b,0x000000d6,0x00000278, 990x000000d9,0x0000027b,0x0000000b,0x0004002b,
990x0000000b,0x0004002b,0x00000006,0x000002a0, 1000x00000006,0x000002a3,0x0000ffff,0x0004002b,
1000x0000ffff,0x0004002b,0x00000006,0x000002b4, 1010x00000006,0x000002b7,0x00000003,0x00040017,
1010x00000003,0x00040017,0x000002b9,0x00000027, 1020x000002bc,0x00000027,0x00000004,0x0004001c,
1020x00000004,0x0004001c,0x000002f3,0x0000004b, 1030x000002f6,0x0000004b,0x000002b7,0x00040020,
1030x000002b4,0x00040020,0x000002f4,0x00000007, 1040x000002f7,0x00000007,0x000002f6,0x0004002b,
1040x000002f3,0x0004002b,0x000000d6,0x00000305, 1050x000000d9,0x00000308,0x00000008,0x0004002b,
1050x00000008,0x0004002b,0x00000006,0x00000344, 1060x00000006,0x00000347,0x00000024,0x0004002b,
1060x00000024,0x0004002b,0x00000006,0x0000034f, 1070x00000006,0x00000352,0x00000028,0x0004002b,
1070x00000028,0x0004002b,0x00000006,0x0000035a, 1080x00000006,0x0000035d,0x0000002c,0x0004002b,
1080x0000002c,0x0004002b,0x00000006,0x00000365, 1090x00000006,0x00000368,0x00000030,0x0004002b,
1090x00000030,0x0004002b,0x000000d6,0x00000367, 1100x000000d9,0x0000036a,0x0000000c,0x0004002b,
1100x0000000c,0x0004002b,0x00000006,0x00000371, 1110x00000006,0x00000374,0x00000034,0x0004002b,
1110x00000034,0x0004002b,0x00000006,0x0000037b, 1120x00000006,0x0000037e,0x00000038,0x0004002b,
1120x00000038,0x0004002b,0x00000006,0x0000037d, 1130x00000006,0x00000380,0xffffffff,0x0004002b,
1130xffffffff,0x0004002b,0x00000006,0x00000385, 1140x00000006,0x00000388,0x0000003c,0x0004002b,
1140x0000003c,0x0004002b,0x00000006,0x00000387, 1150x00000006,0x0000038a,0x00000009,0x00040017,
1150x00000009,0x00040017,0x00000392,0x0000002f, 1160x00000395,0x0000002f,0x00000003,0x0004001c,
1160x00000003,0x0004001c,0x000003d6,0x00000027, 1170x000003d9,0x00000027,0x00000118,0x00040020,
1170x00000115,0x00040020,0x000003d7,0x00000007, 1180x000003da,0x00000007,0x000003d9,0x0004002b,
1180x000003d6,0x0004002b,0x00000006,0x00000460, 1190x00000006,0x00000463,0x0000001c,0x0004002b,
1190x0000001c,0x0004002b,0x00000006,0x00000466, 1200x00000006,0x00000469,0x00000020,0x0004002b,
1200x00000020,0x0004002b,0x000000d6,0x0000047b, 1210x000000d9,0x0000047e,0x00000018,0x0004002b,
1210x00000018,0x0004002b,0x000000d6,0x000004d5, 1220x000000d9,0x000004d8,0x00000007,0x0004002b,
1220x00000007,0x0004002b,0x00000027,0x000004f9, 1230x00000027,0x000004fc,0x3f800000,0x0004002b,
1230x3f800000,0x0004002b,0x00000006,0x0000052e, 1240x00000006,0x00000531,0x3fffffff,0x00040018,
1240x3fffffff,0x00040018,0x00000548,0x0000004b, 1250x0000054b,0x0000004b,0x00000003,0x00040020,
1250x00000003,0x00040020,0x00000549,0x00000007, 1260x0000054c,0x00000007,0x0000054b,0x0006002c,
1260x00000548,0x0006002c,0x0000004b,0x0000056d, 1270x0000004b,0x00000570,0x0000026d,0x0000026d,
1270x0000026a,0x0000026a,0x0000026a,0x0006002c, 1280x0000026d,0x0006002c,0x0000054b,0x00000571,
1280x00000548,0x0000056e,0x0000056d,0x0000056d, 1290x00000570,0x00000570,0x00000570,0x0004002b,
1290x0000056d,0x0004002b,0x00000006,0x00000594, 1300x00000006,0x00000597,0x00000044,0x0004002b,
1300x00000044,0x0004002b,0x00000006,0x000005a3, 1310x00000006,0x000005a6,0x00000048,0x0004002b,
1310x00000048,0x0004002b,0x00000006,0x000005b2, 1320x00000006,0x000005b5,0x0000004c,0x0004002b,
1320x0000004c,0x0004002b,0x00000006,0x000005c3, 1330x00000006,0x000005c6,0x00000070,0x0004002b,
1330x00000070,0x0004002b,0x00000006,0x000005cd, 1340x00000006,0x000005d0,0x00000074,0x0004002b,
1340x00000074,0x0004002b,0x00000006,0x000005d6, 1350x00000006,0x000005d9,0x00000078,0x0004002b,
1350x00000078,0x0004002b,0x00000006,0x000005df, 1360x00000006,0x000005e2,0x0000007c,0x0004002b,
1360x0000007c,0x0004002b,0x00000006,0x000005fb, 1370x00000006,0x000005fe,0x000003ff,0x0004002b,
1370x000003ff,0x0004002b,0x00000006,0x00000602, 1380x00000006,0x00000605,0x030000ff,0x0004002b,
1380x030000ff,0x0004002b,0x00000006,0x00000608, 1390x00000006,0x0000060b,0x0300f00f,0x0004002b,
1390x0300f00f,0x0004002b,0x00000006,0x0000060e, 1400x00000006,0x00000611,0x030c30c3,0x0004002b,
1400x030c30c3,0x0004002b,0x00000006,0x00000614, 1410x00000006,0x00000617,0x09249249,0x0004002b,
1410x09249249,0x0004002b,0x00000027,0x00000657, 1420x00000027,0x0000065a,0x0da24260,0x0006002c,
1420x0da24260,0x0006002c,0x0000004b,0x00000658, 1430x0000004b,0x0000065b,0x0000065a,0x0000065a,
1430x00000657,0x00000657,0x00000657,0x00040017, 1440x0000065a,0x00040017,0x0000065d,0x00000006,
1440x0000065a,0x00000006,0x00000003,0x0004002b, 1450x00000003,0x0004002b,0x00000027,0x0000066b,
1450x00000027,0x00000668,0x447fc000,0x0004002b, 1460x447fc000,0x0004002b,0x00000006,0x000006ac,
1460x00000006,0x000006ca,0x0000000f,0x0004001c, 1470x00000400,0x0004001c,0x000006ad,0x00000006,
1470x000006d2,0x00000006,0x0000011c,0x00040020, 1480x000006ac,0x00040020,0x000006ae,0x00000004,
1480x000006d3,0x00000004,0x000006d2,0x0004003b, 1490x000006ad,0x0004003b,0x000006ae,0x000006af,
1490x000006d3,0x000006d4,0x00000004,0x00040020, 1500x00000004,0x00040020,0x000006c2,0x00000004,
1500x000006d6,0x00000004,0x00000006,0x0004002b, 1510x00000006,0x0004003b,0x000006ae,0x000006c4,
1510x00000006,0x000006d8,0x00000108,0x0004002b, 1520x00000004,0x0004002b,0x00000006,0x000006da,
1520x00000006,0x00000717,0x0000003f,0x0004001c, 1530x00000108,0x0004002b,0x00000006,0x00000799,
1530x0000073e,0x00000006,0x00000104,0x00040020, 1540x0000000f,0x0004001c,0x000007a1,0x00000006,
1540x0000073f,0x00000004,0x0000073e,0x0004003b, 1550x0000011f,0x00040020,0x000007a2,0x00000004,
1550x0000073f,0x00000740,0x00000004,0x0004003b, 1560x000007a1,0x0004003b,0x000007a2,0x000007a3,
1560x000006d3,0x00000789,0x00000004,0x0004001c, 1570x00000004,0x0004002b,0x00000006,0x000007e4,
1570x000007e0,0x0000073e,0x0000011c,0x00040020, 1580x0000003f,0x0004001c,0x0000080b,0x00000006,
1580x000007e1,0x00000004,0x000007e0,0x0004003b, 1590x00000107,0x00040020,0x0000080c,0x00000004,
1590x000007e1,0x000007e2,0x00000004,0x00040020, 1600x0000080b,0x0004003b,0x0000080c,0x0000080d,
1600x000007fe,0x00000007,0x000006d2,0x0004002b, 1610x00000004,0x0004003b,0x000007a2,0x00000856,
1610x000000d6,0x00000850,0x0000003f,0x0004002b, 1620x00000004,0x0004001c,0x000008ad,0x0000080b,
1620x000000d6,0x000008bc,0x0000000d,0x0004002b, 1630x0000011f,0x00040020,0x000008ae,0x00000004,
1630x000000d6,0x000008c7,0x00000011,0x0004002b, 1640x000008ad,0x0004003b,0x000008ae,0x000008af,
1640x000000d6,0x0000096f,0x00000012,0x00040020, 1650x00000004,0x00040020,0x000008cb,0x00000007,
1650x000009e5,0x00000001,0x0000065a,0x0004003b, 1660x000007a1,0x0004002b,0x000000d9,0x0000091d,
1660x000009e5,0x000009e6,0x00000001,0x00040020, 1670x0000003f,0x0004002b,0x00000006,0x00000967,
1670x000009e7,0x00000001,0x00000006,0x0004002b, 1680x00000007,0x0004002b,0x000000d9,0x0000096c,
1680x00000006,0x000009ec,0x00000007,0x0004003b, 1690x0000000d,0x0004002b,0x000000d9,0x000009ef,
1690x000009e5,0x000009f0,0x00000001,0x0004003b, 1700x00000011,0x0004002b,0x000000d9,0x00000a97,
1700x000009e5,0x000009f1,0x00000001,0x0006002c, 1710x00000012,0x00040020,0x00000b0d,0x00000001,
1710x0000065a,0x00000a6c,0x00000104,0x000000ad, 1720x0000065d,0x0004003b,0x00000b0d,0x00000b0e,
1720x000000ad,0x0006002c,0x0000004b,0x00002b61, 1730x00000001,0x00040020,0x00000b0f,0x00000001,
1730x000004f9,0x000004f9,0x000004f9,0x0004002b, 1740x00000006,0x0004003b,0x00000b0d,0x00000b17,
1740x00000027,0x00002b63,0x7f800000,0x0006002c, 1750x00000001,0x0004003b,0x00000b0d,0x00000b18,
1750x0000004b,0x00002b64,0x00002b63,0x00002b63, 1760x00000001,0x0004002b,0x00000006,0x00000b3a,
1760x00002b63,0x0004002b,0x00000027,0x00002b65, 1770x0000000a,0x0004002b,0x00000006,0x00000b57,
1770xff800000,0x0006002c,0x0000004b,0x00002b66, 1780x0000000d,0x0004002b,0x00000006,0x00000b94,
1780x00002b65,0x00002b65,0x00002b65,0x0004002b, 1790x0000000b,0x0006002c,0x0000065d,0x00000bf1,
1790x00000006,0x00002b67,0x000007ff,0x00050036, 1800x00000107,0x000000b0,0x000000b0,0x0006002c,
1800x00000002,0x00000004,0x00000000,0x00000003, 1810x0000004b,0x000032a2,0x000004fc,0x000004fc,
1810x000200f8,0x00000005,0x0004003b,0x000003d7, 1820x000004fc,0x0004002b,0x00000027,0x000032a4,
1820x00001884,0x00000007,0x0004003b,0x00000549, 1830x7f800000,0x0006002c,0x0000004b,0x000032a5,
1830x000018c5,0x00000007,0x0004003b,0x0000004c, 1840x000032a4,0x000032a4,0x000032a4,0x0004002b,
1840x000018c8,0x00000007,0x0004003b,0x0000004c, 1850x00000027,0x000032a6,0xff800000,0x0006002c,
1850x00001424,0x00000007,0x0004003b,0x000002f4, 1860x0000004b,0x000032a7,0x000032a6,0x000032a6,
1860x00001239,0x00000007,0x0004003b,0x000007fe, 1870x000032a6,0x0004002b,0x00000006,0x000032a8,
1870x00000c2a,0x00000007,0x000300f7,0x00000a6e, 1880x000000ff,0x00050036,0x00000002,0x00000004,
1880x00000000,0x000300fb,0x000000a3,0x00000a6f, 1890x00000000,0x00000003,0x000200f8,0x00000005,
1890x000200f8,0x00000a6f,0x00050041,0x000009e7, 1900x0004003b,0x000003da,0x00001c65,0x00000007,
1900x000009e8,0x000009e6,0x000000a3,0x0004003d, 1910x0004003b,0x0000054c,0x00001ca6,0x00000007,
1910x00000006,0x000009e9,0x000009e8,0x00050041, 1920x0004003b,0x0000004c,0x00001ca9,0x00000007,
1920x000000fb,0x000009ea,0x000000f9,0x00000230, 1930x0004003b,0x0000004c,0x00001805,0x00000007,
1930x0004003d,0x00000006,0x000009eb,0x000009ea, 1940x0004003b,0x000002f7,0x0000161a,0x00000007,
1940x000500aa,0x0000002f,0x000009ed,0x000009eb, 1950x0004003b,0x000008cb,0x00000daf,0x00000007,
1950x000009ec,0x000300f7,0x000009ef,0x00000000, 1960x000300f7,0x00000bf3,0x00000000,0x000300fb,
1960x000400fa,0x000009ed,0x000009ee,0x000009ef, 1970x000000a6,0x00000bf4,0x000200f8,0x00000bf4,
1970x000200f8,0x000009ee,0x00050041,0x000009e7, 1980x00050041,0x00000b0f,0x00000b10,0x00000b0e,
1980x000009f3,0x000009f0,0x000000a3,0x0004003d, 1990x000000a6,0x0004003d,0x00000006,0x00000b11,
1990x00000006,0x000009f4,0x000009f3,0x00050041, 2000x00000b10,0x00050041,0x000000fe,0x00000b12,
2000x000009e7,0x000009f6,0x000009f1,0x000000a3, 2010x000000fc,0x00000233,0x0004003d,0x00000006,
2010x0004003d,0x00000006,0x000009f7,0x000009f6, 2020x00000b13,0x00000b12,0x000500aa,0x0000002f,
2020x000500b0,0x0000002f,0x00000a8b,0x000009f7, 2030x00000b14,0x00000b13,0x00000967,0x000300f7,
2030x0000011c,0x000300f7,0x00000a8f,0x00000000, 2040x00000b16,0x00000000,0x000400fa,0x00000b14,
2040x000400fa,0x00000a8b,0x00000a8c,0x00000a8f, 2050x00000b15,0x00000b16,0x000200f8,0x00000b15,
2050x000200f8,0x00000a8c,0x00050041,0x000006d6, 2060x00050041,0x00000b0f,0x00000b1a,0x00000b17,
2060x00000a8e,0x000006d4,0x000009f7,0x0003003e, 2070x000000a6,0x0004003d,0x00000006,0x00000b1b,
2070x00000a8e,0x000000a3,0x000200f9,0x00000a8f, 2080x00000b1a,0x00050041,0x00000b0f,0x00000b1d,
2080x000200f8,0x00000a8f,0x000400e0,0x0000016d, 2090x00000b18,0x000000a6,0x0004003d,0x00000006,
2090x0000016d,0x000006d8,0x00050084,0x00000006, 2100x00000b1e,0x00000b1d,0x000500b0,0x0000002f,
2100x00000a91,0x000009f4,0x000000fe,0x00050080, 2110x00000c10,0x00000b1e,0x0000011f,0x000300f7,
2110x00000006,0x00000a93,0x00000a91,0x000000fe, 2120x00000c14,0x00000000,0x000400fa,0x00000c10,
2120x00050041,0x000000fb,0x00000a94,0x000000f9, 2130x00000c11,0x00000c14,0x000200f8,0x00000c11,
2130x000000fa,0x0004003d,0x00000006,0x00000a95, 2140x00050041,0x000006c2,0x00000c13,0x000007a3,
2140x00000a94,0x0007000c,0x00000006,0x00000a96, 2150x00000b1e,0x0003003e,0x00000c13,0x000000a6,
2150x00000001,0x00000026,0x00000a93,0x00000a95, 2160x000200f9,0x00000c14,0x000200f8,0x00000c14,
2160x00050080,0x00000006,0x00000a99,0x00000a91, 2170x000400e0,0x00000170,0x00000170,0x000006da,
2170x000009f7,0x000200f9,0x00000a9a,0x000200f8, 2180x00050084,0x00000006,0x00000c16,0x00000b1b,
2180x00000a9a,0x000700f5,0x00000006,0x00002b52, 2190x00000101,0x00050080,0x00000006,0x00000c18,
2190x00000a99,0x00000a8f,0x00000aac,0x00000aaa, 2200x00000c16,0x00000101,0x00050041,0x000000fe,
2200x000500b0,0x0000002f,0x00000a9e,0x00002b52, 2210x00000c19,0x000000fc,0x000000fd,0x0004003d,
2210x00000a96,0x000400f6,0x00000aad,0x00000aaa, 2220x00000006,0x00000c1a,0x00000c19,0x0007000c,
2220x00000000,0x000400fa,0x00000a9e,0x00000a9f, 2230x00000006,0x00000c1b,0x00000001,0x00000026,
2230x00000aad,0x000200f8,0x00000a9f,0x00050041, 2240x00000c18,0x00000c1a,0x00050080,0x00000006,
2240x000000fb,0x00000ac3,0x000000f9,0x00000305, 2250x00000c1e,0x00000c16,0x00000b1e,0x000200f9,
2250x0004003d,0x00000006,0x00000ac4,0x00000ac3, 2260x00000c1f,0x000200f8,0x00000c1f,0x000700f5,
2260x000500c7,0x00000006,0x00000ac5,0x00000ac4, 2270x00000006,0x00003283,0x00000c1e,0x00000c14,
2270x000000ad,0x000500aa,0x0000002f,0x00000ac6, 2280x00000c31,0x00000c2f,0x000500b0,0x0000002f,
2280x00000ac5,0x000000a3,0x000300f7,0x00000acb, 2290x00000c23,0x00003283,0x00000c1b,0x000400f6,
2290x00000000,0x000400fa,0x00000ac6,0x00000ac7, 2300x00000c32,0x00000c2f,0x00000000,0x000400fa,
2300x00000ac9,0x000200f8,0x00000ac7,0x000200f9, 2310x00000c23,0x00000c24,0x00000c32,0x000200f8,
2310x00000acb,0x000200f8,0x00000ac9,0x00050084, 2320x00000c24,0x00050041,0x000000fe,0x00000c48,
2320x00000006,0x00000ad3,0x0000010e,0x00000a95, 2330x000000fc,0x00000308,0x0004003d,0x00000006,
2330x00050080,0x00000006,0x00000ad4,0x00000104, 2340x00000c49,0x00000c48,0x000500c7,0x00000006,
2340x00000ad3,0x000200f9,0x00000acb,0x000200f8, 2350x00000c4a,0x00000c49,0x000000b0,0x000500aa,
2350x00000acb,0x000700f5,0x00000006,0x00002b53, 2360x0000002f,0x00000c4b,0x00000c4a,0x000000a6,
2360x00000104,0x00000ac7,0x00000ad4,0x00000ac9, 2370x000300f7,0x00000c50,0x00000000,0x000400fa,
2370x00050084,0x00000006,0x00000aa2,0x00000107, 2380x00000c4b,0x00000c4c,0x00000c4e,0x000200f8,
2380x00002b52,0x00050080,0x00000006,0x00000aa3, 2390x00000c4c,0x000200f9,0x00000c50,0x000200f8,
2390x00002b53,0x00000aa2,0x00050041,0x00000153, 2400x00000c4e,0x00050084,0x00000006,0x00000c58,
2400x00000aa4,0x000000f9,0x00000151,0x0004003d, 2410x00000111,0x00000c1a,0x00050080,0x00000006,
2410x00000007,0x00000aa5,0x00000aa4,0x00050051, 2420x00000c59,0x00000107,0x00000c58,0x000200f9,
2420x00000006,0x00000aeb,0x00000aa5,0x00000000, 2430x00000c50,0x000200f8,0x00000c50,0x000700f5,
2430x00050095,0x000000a8,0x00000aed,0x00000aeb, 2440x00000006,0x00003284,0x00000107,0x00000c4c,
2440x00000aa3,0x00050051,0x00000006,0x00000aee, 2450x00000c59,0x00000c4e,0x00050084,0x00000006,
2450x00000aed,0x00000001,0x00050051,0x00000006, 2460x00000c27,0x0000010a,0x00003283,0x00050080,
2460x00000aef,0x00000aed,0x00000000,0x00050051, 2470x00000006,0x00000c28,0x00003284,0x00000c27,
2470x00000006,0x00000af2,0x00000aa5,0x00000001, 2480x00050041,0x00000156,0x00000c29,0x000000fc,
2480x00050080,0x00000006,0x00000af4,0x00000af2, 2490x00000154,0x0004003d,0x00000007,0x00000c2a,
2490x00000aee,0x00050050,0x00000007,0x00000af5, 2500x00000c29,0x00050051,0x00000006,0x00000c70,
2500x00000aef,0x00000af4,0x0004007c,0x00000014, 2510x00000c2a,0x00000000,0x00050095,0x000000ab,
2510x00000ae5,0x00000af5,0x00060041,0x000000d8, 2520x00000c72,0x00000c70,0x00000c28,0x00050051,
2520x00000adc,0x00000ae5,0x000000d7,0x000000d7, 2530x00000006,0x00000c73,0x00000c72,0x00000001,
2530x0006003d,0x00000006,0x00000add,0x00000adc, 2540x00050051,0x00000006,0x00000c74,0x00000c72,
2550x00000000,0x00050051,0x00000006,0x00000c77,
2560x00000c2a,0x00000001,0x00050080,0x00000006,
2570x00000c79,0x00000c77,0x00000c73,0x00050050,
2580x00000007,0x00000c7a,0x00000c74,0x00000c79,
2590x0004007c,0x00000014,0x00000c6a,0x00000c7a,
2600x00060041,0x000000db,0x00000c61,0x00000c6a,
2610x000000da,0x000000da,0x0006003d,0x00000006,
2620x00000c62,0x00000c61,0x00000002,0x00000004,
2630x00050084,0x00000006,0x00000c80,0x0000010a,
2640x00000c49,0x000500c2,0x00000006,0x00000c81,
2650x00000c62,0x00000c80,0x000500c7,0x00000006,
2660x00000c82,0x00000c81,0x00000799,0x00050041,
2670x000006c2,0x00000c2d,0x000007a3,0x00000c82,
2680x000700ea,0x00000006,0x00000c2e,0x00000c2d,
2690x000000b0,0x000000a6,0x000000b0,0x000200f9,
2700x00000c2f,0x000200f8,0x00000c2f,0x00050080,
2710x00000006,0x00000c31,0x00003283,0x00000107,
2720x000200f9,0x00000c1f,0x000200f8,0x00000c32,
2730x000400e0,0x00000170,0x00000170,0x000006da,
2740x000300f7,0x00000c44,0x00000000,0x000400fa,
2750x00000c10,0x00000c35,0x00000c44,0x000200f8,
2760x00000c35,0x00050084,0x00000006,0x00000c87,
2770x0000011f,0x00000c1a,0x00050080,0x00000006,
2780x00000c88,0x00000107,0x00000c87,0x00050080,
2790x00000006,0x00000c8e,0x00000c1a,0x000032a8,
2800x00050086,0x00000006,0x00000c8f,0x00000c8e,
2810x00000101,0x00050084,0x00000006,0x00000c39,
2820x00000b1e,0x00000c8f,0x00050080,0x00000006,
2830x00000c3b,0x00000c39,0x00000b1b,0x00050084,
2840x00000006,0x00000c3c,0x0000010a,0x00000c3b,
2850x00050080,0x00000006,0x00000c3d,0x00000c88,
2860x00000c3c,0x00050041,0x00000156,0x00000c3f,
2870x000000fc,0x00000154,0x0004003d,0x00000007,
2880x00000c40,0x00000c3f,0x00050041,0x000006c2,
2890x00000c41,0x000007a3,0x00000b1e,0x0004003d,
2900x00000006,0x00000c42,0x00000c41,0x00050051,
2910x00000006,0x00000ca5,0x00000c40,0x00000000,
2920x00050095,0x000000ab,0x00000ca7,0x00000ca5,
2930x00000c3d,0x00050051,0x00000006,0x00000ca8,
2940x00000ca7,0x00000001,0x00050051,0x00000006,
2950x00000ca9,0x00000ca7,0x00000000,0x00050051,
2960x00000006,0x00000cac,0x00000c40,0x00000001,
2970x00050080,0x00000006,0x00000cae,0x00000cac,
2980x00000ca8,0x00050050,0x00000007,0x00000caf,
2990x00000ca9,0x00000cae,0x0004007c,0x00000014,
3000x00000c9f,0x00000caf,0x00060041,0x000000db,
3010x00000c97,0x00000c9f,0x000000da,0x000000da,
3020x0005003e,0x00000c97,0x00000c42,0x00000002,
3030x00000004,0x000200f9,0x00000c44,0x000200f8,
3040x00000c44,0x000200f9,0x00000bf3,0x000200f8,
3050x00000b16,0x000500aa,0x0000002f,0x00000b23,
3060x00000b13,0x00000111,0x000300f7,0x00000b25,
3070x00000000,0x000400fa,0x00000b23,0x00000b24,
3080x00000b25,0x000200f8,0x00000b24,0x00050041,
3090x00000b0f,0x00000b27,0x00000b18,0x000000a6,
3100x0004003d,0x00000006,0x00000b28,0x00000b27,
3110x00050041,0x000000fe,0x00000d22,0x000000fc,
3120x000000fd,0x0004003d,0x00000006,0x00000d23,
3130x00000d22,0x00050080,0x00000006,0x00000d25,
3140x00000d23,0x000032a8,0x00050086,0x00000006,
3150x00000d26,0x00000d25,0x00000101,0x00050084,
3160x00000006,0x00000cc5,0x0000011f,0x00000d26,
3170x00050080,0x00000006,0x00000cc7,0x00000cc5,
3180x000007e4,0x00050086,0x00000006,0x00000cc8,
3190x00000cc7,0x00000107,0x00050084,0x00000006,
3200x00000ccb,0x00000b28,0x00000cc8,0x0007000c,
3210x00000006,0x00000ccd,0x00000001,0x00000026,
3220x00000ccb,0x00000cc5,0x00050080,0x00000006,
3230x00000cd0,0x00000ccd,0x00000cc8,0x0007000c,
3240x00000006,0x00000cd2,0x00000001,0x00000026,
3250x00000cd0,0x00000cc5,0x000200f9,0x00000cd4,
3260x000200f8,0x00000cd4,0x000700f5,0x00000006,
3270x0000327e,0x000000a6,0x00000b24,0x00000ce2,
3280x00000cd9,0x000700f5,0x00000006,0x0000327d,
3290x00000ccd,0x00000b24,0x00000ce5,0x00000cd9,
3300x000500b0,0x0000002f,0x00000cd8,0x0000327d,
3310x00000cd2,0x000400f6,0x00000ce6,0x00000cd9,
3320x00000000,0x000400fa,0x00000cd8,0x00000cd9,
3330x00000ce6,0x000200f8,0x00000cd9,0x00050084,
3340x00000006,0x00000d2b,0x0000011f,0x00000d23,
3350x00050080,0x00000006,0x00000d2c,0x00000107,
3360x00000d2b,0x00050084,0x00000006,0x00000cdc,
3370x0000010a,0x0000327d,0x00050080,0x00000006,
3380x00000cdd,0x00000d2c,0x00000cdc,0x00050041,
3390x00000156,0x00000cde,0x000000fc,0x00000154,
3400x0004003d,0x00000007,0x00000cdf,0x00000cde,
3410x00050051,0x00000006,0x00000d43,0x00000cdf,
3420x00000000,0x00050095,0x000000ab,0x00000d45,
3430x00000d43,0x00000cdd,0x00050051,0x00000006,
3440x00000d46,0x00000d45,0x00000001,0x00050051,
3450x00000006,0x00000d47,0x00000d45,0x00000000,
3460x00050051,0x00000006,0x00000d4a,0x00000cdf,
3470x00000001,0x00050080,0x00000006,0x00000d4c,
3480x00000d4a,0x00000d46,0x00050050,0x00000007,
3490x00000d4d,0x00000d47,0x00000d4c,0x0004007c,
3500x00000014,0x00000d3d,0x00000d4d,0x00060041,
3510x000000db,0x00000d34,0x00000d3d,0x000000da,
3520x000000da,0x0006003d,0x00000006,0x00000d35,
3530x00000d34,0x00000002,0x00000004,0x00050080,
3540x00000006,0x00000ce2,0x0000327e,0x00000d35,
3550x00050080,0x00000006,0x00000ce5,0x0000327d,
3560x00000154,0x000200f9,0x00000cd4,0x000200f8,
3570x00000ce6,0x00050041,0x000006c2,0x00000ce9,
3580x0000080d,0x00000b28,0x0003003e,0x00000ce9,
3590x0000327e,0x000400e0,0x00000170,0x00000170,
3600x000006da,0x000500aa,0x0000002f,0x00000ceb,
3610x00000b28,0x000000a6,0x000300f7,0x00000cff,
3620x00000000,0x000400fa,0x00000ceb,0x00000cec,
3630x00000cff,0x000200f8,0x00000cec,0x000200f9,
3640x00000ced,0x000200f8,0x00000ced,0x000700f5,
3650x00000006,0x00003282,0x000000a6,0x00000cec,
3660x00000cfa,0x00000cf1,0x000700f5,0x00000006,
3670x0000327f,0x000000a6,0x00000cec,0x00000cfd,
3680x00000cf1,0x000500b0,0x0000002f,0x00000cf0,
3690x0000327f,0x00000107,0x000400f6,0x00000cfe,
3700x00000cf1,0x00000000,0x000400fa,0x00000cf0,
3710x00000cf1,0x00000cfe,0x000200f8,0x00000cf1,
3720x00050041,0x000006c2,0x00000cf3,0x0000080d,
3730x0000327f,0x0004003d,0x00000006,0x00000cf4,
3740x00000cf3,0x0003003e,0x00000cf3,0x00003282,
3750x00050080,0x00000006,0x00000cfa,0x00003282,
3760x00000cf4,0x00050080,0x00000006,0x00000cfd,
3770x0000327f,0x00000154,0x000200f9,0x00000ced,
3780x000200f8,0x00000cfe,0x000200f9,0x00000cff,
3790x000200f8,0x00000cff,0x000400e0,0x00000170,
3800x00000170,0x000006da,0x0004003d,0x00000006,
3810x00000d02,0x00000ce9,0x000200f9,0x00000d04,
3820x000200f8,0x00000d04,0x000700f5,0x00000006,
3830x00003281,0x00000d02,0x00000cff,0x00000d1b,
3840x00000d09,0x000700f5,0x00000006,0x00003280,
3850x00000ccd,0x00000cff,0x00000d1e,0x00000d09,
3860x000500b0,0x0000002f,0x00000d08,0x00003280,
3870x00000cd2,0x000400f6,0x00000d1f,0x00000d09,
3880x00000000,0x000400fa,0x00000d08,0x00000d09,
3890x00000d1f,0x000200f8,0x00000d09,0x00050084,
3900x00000006,0x00000d52,0x0000011f,0x00000d23,
3910x00050080,0x00000006,0x00000d53,0x00000107,
3920x00000d52,0x00050084,0x00000006,0x00000d0c,
3930x0000010a,0x00003280,0x00050080,0x00000006,
3940x00000d0d,0x00000d53,0x00000d0c,0x00050041,
3950x00000156,0x00000d0e,0x000000fc,0x00000154,
3960x0004003d,0x00000007,0x00000d0f,0x00000d0e,
3970x00050051,0x00000006,0x00000d6a,0x00000d0f,
3980x00000000,0x00050095,0x000000ab,0x00000d6c,
3990x00000d6a,0x00000d0d,0x00050051,0x00000006,
4000x00000d6d,0x00000d6c,0x00000001,0x00050051,
4010x00000006,0x00000d6e,0x00000d6c,0x00000000,
4020x00050051,0x00000006,0x00000d71,0x00000d0f,
4030x00000001,0x00050080,0x00000006,0x00000d73,
4040x00000d71,0x00000d6d,0x00050050,0x00000007,
4050x00000d74,0x00000d6e,0x00000d73,0x0004007c,
4060x00000014,0x00000d64,0x00000d74,0x00060041,
4070x000000db,0x00000d5b,0x00000d64,0x000000da,
4080x000000da,0x0006003d,0x00000006,0x00000d5c,
4090x00000d5b,0x00000002,0x00000004,0x0005003e,
4100x00000d5b,0x00003281,0x00000002,0x00000004,
4110x00050080,0x00000006,0x00000d1b,0x00003281,
4120x00000d5c,0x00050080,0x00000006,0x00000d1e,
4130x00003280,0x00000154,0x000200f9,0x00000d04,
4140x000200f8,0x00000d1f,0x000200f9,0x00000bf3,
4150x000200f8,0x00000b25,0x000500aa,0x0000002f,
4160x00000b2d,0x00000b13,0x0000038a,0x000300f7,
4170x00000b2f,0x00000000,0x000400fa,0x00000b2d,
4180x00000b2e,0x00000b2f,0x000200f8,0x00000b2e,
4190x00050041,0x00000b0f,0x00000b31,0x00000b17,
4200x000000a6,0x0004003d,0x00000006,0x00000b32,
4210x00000b31,0x00050041,0x00000b0f,0x00000b34,
4220x00000b18,0x000000a6,0x0004003d,0x00000006,
4230x00000b35,0x00000b34,0x000500b0,0x0000002f,
4240x00000dbb,0x00000b35,0x0000011f,0x000300f7,
4250x00000dca,0x00000000,0x000400fa,0x00000dbb,
4260x00000dbc,0x00000dca,0x000200f8,0x00000dbc,
4270x00050041,0x000000fe,0x00000e6c,0x000000fc,
4280x000000fd,0x0004003d,0x00000006,0x00000e6d,
4290x00000e6c,0x00050084,0x00000006,0x00000e6e,
4300x0000011f,0x00000e6d,0x00050080,0x00000006,
4310x00000e6f,0x00000107,0x00000e6e,0x00050080,
4320x00000006,0x00000e75,0x00000e6d,0x000032a8,
4330x00050086,0x00000006,0x00000e76,0x00000e75,
4340x00000101,0x00050084,0x00000006,0x00000dc1,
4350x00000b35,0x00000e76,0x00050080,0x00000006,
4360x00000dc3,0x00000dc1,0x00000b32,0x00050084,
4370x00000006,0x00000dc4,0x0000010a,0x00000dc3,
4380x00050080,0x00000006,0x00000dc5,0x00000e6f,
4390x00000dc4,0x00050041,0x00000156,0x00000dc6,
4400x000000fc,0x00000154,0x0004003d,0x00000007,
4410x00000dc7,0x00000dc6,0x00050051,0x00000006,
4420x00000e8d,0x00000dc7,0x00000000,0x00050095,
4430x000000ab,0x00000e8f,0x00000e8d,0x00000dc5,
4440x00050051,0x00000006,0x00000e90,0x00000e8f,
4450x00000001,0x00050051,0x00000006,0x00000e91,
4460x00000e8f,0x00000000,0x00050051,0x00000006,
4470x00000e94,0x00000dc7,0x00000001,0x00050080,
4480x00000006,0x00000e96,0x00000e94,0x00000e90,
4490x00050050,0x00000007,0x00000e97,0x00000e91,
4500x00000e96,0x0004007c,0x00000014,0x00000e87,
4510x00000e97,0x00060041,0x000000db,0x00000e7e,
4520x00000e87,0x000000da,0x000000da,0x0006003d,
4530x00000006,0x00000e7f,0x00000e7e,0x00000002,
4540x00000004,0x00050041,0x000006c2,0x00000dc9,
4550x00000856,0x00000b35,0x0003003e,0x00000dc9,
4560x00000e7f,0x000200f9,0x00000dca,0x000200f8,
4570x00000dca,0x00050084,0x00000006,0x00000dcc,
4580x00000b32,0x00000101,0x00050080,0x00000006,
4590x00000dce,0x00000dcc,0x00000101,0x00050041,
4600x000000fe,0x00000dcf,0x000000fc,0x000000fd,
4610x0004003d,0x00000006,0x00000dd0,0x00000dcf,
4620x0007000c,0x00000006,0x00000dd1,0x00000001,
4630x00000026,0x00000dce,0x00000dd0,0x000200f9,
4640x00000dd3,0x000200f8,0x00000dd3,0x000700f5,
4650x00000006,0x00003264,0x00000dcc,0x00000dca,
4660x00000e68,0x00000e66,0x000500b0,0x0000002f,
4670x00000dd7,0x00003264,0x00000dd1,0x000400f6,
4680x00000e69,0x00000e66,0x00000000,0x000400fa,
4690x00000dd7,0x00000dd8,0x00000e69,0x000200f8,
4700x00000dd8,0x00050080,0x00000006,0x00000ddb,
4710x00003264,0x00000b35,0x000500b0,0x0000002f,
4720x00000dde,0x00000ddb,0x00000dd1,0x000300f7,
4730x00000de9,0x00000000,0x000400fa,0x00000dde,
4740x00000de0,0x00000de8,0x000200f8,0x00000de0,
4750x00050041,0x000000fe,0x00000e9b,0x000000fc,
4760x00000308,0x0004003d,0x00000006,0x00000e9c,
4770x00000e9b,0x000500c7,0x00000006,0x00000e9d,
4780x00000e9c,0x000000b0,0x000500aa,0x0000002f,
4790x00000e9e,0x00000e9d,0x000000a6,0x000300f7,
4800x00000ea3,0x00000000,0x000400fa,0x00000e9e,
4810x00000e9f,0x00000ea1,0x000200f8,0x00000e9f,
4820x000200f9,0x00000ea3,0x000200f8,0x00000ea1,
4830x00050084,0x00000006,0x00000eab,0x00000111,
4840x00000dd0,0x00050080,0x00000006,0x00000eac,
4850x00000107,0x00000eab,0x000200f9,0x00000ea3,
4860x000200f8,0x00000ea3,0x000700f5,0x00000006,
4870x00003265,0x00000107,0x00000e9f,0x00000eac,
4880x00000ea1,0x00050084,0x00000006,0x00000de3,
4890x0000010a,0x00000ddb,0x00050080,0x00000006,
4900x00000de4,0x00003265,0x00000de3,0x00050041,
4910x00000156,0x00000de5,0x000000fc,0x00000154,
4920x0004003d,0x00000007,0x00000de6,0x00000de5,
4930x00050051,0x00000006,0x00000ec3,0x00000de6,
4940x00000000,0x00050095,0x000000ab,0x00000ec5,
4950x00000ec3,0x00000de4,0x00050051,0x00000006,
4960x00000ec6,0x00000ec5,0x00000001,0x00050051,
4970x00000006,0x00000ec7,0x00000ec5,0x00000000,
4980x00050051,0x00000006,0x00000eca,0x00000de6,
4990x00000001,0x00050080,0x00000006,0x00000ecc,
5000x00000eca,0x00000ec6,0x00050050,0x00000007,
5010x00000ecd,0x00000ec7,0x00000ecc,0x0004007c,
5020x00000014,0x00000ebd,0x00000ecd,0x00060041,
5030x000000db,0x00000eb4,0x00000ebd,0x000000da,
5040x000000da,0x0006003d,0x00000006,0x00000eb5,
5050x00000eb4,0x00000002,0x00000004,0x000200f9,
5060x00000de9,0x000200f8,0x00000de8,0x000200f9,
5070x00000de9,0x000200f8,0x00000de9,0x000700f5,
5080x00000006,0x00003266,0x00000eb5,0x00000ea3,
5090x000000a6,0x00000de8,0x000300f7,0x00000df5,
5100x00000000,0x000400fa,0x00000dde,0x00000dec,
5110x00000df4,0x000200f8,0x00000dec,0x00050041,
5120x000000fe,0x00000ed1,0x000000fc,0x00000308,
5130x0004003d,0x00000006,0x00000ed2,0x00000ed1,
5140x000500c7,0x00000006,0x00000ed3,0x00000ed2,
5150x000000b0,0x000500aa,0x0000002f,0x00000ed4,
5160x00000ed3,0x000000a6,0x000300f7,0x00000ed9,
5170x00000000,0x000400fa,0x00000ed4,0x00000ed5,
5180x00000ed7,0x000200f8,0x00000ed5,0x00050084,
5190x00000006,0x00000edf,0x0000010a,0x00000dd0,
5200x00050080,0x00000006,0x00000ee0,0x00000107,
5210x00000edf,0x000200f9,0x00000ed9,0x000200f8,
5220x00000ed7,0x00050084,0x00000006,0x00000ee5,
5230x00000118,0x00000dd0,0x00050080,0x00000006,
5240x00000ee6,0x00000107,0x00000ee5,0x000200f9,
5250x00000ed9,0x000200f8,0x00000ed9,0x000700f5,
5260x00000006,0x00003267,0x00000ee0,0x00000ed5,
5270x00000ee6,0x00000ed7,0x00050084,0x00000006,
5280x00000def,0x0000010a,0x00000ddb,0x00050080,
5290x00000006,0x00000df0,0x00003267,0x00000def,
5300x00050041,0x00000156,0x00000df1,0x000000fc,
5310x00000154,0x0004003d,0x00000007,0x00000df2,
5320x00000df1,0x00050051,0x00000006,0x00000efd,
5330x00000df2,0x00000000,0x00050095,0x000000ab,
5340x00000eff,0x00000efd,0x00000df0,0x00050051,
5350x00000006,0x00000f00,0x00000eff,0x00000001,
5360x00050051,0x00000006,0x00000f01,0x00000eff,
5370x00000000,0x00050051,0x00000006,0x00000f04,
5380x00000df2,0x00000001,0x00050080,0x00000006,
5390x00000f06,0x00000f04,0x00000f00,0x00050050,
5400x00000007,0x00000f07,0x00000f01,0x00000f06,
5410x0004007c,0x00000014,0x00000ef7,0x00000f07,
5420x00060041,0x000000db,0x00000eee,0x00000ef7,
5430x000000da,0x000000da,0x0006003d,0x00000006,
5440x00000eef,0x00000eee,0x00000002,0x00000004,
5450x000200f9,0x00000df5,0x000200f8,0x00000df4,
5460x000200f9,0x00000df5,0x000200f8,0x00000df5,
5470x000700f5,0x00000006,0x00003268,0x00000eef,
5480x00000ed9,0x000000a6,0x00000df4,0x00050041,
5490x000000fe,0x00000f0b,0x000000fc,0x00000308,
5500x0004003d,0x00000006,0x00000f0c,0x00000f0b,
5510x00050084,0x00000006,0x00000f0d,0x0000010a,
5520x00000f0c,0x000500c2,0x00000006,0x00000f0e,
5530x00003266,0x00000f0d,0x000500c7,0x00000006,
5540x00000f0f,0x00000f0e,0x00000799,0x000200f9,
5550x00000df9,0x000200f8,0x00000df9,0x000700f5,
5560x00000006,0x00003269,0x000000a6,0x00000df5,
5570x00000e09,0x00000dfd,0x000500b0,0x0000002f,
5580x00000dfc,0x00003269,0x0000011f,0x000400f6,
5590x00000e0a,0x00000dfd,0x00000000,0x000400fa,
5600x00000dfc,0x00000dfd,0x00000e0a,0x000200f8,
5610x00000dfd,0x000500aa,0x0000002f,0x00000e03,
5620x00003269,0x00000f0f,0x000500a7,0x0000002f,
5630x00000e04,0x00000dde,0x00000e03,0x000600a9,
5640x00000006,0x00000e05,0x00000e04,0x000000b0,
5650x000000a6,0x00060041,0x000006c2,0x00000e06,
5660x000008af,0x00003269,0x00000b35,0x0003003e,
5670x00000e06,0x00000e05,0x00050080,0x00000006,
5680x00000e09,0x00003269,0x00000154,0x000200f9,
5690x00000df9,0x000200f8,0x00000e0a,0x000400e0,
5700x00000170,0x00000170,0x000006da,0x000200f9,
5710x00000e0b,0x000200f8,0x00000e0b,0x000700f5,
5720x00000006,0x0000326a,0x000000b0,0x00000e0a,
5730x00000e3c,0x00000e3a,0x000500b0,0x0000002f,
5740x00000e0e,0x0000326a,0x00000107,0x000400f6,
5750x00000e3d,0x00000e3a,0x00000000,0x000400fa,
5760x00000e0e,0x00000e0f,0x00000e3d,0x000200f8,
5770x00000e0f,0x000200f9,0x00000e10,0x000200f8,
5780x00000e10,0x000700f5,0x00000006,0x00003277,
5790x000000a6,0x00000e0f,0x00000e26,0x00000e24,
5800x000500b0,0x0000002f,0x00000e13,0x00003277,
5810x0000011f,0x000400f6,0x00000e27,0x00000e24,
5820x00000000,0x000400fa,0x00000e13,0x00000e14,
5830x00000e27,0x000200f8,0x00000e14,0x000500ae,
5840x0000002f,0x00000e18,0x00000b35,0x0000326a,
5850x000300f7,0x00000e21,0x00000000,0x000400fa,
5860x00000e18,0x00000e19,0x00000e20,0x000200f8,
5870x00000e19,0x00050082,0x00000006,0x00000e1d,
5880x00000b35,0x0000326a,0x00060041,0x000006c2,
5890x00000e1e,0x000008af,0x00003277,0x00000e1d,
5900x0004003d,0x00000006,0x00000e1f,0x00000e1e,
5910x000200f9,0x00000e21,0x000200f8,0x00000e20,
5920x000200f9,0x00000e21,0x000200f8,0x00000e21,
5930x000700f5,0x00000006,0x0000327b,0x00000e1f,
5940x00000e19,0x000000a6,0x00000e20,0x00050041,
5950x00000009,0x00000e23,0x00000daf,0x00003277,
5960x0003003e,0x00000e23,0x0000327b,0x000200f9,
5970x00000e24,0x000200f8,0x00000e24,0x00050080,
5980x00000006,0x00000e26,0x00003277,0x00000154,
5990x000200f9,0x00000e10,0x000200f8,0x00000e27,
6000x000400e0,0x00000170,0x00000170,0x000006da,
6010x000200f9,0x00000e28,0x000200f8,0x00000e28,
6020x000700f5,0x00000006,0x00003278,0x000000a6,
6030x00000e27,0x00000e38,0x00000e2c,0x000500b0,
6040x0000002f,0x00000e2b,0x00003278,0x0000011f,
6050x000400f6,0x00000e39,0x00000e2c,0x00000000,
6060x000400fa,0x00000e2b,0x00000e2c,0x00000e39,
6070x000200f8,0x00000e2c,0x00050041,0x00000009,
6080x00000e30,0x00000daf,0x00003278,0x0004003d,
6090x00000006,0x00000e31,0x00000e30,0x00060041,
6100x000006c2,0x00000e32,0x000008af,0x00003278,
6110x00000b35,0x0004003d,0x00000006,0x00000e33,
6120x00000e32,0x00050080,0x00000006,0x00000e34,
6130x00000e33,0x00000e31,0x0003003e,0x00000e32,
6140x00000e34,0x00050080,0x00000006,0x00000e38,
6150x00003278,0x00000154,0x000200f9,0x00000e28,
6160x000200f8,0x00000e39,0x000400e0,0x00000170,
6170x00000170,0x000006da,0x000200f9,0x00000e3a,
6180x000200f8,0x00000e3a,0x000500c4,0x00000006,
6190x00000e3c,0x0000326a,0x00000154,0x000200f9,
6200x00000e0b,0x000200f8,0x00000e3d,0x000300f7,
6210x00000e59,0x00000000,0x000400fa,0x00000dde,
6220x00000e3f,0x00000e59,0x000200f8,0x00000e3f,
6230x00050041,0x000006c2,0x00000e41,0x00000856,
6240x00000f0f,0x0004003d,0x00000006,0x00000e42,
6250x00000e41,0x00060041,0x000006c2,0x00000e45,
6260x000008af,0x00000f0f,0x00000b35,0x0004003d,
6270x00000006,0x00000e46,0x00000e45,0x00050080,
6280x00000006,0x00000e47,0x00000e42,0x00000e46,
6290x00050082,0x00000006,0x00000e48,0x00000e47,
6300x000000b0,0x000500c7,0x00000006,0x00000f15,
6310x00000f0c,0x000000b0,0x000500aa,0x0000002f,
6320x00000f16,0x00000f15,0x000000a6,0x000300f7,
6330x00000f1b,0x00000000,0x000400fa,0x00000f16,
6340x00000f17,0x00000f19,0x000200f8,0x00000f17,
6350x00050084,0x00000006,0x00000f21,0x00000111,
6360x00000dd0,0x00050080,0x00000006,0x00000f22,
6370x00000107,0x00000f21,0x000200f9,0x00000f1b,
6380x000200f8,0x00000f19,0x000200f9,0x00000f1b,
6390x000200f8,0x00000f1b,0x000700f5,0x00000006,
6400x0000326b,0x00000f22,0x00000f17,0x00000107,
6410x00000f19,0x00050084,0x00000006,0x00000e4b,
6420x0000010a,0x00000e48,0x00050080,0x00000006,
6430x00000e4c,0x0000326b,0x00000e4b,0x00050041,
6440x00000156,0x00000e4d,0x000000fc,0x00000154,
6450x0004003d,0x00000007,0x00000e4e,0x00000e4d,
6460x00050051,0x00000006,0x00000f3a,0x00000e4e,
6470x00000000,0x00050095,0x000000ab,0x00000f3c,
6480x00000f3a,0x00000e4c,0x00050051,0x00000006,
6490x00000f3d,0x00000f3c,0x00000001,0x00050051,
6500x00000006,0x00000f3e,0x00000f3c,0x00000000,
6510x00050051,0x00000006,0x00000f41,0x00000e4e,
6520x00000001,0x00050080,0x00000006,0x00000f43,
6530x00000f41,0x00000f3d,0x00050050,0x00000007,
6540x00000f44,0x00000f3e,0x00000f43,0x0004007c,
6550x00000014,0x00000f34,0x00000f44,0x00060041,
6560x000000db,0x00000f2c,0x00000f34,0x000000da,
6570x000000da,0x0005003e,0x00000f2c,0x00003266,
6580x00000002,0x00000004,0x000300f7,0x00000f50,
6590x00000000,0x000400fa,0x00000f16,0x00000f4c,
6600x00000f4e,0x000200f8,0x00000f4c,0x00050084,
6610x00000006,0x00000f56,0x00000118,0x00000dd0,
6620x00050080,0x00000006,0x00000f57,0x00000107,
6630x00000f56,0x000200f9,0x00000f50,0x000200f8,
6640x00000f4e,0x00050084,0x00000006,0x00000f5c,
6650x0000010a,0x00000dd0,0x00050080,0x00000006,
6660x00000f5d,0x00000107,0x00000f5c,0x000200f9,
6670x00000f50,0x000200f8,0x00000f50,0x000700f5,
6680x00000006,0x0000326c,0x00000f57,0x00000f4c,
6690x00000f5d,0x00000f4e,0x00050080,0x00000006,
6700x00000e54,0x0000326c,0x00000e4b,0x00050095,
6710x000000ab,0x00000f75,0x00000f3a,0x00000e54,
6720x00050051,0x00000006,0x00000f76,0x00000f75,
6730x00000001,0x00050051,0x00000006,0x00000f77,
6740x00000f75,0x00000000,0x00050080,0x00000006,
6750x00000f7c,0x00000f41,0x00000f76,0x00050050,
6760x00000007,0x00000f7d,0x00000f77,0x00000f7c,
6770x0004007c,0x00000014,0x00000f6d,0x00000f7d,
6780x00060041,0x000000db,0x00000f65,0x00000f6d,
6790x000000da,0x000000da,0x0005003e,0x00000f65,
6800x00003268,0x00000002,0x00000004,0x000200f9,
6810x00000e59,0x000200f8,0x00000e59,0x000400e0,
6820x00000170,0x00000170,0x000006da,0x000300f7,
6830x00000e65,0x00000000,0x000400fa,0x00000dbb,
6840x00000e5c,0x00000e65,0x000200f8,0x00000e5c,
6850x00060041,0x000006c2,0x00000e5f,0x000008af,
6860x00000b35,0x0000091d,0x0004003d,0x00000006,
6870x00000e60,0x00000e5f,0x00050041,0x000006c2,
6880x00000e61,0x00000856,0x00000b35,0x0004003d,
6890x00000006,0x00000e62,0x00000e61,0x00050080,
6900x00000006,0x00000e63,0x00000e62,0x00000e60,
6910x0003003e,0x00000e61,0x00000e63,0x000200f9,
6920x00000e65,0x000200f8,0x00000e65,0x000400e0,
6930x00000170,0x00000170,0x000006da,0x000200f9,
6940x00000e66,0x000200f8,0x00000e66,0x00050080,
6950x00000006,0x00000e68,0x00003264,0x00000107,
6960x000200f9,0x00000dd3,0x000200f8,0x00000e69,
6970x000200f9,0x00000bf3,0x000200f8,0x00000b2f,
6980x000500aa,0x0000002f,0x00000b3b,0x00000b13,
6990x00000b3a,0x000300f7,0x00000b3d,0x00000000,
7000x000400fa,0x00000b3b,0x00000b3c,0x00000b3d,
7010x000200f8,0x00000b3c,0x00050041,0x00000b0f,
7020x00000b3f,0x00000b18,0x000000a6,0x0004003d,
7030x00000006,0x00000b40,0x00000b3f,0x00050041,
7040x000000fe,0x00000f98,0x000000fc,0x000000fd,
7050x0004003d,0x00000006,0x00000f99,0x00000f98,
7060x000200f9,0x00000f9a,0x000200f8,0x00000f9a,
7070x000700f5,0x00000006,0x0000324f,0x000000b0,
7080x00000b3c,0x00000fa1,0x00000f9f,0x000500b0,
7090x0000002f,0x00000f9e,0x0000324f,0x00000f99,
7100x000400f6,0x00000fa3,0x00000f9f,0x00000000,
7110x000400fa,0x00000f9e,0x00000f9f,0x00000fa3,
7120x000200f8,0x00000f9f,0x000500c4,0x00000006,
7130x00000fa1,0x0000324f,0x00000154,0x000200f9,
7140x00000f9a,0x000200f8,0x00000fa3,0x000200f9,
7150x00000fa5,0x000200f8,0x00000fa5,0x000700f5,
7160x00000006,0x00003250,0x00000b40,0x00000fa3,
7170x00000fcd,0x00000fcb,0x000500b0,0x0000002f,
7180x00000fa9,0x00003250,0x0000324f,0x000400f6,
7190x00000fce,0x00000fcb,0x00000000,0x000400fa,
7200x00000fa9,0x00000faa,0x00000fce,0x000200f8,
7210x00000faa,0x000500b0,0x0000002f,0x00000fae,
7220x00003250,0x00000f99,0x000300f7,0x00000fb8,
7230x00000000,0x000400fa,0x00000fae,0x00000faf,
7240x00000fb7,0x000200f8,0x00000faf,0x00050084,
7250x00000006,0x00000fb2,0x0000010a,0x00003250,
7260x00050080,0x00000006,0x00000fb3,0x00000107,
7270x00000fb2,0x00050041,0x00000156,0x00000fb4,
7280x000000fc,0x00000154,0x0004003d,0x00000007,
7290x00000fb5,0x00000fb4,0x00050051,0x00000006,
7300x0000105c,0x00000fb5,0x00000000,0x00050095,
7310x000000ab,0x0000105e,0x0000105c,0x00000fb3,
7320x00050051,0x00000006,0x0000105f,0x0000105e,
7330x00000001,0x00050051,0x00000006,0x00001060,
7340x0000105e,0x00000000,0x00050051,0x00000006,
7350x00001063,0x00000fb5,0x00000001,0x00050080,
7360x00000006,0x00001065,0x00001063,0x0000105f,
7370x00050050,0x00000007,0x00001066,0x00001060,
7380x00001065,0x0004007c,0x00000014,0x00001056,
7390x00001066,0x00060041,0x000000db,0x0000104d,
7400x00001056,0x000000da,0x000000da,0x0006003d,
7410x00000006,0x0000104e,0x0000104d,0x00000002,
7420x00000004,0x000200f9,0x00000fb8,0x000200f8,
7430x00000fb7,0x000200f9,0x00000fb8,0x000200f8,
7440x00000fb8,0x000700f5,0x00000006,0x00003260,
7450x0000104e,0x00000faf,0x00000380,0x00000fb7,
7460x00050041,0x000006c2,0x00000fba,0x000006af,
7470x00003250,0x0003003e,0x00000fba,0x00003260,
7480x000300f7,0x00000fc8,0x00000000,0x000400fa,
7490x00000fae,0x00000fbf,0x00000fc7,0x000200f8,
7500x00000fbf,0x00050084,0x00000006,0x0000106b,
7510x0000010a,0x00000f99,0x00050080,0x00000006,
7520x0000106c,0x00000107,0x0000106b,0x00050084,
7530x00000006,0x00000fc2,0x0000010a,0x00003250,
7540x00050080,0x00000006,0x00000fc3,0x0000106c,
7550x00000fc2,0x00050041,0x00000156,0x00000fc4,
7560x000000fc,0x00000154,0x0004003d,0x00000007,
7570x00000fc5,0x00000fc4,0x00050051,0x00000006,
7580x00001083,0x00000fc5,0x00000000,0x00050095,
7590x000000ab,0x00001085,0x00001083,0x00000fc3,
7600x00050051,0x00000006,0x00001086,0x00001085,
7610x00000001,0x00050051,0x00000006,0x00001087,
7620x00001085,0x00000000,0x00050051,0x00000006,
7630x0000108a,0x00000fc5,0x00000001,0x00050080,
7640x00000006,0x0000108c,0x0000108a,0x00001086,
7650x00050050,0x00000007,0x0000108d,0x00001087,
7660x0000108c,0x0004007c,0x00000014,0x0000107d,
7670x0000108d,0x00060041,0x000000db,0x00001074,
7680x0000107d,0x000000da,0x000000da,0x0006003d,
7690x00000006,0x00001075,0x00001074,0x00000002,
7700x00000004,0x000200f9,0x00000fc8,0x000200f8,
7710x00000fc7,0x000200f9,0x00000fc8,0x000200f8,
7720x00000fc8,0x000700f5,0x00000006,0x00003262,
7730x00001075,0x00000fbf,0x00000380,0x00000fc7,
7740x00050041,0x000006c2,0x00000fca,0x000006c4,
7750x00003250,0x0003003e,0x00000fca,0x00003262,
7760x000200f9,0x00000fcb,0x000200f8,0x00000fcb,
7770x00050080,0x00000006,0x00000fcd,0x00003250,
7780x00000107,0x000200f9,0x00000fa5,0x000200f8,
7790x00000fce,0x000400e0,0x00000170,0x00000170,
7800x000006da,0x000200f9,0x00000fcf,0x000200f8,
7810x00000fcf,0x000700f5,0x00000006,0x00003252,
7820x00000170,0x00000fce,0x00001023,0x00001021,
7830x000500b2,0x0000002f,0x00000fd3,0x00003252,
7840x0000324f,0x000400f6,0x00001024,0x00001021,
7850x00000000,0x000400fa,0x00000fd3,0x00000fd4,
7860x00001024,0x000200f8,0x00000fd4,0x000500c2,
7870x00000006,0x00000fd6,0x00003252,0x00000154,
7880x000200f9,0x00000fd7,0x000200f8,0x00000fd7,
7890x000700f5,0x00000006,0x00003255,0x00000fd6,
7900x00000fd4,0x0000101f,0x0000101d,0x000500ac,
7910x0000002f,0x00000fda,0x00003255,0x000000a6,
7920x000400f6,0x00001020,0x0000101d,0x00000000,
7930x000400fa,0x00000fda,0x00000fdb,0x00001020,
7940x000200f8,0x00000fdb,0x000200f9,0x00000fdd,
7950x000200f8,0x00000fdd,0x000700f5,0x00000006,
7960x00003257,0x00000b40,0x00000fdb,0x0000101b,
7970x00001019,0x000500b0,0x0000002f,0x00000fe1,
7980x00003257,0x0000324f,0x000400f6,0x0000101c,
7990x00001019,0x00000000,0x000400fa,0x00000fe1,
8000x00000fe2,0x0000101c,0x000200f8,0x00000fe2,
8010x000500c6,0x00000006,0x00000fe5,0x00003257,
8020x00003255,0x000500ac,0x0000002f,0x00000fe8,
8030x00000fe5,0x00003257,0x000300f7,0x00001018,
8040x00000000,0x000400fa,0x00000fe8,0x00000fe9,
8050x00001018,0x000200f8,0x00000fe9,0x00050041,
8060x000006c2,0x00000feb,0x000006af,0x00003257,
8070x0004003d,0x00000006,0x00000fec,0x00000feb,
8080x00050041,0x000006c2,0x00000fee,0x000006af,
8090x00000fe5,0x0004003d,0x00000006,0x00000fef,
8100x00000fee,0x00050041,0x000006c2,0x00000ff1,
8110x000006c4,0x00003257,0x0004003d,0x00000006,
8120x00000ff2,0x00000ff1,0x00050041,0x000006c2,
8130x00000ff4,0x000006c4,0x00000fe5,0x0004003d,
8140x00000006,0x00000ff5,0x00000ff4,0x000500ac,
8150x0000002f,0x00000ff8,0x00000fec,0x00000fef,
8160x000400a8,0x0000002f,0x00000ff9,0x00000ff8,
8170x000300f7,0x00001002,0x00000000,0x000400fa,
8180x00000ff9,0x00000ffa,0x00001002,0x000200f8,
8190x00000ffa,0x000500aa,0x0000002f,0x00000ffd,
8200x00000fec,0x00000fef,0x000500ac,0x0000002f,
8210x00001000,0x00000ff2,0x00000ff5,0x000500a7,
8220x0000002f,0x00001001,0x00000ffd,0x00001000,
8230x000200f9,0x00001002,0x000200f8,0x00001002,
8240x000700f5,0x0000002f,0x00001003,0x00000ff8,
8250x00000fe9,0x00001001,0x00000ffa,0x000500c7,
8260x00000006,0x00001007,0x00003257,0x00003252,
8270x000500aa,0x0000002f,0x00001008,0x00001007,
8280x000000a6,0x000500a4,0x0000002f,0x00001009,
8290x00001003,0x00001008,0x000300f7,0x00001017,
8300x00000000,0x000400fa,0x00001009,0x0000100a,
8310x00001017,0x000200f8,0x0000100a,0x0003003e,
8320x00000feb,0x00000fef,0x0003003e,0x00000fee,
8330x00000fec,0x0003003e,0x00000ff1,0x00000ff5,
8340x0003003e,0x00000ff4,0x00000ff2,0x000200f9,
8350x00001017,0x000200f8,0x00001017,0x000200f9,
8360x00001018,0x000200f8,0x00001018,0x000200f9,
8370x00001019,0x000200f8,0x00001019,0x00050080,
8380x00000006,0x0000101b,0x00003257,0x00000107,
8390x000200f9,0x00000fdd,0x000200f8,0x0000101c,
8400x000400e0,0x00000170,0x00000170,0x000006da,
8410x000200f9,0x0000101d,0x000200f8,0x0000101d,
8420x000500c2,0x00000006,0x0000101f,0x00003255,
8430x00000154,0x000200f9,0x00000fd7,0x000200f8,
8440x00001020,0x000200f9,0x00001021,0x000200f8,
8450x00001021,0x000500c4,0x00000006,0x00001023,
8460x00003252,0x00000154,0x000200f9,0x00000fcf,
8470x000200f8,0x00001024,0x000200f9,0x00001026,
8480x000200f8,0x00001026,0x000700f5,0x00000006,
8490x00003254,0x00000b40,0x00001024,0x00001042,
8500x0000102b,0x000500b0,0x0000002f,0x0000102a,
8510x00003254,0x00000f99,0x000400f6,0x00001043,
8520x0000102b,0x00000000,0x000400fa,0x0000102a,
8530x0000102b,0x00001043,0x000200f8,0x0000102b,
8540x00050084,0x00000006,0x0000102e,0x0000010a,
8550x00003254,0x00050080,0x00000006,0x0000102f,
8560x00000107,0x0000102e,0x00050041,0x00000156,
8570x00001031,0x000000fc,0x00000154,0x0004003d,
8580x00000007,0x00001032,0x00001031,0x00050041,
8590x000006c2,0x00001033,0x000006af,0x00003254,
8600x0004003d,0x00000006,0x00001034,0x00001033,
8610x00050051,0x00000006,0x000010a5,0x00001032,
8620x00000000,0x00050095,0x000000ab,0x000010a7,
8630x000010a5,0x0000102f,0x00050051,0x00000006,
8640x000010a8,0x000010a7,0x00000001,0x00050051,
8650x00000006,0x000010a9,0x000010a7,0x00000000,
8660x00050051,0x00000006,0x000010ac,0x00001032,
8670x00000001,0x00050080,0x00000006,0x000010ae,
8680x000010ac,0x000010a8,0x00050050,0x00000007,
8690x000010af,0x000010a9,0x000010ae,0x0004007c,
8700x00000014,0x0000109f,0x000010af,0x00060041,
8710x000000db,0x00001097,0x0000109f,0x000000da,
8720x000000da,0x0005003e,0x00001097,0x00001034,
2540x00000002,0x00000004,0x00050084,0x00000006, 8730x00000002,0x00000004,0x00050084,0x00000006,
2550x00000afb,0x00000107,0x00000ac4,0x000500c2, 8740x000010b4,0x0000010a,0x00000f99,0x00050080,
2560x00000006,0x00000afc,0x00000add,0x00000afb, 8750x00000006,0x000010b5,0x00000107,0x000010b4,
2570x000500c7,0x00000006,0x00000afd,0x00000afc, 8760x00050080,0x00000006,0x00001039,0x000010b5,
2580x000006ca,0x00050041,0x000006d6,0x00000aa8, 8770x0000102e,0x00050041,0x000006c2,0x0000103d,
2590x000006d4,0x00000afd,0x000700ea,0x00000006, 8780x000006c4,0x00003254,0x0004003d,0x00000006,
2600x00000aa9,0x00000aa8,0x000000ad,0x000000a3, 8790x0000103e,0x0000103d,0x00050095,0x000000ab,
2610x000000ad,0x000200f9,0x00000aaa,0x000200f8, 8800x000010cd,0x000010a5,0x00001039,0x00050051,
2620x00000aaa,0x00050080,0x00000006,0x00000aac, 8810x00000006,0x000010ce,0x000010cd,0x00000001,
2630x00002b52,0x00000104,0x000200f9,0x00000a9a, 8820x00050051,0x00000006,0x000010cf,0x000010cd,
2640x000200f8,0x00000aad,0x000400e0,0x0000016d, 8830x00000000,0x00050080,0x00000006,0x000010d4,
2650x0000016d,0x000006d8,0x000300f7,0x00000abf, 8840x000010ac,0x000010ce,0x00050050,0x00000007,
2660x00000000,0x000400fa,0x00000a8b,0x00000ab0, 8850x000010d5,0x000010cf,0x000010d4,0x0004007c,
2670x00000abf,0x000200f8,0x00000ab0,0x00050084, 8860x00000014,0x000010c5,0x000010d5,0x00060041,
2680x00000006,0x00000b02,0x0000011c,0x00000a95, 8870x000000db,0x000010bd,0x000010c5,0x000000da,
2690x00050080,0x00000006,0x00000b03,0x00000104, 8880x000000da,0x0005003e,0x000010bd,0x0000103e,
2700x00000b02,0x00050080,0x00000006,0x00000b09,
2710x00000a95,0x00002b67,0x00050086,0x00000006,
2720x00000b0a,0x00000b09,0x000000fe,0x00050084,
2730x00000006,0x00000ab4,0x000009f7,0x00000b0a,
2740x00050080,0x00000006,0x00000ab6,0x00000ab4,
2750x000009f4,0x00050084,0x00000006,0x00000ab7,
2760x00000107,0x00000ab6,0x00050080,0x00000006,
2770x00000ab8,0x00000b03,0x00000ab7,0x00050041,
2780x00000153,0x00000aba,0x000000f9,0x00000151,
2790x0004003d,0x00000007,0x00000abb,0x00000aba,
2800x00050041,0x000006d6,0x00000abc,0x000006d4,
2810x000009f7,0x0004003d,0x00000006,0x00000abd,
2820x00000abc,0x00050051,0x00000006,0x00000b20,
2830x00000abb,0x00000000,0x00050095,0x000000a8,
2840x00000b22,0x00000b20,0x00000ab8,0x00050051,
2850x00000006,0x00000b23,0x00000b22,0x00000001,
2860x00050051,0x00000006,0x00000b24,0x00000b22,
2870x00000000,0x00050051,0x00000006,0x00000b27,
2880x00000abb,0x00000001,0x00050080,0x00000006,
2890x00000b29,0x00000b27,0x00000b23,0x00050050,
2900x00000007,0x00000b2a,0x00000b24,0x00000b29,
2910x0004007c,0x00000014,0x00000b1a,0x00000b2a,
2920x00060041,0x000000d8,0x00000b12,0x00000b1a,
2930x000000d7,0x000000d7,0x0005003e,0x00000b12,
2940x00000abd,0x00000002,0x00000004,0x000200f9,
2950x00000abf,0x000200f8,0x00000abf,0x000200f9,
2960x00000a6e,0x000200f8,0x000009ef,0x000500aa,
2970x0000002f,0x000009fc,0x000009eb,0x0000010e,
2980x000300f7,0x000009fe,0x00000000,0x000400fa,
2990x000009fc,0x000009fd,0x000009fe,0x000200f8,
3000x000009fd,0x00050041,0x000009e7,0x00000a00,
3010x000009f1,0x000000a3,0x0004003d,0x00000006,
3020x00000a01,0x00000a00,0x00050041,0x000000fb,
3030x00000b9d,0x000000f9,0x000000fa,0x0004003d,
3040x00000006,0x00000b9e,0x00000b9d,0x00050080,
3050x00000006,0x00000ba0,0x00000b9e,0x00002b67,
3060x00050086,0x00000006,0x00000ba1,0x00000ba0,
3070x000000fe,0x00050084,0x00000006,0x00000b40,
3080x0000011c,0x00000ba1,0x00050080,0x00000006,
3090x00000b42,0x00000b40,0x00000717,0x00050086,
3100x00000006,0x00000b43,0x00000b42,0x00000104,
3110x00050084,0x00000006,0x00000b46,0x00000a01,
3120x00000b43,0x0007000c,0x00000006,0x00000b48,
3130x00000001,0x00000026,0x00000b46,0x00000b40,
3140x00050080,0x00000006,0x00000b4b,0x00000b48,
3150x00000b43,0x0007000c,0x00000006,0x00000b4d,
3160x00000001,0x00000026,0x00000b4b,0x00000b40,
3170x000200f9,0x00000b4f,0x000200f8,0x00000b4f,
3180x000700f5,0x00000006,0x00002b4d,0x000000a3,
3190x000009fd,0x00000b5d,0x00000b54,0x000700f5,
3200x00000006,0x00002b4c,0x00000b48,0x000009fd,
3210x00000b60,0x00000b54,0x000500b0,0x0000002f,
3220x00000b53,0x00002b4c,0x00000b4d,0x000400f6,
3230x00000b61,0x00000b54,0x00000000,0x000400fa,
3240x00000b53,0x00000b54,0x00000b61,0x000200f8,
3250x00000b54,0x00050084,0x00000006,0x00000ba6,
3260x0000011c,0x00000b9e,0x00050080,0x00000006,
3270x00000ba7,0x00000104,0x00000ba6,0x00050084,
3280x00000006,0x00000b57,0x00000107,0x00002b4c,
3290x00050080,0x00000006,0x00000b58,0x00000ba7,
3300x00000b57,0x00050041,0x00000153,0x00000b59,
3310x000000f9,0x00000151,0x0004003d,0x00000007,
3320x00000b5a,0x00000b59,0x00050051,0x00000006,
3330x00000bbe,0x00000b5a,0x00000000,0x00050095,
3340x000000a8,0x00000bc0,0x00000bbe,0x00000b58,
3350x00050051,0x00000006,0x00000bc1,0x00000bc0,
3360x00000001,0x00050051,0x00000006,0x00000bc2,
3370x00000bc0,0x00000000,0x00050051,0x00000006,
3380x00000bc5,0x00000b5a,0x00000001,0x00050080,
3390x00000006,0x00000bc7,0x00000bc5,0x00000bc1,
3400x00050050,0x00000007,0x00000bc8,0x00000bc2,
3410x00000bc7,0x0004007c,0x00000014,0x00000bb8,
3420x00000bc8,0x00060041,0x000000d8,0x00000baf,
3430x00000bb8,0x000000d7,0x000000d7,0x0006003d,
3440x00000006,0x00000bb0,0x00000baf,0x00000002,
3450x00000004,0x00050080,0x00000006,0x00000b5d,
3460x00002b4d,0x00000bb0,0x00050080,0x00000006,
3470x00000b60,0x00002b4c,0x00000151,0x000200f9,
3480x00000b4f,0x000200f8,0x00000b61,0x00050041,
3490x000006d6,0x00000b64,0x00000740,0x00000a01,
3500x0003003e,0x00000b64,0x00002b4d,0x000400e0,
3510x0000016d,0x0000016d,0x000006d8,0x000500aa,
3520x0000002f,0x00000b66,0x00000a01,0x000000a3,
3530x000300f7,0x00000b7a,0x00000000,0x000400fa,
3540x00000b66,0x00000b67,0x00000b7a,0x000200f8,
3550x00000b67,0x000200f9,0x00000b68,0x000200f8,
3560x00000b68,0x000700f5,0x00000006,0x00002b51,
3570x000000a3,0x00000b67,0x00000b75,0x00000b6c,
3580x000700f5,0x00000006,0x00002b4e,0x000000a3,
3590x00000b67,0x00000b78,0x00000b6c,0x000500b0,
3600x0000002f,0x00000b6b,0x00002b4e,0x00000104,
3610x000400f6,0x00000b79,0x00000b6c,0x00000000,
3620x000400fa,0x00000b6b,0x00000b6c,0x00000b79,
3630x000200f8,0x00000b6c,0x00050041,0x000006d6,
3640x00000b6e,0x00000740,0x00002b4e,0x0004003d,
3650x00000006,0x00000b6f,0x00000b6e,0x0003003e,
3660x00000b6e,0x00002b51,0x00050080,0x00000006,
3670x00000b75,0x00002b51,0x00000b6f,0x00050080,
3680x00000006,0x00000b78,0x00002b4e,0x00000151,
3690x000200f9,0x00000b68,0x000200f8,0x00000b79,
3700x000200f9,0x00000b7a,0x000200f8,0x00000b7a,
3710x000400e0,0x0000016d,0x0000016d,0x000006d8,
3720x0004003d,0x00000006,0x00000b7d,0x00000b64,
3730x000200f9,0x00000b7f,0x000200f8,0x00000b7f,
3740x000700f5,0x00000006,0x00002b50,0x00000b7d,
3750x00000b7a,0x00000b96,0x00000b84,0x000700f5,
3760x00000006,0x00002b4f,0x00000b48,0x00000b7a,
3770x00000b99,0x00000b84,0x000500b0,0x0000002f,
3780x00000b83,0x00002b4f,0x00000b4d,0x000400f6,
3790x00000b9a,0x00000b84,0x00000000,0x000400fa,
3800x00000b83,0x00000b84,0x00000b9a,0x000200f8,
3810x00000b84,0x00050084,0x00000006,0x00000bcd,
3820x0000011c,0x00000b9e,0x00050080,0x00000006,
3830x00000bce,0x00000104,0x00000bcd,0x00050084,
3840x00000006,0x00000b87,0x00000107,0x00002b4f,
3850x00050080,0x00000006,0x00000b88,0x00000bce,
3860x00000b87,0x00050041,0x00000153,0x00000b89,
3870x000000f9,0x00000151,0x0004003d,0x00000007,
3880x00000b8a,0x00000b89,0x00050051,0x00000006,
3890x00000be5,0x00000b8a,0x00000000,0x00050095,
3900x000000a8,0x00000be7,0x00000be5,0x00000b88,
3910x00050051,0x00000006,0x00000be8,0x00000be7,
3920x00000001,0x00050051,0x00000006,0x00000be9,
3930x00000be7,0x00000000,0x00050051,0x00000006,
3940x00000bec,0x00000b8a,0x00000001,0x00050080,
3950x00000006,0x00000bee,0x00000bec,0x00000be8,
3960x00050050,0x00000007,0x00000bef,0x00000be9,
3970x00000bee,0x0004007c,0x00000014,0x00000bdf,
3980x00000bef,0x00060041,0x000000d8,0x00000bd6,
3990x00000bdf,0x000000d7,0x000000d7,0x0006003d,
4000x00000006,0x00000bd7,0x00000bd6,0x00000002,
4010x00000004,0x0005003e,0x00000bd6,0x00002b50,
4020x00000002,0x00000004,0x00050080,0x00000006,
4030x00000b96,0x00002b50,0x00000bd7,0x00050080,
4040x00000006,0x00000b99,0x00002b4f,0x00000151,
4050x000200f9,0x00000b7f,0x000200f8,0x00000b9a,
4060x000200f9,0x00000a6e,0x000200f8,0x000009fe,
4070x000500aa,0x0000002f,0x00000a06,0x000009eb,
4080x00000387,0x000300f7,0x00000a08,0x00000000,
4090x000400fa,0x00000a06,0x00000a07,0x00000a08,
4100x000200f8,0x00000a07,0x00050041,0x000009e7,
4110x00000a0a,0x000009f0,0x000000a3,0x0004003d,
4120x00000006,0x00000a0b,0x00000a0a,0x00050041,
4130x000009e7,0x00000a0d,0x000009f1,0x000000a3,
4140x0004003d,0x00000006,0x00000a0e,0x00000a0d,
4150x000500b0,0x0000002f,0x00000c36,0x00000a0e,
4160x0000011c,0x000300f7,0x00000c45,0x00000000,
4170x000400fa,0x00000c36,0x00000c37,0x00000c45,
4180x000200f8,0x00000c37,0x00050041,0x000000fb,
4190x00000ce7,0x000000f9,0x000000fa,0x0004003d,
4200x00000006,0x00000ce8,0x00000ce7,0x00050084,
4210x00000006,0x00000ce9,0x0000011c,0x00000ce8,
4220x00050080,0x00000006,0x00000cea,0x00000104,
4230x00000ce9,0x00050080,0x00000006,0x00000cf0,
4240x00000ce8,0x00002b67,0x00050086,0x00000006,
4250x00000cf1,0x00000cf0,0x000000fe,0x00050084,
4260x00000006,0x00000c3c,0x00000a0e,0x00000cf1,
4270x00050080,0x00000006,0x00000c3e,0x00000c3c,
4280x00000a0b,0x00050084,0x00000006,0x00000c3f,
4290x00000107,0x00000c3e,0x00050080,0x00000006,
4300x00000c40,0x00000cea,0x00000c3f,0x00050041,
4310x00000153,0x00000c41,0x000000f9,0x00000151,
4320x0004003d,0x00000007,0x00000c42,0x00000c41,
4330x00050051,0x00000006,0x00000d08,0x00000c42,
4340x00000000,0x00050095,0x000000a8,0x00000d0a,
4350x00000d08,0x00000c40,0x00050051,0x00000006,
4360x00000d0b,0x00000d0a,0x00000001,0x00050051,
4370x00000006,0x00000d0c,0x00000d0a,0x00000000,
4380x00050051,0x00000006,0x00000d0f,0x00000c42,
4390x00000001,0x00050080,0x00000006,0x00000d11,
4400x00000d0f,0x00000d0b,0x00050050,0x00000007,
4410x00000d12,0x00000d0c,0x00000d11,0x0004007c,
4420x00000014,0x00000d02,0x00000d12,0x00060041,
4430x000000d8,0x00000cf9,0x00000d02,0x000000d7,
4440x000000d7,0x0006003d,0x00000006,0x00000cfa,
4450x00000cf9,0x00000002,0x00000004,0x00050041,
4460x000006d6,0x00000c44,0x00000789,0x00000a0e,
4470x0003003e,0x00000c44,0x00000cfa,0x000200f9,
4480x00000c45,0x000200f8,0x00000c45,0x00050084,
4490x00000006,0x00000c47,0x00000a0b,0x000000fe,
4500x00050080,0x00000006,0x00000c49,0x00000c47,
4510x000000fe,0x00050041,0x000000fb,0x00000c4a,
4520x000000f9,0x000000fa,0x0004003d,0x00000006,
4530x00000c4b,0x00000c4a,0x0007000c,0x00000006,
4540x00000c4c,0x00000001,0x00000026,0x00000c49,
4550x00000c4b,0x000200f9,0x00000c4e,0x000200f8,
4560x00000c4e,0x000700f5,0x00000006,0x00002b33,
4570x00000c47,0x00000c45,0x00000ce3,0x00000ce1,
4580x000500b0,0x0000002f,0x00000c52,0x00002b33,
4590x00000c4c,0x000400f6,0x00000ce4,0x00000ce1,
4600x00000000,0x000400fa,0x00000c52,0x00000c53,
4610x00000ce4,0x000200f8,0x00000c53,0x00050080,
4620x00000006,0x00000c56,0x00002b33,0x00000a0e,
4630x000500b0,0x0000002f,0x00000c59,0x00000c56,
4640x00000c4c,0x000300f7,0x00000c64,0x00000000,
4650x000400fa,0x00000c59,0x00000c5b,0x00000c63,
4660x000200f8,0x00000c5b,0x00050041,0x000000fb,
4670x00000d16,0x000000f9,0x00000305,0x0004003d,
4680x00000006,0x00000d17,0x00000d16,0x000500c7,
4690x00000006,0x00000d18,0x00000d17,0x000000ad,
4700x000500aa,0x0000002f,0x00000d19,0x00000d18,
4710x000000a3,0x000300f7,0x00000d1e,0x00000000,
4720x000400fa,0x00000d19,0x00000d1a,0x00000d1c,
4730x000200f8,0x00000d1a,0x000200f9,0x00000d1e,
4740x000200f8,0x00000d1c,0x00050084,0x00000006,
4750x00000d26,0x0000010e,0x00000c4b,0x00050080,
4760x00000006,0x00000d27,0x00000104,0x00000d26,
4770x000200f9,0x00000d1e,0x000200f8,0x00000d1e,
4780x000700f5,0x00000006,0x00002b34,0x00000104,
4790x00000d1a,0x00000d27,0x00000d1c,0x00050084,
4800x00000006,0x00000c5e,0x00000107,0x00000c56,
4810x00050080,0x00000006,0x00000c5f,0x00002b34,
4820x00000c5e,0x00050041,0x00000153,0x00000c60,
4830x000000f9,0x00000151,0x0004003d,0x00000007,
4840x00000c61,0x00000c60,0x00050051,0x00000006,
4850x00000d3e,0x00000c61,0x00000000,0x00050095,
4860x000000a8,0x00000d40,0x00000d3e,0x00000c5f,
4870x00050051,0x00000006,0x00000d41,0x00000d40,
4880x00000001,0x00050051,0x00000006,0x00000d42,
4890x00000d40,0x00000000,0x00050051,0x00000006,
4900x00000d45,0x00000c61,0x00000001,0x00050080,
4910x00000006,0x00000d47,0x00000d45,0x00000d41,
4920x00050050,0x00000007,0x00000d48,0x00000d42,
4930x00000d47,0x0004007c,0x00000014,0x00000d38,
4940x00000d48,0x00060041,0x000000d8,0x00000d2f,
4950x00000d38,0x000000d7,0x000000d7,0x0006003d,
4960x00000006,0x00000d30,0x00000d2f,0x00000002,
4970x00000004,0x000200f9,0x00000c64,0x000200f8,
4980x00000c63,0x000200f9,0x00000c64,0x000200f8,
4990x00000c64,0x000700f5,0x00000006,0x00002b35,
5000x00000d30,0x00000d1e,0x000000a3,0x00000c63,
5010x000300f7,0x00000c70,0x00000000,0x000400fa,
5020x00000c59,0x00000c67,0x00000c6f,0x000200f8,
5030x00000c67,0x00050041,0x000000fb,0x00000d4c,
5040x000000f9,0x00000305,0x0004003d,0x00000006,
5050x00000d4d,0x00000d4c,0x000500c7,0x00000006,
5060x00000d4e,0x00000d4d,0x000000ad,0x000500aa,
5070x0000002f,0x00000d4f,0x00000d4e,0x000000a3,
5080x000300f7,0x00000d54,0x00000000,0x000400fa,
5090x00000d4f,0x00000d50,0x00000d52,0x000200f8,
5100x00000d50,0x00050084,0x00000006,0x00000d5a,
5110x00000107,0x00000c4b,0x00050080,0x00000006,
5120x00000d5b,0x00000104,0x00000d5a,0x000200f9,
5130x00000d54,0x000200f8,0x00000d52,0x00050084,
5140x00000006,0x00000d60,0x00000115,0x00000c4b,
5150x00050080,0x00000006,0x00000d61,0x00000104,
5160x00000d60,0x000200f9,0x00000d54,0x000200f8,
5170x00000d54,0x000700f5,0x00000006,0x00002b36,
5180x00000d5b,0x00000d50,0x00000d61,0x00000d52,
5190x00050084,0x00000006,0x00000c6a,0x00000107,
5200x00000c56,0x00050080,0x00000006,0x00000c6b,
5210x00002b36,0x00000c6a,0x00050041,0x00000153,
5220x00000c6c,0x000000f9,0x00000151,0x0004003d,
5230x00000007,0x00000c6d,0x00000c6c,0x00050051,
5240x00000006,0x00000d78,0x00000c6d,0x00000000,
5250x00050095,0x000000a8,0x00000d7a,0x00000d78,
5260x00000c6b,0x00050051,0x00000006,0x00000d7b,
5270x00000d7a,0x00000001,0x00050051,0x00000006,
5280x00000d7c,0x00000d7a,0x00000000,0x00050051,
5290x00000006,0x00000d7f,0x00000c6d,0x00000001,
5300x00050080,0x00000006,0x00000d81,0x00000d7f,
5310x00000d7b,0x00050050,0x00000007,0x00000d82,
5320x00000d7c,0x00000d81,0x0004007c,0x00000014,
5330x00000d72,0x00000d82,0x00060041,0x000000d8,
5340x00000d69,0x00000d72,0x000000d7,0x000000d7,
5350x0006003d,0x00000006,0x00000d6a,0x00000d69,
5360x00000002,0x00000004,0x000200f9,0x00000c70,
5370x000200f8,0x00000c6f,0x000200f9,0x00000c70,
5380x000200f8,0x00000c70,0x000700f5,0x00000006,
5390x00002b37,0x00000d6a,0x00000d54,0x000000a3,
5400x00000c6f,0x00050041,0x000000fb,0x00000d86,
5410x000000f9,0x00000305,0x0004003d,0x00000006,
5420x00000d87,0x00000d86,0x00050084,0x00000006,
5430x00000d88,0x00000107,0x00000d87,0x000500c2,
5440x00000006,0x00000d89,0x00002b35,0x00000d88,
5450x000500c7,0x00000006,0x00000d8a,0x00000d89,
5460x000006ca,0x000200f9,0x00000c74,0x000200f8,
5470x00000c74,0x000700f5,0x00000006,0x00002b38,
5480x000000a3,0x00000c70,0x00000c84,0x00000c78,
5490x000500b0,0x0000002f,0x00000c77,0x00002b38,
5500x0000011c,0x000400f6,0x00000c85,0x00000c78,
5510x00000000,0x000400fa,0x00000c77,0x00000c78,
5520x00000c85,0x000200f8,0x00000c78,0x000500aa,
5530x0000002f,0x00000c7e,0x00002b38,0x00000d8a,
5540x000500a7,0x0000002f,0x00000c7f,0x00000c59,
5550x00000c7e,0x000600a9,0x00000006,0x00000c80,
5560x00000c7f,0x000000ad,0x000000a3,0x00060041,
5570x000006d6,0x00000c81,0x000007e2,0x00002b38,
5580x00000a0e,0x0003003e,0x00000c81,0x00000c80,
5590x00050080,0x00000006,0x00000c84,0x00002b38,
5600x00000151,0x000200f9,0x00000c74,0x000200f8,
5610x00000c85,0x000400e0,0x0000016d,0x0000016d,
5620x000006d8,0x000200f9,0x00000c86,0x000200f8,
5630x00000c86,0x000700f5,0x00000006,0x00002b39,
5640x000000ad,0x00000c85,0x00000cb7,0x00000cb5,
5650x000500b0,0x0000002f,0x00000c89,0x00002b39,
5660x00000104,0x000400f6,0x00000cb8,0x00000cb5,
5670x00000000,0x000400fa,0x00000c89,0x00000c8a,
5680x00000cb8,0x000200f8,0x00000c8a,0x000200f9,
5690x00000c8b,0x000200f8,0x00000c8b,0x000700f5,
5700x00000006,0x00002b46,0x000000a3,0x00000c8a,
5710x00000ca1,0x00000c9f,0x000500b0,0x0000002f,
5720x00000c8e,0x00002b46,0x0000011c,0x000400f6,
5730x00000ca2,0x00000c9f,0x00000000,0x000400fa,
5740x00000c8e,0x00000c8f,0x00000ca2,0x000200f8,
5750x00000c8f,0x000500ae,0x0000002f,0x00000c93,
5760x00000a0e,0x00002b39,0x000300f7,0x00000c9c,
5770x00000000,0x000400fa,0x00000c93,0x00000c94,
5780x00000c9b,0x000200f8,0x00000c94,0x00050082,
5790x00000006,0x00000c98,0x00000a0e,0x00002b39,
5800x00060041,0x000006d6,0x00000c99,0x000007e2,
5810x00002b46,0x00000c98,0x0004003d,0x00000006,
5820x00000c9a,0x00000c99,0x000200f9,0x00000c9c,
5830x000200f8,0x00000c9b,0x000200f9,0x00000c9c,
5840x000200f8,0x00000c9c,0x000700f5,0x00000006,
5850x00002b4a,0x00000c9a,0x00000c94,0x000000a3,
5860x00000c9b,0x00050041,0x00000009,0x00000c9e,
5870x00000c2a,0x00002b46,0x0003003e,0x00000c9e,
5880x00002b4a,0x000200f9,0x00000c9f,0x000200f8,
5890x00000c9f,0x00050080,0x00000006,0x00000ca1,
5900x00002b46,0x00000151,0x000200f9,0x00000c8b,
5910x000200f8,0x00000ca2,0x000400e0,0x0000016d,
5920x0000016d,0x000006d8,0x000200f9,0x00000ca3,
5930x000200f8,0x00000ca3,0x000700f5,0x00000006,
5940x00002b47,0x000000a3,0x00000ca2,0x00000cb3,
5950x00000ca7,0x000500b0,0x0000002f,0x00000ca6,
5960x00002b47,0x0000011c,0x000400f6,0x00000cb4,
5970x00000ca7,0x00000000,0x000400fa,0x00000ca6,
5980x00000ca7,0x00000cb4,0x000200f8,0x00000ca7,
5990x00050041,0x00000009,0x00000cab,0x00000c2a,
6000x00002b47,0x0004003d,0x00000006,0x00000cac,
6010x00000cab,0x00060041,0x000006d6,0x00000cad,
6020x000007e2,0x00002b47,0x00000a0e,0x0004003d,
6030x00000006,0x00000cae,0x00000cad,0x00050080,
6040x00000006,0x00000caf,0x00000cae,0x00000cac,
6050x0003003e,0x00000cad,0x00000caf,0x00050080,
6060x00000006,0x00000cb3,0x00002b47,0x00000151,
6070x000200f9,0x00000ca3,0x000200f8,0x00000cb4,
6080x000400e0,0x0000016d,0x0000016d,0x000006d8,
6090x000200f9,0x00000cb5,0x000200f8,0x00000cb5,
6100x000500c4,0x00000006,0x00000cb7,0x00002b39,
6110x00000151,0x000200f9,0x00000c86,0x000200f8,
6120x00000cb8,0x000300f7,0x00000cd4,0x00000000,
6130x000400fa,0x00000c59,0x00000cba,0x00000cd4,
6140x000200f8,0x00000cba,0x00050041,0x000006d6,
6150x00000cbc,0x00000789,0x00000d8a,0x0004003d,
6160x00000006,0x00000cbd,0x00000cbc,0x00060041,
6170x000006d6,0x00000cc0,0x000007e2,0x00000d8a,
6180x00000a0e,0x0004003d,0x00000006,0x00000cc1,
6190x00000cc0,0x00050080,0x00000006,0x00000cc2,
6200x00000cbd,0x00000cc1,0x00050082,0x00000006,
6210x00000cc3,0x00000cc2,0x000000ad,0x000500c7,
6220x00000006,0x00000d90,0x00000d87,0x000000ad,
6230x000500aa,0x0000002f,0x00000d91,0x00000d90,
6240x000000a3,0x000300f7,0x00000d96,0x00000000,
6250x000400fa,0x00000d91,0x00000d92,0x00000d94,
6260x000200f8,0x00000d92,0x00050084,0x00000006,
6270x00000d9c,0x0000010e,0x00000c4b,0x00050080,
6280x00000006,0x00000d9d,0x00000104,0x00000d9c,
6290x000200f9,0x00000d96,0x000200f8,0x00000d94,
6300x000200f9,0x00000d96,0x000200f8,0x00000d96,
6310x000700f5,0x00000006,0x00002b3a,0x00000d9d,
6320x00000d92,0x00000104,0x00000d94,0x00050084,
6330x00000006,0x00000cc6,0x00000107,0x00000cc3,
6340x00050080,0x00000006,0x00000cc7,0x00002b3a,
6350x00000cc6,0x00050041,0x00000153,0x00000cc8,
6360x000000f9,0x00000151,0x0004003d,0x00000007,
6370x00000cc9,0x00000cc8,0x00050051,0x00000006,
6380x00000db5,0x00000cc9,0x00000000,0x00050095,
6390x000000a8,0x00000db7,0x00000db5,0x00000cc7,
6400x00050051,0x00000006,0x00000db8,0x00000db7,
6410x00000001,0x00050051,0x00000006,0x00000db9,
6420x00000db7,0x00000000,0x00050051,0x00000006,
6430x00000dbc,0x00000cc9,0x00000001,0x00050080,
6440x00000006,0x00000dbe,0x00000dbc,0x00000db8,
6450x00050050,0x00000007,0x00000dbf,0x00000db9,
6460x00000dbe,0x0004007c,0x00000014,0x00000daf,
6470x00000dbf,0x00060041,0x000000d8,0x00000da7,
6480x00000daf,0x000000d7,0x000000d7,0x0005003e,
6490x00000da7,0x00002b35,0x00000002,0x00000004,
6500x000300f7,0x00000dcb,0x00000000,0x000400fa,
6510x00000d91,0x00000dc7,0x00000dc9,0x000200f8,
6520x00000dc7,0x00050084,0x00000006,0x00000dd1,
6530x00000115,0x00000c4b,0x00050080,0x00000006,
6540x00000dd2,0x00000104,0x00000dd1,0x000200f9,
6550x00000dcb,0x000200f8,0x00000dc9,0x00050084,
6560x00000006,0x00000dd7,0x00000107,0x00000c4b,
6570x00050080,0x00000006,0x00000dd8,0x00000104,
6580x00000dd7,0x000200f9,0x00000dcb,0x000200f8,
6590x00000dcb,0x000700f5,0x00000006,0x00002b3b,
6600x00000dd2,0x00000dc7,0x00000dd8,0x00000dc9,
6610x00050080,0x00000006,0x00000ccf,0x00002b3b,
6620x00000cc6,0x00050095,0x000000a8,0x00000df0,
6630x00000db5,0x00000ccf,0x00050051,0x00000006,
6640x00000df1,0x00000df0,0x00000001,0x00050051,
6650x00000006,0x00000df2,0x00000df0,0x00000000,
6660x00050080,0x00000006,0x00000df7,0x00000dbc,
6670x00000df1,0x00050050,0x00000007,0x00000df8,
6680x00000df2,0x00000df7,0x0004007c,0x00000014,
6690x00000de8,0x00000df8,0x00060041,0x000000d8,
6700x00000de0,0x00000de8,0x000000d7,0x000000d7,
6710x0005003e,0x00000de0,0x00002b37,0x00000002,
6720x00000004,0x000200f9,0x00000cd4,0x000200f8,
6730x00000cd4,0x000400e0,0x0000016d,0x0000016d,
6740x000006d8,0x000300f7,0x00000ce0,0x00000000,
6750x000400fa,0x00000c36,0x00000cd7,0x00000ce0,
6760x000200f8,0x00000cd7,0x00060041,0x000006d6,
6770x00000cda,0x000007e2,0x00000a0e,0x00000850,
6780x0004003d,0x00000006,0x00000cdb,0x00000cda,
6790x00050041,0x000006d6,0x00000cdc,0x00000789,
6800x00000a0e,0x0004003d,0x00000006,0x00000cdd,
6810x00000cdc,0x00050080,0x00000006,0x00000cde,
6820x00000cdd,0x00000cdb,0x0003003e,0x00000cdc,
6830x00000cde,0x000200f9,0x00000ce0,0x000200f8,
6840x00000ce0,0x000400e0,0x0000016d,0x0000016d,
6850x000006d8,0x000200f9,0x00000ce1,0x000200f8,
6860x00000ce1,0x00050080,0x00000006,0x00000ce3,
6870x00002b33,0x00000104,0x000200f9,0x00000c4e,
6880x000200f8,0x00000ce4,0x000200f9,0x00000a6e,
6890x000200f8,0x00000a08,0x000500aa,0x0000002f,
6900x00000a13,0x000009eb,0x00000236,0x000300f7,
6910x00000a15,0x00000000,0x000400fa,0x00000a13,
6920x00000a14,0x00000a15,0x000200f8,0x00000a14,
6930x000500aa,0x0000002f,0x00000a17,0x000009e9,
6940x000000a3,0x000300f7,0x00000a19,0x00000000,
6950x000400fa,0x00000a17,0x00000a18,0x00000a19,
6960x000200f8,0x00000a18,0x00050041,0x000000fb,
6970x00000e31,0x000000f9,0x00000305,0x0004003d,
6980x00000006,0x00000e32,0x00000e31,0x00050041,
6990x000000fb,0x00000e33,0x000000f9,0x000008bc,
7000x0004003d,0x00000006,0x00000e34,0x00000e33,
7010x00050080,0x00000006,0x00000e36,0x00000e34,
7020x00000e32,0x00050041,0x000000fb,0x00000ec7,
7030x000000f9,0x000000fa,0x0004003d,0x00000006,
7040x00000ec8,0x00000ec7,0x00050084,0x00000006,
7050x00000ec9,0x0000011c,0x00000ec8,0x00050080,
7060x00000006,0x00000eca,0x00000104,0x00000ec9,
7070x00050080,0x00000006,0x00000ed0,0x00000ec8,
7080x00002b67,0x00050086,0x00000006,0x00000ed1,
7090x00000ed0,0x000000fe,0x00050084,0x00000006,
7100x00000ec3,0x00000104,0x00000ed1,0x00050080,
7110x00000006,0x00000ec4,0x00000eca,0x00000ec3,
7120x00050084,0x00000006,0x00000e98,0x0000014d,
7130x00000e36,0x00050080,0x00000006,0x00000e99,
7140x00000ec4,0x00000e98,0x00050041,0x00000153,
7150x00000e9a,0x000000f9,0x00000151,0x0004003d,
7160x00000007,0x00000e9b,0x00000e9a,0x00050051,
7170x00000006,0x00000ee8,0x00000e9b,0x00000000,
7180x00050095,0x000000a8,0x00000eea,0x00000ee8,
7190x00000e99,0x00050051,0x00000006,0x00000eeb,
7200x00000eea,0x00000001,0x00050051,0x00000006,
7210x00000eec,0x00000eea,0x00000000,0x00050051,
7220x00000006,0x00000eef,0x00000e9b,0x00000001,
7230x00050080,0x00000006,0x00000ef1,0x00000eef,
7240x00000eeb,0x00050050,0x00000007,0x00000ef2,
7250x00000eec,0x00000ef1,0x0004007c,0x00000014,
7260x00000ee2,0x00000ef2,0x00060041,0x000000d8,
7270x00000ed9,0x00000ee2,0x000000d7,0x000000d7,
7280x0006003d,0x00000006,0x00000eda,0x00000ed9,
7290x00000002,0x00000004,0x00050080,0x00000006,
7300x00000ea0,0x00000e99,0x00000107,0x00050095,
7310x000000a8,0x00000f0b,0x00000ee8,0x00000ea0,
7320x00050051,0x00000006,0x00000f0c,0x00000f0b,
7330x00000001,0x00050051,0x00000006,0x00000f0d,
7340x00000f0b,0x00000000,0x00050080,0x00000006,
7350x00000f12,0x00000eef,0x00000f0c,0x00050050,
7360x00000007,0x00000f13,0x00000f0d,0x00000f12,
7370x0004007c,0x00000014,0x00000f03,0x00000f13,
7380x00060041,0x000000d8,0x00000efa,0x00000f03,
7390x000000d7,0x000000d7,0x0006003d,0x00000006,
7400x00000efb,0x00000efa,0x00000002,0x00000004,
7410x00050080,0x00000006,0x00000ea6,0x00000e99,
7420x0000010e,0x00050095,0x000000a8,0x00000f2c,
7430x00000ee8,0x00000ea6,0x00050051,0x00000006,
7440x00000f2d,0x00000f2c,0x00000001,0x00050051,
7450x00000006,0x00000f2e,0x00000f2c,0x00000000,
7460x00050080,0x00000006,0x00000f33,0x00000eef,
7470x00000f2d,0x00050050,0x00000007,0x00000f34,
7480x00000f2e,0x00000f33,0x0004007c,0x00000014,
7490x00000f24,0x00000f34,0x00060041,0x000000d8,
7500x00000f1b,0x00000f24,0x000000d7,0x000000d7,
7510x0006003d,0x00000006,0x00000f1c,0x00000f1b,
7520x00000002,0x00000004,0x00050080,0x00000006,
7530x00000ead,0x00000e99,0x00000115,0x00050095,
7540x000000a8,0x00000f4d,0x00000ee8,0x00000ead,
7550x00050051,0x00000006,0x00000f4e,0x00000f4d,
7560x00000001,0x00050051,0x00000006,0x00000f4f,
7570x00000f4d,0x00000000,0x00050080,0x00000006,
7580x00000f54,0x00000eef,0x00000f4e,0x00050050,
7590x00000007,0x00000f55,0x00000f4f,0x00000f54,
7600x0004007c,0x00000014,0x00000f45,0x00000f55,
7610x00060041,0x000000d8,0x00000f3c,0x00000f45,
7620x000000d7,0x000000d7,0x0006003d,0x00000006,
7630x00000f3d,0x00000f3c,0x00000002,0x00000004,
7640x00050080,0x00000006,0x00000eb3,0x00000e99,
7650x0000011c,0x00050095,0x000000a8,0x00000f6e,
7660x00000ee8,0x00000eb3,0x00050051,0x00000006,
7670x00000f6f,0x00000f6e,0x00000001,0x00050051,
7680x00000006,0x00000f70,0x00000f6e,0x00000000,
7690x00050080,0x00000006,0x00000f75,0x00000eef,
7700x00000f6f,0x00050050,0x00000007,0x00000f76,
7710x00000f70,0x00000f75,0x0004007c,0x00000014,
7720x00000f66,0x00000f76,0x00060041,0x000000d8,
7730x00000f5d,0x00000f66,0x000000d7,0x000000d7,
7740x0006003d,0x00000006,0x00000f5e,0x00000f5d,
7750x00000002,0x00000004,0x00050080,0x00000006,
7760x00000eb9,0x00000e99,0x00000186,0x00050095,
7770x000000a8,0x00000f8f,0x00000ee8,0x00000eb9,
7780x00050051,0x00000006,0x00000f90,0x00000f8f,
7790x00000001,0x00050051,0x00000006,0x00000f91,
7800x00000f8f,0x00000000,0x00050080,0x00000006,
7810x00000f96,0x00000eef,0x00000f90,0x00050050,
7820x00000007,0x00000f97,0x00000f91,0x00000f96,
7830x0004007c,0x00000014,0x00000f87,0x00000f97,
7840x00060041,0x000000d8,0x00000f7e,0x00000f87,
7850x000000d7,0x000000d7,0x0006003d,0x00000006,
7860x00000f7f,0x00000f7e,0x00000002,0x00000004,
7870x00050041,0x000000fb,0x00000e3a,0x000000f9,
7880x00000221,0x0004003d,0x00000006,0x00000e3b,
7890x00000e3a,0x000500ab,0x0000002f,0x00000e3c,
7900x00000e3b,0x000000a3,0x000600a9,0x00000006,
7910x00000e3d,0x00000e3c,0x000000a3,0x0000012d,
7920x000500c5,0x00000006,0x00000e3e,0x00000e3d,
7930x00000236,0x00050041,0x00000153,0x00000e3f,
7940x000000f9,0x000000d7,0x0004003d,0x00000007,
7950x00000e40,0x00000e3f,0x00050051,0x00000006,
7960x00000fad,0x00000e40,0x00000000,0x00050095,
7970x000000a8,0x00000faf,0x00000fad,0x000000a3,
7980x00050051,0x00000006,0x00000fb0,0x00000faf,
7990x00000001,0x00050051,0x00000006,0x00000fb1,
8000x00000faf,0x00000000,0x00050051,0x00000006,
8010x00000fb4,0x00000e40,0x00000001,0x00050080,
8020x00000006,0x00000fb6,0x00000fb4,0x00000fb0,
8030x00050050,0x00000007,0x00000fb7,0x00000fb1,
8040x00000fb6,0x0004007c,0x00000014,0x00000fa7,
8050x00000fb7,0x00060041,0x000000d8,0x00000f9f,
8060x00000fa7,0x000000d7,0x000000d7,0x0005003e,
8070x00000f9f,0x00000e3e,0x00000002,0x00000004,
8080x00050041,0x000000fb,0x00000e42,0x000000f9,
8090x0000096f,0x0004003d,0x00000006,0x00000e43,
8100x00000e42,0x00050086,0x00000006,0x00000e44,
8110x00000e43,0x00000104,0x00050095,0x000000a8,
8120x00000fcf,0x00000fad,0x00000107,0x00050051,
8130x00000006,0x00000fd0,0x00000fcf,0x00000001,
8140x00050051,0x00000006,0x00000fd1,0x00000fcf,
8150x00000000,0x00050080,0x00000006,0x00000fd6,
8160x00000fb4,0x00000fd0,0x00050050,0x00000007,
8170x00000fd7,0x00000fd1,0x00000fd6,0x0004007c,
8180x00000014,0x00000fc7,0x00000fd7,0x00060041,
8190x000000d8,0x00000fbf,0x00000fc7,0x000000d7,
8200x000000d7,0x0005003e,0x00000fbf,0x00000e44,
8210x00000002,0x00000004,0x00050095,0x000000a8,
8220x00000fef,0x00000fad,0x0000010e,0x00050051,
8230x00000006,0x00000ff0,0x00000fef,0x00000001,
8240x00050051,0x00000006,0x00000ff1,0x00000fef,
8250x00000000,0x00050080,0x00000006,0x00000ff6,
8260x00000fb4,0x00000ff0,0x00050050,0x00000007,
8270x00000ff7,0x00000ff1,0x00000ff6,0x0004007c,
8280x00000014,0x00000fe7,0x00000ff7,0x00060041,
8290x000000d8,0x00000fdf,0x00000fe7,0x000000d7,
8300x000000d7,0x0005003e,0x00000fdf,0x000000a3,
8310x00000002,0x00000004,0x00050095,0x000000a8,
8320x0000100f,0x00000fad,0x00000115,0x00050051,
8330x00000006,0x00001010,0x0000100f,0x00000001,
8340x00050051,0x00000006,0x00001011,0x0000100f,
8350x00000000,0x00050080,0x00000006,0x00001016,
8360x00000fb4,0x00001010,0x00050050,0x00000007,
8370x00001017,0x00001011,0x00001016,0x0004007c,
8380x00000014,0x00001007,0x00001017,0x00060041,
8390x000000d8,0x00000fff,0x00001007,0x000000d7,
8400x000000d7,0x0005003e,0x00000fff,0x00000e34,
8410x00000002,0x00000004,0x00050095,0x000000a8,
8420x00001038,0x00000fad,0x0000011c,0x00050051,
8430x00000006,0x00001039,0x00001038,0x00000001,
8440x00050051,0x00000006,0x0000103a,0x00001038,
8450x00000000,0x00050080,0x00000006,0x0000103f,
8460x00000fb4,0x00001039,0x00050050,0x00000007,
8470x00001040,0x0000103a,0x0000103f,0x0004007c,
8480x00000014,0x00001030,0x00001040,0x00060041,
8490x000000d8,0x00001028,0x00001030,0x000000d7,
8500x000000d7,0x0005003e,0x00001028,0x00000eda,
8510x00000002,0x00000004,0x00050095,0x000000a8,
8520x00001061,0x00000fad,0x00000186,0x00050051,
8530x00000006,0x00001062,0x00001061,0x00000001,
8540x00050051,0x00000006,0x00001063,0x00001061,
8550x00000000,0x00050080,0x00000006,0x00001068,
8560x00000fb4,0x00001062,0x00050050,0x00000007,
8570x00001069,0x00001063,0x00001068,0x0004007c,
8580x00000014,0x00001059,0x00001069,0x00060041,
8590x000000d8,0x00001051,0x00001059,0x000000d7,
8600x000000d7,0x0005003e,0x00001051,0x00000efb,
8610x00000002,0x00000004,0x00050095,0x000000a8,
8620x0000108a,0x00000fad,0x0000014d,0x00050051,
8630x00000006,0x0000108b,0x0000108a,0x00000001,
8640x00050051,0x00000006,0x0000108c,0x0000108a,
8650x00000000,0x00050080,0x00000006,0x00001091,
8660x00000fb4,0x0000108b,0x00050050,0x00000007,
8670x00001092,0x0000108c,0x00001091,0x0004007c,
8680x00000014,0x00001082,0x00001092,0x00060041,
8690x000000d8,0x0000107a,0x00001082,0x000000d7,
8700x000000d7,0x0005003e,0x0000107a,0x00000f1c,
8710x00000002,0x00000004,0x00050095,0x000000a8,
8720x000010b3,0x00000fad,0x00000460,0x00050051,
8730x00000006,0x000010b4,0x000010b3,0x00000001,
8740x00050051,0x00000006,0x000010b5,0x000010b3,
8750x00000000,0x00050080,0x00000006,0x000010ba,
8760x00000fb4,0x000010b4,0x00050050,0x00000007,
8770x000010bb,0x000010b5,0x000010ba,0x0004007c,
8780x00000014,0x000010ab,0x000010bb,0x00060041,
8790x000000d8,0x000010a3,0x000010ab,0x000000d7,
8800x000000d7,0x0005003e,0x000010a3,0x00000f3d,
8810x00000002,0x00000004,0x00050095,0x000000a8,
8820x000010dc,0x00000fad,0x00000466,0x00050051,
8830x00000006,0x000010dd,0x000010dc,0x00000001,
8840x00050051,0x00000006,0x000010de,0x000010dc,
8850x00000000,0x00050080,0x00000006,0x000010e3,
8860x00000fb4,0x000010dd,0x00050050,0x00000007,
8870x000010e4,0x000010de,0x000010e3,0x0004007c,
8880x00000014,0x000010d4,0x000010e4,0x00060041,
8890x000000d8,0x000010cc,0x000010d4,0x000000d7,
8900x000000d7,0x0005003e,0x000010cc,0x00000f5e,
8910x00000002,0x00000004,0x00050095,0x000000a8,
8920x00001105,0x00000fad,0x00000344,0x00050051,
8930x00000006,0x00001106,0x00001105,0x00000001,
8940x00050051,0x00000006,0x00001107,0x00001105,
8950x00000000,0x00050080,0x00000006,0x0000110c,
8960x00000fb4,0x00001106,0x00050050,0x00000007,
8970x0000110d,0x00001107,0x0000110c,0x0004007c,
8980x00000014,0x000010fd,0x0000110d,0x00060041,
8990x000000d8,0x000010f5,0x000010fd,0x000000d7,
9000x000000d7,0x0005003e,0x000010f5,0x00000f7f,
9010x00000002,0x00000004,0x00050041,0x000000fb,
9020x00000e70,0x000000f9,0x0000023b,0x0004003d,
9030x00000006,0x00000e71,0x00000e70,0x00050095,
9040x000000a8,0x00001125,0x00000fad,0x0000034f,
9050x00050051,0x00000006,0x00001126,0x00001125,
9060x00000001,0x00050051,0x00000006,0x00001127,
9070x00001125,0x00000000,0x00050080,0x00000006,
9080x0000112c,0x00000fb4,0x00001126,0x00050050,
9090x00000007,0x0000112d,0x00001127,0x0000112c,
9100x0004007c,0x00000014,0x0000111d,0x0000112d,
9110x00060041,0x000000d8,0x00001115,0x0000111d,
9120x000000d7,0x000000d7,0x0005003e,0x00001115,
9130x00000e71,0x00000002,0x00000004,0x00050095,
9140x000000a8,0x00001145,0x00000fad,0x0000035a,
9150x00050051,0x00000006,0x00001146,0x00001145,
9160x00000001,0x00050051,0x00000006,0x00001147,
9170x00001145,0x00000000,0x00050080,0x00000006,
9180x0000114c,0x00000fb4,0x00001146,0x00050050,
9190x00000007,0x0000114d,0x00001147,0x0000114c,
9200x0004007c,0x00000014,0x0000113d,0x0000114d,
9210x00060041,0x000000d8,0x00001135,0x0000113d,
9220x000000d7,0x000000d7,0x0005003e,0x00001135,
9230x000000a3,0x00000002,0x00000004,0x00050084,
9240x00000006,0x00001153,0x00000e32,0x00000225,
9250x00050080,0x00000006,0x00001154,0x00000e71,
9260x00001153,0x000500c2,0x00000006,0x00001155,
9270x00001154,0x00000230,0x000500c4,0x00000006,
9280x00001156,0x00001155,0x0000020a,0x000500c5,
9290x00000006,0x00001157,0x00001156,0x00000243,
9300x00050095,0x000000a8,0x0000116f,0x00000fad,
9310x00000365,0x00050051,0x00000006,0x00001170,
9320x0000116f,0x00000001,0x00050051,0x00000006,
9330x00001171,0x0000116f,0x00000000,0x00050080,
9340x00000006,0x00001176,0x00000fb4,0x00001170,
9350x00050050,0x00000007,0x00001177,0x00001171,
9360x00001176,0x0004007c,0x00000014,0x00001167,
9370x00001177,0x00060041,0x000000d8,0x0000115f,
9380x00001167,0x000000d7,0x000000d7,0x0005003e,
9390x0000115f,0x00001157,0x00000002,0x00000004,
9400x00050041,0x000000fb,0x00000e7d,0x000000f9,
9410x00000229,0x0004003d,0x00000006,0x00000e7e,
9420x00000e7d,0x00050095,0x000000a8,0x0000118f,
9430x00000fad,0x00000371,0x00050051,0x00000006,
9440x00001190,0x0000118f,0x00000001,0x00050051,
9450x00000006,0x00001191,0x0000118f,0x00000000,
9460x00050080,0x00000006,0x00001196,0x00000fb4,
9470x00001190,0x00050050,0x00000007,0x00001197,
9480x00001191,0x00001196,0x0004007c,0x00000014,
9490x00001187,0x00001197,0x00060041,0x000000d8,
9500x0000117f,0x00001187,0x000000d7,0x000000d7,
9510x0005003e,0x0000117f,0x00000e7e,0x00000002,
9520x00000004,0x00050041,0x000000fb,0x00000e82,
9530x000000f9,0x000008c7,0x0004003d,0x00000006,
9540x00000e83,0x00000e82,0x00050095,0x000000a8,
9550x000011af,0x00000fad,0x0000037b,0x00050051,
9560x00000006,0x000011b0,0x000011af,0x00000001,
9570x00050051,0x00000006,0x000011b1,0x000011af,
9580x00000000,0x00050080,0x00000006,0x000011b6,
9590x00000fb4,0x000011b0,0x00050050,0x00000007,
9600x000011b7,0x000011b1,0x000011b6,0x0004007c,
9610x00000014,0x000011a7,0x000011b7,0x00060041,
9620x000000d8,0x0000119f,0x000011a7,0x000000d7,
9630x000000d7,0x0005003e,0x0000119f,0x00000e83,
9640x00000002,0x00000004,0x00050095,0x000000a8,
9650x000011cf,0x00000fad,0x00000385,0x00050051,
9660x00000006,0x000011d0,0x000011cf,0x00000001,
9670x00050051,0x00000006,0x000011d1,0x000011cf,
9680x00000000,0x00050080,0x00000006,0x000011d6,
9690x00000fb4,0x000011d0,0x00050050,0x00000007,
9700x000011d7,0x000011d1,0x000011d6,0x0004007c,
9710x00000014,0x000011c7,0x000011d7,0x00060041,
9720x000000d8,0x000011bf,0x000011c7,0x000000d7,
9730x000000d7,0x0005003e,0x000011bf,0x000000a3,
9740x00000002,0x00000004,0x000200f9,0x00000a19,
9750x000200f8,0x00000a19,0x000200f9,0x00000a6e,
9760x000200f8,0x00000a15,0x00050041,0x000000fb,
9770x00000a1d,0x000000f9,0x000004d5,0x0004003d,
9780x00000006,0x00000a1e,0x00000a1d,0x000500ae,
9790x0000002f,0x00000a1f,0x000009e9,0x00000a1e,
9800x000300f7,0x00000a21,0x00000000,0x000400fa,
9810x00000a1f,0x00000a20,0x00000a21,0x000200f8,
9820x00000a20,0x000200f9,0x00000a6e,0x000200f8,
9830x00000a21,0x000500aa,0x0000002f,0x00000a25,
9840x000009eb,0x000000a3,0x000300f7,0x00000a27,
9850x00000000,0x000400fa,0x00000a25,0x00000a26,
9860x00000a48,0x000200f8,0x00000a26,0x00050041,
9870x000000fb,0x00000a28,0x000000f9,0x000008c7,
9880x0004003d,0x00000006,0x00000a29,0x00000a28,
9890x00050084,0x00000006,0x00000a2b,0x00000107,
9900x000009e9,0x00050080,0x00000006,0x00000a2c,
9910x00000a29,0x00000a2b,0x00050041,0x00000153,
9920x00000a2e,0x000000f9,0x000000d7,0x0004003d,
9930x00000007,0x00000a2f,0x00000a2e,0x00050051,
9940x00000006,0x000011ed,0x00000a2f,0x00000000,
9950x00050095,0x000000a8,0x000011ef,0x000011ed,
9960x00000a2c,0x00050051,0x00000006,0x000011f0,
9970x000011ef,0x00000001,0x00050051,0x00000006,
9980x000011f1,0x000011ef,0x00000000,0x00050051,
9990x00000006,0x000011f4,0x00000a2f,0x00000001,
10000x00050080,0x00000006,0x000011f6,0x000011f4,
10010x000011f0,0x00050050,0x00000007,0x000011f7,
10020x000011f1,0x000011f6,0x0004007c,0x00000014,
10030x000011e7,0x000011f7,0x00060041,0x000000d8,
10040x000011df,0x000011e7,0x000000d7,0x000000d7,
10050x0005003e,0x000011df,0x0000037d,0x00000002,
10060x00000004,0x000500b0,0x0000002f,0x00000a34,
10070x000009e9,0x000002b4,0x000300f7,0x00000a36,
10080x00000000,0x000400fa,0x00000a34,0x00000a35,
10090x00000a36,0x000200f8,0x00000a35,0x00050041,
10100x00000153,0x00000a3a,0x000000f9,0x00000151,
10110x0004003d,0x00000007,0x00000a3b,0x00000a3a,
10120x00050051,0x00000006,0x0000120d,0x00000a3b,
10130x00000000,0x00050095,0x000000a8,0x0000120f,
10140x0000120d,0x00000a2b,0x00050051,0x00000006,
10150x00001210,0x0000120f,0x00000001,0x00050051,
10160x00000006,0x00001211,0x0000120f,0x00000000,
10170x00050051,0x00000006,0x00001214,0x00000a3b,
10180x00000001,0x00050080,0x00000006,0x00001216,
10190x00001214,0x00001210,0x00050050,0x00000007,
10200x00001217,0x00001211,0x00001216,0x0004007c,
10210x00000014,0x00001207,0x00001217,0x00060041,
10220x000000d8,0x000011ff,0x00001207,0x000000d7,
10230x000000d7,0x0005003e,0x000011ff,0x0000037d,
10240x00000002,0x00000004,0x00050080,0x00000006, 8890x00000002,0x00000004,0x00050080,0x00000006,
10250x00000a41,0x00000115,0x00000a2b,0x00050095, 8900x00001042,0x00003254,0x00000107,0x000200f9,
10260x000000a8,0x0000122f,0x0000120d,0x00000a41, 8910x00001026,0x000200f8,0x00001043,0x000200f9,
10270x00050051,0x00000006,0x00001230,0x0000122f, 8920x00000bf3,0x000200f8,0x00000b3d,0x000500aa,
10280x00000001,0x00050051,0x00000006,0x00001231, 8930x0000002f,0x00000b45,0x00000b13,0x00000239,
10290x0000122f,0x00000000,0x00050080,0x00000006, 8940x000300f7,0x00000b47,0x00000000,0x000400fa,
10300x00001236,0x00001214,0x00001230,0x00050050, 8950x00000b45,0x00000b46,0x00000b47,0x000200f8,
10310x00000007,0x00001237,0x00001231,0x00001236, 8960x00000b46,0x000500aa,0x0000002f,0x00000b49,
10320x0004007c,0x00000014,0x00001227,0x00001237, 8970x00000b11,0x000000a6,0x000300f7,0x00000b4b,
10330x00060041,0x000000d8,0x0000121f,0x00001227, 8980x00000000,0x000400fa,0x00000b49,0x00000b4a,
10340x000000d7,0x000000d7,0x0005003e,0x0000121f, 8990x00000b4b,0x000200f8,0x00000b4a,0x00050041,
10350x000000a3,0x00000002,0x00000004,0x000200f9, 9000x000000fe,0x0000110e,0x000000fc,0x00000308,
10360x00000a36,0x000200f8,0x00000a36,0x000200f9, 9010x0004003d,0x00000006,0x0000110f,0x0000110e,
10370x00000a27,0x000200f8,0x00000a48,0x000500aa, 9020x00050041,0x000000fe,0x00001110,0x000000fc,
10380x0000002f,0x00000a4b,0x000009eb,0x000000ad, 9030x0000096c,0x0004003d,0x00000006,0x00001111,
10390x000300f7,0x00000a4d,0x00000000,0x000400fa, 9040x00001110,0x00050080,0x00000006,0x00001113,
10400x00000a4b,0x00000a4c,0x00000a51,0x000200f8, 9050x00001111,0x0000110f,0x00050041,0x000000fe,
10410x00000a4c,0x000200f9,0x00001267,0x000200f8, 9060x000011a4,0x000000fc,0x000000fd,0x0004003d,
10420x00001267,0x000700f5,0x00000006,0x00002b1e, 9070x00000006,0x000011a5,0x000011a4,0x00050084,
10430x000000a3,0x00000a4c,0x00001277,0x00001275, 9080x00000006,0x000011a6,0x0000011f,0x000011a5,
10440x000500b0,0x0000002f,0x0000126a,0x00002b1e, 9090x00050080,0x00000006,0x000011a7,0x00000107,
10450x000002b4,0x000400f6,0x00001278,0x00001275, 9100x000011a6,0x00050080,0x00000006,0x000011ad,
10460x00000000,0x000400fa,0x0000126a,0x0000126b, 9110x000011a5,0x000032a8,0x00050086,0x00000006,
10470x00001278,0x000200f8,0x0000126b,0x00050084, 9120x000011ae,0x000011ad,0x00000101,0x00050084,
10480x00000006,0x0000126e,0x000002b4,0x000009e9, 9130x00000006,0x000011a0,0x00000107,0x000011ae,
10490x00050080,0x00000006,0x00001270,0x0000126e, 9140x00050080,0x00000006,0x000011a1,0x000011a7,
10500x00002b1e,0x000300f7,0x00001335,0x00000000, 9150x000011a0,0x00050084,0x00000006,0x00001175,
10510x000300fb,0x000000a3,0x00001313,0x000200f8, 9160x00000150,0x00001113,0x00050080,0x00000006,
10520x00001313,0x00050041,0x000000fb,0x00001314, 9170x00001176,0x000011a1,0x00001175,0x00050041,
10530x000000f9,0x00000278,0x0004003d,0x00000006, 9180x00000156,0x00001177,0x000000fc,0x00000154,
10540x00001315,0x00001314,0x000500aa,0x0000002f, 9190x0004003d,0x00000007,0x00001178,0x00001177,
10550x00001316,0x00001315,0x000000a3,0x000300f7, 9200x00050051,0x00000006,0x000011c5,0x00001178,
10560x00001319,0x00000000,0x000400fa,0x00001316, 9210x00000000,0x00050095,0x000000ab,0x000011c7,
10570x00001317,0x00001319,0x000200f8,0x00001317, 9220x000011c5,0x00001176,0x00050051,0x00000006,
10580x000200f9,0x00001335,0x000200f8,0x00001319, 9230x000011c8,0x000011c7,0x00000001,0x00050051,
10590x000500aa,0x0000002f,0x0000131c,0x00001315, 9240x00000006,0x000011c9,0x000011c7,0x00000000,
10600x0000016d,0x000300f7,0x00001323,0x00000000, 9250x00050051,0x00000006,0x000011cc,0x00001178,
10610x000400fa,0x0000131c,0x0000131d,0x00001323, 9260x00000001,0x00050080,0x00000006,0x000011ce,
10620x000200f8,0x0000131d,0x00050084,0x00000006, 9270x000011cc,0x000011c8,0x00050050,0x00000007,
10630x0000131f,0x00000107,0x00001270,0x00050041, 9280x000011cf,0x000011c9,0x000011ce,0x0004007c,
10640x00000153,0x00001320,0x000000f9,0x0000020a, 9290x00000014,0x000011bf,0x000011cf,0x00060041,
10650x0004003d,0x00000007,0x00001321,0x00001320, 9300x000000db,0x000011b6,0x000011bf,0x000000da,
10660x00050051,0x00000006,0x0000134d,0x00001321, 9310x000000da,0x0006003d,0x00000006,0x000011b7,
10670x00000000,0x00050095,0x000000a8,0x0000134f, 9320x000011b6,0x00000002,0x00000004,0x00050080,
10680x0000134d,0x0000131f,0x00050051,0x00000006, 9330x00000006,0x0000117d,0x00001176,0x0000010a,
10690x00001350,0x0000134f,0x00000001,0x00050051, 9340x00050095,0x000000ab,0x000011e8,0x000011c5,
10700x00000006,0x00001351,0x0000134f,0x00000000, 9350x0000117d,0x00050051,0x00000006,0x000011e9,
10710x00050051,0x00000006,0x00001354,0x00001321, 9360x000011e8,0x00000001,0x00050051,0x00000006,
10720x00000001,0x00050080,0x00000006,0x00001356, 9370x000011ea,0x000011e8,0x00000000,0x00050080,
10730x00001354,0x00001350,0x00050050,0x00000007, 9380x00000006,0x000011ef,0x000011cc,0x000011e9,
10740x00001357,0x00001351,0x00001356,0x0004007c, 9390x00050050,0x00000007,0x000011f0,0x000011ea,
10750x00000014,0x00001347,0x00001357,0x00060041, 9400x000011ef,0x0004007c,0x00000014,0x000011e0,
10760x000000d8,0x0000133e,0x00001347,0x000000d7, 9410x000011f0,0x00060041,0x000000db,0x000011d7,
10770x000000d7,0x0006003d,0x00000006,0x0000133f, 9420x000011e0,0x000000da,0x000000da,0x0006003d,
10780x0000133e,0x00000002,0x00000004,0x000200f9, 9430x00000006,0x000011d8,0x000011d7,0x00000002,
10790x00001335,0x000200f8,0x00001323,0x000500c2, 9440x00000004,0x00050080,0x00000006,0x00001183,
10800x00000006,0x00001325,0x00001270,0x00000151, 9450x00001176,0x00000111,0x00050095,0x000000ab,
10810x00050084,0x00000006,0x00001326,0x00000107, 9460x00001209,0x000011c5,0x00001183,0x00050051,
10820x00001325,0x00050041,0x00000153,0x00001327, 9470x00000006,0x0000120a,0x00001209,0x00000001,
10830x000000f9,0x0000020a,0x0004003d,0x00000007, 9480x00050051,0x00000006,0x0000120b,0x00001209,
10840x00001328,0x00001327,0x00050051,0x00000006, 9490x00000000,0x00050080,0x00000006,0x00001210,
10850x0000136e,0x00001328,0x00000000,0x00050095, 9500x000011cc,0x0000120a,0x00050050,0x00000007,
10860x000000a8,0x00001370,0x0000136e,0x00001326, 9510x00001211,0x0000120b,0x00001210,0x0004007c,
10870x00050051,0x00000006,0x00001371,0x00001370, 9520x00000014,0x00001201,0x00001211,0x00060041,
10880x00000001,0x00050051,0x00000006,0x00001372, 9530x000000db,0x000011f8,0x00001201,0x000000da,
10890x00001370,0x00000000,0x00050051,0x00000006, 9540x000000da,0x0006003d,0x00000006,0x000011f9,
10900x00001375,0x00001328,0x00000001,0x00050080, 9550x000011f8,0x00000002,0x00000004,0x00050080,
10910x00000006,0x00001377,0x00001375,0x00001371, 9560x00000006,0x0000118a,0x00001176,0x00000118,
10920x00050050,0x00000007,0x00001378,0x00001372, 9570x00050095,0x000000ab,0x0000122a,0x000011c5,
10930x00001377,0x0004007c,0x00000014,0x00001368, 9580x0000118a,0x00050051,0x00000006,0x0000122b,
10940x00001378,0x00060041,0x000000d8,0x0000135f, 9590x0000122a,0x00000001,0x00050051,0x00000006,
10950x00001368,0x000000d7,0x000000d7,0x0006003d, 9600x0000122c,0x0000122a,0x00000000,0x00050080,
10960x00000006,0x00001360,0x0000135f,0x00000002, 9610x00000006,0x00001231,0x000011cc,0x0000122b,
10970x00000004,0x000500c7,0x00000006,0x0000132b, 9620x00050050,0x00000007,0x00001232,0x0000122c,
10980x00001270,0x000000ad,0x000500ab,0x0000002f, 9630x00001231,0x0004007c,0x00000014,0x00001222,
10990x0000132c,0x0000132b,0x000000a3,0x000300f7, 9640x00001232,0x00060041,0x000000db,0x00001219,
11000x00001333,0x00000000,0x000400fa,0x0000132c, 9650x00001222,0x000000da,0x000000da,0x0006003d,
11010x0000132d,0x00001330,0x000200f8,0x0000132d, 9660x00000006,0x0000121a,0x00001219,0x00000002,
11020x000500c2,0x00000006,0x0000132f,0x00001360, 9670x00000004,0x00050080,0x00000006,0x00001190,
11030x0000023b,0x000200f9,0x00001333,0x000200f8, 9680x00001176,0x0000011f,0x00050095,0x000000ab,
11040x00001330,0x000500c7,0x00000006,0x00001332, 9690x0000124b,0x000011c5,0x00001190,0x00050051,
11050x00001360,0x000002a0,0x000200f9,0x00001333, 9700x00000006,0x0000124c,0x0000124b,0x00000001,
11060x000200f8,0x00001333,0x000700f5,0x00000006, 9710x00050051,0x00000006,0x0000124d,0x0000124b,
11070x00002b28,0x0000132f,0x0000132d,0x00001332, 9720x00000000,0x00050080,0x00000006,0x00001252,
11080x00001330,0x000200f9,0x00001335,0x000200f8, 9730x000011cc,0x0000124c,0x00050050,0x00000007,
11090x00001335,0x000900f5,0x00000006,0x00002b29, 9740x00001253,0x0000124d,0x00001252,0x0004007c,
11100x00001270,0x00001317,0x0000133f,0x0000131d, 9750x00000014,0x00001243,0x00001253,0x00060041,
11110x00002b28,0x00001333,0x00050041,0x000000fb, 9760x000000db,0x0000123a,0x00001243,0x000000da,
11120x00001389,0x000000f9,0x0000024d,0x0004003d, 9770x000000da,0x0006003d,0x00000006,0x0000123b,
11130x00000006,0x0000138a,0x00001389,0x00050084, 9780x0000123a,0x00000002,0x00000004,0x00050080,
11140x00000006,0x0000138b,0x00002b29,0x0000138a, 9790x00000006,0x00001196,0x00001176,0x00000189,
11150x00050041,0x00000153,0x0000138c,0x000000f9, 9800x00050095,0x000000ab,0x0000126c,0x000011c5,
11160x00000202,0x0004003d,0x00000007,0x0000138d, 9810x00001196,0x00050051,0x00000006,0x0000126d,
11170x0000138c,0x00050051,0x00000006,0x000013a8, 9820x0000126c,0x00000001,0x00050051,0x00000006,
11180x0000138d,0x00000000,0x00050095,0x000000a8, 9830x0000126e,0x0000126c,0x00000000,0x00050080,
11190x000013aa,0x000013a8,0x0000138b,0x00050051, 9840x00000006,0x00001273,0x000011cc,0x0000126d,
11200x00000006,0x000013ab,0x000013aa,0x00000001, 9850x00050050,0x00000007,0x00001274,0x0000126e,
11210x00050051,0x00000006,0x000013ac,0x000013aa, 9860x00001273,0x0004007c,0x00000014,0x00001264,
11220x00000000,0x00050051,0x00000006,0x000013af, 9870x00001274,0x00060041,0x000000db,0x0000125b,
11230x0000138d,0x00000001,0x00050080,0x00000006, 9880x00001264,0x000000da,0x000000da,0x0006003d,
11240x000013b1,0x000013af,0x000013ab,0x00050095, 9890x00000006,0x0000125c,0x0000125b,0x00000002,
11250x000000a8,0x000013cb,0x000013ac,0x000000a3, 9900x00000004,0x00050041,0x000000fe,0x00001117,
11260x00050051,0x00000006,0x000013cc,0x000013cb, 9910x000000fc,0x00000224,0x0004003d,0x00000006,
11270x00000001,0x00050051,0x00000006,0x000013cd, 9920x00001118,0x00001117,0x000500ab,0x0000002f,
11280x000013cb,0x00000000,0x00050080,0x00000006, 9930x00001119,0x00001118,0x000000a6,0x000600a9,
11290x000013d2,0x000013b1,0x000013cc,0x00050050, 9940x00000006,0x0000111a,0x00001119,0x000000a6,
11300x00000007,0x000013d3,0x000013cd,0x000013d2, 9950x00000130,0x000500c5,0x00000006,0x0000111b,
11310x0004007c,0x00000014,0x000013c3,0x000013d3, 9960x0000111a,0x00000239,0x00050041,0x00000156,
11320x00060041,0x000000d8,0x000013ba,0x000013c3, 9970x0000111c,0x000000fc,0x000000da,0x0004003d,
11330x000000d7,0x000000d7,0x0006003d,0x00000006, 9980x00000007,0x0000111d,0x0000111c,0x00050051,
11340x000013bb,0x000013ba,0x00000002,0x00000004, 9990x00000006,0x0000128a,0x0000111d,0x00000000,
11350x0004007c,0x00000027,0x00001391,0x000013bb, 10000x00050095,0x000000ab,0x0000128c,0x0000128a,
11360x00050095,0x000000a8,0x000013ec,0x000013ac, 10010x000000a6,0x00050051,0x00000006,0x0000128d,
11370x00000107,0x00050051,0x00000006,0x000013ed, 10020x0000128c,0x00000001,0x00050051,0x00000006,
11380x000013ec,0x00000001,0x00050051,0x00000006, 10030x0000128e,0x0000128c,0x00000000,0x00050051,
11390x000013ee,0x000013ec,0x00000000,0x00050080, 10040x00000006,0x00001291,0x0000111d,0x00000001,
11400x00000006,0x000013f3,0x000013b1,0x000013ed, 10050x00050080,0x00000006,0x00001293,0x00001291,
11410x00050050,0x00000007,0x000013f4,0x000013ee, 10060x0000128d,0x00050050,0x00000007,0x00001294,
11420x000013f3,0x0004007c,0x00000014,0x000013e4, 10070x0000128e,0x00001293,0x0004007c,0x00000014,
11430x000013f4,0x00060041,0x000000d8,0x000013db, 10080x00001284,0x00001294,0x00060041,0x000000db,
11440x000013e4,0x000000d7,0x000000d7,0x0006003d, 10090x0000127c,0x00001284,0x000000da,0x000000da,
11450x00000006,0x000013dc,0x000013db,0x00000002, 10100x0005003e,0x0000127c,0x0000111b,0x00000002,
11460x00000004,0x0004007c,0x00000027,0x00001394, 10110x00000004,0x00050041,0x000000fe,0x0000111f,
11470x000013dc,0x00050041,0x000000fb,0x00001395, 10120x000000fc,0x00000a97,0x0004003d,0x00000006,
11480x000000f9,0x00000263,0x0004003d,0x00000006, 10130x00001120,0x0000111f,0x00050086,0x00000006,
11490x00001396,0x00001395,0x000500aa,0x0000002f, 10140x00001121,0x00001120,0x00000107,0x00050095,
11500x00001397,0x00001396,0x000000ad,0x000300f7, 10150x000000ab,0x000012ac,0x0000128a,0x0000010a,
11510x0000139d,0x00000000,0x000400fa,0x00001397, 10160x00050051,0x00000006,0x000012ad,0x000012ac,
11520x00001398,0x00001399,0x000200f8,0x00001398, 10170x00000001,0x00050051,0x00000006,0x000012ae,
11530x000200f9,0x0000139d,0x000200f8,0x00001399, 10180x000012ac,0x00000000,0x00050080,0x00000006,
11540x00050095,0x000000a8,0x0000140d,0x000013ac, 10190x000012b3,0x00001291,0x000012ad,0x00050050,
11550x0000010e,0x00050051,0x00000006,0x0000140e, 10200x00000007,0x000012b4,0x000012ae,0x000012b3,
11560x0000140d,0x00000001,0x00050051,0x00000006, 10210x0004007c,0x00000014,0x000012a4,0x000012b4,
11570x0000140f,0x0000140d,0x00000000,0x00050080, 10220x00060041,0x000000db,0x0000129c,0x000012a4,
11580x00000006,0x00001414,0x000013b1,0x0000140e, 10230x000000da,0x000000da,0x0005003e,0x0000129c,
11590x00050050,0x00000007,0x00001415,0x0000140f, 10240x00001121,0x00000002,0x00000004,0x00050095,
11600x00001414,0x0004007c,0x00000014,0x00001405, 10250x000000ab,0x000012cc,0x0000128a,0x00000111,
11610x00001415,0x00060041,0x000000d8,0x000013fc, 10260x00050051,0x00000006,0x000012cd,0x000012cc,
11620x00001405,0x000000d7,0x000000d7,0x0006003d, 10270x00000001,0x00050051,0x00000006,0x000012ce,
11630x00000006,0x000013fd,0x000013fc,0x00000002, 10280x000012cc,0x00000000,0x00050080,0x00000006,
11640x00000004,0x0004007c,0x00000027,0x0000139c, 10290x000012d3,0x00001291,0x000012cd,0x00050050,
11650x000013fd,0x000200f9,0x0000139d,0x000200f8, 10300x00000007,0x000012d4,0x000012ce,0x000012d3,
11660x0000139d,0x000700f5,0x00000027,0x00002b2a, 10310x0004007c,0x00000014,0x000012c4,0x000012d4,
11670x0000026a,0x00001398,0x0000139c,0x00001399, 10320x00060041,0x000000db,0x000012bc,0x000012c4,
11680x00060050,0x0000004b,0x000013a2,0x00001391, 10330x000000da,0x000000da,0x0005003e,0x000012bc,
11690x00001394,0x00002b2a,0x000300f7,0x0000145b, 10340x000000a6,0x00000002,0x00000004,0x00050095,
11700x00000000,0x000300fb,0x000000a3,0x00001427, 10350x000000ab,0x000012ec,0x0000128a,0x00000118,
11710x000200f8,0x00001427,0x00050041,0x00000153, 10360x00050051,0x00000006,0x000012ed,0x000012ec,
11720x00001428,0x000000f9,0x00000212,0x0004003d, 10370x00000001,0x00050051,0x00000006,0x000012ee,
11730x00000007,0x00001429,0x00001428,0x00050051, 10380x000012ec,0x00000000,0x00050080,0x00000006,
11740x00000006,0x00001460,0x00001429,0x00000000, 10390x000012f3,0x00001291,0x000012ed,0x00050050,
11750x000500aa,0x0000002f,0x00001461,0x00001460, 10400x00000007,0x000012f4,0x000012ee,0x000012f3,
11760x000000a3,0x000300f7,0x00001466,0x00000000, 10410x0004007c,0x00000014,0x000012e4,0x000012f4,
11770x000400fa,0x00001461,0x00001462,0x00001466, 10420x00060041,0x000000db,0x000012dc,0x000012e4,
11780x000200f8,0x00001462,0x00050051,0x00000006, 10430x000000da,0x000000da,0x0005003e,0x000012dc,
11790x00001464,0x00001429,0x00000001,0x000500aa, 10440x00001111,0x00000002,0x00000004,0x00050095,
11800x0000002f,0x00001465,0x00001464,0x000000a3, 10450x000000ab,0x00001315,0x0000128a,0x0000011f,
11810x000200f9,0x00001466,0x000200f8,0x00001466, 10460x00050051,0x00000006,0x00001316,0x00001315,
11820x000700f5,0x0000002f,0x00001467,0x00001461, 10470x00000001,0x00050051,0x00000006,0x00001317,
11830x00001427,0x00001465,0x00001462,0x000300f7, 10480x00001315,0x00000000,0x00050080,0x00000006,
11840x0000142d,0x00000000,0x000400fa,0x00001467, 10490x0000131c,0x00001291,0x00001316,0x00050050,
11850x0000142b,0x0000142d,0x000200f8,0x0000142b, 10500x00000007,0x0000131d,0x00001317,0x0000131c,
11860x000200f9,0x0000145b,0x000200f8,0x0000142d, 10510x0004007c,0x00000014,0x0000130d,0x0000131d,
11870x000200f9,0x0000142e,0x000200f8,0x0000142e, 10520x00060041,0x000000db,0x00001305,0x0000130d,
11880x000700f5,0x00000006,0x00002b2b,0x000000a3, 10530x000000da,0x000000da,0x0005003e,0x00001305,
11890x0000142d,0x00001458,0x00001432,0x000500b0, 10540x000011b7,0x00000002,0x00000004,0x00050095,
11900x0000002f,0x00001431,0x00002b2b,0x000002b4, 10550x000000ab,0x0000133e,0x0000128a,0x00000189,
11910x000400f6,0x00001459,0x00001432,0x00000000, 10560x00050051,0x00000006,0x0000133f,0x0000133e,
11920x000400fa,0x00001431,0x00001432,0x00001459, 10570x00000001,0x00050051,0x00000006,0x00001340,
11930x000200f8,0x00001432,0x00050084,0x00000006, 10580x0000133e,0x00000000,0x00050080,0x00000006,
11940x00001434,0x0000011c,0x00002b2b,0x00050095, 10590x00001345,0x00001291,0x0000133f,0x00050050,
11950x000000a8,0x00001480,0x00001460,0x00001434, 10600x00000007,0x00001346,0x00001340,0x00001345,
11960x00050051,0x00000006,0x00001481,0x00001480, 10610x0004007c,0x00000014,0x00001336,0x00001346,
11970x00000001,0x00050051,0x00000006,0x00001482, 10620x00060041,0x000000db,0x0000132e,0x00001336,
11980x00001480,0x00000000,0x00050051,0x00000006, 10630x000000da,0x000000da,0x0005003e,0x0000132e,
11990x00001485,0x00001429,0x00000001,0x00050080, 10640x000011d8,0x00000002,0x00000004,0x00050095,
12000x00000006,0x00001487,0x00001485,0x00001481, 10650x000000ab,0x00001367,0x0000128a,0x00000150,
12010x00050050,0x00000007,0x00001488,0x00001482, 10660x00050051,0x00000006,0x00001368,0x00001367,
12020x00001487,0x0004007c,0x00000014,0x00001478, 10670x00000001,0x00050051,0x00000006,0x00001369,
12030x00001488,0x00060041,0x000000d8,0x0000146f, 10680x00001367,0x00000000,0x00050080,0x00000006,
12040x00001478,0x000000d7,0x000000d7,0x0006003d, 10690x0000136e,0x00001291,0x00001368,0x00050050,
12050x00000006,0x00001470,0x0000146f,0x00000002, 10700x00000007,0x0000136f,0x00001369,0x0000136e,
12060x00000004,0x0004007c,0x00000027,0x00001439, 10710x0004007c,0x00000014,0x0000135f,0x0000136f,
12070x00001470,0x00050080,0x00000006,0x0000143b, 10720x00060041,0x000000db,0x00001357,0x0000135f,
12080x00001434,0x00000107,0x00050095,0x000000a8, 10730x000000da,0x000000da,0x0005003e,0x00001357,
12090x000014a1,0x00001460,0x0000143b,0x00050051, 10740x000011f9,0x00000002,0x00000004,0x00050095,
12100x00000006,0x000014a2,0x000014a1,0x00000001, 10750x000000ab,0x00001390,0x0000128a,0x00000463,
12110x00050051,0x00000006,0x000014a3,0x000014a1, 10760x00050051,0x00000006,0x00001391,0x00001390,
12120x00000000,0x00050080,0x00000006,0x000014a8, 10770x00000001,0x00050051,0x00000006,0x00001392,
12130x00001485,0x000014a2,0x00050050,0x00000007, 10780x00001390,0x00000000,0x00050080,0x00000006,
12140x000014a9,0x000014a3,0x000014a8,0x0004007c, 10790x00001397,0x00001291,0x00001391,0x00050050,
12150x00000014,0x00001499,0x000014a9,0x00060041, 10800x00000007,0x00001398,0x00001392,0x00001397,
12160x000000d8,0x00001490,0x00001499,0x000000d7, 10810x0004007c,0x00000014,0x00001388,0x00001398,
12170x000000d7,0x0006003d,0x00000006,0x00001491, 10820x00060041,0x000000db,0x00001380,0x00001388,
12180x00001490,0x00000002,0x00000004,0x0004007c, 10830x000000da,0x000000da,0x0005003e,0x00001380,
12190x00000027,0x0000143f,0x00001491,0x00050080, 10840x0000121a,0x00000002,0x00000004,0x00050095,
12200x00000006,0x00001441,0x00001434,0x0000010e, 10850x000000ab,0x000013b9,0x0000128a,0x00000469,
12210x00050095,0x000000a8,0x000014c2,0x00001460, 10860x00050051,0x00000006,0x000013ba,0x000013b9,
12220x00001441,0x00050051,0x00000006,0x000014c3, 10870x00000001,0x00050051,0x00000006,0x000013bb,
12230x000014c2,0x00000001,0x00050051,0x00000006, 10880x000013b9,0x00000000,0x00050080,0x00000006,
12240x000014c4,0x000014c2,0x00000000,0x00050080, 10890x000013c0,0x00001291,0x000013ba,0x00050050,
12250x00000006,0x000014c9,0x00001485,0x000014c3, 10900x00000007,0x000013c1,0x000013bb,0x000013c0,
12260x00050050,0x00000007,0x000014ca,0x000014c4, 10910x0004007c,0x00000014,0x000013b1,0x000013c1,
12270x000014c9,0x0004007c,0x00000014,0x000014ba, 10920x00060041,0x000000db,0x000013a9,0x000013b1,
12280x000014ca,0x00060041,0x000000d8,0x000014b1, 10930x000000da,0x000000da,0x0005003e,0x000013a9,
12290x000014ba,0x000000d7,0x000000d7,0x0006003d, 10940x0000123b,0x00000002,0x00000004,0x00050095,
12300x00000006,0x000014b2,0x000014b1,0x00000002, 10950x000000ab,0x000013e2,0x0000128a,0x00000347,
12310x00000004,0x0004007c,0x00000027,0x00001445, 10960x00050051,0x00000006,0x000013e3,0x000013e2,
12320x000014b2,0x00050080,0x00000006,0x00001447, 10970x00000001,0x00050051,0x00000006,0x000013e4,
12330x00001434,0x00000115,0x00050095,0x000000a8, 10980x000013e2,0x00000000,0x00050080,0x00000006,
12340x000014e3,0x00001460,0x00001447,0x00050051, 10990x000013e9,0x00001291,0x000013e3,0x00050050,
12350x00000006,0x000014e4,0x000014e3,0x00000001, 11000x00000007,0x000013ea,0x000013e4,0x000013e9,
12360x00050051,0x00000006,0x000014e5,0x000014e3, 11010x0004007c,0x00000014,0x000013da,0x000013ea,
12370x00000000,0x00050080,0x00000006,0x000014ea, 11020x00060041,0x000000db,0x000013d2,0x000013da,
12380x00001485,0x000014e4,0x00050050,0x00000007, 11030x000000da,0x000000da,0x0005003e,0x000013d2,
12390x000014eb,0x000014e5,0x000014ea,0x0004007c, 11040x0000125c,0x00000002,0x00000004,0x00050041,
12400x00000014,0x000014db,0x000014eb,0x00060041, 11050x000000fe,0x0000114d,0x000000fc,0x0000023e,
12410x000000d8,0x000014d2,0x000014db,0x000000d7, 11060x0004003d,0x00000006,0x0000114e,0x0000114d,
12420x000000d7,0x0006003d,0x00000006,0x000014d3, 11070x00050095,0x000000ab,0x00001402,0x0000128a,
12430x000014d2,0x00000002,0x00000004,0x0004007c, 11080x00000352,0x00050051,0x00000006,0x00001403,
12440x00000027,0x0000144b,0x000014d3,0x00070050, 11090x00001402,0x00000001,0x00050051,0x00000006,
12450x000002b9,0x0000144c,0x00001439,0x0000143f, 11100x00001404,0x00001402,0x00000000,0x00050080,
12460x00001445,0x0000144b,0x0008004f,0x0000004b, 11110x00000006,0x00001409,0x00001291,0x00001403,
12470x0000144f,0x0000144c,0x0000144c,0x00000000, 11120x00050050,0x00000007,0x0000140a,0x00001404,
12480x00000001,0x00000002,0x00050094,0x00000027, 11130x00001409,0x0004007c,0x00000014,0x000013fa,
12490x00001451,0x0000144f,0x000013a2,0x00050081, 11140x0000140a,0x00060041,0x000000db,0x000013f2,
12500x00000027,0x00001454,0x00001451,0x0000144b, 11150x000013fa,0x000000da,0x000000da,0x0005003e,
12510x00050041,0x00000028,0x00001455,0x00001424, 11160x000013f2,0x0000114e,0x00000002,0x00000004,
12520x00002b2b,0x0003003e,0x00001455,0x00001454, 11170x00050095,0x000000ab,0x00001422,0x0000128a,
12530x00050080,0x00000006,0x00001458,0x00002b2b, 11180x0000035d,0x00050051,0x00000006,0x00001423,
12540x00000151,0x000200f9,0x0000142e,0x000200f8, 11190x00001422,0x00000001,0x00050051,0x00000006,
12550x00001459,0x0004003d,0x0000004b,0x0000145a, 11200x00001424,0x00001422,0x00000000,0x00050080,
12560x00001424,0x000200f9,0x0000145b,0x000200f8, 11210x00000006,0x00001429,0x00001291,0x00001423,
12570x0000145b,0x000700f5,0x0000004b,0x00002b2c, 11220x00050050,0x00000007,0x0000142a,0x00001424,
12580x000013a2,0x0000142b,0x0000145a,0x00001459, 11230x00001429,0x0004007c,0x00000014,0x0000141a,
12590x00050041,0x0000004c,0x00001274,0x00001239, 11240x0000142a,0x00060041,0x000000db,0x00001412,
12600x00002b1e,0x0003003e,0x00001274,0x00002b2c, 11250x0000141a,0x000000da,0x000000da,0x0005003e,
12610x000200f9,0x00001275,0x000200f8,0x00001275, 11260x00001412,0x000000a6,0x00000002,0x00000004,
12620x00050080,0x00000006,0x00001277,0x00002b1e, 11270x00050084,0x00000006,0x00001430,0x0000110f,
12630x00000151,0x000200f9,0x00001267,0x000200f8, 11280x00000228,0x00050080,0x00000006,0x00001431,
12640x00001278,0x00050041,0x000000fb,0x00001279, 11290x0000114e,0x00001430,0x000500c2,0x00000006,
12650x000000f9,0x00000305,0x0004003d,0x00000006, 11300x00001432,0x00001431,0x00000233,0x000500c4,
12660x0000127a,0x00001279,0x00050080,0x00000006, 11310x00000006,0x00001433,0x00001432,0x0000020d,
12670x0000127c,0x0000127a,0x000009e9,0x00050041, 11320x000500c5,0x00000006,0x00001434,0x00001433,
12680x000000fb,0x0000127d,0x000000f9,0x00000229, 11330x00000246,0x00050095,0x000000ab,0x0000144c,
12690x0004003d,0x00000006,0x0000127e,0x0000127d, 11340x0000128a,0x00000368,0x00050051,0x00000006,
12700x00050084,0x00000006,0x00001280,0x00000104, 11350x0000144d,0x0000144c,0x00000001,0x00050051,
12710x0000127c,0x00050080,0x00000006,0x00001281, 11360x00000006,0x0000144e,0x0000144c,0x00000000,
12720x0000127e,0x00001280,0x000200f9,0x00001282, 11370x00050080,0x00000006,0x00001453,0x00001291,
12730x000200f8,0x00001282,0x000700f5,0x00000006, 11380x0000144d,0x00050050,0x00000007,0x00001454,
12740x00002b1f,0x000000a3,0x00001278,0x000012a9, 11390x0000144e,0x00001453,0x0004007c,0x00000014,
12750x00001286,0x000500b0,0x0000002f,0x00001285, 11400x00001444,0x00001454,0x00060041,0x000000db,
12760x00002b1f,0x000002b4,0x000400f6,0x000012aa, 11410x0000143c,0x00001444,0x000000da,0x000000da,
12770x00001286,0x00000000,0x000400fa,0x00001285, 11420x0005003e,0x0000143c,0x00001434,0x00000002,
12780x00001286,0x000012aa,0x000200f8,0x00001286, 11430x00000004,0x00050041,0x000000fe,0x0000115a,
12790x00050084,0x00000006,0x00001289,0x00000115, 11440x000000fc,0x0000022c,0x0004003d,0x00000006,
12800x00002b1f,0x00050080,0x00000006,0x0000128a, 11450x0000115b,0x0000115a,0x00050095,0x000000ab,
12810x00001281,0x00001289,0x00050041,0x00000153, 11460x0000146c,0x0000128a,0x00000374,0x00050051,
12820x0000128c,0x000000f9,0x000000d7,0x0004003d, 11470x00000006,0x0000146d,0x0000146c,0x00000001,
12830x00000007,0x0000128d,0x0000128c,0x00060041, 11480x00050051,0x00000006,0x0000146e,0x0000146c,
12840x00000028,0x0000128e,0x00001239,0x00002b1f, 11490x00000000,0x00050080,0x00000006,0x00001473,
12850x000000a3,0x0004003d,0x00000027,0x0000128f, 11500x00001291,0x0000146d,0x00050050,0x00000007,
12860x0000128e,0x0004007c,0x00000006,0x000014f1, 11510x00001474,0x0000146e,0x00001473,0x0004007c,
12870x0000128f,0x00050051,0x00000006,0x0000150a, 11520x00000014,0x00001464,0x00001474,0x00060041,
12880x0000128d,0x00000000,0x00050095,0x000000a8, 11530x000000db,0x0000145c,0x00001464,0x000000da,
12890x0000150c,0x0000150a,0x0000128a,0x00050051, 11540x000000da,0x0005003e,0x0000145c,0x0000115b,
12900x00000006,0x0000150d,0x0000150c,0x00000001, 11550x00000002,0x00000004,0x00050041,0x000000fe,
12910x00050051,0x00000006,0x0000150e,0x0000150c, 11560x0000115f,0x000000fc,0x000009ef,0x0004003d,
12920x00000000,0x00050051,0x00000006,0x00001511, 11570x00000006,0x00001160,0x0000115f,0x00050095,
12930x0000128d,0x00000001,0x00050080,0x00000006, 11580x000000ab,0x0000148c,0x0000128a,0x0000037e,
12940x00001513,0x00001511,0x0000150d,0x00050050, 11590x00050051,0x00000006,0x0000148d,0x0000148c,
12950x00000007,0x00001514,0x0000150e,0x00001513, 11600x00000001,0x00050051,0x00000006,0x0000148e,
12960x0004007c,0x00000014,0x00001504,0x00001514, 11610x0000148c,0x00000000,0x00050080,0x00000006,
12970x00060041,0x000000d8,0x000014fc,0x00001504, 11620x00001493,0x00001291,0x0000148d,0x00050050,
12980x000000d7,0x000000d7,0x0005003e,0x000014fc, 11630x00000007,0x00001494,0x0000148e,0x00001493,
12990x000014f1,0x00000002,0x00000004,0x00050080, 11640x0004007c,0x00000014,0x00001484,0x00001494,
13000x00000006,0x00001295,0x0000128a,0x00000107, 11650x00060041,0x000000db,0x0000147c,0x00001484,
13010x00060041,0x00000028,0x00001299,0x00001239, 11660x000000da,0x000000da,0x0005003e,0x0000147c,
13020x00002b1f,0x000000ad,0x0004003d,0x00000027, 11670x00001160,0x00000002,0x00000004,0x00050095,
13030x0000129a,0x00001299,0x0004007c,0x00000006, 11680x000000ab,0x000014ac,0x0000128a,0x00000388,
13040x0000151a,0x0000129a,0x00050095,0x000000a8, 11690x00050051,0x00000006,0x000014ad,0x000014ac,
13050x00001535,0x0000150a,0x00001295,0x00050051, 11700x00000001,0x00050051,0x00000006,0x000014ae,
13060x00000006,0x00001536,0x00001535,0x00000001, 11710x000014ac,0x00000000,0x00050080,0x00000006,
13070x00050051,0x00000006,0x00001537,0x00001535, 11720x000014b3,0x00001291,0x000014ad,0x00050050,
13080x00000000,0x00050080,0x00000006,0x0000153c, 11730x00000007,0x000014b4,0x000014ae,0x000014b3,
13090x00001511,0x00001536,0x00050050,0x00000007, 11740x0004007c,0x00000014,0x000014a4,0x000014b4,
13100x0000153d,0x00001537,0x0000153c,0x0004007c, 11750x00060041,0x000000db,0x0000149c,0x000014a4,
13110x00000014,0x0000152d,0x0000153d,0x00060041, 11760x000000da,0x000000da,0x0005003e,0x0000149c,
13120x000000d8,0x00001525,0x0000152d,0x000000d7, 11770x000000a6,0x00000002,0x00000004,0x000200f9,
13130x000000d7,0x0005003e,0x00001525,0x0000151a, 11780x00000b4b,0x000200f8,0x00000b4b,0x000200f9,
13140x00000002,0x00000004,0x00050080,0x00000006, 11790x00000bf3,0x000200f8,0x00000b47,0x00050041,
13150x000012a0,0x0000128a,0x0000010e,0x00060041, 11800x000000fe,0x00000b4f,0x000000fc,0x000004d8,
13160x00000028,0x000012a4,0x00001239,0x00002b1f, 11810x0004003d,0x00000006,0x00000b50,0x00000b4f,
13170x0000016d,0x0004003d,0x00000027,0x000012a5, 11820x000500ae,0x0000002f,0x00000b51,0x00000b11,
13180x000012a4,0x0004007c,0x00000006,0x00001543, 11830x00000b50,0x000300f7,0x00000b53,0x00000000,
13190x000012a5,0x00050095,0x000000a8,0x0000155e, 11840x000400fa,0x00000b51,0x00000b52,0x00000b53,
13200x0000150a,0x000012a0,0x00050051,0x00000006, 11850x000200f8,0x00000b52,0x000200f9,0x00000bf3,
13210x0000155f,0x0000155e,0x00000001,0x00050051, 11860x000200f8,0x00000b53,0x000500aa,0x0000002f,
13220x00000006,0x00001560,0x0000155e,0x00000000, 11870x00000b58,0x00000b13,0x00000b57,0x000300f7,
13230x00050080,0x00000006,0x00001565,0x00001511, 11880x00000b5a,0x00000000,0x000400fa,0x00000b58,
13240x0000155f,0x00050050,0x00000007,0x00001566, 11890x00000b59,0x00000b5a,0x000200f8,0x00000b59,
13250x00001560,0x00001565,0x0004007c,0x00000014, 11900x000500aa,0x0000002f,0x00000b5c,0x00000b11,
13260x00001556,0x00001566,0x00060041,0x000000d8, 11910x000000a6,0x000300f7,0x00000b5e,0x00000000,
13270x0000154e,0x00001556,0x000000d7,0x000000d7, 11920x000400fa,0x00000b5c,0x00000b5d,0x00000b5e,
13280x0005003e,0x0000154e,0x00001543,0x00000002, 11930x000200f8,0x00000b5d,0x00050041,0x00000156,
13290x00000004,0x00050080,0x00000006,0x000012a9, 11940x00000b60,0x000000fc,0x00000205,0x0004003d,
13300x00002b1f,0x00000151,0x000200f9,0x00001282, 11950x00000007,0x00000b61,0x00000b60,0x00050051,
13310x000200f8,0x000012aa,0x00050080,0x00000006, 11960x00000006,0x000014cb,0x00000b61,0x00000000,
13320x000012ac,0x00001281,0x00000344,0x00050041, 11970x00050095,0x000000ab,0x000014cd,0x000014cb,
13330x00000153,0x000012ad,0x000000f9,0x000000d7, 11980x0000010a,0x00050051,0x00000006,0x000014ce,
13340x0004003d,0x00000007,0x000012ae,0x000012ad, 11990x000014cd,0x00000001,0x00050051,0x00000006,
13350x00060041,0x00000028,0x000012af,0x00001239, 12000x000014cf,0x000014cd,0x00000000,0x00050051,
13360x00000202,0x000000a3,0x0004003d,0x00000027, 12010x00000006,0x000014d2,0x00000b61,0x00000001,
13370x000012b0,0x000012af,0x0004007c,0x00000006, 12020x00050080,0x00000006,0x000014d4,0x000014d2,
13380x0000156c,0x000012b0,0x00050051,0x00000006, 12030x000014ce,0x00050050,0x00000007,0x000014d5,
13390x00001585,0x000012ae,0x00000000,0x00050095, 12040x000014cf,0x000014d4,0x0004007c,0x00000014,
13400x000000a8,0x00001587,0x00001585,0x000012ac, 12050x000014c5,0x000014d5,0x00060041,0x000000db,
13410x00050051,0x00000006,0x00001588,0x00001587, 12060x000014bc,0x000014c5,0x000000da,0x000000da,
13420x00000001,0x00050051,0x00000006,0x00001589, 12070x0006003d,0x00000006,0x000014bd,0x000014bc,
13430x00001587,0x00000000,0x00050051,0x00000006, 12080x00000002,0x00000004,0x00050084,0x00000006,
13440x0000158c,0x000012ae,0x00000001,0x00050080, 12090x00000b64,0x000014bd,0x00000107,0x00050041,
13450x00000006,0x0000158e,0x0000158c,0x00001588, 12100x00000156,0x00000b66,0x000000fc,0x000000da,
13460x00050050,0x00000007,0x0000158f,0x00001589, 12110x0004003d,0x00000007,0x00000b67,0x00000b66,
13470x0000158e,0x0004007c,0x00000014,0x0000157f, 12120x00050051,0x00000006,0x000014eb,0x00000b67,
13480x0000158f,0x00060041,0x000000d8,0x00001577, 12130x00000000,0x00050095,0x000000ab,0x000014ed,
13490x0000157f,0x000000d7,0x000000d7,0x0005003e, 12140x000014eb,0x000000a6,0x00050051,0x00000006,
13500x00001577,0x0000156c,0x00000002,0x00000004, 12150x000014ee,0x000014ed,0x00000001,0x00050051,
13510x00050080,0x00000006,0x000012b3,0x00001281, 12160x00000006,0x000014ef,0x000014ed,0x00000000,
13520x0000034f,0x00060041,0x00000028,0x000012b6, 12170x00050051,0x00000006,0x000014f2,0x00000b67,
13530x00001239,0x00000202,0x000000ad,0x0004003d, 12180x00000001,0x00050080,0x00000006,0x000014f4,
13540x00000027,0x000012b7,0x000012b6,0x0004007c, 12190x000014f2,0x000014ee,0x00050050,0x00000007,
13550x00000006,0x00001595,0x000012b7,0x00050095, 12200x000014f5,0x000014ef,0x000014f4,0x0004007c,
13560x000000a8,0x000015b0,0x00001585,0x000012b3, 12210x00000014,0x000014e5,0x000014f5,0x00060041,
13570x00050051,0x00000006,0x000015b1,0x000015b0, 12220x000000db,0x000014dd,0x000014e5,0x000000da,
13580x00000001,0x00050051,0x00000006,0x000015b2, 12230x000000da,0x0005003e,0x000014dd,0x00000b64,
13590x000015b0,0x00000000,0x00050080,0x00000006, 12240x00000002,0x00000004,0x00050095,0x000000ab,
13600x000015b7,0x0000158c,0x000015b1,0x00050050, 12250x0000150d,0x000014eb,0x0000010a,0x00050051,
13610x00000007,0x000015b8,0x000015b2,0x000015b7, 12260x00000006,0x0000150e,0x0000150d,0x00000001,
13620x0004007c,0x00000014,0x000015a8,0x000015b8, 12270x00050051,0x00000006,0x0000150f,0x0000150d,
13630x00060041,0x000000d8,0x000015a0,0x000015a8, 12280x00000000,0x00050080,0x00000006,0x00001514,
13640x000000d7,0x000000d7,0x0005003e,0x000015a0, 12290x000014f2,0x0000150e,0x00050050,0x00000007,
13650x00001595,0x00000002,0x00000004,0x00050080, 12300x00001515,0x0000150f,0x00001514,0x0004007c,
13660x00000006,0x000012ba,0x00001281,0x0000035a, 12310x00000014,0x00001505,0x00001515,0x00060041,
13670x00060041,0x00000028,0x000012bd,0x00001239, 12320x000000db,0x000014fd,0x00001505,0x000000da,
13680x00000202,0x0000016d,0x0004003d,0x00000027, 12330x000000da,0x0005003e,0x000014fd,0x000000a6,
13690x000012be,0x000012bd,0x0004007c,0x00000006, 12340x00000002,0x00000004,0x000200f9,0x00000b5e,
13700x000015be,0x000012be,0x00050095,0x000000a8, 12350x000200f8,0x00000b5e,0x000200f9,0x00000bf3,
13710x000015d9,0x00001585,0x000012ba,0x00050051, 12360x000200f8,0x00000b5a,0x000500aa,0x0000002f,
13720x00000006,0x000015da,0x000015d9,0x00000001, 12370x00000b74,0x00000b13,0x00000118,0x000300f7,
13730x00050051,0x00000006,0x000015db,0x000015d9, 12380x00000b76,0x00000000,0x000400fa,0x00000b74,
13740x00000000,0x00050080,0x00000006,0x000015e0, 12390x00000b75,0x00000b76,0x000200f8,0x00000b75,
13750x0000158c,0x000015da,0x00050050,0x00000007, 12400x00050084,0x00000006,0x00000b78,0x0000010a,
13760x000015e1,0x000015db,0x000015e0,0x0004007c, 12410x00000b11,0x00050041,0x00000156,0x00000b7a,
13770x00000014,0x000015d1,0x000015e1,0x00060041, 12420x000000fc,0x00000205,0x0004003d,0x00000007,
13780x000000d8,0x000015c9,0x000015d1,0x000000d7, 12430x00000b7b,0x00000b7a,0x00050051,0x00000006,
13790x000000d7,0x0005003e,0x000015c9,0x000015be, 12440x0000152c,0x00000b7b,0x00000000,0x00050095,
13800x00000002,0x00000004,0x00050080,0x00000006, 12450x000000ab,0x0000152e,0x0000152c,0x0000010a,
13810x000012c1,0x00001281,0x00000365,0x00050041, 12460x00050051,0x00000006,0x0000152f,0x0000152e,
13820x000000fb,0x000012c4,0x000000f9,0x00000367, 12470x00000001,0x00050051,0x00000006,0x00001530,
13830x0004003d,0x00000006,0x000012c5,0x000012c4, 12480x0000152e,0x00000000,0x00050051,0x00000006,
13840x00050095,0x000000a8,0x000015f9,0x00001585, 12490x00001533,0x00000b7b,0x00000001,0x00050080,
13850x000012c1,0x00050051,0x00000006,0x000015fa, 12500x00000006,0x00001535,0x00001533,0x0000152f,
13860x000015f9,0x00000001,0x00050051,0x00000006, 12510x00050050,0x00000007,0x00001536,0x00001530,
13870x000015fb,0x000015f9,0x00000000,0x00050080, 12520x00001535,0x0004007c,0x00000014,0x00001526,
13880x00000006,0x00001600,0x0000158c,0x000015fa, 12530x00001536,0x00060041,0x000000db,0x0000151d,
13890x00050050,0x00000007,0x00001601,0x000015fb, 12540x00001526,0x000000da,0x000000da,0x0006003d,
13900x00001600,0x0004007c,0x00000014,0x000015f1, 12550x00000006,0x0000151e,0x0000151d,0x00000002,
13910x00001601,0x00060041,0x000000d8,0x000015e9, 12560x00000004,0x00050084,0x00000006,0x00000b7e,
13920x000015f1,0x000000d7,0x000000d7,0x0005003e, 12570x0000151e,0x00000107,0x000500b0,0x0000002f,
13930x000015e9,0x000012c5,0x00000002,0x00000004, 12580x00000b7f,0x00000b78,0x00000b7e,0x000300f7,
13940x00050080,0x00000006,0x000012c8,0x00001281, 12590x00000b81,0x00000000,0x000400fa,0x00000b7f,
13950x00000371,0x00050095,0x000000a8,0x00001619, 12600x00000b80,0x00000b81,0x000200f8,0x00000b80,
13960x00001585,0x000012c8,0x00050051,0x00000006, 12610x00050095,0x000000ab,0x0000154f,0x0000152c,
13970x0000161a,0x00001619,0x00000001,0x00050051, 12620x00000b78,0x00050051,0x00000006,0x00001550,
13980x00000006,0x0000161b,0x00001619,0x00000000, 12630x0000154f,0x00000001,0x00050051,0x00000006,
13990x00050080,0x00000006,0x00001620,0x0000158c, 12640x00001551,0x0000154f,0x00000000,0x00050080,
14000x0000161a,0x00050050,0x00000007,0x00001621, 12650x00000006,0x00001556,0x00001533,0x00001550,
14010x0000161b,0x00001620,0x0004007c,0x00000014, 12660x00050050,0x00000007,0x00001557,0x00001551,
14020x00001611,0x00001621,0x00060041,0x000000d8, 12670x00001556,0x0004007c,0x00000014,0x00001547,
14030x00001609,0x00001611,0x000000d7,0x000000d7, 12680x00001557,0x00060041,0x000000db,0x0000153e,
14040x0005003e,0x00001609,0x000009e9,0x00000002, 12690x00001547,0x000000da,0x000000da,0x0006003d,
14050x00000004,0x00050080,0x00000006,0x000012ce, 12700x00000006,0x0000153f,0x0000153e,0x00000002,
14060x00001281,0x0000037b,0x00050095,0x000000a8, 12710x00000004,0x00050041,0x00000156,0x00000b8c,
14070x00001639,0x00001585,0x000012ce,0x00050051, 12720x000000fc,0x000000da,0x0004003d,0x00000007,
14080x00000006,0x0000163a,0x00001639,0x00000001, 12730x00000b8d,0x00000b8c,0x00050051,0x00000006,
14090x00050051,0x00000006,0x0000163b,0x00001639, 12740x0000156d,0x00000b8d,0x00000000,0x00050095,
14100x00000000,0x00050080,0x00000006,0x00001640, 12750x000000ab,0x0000156f,0x0000156d,0x00000b78,
14110x0000158c,0x0000163a,0x00050050,0x00000007, 12760x00050051,0x00000006,0x00001570,0x0000156f,
14120x00001641,0x0000163b,0x00001640,0x0004007c, 12770x00000001,0x00050051,0x00000006,0x00001571,
14130x00000014,0x00001631,0x00001641,0x00060041, 12780x0000156f,0x00000000,0x00050051,0x00000006,
14140x000000d8,0x00001629,0x00001631,0x000000d7, 12790x00001574,0x00000b8d,0x00000001,0x00050080,
14150x000000d7,0x0005003e,0x00001629,0x0000037d, 12800x00000006,0x00001576,0x00001574,0x00001570,
14160x00000002,0x00000004,0x00050080,0x00000006, 12810x00050050,0x00000007,0x00001577,0x00001571,
14170x000012d3,0x00001281,0x00000385,0x00050095, 12820x00001576,0x0004007c,0x00000014,0x00001567,
14180x000000a8,0x00001659,0x00001585,0x000012d3, 12830x00001577,0x00060041,0x000000db,0x0000155f,
14190x00050051,0x00000006,0x0000165a,0x00001659, 12840x00001567,0x000000da,0x000000da,0x0005003e,
14200x00000001,0x00050051,0x00000006,0x0000165b, 12850x0000155f,0x0000153f,0x00000002,0x00000004,
14210x00001659,0x00000000,0x00050080,0x00000006, 12860x000200f9,0x00000b81,0x000200f8,0x00000b81,
14220x00001660,0x0000158c,0x0000165a,0x00050050, 12870x000200f9,0x00000bf3,0x000200f8,0x00000b76,
14230x00000007,0x00001661,0x0000165b,0x00001660, 12880x000500aa,0x0000002f,0x00000b95,0x00000b13,
14240x0004007c,0x00000014,0x00001651,0x00001661, 12890x00000b94,0x000300f7,0x00000b97,0x00000000,
14250x00060041,0x000000d8,0x00001649,0x00001651, 12900x000400fa,0x00000b95,0x00000b96,0x00000ba7,
14260x000000d7,0x000000d7,0x0005003e,0x00001649, 12910x000200f8,0x00000b96,0x00050084,0x00000006,
14270x00000387,0x00000002,0x00000004,0x00050041, 12920x00000b99,0x0000010a,0x00000b11,0x00050041,
14280x0000004c,0x000012d7,0x00001239,0x000000d7, 12930x00000156,0x00000b9d,0x000000fc,0x00000205,
14290x0004003d,0x0000004b,0x000012d8,0x000012d7, 12940x0004003d,0x00000007,0x00000b9e,0x00000b9d,
14300x0004009c,0x00000392,0x000012d9,0x000012d8, 12950x00050051,0x00000006,0x0000158e,0x00000b9e,
14310x0004009a,0x0000002f,0x000012da,0x000012d9, 12960x00000000,0x00050095,0x000000ab,0x00001590,
14320x000400a8,0x0000002f,0x000012db,0x000012da, 12970x0000158e,0x00000b99,0x00050051,0x00000006,
14330x000300f7,0x000012e1,0x00000000,0x000400fa, 12980x00001591,0x00001590,0x00000001,0x00050051,
14340x000012db,0x000012dc,0x000012e1,0x000200f8, 12990x00000006,0x00001592,0x00001590,0x00000000,
14350x000012dc,0x00050041,0x0000004c,0x000012dd, 13000x00050051,0x00000006,0x00001595,0x00000b9e,
14360x00001239,0x00000151,0x0004003d,0x0000004b, 13010x00000001,0x00050080,0x00000006,0x00001597,
14370x000012de,0x000012dd,0x0004009c,0x00000392, 13020x00001595,0x00001591,0x00050050,0x00000007,
14380x000012df,0x000012de,0x0004009a,0x0000002f, 13030x00001598,0x00001592,0x00001597,0x0004007c,
14390x000012e0,0x000012df,0x000200f9,0x000012e1, 13040x00000014,0x00001588,0x00001598,0x00060041,
14400x000200f8,0x000012e1,0x000700f5,0x0000002f, 13050x000000db,0x0000157f,0x00001588,0x000000da,
14410x000012e2,0x000012da,0x000012aa,0x000012e0, 13060x000000da,0x0006003d,0x00000006,0x00001580,
14420x000012dc,0x000400a8,0x0000002f,0x000012e3, 13070x0000157f,0x00000002,0x00000004,0x00050041,
14430x000012e2,0x000300f7,0x000012e9,0x00000000, 13080x00000156,0x00000ba2,0x000000fc,0x000000da,
14440x000400fa,0x000012e3,0x000012e4,0x000012e9, 13090x0004003d,0x00000007,0x00000ba3,0x00000ba2,
14450x000200f8,0x000012e4,0x00050041,0x0000004c, 13100x00050051,0x00000006,0x000015ae,0x00000ba3,
14460x000012e5,0x00001239,0x00000202,0x0004003d, 13110x00000000,0x00050095,0x000000ab,0x000015b0,
14470x0000004b,0x000012e6,0x000012e5,0x0004009c, 13120x000015ae,0x00000b99,0x00050051,0x00000006,
14480x00000392,0x000012e7,0x000012e6,0x0004009a, 13130x000015b1,0x000015b0,0x00000001,0x00050051,
14490x0000002f,0x000012e8,0x000012e7,0x000200f9, 13140x00000006,0x000015b2,0x000015b0,0x00000000,
14500x000012e9,0x000200f8,0x000012e9,0x000700f5, 13150x00050051,0x00000006,0x000015b5,0x00000ba3,
14510x0000002f,0x000012ea,0x000012e2,0x000012e1, 13160x00000001,0x00050080,0x00000006,0x000015b7,
14520x000012e8,0x000012e4,0x0004003d,0x0000004b, 13170x000015b5,0x000015b1,0x00050050,0x00000007,
14530x000012ec,0x000012d7,0x00050041,0x0000004c, 13180x000015b8,0x000015b2,0x000015b7,0x0004007c,
14540x000012ed,0x00001239,0x00000151,0x0004003d, 13190x00000014,0x000015a8,0x000015b8,0x00060041,
14550x0000004b,0x000012ee,0x000012ed,0x0007000c, 13200x000000db,0x000015a0,0x000015a8,0x000000da,
14560x0000004b,0x000012ef,0x00000001,0x00000025, 13210x000000da,0x0005003e,0x000015a0,0x00001580,
14570x000012ec,0x000012ee,0x00050041,0x0000004c, 13220x00000002,0x00000004,0x000200f9,0x00000b97,
14580x000012f0,0x00001239,0x00000202,0x0004003d, 13230x000200f8,0x00000ba7,0x000500aa,0x0000002f,
14590x0000004b,0x000012f1,0x000012f0,0x0007000c, 13240x00000baa,0x00000b13,0x000000a6,0x000300f7,
14600x0000004b,0x000012f2,0x00000001,0x00000025, 13250x00000bac,0x00000000,0x000400fa,0x00000baa,
14610x000012ef,0x000012f1,0x0004003d,0x0000004b, 13260x00000bab,0x00000bcd,0x000200f8,0x00000bab,
14620x000012f4,0x000012d7,0x0004003d,0x0000004b, 13270x00050041,0x000000fe,0x00000bad,0x000000fc,
14630x000012f6,0x000012ed,0x0007000c,0x0000004b, 13280x000009ef,0x0004003d,0x00000006,0x00000bae,
14640x000012f7,0x00000001,0x00000028,0x000012f4, 13290x00000bad,0x00050084,0x00000006,0x00000bb0,
14650x000012f6,0x0004003d,0x0000004b,0x000012f9, 13300x0000010a,0x00000b11,0x00050080,0x00000006,
14660x000012f0,0x0007000c,0x0000004b,0x000012fa, 13310x00000bb1,0x00000bae,0x00000bb0,0x00050041,
14670x00000001,0x00000028,0x000012f7,0x000012f9, 13320x00000156,0x00000bb3,0x000000fc,0x000000da,
14680x00060050,0x00000392,0x00002b68,0x000012ea, 13330x0004003d,0x00000007,0x00000bb4,0x00000bb3,
14690x000012ea,0x000012ea,0x000600a9,0x0000004b, 13340x00050051,0x00000006,0x000015ce,0x00000bb4,
14700x00002b69,0x00002b68,0x00002b66,0x000012fa, 13350x00000000,0x00050095,0x000000ab,0x000015d0,
14710x000600a9,0x0000004b,0x00002b6b,0x00002b68, 13360x000015ce,0x00000bb1,0x00050051,0x00000006,
14720x00002b64,0x000012f2,0x00050041,0x000000fb, 13370x000015d1,0x000015d0,0x00000001,0x00050051,
14730x000016ab,0x000000f9,0x000000fa,0x0004003d, 13380x00000006,0x000015d2,0x000015d0,0x00000000,
14740x00000006,0x000016ac,0x000016ab,0x00050084, 13390x00050051,0x00000006,0x000015d5,0x00000bb4,
14750x00000006,0x000016ad,0x0000011c,0x000016ac, 13400x00000001,0x00050080,0x00000006,0x000015d7,
14760x00050080,0x00000006,0x000016ae,0x00000104, 13410x000015d5,0x000015d1,0x00050050,0x00000007,
14770x000016ad,0x00050080,0x00000006,0x000016b4, 13420x000015d8,0x000015d2,0x000015d7,0x0004007c,
14780x000016ac,0x00002b67,0x00050086,0x00000006, 13430x00000014,0x000015c8,0x000015d8,0x00060041,
14790x000016b5,0x000016b4,0x000000fe,0x00050084, 13440x000000db,0x000015c0,0x000015c8,0x000000da,
14800x00000006,0x000016a7,0x00000104,0x000016b5, 13450x000000da,0x0005003e,0x000015c0,0x00000380,
14810x00050080,0x00000006,0x000016a8,0x000016ae, 13460x00000002,0x00000004,0x000500b0,0x0000002f,
14820x000016a7,0x00050084,0x00000006,0x00001678, 13470x00000bb9,0x00000b11,0x000002b7,0x000300f7,
14830x0000014d,0x0000127c,0x00050080,0x00000006, 13480x00000bbb,0x00000000,0x000400fa,0x00000bb9,
14840x00001679,0x000016a8,0x00001678,0x00050041, 13490x00000bba,0x00000bbb,0x000200f8,0x00000bba,
14850x00000153,0x0000167a,0x000000f9,0x00000151, 13500x00050041,0x00000156,0x00000bbf,0x000000fc,
14860x0004003d,0x00000007,0x0000167b,0x0000167a, 13510x00000154,0x0004003d,0x00000007,0x00000bc0,
14870x00050051,0x00000027,0x0000167e,0x00002b6b, 13520x00000bbf,0x00050051,0x00000006,0x000015ee,
14880x00000000,0x0004007c,0x00000006,0x000016bb, 13530x00000bc0,0x00000000,0x00050095,0x000000ab,
14890x0000167e,0x00050051,0x00000006,0x000016d4, 13540x000015f0,0x000015ee,0x00000bb0,0x00050051,
14900x0000167b,0x00000000,0x00050095,0x000000a8, 13550x00000006,0x000015f1,0x000015f0,0x00000001,
14910x000016d6,0x000016d4,0x00001679,0x00050051, 13560x00050051,0x00000006,0x000015f2,0x000015f0,
14920x00000006,0x000016d7,0x000016d6,0x00000001, 13570x00000000,0x00050051,0x00000006,0x000015f5,
14930x00050051,0x00000006,0x000016d8,0x000016d6, 13580x00000bc0,0x00000001,0x00050080,0x00000006,
14940x00000000,0x00050051,0x00000006,0x000016db, 13590x000015f7,0x000015f5,0x000015f1,0x00050050,
14950x0000167b,0x00000001,0x00050080,0x00000006, 13600x00000007,0x000015f8,0x000015f2,0x000015f7,
14960x000016dd,0x000016db,0x000016d7,0x00050050, 13610x0004007c,0x00000014,0x000015e8,0x000015f8,
14970x00000007,0x000016de,0x000016d8,0x000016dd, 13620x00060041,0x000000db,0x000015e0,0x000015e8,
14980x0004007c,0x00000014,0x000016ce,0x000016de, 13630x000000da,0x000000da,0x0005003e,0x000015e0,
14990x00060041,0x000000d8,0x000016c6,0x000016ce, 13640x00000380,0x00000002,0x00000004,0x00050080,
15000x000000d7,0x000000d7,0x0005003e,0x000016c6, 13650x00000006,0x00000bc6,0x00000118,0x00000bb0,
15010x000016bb,0x00000002,0x00000004,0x00050080, 13660x00050095,0x000000ab,0x00001610,0x000015ee,
15020x00000006,0x00001681,0x00001679,0x00000107, 13670x00000bc6,0x00050051,0x00000006,0x00001611,
15030x00050051,0x00000027,0x00001685,0x00002b6b, 13680x00001610,0x00000001,0x00050051,0x00000006,
15040x00000001,0x0004007c,0x00000006,0x000016e4, 13690x00001612,0x00001610,0x00000000,0x00050080,
15050x00001685,0x00050095,0x000000a8,0x000016ff, 13700x00000006,0x00001617,0x000015f5,0x00001611,
15060x000016d4,0x00001681,0x00050051,0x00000006, 13710x00050050,0x00000007,0x00001618,0x00001612,
15070x00001700,0x000016ff,0x00000001,0x00050051, 13720x00001617,0x0004007c,0x00000014,0x00001608,
15080x00000006,0x00001701,0x000016ff,0x00000000, 13730x00001618,0x00060041,0x000000db,0x00001600,
15090x00050080,0x00000006,0x00001706,0x000016db, 13740x00001608,0x000000da,0x000000da,0x0005003e,
15100x00001700,0x00050050,0x00000007,0x00001707, 13750x00001600,0x000000a6,0x00000002,0x00000004,
15110x00001701,0x00001706,0x0004007c,0x00000014, 13760x000200f9,0x00000bbb,0x000200f8,0x00000bbb,
15120x000016f7,0x00001707,0x00060041,0x000000d8, 13770x000200f9,0x00000bac,0x000200f8,0x00000bcd,
15130x000016ef,0x000016f7,0x000000d7,0x000000d7, 13780x000500aa,0x0000002f,0x00000bd0,0x00000b13,
15140x0005003e,0x000016ef,0x000016e4,0x00000002, 13790x000000b0,0x000300f7,0x00000bd2,0x00000000,
15150x00000004,0x00050080,0x00000006,0x00001688, 13800x000400fa,0x00000bd0,0x00000bd1,0x00000bd6,
15160x00001679,0x0000010e,0x00050051,0x00000027, 13810x000200f8,0x00000bd1,0x000200f9,0x00001648,
15170x0000168c,0x00002b6b,0x00000002,0x0004007c, 13820x000200f8,0x00001648,0x000700f5,0x00000006,
15180x00000006,0x0000170d,0x0000168c,0x00050095, 13830x0000323a,0x000000a6,0x00000bd1,0x00001658,
15190x000000a8,0x00001728,0x000016d4,0x00001688, 13840x00001656,0x000500b0,0x0000002f,0x0000164b,
15200x00050051,0x00000006,0x00001729,0x00001728, 13850x0000323a,0x000002b7,0x000400f6,0x00001659,
15210x00000001,0x00050051,0x00000006,0x0000172a, 13860x00001656,0x00000000,0x000400fa,0x0000164b,
15220x00001728,0x00000000,0x00050080,0x00000006, 13870x0000164c,0x00001659,0x000200f8,0x0000164c,
15230x0000172f,0x000016db,0x00001729,0x00050050, 13880x00050084,0x00000006,0x0000164f,0x000002b7,
15240x00000007,0x00001730,0x0000172a,0x0000172f, 13890x00000b11,0x00050080,0x00000006,0x00001651,
15250x0004007c,0x00000014,0x00001720,0x00001730, 13900x0000164f,0x0000323a,0x000300f7,0x00001716,
15260x00060041,0x000000d8,0x00001718,0x00001720, 13910x00000000,0x000300fb,0x000000a6,0x000016f4,
15270x000000d7,0x000000d7,0x0005003e,0x00001718, 13920x000200f8,0x000016f4,0x00050041,0x000000fe,
15280x0000170d,0x00000002,0x00000004,0x00050080, 13930x000016f5,0x000000fc,0x0000027b,0x0004003d,
15290x00000006,0x0000168f,0x00001679,0x00000115, 13940x00000006,0x000016f6,0x000016f5,0x000500aa,
15300x00050051,0x00000027,0x00001693,0x00002b69, 13950x0000002f,0x000016f7,0x000016f6,0x000000a6,
15310x00000000,0x0004007c,0x00000006,0x00001736, 13960x000300f7,0x000016fa,0x00000000,0x000400fa,
15320x00001693,0x00050095,0x000000a8,0x00001751, 13970x000016f7,0x000016f8,0x000016fa,0x000200f8,
15330x000016d4,0x0000168f,0x00050051,0x00000006, 13980x000016f8,0x000200f9,0x00001716,0x000200f8,
15340x00001752,0x00001751,0x00000001,0x00050051, 13990x000016fa,0x000500aa,0x0000002f,0x000016fd,
15350x00000006,0x00001753,0x00001751,0x00000000, 14000x000016f6,0x00000170,0x000300f7,0x00001704,
15360x00050080,0x00000006,0x00001758,0x000016db, 14010x00000000,0x000400fa,0x000016fd,0x000016fe,
14020x00001704,0x000200f8,0x000016fe,0x00050084,
14030x00000006,0x00001700,0x0000010a,0x00001651,
14040x00050041,0x00000156,0x00001701,0x000000fc,
14050x0000020d,0x0004003d,0x00000007,0x00001702,
14060x00001701,0x00050051,0x00000006,0x0000172e,
14070x00001702,0x00000000,0x00050095,0x000000ab,
14080x00001730,0x0000172e,0x00001700,0x00050051,
14090x00000006,0x00001731,0x00001730,0x00000001,
14100x00050051,0x00000006,0x00001732,0x00001730,
14110x00000000,0x00050051,0x00000006,0x00001735,
14120x00001702,0x00000001,0x00050080,0x00000006,
14130x00001737,0x00001735,0x00001731,0x00050050,
14140x00000007,0x00001738,0x00001732,0x00001737,
14150x0004007c,0x00000014,0x00001728,0x00001738,
14160x00060041,0x000000db,0x0000171f,0x00001728,
14170x000000da,0x000000da,0x0006003d,0x00000006,
14180x00001720,0x0000171f,0x00000002,0x00000004,
14190x000200f9,0x00001716,0x000200f8,0x00001704,
14200x000500c2,0x00000006,0x00001706,0x00001651,
14210x00000154,0x00050084,0x00000006,0x00001707,
14220x0000010a,0x00001706,0x00050041,0x00000156,
14230x00001708,0x000000fc,0x0000020d,0x0004003d,
14240x00000007,0x00001709,0x00001708,0x00050051,
14250x00000006,0x0000174f,0x00001709,0x00000000,
14260x00050095,0x000000ab,0x00001751,0x0000174f,
14270x00001707,0x00050051,0x00000006,0x00001752,
14280x00001751,0x00000001,0x00050051,0x00000006,
14290x00001753,0x00001751,0x00000000,0x00050051,
14300x00000006,0x00001756,0x00001709,0x00000001,
14310x00050080,0x00000006,0x00001758,0x00001756,
15370x00001752,0x00050050,0x00000007,0x00001759, 14320x00001752,0x00050050,0x00000007,0x00001759,
15380x00001753,0x00001758,0x0004007c,0x00000014, 14330x00001753,0x00001758,0x0004007c,0x00000014,
15390x00001749,0x00001759,0x00060041,0x000000d8, 14340x00001749,0x00001759,0x00060041,0x000000db,
15400x00001741,0x00001749,0x000000d7,0x000000d7, 14350x00001740,0x00001749,0x000000da,0x000000da,
15410x0005003e,0x00001741,0x00001736,0x00000002, 14360x0006003d,0x00000006,0x00001741,0x00001740,
15420x00000004,0x00050080,0x00000006,0x00001696, 14370x00000002,0x00000004,0x000500c7,0x00000006,
15430x00001679,0x0000011c,0x00050051,0x00000027, 14380x0000170c,0x00001651,0x000000b0,0x000500ab,
15440x0000169a,0x00002b69,0x00000001,0x0004007c, 14390x0000002f,0x0000170d,0x0000170c,0x000000a6,
15450x00000006,0x0000175f,0x0000169a,0x00050095, 14400x000300f7,0x00001714,0x00000000,0x000400fa,
15460x000000a8,0x0000177a,0x000016d4,0x00001696, 14410x0000170d,0x0000170e,0x00001711,0x000200f8,
15470x00050051,0x00000006,0x0000177b,0x0000177a, 14420x0000170e,0x000500c2,0x00000006,0x00001710,
15480x00000001,0x00050051,0x00000006,0x0000177c, 14430x00001741,0x0000023e,0x000200f9,0x00001714,
15490x0000177a,0x00000000,0x00050080,0x00000006, 14440x000200f8,0x00001711,0x000500c7,0x00000006,
15500x00001781,0x000016db,0x0000177b,0x00050050, 14450x00001713,0x00001741,0x000002a3,0x000200f9,
15510x00000007,0x00001782,0x0000177c,0x00001781, 14460x00001714,0x000200f8,0x00001714,0x000700f5,
15520x0004007c,0x00000014,0x00001772,0x00001782, 14470x00000006,0x00003244,0x00001710,0x0000170e,
15530x00060041,0x000000d8,0x0000176a,0x00001772, 14480x00001713,0x00001711,0x000200f9,0x00001716,
15540x000000d7,0x000000d7,0x0005003e,0x0000176a, 14490x000200f8,0x00001716,0x000900f5,0x00000006,
15550x0000175f,0x00000002,0x00000004,0x00050080, 14500x00003245,0x00001651,0x000016f8,0x00001720,
15560x00000006,0x0000169d,0x00001679,0x00000186, 14510x000016fe,0x00003244,0x00001714,0x00050041,
15570x00050051,0x00000027,0x000016a1,0x00002b69, 14520x000000fe,0x0000176a,0x000000fc,0x00000250,
15580x00000002,0x0004007c,0x00000006,0x00001788, 14530x0004003d,0x00000006,0x0000176b,0x0000176a,
15590x000016a1,0x00050095,0x000000a8,0x000017a3, 14540x00050084,0x00000006,0x0000176c,0x00003245,
15600x000016d4,0x0000169d,0x00050051,0x00000006, 14550x0000176b,0x00050041,0x00000156,0x0000176d,
15610x000017a4,0x000017a3,0x00000001,0x00050051, 14560x000000fc,0x00000205,0x0004003d,0x00000007,
15620x00000006,0x000017a5,0x000017a3,0x00000000, 14570x0000176e,0x0000176d,0x00050051,0x00000006,
15630x00050080,0x00000006,0x000017aa,0x000016db, 14580x00001789,0x0000176e,0x00000000,0x00050095,
15640x000017a4,0x00050050,0x00000007,0x000017ab, 14590x000000ab,0x0000178b,0x00001789,0x0000176c,
15650x000017a5,0x000017aa,0x0004007c,0x00000014, 14600x00050051,0x00000006,0x0000178c,0x0000178b,
15660x0000179b,0x000017ab,0x00060041,0x000000d8, 14610x00000001,0x00050051,0x00000006,0x0000178d,
15670x00001793,0x0000179b,0x000000d7,0x000000d7, 14620x0000178b,0x00000000,0x00050051,0x00000006,
15680x0005003e,0x00001793,0x00001788,0x00000002, 14630x00001790,0x0000176e,0x00000001,0x00050080,
15690x00000004,0x000300f7,0x000017eb,0x00000000, 14640x00000006,0x00001792,0x00001790,0x0000178c,
15700x000300fb,0x000000a3,0x000017ba,0x000200f8, 14650x00050095,0x000000ab,0x000017ac,0x0000178d,
15710x000017ba,0x000500bc,0x0000002f,0x000017f2, 14660x000000a6,0x00050051,0x00000006,0x000017ad,
15720x0000167e,0x00001693,0x000300f7,0x000017f9, 14670x000017ac,0x00000001,0x00050051,0x00000006,
15730x00000000,0x000400fa,0x000017f2,0x000017f3, 14680x000017ae,0x000017ac,0x00000000,0x00050080,
15740x000017f9,0x000200f8,0x000017f3,0x000500bc, 14690x00000006,0x000017b3,0x00001792,0x000017ad,
15750x0000002f,0x000017f8,0x00001685,0x0000169a, 14700x00050050,0x00000007,0x000017b4,0x000017ae,
15760x000200f9,0x000017f9,0x000200f8,0x000017f9, 14710x000017b3,0x0004007c,0x00000014,0x000017a4,
15770x000700f5,0x0000002f,0x000017fa,0x000017f2, 14720x000017b4,0x00060041,0x000000db,0x0000179b,
15780x000017ba,0x000017f8,0x000017f3,0x000300f7, 14730x000017a4,0x000000da,0x000000da,0x0006003d,
15790x00001801,0x00000000,0x000400fa,0x000017fa, 14740x00000006,0x0000179c,0x0000179b,0x00000002,
15800x000017fb,0x00001801,0x000200f8,0x000017fb, 14750x00000004,0x0004007c,0x00000027,0x00001772,
15810x000500bc,0x0000002f,0x00001800,0x0000168c, 14760x0000179c,0x00050095,0x000000ab,0x000017cd,
15820x000016a1,0x000200f9,0x00001801,0x000200f8, 14770x0000178d,0x0000010a,0x00050051,0x00000006,
15830x00001801,0x000700f5,0x0000002f,0x00001802, 14780x000017ce,0x000017cd,0x00000001,0x00050051,
15840x000017fa,0x000017f9,0x00001800,0x000017fb, 14790x00000006,0x000017cf,0x000017cd,0x00000000,
15850x000400a8,0x0000002f,0x00001803,0x00001802, 14800x00050080,0x00000006,0x000017d4,0x00001792,
15860x000300f7,0x000017bf,0x00000000,0x000400fa, 14810x000017ce,0x00050050,0x00000007,0x000017d5,
15870x00001803,0x000017be,0x000017bf,0x000200f8, 14820x000017cf,0x000017d4,0x0004007c,0x00000014,
15880x000017be,0x000200f9,0x000017eb,0x000200f8, 14830x000017c5,0x000017d5,0x00060041,0x000000db,
15890x000017bf,0x00050081,0x0000004b,0x000017c2, 14840x000017bc,0x000017c5,0x000000da,0x000000da,
15900x00002b6b,0x00002b69,0x0005008e,0x0000004b, 14850x0006003d,0x00000006,0x000017bd,0x000017bc,
15910x000017c3,0x000017c2,0x000001ea,0x00050095,
15920x000000a8,0x00001813,0x000016d4,0x000000a3,
15930x00050051,0x00000006,0x00001814,0x00001813,
15940x00000001,0x00050051,0x00000006,0x00001815,
15950x00001813,0x00000000,0x00050080,0x00000006,
15960x0000181a,0x000016db,0x00001814,0x00050050,
15970x00000007,0x0000181b,0x00001815,0x0000181a,
15980x0004007c,0x00000014,0x0000180b,0x0000181b,
15990x00060041,0x000000d8,0x000017c8,0x0000180b,
16000x000000d7,0x000000d7,0x00050051,0x00000027,
16010x000017ca,0x000017c3,0x00000000,0x0004007c,
16020x00000006,0x00001821,0x000017ca,0x000500c7,
16030x00000006,0x00001823,0x00001821,0x0000012d,
16040x000500ab,0x0000002f,0x00001824,0x00001823,
16050x000000a3,0x000300f7,0x0000182b,0x00000000,
16060x000400fa,0x00001824,0x00001825,0x00001828,
16070x000200f8,0x00001825,0x000400c8,0x00000006,
16080x00001827,0x00001821,0x000200f9,0x0000182b,
16090x000200f8,0x00001828,0x000500c5,0x00000006,
16100x0000182a,0x00001821,0x0000012d,0x000200f9,
16110x0000182b,0x000200f8,0x0000182b,0x000700f5,
16120x00000006,0x00002b22,0x00001827,0x00001825,
16130x0000182a,0x00001828,0x000700ed,0x00000006,
16140x000017cc,0x000017c8,0x000000ad,0x000000a3,
16150x00002b22,0x00060041,0x000000d8,0x000017ce,
16160x0000180b,0x000000d7,0x00000151,0x00050051,
16170x00000027,0x000017d0,0x000017c3,0x00000001,
16180x0004007c,0x00000006,0x00001832,0x000017d0,
16190x000500c7,0x00000006,0x00001834,0x00001832,
16200x0000012d,0x000500ab,0x0000002f,0x00001835,
16210x00001834,0x000000a3,0x000300f7,0x0000183c,
16220x00000000,0x000400fa,0x00001835,0x00001836,
16230x00001839,0x000200f8,0x00001836,0x000400c8,
16240x00000006,0x00001838,0x00001832,0x000200f9,
16250x0000183c,0x000200f8,0x00001839,0x000500c5,
16260x00000006,0x0000183b,0x00001832,0x0000012d,
16270x000200f9,0x0000183c,0x000200f8,0x0000183c,
16280x000700f5,0x00000006,0x00002b23,0x00001838,
16290x00001836,0x0000183b,0x00001839,0x000700ed,
16300x00000006,0x000017d2,0x000017ce,0x000000ad,
16310x000000a3,0x00002b23,0x00060041,0x000000d8,
16320x000017d4,0x0000180b,0x000000d7,0x00000202,
16330x00050051,0x00000027,0x000017d6,0x000017c3,
16340x00000002,0x0004007c,0x00000006,0x00001843,
16350x000017d6,0x000500c7,0x00000006,0x00001845,
16360x00001843,0x0000012d,0x000500ab,0x0000002f,
16370x00001846,0x00001845,0x000000a3,0x000300f7,
16380x0000184d,0x00000000,0x000400fa,0x00001846,
16390x00001847,0x0000184a,0x000200f8,0x00001847,
16400x000400c8,0x00000006,0x00001849,0x00001843,
16410x000200f9,0x0000184d,0x000200f8,0x0000184a,
16420x000500c5,0x00000006,0x0000184c,0x00001843,
16430x0000012d,0x000200f9,0x0000184d,0x000200f8,
16440x0000184d,0x000700f5,0x00000006,0x00002b24,
16450x00001849,0x00001847,0x0000184c,0x0000184a,
16460x000700ed,0x00000006,0x000017d8,0x000017d4,
16470x000000ad,0x000000a3,0x00002b24,0x00060041,
16480x000000d8,0x000017da,0x0000180b,0x000000d7,
16490x0000020a,0x000300f7,0x0000185e,0x00000000,
16500x000400fa,0x00001824,0x00001858,0x0000185b,
16510x000200f8,0x00001858,0x000400c8,0x00000006,
16520x0000185a,0x00001821,0x000200f9,0x0000185e,
16530x000200f8,0x0000185b,0x000500c5,0x00000006,
16540x0000185d,0x00001821,0x0000012d,0x000200f9,
16550x0000185e,0x000200f8,0x0000185e,0x000700f5,
16560x00000006,0x00002b25,0x0000185a,0x00001858,
16570x0000185d,0x0000185b,0x000700ef,0x00000006,
16580x000017de,0x000017da,0x000000ad,0x000000a3,
16590x00002b25,0x00060041,0x000000d8,0x000017e0,
16600x0000180b,0x000000d7,0x00000212,0x000300f7,
16610x0000186f,0x00000000,0x000400fa,0x00001835,
16620x00001869,0x0000186c,0x000200f8,0x00001869,
16630x000400c8,0x00000006,0x0000186b,0x00001832,
16640x000200f9,0x0000186f,0x000200f8,0x0000186c,
16650x000500c5,0x00000006,0x0000186e,0x00001832,
16660x0000012d,0x000200f9,0x0000186f,0x000200f8,
16670x0000186f,0x000700f5,0x00000006,0x00002b26,
16680x0000186b,0x00001869,0x0000186e,0x0000186c,
16690x000700ef,0x00000006,0x000017e4,0x000017e0,
16700x000000ad,0x000000a3,0x00002b26,0x00060041,
16710x000000d8,0x000017e6,0x0000180b,0x000000d7,
16720x0000021a,0x000300f7,0x00001880,0x00000000,
16730x000400fa,0x00001846,0x0000187a,0x0000187d,
16740x000200f8,0x0000187a,0x000400c8,0x00000006,
16750x0000187c,0x00001843,0x000200f9,0x00001880,
16760x000200f8,0x0000187d,0x000500c5,0x00000006,
16770x0000187f,0x00001843,0x0000012d,0x000200f9,
16780x00001880,0x000200f8,0x00001880,0x000700f5,
16790x00000006,0x00002b27,0x0000187c,0x0000187a,
16800x0000187f,0x0000187d,0x000700ef,0x00000006,
16810x000017ea,0x000017e6,0x000000ad,0x000000a3,
16820x00002b27,0x000200f9,0x000017eb,0x000200f8,
16830x000017eb,0x000200f9,0x00000a4d,0x000200f8,
16840x00000a51,0x000500aa,0x0000002f,0x00000a54,
16850x000009eb,0x0000016d,0x000300f7,0x00000a56,
16860x00000000,0x000400fa,0x00000a54,0x00000a55,
16870x00000a5a,0x000200f8,0x00000a55,0x00050084,
16880x00000006,0x000018e9,0x00000104,0x000009e9,
16890x000200f9,0x000018ea,0x000200f8,0x000018ea,
16900x000700f5,0x00000006,0x00002ad4,0x000000a3,
16910x00000a55,0x000018fb,0x000018ee,0x000500b0,
16920x0000002f,0x000018ed,0x00002ad4,0x00000115,
16930x000400f6,0x000018fc,0x000018ee,0x00000000,
16940x000400fa,0x000018ed,0x000018ee,0x000018fc,
16950x000200f8,0x000018ee,0x00050084,0x00000006,
16960x000018f2,0x00000107,0x00002ad4,0x00050080,
16970x00000006,0x000018f3,0x000018e9,0x000018f2,
16980x00050041,0x00000153,0x000018f4,0x000000f9,
16990x00000202,0x0004003d,0x00000007,0x000018f5,
17000x000018f4,0x00050051,0x00000006,0x00001ab6,
17010x000018f5,0x00000000,0x00050095,0x000000a8,
17020x00001ab8,0x00001ab6,0x000018f3,0x00050051,
17030x00000006,0x00001ab9,0x00001ab8,0x00000001,
17040x00050051,0x00000006,0x00001aba,0x00001ab8,
17050x00000000,0x00050051,0x00000006,0x00001abd,
17060x000018f5,0x00000001,0x00050080,0x00000006,
17070x00001abf,0x00001abd,0x00001ab9,0x00050050,
17080x00000007,0x00001ac0,0x00001aba,0x00001abf,
17090x0004007c,0x00000014,0x00001ab0,0x00001ac0,
17100x00060041,0x000000d8,0x00001aa7,0x00001ab0,
17110x000000d7,0x000000d7,0x0006003d,0x00000006,
17120x00001aa8,0x00001aa7,0x00000002,0x00000004,
17130x0004007c,0x00000027,0x000018f7,0x00001aa8,
17140x00050041,0x00000028,0x000018f8,0x00001884,
17150x00002ad4,0x0003003e,0x000018f8,0x000018f7,
17160x00050080,0x00000006,0x000018fb,0x00002ad4,
17170x00000151,0x000200f9,0x000018ea,0x000200f8,
17180x000018fc,0x00050080,0x00000006,0x000018fe,
17190x000018e9,0x00000365,0x00050041,0x00000153,
17200x000018ff,0x000000f9,0x00000202,0x0004003d,
17210x00000007,0x00001900,0x000018ff,0x00050051,
17220x00000006,0x00001ad7,0x00001900,0x00000000,
17230x00050095,0x000000a8,0x00001ad9,0x00001ad7,
17240x000018fe,0x00050051,0x00000006,0x00001ada,
17250x00001ad9,0x00000001,0x00050051,0x00000006,
17260x00001adb,0x00001ad9,0x00000000,0x00050051,
17270x00000006,0x00001ade,0x00001900,0x00000001,
17280x00050080,0x00000006,0x00001ae0,0x00001ade,
17290x00001ada,0x00050050,0x00000007,0x00001ae1,
17300x00001adb,0x00001ae0,0x0004007c,0x00000014,
17310x00001ad1,0x00001ae1,0x00060041,0x000000d8,
17320x00001ac8,0x00001ad1,0x000000d7,0x000000d7,
17330x0006003d,0x00000006,0x00001ac9,0x00001ac8,
17340x00000002,0x00000004,0x00050080,0x00000006,
17350x00001903,0x000018e9,0x00000371,0x00050095,
17360x000000a8,0x00001afa,0x00001ad7,0x00001903,
17370x00050051,0x00000006,0x00001afb,0x00001afa,
17380x00000001,0x00050051,0x00000006,0x00001afc,
17390x00001afa,0x00000000,0x00050080,0x00000006,
17400x00001b01,0x00001ade,0x00001afb,0x00050050,
17410x00000007,0x00001b02,0x00001afc,0x00001b01,
17420x0004007c,0x00000014,0x00001af2,0x00001b02,
17430x00060041,0x000000d8,0x00001ae9,0x00001af2,
17440x000000d7,0x000000d7,0x0006003d,0x00000006,
17450x00001aea,0x00001ae9,0x00000002,0x00000004,
17460x00050080,0x00000006,0x00001908,0x000018e9,
17470x0000037b,0x00050095,0x000000a8,0x00001b1b,
17480x00001ad7,0x00001908,0x00050051,0x00000006,
17490x00001b1c,0x00001b1b,0x00000001,0x00050051,
17500x00000006,0x00001b1d,0x00001b1b,0x00000000,
17510x00050080,0x00000006,0x00001b22,0x00001ade,
17520x00001b1c,0x00050050,0x00000007,0x00001b23,
17530x00001b1d,0x00001b22,0x0004007c,0x00000014,
17540x00001b13,0x00001b23,0x00060041,0x000000d8,
17550x00001b0a,0x00001b13,0x000000d7,0x000000d7,
17560x0006003d,0x00000006,0x00001b0b,0x00001b0a,
17570x00000002,0x00000004,0x00050080,0x00000006,
17580x0000190d,0x000018e9,0x00000385,0x00050095,
17590x000000a8,0x00001b3c,0x00001ad7,0x0000190d,
17600x00050051,0x00000006,0x00001b3d,0x00001b3c,
17610x00000001,0x00050051,0x00000006,0x00001b3e,
17620x00001b3c,0x00000000,0x00050080,0x00000006,
17630x00001b43,0x00001ade,0x00001b3d,0x00050050,
17640x00000007,0x00001b44,0x00001b3e,0x00001b43,
17650x0004007c,0x00000014,0x00001b34,0x00001b44,
17660x00060041,0x000000d8,0x00001b2b,0x00001b34,
17670x000000d7,0x000000d7,0x0006003d,0x00000006,
17680x00001b2c,0x00001b2b,0x00000002,0x00000004,
17690x00050041,0x000000fb,0x00001912,0x000000f9,
17700x00000229,0x0004003d,0x00000006,0x00001913,
17710x00001912,0x00050084,0x00000006,0x00001915,
17720x00000225,0x000009e9,0x00050080,0x00000006,
17730x00001916,0x00001913,0x00001915,0x000200f9,
17740x00001917,0x000200f8,0x00001917,0x000700f5,
17750x00000006,0x00002ad5,0x000000a3,0x000018fc,
17760x00001928,0x0000191b,0x000500b0,0x0000002f,
17770x0000191a,0x00002ad5,0x00000115,0x000400f6,
17780x00001929,0x0000191b,0x00000000,0x000400fa,
17790x0000191a,0x0000191b,0x00001929,0x000200f8,
17800x0000191b,0x00050084,0x00000006,0x0000191e,
17810x00000107,0x00002ad5,0x00050080,0x00000006,
17820x0000191f,0x00001916,0x0000191e,0x00050041,
17830x00000153,0x00001921,0x000000f9,0x000000d7,
17840x0004003d,0x00000007,0x00001922,0x00001921,
17850x00050041,0x00000028,0x00001923,0x00001884,
17860x00002ad5,0x0004003d,0x00000027,0x00001924,
17870x00001923,0x0004007c,0x00000006,0x00001b4a,
17880x00001924,0x00050051,0x00000006,0x00001b63,
17890x00001922,0x00000000,0x00050095,0x000000a8,
17900x00001b65,0x00001b63,0x0000191f,0x00050051,
17910x00000006,0x00001b66,0x00001b65,0x00000001,
17920x00050051,0x00000006,0x00001b67,0x00001b65,
17930x00000000,0x00050051,0x00000006,0x00001b6a,
17940x00001922,0x00000001,0x00050080,0x00000006,
17950x00001b6c,0x00001b6a,0x00001b66,0x00050050,
17960x00000007,0x00001b6d,0x00001b67,0x00001b6c,
17970x0004007c,0x00000014,0x00001b5d,0x00001b6d,
17980x00060041,0x000000d8,0x00001b55,0x00001b5d,
17990x000000d7,0x000000d7,0x0005003e,0x00001b55,
18000x00001b4a,0x00000002,0x00000004,0x00050080,
18010x00000006,0x00001928,0x00002ad5,0x00000151,
18020x000200f9,0x00001917,0x000200f8,0x00001929,
18030x00050080,0x00000006,0x0000192b,0x00001916,
18040x00000365,0x00050041,0x00000153,0x0000192c,
18050x000000f9,0x000000d7,0x0004003d,0x00000007,
18060x0000192d,0x0000192c,0x00050051,0x00000006,
18070x00001b83,0x0000192d,0x00000000,0x00050095,
18080x000000a8,0x00001b85,0x00001b83,0x0000192b,
18090x00050051,0x00000006,0x00001b86,0x00001b85,
18100x00000001,0x00050051,0x00000006,0x00001b87,
18110x00001b85,0x00000000,0x00050051,0x00000006,
18120x00001b8a,0x0000192d,0x00000001,0x00050080,
18130x00000006,0x00001b8c,0x00001b8a,0x00001b86,
18140x00050050,0x00000007,0x00001b8d,0x00001b87,
18150x00001b8c,0x0004007c,0x00000014,0x00001b7d,
18160x00001b8d,0x00060041,0x000000d8,0x00001b75,
18170x00001b7d,0x000000d7,0x000000d7,0x0005003e,
18180x00001b75,0x00001ac9,0x00000002,0x00000004,
18190x00050080,0x00000006,0x00001931,0x00001916,
18200x00000371,0x00050095,0x000000a8,0x00001ba5,
18210x00001b83,0x00001931,0x00050051,0x00000006,
18220x00001ba6,0x00001ba5,0x00000001,0x00050051,
18230x00000006,0x00001ba7,0x00001ba5,0x00000000,
18240x00050080,0x00000006,0x00001bac,0x00001b8a,
18250x00001ba6,0x00050050,0x00000007,0x00001bad,
18260x00001ba7,0x00001bac,0x0004007c,0x00000014,
18270x00001b9d,0x00001bad,0x00060041,0x000000d8,
18280x00001b95,0x00001b9d,0x000000d7,0x000000d7,
18290x0005003e,0x00001b95,0x00001aea,0x00000002,
18300x00000004,0x000500aa,0x0000002f,0x00001bb2,
18310x00001b0b,0x000000a3,0x000300f7,0x00001bb7,
18320x00000000,0x000400fa,0x00001bb2,0x00001bb3,
18330x00001bb7,0x000200f8,0x00001bb3,0x000500aa,
18340x0000002f,0x00001bb6,0x00001b2c,0x000000a3,
18350x000200f9,0x00001bb7,0x000200f8,0x00001bb7,
18360x000700f5,0x0000002f,0x00001bb8,0x00001bb2,
18370x00001929,0x00001bb6,0x00001bb3,0x000400a8,
18380x0000002f,0x0000193c,0x00001bb8,0x000300f7,
18390x000019d2,0x00000000,0x000400fa,0x0000193c,
18400x0000193d,0x000019d2,0x000200f8,0x0000193d,
18410x00050041,0x00000153,0x0000193f,0x000000f9,
18420x0000021a,0x0004003d,0x00000007,0x00001940,
18430x0000193f,0x00050051,0x00000006,0x00001bc0,
18440x00001940,0x00000000,0x00050095,0x000000a8,
18450x00001bc1,0x00001b0b,0x00001bc0,0x00050051,
18460x00000006,0x00001bc2,0x00001bc1,0x00000001,
18470x00050051,0x00000006,0x00001bc3,0x00001bc1,
18480x00000000,0x00050051,0x00000006,0x00001bc8,
18490x00001940,0x00000001,0x00050080,0x00000006,
18500x00001bc9,0x00001b2c,0x00001bc8,0x00050080,
18510x00000006,0x00001bcb,0x00001bc9,0x00001bc2,
18520x00050095,0x000000a8,0x00001be5,0x00001bc3,
18530x00000365,0x00050051,0x00000006,0x00001be6,
18540x00001be5,0x00000001,0x00050051,0x00000006,
18550x00001be7,0x00001be5,0x00000000,0x00050080,
18560x00000006,0x00001bec,0x00001bcb,0x00001be6,
18570x00050050,0x00000007,0x00001bed,0x00001be7,
18580x00001bec,0x0004007c,0x00000014,0x00001bdd,
18590x00001bed,0x00060041,0x000000d8,0x00001bd4,
18600x00001bdd,0x000000d7,0x000000d7,0x0006003d,
18610x00000006,0x00001bd5,0x00001bd4,0x00000002,
18620x00000004,0x00050095,0x000000a8,0x00001c06,
18630x00001bc3,0x0000011c,0x00050051,0x00000006,
18640x00001c07,0x00001c06,0x00000001,0x00050051,
18650x00000006,0x00001c08,0x00001c06,0x00000000,
18660x00050080,0x00000006,0x00001c0d,0x00001bcb,
18670x00001c07,0x00050050,0x00000007,0x00001c0e,
18680x00001c08,0x00001c0d,0x0004007c,0x00000014,
18690x00001bfe,0x00001c0e,0x00060041,0x000000d8,
18700x00001bf5,0x00001bfe,0x000000d7,0x000000d7,
18710x0006003d,0x00000006,0x00001bf6,0x00001bf5,
18720x00000002,0x00000004,0x0004007c,0x00000027, 14860x00000002,0x00000004,0x0004007c,0x00000027,
18730x00001946,0x00001bf6,0x00050095,0x000000a8, 14870x00001775,0x000017bd,0x00050041,0x000000fe,
18740x00001c27,0x00001bc3,0x00000186,0x00050051, 14880x00001776,0x000000fc,0x00000266,0x0004003d,
18750x00000006,0x00001c28,0x00001c27,0x00000001, 14890x00000006,0x00001777,0x00001776,0x000500aa,
18760x00050051,0x00000006,0x00001c29,0x00001c27, 14900x0000002f,0x00001778,0x00001777,0x000000b0,
18770x00000000,0x00050080,0x00000006,0x00001c2e, 14910x000300f7,0x0000177e,0x00000000,0x000400fa,
18780x00001bcb,0x00001c28,0x00050050,0x00000007, 14920x00001778,0x00001779,0x0000177a,0x000200f8,
18790x00001c2f,0x00001c29,0x00001c2e,0x0004007c, 14930x00001779,0x000200f9,0x0000177e,0x000200f8,
18800x00000014,0x00001c1f,0x00001c2f,0x00060041, 14940x0000177a,0x00050095,0x000000ab,0x000017ee,
18810x000000d8,0x00001c16,0x00001c1f,0x000000d7, 14950x0000178d,0x00000111,0x00050051,0x00000006,
18820x000000d7,0x0006003d,0x00000006,0x00001c17, 14960x000017ef,0x000017ee,0x00000001,0x00050051,
18830x00001c16,0x00000002,0x00000004,0x0004007c, 14970x00000006,0x000017f0,0x000017ee,0x00000000,
18840x00000027,0x00001949,0x00001c17,0x00050095, 14980x00050080,0x00000006,0x000017f5,0x00001792,
18850x000000a8,0x00001c48,0x00001bc3,0x0000014d, 14990x000017ef,0x00050050,0x00000007,0x000017f6,
18860x00050051,0x00000006,0x00001c49,0x00001c48, 15000x000017f0,0x000017f5,0x0004007c,0x00000014,
18870x00000001,0x00050051,0x00000006,0x00001c4a, 15010x000017e6,0x000017f6,0x00060041,0x000000db,
18880x00001c48,0x00000000,0x00050080,0x00000006, 15020x000017dd,0x000017e6,0x000000da,0x000000da,
18890x00001c4f,0x00001bcb,0x00001c49,0x00050050, 15030x0006003d,0x00000006,0x000017de,0x000017dd,
18900x00000007,0x00001c50,0x00001c4a,0x00001c4f,
18910x0004007c,0x00000014,0x00001c40,0x00001c50,
18920x00060041,0x000000d8,0x00001c37,0x00001c40,
18930x000000d7,0x000000d7,0x0006003d,0x00000006,
18940x00001c38,0x00001c37,0x00000002,0x00000004,
18950x0004007c,0x00000027,0x0000194c,0x00001c38,
18960x00050095,0x000000a8,0x00001c69,0x00001bc3,
18970x00000460,0x00050051,0x00000006,0x00001c6a,
18980x00001c69,0x00000001,0x00050051,0x00000006,
18990x00001c6b,0x00001c69,0x00000000,0x00050080,
19000x00000006,0x00001c70,0x00001bcb,0x00001c6a,
19010x00050050,0x00000007,0x00001c71,0x00001c6b,
19020x00001c70,0x0004007c,0x00000014,0x00001c61,
19030x00001c71,0x00060041,0x000000d8,0x00001c58,
19040x00001c61,0x000000d7,0x000000d7,0x0006003d,
19050x00000006,0x00001c59,0x00001c58,0x00000002,
19060x00000004,0x0004007c,0x00000027,0x00001950,
19070x00001c59,0x00050095,0x000000a8,0x00001c8a,
19080x00001bc3,0x00000466,0x00050051,0x00000006,
19090x00001c8b,0x00001c8a,0x00000001,0x00050051,
19100x00000006,0x00001c8c,0x00001c8a,0x00000000,
19110x00050080,0x00000006,0x00001c91,0x00001bcb,
19120x00001c8b,0x00050050,0x00000007,0x00001c92,
19130x00001c8c,0x00001c91,0x0004007c,0x00000014,
19140x00001c82,0x00001c92,0x00060041,0x000000d8,
19150x00001c79,0x00001c82,0x000000d7,0x000000d7,
19160x0006003d,0x00000006,0x00001c7a,0x00001c79,
19170x00000002,0x00000004,0x0004007c,0x00000027, 15040x00000002,0x00000004,0x0004007c,0x00000027,
19180x00001953,0x00001c7a,0x00050095,0x000000a8, 15050x0000177d,0x000017de,0x000200f9,0x0000177e,
19190x00001cab,0x00001bc3,0x00000344,0x00050051, 15060x000200f8,0x0000177e,0x000700f5,0x00000027,
19200x00000006,0x00001cac,0x00001cab,0x00000001, 15070x00003246,0x0000026d,0x00001779,0x0000177d,
19210x00050051,0x00000006,0x00001cad,0x00001cab, 15080x0000177a,0x00060050,0x0000004b,0x00001783,
19220x00000000,0x00050080,0x00000006,0x00001cb2, 15090x00001772,0x00001775,0x00003246,0x000300f7,
19230x00001bcb,0x00001cac,0x00050050,0x00000007, 15100x0000183c,0x00000000,0x000300fb,0x000000a6,
19240x00001cb3,0x00001cad,0x00001cb2,0x0004007c, 15110x00001808,0x000200f8,0x00001808,0x00050041,
19250x00000014,0x00001ca3,0x00001cb3,0x00060041, 15120x00000156,0x00001809,0x000000fc,0x00000215,
19260x000000d8,0x00001c9a,0x00001ca3,0x000000d7, 15130x0004003d,0x00000007,0x0000180a,0x00001809,
19270x000000d7,0x0006003d,0x00000006,0x00001c9b, 15140x00050051,0x00000006,0x00001841,0x0000180a,
19280x00001c9a,0x00000002,0x00000004,0x0004007c, 15150x00000000,0x000500aa,0x0000002f,0x00001842,
19290x00000027,0x00001956,0x00001c9b,0x000500bc, 15160x00001841,0x000000a6,0x000300f7,0x00001847,
19300x0000002f,0x00001cba,0x00001946,0x00001950, 15170x00000000,0x000400fa,0x00001842,0x00001843,
19310x000300f7,0x00001cc1,0x00000000,0x000400fa, 15180x00001847,0x000200f8,0x00001843,0x00050051,
19320x00001cba,0x00001cbb,0x00001cc1,0x000200f8, 15190x00000006,0x00001845,0x0000180a,0x00000001,
19330x00001cbb,0x000500bc,0x0000002f,0x00001cc0, 15200x000500aa,0x0000002f,0x00001846,0x00001845,
19340x00001949,0x00001953,0x000200f9,0x00001cc1, 15210x000000a6,0x000200f9,0x00001847,0x000200f8,
19350x000200f8,0x00001cc1,0x000700f5,0x0000002f, 15220x00001847,0x000700f5,0x0000002f,0x00001848,
19360x00001cc2,0x00001cba,0x0000193d,0x00001cc0, 15230x00001842,0x00001808,0x00001846,0x00001843,
19370x00001cbb,0x000300f7,0x00001cc9,0x00000000, 15240x000300f7,0x0000180e,0x00000000,0x000400fa,
19380x000400fa,0x00001cc2,0x00001cc3,0x00001cc9, 15250x00001848,0x0000180c,0x0000180e,0x000200f8,
19390x000200f8,0x00001cc3,0x000500bc,0x0000002f, 15260x0000180c,0x000200f9,0x0000183c,0x000200f8,
19400x00001cc8,0x0000194c,0x00001956,0x000200f9, 15270x0000180e,0x000200f9,0x0000180f,0x000200f8,
19410x00001cc9,0x000200f8,0x00001cc9,0x000700f5, 15280x0000180f,0x000700f5,0x00000006,0x00003247,
19420x0000002f,0x00001cca,0x00001cc2,0x00001cc1, 15290x000000a6,0x0000180e,0x00001839,0x00001813,
19430x00001cc8,0x00001cc3,0x000300f7,0x00001960, 15300x000500b0,0x0000002f,0x00001812,0x00003247,
19440x00000000,0x000400fa,0x00001cca,0x0000195c, 15310x000002b7,0x000400f6,0x0000183a,0x00001813,
19450x00001960,0x000200f8,0x0000195c,0x000500c2, 15320x00000000,0x000400fa,0x00001812,0x00001813,
19460x00000006,0x0000195e,0x00001ac9,0x0000047b, 15330x0000183a,0x000200f8,0x00001813,0x00050084,
19470x000500ab,0x0000002f,0x0000195f,0x0000195e, 15340x00000006,0x00001815,0x0000011f,0x00003247,
19480x000000a3,0x000200f9,0x00001960,0x000200f8, 15350x00050095,0x000000ab,0x00001861,0x00001841,
19490x00001960,0x000700f5,0x0000002f,0x00001961, 15360x00001815,0x00050051,0x00000006,0x00001862,
19500x00001cca,0x00001cc9,0x0000195f,0x0000195c, 15370x00001861,0x00000001,0x00050051,0x00000006,
19510x000300f7,0x000019d1,0x00000000,0x000400fa, 15380x00001863,0x00001861,0x00000000,0x00050051,
19520x00001961,0x00001962,0x000019d1,0x000200f8, 15390x00000006,0x00001866,0x0000180a,0x00000001,
19530x00001962,0x000200f9,0x00001963,0x000200f8, 15400x00050080,0x00000006,0x00001868,0x00001866,
19540x00001963,0x000700f5,0x0000004b,0x00002b0b, 15410x00001862,0x00050050,0x00000007,0x00001869,
19550x00002b66,0x00001962,0x000019cc,0x00001967, 15420x00001863,0x00001868,0x0004007c,0x00000014,
19560x000700f5,0x0000004b,0x00002af9,0x00002b64, 15430x00001859,0x00001869,0x00060041,0x000000db,
19570x00001962,0x000019c9,0x00001967,0x000700f5, 15440x00001850,0x00001859,0x000000da,0x000000da,
19580x00000006,0x00002ad6,0x000000a3,0x00001962, 15450x0006003d,0x00000006,0x00001851,0x00001850,
19590x000019cf,0x00001967,0x000500b0,0x0000002f, 15460x00000002,0x00000004,0x0004007c,0x00000027,
19600x00001966,0x00002ad6,0x0000010e,0x000400f6, 15470x0000181a,0x00001851,0x00050080,0x00000006,
19610x000019d0,0x00001967,0x00000000,0x000400fa, 15480x0000181c,0x00001815,0x0000010a,0x00050095,
19620x00001966,0x00001967,0x000019d0,0x000200f8, 15490x000000ab,0x00001882,0x00001841,0x0000181c,
19630x00001967,0x000500c7,0x00000006,0x00001969, 15500x00050051,0x00000006,0x00001883,0x00001882,
19640x00002ad6,0x000000ad,0x000500ab,0x0000002f, 15510x00000001,0x00050051,0x00000006,0x00001884,
19650x0000196a,0x00001969,0x000000a3,0x000600a9, 15520x00001882,0x00000000,0x00050080,0x00000006,
19660x00000027,0x00002b6c,0x0000196a,0x00001950, 15530x00001889,0x00001866,0x00001883,0x00050050,
19670x00001946,0x000500c7,0x00000006,0x00001974, 15540x00000007,0x0000188a,0x00001884,0x00001889,
19680x00002ad6,0x0000016d,0x000500ab,0x0000002f, 15550x0004007c,0x00000014,0x0000187a,0x0000188a,
19690x00001975,0x00001974,0x000000a3,0x000600a9, 15560x00060041,0x000000db,0x00001871,0x0000187a,
19700x00000027,0x00002b6d,0x00001975,0x00001953, 15570x000000da,0x000000da,0x0006003d,0x00000006,
19710x00001949,0x000500c7,0x00000006,0x0000197f, 15580x00001872,0x00001871,0x00000002,0x00000004,
19720x00002ad6,0x00000107,0x000500ab,0x0000002f, 15590x0004007c,0x00000027,0x00001820,0x00001872,
19730x00001980,0x0000197f,0x000000a3,0x000600a9, 15600x00050080,0x00000006,0x00001822,0x00001815,
19740x00000027,0x00002b6e,0x00001980,0x00001956, 15610x00000111,0x00050095,0x000000ab,0x000018a3,
19750x0000194c,0x00050041,0x00000028,0x0000198a, 15620x00001841,0x00001822,0x00050051,0x00000006,
19760x00001884,0x000000d7,0x0004003d,0x00000027, 15630x000018a4,0x000018a3,0x00000001,0x00050051,
19770x0000198b,0x0000198a,0x00050085,0x00000027, 15640x00000006,0x000018a5,0x000018a3,0x00000000,
19780x0000198e,0x0000198b,0x00002b6c,0x00050041, 15650x00050080,0x00000006,0x000018aa,0x00001866,
19790x00000028,0x0000198f,0x00001884,0x00000151, 15660x000018a4,0x00050050,0x00000007,0x000018ab,
19800x0004003d,0x00000027,0x00001990,0x0000198f, 15670x000018a5,0x000018aa,0x0004007c,0x00000014,
19810x00050085,0x00000027,0x00001993,0x00001990, 15680x0000189b,0x000018ab,0x00060041,0x000000db,
19820x00002b6d,0x00050081,0x00000027,0x00001994, 15690x00001892,0x0000189b,0x000000da,0x000000da,
19830x0000198e,0x00001993,0x00050041,0x00000028, 15700x0006003d,0x00000006,0x00001893,0x00001892,
19840x00001995,0x00001884,0x00000202,0x0004003d, 15710x00000002,0x00000004,0x0004007c,0x00000027,
19850x00000027,0x00001996,0x00001995,0x00050085, 15720x00001826,0x00001893,0x00050080,0x00000006,
19860x00000027,0x00001999,0x00001996,0x00002b6e, 15730x00001828,0x00001815,0x00000118,0x00050095,
19870x00050081,0x00000027,0x0000199a,0x00001994, 15740x000000ab,0x000018c4,0x00001841,0x00001828,
19880x00001999,0x00050041,0x00000028,0x0000199b, 15750x00050051,0x00000006,0x000018c5,0x000018c4,
19890x00001884,0x0000020a,0x0004003d,0x00000027, 15760x00000001,0x00050051,0x00000006,0x000018c6,
19900x0000199c,0x0000199b,0x00050081,0x00000027, 15770x000018c4,0x00000000,0x00050080,0x00000006,
19910x0000199d,0x0000199a,0x0000199c,0x00050041, 15780x000018cb,0x00001866,0x000018c5,0x00050050,
19920x00000028,0x0000199e,0x00001884,0x00000212, 15790x00000007,0x000018cc,0x000018c6,0x000018cb,
19930x0004003d,0x00000027,0x0000199f,0x0000199e, 15800x0004007c,0x00000014,0x000018bc,0x000018cc,
19940x00050085,0x00000027,0x000019a2,0x0000199f, 15810x00060041,0x000000db,0x000018b3,0x000018bc,
19950x00002b6c,0x00050041,0x00000028,0x000019a3, 15820x000000da,0x000000da,0x0006003d,0x00000006,
19960x00001884,0x0000021a,0x0004003d,0x00000027, 15830x000018b4,0x000018b3,0x00000002,0x00000004,
19970x000019a4,0x000019a3,0x00050085,0x00000027, 15840x0004007c,0x00000027,0x0000182c,0x000018b4,
19980x000019a7,0x000019a4,0x00002b6d,0x00050081, 15850x00070050,0x000002bc,0x0000182d,0x0000181a,
19990x00000027,0x000019a8,0x000019a2,0x000019a7, 15860x00001820,0x00001826,0x0000182c,0x0008004f,
20000x00050041,0x00000028,0x000019a9,0x00001884, 15870x0000004b,0x00001830,0x0000182d,0x0000182d,
20010x00000230,0x0004003d,0x00000027,0x000019aa, 15880x00000000,0x00000001,0x00000002,0x00050094,
20020x000019a9,0x00050085,0x00000027,0x000019ad, 15890x00000027,0x00001832,0x00001830,0x00001783,
20030x000019aa,0x00002b6e,0x00050081,0x00000027, 15900x00050081,0x00000027,0x00001835,0x00001832,
20040x000019ae,0x000019a8,0x000019ad,0x00050041, 15910x0000182c,0x00050041,0x00000028,0x00001836,
20050x00000028,0x000019af,0x00001884,0x000004d5, 15920x00001805,0x00003247,0x0003003e,0x00001836,
20060x0004003d,0x00000027,0x000019b0,0x000019af, 15930x00001835,0x00050080,0x00000006,0x00001839,
20070x00050081,0x00000027,0x000019b1,0x000019ae, 15940x00003247,0x00000154,0x000200f9,0x0000180f,
20080x000019b0,0x00050041,0x00000028,0x000019b2, 15950x000200f8,0x0000183a,0x0004003d,0x0000004b,
20090x00001884,0x00000305,0x0004003d,0x00000027, 15960x0000183b,0x00001805,0x000200f9,0x0000183c,
20100x000019b3,0x000019b2,0x00050085,0x00000027, 15970x000200f8,0x0000183c,0x000700f5,0x0000004b,
20110x000019b6,0x000019b3,0x00002b6c,0x00050041, 15980x00003248,0x00001783,0x0000180c,0x0000183b,
20120x00000028,0x000019b7,0x00001884,0x0000024d, 15990x0000183a,0x00050041,0x0000004c,0x00001655,
20130x0004003d,0x00000027,0x000019b8,0x000019b7, 16000x0000161a,0x0000323a,0x0003003e,0x00001655,
20140x00050085,0x00000027,0x000019bb,0x000019b8, 16010x00003248,0x000200f9,0x00001656,0x000200f8,
20150x00002b6d,0x00050081,0x00000027,0x000019bc, 16020x00001656,0x00050080,0x00000006,0x00001658,
20160x000019b6,0x000019bb,0x00050041,0x00000028, 16030x0000323a,0x00000154,0x000200f9,0x00001648,
20170x000019bd,0x00001884,0x00000263,0x0004003d, 16040x000200f8,0x00001659,0x00050041,0x000000fe,
20180x00000027,0x000019be,0x000019bd,0x00050085, 16050x0000165a,0x000000fc,0x00000308,0x0004003d,
20190x00000027,0x000019c1,0x000019be,0x00002b6e, 16060x00000006,0x0000165b,0x0000165a,0x00050080,
20200x00050081,0x00000027,0x000019c2,0x000019bc, 16070x00000006,0x0000165d,0x0000165b,0x00000b11,
20210x000019c1,0x00050041,0x00000028,0x000019c3, 16080x00050041,0x000000fe,0x0000165e,0x000000fc,
20220x00001884,0x00000278,0x0004003d,0x00000027, 16090x0000022c,0x0004003d,0x00000006,0x0000165f,
20230x000019c4,0x000019c3,0x00050081,0x00000027, 16100x0000165e,0x00050084,0x00000006,0x00001661,
20240x000019c5,0x000019c2,0x000019c4,0x00060050, 16110x00000107,0x0000165d,0x00050080,0x00000006,
20250x0000004b,0x000019c6,0x0000199d,0x000019b1, 16120x00001662,0x0000165f,0x00001661,0x000200f9,
20260x000019c5,0x0007000c,0x0000004b,0x000019c9, 16130x00001663,0x000200f8,0x00001663,0x000700f5,
20270x00000001,0x00000025,0x00002af9,0x000019c6, 16140x00000006,0x0000323b,0x000000a6,0x00001659,
20280x0007000c,0x0000004b,0x000019cc,0x00000001, 16150x0000168a,0x00001667,0x000500b0,0x0000002f,
20290x00000028,0x00002b0b,0x000019c6,0x00050080, 16160x00001666,0x0000323b,0x000002b7,0x000400f6,
20300x00000006,0x000019cf,0x00002ad6,0x00000151, 16170x0000168b,0x00001667,0x00000000,0x000400fa,
20310x000200f9,0x00001963,0x000200f8,0x000019d0, 16180x00001666,0x00001667,0x0000168b,0x000200f8,
20320x000200f9,0x000019d1,0x000200f8,0x000019d1, 16190x00001667,0x00050084,0x00000006,0x0000166a,
20330x000700f5,0x0000004b,0x00002b07,0x00002b66, 16200x00000118,0x0000323b,0x00050080,0x00000006,
20340x00001960,0x00002b0b,0x000019d0,0x000700f5, 16210x0000166b,0x00001662,0x0000166a,0x00050041,
20350x0000004b,0x00002af5,0x00002b64,0x00001960, 16220x00000156,0x0000166d,0x000000fc,0x000000da,
20360x00002af9,0x000019d0,0x000200f9,0x000019d2, 16230x0004003d,0x00000007,0x0000166e,0x0000166d,
20370x000200f8,0x000019d2,0x000700f5,0x0000004b, 16240x00060041,0x00000028,0x0000166f,0x0000161a,
20380x00002b05,0x00002b66,0x00001bb7,0x00002b07, 16250x0000323b,0x000000a6,0x0004003d,0x00000027,
20390x000019d1,0x000700f5,0x0000004b,0x00002af3, 16260x00001670,0x0000166f,0x0004007c,0x00000006,
20400x00002b64,0x00001bb7,0x00002af5,0x000019d1, 16270x000018d2,0x00001670,0x00050051,0x00000006,
20410x000700f5,0x00000006,0x00002adf,0x0000037d, 16280x000018eb,0x0000166e,0x00000000,0x00050095,
20420x00001bb7,0x00001bd5,0x000019d1,0x00050041, 16290x000000ab,0x000018ed,0x000018eb,0x0000166b,
20430x00000028,0x000019d3,0x00001884,0x000000d7, 16300x00050051,0x00000006,0x000018ee,0x000018ed,
20440x0004003d,0x00000027,0x000019d4,0x000019d3, 16310x00000001,0x00050051,0x00000006,0x000018ef,
20450x000500b4,0x0000002f,0x000019d5,0x000019d4, 16320x000018ed,0x00000000,0x00050051,0x00000006,
20460x000004f9,0x000300f7,0x000019da,0x00000000, 16330x000018f2,0x0000166e,0x00000001,0x00050080,
20470x000400fa,0x000019d5,0x000019d6,0x000019da, 16340x00000006,0x000018f4,0x000018f2,0x000018ee,
20480x000200f8,0x000019d6,0x00050041,0x00000028, 16350x00050050,0x00000007,0x000018f5,0x000018ef,
20490x000019d7,0x00001884,0x00000151,0x0004003d, 16360x000018f4,0x0004007c,0x00000014,0x000018e5,
20500x00000027,0x000019d8,0x000019d7,0x000500b4, 16370x000018f5,0x00060041,0x000000db,0x000018dd,
20510x0000002f,0x000019d9,0x000019d8,0x0000026a, 16380x000018e5,0x000000da,0x000000da,0x0005003e,
20520x000200f9,0x000019da,0x000200f8,0x000019da, 16390x000018dd,0x000018d2,0x00000002,0x00000004,
20530x000700f5,0x0000002f,0x000019db,0x000019d5, 16400x00050080,0x00000006,0x00001676,0x0000166b,
20540x000019d2,0x000019d9,0x000019d6,0x000300f7, 16410x0000010a,0x00060041,0x00000028,0x0000167a,
20550x000019e0,0x00000000,0x000400fa,0x000019db, 16420x0000161a,0x0000323b,0x000000b0,0x0004003d,
20560x000019dc,0x000019e0,0x000200f8,0x000019dc, 16430x00000027,0x0000167b,0x0000167a,0x0004007c,
20570x00050041,0x00000028,0x000019dd,0x00001884, 16440x00000006,0x000018fb,0x0000167b,0x00050095,
20580x00000202,0x0004003d,0x00000027,0x000019de, 16450x000000ab,0x00001916,0x000018eb,0x00001676,
20590x000019dd,0x000500b4,0x0000002f,0x000019df, 16460x00050051,0x00000006,0x00001917,0x00001916,
20600x000019de,0x0000026a,0x000200f9,0x000019e0, 16470x00000001,0x00050051,0x00000006,0x00001918,
20610x000200f8,0x000019e0,0x000700f5,0x0000002f, 16480x00001916,0x00000000,0x00050080,0x00000006,
20620x000019e1,0x000019db,0x000019da,0x000019df, 16490x0000191d,0x000018f2,0x00001917,0x00050050,
20630x000019dc,0x000300f7,0x000019e6,0x00000000, 16500x00000007,0x0000191e,0x00001918,0x0000191d,
20640x000400fa,0x000019e1,0x000019e2,0x000019e6, 16510x0004007c,0x00000014,0x0000190e,0x0000191e,
20650x000200f8,0x000019e2,0x00050041,0x00000028, 16520x00060041,0x000000db,0x00001906,0x0000190e,
20660x000019e3,0x00001884,0x00000212,0x0004003d, 16530x000000da,0x000000da,0x0005003e,0x00001906,
20670x00000027,0x000019e4,0x000019e3,0x000500b4, 16540x000018fb,0x00000002,0x00000004,0x00050080,
20680x0000002f,0x000019e5,0x000019e4,0x0000026a, 16550x00000006,0x00001681,0x0000166b,0x00000111,
20690x000200f9,0x000019e6,0x000200f8,0x000019e6, 16560x00060041,0x00000028,0x00001685,0x0000161a,
20700x000700f5,0x0000002f,0x000019e7,0x000019e1, 16570x0000323b,0x00000170,0x0004003d,0x00000027,
20710x000019e0,0x000019e5,0x000019e2,0x000300f7, 16580x00001686,0x00001685,0x0004007c,0x00000006,
20720x000019ec,0x00000000,0x000400fa,0x000019e7, 16590x00001924,0x00001686,0x00050095,0x000000ab,
20730x000019e8,0x000019ec,0x000200f8,0x000019e8, 16600x0000193f,0x000018eb,0x00001681,0x00050051,
20740x00050041,0x00000028,0x000019e9,0x00001884, 16610x00000006,0x00001940,0x0000193f,0x00000001,
20750x0000021a,0x0004003d,0x00000027,0x000019ea, 16620x00050051,0x00000006,0x00001941,0x0000193f,
20760x000019e9,0x000500b4,0x0000002f,0x000019eb, 16630x00000000,0x00050080,0x00000006,0x00001946,
20770x000019ea,0x000004f9,0x000200f9,0x000019ec, 16640x000018f2,0x00001940,0x00050050,0x00000007,
20780x000200f8,0x000019ec,0x000700f5,0x0000002f, 16650x00001947,0x00001941,0x00001946,0x0004007c,
20790x000019ed,0x000019e7,0x000019e6,0x000019eb, 16660x00000014,0x00001937,0x00001947,0x00060041,
20800x000019e8,0x000300f7,0x000019f2,0x00000000, 16670x000000db,0x0000192f,0x00001937,0x000000da,
20810x000400fa,0x000019ed,0x000019ee,0x000019f2, 16680x000000da,0x0005003e,0x0000192f,0x00001924,
20820x000200f8,0x000019ee,0x00050041,0x00000028,
20830x000019ef,0x00001884,0x00000230,0x0004003d,
20840x00000027,0x000019f0,0x000019ef,0x000500b4,
20850x0000002f,0x000019f1,0x000019f0,0x0000026a,
20860x000200f9,0x000019f2,0x000200f8,0x000019f2,
20870x000700f5,0x0000002f,0x000019f3,0x000019ed,
20880x000019ec,0x000019f1,0x000019ee,0x000300f7,
20890x000019f8,0x00000000,0x000400fa,0x000019f3,
20900x000019f4,0x000019f8,0x000200f8,0x000019f4,
20910x00050041,0x00000028,0x000019f5,0x00001884,
20920x00000305,0x0004003d,0x00000027,0x000019f6,
20930x000019f5,0x000500b4,0x0000002f,0x000019f7,
20940x000019f6,0x0000026a,0x000200f9,0x000019f8,
20950x000200f8,0x000019f8,0x000700f5,0x0000002f,
20960x000019f9,0x000019f3,0x000019f2,0x000019f7,
20970x000019f4,0x000300f7,0x000019fe,0x00000000,
20980x000400fa,0x000019f9,0x000019fa,0x000019fe,
20990x000200f8,0x000019fa,0x00050041,0x00000028,
21000x000019fb,0x00001884,0x0000024d,0x0004003d,
21010x00000027,0x000019fc,0x000019fb,0x000500b4,
21020x0000002f,0x000019fd,0x000019fc,0x0000026a,
21030x000200f9,0x000019fe,0x000200f8,0x000019fe,
21040x000700f5,0x0000002f,0x000019ff,0x000019f9,
21050x000019f8,0x000019fd,0x000019fa,0x000300f7,
21060x00001a04,0x00000000,0x000400fa,0x000019ff,
21070x00001a00,0x00001a04,0x000200f8,0x00001a00,
21080x00050041,0x00000028,0x00001a01,0x00001884,
21090x00000263,0x0004003d,0x00000027,0x00001a02,
21100x00001a01,0x000500b4,0x0000002f,0x00001a03,
21110x00001a02,0x000004f9,0x000200f9,0x00001a04,
21120x000200f8,0x00001a04,0x000700f5,0x0000002f,
21130x00001a05,0x000019ff,0x000019fe,0x00001a03,
21140x00001a00,0x00050080,0x00000006,0x00001a07,
21150x00001916,0x0000037b,0x000500c7,0x00000006,
21160x00001a09,0x00002adf,0x0000052e,0x000600a9,
21170x00000006,0x00001a0b,0x00001a05,0x0000012d,
21180x000000a3,0x000500c5,0x00000006,0x00001a0c,
21190x00001a09,0x00001a0b,0x00050095,0x000000a8,
21200x00001ce3,0x00001b83,0x00001a07,0x00050051,
21210x00000006,0x00001ce4,0x00001ce3,0x00000001,
21220x00050051,0x00000006,0x00001ce5,0x00001ce3,
21230x00000000,0x00050080,0x00000006,0x00001cea,
21240x00001b8a,0x00001ce4,0x00050050,0x00000007,
21250x00001ceb,0x00001ce5,0x00001cea,0x0004007c,
21260x00000014,0x00001cdb,0x00001ceb,0x00060041,
21270x000000d8,0x00001cd3,0x00001cdb,0x000000d7,
21280x000000d7,0x0005003e,0x00001cd3,0x00001a0c,
21290x00000002,0x00000004,0x00050080,0x00000006,
21300x00001a11,0x00001916,0x00000385,0x000500c2,
21310x00000006,0x00001a14,0x00001b0b,0x00000305,
21320x000500c4,0x00000006,0x00001a17,0x00001b2c,
21330x0000047b,0x000500c5,0x00000006,0x00001a18,
21340x00001a14,0x00001a17,0x00050095,0x000000a8,
21350x00001d03,0x00001b83,0x00001a11,0x00050051,
21360x00000006,0x00001d04,0x00001d03,0x00000001,
21370x00050051,0x00000006,0x00001d05,0x00001d03,
21380x00000000,0x00050080,0x00000006,0x00001d0a,
21390x00001b8a,0x00001d04,0x00050050,0x00000007,
21400x00001d0b,0x00001d05,0x00001d0a,0x0004007c,
21410x00000014,0x00001cfb,0x00001d0b,0x00060041,
21420x000000d8,0x00001cf3,0x00001cfb,0x000000d7,
21430x000000d7,0x0005003e,0x00001cf3,0x00001a18,
21440x00000002,0x00000004,0x0004003d,0x00000027,
21450x00001a1d,0x000019d3,0x00050041,0x00000028,
21460x00001a1e,0x00001884,0x00000212,0x0004003d,
21470x00000027,0x00001a1f,0x00001a1e,0x00050041,
21480x00000028,0x00001a20,0x00001884,0x00000305,
21490x0004003d,0x00000027,0x00001a21,0x00001a20,
21500x00050041,0x00000028,0x00001a22,0x00001884,
21510x00000151,0x0004003d,0x00000027,0x00001a23,
21520x00001a22,0x00050041,0x00000028,0x00001a24,
21530x00001884,0x0000021a,0x0004003d,0x00000027,
21540x00001a25,0x00001a24,0x00050041,0x00000028,
21550x00001a26,0x00001884,0x0000024d,0x0004003d,
21560x00000027,0x00001a27,0x00001a26,0x00050041,
21570x00000028,0x00001a28,0x00001884,0x00000202,
21580x0004003d,0x00000027,0x00001a29,0x00001a28,
21590x00050041,0x00000028,0x00001a2a,0x00001884,
21600x00000230,0x0004003d,0x00000027,0x00001a2b,
21610x00001a2a,0x00050041,0x00000028,0x00001a2c,
21620x00001884,0x00000263,0x0004003d,0x00000027,
21630x00001a2d,0x00001a2c,0x00060050,0x0000004b,
21640x00001a2e,0x00001a1d,0x00001a1f,0x00001a21,
21650x00060050,0x0000004b,0x00001a2f,0x00001a23,
21660x00001a25,0x00001a27,0x00060050,0x0000004b,
21670x00001a30,0x00001a29,0x00001a2b,0x00001a2d,
21680x00060050,0x00000548,0x00001a31,0x00001a2e,
21690x00001a2f,0x00001a30,0x0006000c,0x00000027,
21700x00001a33,0x00000001,0x00000021,0x00001a31,
21710x000500b7,0x0000002f,0x00001a35,0x00001a33,
21720x0000026a,0x000300f7,0x00001a3a,0x00000000,
21730x000400fa,0x00001a35,0x00001a36,0x00001a39,
21740x000200f8,0x00001a36,0x0006000c,0x00000548,
21750x00001a38,0x00000001,0x00000022,0x00001a31,
21760x000200f9,0x00001a3a,0x000200f8,0x00001a39,
21770x000200f9,0x00001a3a,0x000200f8,0x00001a3a,
21780x000700f5,0x00000548,0x00002ae6,0x00001a38,
21790x00001a36,0x0000056e,0x00001a39,0x0003003e,
21800x000018c5,0x00002ae6,0x00050041,0x00000028,
21810x00001a3c,0x00001884,0x0000020a,0x0004003d,
21820x00000027,0x00001a3d,0x00001a3c,0x00050041,
21830x00000028,0x00001a3e,0x00001884,0x000004d5,
21840x0004003d,0x00000027,0x00001a3f,0x00001a3e,
21850x00050041,0x00000028,0x00001a40,0x00001884,
21860x00000278,0x0004003d,0x00000027,0x00001a41,
21870x00001a40,0x00060050,0x0000004b,0x00001a42,
21880x00001a3d,0x00001a3f,0x00001a41,0x00050091,
21890x0000004b,0x00001a45,0x00002ae6,0x00001a42,
21900x0004007f,0x0000004b,0x00001a46,0x00001a45,
21910x0003003e,0x000018c8,0x00001a46,0x000200f9,
21920x00001a47,0x000200f8,0x00001a47,0x000700f5,
21930x00000006,0x00002ae7,0x000000a3,0x00001a3a,
21940x00001a7a,0x00001a4b,0x000500b0,0x0000002f,
21950x00001a4a,0x00002ae7,0x000002b4,0x000400f6,
21960x00001a7b,0x00001a4b,0x00000000,0x000400fa,
21970x00001a4a,0x00001a4b,0x00001a7b,0x000200f8,
21980x00001a4b,0x00050080,0x00000006,0x00001a4d,
21990x00001916,0x00000104,0x00050084,0x00000006,
22000x00001a4f,0x0000011c,0x00002ae7,0x00050080,
22010x00000006,0x00001a50,0x00001a4d,0x00001a4f,
22020x00060041,0x00000028,0x00001a54,0x000018c5,
22030x000000d7,0x00002ae7,0x0004003d,0x00000027,
22040x00001a55,0x00001a54,0x0004007c,0x00000006,
22050x00001d11,0x00001a55,0x00050095,0x000000a8,
22060x00001d2c,0x00001b83,0x00001a50,0x00050051,
22070x00000006,0x00001d2d,0x00001d2c,0x00000001,
22080x00050051,0x00000006,0x00001d2e,0x00001d2c,
22090x00000000,0x00050080,0x00000006,0x00001d33,
22100x00001b8a,0x00001d2d,0x00050050,0x00000007,
22110x00001d34,0x00001d2e,0x00001d33,0x0004007c,
22120x00000014,0x00001d24,0x00001d34,0x00060041,
22130x000000d8,0x00001d1c,0x00001d24,0x000000d7,
22140x000000d7,0x0005003e,0x00001d1c,0x00001d11,
22150x00000002,0x00000004,0x00050080,0x00000006, 16690x00000002,0x00000004,0x00050080,0x00000006,
22160x00001a58,0x00001916,0x00000594,0x00050080, 16700x0000168a,0x0000323b,0x00000154,0x000200f9,
22170x00000006,0x00001a5b,0x00001a58,0x00001a4f, 16710x00001663,0x000200f8,0x0000168b,0x00050080,
22180x00060041,0x00000028,0x00001a5f,0x000018c5, 16720x00000006,0x0000168d,0x00001662,0x00000347,
22190x00000151,0x00002ae7,0x0004003d,0x00000027, 16730x00050041,0x00000156,0x0000168e,0x000000fc,
22200x00001a60,0x00001a5f,0x0004007c,0x00000006, 16740x000000da,0x0004003d,0x00000007,0x0000168f,
22210x00001d3a,0x00001a60,0x00050095,0x000000a8, 16750x0000168e,0x00060041,0x00000028,0x00001690,
22220x00001d55,0x00001b83,0x00001a5b,0x00050051, 16760x0000161a,0x00000205,0x000000a6,0x0004003d,
22230x00000006,0x00001d56,0x00001d55,0x00000001, 16770x00000027,0x00001691,0x00001690,0x0004007c,
22240x00050051,0x00000006,0x00001d57,0x00001d55, 16780x00000006,0x0000194d,0x00001691,0x00050051,
22250x00000000,0x00050080,0x00000006,0x00001d5c, 16790x00000006,0x00001966,0x0000168f,0x00000000,
22260x00001b8a,0x00001d56,0x00050050,0x00000007, 16800x00050095,0x000000ab,0x00001968,0x00001966,
22270x00001d5d,0x00001d57,0x00001d5c,0x0004007c, 16810x0000168d,0x00050051,0x00000006,0x00001969,
22280x00000014,0x00001d4d,0x00001d5d,0x00060041, 16820x00001968,0x00000001,0x00050051,0x00000006,
22290x000000d8,0x00001d45,0x00001d4d,0x000000d7, 16830x0000196a,0x00001968,0x00000000,0x00050051,
22300x000000d7,0x0005003e,0x00001d45,0x00001d3a, 16840x00000006,0x0000196d,0x0000168f,0x00000001,
16850x00050080,0x00000006,0x0000196f,0x0000196d,
16860x00001969,0x00050050,0x00000007,0x00001970,
16870x0000196a,0x0000196f,0x0004007c,0x00000014,
16880x00001960,0x00001970,0x00060041,0x000000db,
16890x00001958,0x00001960,0x000000da,0x000000da,
16900x0005003e,0x00001958,0x0000194d,0x00000002,
16910x00000004,0x00050080,0x00000006,0x00001694,
16920x00001662,0x00000352,0x00060041,0x00000028,
16930x00001697,0x0000161a,0x00000205,0x000000b0,
16940x0004003d,0x00000027,0x00001698,0x00001697,
16950x0004007c,0x00000006,0x00001976,0x00001698,
16960x00050095,0x000000ab,0x00001991,0x00001966,
16970x00001694,0x00050051,0x00000006,0x00001992,
16980x00001991,0x00000001,0x00050051,0x00000006,
16990x00001993,0x00001991,0x00000000,0x00050080,
17000x00000006,0x00001998,0x0000196d,0x00001992,
17010x00050050,0x00000007,0x00001999,0x00001993,
17020x00001998,0x0004007c,0x00000014,0x00001989,
17030x00001999,0x00060041,0x000000db,0x00001981,
17040x00001989,0x000000da,0x000000da,0x0005003e,
17050x00001981,0x00001976,0x00000002,0x00000004,
17060x00050080,0x00000006,0x0000169b,0x00001662,
17070x0000035d,0x00060041,0x00000028,0x0000169e,
17080x0000161a,0x00000205,0x00000170,0x0004003d,
17090x00000027,0x0000169f,0x0000169e,0x0004007c,
17100x00000006,0x0000199f,0x0000169f,0x00050095,
17110x000000ab,0x000019ba,0x00001966,0x0000169b,
17120x00050051,0x00000006,0x000019bb,0x000019ba,
17130x00000001,0x00050051,0x00000006,0x000019bc,
17140x000019ba,0x00000000,0x00050080,0x00000006,
17150x000019c1,0x0000196d,0x000019bb,0x00050050,
17160x00000007,0x000019c2,0x000019bc,0x000019c1,
17170x0004007c,0x00000014,0x000019b2,0x000019c2,
17180x00060041,0x000000db,0x000019aa,0x000019b2,
17190x000000da,0x000000da,0x0005003e,0x000019aa,
17200x0000199f,0x00000002,0x00000004,0x00050080,
17210x00000006,0x000016a2,0x00001662,0x00000368,
17220x00050041,0x000000fe,0x000016a5,0x000000fc,
17230x0000036a,0x0004003d,0x00000006,0x000016a6,
17240x000016a5,0x00050095,0x000000ab,0x000019da,
17250x00001966,0x000016a2,0x00050051,0x00000006,
17260x000019db,0x000019da,0x00000001,0x00050051,
17270x00000006,0x000019dc,0x000019da,0x00000000,
17280x00050080,0x00000006,0x000019e1,0x0000196d,
17290x000019db,0x00050050,0x00000007,0x000019e2,
17300x000019dc,0x000019e1,0x0004007c,0x00000014,
17310x000019d2,0x000019e2,0x00060041,0x000000db,
17320x000019ca,0x000019d2,0x000000da,0x000000da,
17330x0005003e,0x000019ca,0x000016a6,0x00000002,
17340x00000004,0x00050080,0x00000006,0x000016a9,
17350x00001662,0x00000374,0x00050095,0x000000ab,
17360x000019fa,0x00001966,0x000016a9,0x00050051,
17370x00000006,0x000019fb,0x000019fa,0x00000001,
17380x00050051,0x00000006,0x000019fc,0x000019fa,
17390x00000000,0x00050080,0x00000006,0x00001a01,
17400x0000196d,0x000019fb,0x00050050,0x00000007,
17410x00001a02,0x000019fc,0x00001a01,0x0004007c,
17420x00000014,0x000019f2,0x00001a02,0x00060041,
17430x000000db,0x000019ea,0x000019f2,0x000000da,
17440x000000da,0x0005003e,0x000019ea,0x00000b11,
22310x00000002,0x00000004,0x00050080,0x00000006, 17450x00000002,0x00000004,0x00050080,0x00000006,
22320x00001a63,0x00001916,0x000005a3,0x00050080, 17460x000016af,0x00001662,0x0000037e,0x00050095,
22330x00000006,0x00001a66,0x00001a63,0x00001a4f, 17470x000000ab,0x00001a1a,0x00001966,0x000016af,
22340x00060041,0x00000028,0x00001a6a,0x000018c5, 17480x00050051,0x00000006,0x00001a1b,0x00001a1a,
22350x00000202,0x00002ae7,0x0004003d,0x00000027, 17490x00000001,0x00050051,0x00000006,0x00001a1c,
22360x00001a6b,0x00001a6a,0x0004007c,0x00000006, 17500x00001a1a,0x00000000,0x00050080,0x00000006,
22370x00001d63,0x00001a6b,0x00050095,0x000000a8, 17510x00001a21,0x0000196d,0x00001a1b,0x00050050,
22380x00001d7e,0x00001b83,0x00001a66,0x00050051, 17520x00000007,0x00001a22,0x00001a1c,0x00001a21,
22390x00000006,0x00001d7f,0x00001d7e,0x00000001, 17530x0004007c,0x00000014,0x00001a12,0x00001a22,
22400x00050051,0x00000006,0x00001d80,0x00001d7e, 17540x00060041,0x000000db,0x00001a0a,0x00001a12,
22410x00000000,0x00050080,0x00000006,0x00001d85, 17550x000000da,0x000000da,0x0005003e,0x00001a0a,
22420x00001b8a,0x00001d7f,0x00050050,0x00000007, 17560x00000380,0x00000002,0x00000004,0x00050080,
22430x00001d86,0x00001d80,0x00001d85,0x0004007c, 17570x00000006,0x000016b4,0x00001662,0x00000388,
22440x00000014,0x00001d76,0x00001d86,0x00060041, 17580x00050095,0x000000ab,0x00001a3a,0x00001966,
22450x000000d8,0x00001d6e,0x00001d76,0x000000d7, 17590x000016b4,0x00050051,0x00000006,0x00001a3b,
22460x000000d7,0x0005003e,0x00001d6e,0x00001d63, 17600x00001a3a,0x00000001,0x00050051,0x00000006,
17610x00001a3c,0x00001a3a,0x00000000,0x00050080,
17620x00000006,0x00001a41,0x0000196d,0x00001a3b,
17630x00050050,0x00000007,0x00001a42,0x00001a3c,
17640x00001a41,0x0004007c,0x00000014,0x00001a32,
17650x00001a42,0x00060041,0x000000db,0x00001a2a,
17660x00001a32,0x000000da,0x000000da,0x0005003e,
17670x00001a2a,0x0000038a,0x00000002,0x00000004,
17680x00050041,0x0000004c,0x000016b8,0x0000161a,
17690x000000da,0x0004003d,0x0000004b,0x000016b9,
17700x000016b8,0x0004009c,0x00000395,0x000016ba,
17710x000016b9,0x0004009a,0x0000002f,0x000016bb,
17720x000016ba,0x000400a8,0x0000002f,0x000016bc,
17730x000016bb,0x000300f7,0x000016c2,0x00000000,
17740x000400fa,0x000016bc,0x000016bd,0x000016c2,
17750x000200f8,0x000016bd,0x00050041,0x0000004c,
17760x000016be,0x0000161a,0x00000154,0x0004003d,
17770x0000004b,0x000016bf,0x000016be,0x0004009c,
17780x00000395,0x000016c0,0x000016bf,0x0004009a,
17790x0000002f,0x000016c1,0x000016c0,0x000200f9,
17800x000016c2,0x000200f8,0x000016c2,0x000700f5,
17810x0000002f,0x000016c3,0x000016bb,0x0000168b,
17820x000016c1,0x000016bd,0x000400a8,0x0000002f,
17830x000016c4,0x000016c3,0x000300f7,0x000016ca,
17840x00000000,0x000400fa,0x000016c4,0x000016c5,
17850x000016ca,0x000200f8,0x000016c5,0x00050041,
17860x0000004c,0x000016c6,0x0000161a,0x00000205,
17870x0004003d,0x0000004b,0x000016c7,0x000016c6,
17880x0004009c,0x00000395,0x000016c8,0x000016c7,
17890x0004009a,0x0000002f,0x000016c9,0x000016c8,
17900x000200f9,0x000016ca,0x000200f8,0x000016ca,
17910x000700f5,0x0000002f,0x000016cb,0x000016c3,
17920x000016c2,0x000016c9,0x000016c5,0x0004003d,
17930x0000004b,0x000016cd,0x000016b8,0x00050041,
17940x0000004c,0x000016ce,0x0000161a,0x00000154,
17950x0004003d,0x0000004b,0x000016cf,0x000016ce,
17960x0007000c,0x0000004b,0x000016d0,0x00000001,
17970x00000025,0x000016cd,0x000016cf,0x00050041,
17980x0000004c,0x000016d1,0x0000161a,0x00000205,
17990x0004003d,0x0000004b,0x000016d2,0x000016d1,
18000x0007000c,0x0000004b,0x000016d3,0x00000001,
18010x00000025,0x000016d0,0x000016d2,0x0004003d,
18020x0000004b,0x000016d5,0x000016b8,0x0004003d,
18030x0000004b,0x000016d7,0x000016ce,0x0007000c,
18040x0000004b,0x000016d8,0x00000001,0x00000028,
18050x000016d5,0x000016d7,0x0004003d,0x0000004b,
18060x000016da,0x000016d1,0x0007000c,0x0000004b,
18070x000016db,0x00000001,0x00000028,0x000016d8,
18080x000016da,0x00060050,0x00000395,0x000032a9,
18090x000016cb,0x000016cb,0x000016cb,0x000600a9,
18100x0000004b,0x000032aa,0x000032a9,0x000032a7,
18110x000016db,0x000600a9,0x0000004b,0x000032ac,
18120x000032a9,0x000032a5,0x000016d3,0x00050041,
18130x000000fe,0x00001a8c,0x000000fc,0x000000fd,
18140x0004003d,0x00000006,0x00001a8d,0x00001a8c,
18150x00050084,0x00000006,0x00001a8e,0x0000011f,
18160x00001a8d,0x00050080,0x00000006,0x00001a8f,
18170x00000107,0x00001a8e,0x00050080,0x00000006,
18180x00001a95,0x00001a8d,0x000032a8,0x00050086,
18190x00000006,0x00001a96,0x00001a95,0x00000101,
18200x00050084,0x00000006,0x00001a88,0x00000107,
18210x00001a96,0x00050080,0x00000006,0x00001a89,
18220x00001a8f,0x00001a88,0x00050084,0x00000006,
18230x00001a59,0x00000150,0x0000165d,0x00050080,
18240x00000006,0x00001a5a,0x00001a89,0x00001a59,
18250x00050041,0x00000156,0x00001a5b,0x000000fc,
18260x00000154,0x0004003d,0x00000007,0x00001a5c,
18270x00001a5b,0x00050051,0x00000027,0x00001a5f,
18280x000032ac,0x00000000,0x0004007c,0x00000006,
18290x00001a9c,0x00001a5f,0x00050051,0x00000006,
18300x00001ab5,0x00001a5c,0x00000000,0x00050095,
18310x000000ab,0x00001ab7,0x00001ab5,0x00001a5a,
18320x00050051,0x00000006,0x00001ab8,0x00001ab7,
18330x00000001,0x00050051,0x00000006,0x00001ab9,
18340x00001ab7,0x00000000,0x00050051,0x00000006,
18350x00001abc,0x00001a5c,0x00000001,0x00050080,
18360x00000006,0x00001abe,0x00001abc,0x00001ab8,
18370x00050050,0x00000007,0x00001abf,0x00001ab9,
18380x00001abe,0x0004007c,0x00000014,0x00001aaf,
18390x00001abf,0x00060041,0x000000db,0x00001aa7,
18400x00001aaf,0x000000da,0x000000da,0x0005003e,
18410x00001aa7,0x00001a9c,0x00000002,0x00000004,
18420x00050080,0x00000006,0x00001a62,0x00001a5a,
18430x0000010a,0x00050051,0x00000027,0x00001a66,
18440x000032ac,0x00000001,0x0004007c,0x00000006,
18450x00001ac5,0x00001a66,0x00050095,0x000000ab,
18460x00001ae0,0x00001ab5,0x00001a62,0x00050051,
18470x00000006,0x00001ae1,0x00001ae0,0x00000001,
18480x00050051,0x00000006,0x00001ae2,0x00001ae0,
18490x00000000,0x00050080,0x00000006,0x00001ae7,
18500x00001abc,0x00001ae1,0x00050050,0x00000007,
18510x00001ae8,0x00001ae2,0x00001ae7,0x0004007c,
18520x00000014,0x00001ad8,0x00001ae8,0x00060041,
18530x000000db,0x00001ad0,0x00001ad8,0x000000da,
18540x000000da,0x0005003e,0x00001ad0,0x00001ac5,
22470x00000002,0x00000004,0x00050080,0x00000006, 18550x00000002,0x00000004,0x00050080,0x00000006,
22480x00001a6e,0x00001916,0x000005b2,0x00050080, 18560x00001a69,0x00001a5a,0x00000111,0x00050051,
22490x00000006,0x00001a71,0x00001a6e,0x00001a4f, 18570x00000027,0x00001a6d,0x000032ac,0x00000002,
22500x00050041,0x00000028,0x00001a75,0x000018c8, 18580x0004007c,0x00000006,0x00001aee,0x00001a6d,
22510x00002ae7,0x0004003d,0x00000027,0x00001a76, 18590x00050095,0x000000ab,0x00001b09,0x00001ab5,
22520x00001a75,0x0004007c,0x00000006,0x00001d8c, 18600x00001a69,0x00050051,0x00000006,0x00001b0a,
22530x00001a76,0x00050095,0x000000a8,0x00001da7, 18610x00001b09,0x00000001,0x00050051,0x00000006,
22540x00001b83,0x00001a71,0x00050051,0x00000006, 18620x00001b0b,0x00001b09,0x00000000,0x00050080,
22550x00001da8,0x00001da7,0x00000001,0x00050051, 18630x00000006,0x00001b10,0x00001abc,0x00001b0a,
22560x00000006,0x00001da9,0x00001da7,0x00000000, 18640x00050050,0x00000007,0x00001b11,0x00001b0b,
22570x00050080,0x00000006,0x00001dae,0x00001b8a, 18650x00001b10,0x0004007c,0x00000014,0x00001b01,
22580x00001da8,0x00050050,0x00000007,0x00001daf, 18660x00001b11,0x00060041,0x000000db,0x00001af9,
22590x00001da9,0x00001dae,0x0004007c,0x00000014, 18670x00001b01,0x000000da,0x000000da,0x0005003e,
22600x00001d9f,0x00001daf,0x00060041,0x000000d8, 18680x00001af9,0x00001aee,0x00000002,0x00000004,
22610x00001d97,0x00001d9f,0x000000d7,0x000000d7, 18690x00050080,0x00000006,0x00001a70,0x00001a5a,
22620x0005003e,0x00001d97,0x00001d8c,0x00000002, 18700x00000118,0x00050051,0x00000027,0x00001a74,
22630x00000004,0x00050080,0x00000006,0x00001a7a, 18710x000032aa,0x00000000,0x0004007c,0x00000006,
22640x00002ae7,0x00000151,0x000200f9,0x00001a47, 18720x00001b17,0x00001a74,0x00050095,0x000000ab,
22650x000200f8,0x00001a7b,0x00050080,0x00000006, 18730x00001b32,0x00001ab5,0x00001a70,0x00050051,
22660x00001a7d,0x00001916,0x000005c3,0x00050095, 18740x00000006,0x00001b33,0x00001b32,0x00000001,
22670x000000a8,0x00001dc7,0x00001b83,0x00001a7d, 18750x00050051,0x00000006,0x00001b34,0x00001b32,
22680x00050051,0x00000006,0x00001dc8,0x00001dc7, 18760x00000000,0x00050080,0x00000006,0x00001b39,
22690x00000001,0x00050051,0x00000006,0x00001dc9, 18770x00001abc,0x00001b33,0x00050050,0x00000007,
22700x00001dc7,0x00000000,0x00050080,0x00000006, 18780x00001b3a,0x00001b34,0x00001b39,0x0004007c,
22710x00001dce,0x00001b8a,0x00001dc8,0x00050050, 18790x00000014,0x00001b2a,0x00001b3a,0x00060041,
22720x00000007,0x00001dcf,0x00001dc9,0x00001dce, 18800x000000db,0x00001b22,0x00001b2a,0x000000da,
22730x0004007c,0x00000014,0x00001dbf,0x00001dcf, 18810x000000da,0x0005003e,0x00001b22,0x00001b17,
22740x00060041,0x000000d8,0x00001db7,0x00001dbf,
22750x000000d7,0x000000d7,0x0005003e,0x00001db7,
22760x000009e9,0x00000002,0x00000004,0x00050080,
22770x00000006,0x00001a83,0x00001916,0x000005cd,
22780x00050095,0x000000a8,0x00001de7,0x00001b83,
22790x00001a83,0x00050051,0x00000006,0x00001de8,
22800x00001de7,0x00000001,0x00050051,0x00000006,
22810x00001de9,0x00001de7,0x00000000,0x00050080,
22820x00000006,0x00001dee,0x00001b8a,0x00001de8,
22830x00050050,0x00000007,0x00001def,0x00001de9,
22840x00001dee,0x0004007c,0x00000014,0x00001ddf,
22850x00001def,0x00060041,0x000000d8,0x00001dd7,
22860x00001ddf,0x000000d7,0x000000d7,0x0005003e,
22870x00001dd7,0x0000037d,0x00000002,0x00000004,
22880x00050080,0x00000006,0x00001a88,0x00001916,
22890x000005d6,0x00050095,0x000000a8,0x00001e07,
22900x00001b83,0x00001a88,0x00050051,0x00000006,
22910x00001e08,0x00001e07,0x00000001,0x00050051,
22920x00000006,0x00001e09,0x00001e07,0x00000000,
22930x00050080,0x00000006,0x00001e0e,0x00001b8a,
22940x00001e08,0x00050050,0x00000007,0x00001e0f,
22950x00001e09,0x00001e0e,0x0004007c,0x00000014,
22960x00001dff,0x00001e0f,0x00060041,0x000000d8,
22970x00001df7,0x00001dff,0x000000d7,0x000000d7,
22980x0005003e,0x00001df7,0x000000a3,0x00000002,
22990x00000004,0x00050080,0x00000006,0x00001a8d,
23000x00001916,0x000005df,0x00050095,0x000000a8,
23010x00001e27,0x00001b83,0x00001a8d,0x00050051,
23020x00000006,0x00001e28,0x00001e27,0x00000001,
23030x00050051,0x00000006,0x00001e29,0x00001e27,
23040x00000000,0x00050080,0x00000006,0x00001e2e,
23050x00001b8a,0x00001e28,0x00050050,0x00000007,
23060x00001e2f,0x00001e29,0x00001e2e,0x0004007c,
23070x00000014,0x00001e1f,0x00001e2f,0x00060041,
23080x000000d8,0x00001e17,0x00001e1f,0x000000d7,
23090x000000d7,0x0005003e,0x00001e17,0x000000a3,
23100x00000002,0x00000004,0x000500b4,0x0000002f,
23110x00001a92,0x00001a33,0x0000026a,0x00060050,
23120x00000392,0x00002b6f,0x00001a92,0x00001a92,
23130x00001a92,0x000600a9,0x0000004b,0x00002b70,
23140x00002b6f,0x00002b66,0x00002b05,0x000600a9,
23150x0000004b,0x00002b72,0x00002b6f,0x00002b64,
23160x00002af3,0x00050041,0x000000fb,0x00001e79,
23170x000000f9,0x000000fa,0x0004003d,0x00000006,
23180x00001e7a,0x00001e79,0x00050084,0x00000006,
23190x00001e7b,0x0000011c,0x00001e7a,0x00050080,
23200x00000006,0x00001e7c,0x00000104,0x00001e7b,
23210x00050080,0x00000006,0x00001e82,0x00001e7a,
23220x00002b67,0x00050086,0x00000006,0x00001e83,
23230x00001e82,0x000000fe,0x00050084,0x00000006,
23240x00001e75,0x00000104,0x00001e83,0x00050080,
23250x00000006,0x00001e76,0x00001e7c,0x00001e75,
23260x00050084,0x00000006,0x00001e46,0x0000014d,
23270x000009e9,0x00050080,0x00000006,0x00001e47,
23280x00001e76,0x00001e46,0x00050041,0x00000153,
23290x00001e48,0x000000f9,0x00000151,0x0004003d,
23300x00000007,0x00001e49,0x00001e48,0x00050051,
23310x00000027,0x00001e4c,0x00002b72,0x00000000,
23320x0004007c,0x00000006,0x00001e89,0x00001e4c,
23330x00050051,0x00000006,0x00001ea2,0x00001e49,
23340x00000000,0x00050095,0x000000a8,0x00001ea4,
23350x00001ea2,0x00001e47,0x00050051,0x00000006,
23360x00001ea5,0x00001ea4,0x00000001,0x00050051,
23370x00000006,0x00001ea6,0x00001ea4,0x00000000,
23380x00050051,0x00000006,0x00001ea9,0x00001e49,
23390x00000001,0x00050080,0x00000006,0x00001eab,
23400x00001ea9,0x00001ea5,0x00050050,0x00000007,
23410x00001eac,0x00001ea6,0x00001eab,0x0004007c,
23420x00000014,0x00001e9c,0x00001eac,0x00060041,
23430x000000d8,0x00001e94,0x00001e9c,0x000000d7,
23440x000000d7,0x0005003e,0x00001e94,0x00001e89,
23450x00000002,0x00000004,0x00050080,0x00000006, 18820x00000002,0x00000004,0x00050080,0x00000006,
23460x00001e4f,0x00001e47,0x00000107,0x00050051, 18830x00001a77,0x00001a5a,0x0000011f,0x00050051,
23470x00000027,0x00001e53,0x00002b72,0x00000001, 18840x00000027,0x00001a7b,0x000032aa,0x00000001,
23480x0004007c,0x00000006,0x00001eb2,0x00001e53, 18850x0004007c,0x00000006,0x00001b40,0x00001a7b,
23490x00050095,0x000000a8,0x00001ecd,0x00001ea2, 18860x00050095,0x000000ab,0x00001b5b,0x00001ab5,
23500x00001e4f,0x00050051,0x00000006,0x00001ece, 18870x00001a77,0x00050051,0x00000006,0x00001b5c,
23510x00001ecd,0x00000001,0x00050051,0x00000006, 18880x00001b5b,0x00000001,0x00050051,0x00000006,
23520x00001ecf,0x00001ecd,0x00000000,0x00050080, 18890x00001b5d,0x00001b5b,0x00000000,0x00050080,
23530x00000006,0x00001ed4,0x00001ea9,0x00001ece, 18900x00000006,0x00001b62,0x00001abc,0x00001b5c,
23540x00050050,0x00000007,0x00001ed5,0x00001ecf, 18910x00050050,0x00000007,0x00001b63,0x00001b5d,
23550x00001ed4,0x0004007c,0x00000014,0x00001ec5, 18920x00001b62,0x0004007c,0x00000014,0x00001b53,
23560x00001ed5,0x00060041,0x000000d8,0x00001ebd, 18930x00001b63,0x00060041,0x000000db,0x00001b4b,
23570x00001ec5,0x000000d7,0x000000d7,0x0005003e, 18940x00001b53,0x000000da,0x000000da,0x0005003e,
23580x00001ebd,0x00001eb2,0x00000002,0x00000004, 18950x00001b4b,0x00001b40,0x00000002,0x00000004,
23590x00050080,0x00000006,0x00001e56,0x00001e47, 18960x00050080,0x00000006,0x00001a7e,0x00001a5a,
23600x0000010e,0x00050051,0x00000027,0x00001e5a, 18970x00000189,0x00050051,0x00000027,0x00001a82,
23610x00002b72,0x00000002,0x0004007c,0x00000006, 18980x000032aa,0x00000002,0x0004007c,0x00000006,
23620x00001edb,0x00001e5a,0x00050095,0x000000a8, 18990x00001b69,0x00001a82,0x00050095,0x000000ab,
23630x00001ef6,0x00001ea2,0x00001e56,0x00050051, 19000x00001b84,0x00001ab5,0x00001a7e,0x00050051,
23640x00000006,0x00001ef7,0x00001ef6,0x00000001, 19010x00000006,0x00001b85,0x00001b84,0x00000001,
23650x00050051,0x00000006,0x00001ef8,0x00001ef6, 19020x00050051,0x00000006,0x00001b86,0x00001b84,
23660x00000000,0x00050080,0x00000006,0x00001efd, 19030x00000000,0x00050080,0x00000006,0x00001b8b,
23670x00001ea9,0x00001ef7,0x00050050,0x00000007, 19040x00001abc,0x00001b85,0x00050050,0x00000007,
23680x00001efe,0x00001ef8,0x00001efd,0x0004007c, 19050x00001b8c,0x00001b86,0x00001b8b,0x0004007c,
23690x00000014,0x00001eee,0x00001efe,0x00060041, 19060x00000014,0x00001b7c,0x00001b8c,0x00060041,
23700x000000d8,0x00001ee6,0x00001eee,0x000000d7, 19070x000000db,0x00001b74,0x00001b7c,0x000000da,
23710x000000d7,0x0005003e,0x00001ee6,0x00001edb, 19080x000000da,0x0005003e,0x00001b74,0x00001b69,
19090x00000002,0x00000004,0x000300f7,0x00001bcc,
19100x00000000,0x000300fb,0x000000a6,0x00001b9b,
19110x000200f8,0x00001b9b,0x000500bc,0x0000002f,
19120x00001bd3,0x00001a5f,0x00001a74,0x000300f7,
19130x00001bda,0x00000000,0x000400fa,0x00001bd3,
19140x00001bd4,0x00001bda,0x000200f8,0x00001bd4,
19150x000500bc,0x0000002f,0x00001bd9,0x00001a66,
19160x00001a7b,0x000200f9,0x00001bda,0x000200f8,
19170x00001bda,0x000700f5,0x0000002f,0x00001bdb,
19180x00001bd3,0x00001b9b,0x00001bd9,0x00001bd4,
19190x000300f7,0x00001be2,0x00000000,0x000400fa,
19200x00001bdb,0x00001bdc,0x00001be2,0x000200f8,
19210x00001bdc,0x000500bc,0x0000002f,0x00001be1,
19220x00001a6d,0x00001a82,0x000200f9,0x00001be2,
19230x000200f8,0x00001be2,0x000700f5,0x0000002f,
19240x00001be3,0x00001bdb,0x00001bda,0x00001be1,
19250x00001bdc,0x000400a8,0x0000002f,0x00001be4,
19260x00001be3,0x000300f7,0x00001ba0,0x00000000,
19270x000400fa,0x00001be4,0x00001b9f,0x00001ba0,
19280x000200f8,0x00001b9f,0x000200f9,0x00001bcc,
19290x000200f8,0x00001ba0,0x00050081,0x0000004b,
19300x00001ba3,0x000032ac,0x000032aa,0x0005008e,
19310x0000004b,0x00001ba4,0x00001ba3,0x000001ed,
19320x00050095,0x000000ab,0x00001bf4,0x00001ab5,
19330x000000a6,0x00050051,0x00000006,0x00001bf5,
19340x00001bf4,0x00000001,0x00050051,0x00000006,
19350x00001bf6,0x00001bf4,0x00000000,0x00050080,
19360x00000006,0x00001bfb,0x00001abc,0x00001bf5,
19370x00050050,0x00000007,0x00001bfc,0x00001bf6,
19380x00001bfb,0x0004007c,0x00000014,0x00001bec,
19390x00001bfc,0x00060041,0x000000db,0x00001ba9,
19400x00001bec,0x000000da,0x000000da,0x00050051,
19410x00000027,0x00001bab,0x00001ba4,0x00000000,
19420x0004007c,0x00000006,0x00001c02,0x00001bab,
19430x000500c7,0x00000006,0x00001c04,0x00001c02,
19440x00000130,0x000500ab,0x0000002f,0x00001c05,
19450x00001c04,0x000000a6,0x000300f7,0x00001c0c,
19460x00000000,0x000400fa,0x00001c05,0x00001c06,
19470x00001c09,0x000200f8,0x00001c06,0x000400c8,
19480x00000006,0x00001c08,0x00001c02,0x000200f9,
19490x00001c0c,0x000200f8,0x00001c09,0x000500c5,
19500x00000006,0x00001c0b,0x00001c02,0x00000130,
19510x000200f9,0x00001c0c,0x000200f8,0x00001c0c,
19520x000700f5,0x00000006,0x0000323e,0x00001c08,
19530x00001c06,0x00001c0b,0x00001c09,0x000700ed,
19540x00000006,0x00001bad,0x00001ba9,0x000000b0,
19550x000000a6,0x0000323e,0x00060041,0x000000db,
19560x00001baf,0x00001bec,0x000000da,0x00000154,
19570x00050051,0x00000027,0x00001bb1,0x00001ba4,
19580x00000001,0x0004007c,0x00000006,0x00001c13,
19590x00001bb1,0x000500c7,0x00000006,0x00001c15,
19600x00001c13,0x00000130,0x000500ab,0x0000002f,
19610x00001c16,0x00001c15,0x000000a6,0x000300f7,
19620x00001c1d,0x00000000,0x000400fa,0x00001c16,
19630x00001c17,0x00001c1a,0x000200f8,0x00001c17,
19640x000400c8,0x00000006,0x00001c19,0x00001c13,
19650x000200f9,0x00001c1d,0x000200f8,0x00001c1a,
19660x000500c5,0x00000006,0x00001c1c,0x00001c13,
19670x00000130,0x000200f9,0x00001c1d,0x000200f8,
19680x00001c1d,0x000700f5,0x00000006,0x0000323f,
19690x00001c19,0x00001c17,0x00001c1c,0x00001c1a,
19700x000700ed,0x00000006,0x00001bb3,0x00001baf,
19710x000000b0,0x000000a6,0x0000323f,0x00060041,
19720x000000db,0x00001bb5,0x00001bec,0x000000da,
19730x00000205,0x00050051,0x00000027,0x00001bb7,
19740x00001ba4,0x00000002,0x0004007c,0x00000006,
19750x00001c24,0x00001bb7,0x000500c7,0x00000006,
19760x00001c26,0x00001c24,0x00000130,0x000500ab,
19770x0000002f,0x00001c27,0x00001c26,0x000000a6,
19780x000300f7,0x00001c2e,0x00000000,0x000400fa,
19790x00001c27,0x00001c28,0x00001c2b,0x000200f8,
19800x00001c28,0x000400c8,0x00000006,0x00001c2a,
19810x00001c24,0x000200f9,0x00001c2e,0x000200f8,
19820x00001c2b,0x000500c5,0x00000006,0x00001c2d,
19830x00001c24,0x00000130,0x000200f9,0x00001c2e,
19840x000200f8,0x00001c2e,0x000700f5,0x00000006,
19850x00003240,0x00001c2a,0x00001c28,0x00001c2d,
19860x00001c2b,0x000700ed,0x00000006,0x00001bb9,
19870x00001bb5,0x000000b0,0x000000a6,0x00003240,
19880x00060041,0x000000db,0x00001bbb,0x00001bec,
19890x000000da,0x0000020d,0x000300f7,0x00001c3f,
19900x00000000,0x000400fa,0x00001c05,0x00001c39,
19910x00001c3c,0x000200f8,0x00001c39,0x000400c8,
19920x00000006,0x00001c3b,0x00001c02,0x000200f9,
19930x00001c3f,0x000200f8,0x00001c3c,0x000500c5,
19940x00000006,0x00001c3e,0x00001c02,0x00000130,
19950x000200f9,0x00001c3f,0x000200f8,0x00001c3f,
19960x000700f5,0x00000006,0x00003241,0x00001c3b,
19970x00001c39,0x00001c3e,0x00001c3c,0x000700ef,
19980x00000006,0x00001bbf,0x00001bbb,0x000000b0,
19990x000000a6,0x00003241,0x00060041,0x000000db,
20000x00001bc1,0x00001bec,0x000000da,0x00000215,
20010x000300f7,0x00001c50,0x00000000,0x000400fa,
20020x00001c16,0x00001c4a,0x00001c4d,0x000200f8,
20030x00001c4a,0x000400c8,0x00000006,0x00001c4c,
20040x00001c13,0x000200f9,0x00001c50,0x000200f8,
20050x00001c4d,0x000500c5,0x00000006,0x00001c4f,
20060x00001c13,0x00000130,0x000200f9,0x00001c50,
20070x000200f8,0x00001c50,0x000700f5,0x00000006,
20080x00003242,0x00001c4c,0x00001c4a,0x00001c4f,
20090x00001c4d,0x000700ef,0x00000006,0x00001bc5,
20100x00001bc1,0x000000b0,0x000000a6,0x00003242,
20110x00060041,0x000000db,0x00001bc7,0x00001bec,
20120x000000da,0x0000021d,0x000300f7,0x00001c61,
20130x00000000,0x000400fa,0x00001c27,0x00001c5b,
20140x00001c5e,0x000200f8,0x00001c5b,0x000400c8,
20150x00000006,0x00001c5d,0x00001c24,0x000200f9,
20160x00001c61,0x000200f8,0x00001c5e,0x000500c5,
20170x00000006,0x00001c60,0x00001c24,0x00000130,
20180x000200f9,0x00001c61,0x000200f8,0x00001c61,
20190x000700f5,0x00000006,0x00003243,0x00001c5d,
20200x00001c5b,0x00001c60,0x00001c5e,0x000700ef,
20210x00000006,0x00001bcb,0x00001bc7,0x000000b0,
20220x000000a6,0x00003243,0x000200f9,0x00001bcc,
20230x000200f8,0x00001bcc,0x000200f9,0x00000bd2,
20240x000200f8,0x00000bd6,0x000500aa,0x0000002f,
20250x00000bd9,0x00000b13,0x00000170,0x000300f7,
20260x00000bdb,0x00000000,0x000400fa,0x00000bd9,
20270x00000bda,0x00000bdf,0x000200f8,0x00000bda,
20280x00050084,0x00000006,0x00001cca,0x00000107,
20290x00000b11,0x000200f9,0x00001ccb,0x000200f8,
20300x00001ccb,0x000700f5,0x00000006,0x000031f0,
20310x000000a6,0x00000bda,0x00001cdc,0x00001ccf,
20320x000500b0,0x0000002f,0x00001cce,0x000031f0,
20330x00000118,0x000400f6,0x00001cdd,0x00001ccf,
20340x00000000,0x000400fa,0x00001cce,0x00001ccf,
20350x00001cdd,0x000200f8,0x00001ccf,0x00050084,
20360x00000006,0x00001cd3,0x0000010a,0x000031f0,
20370x00050080,0x00000006,0x00001cd4,0x00001cca,
20380x00001cd3,0x00050041,0x00000156,0x00001cd5,
20390x000000fc,0x00000205,0x0004003d,0x00000007,
20400x00001cd6,0x00001cd5,0x00050051,0x00000006,
20410x00001e97,0x00001cd6,0x00000000,0x00050095,
20420x000000ab,0x00001e99,0x00001e97,0x00001cd4,
20430x00050051,0x00000006,0x00001e9a,0x00001e99,
20440x00000001,0x00050051,0x00000006,0x00001e9b,
20450x00001e99,0x00000000,0x00050051,0x00000006,
20460x00001e9e,0x00001cd6,0x00000001,0x00050080,
20470x00000006,0x00001ea0,0x00001e9e,0x00001e9a,
20480x00050050,0x00000007,0x00001ea1,0x00001e9b,
20490x00001ea0,0x0004007c,0x00000014,0x00001e91,
20500x00001ea1,0x00060041,0x000000db,0x00001e88,
20510x00001e91,0x000000da,0x000000da,0x0006003d,
20520x00000006,0x00001e89,0x00001e88,0x00000002,
20530x00000004,0x0004007c,0x00000027,0x00001cd8,
20540x00001e89,0x00050041,0x00000028,0x00001cd9,
20550x00001c65,0x000031f0,0x0003003e,0x00001cd9,
20560x00001cd8,0x00050080,0x00000006,0x00001cdc,
20570x000031f0,0x00000154,0x000200f9,0x00001ccb,
20580x000200f8,0x00001cdd,0x00050080,0x00000006,
20590x00001cdf,0x00001cca,0x00000368,0x00050041,
20600x00000156,0x00001ce0,0x000000fc,0x00000205,
20610x0004003d,0x00000007,0x00001ce1,0x00001ce0,
20620x00050051,0x00000006,0x00001eb8,0x00001ce1,
20630x00000000,0x00050095,0x000000ab,0x00001eba,
20640x00001eb8,0x00001cdf,0x00050051,0x00000006,
20650x00001ebb,0x00001eba,0x00000001,0x00050051,
20660x00000006,0x00001ebc,0x00001eba,0x00000000,
20670x00050051,0x00000006,0x00001ebf,0x00001ce1,
20680x00000001,0x00050080,0x00000006,0x00001ec1,
20690x00001ebf,0x00001ebb,0x00050050,0x00000007,
20700x00001ec2,0x00001ebc,0x00001ec1,0x0004007c,
20710x00000014,0x00001eb2,0x00001ec2,0x00060041,
20720x000000db,0x00001ea9,0x00001eb2,0x000000da,
20730x000000da,0x0006003d,0x00000006,0x00001eaa,
20740x00001ea9,0x00000002,0x00000004,0x00050080,
20750x00000006,0x00001ce4,0x00001cca,0x00000374,
20760x00050095,0x000000ab,0x00001edb,0x00001eb8,
20770x00001ce4,0x00050051,0x00000006,0x00001edc,
20780x00001edb,0x00000001,0x00050051,0x00000006,
20790x00001edd,0x00001edb,0x00000000,0x00050080,
20800x00000006,0x00001ee2,0x00001ebf,0x00001edc,
20810x00050050,0x00000007,0x00001ee3,0x00001edd,
20820x00001ee2,0x0004007c,0x00000014,0x00001ed3,
20830x00001ee3,0x00060041,0x000000db,0x00001eca,
20840x00001ed3,0x000000da,0x000000da,0x0006003d,
20850x00000006,0x00001ecb,0x00001eca,0x00000002,
20860x00000004,0x00050080,0x00000006,0x00001ce9,
20870x00001cca,0x0000037e,0x00050095,0x000000ab,
20880x00001efc,0x00001eb8,0x00001ce9,0x00050051,
20890x00000006,0x00001efd,0x00001efc,0x00000001,
20900x00050051,0x00000006,0x00001efe,0x00001efc,
20910x00000000,0x00050080,0x00000006,0x00001f03,
20920x00001ebf,0x00001efd,0x00050050,0x00000007,
20930x00001f04,0x00001efe,0x00001f03,0x0004007c,
20940x00000014,0x00001ef4,0x00001f04,0x00060041,
20950x000000db,0x00001eeb,0x00001ef4,0x000000da,
20960x000000da,0x0006003d,0x00000006,0x00001eec,
20970x00001eeb,0x00000002,0x00000004,0x00050080,
20980x00000006,0x00001cee,0x00001cca,0x00000388,
20990x00050095,0x000000ab,0x00001f1d,0x00001eb8,
21000x00001cee,0x00050051,0x00000006,0x00001f1e,
21010x00001f1d,0x00000001,0x00050051,0x00000006,
21020x00001f1f,0x00001f1d,0x00000000,0x00050080,
21030x00000006,0x00001f24,0x00001ebf,0x00001f1e,
21040x00050050,0x00000007,0x00001f25,0x00001f1f,
21050x00001f24,0x0004007c,0x00000014,0x00001f15,
21060x00001f25,0x00060041,0x000000db,0x00001f0c,
21070x00001f15,0x000000da,0x000000da,0x0006003d,
21080x00000006,0x00001f0d,0x00001f0c,0x00000002,
21090x00000004,0x00050041,0x000000fe,0x00001cf3,
21100x000000fc,0x0000022c,0x0004003d,0x00000006,
21110x00001cf4,0x00001cf3,0x00050084,0x00000006,
21120x00001cf6,0x00000228,0x00000b11,0x00050080,
21130x00000006,0x00001cf7,0x00001cf4,0x00001cf6,
21140x000200f9,0x00001cf8,0x000200f8,0x00001cf8,
21150x000700f5,0x00000006,0x000031f1,0x000000a6,
21160x00001cdd,0x00001d09,0x00001cfc,0x000500b0,
21170x0000002f,0x00001cfb,0x000031f1,0x00000118,
21180x000400f6,0x00001d0a,0x00001cfc,0x00000000,
21190x000400fa,0x00001cfb,0x00001cfc,0x00001d0a,
21200x000200f8,0x00001cfc,0x00050084,0x00000006,
21210x00001cff,0x0000010a,0x000031f1,0x00050080,
21220x00000006,0x00001d00,0x00001cf7,0x00001cff,
21230x00050041,0x00000156,0x00001d02,0x000000fc,
21240x000000da,0x0004003d,0x00000007,0x00001d03,
21250x00001d02,0x00050041,0x00000028,0x00001d04,
21260x00001c65,0x000031f1,0x0004003d,0x00000027,
21270x00001d05,0x00001d04,0x0004007c,0x00000006,
21280x00001f2b,0x00001d05,0x00050051,0x00000006,
21290x00001f44,0x00001d03,0x00000000,0x00050095,
21300x000000ab,0x00001f46,0x00001f44,0x00001d00,
21310x00050051,0x00000006,0x00001f47,0x00001f46,
21320x00000001,0x00050051,0x00000006,0x00001f48,
21330x00001f46,0x00000000,0x00050051,0x00000006,
21340x00001f4b,0x00001d03,0x00000001,0x00050080,
21350x00000006,0x00001f4d,0x00001f4b,0x00001f47,
21360x00050050,0x00000007,0x00001f4e,0x00001f48,
21370x00001f4d,0x0004007c,0x00000014,0x00001f3e,
21380x00001f4e,0x00060041,0x000000db,0x00001f36,
21390x00001f3e,0x000000da,0x000000da,0x0005003e,
21400x00001f36,0x00001f2b,0x00000002,0x00000004,
21410x00050080,0x00000006,0x00001d09,0x000031f1,
21420x00000154,0x000200f9,0x00001cf8,0x000200f8,
21430x00001d0a,0x00050080,0x00000006,0x00001d0c,
21440x00001cf7,0x00000368,0x00050041,0x00000156,
21450x00001d0d,0x000000fc,0x000000da,0x0004003d,
21460x00000007,0x00001d0e,0x00001d0d,0x00050051,
21470x00000006,0x00001f64,0x00001d0e,0x00000000,
21480x00050095,0x000000ab,0x00001f66,0x00001f64,
21490x00001d0c,0x00050051,0x00000006,0x00001f67,
21500x00001f66,0x00000001,0x00050051,0x00000006,
21510x00001f68,0x00001f66,0x00000000,0x00050051,
21520x00000006,0x00001f6b,0x00001d0e,0x00000001,
21530x00050080,0x00000006,0x00001f6d,0x00001f6b,
21540x00001f67,0x00050050,0x00000007,0x00001f6e,
21550x00001f68,0x00001f6d,0x0004007c,0x00000014,
21560x00001f5e,0x00001f6e,0x00060041,0x000000db,
21570x00001f56,0x00001f5e,0x000000da,0x000000da,
21580x0005003e,0x00001f56,0x00001eaa,0x00000002,
21590x00000004,0x00050080,0x00000006,0x00001d12,
21600x00001cf7,0x00000374,0x00050095,0x000000ab,
21610x00001f86,0x00001f64,0x00001d12,0x00050051,
21620x00000006,0x00001f87,0x00001f86,0x00000001,
21630x00050051,0x00000006,0x00001f88,0x00001f86,
21640x00000000,0x00050080,0x00000006,0x00001f8d,
21650x00001f6b,0x00001f87,0x00050050,0x00000007,
21660x00001f8e,0x00001f88,0x00001f8d,0x0004007c,
21670x00000014,0x00001f7e,0x00001f8e,0x00060041,
21680x000000db,0x00001f76,0x00001f7e,0x000000da,
21690x000000da,0x0005003e,0x00001f76,0x00001ecb,
21700x00000002,0x00000004,0x000500aa,0x0000002f,
21710x00001f93,0x00001eec,0x000000a6,0x000300f7,
21720x00001f98,0x00000000,0x000400fa,0x00001f93,
21730x00001f94,0x00001f98,0x000200f8,0x00001f94,
21740x000500aa,0x0000002f,0x00001f97,0x00001f0d,
21750x000000a6,0x000200f9,0x00001f98,0x000200f8,
21760x00001f98,0x000700f5,0x0000002f,0x00001f99,
21770x00001f93,0x00001d0a,0x00001f97,0x00001f94,
21780x000400a8,0x0000002f,0x00001d1d,0x00001f99,
21790x000300f7,0x00001db3,0x00000000,0x000400fa,
21800x00001d1d,0x00001d1e,0x00001db3,0x000200f8,
21810x00001d1e,0x00050041,0x00000156,0x00001d20,
21820x000000fc,0x0000021d,0x0004003d,0x00000007,
21830x00001d21,0x00001d20,0x00050051,0x00000006,
21840x00001fa1,0x00001d21,0x00000000,0x00050095,
21850x000000ab,0x00001fa2,0x00001eec,0x00001fa1,
21860x00050051,0x00000006,0x00001fa3,0x00001fa2,
21870x00000001,0x00050051,0x00000006,0x00001fa4,
21880x00001fa2,0x00000000,0x00050051,0x00000006,
21890x00001fa9,0x00001d21,0x00000001,0x00050080,
21900x00000006,0x00001faa,0x00001f0d,0x00001fa9,
21910x00050080,0x00000006,0x00001fac,0x00001faa,
21920x00001fa3,0x00050095,0x000000ab,0x00001fc6,
21930x00001fa4,0x00000368,0x00050051,0x00000006,
21940x00001fc7,0x00001fc6,0x00000001,0x00050051,
21950x00000006,0x00001fc8,0x00001fc6,0x00000000,
21960x00050080,0x00000006,0x00001fcd,0x00001fac,
21970x00001fc7,0x00050050,0x00000007,0x00001fce,
21980x00001fc8,0x00001fcd,0x0004007c,0x00000014,
21990x00001fbe,0x00001fce,0x00060041,0x000000db,
22000x00001fb5,0x00001fbe,0x000000da,0x000000da,
22010x0006003d,0x00000006,0x00001fb6,0x00001fb5,
22020x00000002,0x00000004,0x00050095,0x000000ab,
22030x00001fe7,0x00001fa4,0x0000011f,0x00050051,
22040x00000006,0x00001fe8,0x00001fe7,0x00000001,
22050x00050051,0x00000006,0x00001fe9,0x00001fe7,
22060x00000000,0x00050080,0x00000006,0x00001fee,
22070x00001fac,0x00001fe8,0x00050050,0x00000007,
22080x00001fef,0x00001fe9,0x00001fee,0x0004007c,
22090x00000014,0x00001fdf,0x00001fef,0x00060041,
22100x000000db,0x00001fd6,0x00001fdf,0x000000da,
22110x000000da,0x0006003d,0x00000006,0x00001fd7,
22120x00001fd6,0x00000002,0x00000004,0x0004007c,
22130x00000027,0x00001d27,0x00001fd7,0x00050095,
22140x000000ab,0x00002008,0x00001fa4,0x00000189,
22150x00050051,0x00000006,0x00002009,0x00002008,
22160x00000001,0x00050051,0x00000006,0x0000200a,
22170x00002008,0x00000000,0x00050080,0x00000006,
22180x0000200f,0x00001fac,0x00002009,0x00050050,
22190x00000007,0x00002010,0x0000200a,0x0000200f,
22200x0004007c,0x00000014,0x00002000,0x00002010,
22210x00060041,0x000000db,0x00001ff7,0x00002000,
22220x000000da,0x000000da,0x0006003d,0x00000006,
22230x00001ff8,0x00001ff7,0x00000002,0x00000004,
22240x0004007c,0x00000027,0x00001d2a,0x00001ff8,
22250x00050095,0x000000ab,0x00002029,0x00001fa4,
22260x00000150,0x00050051,0x00000006,0x0000202a,
22270x00002029,0x00000001,0x00050051,0x00000006,
22280x0000202b,0x00002029,0x00000000,0x00050080,
22290x00000006,0x00002030,0x00001fac,0x0000202a,
22300x00050050,0x00000007,0x00002031,0x0000202b,
22310x00002030,0x0004007c,0x00000014,0x00002021,
22320x00002031,0x00060041,0x000000db,0x00002018,
22330x00002021,0x000000da,0x000000da,0x0006003d,
22340x00000006,0x00002019,0x00002018,0x00000002,
22350x00000004,0x0004007c,0x00000027,0x00001d2d,
22360x00002019,0x00050095,0x000000ab,0x0000204a,
22370x00001fa4,0x00000463,0x00050051,0x00000006,
22380x0000204b,0x0000204a,0x00000001,0x00050051,
22390x00000006,0x0000204c,0x0000204a,0x00000000,
22400x00050080,0x00000006,0x00002051,0x00001fac,
22410x0000204b,0x00050050,0x00000007,0x00002052,
22420x0000204c,0x00002051,0x0004007c,0x00000014,
22430x00002042,0x00002052,0x00060041,0x000000db,
22440x00002039,0x00002042,0x000000da,0x000000da,
22450x0006003d,0x00000006,0x0000203a,0x00002039,
22460x00000002,0x00000004,0x0004007c,0x00000027,
22470x00001d31,0x0000203a,0x00050095,0x000000ab,
22480x0000206b,0x00001fa4,0x00000469,0x00050051,
22490x00000006,0x0000206c,0x0000206b,0x00000001,
22500x00050051,0x00000006,0x0000206d,0x0000206b,
22510x00000000,0x00050080,0x00000006,0x00002072,
22520x00001fac,0x0000206c,0x00050050,0x00000007,
22530x00002073,0x0000206d,0x00002072,0x0004007c,
22540x00000014,0x00002063,0x00002073,0x00060041,
22550x000000db,0x0000205a,0x00002063,0x000000da,
22560x000000da,0x0006003d,0x00000006,0x0000205b,
22570x0000205a,0x00000002,0x00000004,0x0004007c,
22580x00000027,0x00001d34,0x0000205b,0x00050095,
22590x000000ab,0x0000208c,0x00001fa4,0x00000347,
22600x00050051,0x00000006,0x0000208d,0x0000208c,
22610x00000001,0x00050051,0x00000006,0x0000208e,
22620x0000208c,0x00000000,0x00050080,0x00000006,
22630x00002093,0x00001fac,0x0000208d,0x00050050,
22640x00000007,0x00002094,0x0000208e,0x00002093,
22650x0004007c,0x00000014,0x00002084,0x00002094,
22660x00060041,0x000000db,0x0000207b,0x00002084,
22670x000000da,0x000000da,0x0006003d,0x00000006,
22680x0000207c,0x0000207b,0x00000002,0x00000004,
22690x0004007c,0x00000027,0x00001d37,0x0000207c,
22700x000500bc,0x0000002f,0x0000209b,0x00001d27,
22710x00001d31,0x000300f7,0x000020a2,0x00000000,
22720x000400fa,0x0000209b,0x0000209c,0x000020a2,
22730x000200f8,0x0000209c,0x000500bc,0x0000002f,
22740x000020a1,0x00001d2a,0x00001d34,0x000200f9,
22750x000020a2,0x000200f8,0x000020a2,0x000700f5,
22760x0000002f,0x000020a3,0x0000209b,0x00001d1e,
22770x000020a1,0x0000209c,0x000300f7,0x000020aa,
22780x00000000,0x000400fa,0x000020a3,0x000020a4,
22790x000020aa,0x000200f8,0x000020a4,0x000500bc,
22800x0000002f,0x000020a9,0x00001d2d,0x00001d37,
22810x000200f9,0x000020aa,0x000200f8,0x000020aa,
22820x000700f5,0x0000002f,0x000020ab,0x000020a3,
22830x000020a2,0x000020a9,0x000020a4,0x000300f7,
22840x00001d41,0x00000000,0x000400fa,0x000020ab,
22850x00001d3d,0x00001d41,0x000200f8,0x00001d3d,
22860x000500c2,0x00000006,0x00001d3f,0x00001eaa,
22870x0000047e,0x000500ab,0x0000002f,0x00001d40,
22880x00001d3f,0x000000a6,0x000200f9,0x00001d41,
22890x000200f8,0x00001d41,0x000700f5,0x0000002f,
22900x00001d42,0x000020ab,0x000020aa,0x00001d40,
22910x00001d3d,0x000300f7,0x00001db2,0x00000000,
22920x000400fa,0x00001d42,0x00001d43,0x00001db2,
22930x000200f8,0x00001d43,0x000200f9,0x00001d44,
22940x000200f8,0x00001d44,0x000700f5,0x0000004b,
22950x00003227,0x000032a7,0x00001d43,0x00001dad,
22960x00001d48,0x000700f5,0x0000004b,0x00003215,
22970x000032a5,0x00001d43,0x00001daa,0x00001d48,
22980x000700f5,0x00000006,0x000031f2,0x000000a6,
22990x00001d43,0x00001db0,0x00001d48,0x000500b0,
23000x0000002f,0x00001d47,0x000031f2,0x00000111,
23010x000400f6,0x00001db1,0x00001d48,0x00000000,
23020x000400fa,0x00001d47,0x00001d48,0x00001db1,
23030x000200f8,0x00001d48,0x000500c7,0x00000006,
23040x00001d4a,0x000031f2,0x000000b0,0x000500ab,
23050x0000002f,0x00001d4b,0x00001d4a,0x000000a6,
23060x000600a9,0x00000027,0x000032ad,0x00001d4b,
23070x00001d31,0x00001d27,0x000500c7,0x00000006,
23080x00001d55,0x000031f2,0x00000170,0x000500ab,
23090x0000002f,0x00001d56,0x00001d55,0x000000a6,
23100x000600a9,0x00000027,0x000032ae,0x00001d56,
23110x00001d34,0x00001d2a,0x000500c7,0x00000006,
23120x00001d60,0x000031f2,0x0000010a,0x000500ab,
23130x0000002f,0x00001d61,0x00001d60,0x000000a6,
23140x000600a9,0x00000027,0x000032af,0x00001d61,
23150x00001d37,0x00001d2d,0x00050041,0x00000028,
23160x00001d6b,0x00001c65,0x000000da,0x0004003d,
23170x00000027,0x00001d6c,0x00001d6b,0x00050085,
23180x00000027,0x00001d6f,0x00001d6c,0x000032ad,
23190x00050041,0x00000028,0x00001d70,0x00001c65,
23200x00000154,0x0004003d,0x00000027,0x00001d71,
23210x00001d70,0x00050085,0x00000027,0x00001d74,
23220x00001d71,0x000032ae,0x00050081,0x00000027,
23230x00001d75,0x00001d6f,0x00001d74,0x00050041,
23240x00000028,0x00001d76,0x00001c65,0x00000205,
23250x0004003d,0x00000027,0x00001d77,0x00001d76,
23260x00050085,0x00000027,0x00001d7a,0x00001d77,
23270x000032af,0x00050081,0x00000027,0x00001d7b,
23280x00001d75,0x00001d7a,0x00050041,0x00000028,
23290x00001d7c,0x00001c65,0x0000020d,0x0004003d,
23300x00000027,0x00001d7d,0x00001d7c,0x00050081,
23310x00000027,0x00001d7e,0x00001d7b,0x00001d7d,
23320x00050041,0x00000028,0x00001d7f,0x00001c65,
23330x00000215,0x0004003d,0x00000027,0x00001d80,
23340x00001d7f,0x00050085,0x00000027,0x00001d83,
23350x00001d80,0x000032ad,0x00050041,0x00000028,
23360x00001d84,0x00001c65,0x0000021d,0x0004003d,
23370x00000027,0x00001d85,0x00001d84,0x00050085,
23380x00000027,0x00001d88,0x00001d85,0x000032ae,
23390x00050081,0x00000027,0x00001d89,0x00001d83,
23400x00001d88,0x00050041,0x00000028,0x00001d8a,
23410x00001c65,0x00000233,0x0004003d,0x00000027,
23420x00001d8b,0x00001d8a,0x00050085,0x00000027,
23430x00001d8e,0x00001d8b,0x000032af,0x00050081,
23440x00000027,0x00001d8f,0x00001d89,0x00001d8e,
23450x00050041,0x00000028,0x00001d90,0x00001c65,
23460x000004d8,0x0004003d,0x00000027,0x00001d91,
23470x00001d90,0x00050081,0x00000027,0x00001d92,
23480x00001d8f,0x00001d91,0x00050041,0x00000028,
23490x00001d93,0x00001c65,0x00000308,0x0004003d,
23500x00000027,0x00001d94,0x00001d93,0x00050085,
23510x00000027,0x00001d97,0x00001d94,0x000032ad,
23520x00050041,0x00000028,0x00001d98,0x00001c65,
23530x00000250,0x0004003d,0x00000027,0x00001d99,
23540x00001d98,0x00050085,0x00000027,0x00001d9c,
23550x00001d99,0x000032ae,0x00050081,0x00000027,
23560x00001d9d,0x00001d97,0x00001d9c,0x00050041,
23570x00000028,0x00001d9e,0x00001c65,0x00000266,
23580x0004003d,0x00000027,0x00001d9f,0x00001d9e,
23590x00050085,0x00000027,0x00001da2,0x00001d9f,
23600x000032af,0x00050081,0x00000027,0x00001da3,
23610x00001d9d,0x00001da2,0x00050041,0x00000028,
23620x00001da4,0x00001c65,0x0000027b,0x0004003d,
23630x00000027,0x00001da5,0x00001da4,0x00050081,
23640x00000027,0x00001da6,0x00001da3,0x00001da5,
23650x00060050,0x0000004b,0x00001da7,0x00001d7e,
23660x00001d92,0x00001da6,0x0007000c,0x0000004b,
23670x00001daa,0x00000001,0x00000025,0x00003215,
23680x00001da7,0x0007000c,0x0000004b,0x00001dad,
23690x00000001,0x00000028,0x00003227,0x00001da7,
23700x00050080,0x00000006,0x00001db0,0x000031f2,
23710x00000154,0x000200f9,0x00001d44,0x000200f8,
23720x00001db1,0x000200f9,0x00001db2,0x000200f8,
23730x00001db2,0x000700f5,0x0000004b,0x00003223,
23740x000032a7,0x00001d41,0x00003227,0x00001db1,
23750x000700f5,0x0000004b,0x00003211,0x000032a5,
23760x00001d41,0x00003215,0x00001db1,0x000200f9,
23770x00001db3,0x000200f8,0x00001db3,0x000700f5,
23780x0000004b,0x00003221,0x000032a7,0x00001f98,
23790x00003223,0x00001db2,0x000700f5,0x0000004b,
23800x0000320f,0x000032a5,0x00001f98,0x00003211,
23810x00001db2,0x000700f5,0x00000006,0x000031fb,
23820x00000380,0x00001f98,0x00001fb6,0x00001db2,
23830x00050041,0x00000028,0x00001db4,0x00001c65,
23840x000000da,0x0004003d,0x00000027,0x00001db5,
23850x00001db4,0x000500b4,0x0000002f,0x00001db6,
23860x00001db5,0x000004fc,0x000300f7,0x00001dbb,
23870x00000000,0x000400fa,0x00001db6,0x00001db7,
23880x00001dbb,0x000200f8,0x00001db7,0x00050041,
23890x00000028,0x00001db8,0x00001c65,0x00000154,
23900x0004003d,0x00000027,0x00001db9,0x00001db8,
23910x000500b4,0x0000002f,0x00001dba,0x00001db9,
23920x0000026d,0x000200f9,0x00001dbb,0x000200f8,
23930x00001dbb,0x000700f5,0x0000002f,0x00001dbc,
23940x00001db6,0x00001db3,0x00001dba,0x00001db7,
23950x000300f7,0x00001dc1,0x00000000,0x000400fa,
23960x00001dbc,0x00001dbd,0x00001dc1,0x000200f8,
23970x00001dbd,0x00050041,0x00000028,0x00001dbe,
23980x00001c65,0x00000205,0x0004003d,0x00000027,
23990x00001dbf,0x00001dbe,0x000500b4,0x0000002f,
24000x00001dc0,0x00001dbf,0x0000026d,0x000200f9,
24010x00001dc1,0x000200f8,0x00001dc1,0x000700f5,
24020x0000002f,0x00001dc2,0x00001dbc,0x00001dbb,
24030x00001dc0,0x00001dbd,0x000300f7,0x00001dc7,
24040x00000000,0x000400fa,0x00001dc2,0x00001dc3,
24050x00001dc7,0x000200f8,0x00001dc3,0x00050041,
24060x00000028,0x00001dc4,0x00001c65,0x00000215,
24070x0004003d,0x00000027,0x00001dc5,0x00001dc4,
24080x000500b4,0x0000002f,0x00001dc6,0x00001dc5,
24090x0000026d,0x000200f9,0x00001dc7,0x000200f8,
24100x00001dc7,0x000700f5,0x0000002f,0x00001dc8,
24110x00001dc2,0x00001dc1,0x00001dc6,0x00001dc3,
24120x000300f7,0x00001dcd,0x00000000,0x000400fa,
24130x00001dc8,0x00001dc9,0x00001dcd,0x000200f8,
24140x00001dc9,0x00050041,0x00000028,0x00001dca,
24150x00001c65,0x0000021d,0x0004003d,0x00000027,
24160x00001dcb,0x00001dca,0x000500b4,0x0000002f,
24170x00001dcc,0x00001dcb,0x000004fc,0x000200f9,
24180x00001dcd,0x000200f8,0x00001dcd,0x000700f5,
24190x0000002f,0x00001dce,0x00001dc8,0x00001dc7,
24200x00001dcc,0x00001dc9,0x000300f7,0x00001dd3,
24210x00000000,0x000400fa,0x00001dce,0x00001dcf,
24220x00001dd3,0x000200f8,0x00001dcf,0x00050041,
24230x00000028,0x00001dd0,0x00001c65,0x00000233,
24240x0004003d,0x00000027,0x00001dd1,0x00001dd0,
24250x000500b4,0x0000002f,0x00001dd2,0x00001dd1,
24260x0000026d,0x000200f9,0x00001dd3,0x000200f8,
24270x00001dd3,0x000700f5,0x0000002f,0x00001dd4,
24280x00001dce,0x00001dcd,0x00001dd2,0x00001dcf,
24290x000300f7,0x00001dd9,0x00000000,0x000400fa,
24300x00001dd4,0x00001dd5,0x00001dd9,0x000200f8,
24310x00001dd5,0x00050041,0x00000028,0x00001dd6,
24320x00001c65,0x00000308,0x0004003d,0x00000027,
24330x00001dd7,0x00001dd6,0x000500b4,0x0000002f,
24340x00001dd8,0x00001dd7,0x0000026d,0x000200f9,
24350x00001dd9,0x000200f8,0x00001dd9,0x000700f5,
24360x0000002f,0x00001dda,0x00001dd4,0x00001dd3,
24370x00001dd8,0x00001dd5,0x000300f7,0x00001ddf,
24380x00000000,0x000400fa,0x00001dda,0x00001ddb,
24390x00001ddf,0x000200f8,0x00001ddb,0x00050041,
24400x00000028,0x00001ddc,0x00001c65,0x00000250,
24410x0004003d,0x00000027,0x00001ddd,0x00001ddc,
24420x000500b4,0x0000002f,0x00001dde,0x00001ddd,
24430x0000026d,0x000200f9,0x00001ddf,0x000200f8,
24440x00001ddf,0x000700f5,0x0000002f,0x00001de0,
24450x00001dda,0x00001dd9,0x00001dde,0x00001ddb,
24460x000300f7,0x00001de5,0x00000000,0x000400fa,
24470x00001de0,0x00001de1,0x00001de5,0x000200f8,
24480x00001de1,0x00050041,0x00000028,0x00001de2,
24490x00001c65,0x00000266,0x0004003d,0x00000027,
24500x00001de3,0x00001de2,0x000500b4,0x0000002f,
24510x00001de4,0x00001de3,0x000004fc,0x000200f9,
24520x00001de5,0x000200f8,0x00001de5,0x000700f5,
24530x0000002f,0x00001de6,0x00001de0,0x00001ddf,
24540x00001de4,0x00001de1,0x00050080,0x00000006,
24550x00001de8,0x00001cf7,0x0000037e,0x000500c7,
24560x00000006,0x00001dea,0x000031fb,0x00000531,
24570x000600a9,0x00000006,0x00001dec,0x00001de6,
24580x00000130,0x000000a6,0x000500c5,0x00000006,
24590x00001ded,0x00001dea,0x00001dec,0x00050095,
24600x000000ab,0x000020c4,0x00001f64,0x00001de8,
24610x00050051,0x00000006,0x000020c5,0x000020c4,
24620x00000001,0x00050051,0x00000006,0x000020c6,
24630x000020c4,0x00000000,0x00050080,0x00000006,
24640x000020cb,0x00001f6b,0x000020c5,0x00050050,
24650x00000007,0x000020cc,0x000020c6,0x000020cb,
24660x0004007c,0x00000014,0x000020bc,0x000020cc,
24670x00060041,0x000000db,0x000020b4,0x000020bc,
24680x000000da,0x000000da,0x0005003e,0x000020b4,
24690x00001ded,0x00000002,0x00000004,0x00050080,
24700x00000006,0x00001df2,0x00001cf7,0x00000388,
24710x000500c2,0x00000006,0x00001df5,0x00001eec,
24720x00000308,0x000500c4,0x00000006,0x00001df8,
24730x00001f0d,0x0000047e,0x000500c5,0x00000006,
24740x00001df9,0x00001df5,0x00001df8,0x00050095,
24750x000000ab,0x000020e4,0x00001f64,0x00001df2,
24760x00050051,0x00000006,0x000020e5,0x000020e4,
24770x00000001,0x00050051,0x00000006,0x000020e6,
24780x000020e4,0x00000000,0x00050080,0x00000006,
24790x000020eb,0x00001f6b,0x000020e5,0x00050050,
24800x00000007,0x000020ec,0x000020e6,0x000020eb,
24810x0004007c,0x00000014,0x000020dc,0x000020ec,
24820x00060041,0x000000db,0x000020d4,0x000020dc,
24830x000000da,0x000000da,0x0005003e,0x000020d4,
24840x00001df9,0x00000002,0x00000004,0x0004003d,
24850x00000027,0x00001dfe,0x00001db4,0x00050041,
24860x00000028,0x00001dff,0x00001c65,0x00000215,
24870x0004003d,0x00000027,0x00001e00,0x00001dff,
24880x00050041,0x00000028,0x00001e01,0x00001c65,
24890x00000308,0x0004003d,0x00000027,0x00001e02,
24900x00001e01,0x00050041,0x00000028,0x00001e03,
24910x00001c65,0x00000154,0x0004003d,0x00000027,
24920x00001e04,0x00001e03,0x00050041,0x00000028,
24930x00001e05,0x00001c65,0x0000021d,0x0004003d,
24940x00000027,0x00001e06,0x00001e05,0x00050041,
24950x00000028,0x00001e07,0x00001c65,0x00000250,
24960x0004003d,0x00000027,0x00001e08,0x00001e07,
24970x00050041,0x00000028,0x00001e09,0x00001c65,
24980x00000205,0x0004003d,0x00000027,0x00001e0a,
24990x00001e09,0x00050041,0x00000028,0x00001e0b,
25000x00001c65,0x00000233,0x0004003d,0x00000027,
25010x00001e0c,0x00001e0b,0x00050041,0x00000028,
25020x00001e0d,0x00001c65,0x00000266,0x0004003d,
25030x00000027,0x00001e0e,0x00001e0d,0x00060050,
25040x0000004b,0x00001e0f,0x00001dfe,0x00001e00,
25050x00001e02,0x00060050,0x0000004b,0x00001e10,
25060x00001e04,0x00001e06,0x00001e08,0x00060050,
25070x0000004b,0x00001e11,0x00001e0a,0x00001e0c,
25080x00001e0e,0x00060050,0x0000054b,0x00001e12,
25090x00001e0f,0x00001e10,0x00001e11,0x0006000c,
25100x00000027,0x00001e14,0x00000001,0x00000021,
25110x00001e12,0x000500b7,0x0000002f,0x00001e16,
25120x00001e14,0x0000026d,0x000300f7,0x00001e1b,
25130x00000000,0x000400fa,0x00001e16,0x00001e17,
25140x00001e1a,0x000200f8,0x00001e17,0x0006000c,
25150x0000054b,0x00001e19,0x00000001,0x00000022,
25160x00001e12,0x000200f9,0x00001e1b,0x000200f8,
25170x00001e1a,0x000200f9,0x00001e1b,0x000200f8,
25180x00001e1b,0x000700f5,0x0000054b,0x00003202,
25190x00001e19,0x00001e17,0x00000571,0x00001e1a,
25200x0003003e,0x00001ca6,0x00003202,0x00050041,
25210x00000028,0x00001e1d,0x00001c65,0x0000020d,
25220x0004003d,0x00000027,0x00001e1e,0x00001e1d,
25230x00050041,0x00000028,0x00001e1f,0x00001c65,
25240x000004d8,0x0004003d,0x00000027,0x00001e20,
25250x00001e1f,0x00050041,0x00000028,0x00001e21,
25260x00001c65,0x0000027b,0x0004003d,0x00000027,
25270x00001e22,0x00001e21,0x00060050,0x0000004b,
25280x00001e23,0x00001e1e,0x00001e20,0x00001e22,
25290x00050091,0x0000004b,0x00001e26,0x00003202,
25300x00001e23,0x0004007f,0x0000004b,0x00001e27,
25310x00001e26,0x0003003e,0x00001ca9,0x00001e27,
25320x000200f9,0x00001e28,0x000200f8,0x00001e28,
25330x000700f5,0x00000006,0x00003203,0x000000a6,
25340x00001e1b,0x00001e5b,0x00001e2c,0x000500b0,
25350x0000002f,0x00001e2b,0x00003203,0x000002b7,
25360x000400f6,0x00001e5c,0x00001e2c,0x00000000,
25370x000400fa,0x00001e2b,0x00001e2c,0x00001e5c,
25380x000200f8,0x00001e2c,0x00050080,0x00000006,
25390x00001e2e,0x00001cf7,0x00000107,0x00050084,
25400x00000006,0x00001e30,0x0000011f,0x00003203,
25410x00050080,0x00000006,0x00001e31,0x00001e2e,
25420x00001e30,0x00060041,0x00000028,0x00001e35,
25430x00001ca6,0x000000da,0x00003203,0x0004003d,
25440x00000027,0x00001e36,0x00001e35,0x0004007c,
25450x00000006,0x000020f2,0x00001e36,0x00050095,
25460x000000ab,0x0000210d,0x00001f64,0x00001e31,
25470x00050051,0x00000006,0x0000210e,0x0000210d,
25480x00000001,0x00050051,0x00000006,0x0000210f,
25490x0000210d,0x00000000,0x00050080,0x00000006,
25500x00002114,0x00001f6b,0x0000210e,0x00050050,
25510x00000007,0x00002115,0x0000210f,0x00002114,
25520x0004007c,0x00000014,0x00002105,0x00002115,
25530x00060041,0x000000db,0x000020fd,0x00002105,
25540x000000da,0x000000da,0x0005003e,0x000020fd,
25550x000020f2,0x00000002,0x00000004,0x00050080,
25560x00000006,0x00001e39,0x00001cf7,0x00000597,
25570x00050080,0x00000006,0x00001e3c,0x00001e39,
25580x00001e30,0x00060041,0x00000028,0x00001e40,
25590x00001ca6,0x00000154,0x00003203,0x0004003d,
25600x00000027,0x00001e41,0x00001e40,0x0004007c,
25610x00000006,0x0000211b,0x00001e41,0x00050095,
25620x000000ab,0x00002136,0x00001f64,0x00001e3c,
25630x00050051,0x00000006,0x00002137,0x00002136,
25640x00000001,0x00050051,0x00000006,0x00002138,
25650x00002136,0x00000000,0x00050080,0x00000006,
25660x0000213d,0x00001f6b,0x00002137,0x00050050,
25670x00000007,0x0000213e,0x00002138,0x0000213d,
25680x0004007c,0x00000014,0x0000212e,0x0000213e,
25690x00060041,0x000000db,0x00002126,0x0000212e,
25700x000000da,0x000000da,0x0005003e,0x00002126,
25710x0000211b,0x00000002,0x00000004,0x00050080,
25720x00000006,0x00001e44,0x00001cf7,0x000005a6,
25730x00050080,0x00000006,0x00001e47,0x00001e44,
25740x00001e30,0x00060041,0x00000028,0x00001e4b,
25750x00001ca6,0x00000205,0x00003203,0x0004003d,
25760x00000027,0x00001e4c,0x00001e4b,0x0004007c,
25770x00000006,0x00002144,0x00001e4c,0x00050095,
25780x000000ab,0x0000215f,0x00001f64,0x00001e47,
25790x00050051,0x00000006,0x00002160,0x0000215f,
25800x00000001,0x00050051,0x00000006,0x00002161,
25810x0000215f,0x00000000,0x00050080,0x00000006,
25820x00002166,0x00001f6b,0x00002160,0x00050050,
25830x00000007,0x00002167,0x00002161,0x00002166,
25840x0004007c,0x00000014,0x00002157,0x00002167,
25850x00060041,0x000000db,0x0000214f,0x00002157,
25860x000000da,0x000000da,0x0005003e,0x0000214f,
25870x00002144,0x00000002,0x00000004,0x00050080,
25880x00000006,0x00001e4f,0x00001cf7,0x000005b5,
25890x00050080,0x00000006,0x00001e52,0x00001e4f,
25900x00001e30,0x00050041,0x00000028,0x00001e56,
25910x00001ca9,0x00003203,0x0004003d,0x00000027,
25920x00001e57,0x00001e56,0x0004007c,0x00000006,
25930x0000216d,0x00001e57,0x00050095,0x000000ab,
25940x00002188,0x00001f64,0x00001e52,0x00050051,
25950x00000006,0x00002189,0x00002188,0x00000001,
25960x00050051,0x00000006,0x0000218a,0x00002188,
25970x00000000,0x00050080,0x00000006,0x0000218f,
25980x00001f6b,0x00002189,0x00050050,0x00000007,
25990x00002190,0x0000218a,0x0000218f,0x0004007c,
26000x00000014,0x00002180,0x00002190,0x00060041,
26010x000000db,0x00002178,0x00002180,0x000000da,
26020x000000da,0x0005003e,0x00002178,0x0000216d,
23720x00000002,0x00000004,0x00050080,0x00000006, 26030x00000002,0x00000004,0x00050080,0x00000006,
23730x00001e5d,0x00001e47,0x00000115,0x00050051, 26040x00001e5b,0x00003203,0x00000154,0x000200f9,
23740x00000027,0x00001e61,0x00002b70,0x00000000, 26050x00001e28,0x000200f8,0x00001e5c,0x00050080,
23750x0004007c,0x00000006,0x00001f04,0x00001e61, 26060x00000006,0x00001e5e,0x00001cf7,0x000005c6,
23760x00050095,0x000000a8,0x00001f1f,0x00001ea2, 26070x00050095,0x000000ab,0x000021a8,0x00001f64,
23770x00001e5d,0x00050051,0x00000006,0x00001f20, 26080x00001e5e,0x00050051,0x00000006,0x000021a9,
23780x00001f1f,0x00000001,0x00050051,0x00000006, 26090x000021a8,0x00000001,0x00050051,0x00000006,
23790x00001f21,0x00001f1f,0x00000000,0x00050080, 26100x000021aa,0x000021a8,0x00000000,0x00050080,
23800x00000006,0x00001f26,0x00001ea9,0x00001f20, 26110x00000006,0x000021af,0x00001f6b,0x000021a9,
23810x00050050,0x00000007,0x00001f27,0x00001f21, 26120x00050050,0x00000007,0x000021b0,0x000021aa,
23820x00001f26,0x0004007c,0x00000014,0x00001f17, 26130x000021af,0x0004007c,0x00000014,0x000021a0,
23830x00001f27,0x00060041,0x000000d8,0x00001f0f, 26140x000021b0,0x00060041,0x000000db,0x00002198,
23840x00001f17,0x000000d7,0x000000d7,0x0005003e, 26150x000021a0,0x000000da,0x000000da,0x0005003e,
23850x00001f0f,0x00001f04,0x00000002,0x00000004, 26160x00002198,0x00000b11,0x00000002,0x00000004,
23860x00050080,0x00000006,0x00001e64,0x00001e47, 26170x00050080,0x00000006,0x00001e64,0x00001cf7,
23870x0000011c,0x00050051,0x00000027,0x00001e68, 26180x000005d0,0x00050095,0x000000ab,0x000021c8,
23880x00002b70,0x00000001,0x0004007c,0x00000006, 26190x00001f64,0x00001e64,0x00050051,0x00000006,
23890x00001f2d,0x00001e68,0x00050095,0x000000a8, 26200x000021c9,0x000021c8,0x00000001,0x00050051,
23900x00001f48,0x00001ea2,0x00001e64,0x00050051, 26210x00000006,0x000021ca,0x000021c8,0x00000000,
23910x00000006,0x00001f49,0x00001f48,0x00000001, 26220x00050080,0x00000006,0x000021cf,0x00001f6b,
23920x00050051,0x00000006,0x00001f4a,0x00001f48, 26230x000021c9,0x00050050,0x00000007,0x000021d0,
23930x00000000,0x00050080,0x00000006,0x00001f4f, 26240x000021ca,0x000021cf,0x0004007c,0x00000014,
23940x00001ea9,0x00001f49,0x00050050,0x00000007, 26250x000021c0,0x000021d0,0x00060041,0x000000db,
23950x00001f50,0x00001f4a,0x00001f4f,0x0004007c, 26260x000021b8,0x000021c0,0x000000da,0x000000da,
23960x00000014,0x00001f40,0x00001f50,0x00060041, 26270x0005003e,0x000021b8,0x00000380,0x00000002,
23970x000000d8,0x00001f38,0x00001f40,0x000000d7, 26280x00000004,0x00050080,0x00000006,0x00001e69,
23980x000000d7,0x0005003e,0x00001f38,0x00001f2d, 26290x00001cf7,0x000005d9,0x00050095,0x000000ab,
26300x000021e8,0x00001f64,0x00001e69,0x00050051,
26310x00000006,0x000021e9,0x000021e8,0x00000001,
26320x00050051,0x00000006,0x000021ea,0x000021e8,
26330x00000000,0x00050080,0x00000006,0x000021ef,
26340x00001f6b,0x000021e9,0x00050050,0x00000007,
26350x000021f0,0x000021ea,0x000021ef,0x0004007c,
26360x00000014,0x000021e0,0x000021f0,0x00060041,
26370x000000db,0x000021d8,0x000021e0,0x000000da,
26380x000000da,0x0005003e,0x000021d8,0x000000a6,
23990x00000002,0x00000004,0x00050080,0x00000006, 26390x00000002,0x00000004,0x00050080,0x00000006,
24000x00001e6b,0x00001e47,0x00000186,0x00050051, 26400x00001e6e,0x00001cf7,0x000005e2,0x00050095,
24010x00000027,0x00001e6f,0x00002b70,0x00000002, 26410x000000ab,0x00002208,0x00001f64,0x00001e6e,
24020x0004007c,0x00000006,0x00001f56,0x00001e6f, 26420x00050051,0x00000006,0x00002209,0x00002208,
24030x00050095,0x000000a8,0x00001f71,0x00001ea2, 26430x00000001,0x00050051,0x00000006,0x0000220a,
24040x00001e6b,0x00050051,0x00000006,0x00001f72, 26440x00002208,0x00000000,0x00050080,0x00000006,
24050x00001f71,0x00000001,0x00050051,0x00000006, 26450x0000220f,0x00001f6b,0x00002209,0x00050050,
24060x00001f73,0x00001f71,0x00000000,0x00050080, 26460x00000007,0x00002210,0x0000220a,0x0000220f,
24070x00000006,0x00001f78,0x00001ea9,0x00001f72, 26470x0004007c,0x00000014,0x00002200,0x00002210,
24080x00050050,0x00000007,0x00001f79,0x00001f73, 26480x00060041,0x000000db,0x000021f8,0x00002200,
24090x00001f78,0x0004007c,0x00000014,0x00001f69, 26490x000000da,0x000000da,0x0005003e,0x000021f8,
24100x00001f79,0x00060041,0x000000d8,0x00001f61, 26500x000000a6,0x00000002,0x00000004,0x000500b4,
24110x00001f69,0x000000d7,0x000000d7,0x0005003e, 26510x0000002f,0x00001e73,0x00001e14,0x0000026d,
24120x00001f61,0x00001f56,0x00000002,0x00000004, 26520x00060050,0x00000395,0x000032b0,0x00001e73,
24130x000300f7,0x00001fb9,0x00000000,0x000300fb, 26530x00001e73,0x00001e73,0x000600a9,0x0000004b,
24140x000000a3,0x00001f88,0x000200f8,0x00001f88, 26540x000032b1,0x000032b0,0x000032a7,0x00003221,
24150x000500bc,0x0000002f,0x00001fc0,0x00001e4c, 26550x000600a9,0x0000004b,0x000032b3,0x000032b0,
24160x00001e61,0x000300f7,0x00001fc7,0x00000000, 26560x000032a5,0x0000320f,0x00050041,0x000000fe,
24170x000400fa,0x00001fc0,0x00001fc1,0x00001fc7, 26570x0000225a,0x000000fc,0x000000fd,0x0004003d,
24180x000200f8,0x00001fc1,0x000500bc,0x0000002f, 26580x00000006,0x0000225b,0x0000225a,0x00050084,
24190x00001fc6,0x00001e53,0x00001e68,0x000200f9, 26590x00000006,0x0000225c,0x0000011f,0x0000225b,
24200x00001fc7,0x000200f8,0x00001fc7,0x000700f5, 26600x00050080,0x00000006,0x0000225d,0x00000107,
24210x0000002f,0x00001fc8,0x00001fc0,0x00001f88, 26610x0000225c,0x00050080,0x00000006,0x00002263,
24220x00001fc6,0x00001fc1,0x000300f7,0x00001fcf, 26620x0000225b,0x000032a8,0x00050086,0x00000006,
24230x00000000,0x000400fa,0x00001fc8,0x00001fc9, 26630x00002264,0x00002263,0x00000101,0x00050084,
24240x00001fcf,0x000200f8,0x00001fc9,0x000500bc, 26640x00000006,0x00002256,0x00000107,0x00002264,
24250x0000002f,0x00001fce,0x00001e5a,0x00001e6f, 26650x00050080,0x00000006,0x00002257,0x0000225d,
24260x000200f9,0x00001fcf,0x000200f8,0x00001fcf, 26660x00002256,0x00050084,0x00000006,0x00002227,
24270x000700f5,0x0000002f,0x00001fd0,0x00001fc8, 26670x00000150,0x00000b11,0x00050080,0x00000006,
24280x00001fc7,0x00001fce,0x00001fc9,0x000400a8, 26680x00002228,0x00002257,0x00002227,0x00050041,
24290x0000002f,0x00001fd1,0x00001fd0,0x000300f7, 26690x00000156,0x00002229,0x000000fc,0x00000154,
24300x00001f8d,0x00000000,0x000400fa,0x00001fd1, 26700x0004003d,0x00000007,0x0000222a,0x00002229,
24310x00001f8c,0x00001f8d,0x000200f8,0x00001f8c, 26710x00050051,0x00000027,0x0000222d,0x000032b3,
24320x000200f9,0x00001fb9,0x000200f8,0x00001f8d, 26720x00000000,0x0004007c,0x00000006,0x0000226a,
24330x00050081,0x0000004b,0x00001f90,0x00002b72, 26730x0000222d,0x00050051,0x00000006,0x00002283,
24340x00002b70,0x0005008e,0x0000004b,0x00001f91, 26740x0000222a,0x00000000,0x00050095,0x000000ab,
24350x00001f90,0x000001ea,0x00050095,0x000000a8, 26750x00002285,0x00002283,0x00002228,0x00050051,
24360x00001fe1,0x00001ea2,0x000000a3,0x00050051, 26760x00000006,0x00002286,0x00002285,0x00000001,
24370x00000006,0x00001fe2,0x00001fe1,0x00000001, 26770x00050051,0x00000006,0x00002287,0x00002285,
24380x00050051,0x00000006,0x00001fe3,0x00001fe1, 26780x00000000,0x00050051,0x00000006,0x0000228a,
24390x00000000,0x00050080,0x00000006,0x00001fe8, 26790x0000222a,0x00000001,0x00050080,0x00000006,
24400x00001ea9,0x00001fe2,0x00050050,0x00000007, 26800x0000228c,0x0000228a,0x00002286,0x00050050,
24410x00001fe9,0x00001fe3,0x00001fe8,0x0004007c, 26810x00000007,0x0000228d,0x00002287,0x0000228c,
24420x00000014,0x00001fd9,0x00001fe9,0x00060041, 26820x0004007c,0x00000014,0x0000227d,0x0000228d,
24430x000000d8,0x00001f96,0x00001fd9,0x000000d7, 26830x00060041,0x000000db,0x00002275,0x0000227d,
24440x000000d7,0x00050051,0x00000027,0x00001f98, 26840x000000da,0x000000da,0x0005003e,0x00002275,
24450x00001f91,0x00000000,0x0004007c,0x00000006, 26850x0000226a,0x00000002,0x00000004,0x00050080,
24460x00001fef,0x00001f98,0x000500c7,0x00000006, 26860x00000006,0x00002230,0x00002228,0x0000010a,
24470x00001ff1,0x00001fef,0x0000012d,0x000500ab, 26870x00050051,0x00000027,0x00002234,0x000032b3,
24480x0000002f,0x00001ff2,0x00001ff1,0x000000a3, 26880x00000001,0x0004007c,0x00000006,0x00002293,
24490x000300f7,0x00001ff9,0x00000000,0x000400fa, 26890x00002234,0x00050095,0x000000ab,0x000022ae,
24500x00001ff2,0x00001ff3,0x00001ff6,0x000200f8, 26900x00002283,0x00002230,0x00050051,0x00000006,
24510x00001ff3,0x000400c8,0x00000006,0x00001ff5, 26910x000022af,0x000022ae,0x00000001,0x00050051,
24520x00001fef,0x000200f9,0x00001ff9,0x000200f8, 26920x00000006,0x000022b0,0x000022ae,0x00000000,
24530x00001ff6,0x000500c5,0x00000006,0x00001ff8, 26930x00050080,0x00000006,0x000022b5,0x0000228a,
24540x00001fef,0x0000012d,0x000200f9,0x00001ff9, 26940x000022af,0x00050050,0x00000007,0x000022b6,
24550x000200f8,0x00001ff9,0x000700f5,0x00000006, 26950x000022b0,0x000022b5,0x0004007c,0x00000014,
24560x00002b0c,0x00001ff5,0x00001ff3,0x00001ff8, 26960x000022a6,0x000022b6,0x00060041,0x000000db,
24570x00001ff6,0x000700ed,0x00000006,0x00001f9a, 26970x0000229e,0x000022a6,0x000000da,0x000000da,
24580x00001f96,0x000000ad,0x000000a3,0x00002b0c, 26980x0005003e,0x0000229e,0x00002293,0x00000002,
24590x00060041,0x000000d8,0x00001f9c,0x00001fd9, 26990x00000004,0x00050080,0x00000006,0x00002237,
24600x000000d7,0x00000151,0x00050051,0x00000027, 27000x00002228,0x00000111,0x00050051,0x00000027,
24610x00001f9e,0x00001f91,0x00000001,0x0004007c, 27010x0000223b,0x000032b3,0x00000002,0x0004007c,
24620x00000006,0x00002000,0x00001f9e,0x000500c7, 27020x00000006,0x000022bc,0x0000223b,0x00050095,
24630x00000006,0x00002002,0x00002000,0x0000012d, 27030x000000ab,0x000022d7,0x00002283,0x00002237,
24640x000500ab,0x0000002f,0x00002003,0x00002002, 27040x00050051,0x00000006,0x000022d8,0x000022d7,
24650x000000a3,0x000300f7,0x0000200a,0x00000000, 27050x00000001,0x00050051,0x00000006,0x000022d9,
24660x000400fa,0x00002003,0x00002004,0x00002007, 27060x000022d7,0x00000000,0x00050080,0x00000006,
24670x000200f8,0x00002004,0x000400c8,0x00000006, 27070x000022de,0x0000228a,0x000022d8,0x00050050,
24680x00002006,0x00002000,0x000200f9,0x0000200a, 27080x00000007,0x000022df,0x000022d9,0x000022de,
24690x000200f8,0x00002007,0x000500c5,0x00000006, 27090x0004007c,0x00000014,0x000022cf,0x000022df,
24700x00002009,0x00002000,0x0000012d,0x000200f9, 27100x00060041,0x000000db,0x000022c7,0x000022cf,
24710x0000200a,0x000200f8,0x0000200a,0x000700f5, 27110x000000da,0x000000da,0x0005003e,0x000022c7,
24720x00000006,0x00002b0d,0x00002006,0x00002004, 27120x000022bc,0x00000002,0x00000004,0x00050080,
24730x00002009,0x00002007,0x000700ed,0x00000006, 27130x00000006,0x0000223e,0x00002228,0x00000118,
24740x00001fa0,0x00001f9c,0x000000ad,0x000000a3, 27140x00050051,0x00000027,0x00002242,0x000032b1,
24750x00002b0d,0x00060041,0x000000d8,0x00001fa2, 27150x00000000,0x0004007c,0x00000006,0x000022e5,
24760x00001fd9,0x000000d7,0x00000202,0x00050051, 27160x00002242,0x00050095,0x000000ab,0x00002300,
24770x00000027,0x00001fa4,0x00001f91,0x00000002, 27170x00002283,0x0000223e,0x00050051,0x00000006,
24780x0004007c,0x00000006,0x00002011,0x00001fa4, 27180x00002301,0x00002300,0x00000001,0x00050051,
24790x000500c7,0x00000006,0x00002013,0x00002011, 27190x00000006,0x00002302,0x00002300,0x00000000,
24800x0000012d,0x000500ab,0x0000002f,0x00002014, 27200x00050080,0x00000006,0x00002307,0x0000228a,
24810x00002013,0x000000a3,0x000300f7,0x0000201b, 27210x00002301,0x00050050,0x00000007,0x00002308,
24820x00000000,0x000400fa,0x00002014,0x00002015, 27220x00002302,0x00002307,0x0004007c,0x00000014,
24830x00002018,0x000200f8,0x00002015,0x000400c8, 27230x000022f8,0x00002308,0x00060041,0x000000db,
24840x00000006,0x00002017,0x00002011,0x000200f9, 27240x000022f0,0x000022f8,0x000000da,0x000000da,
24850x0000201b,0x000200f8,0x00002018,0x000500c5, 27250x0005003e,0x000022f0,0x000022e5,0x00000002,
24860x00000006,0x0000201a,0x00002011,0x0000012d, 27260x00000004,0x00050080,0x00000006,0x00002245,
24870x000200f9,0x0000201b,0x000200f8,0x0000201b, 27270x00002228,0x0000011f,0x00050051,0x00000027,
24880x000700f5,0x00000006,0x00002b0e,0x00002017, 27280x00002249,0x000032b1,0x00000001,0x0004007c,
24890x00002015,0x0000201a,0x00002018,0x000700ed, 27290x00000006,0x0000230e,0x00002249,0x00050095,
24900x00000006,0x00001fa6,0x00001fa2,0x000000ad, 27300x000000ab,0x00002329,0x00002283,0x00002245,
24910x000000a3,0x00002b0e,0x00060041,0x000000d8, 27310x00050051,0x00000006,0x0000232a,0x00002329,
24920x00001fa8,0x00001fd9,0x000000d7,0x0000020a, 27320x00000001,0x00050051,0x00000006,0x0000232b,
24930x000300f7,0x0000202c,0x00000000,0x000400fa, 27330x00002329,0x00000000,0x00050080,0x00000006,
24940x00001ff2,0x00002026,0x00002029,0x000200f8, 27340x00002330,0x0000228a,0x0000232a,0x00050050,
24950x00002026,0x000400c8,0x00000006,0x00002028, 27350x00000007,0x00002331,0x0000232b,0x00002330,
24960x00001fef,0x000200f9,0x0000202c,0x000200f8, 27360x0004007c,0x00000014,0x00002321,0x00002331,
24970x00002029,0x000500c5,0x00000006,0x0000202b, 27370x00060041,0x000000db,0x00002319,0x00002321,
24980x00001fef,0x0000012d,0x000200f9,0x0000202c, 27380x000000da,0x000000da,0x0005003e,0x00002319,
24990x000200f8,0x0000202c,0x000700f5,0x00000006, 27390x0000230e,0x00000002,0x00000004,0x00050080,
25000x00002b0f,0x00002028,0x00002026,0x0000202b, 27400x00000006,0x0000224c,0x00002228,0x00000189,
25010x00002029,0x000700ef,0x00000006,0x00001fac, 27410x00050051,0x00000027,0x00002250,0x000032b1,
25020x00001fa8,0x000000ad,0x000000a3,0x00002b0f, 27420x00000002,0x0004007c,0x00000006,0x00002337,
25030x00060041,0x000000d8,0x00001fae,0x00001fd9, 27430x00002250,0x00050095,0x000000ab,0x00002352,
25040x000000d7,0x00000212,0x000300f7,0x0000203d, 27440x00002283,0x0000224c,0x00050051,0x00000006,
25050x00000000,0x000400fa,0x00002003,0x00002037, 27450x00002353,0x00002352,0x00000001,0x00050051,
25060x0000203a,0x000200f8,0x00002037,0x000400c8, 27460x00000006,0x00002354,0x00002352,0x00000000,
25070x00000006,0x00002039,0x00002000,0x000200f9, 27470x00050080,0x00000006,0x00002359,0x0000228a,
25080x0000203d,0x000200f8,0x0000203a,0x000500c5, 27480x00002353,0x00050050,0x00000007,0x0000235a,
25090x00000006,0x0000203c,0x00002000,0x0000012d, 27490x00002354,0x00002359,0x0004007c,0x00000014,
25100x000200f9,0x0000203d,0x000200f8,0x0000203d, 27500x0000234a,0x0000235a,0x00060041,0x000000db,
25110x000700f5,0x00000006,0x00002b10,0x00002039, 27510x00002342,0x0000234a,0x000000da,0x000000da,
25120x00002037,0x0000203c,0x0000203a,0x000700ef, 27520x0005003e,0x00002342,0x00002337,0x00000002,
25130x00000006,0x00001fb2,0x00001fae,0x000000ad, 27530x00000004,0x000300f7,0x0000239a,0x00000000,
25140x000000a3,0x00002b10,0x00060041,0x000000d8, 27540x000300fb,0x000000a6,0x00002369,0x000200f8,
25150x00001fb4,0x00001fd9,0x000000d7,0x0000021a, 27550x00002369,0x000500bc,0x0000002f,0x000023a1,
25160x000300f7,0x0000204e,0x00000000,0x000400fa, 27560x0000222d,0x00002242,0x000300f7,0x000023a8,
25170x00002014,0x00002048,0x0000204b,0x000200f8, 27570x00000000,0x000400fa,0x000023a1,0x000023a2,
25180x00002048,0x000400c8,0x00000006,0x0000204a, 27580x000023a8,0x000200f8,0x000023a2,0x000500bc,
25190x00002011,0x000200f9,0x0000204e,0x000200f8, 27590x0000002f,0x000023a7,0x00002234,0x00002249,
25200x0000204b,0x000500c5,0x00000006,0x0000204d, 27600x000200f9,0x000023a8,0x000200f8,0x000023a8,
25210x00002011,0x0000012d,0x000200f9,0x0000204e, 27610x000700f5,0x0000002f,0x000023a9,0x000023a1,
25220x000200f8,0x0000204e,0x000700f5,0x00000006, 27620x00002369,0x000023a7,0x000023a2,0x000300f7,
25230x00002b11,0x0000204a,0x00002048,0x0000204d, 27630x000023b0,0x00000000,0x000400fa,0x000023a9,
25240x0000204b,0x000700ef,0x00000006,0x00001fb8, 27640x000023aa,0x000023b0,0x000200f8,0x000023aa,
25250x00001fb4,0x000000ad,0x000000a3,0x00002b11, 27650x000500bc,0x0000002f,0x000023af,0x0000223b,
25260x000200f9,0x00001fb9,0x000200f8,0x00001fb9, 27660x00002250,0x000200f9,0x000023b0,0x000200f8,
25270x000200f9,0x00000a56,0x000200f8,0x00000a5a, 27670x000023b0,0x000700f5,0x0000002f,0x000023b1,
25280x000500aa,0x0000002f,0x00000a5d,0x000009eb, 27680x000023a9,0x000023a8,0x000023af,0x000023aa,
25290x000002b4,0x000300f7,0x00000a5f,0x00000000, 27690x000400a8,0x0000002f,0x000023b2,0x000023b1,
25300x000400fa,0x00000a5d,0x00000a5e,0x00000a63, 27700x000300f7,0x0000236e,0x00000000,0x000400fa,
25310x000200f8,0x00000a5e,0x00050041,0x000000fb, 27710x000023b2,0x0000236d,0x0000236e,0x000200f8,
25320x00002103,0x000000f9,0x000000fa,0x0004003d, 27720x0000236d,0x000200f9,0x0000239a,0x000200f8,
25330x00000006,0x00002104,0x00002103,0x00050084, 27730x0000236e,0x00050081,0x0000004b,0x00002371,
25340x00000006,0x00002105,0x0000011c,0x00002104, 27740x000032b3,0x000032b1,0x0005008e,0x0000004b,
25350x00050080,0x00000006,0x00002106,0x00000104, 27750x00002372,0x00002371,0x000001ed,0x00050095,
25360x00002105,0x00050080,0x00000006,0x0000210c, 27760x000000ab,0x000023c2,0x00002283,0x000000a6,
25370x00002104,0x00002b67,0x00050086,0x00000006, 27770x00050051,0x00000006,0x000023c3,0x000023c2,
25380x0000210d,0x0000210c,0x000000fe,0x00050084, 27780x00000001,0x00050051,0x00000006,0x000023c4,
25390x00000006,0x000020ff,0x00000104,0x0000210d, 27790x000023c2,0x00000000,0x00050080,0x00000006,
25400x00050080,0x00000006,0x00002100,0x00002106, 27800x000023c9,0x0000228a,0x000023c3,0x00050050,
25410x000020ff,0x00050084,0x00000006,0x000020d4, 27810x00000007,0x000023ca,0x000023c4,0x000023c9,
25420x0000014d,0x000009e9,0x00050080,0x00000006, 27820x0004007c,0x00000014,0x000023ba,0x000023ca,
25430x000020d5,0x00002100,0x000020d4,0x00050041, 27830x00060041,0x000000db,0x00002377,0x000023ba,
25440x00000153,0x000020d6,0x000000f9,0x00000151, 27840x000000da,0x000000da,0x00050051,0x00000027,
25450x0004003d,0x00000007,0x000020d7,0x000020d6, 27850x00002379,0x00002372,0x00000000,0x0004007c,
25460x00050051,0x00000006,0x00002124,0x000020d7, 27860x00000006,0x000023d0,0x00002379,0x000500c7,
25470x00000000,0x00050095,0x000000a8,0x00002126, 27870x00000006,0x000023d2,0x000023d0,0x00000130,
25480x00002124,0x000020d5,0x00050051,0x00000006, 27880x000500ab,0x0000002f,0x000023d3,0x000023d2,
25490x00002127,0x00002126,0x00000001,0x00050051, 27890x000000a6,0x000300f7,0x000023da,0x00000000,
25500x00000006,0x00002128,0x00002126,0x00000000, 27900x000400fa,0x000023d3,0x000023d4,0x000023d7,
25510x00050051,0x00000006,0x0000212b,0x000020d7, 27910x000200f8,0x000023d4,0x000400c8,0x00000006,
25520x00000001,0x00050080,0x00000006,0x0000212d, 27920x000023d6,0x000023d0,0x000200f9,0x000023da,
25530x0000212b,0x00002127,0x00050050,0x00000007, 27930x000200f8,0x000023d7,0x000500c5,0x00000006,
25540x0000212e,0x00002128,0x0000212d,0x0004007c, 27940x000023d9,0x000023d0,0x00000130,0x000200f9,
25550x00000014,0x0000211e,0x0000212e,0x00060041, 27950x000023da,0x000200f8,0x000023da,0x000700f5,
25560x000000d8,0x00002115,0x0000211e,0x000000d7, 27960x00000006,0x00003228,0x000023d6,0x000023d4,
25570x000000d7,0x0006003d,0x00000006,0x00002116, 27970x000023d9,0x000023d7,0x000700ed,0x00000006,
25580x00002115,0x00000002,0x00000004,0x0004007c, 27980x0000237b,0x00002377,0x000000b0,0x000000a6,
25590x00000027,0x000020da,0x00002116,0x00050080, 27990x00003228,0x00060041,0x000000db,0x0000237d,
25600x00000006,0x000020dc,0x000020d5,0x00000107, 28000x000023ba,0x000000da,0x00000154,0x00050051,
25610x00050095,0x000000a8,0x00002147,0x00002124, 28010x00000027,0x0000237f,0x00002372,0x00000001,
25620x000020dc,0x00050051,0x00000006,0x00002148, 28020x0004007c,0x00000006,0x000023e1,0x0000237f,
25630x00002147,0x00000001,0x00050051,0x00000006, 28030x000500c7,0x00000006,0x000023e3,0x000023e1,
25640x00002149,0x00002147,0x00000000,0x00050080, 28040x00000130,0x000500ab,0x0000002f,0x000023e4,
25650x00000006,0x0000214e,0x0000212b,0x00002148, 28050x000023e3,0x000000a6,0x000300f7,0x000023eb,
25660x00050050,0x00000007,0x0000214f,0x00002149, 28060x00000000,0x000400fa,0x000023e4,0x000023e5,
25670x0000214e,0x0004007c,0x00000014,0x0000213f, 28070x000023e8,0x000200f8,0x000023e5,0x000400c8,
25680x0000214f,0x00060041,0x000000d8,0x00002136, 28080x00000006,0x000023e7,0x000023e1,0x000200f9,
25690x0000213f,0x000000d7,0x000000d7,0x0006003d, 28090x000023eb,0x000200f8,0x000023e8,0x000500c5,
25700x00000006,0x00002137,0x00002136,0x00000002, 28100x00000006,0x000023ea,0x000023e1,0x00000130,
25710x00000004,0x0004007c,0x00000027,0x000020e0, 28110x000200f9,0x000023eb,0x000200f8,0x000023eb,
25720x00002137,0x00050080,0x00000006,0x000020e2, 28120x000700f5,0x00000006,0x00003229,0x000023e7,
25730x000020d5,0x0000010e,0x00050095,0x000000a8, 28130x000023e5,0x000023ea,0x000023e8,0x000700ed,
25740x00002168,0x00002124,0x000020e2,0x00050051, 28140x00000006,0x00002381,0x0000237d,0x000000b0,
25750x00000006,0x00002169,0x00002168,0x00000001, 28150x000000a6,0x00003229,0x00060041,0x000000db,
25760x00050051,0x00000006,0x0000216a,0x00002168, 28160x00002383,0x000023ba,0x000000da,0x00000205,
25770x00000000,0x00050080,0x00000006,0x0000216f, 28170x00050051,0x00000027,0x00002385,0x00002372,
25780x0000212b,0x00002169,0x00050050,0x00000007, 28180x00000002,0x0004007c,0x00000006,0x000023f2,
25790x00002170,0x0000216a,0x0000216f,0x0004007c, 28190x00002385,0x000500c7,0x00000006,0x000023f4,
25800x00000014,0x00002160,0x00002170,0x00060041, 28200x000023f2,0x00000130,0x000500ab,0x0000002f,
25810x000000d8,0x00002157,0x00002160,0x000000d7, 28210x000023f5,0x000023f4,0x000000a6,0x000300f7,
25820x000000d7,0x0006003d,0x00000006,0x00002158, 28220x000023fc,0x00000000,0x000400fa,0x000023f5,
25830x00002157,0x00000002,0x00000004,0x0004007c, 28230x000023f6,0x000023f9,0x000200f8,0x000023f6,
25840x00000027,0x000020e6,0x00002158,0x00060050, 28240x000400c8,0x00000006,0x000023f8,0x000023f2,
25850x0000004b,0x000020e7,0x000020da,0x000020e0, 28250x000200f9,0x000023fc,0x000200f8,0x000023f9,
25860x000020e6,0x00050080,0x00000006,0x000020e9, 28260x000500c5,0x00000006,0x000023fb,0x000023f2,
25870x000020d5,0x00000115,0x00050095,0x000000a8, 28270x00000130,0x000200f9,0x000023fc,0x000200f8,
25880x00002189,0x00002124,0x000020e9,0x00050051, 28280x000023fc,0x000700f5,0x00000006,0x0000322a,
25890x00000006,0x0000218a,0x00002189,0x00000001, 28290x000023f8,0x000023f6,0x000023fb,0x000023f9,
25900x00050051,0x00000006,0x0000218b,0x00002189, 28300x000700ed,0x00000006,0x00002387,0x00002383,
25910x00000000,0x00050080,0x00000006,0x00002190, 28310x000000b0,0x000000a6,0x0000322a,0x00060041,
25920x0000212b,0x0000218a,0x00050050,0x00000007, 28320x000000db,0x00002389,0x000023ba,0x000000da,
25930x00002191,0x0000218b,0x00002190,0x0004007c, 28330x0000020d,0x000300f7,0x0000240d,0x00000000,
25940x00000014,0x00002181,0x00002191,0x00060041, 28340x000400fa,0x000023d3,0x00002407,0x0000240a,
25950x000000d8,0x00002178,0x00002181,0x000000d7, 28350x000200f8,0x00002407,0x000400c8,0x00000006,
25960x000000d7,0x0006003d,0x00000006,0x00002179, 28360x00002409,0x000023d0,0x000200f9,0x0000240d,
25970x00002178,0x00000002,0x00000004,0x0004007c, 28370x000200f8,0x0000240a,0x000500c5,0x00000006,
25980x00000027,0x000020ed,0x00002179,0x00050080, 28380x0000240c,0x000023d0,0x00000130,0x000200f9,
25990x00000006,0x000020ef,0x000020d5,0x0000011c, 28390x0000240d,0x000200f8,0x0000240d,0x000700f5,
26000x00050095,0x000000a8,0x000021aa,0x00002124, 28400x00000006,0x0000322b,0x00002409,0x00002407,
26010x000020ef,0x00050051,0x00000006,0x000021ab, 28410x0000240c,0x0000240a,0x000700ef,0x00000006,
26020x000021aa,0x00000001,0x00050051,0x00000006, 28420x0000238d,0x00002389,0x000000b0,0x000000a6,
26030x000021ac,0x000021aa,0x00000000,0x00050080, 28430x0000322b,0x00060041,0x000000db,0x0000238f,
26040x00000006,0x000021b1,0x0000212b,0x000021ab, 28440x000023ba,0x000000da,0x00000215,0x000300f7,
26050x00050050,0x00000007,0x000021b2,0x000021ac, 28450x0000241e,0x00000000,0x000400fa,0x000023e4,
26060x000021b1,0x0004007c,0x00000014,0x000021a2, 28460x00002418,0x0000241b,0x000200f8,0x00002418,
26070x000021b2,0x00060041,0x000000d8,0x00002199, 28470x000400c8,0x00000006,0x0000241a,0x000023e1,
26080x000021a2,0x000000d7,0x000000d7,0x0006003d, 28480x000200f9,0x0000241e,0x000200f8,0x0000241b,
26090x00000006,0x0000219a,0x00002199,0x00000002, 28490x000500c5,0x00000006,0x0000241d,0x000023e1,
26100x00000004,0x0004007c,0x00000027,0x000020f3, 28500x00000130,0x000200f9,0x0000241e,0x000200f8,
26110x0000219a,0x00050080,0x00000006,0x000020f5, 28510x0000241e,0x000700f5,0x00000006,0x0000322c,
26120x000020d5,0x00000186,0x00050095,0x000000a8, 28520x0000241a,0x00002418,0x0000241d,0x0000241b,
26130x000021cb,0x00002124,0x000020f5,0x00050051, 28530x000700ef,0x00000006,0x00002393,0x0000238f,
26140x00000006,0x000021cc,0x000021cb,0x00000001, 28540x000000b0,0x000000a6,0x0000322c,0x00060041,
26150x00050051,0x00000006,0x000021cd,0x000021cb, 28550x000000db,0x00002395,0x000023ba,0x000000da,
26160x00000000,0x00050080,0x00000006,0x000021d2, 28560x0000021d,0x000300f7,0x0000242f,0x00000000,
26170x0000212b,0x000021cc,0x00050050,0x00000007, 28570x000400fa,0x000023f5,0x00002429,0x0000242c,
26180x000021d3,0x000021cd,0x000021d2,0x0004007c, 28580x000200f8,0x00002429,0x000400c8,0x00000006,
26190x00000014,0x000021c3,0x000021d3,0x00060041, 28590x0000242b,0x000023f2,0x000200f9,0x0000242f,
26200x000000d8,0x000021ba,0x000021c3,0x000000d7, 28600x000200f8,0x0000242c,0x000500c5,0x00000006,
26210x000000d7,0x0006003d,0x00000006,0x000021bb, 28610x0000242e,0x000023f2,0x00000130,0x000200f9,
26220x000021ba,0x00000002,0x00000004,0x0004007c, 28620x0000242f,0x000200f8,0x0000242f,0x000700f5,
26230x00000027,0x000020f9,0x000021bb,0x00060050, 28630x00000006,0x0000322d,0x0000242b,0x00002429,
26240x0000004b,0x000020fa,0x000020ed,0x000020f3, 28640x0000242e,0x0000242c,0x000700ef,0x00000006,
26250x000020f9,0x000500bc,0x0000002f,0x000021da, 28650x00002399,0x00002395,0x000000b0,0x000000a6,
26260x000020da,0x000020ed,0x000300f7,0x000021e1, 28660x0000322d,0x000200f9,0x0000239a,0x000200f8,
26270x00000000,0x000400fa,0x000021da,0x000021db, 28670x0000239a,0x000200f9,0x00000bdb,0x000200f8,
26280x000021e1,0x000200f8,0x000021db,0x000500bc, 28680x00000bdf,0x000500aa,0x0000002f,0x00000be2,
26290x0000002f,0x000021e0,0x000020e0,0x000020f3, 28690x00000b13,0x000002b7,0x000300f7,0x00000be4,
26300x000200f9,0x000021e1,0x000200f8,0x000021e1, 28700x00000000,0x000400fa,0x00000be2,0x00000be3,
26310x000700f5,0x0000002f,0x000021e2,0x000021da, 28710x00000be8,0x000200f8,0x00000be3,0x00050041,
26320x00000a5e,0x000021e0,0x000021db,0x000300f7, 28720x000000fe,0x000024e4,0x000000fc,0x000000fd,
26330x000021e9,0x00000000,0x000400fa,0x000021e2, 28730x0004003d,0x00000006,0x000024e5,0x000024e4,
26340x000021e3,0x000021e9,0x000200f8,0x000021e3, 28740x00050084,0x00000006,0x000024e6,0x0000011f,
26350x000500bc,0x0000002f,0x000021e8,0x000020e6, 28750x000024e5,0x00050080,0x00000006,0x000024e7,
26360x000020f9,0x000200f9,0x000021e9,0x000200f8, 28760x00000107,0x000024e6,0x00050080,0x00000006,
26370x000021e9,0x000700f5,0x0000002f,0x000021ea, 28770x000024ed,0x000024e5,0x000032a8,0x00050086,
26380x000021e2,0x000021e1,0x000021e8,0x000021e3, 28780x00000006,0x000024ee,0x000024ed,0x00000101,
26390x000300f7,0x000020b3,0x00000000,0x000400fa, 28790x00050084,0x00000006,0x000024e0,0x00000107,
26400x000021ea,0x00002077,0x000020b3,0x000200f8, 28800x000024ee,0x00050080,0x00000006,0x000024e1,
26410x00002077,0x00050095,0x000000a8,0x000021fb, 28810x000024e7,0x000024e0,0x00050084,0x00000006,
26420x00002124,0x000000a3,0x00050051,0x00000006, 28820x000024b5,0x00000150,0x00000b11,0x00050080,
26430x000021fc,0x000021fb,0x00000001,0x00050051, 28830x00000006,0x000024b6,0x000024e1,0x000024b5,
26440x00000006,0x000021fd,0x000021fb,0x00000000, 28840x00050041,0x00000156,0x000024b7,0x000000fc,
26450x00050080,0x00000006,0x00002202,0x0000212b, 28850x00000154,0x0004003d,0x00000007,0x000024b8,
26460x000021fc,0x00050050,0x00000007,0x00002203, 28860x000024b7,0x00050051,0x00000006,0x00002505,
26470x000021fd,0x00002202,0x0004007c,0x00000014, 28870x000024b8,0x00000000,0x00050095,0x000000ab,
26480x000021f3,0x00002203,0x00060041,0x000000d8, 28880x00002507,0x00002505,0x000024b6,0x00050051,
26490x0000207c,0x000021f3,0x000000d7,0x000000d7, 28890x00000006,0x00002508,0x00002507,0x00000001,
26500x0006003d,0x00000006,0x0000207d,0x0000207c, 28900x00050051,0x00000006,0x00002509,0x00002507,
28910x00000000,0x00050051,0x00000006,0x0000250c,
28920x000024b8,0x00000001,0x00050080,0x00000006,
28930x0000250e,0x0000250c,0x00002508,0x00050050,
28940x00000007,0x0000250f,0x00002509,0x0000250e,
28950x0004007c,0x00000014,0x000024ff,0x0000250f,
28960x00060041,0x000000db,0x000024f6,0x000024ff,
28970x000000da,0x000000da,0x0006003d,0x00000006,
28980x000024f7,0x000024f6,0x00000002,0x00000004,
28990x0004007c,0x00000027,0x000024bb,0x000024f7,
29000x00050080,0x00000006,0x000024bd,0x000024b6,
29010x0000010a,0x00050095,0x000000ab,0x00002528,
29020x00002505,0x000024bd,0x00050051,0x00000006,
29030x00002529,0x00002528,0x00000001,0x00050051,
29040x00000006,0x0000252a,0x00002528,0x00000000,
29050x00050080,0x00000006,0x0000252f,0x0000250c,
29060x00002529,0x00050050,0x00000007,0x00002530,
29070x0000252a,0x0000252f,0x0004007c,0x00000014,
29080x00002520,0x00002530,0x00060041,0x000000db,
29090x00002517,0x00002520,0x000000da,0x000000da,
29100x0006003d,0x00000006,0x00002518,0x00002517,
29110x00000002,0x00000004,0x0004007c,0x00000027,
29120x000024c1,0x00002518,0x00050080,0x00000006,
29130x000024c3,0x000024b6,0x00000111,0x00050095,
29140x000000ab,0x00002549,0x00002505,0x000024c3,
29150x00050051,0x00000006,0x0000254a,0x00002549,
29160x00000001,0x00050051,0x00000006,0x0000254b,
29170x00002549,0x00000000,0x00050080,0x00000006,
29180x00002550,0x0000250c,0x0000254a,0x00050050,
29190x00000007,0x00002551,0x0000254b,0x00002550,
29200x0004007c,0x00000014,0x00002541,0x00002551,
29210x00060041,0x000000db,0x00002538,0x00002541,
29220x000000da,0x000000da,0x0006003d,0x00000006,
29230x00002539,0x00002538,0x00000002,0x00000004,
29240x0004007c,0x00000027,0x000024c7,0x00002539,
29250x00060050,0x0000004b,0x000024c8,0x000024bb,
29260x000024c1,0x000024c7,0x00050080,0x00000006,
29270x000024ca,0x000024b6,0x00000118,0x00050095,
29280x000000ab,0x0000256a,0x00002505,0x000024ca,
29290x00050051,0x00000006,0x0000256b,0x0000256a,
29300x00000001,0x00050051,0x00000006,0x0000256c,
29310x0000256a,0x00000000,0x00050080,0x00000006,
29320x00002571,0x0000250c,0x0000256b,0x00050050,
29330x00000007,0x00002572,0x0000256c,0x00002571,
29340x0004007c,0x00000014,0x00002562,0x00002572,
29350x00060041,0x000000db,0x00002559,0x00002562,
29360x000000da,0x000000da,0x0006003d,0x00000006,
29370x0000255a,0x00002559,0x00000002,0x00000004,
29380x0004007c,0x00000027,0x000024ce,0x0000255a,
29390x00050080,0x00000006,0x000024d0,0x000024b6,
29400x0000011f,0x00050095,0x000000ab,0x0000258b,
29410x00002505,0x000024d0,0x00050051,0x00000006,
29420x0000258c,0x0000258b,0x00000001,0x00050051,
29430x00000006,0x0000258d,0x0000258b,0x00000000,
29440x00050080,0x00000006,0x00002592,0x0000250c,
29450x0000258c,0x00050050,0x00000007,0x00002593,
29460x0000258d,0x00002592,0x0004007c,0x00000014,
29470x00002583,0x00002593,0x00060041,0x000000db,
29480x0000257a,0x00002583,0x000000da,0x000000da,
29490x0006003d,0x00000006,0x0000257b,0x0000257a,
29500x00000002,0x00000004,0x0004007c,0x00000027,
29510x000024d4,0x0000257b,0x00050080,0x00000006,
29520x000024d6,0x000024b6,0x00000189,0x00050095,
29530x000000ab,0x000025ac,0x00002505,0x000024d6,
29540x00050051,0x00000006,0x000025ad,0x000025ac,
29550x00000001,0x00050051,0x00000006,0x000025ae,
29560x000025ac,0x00000000,0x00050080,0x00000006,
29570x000025b3,0x0000250c,0x000025ad,0x00050050,
29580x00000007,0x000025b4,0x000025ae,0x000025b3,
29590x0004007c,0x00000014,0x000025a4,0x000025b4,
29600x00060041,0x000000db,0x0000259b,0x000025a4,
29610x000000da,0x000000da,0x0006003d,0x00000006,
29620x0000259c,0x0000259b,0x00000002,0x00000004,
29630x0004007c,0x00000027,0x000024da,0x0000259c,
29640x00060050,0x0000004b,0x000024db,0x000024ce,
29650x000024d4,0x000024da,0x000500bc,0x0000002f,
29660x000025bb,0x000024bb,0x000024ce,0x000300f7,
29670x000025c2,0x00000000,0x000400fa,0x000025bb,
29680x000025bc,0x000025c2,0x000200f8,0x000025bc,
29690x000500bc,0x0000002f,0x000025c1,0x000024c1,
29700x000024d4,0x000200f9,0x000025c2,0x000200f8,
29710x000025c2,0x000700f5,0x0000002f,0x000025c3,
29720x000025bb,0x00000be3,0x000025c1,0x000025bc,
29730x000300f7,0x000025ca,0x00000000,0x000400fa,
29740x000025c3,0x000025c4,0x000025ca,0x000200f8,
29750x000025c4,0x000500bc,0x0000002f,0x000025c9,
29760x000024c7,0x000024da,0x000200f9,0x000025ca,
29770x000200f8,0x000025ca,0x000700f5,0x0000002f,
29780x000025cb,0x000025c3,0x000025c2,0x000025c9,
29790x000025c4,0x000300f7,0x00002494,0x00000000,
29800x000400fa,0x000025cb,0x00002458,0x00002494,
29810x000200f8,0x00002458,0x00050095,0x000000ab,
29820x000025dc,0x00002505,0x000000a6,0x00050051,
29830x00000006,0x000025dd,0x000025dc,0x00000001,
29840x00050051,0x00000006,0x000025de,0x000025dc,
29850x00000000,0x00050080,0x00000006,0x000025e3,
29860x0000250c,0x000025dd,0x00050050,0x00000007,
29870x000025e4,0x000025de,0x000025e3,0x0004007c,
29880x00000014,0x000025d4,0x000025e4,0x00060041,
29890x000000db,0x0000245d,0x000025d4,0x000000da,
29900x000000da,0x0006003d,0x00000006,0x0000245e,
29910x0000245d,0x00000002,0x00000004,0x000500c7,
29920x00000006,0x000025e9,0x0000245e,0x00000130,
29930x000500ab,0x0000002f,0x000025ea,0x000025e9,
29940x000000a6,0x000300f7,0x000025f1,0x00000000,
29950x000400fa,0x000025ea,0x000025eb,0x000025ee,
29960x000200f8,0x000025eb,0x000500c7,0x00000006,
29970x000025ed,0x0000245e,0x00000145,0x000200f9,
29980x000025f1,0x000200f8,0x000025ee,0x000400c8,
29990x00000006,0x000025f0,0x0000245e,0x000200f9,
30000x000025f1,0x000200f8,0x000025f1,0x000700f5,
30010x00000006,0x000031e7,0x000025ed,0x000025eb,
30020x000025f0,0x000025ee,0x0004007c,0x00000027,
30030x000025f3,0x000031e7,0x00060041,0x000000db,
30040x00002461,0x000025d4,0x000000da,0x00000154,
30050x0006003d,0x00000006,0x00002462,0x00002461,
30060x00000002,0x00000004,0x000500c7,0x00000006,
30070x000025f8,0x00002462,0x00000130,0x000500ab,
30080x0000002f,0x000025f9,0x000025f8,0x000000a6,
30090x000300f7,0x00002600,0x00000000,0x000400fa,
30100x000025f9,0x000025fa,0x000025fd,0x000200f8,
30110x000025fa,0x000500c7,0x00000006,0x000025fc,
30120x00002462,0x00000145,0x000200f9,0x00002600,
30130x000200f8,0x000025fd,0x000400c8,0x00000006,
30140x000025ff,0x00002462,0x000200f9,0x00002600,
30150x000200f8,0x00002600,0x000700f5,0x00000006,
30160x000031e8,0x000025fc,0x000025fa,0x000025ff,
30170x000025fd,0x0004007c,0x00000027,0x00002602,
30180x000031e8,0x00060041,0x000000db,0x00002465,
30190x000025d4,0x000000da,0x00000205,0x0006003d,
30200x00000006,0x00002466,0x00002465,0x00000002,
30210x00000004,0x000500c7,0x00000006,0x00002607,
30220x00002466,0x00000130,0x000500ab,0x0000002f,
30230x00002608,0x00002607,0x000000a6,0x000300f7,
30240x0000260f,0x00000000,0x000400fa,0x00002608,
30250x00002609,0x0000260c,0x000200f8,0x00002609,
30260x000500c7,0x00000006,0x0000260b,0x00002466,
30270x00000145,0x000200f9,0x0000260f,0x000200f8,
30280x0000260c,0x000400c8,0x00000006,0x0000260e,
30290x00002466,0x000200f9,0x0000260f,0x000200f8,
30300x0000260f,0x000700f5,0x00000006,0x000031e9,
30310x0000260b,0x00002609,0x0000260e,0x0000260c,
30320x0004007c,0x00000027,0x00002611,0x000031e9,
30330x00060050,0x0000004b,0x00002468,0x000025f3,
30340x00002602,0x00002611,0x00060041,0x000000db,
30350x0000246a,0x000025d4,0x000000da,0x0000020d,
30360x0006003d,0x00000006,0x0000246b,0x0000246a,
26510x00000002,0x00000004,0x000500c7,0x00000006, 30370x00000002,0x00000004,0x000500c7,0x00000006,
26520x00002208,0x0000207d,0x0000012d,0x000500ab, 30380x00002616,0x0000246b,0x00000130,0x000500ab,
26530x0000002f,0x00002209,0x00002208,0x000000a3, 30390x0000002f,0x00002617,0x00002616,0x000000a6,
26540x000300f7,0x00002210,0x00000000,0x000400fa, 30400x000300f7,0x0000261e,0x00000000,0x000400fa,
26550x00002209,0x0000220a,0x0000220d,0x000200f8, 30410x00002617,0x00002618,0x0000261b,0x000200f8,
26560x0000220a,0x000500c7,0x00000006,0x0000220c, 30420x00002618,0x000500c7,0x00000006,0x0000261a,
26570x0000207d,0x00000142,0x000200f9,0x00002210, 30430x0000246b,0x00000145,0x000200f9,0x0000261e,
26580x000200f8,0x0000220d,0x000400c8,0x00000006, 30440x000200f8,0x0000261b,0x000400c8,0x00000006,
26590x0000220f,0x0000207d,0x000200f9,0x00002210, 30450x0000261d,0x0000246b,0x000200f9,0x0000261e,
26600x000200f8,0x00002210,0x000700f5,0x00000006, 30460x000200f8,0x0000261e,0x000700f5,0x00000006,
26610x00002acb,0x0000220c,0x0000220a,0x0000220f, 30470x000031ea,0x0000261a,0x00002618,0x0000261d,
26620x0000220d,0x0004007c,0x00000027,0x00002212, 30480x0000261b,0x0004007c,0x00000027,0x00002620,
26630x00002acb,0x00060041,0x000000d8,0x00002080, 30490x000031ea,0x00060041,0x000000db,0x0000246e,
26640x000021f3,0x000000d7,0x00000151,0x0006003d, 30500x000025d4,0x000000da,0x00000215,0x0006003d,
26650x00000006,0x00002081,0x00002080,0x00000002, 30510x00000006,0x0000246f,0x0000246e,0x00000002,
26660x00000004,0x000500c7,0x00000006,0x00002217, 30520x00000004,0x000500c7,0x00000006,0x00002625,
26670x00002081,0x0000012d,0x000500ab,0x0000002f, 30530x0000246f,0x00000130,0x000500ab,0x0000002f,
26680x00002218,0x00002217,0x000000a3,0x000300f7, 30540x00002626,0x00002625,0x000000a6,0x000300f7,
26690x0000221f,0x00000000,0x000400fa,0x00002218, 30550x0000262d,0x00000000,0x000400fa,0x00002626,
26700x00002219,0x0000221c,0x000200f8,0x00002219, 30560x00002627,0x0000262a,0x000200f8,0x00002627,
26710x000500c7,0x00000006,0x0000221b,0x00002081, 30570x000500c7,0x00000006,0x00002629,0x0000246f,
26720x00000142,0x000200f9,0x0000221f,0x000200f8, 30580x00000145,0x000200f9,0x0000262d,0x000200f8,
26730x0000221c,0x000400c8,0x00000006,0x0000221e, 30590x0000262a,0x000400c8,0x00000006,0x0000262c,
26740x00002081,0x000200f9,0x0000221f,0x000200f8, 30600x0000246f,0x000200f9,0x0000262d,0x000200f8,
26750x0000221f,0x000700f5,0x00000006,0x00002acc, 30610x0000262d,0x000700f5,0x00000006,0x000031eb,
26760x0000221b,0x00002219,0x0000221e,0x0000221c, 30620x00002629,0x00002627,0x0000262c,0x0000262a,
26770x0004007c,0x00000027,0x00002221,0x00002acc, 30630x0004007c,0x00000027,0x0000262f,0x000031eb,
26780x00060041,0x000000d8,0x00002084,0x000021f3, 30640x00060041,0x000000db,0x00002472,0x000025d4,
26790x000000d7,0x00000202,0x0006003d,0x00000006, 30650x000000da,0x0000021d,0x0006003d,0x00000006,
26800x00002085,0x00002084,0x00000002,0x00000004, 30660x00002473,0x00002472,0x00000002,0x00000004,
26810x000500c7,0x00000006,0x00002226,0x00002085, 30670x000500c7,0x00000006,0x00002634,0x00002473,
26820x0000012d,0x000500ab,0x0000002f,0x00002227, 30680x00000130,0x000500ab,0x0000002f,0x00002635,
26830x00002226,0x000000a3,0x000300f7,0x0000222e, 30690x00002634,0x000000a6,0x000300f7,0x0000263c,
26840x00000000,0x000400fa,0x00002227,0x00002228, 30700x00000000,0x000400fa,0x00002635,0x00002636,
26850x0000222b,0x000200f8,0x00002228,0x000500c7, 30710x00002639,0x000200f8,0x00002636,0x000500c7,
26860x00000006,0x0000222a,0x00002085,0x00000142, 30720x00000006,0x00002638,0x00002473,0x00000145,
26870x000200f9,0x0000222e,0x000200f8,0x0000222b, 30730x000200f9,0x0000263c,0x000200f8,0x00002639,
26880x000400c8,0x00000006,0x0000222d,0x00002085, 30740x000400c8,0x00000006,0x0000263b,0x00002473,
26890x000200f9,0x0000222e,0x000200f8,0x0000222e, 30750x000200f9,0x0000263c,0x000200f8,0x0000263c,
26900x000700f5,0x00000006,0x00002acd,0x0000222a, 30760x000700f5,0x00000006,0x000031ec,0x00002638,
26910x00002228,0x0000222d,0x0000222b,0x0004007c, 30770x00002636,0x0000263b,0x00002639,0x0004007c,
26920x00000027,0x00002230,0x00002acd,0x00060050, 30780x00000027,0x0000263e,0x000031ec,0x00060050,
26930x0000004b,0x00002087,0x00002212,0x00002221, 30790x0000004b,0x00002475,0x00002620,0x0000262f,
26940x00002230,0x00060041,0x000000d8,0x00002089, 30800x0000263e,0x00050083,0x0000004b,0x00002478,
26950x000021f3,0x000000d7,0x0000020a,0x0006003d, 30810x00002475,0x00002468,0x0007000c,0x0000004b,
26960x00000006,0x0000208a,0x00002089,0x00000002, 30820x00002479,0x00000001,0x00000028,0x00002478,
26970x00000004,0x000500c7,0x00000006,0x00002235, 30830x0000065b,0x00050081,0x0000004b,0x0000247c,
26980x0000208a,0x0000012d,0x000500ab,0x0000002f, 30840x000024c8,0x000024db,0x0005008e,0x0000004b,
26990x00002236,0x00002235,0x000000a3,0x000300f7, 30850x0000247d,0x0000247c,0x000001ed,0x00050083,
27000x0000223d,0x00000000,0x000400fa,0x00002236, 30860x0000004b,0x0000247f,0x0000247d,0x00002468,
27010x00002237,0x0000223a,0x000200f8,0x00002237, 30870x00050088,0x0000004b,0x00002481,0x0000247f,
27020x000500c7,0x00000006,0x00002239,0x0000208a, 30880x00002479,0x0008000c,0x0000004b,0x00002484,
27030x00000142,0x000200f9,0x0000223d,0x000200f8, 30890x00000001,0x0000002b,0x00002481,0x00000570,
27040x0000223a,0x000400c8,0x00000006,0x0000223c, 30900x000032a2,0x0005008e,0x0000004b,0x00002485,
27050x0000208a,0x000200f9,0x0000223d,0x000200f8, 30910x00002484,0x0000066b,0x0004006d,0x0000065d,
27060x0000223d,0x000700f5,0x00000006,0x00002ace, 30920x00002486,0x00002485,0x00050051,0x00000006,
27070x00002239,0x00002237,0x0000223c,0x0000223a, 30930x00002488,0x00002486,0x00000000,0x000500c7,
27080x0004007c,0x00000027,0x0000223f,0x00002ace, 30940x00000006,0x00002642,0x00002488,0x000005fe,
27090x00060041,0x000000d8,0x0000208d,0x000021f3, 30950x000500c4,0x00000006,0x00002645,0x00002642,
27100x000000d7,0x00000212,0x0006003d,0x00000006, 30960x0000023e,0x000500c5,0x00000006,0x00002646,
27110x0000208e,0x0000208d,0x00000002,0x00000004, 30970x00002642,0x00002645,0x000500c7,0x00000006,
27120x000500c7,0x00000006,0x00002244,0x0000208e, 30980x00002647,0x00002646,0x00000605,0x000500c4,
27130x0000012d,0x000500ab,0x0000002f,0x00002245, 30990x00000006,0x0000264a,0x00002647,0x00000308,
27140x00002244,0x000000a3,0x000300f7,0x0000224c, 31000x000500c5,0x00000006,0x0000264b,0x00002647,
27150x00000000,0x000400fa,0x00002245,0x00002246, 31010x0000264a,0x000500c7,0x00000006,0x0000264c,
27160x00002249,0x000200f8,0x00002246,0x000500c7, 31020x0000264b,0x0000060b,0x000500c4,0x00000006,
27170x00000006,0x00002248,0x0000208e,0x00000142, 31030x0000264f,0x0000264c,0x00000215,0x000500c5,
27180x000200f9,0x0000224c,0x000200f8,0x00002249, 31040x00000006,0x00002650,0x0000264c,0x0000264f,
27190x000400c8,0x00000006,0x0000224b,0x0000208e, 31050x000500c7,0x00000006,0x00002651,0x00002650,
27200x000200f9,0x0000224c,0x000200f8,0x0000224c, 31060x00000611,0x000500c4,0x00000006,0x00002654,
27210x000700f5,0x00000006,0x00002acf,0x00002248, 31070x00002651,0x00000205,0x000500c5,0x00000006,
27220x00002246,0x0000224b,0x00002249,0x0004007c, 31080x00002655,0x00002651,0x00002654,0x000500c7,
27230x00000027,0x0000224e,0x00002acf,0x00060041, 31090x00000006,0x00002656,0x00002655,0x00000617,
27240x000000d8,0x00002091,0x000021f3,0x000000d7, 31100x000500c4,0x00000006,0x0000248a,0x00002656,
27250x0000021a,0x0006003d,0x00000006,0x00002092, 31110x00000205,0x00050051,0x00000006,0x0000248c,
27260x00002091,0x00000002,0x00000004,0x000500c7, 31120x00002486,0x00000001,0x000500c7,0x00000006,
27270x00000006,0x00002253,0x00002092,0x0000012d, 31130x0000265b,0x0000248c,0x000005fe,0x000500c4,
27280x000500ab,0x0000002f,0x00002254,0x00002253, 31140x00000006,0x0000265e,0x0000265b,0x0000023e,
27290x000000a3,0x000300f7,0x0000225b,0x00000000, 31150x000500c5,0x00000006,0x0000265f,0x0000265b,
27300x000400fa,0x00002254,0x00002255,0x00002258, 31160x0000265e,0x000500c7,0x00000006,0x00002660,
27310x000200f8,0x00002255,0x000500c7,0x00000006, 31170x0000265f,0x00000605,0x000500c4,0x00000006,
27320x00002257,0x00002092,0x00000142,0x000200f9, 31180x00002663,0x00002660,0x00000308,0x000500c5,
27330x0000225b,0x000200f8,0x00002258,0x000400c8, 31190x00000006,0x00002664,0x00002660,0x00002663,
27340x00000006,0x0000225a,0x00002092,0x000200f9, 31200x000500c7,0x00000006,0x00002665,0x00002664,
27350x0000225b,0x000200f8,0x0000225b,0x000700f5, 31210x0000060b,0x000500c4,0x00000006,0x00002668,
27360x00000006,0x00002ad0,0x00002257,0x00002255, 31220x00002665,0x00000215,0x000500c5,0x00000006,
27370x0000225a,0x00002258,0x0004007c,0x00000027, 31230x00002669,0x00002665,0x00002668,0x000500c7,
27380x0000225d,0x00002ad0,0x00060050,0x0000004b, 31240x00000006,0x0000266a,0x00002669,0x00000611,
27390x00002094,0x0000223f,0x0000224e,0x0000225d, 31250x000500c4,0x00000006,0x0000266d,0x0000266a,
27400x00050083,0x0000004b,0x00002097,0x00002094, 31260x00000205,0x000500c5,0x00000006,0x0000266e,
27410x00002087,0x0007000c,0x0000004b,0x00002098, 31270x0000266a,0x0000266d,0x000500c7,0x00000006,
27420x00000001,0x00000028,0x00002097,0x00000658, 31280x0000266f,0x0000266e,0x00000617,0x000500c4,
27430x00050081,0x0000004b,0x0000209b,0x000020e7, 31290x00000006,0x0000248e,0x0000266f,0x00000154,
27440x000020fa,0x0005008e,0x0000004b,0x0000209c, 31300x000500c5,0x00000006,0x0000248f,0x0000248a,
27450x0000209b,0x000001ea,0x00050083,0x0000004b, 31310x0000248e,0x00050051,0x00000006,0x00002491,
27460x0000209e,0x0000209c,0x00002087,0x00050088, 31320x00002486,0x00000002,0x000500c7,0x00000006,
27470x0000004b,0x000020a0,0x0000209e,0x00002098, 31330x00002674,0x00002491,0x000005fe,0x000500c4,
27480x0008000c,0x0000004b,0x000020a3,0x00000001, 31340x00000006,0x00002677,0x00002674,0x0000023e,
27490x0000002b,0x000020a0,0x0000056d,0x00002b61, 31350x000500c5,0x00000006,0x00002678,0x00002674,
27500x0005008e,0x0000004b,0x000020a4,0x000020a3, 31360x00002677,0x000500c7,0x00000006,0x00002679,
27510x00000668,0x0004006d,0x0000065a,0x000020a5, 31370x00002678,0x00000605,0x000500c4,0x00000006,
27520x000020a4,0x00050051,0x00000006,0x000020a7, 31380x0000267c,0x00002679,0x00000308,0x000500c5,
27530x000020a5,0x00000000,0x000500c7,0x00000006, 31390x00000006,0x0000267d,0x00002679,0x0000267c,
27540x00002261,0x000020a7,0x000005fb,0x000500c4, 31400x000500c7,0x00000006,0x0000267e,0x0000267d,
27550x00000006,0x00002264,0x00002261,0x0000023b, 31410x0000060b,0x000500c4,0x00000006,0x00002681,
27560x000500c5,0x00000006,0x00002265,0x00002261, 31420x0000267e,0x00000215,0x000500c5,0x00000006,
27570x00002264,0x000500c7,0x00000006,0x00002266, 31430x00002682,0x0000267e,0x00002681,0x000500c7,
27580x00002265,0x00000602,0x000500c4,0x00000006, 31440x00000006,0x00002683,0x00002682,0x00000611,
27590x00002269,0x00002266,0x00000305,0x000500c5, 31450x000500c4,0x00000006,0x00002686,0x00002683,
27600x00000006,0x0000226a,0x00002266,0x00002269, 31460x00000205,0x000500c5,0x00000006,0x00002687,
27610x000500c7,0x00000006,0x0000226b,0x0000226a, 31470x00002683,0x00002686,0x000500c7,0x00000006,
27620x00000608,0x000500c4,0x00000006,0x0000226e, 31480x00002688,0x00002687,0x00000617,0x000500c5,
27630x0000226b,0x00000212,0x000500c5,0x00000006, 31490x00000006,0x00002493,0x0000248f,0x00002688,
27640x0000226f,0x0000226b,0x0000226e,0x000500c7, 31500x000200f9,0x00002494,0x000200f8,0x00002494,
27650x00000006,0x00002270,0x0000226f,0x0000060e, 31510x000700f5,0x00000006,0x000031ed,0x00000531,
27660x000500c4,0x00000006,0x00002273,0x00002270, 31520x000025ca,0x00002493,0x0000263c,0x00050084,
27670x00000202,0x000500c5,0x00000006,0x00002274, 31530x00000006,0x00002497,0x0000010a,0x00000b11,
27680x00002270,0x00002273,0x000500c7,0x00000006, 31540x00050080,0x00000006,0x00002498,0x00000107,
27690x00002275,0x00002274,0x00000614,0x000500c4, 31550x00002497,0x00050095,0x000000ab,0x000026a3,
27700x00000006,0x000020a9,0x00002275,0x00000202, 31560x00002505,0x00002498,0x00050051,0x00000006,
27710x00050051,0x00000006,0x000020ab,0x000020a5, 31570x000026a4,0x000026a3,0x00000001,0x00050051,
27720x00000001,0x000500c7,0x00000006,0x0000227a, 31580x00000006,0x000026a5,0x000026a3,0x00000000,
27730x000020ab,0x000005fb,0x000500c4,0x00000006, 31590x00050080,0x00000006,0x000026aa,0x0000250c,
27740x0000227d,0x0000227a,0x0000023b,0x000500c5, 31600x000026a4,0x00050050,0x00000007,0x000026ab,
27750x00000006,0x0000227e,0x0000227a,0x0000227d, 31610x000026a5,0x000026aa,0x0004007c,0x00000014,
27760x000500c7,0x00000006,0x0000227f,0x0000227e, 31620x0000269b,0x000026ab,0x00060041,0x000000db,
27770x00000602,0x000500c4,0x00000006,0x00002282, 31630x00002693,0x0000269b,0x000000da,0x000000da,
27780x0000227f,0x00000305,0x000500c5,0x00000006, 31640x0005003e,0x00002693,0x000031ed,0x00000002,
27790x00002283,0x0000227f,0x00002282,0x000500c7, 31650x00000004,0x00050084,0x00000006,0x000026b0,
27800x00000006,0x00002284,0x00002283,0x00000608, 31660x0000010a,0x000024e5,0x00050080,0x00000006,
27810x000500c4,0x00000006,0x00002287,0x00002284, 31670x000026b1,0x00000107,0x000026b0,0x00050080,
27820x00000212,0x000500c5,0x00000006,0x00002288, 31680x00000006,0x000024a0,0x000026b1,0x00002497,
27830x00002284,0x00002287,0x000500c7,0x00000006, 31690x00050095,0x000000ab,0x000026c9,0x00002505,
27840x00002289,0x00002288,0x0000060e,0x000500c4, 31700x000024a0,0x00050051,0x00000006,0x000026ca,
27850x00000006,0x0000228c,0x00002289,0x00000202, 31710x000026c9,0x00000001,0x00050051,0x00000006,
27860x000500c5,0x00000006,0x0000228d,0x00002289, 31720x000026cb,0x000026c9,0x00000000,0x00050080,
27870x0000228c,0x000500c7,0x00000006,0x0000228e, 31730x00000006,0x000026d0,0x0000250c,0x000026ca,
27880x0000228d,0x00000614,0x000500c4,0x00000006, 31740x00050050,0x00000007,0x000026d1,0x000026cb,
27890x000020ad,0x0000228e,0x00000151,0x000500c5, 31750x000026d0,0x0004007c,0x00000014,0x000026c1,
27900x00000006,0x000020ae,0x000020a9,0x000020ad, 31760x000026d1,0x00060041,0x000000db,0x000026b9,
27910x00050051,0x00000006,0x000020b0,0x000020a5, 31770x000026c1,0x000000da,0x000000da,0x0005003e,
27920x00000002,0x000500c7,0x00000006,0x00002293, 31780x000026b9,0x00000b11,0x00000002,0x00000004,
27930x000020b0,0x000005fb,0x000500c4,0x00000006, 31790x000200f9,0x00000be4,0x000200f8,0x00000be8,
27940x00002296,0x00002293,0x0000023b,0x000500c5, 31800x000500aa,0x0000002f,0x00000beb,0x00000b13,
27950x00000006,0x00002297,0x00002293,0x00002296, 31810x00000246,0x000300f7,0x00000bed,0x00000000,
27960x000500c7,0x00000006,0x00002298,0x00002297, 31820x000400fa,0x00000beb,0x00000bec,0x00000bed,
27970x00000602,0x000500c4,0x00000006,0x0000229b, 31830x000200f8,0x00000bec,0x00050041,0x000000fe,
27980x00002298,0x00000305,0x000500c5,0x00000006, 31840x00002720,0x000000fc,0x00000308,0x0004003d,
27990x0000229c,0x00002298,0x0000229b,0x000500c7, 31850x00000006,0x00002721,0x00002720,0x00050080,
28000x00000006,0x0000229d,0x0000229c,0x00000608, 31860x00000006,0x00002723,0x00002721,0x00000b11,
28010x000500c4,0x00000006,0x000022a0,0x0000229d, 31870x00050041,0x000000fe,0x00002829,0x000000fc,
28020x00000212,0x000500c5,0x00000006,0x000022a1, 31880x0000023e,0x0004003d,0x00000006,0x0000282a,
28030x0000229d,0x000022a0,0x000500c7,0x00000006, 31890x00002829,0x00050084,0x00000006,0x0000282c,
28040x000022a2,0x000022a1,0x0000060e,0x000500c4, 31900x00002723,0x00000228,0x00050080,0x00000006,
28050x00000006,0x000022a5,0x000022a2,0x00000202, 31910x0000282d,0x0000282a,0x0000282c,0x000500c2,
28060x000500c5,0x00000006,0x000022a6,0x000022a2, 31920x00000006,0x0000282e,0x0000282d,0x00000233,
28070x000022a5,0x000500c7,0x00000006,0x000022a7, 31930x000500c4,0x00000006,0x0000282f,0x0000282e,
28080x000022a6,0x00000614,0x000500c5,0x00000006, 31940x0000020d,0x000500c5,0x00000006,0x00002830,
28090x000020b2,0x000020ae,0x000022a7,0x000200f9, 31950x0000282f,0x00000246,0x000200f9,0x0000272f,
28100x000020b3,0x000200f8,0x000020b3,0x000700f5, 31960x000200f8,0x0000272f,0x000700f5,0x0000004b,
28110x00000006,0x00002ad1,0x0000052e,0x000021e9, 31970x000031a2,0x000032a7,0x00000bec,0x0000328b,
28120x000020b2,0x0000225b,0x00050084,0x00000006, 31980x0000280b,0x000700f5,0x0000004b,0x000031a0,
28130x000020b6,0x00000107,0x000009e9,0x00050080, 31990x000032a5,0x00000bec,0x00003286,0x0000280b,
28140x00000006,0x000020b7,0x00000104,0x000020b6, 32000x000700f5,0x00000006,0x0000319d,0x000000a6,
28150x00050095,0x000000a8,0x000022c2,0x00002124, 32010x00000bec,0x0000280d,0x0000280b,0x000500b0,
28160x000020b7,0x00050051,0x00000006,0x000022c3, 32020x0000002f,0x00002732,0x0000319d,0x0000010a,
28170x000022c2,0x00000001,0x00050051,0x00000006, 32030x000400f6,0x0000280e,0x0000280b,0x00000000,
28180x000022c4,0x000022c2,0x00000000,0x00050080, 32040x000400fa,0x00002732,0x00002733,0x0000280e,
28190x00000006,0x000022c9,0x0000212b,0x000022c3, 32050x000200f8,0x00002733,0x00050084,0x00000006,
28200x00050050,0x00000007,0x000022ca,0x000022c4, 32060x00002735,0x0000010a,0x00000b11,0x00050080,
28210x000022c9,0x0004007c,0x00000014,0x000022ba, 32070x00000006,0x00002737,0x00002735,0x0000319d,
28220x000022ca,0x00060041,0x000000d8,0x000022b2, 32080x00050041,0x000000fe,0x0000273c,0x000000fc,
28230x000022ba,0x000000d7,0x000000d7,0x0005003e, 32090x0000027b,0x0004003d,0x00000006,0x0000273d,
28240x000022b2,0x00002ad1,0x00000002,0x00000004, 32100x0000273c,0x000500aa,0x0000002f,0x0000273e,
28250x00050084,0x00000006,0x000022cf,0x00000107, 32110x0000273d,0x000000b0,0x000300f7,0x000027d4,
28260x00002104,0x00050080,0x00000006,0x000022d0, 32120x00000000,0x000400fa,0x0000273e,0x0000273f,
28270x00000104,0x000022cf,0x00050080,0x00000006, 32130x00002784,0x000200f8,0x0000273f,0x00050084,
28280x000020bf,0x000022d0,0x000020b6,0x00050095, 32140x00000006,0x00002742,0x0000010a,0x0000319d,
28290x000000a8,0x000022e8,0x00002124,0x000020bf, 32150x00050080,0x00000006,0x00002743,0x0000282d,
28300x00050051,0x00000006,0x000022e9,0x000022e8, 32160x00002742,0x00050041,0x00000156,0x00002744,
28310x00000001,0x00050051,0x00000006,0x000022ea, 32170x000000fc,0x000000da,0x0004003d,0x00000007,
28320x000022e8,0x00000000,0x00050080,0x00000006, 32180x00002745,0x00002744,0x00050051,0x00000006,
28330x000022ef,0x0000212b,0x000022e9,0x00050050, 32190x00002847,0x00002745,0x00000000,0x00050095,
28340x00000007,0x000022f0,0x000022ea,0x000022ef, 32200x000000ab,0x00002849,0x00002847,0x00002743,
28350x0004007c,0x00000014,0x000022e0,0x000022f0, 32210x00050051,0x00000006,0x0000284a,0x00002849,
28360x00060041,0x000000d8,0x000022d8,0x000022e0, 32220x00000001,0x00050051,0x00000006,0x0000284b,
28370x000000d7,0x000000d7,0x0005003e,0x000022d8, 32230x00002849,0x00000000,0x00050051,0x00000006,
28380x000009e9,0x00000002,0x00000004,0x000200f9, 32240x0000284e,0x00002745,0x00000001,0x00050080,
28390x00000a5f,0x000200f8,0x00000a63,0x000500aa, 32250x00000006,0x00002850,0x0000284e,0x0000284a,
28400x0000002f,0x00000a66,0x000009eb,0x00000243, 32260x00050050,0x00000007,0x00002851,0x0000284b,
28410x000300f7,0x00000a68,0x00000000,0x000400fa, 32270x00002850,0x0004007c,0x00000014,0x00002841,
28420x00000a66,0x00000a67,0x00000a68,0x000200f8, 32280x00002851,0x00060041,0x000000db,0x00002838,
28430x00000a67,0x00050041,0x000000fb,0x0000232f, 32290x00002841,0x000000da,0x000000da,0x0006003d,
28440x000000f9,0x00000305,0x0004003d,0x00000006, 32300x00000006,0x00002839,0x00002838,0x00000002,
28450x00002330,0x0000232f,0x00050080,0x00000006, 32310x00000004,0x000500ab,0x0000002f,0x00002748,
28460x00002332,0x00002330,0x000009e9,0x00050041, 32320x00002839,0x00000380,0x000300f7,0x00002783,
28470x000000fb,0x000023ee,0x000000f9,0x0000023b, 32330x00000000,0x000400fa,0x00002748,0x00002749,
28480x0004003d,0x00000006,0x000023ef,0x000023ee, 32340x00002783,0x000200f8,0x00002749,0x000500c2,
28490x00050084,0x00000006,0x000023f1,0x00002332, 32350x00000006,0x00002855,0x00002839,0x0000020d,
28500x00000225,0x00050080,0x00000006,0x000023f2, 32360x00050084,0x00000006,0x0000274c,0x00002855,
28510x000023ef,0x000023f1,0x000500c2,0x00000006, 32370x00000107,0x000500c7,0x00000006,0x0000274e,
28520x000023f3,0x000023f2,0x00000230,0x000500c4, 32380x00002839,0x00000967,0x000500aa,0x0000002f,
28530x00000006,0x000023f4,0x000023f3,0x0000020a, 32390x0000274f,0x0000274e,0x00000246,0x000300f7,
28540x000500c5,0x00000006,0x000023f5,0x000023f4, 32400x00002776,0x00000000,0x000400fa,0x0000274f,
28550x00000243,0x000200f9,0x0000233e,0x000200f8, 32410x00002750,0x0000275c,0x000200f8,0x00002750,
28560x0000233e,0x000700f5,0x0000004b,0x00002aaa, 32420x00050041,0x000000fe,0x00002751,0x000000fc,
28570x00002b66,0x00000a67,0x00002b57,0x000023d0, 32430x0000096c,0x0004003d,0x00000006,0x00002752,
28580x000700f5,0x0000004b,0x00002aa8,0x00002b64, 32440x00002751,0x00050082,0x00000006,0x00002756,
28590x00000a67,0x00002b55,0x000023d0,0x000700f5, 32450x0000274c,0x0000282a,0x00050086,0x00000006,
28600x00000006,0x00002aa5,0x000000a3,0x00000a67, 32460x00002757,0x00002756,0x00000228,0x00050080,
28610x000023d2,0x000023d0,0x000500b0,0x0000002f, 32470x00000006,0x00002758,0x00002752,0x00002757,
28620x00002341,0x00002aa5,0x00000107,0x000400f6, 32480x00050041,0x000000fe,0x00002895,0x000000fc,
28630x000023d3,0x000023d0,0x00000000,0x000400fa, 32490x000000fd,0x0004003d,0x00000006,0x00002896,
28640x00002341,0x00002342,0x000023d3,0x000200f8, 32500x00002895,0x00050084,0x00000006,0x00002897,
28650x00002342,0x00050084,0x00000006,0x00002344, 32510x0000011f,0x00002896,0x00050080,0x00000006,
28660x00000107,0x000009e9,0x00050080,0x00000006, 32520x00002898,0x00000107,0x00002897,0x00050080,
28670x00002346,0x00002344,0x00002aa5,0x00050041, 32530x00000006,0x0000289e,0x00002896,0x000032a8,
28680x000000fb,0x0000234c,0x000000f9,0x0000024d, 32540x00050086,0x00000006,0x0000289f,0x0000289e,
28690x0004003d,0x00000006,0x0000234d,0x0000234c, 32550x00000101,0x00050084,0x00000006,0x00002891,
28700x000500b0,0x0000002f,0x0000234e,0x00002346, 32560x00000107,0x0000289f,0x00050080,0x00000006,
28710x0000234d,0x000300f7,0x00002399,0x00000000, 32570x00002892,0x00002898,0x00002891,0x00050084,
28720x000400fa,0x0000234e,0x0000234f,0x00002399, 32580x00000006,0x00002866,0x00000150,0x00002758,
28730x000200f8,0x0000234f,0x00050041,0x000000fb, 32590x00050080,0x00000006,0x00002867,0x00002892,
28740x00002350,0x000000f9,0x00000263,0x0004003d, 32600x00002866,0x00050041,0x00000156,0x00002868,
28750x00000006,0x00002351,0x00002350,0x000500aa, 32610x000000fc,0x00000154,0x0004003d,0x00000007,
28760x0000002f,0x00002352,0x00002351,0x0000037d, 32620x00002869,0x00002868,0x00050051,0x00000006,
28770x000300f7,0x0000237e,0x00000000,0x000400fa, 32630x000028b6,0x00002869,0x00000000,0x00050095,
28780x00002352,0x00002353,0x00002370,0x000200f8, 32640x000000ab,0x000028b8,0x000028b6,0x00002867,
28790x00002353,0x00050041,0x000000fb,0x000023f8, 32650x00050051,0x00000006,0x000028b9,0x000028b8,
28800x000000f9,0x000000fa,0x0004003d,0x00000006, 32660x00000001,0x00050051,0x00000006,0x000028ba,
28810x000023f9,0x000023f8,0x00050084,0x00000006, 32670x000028b8,0x00000000,0x00050051,0x00000006,
28820x000023fa,0x00000107,0x000023f9,0x00050080, 32680x000028bd,0x00002869,0x00000001,0x00050080,
28830x00000006,0x000023fb,0x00000104,0x000023fa, 32690x00000006,0x000028bf,0x000028bd,0x000028b9,
28840x00050084,0x00000006,0x00002356,0x00000107, 32700x00050050,0x00000007,0x000028c0,0x000028ba,
28850x00002346,0x00050080,0x00000006,0x00002357, 32710x000028bf,0x0004007c,0x00000014,0x000028b0,
28860x000023fb,0x00002356,0x00050041,0x00000153, 32720x000028c0,0x00060041,0x000000db,0x000028a7,
28870x00002358,0x000000f9,0x00000151,0x0004003d, 32730x000028b0,0x000000da,0x000000da,0x0006003d,
28880x00000007,0x00002359,0x00002358,0x00050051, 32740x00000006,0x000028a8,0x000028a7,0x00000002,
28890x00000006,0x00002412,0x00002359,0x00000000, 32750x00000004,0x0004007c,0x00000027,0x0000286c,
28900x00050095,0x000000a8,0x00002414,0x00002412, 32760x000028a8,0x00050080,0x00000006,0x0000286e,
28910x00002357,0x00050051,0x00000006,0x00002415, 32770x00002867,0x0000010a,0x00050095,0x000000ab,
28920x00002414,0x00000001,0x00050051,0x00000006, 32780x000028d9,0x000028b6,0x0000286e,0x00050051,
28930x00002416,0x00002414,0x00000000,0x00050051, 32790x00000006,0x000028da,0x000028d9,0x00000001,
28940x00000006,0x00002419,0x00002359,0x00000001, 32800x00050051,0x00000006,0x000028db,0x000028d9,
28950x00050080,0x00000006,0x0000241b,0x00002419, 32810x00000000,0x00050080,0x00000006,0x000028e0,
28960x00002415,0x00050050,0x00000007,0x0000241c, 32820x000028bd,0x000028da,0x00050050,0x00000007,
28970x00002416,0x0000241b,0x0004007c,0x00000014, 32830x000028e1,0x000028db,0x000028e0,0x0004007c,
28980x0000240c,0x0000241c,0x00060041,0x000000d8, 32840x00000014,0x000028d1,0x000028e1,0x00060041,
28990x00002403,0x0000240c,0x000000d7,0x000000d7, 32850x000000db,0x000028c8,0x000028d1,0x000000da,
29000x0006003d,0x00000006,0x00002404,0x00002403, 32860x000000da,0x0006003d,0x00000006,0x000028c9,
29010x00000002,0x00000004,0x00050041,0x000000fb, 32870x000028c8,0x00000002,0x00000004,0x0004007c,
29020x0000241f,0x000000f9,0x00000229,0x0004003d, 32880x00000027,0x00002872,0x000028c9,0x00050080,
29030x00000006,0x00002420,0x0000241f,0x00050041, 32890x00000006,0x00002874,0x00002867,0x00000111,
29040x000000fb,0x0000242e,0x000000f9,0x00000221, 32900x00050095,0x000000ab,0x000028fa,0x000028b6,
29050x0004003d,0x00000006,0x0000242f,0x0000242e, 32910x00002874,0x00050051,0x00000006,0x000028fb,
29060x000500ab,0x0000002f,0x00002430,0x0000242f, 32920x000028fa,0x00000001,0x00050051,0x00000006,
29070x000000a3,0x000600a9,0x00000006,0x00002431, 32930x000028fc,0x000028fa,0x00000000,0x00050080,
29080x00002430,0x00000225,0x00000104,0x00050084, 32940x00000006,0x00002901,0x000028bd,0x000028fb,
29090x00000006,0x00002423,0x00002404,0x00002431, 32950x00050050,0x00000007,0x00002902,0x000028fc,
29100x00050080,0x00000006,0x00002424,0x00002420, 32960x00002901,0x0004007c,0x00000014,0x000028f2,
29110x00002423,0x000500c2,0x00000006,0x00002425, 32970x00002902,0x00060041,0x000000db,0x000028e9,
29120x00002424,0x00000230,0x000500c4,0x00000006, 32980x000028f2,0x000000da,0x000000da,0x0006003d,
29130x00002426,0x00002425,0x0000020a,0x000600a9, 32990x00000006,0x000028ea,0x000028e9,0x00000002,
29140x00000006,0x0000242a,0x00002430,0x00000236, 33000x00000004,0x0004007c,0x00000027,0x00002878,
29150x000000a3,0x000500c5,0x00000006,0x0000242b, 33010x000028ea,0x00060050,0x0000004b,0x00002879,
29160x00002426,0x0000242a,0x00050084,0x00000006, 33020x0000286c,0x00002872,0x00002878,0x00050080,
29170x00002473,0x0000011c,0x000023f9,0x00050080, 33030x00000006,0x0000287b,0x00002867,0x00000118,
29180x00000006,0x00002474,0x00000104,0x00002473, 33040x00050095,0x000000ab,0x0000291b,0x000028b6,
29190x00050080,0x00000006,0x0000247a,0x000023f9, 33050x0000287b,0x00050051,0x00000006,0x0000291c,
29200x00002b67,0x00050086,0x00000006,0x0000247b, 33060x0000291b,0x00000001,0x00050051,0x00000006,
29210x0000247a,0x000000fe,0x00050084,0x00000006, 33070x0000291d,0x0000291b,0x00000000,0x00050080,
29220x0000246d,0x00000104,0x0000247b,0x00050080, 33080x00000006,0x00002922,0x000028bd,0x0000291c,
29230x00000006,0x0000246e,0x00002474,0x0000246d, 33090x00050050,0x00000007,0x00002923,0x0000291d,
29240x00050084,0x00000006,0x00002442,0x0000014d, 33100x00002922,0x0004007c,0x00000014,0x00002913,
29250x00002404,0x00050080,0x00000006,0x00002443, 33110x00002923,0x00060041,0x000000db,0x0000290a,
29260x0000246e,0x00002442,0x00050095,0x000000a8, 33120x00002913,0x000000da,0x000000da,0x0006003d,
29270x00002494,0x00002412,0x00002443,0x00050051, 33130x00000006,0x0000290b,0x0000290a,0x00000002,
29280x00000006,0x00002495,0x00002494,0x00000001, 33140x00000004,0x0004007c,0x00000027,0x0000287f,
29290x00050051,0x00000006,0x00002496,0x00002494, 33150x0000290b,0x00050080,0x00000006,0x00002881,
29300x00000000,0x00050080,0x00000006,0x0000249b, 33160x00002867,0x0000011f,0x00050095,0x000000ab,
29310x00002419,0x00002495,0x00050050,0x00000007, 33170x0000293c,0x000028b6,0x00002881,0x00050051,
29320x0000249c,0x00002496,0x0000249b,0x0004007c, 33180x00000006,0x0000293d,0x0000293c,0x00000001,
29330x00000014,0x0000248c,0x0000249c,0x00060041, 33190x00050051,0x00000006,0x0000293e,0x0000293c,
29340x000000d8,0x00002483,0x0000248c,0x000000d7, 33200x00000000,0x00050080,0x00000006,0x00002943,
29350x000000d7,0x0006003d,0x00000006,0x00002484, 33210x000028bd,0x0000293d,0x00050050,0x00000007,
29360x00002483,0x00000002,0x00000004,0x0004007c, 33220x00002944,0x0000293e,0x00002943,0x0004007c,
29370x00000027,0x00002448,0x00002484,0x00050080, 33230x00000014,0x00002934,0x00002944,0x00060041,
29380x00000006,0x0000244a,0x00002443,0x00000107, 33240x000000db,0x0000292b,0x00002934,0x000000da,
29390x00050095,0x000000a8,0x000024b5,0x00002412, 33250x000000da,0x0006003d,0x00000006,0x0000292c,
29400x0000244a,0x00050051,0x00000006,0x000024b6, 33260x0000292b,0x00000002,0x00000004,0x0004007c,
29410x000024b5,0x00000001,0x00050051,0x00000006, 33270x00000027,0x00002885,0x0000292c,0x00050080,
29420x000024b7,0x000024b5,0x00000000,0x00050080, 33280x00000006,0x00002887,0x00002867,0x00000189,
29430x00000006,0x000024bc,0x00002419,0x000024b6, 33290x00050095,0x000000ab,0x0000295d,0x000028b6,
29440x00050050,0x00000007,0x000024bd,0x000024b7, 33300x00002887,0x00050051,0x00000006,0x0000295e,
29450x000024bc,0x0004007c,0x00000014,0x000024ad, 33310x0000295d,0x00000001,0x00050051,0x00000006,
29460x000024bd,0x00060041,0x000000d8,0x000024a4, 33320x0000295f,0x0000295d,0x00000000,0x00050080,
29470x000024ad,0x000000d7,0x000000d7,0x0006003d, 33330x00000006,0x00002964,0x000028bd,0x0000295e,
29480x00000006,0x000024a5,0x000024a4,0x00000002, 33340x00050050,0x00000007,0x00002965,0x0000295f,
29490x00000004,0x0004007c,0x00000027,0x0000244e, 33350x00002964,0x0004007c,0x00000014,0x00002955,
29500x000024a5,0x00050080,0x00000006,0x00002450, 33360x00002965,0x00060041,0x000000db,0x0000294c,
29510x00002443,0x0000010e,0x00050095,0x000000a8, 33370x00002955,0x000000da,0x000000da,0x0006003d,
29520x000024d6,0x00002412,0x00002450,0x00050051, 33380x00000006,0x0000294d,0x0000294c,0x00000002,
29530x00000006,0x000024d7,0x000024d6,0x00000001, 33390x00000004,0x0004007c,0x00000027,0x0000288b,
29540x00050051,0x00000006,0x000024d8,0x000024d6, 33400x0000294d,0x00060050,0x0000004b,0x0000288c,
29550x00000000,0x00050080,0x00000006,0x000024dd, 33410x0000287f,0x00002885,0x0000288b,0x000200f9,
29560x00002419,0x000024d7,0x00050050,0x00000007, 33420x00002776,0x000200f8,0x0000275c,0x00050041,
29570x000024de,0x000024d8,0x000024dd,0x0004007c, 33430x000000fe,0x0000275e,0x000000fc,0x0000022c,
29580x00000014,0x000024ce,0x000024de,0x00060041, 33440x0004003d,0x00000006,0x0000275f,0x0000275e,
29590x000000d8,0x000024c5,0x000024ce,0x000000d7, 33450x00050082,0x00000006,0x00002760,0x0000274c,
29600x000000d7,0x0006003d,0x00000006,0x000024c6, 33460x0000275f,0x00050041,0x000000fe,0x00002968,
29610x000024c5,0x00000002,0x00000004,0x0004007c, 33470x000000fc,0x00000224,0x0004003d,0x00000006,
29620x00000027,0x00002454,0x000024c6,0x00060050, 33480x00002969,0x00002968,0x000500ab,0x0000002f,
29630x0000004b,0x00002455,0x00002448,0x0000244e, 33490x0000296a,0x00002969,0x000000a6,0x000600a9,
29640x00002454,0x00050080,0x00000006,0x00002457, 33500x00000006,0x0000296b,0x0000296a,0x00000228,
29650x00002443,0x00000115,0x00050095,0x000000a8, 33510x00000107,0x00050086,0x00000006,0x00002762,
29660x000024f7,0x00002412,0x00002457,0x00050051, 33520x00002760,0x0000296b,0x00050041,0x000000fe,
29670x00000006,0x000024f8,0x000024f7,0x00000001, 33530x000029ab,0x000000fc,0x000000fd,0x0004003d,
29680x00050051,0x00000006,0x000024f9,0x000024f7, 33540x00000006,0x000029ac,0x000029ab,0x00050084,
29690x00000000,0x00050080,0x00000006,0x000024fe, 33550x00000006,0x000029ad,0x0000011f,0x000029ac,
29700x00002419,0x000024f8,0x00050050,0x00000007, 33560x00050080,0x00000006,0x000029ae,0x00000107,
29710x000024ff,0x000024f9,0x000024fe,0x0004007c, 33570x000029ad,0x00050080,0x00000006,0x000029b4,
29720x00000014,0x000024ef,0x000024ff,0x00060041, 33580x000029ac,0x000032a8,0x00050086,0x00000006,
29730x000000d8,0x000024e6,0x000024ef,0x000000d7, 33590x000029b5,0x000029b4,0x00000101,0x00050084,
29740x000000d7,0x0006003d,0x00000006,0x000024e7, 33600x00000006,0x000029a7,0x00000107,0x000029b5,
29750x000024e6,0x00000002,0x00000004,0x0004007c, 33610x00050080,0x00000006,0x000029a8,0x000029ae,
29760x00000027,0x0000245b,0x000024e7,0x00050080, 33620x000029a7,0x00050084,0x00000006,0x0000297c,
29770x00000006,0x0000245d,0x00002443,0x0000011c, 33630x00000150,0x00002762,0x00050080,0x00000006,
29780x00050095,0x000000a8,0x00002518,0x00002412, 33640x0000297d,0x000029a8,0x0000297c,0x00050041,
29790x0000245d,0x00050051,0x00000006,0x00002519, 33650x00000156,0x0000297e,0x000000fc,0x00000154,
29800x00002518,0x00000001,0x00050051,0x00000006, 33660x0004003d,0x00000007,0x0000297f,0x0000297e,
29810x0000251a,0x00002518,0x00000000,0x00050080, 33670x00050051,0x00000006,0x000029cc,0x0000297f,
29820x00000006,0x0000251f,0x00002419,0x00002519, 33680x00000000,0x00050095,0x000000ab,0x000029ce,
29830x00050050,0x00000007,0x00002520,0x0000251a, 33690x000029cc,0x0000297d,0x00050051,0x00000006,
29840x0000251f,0x0004007c,0x00000014,0x00002510, 33700x000029cf,0x000029ce,0x00000001,0x00050051,
29850x00002520,0x00060041,0x000000d8,0x00002507, 33710x00000006,0x000029d0,0x000029ce,0x00000000,
29860x00002510,0x000000d7,0x000000d7,0x0006003d, 33720x00050051,0x00000006,0x000029d3,0x0000297f,
29870x00000006,0x00002508,0x00002507,0x00000002, 33730x00000001,0x00050080,0x00000006,0x000029d5,
29880x00000004,0x0004007c,0x00000027,0x00002461, 33740x000029d3,0x000029cf,0x00050050,0x00000007,
29890x00002508,0x00050080,0x00000006,0x00002463, 33750x000029d6,0x000029d0,0x000029d5,0x0004007c,
29900x00002443,0x00000186,0x00050095,0x000000a8, 33760x00000014,0x000029c6,0x000029d6,0x00060041,
29910x00002539,0x00002412,0x00002463,0x00050051, 33770x000000db,0x000029bd,0x000029c6,0x000000da,
29920x00000006,0x0000253a,0x00002539,0x00000001, 33780x000000da,0x0006003d,0x00000006,0x000029be,
29930x00050051,0x00000006,0x0000253b,0x00002539, 33790x000029bd,0x00000002,0x00000004,0x0004007c,
29940x00000000,0x00050080,0x00000006,0x00002540, 33800x00000027,0x00002982,0x000029be,0x00050080,
29950x00002419,0x0000253a,0x00050050,0x00000007, 33810x00000006,0x00002984,0x0000297d,0x0000010a,
29960x00002541,0x0000253b,0x00002540,0x0004007c, 33820x00050095,0x000000ab,0x000029ef,0x000029cc,
29970x00000014,0x00002531,0x00002541,0x00060041, 33830x00002984,0x00050051,0x00000006,0x000029f0,
29980x000000d8,0x00002528,0x00002531,0x000000d7, 33840x000029ef,0x00000001,0x00050051,0x00000006,
29990x000000d7,0x0006003d,0x00000006,0x00002529, 33850x000029f1,0x000029ef,0x00000000,0x00050080,
30000x00002528,0x00000002,0x00000004,0x0004007c, 33860x00000006,0x000029f6,0x000029d3,0x000029f0,
30010x00000027,0x00002467,0x00002529,0x00060050, 33870x00050050,0x00000007,0x000029f7,0x000029f1,
30020x0000004b,0x00002468,0x0000245b,0x00002461, 33880x000029f6,0x0004007c,0x00000014,0x000029e7,
30030x00002467,0x000300f7,0x0000236f,0x00000000, 33890x000029f7,0x00060041,0x000000db,0x000029de,
30040x000400fa,0x00002430,0x00002364,0x0000236f, 33900x000029e7,0x000000da,0x000000da,0x0006003d,
30050x000200f8,0x00002364,0x00050084,0x00000006, 33910x00000006,0x000029df,0x000029de,0x00000002,
30060x00002368,0x00000225,0x00002404,0x00050080, 33920x00000004,0x0004007c,0x00000027,0x00002988,
30070x00000006,0x00002369,0x00002420,0x00002368, 33930x000029df,0x00050080,0x00000006,0x0000298a,
30080x00050080,0x00000006,0x0000236a,0x00002369, 33940x0000297d,0x00000111,0x00050095,0x000000ab,
30090x000005cd,0x00050041,0x00000153,0x0000236b, 33950x00002a10,0x000029cc,0x0000298a,0x00050051,
30100x000000f9,0x000000d7,0x0004003d,0x00000007, 33960x00000006,0x00002a11,0x00002a10,0x00000001,
30110x0000236c,0x0000236b,0x00050051,0x00000006, 33970x00050051,0x00000006,0x00002a12,0x00002a10,
30120x00002557,0x0000236c,0x00000000,0x00050095, 33980x00000000,0x00050080,0x00000006,0x00002a17,
30130x000000a8,0x00002559,0x00002557,0x0000236a, 33990x000029d3,0x00002a11,0x00050050,0x00000007,
30140x00050051,0x00000006,0x0000255a,0x00002559, 34000x00002a18,0x00002a12,0x00002a17,0x0004007c,
30150x00000001,0x00050051,0x00000006,0x0000255b, 34010x00000014,0x00002a08,0x00002a18,0x00060041,
30160x00002559,0x00000000,0x00050051,0x00000006, 34020x000000db,0x000029ff,0x00002a08,0x000000da,
30170x0000255e,0x0000236c,0x00000001,0x00050080, 34030x000000da,0x0006003d,0x00000006,0x00002a00,
30180x00000006,0x00002560,0x0000255e,0x0000255a, 34040x000029ff,0x00000002,0x00000004,0x0004007c,
30190x00050050,0x00000007,0x00002561,0x0000255b, 34050x00000027,0x0000298e,0x00002a00,0x00060050,
30200x00002560,0x0004007c,0x00000014,0x00002551, 34060x0000004b,0x0000298f,0x00002982,0x00002988,
30210x00002561,0x00060041,0x000000d8,0x00002549, 34070x0000298e,0x00050080,0x00000006,0x00002991,
30220x00002551,0x000000d7,0x000000d7,0x0005003e, 34080x0000297d,0x00000118,0x00050095,0x000000ab,
30230x00002549,0x000023f5,0x00000002,0x00000004, 34090x00002a31,0x000029cc,0x00002991,0x00050051,
30240x000200f9,0x0000236f,0x000200f8,0x0000236f, 34100x00000006,0x00002a32,0x00002a31,0x00000001,
30250x000200f9,0x0000237e,0x000200f8,0x00002370, 34110x00050051,0x00000006,0x00002a33,0x00002a31,
30260x00050080,0x00000006,0x00002374,0x00002351, 34120x00000000,0x00050080,0x00000006,0x00002a38,
30270x00002346,0x00050084,0x00000006,0x00002567, 34130x000029d3,0x00002a32,0x00050050,0x00000007,
30280x00002374,0x00000225,0x00050080,0x00000006, 34140x00002a39,0x00002a33,0x00002a38,0x0004007c,
30290x00002568,0x000023ef,0x00002567,0x000500c2, 34150x00000014,0x00002a29,0x00002a39,0x00060041,
30300x00000006,0x00002569,0x00002568,0x00000230, 34160x000000db,0x00002a20,0x00002a29,0x000000da,
30310x000500c4,0x00000006,0x0000256a,0x00002569, 34170x000000da,0x0006003d,0x00000006,0x00002a21,
30320x0000020a,0x000500c5,0x00000006,0x0000256b, 34180x00002a20,0x00000002,0x00000004,0x0004007c,
30330x0000256a,0x00000243,0x00050041,0x000000fb, 34190x00000027,0x00002995,0x00002a21,0x00050080,
30340x00002377,0x000000f9,0x000008bc,0x0004003d, 34200x00000006,0x00002997,0x0000297d,0x0000011f,
30350x00000006,0x00002378,0x00002377,0x00050080, 34210x00050095,0x000000ab,0x00002a52,0x000029cc,
30360x00000006,0x0000237a,0x00002378,0x00002374, 34220x00002997,0x00050051,0x00000006,0x00002a53,
30370x00050041,0x000000fb,0x000025ab,0x000000f9, 34230x00002a52,0x00000001,0x00050051,0x00000006,
30380x000000fa,0x0004003d,0x00000006,0x000025ac, 34240x00002a54,0x00002a52,0x00000000,0x00050080,
30390x000025ab,0x00050084,0x00000006,0x000025ad, 34250x00000006,0x00002a59,0x000029d3,0x00002a53,
30400x0000011c,0x000025ac,0x00050080,0x00000006, 34260x00050050,0x00000007,0x00002a5a,0x00002a54,
30410x000025ae,0x00000104,0x000025ad,0x00050080, 34270x00002a59,0x0004007c,0x00000014,0x00002a4a,
30420x00000006,0x000025b4,0x000025ac,0x00002b67, 34280x00002a5a,0x00060041,0x000000db,0x00002a41,
30430x00050086,0x00000006,0x000025b5,0x000025b4, 34290x00002a4a,0x000000da,0x000000da,0x0006003d,
30440x000000fe,0x00050084,0x00000006,0x000025a7, 34300x00000006,0x00002a42,0x00002a41,0x00000002,
30450x00000104,0x000025b5,0x00050080,0x00000006, 34310x00000004,0x0004007c,0x00000027,0x0000299b,
30460x000025a8,0x000025ae,0x000025a7,0x00050084, 34320x00002a42,0x00050080,0x00000006,0x0000299d,
30470x00000006,0x0000257c,0x0000014d,0x0000237a, 34330x0000297d,0x00000189,0x00050095,0x000000ab,
30480x00050080,0x00000006,0x0000257d,0x000025a8, 34340x00002a73,0x000029cc,0x0000299d,0x00050051,
30490x0000257c,0x00050041,0x00000153,0x0000257e, 34350x00000006,0x00002a74,0x00002a73,0x00000001,
30500x000000f9,0x00000151,0x0004003d,0x00000007, 34360x00050051,0x00000006,0x00002a75,0x00002a73,
30510x0000257f,0x0000257e,0x00050051,0x00000006, 34370x00000000,0x00050080,0x00000006,0x00002a7a,
30520x000025cc,0x0000257f,0x00000000,0x00050095, 34380x000029d3,0x00002a74,0x00050050,0x00000007,
30530x000000a8,0x000025ce,0x000025cc,0x0000257d, 34390x00002a7b,0x00002a75,0x00002a7a,0x0004007c,
30540x00050051,0x00000006,0x000025cf,0x000025ce, 34400x00000014,0x00002a6b,0x00002a7b,0x00060041,
30550x00000001,0x00050051,0x00000006,0x000025d0, 34410x000000db,0x00002a62,0x00002a6b,0x000000da,
30560x000025ce,0x00000000,0x00050051,0x00000006, 34420x000000da,0x0006003d,0x00000006,0x00002a63,
30570x000025d3,0x0000257f,0x00000001,0x00050080, 34430x00002a62,0x00000002,0x00000004,0x0004007c,
30580x00000006,0x000025d5,0x000025d3,0x000025cf, 34440x00000027,0x000029a1,0x00002a63,0x00060050,
30590x00050050,0x00000007,0x000025d6,0x000025d0, 34450x0000004b,0x000029a2,0x00002995,0x0000299b,
30600x000025d5,0x0004007c,0x00000014,0x000025c6, 34460x000029a1,0x000300f7,0x00002775,0x00000000,
30610x000025d6,0x00060041,0x000000d8,0x000025bd, 34470x000400fa,0x0000296a,0x0000276a,0x00002775,
30620x000025c6,0x000000d7,0x000000d7,0x0006003d, 34480x000200f8,0x0000276a,0x00050084,0x00000006,
30630x00000006,0x000025be,0x000025bd,0x00000002, 34490x0000276e,0x00000228,0x00002762,0x00050080,
30640x00000004,0x0004007c,0x00000027,0x00002582, 34500x00000006,0x0000276f,0x0000275f,0x0000276e,
30650x000025be,0x00050080,0x00000006,0x00002584, 34510x00050080,0x00000006,0x00002770,0x0000276f,
30660x0000257d,0x00000107,0x00050095,0x000000a8, 34520x000005d0,0x00050095,0x000000ab,0x00002a93,
30670x000025ef,0x000025cc,0x00002584,0x00050051, 34530x00002847,0x00002770,0x00050051,0x00000006,
30680x00000006,0x000025f0,0x000025ef,0x00000001, 34540x00002a94,0x00002a93,0x00000001,0x00050051,
30690x00050051,0x00000006,0x000025f1,0x000025ef, 34550x00000006,0x00002a95,0x00002a93,0x00000000,
30700x00000000,0x00050080,0x00000006,0x000025f6, 34560x00050080,0x00000006,0x00002a9a,0x0000284e,
30710x000025d3,0x000025f0,0x00050050,0x00000007, 34570x00002a94,0x00050050,0x00000007,0x00002a9b,
30720x000025f7,0x000025f1,0x000025f6,0x0004007c, 34580x00002a95,0x00002a9a,0x0004007c,0x00000014,
30730x00000014,0x000025e7,0x000025f7,0x00060041, 34590x00002a8b,0x00002a9b,0x00060041,0x000000db,
30740x000000d8,0x000025de,0x000025e7,0x000000d7, 34600x00002a83,0x00002a8b,0x000000da,0x000000da,
30750x000000d7,0x0006003d,0x00000006,0x000025df, 34610x0005003e,0x00002a83,0x00002830,0x00000002,
30760x000025de,0x00000002,0x00000004,0x0004007c, 34620x00000004,0x000200f9,0x00002775,0x000200f8,
30770x00000027,0x00002588,0x000025df,0x00050080, 34630x00002775,0x000200f9,0x00002776,0x000200f8,
30780x00000006,0x0000258a,0x0000257d,0x0000010e, 34640x00002776,0x000700f5,0x0000004b,0x000031b7,
30790x00050095,0x000000a8,0x00002610,0x000025cc, 34650x0000288c,0x00002750,0x000029a2,0x00002775,
30800x0000258a,0x00050051,0x00000006,0x00002611, 34660x000700f5,0x0000004b,0x000031b5,0x00002879,
30810x00002610,0x00000001,0x00050051,0x00000006, 34670x00002750,0x0000298f,0x00002775,0x00050051,
30820x00002612,0x00002610,0x00000000,0x00050080, 34680x00000027,0x00002a9f,0x000031b5,0x00000000,
30830x00000006,0x00002617,0x000025d3,0x00002611, 34690x00050051,0x00000027,0x00002aa1,0x000031b7,
30840x00050050,0x00000007,0x00002618,0x00002612, 34700x00000000,0x000500bc,0x0000002f,0x00002aa2,
30850x00002617,0x0004007c,0x00000014,0x00002608, 34710x00002a9f,0x00002aa1,0x000300f7,0x00002aa9,
30860x00002618,0x00060041,0x000000d8,0x000025ff, 34720x00000000,0x000400fa,0x00002aa2,0x00002aa3,
30870x00002608,0x000000d7,0x000000d7,0x0006003d, 34730x00002aa9,0x000200f8,0x00002aa3,0x00050051,
30880x00000006,0x00002600,0x000025ff,0x00000002, 34740x00000027,0x00002aa5,0x000031b5,0x00000001,
30890x00000004,0x0004007c,0x00000027,0x0000258e, 34750x00050051,0x00000027,0x00002aa7,0x000031b7,
30900x00002600,0x00060050,0x0000004b,0x0000258f, 34760x00000001,0x000500bc,0x0000002f,0x00002aa8,
30910x00002582,0x00002588,0x0000258e,0x00050080, 34770x00002aa5,0x00002aa7,0x000200f9,0x00002aa9,
30920x00000006,0x00002591,0x0000257d,0x00000115, 34780x000200f8,0x00002aa9,0x000700f5,0x0000002f,
30930x00050095,0x000000a8,0x00002631,0x000025cc, 34790x00002aaa,0x00002aa2,0x00002776,0x00002aa8,
30940x00002591,0x00050051,0x00000006,0x00002632, 34800x00002aa3,0x000300f7,0x00002ab1,0x00000000,
30950x00002631,0x00000001,0x00050051,0x00000006, 34810x000400fa,0x00002aaa,0x00002aab,0x00002ab1,
30960x00002633,0x00002631,0x00000000,0x00050080, 34820x000200f8,0x00002aab,0x00050051,0x00000027,
30970x00000006,0x00002638,0x000025d3,0x00002632, 34830x00002aad,0x000031b5,0x00000002,0x00050051,
30980x00050050,0x00000007,0x00002639,0x00002633, 34840x00000027,0x00002aaf,0x000031b7,0x00000002,
30990x00002638,0x0004007c,0x00000014,0x00002629, 34850x000500bc,0x0000002f,0x00002ab0,0x00002aad,
31000x00002639,0x00060041,0x000000d8,0x00002620, 34860x00002aaf,0x000200f9,0x00002ab1,0x000200f8,
31010x00002629,0x000000d7,0x000000d7,0x0006003d, 34870x00002ab1,0x000700f5,0x0000002f,0x00002ab2,
31020x00000006,0x00002621,0x00002620,0x00000002, 34880x00002aaa,0x00002aa9,0x00002ab0,0x00002aab,
31030x00000004,0x0004007c,0x00000027,0x00002595, 34890x000300f7,0x00002782,0x00000000,0x000400fa,
31040x00002621,0x00050080,0x00000006,0x00002597, 34900x00002ab2,0x0000277b,0x00002782,0x000200f8,
31050x0000257d,0x0000011c,0x00050095,0x000000a8, 34910x0000277b,0x0007000c,0x0000004b,0x0000277e,
31060x00002652,0x000025cc,0x00002597,0x00050051, 34920x00000001,0x00000025,0x000031a0,0x000031b5,
31070x00000006,0x00002653,0x00002652,0x00000001, 34930x0007000c,0x0000004b,0x00002781,0x00000001,
31080x00050051,0x00000006,0x00002654,0x00002652, 34940x00000028,0x000031a2,0x000031b7,0x000200f9,
31090x00000000,0x00050080,0x00000006,0x00002659, 34950x00002782,0x000200f8,0x00002782,0x000700f5,
31100x000025d3,0x00002653,0x00050050,0x00000007, 34960x0000004b,0x0000328d,0x000031a2,0x00002ab1,
31110x0000265a,0x00002654,0x00002659,0x0004007c, 34970x00002781,0x0000277b,0x000700f5,0x0000004b,
31120x00000014,0x0000264a,0x0000265a,0x00060041, 34980x00003288,0x000031a0,0x00002ab1,0x0000277e,
31130x000000d8,0x00002641,0x0000264a,0x000000d7, 34990x0000277b,0x000200f9,0x00002783,0x000200f8,
31140x000000d7,0x0006003d,0x00000006,0x00002642, 35000x00002783,0x000700f5,0x0000004b,0x0000328c,
31150x00002641,0x00000002,0x00000004,0x0004007c, 35010x000031a2,0x0000273f,0x0000328d,0x00002782,
31160x00000027,0x0000259b,0x00002642,0x00050080, 35020x000700f5,0x0000004b,0x00003287,0x000031a0,
31170x00000006,0x0000259d,0x0000257d,0x00000186, 35030x0000273f,0x00003288,0x00002782,0x000700f5,
31180x00050095,0x000000a8,0x00002673,0x000025cc, 35040x0000004b,0x000031e3,0x000032a7,0x0000273f,
31190x0000259d,0x00050051,0x00000006,0x00002674, 35050x000031b7,0x00002782,0x000700f5,0x0000004b,
31200x00002673,0x00000001,0x00050051,0x00000006, 35060x000031de,0x000032a5,0x0000273f,0x000031b5,
31210x00002675,0x00002673,0x00000000,0x00050080, 35070x00002782,0x000200f9,0x000027d4,0x000200f8,
31220x00000006,0x0000267a,0x000025d3,0x00002674, 35080x00002784,0x00050041,0x000000fe,0x00002786,
31230x00050050,0x00000007,0x0000267b,0x00002675, 35090x000000fc,0x00000250,0x0004003d,0x00000006,
31240x0000267a,0x0004007c,0x00000014,0x0000266b, 35100x00002787,0x00002786,0x000500b0,0x0000002f,
31250x0000267b,0x00060041,0x000000d8,0x00002662, 35110x00002788,0x00002737,0x00002787,0x000300f7,
31260x0000266b,0x000000d7,0x000000d7,0x0006003d, 35120x000027d3,0x00000000,0x000400fa,0x00002788,
31270x00000006,0x00002663,0x00002662,0x00000002, 35130x00002789,0x000027d3,0x000200f8,0x00002789,
31280x00000004,0x0004007c,0x00000027,0x000025a1, 35140x00050041,0x000000fe,0x0000278a,0x000000fc,
31290x00002663,0x00060050,0x0000004b,0x000025a2, 35150x00000266,0x0004003d,0x00000006,0x0000278b,
31300x00002595,0x0000259b,0x000025a1,0x000200f9, 35160x0000278a,0x000500aa,0x0000002f,0x0000278c,
31310x0000237e,0x000200f8,0x0000237e,0x000700f5, 35170x0000278b,0x00000380,0x000300f7,0x000027b8,
31320x0000004b,0x00002aaf,0x00002468,0x0000236f, 35180x00000000,0x000400fa,0x0000278c,0x0000278d,
31330x000025a2,0x00002370,0x000700f5,0x0000004b, 35190x000027aa,0x000200f8,0x0000278d,0x00050041,
31340x00002aad,0x00002455,0x0000236f,0x0000258f, 35200x000000fe,0x00002ab6,0x000000fc,0x000000fd,
31350x00002370,0x000700f5,0x00000006,0x00002aab, 35210x0004003d,0x00000006,0x00002ab7,0x00002ab6,
31360x0000242b,0x0000236f,0x0000256b,0x00002370, 35220x00050084,0x00000006,0x00002ab8,0x0000010a,
31370x00050041,0x000000fb,0x0000237f,0x000000f9, 35230x00002ab7,0x00050080,0x00000006,0x00002ab9,
31380x000008c7,0x0004003d,0x00000006,0x00002380, 35240x00000107,0x00002ab8,0x00050084,0x00000006,
31390x0000237f,0x000500c2,0x00000006,0x0000267f, 35250x00002790,0x0000010a,0x00002737,0x00050080,
31400x00002aab,0x0000020a,0x00050041,0x000000fb, 35260x00000006,0x00002791,0x00002ab9,0x00002790,
31410x00002383,0x000000f9,0x00000229,0x0004003d, 35270x00050041,0x00000156,0x00002792,0x000000fc,
31420x00000006,0x00002384,0x00002383,0x00050086, 35280x00000154,0x0004003d,0x00000007,0x00002793,
31430x00000006,0x00002385,0x00002384,0x00000104, 35290x00002792,0x00050051,0x00000006,0x00002ad0,
31440x00050082,0x00000006,0x00002386,0x0000267f, 35300x00002793,0x00000000,0x00050095,0x000000ab,
31450x00002385,0x00050084,0x00000006,0x00002387, 35310x00002ad2,0x00002ad0,0x00002791,0x00050051,
31460x00000107,0x00002386,0x00050080,0x00000006, 35320x00000006,0x00002ad3,0x00002ad2,0x00000001,
31470x00002388,0x00002380,0x00002387,0x00050041, 35330x00050051,0x00000006,0x00002ad4,0x00002ad2,
31480x00000153,0x00002389,0x000000f9,0x000000d7, 35340x00000000,0x00050051,0x00000006,0x00002ad7,
31490x0004003d,0x00000007,0x0000238a,0x00002389, 35350x00002793,0x00000001,0x00050080,0x00000006,
31500x00050051,0x00000006,0x00002695,0x0000238a, 35360x00002ad9,0x00002ad7,0x00002ad3,0x00050050,
31510x00000000,0x00050095,0x000000a8,0x00002697, 35370x00000007,0x00002ada,0x00002ad4,0x00002ad9,
31520x00002695,0x00002388,0x00050051,0x00000006, 35380x0004007c,0x00000014,0x00002aca,0x00002ada,
31530x00002698,0x00002697,0x00000001,0x00050051, 35390x00060041,0x000000db,0x00002ac1,0x00002aca,
31540x00000006,0x00002699,0x00002697,0x00000000, 35400x000000da,0x000000da,0x0006003d,0x00000006,
31550x00050051,0x00000006,0x0000269c,0x0000238a, 35410x00002ac2,0x00002ac1,0x00000002,0x00000004,
31560x00000001,0x00050080,0x00000006,0x0000269e, 35420x00050041,0x000000fe,0x00002add,0x000000fc,
31570x0000269c,0x00002698,0x00050050,0x00000007, 35430x0000022c,0x0004003d,0x00000006,0x00002ade,
31580x0000269f,0x00002699,0x0000269e,0x0004007c, 35440x00002add,0x00050041,0x000000fe,0x00002aec,
31590x00000014,0x0000268f,0x0000269f,0x00060041, 35450x000000fc,0x00000224,0x0004003d,0x00000006,
31600x000000d8,0x00002687,0x0000268f,0x000000d7, 35460x00002aed,0x00002aec,0x000500ab,0x0000002f,
31610x000000d7,0x0005003e,0x00002687,0x000023f5, 35470x00002aee,0x00002aed,0x000000a6,0x000600a9,
31620x00000002,0x00000004,0x00050051,0x00000027, 35480x00000006,0x00002aef,0x00002aee,0x00000228,
31630x000026a3,0x00002aad,0x00000000,0x00050051, 35490x00000107,0x00050084,0x00000006,0x00002ae1,
31640x00000027,0x000026a5,0x00002aaf,0x00000000, 35500x00002ac2,0x00002aef,0x00050080,0x00000006,
31650x000500bc,0x0000002f,0x000026a6,0x000026a3, 35510x00002ae2,0x00002ade,0x00002ae1,0x000500c2,
31660x000026a5,0x000300f7,0x000026ad,0x00000000, 35520x00000006,0x00002ae3,0x00002ae2,0x00000233,
31670x000400fa,0x000026a6,0x000026a7,0x000026ad, 35530x000500c4,0x00000006,0x00002ae4,0x00002ae3,
31680x000200f8,0x000026a7,0x00050051,0x00000027, 35540x0000020d,0x000600a9,0x00000006,0x00002ae8,
31690x000026a9,0x00002aad,0x00000001,0x00050051, 35550x00002aee,0x00000239,0x000000a6,0x000500c5,
31700x00000027,0x000026ab,0x00002aaf,0x00000001, 35560x00000006,0x00002ae9,0x00002ae4,0x00002ae8,
31710x000500bc,0x0000002f,0x000026ac,0x000026a9, 35570x00050084,0x00000006,0x00002b31,0x0000011f,
31720x000026ab,0x000200f9,0x000026ad,0x000200f8, 35580x00002ab7,0x00050080,0x00000006,0x00002b32,
31730x000026ad,0x000700f5,0x0000002f,0x000026ae, 35590x00000107,0x00002b31,0x00050080,0x00000006,
31740x000026a6,0x0000237e,0x000026ac,0x000026a7, 35600x00002b38,0x00002ab7,0x000032a8,0x00050086,
31750x000300f7,0x000026b5,0x00000000,0x000400fa, 35610x00000006,0x00002b39,0x00002b38,0x00000101,
31760x000026ae,0x000026af,0x000026b5,0x000200f8, 35620x00050084,0x00000006,0x00002b2b,0x00000107,
31770x000026af,0x00050051,0x00000027,0x000026b1, 35630x00002b39,0x00050080,0x00000006,0x00002b2c,
31780x00002aad,0x00000002,0x00050051,0x00000027, 35640x00002b32,0x00002b2b,0x00050084,0x00000006,
31790x000026b3,0x00002aaf,0x00000002,0x000500bc, 35650x00002b00,0x00000150,0x00002ac2,0x00050080,
31800x0000002f,0x000026b4,0x000026b1,0x000026b3, 35660x00000006,0x00002b01,0x00002b2c,0x00002b00,
31810x000200f9,0x000026b5,0x000200f8,0x000026b5, 35670x00050095,0x000000ab,0x00002b52,0x00002ad0,
31820x000700f5,0x0000002f,0x000026b6,0x000026ae, 35680x00002b01,0x00050051,0x00000006,0x00002b53,
31830x000026ad,0x000026b4,0x000026af,0x000300f7, 35690x00002b52,0x00000001,0x00050051,0x00000006,
31840x00002398,0x00000000,0x000400fa,0x000026b6, 35700x00002b54,0x00002b52,0x00000000,0x00050080,
31850x00002391,0x00002398,0x000200f8,0x00002391, 35710x00000006,0x00002b59,0x00002ad7,0x00002b53,
31860x0007000c,0x0000004b,0x00002394,0x00000001, 35720x00050050,0x00000007,0x00002b5a,0x00002b54,
31870x00000025,0x00002aa8,0x00002aad,0x0007000c, 35730x00002b59,0x0004007c,0x00000014,0x00002b4a,
31880x0000004b,0x00002397,0x00000001,0x00000028, 35740x00002b5a,0x00060041,0x000000db,0x00002b41,
31890x00002aaa,0x00002aaf,0x000200f9,0x00002398, 35750x00002b4a,0x000000da,0x000000da,0x0006003d,
31900x000200f8,0x00002398,0x000700f5,0x0000004b, 35760x00000006,0x00002b42,0x00002b41,0x00000002,
31910x00002b58,0x00002aaa,0x000026b5,0x00002397, 35770x00000004,0x0004007c,0x00000027,0x00002b06,
31920x00002391,0x000700f5,0x0000004b,0x00002b56, 35780x00002b42,0x00050080,0x00000006,0x00002b08,
31930x00002aa8,0x000026b5,0x00002394,0x00002391, 35790x00002b01,0x0000010a,0x00050095,0x000000ab,
31940x000200f9,0x00002399,0x000200f8,0x00002399, 35800x00002b73,0x00002ad0,0x00002b08,0x00050051,
31950x000700f5,0x0000004b,0x00002b57,0x00002aaa, 35810x00000006,0x00002b74,0x00002b73,0x00000001,
31960x00002342,0x00002b58,0x00002398,0x000700f5, 35820x00050051,0x00000006,0x00002b75,0x00002b73,
31970x0000004b,0x00002b55,0x00002aa8,0x00002342, 35830x00000000,0x00050080,0x00000006,0x00002b7a,
31980x00002b56,0x00002398,0x000700f5,0x0000004b, 35840x00002ad7,0x00002b74,0x00050050,0x00000007,
31990x00002ac9,0x00002b66,0x00002342,0x00002aaf, 35850x00002b7b,0x00002b75,0x00002b7a,0x0004007c,
32000x00002398,0x000700f5,0x0000004b,0x00002ac7, 35860x00000014,0x00002b6b,0x00002b7b,0x00060041,
32010x00002b64,0x00002342,0x00002aad,0x00002398, 35870x000000db,0x00002b62,0x00002b6b,0x000000da,
32020x000700f5,0x00000006,0x00002ac3,0x0000037d, 35880x000000da,0x0006003d,0x00000006,0x00002b63,
32030x00002342,0x00002aab,0x00002398,0x00050084, 35890x00002b62,0x00000002,0x00000004,0x0004007c,
32040x00000006,0x0000239c,0x00000107,0x00002aa5, 35900x00000027,0x00002b0c,0x00002b63,0x00050080,
32050x00050080,0x00000006,0x0000239d,0x000023f2, 35910x00000006,0x00002b0e,0x00002b01,0x00000111,
32060x0000239c,0x00050041,0x00000153,0x0000239e, 35920x00050095,0x000000ab,0x00002b94,0x00002ad0,
32070x000000f9,0x000000d7,0x0004003d,0x00000007, 35930x00002b0e,0x00050051,0x00000006,0x00002b95,
32080x0000239f,0x0000239e,0x00050051,0x00000006, 35940x00002b94,0x00000001,0x00050051,0x00000006,
32090x000026cd,0x0000239f,0x00000000,0x00050095, 35950x00002b96,0x00002b94,0x00000000,0x00050080,
32100x000000a8,0x000026cf,0x000026cd,0x0000239d, 35960x00000006,0x00002b9b,0x00002ad7,0x00002b95,
32110x00050051,0x00000006,0x000026d0,0x000026cf, 35970x00050050,0x00000007,0x00002b9c,0x00002b96,
32120x00000001,0x00050051,0x00000006,0x000026d1, 35980x00002b9b,0x0004007c,0x00000014,0x00002b8c,
32130x000026cf,0x00000000,0x00050051,0x00000006, 35990x00002b9c,0x00060041,0x000000db,0x00002b83,
32140x000026d4,0x0000239f,0x00000001,0x00050080, 36000x00002b8c,0x000000da,0x000000da,0x0006003d,
32150x00000006,0x000026d6,0x000026d4,0x000026d0, 36010x00000006,0x00002b84,0x00002b83,0x00000002,
32160x00050050,0x00000007,0x000026d7,0x000026d1, 36020x00000004,0x0004007c,0x00000027,0x00002b12,
32170x000026d6,0x0004007c,0x00000014,0x000026c7, 36030x00002b84,0x00060050,0x0000004b,0x00002b13,
32180x000026d7,0x00060041,0x000000d8,0x000026bf, 36040x00002b06,0x00002b0c,0x00002b12,0x00050080,
32190x000026c7,0x000000d7,0x000000d7,0x0005003e, 36050x00000006,0x00002b15,0x00002b01,0x00000118,
32200x000026bf,0x00002ac3,0x00000002,0x00000004, 36060x00050095,0x000000ab,0x00002bb5,0x00002ad0,
32210x00050080,0x00000006,0x000023a3,0x000023f2, 36070x00002b15,0x00050051,0x00000006,0x00002bb6,
32220x0000011c,0x00050084,0x00000006,0x000023a5, 36080x00002bb5,0x00000001,0x00050051,0x00000006,
32230x0000014d,0x00002aa5,0x00050080,0x00000006, 36090x00002bb7,0x00002bb5,0x00000000,0x00050080,
32240x000023a6,0x000023a3,0x000023a5,0x00050051, 36100x00000006,0x00002bbc,0x00002ad7,0x00002bb6,
32250x00000027,0x000023ab,0x00002ac7,0x00000000, 36110x00050050,0x00000007,0x00002bbd,0x00002bb7,
32260x0004007c,0x00000006,0x000026dd,0x000023ab, 36120x00002bbc,0x0004007c,0x00000014,0x00002bad,
32270x00050095,0x000000a8,0x000026f8,0x000026cd, 36130x00002bbd,0x00060041,0x000000db,0x00002ba4,
32280x000023a6,0x00050051,0x00000006,0x000026f9, 36140x00002bad,0x000000da,0x000000da,0x0006003d,
32290x000026f8,0x00000001,0x00050051,0x00000006, 36150x00000006,0x00002ba5,0x00002ba4,0x00000002,
32300x000026fa,0x000026f8,0x00000000,0x00050080, 36160x00000004,0x0004007c,0x00000027,0x00002b19,
32310x00000006,0x000026ff,0x000026d4,0x000026f9, 36170x00002ba5,0x00050080,0x00000006,0x00002b1b,
32320x00050050,0x00000007,0x00002700,0x000026fa, 36180x00002b01,0x0000011f,0x00050095,0x000000ab,
32330x000026ff,0x0004007c,0x00000014,0x000026f0, 36190x00002bd6,0x00002ad0,0x00002b1b,0x00050051,
32340x00002700,0x00060041,0x000000d8,0x000026e8, 36200x00000006,0x00002bd7,0x00002bd6,0x00000001,
32350x000026f0,0x000000d7,0x000000d7,0x0005003e, 36210x00050051,0x00000006,0x00002bd8,0x00002bd6,
32360x000026e8,0x000026dd,0x00000002,0x00000004, 36220x00000000,0x00050080,0x00000006,0x00002bdd,
32370x00050080,0x00000006,0x000023ae,0x000023a6, 36230x00002ad7,0x00002bd7,0x00050050,0x00000007,
32380x00000107,0x00050051,0x00000027,0x000023b2, 36240x00002bde,0x00002bd8,0x00002bdd,0x0004007c,
32390x00002ac7,0x00000001,0x0004007c,0x00000006, 36250x00000014,0x00002bce,0x00002bde,0x00060041,
32400x00002706,0x000023b2,0x00050095,0x000000a8, 36260x000000db,0x00002bc5,0x00002bce,0x000000da,
32410x00002721,0x000026cd,0x000023ae,0x00050051, 36270x000000da,0x0006003d,0x00000006,0x00002bc6,
32420x00000006,0x00002722,0x00002721,0x00000001, 36280x00002bc5,0x00000002,0x00000004,0x0004007c,
32430x00050051,0x00000006,0x00002723,0x00002721, 36290x00000027,0x00002b1f,0x00002bc6,0x00050080,
32440x00000000,0x00050080,0x00000006,0x00002728, 36300x00000006,0x00002b21,0x00002b01,0x00000189,
32450x000026d4,0x00002722,0x00050050,0x00000007, 36310x00050095,0x000000ab,0x00002bf7,0x00002ad0,
32460x00002729,0x00002723,0x00002728,0x0004007c, 36320x00002b21,0x00050051,0x00000006,0x00002bf8,
32470x00000014,0x00002719,0x00002729,0x00060041, 36330x00002bf7,0x00000001,0x00050051,0x00000006,
32480x000000d8,0x00002711,0x00002719,0x000000d7, 36340x00002bf9,0x00002bf7,0x00000000,0x00050080,
32490x000000d7,0x0005003e,0x00002711,0x00002706, 36350x00000006,0x00002bfe,0x00002ad7,0x00002bf8,
36360x00050050,0x00000007,0x00002bff,0x00002bf9,
36370x00002bfe,0x0004007c,0x00000014,0x00002bef,
36380x00002bff,0x00060041,0x000000db,0x00002be6,
36390x00002bef,0x000000da,0x000000da,0x0006003d,
36400x00000006,0x00002be7,0x00002be6,0x00000002,
36410x00000004,0x0004007c,0x00000027,0x00002b25,
36420x00002be7,0x00060050,0x0000004b,0x00002b26,
36430x00002b19,0x00002b1f,0x00002b25,0x000300f7,
36440x000027a9,0x00000000,0x000400fa,0x00002aee,
36450x0000279e,0x000027a9,0x000200f8,0x0000279e,
36460x00050084,0x00000006,0x000027a2,0x00000228,
36470x00002ac2,0x00050080,0x00000006,0x000027a3,
36480x00002ade,0x000027a2,0x00050080,0x00000006,
36490x000027a4,0x000027a3,0x000005d0,0x00050041,
36500x00000156,0x000027a5,0x000000fc,0x000000da,
36510x0004003d,0x00000007,0x000027a6,0x000027a5,
36520x00050051,0x00000006,0x00002c15,0x000027a6,
36530x00000000,0x00050095,0x000000ab,0x00002c17,
36540x00002c15,0x000027a4,0x00050051,0x00000006,
36550x00002c18,0x00002c17,0x00000001,0x00050051,
36560x00000006,0x00002c19,0x00002c17,0x00000000,
36570x00050051,0x00000006,0x00002c1c,0x000027a6,
36580x00000001,0x00050080,0x00000006,0x00002c1e,
36590x00002c1c,0x00002c18,0x00050050,0x00000007,
36600x00002c1f,0x00002c19,0x00002c1e,0x0004007c,
36610x00000014,0x00002c0f,0x00002c1f,0x00060041,
36620x000000db,0x00002c07,0x00002c0f,0x000000da,
36630x000000da,0x0005003e,0x00002c07,0x00002830,
36640x00000002,0x00000004,0x000200f9,0x000027a9,
36650x000200f8,0x000027a9,0x000200f9,0x000027b8,
36660x000200f8,0x000027aa,0x00050080,0x00000006,
36670x000027ae,0x0000278b,0x00002737,0x00050084,
36680x00000006,0x00002c25,0x000027ae,0x00000228,
36690x00050080,0x00000006,0x00002c26,0x0000282a,
36700x00002c25,0x000500c2,0x00000006,0x00002c27,
36710x00002c26,0x00000233,0x000500c4,0x00000006,
36720x00002c28,0x00002c27,0x0000020d,0x000500c5,
36730x00000006,0x00002c29,0x00002c28,0x00000246,
36740x00050041,0x000000fe,0x000027b1,0x000000fc,
36750x0000096c,0x0004003d,0x00000006,0x000027b2,
36760x000027b1,0x00050080,0x00000006,0x000027b4,
36770x000027b2,0x000027ae,0x00050041,0x000000fe,
36780x00002c69,0x000000fc,0x000000fd,0x0004003d,
36790x00000006,0x00002c6a,0x00002c69,0x00050084,
36800x00000006,0x00002c6b,0x0000011f,0x00002c6a,
36810x00050080,0x00000006,0x00002c6c,0x00000107,
36820x00002c6b,0x00050080,0x00000006,0x00002c72,
36830x00002c6a,0x000032a8,0x00050086,0x00000006,
36840x00002c73,0x00002c72,0x00000101,0x00050084,
36850x00000006,0x00002c65,0x00000107,0x00002c73,
36860x00050080,0x00000006,0x00002c66,0x00002c6c,
36870x00002c65,0x00050084,0x00000006,0x00002c3a,
36880x00000150,0x000027b4,0x00050080,0x00000006,
36890x00002c3b,0x00002c66,0x00002c3a,0x00050041,
36900x00000156,0x00002c3c,0x000000fc,0x00000154,
36910x0004003d,0x00000007,0x00002c3d,0x00002c3c,
36920x00050051,0x00000006,0x00002c8a,0x00002c3d,
36930x00000000,0x00050095,0x000000ab,0x00002c8c,
36940x00002c8a,0x00002c3b,0x00050051,0x00000006,
36950x00002c8d,0x00002c8c,0x00000001,0x00050051,
36960x00000006,0x00002c8e,0x00002c8c,0x00000000,
36970x00050051,0x00000006,0x00002c91,0x00002c3d,
36980x00000001,0x00050080,0x00000006,0x00002c93,
36990x00002c91,0x00002c8d,0x00050050,0x00000007,
37000x00002c94,0x00002c8e,0x00002c93,0x0004007c,
37010x00000014,0x00002c84,0x00002c94,0x00060041,
37020x000000db,0x00002c7b,0x00002c84,0x000000da,
37030x000000da,0x0006003d,0x00000006,0x00002c7c,
37040x00002c7b,0x00000002,0x00000004,0x0004007c,
37050x00000027,0x00002c40,0x00002c7c,0x00050080,
37060x00000006,0x00002c42,0x00002c3b,0x0000010a,
37070x00050095,0x000000ab,0x00002cad,0x00002c8a,
37080x00002c42,0x00050051,0x00000006,0x00002cae,
37090x00002cad,0x00000001,0x00050051,0x00000006,
37100x00002caf,0x00002cad,0x00000000,0x00050080,
37110x00000006,0x00002cb4,0x00002c91,0x00002cae,
37120x00050050,0x00000007,0x00002cb5,0x00002caf,
37130x00002cb4,0x0004007c,0x00000014,0x00002ca5,
37140x00002cb5,0x00060041,0x000000db,0x00002c9c,
37150x00002ca5,0x000000da,0x000000da,0x0006003d,
37160x00000006,0x00002c9d,0x00002c9c,0x00000002,
37170x00000004,0x0004007c,0x00000027,0x00002c46,
37180x00002c9d,0x00050080,0x00000006,0x00002c48,
37190x00002c3b,0x00000111,0x00050095,0x000000ab,
37200x00002cce,0x00002c8a,0x00002c48,0x00050051,
37210x00000006,0x00002ccf,0x00002cce,0x00000001,
37220x00050051,0x00000006,0x00002cd0,0x00002cce,
37230x00000000,0x00050080,0x00000006,0x00002cd5,
37240x00002c91,0x00002ccf,0x00050050,0x00000007,
37250x00002cd6,0x00002cd0,0x00002cd5,0x0004007c,
37260x00000014,0x00002cc6,0x00002cd6,0x00060041,
37270x000000db,0x00002cbd,0x00002cc6,0x000000da,
37280x000000da,0x0006003d,0x00000006,0x00002cbe,
37290x00002cbd,0x00000002,0x00000004,0x0004007c,
37300x00000027,0x00002c4c,0x00002cbe,0x00060050,
37310x0000004b,0x00002c4d,0x00002c40,0x00002c46,
37320x00002c4c,0x00050080,0x00000006,0x00002c4f,
37330x00002c3b,0x00000118,0x00050095,0x000000ab,
37340x00002cef,0x00002c8a,0x00002c4f,0x00050051,
37350x00000006,0x00002cf0,0x00002cef,0x00000001,
37360x00050051,0x00000006,0x00002cf1,0x00002cef,
37370x00000000,0x00050080,0x00000006,0x00002cf6,
37380x00002c91,0x00002cf0,0x00050050,0x00000007,
37390x00002cf7,0x00002cf1,0x00002cf6,0x0004007c,
37400x00000014,0x00002ce7,0x00002cf7,0x00060041,
37410x000000db,0x00002cde,0x00002ce7,0x000000da,
37420x000000da,0x0006003d,0x00000006,0x00002cdf,
37430x00002cde,0x00000002,0x00000004,0x0004007c,
37440x00000027,0x00002c53,0x00002cdf,0x00050080,
37450x00000006,0x00002c55,0x00002c3b,0x0000011f,
37460x00050095,0x000000ab,0x00002d10,0x00002c8a,
37470x00002c55,0x00050051,0x00000006,0x00002d11,
37480x00002d10,0x00000001,0x00050051,0x00000006,
37490x00002d12,0x00002d10,0x00000000,0x00050080,
37500x00000006,0x00002d17,0x00002c91,0x00002d11,
37510x00050050,0x00000007,0x00002d18,0x00002d12,
37520x00002d17,0x0004007c,0x00000014,0x00002d08,
37530x00002d18,0x00060041,0x000000db,0x00002cff,
37540x00002d08,0x000000da,0x000000da,0x0006003d,
37550x00000006,0x00002d00,0x00002cff,0x00000002,
37560x00000004,0x0004007c,0x00000027,0x00002c59,
37570x00002d00,0x00050080,0x00000006,0x00002c5b,
37580x00002c3b,0x00000189,0x00050095,0x000000ab,
37590x00002d31,0x00002c8a,0x00002c5b,0x00050051,
37600x00000006,0x00002d32,0x00002d31,0x00000001,
37610x00050051,0x00000006,0x00002d33,0x00002d31,
37620x00000000,0x00050080,0x00000006,0x00002d38,
37630x00002c91,0x00002d32,0x00050050,0x00000007,
37640x00002d39,0x00002d33,0x00002d38,0x0004007c,
37650x00000014,0x00002d29,0x00002d39,0x00060041,
37660x000000db,0x00002d20,0x00002d29,0x000000da,
37670x000000da,0x0006003d,0x00000006,0x00002d21,
37680x00002d20,0x00000002,0x00000004,0x0004007c,
37690x00000027,0x00002c5f,0x00002d21,0x00060050,
37700x0000004b,0x00002c60,0x00002c53,0x00002c59,
37710x00002c5f,0x000200f9,0x000027b8,0x000200f8,
37720x000027b8,0x000700f5,0x0000004b,0x000031a7,
37730x00002b26,0x000027a9,0x00002c60,0x000027aa,
37740x000700f5,0x0000004b,0x000031a5,0x00002b13,
37750x000027a9,0x00002c4d,0x000027aa,0x000700f5,
37760x00000006,0x000031a3,0x00002ae9,0x000027a9,
37770x00002c29,0x000027aa,0x00050041,0x000000fe,
37780x000027b9,0x000000fc,0x000009ef,0x0004003d,
37790x00000006,0x000027ba,0x000027b9,0x000500c2,
37800x00000006,0x00002d3d,0x000031a3,0x0000020d,
37810x00050041,0x000000fe,0x000027bd,0x000000fc,
37820x0000022c,0x0004003d,0x00000006,0x000027be,
37830x000027bd,0x00050086,0x00000006,0x000027bf,
37840x000027be,0x00000107,0x00050082,0x00000006,
37850x000027c0,0x00002d3d,0x000027bf,0x00050084,
37860x00000006,0x000027c1,0x0000010a,0x000027c0,
37870x00050080,0x00000006,0x000027c2,0x000027ba,
37880x000027c1,0x00050041,0x00000156,0x000027c3,
37890x000000fc,0x000000da,0x0004003d,0x00000007,
37900x000027c4,0x000027c3,0x00050051,0x00000006,
37910x00002d53,0x000027c4,0x00000000,0x00050095,
37920x000000ab,0x00002d55,0x00002d53,0x000027c2,
37930x00050051,0x00000006,0x00002d56,0x00002d55,
37940x00000001,0x00050051,0x00000006,0x00002d57,
37950x00002d55,0x00000000,0x00050051,0x00000006,
37960x00002d5a,0x000027c4,0x00000001,0x00050080,
37970x00000006,0x00002d5c,0x00002d5a,0x00002d56,
37980x00050050,0x00000007,0x00002d5d,0x00002d57,
37990x00002d5c,0x0004007c,0x00000014,0x00002d4d,
38000x00002d5d,0x00060041,0x000000db,0x00002d45,
38010x00002d4d,0x000000da,0x000000da,0x0005003e,
38020x00002d45,0x00002830,0x00000002,0x00000004,
38030x00050051,0x00000027,0x00002d61,0x000031a5,
38040x00000000,0x00050051,0x00000027,0x00002d63,
38050x000031a7,0x00000000,0x000500bc,0x0000002f,
38060x00002d64,0x00002d61,0x00002d63,0x000300f7,
38070x00002d6b,0x00000000,0x000400fa,0x00002d64,
38080x00002d65,0x00002d6b,0x000200f8,0x00002d65,
38090x00050051,0x00000027,0x00002d67,0x000031a5,
38100x00000001,0x00050051,0x00000027,0x00002d69,
38110x000031a7,0x00000001,0x000500bc,0x0000002f,
38120x00002d6a,0x00002d67,0x00002d69,0x000200f9,
38130x00002d6b,0x000200f8,0x00002d6b,0x000700f5,
38140x0000002f,0x00002d6c,0x00002d64,0x000027b8,
38150x00002d6a,0x00002d65,0x000300f7,0x00002d73,
38160x00000000,0x000400fa,0x00002d6c,0x00002d6d,
38170x00002d73,0x000200f8,0x00002d6d,0x00050051,
38180x00000027,0x00002d6f,0x000031a5,0x00000002,
38190x00050051,0x00000027,0x00002d71,0x000031a7,
38200x00000002,0x000500bc,0x0000002f,0x00002d72,
38210x00002d6f,0x00002d71,0x000200f9,0x00002d73,
38220x000200f8,0x00002d73,0x000700f5,0x0000002f,
38230x00002d74,0x00002d6c,0x00002d6b,0x00002d72,
38240x00002d6d,0x000300f7,0x000027d2,0x00000000,
38250x000400fa,0x00002d74,0x000027cb,0x000027d2,
38260x000200f8,0x000027cb,0x0007000c,0x0000004b,
38270x000027ce,0x00000001,0x00000025,0x000031a0,
38280x000031a5,0x0007000c,0x0000004b,0x000027d1,
38290x00000001,0x00000028,0x000031a2,0x000031a7,
38300x000200f9,0x000027d2,0x000200f8,0x000027d2,
38310x000700f5,0x0000004b,0x0000328f,0x000031a2,
38320x00002d73,0x000027d1,0x000027cb,0x000700f5,
38330x0000004b,0x0000328a,0x000031a0,0x00002d73,
38340x000027ce,0x000027cb,0x000200f9,0x000027d3,
38350x000200f8,0x000027d3,0x000700f5,0x0000004b,
38360x0000328e,0x000031a2,0x00002784,0x0000328f,
38370x000027d2,0x000700f5,0x0000004b,0x00003289,
38380x000031a0,0x00002784,0x0000328a,0x000027d2,
38390x000700f5,0x0000004b,0x000031e5,0x000032a7,
38400x00002784,0x000031a7,0x000027d2,0x000700f5,
38410x0000004b,0x000031e0,0x000032a5,0x00002784,
38420x000031a5,0x000027d2,0x000700f5,0x00000006,
38430x000031d9,0x00000380,0x00002784,0x000031a3,
38440x000027d2,0x000200f9,0x000027d4,0x000200f8,
38450x000027d4,0x000700f5,0x0000004b,0x0000328b,
38460x0000328c,0x00002783,0x0000328e,0x000027d3,
38470x000700f5,0x0000004b,0x00003286,0x00003287,
38480x00002783,0x00003289,0x000027d3,0x000700f5,
38490x0000004b,0x000031e2,0x000031e3,0x00002783,
38500x000031e5,0x000027d3,0x000700f5,0x0000004b,
38510x000031dd,0x000031de,0x00002783,0x000031e0,
38520x000027d3,0x000700f5,0x00000006,0x000031d2,
38530x00002839,0x00002783,0x000031d9,0x000027d3,
38540x00050084,0x00000006,0x000027d7,0x0000010a,
38550x0000319d,0x00050080,0x00000006,0x000027d8,
38560x0000282d,0x000027d7,0x00050041,0x00000156,
38570x000027d9,0x000000fc,0x000000da,0x0004003d,
38580x00000007,0x000027da,0x000027d9,0x00050051,
38590x00000006,0x00002d8b,0x000027da,0x00000000,
38600x00050095,0x000000ab,0x00002d8d,0x00002d8b,
38610x000027d8,0x00050051,0x00000006,0x00002d8e,
38620x00002d8d,0x00000001,0x00050051,0x00000006,
38630x00002d8f,0x00002d8d,0x00000000,0x00050051,
38640x00000006,0x00002d92,0x000027da,0x00000001,
38650x00050080,0x00000006,0x00002d94,0x00002d92,
38660x00002d8e,0x00050050,0x00000007,0x00002d95,
38670x00002d8f,0x00002d94,0x0004007c,0x00000014,
38680x00002d85,0x00002d95,0x00060041,0x000000db,
38690x00002d7d,0x00002d85,0x000000da,0x000000da,
38700x0005003e,0x00002d7d,0x000031d2,0x00000002,
38710x00000004,0x00050080,0x00000006,0x000027de,
38720x0000282d,0x0000011f,0x00050084,0x00000006,
38730x000027e0,0x00000150,0x0000319d,0x00050080,
38740x00000006,0x000027e1,0x000027de,0x000027e0,
38750x00050051,0x00000027,0x000027e6,0x000031dd,
38760x00000000,0x0004007c,0x00000006,0x00002d9b,
38770x000027e6,0x00050095,0x000000ab,0x00002db6,
38780x00002d8b,0x000027e1,0x00050051,0x00000006,
38790x00002db7,0x00002db6,0x00000001,0x00050051,
38800x00000006,0x00002db8,0x00002db6,0x00000000,
38810x00050080,0x00000006,0x00002dbd,0x00002d92,
38820x00002db7,0x00050050,0x00000007,0x00002dbe,
38830x00002db8,0x00002dbd,0x0004007c,0x00000014,
38840x00002dae,0x00002dbe,0x00060041,0x000000db,
38850x00002da6,0x00002dae,0x000000da,0x000000da,
38860x0005003e,0x00002da6,0x00002d9b,0x00000002,
38870x00000004,0x00050080,0x00000006,0x000027e9,
38880x000027e1,0x0000010a,0x00050051,0x00000027,
38890x000027ed,0x000031dd,0x00000001,0x0004007c,
38900x00000006,0x00002dc4,0x000027ed,0x00050095,
38910x000000ab,0x00002ddf,0x00002d8b,0x000027e9,
38920x00050051,0x00000006,0x00002de0,0x00002ddf,
38930x00000001,0x00050051,0x00000006,0x00002de1,
38940x00002ddf,0x00000000,0x00050080,0x00000006,
38950x00002de6,0x00002d92,0x00002de0,0x00050050,
38960x00000007,0x00002de7,0x00002de1,0x00002de6,
38970x0004007c,0x00000014,0x00002dd7,0x00002de7,
38980x00060041,0x000000db,0x00002dcf,0x00002dd7,
38990x000000da,0x000000da,0x0005003e,0x00002dcf,
39000x00002dc4,0x00000002,0x00000004,0x00050080,
39010x00000006,0x000027f0,0x000027e1,0x00000111,
39020x00050051,0x00000027,0x000027f4,0x000031dd,
39030x00000002,0x0004007c,0x00000006,0x00002ded,
39040x000027f4,0x00050095,0x000000ab,0x00002e08,
39050x00002d8b,0x000027f0,0x00050051,0x00000006,
39060x00002e09,0x00002e08,0x00000001,0x00050051,
39070x00000006,0x00002e0a,0x00002e08,0x00000000,
39080x00050080,0x00000006,0x00002e0f,0x00002d92,
39090x00002e09,0x00050050,0x00000007,0x00002e10,
39100x00002e0a,0x00002e0f,0x0004007c,0x00000014,
39110x00002e00,0x00002e10,0x00060041,0x000000db,
39120x00002df8,0x00002e00,0x000000da,0x000000da,
39130x0005003e,0x00002df8,0x00002ded,0x00000002,
39140x00000004,0x00050080,0x00000006,0x000027f7,
39150x000027e1,0x00000118,0x00050051,0x00000027,
39160x000027fb,0x000031e2,0x00000000,0x0004007c,
39170x00000006,0x00002e16,0x000027fb,0x00050095,
39180x000000ab,0x00002e31,0x00002d8b,0x000027f7,
39190x00050051,0x00000006,0x00002e32,0x00002e31,
39200x00000001,0x00050051,0x00000006,0x00002e33,
39210x00002e31,0x00000000,0x00050080,0x00000006,
39220x00002e38,0x00002d92,0x00002e32,0x00050050,
39230x00000007,0x00002e39,0x00002e33,0x00002e38,
39240x0004007c,0x00000014,0x00002e29,0x00002e39,
39250x00060041,0x000000db,0x00002e21,0x00002e29,
39260x000000da,0x000000da,0x0005003e,0x00002e21,
39270x00002e16,0x00000002,0x00000004,0x00050080,
39280x00000006,0x000027fe,0x000027e1,0x0000011f,
39290x00050051,0x00000027,0x00002802,0x000031e2,
39300x00000001,0x0004007c,0x00000006,0x00002e3f,
39310x00002802,0x00050095,0x000000ab,0x00002e5a,
39320x00002d8b,0x000027fe,0x00050051,0x00000006,
39330x00002e5b,0x00002e5a,0x00000001,0x00050051,
39340x00000006,0x00002e5c,0x00002e5a,0x00000000,
39350x00050080,0x00000006,0x00002e61,0x00002d92,
39360x00002e5b,0x00050050,0x00000007,0x00002e62,
39370x00002e5c,0x00002e61,0x0004007c,0x00000014,
39380x00002e52,0x00002e62,0x00060041,0x000000db,
39390x00002e4a,0x00002e52,0x000000da,0x000000da,
39400x0005003e,0x00002e4a,0x00002e3f,0x00000002,
39410x00000004,0x00050080,0x00000006,0x00002805,
39420x000027e1,0x00000189,0x00050051,0x00000027,
39430x00002809,0x000031e2,0x00000002,0x0004007c,
39440x00000006,0x00002e68,0x00002809,0x00050095,
39450x000000ab,0x00002e83,0x00002d8b,0x00002805,
39460x00050051,0x00000006,0x00002e84,0x00002e83,
39470x00000001,0x00050051,0x00000006,0x00002e85,
39480x00002e83,0x00000000,0x00050080,0x00000006,
39490x00002e8a,0x00002d92,0x00002e84,0x00050050,
39500x00000007,0x00002e8b,0x00002e85,0x00002e8a,
39510x0004007c,0x00000014,0x00002e7b,0x00002e8b,
39520x00060041,0x000000db,0x00002e73,0x00002e7b,
39530x000000da,0x000000da,0x0005003e,0x00002e73,
39540x00002e68,0x00000002,0x00000004,0x000200f9,
39550x0000280b,0x000200f8,0x0000280b,0x00050080,
39560x00000006,0x0000280d,0x0000319d,0x00000154,
39570x000200f9,0x0000272f,0x000200f8,0x0000280e,
39580x000200f9,0x0000280f,0x000200f8,0x0000280f,
39590x000700f5,0x00000006,0x0000319e,0x000000a6,
39600x0000280e,0x0000281e,0x00002813,0x000500b0,
39610x0000002f,0x00002812,0x0000319e,0x0000010a,
39620x000400f6,0x0000281f,0x00002813,0x00000000,
39630x000400fa,0x00002812,0x00002813,0x0000281f,
39640x000200f8,0x00002813,0x00050080,0x00000006,
39650x00002815,0x0000282d,0x000005c6,0x00050084,
39660x00000006,0x00002817,0x0000010a,0x0000319e,
39670x00050080,0x00000006,0x00002818,0x00002815,
39680x00002817,0x00050041,0x00000156,0x00002819,
39690x000000fc,0x000000da,0x0004003d,0x00000007,
39700x0000281a,0x00002819,0x00050051,0x00000006,
39710x00002ea1,0x0000281a,0x00000000,0x00050095,
39720x000000ab,0x00002ea3,0x00002ea1,0x00002818,
39730x00050051,0x00000006,0x00002ea4,0x00002ea3,
39740x00000001,0x00050051,0x00000006,0x00002ea5,
39750x00002ea3,0x00000000,0x00050051,0x00000006,
39760x00002ea8,0x0000281a,0x00000001,0x00050080,
39770x00000006,0x00002eaa,0x00002ea8,0x00002ea4,
39780x00050050,0x00000007,0x00002eab,0x00002ea5,
39790x00002eaa,0x0004007c,0x00000014,0x00002e9b,
39800x00002eab,0x00060041,0x000000db,0x00002e93,
39810x00002e9b,0x000000da,0x000000da,0x0005003e,
39820x00002e93,0x000000a6,0x00000002,0x00000004,
39830x00050080,0x00000006,0x0000281e,0x0000319e,
39840x00000154,0x000200f9,0x0000280f,0x000200f8,
39850x0000281f,0x00050041,0x000000fe,0x00002820,
39860x000000fc,0x0000096c,0x0004003d,0x00000006,
39870x00002821,0x00002820,0x00050080,0x00000006,
39880x00002823,0x00002821,0x00002723,0x00050041,
39890x000000fe,0x00002ef5,0x000000fc,0x000000fd,
39900x0004003d,0x00000006,0x00002ef6,0x00002ef5,
39910x00050084,0x00000006,0x00002ef7,0x0000011f,
39920x00002ef6,0x00050080,0x00000006,0x00002ef8,
39930x00000107,0x00002ef7,0x00050080,0x00000006,
39940x00002efe,0x00002ef6,0x000032a8,0x00050086,
39950x00000006,0x00002eff,0x00002efe,0x00000101,
39960x00050084,0x00000006,0x00002ef1,0x00000107,
39970x00002eff,0x00050080,0x00000006,0x00002ef2,
39980x00002ef8,0x00002ef1,0x00050084,0x00000006,
39990x00002ec2,0x00000150,0x00002823,0x00050080,
40000x00000006,0x00002ec3,0x00002ef2,0x00002ec2,
40010x00050041,0x00000156,0x00002ec4,0x000000fc,
40020x00000154,0x0004003d,0x00000007,0x00002ec5,
40030x00002ec4,0x00050051,0x00000027,0x00002ec8,
40040x000031a0,0x00000000,0x0004007c,0x00000006,
40050x00002f05,0x00002ec8,0x00050051,0x00000006,
40060x00002f1e,0x00002ec5,0x00000000,0x00050095,
40070x000000ab,0x00002f20,0x00002f1e,0x00002ec3,
40080x00050051,0x00000006,0x00002f21,0x00002f20,
40090x00000001,0x00050051,0x00000006,0x00002f22,
40100x00002f20,0x00000000,0x00050051,0x00000006,
40110x00002f25,0x00002ec5,0x00000001,0x00050080,
40120x00000006,0x00002f27,0x00002f25,0x00002f21,
40130x00050050,0x00000007,0x00002f28,0x00002f22,
40140x00002f27,0x0004007c,0x00000014,0x00002f18,
40150x00002f28,0x00060041,0x000000db,0x00002f10,
40160x00002f18,0x000000da,0x000000da,0x0005003e,
40170x00002f10,0x00002f05,0x00000002,0x00000004,
40180x00050080,0x00000006,0x00002ecb,0x00002ec3,
40190x0000010a,0x00050051,0x00000027,0x00002ecf,
40200x000031a0,0x00000001,0x0004007c,0x00000006,
40210x00002f2e,0x00002ecf,0x00050095,0x000000ab,
40220x00002f49,0x00002f1e,0x00002ecb,0x00050051,
40230x00000006,0x00002f4a,0x00002f49,0x00000001,
40240x00050051,0x00000006,0x00002f4b,0x00002f49,
40250x00000000,0x00050080,0x00000006,0x00002f50,
40260x00002f25,0x00002f4a,0x00050050,0x00000007,
40270x00002f51,0x00002f4b,0x00002f50,0x0004007c,
40280x00000014,0x00002f41,0x00002f51,0x00060041,
40290x000000db,0x00002f39,0x00002f41,0x000000da,
40300x000000da,0x0005003e,0x00002f39,0x00002f2e,
32500x00000002,0x00000004,0x00050080,0x00000006, 40310x00000002,0x00000004,0x00050080,0x00000006,
32510x000023b5,0x000023a6,0x0000010e,0x00050051, 40320x00002ed2,0x00002ec3,0x00000111,0x00050051,
32520x00000027,0x000023b9,0x00002ac7,0x00000002, 40330x00000027,0x00002ed6,0x000031a0,0x00000002,
32530x0004007c,0x00000006,0x0000272f,0x000023b9, 40340x0004007c,0x00000006,0x00002f57,0x00002ed6,
32540x00050095,0x000000a8,0x0000274a,0x000026cd, 40350x00050095,0x000000ab,0x00002f72,0x00002f1e,
32550x000023b5,0x00050051,0x00000006,0x0000274b, 40360x00002ed2,0x00050051,0x00000006,0x00002f73,
32560x0000274a,0x00000001,0x00050051,0x00000006, 40370x00002f72,0x00000001,0x00050051,0x00000006,
32570x0000274c,0x0000274a,0x00000000,0x00050080, 40380x00002f74,0x00002f72,0x00000000,0x00050080,
32580x00000006,0x00002751,0x000026d4,0x0000274b, 40390x00000006,0x00002f79,0x00002f25,0x00002f73,
32590x00050050,0x00000007,0x00002752,0x0000274c, 40400x00050050,0x00000007,0x00002f7a,0x00002f74,
32600x00002751,0x0004007c,0x00000014,0x00002742, 40410x00002f79,0x0004007c,0x00000014,0x00002f6a,
32610x00002752,0x00060041,0x000000d8,0x0000273a, 40420x00002f7a,0x00060041,0x000000db,0x00002f62,
32620x00002742,0x000000d7,0x000000d7,0x0005003e, 40430x00002f6a,0x000000da,0x000000da,0x0005003e,
32630x0000273a,0x0000272f,0x00000002,0x00000004, 40440x00002f62,0x00002f57,0x00000002,0x00000004,
32640x00050080,0x00000006,0x000023bc,0x000023a6, 40450x00050080,0x00000006,0x00002ed9,0x00002ec3,
32650x00000115,0x00050051,0x00000027,0x000023c0, 40460x00000118,0x00050051,0x00000027,0x00002edd,
32660x00002ac9,0x00000000,0x0004007c,0x00000006, 40470x000031a2,0x00000000,0x0004007c,0x00000006,
32670x00002758,0x000023c0,0x00050095,0x000000a8, 40480x00002f80,0x00002edd,0x00050095,0x000000ab,
32680x00002773,0x000026cd,0x000023bc,0x00050051, 40490x00002f9b,0x00002f1e,0x00002ed9,0x00050051,
32690x00000006,0x00002774,0x00002773,0x00000001, 40500x00000006,0x00002f9c,0x00002f9b,0x00000001,
32700x00050051,0x00000006,0x00002775,0x00002773, 40510x00050051,0x00000006,0x00002f9d,0x00002f9b,
32710x00000000,0x00050080,0x00000006,0x0000277a, 40520x00000000,0x00050080,0x00000006,0x00002fa2,
32720x000026d4,0x00002774,0x00050050,0x00000007, 40530x00002f25,0x00002f9c,0x00050050,0x00000007,
32730x0000277b,0x00002775,0x0000277a,0x0004007c, 40540x00002fa3,0x00002f9d,0x00002fa2,0x0004007c,
32740x00000014,0x0000276b,0x0000277b,0x00060041, 40550x00000014,0x00002f93,0x00002fa3,0x00060041,
32750x000000d8,0x00002763,0x0000276b,0x000000d7, 40560x000000db,0x00002f8b,0x00002f93,0x000000da,
32760x000000d7,0x0005003e,0x00002763,0x00002758, 40570x000000da,0x0005003e,0x00002f8b,0x00002f80,
32770x00000002,0x00000004,0x00050080,0x00000006, 40580x00000002,0x00000004,0x00050080,0x00000006,
32780x000023c3,0x000023a6,0x0000011c,0x00050051, 40590x00002ee0,0x00002ec3,0x0000011f,0x00050051,
32790x00000027,0x000023c7,0x00002ac9,0x00000001, 40600x00000027,0x00002ee4,0x000031a2,0x00000001,
32800x0004007c,0x00000006,0x00002781,0x000023c7, 40610x0004007c,0x00000006,0x00002fa9,0x00002ee4,
32810x00050095,0x000000a8,0x0000279c,0x000026cd, 40620x00050095,0x000000ab,0x00002fc4,0x00002f1e,
32820x000023c3,0x00050051,0x00000006,0x0000279d, 40630x00002ee0,0x00050051,0x00000006,0x00002fc5,
32830x0000279c,0x00000001,0x00050051,0x00000006, 40640x00002fc4,0x00000001,0x00050051,0x00000006,
32840x0000279e,0x0000279c,0x00000000,0x00050080, 40650x00002fc6,0x00002fc4,0x00000000,0x00050080,
32850x00000006,0x000027a3,0x000026d4,0x0000279d, 40660x00000006,0x00002fcb,0x00002f25,0x00002fc5,
32860x00050050,0x00000007,0x000027a4,0x0000279e, 40670x00050050,0x00000007,0x00002fcc,0x00002fc6,
32870x000027a3,0x0004007c,0x00000014,0x00002794, 40680x00002fcb,0x0004007c,0x00000014,0x00002fbc,
32880x000027a4,0x00060041,0x000000d8,0x0000278c, 40690x00002fcc,0x00060041,0x000000db,0x00002fb4,
32890x00002794,0x000000d7,0x000000d7,0x0005003e, 40700x00002fbc,0x000000da,0x000000da,0x0005003e,
32900x0000278c,0x00002781,0x00000002,0x00000004, 40710x00002fb4,0x00002fa9,0x00000002,0x00000004,
32910x00050080,0x00000006,0x000023ca,0x000023a6, 40720x00050080,0x00000006,0x00002ee7,0x00002ec3,
32920x00000186,0x00050051,0x00000027,0x000023ce, 40730x00000189,0x00050051,0x00000027,0x00002eeb,
32930x00002ac9,0x00000002,0x0004007c,0x00000006, 40740x000031a2,0x00000002,0x0004007c,0x00000006,
32940x000027aa,0x000023ce,0x00050095,0x000000a8, 40750x00002fd2,0x00002eeb,0x00050095,0x000000ab,
32950x000027c5,0x000026cd,0x000023ca,0x00050051, 40760x00002fed,0x00002f1e,0x00002ee7,0x00050051,
32960x00000006,0x000027c6,0x000027c5,0x00000001, 40770x00000006,0x00002fee,0x00002fed,0x00000001,
32970x00050051,0x00000006,0x000027c7,0x000027c5, 40780x00050051,0x00000006,0x00002fef,0x00002fed,
32980x00000000,0x00050080,0x00000006,0x000027cc, 40790x00000000,0x00050080,0x00000006,0x00002ff4,
32990x000026d4,0x000027c6,0x00050050,0x00000007, 40800x00002f25,0x00002fee,0x00050050,0x00000007,
33000x000027cd,0x000027c7,0x000027cc,0x0004007c, 40810x00002ff5,0x00002fef,0x00002ff4,0x0004007c,
33010x00000014,0x000027bd,0x000027cd,0x00060041, 40820x00000014,0x00002fe5,0x00002ff5,0x00060041,
33020x000000d8,0x000027b5,0x000027bd,0x000000d7, 40830x000000db,0x00002fdd,0x00002fe5,0x000000da,
33030x000000d7,0x0005003e,0x000027b5,0x000027aa, 40840x000000da,0x0005003e,0x00002fdd,0x00002fd2,
33040x00000002,0x00000004,0x000200f9,0x000023d0, 40850x00000002,0x00000004,0x000200f9,0x00000bed,
33050x000200f8,0x000023d0,0x00050080,0x00000006, 40860x000200f8,0x00000bed,0x000200f9,0x00000be4,
33060x000023d2,0x00002aa5,0x00000151,0x000200f9, 40870x000200f8,0x00000be4,0x000200f9,0x00000bdb,
33070x0000233e,0x000200f8,0x000023d3,0x000200f9, 40880x000200f8,0x00000bdb,0x000200f9,0x00000bd2,
33080x000023d4,0x000200f8,0x000023d4,0x000700f5, 40890x000200f8,0x00000bd2,0x000200f9,0x00000bac,
33090x00000006,0x00002aa6,0x000000a3,0x000023d3, 40900x000200f8,0x00000bac,0x000200f9,0x00000b97,
33100x000023e3,0x000023d8,0x000500b0,0x0000002f, 40910x000200f8,0x00000b97,0x000200f9,0x00000bf3,
33110x000023d7,0x00002aa6,0x00000107,0x000400f6, 40920x000200f8,0x00000bf3,0x000100fd,0x00010038}
33120x000023e4,0x000023d8,0x00000000,0x000400fa,
33130x000023d7,0x000023d8,0x000023e4,0x000200f8,
33140x000023d8,0x00050080,0x00000006,0x000023da,
33150x000023f2,0x000005c3,0x00050084,0x00000006,
33160x000023dc,0x00000107,0x00002aa6,0x00050080,
33170x00000006,0x000023dd,0x000023da,0x000023dc,
33180x00050041,0x00000153,0x000023de,0x000000f9,
33190x000000d7,0x0004003d,0x00000007,0x000023df,
33200x000023de,0x00050051,0x00000006,0x000027e3,
33210x000023df,0x00000000,0x00050095,0x000000a8,
33220x000027e5,0x000027e3,0x000023dd,0x00050051,
33230x00000006,0x000027e6,0x000027e5,0x00000001,
33240x00050051,0x00000006,0x000027e7,0x000027e5,
33250x00000000,0x00050051,0x00000006,0x000027ea,
33260x000023df,0x00000001,0x00050080,0x00000006,
33270x000027ec,0x000027ea,0x000027e6,0x00050050,
33280x00000007,0x000027ed,0x000027e7,0x000027ec,
33290x0004007c,0x00000014,0x000027dd,0x000027ed,
33300x00060041,0x000000d8,0x000027d5,0x000027dd,
33310x000000d7,0x000000d7,0x0005003e,0x000027d5,
33320x000000a3,0x00000002,0x00000004,0x00050080,
33330x00000006,0x000023e3,0x00002aa6,0x00000151,
33340x000200f9,0x000023d4,0x000200f8,0x000023e4,
33350x00050041,0x000000fb,0x000023e5,0x000000f9,
33360x000008bc,0x0004003d,0x00000006,0x000023e6,
33370x000023e5,0x00050080,0x00000006,0x000023e8,
33380x000023e6,0x00002332,0x00050041,0x000000fb,
33390x00002837,0x000000f9,0x000000fa,0x0004003d,
33400x00000006,0x00002838,0x00002837,0x00050084,
33410x00000006,0x00002839,0x0000011c,0x00002838,
33420x00050080,0x00000006,0x0000283a,0x00000104,
33430x00002839,0x00050080,0x00000006,0x00002840,
33440x00002838,0x00002b67,0x00050086,0x00000006,
33450x00002841,0x00002840,0x000000fe,0x00050084,
33460x00000006,0x00002833,0x00000104,0x00002841,
33470x00050080,0x00000006,0x00002834,0x0000283a,
33480x00002833,0x00050084,0x00000006,0x00002804,
33490x0000014d,0x000023e8,0x00050080,0x00000006,
33500x00002805,0x00002834,0x00002804,0x00050041,
33510x00000153,0x00002806,0x000000f9,0x00000151,
33520x0004003d,0x00000007,0x00002807,0x00002806,
33530x00050051,0x00000027,0x0000280a,0x00002aa8,
33540x00000000,0x0004007c,0x00000006,0x00002847,
33550x0000280a,0x00050051,0x00000006,0x00002860,
33560x00002807,0x00000000,0x00050095,0x000000a8,
33570x00002862,0x00002860,0x00002805,0x00050051,
33580x00000006,0x00002863,0x00002862,0x00000001,
33590x00050051,0x00000006,0x00002864,0x00002862,
33600x00000000,0x00050051,0x00000006,0x00002867,
33610x00002807,0x00000001,0x00050080,0x00000006,
33620x00002869,0x00002867,0x00002863,0x00050050,
33630x00000007,0x0000286a,0x00002864,0x00002869,
33640x0004007c,0x00000014,0x0000285a,0x0000286a,
33650x00060041,0x000000d8,0x00002852,0x0000285a,
33660x000000d7,0x000000d7,0x0005003e,0x00002852,
33670x00002847,0x00000002,0x00000004,0x00050080,
33680x00000006,0x0000280d,0x00002805,0x00000107,
33690x00050051,0x00000027,0x00002811,0x00002aa8,
33700x00000001,0x0004007c,0x00000006,0x00002870,
33710x00002811,0x00050095,0x000000a8,0x0000288b,
33720x00002860,0x0000280d,0x00050051,0x00000006,
33730x0000288c,0x0000288b,0x00000001,0x00050051,
33740x00000006,0x0000288d,0x0000288b,0x00000000,
33750x00050080,0x00000006,0x00002892,0x00002867,
33760x0000288c,0x00050050,0x00000007,0x00002893,
33770x0000288d,0x00002892,0x0004007c,0x00000014,
33780x00002883,0x00002893,0x00060041,0x000000d8,
33790x0000287b,0x00002883,0x000000d7,0x000000d7,
33800x0005003e,0x0000287b,0x00002870,0x00000002,
33810x00000004,0x00050080,0x00000006,0x00002814,
33820x00002805,0x0000010e,0x00050051,0x00000027,
33830x00002818,0x00002aa8,0x00000002,0x0004007c,
33840x00000006,0x00002899,0x00002818,0x00050095,
33850x000000a8,0x000028b4,0x00002860,0x00002814,
33860x00050051,0x00000006,0x000028b5,0x000028b4,
33870x00000001,0x00050051,0x00000006,0x000028b6,
33880x000028b4,0x00000000,0x00050080,0x00000006,
33890x000028bb,0x00002867,0x000028b5,0x00050050,
33900x00000007,0x000028bc,0x000028b6,0x000028bb,
33910x0004007c,0x00000014,0x000028ac,0x000028bc,
33920x00060041,0x000000d8,0x000028a4,0x000028ac,
33930x000000d7,0x000000d7,0x0005003e,0x000028a4,
33940x00002899,0x00000002,0x00000004,0x00050080,
33950x00000006,0x0000281b,0x00002805,0x00000115,
33960x00050051,0x00000027,0x0000281f,0x00002aaa,
33970x00000000,0x0004007c,0x00000006,0x000028c2,
33980x0000281f,0x00050095,0x000000a8,0x000028dd,
33990x00002860,0x0000281b,0x00050051,0x00000006,
34000x000028de,0x000028dd,0x00000001,0x00050051,
34010x00000006,0x000028df,0x000028dd,0x00000000,
34020x00050080,0x00000006,0x000028e4,0x00002867,
34030x000028de,0x00050050,0x00000007,0x000028e5,
34040x000028df,0x000028e4,0x0004007c,0x00000014,
34050x000028d5,0x000028e5,0x00060041,0x000000d8,
34060x000028cd,0x000028d5,0x000000d7,0x000000d7,
34070x0005003e,0x000028cd,0x000028c2,0x00000002,
34080x00000004,0x00050080,0x00000006,0x00002822,
34090x00002805,0x0000011c,0x00050051,0x00000027,
34100x00002826,0x00002aaa,0x00000001,0x0004007c,
34110x00000006,0x000028eb,0x00002826,0x00050095,
34120x000000a8,0x00002906,0x00002860,0x00002822,
34130x00050051,0x00000006,0x00002907,0x00002906,
34140x00000001,0x00050051,0x00000006,0x00002908,
34150x00002906,0x00000000,0x00050080,0x00000006,
34160x0000290d,0x00002867,0x00002907,0x00050050,
34170x00000007,0x0000290e,0x00002908,0x0000290d,
34180x0004007c,0x00000014,0x000028fe,0x0000290e,
34190x00060041,0x000000d8,0x000028f6,0x000028fe,
34200x000000d7,0x000000d7,0x0005003e,0x000028f6,
34210x000028eb,0x00000002,0x00000004,0x00050080,
34220x00000006,0x00002829,0x00002805,0x00000186,
34230x00050051,0x00000027,0x0000282d,0x00002aaa,
34240x00000002,0x0004007c,0x00000006,0x00002914,
34250x0000282d,0x00050095,0x000000a8,0x0000292f,
34260x00002860,0x00002829,0x00050051,0x00000006,
34270x00002930,0x0000292f,0x00000001,0x00050051,
34280x00000006,0x00002931,0x0000292f,0x00000000,
34290x00050080,0x00000006,0x00002936,0x00002867,
34300x00002930,0x00050050,0x00000007,0x00002937,
34310x00002931,0x00002936,0x0004007c,0x00000014,
34320x00002927,0x00002937,0x00060041,0x000000d8,
34330x0000291f,0x00002927,0x000000d7,0x000000d7,
34340x0005003e,0x0000291f,0x00002914,0x00000002,
34350x00000004,0x000200f9,0x00000a68,0x000200f8,
34360x00000a68,0x000200f9,0x00000a5f,0x000200f8,
34370x00000a5f,0x000200f9,0x00000a56,0x000200f8,
34380x00000a56,0x000200f9,0x00000a4d,0x000200f8,
34390x00000a4d,0x000200f9,0x00000a27,0x000200f8,
34400x00000a27,0x000200f9,0x00000a6e,0x000200f8,
34410x00000a6e,0x000100fd,0x00010038}
diff --git a/runtime/test/allocator_proxy_test.cpp b/runtime/test/allocator_proxy_test.cpp
new file mode 100644
index 000000000..733e37cac
--- /dev/null
+++ b/runtime/test/allocator_proxy_test.cpp
@@ -0,0 +1,382 @@
1// Xbox-ABI command allocator proxies (d3d12_xs_device.h, device slot 9) behind the device proxy, on the Vulkan-backed
2// device and on the host PC runtime (WARP, and the first hardware adapter when there is one):
3// - Vulkan device: slot 9 wraps the allocator; the public chain (9 slots) is forwarded with the real allocator's
4// answers, every slot past it up to the end of the table is refused (E_NOTIMPL), and a read past the table faults
5// in the guard region and is counted;
6// - QueryInterface identity, GetDevice -> the device proxy, references and release orders;
7// - a command list created on the proxy and Reset on it (the Vulkan layer resolves the proxy), recording a buffer
8// copy that runs through the queue and fence proxies and is read back, twice, with the allocator Reset between;
9// and D3D12's allocator rules through the proxy (Reset while a list records: E_FAIL; a second list on a busy
10// allocator: E_INVALIDARG);
11// - MakeResident/Evict with an allocator proxy give the real allocator's HRESULT;
12// - host runtime: slot 9 hands out the PC allocator unwrapped (its lists could not resolve a proxy), and the same
13// copy works.
14// LEONIDA_VK_VALIDATION=1 runs the Vulkan device under VK_LAYER_KHRONOS_validation with synchronization validation;
15// any validation error fails the test. Exits 77 when neither a host D3D12 device nor a Vulkan device can be made.
16// No shaders, game data or Xbox DLLs.
17#include "vk_test_device.h"
18#include "../shims/d3d12_com.h"
19#include "../shims/d3d12_xs_device.h"
20
21#include <d3d12.h>
22#include <dxgi1_4.h>
23
24#include <cstdint>
25#include <cstdio>
26#include <cstring>
27
28#define EXPECT(condition) do { \
29 if (!(condition)) { std::fprintf(stderr, "%s line %d: %s\n", label, __LINE__, #condition); return 1; } \
30} while (0)
31
32namespace {
33
34namespace xs = rt::d3d12_xs;
35
36template <class T>
37struct Ref {
38 T* p = nullptr;
39 Ref() = default;
40 Ref(const Ref&) = delete;
41 Ref& operator=(const Ref&) = delete;
42 ~Ref() { reset(); }
43 void reset() {
44 if (p) p->Release();
45 p = nullptr;
46 }
47 T* operator->() const { return p; }
48};
49
50struct Backend {
51 const char* label;
52 ID3D12Device* device; // the device proxy
53 ID3D12Device* real; // the device behind it (PC runtime or Vulkan layer)
54 bool vulkan;
55};
56
57using SlotFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t,
58 std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t,
59 std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t);
60
61// A call through slot `slot` with all words zero, the way a title calls a console method the PC interface lacks.
62HRESULT call_slot(void* object, unsigned slot) {
63 void** vtable = *reinterpret_cast<void***>(object);
64 return static_cast<HRESULT>(static_cast<std::uint32_t>(
65 reinterpret_cast<SlotFn>(vtable[slot])(object, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
66}
67
68ULONG_PTR g_fault_address = 0;
69
70int record_fault(EXCEPTION_POINTERS* info) {
71 g_fault_address = info->ExceptionRecord->NumberParameters >= 2 ? info->ExceptionRecord->ExceptionInformation[1] : 0;
72 return EXCEPTION_EXECUTE_HANDLER;
73}
74
75// The read in a function of its own: clang-cl's __try only catches a fault raised inside a call.
76__declspec(noinline) void* read_entry(void* const* vtable, unsigned slot) {
77 return *static_cast<void* const volatile*>(&vtable[slot]);
78}
79
80// Reads vtable[slot] the way a call through it does. The exception code, or 0 when the read worked.
81DWORD read_slot_guarded(void* const* vtable, unsigned slot) {
82 g_fault_address = 0;
83 __try {
84 void* volatile entry = read_entry(vtable, slot);
85 (void)entry;
86 return 0;
87 } __except (record_fault(GetExceptionInformation())) {
88 return GetExceptionCode();
89 }
90}
91
92int wait_for(const char* label, ID3D12Fence* fence, UINT64 value) {
93 HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
94 EXPECT(event != nullptr);
95 const bool set = SUCCEEDED(fence->SetEventOnCompletion(value, event)) && WaitForSingleObject(event, 5000) == 0;
96 CloseHandle(event);
97 EXPECT(set && fence->GetCompletedValue() >= value);
98 return 0;
99}
100
101int make_buffer(const char* label, ID3D12Device* device, D3D12_HEAP_TYPE heap_type, D3D12_RESOURCE_STATES state,
102 Ref<ID3D12Resource>& out) {
103 D3D12_HEAP_PROPERTIES heap{};
104 heap.Type = heap_type;
105 D3D12_RESOURCE_DESC desc{};
106 desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
107 desc.Width = 256;
108 desc.Height = desc.DepthOrArraySize = desc.MipLevels = 1;
109 desc.SampleDesc.Count = 1;
110 desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
111 EXPECT(SUCCEEDED(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, state, nullptr,
112 IID_PPV_ARGS(&out.p))));
113 return 0;
114}
115
116// One recording on `list` (open, recording into the allocator): 256 bytes of `byte` copied from an upload buffer to a
117// readback buffer, executed through the queue proxy, finished through the fence proxy at `value`, then compared.
118int copy_round(const char* label, ID3D12Device* device, ID3D12CommandQueue* queue, ID3D12Fence* fence,
119 ID3D12GraphicsCommandList* list, std::uint8_t byte, UINT64 value) {
120 Ref<ID3D12Resource> upload, readback;
121 if (make_buffer(label, device, D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, upload)) return 1;
122 if (make_buffer(label, device, D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST, readback)) return 1;
123 void* mapped = nullptr;
124 EXPECT(SUCCEEDED(upload->Map(0, nullptr, &mapped)) && mapped);
125 std::memset(mapped, byte, 256);
126 upload->Unmap(0, nullptr);
127 list->CopyBufferRegion(readback.p, 0, upload.p, 0, 256);
128 EXPECT(SUCCEEDED(list->Close()));
129 ID3D12CommandList* lists[] = {list};
130 queue->ExecuteCommandLists(1, lists);
131 EXPECT(SUCCEEDED(queue->Signal(fence, value)));
132 if (wait_for(label, fence, value)) return 1;
133 const D3D12_RANGE read{0, 256};
134 EXPECT(SUCCEEDED(readback->Map(0, &read, &mapped)) && mapped);
135 const auto* bytes = static_cast<const std::uint8_t*>(mapped);
136 int wrong = 0;
137 for (int i = 0; i < 256; ++i) wrong += bytes[i] != byte;
138 const D3D12_RANGE none{0, 0};
139 readback->Unmap(0, &none);
140 EXPECT(wrong == 0);
141 return 0;
142}
143
144// ---- 1. The proxy itself: slots, identity, guard (Vulkan device) ----
145
146int check_proxy(const Backend& b, ID3D12CommandAllocator* allocator) {
147 const char* label = b.label;
148 ID3D12CommandAllocator* real = xs::allocator_proxy_real_allocator(allocator);
149 EXPECT(real && static_cast<void*>(real) != static_cast<void*>(allocator));
150 EXPECT(xs::allocator_proxy_slot_count(allocator) == 9);
151 EXPECT(xs::command_object_proxy_ref_count(allocator) == 1);
152
153 // QueryInterface: the base chain and the allocator itself answer with the proxy; anything else is refused.
154 const IID modelled[] = {__uuidof(IUnknown), __uuidof(ID3D12Object), __uuidof(ID3D12DeviceChild),
155 __uuidof(ID3D12Pageable), __uuidof(ID3D12CommandAllocator)};
156 for (const IID& iid : modelled) {
157 void* same = nullptr;
158 EXPECT(SUCCEEDED(allocator->QueryInterface(iid, &same)) && same == allocator);
159 static_cast<IUnknown*>(same)->Release();
160 }
161 void* other = reinterpret_cast<void*>(1);
162 EXPECT(allocator->QueryInterface(__uuidof(ID3D12Fence), &other) == E_NOINTERFACE && !other);
163 other = reinterpret_cast<void*>(1); // the Vulkan layer's private tag: not modelled, the real object stays hidden
164 EXPECT(allocator->QueryInterface(xs::kLeonidaCommandAllocatorTag, &other) == E_NOINTERFACE && !other);
165 EXPECT(xs::command_object_proxy_ref_count(allocator) == 1);
166
167 ID3D12Device* owner = nullptr;
168 EXPECT(SUCCEEDED(allocator->GetDevice(IID_PPV_ARGS(&owner))) && owner == b.device);
169 owner->Release();
170 // Private data and SetName go to the real allocator; the proxy pointer round-trips as an interface.
171 EXPECT(SUCCEEDED(allocator->SetName(L"leonida allocator proxy")));
172 constexpr GUID key{0x2a6b8c41, 0x77d2, 0x4e19, {0x9c, 0x3a, 0x51, 0xe0, 0x8f, 0x24, 0x6d, 0x0b}};
173 EXPECT(SUCCEEDED(allocator->SetPrivateDataInterface(key, allocator)));
174 IUnknown* back = nullptr;
175 UINT size = sizeof(back);
176 EXPECT(SUCCEEDED(allocator->GetPrivateData(key, &size, &back)) && back == allocator);
177 back->Release();
178 EXPECT(SUCCEEDED(allocator->SetPrivateDataInterface(key, nullptr)));
179
180 // The refused tail: every slot past the public chain, up to the table end, is E_NOTIMPL and counted.
181 const unsigned table = xs::allocator_proxy_table_size();
182 EXPECT(table == 64);
183 for (unsigned slot = 9; slot < table; ++slot) {
184 const std::uint64_t before = xs::allocator_slot_hits(slot);
185 EXPECT(call_slot(allocator, slot) == E_NOTIMPL);
186 EXPECT(xs::allocator_slot_hits(slot) == before + 1 && xs::allocator_slot_first_call_seen(slot));
187 }
188
189 // Past the table: the vtable read itself faults in the guard region, at the slot's address, and is counted.
190 EXPECT(xs::command_object_tables_guarded());
191 void* const* vtable = *reinterpret_cast<void* const* const*>(allocator);
192 EXPECT(read_slot_guarded(vtable, table - 1) == 0);
193 for (unsigned slot : {table, table + 512, table + 7000}) {
194 const std::uint64_t before = xs::allocator_table_overruns();
195 EXPECT(read_slot_guarded(vtable, slot) == EXCEPTION_ACCESS_VIOLATION);
196 EXPECT(g_fault_address == reinterpret_cast<ULONG_PTR>(&vtable[slot]));
197 EXPECT(xs::allocator_table_overruns() == before + 1);
198 }
199 std::printf("%s: allocator proxy: 9 public slots forwarded, slots 9-%u refused, the guard region names a read "
200 "past the table; QueryInterface/GetDevice/private data keep the proxy identity\n", label, table - 1);
201 return 0;
202}
203
204// ---- 2. Lists on the allocator, GPU work, D3D12's allocator rules, residency ----
205
206int check_backend(const Backend& b) {
207 const char* label = b.label;
208 const unsigned long device_refs = xs::device_proxy_ref_count(b.device);
209 {
210 Ref<ID3D12CommandAllocator> allocator;
211 EXPECT(SUCCEEDED(b.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
212 IID_PPV_ARGS(&allocator.p))));
213 // Vulkan layer: wrapped. Host runtime: its lists could not resolve a proxy, so the PC allocator comes back.
214 EXPECT(xs::is_allocator_proxy(allocator.p) == b.vulkan);
215 if (b.vulkan && check_proxy(b, allocator.p)) return 1;
216 // As IUnknown, and without an output (the device's own answer), as slot 8 does for queues.
217 Ref<IUnknown> as_unknown;
218 EXPECT(SUCCEEDED(b.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(IUnknown),
219 reinterpret_cast<void**>(&as_unknown.p))));
220 EXPECT(xs::is_allocator_proxy(as_unknown.p) == b.vulkan);
221#pragma warning(suppress : 6387) // the null output on purpose
222 EXPECT(b.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(ID3D12CommandAllocator),
223 nullptr) ==
224 b.real->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(ID3D12CommandAllocator),
225 nullptr));
226 Ref<ID3D12Fence> not_an_allocator; // asked for an interface the allocator does not have
227 not_an_allocator.p = reinterpret_cast<ID3D12Fence*>(1);
228 const HRESULT wrong_iid = b.device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
229 IID_PPV_ARGS(&not_an_allocator.p));
230 const bool cleared = !not_an_allocator.p;
231 not_an_allocator.p = nullptr;
232 EXPECT(FAILED(wrong_iid) && cleared);
233
234 D3D12_COMMAND_QUEUE_DESC queue_desc{};
235 Ref<ID3D12CommandQueue> queue;
236 Ref<ID3D12Fence> fence;
237 EXPECT(SUCCEEDED(b.device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p))));
238 EXPECT(SUCCEEDED(b.device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p))));
239 EXPECT(xs::is_queue_proxy(queue.p) && xs::is_fence_proxy(fence.p));
240
241 // A list on the allocator: the Vulkan layer resolves the proxy in CreateCommandList.
242 Ref<ID3D12GraphicsCommandList> list;
243 EXPECT(SUCCEEDED(b.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr,
244 IID_PPV_ARGS(&list.p))));
245 // D3D12's rules, through the proxy: a recording list holds the allocator.
246 const std::uint64_t resets_before = xs::allocator_slot_hits(8);
247 EXPECT(allocator->Reset() == E_FAIL);
248 Ref<ID3D12GraphicsCommandList> second;
249 EXPECT(b.device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr,
250 IID_PPV_ARGS(&second.p)) == E_INVALIDARG && !second.p);
251 if (copy_round(label, b.device, queue.p, fence.p, list.p, 0x5a, 1)) return 1;
252
253 // Done on the GPU: the allocator resets through the proxy, and the list resets onto it (Reset resolves it).
254 EXPECT(SUCCEEDED(allocator->Reset()));
255 EXPECT(SUCCEEDED(list->Reset(allocator.p, nullptr)));
256 if (copy_round(label, b.device, queue.p, fence.p, list.p, 0xa5, 2)) return 1;
257 // The two allocator Reset calls above went through slot 8 (list->Reset is the list's method, not this one).
258 if (b.vulkan) EXPECT(xs::allocator_slot_hits(8) == resets_before + 2);
259
260 // Residency: the real runtime gets the real allocator (an allocator is a pageable).
261 ID3D12Pageable* pageable = allocator.p;
262 ID3D12CommandAllocator* real_allocator =
263 b.vulkan ? xs::allocator_proxy_real_allocator(allocator.p) : allocator.p;
264 ID3D12Pageable* real_pageable = real_allocator;
265 EXPECT(b.device->MakeResident(1, &pageable) == b.real->MakeResident(1, &real_pageable));
266 EXPECT(b.device->Evict(1, &pageable) == b.real->Evict(1, &real_pageable));
267
268 // Release orders: the allocator first while its (closed) list still exists, then the list.
269 if (b.vulkan) EXPECT(xs::command_object_proxy_ref_count(allocator.p) == 1);
270 allocator.reset();
271 list.reset();
272 }
273 EXPECT(xs::device_proxy_ref_count(b.device) == device_refs); // nothing the proxies made kept the device
274 std::printf("%s: CreateCommandAllocator %s; a list created and Reset on it, two GPU copies through the queue and "
275 "fence proxies read back exactly; allocator rules and residency as on the real allocator\n", label,
276 b.vulkan ? "returns an allocator proxy" : "returns the PC allocator unwrapped");
277 return 0;
278}
279
280int run_host(IDXGIAdapter1* adapter, const char* label) {
281 ID3D12Device* real = nullptr;
282 if (FAILED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&real)))) {
283 std::printf("%s: no D3D12 device, skipped\n", label);
284 return 77;
285 }
286 real->AddRef(); // the backend's own reference; the proxy takes the other
287 Ref<ID3D12Device> device;
288 if (FAILED(xs::create_device_proxy(real, __uuidof(ID3D12Device), reinterpret_cast<void**>(&device.p)))) {
289 real->Release();
290 real->Release();
291 std::fprintf(stderr, "%s: device proxy creation failed\n", label);
292 return 1;
293 }
294 const int result = check_backend(Backend{label, device.p, real, false});
295 device.reset();
296 if (result) return 1;
297 if (real->Release() != 0) {
298 std::fprintf(stderr, "%s: the PC device outlives its proxies\n", label);
299 return 1;
300 }
301 return 0;
302}
303
304} // namespace
305
306// A failure ends the process with a message on stderr, never in a dialog a test run would wait on.
307static void no_dialogs() {
308 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
309 SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
310}
311
312int main() {
313 no_dialogs();
314 std::setvbuf(stdout, nullptr, _IONBF, 0);
315 const char* label = "allocator_proxy_test";
316 int ran = 0;
317
318 // Host PC runtime: WARP, then the first hardware adapter. Under Wine the host d3d12.dll is Wine's own, not the
319 // PC runtime the proxy is written against, so only Vulkan runs there.
320 const bool wine = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr;
321 Ref<IDXGIFactory4> factory;
322 if (wine) std::printf("host D3D12: under Wine, skipped\n");
323 if (!wine && SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p)))) {
324 Ref<IDXGIAdapter1> warp;
325 if (SUCCEEDED(factory->EnumWarpAdapter(IID_PPV_ARGS(&warp.p)))) {
326 const int r = run_host(warp.p, "host WARP");
327 if (r == 1) return 1;
328 ran += r == 0;
329 }
330 for (UINT i = 0;; ++i) {
331 Ref<IDXGIAdapter1> adapter;
332 if (factory->EnumAdapters1(i, &adapter.p) == DXGI_ERROR_NOT_FOUND) break;
333 DXGI_ADAPTER_DESC1 desc{};
334 if (FAILED(adapter->GetDesc1(&desc)) || (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)) continue;
335 char name[128] = {};
336 WideCharToMultiByte(CP_UTF8, 0, desc.Description, -1, name, sizeof(name) - 1, nullptr, nullptr);
337 char host_label[160];
338 std::snprintf(host_label, sizeof(host_label), "host %s", name);
339 const int r = run_host(adapter.p, host_label);
340 if (r == 1) return 1;
341 ran += r == 0;
342 break;
343 }
344 }
345
346 // The Vulkan-backed device, the way D3D12XboxCreateDevice hands it out with LEONIDA_D3D12=vulkan.
347 vktest::Device d;
348 if (d.create()) {
349 label = "Vulkan";
350 rt::d3d12::VulkanDeviceInfo info{};
351 info.get_instance_proc = d.instance_proc;
352 info.instance = d.instance;
353 info.physical = d.physical;
354 info.device = d.device;
355 info.queue = d.queue;
356 info.queue_family = d.family;
357 ID3D12Device* inner = nullptr;
358 EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner))));
359 inner->AddRef(); // the backend's own reference; the proxy takes the other
360 ID3D12Device* device = nullptr;
361 EXPECT(SUCCEEDED(xs::create_device_proxy(inner, __uuidof(ID3D12Device), reinterpret_cast<void**>(&device))));
362 rt::d3d12::set_device_outer(inner, device);
363 const int result = check_backend(Backend{label, device, inner, true});
364 device->Release();
365 if (result) return 1;
366 EXPECT(inner->Release() == 0); // nothing the proxies made kept the layer's device alive
367 ++ran;
368 if (d.validation_errors()) {
369 std::fprintf(stderr, "%u validation errors\n", d.validation_errors());
370 return 1;
371 }
372 } else {
373 std::printf("Vulkan: no device, skipped\n");
374 }
375
376 if (!ran) {
377 std::printf("SKIP allocator_proxy_test: neither a host D3D12 device nor a Vulkan device\n");
378 return 77;
379 }
380 std::printf("allocator_proxy_test: %d backend(s) passed\n", ran);
381 return 0;
382}
diff --git a/runtime/test/bindless_sizing_test.cpp b/runtime/test/bindless_sizing_test.cpp
index 469274d56..07715f01e 100644
--- a/runtime/test/bindless_sizing_test.cpp
+++ b/runtime/test/bindless_sizing_test.cpp
@@ -172,6 +172,37 @@ int main() {
172 EXPECT(totals(f).all <= 30000 && count(f, D::dim_2d) > 4096); 172 EXPECT(totals(f).all <= 30000 && count(f, D::dim_2d) > 4096);
173 } 173 }
174 174
175 // D3D-219: past maxPerSetDescriptors, growth follows layout_supported (vkGetDescriptorSetLayoutSupport), which
176 // is asked only above that limit. Intel's Xe-LP reports 6159 and supports the full sizes.
177 {
178 Device d = uniform(1048576, 1048576);
179 d.v11.maxPerSetDescriptors = 6159;
180 d.limits.maxSamplerAllocationCount = 4000;
181 unsigned asked = 0, asked_within = 0;
182 const auto all_supported = [&](const BindlessFeatures& candidate) {
183 ++asked;
184 asked_within += totals(candidate).all <= 6159;
185 return true;
186 };
187 BindlessFeatures f = with_ms(true);
188 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported));
189 EXPECT(asked > 0 && asked_within == 0);
190 EXPECT(count(f, D::dim_2d) == bindless::max_2d_images &&
191 f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers);
192 EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f));
193
194 // A driver that supports less: growth stops where it says no.
195 const auto up_to_20000 = [&](const BindlessFeatures& candidate) { return totals(candidate).all <= 20000; };
196 f = with_ms(true);
197 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, up_to_20000));
198 EXPECT(totals(f).all <= 20000 && totals(f).all > 6159 && count(f, D::dim_2d) > 4096);
199
200 // Without the callback, maxPerSetDescriptors still caps growth as before.
201 f = with_ms(true);
202 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12));
203 EXPECT(totals(f).all <= 6159 || (count(f, D::dim_2d) == 4096 && f.counts[bindless::sampler_binding] == 1024));
204 }
205
175 // The default features are today's counts, which the device-less users (vk_image_fuzz) still get. 206 // The default features are today's counts, which the device-less users (vk_image_fuzz) still get.
176 EXPECT(BindlessFeatures{}.counts == defaults); 207 EXPECT(BindlessFeatures{}.counts == defaults);
177 std::printf("bindless sizing: synthetic limits gave the expected counts\n"); 208 std::printf("bindless sizing: synthetic limits gave the expected counts\n");
diff --git a/runtime/test/bink_audio_test.cpp b/runtime/test/bink_audio_test.cpp
index 2156e5eff..8616d9165 100644
--- a/runtime/test/bink_audio_test.cpp
+++ b/runtime/test/bink_audio_test.cpp
@@ -237,7 +237,7 @@ int main() {
237 header.flags[i]); 237 header.flags[i]);
238 if (!header.audio_tracks) { 238 if (!header.audio_tracks) {
239 std::printf("SKIP (movie has no audio tracks)\n"); 239 std::printf("SKIP (movie has no audio tracks)\n");
240 return 0; 240 return 77; // nothing was checked: a ctest SKIP (SKIP_RETURN_CODE 77), not a pass
241 } 241 }
242 242
243 try { 243 try {
diff --git a/runtime/test/check_d3d12_trace.py b/runtime/test/check_d3d12_trace.py
index c32536464..d24e02058 100644
--- a/runtime/test/check_d3d12_trace.py
+++ b/runtime/test/check_d3d12_trace.py
@@ -50,6 +50,8 @@ def main():
50 ] 50 ]
51 else: 51 else:
52 expected = [ 52 expected = [
53 "ID3D12GraphicsCommandList::SetPipelineState called",
54 "ID3D12GraphicsCommandList::SetGraphicsRootSignature called",
53 "ID3D12GraphicsCommandList::SetMarker called", 55 "ID3D12GraphicsCommandList::SetMarker called",
54 "ID3D12GraphicsCommandList3::SetProtectedResourceSession unsupported", 56 "ID3D12GraphicsCommandList3::SetProtectedResourceSession unsupported",
55 "ID3D12GraphicsCommandList3::SetProtectedResourceSession unsupported", 57 "ID3D12GraphicsCommandList3::SetProtectedResourceSession unsupported",
diff --git a/runtime/test/check_texture_readback_sync.cmake b/runtime/test/check_texture_readback_sync.cmake
index f82156789..81ef3f24e 100644
--- a/runtime/test/check_texture_readback_sync.cmake
+++ b/runtime/test/check_texture_readback_sync.cmake
@@ -1,10 +1,11 @@
1# Run with -DTOOL=<vk_texture_test> -DSPIRV=<directory built by the GPU suite> 1# Run with -DTOOL=<vk_texture_test> -DSPIRV=<directory built by the GPU suite>
2# -DOUTPUT=<readback file> -P runtime/test/check_texture_readback_sync.cmake. 2# -DOUTPUT=<readback file> -P runtime/test/check_texture_readback_sync.cmake.
3# For a cross build, pass the configured emulator as "-DRUNNER=<emulator;args>".
3# Requires the Khronos validation layer and a device that supports the texture harness. 4# Requires the Khronos validation layer and a device that supports the texture harness.
4execute_process( 5execute_process(
5 COMMAND "${CMAKE_COMMAND}" -E env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation 6 COMMAND "${CMAKE_COMMAND}" -E env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
6 VK_LOADER_DEBUG=layer VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT 7 VK_LOADER_DEBUG=layer VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT
7 "${TOOL}" cube "${OUTPUT}" 8 ${RUNNER} "${TOOL}" cube "${OUTPUT}"
8 WORKING_DIRECTORY "${SPIRV}" TIMEOUT 90 9 WORKING_DIRECTORY "${SPIRV}" TIMEOUT 90
9 RESULT_VARIABLE code OUTPUT_VARIABLE log ERROR_VARIABLE log) 10 RESULT_VARIABLE code OUTPUT_VARIABLE log ERROR_VARIABLE log)
10if(NOT code STREQUAL "0" OR NOT log MATCHES "vk_texture_test cube: PASSED" 11if(NOT code STREQUAL "0" OR NOT log MATCHES "vk_texture_test cube: PASSED"
diff --git a/runtime/test/check_vk_pipeline_cli.cmake b/runtime/test/check_vk_pipeline_cli.cmake
new file mode 100644
index 000000000..8c98ba1eb
--- /dev/null
+++ b/runtime/test/check_vk_pipeline_cli.cmake
@@ -0,0 +1,34 @@
1file(MAKE_DIRECTORY "${TEST_DIR}")
2file(WRITE "${TEST_DIR}/index.json" "not JSON\n")
3
4# ${RUNNER} is CMAKE_CROSSCOMPILING_EMULATOR: CTest does not apply it to a script
5# test (the command is the host CMake), so the script runs the tool through it itself.
6function(check_invalid option)
7 execute_process(COMMAND ${RUNNER} "${TOOL}" "${TEST_DIR}" "${option}" ${ARGN}
8 RESULT_VARIABLE code OUTPUT_VARIABLE log ERROR_VARIABLE log TIMEOUT 5)
9 if(NOT code STREQUAL "2" OR NOT log MATCHES "${option} requires a valid value")
10 message(FATAL_ERROR "${option} ${ARGN}: expected usage error, got ${code}\n${log}")
11 endif()
12endfunction()
13
14check_invalid(--count)
15check_invalid(--count --compute-only)
16check_invalid(--count 18446744073709551616)
17check_invalid(--jobs 4294967296)
18check_invalid(--start -1)
19check_invalid(--max-bytes 1MiB)
20check_invalid(--large-module-bytes -1)
21check_invalid(--slow nonsense)
22check_invalid(--slow nan)
23check_invalid(--slow -0.5)
24check_invalid(--stage --graphics-only)
25check_invalid(--stats)
26
27execute_process(COMMAND ${RUNNER} "${TOOL}" "${TEST_DIR}"
28 --jobs 2 --start 3 --count 0 --max-bytes 0 --large-module-bytes 0
29 --slow 0.5 --stage cs --stats report.csv
30 RESULT_VARIABLE code OUTPUT_VARIABLE log ERROR_VARIABLE log TIMEOUT 5)
31# The index parser names the file and where it stopped (#1847: "index.json: expected '{' at byte 0").
32if(NOT code STREQUAL "2" OR NOT log MATCHES "index.json: ")
33 message(FATAL_ERROR "Expected valid arguments to reach the malformed index, got ${code}\n${log}")
34endif()
diff --git a/runtime/test/d3d12_buffer_uav_test.cpp b/runtime/test/d3d12_buffer_uav_test.cpp
new file mode 100644
index 000000000..cf936012a
--- /dev/null
+++ b/runtime/test/d3d12_buffer_uav_test.cpp
@@ -0,0 +1,699 @@
1// Typed buffer UAVs and UAV counters (docs/d3d12_vulkan.md section 3.4, "Buffer UAVs"), through the D3D12 API on the
2// proxy, with compute shaders that are translator output (test/shaders/cs_buf_typed.asm and cs_buf_counter.asm,
3// hand-written RDNA2), plus D3D12-only behaviour compared with the host runtime on the same adapter.
4//
5// Part 1, one DIRECT list: a compute root signature (four root constants and a table of six UAVs), two compute PSOs.
6// cs_buf_typed writes typed buffer views (R32_UINT with an atomic add, R16G16B16A16_FLOAT, R8G8B8A8_UNORM from
7// FirstElement 16, R32G32B32A32_UINT, R32_SINT) and reads an R32_FLOAT view. Two views are shorter
8// than the dispatch (240 and 250 elements of 256): the V#'s NUM_RECORDS is the bound, so stores past
9// it leave the buffer's sentinel and loads past it give 0.
10// cs_buf_counter a structured UAV with a counter at CounterOffsetInBytes 4096 of another buffer: 256 lanes append
11// (buffer_atomic_add on the counter V# in the slot's upper half, store at the returned index), then
12// 128 lanes consume (buffer_atomic_sub, load the record just below). "CopyStructureCount" in D3D12
13// is CopyBufferRegion of the counter's 4 bytes into a buffer: read after the append (256) and after
14// the consume (128). Lane order is up to the GPU, so records are compared as sets.
15// Everything is compared with a CPU reference, word by word, error 0.
16// Part 2, the layer's device (no proxy) and the host runtime on the SAME adapter (LUID): typed buffer UAVs created with
17// CreateUnorderedAccessView and cleared with ClearUnorderedAccessViewUint / Float (thirteen formats, sub-ranges, an
18// element range ending off a word boundary), and a structured UAV with a counter: a clear of the structured view and
19// of the counter's own word through a raw view. The bytes read back are compared with the host's; with no host D3D12
20// the layer's are compared with the model of uav_clear.h.
21// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation (0 errors required).
22#include "vk_test_device.h"
23#include "d3d12_test_shaders.h"
24#include "d3d12_copy_compare.h"
25#include "../shims/d3d12_com.h"
26#include "../shims/d3d12_xs_device.h"
27#include "../src/gfx10_descriptors.h"
28#include "../src/shader_library.h"
29#include "../src/uav_clear.h"
30
31#include <algorithm>
32#include <array>
33#include <bit>
34#include <cmath>
35#include <cstring>
36
37#ifndef LEONIDA_TEST_BUFFER_UAV_DIR
38#error "LEONIDA_TEST_BUFFER_UAV_DIR must name the folder build.py wrote (spirv/index.json, fssm/cs_*.fssm)"
39#endif
40
41#define EXPECT(condition) do { \
42 if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \
43} while (0)
44
45using namespace d3d12test;
46using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void* heap); // heap slots 9/10: handle in RAX
47namespace g = leonida::gfx10;
48namespace uc = leonida::uav_clear;
49
50namespace {
51
52std::vector<std::uint8_t> read_file(const std::filesystem::path& path) {
53 std::ifstream in(path, std::ios::binary);
54 return {std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()};
55}
56
57constexpr UINT lanes = 256;
58constexpr UINT seed = 0x00c0ffee, multiplier = 0x01000193;
59constexpr std::uint32_t sentinel = 0xa5a5a5a5u;
60constexpr UINT out0_elements = 240, in4_elements = 250, out2_first = 16;
61constexpr UINT64 counter_offset = 4096, counter_buffer_bytes = 8192;
62constexpr UINT consumed = 128;
63
64// The buffers of part 1: sizes, in the order of their slices of the upload and of the readback buffer.
65enum Buf { out0, out1, out2, out3, in4, out5, records, counter, consumed_out, buffer_count };
66constexpr UINT64 sizes[buffer_count] = {lanes * 4, lanes * 8, (out2_first + lanes) * 4, lanes * 16, lanes * 4,
67 lanes * 4, lanes * 8, counter_buffer_bytes, consumed * 8};
68constexpr UINT64 slice(Buf which) {
69 UINT64 at = 0;
70 for (int i = 0; i < which; ++i) at += (sizes[i] + 255) / 256 * 256;
71 return at;
72}
73constexpr UINT64 total_bytes = slice(consumed_out) + (sizes[consumed_out] + 255) / 256 * 256;
74constexpr UINT64 count_after_append = total_bytes, count_after_consume = total_bytes + 4;
75constexpr UINT64 readback_bytes = total_bytes + 8;
76
77std::uint16_t half_bits(float value) { // exact for the values the reference uses (finite, in the normal range)
78 const std::uint32_t f = std::bit_cast<std::uint32_t>(value);
79 if (!(f & 0x7fffffffu)) return std::uint16_t(f >> 16);
80 const int exponent = int((f >> 23) & 0xff) - 127 + 15;
81 return std::uint16_t(((f >> 16) & 0x8000) | (exponent << 10) | ((f >> 13) & 0x3ff));
82}
83
84float input_value(UINT g) { return float(g) - 100.5f; }
85
86struct Reference {
87 std::vector<std::uint32_t> words[buffer_count];
88};
89
90Reference reference() {
91 Reference ref;
92 for (int i = 0; i < buffer_count; ++i) ref.words[i].assign(sizes[i] / 4, sentinel);
93 for (UINT g = 0; g < lanes; ++g) {
94 if (g < out0_elements) ref.words[out0][g] = (g * multiplier + seed) + g;
95 const float x = float(g);
96 ref.words[out1][g * 2] = half_bits(x) | std::uint32_t(half_bits(x + 0.5f)) << 16;
97 ref.words[out1][g * 2 + 1] = half_bits(-1.0f - x) | std::uint32_t(half_bits(0.25f)) << 16;
98 const std::uint32_t k = g & 255;
99 ref.words[out2][out2_first + g] = k | (255 - k) << 8 | 0xff000000u;
100 ref.words[out3][g * 4 + 0] = g;
101 ref.words[out3][g * 4 + 1] = g ^ 0xffff;
102 ref.words[out3][g * 4 + 2] = g * 7;
103 ref.words[out3][g * 4 + 3] = 0xa5;
104 ref.words[in4][g] = std::bit_cast<std::uint32_t>(input_value(g));
105 ref.words[out5][g] = g < in4_elements ? std::uint32_t(int(2.0f * input_value(g))) : 0;
106 }
107 return ref;
108}
109
110D3D12_RESOURCE_BARRIER uav_barrier(ID3D12Resource* resource) {
111 D3D12_RESOURCE_BARRIER b{};
112 b.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
113 b.UAV.pResource = resource;
114 return b;
115}
116
117D3D12_UNORDERED_ACCESS_VIEW_DESC buffer_view(DXGI_FORMAT format, UINT64 first, UINT count, UINT stride,
118 UINT64 counter_at = 0, D3D12_BUFFER_UAV_FLAGS flags = D3D12_BUFFER_UAV_FLAG_NONE) {
119 D3D12_UNORDERED_ACCESS_VIEW_DESC view{};
120 view.Format = format;
121 view.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
122 view.Buffer = {first, count, stride, counter_at, flags};
123 return view;
124}
125
126// What a V# in a slot says, as the shader loads it.
127struct Vsharp {
128 std::uint64_t address;
129 std::uint32_t stride, records, format, oob;
130};
131Vsharp vsharp(const void* slot_pointer, unsigned dword = 0) {
132 std::uint32_t w[4];
133 std::memcpy(w, static_cast<const std::uint32_t*>(slot_pointer) + dword, sizeof(w));
134 return {(std::uint64_t(w[1] & 0xffff) << 32) | w[0], w[1] >> 16 & 0x3fff, w[2], w[3] >> 12 & 0x7f, w[3] >> 28 & 3};
135}
136
137// ---- part 1 -----------------------------------------------------------------------------------------------------
138
139int run_shaders(vktest::Device& d, const std::filesystem::path& root_dir, unsigned& words_checked) {
140 leonida::ShaderLibrary library;
141 EXPECT(library.load((root_dir / "spirv").string()));
142 const auto program = [&](const char* name) { return read_file(root_dir / "fssm" / (std::string(name) + ".fssm")); };
143 const auto typed_fssm = program("cs_buf_typed"), counter_fssm = program("cs_buf_counter");
144 EXPECT(typed_fssm.size() >= 0x150 && counter_fssm.size() >= 0x150 && typed_fssm != counter_fssm);
145 EXPECT(library.find("cs", leonida::sha256_hex(typed_fssm)) && library.find("cs", leonida::sha256_hex(counter_fssm)));
146 const auto typed_container = shader_container(typed_fssm), counter_container = shader_container(counter_fssm);
147
148 rt::d3d12::VulkanDeviceInfo info{};
149 info.get_instance_proc = d.instance_proc;
150 info.instance = d.instance;
151 info.physical = d.physical;
152 info.device = d.device;
153 info.queue = d.queue;
154 info.queue_family = d.family;
155 info.buffer_device_address = true;
156 info.bindless = d.bindless;
157 info.bindless_partially_bound = d.partially_bound;
158 info.image_view_min_lod = d.image_view_min_lod;
159 info.shader_dir = (root_dir / "spirv").string();
160 ID3D12Device* inner = nullptr;
161 EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner))));
162 Ref<ID3D12Device> device;
163 EXPECT(SUCCEEDED(rt::d3d12_xs::create_device_proxy(inner, __uuidof(ID3D12Device),
164 reinterpret_cast<void**>(&device.p))));
165 rt::d3d12::set_device_outer(inner, device.p);
166 EXPECT(rt::d3d12::bindless_set(device.p) != VK_NULL_HANDLE);
167
168 D3D12_DESCRIPTOR_RANGE uav_range{D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 6, 0, 0, 0};
169 D3D12_ROOT_PARAMETER params[2] = {};
170 params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
171 params[0].Constants = {0, 0, 4};
172 params[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
173 params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
174 params[1].DescriptorTable = {1, &uav_range};
175 params[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
176 D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{};
177 root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
178 root_desc.Desc_1_0 = {2, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE};
179 const auto root_blob = serialize_root_signature(root_desc);
180 EXPECT(!root_blob.empty());
181 Ref<ID3D12RootSignature> root;
182 EXPECT(SUCCEEDED(device->CreateRootSignature(0, root_blob.data(), root_blob.size(), IID_PPV_ARGS(&root.p))));
183 D3D12_COMPUTE_PIPELINE_STATE_DESC pso_desc{};
184 pso_desc.pRootSignature = root.p;
185 pso_desc.CS = {typed_container.data(), typed_container.size()};
186 Ref<ID3D12PipelineState> pso_typed, pso_counter;
187 EXPECT(SUCCEEDED(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&pso_typed.p))));
188 pso_desc.CS = {counter_container.data(), counter_container.size()};
189 EXPECT(SUCCEEDED(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&pso_counter.p))));
190
191 const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}, upload_heap{D3D12_HEAP_TYPE_UPLOAD},
192 readback_heap{D3D12_HEAP_TYPE_READBACK};
193 Ref<ID3D12Resource> upload, readback, buf[buffer_count];
194 const auto create = [&](Ref<ID3D12Resource>& out, const D3D12_HEAP_PROPERTIES& heap, UINT64 bytes,
195 D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES state) {
196 const auto desc = buffer_desc(bytes, flags);
197 return SUCCEEDED(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, state, nullptr,
198 IID_PPV_ARGS(&out.p)));
199 };
200 EXPECT(create(upload, upload_heap, total_bytes, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ));
201 EXPECT(create(readback, readback_heap, readback_bytes, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST));
202 for (int i = 0; i < buffer_count; ++i)
203 EXPECT(create(buf[i], default_heap, sizes[i], D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS,
204 D3D12_RESOURCE_STATE_COPY_DEST));
205 Reference want = reference();
206 {
207 std::uint8_t* mapped = nullptr;
208 EXPECT(SUCCEEDED(upload->Map(0, nullptr, reinterpret_cast<void**>(&mapped))));
209 for (UINT64 i = 0; i < total_bytes / 4; ++i) std::memcpy(mapped + i * 4, &sentinel, 4);
210 // The input buffer holds floats; the counter's own word starts at 0 (the rest of its buffer is sentinel).
211 std::memcpy(mapped + slice(in4), want.words[in4].data(), sizes[in4]);
212 std::memset(mapped + slice(counter) + counter_offset, 0, 4);
213 upload->Unmap(0, nullptr);
214 }
215
216 // The table: slots 0..5 typed views for cs_buf_typed; slot 6 a structured UAV with a counter, slot 7 a raw output
217 // for cs_buf_counter (its table starts at slot 6).
218 const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 12,
219 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0};
220 Ref<ID3D12DescriptorHeap> heap;
221 EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap.p))));
222 const std::uint64_t cpu = reinterpret_cast<XboxHeapHandleFn>(slot(heap.p, 9))(heap.p);
223 const std::uint64_t gpu = reinterpret_cast<XboxHeapHandleFn>(slot(heap.p, 10))(heap.p);
224 const UINT step = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
225 EXPECT(cpu && gpu >= 0x10000 && gpu < (1ull << 32) && step == 32); // the shaders step 32 bytes a slot
226 const auto handle = [&](UINT i) { return D3D12_CPU_DESCRIPTOR_HANDLE{SIZE_T(cpu + std::uint64_t(i) * step)}; };
227 const auto make = [&](UINT i, Buf which, const D3D12_UNORDERED_ACCESS_VIEW_DESC& view, ID3D12Resource* counter_res = nullptr) {
228 device->CreateUnorderedAccessView(buf[which].p, counter_res, &view, handle(i));
229 };
230 make(0, out0, buffer_view(DXGI_FORMAT_R32_UINT, 0, out0_elements, 0));
231 make(1, out1, buffer_view(DXGI_FORMAT_R16G16B16A16_FLOAT, 0, lanes, 0));
232 make(2, out2, buffer_view(DXGI_FORMAT_R8G8B8A8_UNORM, out2_first, lanes, 0));
233 make(3, out3, buffer_view(DXGI_FORMAT_R32G32B32A32_UINT, 0, lanes, 0));
234 make(4, in4, buffer_view(DXGI_FORMAT_R32_FLOAT, 0, in4_elements, 0));
235 make(5, out5, buffer_view(DXGI_FORMAT_R32_SINT, 0, lanes, 0));
236 make(6, records, buffer_view(DXGI_FORMAT_UNKNOWN, 0, lanes, 8, counter_offset), buf[counter].p);
237 make(7, consumed_out, buffer_view(DXGI_FORMAT_R32_TYPELESS, 0, consumed * 2, 0, 0, D3D12_BUFFER_UAV_FLAG_RAW));
238
239 // The V#s the shaders load: format code, element size as stride, element count, OOB_SELECT 1 (structured); the
240 // R8G8B8A8 view starts 16 elements in; the counter V# is raw (stride 0, 4 bytes, OOB_SELECT 3) in the slot's upper half.
241 const auto at = [&](UINT i) { return reinterpret_cast<const void*>(handle(i).ptr); };
242 const auto expect_typed = [&](UINT i, Buf which, UINT code, UINT bytes, UINT elements, UINT first) {
243 const Vsharp v = vsharp(at(i));
244 return v.address == buf[which]->GetGPUVirtualAddress() + UINT64(first) * bytes && v.stride == bytes &&
245 v.records == elements && v.format == code && v.oob == 1;
246 };
247 EXPECT(expect_typed(0, out0, 20, 4, out0_elements, 0)); // GFX10_FORMAT_32_UINT
248 EXPECT(expect_typed(1, out1, 71, 8, lanes, 0)); // 16_16_16_16_FLOAT
249 EXPECT(expect_typed(2, out2, 56, 4, lanes, out2_first)); // 8_8_8_8_UNORM
250 EXPECT(expect_typed(3, out3, 75, 16, lanes, 0)); // 32_32_32_32_UINT
251 EXPECT(expect_typed(4, in4, 22, 4, in4_elements, 0)); // 32_FLOAT
252 EXPECT(expect_typed(5, out5, 21, 4, lanes, 0)); // 32_SINT
253 {
254 const Vsharp v = vsharp(at(6)), c = vsharp(at(6), 4);
255 EXPECT(v.address == buf[records]->GetGPUVirtualAddress() && v.stride == 8 && v.records == lanes && v.format == 0 &&
256 v.oob == 0);
257 EXPECT(c.address == buf[counter]->GetGPUVirtualAddress() + counter_offset && c.stride == 0 && c.records == 4 &&
258 c.format == 0 && c.oob == 3);
259 const Vsharp r = vsharp(at(7));
260 EXPECT(r.address == buf[consumed_out]->GetGPUVirtualAddress() && r.stride == 0 && r.records == consumed * 8 &&
261 r.oob == 3);
262 // A view with no counter leaves the slot's upper half zero.
263 const Vsharp none = vsharp(at(7), 4);
264 EXPECT(!none.address && !none.records);
265 }
266
267 D3D12_COMMAND_QUEUE_DESC queue_desc{};
268 queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
269 Ref<ID3D12CommandQueue> queue;
270 EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p))));
271 Ref<ID3D12CommandAllocator> allocator;
272 Ref<ID3D12GraphicsCommandList> list;
273 Ref<ID3D12Fence> fence;
274 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p))));
275 EXPECT(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr,
276 IID_PPV_ARGS(&list.p))));
277 EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p))));
278
279 constexpr auto uav_state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
280 for (int i = 0; i < buffer_count; ++i) list->CopyBufferRegion(buf[i].p, 0, upload.p, slice(Buf(i)), sizes[i]);
281 D3D12_RESOURCE_BARRIER barriers[buffer_count];
282 for (int i = 0; i < buffer_count; ++i) barriers[i] = transition(buf[i].p, D3D12_RESOURCE_STATE_COPY_DEST, uav_state);
283 list->ResourceBarrier(buffer_count, barriers);
284 ID3D12DescriptorHeap* heaps[] = {heap.p};
285 list->SetDescriptorHeaps(1, heaps);
286 list->SetComputeRootSignature(root.p);
287 const auto constants = [&](std::uint32_t a, std::uint32_t b) {
288 const std::uint32_t values[4] = {a, b, 0, 0};
289 list->SetComputeRoot32BitConstants(0, 4, values, 0);
290 };
291 list->SetPipelineState(pso_typed.p);
292 constants(seed, multiplier);
293 list->SetComputeRootDescriptorTable(1, D3D12_GPU_DESCRIPTOR_HANDLE{gpu});
294 list->Dispatch(lanes / 64, 1, 1);
295 list->SetPipelineState(pso_counter.p);
296 constants(0, 0); // append
297 list->SetComputeRootDescriptorTable(1, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 6ull * step});
298 list->Dispatch(lanes / 64, 1, 1);
299 D3D12_RESOURCE_BARRIER sync[2] = {uav_barrier(buf[records].p), uav_barrier(buf[counter].p)};
300 list->ResourceBarrier(2, sync);
301 // CopyStructureCount: the counter's 4 bytes into a buffer, after the append.
302 D3D12_RESOURCE_BARRIER to_copy = transition(buf[counter].p, uav_state, D3D12_RESOURCE_STATE_COPY_SOURCE);
303 list->ResourceBarrier(1, &to_copy);
304 list->CopyBufferRegion(readback.p, count_after_append, buf[counter].p, counter_offset, 4);
305 D3D12_RESOURCE_BARRIER back = transition(buf[counter].p, D3D12_RESOURCE_STATE_COPY_SOURCE, uav_state);
306 list->ResourceBarrier(1, &back);
307 constants(1, 0); // consume
308 list->Dispatch(consumed / 64, 1, 1);
309 for (int i = 0; i < buffer_count; ++i) barriers[i] = transition(buf[i].p, uav_state, D3D12_RESOURCE_STATE_COPY_SOURCE);
310 list->ResourceBarrier(buffer_count, barriers);
311 for (int i = 0; i < buffer_count; ++i) list->CopyBufferRegion(readback.p, slice(Buf(i)), buf[i].p, 0, sizes[i]);
312 list->CopyBufferRegion(readback.p, count_after_consume, buf[counter].p, counter_offset, 4);
313 EXPECT(list->Close() == S_OK);
314 ID3D12CommandList* lists[] = {list.p};
315 queue->ExecuteCommandLists(1, lists);
316 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
317 EXPECT(SUCCEEDED(queue->Signal(fence.p, 1)));
318 const HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
319 EXPECT(event != nullptr);
320 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(1, event)));
321 if (WaitForSingleObject(event, 20000) != WAIT_OBJECT_0) {
322 std::fprintf(stderr, "the fence never reached 1\n");
323 return 1;
324 }
325 CloseHandle(event);
326
327 std::vector<std::uint8_t> got;
328 {
329 void* mapped = nullptr;
330 EXPECT(SUCCEEDED(readback->Map(0, nullptr, &mapped)));
331 got.assign(static_cast<const std::uint8_t*>(mapped), static_cast<const std::uint8_t*>(mapped) + readback_bytes);
332 readback->Unmap(0, nullptr);
333 }
334 const auto word_at = [&](UINT64 offset) {
335 std::uint32_t value = 0;
336 std::memcpy(&value, got.data() + offset, 4);
337 return value;
338 };
339
340 unsigned mismatches = 0;
341 const auto compare = [&](const char* what, Buf which, const std::vector<std::uint32_t>& expected) {
342 unsigned bad = 0;
343 for (std::size_t i = 0; i < expected.size(); ++i) {
344 ++words_checked;
345 const std::uint32_t value = word_at(slice(which) + i * 4);
346 if (value == expected[i]) continue;
347 ++mismatches;
348 if (bad++ < 4) std::fprintf(stderr, "%s word %zu: got %08x want %08x\n", what, i, value, expected[i]);
349 }
350 if (bad) std::fprintf(stderr, "%s: %u of %zu words differ\n", what, bad, expected.size());
351 };
352 compare("R32_UINT store + atomic add (240 of 256 elements)", out0, want.words[out0]);
353 compare("R16G16B16A16_FLOAT store", out1, want.words[out1]);
354 compare("R8G8B8A8_UNORM store (FirstElement 16)", out2, want.words[out2]);
355 compare("R32G32B32A32_UINT store", out3, want.words[out3]);
356 compare("R32_FLOAT input untouched", in4, want.words[in4]);
357 compare("R32_FLOAT load -> R32_SINT store (250 of 256 loads in range)", out5, want.words[out5]);
358
359 // The counter: 256 after the append, 128 after the consume, and nothing else of its buffer touched.
360 ++words_checked;
361 if (word_at(count_after_append) != lanes) {
362 std::fprintf(stderr, "counter after the append: %u, want %u\n", word_at(count_after_append), lanes);
363 ++mismatches;
364 }
365 ++words_checked;
366 if (word_at(count_after_consume) != lanes - consumed) {
367 std::fprintf(stderr, "counter after the consume: %u, want %u\n", word_at(count_after_consume), lanes - consumed);
368 ++mismatches;
369 }
370 for (UINT64 i = 0; i < counter_buffer_bytes / 4; ++i) {
371 ++words_checked;
372 const std::uint32_t expected = i == counter_offset / 4 ? lanes - consumed : sentinel;
373 if (word_at(slice(counter) + i * 4) != expected && mismatches++ < 12)
374 std::fprintf(stderr, "counter buffer word %llu: got %08x want %08x\n", static_cast<unsigned long long>(i),
375 word_at(slice(counter) + i * 4), expected);
376 }
377 // The appended records: every g exactly once with its second field, in whatever order the lanes took the counter.
378 std::vector<std::array<std::uint32_t, 2>> appended, taken;
379 for (UINT i = 0; i < lanes; ++i)
380 appended.push_back({word_at(slice(records) + i * 8), word_at(slice(records) + i * 8 + 4)});
381 std::vector<std::array<std::uint32_t, 2>> sorted = appended;
382 std::sort(sorted.begin(), sorted.end());
383 for (UINT i = 0; i < lanes; ++i) {
384 ++words_checked;
385 if (sorted[i][0] != i || sorted[i][1] != i * 3 + 1) {
386 if (mismatches++ < 12)
387 std::fprintf(stderr, "appended record %u (sorted): { %u, %u }, want { %u, %u }\n", i, sorted[i][0],
388 sorted[i][1], i, i * 3 + 1);
389 }
390 }
391 // The consumed ones: the records at indices 128..255 (the counter went from 256 down to 128), each once.
392 for (UINT i = 0; i < consumed; ++i)
393 taken.push_back({word_at(slice(consumed_out) + i * 8), word_at(slice(consumed_out) + i * 8 + 4)});
394 std::vector<std::array<std::uint32_t, 2>> tail(appended.begin() + (lanes - consumed), appended.end());
395 std::sort(taken.begin(), taken.end());
396 std::sort(tail.begin(), tail.end());
397 for (UINT i = 0; i < consumed; ++i) {
398 ++words_checked;
399 if (taken[i] != tail[i] && mismatches++ < 12)
400 std::fprintf(stderr, "consumed record %u (sorted): { %u, %u }, want { %u, %u }\n", i, taken[i][0], taken[i][1],
401 tail[i][0], tail[i][1]);
402 }
403 EXPECT(!mismatches);
404
405 for (auto& b : buf) b.reset();
406 upload.reset(); readback.reset(); list.reset(); allocator.reset(); fence.reset(); queue.reset();
407 pso_typed.reset(); pso_counter.reset(); root.reset(); heap.reset();
408 EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) == 1);
409 return 0;
410}
411
412// ---- part 2 -----------------------------------------------------------------------------------------------------
413
414struct ClearCase {
415 DXGI_FORMAT format;
416 VkFormat vulkan; // for the model
417 bool is_float;
418 std::array<std::uint32_t, 4> values;
419 UINT64 byte_offset;
420 UINT elements;
421};
422std::uint32_t fb(float f) { return std::bit_cast<std::uint32_t>(f); }
423
424// Values in the domain D3D12 defines the same on every driver: no exact .5 ties in a float -> UNORM rounding (the RTX 5070's
425// D3D12 rounds 127.5 down, the layer and the spec's round-to-nearest up) and no integer wider than its channel (the low bits
426// are kept here, one vendor clamps).
427const ClearCase clear_cases[] = {
428 {DXGI_FORMAT_R32_UINT, VK_FORMAT_R32_UINT, false, {0x12345678, 0, 0, 0}, 0, 16},
429 {DXGI_FORMAT_R32_SINT, VK_FORMAT_R32_SINT, false, {0xfffffff0, 0, 0, 0}, 256, 8},
430 {DXGI_FORMAT_R32_FLOAT, VK_FORMAT_R32_SFLOAT, true, {fb(1.5f), 0, 0, 0}, 512, 8},
431 {DXGI_FORMAT_R16G16B16A16_FLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, true, {fb(1.0f), fb(0.5f), fb(-2.0f), fb(0.25f)}, 768, 8},
432 {DXGI_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, true, {fb(1.0f), fb(0.4f), fb(0.2f), fb(2.0f)}, 1024, 16},
433 {DXGI_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_UINT, false, {0xf1, 2, 3, 0x80}, 1280, 16},
434 {DXGI_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_UINT, false, {1, 2, 3, 4}, 1536, 4},
435 {DXGI_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, true, {fb(0.25f), 0, 0, 0}, 1792, 16},
436 {DXGI_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM, true, {fb(0.2f), 0, 0, 0}, 2048, 21}, // ends off a word boundary
437 {DXGI_FORMAT_R10G10B10A2_UNORM, VK_FORMAT_A2B10G10R10_UNORM_PACK32, true, {fb(0.25f), fb(0.4f), fb(0.75f), fb(1.0f)}, 2304, 8},
438 {DXGI_FORMAT_R11G11B10_FLOAT, VK_FORMAT_B10G11R11_UFLOAT_PACK32, true, {fb(1.0f), fb(2.0f), fb(0.5f), 0}, 2560, 8},
439 {DXGI_FORMAT_R16G16_FLOAT, VK_FORMAT_R16G16_SFLOAT, true, {fb(1.5f), fb(-0.5f), 0, 0}, 2816, 8},
440 {DXGI_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_UINT, false, {0xaa, 0xbb, 0, 0}, 3072, 10},
441};
442constexpr UINT64 api_data_bytes = 4096, api_records_bytes = 4096;
443constexpr UINT api_readback = api_data_bytes + api_records_bytes + counter_buffer_bytes;
444
445// The same scenario on `device`: bytes read back, or empty on failure. host: a real heap pair (a non-shader-visible one the
446// views are made in, a shader-visible one the clear's GPU handle comes from), as the PC runtime wants; the layer takes the
447// CPU handle and ignores the GPU one.
448bool run_api(ID3D12Device* device, bool host, std::vector<std::uint8_t>& out, std::vector<bool>& supported_by_host) {
449 const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}, upload_heap{D3D12_HEAP_TYPE_UPLOAD},
450 readback_heap{D3D12_HEAP_TYPE_READBACK};
451 const auto create = [&](Ref<ID3D12Resource>& r, const D3D12_HEAP_PROPERTIES& heap, UINT64 bytes,
452 D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES state) {
453 const auto desc = buffer_desc(bytes, flags);
454 return SUCCEEDED(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, state, nullptr,
455 IID_PPV_ARGS(&r.p)));
456 };
457 constexpr auto uav_flag = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
458 Ref<ID3D12Resource> data, structured, counter_buffer, upload, readback;
459 if (!create(data, default_heap, api_data_bytes, uav_flag, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) ||
460 !create(structured, default_heap, api_records_bytes, uav_flag, D3D12_RESOURCE_STATE_COPY_DEST) ||
461 !create(counter_buffer, default_heap, counter_buffer_bytes, uav_flag, D3D12_RESOURCE_STATE_COPY_DEST) ||
462 !create(upload, upload_heap, api_records_bytes + counter_buffer_bytes, D3D12_RESOURCE_FLAG_NONE,
463 D3D12_RESOURCE_STATE_GENERIC_READ) ||
464 !create(readback, readback_heap, api_readback, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST))
465 return std::fprintf(stderr, "resource creation failed\n"), false;
466 {
467 std::uint8_t* mapped = nullptr;
468 if (FAILED(upload->Map(0, nullptr, reinterpret_cast<void**>(&mapped)))) return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
469 std::memset(mapped, 0x11, api_records_bytes + counter_buffer_bytes);
470 const std::uint32_t seven = 7;
471 std::memcpy(mapped + api_records_bytes + counter_offset, &seven, 4); // the counter's word
472 upload->Unmap(0, nullptr);
473 }
474 constexpr UINT slots = 24;
475 Ref<ID3D12DescriptorHeap> cpu_heap, gpu_heap;
476 D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, slots, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
477 if (FAILED(device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&cpu_heap.p)))) return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
478 if (host) {
479 desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
480 if (FAILED(device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&gpu_heap.p)))) return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
481 }
482 const UINT step = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
483 const auto cpu = [&](UINT i) {
484 D3D12_CPU_DESCRIPTOR_HANDLE h = cpu_heap->GetCPUDescriptorHandleForHeapStart();
485 h.ptr += SIZE_T(i) * step;
486 return h;
487 };
488 const auto gpu = [&](UINT i) {
489 if (!host) return D3D12_GPU_DESCRIPTOR_HANDLE{0};
490 D3D12_GPU_DESCRIPTOR_HANDLE h = gpu_heap->GetGPUDescriptorHandleForHeapStart();
491 h.ptr += UINT64(i) * step;
492 return h;
493 };
494 UINT next_slot = 0;
495 const auto make = [&](ID3D12Resource* resource, ID3D12Resource* counter, const D3D12_UNORDERED_ACCESS_VIEW_DESC& view) {
496 const UINT i = next_slot++;
497 device->CreateUnorderedAccessView(resource, counter, &view, cpu(i));
498 if (host) {
499 D3D12_CPU_DESCRIPTOR_HANDLE visible = gpu_heap->GetCPUDescriptorHandleForHeapStart();
500 visible.ptr += SIZE_T(i) * step;
501 device->CopyDescriptorsSimple(1, visible, cpu(i), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
502 }
503 return i;
504 };
505
506 Ref<ID3D12CommandQueue> queue;
507 Ref<ID3D12CommandAllocator> allocator;
508 Ref<ID3D12GraphicsCommandList> list;
509 Ref<ID3D12Fence> fence;
510 const D3D12_COMMAND_QUEUE_DESC queue_desc{D3D12_COMMAND_LIST_TYPE_DIRECT};
511 if (FAILED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p))) ||
512 FAILED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p))) ||
513 FAILED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr, IID_PPV_ARGS(&list.p))) ||
514 FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p))))
515 return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
516 ID3D12DescriptorHeap* heaps[] = {gpu_heap.p};
517 if (host) list->SetDescriptorHeaps(1, heaps);
518
519 const auto clear = [&](UINT slot_index, ID3D12Resource* resource, bool is_float, const std::array<std::uint32_t, 4>& v) {
520 if (is_float) {
521 const float f[4] = {std::bit_cast<float>(v[0]), std::bit_cast<float>(v[1]), std::bit_cast<float>(v[2]),
522 std::bit_cast<float>(v[3])};
523 list->ClearUnorderedAccessViewFloat(gpu(slot_index), cpu(slot_index), resource, f, 0, nullptr);
524 } else {
525 list->ClearUnorderedAccessViewUint(gpu(slot_index), cpu(slot_index), resource, v.data(), 0, nullptr);
526 }
527 const D3D12_RESOURCE_BARRIER barrier = uav_barrier(resource);
528 list->ResourceBarrier(1, &barrier);
529 };
530 // The whole buffer 0xcdcdcdcd through a raw view, then each case's elements through a typed view.
531 clear(make(data.p, nullptr, buffer_view(DXGI_FORMAT_R32_TYPELESS, 0, api_data_bytes / 4, 0, 0, D3D12_BUFFER_UAV_FLAG_RAW)),
532 data.p, false, {0xcdcdcdcd, 0, 0, 0});
533 supported_by_host.assign(std::size(clear_cases), true);
534 for (std::size_t c = 0; c < std::size(clear_cases); ++c) {
535 const ClearCase& test = clear_cases[c];
536 if (host) {
537 D3D12_FEATURE_DATA_FORMAT_SUPPORT support{test.format};
538 supported_by_host[c] = SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &support, sizeof(support))) &&
539 (support.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE);
540 }
541 if (!supported_by_host[c]) continue;
542 const UINT size = uc::layout(test.vulkan)->bytes;
543 clear(make(data.p, nullptr, buffer_view(test.format, test.byte_offset / size, test.elements, 0)), data.p,
544 test.is_float, test.values);
545 }
546 // A structured view with a counter. The clear writes the records and leaves the counter (preset to 7) alone ...
547 list->CopyBufferRegion(structured.p, 0, upload.p, 0, api_records_bytes);
548 list->CopyBufferRegion(counter_buffer.p, 0, upload.p, api_records_bytes, counter_buffer_bytes);
549 D3D12_RESOURCE_BARRIER to_uav[2] = {transition(structured.p, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
550 transition(counter_buffer.p, D3D12_RESOURCE_STATE_COPY_DEST,
551 D3D12_RESOURCE_STATE_UNORDERED_ACCESS)};
552 list->ResourceBarrier(2, to_uav);
553 clear(make(structured.p, counter_buffer.p, buffer_view(DXGI_FORMAT_UNKNOWN, 0, 256, 16, counter_offset)), structured.p,
554 false, {0xab, 0xcd, 0xef, 0x01});
555 // ... and a raw view of the counter's own word (element 1024) clears it, as a game resets its counter.
556 clear(make(counter_buffer.p, nullptr, buffer_view(DXGI_FORMAT_R32_TYPELESS, counter_offset / 4, 1, 0, 0, D3D12_BUFFER_UAV_FLAG_RAW)),
557 counter_buffer.p, false, {3, 0, 0, 0});
558 D3D12_RESOURCE_BARRIER to_copy[3] = {
559 transition(data.p, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE),
560 transition(structured.p, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE),
561 transition(counter_buffer.p, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)};
562 list->ResourceBarrier(3, to_copy);
563 list->CopyBufferRegion(readback.p, 0, data.p, 0, api_data_bytes);
564 list->CopyBufferRegion(readback.p, api_data_bytes, structured.p, 0, api_records_bytes);
565 list->CopyBufferRegion(readback.p, api_data_bytes + api_records_bytes, counter_buffer.p, 0, counter_buffer_bytes);
566 if (const HRESULT hr = list->Close(); FAILED(hr)) return std::fprintf(stderr, "Close: %08lx\n", static_cast<unsigned long>(hr)), false;
567 ID3D12CommandList* lists[] = {list.p};
568 queue->ExecuteCommandLists(1, lists);
569 if (!host && rt::d3d12::last_execute_result(queue.p) != leonida::ReplayResult::success)
570 return std::fprintf(stderr, "replay result %d\n", int(rt::d3d12::last_execute_result(queue.p))), false;
571 if (FAILED(queue->Signal(fence.p, 1))) return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
572 const HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
573 if (!event || FAILED(fence->SetEventOnCompletion(1, event)) || WaitForSingleObject(event, 20000) != WAIT_OBJECT_0)
574 return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
575 CloseHandle(event);
576 void* mapped = nullptr;
577 if (FAILED(readback->Map(0, nullptr, &mapped))) return std::fprintf(stderr, "run_api: line %d\n", __LINE__), false;
578 out.assign(static_cast<const std::uint8_t*>(mapped), static_cast<const std::uint8_t*>(mapped) + api_readback);
579 readback->Unmap(0, nullptr);
580 return true;
581}
582
583// What D3D12 says the same sequence leaves, from uav_clear.h: the model for a run with no host runtime to compare with.
584std::vector<std::uint8_t> model(const std::vector<bool>& supported) {
585 std::vector<std::uint8_t> bytes(api_readback, 0x11);
586 std::fill(bytes.begin(), bytes.begin() + api_data_bytes, std::uint8_t(0xcd));
587 for (std::size_t c = 0; c < std::size(clear_cases); ++c) {
588 const ClearCase& test = clear_cases[c];
589 uc::Element e{};
590 if (!supported[c] || !uc::encode(test.vulkan, test.is_float, test.values, e)) continue;
591 for (UINT64 i = 0; i < UINT64(test.elements) * e.size; ++i) bytes[test.byte_offset + i] = e.bytes[i % e.size];
592 }
593 // A structured view clears every 32-bit word to the first value (D3D12 ignores the other three).
594 for (UINT64 i = 0; i < api_records_bytes; ++i) bytes[api_data_bytes + i] = i % 4 == 0 ? 0xab : 0;
595 const std::uint32_t three = 3;
596 std::memcpy(bytes.data() + api_data_bytes + api_records_bytes + counter_offset, &three, 4);
597 return bytes;
598}
599
600} // namespace
601
602int main() {
603 vktest::Device d;
604 const auto device_status = d.initialize();
605 if (device_status == vktest::DeviceStatus::unavailable) return 77; // no Vulkan GPU: ctest skips
606 if (device_status != vktest::DeviceStatus::ready) return 1;
607 if (!d.bindless) {
608 std::printf("SKIP: the device lacks the descriptor indexing features of the bindless set 0\n");
609 return 77;
610 }
611 const std::filesystem::path root_dir = LEONIDA_TEST_BUFFER_UAV_DIR;
612
613 unsigned words = 0;
614 if (const int status = run_shaders(d, root_dir, words)) return status;
615
616 // Part 2: the layer's device and the host's on the same adapter.
617 std::vector<std::uint8_t> ours, host_bytes;
618 std::vector<bool> supported;
619 {
620 rt::d3d12::VulkanDeviceInfo info{};
621 info.get_instance_proc = d.instance_proc;
622 info.instance = d.instance;
623 info.physical = d.physical;
624 info.device = d.device;
625 info.queue = d.queue;
626 info.queue_family = d.family;
627 info.buffer_device_address = true; // the V# holds the buffer's address
628 Ref<ID3D12Device> device;
629 EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&device.p))));
630 EXPECT(run_api(device.p, false, ours, supported));
631 }
632 std::string host_name = "none";
633 bool compared = false;
634 {
635 VkPhysicalDeviceIDProperties id{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES};
636 VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &id};
637 d.instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2")(d.physical, &properties);
638 copycmp::Ptr<ID3D12Device> host;
639 LUID luid{};
640 std::memcpy(&luid, id.deviceLUID, sizeof(luid));
641 if (id.deviceLUIDValid && copycmp::try_create_host(host, host_name, &luid)) {
642 std::vector<bool> host_supported;
643 EXPECT(run_api(host.p, true, host_bytes, host_supported));
644 supported = host_supported;
645 compared = true;
646 }
647 }
648 if (!compared) {
649 std::printf("no host D3D12 device on the layer's adapter: the layer's bytes are compared with uav_clear.h\n");
650 host_bytes = model(supported);
651 host_name = "the uav_clear.h model";
652 } else {
653 // The layer ran every case; the host only those its adapter can store typed. Mask the others in both.
654 for (std::size_t c = 0; c < std::size(clear_cases); ++c) {
655 if (supported[c]) continue;
656 const ClearCase& test = clear_cases[c];
657 const UINT size = uc::layout(test.vulkan)->bytes;
658 std::fill_n(ours.begin() + test.byte_offset, UINT64(test.elements) * size, std::uint8_t(0));
659 std::fill_n(host_bytes.begin() + test.byte_offset, UINT64(test.elements) * size, std::uint8_t(0));
660 std::printf("host adapter has no typed UAV store for DXGI format %d: that case is not compared\n",
661 int(test.format));
662 }
663 }
664 EXPECT(ours.size() == api_readback && host_bytes.size() == api_readback);
665 unsigned differing = 0;
666 for (std::size_t i = 0; i < ours.size(); ++i) {
667 ++words;
668 if (ours[i] == host_bytes[i]) continue;
669 if (differing++ < 12) {
670 const char* where = i < api_data_bytes ? "typed clears" : i < api_data_bytes + api_records_bytes ? "structured clear with a counter" : "counter buffer";
671 std::fprintf(stderr, "%s byte %zu: layer %02x, %s %02x\n", where, i, ours[i], host_name.c_str(), host_bytes[i]);
672 }
673 }
674 if (differing) {
675 // Say which clear case the first differing byte belongs to.
676 for (std::size_t c = 0; c < std::size(clear_cases); ++c) {
677 const ClearCase& test = clear_cases[c];
678 const UINT size = uc::layout(test.vulkan)->bytes;
679 for (UINT64 i = 0; i < UINT64(test.elements) * size; ++i)
680 if (ours[test.byte_offset + i] != host_bytes[test.byte_offset + i]) {
681 std::fprintf(stderr, "case %zu (DXGI format %d) differs\n", c, int(test.format));
682 break;
683 }
684 }
685 std::fprintf(stderr, "%u bytes differ\n", differing);
686 return 1;
687 }
688 if (d.validation_errors()) {
689 std::fprintf(stderr, "%u validation errors\n", d.validation_errors());
690 return 1;
691 }
692 std::printf("Buffer UAVs: typed views (R32_UINT with an atomic, R16G16B16A16_FLOAT, R8G8B8A8_UNORM from FirstElement 16, "
693 "R32G32B32A32_UINT, R32_FLOAT loads, R32_SINT) written by a translated compute shader with NUM_RECORDS "
694 "as the bound, and a structured UAV with a counter at offset 4096 appended to by 256 lanes and consumed "
695 "by 128 (counter 256 then 128 through CopyBufferRegion) matched the CPU reference; typed-buffer and "
696 "counter clears matched %s: %u values compared, error 0\n",
697 host_name.c_str(), words);
698 return 0;
699}
diff --git a/runtime/test/d3d12_compute_test.cpp b/runtime/test/d3d12_compute_test.cpp
index a2011d3c2..2d9dff03f 100644
--- a/runtime/test/d3d12_compute_test.cpp
+++ b/runtime/test/d3d12_compute_test.cpp
@@ -10,6 +10,7 @@
10// No game data. Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation. 10// No game data. Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation.
11#include "vk_test_device.h" 11#include "vk_test_device.h"
12#include "../shims/d3d12_com.h" 12#include "../shims/d3d12_com.h"
13#include "../src/gfx10_descriptors.h"
13#include "../src/shader_library.h" 14#include "../src/shader_library.h"
14#include "../shims/d3d12_xs_device.h" 15#include "../shims/d3d12_xs_device.h"
15 16
@@ -33,6 +34,8 @@ using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void* heap); // heap slots 9/10
33// Device slot 62 as XboxBvhBuilder.dll calls it on 1.0.2.1: (desc, 0, 0, riid, out) (main's 28cf235). 34// Device slot 62 as XboxBvhBuilder.dll calls it on 1.0.2.1: (desc, 0, 0, riid, out) (main's 28cf235).
34using XboxComputePipelineFn = HRESULT(WINAPI*)(void* device, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, std::uint64_t, 35using XboxComputePipelineFn = HRESULT(WINAPI*)(void* device, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, std::uint64_t,
35 std::uint64_t, const IID*, void**); 36 std::uint64_t, const IID*, void**);
37// Device slot 67 as amd_fidelityfx_upscaler_xbox.dll calls it: (desc, riid, out).
38using XboxNativeComputePipelineFn = HRESULT(WINAPI*)(void* device, const void*, const IID*, void**);
36using SerializeFn = HRESULT(WINAPI*)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC*, ID3DBlob**, ID3DBlob**); 39using SerializeFn = HRESULT(WINAPI*)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC*, ID3DBlob**, ID3DBlob**);
37 40
38template<class T> 41template<class T>
@@ -169,6 +172,7 @@ int main() {
169 constexpr UINT elements = 64, bytes = elements * 4; 172 constexpr UINT elements = 64, bytes = elements * 4;
170 const std::uint32_t table_values[4] = {1000, 2000, 3000, 4000}; 173 const std::uint32_t table_values[4] = {1000, 2000, 3000, 4000};
171 std::vector<std::uint32_t> first(elements), second(elements); 174 std::vector<std::uint32_t> first(elements), second(elements);
175 std::vector<std::uint32_t> cbv_a_out(elements), cbv_oob_out(elements), cbv_b_out(elements), cbv_null_out(elements);
172 { 176 {
173 rt::d3d12::VulkanDeviceInfo info{}; 177 rt::d3d12::VulkanDeviceInfo info{};
174 info.get_instance_proc = d.instance_proc; 178 info.get_instance_proc = d.instance_proc;
@@ -221,6 +225,40 @@ int main() {
221 EXPECT(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&unknown.p)) == E_INVALIDARG && !unknown.p); 225 EXPECT(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&unknown.p)) == E_INVALIDARG && !unknown.p);
222 pso_desc.CS = {container.data(), container.size()}; 226 pso_desc.CS = {container.data(), container.size()};
223 227
228 // The PSO through slot 67, compute pipeline from native code; maps to CreateComputePipelineState.
229 struct XboxNativeComputeDesc {
230 ID3D12RootSignature* root_signature;
231 const void* kind0;
232 std::uint64_t kind0_size;
233 const void* kind1;
234 std::uint64_t kind1_size;
235 const void* kind6;
236 std::uint64_t kind6_size;
237 const void* kind7;
238 std::uint64_t kind7_size;
239 } native_desc{};
240 native_desc.root_signature = root.p;
241 native_desc.kind6 = fssm.data();
242 native_desc.kind6_size = fssm.size();
243 Ref<ID3D12PipelineState> pso67, unknown67;
244 EXPECT(SUCCEEDED(reinterpret_cast<XboxNativeComputePipelineFn>(slot(device.p, 67))(
245 device.p, &native_desc, &pso_iid, reinterpret_cast<void**>(&pso67.p))));
246 EXPECT(pso67.p != nullptr);
247 native_desc.kind6 = other.data();
248 native_desc.kind6_size = other.size();
249 EXPECT(reinterpret_cast<XboxNativeComputePipelineFn>(slot(device.p, 67))(
250 device.p, &native_desc, &pso_iid, reinterpret_cast<void**>(&unknown67.p)) == E_INVALIDARG && !unknown67.p);
251 void* out_null = reinterpret_cast<void*>(0x1111);
252 EXPECT(reinterpret_cast<XboxNativeComputePipelineFn>(slot(device.p, 67))(
253 device.p, nullptr, &pso_iid, &out_null) == E_INVALIDARG && !out_null);
254 out_null = reinterpret_cast<void*>(0x1111);
255 native_desc.kind6 = fssm.data();
256 native_desc.kind6_size = fssm.size();
257 EXPECT(reinterpret_cast<XboxNativeComputePipelineFn>(slot(device.p, 67))(
258 device.p, &native_desc, nullptr, &out_null) == E_POINTER && !out_null);
259 EXPECT(reinterpret_cast<XboxNativeComputePipelineFn>(slot(device.p, 67))(
260 device.p, &native_desc, &pso_iid, nullptr) == E_POINTER);
261
224 // A device whose maxPushConstantsSize is the Vulkan minimum (128 bytes) cannot hold the 144-byte block, so 262 // A device whose maxPushConstantsSize is the Vulkan minimum (128 bytes) cannot hold the 144-byte block, so
225 // its PSOs are refused instead of creating a pipeline layout the spec forbids (#224's fallback flag). 263 // its PSOs are refused instead of creating a pipeline layout the spec forbids (#224's fallback flag).
226 { 264 {
@@ -344,7 +382,131 @@ int main() {
344 std::memcpy(first.data(), results, bytes); 382 std::memcpy(first.data(), results, bytes);
345 std::memcpy(second.data(), static_cast<const std::uint8_t*>(results) + bytes, bytes); 383 std::memcpy(second.data(), static_cast<const std::uint8_t*>(results) + bytes, bytes);
346 384
385 // CreateConstantBufferView: populate shader-visible descriptor heap slots with GFX10 V# descriptors for a
386 // 512-byte arena constant buffer (two 256-byte CBVs: A at +0, B at +256) and null CBVs.
387 {
388 const UINT inc = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
389 EXPECT(inc == 32);
390 const auto cb_desc = buffer_desc(512, D3D12_RESOURCE_FLAG_NONE);
391 Ref<ID3D12Resource> cb_upload, cb_default, cb_readback;
392 EXPECT(SUCCEEDED(device->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE, &cb_desc,
393 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
394 IID_PPV_ARGS(&cb_upload.p))));
395 EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &cb_desc,
396 D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
397 IID_PPV_ARGS(&cb_default.p))));
398 const auto cb_rb_desc = buffer_desc(4 * bytes, D3D12_RESOURCE_FLAG_NONE);
399 EXPECT(SUCCEEDED(device->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &cb_rb_desc,
400 D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
401 IID_PPV_ARGS(&cb_readback.p))));
402 void* cb_mapped = nullptr;
403 EXPECT(SUCCEEDED(cb_upload->Map(0, nullptr, &cb_mapped)));
404 auto* cb_words = static_cast<std::uint32_t*>(cb_mapped);
405 for (UINT i = 0; i < elements; ++i) {
406 cb_words[i] = 0x10000u + i;
407 cb_words[elements + i] = 0x20000u + i;
408 }
409 const D3D12_GPU_VIRTUAL_ADDRESS cb_va = cb_default->GetGPUVirtualAddress();
410 EXPECT(cb_va >= 0x10000 && cb_va < (1ull << 32));
411
412 const auto slot_cpu = [&](UINT idx) { return D3D12_CPU_DESCRIPTOR_HANDLE{SIZE_T(cpu + idx * inc)}; };
413 const auto slot_gpu = [&](UINT idx) { return D3D12_GPU_DESCRIPTOR_HANDLE{gpu + idx * inc}; };
414
415 // Pre-fill slot 3 with non-zero bytes to prove null CBV zeroes the entire 32-byte slot.
416 std::memset(reinterpret_cast<void*>(slot_cpu(3).ptr), 0xA5, inc);
417 device->CreateConstantBufferView(nullptr, slot_cpu(3));
418 std::uint8_t zeros[32] = {};
419 EXPECT(std::memcmp(reinterpret_cast<const void*>(slot_cpu(3).ptr), zeros, sizeof(zeros)) == 0);
420
421 // Zero BufferLocation or zero SizeInBytes also produces a zeroed null V#.
422 const D3D12_CONSTANT_BUFFER_VIEW_DESC zero_loc{0, 256};
423 std::memset(reinterpret_cast<void*>(slot_cpu(3).ptr), 0x5A, inc);
424 device->CreateConstantBufferView(&zero_loc, slot_cpu(3));
425 EXPECT(std::memcmp(reinterpret_cast<const void*>(slot_cpu(3).ptr), zeros, sizeof(zeros)) == 0);
426 const D3D12_CONSTANT_BUFFER_VIEW_DESC zero_size{cb_va, 0};
427 std::memset(reinterpret_cast<void*>(slot_cpu(3).ptr), 0x5A, inc);
428 device->CreateConstantBufferView(&zero_size, slot_cpu(3));
429 EXPECT(std::memcmp(reinterpret_cast<const void*>(slot_cpu(3).ptr), zeros, sizeof(zeros)) == 0);
430
431 const D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_a{cb_va, 256};
432 const D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_b{cb_va + 256, 256};
433 device->CreateConstantBufferView(&cbv_a, slot_cpu(1));
434 device->CreateConstantBufferView(&cbv_b, slot_cpu(2));
435
436 // Decode the written V# in slots 1 and 2 and verify every field + zeroed trailing 16 bytes.
437 for (const auto& [slot_idx, expected_va] :
438 {std::pair{1u, std::uint64_t(cb_va)}, std::pair{2u, std::uint64_t(cb_va + 256)}}) {
439 leonida::gfx10::BufferWords raw{};
440 std::memcpy(raw.data(), reinterpret_cast<const void*>(slot_cpu(slot_idx).ptr), sizeof(raw));
441 leonida::gfx10::Buffer decoded{};
442 EXPECT(leonida::gfx10::decode(raw, decoded));
443 EXPECT(decoded.address == expected_va);
444 EXPECT(decoded.stride == 0);
445 EXPECT(decoded.num_records == 256);
446 EXPECT(decoded.format == leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT));
447 EXPECT(decoded.swizzle == leonida::gfx10::identity_swizzle);
448 EXPECT(decoded.oob_select == leonida::gfx10::OobSelect::raw);
449 EXPECT(std::memcmp(reinterpret_cast<const std::uint8_t*>(slot_cpu(slot_idx).ptr) + 16, zeros, 16) == 0);
450 }
451
452 // Copy CBV data into the arena buffer, then run 4 dispatches:
453 // 1) CBV A at byte offset 0 (all 64 dwords in-bounds)
454 // 2) CBV A at byte offset 128 (dwords 0..31 in-bounds, dwords 32..63 OOB -> 0)
455 // 3) CBV B at byte offset 0 (negative control: all 64 dwords flip to 0x20000 + i)
456 // 4) Null CBV at byte offset 0 (negative control: all 64 dwords become 0)
457 EXPECT(SUCCEEDED(allocator->Reset()) && SUCCEEDED(list->Reset(allocator.p, pso.p)));
458 list->CopyBufferRegion(cb_default.p, 0, cb_upload.p, 0, 512);
459 const D3D12_RESOURCE_BARRIER cb_ready[] = {
460 transition(cb_default.p, D3D12_RESOURCE_STATE_COPY_DEST,
461 D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER),
462 transition(out_a.p, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
463 };
464 list->ResourceBarrier(2, cb_ready);
465 list->SetDescriptorHeaps(1, heaps);
466 list->SetComputeRootSignature(root.p);
467 list->SetComputeRootUnorderedAccessView(1, va_a);
468
469 const struct CbvDispatch {
470 UINT byte_offset;
471 UINT slot_idx;
472 UINT readback_offset;
473 } cbv_dispatches[] = {
474 {0, 1, 0 * bytes},
475 {128, 1, 1 * bytes},
476 {0, 2, 2 * bytes},
477 {0, 3, 3 * bytes},
478 };
479 for (const auto& d_cfg : cbv_dispatches) {
480 const std::uint32_t rc[2] = {d_cfg.byte_offset, 0}; // s1 == 0 selects CBV V# mode
481 list->SetComputeRoot32BitConstants(0, 2, rc, 0);
482 list->SetComputeRootDescriptorTable(2, slot_gpu(d_cfg.slot_idx));
483 list->Dispatch(1, 1, 1);
484 const auto to_src =
485 transition(out_a.p, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
486 list->ResourceBarrier(1, &to_src);
487 list->CopyBufferRegion(cb_readback.p, d_cfg.readback_offset, out_a.p, 0, bytes);
488 const auto to_uav =
489 transition(out_a.p, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
490 list->ResourceBarrier(1, &to_uav);
491 }
492 EXPECT(list->Close() == S_OK);
493 queue->ExecuteCommandLists(1, lists);
494 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
495 EXPECT(SUCCEEDED(queue->Signal(fence.p, 2)));
496 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(2, nullptr)));
497
498 void* cb_res = nullptr;
499 EXPECT(SUCCEEDED(cb_readback->Map(0, nullptr, &cb_res)));
500 const auto* src_bytes = static_cast<const std::uint8_t*>(cb_res);
501 std::memcpy(cbv_a_out.data(), src_bytes + 0 * bytes, bytes);
502 std::memcpy(cbv_oob_out.data(), src_bytes + 1 * bytes, bytes);
503 std::memcpy(cbv_b_out.data(), src_bytes + 2 * bytes, bytes);
504 std::memcpy(cbv_null_out.data(), src_bytes + 3 * bytes, bytes);
505 }
506
347 for (auto* r : {&out_a, &out_b, &constants, &readback}) r->reset(); 507 for (auto* r : {&out_a, &out_b, &constants, &readback}) r->reset();
508 pso67.reset();
509 unknown67.reset();
348 pso.reset(); 510 pso.reset();
349 root.reset(); 511 root.reset();
350 heap.reset(); 512 heap.reset();
@@ -364,6 +526,27 @@ int main() {
364 std::fprintf(stderr, "element %u: got %u and %u, want %u and %u\n", i, first[i], second[i], a, b); 526 std::fprintf(stderr, "element %u: got %u and %u, want %u and %u\n", i, first[i], second[i], a, b);
365 } 527 }
366 EXPECT(!mismatches); 528 EXPECT(!mismatches);
529 UINT cbv_b_diff = 0, cbv_null_diff = 0;
530 for (std::uint32_t i = 0; i < elements; ++i) {
531 const std::uint32_t want_a = 0x10000u + i;
532 const std::uint32_t want_oob = i < 32 ? (0x10000u + 32u + i) : 0u;
533 const std::uint32_t want_b = 0x20000u + i;
534 if (cbv_a_out[i] != want_a && mismatches++ < 4)
535 std::fprintf(stderr, "CBV A[%u]: got 0x%x want 0x%x\n", i, cbv_a_out[i], want_a);
536 if (cbv_oob_out[i] != want_oob && mismatches++ < 4)
537 std::fprintf(stderr, "CBV OOB[%u]: got 0x%x want 0x%x\n", i, cbv_oob_out[i], want_oob);
538 if (cbv_b_out[i] != want_b && mismatches++ < 4)
539 std::fprintf(stderr, "CBV B[%u]: got 0x%x want 0x%x\n", i, cbv_b_out[i], want_b);
540 if (cbv_null_out[i] != 0u && mismatches++ < 4)
541 std::fprintf(stderr, "CBV null[%u]: got 0x%x want 0\n", i, cbv_null_out[i]);
542 if (cbv_b_out[i] != cbv_a_out[i]) ++cbv_b_diff;
543 if (cbv_null_out[i] != cbv_a_out[i]) ++cbv_null_diff;
544 }
545 EXPECT(!mismatches);
546 EXPECT(cbv_b_diff == elements && cbv_null_diff == elements);
547 std::printf("CreateConstantBufferView: 64/64 dwords matched for CBV A, 32 in-bounds + 32 OOB-zero matched at "
548 "+128, negative controls flipped %u/%u (CBV B) and %u/%u (null CBV)\n",
549 cbv_b_diff, elements, cbv_null_diff, elements);
367 if (d.validation_errors()) { 550 if (d.validation_errors()) {
368 std::fprintf(stderr, "%u validation errors\n", d.validation_errors()); 551 std::fprintf(stderr, "%u validation errors\n", d.validation_errors());
369 return 1; 552 return 1;
diff --git a/runtime/test/d3d12_copy_compare.h b/runtime/test/d3d12_copy_compare.h
index 3679ab754..3d4281a17 100644
--- a/runtime/test/d3d12_copy_compare.h
+++ b/runtime/test/d3d12_copy_compare.h
@@ -5,7 +5,8 @@
5// into a readback buffer prefilled with 0xcd, and the bytes are compared. Only the texels a footprint row holds are 5// into a readback buffer prefilled with 0xcd, and the bytes are compared. Only the texels a footprint row holds are
6// compared (row padding is the driver's); everything else, including the 0xcd around a partial copy, must match. 6// compared (row padding is the driver's); everything else, including the 0xcd around a partial copy, must match.
7// Layouts come from the host's GetCopyableFootprints for both sides (those are compared separately). 7// Layouts come from the host's GetCopyableFootprints for both sides (those are compared separately).
8// LEONIDA_HOST_ADAPTER picks the host side: "warp", or part of an adapter name; unset is the default adapter. 8// LEONIDA_HOST_ADAPTER picks the host side: "warp", or part of an adapter name; unset is the layer's own adapter when
9// the test has set layer_adapter(), else the default adapter.
9#pragma once 10#pragma once
10#include <windows.h> 11#include <windows.h>
11#include <d3d12.h> 12#include <d3d12.h>
@@ -18,6 +19,7 @@
18#include <cstdio> 19#include <cstdio>
19#include <cstring> 20#include <cstring>
20#include <functional> 21#include <functional>
22#include <optional>
21#include <string> 23#include <string>
22#include <vector> 24#include <vector>
23 25
@@ -110,12 +112,25 @@ inline bool try_create_host(Ptr<ID3D12Device>& host, std::string& name, const LU
110 return true; 112 return true;
111} 113}
112 114
113// A host device, or false when there is none (the comparisons are then skipped). When LEONIDA_HOST_ADAPTER names an 115// The adapter behind the layer's Vulkan device (VkPhysicalDeviceIDProperties::deviceLUID), for a test that knows it.
114// adapter that cannot be had, the run fails: a typo must not turn the comparisons into a silent pass. 116// On a PC with two GPUs D3D12's default adapter can be the other one, whose driver accepts other formats (an AMD
117// layer device accepts an R9G9B9E5 render target that the NVIDIA host refuses), so the comparison would be between
118// two GPUs instead of between the layer and the host runtime.
119inline std::optional<LUID>& layer_adapter() {
120 static std::optional<LUID> luid;
121 return luid;
122}
123
124// A host device, or false when there is none (the comparisons are then skipped). Without LEONIDA_HOST_ADAPTER it is
125// on the layer's own adapter when that is set and has a D3D12 device, else on the default adapter. When
126// LEONIDA_HOST_ADAPTER names an adapter that cannot be had, the run fails: a typo must not turn the comparisons into a
127// silent pass.
115inline bool create_host(Ptr<ID3D12Device>& host, std::string& name) { 128inline bool create_host(Ptr<ID3D12Device>& host, std::string& name) {
116 if (try_create_host(host, name)) return true;
117 char want[128] = {}; 129 char want[128] = {};
118 if (GetEnvironmentVariableA("LEONIDA_HOST_ADAPTER", want, sizeof(want)) && want[0]) { 130 const bool named = GetEnvironmentVariableA("LEONIDA_HOST_ADAPTER", want, sizeof(want)) && want[0];
131 if (!named && layer_adapter() && try_create_host(host, name, &*layer_adapter())) return true;
132 if (try_create_host(host, name)) return true;
133 if (named) {
119 std::fprintf(stderr, "LEONIDA_HOST_ADAPTER=%s: no such adapter, or no D3D12 device on it\n", want); 134 std::fprintf(stderr, "LEONIDA_HOST_ADAPTER=%s: no such adapter, or no D3D12 device on it\n", want);
120 std::exit(1); 135 std::exit(1);
121 } 136 }
diff --git a/runtime/test/d3d12_descriptor_test.cpp b/runtime/test/d3d12_descriptor_test.cpp
index 64ef24da6..13c10d043 100644
--- a/runtime/test/d3d12_descriptor_test.cpp
+++ b/runtime/test/d3d12_descriptor_test.cpp
@@ -698,6 +698,42 @@ int main() {
698 const auto null_at = [&](UINT i) { 698 const auto null_at = [&](UINT i) {
699 return std::all_of(view_bytes(i), view_bytes(i) + step, [](std::uint8_t byte) { return byte == 0; }); 699 return std::all_of(view_bytes(i), view_bytes(i) + step, [](std::uint8_t byte) { return byte == 0; });
700 }; 700 };
701 // An explicit D3D12_SRV_DIMENSION_TEXTURE1D view on a 1D texture array selects layer zero (like TEXTURE2D
702 // and TEXTURE2DMS on 2D arrays), while a default (nullptr) SRV on a 1D array remains a null descriptor.
703 {
704 auto line_array_desc = line_desc;
705 line_array_desc.DepthOrArraySize = 3;
706 Ref<ID3D12Resource> line_array;
707 EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &line_array_desc,
708 D3D12_RESOURCE_STATE_COMMON, nullptr,
709 IID_PPV_ARGS(&line_array.p))));
710 D3D12_DESCRIPTOR_HEAP_DESC la_heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 2,
711 D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
712 Ref<ID3D12DescriptorHeap> la_heap;
713 EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&la_heap_desc, IID_PPV_ARGS(&la_heap.p))));
714 const std::uint64_t la_cpu = reinterpret_cast<XboxHeapHandleFn>(slot(la_heap.p, 9))(la_heap.p);
715 const D3D12_CPU_DESCRIPTOR_HANDLE la_default{SIZE_T(la_cpu)}, la_slice0{SIZE_T(la_cpu + step)};
716 std::memset(reinterpret_cast<void*>(la_default.ptr), 0x77, step);
717 device->CreateShaderResourceView(line_array.p, nullptr, la_default);
718 EXPECT(std::all_of(reinterpret_cast<const std::uint8_t*>(la_default.ptr),
719 reinterpret_cast<const std::uint8_t*>(la_default.ptr) + step,
720 [](std::uint8_t byte) { return byte == 0; }));
721 D3D12_SHADER_RESOURCE_VIEW_DESC la_view{};
722 la_view.Format = DXGI_FORMAT_UNKNOWN;
723 la_view.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
724 la_view.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
725 la_view.Texture1D = {1, 1, 0};
726 device->CreateShaderResourceView(line_array.p, &la_view, la_slice0);
727 g::ImageWords la_words{};
728 std::memcpy(la_words.data(), reinterpret_cast<const void*>(la_slice0.ptr), sizeof(la_words));
729 g::Image la_image{};
730 EXPECT(g::is_image(la_words) && g::decode(la_words, la_image) &&
731 la_image.type == g::ImageType::image_1d && la_image.first_mip == 1 && la_image.mip_count == 1 &&
732 la_image.first_layer == 0 && la_image.layer_count == 1);
733 std::uint32_t la_key[8]{};
734 std::memcpy(la_key, la_words.data(), sizeof(la_key));
735 EXPECT(rt::d3d12::bindless_hash_lookup(device.p, la_key) != 0);
736 }
701 D3D12_RESOURCE_DESC ms_desc = texture_desc; 737 D3D12_RESOURCE_DESC ms_desc = texture_desc;
702 ms_desc.Width = ms_desc.Height = 4; 738 ms_desc.Width = ms_desc.Height = 4;
703 ms_desc.SampleDesc.Count = 4; 739 ms_desc.SampleDesc.Count = 4;
@@ -2166,6 +2202,47 @@ int main() {
2166#endif 2202#endif
2167 } 2203 }
2168 2204
2205 // Cross-family castable SRV: write_image_descriptor must pass resource.has_view_format_list() into a single
2206 // bind_image call so a listed R8G8B8A8_UINT -> R32_UINT view registers cleanly without a spurious first-pass
2207 // failure (and without double-binding every view).
2208 if (d.bindless) {
2209 Ref<ID3D12Device10> inner10;
2210 EXPECT(SUCCEEDED(inner->QueryInterface(IID_PPV_ARGS(&inner10.p))));
2211 D3D12_RESOURCE_DESC1 cast_desc{};
2212 cast_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
2213 cast_desc.Width = 4;
2214 cast_desc.Height = 4;
2215 cast_desc.DepthOrArraySize = 1;
2216 cast_desc.MipLevels = 1;
2217 cast_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT;
2218 cast_desc.SampleDesc = {1, 0};
2219 cast_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
2220 const DXGI_FORMAT cast_formats[] = {DXGI_FORMAT_R8G8B8A8_UINT, DXGI_FORMAT_R32_UINT};
2221 Ref<ID3D12Resource> cast_tex;
2222 EXPECT(SUCCEEDED(inner10->CreateCommittedResource3(
2223 &default_heap, D3D12_HEAP_FLAG_NONE, &cast_desc, D3D12_BARRIER_LAYOUT_COMMON, nullptr, nullptr,
2224 2, cast_formats, IID_PPV_ARGS(&cast_tex.p))));
2225 const D3D12_DESCRIPTOR_HEAP_DESC cast_hd{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1,
2226 D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
2227 Ref<ID3D12DescriptorHeap> cast_heap;
2228 EXPECT(SUCCEEDED(inner10->CreateDescriptorHeap(&cast_hd, IID_PPV_ARGS(&cast_heap.p))));
2229 const D3D12_CPU_DESCRIPTOR_HANDLE cast_slot = cast_heap->GetCPUDescriptorHandleForHeapStart();
2230 D3D12_SHADER_RESOURCE_VIEW_DESC cast_srv{};
2231 cast_srv.Format = DXGI_FORMAT_R32_UINT;
2232 cast_srv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
2233 cast_srv.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
2234 cast_srv.Texture2D.MipLevels = 1;
2235 inner10->CreateShaderResourceView(cast_tex.p, &cast_srv, cast_slot);
2236 g::ImageWords cast_words{};
2237 std::memcpy(cast_words.data(), reinterpret_cast<const void*>(cast_slot.ptr), sizeof(cast_words));
2238 g::Image decoded{};
2239 EXPECT(g::decode(cast_words, decoded) && decoded.type == g::ImageType::image_2d);
2240 EXPECT(decoded.format == g::format_from_vulkan(VK_FORMAT_R32_UINT));
2241 std::uint32_t cast_key[8]{};
2242 std::memcpy(cast_key, cast_words.data(), sizeof(cast_key));
2243 EXPECT(rt::d3d12::bindless_hash_lookup(device.p, cast_key) != 0);
2244 }
2245
2169 upload.reset(); 2246 upload.reset();
2170 array_texture.reset(); 2247 array_texture.reset();
2171 line.reset(); 2248 line.reset();
diff --git a/runtime/test/d3d12_draw_test.cpp b/runtime/test/d3d12_draw_test.cpp
index 1c29d3822..12a1c71cf 100644
--- a/runtime/test/d3d12_draw_test.cpp
+++ b/runtime/test/d3d12_draw_test.cpp
@@ -630,7 +630,8 @@ int main() {
630 EXPECT(list->Close() == S_OK); 630 EXPECT(list->Close() == S_OK);
631 queue->ExecuteCommandLists(1, lists); 631 queue->ExecuteCommandLists(1, lists);
632 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 632 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
633 EXPECT(SUCCEEDED(queue->Signal(fence.p, 4)) && SUCCEEDED(fence->SetEventOnCompletion(4, nullptr))); 633 // Above the strip passes' 20: a lower value is already reached, so the wait would return at once.
634 EXPECT(SUCCEEDED(queue->Signal(fence.p, 21)) && SUCCEEDED(fence->SetEventOnCompletion(21, nullptr)));
634 const auto* result = static_cast<const std::uint8_t*>(mapped); 635 const auto* result = static_cast<const std::uint8_t*>(mapped);
635 for (UINT row = 0; row < size; ++row) { 636 for (UINT row = 0; row < size; ++row) {
636 for (UINT col = 0; col < size; ++col) { 637 for (UINT col = 0; col < size; ++col) {
diff --git a/runtime/test/d3d12_gcl8_test.cpp b/runtime/test/d3d12_gcl8_test.cpp
index 5872a624f..8b0426e6c 100644
--- a/runtime/test/d3d12_gcl8_test.cpp
+++ b/runtime/test/d3d12_gcl8_test.cpp
@@ -36,6 +36,10 @@ int main(int argc, char** argv) {
36 EXPECT(SUCCEEDED(create_command_allocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); 36 EXPECT(SUCCEEDED(create_command_allocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p))));
37 EXPECT(SUCCEEDED(create_command_list(D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, IID_PPV_ARGS(&list7.p)))); 37 EXPECT(SUCCEEDED(create_command_list(D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, IID_PPV_ARGS(&list7.p))));
38 38
39 // Null bindings exercise the public entry points without creating a pipeline or loading Vulkan.
40 list7.p->SetPipelineState(nullptr);
41 list7.p->SetGraphicsRootSignature(nullptr);
42
39 // AddRef through the GCL7 pointer gives the count this test expects while the QueryInterface reference is held. 43 // AddRef through the GCL7 pointer gives the count this test expects while the QueryInterface reference is held.
40 const ULONG held = list7.p->AddRef(); 44 const ULONG held = list7.p->AddRef();
41 list7.p->Release(); 45 list7.p->Release();
diff --git a/runtime/test/d3d12_m2_textured_test.cpp b/runtime/test/d3d12_m2_textured_test.cpp
index db8e9fd3f..8d13bf214 100644
--- a/runtime/test/d3d12_m2_textured_test.cpp
+++ b/runtime/test/d3d12_m2_textured_test.cpp
@@ -20,6 +20,7 @@
20// [1] POINT/WRAP. The left half takes the WRAP sampler (U + 1 wraps back: the gradient again), the right half the 20// [1] POINT/WRAP. The left half takes the WRAP sampler (U + 1 wraps back: the gradient again), the right half the
21// CLAMP one (U + 1 clamps to the last column: each row is that row's right-edge texel of the reflected texture). The 21// CLAMP one (U + 1 clamps to the last column: each row is that row's right-edge texel of the reflected texture). The
22// pixels are predicted on the CPU, error 0, and 1536 of them differ from the plain reflection. 22// pixels are predicted on the CPU, error 0, and 1536 of them differ from the plain reflection.
23// The control also keeps one unbounded SRV table bound and selects its two entries by a root constant.
23// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation (0 errors required). 24// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation (0 errors required).
24#include "vk_test_device.h" 25#include "vk_test_device.h"
25#include "d3d12_test_shaders.h" 26#include "d3d12_test_shaders.h"
@@ -148,6 +149,22 @@ int main() {
148 pso_desc.SampleDesc.Count = 1; 149 pso_desc.SampleDesc.Count = 1;
149 Ref<ID3D12PipelineState> pso, uoff_pso; 150 Ref<ID3D12PipelineState> pso, uoff_pso;
150 EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&pso_desc, IID_PPV_ARGS(&pso.p)))); 151 EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&pso_desc, IID_PPV_ARGS(&pso.p))));
152 D3D12_DESCRIPTOR_RANGE indexed_range = srv_range;
153 indexed_range.NumDescriptors = UINT32_MAX;
154 D3D12_ROOT_PARAMETER indexed_params[3] = {params[0], params[1], {}};
155 indexed_params[0].DescriptorTable = {1, &indexed_range};
156 indexed_params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
157 indexed_params[2].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
158 indexed_params[2].Constants = {0, 0, 2}; // s4 = SRV index, s5 = SRV stride in bytes
159 D3D12_VERSIONED_ROOT_SIGNATURE_DESC indexed_desc = root_desc;
160 indexed_desc.Desc_1_0.NumParameters = 3;
161 indexed_desc.Desc_1_0.pParameters = indexed_params;
162 const auto indexed_blob = serialize_root_signature(indexed_desc);
163 EXPECT(!indexed_blob.empty());
164 Ref<ID3D12RootSignature> indexed_root;
165 EXPECT(SUCCEEDED(device->CreateRootSignature(0, indexed_blob.data(), indexed_blob.size(),
166 IID_PPV_ARGS(&indexed_root.p))));
167 pso_desc.pRootSignature = indexed_root.p;
151 pso_desc.PS = {uoff_container.data(), uoff_container.size()}; 168 pso_desc.PS = {uoff_container.data(), uoff_container.size()};
152 EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&pso_desc, IID_PPV_ARGS(&uoff_pso.p)))); 169 EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&pso_desc, IID_PPV_ARGS(&uoff_pso.p))));
153 170
@@ -350,8 +367,9 @@ int main() {
350 D3D12_RESOURCE_STATE_RENDER_TARGET); 367 D3D12_RESOURCE_STATE_RENDER_TARGET);
351 list2->ResourceBarrier(1, &back); 368 list2->ResourceBarrier(1, &back);
352 list2->ClearRenderTargetView(rtv, clear, 0, nullptr); 369 list2->ClearRenderTargetView(rtv, clear, 0, nullptr);
353 list2->SetGraphicsRootSignature(root.p); 370 list2->SetGraphicsRootSignature(indexed_root.p);
354 list2->SetDescriptorHeaps(2, heaps); 371 list2->SetDescriptorHeaps(2, heaps);
372 list2->SetGraphicsRootDescriptorTable(0, D3D12_GPU_DESCRIPTOR_HANDLE{srv_gpu});
355 list2->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); 373 list2->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
356 list2->IASetIndexBuffer(&ibv); 374 list2->IASetIndexBuffer(&ibv);
357 list2->RSSetViewports(1, &viewport); 375 list2->RSSetViewports(1, &viewport);
@@ -359,7 +377,8 @@ int main() {
359 for (UINT half = 0; half < 2; ++half) { 377 for (UINT half = 0; half < 2; ++half) {
360 const D3D12_RECT scissor{LONG(half * target_size / 2), 0, LONG((half + 1) * target_size / 2), LONG(target_size)}; 378 const D3D12_RECT scissor{LONG(half * target_size / 2), 0, LONG((half + 1) * target_size / 2), LONG(target_size)};
361 list2->RSSetScissorRects(1, &scissor); 379 list2->RSSetScissorRects(1, &scissor);
362 list2->SetGraphicsRootDescriptorTable(0, D3D12_GPU_DESCRIPTOR_HANDLE{srv_gpu + std::uint64_t(half) * step}); 380 const UINT srv_args[] = {half, step};
381 list2->SetGraphicsRoot32BitConstants(2, 2, srv_args, 0);
363 list2->SetGraphicsRootDescriptorTable( 382 list2->SetGraphicsRootDescriptorTable(
364 1, D3D12_GPU_DESCRIPTOR_HANDLE{sampler_gpu + std::uint64_t(half == 0 ? sampler_step : 0)}); 383 1, D3D12_GPU_DESCRIPTOR_HANDLE{sampler_gpu + std::uint64_t(half == 0 ? sampler_step : 0)});
365 list2->DrawIndexedInstanced(6, 1, 0, 0, 0); 384 list2->DrawIndexedInstanced(6, 1, 0, 0, 0);
@@ -387,6 +406,7 @@ int main() {
387 uoff_pso.reset(); 406 uoff_pso.reset();
388 list2.reset(); 407 list2.reset();
389 allocator2.reset(); 408 allocator2.reset();
409 indexed_root.reset();
390 root.reset(); 410 root.reset();
391 srv_heap.reset(); 411 srv_heap.reset();
392 sampler_heap.reset(); 412 sampler_heap.reset();
diff --git a/runtime/test/d3d12_m4_compute_test.cpp b/runtime/test/d3d12_m4_compute_test.cpp
new file mode 100644
index 000000000..bd3a555fd
--- /dev/null
+++ b/runtime/test/d3d12_m4_compute_test.cpp
@@ -0,0 +1,395 @@
1// Milestone M4, the synthetic part (docs/d3d12_vulkan.md section 6): a compute workload with the structure a game's asset
2// streaming and compute passes have, through the D3D12 API on the proxy, with compute shaders that are translator output
3// (test/shaders/cs_m4_fill.asm and cs_m4_indirect.asm, hand-written RDNA2).
4// Three queues' worth of work, each its own command list type:
5// COPY queue streams an input buffer: CopyBufferRegion from an UPLOAD buffer into a DEFAULT buffer that was created
6// in COMMON (promoted to COPY_DEST there), then Signal(copy fence, 1).
7// COMPUTE queue Wait(copy fence, 1), then one list: a barrier COMMON -> UNORDERED_ACCESS for the input, a compute root
8// signature (four root constants and a descriptor table of five UAVs: a structured buffer, a raw
9// buffer, an R32_UINT RWTexture2D, the raw input and a raw output), a compute PSO, and Dispatch with
10// four groups. That shader fills the structured buffer and the image from the input and writes the
11// arguments of the next dispatch into the raw buffer. Barriers (a transition of the argument buffer to
12// INDIRECT_ARGUMENT and UAV barriers on the buffer and the image) and ExecuteIndirect with a dispatch
13// command signature runs a second PSO whose group count is that buffer's first word: it reads the
14// structured buffer and the image back and writes the raw output. Everything then goes to COMMON and
15// the queue does Signal(compute fence, 1).
16// COPY queue Wait(compute fence, 1), a COPY list that copies the five results (four buffers and the image through
17// CopyTextureRegion) to a READBACK buffer, Signal(copy fence, 2). The CPU waits for that with
18// SetEventOnCompletion and an event.
19// When the Vulkan family has two queues, the copy and the compute D3D12 queue get their own VkQueue (so the fences are
20// real cross-queue semaphores); with one, they share it. Either way the three batches are submitted in dependency order.
21// Compared with a CPU reference, word by word, error 0: the input after the round trip, the structured buffer, the
22// argument buffer, the image and the indirect dispatch's output (which also shows that exactly the 3 groups the
23// first dispatch asked for ran).
24// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation (0 errors required).
25#include "vk_test_device.h"
26#include "d3d12_test_shaders.h"
27#include "../shims/d3d12_com.h"
28#include "../shims/d3d12_xs_device.h"
29#include "../src/shader_library.h"
30
31#include <array>
32#include <cstring>
33
34#ifndef LEONIDA_TEST_M4_DIR
35#error "LEONIDA_TEST_M4_DIR must name the folder build.py wrote (spirv/index.json, fssm/cs_*.fssm)"
36#endif
37
38#define EXPECT(condition) do { \
39 if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \
40} while (0)
41
42using namespace d3d12test;
43using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void* heap); // heap slots 9/10: handle in RAX
44
45namespace {
46
47std::vector<std::uint8_t> read_file(const std::filesystem::path& path) {
48 std::ifstream in(path, std::ios::binary);
49 return {std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>()};
50}
51
52constexpr UINT records = 256; // fill: 4 groups of 64
53constexpr UINT second_groups = 3; // the indirect dispatch: 3 groups of 64
54constexpr UINT image_dim = 16; // 16 x 16 R32_UINT, one texel a record
55constexpr UINT seed = 0x00c0ffee, multiplier = 0x01000193;
56// The readback buffer: the structured buffer, the argument buffer's 16 bytes, the second output, the input, the image.
57constexpr UINT64 data_bytes = records * 16, args_bytes = 16, out2_bytes = second_groups * 64 * 8, in_bytes = records * 4;
58constexpr UINT64 offset_data = 0, offset_args = offset_data + data_bytes, offset_out2 = offset_args + args_bytes,
59 offset_in = offset_out2 + out2_bytes;
60constexpr UINT64 offset_image = (offset_in + in_bytes + 511) / 512 * 512;
61constexpr UINT image_pitch = D3D12_TEXTURE_DATA_PITCH_ALIGNMENT;
62constexpr UINT64 readback_bytes = offset_image + UINT64(image_dim) * image_pitch;
63
64std::uint32_t rotr(std::uint32_t v, unsigned n) { return (v >> n) | (v << (32 - n)); }
65std::uint32_t input_word(UINT g) { return (g + 1) * 0x9e3779b1u ^ (g << 7); }
66
67struct Reference {
68 std::vector<std::uint32_t> data, args, in, image, out2;
69};
70Reference reference() {
71 Reference ref;
72 ref.args = {second_groups, 1, 1, 0xc0de0001u};
73 ref.data.resize(records * 4);
74 ref.image.resize(image_dim * image_dim);
75 for (UINT g = 0; g < records; ++g) {
76 const std::uint32_t in = input_word(g);
77 ref.in.push_back(in);
78 ref.data[g * 4 + 0] = in + seed;
79 ref.data[g * 4 + 1] = g * multiplier;
80 ref.data[g * 4 + 2] = in ^ (g << 8);
81 ref.data[g * 4 + 3] = rotr(in, 13);
82 const UINT x = g & 15, y = g >> 4;
83 ref.image[y * image_dim + x] = in * 3 + x * 0x10001u + y;
84 }
85 for (UINT g = 0; g < second_groups * 64; ++g) {
86 const std::uint32_t t = ref.image[g]; // (g & 15, g >> 4) is texel g of the row-major image
87 ref.out2.push_back((ref.data[g * 4 + 0] + t) ^ ref.data[g * 4 + 3]);
88 ref.out2.push_back((ref.data[g * 4 + 2] ^ t) + ref.data[g * 4 + 1]);
89 }
90 return ref;
91}
92
93} // namespace
94
95int main() {
96 vktest::Device d;
97 d.queue_count_wanted = 2; // the copy queue and the compute queue each get a VkQueue where the family has two
98 const auto device_status = d.initialize();
99 if (device_status == vktest::DeviceStatus::unavailable) return 77; // no Vulkan GPU: ctest skips
100 if (device_status != vktest::DeviceStatus::ready) return 1;
101 if (!d.bindless) {
102 std::printf("SKIP: the device lacks the descriptor indexing features of the bindless set 0\n");
103 return 77;
104 }
105
106 const std::filesystem::path root_dir = LEONIDA_TEST_M4_DIR;
107 leonida::ShaderLibrary library;
108 EXPECT(library.load((root_dir / "spirv").string()));
109 const auto program = [&](const char* name) { return read_file(root_dir / "fssm" / (std::string(name) + ".fssm")); };
110 const auto fill = program("cs_m4_fill"), indirect = program("cs_m4_indirect");
111 EXPECT(fill.size() >= 0x150 && indirect.size() >= 0x150 && fill != indirect);
112 EXPECT(library.find("cs", leonida::sha256_hex(fill)) && library.find("cs", leonida::sha256_hex(indirect)));
113 const auto fill_container = shader_container(fill), indirect_container = shader_container(indirect);
114
115 const bool distinct_queues = d.queues.size() >= 2;
116 Reference want = reference();
117 std::vector<std::uint8_t> got;
118 {
119 rt::d3d12::VulkanDeviceInfo info{};
120 info.get_instance_proc = d.instance_proc;
121 info.instance = d.instance;
122 info.physical = d.physical;
123 info.device = d.device;
124 info.queue = d.queue;
125 info.queue_family = d.family;
126 if (distinct_queues) info.command_queues = d.queues;
127 info.buffer_device_address = true;
128 info.bindless = d.bindless;
129 info.bindless_partially_bound = d.partially_bound;
130 info.image_view_min_lod = d.image_view_min_lod;
131 info.shader_dir = (root_dir / "spirv").string();
132 ID3D12Device* inner = nullptr;
133 EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner))));
134 Ref<ID3D12Device> device;
135 EXPECT(SUCCEEDED(rt::d3d12_xs::create_device_proxy(inner, __uuidof(ID3D12Device),
136 reinterpret_cast<void**>(&device.p))));
137 rt::d3d12::set_device_outer(inner, device.p);
138 EXPECT(rt::d3d12::bindless_set(device.p) != VK_NULL_HANDLE);
139
140 // [0] four 32-bit constants (s0..s3), [1] a table of five UAVs (s[4:5]).
141 D3D12_DESCRIPTOR_RANGE uav_range{D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 5, 0, 0, 0};
142 D3D12_ROOT_PARAMETER params[2] = {};
143 params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
144 params[0].Constants = {0, 0, 4};
145 params[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
146 params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
147 params[1].DescriptorTable = {1, &uav_range};
148 params[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
149 D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{};
150 root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
151 root_desc.Desc_1_0 = {2, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE};
152 const auto root_blob = serialize_root_signature(root_desc);
153 EXPECT(!root_blob.empty());
154 Ref<ID3D12RootSignature> root;
155 EXPECT(SUCCEEDED(device->CreateRootSignature(0, root_blob.data(), root_blob.size(), IID_PPV_ARGS(&root.p))));
156
157 D3D12_COMPUTE_PIPELINE_STATE_DESC pso_desc{};
158 pso_desc.pRootSignature = root.p;
159 pso_desc.CS = {fill_container.data(), fill_container.size()};
160 Ref<ID3D12PipelineState> pso_fill, pso_indirect;
161 EXPECT(SUCCEEDED(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&pso_fill.p))));
162 pso_desc.CS = {indirect_container.data(), indirect_container.size()};
163 EXPECT(SUCCEEDED(device->CreateComputePipelineState(&pso_desc, IID_PPV_ARGS(&pso_indirect.p))));
164
165 D3D12_INDIRECT_ARGUMENT_DESC argument{};
166 argument.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH;
167 D3D12_COMMAND_SIGNATURE_DESC signature_desc{};
168 signature_desc.ByteStride = sizeof(D3D12_DISPATCH_ARGUMENTS);
169 signature_desc.NumArgumentDescs = 1;
170 signature_desc.pArgumentDescs = &argument;
171 Ref<ID3D12CommandSignature> signature;
172 EXPECT(SUCCEEDED(device->CreateCommandSignature(&signature_desc, nullptr, IID_PPV_ARGS(&signature.p))));
173
174 const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT};
175 const D3D12_HEAP_PROPERTIES upload_heap{D3D12_HEAP_TYPE_UPLOAD};
176 const D3D12_HEAP_PROPERTIES readback_heap{D3D12_HEAP_TYPE_READBACK};
177 constexpr auto uav_flag = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
178 constexpr auto uav_state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
179 constexpr auto common = D3D12_RESOURCE_STATE_COMMON;
180 Ref<ID3D12Resource> upload, input, data, args, out2, image, readback;
181 const auto create_buffer = [&](Ref<ID3D12Resource>& out, const D3D12_HEAP_PROPERTIES& heap, UINT64 bytes,
182 D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES state) {
183 const auto desc = buffer_desc(bytes, flags);
184 return SUCCEEDED(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, state, nullptr,
185 IID_PPV_ARGS(&out.p)));
186 };
187 EXPECT(create_buffer(upload, upload_heap, in_bytes, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ));
188 EXPECT(create_buffer(input, default_heap, in_bytes, uav_flag, common));
189 EXPECT(create_buffer(data, default_heap, data_bytes, uav_flag, uav_state));
190 EXPECT(create_buffer(args, default_heap, 256, uav_flag, uav_state));
191 EXPECT(create_buffer(out2, default_heap, out2_bytes, uav_flag, uav_state));
192 EXPECT(create_buffer(readback, readback_heap, readback_bytes, D3D12_RESOURCE_FLAG_NONE,
193 D3D12_RESOURCE_STATE_COPY_DEST));
194 D3D12_RESOURCE_DESC image_desc{};
195 image_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
196 image_desc.Width = image_desc.Height = image_dim;
197 image_desc.DepthOrArraySize = 1;
198 image_desc.MipLevels = 1;
199 image_desc.Format = DXGI_FORMAT_R32_UINT;
200 image_desc.SampleDesc.Count = 1;
201 image_desc.Flags = uav_flag;
202 EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &image_desc, uav_state,
203 nullptr, IID_PPV_ARGS(&image.p))));
204 {
205 std::uint32_t* mapped = nullptr;
206 EXPECT(SUCCEEDED(upload->Map(0, nullptr, reinterpret_cast<void**>(&mapped))));
207 for (UINT g = 0; g < records; ++g) mapped[g] = input_word(g);
208 upload->Unmap(0, nullptr);
209 }
210
211 // The table: slot 0 structured buffer (stride 16), 1 raw argument buffer, 2 image, 3 raw input, 4 raw output.
212 const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 5,
213 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0};
214 Ref<ID3D12DescriptorHeap> heap;
215 EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap.p))));
216 const std::uint64_t cpu = reinterpret_cast<XboxHeapHandleFn>(slot(heap.p, 9))(heap.p);
217 const std::uint64_t gpu = reinterpret_cast<XboxHeapHandleFn>(slot(heap.p, 10))(heap.p);
218 const UINT step = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
219 EXPECT(cpu && gpu >= 0x10000 && gpu < (1ull << 32) && step == 32); // the shaders step 32 bytes a slot
220 const auto handle = [&](UINT i) { return D3D12_CPU_DESCRIPTOR_HANDLE{SIZE_T(cpu + std::uint64_t(i) * step)}; };
221 const auto buffer_view = [](DXGI_FORMAT format, UINT count, UINT stride, D3D12_BUFFER_UAV_FLAGS flags) {
222 D3D12_UNORDERED_ACCESS_VIEW_DESC view{};
223 view.Format = format;
224 view.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
225 view.Buffer = {0, count, stride, 0, flags};
226 return view;
227 };
228 auto view = buffer_view(DXGI_FORMAT_UNKNOWN, records, 16, D3D12_BUFFER_UAV_FLAG_NONE);
229 device->CreateUnorderedAccessView(data.p, nullptr, &view, handle(0));
230 view = buffer_view(DXGI_FORMAT_R32_TYPELESS, 4, 0, D3D12_BUFFER_UAV_FLAG_RAW); // the 16 bytes of arguments
231 device->CreateUnorderedAccessView(args.p, nullptr, &view, handle(1));
232 D3D12_UNORDERED_ACCESS_VIEW_DESC image_view{};
233 image_view.Format = DXGI_FORMAT_R32_UINT;
234 image_view.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
235 device->CreateUnorderedAccessView(image.p, nullptr, &image_view, handle(2));
236 view = buffer_view(DXGI_FORMAT_R32_TYPELESS, records, 0, D3D12_BUFFER_UAV_FLAG_RAW);
237 device->CreateUnorderedAccessView(input.p, nullptr, &view, handle(3));
238 view = buffer_view(DXGI_FORMAT_R32_TYPELESS, UINT(out2_bytes / 4), 0, D3D12_BUFFER_UAV_FLAG_RAW);
239 device->CreateUnorderedAccessView(out2.p, nullptr, &view, handle(4));
240 // The V# of the structured view and the T# of the image view are what the shader loads from the table.
241 std::uint32_t v_data[4], v_args[4];
242 std::memcpy(v_data, reinterpret_cast<const void*>(handle(0).ptr), sizeof(v_data));
243 std::memcpy(v_args, reinterpret_cast<const void*>(handle(1).ptr), sizeof(v_args));
244 EXPECT(v_data[0] == std::uint32_t(data->GetGPUVirtualAddress()) && (v_data[1] >> 16 & 0x3fff) == 16 &&
245 v_data[2] == records);
246 EXPECT(v_args[0] == std::uint32_t(args->GetGPUVirtualAddress()) && (v_args[1] >> 16 & 0x3fff) == 0 &&
247 v_args[2] == 16);
248
249 D3D12_COMMAND_QUEUE_DESC queue_desc{};
250 Ref<ID3D12CommandQueue> copy_queue, compute_queue;
251 queue_desc.Type = D3D12_COMMAND_LIST_TYPE_COPY;
252 EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&copy_queue.p))));
253 queue_desc.Type = D3D12_COMMAND_LIST_TYPE_COMPUTE;
254 EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&compute_queue.p))));
255 Ref<ID3D12CommandAllocator> stream_alloc, compute_alloc, readback_alloc;
256 Ref<ID3D12GraphicsCommandList> stream_list, compute_list, readback_list;
257 Ref<ID3D12Fence> copy_fence, compute_fence;
258 const auto make_list = [&](D3D12_COMMAND_LIST_TYPE type, Ref<ID3D12CommandAllocator>& alloc,
259 Ref<ID3D12GraphicsCommandList>& list) {
260 return SUCCEEDED(device->CreateCommandAllocator(type, IID_PPV_ARGS(&alloc.p))) &&
261 SUCCEEDED(device->CreateCommandList(0, type, alloc.p, nullptr, IID_PPV_ARGS(&list.p)));
262 };
263 EXPECT(make_list(D3D12_COMMAND_LIST_TYPE_COPY, stream_alloc, stream_list));
264 EXPECT(make_list(D3D12_COMMAND_LIST_TYPE_COMPUTE, compute_alloc, compute_list));
265 EXPECT(make_list(D3D12_COMMAND_LIST_TYPE_COPY, readback_alloc, readback_list));
266 EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&copy_fence.p))));
267 EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&compute_fence.p))));
268
269 // Copy list 1: stream the input in (the buffer is in COMMON and is promoted to COPY_DEST by the copy). This is the
270 // first submission after the UAV views were written, and a copy queue: it must not initialize the storage image
271 // (the compute queue does, in the submission that dispatches), or the data written later would be at risk.
272 stream_list->CopyBufferRegion(input.p, 0, upload.p, 0, in_bytes);
273 EXPECT(stream_list->Close() == S_OK);
274
275 D3D12_TEXTURE_COPY_LOCATION dst{}, src{};
276 dst.pResource = readback.p;
277 dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
278 dst.PlacedFootprint = {offset_image, {DXGI_FORMAT_R32_UINT, image_dim, image_dim, 1, image_pitch}};
279 src.pResource = image.p;
280 src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
281
282 // Compute list.
283 ID3D12DescriptorHeap* heaps[] = {heap.p};
284 D3D12_RESOURCE_BARRIER acquire = transition(input.p, common, uav_state);
285 compute_list->ResourceBarrier(1, &acquire);
286 compute_list->SetDescriptorHeaps(1, heaps);
287 compute_list->SetComputeRootSignature(root.p);
288 compute_list->SetPipelineState(pso_fill.p);
289 const std::uint32_t constants[4] = {seed, multiplier, second_groups, 0};
290 compute_list->SetComputeRoot32BitConstants(0, 4, constants, 0);
291 compute_list->SetComputeRootDescriptorTable(1, D3D12_GPU_DESCRIPTOR_HANDLE{gpu});
292 compute_list->Dispatch(records / 64, 1, 1);
293 D3D12_RESOURCE_BARRIER between[3] = {transition(args.p, uav_state, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT),
294 {}, {}};
295 for (int i : {1, 2}) {
296 between[i].Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
297 between[i].UAV.pResource = i == 1 ? data.p : image.p;
298 }
299 compute_list->ResourceBarrier(3, between);
300 compute_list->SetPipelineState(pso_indirect.p); // the root arguments stay
301 compute_list->ExecuteIndirect(signature.p, 1, args.p, 0, nullptr, 0);
302 D3D12_RESOURCE_BARRIER release[5] = {transition(data.p, uav_state, common),
303 transition(args.p, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, common),
304 transition(out2.p, uav_state, common),
305 transition(input.p, uav_state, common),
306 transition(image.p, uav_state, common)};
307 compute_list->ResourceBarrier(5, release);
308 EXPECT(compute_list->Close() == S_OK);
309
310 // Copy list 2: the results to the readback buffer, once the compute queue is done.
311 readback_list->CopyBufferRegion(readback.p, offset_data, data.p, 0, data_bytes);
312 readback_list->CopyBufferRegion(readback.p, offset_args, args.p, 0, args_bytes);
313 readback_list->CopyBufferRegion(readback.p, offset_out2, out2.p, 0, out2_bytes);
314 readback_list->CopyBufferRegion(readback.p, offset_in, input.p, 0, in_bytes);
315 readback_list->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr);
316 EXPECT(readback_list->Close() == S_OK);
317
318 const auto execute = [&](ID3D12CommandQueue* queue, ID3D12GraphicsCommandList* list) {
319 ID3D12CommandList* lists[] = {list};
320 queue->ExecuteCommandLists(1, lists);
321 return rt::d3d12::last_execute_result(queue) == leonida::ReplayResult::success;
322 };
323 const auto submit_copy = [&] {
324 return execute(copy_queue.p, stream_list.p) && SUCCEEDED(copy_queue->Signal(copy_fence.p, 1));
325 };
326 const auto submit_readback = [&] {
327 return SUCCEEDED(copy_queue->Wait(compute_fence.p, 1)) && execute(copy_queue.p, readback_list.p) &&
328 SUCCEEDED(copy_queue->Signal(copy_fence.p, 2));
329 };
330 const auto submit_compute = [&] {
331 return SUCCEEDED(compute_queue->Wait(copy_fence.p, 1)) && execute(compute_queue.p, compute_list.p) &&
332 SUCCEEDED(compute_queue->Signal(compute_fence.p, 1));
333 };
334 // In dependency order: the layer replays a list at ExecuteCommandLists and tracks every image's layout in that
335 // order, so a list that waits for another queue's signal has to be submitted after the list it waits for
336 // (the Wait-before-Signal order d3d12_queue_wait_test covers, without a resource handed over).
337 EXPECT(submit_copy() && submit_compute() && submit_readback());
338
339 const HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
340 EXPECT(event != nullptr);
341 EXPECT(SUCCEEDED(copy_fence->SetEventOnCompletion(2, event)));
342 if (WaitForSingleObject(event, 20000) != WAIT_OBJECT_0) {
343 std::fprintf(stderr, "the copy fence never reached 2 (compute fence at %llu)\n",
344 static_cast<unsigned long long>(compute_fence->GetCompletedValue()));
345 return 1;
346 }
347 CloseHandle(event);
348 EXPECT(copy_fence->GetCompletedValue() >= 2 && compute_fence->GetCompletedValue() >= 1);
349
350 void* mapped = nullptr;
351 EXPECT(SUCCEEDED(readback->Map(0, nullptr, &mapped)));
352 got.assign(static_cast<const std::uint8_t*>(mapped), static_cast<const std::uint8_t*>(mapped) + readback_bytes);
353 readback->Unmap(0, nullptr);
354
355 for (auto* r : {&upload, &input, &data, &args, &out2, &image, &readback}) r->reset();
356 stream_list.reset(); compute_list.reset(); readback_list.reset();
357 stream_alloc.reset(); compute_alloc.reset(); readback_alloc.reset();
358 copy_fence.reset(); compute_fence.reset();
359 signature.reset(); pso_fill.reset(); pso_indirect.reset(); root.reset(); heap.reset();
360 copy_queue.reset(); compute_queue.reset();
361 EXPECT(rt::d3d12_xs::device_proxy_ref_count(device.p) == 1);
362 }
363
364 unsigned mismatches = 0, words = 0;
365 const auto compare = [&](const char* what, UINT64 offset, const std::vector<std::uint32_t>& expected, UINT pitch,
366 UINT row_words) {
367 unsigned bad = 0;
368 for (std::size_t i = 0; i < expected.size(); ++i) {
369 std::uint32_t value = 0;
370 const UINT64 at = offset + (pitch ? (i / row_words) * pitch + (i % row_words) * 4 : i * 4);
371 std::memcpy(&value, got.data() + at, 4);
372 ++words;
373 if (value == expected[i]) continue;
374 ++mismatches;
375 if (bad++ < 4) std::fprintf(stderr, "%s word %zu: got %08x want %08x\n", what, i, value, expected[i]);
376 }
377 if (bad) std::fprintf(stderr, "%s: %u of %zu words differ\n", what, bad, expected.size());
378 };
379 compare("input (copy queue round trip)", offset_in, want.in, 0, 0);
380 compare("structured buffer", offset_data, want.data, 0, 0);
381 compare("dispatch arguments", offset_args, want.args, 0, 0);
382 compare("image", offset_image, want.image, image_pitch, image_dim);
383 compare("indirect dispatch output", offset_out2, want.out2, 0, 0);
384 EXPECT(!mismatches);
385 if (d.validation_errors()) {
386 std::fprintf(stderr, "%u validation errors\n", d.validation_errors());
387 return 1;
388 }
389 std::printf("M4: a COPY queue streamed an input buffer in, a COMPUTE queue ran a compute PSO over a UAV table "
390 "(structured buffer, raw buffers, an R32_UINT storage image) and a second dispatch through "
391 "ExecuteIndirect from arguments the first wrote, and a COPY queue behind a cross-queue fence read the "
392 "results back (%s): %u words matched the CPU reference (error 0)\n",
393 distinct_queues ? "two VkQueues" : "one VkQueue", words);
394 return 0;
395}
diff --git a/runtime/test/d3d12_pipeline_library_test.cpp b/runtime/test/d3d12_pipeline_library_test.cpp
new file mode 100644
index 000000000..cd7b411e5
--- /dev/null
+++ b/runtime/test/d3d12_pipeline_library_test.cpp
@@ -0,0 +1,316 @@
1// Synthetic GPU test for ID3D12Device1::CreatePipelineLibrary and ID3D12PipelineLibrary / ID3D12PipelineLibrary1:
2// - empty library creation (0-byte blob), null-output capability check (S_FALSE), and invalid/foreign/corrupt
3// blob rejection (E_INVALIDARG for null pointer with non-zero size, D3D12_ERROR_DRIVER_VERSION_MISMATCH for
4// unrecognized or corrupt headers);
5// - StorePipeline (unique names, duplicate rejection, null/empty name rejection, null/foreign PSO rejection);
6// - LoadComputePipeline, LoadGraphicsPipeline, and ID3D12PipelineLibrary1::LoadPipeline (including cross-type
7// mismatch rejection when a compute PSO is requested through LoadGraphicsPipeline or vice versa);
8// - GetSerializedSize + Serialize round-trip into a second CreatePipelineLibrary;
9// - GPU execution of both loaded compute and loaded graphics PSOs under LEONIDA_VK_VALIDATION=1.
10// No game data.
11#include "vk_test_device.h"
12#include "d3d12_test_shaders.h"
13#include "../shims/d3d12_com.h"
14#include "../src/shader_library.h"
15
16#include <cstring>
17#include <filesystem>
18#include <fstream>
19#include <vector>
20
21#if !defined(LEONIDA_TEST_CS_SPV) || !defined(LEONIDA_TEST_VS_SPV) || !defined(LEONIDA_TEST_PS_SPV)
22#error "LEONIDA_TEST_CS_SPV, LEONIDA_TEST_VS_SPV and LEONIDA_TEST_PS_SPV must be defined"
23#endif
24
25#define EXPECT(condition) do { \
26 if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \
27} while (0)
28
29using namespace d3d12test;
30
31namespace {
32
33struct Vertex {
34 float x, y;
35 std::uint8_t r, g, b, a;
36};
37
38D3D12_RESOURCE_DESC tex2d_desc(UINT w, UINT h, DXGI_FORMAT fmt, D3D12_RESOURCE_FLAGS flags) {
39 D3D12_RESOURCE_DESC d{};
40 d.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
41 d.Width = w;
42 d.Height = h;
43 d.DepthOrArraySize = 1;
44 d.MipLevels = 1;
45 d.Format = fmt;
46 d.SampleDesc = {1, 0};
47 d.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
48 d.Flags = flags;
49 return d;
50}
51
52} // namespace
53
54int main() {
55 vktest::Device d;
56 const auto status = d.initialize();
57 if (status == vktest::DeviceStatus::unavailable) {
58 std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n");
59 return 77;
60 }
61 EXPECT(status == vktest::DeviceStatus::ready);
62
63 const auto cs_prog = fssm_program({0x43532001, 0xbf810000});
64 const auto vs_prog = fssm_program({0x56532001, 0xbf810000});
65 const auto ps_prog = fssm_program({0x50532001, 0xbf810000});
66 const auto cs_dxbc = shader_container(cs_prog);
67 const auto vs_dxbc = shader_container(vs_prog);
68 const auto ps_dxbc = shader_container(ps_prog);
69
70 const auto lib_dir = std::filesystem::temp_directory_path() / "leonida_pipeline_library_test";
71 std::filesystem::create_directories(lib_dir);
72 std::filesystem::copy_file(LEONIDA_TEST_CS_SPV, lib_dir / "cs.spv",
73 std::filesystem::copy_options::overwrite_existing);
74 std::filesystem::copy_file(LEONIDA_TEST_VS_SPV, lib_dir / "vs.spv",
75 std::filesystem::copy_options::overwrite_existing);
76 std::filesystem::copy_file(LEONIDA_TEST_PS_SPV, lib_dir / "ps.spv",
77 std::filesystem::copy_options::overwrite_existing);
78 {
79 std::ofstream idx(lib_dir / "index.json", std::ios::binary);
80 idx << "{\"cs\": {\"stage\": \"cs\", \"fssm_sha256\": \"" << leonida::sha256_hex(cs_prog)
81 << "\", \"bindings\": [], \"push_constant_bytes\": 144},\n"
82 " \"vs\": {\"stage\": \"vs\", \"fssm_sha256\": \"" << leonida::sha256_hex(vs_prog)
83 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"input_signature\": ["
84 "{\"semantic\": \"COLOR\", \"semantic_index\": 0, \"register\": 0, \"mask\": 15, \"rw_mask\": 15, "
85 "\"system_value\": 0, \"component_type\": \"float\"}, "
86 "{\"semantic\": \"POSITION\", \"semantic_index\": 0, \"register\": 1, \"mask\": 3, \"rw_mask\": 3, "
87 "\"system_value\": 0, \"component_type\": \"float\"}]},\n"
88 " \"ps\": {\"stage\": \"ps\", \"fssm_sha256\": \"" << leonida::sha256_hex(ps_prog)
89 << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"outputs\": [0]}}";
90 }
91
92 rt::d3d12::VulkanDeviceInfo info{};
93 info.get_instance_proc = d.instance_proc;
94 info.instance = d.instance;
95 info.physical = d.physical;
96 info.device = d.device;
97 info.queue = d.queue;
98 info.queue_family = d.family;
99 info.buffer_device_address = true;
100 info.shader_dir = lib_dir.string();
101
102 Ref<ID3D12Device1> device;
103 EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&device.p))));
104
105 // 1. CreatePipelineLibrary creation, capability check (null output -> S_FALSE), and invalid/corrupt blobs.
106 {
107 EXPECT(device->CreatePipelineLibrary(nullptr, 0, __uuidof(ID3D12PipelineLibrary), nullptr) == S_FALSE);
108 Ref<ID3D12PipelineLibrary> bad;
109 EXPECT(device->CreatePipelineLibrary(nullptr, 16, IID_PPV_ARGS(&bad.p)) == E_INVALIDARG && !bad.p);
110 const std::uint32_t foreign[4] = {0xDEADBEEFu, 1u, 0u, 0u};
111 EXPECT(device->CreatePipelineLibrary(foreign, sizeof(foreign), IID_PPV_ARGS(&bad.p)) ==
112 D3D12_ERROR_DRIVER_VERSION_MISMATCH &&
113 !bad.p);
114 const std::uint8_t tiny[4] = {1, 2, 3, 4};
115 EXPECT(device->CreatePipelineLibrary(tiny, sizeof(tiny), IID_PPV_ARGS(&bad.p)) ==
116 D3D12_ERROR_DRIVER_VERSION_MISMATCH &&
117 !bad.p);
118 }
119
120 // 2. Build one compute PSO and one graphics PSO.
121 D3D12_DESCRIPTOR_RANGE uav_range{D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 1, 0, 0};
122 D3D12_ROOT_PARAMETER cs_params[3]{};
123 cs_params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
124 cs_params[0].Constants = {0, 0, 1};
125 cs_params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV;
126 cs_params[1].Descriptor = {0, 0};
127 cs_params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
128 cs_params[2].DescriptorTable = {1, &uav_range};
129 D3D12_VERSIONED_ROOT_SIGNATURE_DESC cs_rs_desc{};
130 cs_rs_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
131 cs_rs_desc.Desc_1_0 = {3, cs_params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE};
132 const auto cs_rs_blob = serialize_root_signature(cs_rs_desc);
133 Ref<ID3D12RootSignature> cs_rs;
134 EXPECT(SUCCEEDED(device->CreateRootSignature(0, cs_rs_blob.data(), cs_rs_blob.size(), IID_PPV_ARGS(&cs_rs.p))));
135
136 D3D12_COMPUTE_PIPELINE_STATE_DESC cs_desc{};
137 cs_desc.pRootSignature = cs_rs.p;
138 cs_desc.CS = {cs_dxbc.data(), cs_dxbc.size()};
139 Ref<ID3D12PipelineState> cs_pso;
140 EXPECT(SUCCEEDED(device->CreateComputePipelineState(&cs_desc, IID_PPV_ARGS(&cs_pso.p))));
141
142 D3D12_ROOT_PARAMETER gfx_params[2]{};
143 gfx_params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
144 gfx_params[0].Constants = {0, 0, 2};
145 gfx_params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
146 gfx_params[1].Descriptor = {1, 0};
147 D3D12_VERSIONED_ROOT_SIGNATURE_DESC gfx_rs_desc{};
148 gfx_rs_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0;
149 gfx_rs_desc.Desc_1_0 = {2, gfx_params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT};
150 const auto gfx_rs_blob = serialize_root_signature(gfx_rs_desc);
151 Ref<ID3D12RootSignature> gfx_rs;
152 EXPECT(SUCCEEDED(device->CreateRootSignature(0, gfx_rs_blob.data(), gfx_rs_blob.size(), IID_PPV_ARGS(&gfx_rs.p))));
153
154 const D3D12_INPUT_ELEMENT_DESC input_elems[2] = {
155 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
156 {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT,
157 D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
158 };
159 D3D12_GRAPHICS_PIPELINE_STATE_DESC gfx_desc{};
160 gfx_desc.pRootSignature = gfx_rs.p;
161 gfx_desc.VS = {vs_dxbc.data(), vs_dxbc.size()};
162 gfx_desc.PS = {ps_dxbc.data(), ps_dxbc.size()};
163 gfx_desc.BlendState.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
164 gfx_desc.SampleMask = 0xFFFFFFFFu;
165 gfx_desc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
166 gfx_desc.RasterizerState.CullMode = D3D12_CULL_MODE_BACK;
167 gfx_desc.RasterizerState.DepthClipEnable = TRUE;
168 gfx_desc.InputLayout = {input_elems, 2};
169 gfx_desc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
170 gfx_desc.NumRenderTargets = 1;
171 gfx_desc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
172 gfx_desc.SampleDesc = {1, 0};
173 Ref<ID3D12PipelineState> gfx_pso;
174 EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&gfx_desc, IID_PPV_ARGS(&gfx_pso.p))));
175
176 // 3. Store, load, cross-type rejection, and serialize round-trip.
177 Ref<ID3D12PipelineLibrary1> lib;
178 EXPECT(SUCCEEDED(device->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(&lib.p))) && lib.p);
179 Ref<ID3D12Device> parent_dev;
180 EXPECT(SUCCEEDED(lib->GetDevice(IID_PPV_ARGS(&parent_dev.p))) && parent_dev.p);
181
182 EXPECT(lib->StorePipeline(nullptr, cs_pso.p) == E_INVALIDARG);
183 EXPECT(lib->StorePipeline(L"", cs_pso.p) == E_INVALIDARG);
184 EXPECT(lib->StorePipeline(L"cs", nullptr) == E_INVALIDARG);
185 EXPECT(SUCCEEDED(lib->StorePipeline(L"cs", cs_pso.p)));
186 EXPECT(lib->StorePipeline(L"cs", cs_pso.p) == E_INVALIDARG); // duplicate name
187 EXPECT(SUCCEEDED(lib->StorePipeline(L"gfx", gfx_pso.p)));
188
189 Ref<ID3D12PipelineState> loaded_cs, loaded_gfx, loaded_any, wrong;
190 EXPECT(lib->LoadComputePipeline(L"missing", &cs_desc, IID_PPV_ARGS(&wrong.p)) == E_INVALIDARG && !wrong.p);
191 EXPECT(lib->LoadComputePipeline(L"gfx", &cs_desc, IID_PPV_ARGS(&wrong.p)) == E_INVALIDARG && !wrong.p);
192 EXPECT(lib->LoadGraphicsPipeline(L"cs", &gfx_desc, IID_PPV_ARGS(&wrong.p)) == E_INVALIDARG && !wrong.p);
193 EXPECT(SUCCEEDED(lib->LoadComputePipeline(L"cs", &cs_desc, IID_PPV_ARGS(&loaded_cs.p))) && loaded_cs.p);
194 EXPECT(SUCCEEDED(lib->LoadGraphicsPipeline(L"gfx", &gfx_desc, IID_PPV_ARGS(&loaded_gfx.p))) && loaded_gfx.p);
195
196 std::uint32_t dummy_stream = 0;
197 D3D12_PIPELINE_STATE_STREAM_DESC stream_desc{sizeof(dummy_stream), &dummy_stream};
198 D3D12_PIPELINE_STATE_STREAM_DESC empty_stream{0, nullptr};
199 EXPECT(lib->LoadPipeline(L"gfx", &empty_stream, IID_PPV_ARGS(&wrong.p)) == E_INVALIDARG && !wrong.p);
200 EXPECT(SUCCEEDED(lib->LoadPipeline(L"gfx", &stream_desc, IID_PPV_ARGS(&loaded_any.p))) && loaded_any.p);
201
202 const SIZE_T blob_size = lib->GetSerializedSize();
203 EXPECT(blob_size >= 16);
204 std::vector<std::uint8_t> blob(blob_size);
205 EXPECT(lib->Serialize(nullptr, blob_size) == E_INVALIDARG);
206 EXPECT(lib->Serialize(blob.data(), blob_size - 1) == E_INVALIDARG);
207 EXPECT(SUCCEEDED(lib->Serialize(blob.data(), blob_size)));
208
209 Ref<ID3D12PipelineLibrary> reloaded;
210 EXPECT(SUCCEEDED(device->CreatePipelineLibrary(blob.data(), blob.size(), IID_PPV_ARGS(&reloaded.p))) && reloaded.p);
211
212 // 4. Execute the loaded compute PSO and loaded graphics PSO on the GPU.
213 Ref<ID3D12CommandQueue> queue;
214 const D3D12_COMMAND_QUEUE_DESC qd{D3D12_COMMAND_LIST_TYPE_DIRECT, 0, D3D12_COMMAND_QUEUE_FLAG_NONE, 0};
215 EXPECT(SUCCEEDED(device->CreateCommandQueue(&qd, IID_PPV_ARGS(&queue.p))));
216 Ref<ID3D12CommandAllocator> alloc;
217 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&alloc.p))));
218 Ref<ID3D12GraphicsCommandList> list;
219 EXPECT(SUCCEEDED(
220 device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, alloc.p, nullptr, IID_PPV_ARGS(&list.p))));
221 Ref<ID3D12Fence> fence;
222 EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p))));
223
224 constexpr UINT W = 16, H = 16;
225 const D3D12_HEAP_PROPERTIES hp_def{D3D12_HEAP_TYPE_DEFAULT};
226 const D3D12_HEAP_PROPERTIES hp_up{D3D12_HEAP_TYPE_UPLOAD};
227 const D3D12_HEAP_PROPERTIES hp_rb{D3D12_HEAP_TYPE_READBACK};
228 const auto rtd = tex2d_desc(W, H, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
229 const Vertex verts[4] = {
230 {-1.0f, 1.0f, 255, 0, 0, 255},
231 { 0.0f, 1.0f, 255, 0, 0, 255},
232 { 0.0f, 0.0f, 255, 0, 0, 255},
233 {-1.0f, 0.0f, 255, 0, 0, 255},
234 };
235 const std::uint16_t indices[6] = {0, 1, 2, 0, 2, 3};
236 const float tint[4] = {1.0f, 0.0f, 1.0f, 1.0f};
237 const auto vbd = buffer_desc(sizeof(verts));
238 const auto ibd = buffer_desc(sizeof(indices));
239 const auto cbd = buffer_desc(256);
240 Ref<ID3D12Resource> rt, vb, ib, cb, rb;
241 EXPECT(SUCCEEDED(device->CreateCommittedResource(&hp_def, D3D12_HEAP_FLAG_NONE, &rtd,
242 D3D12_RESOURCE_STATE_RENDER_TARGET, nullptr, IID_PPV_ARGS(&rt.p))));
243 EXPECT(SUCCEEDED(device->CreateCommittedResource(&hp_up, D3D12_HEAP_FLAG_NONE, &vbd,
244 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&vb.p))));
245 EXPECT(SUCCEEDED(device->CreateCommittedResource(&hp_up, D3D12_HEAP_FLAG_NONE, &ibd,
246 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&ib.p))));
247 EXPECT(SUCCEEDED(device->CreateCommittedResource(&hp_up, D3D12_HEAP_FLAG_NONE, &cbd,
248 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&cb.p))));
249 void* p = nullptr;
250 EXPECT(SUCCEEDED(vb->Map(0, nullptr, &p)));
251 std::memcpy(p, verts, sizeof(verts));
252 vb->Unmap(0, nullptr);
253 EXPECT(SUCCEEDED(ib->Map(0, nullptr, &p)));
254 std::memcpy(p, indices, sizeof(indices));
255 ib->Unmap(0, nullptr);
256 EXPECT(SUCCEEDED(cb->Map(0, nullptr, &p)));
257 std::memcpy(p, tint, sizeof(tint));
258 cb->Unmap(0, nullptr);
259
260 D3D12_PLACED_SUBRESOURCE_FOOTPRINT fp{};
261 UINT64 total_bytes = 0;
262 device->GetCopyableFootprints(&rtd, 0, 1, 0, &fp, nullptr, nullptr, &total_bytes);
263 const auto rbd = buffer_desc(total_bytes);
264 EXPECT(SUCCEEDED(device->CreateCommittedResource(&hp_rb, D3D12_HEAP_FLAG_NONE, &rbd,
265 D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&rb.p))));
266
267 Ref<ID3D12DescriptorHeap> rtv_heap;
268 const D3D12_DESCRIPTOR_HEAP_DESC rhd{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
269 EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&rhd, IID_PPV_ARGS(&rtv_heap.p))));
270 const auto rtv = rtv_heap->GetCPUDescriptorHandleForHeapStart();
271 device->CreateRenderTargetView(rt.p, nullptr, rtv);
272
273 const float blue[4] = {0.0f, 0.0f, 1.0f, 1.0f};
274 list->ClearRenderTargetView(rtv, blue, 0, nullptr);
275 list->OMSetRenderTargets(1, &rtv, FALSE, nullptr);
276 const D3D12_VIEWPORT vp{0, 0, float(W), float(H), 0.0f, 1.0f};
277 const D3D12_RECT sc{0, 0, LONG(W), LONG(H)};
278 list->RSSetViewports(1, &vp);
279 list->RSSetScissorRects(1, &sc);
280 list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
281 const D3D12_VERTEX_BUFFER_VIEW vbv{vb->GetGPUVirtualAddress(), sizeof(verts), sizeof(Vertex)};
282 const D3D12_INDEX_BUFFER_VIEW ibv{ib->GetGPUVirtualAddress(), sizeof(indices), DXGI_FORMAT_R16_UINT};
283 list->IASetVertexBuffers(0, 1, &vbv);
284 list->IASetIndexBuffer(&ibv);
285 list->SetGraphicsRootSignature(gfx_rs.p);
286 const float offset[2] = {0.0f, 0.0f};
287 list->SetGraphicsRoot32BitConstants(0, 2, offset, 0);
288 list->SetGraphicsRootConstantBufferView(1, cb->GetGPUVirtualAddress());
289 list->SetPipelineState(loaded_gfx.p);
290 list->DrawIndexedInstanced(6, 1, 0, 0, 0);
291
292 const auto to_src = transition(rt.p, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
293 list->ResourceBarrier(1, &to_src);
294 D3D12_TEXTURE_COPY_LOCATION src_loc{rt.p, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, {0}};
295 D3D12_TEXTURE_COPY_LOCATION dst_loc{rb.p, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, {}};
296 dst_loc.PlacedFootprint = fp;
297 list->CopyTextureRegion(&dst_loc, 0, 0, 0, &src_loc, nullptr);
298 EXPECT(SUCCEEDED(list->Close()));
299 ID3D12CommandList* lists[] = {list.p};
300 queue->ExecuteCommandLists(1, lists);
301 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
302 EXPECT(SUCCEEDED(queue->Signal(fence.p, 1)) && SUCCEEDED(fence->SetEventOnCompletion(1, nullptr)));
303
304 EXPECT(SUCCEEDED(rb->Map(0, nullptr, &p)));
305 const auto* bytes = static_cast<const std::uint8_t*>(p);
306 std::uint32_t tl = 0, br = 0;
307 std::memcpy(&tl, bytes + 2 * fp.Footprint.RowPitch + 2 * 4, 4);
308 std::memcpy(&br, bytes + 12 * fp.Footprint.RowPitch + 12 * 4, 4);
309 EXPECT(tl == 0xFF0000FFu); // red quad drawn by PSO loaded from PipelineLibrary
310 EXPECT(br == 0xFFFF0000u); // blue background clear
311 rb->Unmap(0, nullptr);
312
313 EXPECT(d.validation_errors() == 0);
314 std::printf("d3d12_pipeline_library_test: ok\n");
315 return 0;
316}
diff --git a/runtime/test/d3d12_present_test.cpp b/runtime/test/d3d12_present_test.cpp
index 8b28eb67a..f01fb902b 100644
--- a/runtime/test/d3d12_present_test.cpp
+++ b/runtime/test/d3d12_present_test.cpp
@@ -115,6 +115,8 @@ int fail_semaphore_in = 0; // armed: the n-th vkCreateSemaphore fr
115bool fail_surface_formats = false; // armed: the next surface-format query fails before creation 115bool fail_surface_formats = false; // armed: the next surface-format query fails before creation
116bool observe_next_swapchain = false; 116bool observe_next_swapchain = false;
117bool report_undefined_extent = false; // armed: surface capabilities reports undefined extent (0xFFFFFFFF) 117bool report_undefined_extent = false; // armed: surface capabilities reports undefined extent (0xFFFFFFFF)
118bool undefined_extent_queried = false;
119VkExtent2D last_swapchain_extent{};
118VkSwapchainKHR last_created_swapchain = VK_NULL_HANDLE; 120VkSwapchainKHR last_created_swapchain = VK_NULL_HANDLE;
119VkSwapchainKHR observed_old_swapchain = VK_NULL_HANDLE; 121VkSwapchainKHR observed_old_swapchain = VK_NULL_HANDLE;
120unsigned out_of_date = 0; // presents the real driver reported out of date 122unsigned out_of_date = 0; // presents the real driver reported out of date
@@ -170,6 +172,7 @@ VKAPI_ATTR VkResult VKAPI_CALL surface_formats(VkPhysicalDevice physical, VkSurf
170 172
171VKAPI_ATTR VkResult VKAPI_CALL create_swapchain(VkDevice device, const VkSwapchainCreateInfoKHR* info, 173VKAPI_ATTR VkResult VKAPI_CALL create_swapchain(VkDevice device, const VkSwapchainCreateInfoKHR* info,
172 const VkAllocationCallbacks* allocator, VkSwapchainKHR* out) { 174 const VkAllocationCallbacks* allocator, VkSwapchainKHR* out) {
175 if (info) last_swapchain_extent = info->imageExtent;
173 if (observe_next_swapchain) { 176 if (observe_next_swapchain) {
174 observed_old_swapchain = info->oldSwapchain; 177 observed_old_swapchain = info->oldSwapchain;
175 observe_next_swapchain = false; 178 observe_next_swapchain = false;
@@ -185,6 +188,7 @@ VKAPI_ATTR VkResult VKAPI_CALL get_surface_capabilities(VkPhysicalDevice physica
185 if (result == VK_SUCCESS && report_undefined_extent && caps) { 188 if (result == VK_SUCCESS && report_undefined_extent && caps) {
186 caps->currentExtent.width = 0xFFFFFFFF; 189 caps->currentExtent.width = 0xFFFFFFFF;
187 caps->currentExtent.height = 0xFFFFFFFF; 190 caps->currentExtent.height = 0xFFFFFFFF;
191 undefined_extent_queried = true;
188 } 192 }
189 return result; 193 return result;
190} 194}
@@ -409,9 +413,14 @@ int main() {
409 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(signalled, nullptr))); 413 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(signalled, nullptr)));
410 414
411 // 4. Undefined surface extent (0xFFFFFFFF, reported by Intel UHD graphics / Win32 WSI; D3D-165): 415 // 4. Undefined surface extent (0xFFFFFFFF, reported by Intel UHD graphics / Win32 WSI; D3D-165):
412 // the presenter queries the window client extent and clamps to surface bounds. 416 // switch vsync to 0 to force swapchain recreation, verifying that vkGetPhysicalDeviceSurfaceCapabilitiesKHR
417 // is reached while armed and that vkCreateSwapchainKHR receives the clamped client extent (400x300)
418 // instead of 0xFFFFFFFF.
413 driver::report_undefined_extent = true; 419 driver::report_undefined_extent = true;
414 EXPECT(frame(1)); 420 driver::undefined_extent_queried = false;
421 EXPECT(frame(0));
422 EXPECT(driver::undefined_extent_queried);
423 EXPECT(driver::last_swapchain_extent.width == 400 && driver::last_swapchain_extent.height == 300);
415 EXPECT(presenter->extent().width == 400 && presenter->extent().height == 300); 424 EXPECT(presenter->extent().width == 400 && presenter->extent().height == 300);
416 driver::report_undefined_extent = false; 425 driver::report_undefined_extent = false;
417 426
diff --git a/runtime/test/d3d12_translated_draw_test.cpp b/runtime/test/d3d12_translated_draw_test.cpp
index 80bd911c1..c6b660dda 100644
--- a/runtime/test/d3d12_translated_draw_test.cpp
+++ b/runtime/test/d3d12_translated_draw_test.cpp
@@ -63,8 +63,8 @@ struct Vertex {
63}; 63};
64 64
65using Pixel = std::array<float, 4>; 65using Pixel = std::array<float, 4>;
66constexpr UINT extent = 64; 66constexpr UINT target_extent = 64;
67constexpr UINT pitch = extent * sizeof(Pixel); // 1024, a multiple of 256 67constexpr UINT pitch = target_extent * sizeof(Pixel); // 1024, a multiple of 256
68 68
69// A V# for the vertex records: stride 32, `records` records, format 32_32_32_32_FLOAT, identity swizzle. The 69// A V# for the vertex records: stride 32, `records` records, format 32_32_32_32_FLOAT, identity swizzle. The
70// out-of-range mode is structured (an index checked against num_records), which is what the hardware does with an 70// out-of-range mode is structured (an index checked against num_records), which is what the hardware does with an
@@ -113,7 +113,7 @@ int main() {
113 vertex(-1, 0, c2), vertex(-1, -1, c2), vertex(0, -1, c2)}; 113 vertex(-1, 0, c2), vertex(-1, -1, c2), vertex(0, -1, c2)};
114 static_assert(sizeof(Vertex) == 32 && sizeof(vertices) == 288); 114 static_assert(sizeof(Vertex) == 32 && sizeof(vertices) == 288);
115 115
116 std::vector<Pixel> pixels(extent * extent); 116 std::vector<Pixel> pixels(target_extent * target_extent);
117 { 117 {
118 rt::d3d12::VulkanDeviceInfo info{}; 118 rt::d3d12::VulkanDeviceInfo info{};
119 info.get_instance_proc = d.instance_proc; 119 info.get_instance_proc = d.instance_proc;
@@ -178,13 +178,13 @@ int main() {
178 EXPECT(SUCCEEDED(device->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE, &upload_desc, 178 EXPECT(SUCCEEDED(device->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE, &upload_desc,
179 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, 179 D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
180 IID_PPV_ARGS(&upload.p)))); 180 IID_PPV_ARGS(&upload.p))));
181 const auto readback_desc = buffer_desc(pitch * extent); 181 const auto readback_desc = buffer_desc(pitch * target_extent);
182 EXPECT(SUCCEEDED(device->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &readback_desc, 182 EXPECT(SUCCEEDED(device->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &readback_desc,
183 D3D12_RESOURCE_STATE_COPY_DEST, nullptr, 183 D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
184 IID_PPV_ARGS(&readback.p)))); 184 IID_PPV_ARGS(&readback.p))));
185 D3D12_RESOURCE_DESC rt_desc{}; 185 D3D12_RESOURCE_DESC rt_desc{};
186 rt_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; 186 rt_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
187 rt_desc.Width = rt_desc.Height = extent; 187 rt_desc.Width = rt_desc.Height = target_extent;
188 rt_desc.DepthOrArraySize = 1; 188 rt_desc.DepthOrArraySize = 1;
189 rt_desc.MipLevels = 1; 189 rt_desc.MipLevels = 1;
190 rt_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; 190 rt_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
@@ -245,8 +245,8 @@ int main() {
245 ID3D12DescriptorHeap* heaps[] = {srv_heap.p}; 245 ID3D12DescriptorHeap* heaps[] = {srv_heap.p};
246 list->SetDescriptorHeaps(1, heaps); 246 list->SetDescriptorHeaps(1, heaps);
247 list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); 247 list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
248 const D3D12_VIEWPORT viewport{0, 0, float(extent), float(extent), 0, 1}; 248 const D3D12_VIEWPORT viewport{0, 0, float(target_extent), float(target_extent), 0, 1};
249 const D3D12_RECT scissor{0, 0, LONG(extent), LONG(extent)}; 249 const D3D12_RECT scissor{0, 0, LONG(target_extent), LONG(target_extent)};
250 list->RSSetViewports(1, &viewport); 250 list->RSSetViewports(1, &viewport);
251 list->RSSetScissorRects(1, &scissor); 251 list->RSSetScissorRects(1, &scissor);
252 list->OMSetRenderTargets(1, &rtv, FALSE, nullptr); 252 list->OMSetRenderTargets(1, &rtv, FALSE, nullptr);
@@ -271,7 +271,7 @@ int main() {
271 D3D12_TEXTURE_COPY_LOCATION dst{}; 271 D3D12_TEXTURE_COPY_LOCATION dst{};
272 dst.pResource = readback.p; 272 dst.pResource = readback.p;
273 dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; 273 dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
274 dst.PlacedFootprint = {0, {DXGI_FORMAT_R32G32B32A32_FLOAT, extent, extent, 1, pitch}}; 274 dst.PlacedFootprint = {0, {DXGI_FORMAT_R32G32B32A32_FLOAT, target_extent, target_extent, 1, pitch}};
275 D3D12_TEXTURE_COPY_LOCATION src{}; 275 D3D12_TEXTURE_COPY_LOCATION src{};
276 src.pResource = target.p; 276 src.pResource = target.p;
277 src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; 277 src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
@@ -302,10 +302,10 @@ int main() {
302 const Pixel top_left = {0.125f, 1.0f, 0.75f, 1.0f}, bottom_right = {0.25f, 1.125f, 0.875f, 1.0f}; 302 const Pixel top_left = {0.125f, 1.0f, 0.75f, 1.0f}, bottom_right = {0.25f, 1.125f, 0.875f, 1.0f};
303 const Pixel bottom_left = {0.75f, 0.25f, 0.75f, 1.0f}; 303 const Pixel bottom_left = {0.75f, 0.25f, 0.75f, 1.0f};
304 unsigned mismatches = 0, edge = 0, edge_triangle = 0, edge_clear = 0; 304 unsigned mismatches = 0, edge = 0, edge_triangle = 0, edge_clear = 0;
305 for (UINT row = 0; row < extent; ++row) { 305 for (UINT row = 0; row < target_extent; ++row) {
306 for (UINT col = 0; col < extent; ++col) { 306 for (UINT col = 0; col < target_extent; ++col) {
307 const bool top = row < extent / 2, left = col < extent / 2; 307 const bool top = row < target_extent / 2, left = col < target_extent / 2;
308 const Pixel& got = pixels[row * extent + col]; 308 const Pixel& got = pixels[row * target_extent + col];
309 const auto bits_equal = [&](const Pixel& want) { return std::memcmp(&got, &want, sizeof(Pixel)) == 0; }; 309 const auto bits_equal = [&](const Pixel& want) { return std::memcmp(&got, &want, sizeof(Pixel)) == 0; };
310 const Pixel* want; 310 const Pixel* want;
311 if (top) { 311 if (top) {
@@ -340,6 +340,6 @@ int main() {
340 "pixels on the triangle's diagonal (%u its colour, %u the clear colour). User data from a descriptor " 340 "pixels on the triangle's diagonal (%u its colour, %u the clear colour). User data from a descriptor "
341 "table and root constants, V# vertex fetch from the arena, PS constants " 341 "table and root constants, V# vertex fetch from the arena, PS constants "
342 "through the code base\n", 342 "through the code base\n",
343 extent * extent - edge, extent * extent, edge, edge_triangle, edge_clear); 343 target_extent * target_extent - edge, target_extent * target_extent, edge, edge_triangle, edge_clear);
344 return 0; 344 return 0;
345} 345}
diff --git a/runtime/test/d3d12_typeless_rtv_test.cpp b/runtime/test/d3d12_typeless_rtv_test.cpp
index cc6054f85..d8b8d841e 100644
--- a/runtime/test/d3d12_typeless_rtv_test.cpp
+++ b/runtime/test/d3d12_typeless_rtv_test.cpp
@@ -213,19 +213,36 @@ bool clear_and_read(ID3D12Device* device, DXGI_FORMAT whole_format, DXGI_FORMAT
213 return true; 213 return true;
214} 214}
215bool rejects_view(ID3D12Device* device, DXGI_FORMAT resource_format, const D3D12_RENDER_TARGET_VIEW_DESC* view, 215bool rejects_view(ID3D12Device* device, DXGI_FORMAT resource_format, const D3D12_RENDER_TARGET_VIEW_DESC* view,
216 UINT16 mips = 1, UINT16 layers = 1) { 216 UINT16 mips = 1, UINT16 layers = 1, UINT samples = 1,
217 const DXGI_FORMAT* cast_list = nullptr, UINT32 cast_count = 0) {
217 Ref<ID3D12Resource> resource; 218 Ref<ID3D12Resource> resource;
218 D3D12_HEAP_PROPERTIES heap_properties{D3D12_HEAP_TYPE_DEFAULT}; 219 D3D12_HEAP_PROPERTIES heap_properties{D3D12_HEAP_TYPE_DEFAULT};
219 D3D12_RESOURCE_DESC texture{}; 220 if (cast_count) {
220 texture.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; 221 Ref<ID3D12Device10> device10;
221 texture.Width = texture.Height = 4; 222 CHECK(SUCCEEDED(device->QueryInterface(IID_PPV_ARGS(&device10.p))));
222 texture.DepthOrArraySize = layers; 223 D3D12_RESOURCE_DESC1 tex1{};
223 texture.MipLevels = mips; 224 tex1.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
224 texture.Format = resource_format; 225 tex1.Width = tex1.Height = 4;
225 texture.SampleDesc.Count = 1; 226 tex1.DepthOrArraySize = layers;
226 texture.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; 227 tex1.MipLevels = mips;
227 CHECK(SUCCEEDED(device->CreateCommittedResource(&heap_properties, D3D12_HEAP_FLAG_NONE, &texture, 228 tex1.Format = resource_format;
228 D3D12_RESOURCE_STATE_RENDER_TARGET, nullptr, IID_PPV_ARGS(&resource.p)))); 229 tex1.SampleDesc.Count = samples;
230 tex1.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
231 CHECK(SUCCEEDED(device10->CreateCommittedResource3(&heap_properties, D3D12_HEAP_FLAG_NONE, &tex1,
232 D3D12_BARRIER_LAYOUT_RENDER_TARGET, nullptr, nullptr, cast_count, cast_list,
233 IID_PPV_ARGS(&resource.p))));
234 } else {
235 D3D12_RESOURCE_DESC texture{};
236 texture.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
237 texture.Width = texture.Height = 4;
238 texture.DepthOrArraySize = layers;
239 texture.MipLevels = mips;
240 texture.Format = resource_format;
241 texture.SampleDesc.Count = samples;
242 texture.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
243 CHECK(SUCCEEDED(device->CreateCommittedResource(&heap_properties, D3D12_HEAP_FLAG_NONE, &texture,
244 D3D12_RESOURCE_STATE_RENDER_TARGET, nullptr, IID_PPV_ARGS(&resource.p))));
245 }
229 Ref<ID3D12DescriptorHeap> heap; 246 Ref<ID3D12DescriptorHeap> heap;
230 const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0}; 247 const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
231 CHECK(SUCCEEDED(device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&heap.p)))); 248 CHECK(SUCCEEDED(device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&heap.p))));
@@ -237,7 +254,7 @@ bool rejects_view(ID3D12Device* device, DXGI_FORMAT resource_format, const D3D12
237 const auto handle = heap->GetCPUDescriptorHandleForHeapStart(); 254 const auto handle = heap->GetCPUDescriptorHandleForHeapStart();
238 // For the supported shape, overwrite a valid slot too: rejection must not leave its old RTV active. 255 // For the supported shape, overwrite a valid slot too: rejection must not leave its old RTV active.
239 D3D12_RENDER_TARGET_VIEW_DESC seed{}; 256 D3D12_RENDER_TARGET_VIEW_DESC seed{};
240 seed.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; 257 seed.ViewDimension = samples > 1 ? D3D12_RTV_DIMENSION_TEXTURE2DMS : D3D12_RTV_DIMENSION_TEXTURE2D;
241 seed.Format = resource_format == DXGI_FORMAT_R8G8B8A8_TYPELESS ? DXGI_FORMAT_R8G8B8A8_UNORM : resource_format; 258 seed.Format = resource_format == DXGI_FORMAT_R8G8B8A8_TYPELESS ? DXGI_FORMAT_R8G8B8A8_UNORM : resource_format;
242 device->CreateRenderTargetView(resource.p, &seed, handle); 259 device->CreateRenderTargetView(resource.p, &seed, handle);
243 device->CreateRenderTargetView(resource.p, view, handle); 260 device->CreateRenderTargetView(resource.p, view, handle);
@@ -246,6 +263,150 @@ bool rejects_view(ID3D12Device* device, DXGI_FORMAT resource_format, const D3D12
246 CHECK(list->Close() == E_INVALIDARG); // The invalid list is never sent to the GPU. 263 CHECK(list->Close() == E_INVALIDARG); // The invalid list is never sent to the GPU.
247 return true; 264 return true;
248} 265}
266
267bool clear_and_read_msaa(ID3D12Device* device, DXGI_FORMAT resource_format,
268 const DXGI_FORMAT* cast_list, UINT32 cast_count,
269 DXGI_FORMAT whole_format, DXGI_FORMAT rect_format, bool partial,
270 bool array, UINT first_layer, UINT layer_count,
271 std::vector<unsigned char>& pixels) {
272 Ref<ID3D12CommandQueue> queue;
273 Ref<ID3D12CommandAllocator> allocator;
274 Ref<ID3D12GraphicsCommandList> list;
275 Ref<ID3D12Fence> fence;
276 D3D12_COMMAND_QUEUE_DESC queue_desc{};
277 CHECK(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p))));
278 CHECK(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p))));
279 CHECK(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr,
280 IID_PPV_ARGS(&list.p))));
281 CHECK(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p))));
282
283 constexpr UINT width = 5, height = 3;
284 const UINT16 layers = array ? 4 : 1;
285 Ref<ID3D12Resource> msaa, resolved, readback;
286 D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT};
287 if (cast_count) {
288 Ref<ID3D12Device10> device10;
289 CHECK(SUCCEEDED(device->QueryInterface(IID_PPV_ARGS(&device10.p))));
290 D3D12_RESOURCE_DESC1 tex1{};
291 tex1.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
292 tex1.Width = width;
293 tex1.Height = height;
294 tex1.DepthOrArraySize = layers;
295 tex1.MipLevels = 1;
296 tex1.Format = resource_format;
297 tex1.SampleDesc.Count = 4;
298 tex1.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
299 CHECK(SUCCEEDED(device10->CreateCommittedResource3(&default_heap, D3D12_HEAP_FLAG_NONE, &tex1,
300 D3D12_BARRIER_LAYOUT_RENDER_TARGET, nullptr, nullptr, cast_count, cast_list,
301 IID_PPV_ARGS(&msaa.p))));
302 } else {
303 D3D12_RESOURCE_DESC tex{};
304 tex.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
305 tex.Width = width;
306 tex.Height = height;
307 tex.DepthOrArraySize = layers;
308 tex.MipLevels = 1;
309 tex.Format = resource_format;
310 tex.SampleDesc.Count = 4;
311 tex.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
312 CHECK(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &tex,
313 D3D12_RESOURCE_STATE_RENDER_TARGET, nullptr, IID_PPV_ARGS(&msaa.p))));
314 }
315 D3D12_RESOURCE_DESC resolved_desc{};
316 resolved_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
317 resolved_desc.Width = width;
318 resolved_desc.Height = height;
319 resolved_desc.DepthOrArraySize = layers;
320 resolved_desc.MipLevels = 1;
321 resolved_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
322 resolved_desc.SampleDesc.Count = 1;
323 CHECK(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &resolved_desc,
324 D3D12_RESOURCE_STATE_RESOLVE_DEST, nullptr, IID_PPV_ARGS(&resolved.p))));
325
326 std::vector<D3D12_PLACED_SUBRESOURCE_FOOTPRINT> placed(layers);
327 UINT64 total = 0;
328 device->GetCopyableFootprints(&resolved_desc, 0, layers, 0, placed.data(), nullptr, nullptr, &total);
329 D3D12_RESOURCE_DESC buf{};
330 buf.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
331 buf.Width = total;
332 buf.Height = buf.SampleDesc.Count = 1;
333 buf.DepthOrArraySize = buf.MipLevels = 1;
334 buf.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
335 D3D12_HEAP_PROPERTIES rb_heap{D3D12_HEAP_TYPE_READBACK};
336 CHECK(SUCCEEDED(device->CreateCommittedResource(&rb_heap, D3D12_HEAP_FLAG_NONE, &buf,
337 D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&readback.p))));
338
339 Ref<ID3D12DescriptorHeap> rtv_heap;
340 const D3D12_DESCRIPTOR_HEAP_DESC rtv_desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 2, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
341 CHECK(SUCCEEDED(device->CreateDescriptorHeap(&rtv_desc, IID_PPV_ARGS(&rtv_heap.p))));
342 const auto h0 = rtv_heap->GetCPUDescriptorHandleForHeapStart();
343 const D3D12_CPU_DESCRIPTOR_HANDLE h1{h0.ptr + device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV)};
344
345 D3D12_RENDER_TARGET_VIEW_DESC view{};
346 view.ViewDimension = array ? D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY : D3D12_RTV_DIMENSION_TEXTURE2DMS;
347 if (array) {
348 view.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
349 for (UINT layer = 0; layer < layers; ++layer) {
350 view.Texture2DMSArray = {layer, 1};
351 device->CreateRenderTargetView(msaa.p, &view, h0);
352 const FLOAT seed[] = {FLOAT(layer + 1) * 0.1f, 0.2f, 0.3f, 1.0f};
353 list->ClearRenderTargetView(h0, seed, 0, nullptr);
354 }
355 view.Texture2DMSArray = {first_layer, layer_count};
356 }
357 view.Format = whole_format;
358 device->CreateRenderTargetView(msaa.p, &view, h0);
359 view.Format = rect_format;
360 device->CreateRenderTargetView(msaa.p, &view, h1);
361 const FLOAT full[4] = {0.25f, 0.5f, 0.75f, 0.25f};
362 const FLOAT part[4] = {0.0031308f, 0.18f, 0.5f, 0.75f};
363 list->ClearRenderTargetView(h0, full, 0, nullptr);
364 const D3D12_RECT rect{1, 1, 4, 3};
365 if (partial) list->ClearRenderTargetView(h1, part, 1, &rect);
366
367 D3D12_RESOURCE_BARRIER b{};
368 b.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
369 b.Transition = {msaa.p, D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
370 D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_RESOLVE_SOURCE};
371 list->ResourceBarrier(1, &b);
372 for (UINT layer = 0; layer < layers; ++layer)
373 list->ResolveSubresource(resolved.p, layer, msaa.p, layer, DXGI_FORMAT_R8G8B8A8_UNORM);
374 b.Transition = {resolved.p, D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
375 D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE};
376 list->ResourceBarrier(1, &b);
377 D3D12_TEXTURE_COPY_LOCATION src{}, dst{};
378 src.pResource = resolved.p;
379 src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
380 dst.pResource = readback.p;
381 dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
382 for (UINT layer = 0; layer < layers; ++layer) {
383 src.SubresourceIndex = layer;
384 dst.PlacedFootprint = placed[layer];
385 list->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr);
386 }
387 CHECK(SUCCEEDED(list->Close()));
388 ID3D12CommandList* lists[] = {list.p};
389 queue->ExecuteCommandLists(1, lists);
390 CHECK(SUCCEEDED(queue->Signal(fence.p, 1)));
391 Event event;
392 CHECK(event.handle);
393 CHECK(SUCCEEDED(fence->SetEventOnCompletion(1, event.handle)));
394 CHECK(WaitForSingleObject(event.handle, 5000) == WAIT_OBJECT_0);
395 void* mapped = nullptr;
396 const D3D12_RANGE range{0, SIZE_T(total)};
397 CHECK(SUCCEEDED(readback->Map(0, &range, &mapped)) && mapped);
398 pixels.clear();
399 for (const auto& footprint : placed) {
400 const auto& f = footprint.Footprint;
401 for (UINT y = 0; y < f.Height; ++y) {
402 const auto* row = static_cast<unsigned char*>(mapped) + footprint.Offset + y * f.RowPitch;
403 pixels.insert(pixels.end(), row, row + f.Width * 4);
404 }
405 }
406 const D3D12_RANGE none{};
407 readback->Unmap(0, &none);
408 return true;
409}
249} // namespace 410} // namespace
250 411
251int main() { 412int main() {
@@ -452,8 +613,10 @@ int main() {
452 regressions, vk.conditional_rendering ? "enabled" : "unavailable (predicated cases skipped)"); 613 regressions, vk.conditional_rendering ? "enabled" : "unavailable (predicated cases skipped)");
453 if (mismatches) return 1; 614 if (mismatches) return 1;
454 const auto rejects = [&](DXGI_FORMAT resource_format, const D3D12_RENDER_TARGET_VIEW_DESC* view, 615 const auto rejects = [&](DXGI_FORMAT resource_format, const D3D12_RENDER_TARGET_VIEW_DESC* view,
455 UINT16 mips = 1, UINT16 layers = 1) { 616 UINT16 mips = 1, UINT16 layers = 1, UINT samples = 1,
456 if (!rejects_view(ours.p, resource_format, view, mips, layers)) return false; 617 const DXGI_FORMAT* cast_list = nullptr, UINT32 cast_count = 0) {
618 if (!rejects_view(ours.p, resource_format, view, mips, layers, samples, cast_list, cast_count))
619 return false;
457 ++rejected; 620 ++rejected;
458 return true; 621 return true;
459 }; 622 };
@@ -501,6 +664,64 @@ int main() {
501 invalid.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; 664 invalid.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
502 invalid.Texture2DArray = {1, 1, 2, 1}; 665 invalid.Texture2DArray = {1, 1, 2, 1};
503 if (!rejects(DXGI_FORMAT_R8G8B8A8_TYPELESS, &invalid, 3, 4)) return 1; 666 if (!rejects(DXGI_FORMAT_R8G8B8A8_TYPELESS, &invalid, 3, 4)) return 1;
667
668 // 4x MSAA typeless and castable RGBA8 RTVs (TEXTURE2DMS / TEXTURE2DMSARRAY) compared against WARP.
669 {
670 const DXGI_FORMAT srgb_list[] = {DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB};
671 const auto compare_msaa = [&](DXGI_FORMAT resource_format, const DXGI_FORMAT* cast_list,
672 UINT32 cast_count, DXGI_FORMAT full, DXGI_FORMAT rect, bool partial,
673 bool array, UINT first_layer, UINT layer_count) {
674 std::vector<unsigned char> actual, expected;
675 if (!clear_and_read_msaa(ours.p, resource_format, cast_list, cast_count, full, rect, partial, array,
676 first_layer, layer_count, actual) ||
677 !clear_and_read_msaa(host.p, resource_format, cast_list, cast_count, full, rect, partial, array,
678 first_layer, layer_count, expected))
679 return false;
680 ++comparisons;
681 if (actual.size() != expected.size()) return false;
682 for (std::size_t i = 0; i < actual.size(); ++i) {
683 if (std::abs(int(actual[i]) - int(expected[i])) > 1) {
684 std::fprintf(stderr, "MSAA RTV mismatch fmt %d full %d rect %d array %d byte %zu: ours %u WARP %u\n",
685 int(resource_format), int(full), int(rect), int(array), i, unsigned(actual[i]),
686 unsigned(expected[i]));
687 ++mismatches;
688 return false;
689 }
690 }
691 return true;
692 };
693 if (!compare_msaa(DXGI_FORMAT_R8G8B8A8_TYPELESS, nullptr, 0, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
694 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, false, false, 0, 1))
695 return 1;
696 if (!compare_msaa(DXGI_FORMAT_R8G8B8A8_TYPELESS, nullptr, 0, DXGI_FORMAT_R8G8B8A8_UNORM,
697 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, true, false, 0, 1))
698 return 1;
699 if (!compare_msaa(DXGI_FORMAT_R8G8B8A8_TYPELESS, nullptr, 0, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
700 DXGI_FORMAT_R8G8B8A8_UNORM, true, true, 1, 2))
701 return 1;
702 Ref<ID3D12Device10> host10;
703 if (SUCCEEDED(host->QueryInterface(IID_PPV_ARGS(&host10.p)))) {
704 if (!compare_msaa(DXGI_FORMAT_R8G8B8A8_UNORM, srgb_list, 2, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
705 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, false, false, 0, 1))
706 return 1;
707 if (!compare_msaa(DXGI_FORMAT_R8G8B8A8_UNORM, srgb_list, 2, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
708 DXGI_FORMAT_R8G8B8A8_UNORM, true, true, 1, 2))
709 return 1;
710 }
711 // MSAA vs 1x view-dimension mismatches, out-of-range MSAA array slices, and unlisted castable formats.
712 D3D12_RENDER_TARGET_VIEW_DESC bad_msaa{};
713 bad_msaa.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
714 bad_msaa.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
715 if (!rejects(DXGI_FORMAT_R8G8B8A8_TYPELESS, &bad_msaa, 1, 1, 4)) return 1;
716 bad_msaa.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS;
717 if (!rejects(DXGI_FORMAT_R8G8B8A8_TYPELESS, &bad_msaa, 1, 1, 1)) return 1;
718 bad_msaa.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY;
719 bad_msaa.Texture2DMSArray = {3, 2};
720 if (!rejects(DXGI_FORMAT_R8G8B8A8_TYPELESS, &bad_msaa, 1, 4, 4)) return 1;
721 bad_msaa.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS;
722 bad_msaa.Format = DXGI_FORMAT_R8G8B8A8_UINT;
723 if (!rejects(DXGI_FORMAT_R8G8B8A8_UNORM, &bad_msaa, 1, 1, 4, srgb_list, 2)) return 1;
724 }
504 } 725 }
505 if (vk.validation_errors()) return 1; 726 if (vk.validation_errors()) return 1;
506 std::printf("typeless RTV: %u WARP readbacks matched, descriptor snapshots and format-cache order checked; %u unsupported/invalid views rejected\n", 727 std::printf("typeless RTV: %u WARP readbacks matched, descriptor snapshots and format-cache order checked; %u unsupported/invalid views rejected\n",
diff --git a/runtime/test/d3d12_vulkan_device_test.cpp b/runtime/test/d3d12_vulkan_device_test.cpp
index 556ab1566..9d49740e0 100644
--- a/runtime/test/d3d12_vulkan_device_test.cpp
+++ b/runtime/test/d3d12_vulkan_device_test.cpp
@@ -324,8 +324,8 @@ int cpu_copies(ID3D12Device* device, bool bc, const char* path) {
324 return 0; 324 return 0;
325} 325}
326 326
327// The host PC runtime's D3D12 device to compare answers with: the default adapter, or the one LEONIDA_HOST_ADAPTER 327// The host PC runtime's D3D12 device to compare answers with: the layer's own adapter (set in main), else the default
328// names ("warp", or part of an adapter's name); false if there is none. 328// one, or the one LEONIDA_HOST_ADAPTER names ("warp", or part of an adapter's name); false if there is none.
329// Under Wine there is none (copycmp::create_host). 329// Under Wine there is none (copycmp::create_host).
330bool create_host_device(Ref<ID3D12Device>& host, std::string* adapter_name = nullptr) { 330bool create_host_device(Ref<ID3D12Device>& host, std::string* adapter_name = nullptr) {
331 copycmp::Ptr<ID3D12Device> device; 331 copycmp::Ptr<ID3D12Device> device;
@@ -785,6 +785,9 @@ int compare_allocation_info(ID3D12Device* ours) {
785 d.Layout = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; 785 d.Layout = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE;
786 return d; 786 return d;
787 }(), 0}, 787 }(), 0},
788 {"UNKNOWN 4x MSAA NONE (invalid)", with(texture_desc(256, 256, rgba8, none, 1), 0, 4), 0},
789 {"UNKNOWN 4x MSAA RT+DS (invalid)",
790 with(texture_desc(256, 256, rgba8, rt | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, 1), 0, 4), 0},
788 }; 791 };
789 int mismatches = 0; 792 int mismatches = 0;
790 const auto mismatch = [&](const char* name, const D3D12_RESOURCE_ALLOCATION_INFO& a, 793 const auto mismatch = [&](const char* name, const D3D12_RESOURCE_ALLOCATION_INFO& a,
@@ -797,6 +800,18 @@ int compare_allocation_info(ID3D12Device* ours) {
797 for (const Case& c : cases) { 800 for (const Case& c : cases) {
798 const D3D12_RESOURCE_ALLOCATION_INFO a = ours->GetResourceAllocationInfo(0, 1, &c.desc); 801 const D3D12_RESOURCE_ALLOCATION_INFO a = ours->GetResourceAllocationInfo(0, 1, &c.desc);
799 const D3D12_RESOURCE_ALLOCATION_INFO b = host->GetResourceAllocationInfo(0, 1, &c.desc); 802 const D3D12_RESOURCE_ALLOCATION_INFO b = host->GetResourceAllocationInfo(0, 1, &c.desc);
803 if (c.top_mip_bytes && b.SizeInBytes == UINT64_MAX && c.desc.SampleDesc.Count > 1 &&
804 c.desc.Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE) {
805 D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS ms{
806 c.desc.Format, c.desc.SampleDesc.Count, D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_TILED_RESOURCE, 0};
807 if (SUCCEEDED(host->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &ms, sizeof(ms))) &&
808 ms.NumQualityLevels == 0) {
809 if (a.SizeInBytes == UINT64_MAX || a.Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
810 mismatch(c.name, a, b);
811 std::printf("allocation info %s: host unsupported (NumQualityLevels=0), skipped\n", c.name);
812 continue;
813 }
814 }
800 if (b.SizeInBytes == UINT64_MAX || !c.top_mip_bytes) { 815 if (b.SizeInBytes == UINT64_MAX || !c.top_mip_bytes) {
801 if (a.SizeInBytes != b.SizeInBytes || (b.SizeInBytes != UINT64_MAX && a.Alignment != b.Alignment)) 816 if (a.SizeInBytes != b.SizeInBytes || (b.SizeInBytes != UINT64_MAX && a.Alignment != b.Alignment))
802 mismatch(c.name, a, b); 817 mismatch(c.name, a, b);
@@ -1597,6 +1612,15 @@ int compare_feature_support(ID3D12Device* ours) {
1597 1612
1598// Same-adapter host D3D12 device matched by VkPhysicalDeviceIDProperties (LUID first, then PCI IDs), falling back 1613// Same-adapter host D3D12 device matched by VkPhysicalDeviceIDProperties (LUID first, then PCI IDs), falling back
1599// to the default adapter. False if the host has no D3D12 device. 1614// to the default adapter. False if the host has no D3D12 device.
1615// D3D11.3 spec 3.2.3.8's ideal FLOAT -> SRGB encoding of c in [0, 1], before scaling to the format's maximum.
1616double ideal_srgb(double c) { return c <= 0.0031308 ? c * 12.92 : 1.055 * std::pow(c, 1.0 / 2.4) - 0.055; }
1617
1618// Both bytes within 0.6 ULP (on the integer side) of the ideal value: the tolerance spec 3.2.3.6 (FLOAT -> UNORM)
1619// and 3.2.3.8 (FLOAT -> SRGB) permit, so two drivers may give the codes either side of a near-tie.
1620bool within_06_ulp(std::uint8_t a, std::uint8_t b, double ideal) {
1621 return std::abs(double(a) - ideal) <= 0.6 && std::abs(double(b) - ideal) <= 0.6;
1622}
1623
1600bool create_host_device_for_physical(VkInstance instance, VkPhysicalDevice physical, 1624bool create_host_device_for_physical(VkInstance instance, VkPhysicalDevice physical,
1601 PFN_vkGetInstanceProcAddr instance_proc, Ref<ID3D12Device>& host, 1625 PFN_vkGetInstanceProcAddr instance_proc, Ref<ID3D12Device>& host,
1602 std::string& adapter_name) { 1626 std::string& adapter_name) {
@@ -2205,6 +2229,32 @@ HRESULT fence(ID3D12Device* device, D3D12_FENCE_FLAGS flags, REFIID riid = __uui
2205 return released(device->CreateFence(0, flags, riid, &out), &out); 2229 return released(device->CreateFence(0, flags, riid, &out), &out);
2206} 2230}
2207 2231
2232// A 64 KiB heap description for the CreateHeap/CreateHeap1 cases (D3D-238).
2233D3D12_HEAP_DESC heap_desc_of(UINT64 alignment, D3D12_HEAP_PROPERTIES properties = {D3D12_HEAP_TYPE_DEFAULT},
2234 D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE, UINT64 size = 64 * 1024) {
2235 D3D12_HEAP_DESC desc{};
2236 desc.SizeInBytes = size;
2237 desc.Properties = properties;
2238 desc.Alignment = alignment;
2239 desc.Flags = flags;
2240 return desc;
2241}
2242
2243HRESULT heap_create(ID3D12Device* device, D3D12_HEAP_DESC desc) {
2244 void* out = nullptr;
2245 return released(device->CreateHeap(&desc, __uuidof(ID3D12Heap), &out), &out);
2246}
2247
2248// CreateHeap1 without a protected session; E_NOINTERFACE when the device has no ID3D12Device4.
2249HRESULT heap_create1(ID3D12Device* device, D3D12_HEAP_DESC desc) {
2250 ID3D12Device4* device4 = nullptr;
2251 if (FAILED(device->QueryInterface(IID_PPV_ARGS(&device4)))) return E_NOINTERFACE;
2252 void* out = nullptr;
2253 const HRESULT hr = device4->CreateHeap1(&desc, nullptr, __uuidof(ID3D12Heap), &out);
2254 device4->Release();
2255 return released(hr, &out);
2256}
2257
2208// Map on a fresh committed resource; `range` is the read range, or null. 2258// Map on a fresh committed resource; `range` is the read range, or null.
2209HRESULT map(ID3D12Device* device, D3D12_HEAP_PROPERTIES heap, D3D12_RESOURCE_DESC desc, D3D12_RESOURCE_STATES state, 2259HRESULT map(ID3D12Device* device, D3D12_HEAP_PROPERTIES heap, D3D12_RESOURCE_DESC desc, D3D12_RESOURCE_STATES state,
2210 UINT subresource, const D3D12_RANGE* range, bool want_pointer = true) { 2260 UINT subresource, const D3D12_RANGE* range, bool want_pointer = true) {
@@ -2238,6 +2288,21 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2238 struct Case { 2288 struct Case {
2239 const char* name; 2289 const char* name;
2240 InvalidCase call; 2290 InvalidCase call;
2291 bool (*comparable)(ID3D12Device*) = nullptr;
2292 };
2293 const auto device10 = [](ID3D12Device* d) {
2294 Ref<ID3D12Device10> newer;
2295 return SUCCEEDED(d->QueryInterface(IID_PPV_ARGS(&newer.p)));
2296 };
2297 const auto not_elevated = [](ID3D12Device*) {
2298 HANDLE token = nullptr;
2299 TOKEN_ELEVATION elevation{};
2300 DWORD size = 0;
2301 const bool elevated = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) &&
2302 GetTokenInformation(token, TokenElevation, &elevation, sizeof(elevation), &size) &&
2303 elevation.TokenIsElevated;
2304 if (token) CloseHandle(token);
2305 return !elevated;
2241 }; 2306 };
2242 static const Case cases[] = { 2307 static const Case cases[] = {
2243 // CreateCommittedResource: arguments. 2308 // CreateCommittedResource: arguments.
@@ -2315,7 +2380,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2315 }}, 2380 }},
2316 {"committed: upload buffer in COMMON", [](ID3D12Device* d) { 2381 {"committed: upload buffer in COMMON", [](ID3D12Device* d) {
2317 return committed(d, {D3D12_HEAP_TYPE_UPLOAD}, buffer_desc(256), D3D12_RESOURCE_STATE_COMMON); 2382 return committed(d, {D3D12_HEAP_TYPE_UPLOAD}, buffer_desc(256), D3D12_RESOURCE_STATE_COMMON);
2318 }}, 2383 }, +device10},
2319 {"committed: upload buffer in COPY_DEST", [](ID3D12Device* d) { 2384 {"committed: upload buffer in COPY_DEST", [](ID3D12Device* d) {
2320 return committed(d, {D3D12_HEAP_TYPE_UPLOAD}, buffer_desc(256), D3D12_RESOURCE_STATE_COPY_DEST); 2385 return committed(d, {D3D12_HEAP_TYPE_UPLOAD}, buffer_desc(256), D3D12_RESOURCE_STATE_COPY_DEST);
2321 }}, 2386 }},
@@ -2441,7 +2506,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2441 {"committed: BC1 6x6 top mip", [](ID3D12Device* d) { 2506 {"committed: BC1 6x6 top mip", [](ID3D12Device* d) {
2442 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, 2507 return committed(d, {D3D12_HEAP_TYPE_DEFAULT},
2443 texture_desc(6, 6, DXGI_FORMAT_BC1_UNORM, D3D12_RESOURCE_FLAG_NONE)); 2508 texture_desc(6, 6, DXGI_FORMAT_BC1_UNORM, D3D12_RESOURCE_FLAG_NONE));
2444 }}, 2509 }, host_supports_unaligned_block_textures},
2445 {"committed: render target and depth stencil", [](ID3D12Device* d) { 2510 {"committed: render target and depth stencil", [](ID3D12Device* d) {
2446 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, 2511 return committed(d, {D3D12_HEAP_TYPE_DEFAULT},
2447 texture_desc(16, 16, DXGI_FORMAT_D32_FLOAT, 2512 texture_desc(16, 16, DXGI_FORMAT_D32_FLOAT,
@@ -2513,7 +2578,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2513 }}, 2578 }},
2514 {"committed: readback buffer in COMMON", [](ID3D12Device* d) { 2579 {"committed: readback buffer in COMMON", [](ID3D12Device* d) {
2515 return committed(d, {D3D12_HEAP_TYPE_READBACK}, buffer_desc(256), D3D12_RESOURCE_STATE_COMMON); 2580 return committed(d, {D3D12_HEAP_TYPE_READBACK}, buffer_desc(256), D3D12_RESOURCE_STATE_COMMON);
2516 }}, 2581 }, +device10},
2517 {"committed: readback buffer with UAV", [](ID3D12Device* d) { 2582 {"committed: readback buffer with UAV", [](ID3D12Device* d) {
2518 auto desc = buffer_desc(256); 2583 auto desc = buffer_desc(256);
2519 desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; 2584 desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
@@ -2673,7 +2738,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2673 }}, 2738 }},
2674 {"committed: heap flag HARDWARE_PROTECTED on a texture", [](ID3D12Device* d) { 2739 {"committed: heap flag HARDWARE_PROTECTED on a texture", [](ID3D12Device* d) {
2675 return with_heap_flags(d, rgba8(), D3D12_HEAP_FLAG_HARDWARE_PROTECTED); 2740 return with_heap_flags(d, rgba8(), D3D12_HEAP_FLAG_HARDWARE_PROTECTED);
2676 }}, 2741 }, +device10},
2677 {"committed: heap flag ALLOW_WRITE_WATCH on a buffer", [](ID3D12Device* d) { 2742 {"committed: heap flag ALLOW_WRITE_WATCH on a buffer", [](ID3D12Device* d) {
2678 return with_heap_flags(d, buffer_desc(256), D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH); 2743 return with_heap_flags(d, buffer_desc(256), D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH);
2679 }}, 2744 }},
@@ -2728,7 +2793,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2728 auto desc = buffer_desc(256); 2793 auto desc = buffer_desc(256);
2729 desc.Flags = D3D12_RESOURCE_FLAGS(D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE); 2794 desc.Flags = D3D12_RESOURCE_FLAGS(D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE);
2730 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc); 2795 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc);
2731 }}, 2796 }, +device10},
2732 {"committed: resource flag 0x200 on a buffer", [](ID3D12Device* d) { 2797 {"committed: resource flag 0x200 on a buffer", [](ID3D12Device* d) {
2733 auto desc = buffer_desc(256); 2798 auto desc = buffer_desc(256);
2734 desc.Flags = D3D12_RESOURCE_FLAGS(0x200); 2799 desc.Flags = D3D12_RESOURCE_FLAGS(0x200);
@@ -2756,15 +2821,15 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2756 {"committed: resource flag RAYTRACING_ACCELERATION_STRUCTURE on a texture", [](ID3D12Device* d) { 2821 {"committed: resource flag RAYTRACING_ACCELERATION_STRUCTURE on a texture", [](ID3D12Device* d) {
2757 auto desc = rgba8(D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE); 2822 auto desc = rgba8(D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE);
2758 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc); 2823 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc);
2759 }}, 2824 }, +device10},
2760 {"committed: resource flag 0x400 on a buffer", [](ID3D12Device* d) { 2825 {"committed: resource flag 0x400 on a buffer", [](ID3D12Device* d) {
2761 auto desc = buffer_desc(256); 2826 auto desc = buffer_desc(256);
2762 desc.Flags = D3D12_RESOURCE_FLAGS(0x400); 2827 desc.Flags = D3D12_RESOURCE_FLAGS(0x400);
2763 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc); 2828 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, desc);
2764 }}, 2829 }, +device10},
2765 {"committed: resource flag 0x400 on a texture", [](ID3D12Device* d) { 2830 {"committed: resource flag 0x400 on a texture", [](ID3D12Device* d) {
2766 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, rgba8(D3D12_RESOURCE_FLAGS(0x400))); 2831 return committed(d, {D3D12_HEAP_TYPE_DEFAULT}, rgba8(D3D12_RESOURCE_FLAGS(0x400)));
2767 }}, 2832 }, +device10},
2768 // A null output is a capability check; with invalid arguments too, the host's answer says which comes first. 2833 // A null output is a capability check; with invalid arguments too, the host's answer says which comes first.
2769 {"committed: heap type 99, null output", [](ID3D12Device* d) { 2834 {"committed: heap type 99, null output", [](ID3D12Device* d) {
2770 const H heap{D3D12_HEAP_TYPE(99)}; 2835 const H heap{D3D12_HEAP_TYPE(99)};
@@ -2779,6 +2844,42 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2779 return d->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COMMON, 2844 return d->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COMMON,
2780 nullptr, __uuidof(ID3D12Resource), nullptr); 2845 nullptr, __uuidof(ID3D12Resource), nullptr);
2781 }}, 2846 }},
2847 // CreateHeap and CreateHeap1 (D3D-238): the four descriptions the host refused on an RX 5700 and WARP, the
2848 // heap-property rules CreateCommittedResource shares. A refusal needs no arena; the valid neighbours do, so
2849 // compare_heap_neighbours compares them on the standalone device.
2850 {"heap: alignment 4096", [](ID3D12Device* d) { return heap_create(d, heap_desc_of(4096)); }},
2851 {"heap1: alignment 4096", [](ID3D12Device* d) { return heap_create1(d, heap_desc_of(4096)); }},
2852 {"heap: custom heap, unknown page property", [](ID3D12Device* d) {
2853 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
2854 D3D12_MEMORY_POOL_L0}));
2855 }},
2856 {"heap1: custom heap, unknown page property", [](ID3D12Device* d) {
2857 return heap_create1(d, heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
2858 D3D12_MEMORY_POOL_L0}));
2859 }},
2860 {"heap: all three DENY flags", [](ID3D12Device* d) {
2861 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT},
2862 D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES |
2863 D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES));
2864 }},
2865 {"heap1: all three DENY flags", [](ID3D12Device* d) {
2866 return heap_create1(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT},
2867 D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES |
2868 D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES));
2869 }},
2870 {"heap: type 0", [](ID3D12Device* d) { return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE(0)})); }},
2871 {"heap1: type 0", [](ID3D12Device* d) { return heap_create1(d, heap_desc_of(0, {D3D12_HEAP_TYPE(0)})); }},
2872 {"heap: custom heap, unknown pool", [](ID3D12Device* d) {
2873 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE,
2874 D3D12_MEMORY_POOL_UNKNOWN}));
2875 }},
2876 {"heap: default heap with a CPU page property", [](ID3D12Device* d) {
2877 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_WRITE_BACK}));
2878 }},
2879 {"heap: default heap with a memory pool", [](ID3D12Device* d) {
2880 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
2881 D3D12_MEMORY_POOL_L0}));
2882 }},
2782 // CreateDescriptorHeap. A null description faults in the host runtime, so it is not compared. 2883 // CreateDescriptorHeap. A null description faults in the host runtime, so it is not compared.
2783 {"descriptor heap: null output", [](ID3D12Device* d) { 2884 {"descriptor heap: null output", [](ID3D12Device* d) {
2784 const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 4}; 2885 const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 4};
@@ -2817,7 +2918,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2817 {"descriptor heap: shader-visible 2049 samplers", [](ID3D12Device* d) { 2918 {"descriptor heap: shader-visible 2049 samplers", [](ID3D12Device* d) {
2818 return descriptor_heap(d, {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2049, 2919 return descriptor_heap(d, {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2049,
2819 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}); 2920 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE});
2820 }}, 2921 }, +device10},
2821 {"descriptor heap: shader-visible 2048 samplers", [](ID3D12Device* d) { 2922 {"descriptor heap: shader-visible 2048 samplers", [](ID3D12Device* d) {
2822 return descriptor_heap(d, {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2048, 2923 return descriptor_heap(d, {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2048,
2823 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE}); 2924 D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE});
@@ -2862,7 +2963,7 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2862 }}, 2963 }},
2863 {"command queue: global realtime priority", [](ID3D12Device* d) { 2964 {"command queue: global realtime priority", [](ID3D12Device* d) {
2864 return command_queue(d, {D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME}); 2965 return command_queue(d, {D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME});
2865 }}, 2966 }, +not_elevated},
2866 {"command queue: compute", [](ID3D12Device* d) { return command_queue(d, {D3D12_COMMAND_LIST_TYPE_COMPUTE}); }}, 2967 {"command queue: compute", [](ID3D12Device* d) { return command_queue(d, {D3D12_COMMAND_LIST_TYPE_COMPUTE}); }},
2867 {"command queue: copy", [](ID3D12Device* d) { return command_queue(d, {D3D12_COMMAND_LIST_TYPE_COPY}); }}, 2968 {"command queue: copy", [](ID3D12Device* d) { return command_queue(d, {D3D12_COMMAND_LIST_TYPE_COPY}); }},
2868 {"command queue: high priority", [](ID3D12Device* d) { 2969 {"command queue: high priority", [](ID3D12Device* d) {
@@ -2952,6 +3053,11 @@ int compare_invalid_arguments(ID3D12Device* ours) {
2952 const HRESULT a = call_guarded(c.call, ours), b = call_guarded(c.call, host.p); 3053 const HRESULT a = call_guarded(c.call, ours), b = call_guarded(c.call, host.p);
2953 if (verbose) std::printf(" ours 0x%08lx host 0x%08lx\n", a, b); 3054 if (verbose) std::printf(" ours 0x%08lx host 0x%08lx\n", a, b);
2954 if (a == b) continue; 3055 if (a == b) continue;
3056 if (c.comparable && !c.comparable(host.p)) {
3057 std::printf("invalid arguments %s: not comparable on this host (ours 0x%08lx, host 0x%08lx)\n", c.name,
3058 a, b);
3059 continue;
3060 }
2955 ++mismatches; 3061 ++mismatches;
2956 std::fprintf(stderr, "invalid arguments %s: ours 0x%08lx, host 0x%08lx\n", c.name, a, b); 3062 std::fprintf(stderr, "invalid arguments %s: ours 0x%08lx, host 0x%08lx\n", c.name, a, b);
2957 } 3063 }
@@ -3009,6 +3115,59 @@ int compare_invalid_arguments(ID3D12Device* ours) {
3009 return mismatches; 3115 return mismatches;
3010} 3116}
3011 3117
3118// D3D-238: the valid neighbours of the CreateHeap/CreateHeap1 refusals in compare_invalid_arguments, compared
3119// with the host on a device that has the GPU address arena (without it the layer answers every heap E_NOTIMPL).
3120int compare_heap_neighbours(ID3D12Device* ours) {
3121 Ref<ID3D12Device> host;
3122 if (!create_host_device(host)) return -1;
3123 struct Case {
3124 const char* name;
3125 InvalidCase call;
3126 };
3127 static const Case cases[] = {
3128 {"heap: alignment 0", [](ID3D12Device* d) { return heap_create(d, heap_desc_of(0)); }},
3129 {"heap: alignment 64 KiB", [](ID3D12Device* d) {
3130 return heap_create(d, heap_desc_of(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT));
3131 }},
3132 {"heap: alignment 4 MiB", [](ID3D12Device* d) {
3133 return heap_create(d, heap_desc_of(D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
3134 {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_NONE,
3135 D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT));
3136 }},
3137 {"heap1: alignment 4 MiB", [](ID3D12Device* d) {
3138 return heap_create1(d, heap_desc_of(D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
3139 {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_NONE,
3140 D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT));
3141 }},
3142 {"heap: size 1000", [](ID3D12Device* d) {
3143 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_NONE, 1000));
3144 }},
3145 {"heap: upload", [](ID3D12Device* d) { return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_UPLOAD})); }},
3146 {"heap: readback", [](ID3D12Device* d) {
3147 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_READBACK}));
3148 }},
3149 {"heap: custom write-combine L0", [](ID3D12Device* d) {
3150 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE,
3151 D3D12_MEMORY_POOL_L0}));
3152 }},
3153 {"heap1: custom write-combine L0", [](ID3D12Device* d) {
3154 return heap_create1(d, heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE,
3155 D3D12_MEMORY_POOL_L0}));
3156 }},
3157 {"heap: ALLOW_ONLY_BUFFERS (two DENY flags)", [](ID3D12Device* d) {
3158 return heap_create(d, heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS));
3159 }},
3160 };
3161 int mismatches = 0;
3162 for (const Case& c : cases) {
3163 const HRESULT a = call_guarded(c.call, ours), b = call_guarded(c.call, host.p);
3164 if (a == b) continue;
3165 ++mismatches;
3166 std::fprintf(stderr, "invalid arguments %s: ours 0x%08lx, host 0x%08lx\n", c.name, a, b);
3167 }
3168 return mismatches;
3169}
3170
3012} // namespace 3171} // namespace
3013 3172
3014int main() { 3173int main() {
@@ -3016,6 +3175,18 @@ int main() {
3016 const auto status = d.initialize(); 3175 const auto status = d.initialize();
3017 if (status == vktest::DeviceStatus::unavailable) return 77; 3176 if (status == vktest::DeviceStatus::unavailable) return 77;
3018 if (status == vktest::DeviceStatus::failed) return 1; 3177 if (status == vktest::DeviceStatus::failed) return 1;
3178 {
3179 // The host comparisons (create_host_device, the copies) run on the layer's own adapter, not D3D12's default
3180 // one, which on a PC with two GPUs can be the other GPU (copycmp::layer_adapter).
3181 VkPhysicalDeviceIDProperties id{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES};
3182 VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &id};
3183 d.instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2")(d.physical, &properties);
3184 if (id.deviceLUIDValid) {
3185 LUID luid{};
3186 std::memcpy(&luid, id.deviceLUID, sizeof(luid));
3187 copycmp::layer_adapter() = luid;
3188 }
3189 }
3019 EXPECT(d.depth_format_usable(VK_FORMAT_D32_SFLOAT_S8_UINT)); 3190 EXPECT(d.depth_format_usable(VK_FORMAT_D32_SFLOAT_S8_UINT));
3020 VkSampleCountFlags depth_sample_counts = 0, color_sample_counts = 0; 3191 VkSampleCountFlags depth_sample_counts = 0, color_sample_counts = 0;
3021 { 3192 {
@@ -3422,6 +3593,68 @@ int main() {
3422 std::printf("invalid arguments: no host D3D12 device to compare with, skipped\n"); 3593 std::printf("invalid arguments: no host D3D12 device to compare with, skipped\n");
3423 EXPECT(argument_mismatches <= 0); 3594 EXPECT(argument_mismatches <= 0);
3424 3595
3596 // D3D-236: CreateCommandQueue with D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME requires
3597 // SeIncreaseBasePriorityPrivilege enabled in the token, matching the Windows D3D12 runtime.
3598 {
3599 const D3D12_COMMAND_QUEUE_DESC rt_desc{
3600 D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME,
3601 D3D12_COMMAND_QUEUE_FLAG_NONE, 0};
3602 struct RestoreOverride {
3603 ~RestoreOverride() { rt::d3d12::set_global_realtime_privilege_override_for_test(-1); }
3604 } restore_override;
3605
3606 rt::d3d12::set_global_realtime_privilege_override_for_test(0);
3607 EXPECT(!rt::d3d12::has_global_realtime_privilege());
3608 Ref<ID3D12CommandQueue> denied_q;
3609 EXPECT(device->CreateCommandQueue(&rt_desc, IID_PPV_ARGS(&denied_q.p)) == DXGI_ERROR_ACCESS_DENIED);
3610 EXPECT(!denied_q.p);
3611 EXPECT(device->CreateCommandQueue(&rt_desc, __uuidof(ID3D12CommandQueue), nullptr) ==
3612 DXGI_ERROR_ACCESS_DENIED);
3613
3614 rt::d3d12::set_global_realtime_privilege_override_for_test(1);
3615 EXPECT(rt::d3d12::has_global_realtime_privilege());
3616 EXPECT(device->CreateCommandQueue(&rt_desc, __uuidof(ID3D12CommandQueue), nullptr) == E_UNEXPECTED);
3617 Ref<ID3D12CommandQueue> granted_q;
3618 EXPECT(SUCCEEDED(device->CreateCommandQueue(&rt_desc, IID_PPV_ARGS(&granted_q.p))) && granted_q.p);
3619 if (granted_q.p) {
3620 EXPECT(granted_q->GetDesc().Priority == D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME);
3621 }
3622 granted_q.reset();
3623 rt::d3d12::set_global_realtime_privilege_override_for_test(-1);
3624
3625 // When the process token holds SeIncreaseBasePriorityPrivilege (e.g. an elevated session), toggle the
3626 // real token privilege and verify both states against the host D3D12 runtime.
3627 HANDLE token = nullptr;
3628 LUID luid{};
3629 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
3630 if (LookupPrivilegeValueW(nullptr, L"SeIncreaseBasePriorityPrivilege", &luid)) {
3631 TOKEN_PRIVILEGES tp{}, prev{};
3632 DWORD prev_len = 0;
3633 tp.PrivilegeCount = 1;
3634 tp.Privileges[0].Luid = luid;
3635 tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
3636 if (AdjustTokenPrivileges(token, FALSE, &tp, sizeof(prev), &prev, &prev_len) &&
3637 GetLastError() == ERROR_SUCCESS) {
3638 EXPECT(rt::d3d12::has_global_realtime_privilege());
3639 EXPECT(command_queue(device.p, rt_desc) == S_OK);
3640 Ref<ID3D12Device> host;
3641 if (create_host_device(host)) {
3642 EXPECT(command_queue(host.p, rt_desc) == S_OK);
3643 }
3644 tp.Privileges[0].Attributes = 0;
3645 if (AdjustTokenPrivileges(token, FALSE, &tp, 0, nullptr, nullptr) &&
3646 GetLastError() == ERROR_SUCCESS) {
3647 EXPECT(!rt::d3d12::has_global_realtime_privilege());
3648 EXPECT(command_queue(device.p, rt_desc) == DXGI_ERROR_ACCESS_DENIED);
3649 if (host.p) EXPECT(command_queue(host.p, rt_desc) == DXGI_ERROR_ACCESS_DENIED);
3650 }
3651 AdjustTokenPrivileges(token, FALSE, &prev, 0, nullptr, nullptr);
3652 }
3653 }
3654 CloseHandle(token);
3655 }
3656 }
3657
3425 const int depth_quality_mismatches = compare_depth_multisample_quality_levels(device.p, depth_sample_counts); 3658 const int depth_quality_mismatches = compare_depth_multisample_quality_levels(device.p, depth_sample_counts);
3426 if (depth_quality_mismatches < 0) 3659 if (depth_quality_mismatches < 0)
3427 std::printf("Depth/stencil MSAA quality queries: no host D3D12 device to compare with, skipped\n"); 3660 std::printf("Depth/stencil MSAA quality queries: no host D3D12 device to compare with, skipped\n");
@@ -4741,6 +4974,44 @@ int main() {
4741 EXPECT(SUCCEEDED(zeroes->Map(0, nullptr, &zero_bytes))); 4974 EXPECT(SUCCEEDED(zeroes->Map(0, nullptr, &zero_bytes)));
4742 report("placed buffer", 0, static_cast<std::uint8_t*>(zero_bytes), std::array<std::uint8_t, 64>{}.data(), 64); 4975 report("placed buffer", 0, static_cast<std::uint8_t*>(zero_bytes), std::array<std::uint8_t, 64>{}.data(), 64);
4743 zeroes->Unmap(0, nullptr); 4976 zeroes->Unmap(0, nullptr);
4977
4978 // Placed buffers carry their console VA in VulkanContext (so VA-resolved commands like WriteBufferImmediate
4979 // find them) and placed readback buffers mark host_readable (so the submission flushes GPU writes to host).
4980 {
4981 D3D12_HEAP_DESC rb_heap_desc{};
4982 rb_heap_desc.Properties.Type = D3D12_HEAP_TYPE_READBACK;
4983 rb_heap_desc.SizeInBytes = 65536;
4984 rb_heap_desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
4985 Ref<ID3D12Heap> rb_heap;
4986 Ref<ID3D12Resource> placed_rb;
4987 EXPECT(SUCCEEDED(standalone->CreateHeap(&rb_heap_desc, IID_PPV_ARGS(&rb_heap.p))));
4988 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(rb_heap.p, 0, &placed_buffer,
4989 D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
4990 IID_PPV_ARGS(&placed_rb.p))));
4991 Ref<ID3D12GraphicsCommandList2> placed_list2;
4992 EXPECT(SUCCEEDED(placed_list->QueryInterface(IID_PPV_ARGS(&placed_list2.p))));
4993 EXPECT(SUCCEEDED(placed_allocator->Reset()) && SUCCEEDED(placed_list->Reset(placed_allocator.p, nullptr)));
4994 const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER wp{placed_va + 16, 0xCAFEBABEu};
4995 const D3D12_WRITEBUFFERIMMEDIATE_MODE wm = D3D12_WRITEBUFFERIMMEDIATE_MODE_DEFAULT;
4996 placed_list2->WriteBufferImmediate(1, &wp, &wm);
4997 D3D12_RESOURCE_BARRIER b{};
4998 b.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
4999 b.Transition = {placed_a.p, D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
5000 D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE};
5001 placed_list->ResourceBarrier(1, &b);
5002 placed_list->CopyBufferRegion(placed_rb.p, 0, placed_a.p, 0, 64);
5003 EXPECT(SUCCEEDED(placed_list->Close()));
5004 queue->ExecuteCommandLists(1, placed_lists);
5005 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
5006 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)) && SUCCEEDED(fence->SetEventOnCompletion(7, nullptr)));
5007 void* rb_bytes = nullptr;
5008 EXPECT(SUCCEEDED(placed_rb->Map(0, nullptr, &rb_bytes)));
5009 std::uint32_t word = 0;
5010 std::memcpy(&word, static_cast<const std::uint8_t*>(rb_bytes) + 16, sizeof(word));
5011 EXPECT(word == 0xCAFEBABEu);
5012 placed_rb->Unmap(0, nullptr);
5013 }
5014
4744 // The heap owns the range: releasing it puts the next heap of that size back at the same place. 5015 // The heap owns the range: releasing it puts the next heap of that size back at the same place.
4745 placed_image.reset(); 5016 placed_image.reset();
4746 placed_b.reset(); 5017 placed_b.reset();
@@ -4762,6 +5033,52 @@ int main() {
4762 upload_heap_desc.Properties.Type = D3D12_HEAP_TYPE_UPLOAD; 5033 upload_heap_desc.Properties.Type = D3D12_HEAP_TYPE_UPLOAD;
4763 EXPECT(SUCCEEDED(standalone->CreateHeap(&upload_heap_desc, IID_PPV_ARGS(&upload_placed_heap.p)))); 5034 EXPECT(SUCCEEDED(standalone->CreateHeap(&upload_heap_desc, IID_PPV_ARGS(&upload_placed_heap.p))));
4764 5035
5036 // D3D-238: heap descriptions the host refuses (RX 5700 and WARP), from CreateHeap and CreateHeap1 alike, and
5037 // their valid neighbours. compare_invalid_arguments and compare_heap_neighbours check them against a host.
5038 {
5039 const D3D12_HEAP_FLAGS deny_all = D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES |
5040 D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES;
5041 const D3D12_HEAP_DESC refused_heaps[] = {
5042 heap_desc_of(4096),
5043 heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_L0}),
5044 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, deny_all),
5045 heap_desc_of(0, {D3D12_HEAP_TYPE(0)}),
5046 heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE,
5047 D3D12_MEMORY_POOL_UNKNOWN}),
5048 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_WRITE_BACK}),
5049 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_NONE, 0),
5050 };
5051 for (const D3D12_HEAP_DESC& hd : refused_heaps) {
5052 EXPECT(heap_create(standalone.p, hd) == E_INVALIDARG);
5053 EXPECT(heap_create1(standalone.p, hd) == E_INVALIDARG);
5054 }
5055 const D3D12_HEAP_DESC accepted_heaps[] = {
5056 heap_desc_of(0),
5057 heap_desc_of(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT),
5058 heap_desc_of(D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT, {D3D12_HEAP_TYPE_DEFAULT},
5059 D3D12_HEAP_FLAG_NONE, D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT),
5060 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_NONE, 1000),
5061 heap_desc_of(0, {D3D12_HEAP_TYPE_UPLOAD}),
5062 heap_desc_of(0, {D3D12_HEAP_TYPE_READBACK}),
5063 heap_desc_of(0, {D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, D3D12_MEMORY_POOL_L0}),
5064 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT}, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS),
5065 heap_desc_of(0, {D3D12_HEAP_TYPE_DEFAULT},
5066 D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES),
5067 };
5068 for (const D3D12_HEAP_DESC& hd : accepted_heaps) {
5069 EXPECT(heap_create(standalone.p, hd) == S_OK);
5070 EXPECT(heap_create1(standalone.p, hd) == S_OK);
5071 }
5072 Ref<ID3D12Device4> device4;
5073 Ref<ID3D12Heap> unused;
5074 EXPECT(SUCCEEDED(standalone->QueryInterface(IID_PPV_ARGS(&device4.p))));
5075 EXPECT(device4->CreateHeap1(&placed_heap_desc, nullptr, IID_PPV_ARGS(&unused.p)) == S_OK && unused.p);
5076 const int heap_mismatches = compare_heap_neighbours(standalone.p);
5077 if (heap_mismatches < 0)
5078 std::printf("CreateHeap valid neighbours: no host D3D12 device to compare with, skipped\n");
5079 EXPECT(heap_mismatches <= 0);
5080 }
5081
4765 auto tiled_2d = [&](UINT w, UINT h, DXGI_FORMAT fmt, UINT16 mips, D3D12_RESOURCE_FLAGS flags, 5082 auto tiled_2d = [&](UINT w, UINT h, DXGI_FORMAT fmt, UINT16 mips, D3D12_RESOURCE_FLAGS flags,
4766 UINT64 align = 0) { 5083 UINT64 align = 0) {
4767 D3D12_RESOURCE_DESC d = texture_desc(w, h, fmt, flags, mips); 5084 D3D12_RESOURCE_DESC d = texture_desc(w, h, fmt, flags, mips);
@@ -4846,13 +5163,6 @@ int main() {
4846 EXPECT(!fail.p); 5163 EXPECT(!fail.p);
4847 } 5164 }
4848 { 5165 {
4849 const D3D12_RESOURCE_DESC valid_4x = tiled_2d_msaa(4, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
4850 Ref<ID3D12Resource> fail;
4851 EXPECT(standalone->CreatePlacedResource(tiled_heap.p, 0, &valid_4x, D3D12_RESOURCE_STATE_COMMON, nullptr,
4852 IID_PPV_ARGS(&fail.p)) == E_NOTIMPL);
4853 EXPECT(!fail.p);
4854 }
4855 {
4856 Ref<ID3D12Resource> fail; 5166 Ref<ID3D12Resource> fail;
4857 EXPECT(standalone->CreatePlacedResource(upload_placed_heap.p, 0, &tiled_rt_desc, 5167 EXPECT(standalone->CreatePlacedResource(upload_placed_heap.p, 0, &tiled_rt_desc,
4858 D3D12_RESOURCE_STATE_COMMON, nullptr, 5168 D3D12_RESOURCE_STATE_COMMON, nullptr,
@@ -4900,7 +5210,7 @@ int main() {
4900 ID3D12CommandList* tiled_lists[] = {tiled_list.p}; 5210 ID3D12CommandList* tiled_lists[] = {tiled_list.p};
4901 queue->ExecuteCommandLists(1, tiled_lists); 5211 queue->ExecuteCommandLists(1, tiled_lists);
4902 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 5212 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
4903 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)) && SUCCEEDED(fence->SetEventOnCompletion(7, nullptr))); 5213 EXPECT(SUCCEEDED(queue->Signal(fence.p, 8)) && SUCCEEDED(fence->SetEventOnCompletion(8, nullptr)));
4904 void* tiled_bytes = nullptr; 5214 void* tiled_bytes = nullptr;
4905 EXPECT(SUCCEEDED(tiled_rb->Map(0, nullptr, &tiled_bytes))); 5215 EXPECT(SUCCEEDED(tiled_rb->Map(0, nullptr, &tiled_bytes)));
4906 const std::uint8_t want_rgba[4] = {64, 128, 191, 255}; 5216 const std::uint8_t want_rgba[4] = {64, 128, 191, 255};
@@ -4922,15 +5232,15 @@ int main() {
4922 tiled_3d_desc, 5232 tiled_3d_desc,
4923 }; 5233 };
4924 for (int idx = 0; idx < int(std::size(host_cases)); ++idx) { 5234 for (int idx = 0; idx < int(std::size(host_cases)); ++idx) {
4925 const D3D12_RESOURCE_DESC& d = host_cases[idx]; 5235 const D3D12_RESOURCE_DESC& host_desc = host_cases[idx];
4926 if (d.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D && 5236 if (host_desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D &&
4927 host_opts.TiledResourcesTier < D3D12_TILED_RESOURCES_TIER_3) 5237 host_opts.TiledResourcesTier < D3D12_TILED_RESOURCES_TIER_3)
4928 continue; 5238 continue;
4929 Ref<ID3D12Resource> our_r, host_r; 5239 Ref<ID3D12Resource> our_r, host_r;
4930 const HRESULT our_hr = standalone->CreatePlacedResource( 5240 const HRESULT our_hr = standalone->CreatePlacedResource(
4931 tiled_heap.p, 0, &d, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&our_r.p)); 5241 tiled_heap.p, 0, &host_desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&our_r.p));
4932 const HRESULT host_hr = host_dev->CreatePlacedResource( 5242 const HRESULT host_hr = host_dev->CreatePlacedResource(
4933 host_heap.p, 0, &d, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&host_r.p)); 5243 host_heap.p, 0, &host_desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&host_r.p));
4934 if (FAILED(host_hr)) continue; 5244 if (FAILED(host_hr)) continue;
4935 EXPECT(SUCCEEDED(our_hr)); 5245 EXPECT(SUCCEEDED(our_hr));
4936 EXPECT(our_r->GetDesc().Layout == host_r->GetDesc().Layout); 5246 EXPECT(our_r->GetDesc().Layout == host_r->GetDesc().Layout);
@@ -4948,6 +5258,259 @@ int main() {
4948 } 5258 }
4949 } 5259 }
4950 } 5260 }
5261
5262 // D3D-222: multisampled placed textures (UNKNOWN and 4x tiled).
5263 D3D12_HEAP_DESC msaa_heap_desc{};
5264 msaa_heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
5265 msaa_heap_desc.SizeInBytes = 16 * 1024 * 1024;
5266 msaa_heap_desc.Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT;
5267 Ref<ID3D12Heap> msaa_heap;
5268 EXPECT(SUCCEEDED(standalone->CreateHeap(&msaa_heap_desc, IID_PPV_ARGS(&msaa_heap.p))));
5269 D3D12_HEAP_DESC deny_rt_desc = tiled_heap_desc;
5270 deny_rt_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
5271 Ref<ID3D12Heap> deny_rt_heap;
5272 EXPECT(SUCCEEDED(standalone->CreateHeap(&deny_rt_desc, IID_PPV_ARGS(&deny_rt_heap.p))));
5273
5274 auto msaa_desc = [&](UINT w, UINT h, UINT samples, UINT64 align, D3D12_TEXTURE_LAYOUT layout,
5275 D3D12_RESOURCE_FLAGS flags, DXGI_FORMAT fmt = DXGI_FORMAT_R8G8B8A8_UNORM,
5276 UINT16 mips = 1) {
5277 D3D12_RESOURCE_DESC d = texture_desc(w, h, fmt, flags, mips);
5278 d.Alignment = align;
5279 d.SampleDesc.Count = samples;
5280 d.Layout = layout;
5281 return d;
5282 };
5283 const D3D12_RESOURCE_DESC msaa_unk_rt_desc =
5284 msaa_desc(256, 256, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
5285 const D3D12_RESOURCE_DESC msaa_unk_small_desc = msaa_desc(
5286 256, 256, 4, D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT, D3D12_TEXTURE_LAYOUT_UNKNOWN,
5287 D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
5288 const D3D12_RESOURCE_DESC msaa_unk_ds_desc =
5289 msaa_desc(256, 256, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL,
5290 DXGI_FORMAT_D32_FLOAT);
5291 const D3D12_RESOURCE_DESC msaa_tiled_rt_desc = tiled_2d_msaa(4, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
5292 D3D12_RESOURCE_DESC msaa_xbox_rt_desc = msaa_tiled_rt_desc;
5293 msaa_xbox_rt_desc.Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x101);
5294
5295 Ref<ID3D12Resource> msaa_unk_rt, msaa_unk_small, msaa_unk_ds, msaa_tiled_rt, msaa_xbox_rt, msaa_cast_rt;
5296 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(msaa_heap.p, D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT,
5297 &msaa_unk_rt_desc, D3D12_RESOURCE_STATE_COMMON, nullptr,
5298 IID_PPV_ARGS(&msaa_unk_rt.p))));
5299 EXPECT(msaa_unk_rt->GetGPUVirtualAddress() == 0);
5300 EXPECT(msaa_unk_rt->GetDesc().Alignment == D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT);
5301 EXPECT(msaa_unk_rt->GetDesc().SampleDesc.Count == 4);
5302 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(tiled_heap.p, 65536, &msaa_unk_small_desc,
5303 D3D12_RESOURCE_STATE_COMMON, nullptr,
5304 IID_PPV_ARGS(&msaa_unk_small.p))));
5305 EXPECT(msaa_unk_small->GetDesc().Alignment == D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT);
5306 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(msaa_heap.p, 8 * 1024 * 1024, &msaa_unk_ds_desc,
5307 D3D12_RESOURCE_STATE_COMMON, nullptr,
5308 IID_PPV_ARGS(&msaa_unk_ds.p))));
5309 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(tiled_heap.p, 65536, &msaa_tiled_rt_desc,
5310 D3D12_RESOURCE_STATE_COMMON, nullptr,
5311 IID_PPV_ARGS(&msaa_tiled_rt.p))));
5312 EXPECT(msaa_tiled_rt->GetDesc().Alignment == D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
5313 UINT msaa_tiles = 0;
5314 D3D12_TILE_SHAPE msaa_shape{};
5315 standalone->GetResourceTiling(msaa_tiled_rt.p, &msaa_tiles, nullptr, &msaa_shape, nullptr, 0, nullptr);
5316 EXPECT(msaa_tiles == 16 && msaa_shape.WidthInTexels == 64 && msaa_shape.HeightInTexels == 64);
5317 EXPECT(SUCCEEDED(standalone->CreatePlacedResource(tiled_heap.p, 65536, &msaa_xbox_rt_desc,
5318 D3D12_RESOURCE_STATE_COMMON, nullptr,
5319 IID_PPV_ARGS(&msaa_xbox_rt.p))));
5320 EXPECT(msaa_xbox_rt->GetDesc().Alignment == D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
5321 EXPECT(static_cast<UINT>(msaa_xbox_rt->GetDesc().Layout) == 0x101);
5322
5323 {
5324 Ref<ID3D12Device10> standalone10;
5325 EXPECT(SUCCEEDED(standalone->QueryInterface(IID_PPV_ARGS(&standalone10.p))));
5326 D3D12_RESOURCE_DESC1 cast_msaa{};
5327 cast_msaa.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
5328 cast_msaa.Width = 64;
5329 cast_msaa.Height = 64;
5330 cast_msaa.DepthOrArraySize = 1;
5331 cast_msaa.MipLevels = 1;
5332 cast_msaa.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS;
5333 cast_msaa.SampleDesc.Count = 4;
5334 cast_msaa.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
5335 const DXGI_FORMAT cast_list[] = {DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB};
5336 EXPECT(SUCCEEDED(standalone10->CreatePlacedResource2(
5337 msaa_heap.p, 0, &cast_msaa, D3D12_BARRIER_LAYOUT_COMMON, nullptr, 2, cast_list,
5338 IID_PPV_ARGS(&msaa_cast_rt.p))));
5339 }
5340
5341 // Refusals matching host D3D12 for MSAA placed resources.
5342 {
5343 struct BadMsaaCase {
5344 ID3D12Heap* heap;
5345 UINT64 offset;
5346 D3D12_RESOURCE_DESC desc;
5347 };
5348 D3D12_RESOURCE_DESC msaa_3d =
5349 msaa_desc(16, 16, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET);
5350 msaa_3d.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D;
5351 msaa_3d.DepthOrArraySize = 8;
5352 const BadMsaaCase bad_msaa[] = {
5353 // 4 MiB-aligned UNKNOWN MSAA fails on a 64 KiB heap (even at offset 0) and at misaligned offsets.
5354 {tiled_heap.p, 0, msaa_unk_rt_desc},
5355 {msaa_heap.p, 65536, msaa_unk_rt_desc},
5356 {msaa_heap.p, msaa_heap_desc.SizeInBytes - 65536, msaa_unk_small_desc},
5357 {upload_placed_heap.p, 0, msaa_unk_small_desc},
5358 {deny_rt_heap.p, 0, msaa_unk_small_desc},
5359 {deny_rt_heap.p, 0, tiled_rt_desc},
5360 {msaa_heap.p, 0,
5361 msaa_desc(256, 256, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_NONE)},
5362 {msaa_heap.p, 0,
5363 msaa_desc(256, 256, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN,
5364 D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)},
5365 {msaa_heap.p, 0,
5366 msaa_desc(64, 64, 4, 0, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET,
5367 DXGI_FORMAT_R8G8B8A8_UNORM, 0)},
5368 {msaa_heap.p, 0, msaa_3d},
5369 };
5370 for (const BadMsaaCase& bad : bad_msaa) {
5371 Ref<ID3D12Resource> fail;
5372 EXPECT(standalone->CreatePlacedResource(bad.heap, bad.offset, &bad.desc, D3D12_RESOURCE_STATE_COMMON,
5373 nullptr, IID_PPV_ARGS(&fail.p)) == E_INVALIDARG);
5374 EXPECT(!fail.p);
5375 }
5376 D3D12_HEAP_DESC only_rt_desc = tiled_heap_desc;
5377 only_rt_desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES;
5378 Ref<ID3D12Heap> only_rt_heap;
5379 EXPECT(SUCCEEDED(standalone->CreateHeap(&only_rt_desc, IID_PPV_ARGS(&only_rt_heap.p))));
5380 for (const D3D12_RESOURCE_DESC& bad_only_rt :
5381 {texture_desc(64, 64, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_RESOURCE_FLAG_NONE, 1),
5382 buffer_desc(4096)}) {
5383 Ref<ID3D12Resource> fail;
5384 EXPECT(standalone->CreatePlacedResource(only_rt_heap.p, 0, &bad_only_rt, D3D12_RESOURCE_STATE_COMMON,
5385 nullptr, IID_PPV_ARGS(&fail.p)) == E_INVALIDARG);
5386 EXPECT(!fail.p);
5387 }
5388 }
5389
5390 // Clear placed 4x MSAA RTVs (UNKNOWN + tiled) and DSV, resolve, and read back to verify GPU execution.
5391 {
5392 const D3D12_RESOURCE_DESC resolved_desc =
5393 texture_desc(256, 256, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_RESOURCE_FLAG_NONE, 1);
5394 Ref<ID3D12Resource> msaa_resolved_unk, msaa_resolved_tiled;
5395 D3D12_HEAP_PROPERTIES def_hp{D3D12_HEAP_TYPE_DEFAULT};
5396 EXPECT(SUCCEEDED(standalone->CreateCommittedResource(&def_hp, D3D12_HEAP_FLAG_NONE, &resolved_desc,
5397 D3D12_RESOURCE_STATE_RESOLVE_DEST, nullptr,
5398 IID_PPV_ARGS(&msaa_resolved_unk.p))));
5399 EXPECT(SUCCEEDED(standalone->CreateCommittedResource(&def_hp, D3D12_HEAP_FLAG_NONE, &resolved_desc,
5400 D3D12_RESOURCE_STATE_RESOLVE_DEST, nullptr,
5401 IID_PPV_ARGS(&msaa_resolved_tiled.p))));
5402
5403 D3D12_DESCRIPTOR_HEAP_DESC msaa_rtv_hd{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 2, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
5404 D3D12_DESCRIPTOR_HEAP_DESC msaa_dsv_hd{D3D12_DESCRIPTOR_HEAP_TYPE_DSV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0};
5405 Ref<ID3D12DescriptorHeap> msaa_rtv_heap, msaa_dsv_heap;
5406 EXPECT(SUCCEEDED(standalone->CreateDescriptorHeap(&msaa_rtv_hd, IID_PPV_ARGS(&msaa_rtv_heap.p))));
5407 EXPECT(SUCCEEDED(standalone->CreateDescriptorHeap(&msaa_dsv_hd, IID_PPV_ARGS(&msaa_dsv_heap.p))));
5408 const UINT rtv_step = standalone->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
5409 const D3D12_CPU_DESCRIPTOR_HANDLE rtv0 = msaa_rtv_heap->GetCPUDescriptorHandleForHeapStart();
5410 const D3D12_CPU_DESCRIPTOR_HANDLE rtv1{rtv0.ptr + rtv_step};
5411 standalone->CreateRenderTargetView(msaa_unk_rt.p, nullptr, rtv0);
5412 standalone->CreateRenderTargetView(msaa_tiled_rt.p, nullptr, rtv1);
5413 standalone->CreateDepthStencilView(msaa_unk_ds.p, nullptr, msaa_dsv_heap->GetCPUDescriptorHandleForHeapStart());
5414
5415 EXPECT(SUCCEEDED(tiled_alloc->Reset()) && SUCCEEDED(tiled_list->Reset(tiled_alloc.p, nullptr)));
5416 D3D12_RESOURCE_BARRIER barriers[] = {
5417 transition(msaa_unk_rt.p, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_RENDER_TARGET),
5418 transition(msaa_tiled_rt.p, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_RENDER_TARGET),
5419 transition(msaa_unk_ds.p, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_DEPTH_WRITE),
5420 };
5421 tiled_list->ResourceBarrier(3, barriers);
5422 tiled_list->ClearRenderTargetView(rtv0, tiled_color, 0, nullptr);
5423 tiled_list->ClearRenderTargetView(rtv1, tiled_color, 0, nullptr);
5424 tiled_list->ClearDepthStencilView(msaa_dsv_heap->GetCPUDescriptorHandleForHeapStart(),
5425 D3D12_CLEAR_FLAG_DEPTH, 0.5f, 0, 0, nullptr);
5426 D3D12_RESOURCE_BARRIER to_resolve[] = {
5427 transition(msaa_unk_rt.p, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_RESOLVE_SOURCE),
5428 transition(msaa_tiled_rt.p, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_RESOLVE_SOURCE),
5429 };
5430 tiled_list->ResourceBarrier(2, to_resolve);
5431 tiled_list->ResolveSubresource(msaa_resolved_unk.p, 0, msaa_unk_rt.p, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
5432 tiled_list->ResolveSubresource(msaa_resolved_tiled.p, 0, msaa_tiled_rt.p, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
5433 D3D12_RESOURCE_BARRIER to_copy[] = {
5434 transition(msaa_resolved_unk.p, D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE),
5435 transition(msaa_resolved_tiled.p, D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE),
5436 };
5437 tiled_list->ResourceBarrier(2, to_copy);
5438 Ref<ID3D12Resource> msaa_rb;
5439 const D3D12_RESOURCE_DESC msaa_rb_desc = buffer_desc(1024);
5440 EXPECT(SUCCEEDED(standalone->CreateCommittedResource(&rb_props, D3D12_HEAP_FLAG_NONE, &msaa_rb_desc,
5441 D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
5442 IID_PPV_ARGS(&msaa_rb.p))));
5443 D3D12_PLACED_SUBRESOURCE_FOOTPRINT fp_unk{}, fp_tiled{};
5444 fp_unk.Offset = 0;
5445 fp_unk.Footprint = {DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT};
5446 fp_tiled = fp_unk;
5447 fp_tiled.Offset = D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT;
5448 const D3D12_TEXTURE_COPY_LOCATION dst_unk = footprint(msaa_rb.p, fp_unk);
5449 const D3D12_TEXTURE_COPY_LOCATION src_unk = subresource(msaa_resolved_unk.p, 0);
5450 const D3D12_TEXTURE_COPY_LOCATION dst_tiled = footprint(msaa_rb.p, fp_tiled);
5451 const D3D12_TEXTURE_COPY_LOCATION src_tiled = subresource(msaa_resolved_tiled.p, 0);
5452 tiled_list->CopyTextureRegion(&dst_unk, 0, 0, 0, &src_unk, &box);
5453 tiled_list->CopyTextureRegion(&dst_tiled, 0, 0, 0, &src_tiled, &box);
5454 EXPECT(SUCCEEDED(tiled_list->Close()));
5455 queue->ExecuteCommandLists(1, tiled_lists);
5456 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
5457 EXPECT(SUCCEEDED(queue->Signal(fence.p, 9)) && SUCCEEDED(fence->SetEventOnCompletion(9, nullptr)));
5458 void* msaa_bytes = nullptr;
5459 EXPECT(SUCCEEDED(msaa_rb->Map(0, nullptr, &msaa_bytes)));
5460 const auto* out_bytes = static_cast<const std::uint8_t*>(msaa_bytes);
5461 report("placed MSAA UNKNOWN RTV resolve", 0, out_bytes, want_rgba, 4);
5462 report("placed MSAA tiled RTV resolve", 0, out_bytes + D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT, want_rgba, 4);
5463 EXPECT(std::memcmp(out_bytes, want_rgba, 4) == 0);
5464 EXPECT(std::memcmp(out_bytes + D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT, want_rgba, 4) == 0);
5465 msaa_rb->Unmap(0, nullptr);
5466 }
5467
5468 // Host parity for MSAA placed acceptance/refusals, layout, alignment, heap flags and tiled 4x shape.
5469 if (host_dev.p) {
5470 Ref<ID3D12Heap> host_heap64, host_heap4m;
5471 if (SUCCEEDED(host_dev->CreateHeap(&tiled_heap_desc, IID_PPV_ARGS(&host_heap64.p))) &&
5472 SUCCEEDED(host_dev->CreateHeap(&msaa_heap_desc, IID_PPV_ARGS(&host_heap4m.p)))) {
5473 struct MsaaParityCase {
5474 ID3D12Heap* our_heap;
5475 ID3D12Heap* host_heap;
5476 UINT64 offset;
5477 D3D12_RESOURCE_DESC desc;
5478 };
5479 const MsaaParityCase parity[] = {
5480 {tiled_heap.p, host_heap64.p, 0, msaa_unk_rt_desc},
5481 {msaa_heap.p, host_heap4m.p, 65536, msaa_unk_rt_desc},
5482 {msaa_heap.p, host_heap4m.p, 0, msaa_unk_rt_desc},
5483 {tiled_heap.p, host_heap64.p, 65536, msaa_unk_small_desc},
5484 {tiled_heap.p, host_heap64.p, 65536, msaa_tiled_rt_desc},
5485 };
5486 for (const MsaaParityCase& mc : parity) {
5487 Ref<ID3D12Resource> our_r, host_r;
5488 const HRESULT our_hr = standalone->CreatePlacedResource(
5489 mc.our_heap, mc.offset, &mc.desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&our_r.p));
5490 const HRESULT host_hr = host_dev->CreatePlacedResource(
5491 mc.host_heap, mc.offset, &mc.desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&host_r.p));
5492 EXPECT(SUCCEEDED(our_hr) == SUCCEEDED(host_hr));
5493 if (FAILED(host_hr)) {
5494 EXPECT(our_hr == host_hr);
5495 continue;
5496 }
5497 EXPECT(our_r->GetDesc().Layout == host_r->GetDesc().Layout);
5498 EXPECT(our_r->GetDesc().Alignment == host_r->GetDesc().Alignment);
5499 EXPECT(our_r->GetDesc().SampleDesc.Count == host_r->GetDesc().SampleDesc.Count);
5500 D3D12_HEAP_PROPERTIES ohp{}, hhp{};
5501 EXPECT(SUCCEEDED(our_r->GetHeapProperties(&ohp, nullptr)) &&
5502 SUCCEEDED(host_r->GetHeapProperties(&hhp, nullptr)));
5503 EXPECT(ohp.Type == hhp.Type);
5504 if (mc.desc.Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE) {
5505 D3D12_TILE_SHAPE os{}, hs{};
5506 standalone->GetResourceTiling(our_r.p, nullptr, nullptr, &os, nullptr, 0, nullptr);
5507 host_dev->GetResourceTiling(host_r.p, nullptr, nullptr, &hs, nullptr, 0, nullptr);
5508 EXPECT(os.WidthInTexels == hs.WidthInTexels && os.HeightInTexels == hs.HeightInTexels &&
5509 os.DepthInTexels == hs.DepthInTexels);
5510 }
5511 }
5512 }
5513 }
4951 } 5514 }
4952 5515
4953 // D3D-90, the placed half of castable formats: CreatePlacedResource2 takes NumCastableFormats exactly as 5516 // D3D-90, the placed half of castable formats: CreatePlacedResource2 takes NumCastableFormats exactly as
@@ -5179,6 +5742,15 @@ int main() {
5179 EXPECT(words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == 0); 5742 EXPECT(words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == 0);
5180 } 5743 }
5181 5744
5745 // The tolerance host_side applies, pinned here so every GPU checks it: its accept side only runs where the
5746 // host rounds differently (Intel's SRGB clear), so a change to it would otherwise stay green elsewhere.
5747 // One code either side of a near-tie is accepted; two codes, or a code past 0.6 ULP, are not.
5748 EXPECT(within_06_ulp(187, 188, ideal_srgb(0.5) * 255.0) && within_06_ulp(127, 128, 127.5));
5749 EXPECT(!within_06_ulp(186, 188, ideal_srgb(0.5) * 255.0) && !within_06_ulp(126, 128, 127.5));
5750 EXPECT(!within_06_ulp(224, 225, ideal_srgb(0.75) * 255.0) &&
5751 !within_06_ulp(136, 137, ideal_srgb(0.25) * 255.0));
5752 EXPECT(!within_06_ulp(254, 255, 255.0));
5753
5182 // The host PC runtime's bytes and refusals: the default adapter when it can cast, WARP otherwise. 5754 // The host PC runtime's bytes and refusals: the default adapter when it can cast, WARP otherwise.
5183 bool compared = false; 5755 bool compared = false;
5184 const char* source = "no host"; 5756 const char* source = "no host";
@@ -5188,33 +5760,44 @@ int main() {
5188 if (!placed_cast_scenario(device10, false, host.data())) return false; 5760 if (!placed_cast_scenario(device10, false, host.data())) return false;
5189 if (!placed_cast_refusals(device10, host_refusals)) return false; 5761 if (!placed_cast_refusals(device10, host_refusals)) return false;
5190 unsigned differences = 0; 5762 unsigned differences = 0;
5191 // D3D12 does not pin float -> UNORM at a tie: the D3D11.3 functional spec (3.2.3.6 FLOAT -> UNORM) 5763 // D3D12 does not pin float -> UNORM or float -> SRGB to one code: the D3D11.3 functional spec
5192 // computes c * (2^n - 1) + 0.5 and drops the fraction, but permits a tolerance of 0.6 ULP on the integer 5764 // (3.2.3.6 FLOAT -> UNORM, 3.2.3.8 FLOAT -> SRGB) permits a tolerance of 0.6 ULP on the integer side, so
5193 // side, so a value exactly halfway between two codes (0.5 * 255 = 127.5) may map to either. WARP and AMD 5765 // a value near halfway between two codes may map to either. The plain clear's 0.5 * 255 = 127.5 is a
5194 // give the upper code; NVIDIA's D3D12 driver and its Vulkan driver the lower (RTX 3080 616.64, RTX 3090 5766 // tie: WARP and AMD give the upper code, NVIDIA's D3D12 driver and its Vulkan driver the lower (RTX 3080
5195 // 610.88 and RTX 5070 Laptop 617.42). On the layer's own adapter (same LUID) the comparison stays exact; 5767 // 616.64, RTX 3090 610.88 and RTX 5070 Laptop 617.42). The SRGB-cast clear's 0.5 encodes to 187.516:
5196 // against another adapter or WARP the plain clear accepts either code on a tie channel. 5768 // WARP and NVIDIA's Vulkan driver give 188, Intel's Vulkan driver 187 (UHD 770 101.7092), both within
5769 // 0.6 ULP. On the layer's own adapter (same LUID) the comparison stays exact; against another adapter
5770 // or WARP a byte may differ when both sides are within 0.6 ULP of the ideal value.
5197 const FLOAT clear_value[4] = {0.25f, 0.5f, 0.75f, 1.0f}; // placed_cast_scenario's clear colour 5771 const FLOAT clear_value[4] = {0.25f, 0.5f, 0.75f, 1.0f}; // placed_cast_scenario's clear colour
5198 unsigned tie_bytes_other_way = 0; 5772 const auto within_tolerance = [&](std::uint8_t ours_byte, std::uint8_t host_byte, double ideal) {
5773 return !same_adapter && within_06_ulp(ours_byte, host_byte, ideal);
5774 };
5775 unsigned plain_within = 0, srgb_within = 0;
5199 for (UINT row = 0; row < 4; ++row) 5776 for (UINT row = 0; row < 4; ++row)
5200 for (UINT i = 0; i < 16; ++i) { 5777 for (UINT i = 0; i < 16; ++i) {
5201 const UINT a = row * 256 + i, b = 1024 + row * 256 + i; 5778 const UINT a = row * 256 + i, b = 1024 + row * 256 + i;
5202 const double scaled = double(clear_value[i % 4]) * 255.0; 5779 const double c = clear_value[i % 4];
5203 const bool tie = !same_adapter && scaled - std::floor(scaled) == 0.5; 5780 const double plain_ideal = c * 255.0;
5204 if (tie && std::abs(int(ours[b]) - int(host[b])) == 1) { 5781 const double srgb_ideal = (i % 4 == 3 ? c : ideal_srgb(c)) * 255.0; // alpha stays linear
5205 ++tie_bytes_other_way; 5782 if (ours[b] != host[b]) {
5206 } else if (ours[b] != host[b] && differences++ < 8) { 5783 if (within_tolerance(ours[b], host[b], plain_ideal))
5207 std::fprintf(stderr, "placed plain clear row %u byte %u: ours %02x, host %02x\n", row, i, 5784 ++plain_within;
5208 ours[b], host[b]); 5785 else if (differences++ < 8)
5786 std::fprintf(stderr, "placed plain clear row %u byte %u: ours %02x, host %02x\n", row, i,
5787 ours[b], host[b]);
5788 }
5789 if (ours[a] != host[a]) {
5790 if (within_tolerance(ours[a], host[a], srgb_ideal))
5791 ++srgb_within;
5792 else if (differences++ < 8)
5793 std::fprintf(stderr, "placed SRGB-cast clear row %u byte %u: ours %02x, host %02x\n",
5794 row, i, ours[a], host[a]);
5209 } 5795 }
5210 if (ours[a] != host[a] && differences++ < 8)
5211 std::fprintf(stderr, "placed SRGB-cast clear row %u byte %u: ours %02x, host %02x\n", row,
5212 i, ours[a], host[a]);
5213 } 5796 }
5214 if (tie_bytes_other_way) 5797 if (plain_within || srgb_within)
5215 std::printf("placed plain clear: the host rounds the exact .5 tie the other way in %u bytes (within " 5798 std::printf("placed clears: %u plain and %u SRGB-cast bytes differ from the host by one code, both "
5216 "the 0.6 ULP tolerance of D3D11.3 spec 3.2.3.6)\n", 5799 "within the 0.6 ULP tolerance of D3D11.3 spec 3.2.3.6 and 3.2.3.8\n",
5217 tie_bytes_other_way); 5800 plain_within, srgb_within);
5218 for (UINT i = 0; i < 3; ++i) 5801 for (UINT i = 0; i < 3; ++i)
5219 if (our_refusals[i] != host_refusals[i]) { 5802 if (our_refusals[i] != host_refusals[i]) {
5220 ++differences; 5803 ++differences;
diff --git a/runtime/test/d3d12_xdxr_rt_test.cpp b/runtime/test/d3d12_xdxr_rt_test.cpp
index 9499dbe0d..51f357fc1 100644
--- a/runtime/test/d3d12_xdxr_rt_test.cpp
+++ b/runtime/test/d3d12_xdxr_rt_test.cpp
@@ -2,7 +2,10 @@
2// 4.8, src/xdxr_build.h), the layout the game's translated traversal shaders read. A BLAS of two geometries (an 2// 4.8, src/xdxr_build.h), the layout the game's translated traversal shaders read. A BLAS of two geometries (an
3// unindexed triangle soup, and an R16-indexed grid with a 16-byte stride and a 3x4 transform) and a TLAS of three 3// unindexed triangle soup, and an R16-indexed grid with a 16-byte stride and a 3x4 transform) and a TLAS of three
4// instances are built through the D3D12 API, sized by GetRaytracingAccelerationStructurePrebuildInfo, copied to 4// instances are built through the D3D12 API, sized by GetRaytracingAccelerationStructurePrebuildInfo, copied to
5// readback buffers and written to <out dir> as <case>.bin + <case>.json at their console GPU virtual addresses. 5// readback buffers and written to <out dir>; the BLAS is then updated in place (PERFORM_UPDATE) after its soup moves,
6// and written again as d3d12_blas_update; then its postbuild COMPACTED_SIZE and a TLAS rebuild's CURRENT_SIZE are
7// checked against the prebuild sizes, and the BLAS is compacted (CopyRaytracingAccelerationStructure COMPACT) into a
8// buffer of exactly that size, written as d3d12_blas_compacted as <case>.bin + <case>.json at their console GPU virtual addresses.
6// `python -I tools/xdxr_bvh.py check-build <out dir>` validates them and traces rays against brute force (ctest: 9// `python -I tools/xdxr_bvh.py check-build <out dir>` validates them and traces rays against brute force (ctest:
7// d3d12_xdxr_rt + d3d12_xdxr_rt_check). Exit 77 without a Vulkan device, or with LEONIDA_RT_AS=khr. No game files. 10// d3d12_xdxr_rt + d3d12_xdxr_rt_check). Exit 77 without a Vulkan device, or with LEONIDA_RT_AS=khr. No game files.
8#include "../shims/d3d12_com.h" 11#include "../shims/d3d12_com.h"
@@ -153,6 +156,7 @@ int main(int argc, char** argv) {
153 156
154 D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS blas_inputs{}; 157 D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS blas_inputs{};
155 blas_inputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL; 158 blas_inputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL;
159 blas_inputs.Flags = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE; // updated below
156 blas_inputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; 160 blas_inputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY;
157 blas_inputs.NumDescs = 2; 161 blas_inputs.NumDescs = 2;
158 blas_inputs.pGeometryDescs = geometries; 162 blas_inputs.pGeometryDescs = geometries;
@@ -239,7 +243,7 @@ int main(int argc, char** argv) {
239 ID3D12CommandList* lists[] = {list.p}; 243 ID3D12CommandList* lists[] = {list.p};
240 queue->ExecuteCommandLists(1, lists); 244 queue->ExecuteCommandLists(1, lists);
241 if (FAILED(queue->Signal(fence.p, 1))) return fail("Signal"); 245 if (FAILED(queue->Signal(fence.p, 1))) return fail("Signal");
242 HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr); 246 HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr); // reused for the update below
243 const bool done = event && SUCCEEDED(fence->SetEventOnCompletion(1, event)) && 247 const bool done = event && SUCCEEDED(fence->SetEventOnCompletion(1, event)) &&
244 WaitForSingleObject(event, 10000) == WAIT_OBJECT_0; 248 WaitForSingleObject(event, 10000) == WAIT_OBJECT_0;
245 if (event) CloseHandle(event); 249 if (event) CloseHandle(event);
@@ -258,31 +262,35 @@ int main(int argc, char** argv) {
258 rb->Unmap(0, nullptr); 262 rb->Unmap(0, nullptr);
259 return ok; 263 return ok;
260 }; 264 };
261 std::string tris = "["; 265 // The BLAS's triangles as the reference sees them, for the soup's current positions.
262 bool first = true; 266 auto triangles_json = [&](const std::vector<float>& soup_now) {
263 auto add_tri = [&](const float v[3][3], int geometry, UINT primitive) { 267 std::string tris = "[";
264 tris += first ? "\n [" : ",\n ["; 268 bool first = true;
265 first = false; 269 auto add_tri = [&](const float v[3][3], int geometry, UINT primitive) {
266 for (int k = 0; k < 3; ++k) 270 tris += first ? "\n [" : ",\n [";
267 tris += (k ? ", [" : "[") + num(v[k][0]) + ", " + num(v[k][1]) + ", " + num(v[k][2]) + "]"; 271 first = false;
268 tris += ", " + std::to_string(geometry) + ", " + std::to_string(primitive) + "]"; 272 for (int k = 0; k < 3; ++k)
269 }; 273 tris += (k ? ", [" : "[") + num(v[k][0]) + ", " + num(v[k][1]) + ", " + num(v[k][2]) + "]";
270 for (UINT t = 0; t < soup_tris; ++t) { 274 tris += ", " + std::to_string(geometry) + ", " + std::to_string(primitive) + "]";
271 float v[3][3]; 275 };
272 for (int k = 0; k < 9; ++k) v[k / 3][k % 3] = soup[9 * t + k]; 276 for (UINT t = 0; t < soup_tris; ++t) {
273 add_tri(v, 0, t); 277 float v[3][3];
274 } 278 for (int k = 0; k < 9; ++k) v[k / 3][k % 3] = soup_now[9 * t + k];
275 for (UINT t = 0; t < indices.size() / 3; ++t) { 279 add_tri(v, 0, t);
276 float v[3][3];
277 for (int k = 0; k < 3; ++k) {
278 const float* p = &grid[4 * indices[3 * t + k]];
279 for (int r = 0; r < 3; ++r)
280 v[k][r] = transform[4 * r] * p[0] + transform[4 * r + 1] * p[1] + transform[4 * r + 2] * p[2] +
281 transform[4 * r + 3];
282 } 280 }
283 add_tri(v, 1, t); 281 for (UINT t = 0; t < indices.size() / 3; ++t) {
284 } 282 float v[3][3];
285 tris += "]"; 283 for (int k = 0; k < 3; ++k) {
284 const float* p = &grid[4 * indices[3 * t + k]];
285 for (int r = 0; r < 3; ++r)
286 v[k][r] = transform[4 * r] * p[0] + transform[4 * r + 1] * p[1] + transform[4 * r + 2] * p[2] +
287 transform[4 * r + 3];
288 }
289 add_tri(v, 1, t);
290 }
291 return tris + "]";
292 };
293 const std::string tris = triangles_json(soup);
286 if (!dump(blas_rb.p, blas_info.ResultDataMaxSizeInBytes, "d3d12_blas", 294 if (!dump(blas_rb.p, blas_info.ResultDataMaxSizeInBytes, "d3d12_blas",
287 "{\"kind\": \"blas\", \"address\": " + std::to_string(blas->GetGPUVirtualAddress()) + 295 "{\"kind\": \"blas\", \"address\": " + std::to_string(blas->GetGPUVirtualAddress()) +
288 ", \"triangles\": " + tris + "}\n")) 296 ", \"triangles\": " + tris + "}\n"))
@@ -298,6 +306,103 @@ int main(int argc, char** argv) {
298 "{\"kind\": \"tlas\", \"address\": " + std::to_string(tlas->GetGPUVirtualAddress()) + 306 "{\"kind\": \"tlas\", \"address\": " + std::to_string(tlas->GetGPUVirtualAddress()) +
299 ", \"bias\": 0, \"blas\": [\"d3d12_blas\"], \"instances\": " + inst + "}\n")) 307 ", \"bias\": 0, \"blas\": [\"d3d12_blas\"], \"instances\": " + inst + "}\n"))
300 return fail("TLAS readback"); 308 return fail("TLAS readback");
309
310 // ---- PERFORM_UPDATE in place: the soup moves (every vertex), the grid stays; the BLAS is refitted ----
311 std::vector<float> moved = soup;
312 std::uniform_real_distribution<float> nudge(-1.0f, 1.0f);
313 for (std::size_t v = 0; v < moved.size(); v += 3) {
314 moved[v] = moved[v] * 1.3f + nudge(rng);
315 moved[v + 1] = moved[v + 1] * 0.7f + nudge(rng);
316 moved[v + 2] += nudge(rng);
317 }
318 if (FAILED(upload->Map(0, nullptr, reinterpret_cast<void**>(&mapped)))) return fail("Map upload for the update");
319 std::memcpy(mapped + (soup_va - upload->GetGPUVirtualAddress()), moved.data(), std::size_t(soup_bytes));
320 upload->Unmap(0, nullptr);
321 if (FAILED(allocator->Reset()) || FAILED(list->Reset(allocator.p, nullptr))) return fail("Reset for the update");
322 build.Inputs = blas_inputs;
323 build.Inputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE;
324 build.DestAccelerationStructureData = blas->GetGPUVirtualAddress();
325 build.SourceAccelerationStructureData = blas->GetGPUVirtualAddress();
326 list->BuildRaytracingAccelerationStructure(&build, 0, nullptr);
327 list->ResourceBarrier(1, &barrier);
328 list->CopyBufferRegion(blas_rb.p, 0, blas.p, 0, blas_info.ResultDataMaxSizeInBytes);
329 if (FAILED(hr = list->Close())) return fail("Close (update)", hr);
330 queue->ExecuteCommandLists(1, lists);
331 if (FAILED(queue->Signal(fence.p, 2))) return fail("Signal (update)");
332 event = CreateEventW(nullptr, FALSE, FALSE, nullptr);
333 const bool updated = event && SUCCEEDED(fence->SetEventOnCompletion(2, event)) &&
334 WaitForSingleObject(event, 10000) == WAIT_OBJECT_0;
335 if (event) CloseHandle(event);
336 if (!updated) return fail("the update did not complete");
337 if (!dump(blas_rb.p, blas_info.ResultDataMaxSizeInBytes, "d3d12_blas_update",
338 "{\"kind\": \"blas\", \"address\": " + std::to_string(blas->GetGPUVirtualAddress()) +
339 ", \"triangles\": " + triangles_json(moved) + "}\n"))
340 return fail("BLAS readback after the update");
341
342 // ---- postbuild info and compaction: EmitRaytracingAccelerationStructurePostbuildInfo for both structures, a
343 // TLAS rebuild with a CURRENT_SIZE postbuild desc, then COMPACT the BLAS into a buffer of exactly its size ----
344 auto submit = [&](UINT64 value) {
345 if (FAILED(list->Close())) return false;
346 queue->ExecuteCommandLists(1, lists);
347 if (FAILED(queue->Signal(fence.p, value))) return false;
348 HANDLE e = CreateEventW(nullptr, FALSE, FALSE, nullptr);
349 const bool ok = e && SUCCEEDED(fence->SetEventOnCompletion(value, e)) &&
350 WaitForSingleObject(e, 10000) == WAIT_OBJECT_0;
351 if (e) CloseHandle(e);
352 return ok;
353 };
354 Ref<ID3D12Resource> info, info_rb;
355 if (FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_DEFAULT, 24, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, uav, info.put())) ||
356 FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_READBACK, 24, D3D12_RESOURCE_STATE_COPY_DEST,
357 D3D12_RESOURCE_FLAG_NONE, info_rb.put())))
358 return fail("postbuild buffers", hr);
359 if (FAILED(allocator->Reset()) || FAILED(list->Reset(allocator.p, nullptr))) return fail("Reset for postbuild");
360 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC compacted_desc{
361 info->GetGPUVirtualAddress(), D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE};
362 const D3D12_GPU_VIRTUAL_ADDRESS both[2] = {blas->GetGPUVirtualAddress(), tlas->GetGPUVirtualAddress()};
363 list->EmitRaytracingAccelerationStructurePostbuildInfo(&compacted_desc, 2, both);
364 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC current_desc{
365 info->GetGPUVirtualAddress() + 16, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE};
366 build = {};
367 build.Inputs = tlas_inputs;
368 build.DestAccelerationStructureData = tlas->GetGPUVirtualAddress();
369 build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress();
370 list->BuildRaytracingAccelerationStructure(&build, 1, &current_desc);
371 list->ResourceBarrier(1, &barrier);
372 list->CopyBufferRegion(info_rb.p, 0, info.p, 0, 24);
373 if (!submit(3)) return fail("postbuild submission");
374 UINT64 sizes[3] = {};
375 {
376 void* p = nullptr;
377 if (FAILED(info_rb->Map(0, nullptr, &p))) return fail("Map postbuild");
378 std::memcpy(sizes, p, sizeof sizes);
379 info_rb->Unmap(0, nullptr);
380 }
381 // the builds are exactly their prebuild size, so the compacted size is that size
382 if (sizes[0] != blas_info.ResultDataMaxSizeInBytes || sizes[1] != tlas_info.ResultDataMaxSizeInBytes ||
383 sizes[2] != tlas_info.ResultDataMaxSizeInBytes) {
384 std::fprintf(stderr, "postbuild sizes %llu %llu %llu, prebuild %llu %llu\n",
385 static_cast<unsigned long long>(sizes[0]), static_cast<unsigned long long>(sizes[1]),
386 static_cast<unsigned long long>(sizes[2]),
387 static_cast<unsigned long long>(blas_info.ResultDataMaxSizeInBytes),
388 static_cast<unsigned long long>(tlas_info.ResultDataMaxSizeInBytes));
389 return fail("postbuild sizes");
390 }
391 Ref<ID3D12Resource> compacted, compacted_rb;
392 if (FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_DEFAULT, sizes[0], as_state, uav, compacted.put())) ||
393 FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_READBACK, sizes[0], D3D12_RESOURCE_STATE_COPY_DEST,
394 D3D12_RESOURCE_FLAG_NONE, compacted_rb.put())))
395 return fail("compacted buffers", hr);
396 if (FAILED(allocator->Reset()) || FAILED(list->Reset(allocator.p, nullptr))) return fail("Reset for compaction");
397 list->CopyRaytracingAccelerationStructure(compacted->GetGPUVirtualAddress(), blas->GetGPUVirtualAddress(),
398 D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_COMPACT);
399 list->ResourceBarrier(1, &barrier);
400 list->CopyBufferRegion(compacted_rb.p, 0, compacted.p, 0, sizes[0]);
401 if (!submit(4)) return fail("compaction submission");
402 if (!dump(compacted_rb.p, sizes[0], "d3d12_blas_compacted",
403 "{\"kind\": \"blas\", \"address\": " + std::to_string(compacted->GetGPUVirtualAddress()) +
404 ", \"triangles\": " + triangles_json(moved) + "}\n"))
405 return fail("compacted BLAS readback");
301 std::printf("d3d12_xdxr_rt: BLAS %llu bytes (prebuild %llu), TLAS (prebuild %llu), written to %s\n", 406 std::printf("d3d12_xdxr_rt: BLAS %llu bytes (prebuild %llu), TLAS (prebuild %llu), written to %s\n",
302 static_cast<unsigned long long>(blas_info.ResultDataMaxSizeInBytes), 407 static_cast<unsigned long long>(blas_info.ResultDataMaxSizeInBytes),
303 static_cast<unsigned long long>(blas_info.ResultDataMaxSizeInBytes), 408 static_cast<unsigned long long>(blas_info.ResultDataMaxSizeInBytes),
diff --git a/runtime/test/descriptor_table_test.cpp b/runtime/test/descriptor_table_test.cpp
index a24a9c6e2..26fb39083 100644
--- a/runtime/test/descriptor_table_test.cpp
+++ b/runtime/test/descriptor_table_test.cpp
@@ -233,7 +233,7 @@ int test_clear_resets_table() {
233 return 0; 233 return 0;
234} 234}
235 235
236int test_erase_and_cluster_compact() { 236int test_erase_and_reinsert() {
237 DescriptorTable table(16); 237 DescriptorTable table(16);
238 238
239 const std::uint32_t k1[8] = {1, 10, 100, 1000, 2, 20, 200, 2000}; 239 const std::uint32_t k1[8] = {1, 10, 100, 1000, 2, 20, 200, 2000};
@@ -310,12 +310,12 @@ int test_change_tracking() {
310 EXPECT(!changes.all && changes.slots.size() == 1 && changes.slots.front() == slot); 310 EXPECT(!changes.all && changes.slots.size() == 1 && changes.slots.front() == slot);
311 EXPECT(table.read_slot(slot, read) && read[8] == 43); 311 EXPECT(table.read_slot(slot, read) && read[8] == 43);
312 312
313 // Erasing marks the slot it was in and the ones the cluster compaction moved. 313 // Erasing marks only the slot it was in: no other entry moves.
314 EXPECT(table.insert(k2, 7)); 314 EXPECT(table.insert(k2, 7));
315 table.take_changes(); 315 table.take_changes();
316 EXPECT(table.erase(k1)); 316 EXPECT(table.erase(k1));
317 changes = table.take_changes(); 317 changes = table.take_changes();
318 EXPECT(!changes.all && !changes.slots.empty() && changes.slots.front() == slot); 318 EXPECT(!changes.all && changes.slots.size() == 1 && changes.slots.front() == slot);
319 319
320 // Growth changes the mask, so everything re-uploads. 320 // Growth changes the mask, so everything re-uploads.
321 const std::size_t before = table.capacity(); 321 const std::size_t before = table.capacity();
@@ -366,6 +366,48 @@ int test_relocation_marks_both_slots() {
366 return 0; 366 return 0;
367} 367}
368 368
369// Shaders keep probing the GPU copy of the table while an erase is uploaded without waiting for idle
370// (BindlessSet::flush_needs_idle), so an erase must leave every other key's slot exactly as it was.
371int test_erase_moves_no_other_entry() {
372 DescriptorTable table(64);
373 const std::uint32_t slots = std::uint32_t(table.capacity());
374 // Five keys with one home: they fill five consecutive slots, the cluster the old erase compacted.
375 std::array<DescriptorKey, 5> keys{};
376 for (std::uint32_t i = 0; i < keys.size(); ++i) {
377 auto& key = keys[i];
378 key[0] = i + 1;
379 while ((hash_descriptor_key(key) & (slots - 1)) != slots - 2) ++key[7]; // the cluster wraps the end
380 EXPECT(table.insert_or_update(key.data(), 200 + i) == DescriptorTable::InsertResult::added);
381 }
382 table.take_changes();
383 const auto before = table.build_gpu_buffer();
384
385 EXPECT(table.erase(keys[1].data()));
386 const DescriptorTable::Changes changes = table.take_changes();
387 EXPECT(!changes.all && changes.slots.size() == 1);
388 const std::uint32_t hole = changes.slots.front();
389 const auto after = table.build_gpu_buffer();
390 for (std::uint32_t s = 0; s < slots; ++s) {
391 const bool same = std::memcmp(&before[1 + s * 10], &after[1 + s * 10], 10 * sizeof(std::uint32_t)) == 0;
392 EXPECT(same == (s != hole));
393 }
394 for (std::uint32_t w = 0; w < 10; ++w) EXPECT(after[1 + hole * 10 + w] == 0); // an empty slot: a miss
395 for (std::uint32_t i = 0; i < keys.size(); ++i) EXPECT(table.lookup(keys[i]) == (i == 1 ? 0u : 200 + i));
396
397 // Keys past the hole are still found after more erases, and a new key of the same home reuses the hole.
398 EXPECT(table.erase(keys[0].data()));
399 EXPECT(table.lookup(keys[4]) == 204 && table.lookup(keys[3]) == 203);
400 DescriptorKey extra = keys[0];
401 extra[0] = 100;
402 while ((hash_descriptor_key(extra) & (slots - 1)) != slots - 2) ++extra[7];
403 table.take_changes();
404 EXPECT(table.insert_or_update(extra.data(), 300) == DescriptorTable::InsertResult::added);
405 const DescriptorTable::Changes reuse = table.take_changes();
406 EXPECT(reuse.slots.size() == 1 && reuse.slots.front() == slots - 2); // the first hole of the probe window
407 EXPECT(table.lookup(extra) == 300 && table.size() == 4);
408 return 0;
409}
410
369int main() { 411int main() {
370 EXPECT(test_fnv1a_hash_matches_contract() == 0); 412 EXPECT(test_fnv1a_hash_matches_contract() == 0);
371 EXPECT(test_ssharp_key_padding() == 0); 413 EXPECT(test_ssharp_key_padding() == 0);
@@ -376,9 +418,10 @@ int main() {
376 EXPECT(test_gpu_buffer_serialization() == 0); 418 EXPECT(test_gpu_buffer_serialization() == 0);
377 EXPECT(test_change_tracking() == 0); 419 EXPECT(test_change_tracking() == 0);
378 EXPECT(test_relocation_marks_both_slots() == 0); 420 EXPECT(test_relocation_marks_both_slots() == 0);
421 EXPECT(test_erase_moves_no_other_entry() == 0);
379 EXPECT(test_multithreaded_insert_and_lookup() == 0); 422 EXPECT(test_multithreaded_insert_and_lookup() == 0);
380 EXPECT(test_clear_resets_table() == 0); 423 EXPECT(test_clear_resets_table() == 0);
381 EXPECT(test_erase_and_cluster_compact() == 0); 424 EXPECT(test_erase_and_reinsert() == 0);
382 425
383 std::printf("descriptor_table_test: all tests passed (0 failures)\n"); 426 std::printf("descriptor_table_test: all tests passed (0 failures)\n");
384 return 0; 427 return 0;
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp
index e414f155b..70cae9a89 100644
--- a/runtime/test/device_proxy_test.cpp
+++ b/runtime/test/device_proxy_test.cpp
@@ -151,19 +151,19 @@ int main() {
151 unsigned slots = rt::d3d12_xs::device_proxy_slot_count(device.Get()); 151 unsigned slots = rt::d3d12_xs::device_proxy_slot_count(device.Get());
152 std::printf("proxy forwards %u PC vtable slots (ID3D12Device..Device14 max is 83)\n", slots); 152 std::printf("proxy forwards %u PC vtable slots (ID3D12Device..Device14 max is 83)\n", slots);
153 check(slots >= 44, "proxy forwards at least the base ID3D12Device vtable"); 153 check(slots >= 44, "proxy forwards at least the base ID3D12Device vtable");
154 check(!rt::d3d12_xs::device_slot_overridden(9), "device slot 9 is forwarded (PC CreateCommandAllocator)"); 154 check(rt::d3d12_xs::device_slot_overridden(9), "device slot 9 is CreateCommandAllocator (allocator proxies)");
155 check(!rt::d3d12_xs::device_slot_overridden(10), "device slot 10 is forwarded (PC CreateGraphicsPipelineState)"); 155 check(!rt::d3d12_xs::device_slot_overridden(10), "device slot 10 is forwarded (PC CreateGraphicsPipelineState)");
156 check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); 156 check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override");
157 check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); 157 check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override");
158 check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); 158 check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override");
159 check(rt::d3d12_xs::device_slot_overridden(67), 159 check(rt::d3d12_xs::device_slot_overridden(67),
160 "device slot 67 is refused (console DeserializeComputePipelineStateX, " 160 "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)");
161 "not PC CreateProtectedResourceSession1)");
162 161
163 void** proxy_vtbl = *reinterpret_cast<void***>(device.Get()); 162 void** proxy_vtbl = *reinterpret_cast<void***>(device.Get());
164 void** real_vtbl = real ? *reinterpret_cast<void***>(real) : nullptr; 163 void** real_vtbl = real ? *reinterpret_cast<void***>(real) : nullptr;
165 check(proxy_vtbl != nullptr && proxy_vtbl[14] != real_vtbl[14], "slot 14 thunk differs from the PC entry"); 164 check(proxy_vtbl != nullptr && proxy_vtbl[14] != real_vtbl[14], "slot 14 thunk differs from the PC entry");
166 if (slots > 62) check(proxy_vtbl[62] != real_vtbl[62], "slot 62 thunk differs from PC CreateStateObject"); 165 if (slots > 62) check(proxy_vtbl[62] != real_vtbl[62], "slot 62 thunk differs from PC CreateStateObject");
166 if (slots > 67) check(proxy_vtbl[67] != real_vtbl[67], "slot 67 thunk differs from PC CreateProtectedResourceSession1");
167 if (slots > 76) check(proxy_vtbl[76] != real_vtbl[76], "slot 76 thunk differs from PC CreateCommittedResource3"); 167 if (slots > 76) check(proxy_vtbl[76] != real_vtbl[76], "slot 76 thunk differs from PC CreateCommittedResource3");
168 168
169 rt::d3d12_xs::reset_device_proxy_stats(); 169 rt::d3d12_xs::reset_device_proxy_stats();
@@ -278,6 +278,8 @@ int main() {
278 ComPtr<ID3D12CommandAllocator> allocator; 278 ComPtr<ID3D12CommandAllocator> allocator;
279 hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(allocator.GetAddressOf())); 279 hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(allocator.GetAddressOf()));
280 check(SUCCEEDED(hr) && allocator != nullptr, "device slot 9 forwards CreateCommandAllocator"); 280 check(SUCCEEDED(hr) && allocator != nullptr, "device slot 9 forwards CreateCommandAllocator");
281 // A PC runtime allocator is not wrapped: the PC runtime's lists could not resolve an allocator proxy.
282 check(!rt::d3d12_xs::is_allocator_proxy(allocator.Get()), "slot 9 hands out the PC allocator unwrapped");
281 check(rt::d3d12_xs::device_slot_hits(9) == 1, "slot 9 hit counter is 1"); 283 check(rt::d3d12_xs::device_slot_hits(9) == 1, "slot 9 hit counter is 1");
282 284
283 // Slot 76: buffer resource with the measured Xbox layout word 0x101; PC committed resources take ROW_MAJOR. 285 // Slot 76: buffer resource with the measured Xbox layout word 0x101; PC committed resources take ROW_MAJOR.
@@ -342,6 +344,31 @@ int main() {
342 check(SUCCEEDED(hr) && pso != nullptr, "slot 62 creates a compute PSO via CreateComputePipelineState"); 344 check(SUCCEEDED(hr) && pso != nullptr, "slot 62 creates a compute PSO via CreateComputePipelineState");
343 check(rt::d3d12_xs::device_slot_hits(62) == 1, "slot 62 hit counter is 1"); 345 check(rt::d3d12_xs::device_slot_hits(62) == 1, "slot 62 hit counter is 1");
344 check(rt::d3d12_xs::device_slot_first_call_seen(62), "slot 62 first-call flag is set"); 346 check(rt::d3d12_xs::device_slot_first_call_seen(62), "slot 62 first-call flag is set");
347
348 // Slot 67: Xbox native compute pipeline creation. Maps the console descriptor (+0x00 root signature,
349 // +0x28 kind 6 code blob, +0x30 code size) to D3D12_COMPUTE_PIPELINE_STATE_DESC and calls CreateComputePipelineState.
350 struct XboxNativeComputeDesc {
351 ID3D12RootSignature* root_signature;
352 const void* kind0;
353 std::uint64_t kind0_size;
354 const void* kind1;
355 std::uint64_t kind1_size;
356 const void* kind6;
357 std::uint64_t kind6_size;
358 const void* kind7;
359 std::uint64_t kind7_size;
360 } xbox_desc{};
361 xbox_desc.root_signature = root_signature.Get();
362 xbox_desc.kind6 = bytecode->GetBufferPointer();
363 xbox_desc.kind6_size = bytecode->GetBufferSize();
364
365 using XboxCreateNativeComputePsoFn = HRESULT(WINAPI*)(void*, const void*, const IID*, void**);
366 auto create_native_pso = reinterpret_cast<XboxCreateNativeComputePsoFn>(proxy_vtbl[67]);
367 ComPtr<ID3D12PipelineState> pso67;
368 hr = create_native_pso(device.Get(), &xbox_desc, &iid_pso, reinterpret_cast<void**>(pso67.GetAddressOf()));
369 check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState");
370 check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1");
371 check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set");
345 } 372 }
346 373
347 // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, 374 // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions,
@@ -357,6 +384,14 @@ int main() {
357 D3D12_COMPUTE_PIPELINE_STATE_DESC empty_pso{}; 384 D3D12_COMPUTE_PIPELINE_STATE_DESC empty_pso{};
358 hr = reinterpret_cast<Slot62Fn>(proxy_vtbl[62])(device.Get(), &empty_pso, 0, 0, nullptr, &proxy_out); 385 hr = reinterpret_cast<Slot62Fn>(proxy_vtbl[62])(device.Get(), &empty_pso, 0, 0, nullptr, &proxy_out);
359 check(FAILED(hr) && proxy_out == nullptr, "slot 62 nulls its output for a null IID"); 386 check(FAILED(hr) && proxy_out == nullptr, "slot 62 nulls its output for a null IID");
387 using Slot67Fn = HRESULT(WINAPI*)(void*, const void*, const IID*, void**);
388 proxy_out = reinterpret_cast<void*>(0x1111);
389 const IID iid_pso = __uuidof(ID3D12PipelineState);
390 hr = reinterpret_cast<Slot67Fn>(proxy_vtbl[67])(device.Get(), nullptr, &iid_pso, &proxy_out);
391 check(FAILED(hr) && proxy_out == nullptr, "slot 67 nulls its output for a null description");
392 proxy_out = reinterpret_cast<void*>(0x1111);
393 hr = reinterpret_cast<Slot67Fn>(proxy_vtbl[67])(device.Get(), &root_desc, nullptr, &proxy_out);
394 check(FAILED(hr) && proxy_out == nullptr, "slot 67 nulls its output for a null IID");
360 using Slot76Fn = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, 395 using Slot76Fn = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS,
361 const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES, 396 const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES,
362 const D3D12_CLEAR_VALUE*, const IID*, void**); 397 const D3D12_CLEAR_VALUE*, const IID*, void**);
diff --git a/runtime/test/dxgi_swapchain_test.cpp b/runtime/test/dxgi_swapchain_test.cpp
index 3b23b3579..c22397d90 100644
--- a/runtime/test/dxgi_swapchain_test.cpp
+++ b/runtime/test/dxgi_swapchain_test.cpp
@@ -276,6 +276,18 @@ int main() {
276 scd.BufferCount = 2; 276 scd.BufferCount = 2;
277 scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; 277 scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
278 278
279 for (const UINT count : {0u, 1u, DXGI_MAX_SWAP_CHAIN_BUFFERS + 1u}) {
280 DXGI_SWAP_CHAIN_DESC1 invalid = scd;
281 invalid.BufferCount = count;
282 IDXGISwapChain1* rejected = nullptr;
283 const HRESULT hr = factory->CreateSwapChainForHwnd(queue, hwnd, &invalid, nullptr, nullptr, &rejected);
284 if (rejected) {
285 rejected->Release();
286 return fail("CreateSwapChainForHwnd returned a swapchain for an invalid buffer count");
287 }
288 if (hr != DXGI_ERROR_INVALID_CALL) return fail("CreateSwapChainForHwnd invalid buffer count HRESULT");
289 }
290
279 IDXGISwapChain1* sc1 = nullptr; 291 IDXGISwapChain1* sc1 = nullptr;
280 if (FAILED(factory->CreateSwapChainForHwnd(queue, hwnd, &scd, nullptr, nullptr, &sc1)) || !sc1) 292 if (FAILED(factory->CreateSwapChainForHwnd(queue, hwnd, &scd, nullptr, nullptr, &sc1)) || !sc1)
281 return fail("CreateSwapChainForHwnd"); 293 return fail("CreateSwapChainForHwnd");
@@ -421,12 +433,34 @@ int main() {
421 return 0; 433 return 0;
422 }; 434 };
423 435
436 // Invalid counts must leave the initial back buffers usable for the first frame.
437 {
438 DXGI_SWAP_CHAIN_DESC1 before_resize{};
439 if (FAILED(sc->GetDesc1(&before_resize))) return fail("GetDesc1 before invalid resizes");
440 const std::vector<UINT> node_masks(DXGI_MAX_SWAP_CHAIN_BUFFERS + 1, 1);
441 const std::vector<IUnknown*> present_queues(DXGI_MAX_SWAP_CHAIN_BUFFERS + 1, queue);
442 for (const UINT count : {1u, DXGI_MAX_SWAP_CHAIN_BUFFERS + 1u}) {
443 if (sc->ResizeBuffers(count, 64, 64, DXGI_FORMAT_UNKNOWN, 0) != E_INVALIDARG)
444 return fail("ResizeBuffers invalid buffer count HRESULT");
445 if (sc->ResizeBuffers1(count, 64, 64, DXGI_FORMAT_UNKNOWN, 0, node_masks.data(), present_queues.data()) !=
446 E_INVALIDARG)
447 return fail("ResizeBuffers1 invalid buffer count HRESULT");
448 }
449 DXGI_SWAP_CHAIN_DESC1 after_resize{};
450 if (FAILED(sc->GetDesc1(&after_resize)) || after_resize.BufferCount != before_resize.BufferCount ||
451 after_resize.Width != before_resize.Width || after_resize.Height != before_resize.Height)
452 return fail("Invalid resize changed swapchain buffers");
453 }
454
424 // Frame 1: 128x128 clear to (64, 128, 255, 255), read back all 16,384 pixels, Present. 455 // Frame 1: 128x128 clear to (64, 128, 255, 255), read back all 16,384 pixels, Present.
425 const float blue_ish[4] = {64.0f / 255.0f, 128.0f / 255.0f, 1.0f, 1.0f}; 456 const float blue_ish[4] = {64.0f / 255.0f, 128.0f / 255.0f, 1.0f, 1.0f};
426 if (run_clear_readback_present(128, 128, blue_ish, 64, 128, 255) != 0) return 1; 457 if (run_clear_readback_present(128, 128, blue_ish, 64, 128, 255) != 0) return 1;
427 458
428 // Frame 2: ResizeBuffers to explicit 37x19 on the unchanged 128x128 HWND, clear to green, read back all 703 pixels, Present. 459 // Frame 2: ResizeBuffers to explicit 37x19 on the unchanged 128x128 HWND, clear to green, read back all 703 pixels, Present.
429 if (FAILED(sc->ResizeBuffers(2, 37, 19, DXGI_FORMAT_UNKNOWN, 0))) return fail("ResizeBuffers"); 460 if (FAILED(sc->ResizeBuffers(2, 37, 19, DXGI_FORMAT_UNKNOWN, 0))) return fail("ResizeBuffers");
461 DXGI_SWAP_CHAIN_DESC1 preserved_format{};
462 if (FAILED(sc->GetDesc1(&preserved_format)) || preserved_format.Format != scd.Format)
463 return fail("ResizeBuffers with DXGI_FORMAT_UNKNOWN changed the format");
430 const float green[4] = {0.0f, 1.0f, 0.0f, 1.0f}; 464 const float green[4] = {0.0f, 1.0f, 0.0f, 1.0f};
431 if (run_clear_readback_present(37, 19, green, 0, 255, 0) != 0) return 1; 465 if (run_clear_readback_present(37, 19, green, 0, 255, 0) != 0) return 1;
432 466
@@ -587,9 +621,28 @@ int main() {
587 return fail("GetRotation(nullptr) should return E_INVALIDARG"); 621 return fail("GetRotation(nullptr) should return E_INVALIDARG");
588 } 622 }
589 623
590 // Unsupported swapchain format must fail explicitly instead of silently downgrading to BGRA8. 624 constexpr DXGI_FORMAT invalid_formats[] = {
591 if (sc->ResizeBuffers(2, 37, 19, DXGI_FORMAT_R32_UINT, 0) != DXGI_ERROR_UNSUPPORTED) 625 DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
592 return fail("ResizeBuffers should reject unsupported format DXGI_FORMAT_R32_UINT"); 626 DXGI_FORMAT_R8G8B8A8_TYPELESS, DXGI_FORMAT_R32_UINT,
627 };
628 {
629 DXGI_SWAP_CHAIN_DESC1 before{}, after{};
630 if (FAILED(sc->GetDesc1(&before))) return fail("GetDesc1 before invalid formats");
631 const UINT node_masks[2] = {1, 1};
632 IUnknown* const present_queues[2] = {queue, queue};
633 for (DXGI_FORMAT format : invalid_formats) {
634 if (sc->ResizeBuffers(2, 64, 64, format, 0) != E_INVALIDARG ||
635 sc->ResizeBuffers1(2, 64, 64, format, 0, node_masks, present_queues) != E_INVALIDARG)
636 return fail("ResizeBuffers and ResizeBuffers1 should reject invalid flip-model formats");
637 }
638 if (FAILED(sc->GetDesc1(&after)) || after.Format != before.Format || after.BufferCount != before.BufferCount ||
639 after.Width != before.Width || after.Height != before.Height)
640 return fail("Invalid format changed the existing swapchain");
641 ID3D12Resource* buffer = nullptr;
642 if (FAILED(sc->GetBuffer(sc->GetCurrentBackBufferIndex(), IID_PPV_ARGS(&buffer))) || !buffer)
643 return fail("GetBuffer after invalid swapchain formats");
644 buffer->Release();
645 }
593 646
594 // Measured on host DXGI (RTX 5070 and WARP): DXGI_PRESENT_TEST returns S_OK without presenting, so the back 647 // Measured on host DXGI (RTX 5070 and WARP): DXGI_PRESENT_TEST returns S_OK without presenting, so the back
595 // buffer index and last present count stay; a sync interval above 4 is DXGI_ERROR_INVALID_CALL and presents nothing. 648 // buffer index and last present count stay; a sync interval above 4 is DXGI_ERROR_INVALID_CALL and presents nothing.
@@ -747,6 +800,8 @@ int main() {
747 // Zero width or height means the window's client area, in ResizeBuffers (the usual WM_SIZE call) and at 800 // Zero width or height means the window's client area, in ResizeBuffers (the usual WM_SIZE call) and at
748 // creation; host DXGI: ResizeBuffers(0, 0, 0) after resizing the window gives the new client size. 801 // creation; host DXGI: ResizeBuffers(0, 0, 0) after resizing the window gives the new client size.
749 { 802 {
803 DXGI_SWAP_CHAIN_DESC1 before_zero{};
804 if (FAILED(sc->GetDesc1(&before_zero))) return fail("GetDesc1 before zero-count resize");
750 RECT wr{0, 0, 300, 200}; 805 RECT wr{0, 0, 300, 200};
751 AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); 806 AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
752 SetWindowPos(hwnd, nullptr, 0, 0, wr.right - wr.left, wr.bottom - wr.top, SWP_NOMOVE | SWP_NOZORDER); 807 SetWindowPos(hwnd, nullptr, 0, 0, wr.right - wr.left, wr.bottom - wr.top, SWP_NOMOVE | SWP_NOZORDER);
@@ -754,7 +809,8 @@ int main() {
754 GetClientRect(hwnd, &cr); 809 GetClientRect(hwnd, &cr);
755 if (FAILED(sc->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0))) return fail("ResizeBuffers(0, 0, 0)"); 810 if (FAILED(sc->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0))) return fail("ResizeBuffers(0, 0, 0)");
756 DXGI_SWAP_CHAIN_DESC1 d{}; 811 DXGI_SWAP_CHAIN_DESC1 d{};
757 sc->GetDesc1(&d); 812 if (FAILED(sc->GetDesc1(&d)) || d.BufferCount != before_zero.BufferCount)
813 return fail("ResizeBuffers(0, 0, 0) changed the buffer count");
758 if (d.Width != UINT(cr.right) || d.Height != UINT(cr.bottom)) { 814 if (d.Width != UINT(cr.right) || d.Height != UINT(cr.bottom)) {
759 std::fprintf(stderr, "FAIL: ResizeBuffers(0, 0, 0) gave %ux%u, client area is %ldx%ld\n", d.Width, d.Height, 815 std::fprintf(stderr, "FAIL: ResizeBuffers(0, 0, 0) gave %ux%u, client area is %ldx%ld\n", d.Width, d.Height,
760 cr.right, cr.bottom); 816 cr.right, cr.bottom);
@@ -764,6 +820,21 @@ int main() {
764 HWND hwnd2 = create_test_window(200, 150); 820 HWND hwnd2 = create_test_window(200, 150);
765 if (!hwnd2) return fail("CreateWindowExW (second)"); 821 if (!hwnd2) return fail("CreateWindowExW (second)");
766 GetClientRect(hwnd2, &cr); 822 GetClientRect(hwnd2, &cr);
823 const auto rejects_creation_format = [&](DXGI_FORMAT format) {
824 DXGI_SWAP_CHAIN_DESC1 invalid = scd;
825 invalid.Format = format;
826 IDXGISwapChain1* rejected = nullptr;
827 const HRESULT hr = factory->CreateSwapChainForHwnd(queue, hwnd2, &invalid, nullptr, nullptr, &rejected);
828 if (rejected) {
829 rejected->Release();
830 return false;
831 }
832 return hr == DXGI_ERROR_INVALID_CALL;
833 };
834 if (!rejects_creation_format(DXGI_FORMAT_UNKNOWN))
835 return fail("CreateSwapChainForHwnd accepted DXGI_FORMAT_UNKNOWN");
836 for (DXGI_FORMAT format : invalid_formats)
837 if (!rejects_creation_format(format)) return fail("CreateSwapChainForHwnd invalid flip-model format");
767 DXGI_SWAP_CHAIN_DESC1 zd = scd; 838 DXGI_SWAP_CHAIN_DESC1 zd = scd;
768 zd.Width = 0; 839 zd.Width = 0;
769 zd.Height = 0; 840 zd.Height = 0;
@@ -794,11 +865,31 @@ int main() {
794 return fail("CheckFeatureSupport should reject null data or wrong size with E_INVALIDARG"); 865 return fail("CheckFeatureSupport should reject null data or wrong size with E_INVALIDARG");
795 factory5->Release(); 866 factory5->Release();
796 867
868 constexpr UINT tearing_flag = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
869 constexpr UINT waitable_flag = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
870 constexpr UINT both_flags = tearing_flag | waitable_flag;
871 const UINT node_masks[2] = {1, 1};
872 IUnknown* const present_queues[2] = {queue, queue};
873 const auto rejects_flag_change = [&](IDXGISwapChain3* chain, UINT flags) {
874 DXGI_SWAP_CHAIN_DESC1 before{}, after{};
875 if (FAILED(chain->GetDesc1(&before))) return false;
876 const UINT width = before.Width + 1;
877 return chain->ResizeBuffers(0, width, before.Height, DXGI_FORMAT_UNKNOWN, flags) == E_INVALIDARG &&
878 chain->ResizeBuffers1(2, width, before.Height, DXGI_FORMAT_UNKNOWN, flags,
879 node_masks, present_queues) == E_INVALIDARG &&
880 SUCCEEDED(chain->GetDesc1(&after)) && after.Flags == before.Flags &&
881 after.BufferCount == before.BufferCount && after.Width == before.Width &&
882 after.Height == before.Height;
883 };
884
797 // Non-waitable, non-tearing swapchain: GetFrameLatencyWaitableObject is null and ALLOW_TEARING is rejected. 885 // Non-waitable, non-tearing swapchain: GetFrameLatencyWaitableObject is null and ALLOW_TEARING is rejected.
886 for (UINT flags : {waitable_flag, tearing_flag, both_flags})
887 if (!rejects_flag_change(sc, flags)) return fail("Resize accepted adding a creation-only flag");
798 if (sc->GetFrameLatencyWaitableObject() != nullptr) 888 if (sc->GetFrameLatencyWaitableObject() != nullptr)
799 return fail("Non-waitable swapchain should return nullptr from GetFrameLatencyWaitableObject"); 889 return fail("Non-waitable swapchain should return nullptr from GetFrameLatencyWaitableObject");
800 if (sc->Present(0, DXGI_PRESENT_ALLOW_TEARING) != DXGI_ERROR_INVALID_CALL) 890 if (sc->Present(0, DXGI_PRESENT_ALLOW_TEARING) != DXGI_ERROR_INVALID_CALL)
801 return fail("Present(ALLOW_TEARING) on non-tearing swapchain should return DXGI_ERROR_INVALID_CALL"); 891 return fail("Present(ALLOW_TEARING) on non-tearing swapchain should return DXGI_ERROR_INVALID_CALL");
892 if (FAILED(sc->Present(0, 0))) return fail("Present after rejected resize on a plain swapchain");
802 893
803 HWND hwnd3 = create_test_window(128, 96); 894 HWND hwnd3 = create_test_window(128, 96);
804 if (!hwnd3) return fail("CreateWindowExW (third)"); 895 if (!hwnd3) return fail("CreateWindowExW (third)");
@@ -806,7 +897,7 @@ int main() {
806 wdesc.Width = 128; 897 wdesc.Width = 128;
807 wdesc.Height = 96; 898 wdesc.Height = 96;
808 wdesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; // also tests presenting an untouched offscreen backbuffer 899 wdesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; // also tests presenting an untouched offscreen backbuffer
809 wdesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; 900 wdesc.Flags = both_flags;
810 IDXGISwapChain1* wsc1 = nullptr; 901 IDXGISwapChain1* wsc1 = nullptr;
811 if (FAILED(factory->CreateSwapChainForHwnd(queue, hwnd3, &wdesc, nullptr, nullptr, &wsc1)) || !wsc1) 902 if (FAILED(factory->CreateSwapChainForHwnd(queue, hwnd3, &wdesc, nullptr, nullptr, &wsc1)) || !wsc1)
812 return fail("CreateSwapChainForHwnd (tearing + waitable)"); 903 return fail("CreateSwapChainForHwnd (tearing + waitable)");
@@ -814,6 +905,8 @@ int main() {
814 if (FAILED(wsc1->QueryInterface(IID_PPV_ARGS(&wsc))) || !wsc) return fail("QI IDXGISwapChain3 (waitable)"); 905 if (FAILED(wsc1->QueryInterface(IID_PPV_ARGS(&wsc))) || !wsc) return fail("QI IDXGISwapChain3 (waitable)");
815 wsc1->Release(); 906 wsc1->Release();
816 907
908 for (UINT flags : {0u, waitable_flag, tearing_flag})
909 if (!rejects_flag_change(wsc, flags)) return fail("Resize accepted removing a creation-only flag");
817 DXGI_SWAP_CHAIN_DESC1 got_desc{}; 910 DXGI_SWAP_CHAIN_DESC1 got_desc{};
818 if (FAILED(wsc->GetDesc1(&got_desc)) || got_desc.Flags != wdesc.Flags) 911 if (FAILED(wsc->GetDesc1(&got_desc)) || got_desc.Flags != wdesc.Flags)
819 return fail("Waitable swapchain GetDesc1 did not preserve Flags"); 912 return fail("Waitable swapchain GetDesc1 did not preserve Flags");
@@ -836,11 +929,131 @@ int main() {
836 if (!check_statistics_disjoint(wsc)) return fail("first statistics query after Present should be disjoint"); 929 if (!check_statistics_disjoint(wsc)) return fail("first statistics query after Present should be disjoint");
837 if (WaitForSingleObject(waitable, 5000) != WAIT_OBJECT_0) 930 if (WaitForSingleObject(waitable, 5000) != WAIT_OBJECT_0)
838 return fail("Post-Present WaitForSingleObject on waitable swapchain failed"); 931 return fail("Post-Present WaitForSingleObject on waitable swapchain failed");
932 if (FAILED(wsc->ResizeBuffers(0, wdesc.Width + 1, wdesc.Height, DXGI_FORMAT_UNKNOWN, both_flags)) ||
933 FAILED(wsc->GetDesc1(&got_desc)) || got_desc.Width != wdesc.Width + 1 || got_desc.Flags != both_flags)
934 return fail("ResizeBuffers with matching creation flags failed");
935 if (FAILED(wsc->Present(0, DXGI_PRESENT_ALLOW_TEARING)) ||
936 WaitForSingleObject(waitable, 5000) != WAIT_OBJECT_0)
937 return fail("Present or wait after resizing the waitable swapchain failed");
839 CloseHandle(waitable); 938 CloseHandle(waitable);
840 wsc->Release(); 939 wsc->Release();
841 DestroyWindow(hwnd3); 940 DestroyWindow(hwnd3);
842 } 941 }
843 942
943 // CreateSwapChainForCoreWindow & Occlusion status registration
944 {
945 // 1. Parameter validation
946 IDXGISwapChain1* sc_dummy = nullptr;
947 if (factory->CreateSwapChainForCoreWindow(queue, nullptr, &scd, nullptr, &sc_dummy) != E_INVALIDARG)
948 return fail("CreateSwapChainForCoreWindow(null window) should return E_INVALIDARG");
949 if (factory->CreateSwapChainForCoreWindow(nullptr, queue, &scd, nullptr, &sc_dummy) != E_INVALIDARG)
950 return fail("CreateSwapChainForCoreWindow(null device) should return E_INVALIDARG");
951 if (factory->CreateSwapChainForCoreWindow(queue, queue, nullptr, nullptr, &sc_dummy) != E_INVALIDARG)
952 return fail("CreateSwapChainForCoreWindow(null desc) should return E_INVALIDARG");
953 if (factory->CreateSwapChainForCoreWindow(queue, queue, &scd, nullptr, nullptr) != E_POINTER)
954 return fail("CreateSwapChainForCoreWindow(null out) should return E_POINTER");
955
956 // Non-CoreWindow IUnknown
957 if (factory->CreateSwapChainForCoreWindow(queue, queue, &scd, nullptr, &sc_dummy) != DXGI_ERROR_INVALID_CALL)
958 return fail("CreateSwapChainForCoreWindow with non-CoreWindow should return DXGI_ERROR_INVALID_CALL");
959
960 // 2. Mock ICoreWindow with ICoreWindowInterop
961 static constexpr GUID kIID_ICoreWindowInterop = {
962 0x45D64A29, 0xA63E, 0x4CB6, {0xB4, 0x98, 0x57, 0x81, 0xD2, 0x98, 0xCB, 0x4F}};
963 struct MockCoreWindow final : public IUnknown {
964 HWND window_handle = nullptr;
965 std::atomic<ULONG> refs{1};
966
967 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** out) override {
968 if (!out) return E_POINTER;
969 if (riid == IID_IUnknown || riid == kIID_ICoreWindowInterop) {
970 *out = this;
971 AddRef();
972 return S_OK;
973 }
974 *out = nullptr;
975 return E_NOINTERFACE;
976 }
977 ULONG STDMETHODCALLTYPE AddRef() override { return ++refs; }
978 ULONG STDMETHODCALLTYPE Release() override {
979 ULONG r = --refs;
980 if (!r) delete this;
981 return r;
982 }
983 virtual HRESULT STDMETHODCALLTYPE get_WindowHandle(HWND* hwnd) {
984 if (!hwnd) return E_POINTER;
985 *hwnd = window_handle;
986 return S_OK;
987 }
988 virtual HRESULT STDMETHODCALLTYPE put_MessageHandled(unsigned char) { return S_OK; }
989 };
990
991 auto* mock_cw = new MockCoreWindow();
992 // Null HWND in interop
993 if (factory->CreateSwapChainForCoreWindow(queue, mock_cw, &scd, nullptr, &sc_dummy) != DXGI_ERROR_INVALID_CALL) {
994 mock_cw->Release();
995 return fail("CreateSwapChainForCoreWindow with null HWND should return DXGI_ERROR_INVALID_CALL");
996 }
997
998 // Valid HWND in mock CoreWindow
999 HWND hwnd4 = create_test_window(160, 120);
1000 if (!hwnd4) {
1001 mock_cw->Release();
1002 return fail("CreateWindowExW (fourth)");
1003 }
1004 mock_cw->window_handle = hwnd4;
1005 IDXGISwapChain1* cw_sc1 = nullptr;
1006 if (FAILED(factory->CreateSwapChainForCoreWindow(queue, mock_cw, &scd, nullptr, &cw_sc1)) || !cw_sc1) {
1007 mock_cw->Release();
1008 DestroyWindow(hwnd4);
1009 return fail("CreateSwapChainForCoreWindow with valid MockCoreWindow failed");
1010 }
1011 IDXGISwapChain3* cw_sc = nullptr;
1012 if (FAILED(cw_sc1->QueryInterface(IID_PPV_ARGS(&cw_sc))) || !cw_sc) {
1013 cw_sc1->Release();
1014 mock_cw->Release();
1015 DestroyWindow(hwnd4);
1016 return fail("QI IDXGISwapChain3 on CoreWindow swapchain failed");
1017 }
1018 cw_sc1->Release();
1019 DXGI_SWAP_CHAIN_DESC1 cw_desc{};
1020 if (FAILED(cw_sc->GetDesc1(&cw_desc)) || cw_desc.Width != scd.Width || cw_desc.Height != scd.Height) {
1021 cw_sc->Release();
1022 mock_cw->Release();
1023 DestroyWindow(hwnd4);
1024 return fail("GetDesc1 on CoreWindow swapchain mismatch");
1025 }
1026 if (FAILED(cw_sc->Present(0, 0))) {
1027 cw_sc->Release();
1028 mock_cw->Release();
1029 DestroyWindow(hwnd4);
1030 return fail("Present on CoreWindow swapchain failed");
1031 }
1032 cw_sc->Release();
1033 mock_cw->Release();
1034 DestroyWindow(hwnd4);
1035
1036 // 3. Occlusion status registration
1037 DWORD cookie1 = 0, cookie2 = 0;
1038 if (factory->RegisterOcclusionStatusWindow(nullptr, WM_USER, &cookie1) != DXGI_ERROR_INVALID_CALL)
1039 return fail("RegisterOcclusionStatusWindow(null hwnd) should return DXGI_ERROR_INVALID_CALL");
1040 if (factory->RegisterOcclusionStatusWindow(hwnd, WM_USER, nullptr) != DXGI_ERROR_INVALID_CALL)
1041 return fail("RegisterOcclusionStatusWindow(null cookie) should return DXGI_ERROR_INVALID_CALL");
1042 if (FAILED(factory->RegisterOcclusionStatusWindow(hwnd, WM_USER, &cookie1)) || cookie1 == 0)
1043 return fail("RegisterOcclusionStatusWindow failed");
1044
1045 HANDLE ev = CreateEventW(nullptr, FALSE, FALSE, nullptr);
1046 if (factory->RegisterOcclusionStatusEvent(nullptr, &cookie2) != DXGI_ERROR_INVALID_CALL)
1047 return fail("RegisterOcclusionStatusEvent(null event) should return DXGI_ERROR_INVALID_CALL");
1048 if (factory->RegisterOcclusionStatusEvent(ev, nullptr) != DXGI_ERROR_INVALID_CALL)
1049 return fail("RegisterOcclusionStatusEvent(null cookie) should return DXGI_ERROR_INVALID_CALL");
1050 if (FAILED(factory->RegisterOcclusionStatusEvent(ev, &cookie2)) || cookie2 == 0 || cookie2 == cookie1)
1051 return fail("RegisterOcclusionStatusEvent failed or duplicated cookie");
1052 factory->UnregisterOcclusionStatus(cookie1);
1053 factory->UnregisterOcclusionStatus(cookie2);
1054 CloseHandle(ev);
1055 }
1056
844 rtv_heap->Release(); 1057 rtv_heap->Release();
845 sc->Release(); 1058 sc->Release();
846 fence->Release(); 1059 fence->Release();
@@ -860,7 +1073,7 @@ int main() {
860 return 1; 1073 return 1;
861 } 1074 }
862 std::printf("device: %s (validation %s)\n", chosen.deviceName, val_active ? "on" : "off"); 1075 std::printf("device: %s (validation %s)\n", chosen.deviceName, val_active ? "on" : "off");
863 std::printf("dxgi_swapchain_test: PASS (CreateSwapChainForHwnd, GetBuffer+GetDesc, clear+readback, Present, " 1076 std::printf("dxgi_swapchain_test: PASS (CreateSwapChainForHwnd, CreateSwapChainForCoreWindow, occlusion status, "
864 "ResizeBuffers; 0 validation errors)\n"); 1077 "GetBuffer+GetDesc, clear+readback, Present, ResizeBuffers; 0 validation errors)\n");
865 return 0; 1078 return 0;
866} 1079}
diff --git a/runtime/test/file_system_test.cpp b/runtime/test/file_system_test.cpp
index c33098d2a..1fcaf6710 100644
--- a/runtime/test/file_system_test.cpp
+++ b/runtime/test/file_system_test.cpp
@@ -99,7 +99,7 @@ int main() {
99 write_path(package / "data" / "hello.txt", "package"); 99 write_path(package / "data" / "hello.txt", "package");
100 write_path(package / "data" / "dup.txt", "package"); 100 write_path(package / "data" / "dup.txt", "package");
101 write_path(package / "data" / "bye.txt", "package"); 101 write_path(package / "data" / "bye.txt", "package");
102 std::filesystem::create_directories(package / "data" / "sub"); 102 write_path(package / "data" / "sub" / "nested.txt", "nested");
103 103
104 rt::fs::configure(package, overlay); 104 rt::fs::configure(package, overlay);
105 check(rt::fs::game_dir() == package, "configure() sets the game folder"); 105 check(rt::fs::game_dir() == package, "configure() sets the game folder");
@@ -249,6 +249,15 @@ int main() {
249 SetLastError(0); 249 SetLastError(0);
250 check(delete_w(L"GAME:\\nope\\missing.txt") == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, 250 check(delete_w(L"GAME:\\nope\\missing.txt") == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND,
251 "deleting a file that never existed reports ERROR_FILE_NOT_FOUND"); 251 "deleting a file that never existed reports ERROR_FILE_NOT_FOUND");
252
253 // Deleting a nested package file creates parent directories inside .gta6rt-deleted/; those marker parent
254 // directories must not hide the corresponding ancestor directories in the package.
255 check(delete_w(L"GAME:\\data\\sub\\nested.txt") != FALSE, "DeleteFileW accepts a nested package file");
256 const DWORD sub_attrs = attributes_w(L"GAME:\\data\\sub");
257 check(sub_attrs != INVALID_FILE_ATTRIBUTES && (sub_attrs & FILE_ATTRIBUTE_DIRECTORY) != 0,
258 "deleting a nested package file does not hide its parent folder");
259 check(contains(list(first_w, next_w, find_close, L"GAME:\\data\\*"), L"sub"),
260 "the parent folder stays listed after deleting a nested package file");
252 } 261 }
253 262
254 // Nothing leaves the package and the overlay. 263 // Nothing leaves the package and the overlay.
diff --git a/runtime/test/fixtures/tiny_gdk_load.cpp b/runtime/test/fixtures/tiny_gdk_load.cpp
index 780b10edb..291d3a5d7 100644
--- a/runtime/test/fixtures/tiny_gdk_load.cpp
+++ b/runtime/test/fixtures/tiny_gdk_load.cpp
@@ -51,10 +51,27 @@ int main() {
51 HRESULT hr = init(0, 0, 0x02, &options); 51 HRESULT hr = init(0, 0, 0x02, &options);
52 if (hr != S_OK) return fail("InitializeApiImplEx2", static_cast<unsigned long>(hr)); 52 if (hr != S_OK) return fail("InitializeApiImplEx2", static_cast<unsigned long>(hr));
53 53
54 // XThreadingImpl, the first class XCurl.dll references (docs/runtime_imports.md); not provided offline yet. 54 // XThreadingImpl, the first class XCurl.dll references (docs/runtime_imports.md), used as its thunks do: the
55 // class id as both ids, a slot with `this` first, then Release (slot 2). Slot 12 is XTaskQueueCreate, 17
56 // XTaskQueueCloseHandle.
55 const GUID threading = {0x073b7dcb, 0x1fcf, 0x4030, {0x94, 0xbe, 0xe3, 0xc9, 0xeb, 0x62, 0x34, 0x28}}; 57 const GUID threading = {0x073b7dcb, 0x1fcf, 0x4030, {0x94, 0xbe, 0xe3, 0xc9, 0xeb, 0x62, 0x34, 0x28}};
58 void* obj = nullptr;
59 hr = query(&threading, threading, &obj);
60 if (hr != S_OK || !obj) return fail("QueryApiImpl hands out XThreadingImpl", static_cast<unsigned long>(hr));
61 void* const* vtable = *static_cast<void* const* const*>(obj);
62 using Create = HRESULT(STDMETHODCALLTYPE*)(void*, UINT32, UINT32, void**);
63 using Close = void(STDMETHODCALLTYPE*)(void*, void*);
64 using Release = ULONG(STDMETHODCALLTYPE*)(void*);
65 void* queue = nullptr;
66 hr = reinterpret_cast<Create>(vtable[12])(obj, 0, 0, &queue); // XTaskQueueDispatchMode::Manual twice
67 if (hr != S_OK || !queue) return fail("XThreadingImpl slot 12 (XTaskQueueCreate)", static_cast<unsigned long>(hr));
68 reinterpret_cast<Close>(vtable[17])(obj, queue);
69 reinterpret_cast<Release>(vtable[2])(obj);
70
71 // A class not served yet (XNetworkingImpl) is refused, with the out pointer cleared.
72 const GUID networking = {0x37e56907, 0x2f10, 0x41e8, {0xb7, 0x2f, 0x36, 0xed, 0xb1, 0x85, 0x33, 0x1a}};
56 void* out = reinterpret_cast<void*>(1); 73 void* out = reinterpret_cast<void*>(1);
57 hr = query(&threading, threading, &out); 74 hr = query(&networking, networking, &out);
58 if (hr != static_cast<HRESULT>(0x80070032) || out != nullptr) 75 if (hr != static_cast<HRESULT>(0x80070032) || out != nullptr)
59 return fail("QueryApiImpl refuses an unprovided class and clears its out pointer", static_cast<unsigned long>(hr)); 76 return fail("QueryApiImpl refuses an unprovided class and clears its out pointer", static_cast<unsigned long>(hr));
60 hr = uninit(); 77 hr = uninit();
diff --git a/runtime/test/fsr_dispatch_test.cpp b/runtime/test/fsr_dispatch_test.cpp
index 7affaee7a..9a66071ac 100644
--- a/runtime/test/fsr_dispatch_test.cpp
+++ b/runtime/test/fsr_dispatch_test.cpp
@@ -28,7 +28,7 @@
28// driver refuses one of its textures (DXGI_FORMAT_R9G9B9E5_SHAREDEXP with ALLOW_UNORDERED_ACCESS); on WARP the 28// driver refuses one of its textures (DXGI_FORMAT_R9G9B9E5_SHAREDEXP with ALLOW_UNORDERED_ACCESS); on WARP the
29// context is created as is. The other backend ids are controls: they end in FFX_API_RETURN_ERROR before the device 29// context is created as is. The other backend ids are controls: they end in FFX_API_RETURN_ERROR before the device
30// is touched. In step 7 the dispatch is recorded up to the DLL's compute pipeline, which a PC device cannot create 30// is touched. In step 7 the dispatch is recorded up to the DLL's compute pipeline, which a PC device cannot create
31// (slot 67 is console-only and refused; slot 62's code is not a PC shader). The INFO lines are the measurement; the 31// (slot 67 and 62 codes are not PC shaders). The INFO lines are the measurement; the
32// PASS/FAIL checks only cover what is known to work. 32// PASS/FAIL checks only cover what is known to work.
33#include <windows.h> 33#include <windows.h>
34 34
@@ -958,7 +958,7 @@ int main() {
958 note(" device slot 62 (compute pipeline from a D3D12_COMPUTE_PIPELINE_STATE_DESC) called " + 958 note(" device slot 62 (compute pipeline from a D3D12_COMPUTE_PIPELINE_STATE_DESC) called " +
959 std::to_string(g_slot62_calls) + "x, last HRESULT " + hex(static_cast<uint32_t>(g_slot62_hr))); 959 std::to_string(g_slot62_calls) + "x, last HRESULT " + hex(static_cast<uint32_t>(g_slot62_hr)));
960 if (g_formatted) note(" the DLL formatted HRESULT " + hex(g_first_formatted)); 960 if (g_formatted) note(" the DLL formatted HRESULT " + hex(g_first_formatted));
961 // On a PC device both pipeline paths fail (67 is refused, 62's code is not a PC shader); on the 961 // On a PC device both pipeline paths fail (neither slot 67's nor 62's code is a PC shader); on the
962 // Vulkan device CreateRootSignature (slot 16) is not implemented yet. Either way the dispatch goes 962 // Vulkan device CreateRootSignature (slot 16) is not implemented yet. Either way the dispatch goes
963 // on with a null pipeline and faults when it records it (RVA 0x65ff reads the pipeline's +0x10, 963 // on with a null pipeline and faults when it records it (RVA 0x65ff reads the pipeline's +0x10,
964 // the same pointer it passes to SetPipelineState): a documented stop, not a test failure. 964 // the same pointer it passes to SetPipelineState): a documented stop, not a test failure.
diff --git a/runtime/test/glsl/cs_user_data.comp b/runtime/test/glsl/cs_user_data.comp
index a932cc086..82779ccb1 100644
--- a/runtime/test/glsl/cs_user_data.comp
+++ b/runtime/test/glsl/cs_user_data.comp
@@ -36,8 +36,20 @@ Words at(uvec2 va) {
36void main() { 36void main() {
37 const uint i = gl_GlobalInvocationID.x; 37 const uint i = gl_GlobalInvocationID.x;
38 Words table = at(uvec2(pc.s[4], pc.s[5])); 38 Words table = at(uvec2(pc.s[4], pc.s[5]));
39 Words result = at(uvec2(pc.s[2], pc.s[3]));
40 if (pc.s[1] == 0u) {
41 // CBV V# mode: table holds a 16-byte GFX10 raw buffer descriptor written by CreateConstantBufferView.
42 const uint num_records = table.w[2];
43 const uint byte_off = pc.s[0] + i * 4u;
44 if (byte_off + 4u <= num_records) {
45 Words cbv = at(uvec2(table.w[0], table.w[1] & 0xFFFFu));
46 result.w[i] = cbv.w[byte_off >> 2u];
47 } else {
48 result.w[i] = 0u;
49 }
50 return;
51 }
39 Words constants = at(uvec2(table.w[0], table.w[1])); 52 Words constants = at(uvec2(table.w[0], table.w[1]));
40 Words code = at(pc.code_base); 53 Words code = at(pc.code_base);
41 Words result = at(uvec2(pc.s[2], pc.s[3]));
42 result.w[i] = pc.s[0] + pc.s[1] * i + constants.w[i % 4] + code.w[1]; 54 result.w[i] = pc.s[0] + pc.s[1] * i + constants.w[i % 4] + code.w[1];
43} 55}
diff --git a/runtime/test/process_cmdline_test.cpp b/runtime/test/process_cmdline_test.cpp
index 4c78835bb..8f35a8ef7 100644
--- a/runtime/test/process_cmdline_test.cpp
+++ b/runtime/test/process_cmdline_test.cpp
@@ -1,10 +1,14 @@
1// The process shim's command line round-trips: what GetCommandLineW says must parse with CommandLineToArgvW (the 1// The process shim's command line round-trips: what GetCommandLineW says must parse with CommandLineToArgvW (the
2// documented rules the CRT's argv parser shares) back to the __wargv the shim hands out, and __wargv must hold what 2// documented rules the CRT's argv parser shares) back to the __wargv the shim hands out, and __wargv must hold what
3// main.cpp passed, whatever the system code page (RT-84). No game files. 3// main.cpp passed, whatever the system code page (RT-84). The WinMain line (lpCmdLine) is the game's too, and the
4// command line and ExitProcess are served under kernelbase.dll and the API-set names as well as kernel32.dll.
5// No game files.
4#include <windows.h> 6#include <windows.h>
5#include <shellapi.h> 7#include <shellapi.h>
6 8
7#include <cstdio> 9#include <cstdio>
10#include <cstring>
11#include <cwchar>
8#include <string> 12#include <string>
9#include <vector> 13#include <vector>
10 14
@@ -54,6 +58,60 @@ void check_non_ascii(const std::wstring& want, const char* what) {
54 ++failures; 58 ++failures;
55 } 59 }
56} 60}
61
62// An executable can import GetCommandLineA/W and ExitProcess from kernel32.dll, kernelbase.dll or the API set its
63// umbrella library names, and the loader matches the DLL name exactly: every name must hand out the same shim.
64void check_import_names() {
65 for (const char* dll : {"kernelbase.dll", "api-ms-win-core-processenvironment-l1-1-0.dll"})
66 for (const char* name : {"GetCommandLineA", "GetCommandLineW"}) {
67 void* fn = rt::shims::find(dll, name);
68 if (!fn || fn != rt::shims::find("kernel32.dll", name)) {
69 std::fprintf(stderr, "FAIL %s!%s is not the kernel32.dll shim\n", dll, name);
70 ++failures;
71 }
72 }
73 for (const char* dll : {"kernelbase.dll", "api-ms-win-core-processthreads-l1-1-0.dll"}) {
74 void* fn = rt::shims::find(dll, "ExitProcess");
75 if (!fn || fn != rt::shims::find("kernel32.dll", "ExitProcess")) {
76 std::fprintf(stderr, "FAIL %s!ExitProcess is not the kernel32.dll shim\n", dll);
77 ++failures;
78 }
79 }
80 for (const char* dll : {"api-ms-win-crt-runtime-l1-1-0.dll", "ucrtbase.dll", "ucrtbased.dll"})
81 for (const char* name : {"_get_narrow_winmain_command_line", "_get_wide_winmain_command_line"})
82 if (!rt::shims::find(dll, name)) {
83 std::fprintf(stderr, "FAIL %s!%s is not shimmed\n", dll, name);
84 ++failures;
85 }
86}
87
88// lpCmdLine as the CRT's WinMain startup gets it from _get_wide/_get_narrow_winmain_command_line: the game's command
89// line after the program name and the blanks that follow it (the narrow one in the ANSI code page).
90void check_winmain(const std::wstring& program, const std::vector<std::wstring>& args, const wchar_t* want,
91 const char* what) {
92 rt::process::set_command_line(program, args);
93 using Wide = wchar_t*(__cdecl*)();
94 using Narrow = char*(__cdecl*)();
95 for (const char* dll : {"api-ms-win-crt-runtime-l1-1-0.dll", "ucrtbase.dll"}) {
96 const auto wide_fn = reinterpret_cast<Wide>(rt::shims::find(dll, "_get_wide_winmain_command_line"));
97 const auto narrow_fn = reinterpret_cast<Narrow>(rt::shims::find(dll, "_get_narrow_winmain_command_line"));
98 if (!wide_fn || !narrow_fn) continue; // check_import_names has reported the missing shim
99 const wchar_t* wide = wide_fn();
100 const char* line = narrow_fn();
101 char expected[256] = {};
102 WideCharToMultiByte(CP_ACP, 0, want, -1, expected, sizeof(expected), nullptr, nullptr);
103 if (!wide || std::wcscmp(wide, want) != 0) {
104 std::fwprintf(stderr, L"FAIL %hs (%hs): the wide WinMain line is [%ls], want [%ls]\n", what, dll,
105 wide ? wide : L"(null)", want);
106 ++failures;
107 }
108 if (!line || std::strcmp(line, expected) != 0) {
109 std::fprintf(stderr, "FAIL %s (%s): the narrow WinMain line is [%s], want [%s]\n", what, dll,
110 line ? line : "(null)", expected);
111 ++failures;
112 }
113 }
114}
57} // namespace 115} // namespace
58 116
59int main() { 117int main() {
@@ -67,8 +125,16 @@ int main() {
67 // Greek, Cyrillic and CJK together: no single-byte code page holds all of them, so this covers every PC. 125 // Greek, Cyrillic and CJK together: no single-byte code page holds all of them, so this covers every PC.
68 check_non_ascii(L"\u0394\u0416\u6F22 x", "an argument outside any single-byte code page"); 126 check_non_ascii(L"\u0394\u0416\u6F22 x", "an argument outside any single-byte code page");
69 127
128 check_import_names();
129 check_winmain(L"game.exe", {L"-foo", L"with space"}, L"-foo \"with space\"", "arguments after a plain name");
130 check_winmain(L"C:\\My Games\\game.exe", {L"-x"}, L"-x", "a quoted program name with a space");
131 check_winmain(L"game.exe", {}, L"", "no arguments");
132 // A byte above 0x7f in the narrow program name is part of the name, not the end of it.
133 check_winmain(L"caf\u00e9.exe", {L"-x"}, L"-x", "a non-ASCII program name");
134
70 if (failures) return 1; 135 if (failures) return 1;
71 std::printf("process_cmdline: GetCommandLineW parses back to __wargv, non-ASCII arguments intact (code page %u)\n", 136 std::printf("process_cmdline: GetCommandLineW parses back to __wargv, non-ASCII arguments intact (code page %u); "
137 "the WinMain line and the kernelbase/API-set names are the game's\n",
72 GetACP()); 138 GetACP());
73 return 0; 139 return 0;
74} 140}
diff --git a/runtime/test/shader_library_corpus_test.cpp b/runtime/test/shader_library_corpus_test.cpp
new file mode 100644
index 000000000..6e3e6be94
--- /dev/null
+++ b/runtime/test/shader_library_corpus_test.cpp
@@ -0,0 +1,159 @@
1// The runtime's shader lookup (src/shader_library.h) over a translated corpus from the player's own copy.
2//
3// LEONIDA_SHADERS=<work>/shaders/spirv the translator's output (index.json and the .spv modules)
4// LEONIDA_SHADER_DXBC=<work>/shaders/dxbc optional; the carved DXBC containers, default <spirv>/../dxbc
5//
6// For every container the test does what d3d12_vulkan_device.cpp does with a PSO's bytecode: inflate the FSSM program
7// from the DXIL/XDAT/XBCH entry, hash it and look it up under the container's stage. The stage comes from the DXIL
8// part's program header, not from index.json. Every container has to resolve to its own entry (the one named after
9// the file, or one of its `~N` duplicates) with a readable SPIR-V module, and every index entry has to be reached by
10// a container. Containers with more than one 0x0D payload are counted, and their first payload must not stand in for
11// the last: that is the rule fssm_program follows, so a regression to the first payload fails here.
12//
13// Without LEONIDA_SHADERS it prints SKIP and exits 77 (SKIP_RETURN_CODE). It reads the work folder in place, writes
14// nothing, and prints counts; on a failure it names at most a few shaders, which stay on your machine.
15#include "../src/shader_library.h"
16
17#include <cstdio>
18#include <cstdlib>
19#include <filesystem>
20#include <fstream>
21#include <set>
22#include <string>
23#include <vector>
24
25namespace {
26
27namespace fs = std::filesystem;
28
29std::string env(const char* name) {
30 const char* value = std::getenv(name);
31 return value ? value : "";
32}
33
34std::vector<std::uint8_t> read_file(const fs::path& path) {
35 std::ifstream file(path, std::ios::binary);
36 return {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
37}
38
39std::uint32_t u32(std::span<const std::uint8_t> data, std::size_t at) {
40 if (at + 4 > data.size()) return 0;
41 std::uint32_t v;
42 std::memcpy(&v, data.data() + at, 4);
43 return v;
44}
45
46// The stage the DXIL program header names (DxilProgramHeader::ProgramVersion, kind in bits 31:16; D3D12's
47// D3D12_SHADER_VERSION_TYPE), in the translator's spelling. Empty for a kind the corpus has no translation for.
48std::string dxil_stage(std::span<const std::uint8_t> container) {
49 const auto dxil = leonida::dxbc_part(container, "DXIL");
50 if (dxil.size() < 4) return {};
51 switch (u32(dxil, 0) >> 16) {
52 case 0: return "ps";
53 case 1: return "vs";
54 case 2: return "gs";
55 case 5: return "cs";
56 case 13: return "ms";
57 default: return {};
58 }
59}
60
61// Every 0x0D (XBCH) payload of the container's XDAT table, in table order, inflated. fssm_program keeps the last.
62std::vector<std::vector<std::uint8_t>> all_programs(std::span<const std::uint8_t> container) {
63 std::vector<std::vector<std::uint8_t>> out;
64 const auto dxil = leonida::dxbc_part(container, "DXIL");
65 std::size_t xdat = 0;
66 while (xdat + 4 <= dxil.size() && std::memcmp(dxil.data() + xdat, "XDAT", 4) != 0) ++xdat;
67 const std::uint32_t count = u32(dxil, xdat + 4);
68 for (std::uint32_t i = 0; i < count; ++i) {
69 const std::size_t entry = xdat + 12 + 12 * std::size_t(i);
70 if (entry + 12 > dxil.size()) break;
71 const std::uint32_t tag = u32(dxil, entry), offset = u32(dxil, entry + 4), size = u32(dxil, entry + 8);
72 if (tag != 0x0d || size < 24 || std::size_t(offset) + size > dxil.size()) continue;
73 const auto blob = dxil.subspan(offset, size);
74 std::vector<std::uint8_t> program;
75 if (std::memcmp(blob.data(), "XBCH", 4) == 0 && leonida::zlib_inflate(blob.subspan(24), program, u32(blob, 16)))
76 out.push_back(std::move(program));
77 }
78 return out;
79}
80
81bool own_entry(const leonida::ShaderEntry& entry, const std::string& stem) {
82 return entry.name == stem || entry.name.rfind(stem + "~", 0) == 0;
83}
84
85} // namespace
86
87int main() {
88 const std::string spirv_dir = env("LEONIDA_SHADERS");
89 if (spirv_dir.empty()) {
90 std::printf("SKIP (no translated corpus: set LEONIDA_SHADERS to <work>/shaders/spirv)\n");
91 return 77;
92 }
93 std::string dxbc_dir = env("LEONIDA_SHADER_DXBC");
94 if (dxbc_dir.empty()) dxbc_dir = (fs::path(spirv_dir) / ".." / "dxbc").lexically_normal().string();
95
96 int failures = 0, named = 0;
97 const auto fail = [&](const std::string& what, const std::string& shader) {
98 ++failures;
99 if (named++ < 8) std::fprintf(stderr, "FAIL %s: %s\n", what.c_str(), shader.c_str());
100 };
101
102 leonida::ShaderLibrary library;
103 std::string error;
104 if (!library.load(spirv_dir, &error)) {
105 std::fprintf(stderr, "FAIL loading %s: %s\n", spirv_dir.c_str(), error.c_str());
106 return 1;
107 }
108 std::error_code ec;
109 if (!fs::is_directory(dxbc_dir, ec)) {
110 std::fprintf(stderr, "FAIL no DXBC folder %s (set LEONIDA_SHADER_DXBC)\n", dxbc_dir.c_str());
111 return 1;
112 }
113
114 std::size_t containers = 0, multi = 0;
115 std::set<std::string> reached;
116 for (const auto& item : fs::directory_iterator(dxbc_dir)) {
117 if (!item.is_regular_file() || item.path().extension() != ".dxbc") continue;
118 ++containers;
119 const std::string stem = item.path().stem().string();
120 const auto bytes = read_file(item.path());
121 const std::string stage = dxil_stage(bytes);
122 if (stage.empty()) {
123 fail("no shader stage in the DXIL program header", stem);
124 continue;
125 }
126 const auto program = leonida::fssm_program(bytes);
127 if (program.size() < 4 || std::memcmp(program.data(), "FSSM", 4) != 0) {
128 fail("no FSSM program", stem);
129 continue;
130 }
131 bool found = false;
132 for (const leonida::ShaderEntry* entry : library.candidates(stage, leonida::sha256_hex(program))) {
133 if (!own_entry(*entry, stem)) continue;
134 found = true;
135 reached.insert(entry->name);
136 if (library.spirv(*entry).empty()) fail("no SPIR-V module for", entry->name);
137 }
138 if (!found) fail("not found under its " + stage + " stage", stem);
139
140 // The 0x0D payloads that differ from the last: none of them may be what the index has for this container.
141 const auto programs = all_programs(bytes);
142 if (programs.empty() || programs.back() != program) fail("fssm_program is not the last 0x0D payload", stem);
143 bool differs = false;
144 for (std::size_t i = 0; i + 1 < programs.size(); ++i) {
145 if (programs[i] == program) continue;
146 differs = true;
147 for (const leonida::ShaderEntry* entry : library.candidates(stage, leonida::sha256_hex(programs[i])))
148 if (own_entry(*entry, stem)) fail("an earlier 0x0D payload is the indexed program", stem);
149 }
150 multi += differs;
151 }
152
153 if (containers == 0) fail("no .dxbc containers in", dxbc_dir);
154 if (reached.size() != library.size())
155 fail(std::to_string(library.size() - reached.size()) + " index entries reached by no container", spirv_dir);
156 std::printf("%zu containers, %zu index entries, %zu reached; %zu containers with more than one program; "
157 "%d failures\n", containers, library.size(), reached.size(), multi, failures);
158 return failures ? 1 : 0;
159}
diff --git a/runtime/test/shaders/build.py b/runtime/test/shaders/build.py
index c9796f244..7ec6608d6 100644
--- a/runtime/test/shaders/build.py
+++ b/runtime/test/shaders/build.py
@@ -20,6 +20,8 @@ With LEONIDA_FMA=khr (or glsl), the fused multiply-adds are translated with --fm
20VK_KHR_shader_fma; the test programs enable it when the device has it, else they exit 77) or --fma glsl. 20VK_KHR_shader_fma; the test programs enable it when the device has it, else they exit 77) or --fma glsl.
21With LEONIDA_BARY_FALLBACK=1, pixel shaders that read raw barycentrics are translated with --bary-fallback, and 21With LEONIDA_BARY_FALLBACK=1, pixel shaders that read raw barycentrics are translated with --bary-fallback, and
22each gets a pass-through geometry shader, <name>.bary_gs.spv, that check.py draws it with (tools/bary_fallback_gs.py). 22each gets a pass-through geometry shader, <name>.bary_gs.spv, that check.py draws it with (tools/bary_fallback_gs.py).
23Under that or LEONIDA_F16_INTERP_FALLBACK=1, ps_ij_computed isn't built: its computed I/J pair needs PerVertexKHR
24inputs, and check.py reports it as SKIP.
23""" 25"""
24import json 26import json
25import os 27import os
@@ -38,6 +40,8 @@ import mc_command # noqa: E402
38 40
39MC = mc_command.mc_command() 41MC = mc_command.mc_command()
40RSRC2, GROUP = 0x8088, (64, 1, 1) 42RSRC2, GROUP = 0x8088, (64, 1, 1)
43# Not built under LEONIDA_BARY_FALLBACK=1 or LEONIDA_F16_INTERP_FALLBACK=1 (see main).
44NEEDS_PER_VERTEX_INPUTS = ("ps_ij_computed",)
41sys.path.insert(0, HERE) # this script is also run with python -I 45sys.path.insert(0, HERE) # this script is also run with python -I
42from compute_fixture import compute_header # noqa: E402 46from compute_fixture import compute_header # noqa: E402
43 47
@@ -58,8 +62,8 @@ def asm_mattr(path):
58CLIP_CASES = {"vs_clip": 1, "vs_clip_param4": 4, "vs_clip_undeclared": 1} 62CLIP_CASES = {"vs_clip": 1, "vs_clip_param4": 4, "vs_clip_undeclared": 1}
59 63
60 64
61def asm_fssm(path): 65def asm_fssm_fields(path):
62 """The synthetic FSSM program a vs_/ps_ shader's header asks for, or None.""" 66 """(offset, words) of the "fssm-at" and "fssm-data" header comments, (None, []) without them."""
63 at, words = None, [] 67 at, words = None, []
64 for ln in Path(path).read_text(encoding="utf-8").splitlines(): 68 for ln in Path(path).read_text(encoding="utf-8").splitlines():
65 s = ln.strip() 69 s = ln.strip()
@@ -71,11 +75,27 @@ def asm_fssm(path):
71 m = re.match(r";\s*fssm-data:\s*(.*)", s) 75 m = re.match(r";\s*fssm-data:\s*(.*)", s)
72 if m: 76 if m:
73 words += [int(w, 0) for w in m.group(1).split()] 77 words += [int(w, 0) for w in m.group(1).split()]
78 return at, words
79
80
81def asm_fssm(path):
82 """The synthetic FSSM program a vs_/ps_ shader's header asks for, or None."""
83 at, words = asm_fssm_fields(path)
74 if at is None or not words or at < 4 or at % 4: 84 if at is None or not words or at < 4 or at % 4:
75 return None 85 return None
76 return b"FSSM" + bytes(at - 4) + b"".join(struct.pack("<I", w) for w in words) 86 return b"FSSM" + bytes(at - 4) + b"".join(struct.pack("<I", w) for w in words)
77 87
78 88
89def cs_fssm_extra(path):
90 """A compute shader's "fssm-at"/"fssm-data" words (at 0x148 or later, after compute_header's header), or None.
91 Two compute shaders with the same group size and RSRC2 would otherwise share one FSSM hash, which is what the
92 layer finds a PSO's shader by."""
93 at, words = asm_fssm_fields(path)
94 if at is None or not words or at < 0x148 or at % 4:
95 return None
96 return at, b"".join(struct.pack("<I", w) for w in words)
97
98
79def shader_source(name): 99def shader_source(name):
80 return "vs_clip" if name in CLIP_CASES else name 100 return "vs_clip" if name in CLIP_CASES else name
81 101
@@ -108,12 +128,16 @@ def translate_tests(work, names):
108 sys.exit(f"{n}.asm did not assemble:\n{r.stderr}") 128 sys.exit(f"{n}.asm did not assemble:\n{r.stderr}")
109 # rdna2spirv.py rejects assembler directives such as the "\t.text" llvm-mc prints first. 129 # rdna2spirv.py rejects assembler directives such as the "\t.text" llvm-mc prints first.
110 code = "".join(ln for ln in r.stdout.splitlines(keepends=True) if not ln.lstrip().startswith(".")) 130 code = "".join(ln for ln in r.stdout.splitlines(keepends=True) if not ln.lstrip().startswith("."))
111 (disasm / (n + ".s")).write_text(f"; {n} hand-written test\n{code}", encoding="utf-8") 131 (disasm / (n + ".s")).write_text(f"; {n} hand-written test\n{code}", encoding="utf-8", newline="\n")
112 program = None if n.startswith("cs_") else asm_fssm(asm_path) 132 program = None if n.startswith("cs_") else asm_fssm(asm_path)
113 if program: # where the translator looks for a program to hash, as in the game's work folder 133 if program: # where the translator looks for a program to hash, as in the game's work folder
114 (fssm / (n + ".fssm")).write_bytes(program) 134 (fssm / (n + ".fssm")).write_bytes(program)
115 if n.startswith("cs_"): 135 if n.startswith("cs_"):
116 (fssm / (n + ".fssm")).write_bytes(compute_header(asm_path)) 136 program = bytes(compute_header(asm_path))
137 extra = cs_fssm_extra(asm_path)
138 if extra:
139 program += bytes(extra[0] - len(program)) + extra[1]
140 (fssm / (n + ".fssm")).write_bytes(program)
117 elif n in CLIP_CASES and n != "vs_clip_undeclared": 141 elif n in CLIP_CASES and n != "vs_clip_undeclared":
118 (work / (n + ".dxbc")).write_bytes(clip_container()) 142 (work / (n + ".dxbc")).write_bytes(clip_container())
119 else: 143 else:
@@ -149,6 +173,14 @@ def main():
149 if skipped: 173 if skipped:
150 print("not built (need a DXBC container with signatures):", ", ".join(skipped)) 174 print("not built (need a DXBC container with signatures):", ", ".join(skipped))
151 names = [n for n in names if n not in skipped] 175 names = [n for n in names if n not in skipped]
176 # A computed I/J pair needs PerVertexKHR inputs, which both fallbacks take away: the translator refuses it there,
177 # and check.py and run_gpu_tests.py report it as SKIP. Leave it out instead of losing the whole batch.
178 if os.environ.get("LEONIDA_BARY_FALLBACK") == "1" or os.environ.get("LEONIDA_F16_INTERP_FALLBACK") == "1":
179 per_vertex = [n for n in names if n in NEEDS_PER_VERTEX_INPUTS]
180 if per_vertex:
181 print("not built (computed I/J pairs need PerVertexKHR inputs, off under the fallback):",
182 ", ".join(per_vertex))
183 names = [n for n in names if n not in per_vertex]
152 if not names: 184 if not names:
153 return 0 185 return 0
154 out.mkdir(parents=True, exist_ok=True) 186 out.mkdir(parents=True, exist_ok=True)
@@ -168,13 +200,14 @@ def main():
168 published_index = spirv / index.name 200 published_index = spirv / index.name
169 combined = json.loads(published_index.read_text(encoding="utf-8")) if published_index.exists() else {} 201 combined = json.loads(published_index.read_text(encoding="utf-8")) if published_index.exists() else {}
170 combined.update(validated) 202 combined.update(validated)
171 index.write_text(json.dumps(combined, indent=2) + "\n", encoding="utf-8") 203 index.write_text(json.dumps(combined, indent=2) + "\n", encoding="utf-8", newline="\n")
172 for n in validated: 204 for n in validated:
173 for suffix in (".spv", ".spvasm"): 205 for suffix in (".spv", ".spvasm"):
174 artifact = built / (n + suffix) 206 artifact = built / (n + suffix)
175 artifact.replace(spirv / artifact.name) 207 artifact.replace(spirv / artifact.name)
176 sidecar = work / "fssm" / (n + ".fssm") 208 sidecar = work / "fssm" / (n + ".fssm")
177 if not n.startswith("cs_") and sidecar.is_file(): 209 published = not n.startswith("cs_") or cs_fssm_extra(os.path.join(HERE, n + ".asm"))
210 if published and sidecar.is_file():
178 (out / "fssm").mkdir(exist_ok=True) 211 (out / "fssm").mkdir(exist_ok=True)
179 sidecar.replace(out / "fssm" / sidecar.name) 212 sidecar.replace(out / "fssm" / sidecar.name)
180 index.replace(published_index) 213 index.replace(published_index)
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 2f2853175..3985f85e4 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -81,14 +81,14 @@ CS_SMEM = [0x5eed0024, 0x5eed0028, 0x5eed002c, 0x5eed0030, 0x5eed0010, 0x5eed001
81WAVE32_DUMPS = ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", 81WAVE32_DUMPS = ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute",
82 "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_bpermute32", 82 "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_bpermute32",
83 "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext", 83 "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext",
84 "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sincos") 84 "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sincos", "cs_lds_b64_cmpst")
85# Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is 85# Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is
86# narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with 86# narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with
87# 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may 87# 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may
88# otherwise pick a narrower size and return different words (#774). 88# otherwise pick a narrower size and return different words (#774).
89WAVE32_LANE_ENV = {"VKC_SUBGROUP_SIZE": "32"} 89WAVE32_LANE_ENV = {"VKC_SUBGROUP_SIZE": "32"}
90WAVE32_LANE_DUMPS = ("cs_wqm_w32", "cs_w32_lane_wrap", "cs_w32_permute", "cs_bpermute32", "cs_w32_partial_scmp", "cs_exec_const", 90WAVE32_LANE_DUMPS = ("cs_wqm_w32", "cs_w32_lane_wrap", "cs_w32_permute", "cs_bpermute32", "cs_w32_partial_scmp", "cs_exec_const",
91 "cs_w32_mask_imm") 91 "cs_w32_mask_imm", "cs_lds_b64_cmpst")
92CS_DPP = [("cs_dpp", [1, 0, 3, 2, 5, 4, 7, 6]), 92CS_DPP = [("cs_dpp", [1, 0, 3, 2, 5, 4, 7, 6]),
93 ("cs_dpp_row", [0, 0, 1, 2, 3, 4, 5, 6]), 93 ("cs_dpp_row", [0, 0, 1, 2, 3, 4, 5, 6]),
94 ("cs_dpp_mask", [1, 0, 3, 2, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee]), 94 ("cs_dpp_mask", [1, 0, 3, 2, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee]),
@@ -116,6 +116,9 @@ CS_DUMPS = [*CS_DPP, ("cs_store", CS_STORE), ("cs_smem_soffset_imm", CS_SMEM),
116 ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]), 116 ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]),
117 # SHADER-85: 8-bit LDS reads into one half of a VGPR, the other half kept 117 # SHADER-85: 8-bit LDS reads into one half of a VGPR, the other half kept
118 ("cs_w32_lds_u8_d16", [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234]), 118 ("cs_w32_lds_u8_d16", [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234]),
119 # ds_cmpst_b32 and the b64 2-address forms (cs_lds_b64_cmpst.asm header)
120 ("cs_lds_b64_cmpst", [0x11110001, 0x22220002, 0x33330003, 0x44440004,
121 0xCCCC000C, 0x44440004, 0xBBBB000B, 0x3579BADC]),
119 # constant EXEC: each lane takes its own bit (Intel got 16-bit constants wrong for lanes 16-31) 122 # constant EXEC: each lane takes its own bit (Intel got 16-bit constants wrong for lanes 16-31)
120 ("cs_exec_const", [16, 8, 2, 16, 0, 16]), 123 ("cs_exec_const", [16, 8, 2, 16, 0, 16]),
121 # a constant lane mask (saveexec, wrexec, s_and/s_not/s_mov_b64 into EXEC or VCC) gives lane L its bit L, 124 # a constant lane mask (saveexec, wrexec, s_and/s_not/s_mov_b64 into EXEC or VCC) gives lane L its bit L,
@@ -188,6 +191,16 @@ FMT_XY_XYZ_WORDS = [
188 0x3F800000, 0xA5A50284, 0xA5A50288, 0xA5A5028C, 0x0000FFFF, 0xA5A50294, 0xA5A50298, 0xA5A5029C, 191 0x3F800000, 0xA5A50284, 0xA5A50288, 0xA5A5028C, 0x0000FFFF, 0xA5A50294, 0xA5A50298, 0xA5A5029C,
189 0x0003FF01, 0xA5A502A4, 0xA5A502A8, 0xA5A502AC, 0xA5A502B0, 0xA5A502B4, 0xA5A502B8, 0xA5A502BC, 192 0x0003FF01, 0xA5A502A4, 0xA5A502A8, 0xA5A502AC, 0xA5A502B0, 0xA5A502B4, 0xA5A502B8, 0xA5A502BC,
190 0xA5A502C0, 0xA5A502C4, 0xA5A502C8, 0xA5A502CC] 193 0xA5A502C0, 0xA5A502C4, 0xA5A502C8, 0xA5A502CC]
194# cs_tbuffer_store.asm: 13 tbuffer_store_format_* regions read back, as a Radeon 680M (gfx1035) gives them
195# natively. Layout and rules in the .asm header.
196TBUFFER_STORE_WORDS = [
197 0x3F800000, 0x40000000, 0x40400000, 0x40800000, 0x40003C00, 0x00000000, 0xA5A50218, 0xA5A5021C,
198 0x00030201, 0xA5A50224, 0xA5A50228, 0xA5A5022C, 0xA5A5FF30, 0xA5A50234, 0xA5A50238, 0xA5A5023C,
199 0x40000240, 0xA5A50244, 0xA5A50248, 0xA5A5024C, 0xD00003FF, 0xA5A50254, 0xA5A50258, 0xA5A5025C,
200 0x3F800000, 0x40000000, 0xA5A50268, 0xA5A5026C, 0x40003C00, 0xA5A50274, 0xA5A50278, 0xA5A5027C,
201 0xFF0080FF, 0xA5A50284, 0xA5A50288, 0xA5A5028C, 0xA5A50290, 0xA5A50294, 0xA5A50298, 0xA5A5029C,
202 0xA5A502FF, 0xA5A502A4, 0xA5A502A8, 0xA5A502AC, 0x3F800000, 0xA5A502B4, 0xA5A502B8, 0xA5A502BC,
203 0xA5A502C0, 0xA5A502C4, 0xA5A502C8, 0xA5A502CC]
191# Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups make a 0x2800-byte heap that holds 204# Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups make a 0x2800-byte heap that holds
192# both the right addresses and the 4096-lower ones; only group 0 thread 0 runs, so no wave64 requirement. 205# both the right addresses and the 4096-lower ones; only group 0 thread 0 runs, so no wave64 requirement.
193GLOBAL_OFFSET = [("cs_global_neg_offset", "40", [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 206GLOBAL_OFFSET = [("cs_global_neg_offset", "40", [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4,
@@ -257,6 +270,8 @@ PIXEL_BITS = {"ps_clip_color": (0x3e800000, 0x3f000000, 0x3f400000, 0x3f800000),
257 "ps_vcmpx_forms": (0xf05b2a48, 0xf05e8a12, 0xb174be18, 0x15550000), 270 "ps_vcmpx_forms": (0xf05b2a48, 0xf05e8a12, 0xb174be18, 0x15550000),
258 "ps_med3_mods": (0x3f800000, 0x40400000, 0x40c00000, 0x3f400000), 271 "ps_med3_mods": (0x3f800000, 0x40400000, 0x40c00000, 0x3f400000),
259 "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203), 272 "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203),
273 "ps_scc_logic32": (0x0fff0fff, 0x000f000f, 0xf00ff00f, 0x36),
274 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16),
260 "ps_fma_literal": (0x41b80000, 0x41800000, 0x40e00000, 0x41a40000), 275 "ps_fma_literal": (0x41b80000, 0x41800000, 0x40e00000, 0x41a40000),
261 "ps_f64_mods": (0x40040000, 0x3ff00000, 0x3fe40000, 0x3ff00000), 276 "ps_f64_mods": (0x40040000, 0x3ff00000, 0x3fe40000, 0x3ff00000),
262 # f16 op_sel, partial writes, inline constants: words measured on RDNA2 hardware (.asm headers) 277 # f16 op_sel, partial writes, inline constants: words measured on RDNA2 hardware (.asm headers)
@@ -316,7 +331,8 @@ CLIP_TESTS = ("vs_clip", "vs_clip_param4", "vs_clip_undeclared")
316# One definition: a later assignment used to drop ps_texoff (and any entry added by an earlier assignment) from 331# One definition: a later assignment used to drop ps_texoff (and any entry added by an earlier assignment) from
317# the standalone run. Keep every pixel fixture in this tuple. 332# the standalone run. Keep every pixel fixture in this tuple.
318PIXEL_TESTS = sorted((*PIXEL_BITS, "ps_bary", "ps_flat", "ps_bitmask_perm", "ps_texoff", "ps_texoff_implicit", 333PIXEL_TESTS = sorted((*PIXEL_BITS, "ps_bary", "ps_flat", "ps_bitmask_perm", "ps_texoff", "ps_texoff_implicit",
319 "ps_uniform_branch", "ps_wqm", "ps_scc_mask32", "ps_interp_f16_high", "ps_ij_computed")) 334 "ps_uniform_branch", "ps_wqm", "ps_scc_mask32", "ps_interp_f16_high", "ps_ij_computed",
335 "ps_mandelbrot"))
320# Pixel fixtures drawn with another vertex shader than vs_ids. 336# Pixel fixtures drawn with another vertex shader than vs_ids.
321PIXEL_VERTEX = {"ps_interp_f16_high": "vs_f16_pack", 337PIXEL_VERTEX = {"ps_interp_f16_high": "vs_f16_pack",
322 "ps_interp_f32_mods": "vs_interp_consts", "ps_interp_mov_mods": "vs_interp_consts"} 338 "ps_interp_f32_mods": "vs_interp_consts", "ps_interp_mov_mods": "vs_interp_consts"}
@@ -465,6 +481,12 @@ def fmt_xy_xyz_test(tools, spirv, env=None):
465 return dump_test(tools, spirv, "cs_fmt_xy_xyz", FMT_XY_XYZ_WORDS + [0xEEEEEEEE] * 44, 192, env) 481 return dump_test(tools, spirv, "cs_fmt_xy_xyz", FMT_XY_XYZ_WORDS + [0xEEEEEEEE] * 44, 192, env)
466 482
467 483
484def tbuffer_store_test(tools, spirv, env=None):
485 """The 52 region words tbuffer_store_format_* leaves and the untouched words after them, up to the regions at
486 0x200. The heap needs 0x2d0 bytes, so it is 192 words."""
487 return dump_test(tools, spirv, "cs_tbuffer_store", TBUFFER_STORE_WORDS + [0xEEEEEEEE] * 76, 192, env)
488
489
468class Skip(str): 490class Skip(str):
469 """A result that is neither a pass nor a failure: the device can't run the test.""" 491 """A result that is neither a pass nor a failure: the device can't run the test."""
470 492
@@ -659,6 +681,8 @@ def cvt_f32_sat_test(tools, spirv):
659 for bits, unsigned, signed in CVT_F32_SAT_CASES: 681 for bits, unsigned, signed in CVT_F32_SAT_CASES:
660 problem = compute_test(tools, spirv, "cs_cvt_f32_sat", "1", "dump", expected_words=[unsigned, signed], 682 problem = compute_test(tools, spirv, "cs_cvt_f32_sat", "1", "dump", expected_words=[unsigned, signed],
661 env={"VKC_SGPRS": f"{bits:#010x}"}) 683 env={"VKC_SGPRS": f"{bits:#010x}"})
684 if problem is None or isinstance(problem, Skip):
685 return problem # the device can't run it as recorded (wave size not pinnable): the same for every input
662 if problem: 686 if problem:
663 wrong.append(f"{bits:#010x}: {problem}") 687 wrong.append(f"{bits:#010x}: {problem}")
664 return f"{len(wrong)} of {len(CVT_F32_SAT_CASES)} inputs wrong, first {wrong[0]}" if wrong else "" 688 return f"{len(wrong)} of {len(CVT_F32_SAT_CASES)} inputs wrong, first {wrong[0]}" if wrong else ""
@@ -707,9 +731,10 @@ def subgroup_size(spirv, name):
707 return None 731 return None
708 732
709 733
710def bindless_test(tools, spirv): 734def bindless_test(tools, spirv, pixel="ps_tex"):
711 """ps_tex: a texture found through the descriptor hash table and the bindless set (vk_bindless_test).""" 735 """ps_tex: a texture found through the descriptor hash table and the bindless set (vk_bindless_test).
712 shaders = [os.path.join(spirv, name + ".spv") for name in ("vs_ids", "ps_tex")] 736 ps_imgatomic: image atomics in a pixel shader through the set's r32ui storage arrays, checked per texel."""
737 shaders = [os.path.join(spirv, name + ".spv") for name in ("vs_ids", pixel)]
713 for path in shaders: 738 for path in shaders:
714 if not os.path.isfile(path): 739 if not os.path.isfile(path):
715 return f"missing {os.path.basename(path)}" 740 return f"missing {os.path.basename(path)}"
@@ -717,6 +742,9 @@ def bindless_test(tools, spirv):
717 if code == UNSUPPORTED: 742 if code == UNSUPPORTED:
718 m = re.search(r"unsupported: .*", out) 743 m = re.search(r"unsupported: .*", out)
719 return Skip(f"SKIP ({m.group(0) if m else 'unsupported device'})") 744 return Skip(f"SKIP ({m.group(0) if m else 'unsupported device'})")
745 if pixel == "ps_imgatomic":
746 m = re.search(r"ps_imgatomic: (\d+) of \d+ texels wrong.*; (\d+) of \d+ render-target pixels wrong", out)
747 return "" if code == 0 and m and m.group(1) == "0" and m.group(2) == "0" else failure(code, out, 3)
720 m = re.search(r"(\d+) draws read back, (\d+) bad pixels", out) 748 m = re.search(r"(\d+) draws read back, (\d+) bad pixels", out)
721 return "" if code == 0 and m and m.group(2) == "0" else failure(code, out, 3) 749 return "" if code == 0 and m and m.group(2) == "0" else failure(code, out, 3)
722 750
@@ -1098,6 +1126,46 @@ def wide_pixel_skip(name, out):
1098 return Skip(f"SKIP (this device cannot require a {want}-wide fragment subgroup{seen})") 1126 return Skip(f"SKIP (this device cannot require a {want}-wide fragment subgroup{seen})")
1099 1127
1100 1128
1129def f32(x):
1130 """x rounded to the nearest float32. One double add or multiply of two float32 values, then this, is the exact
1131 IEEE float32 result, so a model built from it matches the GPU bit for bit."""
1132 return struct.unpack("<f", struct.pack("<f", x))[0]
1133
1134
1135def mandelbrot_counts(w):
1136 """ps_mandelbrot.asm's iteration counts over a w x w frame, in the shader's order of float32 operations."""
1137 counts = []
1138 for y in range(w):
1139 cy = f32(f32(3.0 * f32((y + 0.5) / w)) - 1.5)
1140 for x in range(w):
1141 cx = f32(f32(3.0 * f32((x + 0.5) / w)) - 2.25)
1142 zx = zy = 0.0
1143 n = 0
1144 while n < 64:
1145 zx2, zy2 = f32(zx * zx), f32(zy * zy)
1146 if not 4.0 >= f32(zx2 + zy2):
1147 break
1148 xy = f32(zx * zy)
1149 zx, zy = f32(f32(zx2 - zy2) + cx), f32(f32(xy + xy) + cy)
1150 n += 1
1151 counts.append(n)
1152 return counts
1153
1154
1155def mandelbrot_problem(px):
1156 """ps_mandelbrot: channel 3 is the lane's iteration count. A lane that leaves EXEC too early or late, or a loop
1157 that ends on the wrong branch, changes counts; the colour channels are only for looking at the frame."""
1158 w = int(len(px) ** 0.5)
1159 if w * w != len(px):
1160 return f"{len(px)} pixels is not a square frame"
1161 want = mandelbrot_counts(w)
1162 wrong = [(i, p[3], e) for i, (p, e) in enumerate(zip(px, want)) if p[3] != e]
1163 if not wrong:
1164 return ""
1165 i, got, e = wrong[0]
1166 return f"{len(wrong)} of {len(px)} iteration counts differ, e.g. pixel ({i % w}, {i // w}) {got} instead of {e}"
1167
1168
1101def pixel_test(tools, spirv, name): 1169def pixel_test(tools, spirv, name):
1102 path = os.path.join(spirv, name + ".spv") 1170 path = os.path.join(spirv, name + ".spv")
1103 if name == "ps_ij_computed" and (BARY_FALLBACK or F16_HALVES): 1171 if name == "ps_ij_computed" and (BARY_FALLBACK or F16_HALVES):
@@ -1164,6 +1232,8 @@ def pixel_test(tools, spirv, name):
1164 c = collections.Counter((a, b) for a, b, _, _ in px) 1232 c = collections.Counter((a, b) for a, b, _, _ in px)
1165 fine = c[(8, 1)] and c[(8, 0)] and c[(7, 0)] and set(c) <= {(8, 1), (8, 0), (7, 0)} 1233 fine = c[(8, 1)] and c[(8, 0)] and c[(7, 0)] and set(c) <= {(8, 1), (8, 0), (7, 0)}
1166 return "" if fine else f"(s5, bit) counts {dict(c)}" 1234 return "" if fine else f"(s5, bit) counts {dict(c)}"
1235 if name == "ps_mandelbrot":
1236 return mandelbrot_problem(px)
1167 return "no check written for this shader" 1237 return "no check written for this shader"
1168 1238
1169 1239
@@ -1217,6 +1287,7 @@ def main():
1217 results.append(("cs_fmt_1010102", fmt_1010102_test(tools, spirv))) 1287 results.append(("cs_fmt_1010102", fmt_1010102_test(tools, spirv)))
1218 results.append(("cs_fmt_sint32", fmt_sint32_test(tools, spirv))) 1288 results.append(("cs_fmt_sint32", fmt_sint32_test(tools, spirv)))
1219 results.append(("cs_fmt_xy_xyz", fmt_xy_xyz_test(tools, spirv))) 1289 results.append(("cs_fmt_xy_xyz", fmt_xy_xyz_test(tools, spirv)))
1290 results.append(("cs_tbuffer_store", tbuffer_store_test(tools, spirv)))
1220 for name, groups, want in GLOBAL_OFFSET: 1291 for name, groups, want in GLOBAL_OFFSET:
1221 results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want))) 1292 results.append((name, compute_test(tools, spirv, name, groups, "dump", expected_words=want)))
1222 results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump", 1293 results.append(("cs_user_sgprs", compute_test(tools, spirv, "cs_user_sgprs", "1", "dump",
@@ -1254,6 +1325,7 @@ def main():
1254 results.append((name, texture_constant_test(tools, spirv, name))) 1325 results.append((name, texture_constant_test(tools, spirv, name)))
1255 results.append(("ps_tex", bindless_test(tools, spirv))) 1326 results.append(("ps_tex", bindless_test(tools, spirv)))
1256 results.append(("ps_ssharp", sampler_test(tools, spirv))) 1327 results.append(("ps_ssharp", sampler_test(tools, spirv)))
1328 results.append(("ps_imgatomic", bindless_test(tools, spirv, "ps_imgatomic")))
1257 for name in MIP_TEST_PASSES: 1329 for name in MIP_TEST_PASSES:
1258 results.append((name, texture_mip_test(tools, spirv, name))) 1330 results.append((name, texture_mip_test(tools, spirv, name)))
1259 for name in GRADIENT_TESTS: 1331 for name in GRADIENT_TESTS:
diff --git a/runtime/test/shaders/cs_buf_counter.asm b/runtime/test/shaders/cs_buf_counter.asm
new file mode 100644
index 000000000..9bbe84bea
--- /dev/null
+++ b/runtime/test/shaders/cs_buf_counter.asm
@@ -0,0 +1,40 @@
1; group: 64,1,1
2; rsrc2: 0x808c
3; fssm-at: 0x150
4; fssm-data: 0x4e554f43 0x3d524554
5; UAV counters (D3D12 CreateUnorderedAccessView with pCounterResource): AppendStructuredBuffer and
6; ConsumeStructuredBuffer as hand-written RDNA2, the way docs/d3d12_vulkan.md section 3.4 describes the contract:
7; the counter is a second, raw 4-byte V# in the upper 16 bytes of the view's descriptor slot, and append and consume
8; are buffer atomics on it. Run: d3d12_buffer_uav_test (a compute PSO found by the SHA-256 of its synthetic FSSM header).
9; The branch skips the 10 dwords of the append path (checked with llvm-mc -show-encoding).
10; User data, from the root signature: [0] four 32-bit constants, [1] a descriptor table of six UAVs, TGID_X in s6:
11; s0 = mode: 0 append, 1 consume s[4:5] = console VA of the table's first slot (32 bytes a slot)
12; slot 0 (+0x00): V#, structured buffer, stride 8, 256 records; the counter V# in +0x10 (raw, 4 bytes)
13; slot 1 (+0x20): V#, raw buffer, 128 records of 8 bytes (written by consume)
14; g = 64 * group + lane
15; append: i = counter++ (buffer_atomic_add, glc returns the old value); record i = { g, g * 3 + 1 }
16; consume: i = --counter (the old value of buffer_atomic_sub, minus one); out[g] = record i
17s_load_dwordx8 s[8:15], s[4:5], 0x0
18s_load_dwordx4 s[16:19], s[4:5], 0x20
19s_lshl_b32 s7, s6, 6
20s_waitcnt lgkmcnt(0)
21v_add_nc_u32_e32 v1, s7, v0
22v_mov_b32_e32 v2, 1
23s_cmp_eq_u32 s0, 0
24s_cbranch_scc0 10
25buffer_atomic_add v2, off, s[12:15], 0 glc
26s_waitcnt vmcnt(0)
27v_mul_lo_u32 v6, v1, 3
28v_add_nc_u32_e32 v6, 1, v6
29v_mov_b32_e32 v5, v1
30buffer_store_dwordx2 v[5:6], v2, s[8:11], 0 idxen
31s_endpgm
32; consume:
33buffer_atomic_sub v2, off, s[12:15], 0 glc
34s_waitcnt vmcnt(0)
35v_add_nc_u32_e32 v2, -1, v2
36buffer_load_dwordx2 v[5:6], v2, s[8:11], 0 idxen
37s_waitcnt vmcnt(0)
38v_lshlrev_b32_e32 v7, 3, v1
39buffer_store_dwordx2 v[5:6], v7, s[16:19], 0 offen
40s_endpgm
diff --git a/runtime/test/shaders/cs_buf_typed.asm b/runtime/test/shaders/cs_buf_typed.asm
new file mode 100644
index 000000000..b101343e8
--- /dev/null
+++ b/runtime/test/shaders/cs_buf_typed.asm
@@ -0,0 +1,63 @@
1; group: 64,1,1
2; rsrc2: 0x808c
3; fssm-at: 0x150
4; fssm-data: 0x44505954 0x3d424655
5; Typed buffer UAVs (D3D12 CreateUnorderedAccessView with a Format on a BUFFER view): hand-written RDNA2 the way a
6; translated `RWBuffer<T>` shader reads and writes them. Run: d3d12_buffer_uav_test (a compute PSO found by the
7; SHA-256 of its synthetic FSSM header, as for the other cs_ shaders).
8; User data, from the root signature: [0] four 32-bit constants, [1] a descriptor table of six UAVs. RSRC2 0x808c =
9; six user SGPRs and TGID_X, so the group index is s6:
10; s0 = seed s1 = multiplier s[4:5] = console VA of the table's first slot (a slot is 32 bytes, a V# in its first 16)
11; slot 0 (+0x00): V#, typed R32_UINT, 240 elements of a 256-element buffer (written, then atomically added to)
12; slot 1 (+0x20): V#, typed R16G16B16A16_FLOAT, 256 elements (written)
13; slot 2 (+0x40): V#, typed R8G8B8A8_UNORM, 256 elements from element 16 of the buffer (written)
14; slot 3 (+0x60): V#, typed R32G32B32A32_UINT, 256 elements (written)
15; slot 4 (+0x80): V#, typed R32_FLOAT, 250 elements of a 256-element buffer (read)
16; slot 5 (+0xa0): V#, typed R32_SINT, 256 elements (written)
17; g = 64 * group + lane, 0..255 (an index past a view's NUM_RECORDS is out of range: a load gives 0, a store or an
18; atomic touches nothing):
19; slot 0: element g = g * mul + seed, then += g
20; slot 1: element g = { f16(g), f16(g + 0.5), f16(-1 - g), f16(0.25) }
21; slot 2: element g = unorm8 { (g & 255) / 255, (255 - (g & 255)) / 255, 0, 1 }
22; slot 3: element g = { g, g ^ 0xffff, g * 7, 0xa5 }
23; slot 5: element g = (int)(2 * input[g]), input[g] = g - 100.5
24s_load_dwordx4 s[8:11], s[4:5], 0x0
25s_load_dwordx4 s[12:15], s[4:5], 0x20
26s_load_dwordx4 s[16:19], s[4:5], 0x40
27s_load_dwordx4 s[20:23], s[4:5], 0x60
28s_load_dwordx4 s[24:27], s[4:5], 0x80
29s_load_dwordx4 s[28:31], s[4:5], 0xa0
30s_lshl_b32 s7, s6, 6
31s_waitcnt lgkmcnt(0)
32v_add_nc_u32_e32 v1, s7, v0
33v_mul_lo_u32 v2, v1, s1
34v_add_nc_u32_e32 v2, s0, v2
35buffer_store_format_x v2, v1, s[8:11], 0 idxen
36v_mov_b32_e32 v3, v1
37buffer_atomic_add v3, v1, s[8:11], 0 idxen
38v_cvt_f32_u32_e32 v4, v1
39v_add_f32_e32 v5, 0.5, v4
40v_sub_f32_e32 v6, -1.0, v4
41v_mov_b32_e32 v7, 0x3e800000
42buffer_store_format_xyzw v[4:7], v1, s[12:15], 0 idxen
43v_and_b32_e32 v8, 255, v1
44v_cvt_f32_ubyte0_e32 v9, v8
45v_mov_b32_e32 v10, 0x3b808081
46v_mul_f32_e32 v11, v9, v10
47v_sub_nc_u32_e32 v12, 255, v8
48v_cvt_f32_ubyte0_e32 v12, v12
49v_mul_f32_e32 v12, v12, v10
50v_mov_b32_e32 v13, 0
51v_mov_b32_e32 v14, 1.0
52buffer_store_format_xyzw v[11:14], v1, s[16:19], 0 idxen
53v_mov_b32_e32 v15, v1
54v_xor_b32_e32 v16, 0xffff, v1
55v_mul_lo_u32 v17, v1, 7
56v_mov_b32_e32 v18, 0xa5
57buffer_store_format_xyzw v[15:18], v1, s[20:23], 0 idxen
58buffer_load_format_x v19, v1, s[24:27], 0 idxen
59s_waitcnt vmcnt(0)
60v_add_f32_e32 v19, v19, v19
61v_cvt_i32_f32_e32 v19, v19
62buffer_store_format_x v19, v1, s[28:31], 0 idxen
63s_endpgm
diff --git a/runtime/test/shaders/cs_lds_b64_cmpst.asm b/runtime/test/shaders/cs_lds_b64_cmpst.asm
new file mode 100644
index 000000000..0998d8576
--- /dev/null
+++ b/runtime/test/shaders/cs_lds_b64_cmpst.asm
@@ -0,0 +1,132 @@
1; GPU test for the two LDS families that docs/design.md lists as not GPU-verified:
2; ds_cmpst_b32 (the non-returning compare-and-store) and the b64 2-address forms
3; (ds_read2_b64 / ds_write2_b64 and their st64 variants).
4;
5; LDS 4 KiB (RSRC2 0x40088), group 32x1x1, only lane 0 runs. The output words are
6; derived from the RDNA2 ISA's 2-address and DS_CMPST_B32 pseudocode:
7;
8; out[0..3] ds_write2_b64 then ds_read2_b64 at base 0x20, offset0:1 offset1:3,
9; writes A at 0x28 and B at 0x38 (unit 8), reads the same two elements:
10; A.lo A.hi B.lo B.hi
11; out[4] ds_read2st64_b64 at base 0x100, offset0:0 offset1:1 (unit 512):
12; XOR of the four dwords seeded at 0x100 and 0x300
13; out[5] ds_write2st64_b64 at base 0x100, offset0:0 offset1:1, then plain
14; ds_read_b32 at 0x100/0x104/0x300/0x304: XOR of the four dwords
15; out[6] ds_read2_b64 v[2:5], v2 at base 0x200 (vdst overlaps vaddr): the
16; second element's low dword, 0xBBBB000B, read before v2 is overwritten
17; out[7] ds_cmpst_b32 hit (mem 0x13572468 -> 0x2468ABCD) XOR the miss case's
18; unchanged word (0x11111111): 0x3579BADC
19;
20; Run: vk_compute_test cs_lds_b64_cmpst.spv 1 dump
21; -> out[0..7] = 0x11110001 0x22220002 0x33330003 0x44440004
22; 0xCCCC000C 0x44440004 0xBBBB000B 0x3579BADC
23; rsrc2: 0x40088
24; group: 32,1,1
25; mattr: +wavefrontsize32,-wavefrontsize64
26v_cmpx_eq_u32_e32 0, v0
27
28; --- ds_write2_b64 / ds_read2_b64, unit 8 bytes ---
29v_mov_b32_e32 v2, 0x20
30v_mov_b32_e32 v4, 0x11110001
31v_mov_b32_e32 v5, 0x22220002
32v_mov_b32_e32 v6, 0x33330003
33v_mov_b32_e32 v7, 0x44440004
34ds_write2_b64 v2, v[4:5], v[6:7] offset0:1 offset1:3
35s_waitcnt lgkmcnt(0)
36ds_read2_b64 v[10:13], v2 offset0:1 offset1:3
37s_waitcnt lgkmcnt(0)
38v_mov_b32_e32 v21, 0
39buffer_store_dword v10, v21, s[0:3], 0 offen
40v_mov_b32_e32 v21, 4
41buffer_store_dword v11, v21, s[0:3], 0 offen
42v_mov_b32_e32 v21, 8
43buffer_store_dword v12, v21, s[0:3], 0 offen
44v_mov_b32_e32 v21, 12
45buffer_store_dword v13, v21, s[0:3], 0 offen
46
47; --- ds_read2st64_b64, unit 512 bytes: seed 0x100 and 0x300 ---
48v_mov_b32_e32 v1, 0x100
49v_mov_b32_e32 v3, 0x55550005
50ds_write_b32 v1, v3
51v_mov_b32_e32 v1, 0x104
52v_mov_b32_e32 v3, 0x66660006
53ds_write_b32 v1, v3
54v_mov_b32_e32 v1, 0x300
55v_mov_b32_e32 v3, 0x77770007
56ds_write_b32 v1, v3
57v_mov_b32_e32 v1, 0x304
58v_mov_b32_e32 v3, 0x88880008
59ds_write_b32 v1, v3
60s_waitcnt lgkmcnt(0)
61v_mov_b32_e32 v2, 0x100
62ds_read2st64_b64 v[10:13], v2 offset0:0 offset1:1
63s_waitcnt lgkmcnt(0)
64v_xor_b32_e32 v14, v10, v11
65v_xor_b32_e32 v14, v14, v12
66v_xor_b32_e32 v14, v14, v13
67v_mov_b32_e32 v21, 16
68buffer_store_dword v14, v21, s[0:3], 0 offen
69
70; --- ds_write2st64_b64, unit 512 bytes: A at 0x100, B at 0x300 ---
71v_mov_b32_e32 v2, 0x100
72ds_write2st64_b64 v2, v[4:5], v[6:7] offset0:0 offset1:1
73s_waitcnt lgkmcnt(0)
74v_mov_b32_e32 v1, 0x100
75ds_read_b32 v10, v1
76v_mov_b32_e32 v1, 0x104
77ds_read_b32 v11, v1
78v_mov_b32_e32 v1, 0x300
79ds_read_b32 v12, v1
80v_mov_b32_e32 v1, 0x304
81ds_read_b32 v13, v1
82s_waitcnt lgkmcnt(0)
83v_xor_b32_e32 v15, v10, v11
84v_xor_b32_e32 v15, v15, v12
85v_xor_b32_e32 v15, v15, v13
86v_mov_b32_e32 v21, 20
87buffer_store_dword v15, v21, s[0:3], 0 offen
88
89; --- ds_read2_b64 with vdst overlapping vaddr: v[2:5] <- base v2 ---
90v_mov_b32_e32 v1, 0x200
91v_mov_b32_e32 v3, 0x99990009
92ds_write_b32 v1, v3
93v_mov_b32_e32 v1, 0x204
94v_mov_b32_e32 v3, 0xAAAA000A
95ds_write_b32 v1, v3
96v_mov_b32_e32 v1, 0x208
97v_mov_b32_e32 v3, 0xBBBB000B
98ds_write_b32 v1, v3
99v_mov_b32_e32 v1, 0x20C
100v_mov_b32_e32 v3, 0xCCCC000C
101ds_write_b32 v1, v3
102s_waitcnt lgkmcnt(0)
103v_mov_b32_e32 v2, 0x200
104ds_read2_b64 v[2:5], v2 offset0:0 offset1:1
105s_waitcnt lgkmcnt(0)
106v_mov_b32_e32 v21, 24
107buffer_store_dword v4, v21, s[0:3], 0 offen
108
109; --- ds_cmpst_b32: hit at 0x400, miss at 0x404 ---
110v_mov_b32_e32 v1, 0x400
111v_mov_b32_e32 v3, 0x13572468
112ds_write_b32 v1, v3
113v_mov_b32_e32 v1, 0x404
114v_mov_b32_e32 v3, 0x11111111
115ds_write_b32 v1, v3
116s_waitcnt lgkmcnt(0)
117v_mov_b32_e32 v1, 0x400
118v_mov_b32_e32 v3, 0x13572468
119v_mov_b32_e32 v4, 0x2468ABCD
120ds_cmpst_b32 v1, v3, v4
121s_waitcnt lgkmcnt(0)
122ds_read_b32 v10, v1
123v_mov_b32_e32 v1, 0x404
124v_mov_b32_e32 v3, 0
125v_mov_b32_e32 v4, 0xFFFFFFFF
126ds_cmpst_b32 v1, v3, v4
127s_waitcnt lgkmcnt(0)
128ds_read_b32 v11, v1
129v_xor_b32_e32 v16, v10, v11
130v_mov_b32_e32 v21, 28
131buffer_store_dword v16, v21, s[0:3], 0 offen
132s_endpgm
diff --git a/runtime/test/shaders/cs_m4_fill.asm b/runtime/test/shaders/cs_m4_fill.asm
new file mode 100644
index 000000000..1af46dac9
--- /dev/null
+++ b/runtime/test/shaders/cs_m4_fill.asm
@@ -0,0 +1,51 @@
1; group: 64,1,1
2; rsrc2: 0x808c
3; fssm-at: 0x150
4; fssm-data: 0x4c4c4946 0x3d344d5f
5; M4 compute shader 1: fills a structured UAV buffer and a typed UAV image from a raw input buffer, and writes the
6; arguments of the next (indirect) dispatch. Run: d3d12_m4_compute_test (a compute PSO found by the SHA-256 of its
7; synthetic FSSM header, as for the other cs_ shaders).
8; User data, from the root signature: [0] four 32-bit constants, [1] a descriptor table of five UAVs. RSRC2 0x808c =
9; six user SGPRs and TGID_X, so the group index is s6:
10; s0 = seed s1 = multiplier s2 = group count of the indirect dispatch s3 = unused
11; s[4:5] = console VA of the table's first slot. A slot is 32 bytes: a V# in its first 16 bytes or a T# in all 32.
12; slot 0 (+0x00): V#, structured buffer, stride 16, 256 records (written)
13; slot 1 (+0x20): V#, raw buffer, the arguments of the indirect dispatch (written)
14; slot 2 (+0x40): T#, 16x16 R32_UINT image (written)
15; slot 3 (+0x60): V#, raw buffer, 256 input words (read)
16; slot 4 (+0x80): V#, raw buffer, the second shader's output (not used here)
17; g = 64 * group + lane, 0..255: in = input[g]
18; record g = { in + seed, g * mul, in ^ (g << 8), rotr(in, 13) }
19; image(x = g & 15, y = g >> 4) = in * 3 + x * 0x10001 + y
20; g == 0 also writes the arguments { s2, 1, 1, 0xc0de0001 }
21s_load_dwordx4 s[8:11], s[4:5], 0x0
22s_load_dwordx4 s[12:15], s[4:5], 0x20
23s_load_dwordx8 s[16:23], s[4:5], 0x40
24s_load_dwordx4 s[24:27], s[4:5], 0x60
25s_lshl_b32 s7, s6, 6
26s_waitcnt lgkmcnt(0)
27v_add_nc_u32_e32 v1, s7, v0
28v_lshlrev_b32_e32 v2, 2, v1
29buffer_load_dword v3, v2, s[24:27], 0 offen
30s_waitcnt vmcnt(0)
31v_add_nc_u32_e32 v4, s0, v3
32v_mul_lo_u32 v5, v1, s1
33v_lshlrev_b32_e32 v6, 8, v1
34v_xor_b32_e32 v6, v3, v6
35v_alignbit_b32 v7, v3, v3, 13
36buffer_store_dwordx4 v[4:7], v1, s[8:11], 0 idxen
37v_and_b32_e32 v8, 15, v1
38v_lshrrev_b32_e32 v9, 4, v1
39v_mul_u32_u24_e32 v10, 0x10001, v8
40v_mul_lo_u32 v11, v3, 3
41v_add_nc_u32_e32 v10, v10, v11
42v_add_nc_u32_e32 v10, v10, v9
43image_store v10, v[8:9], s[16:23] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
44v_cmpx_eq_u32_e32 0, v1
45v_mov_b32_e32 v12, 0
46v_mov_b32_e32 v13, s2
47v_mov_b32_e32 v14, 1
48v_mov_b32_e32 v15, 1
49v_mov_b32_e32 v16, 0xc0de0001
50buffer_store_dwordx4 v[13:16], v12, s[12:15], 0 offen
51s_endpgm
diff --git a/runtime/test/shaders/cs_m4_indirect.asm b/runtime/test/shaders/cs_m4_indirect.asm
new file mode 100644
index 000000000..8a23596bf
--- /dev/null
+++ b/runtime/test/shaders/cs_m4_indirect.asm
@@ -0,0 +1,28 @@
1; group: 64,1,1
2; rsrc2: 0x808c
3; fssm-at: 0x150
4; fssm-data: 0x44444e49 0x3d344d5f
5; M4 compute shader 2: runs under ExecuteIndirect with the arguments cs_m4_fill wrote ({ groups, 1, 1 }), reads the
6; structured buffer and the image the first dispatch wrote, and writes a raw output buffer. Run:
7; d3d12_m4_compute_test. Same root signature, user data and table as cs_m4_fill (see there):
8; slot 0: structured buffer (read) slot 2: R32_UINT image (read, image_load) slot 4: raw output (written)
9; g = 64 * group + lane; t = image(g & 15, g >> 4); record g = { w0, w1, w2, w3 }
10; out[g] = { (w0 + t) ^ w3, (w2 ^ t) + w1 } at byte offset 8 * g
11s_load_dwordx4 s[8:11], s[4:5], 0x0
12s_load_dwordx8 s[16:23], s[4:5], 0x40
13s_load_dwordx4 s[12:15], s[4:5], 0x80
14s_lshl_b32 s7, s6, 6
15s_waitcnt lgkmcnt(0)
16v_add_nc_u32_e32 v1, s7, v0
17buffer_load_dwordx4 v[4:7], v1, s[8:11], 0 idxen
18v_and_b32_e32 v8, 15, v1
19v_lshrrev_b32_e32 v9, 4, v1
20image_load v10, v[8:9], s[16:23] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
21s_waitcnt vmcnt(0)
22v_add_nc_u32_e32 v11, v4, v10
23v_xor_b32_e32 v11, v11, v7
24v_xor_b32_e32 v12, v6, v10
25v_add_nc_u32_e32 v12, v12, v5
26v_lshlrev_b32_e32 v13, 3, v1
27buffer_store_dwordx2 v[11:12], v13, s[12:15], 0 offen
28s_endpgm
diff --git a/runtime/test/shaders/cs_tbuffer_store.asm b/runtime/test/shaders/cs_tbuffer_store.asm
new file mode 100644
index 000000000..a6e0e78e5
--- /dev/null
+++ b/runtime/test/shaders/cs_tbuffer_store.asm
@@ -0,0 +1,275 @@
1; tbuffer_store_format_* and its d16 forms. Every expected word was measured by running this body natively on a Radeon
2; 680M (gfx1035, RDNA2) through tools/hw_oracle's kernel wrapper, with s[0:3] set to the V# vk_compute_test passes;
3; wave32 and wave64 gave the same 52 words. One thread runs.
4; - The instruction's format replaces the V#'s, for the encoding, the element size and the bounds check alike. No
5; format modifier means GFX10's default, BUF_FMT_8_UNORM: one byte, its neighbours kept.
6; - A store writes its format's whole element: components the format has but the instruction doesn't give are 0
7; (xy into 16_16_16_16 leaves z = w = 0); components the format doesn't have are dropped (xyzw into 32_32 writes
8; x, y; into 32 only x).
9; - d16 data is two 16-bit values per VGPR, low half first.
10; - Bounds (OOB_SELECT 3): the instruction's element must end inside num_records. With NR 0x298, an xy store of a
11; 16-byte element at 0x290 writes nothing, though a V# that says 32_FLOAT has a 4-byte element; with NR 0x2a1, an
12; 8_UNORM byte at 0x2a0 is written, though the V#'s 16-byte element would not fit.
13; - A V# whose FORMAT is 0 (INVALID) disables the store, though the instruction brings its own format.
14; Store regions 0x200..0x2cf start as 0xa5a50000 | address; out[0..51] are the 13 regions read back, in source order.
15; Run: VKC_OUT_WORDS=192 VKC_DUMP=<file> vk_compute_test cs_tbuffer_store.spv 1 dump; check.py compares words 0..127 of
16; the dump with TBUFFER_STORE_WORDS and 76 untouched 0xeeeeeeee words.
17v_cmpx_eq_u32_e32 0, v0
18; the store regions 0x200..0x2cf hold 0xa5a50000 | their address
19v_mov_b32_e32 v1, 0xa5a50200
20v_mov_b32_e32 v2, 0xa5a50204
21v_mov_b32_e32 v3, 0xa5a50208
22v_mov_b32_e32 v4, 0xa5a5020c
23v_mov_b32_e32 v5, 0x200
24buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
25v_mov_b32_e32 v1, 0xa5a50210
26v_mov_b32_e32 v2, 0xa5a50214
27v_mov_b32_e32 v3, 0xa5a50218
28v_mov_b32_e32 v4, 0xa5a5021c
29v_mov_b32_e32 v5, 0x210
30buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
31v_mov_b32_e32 v1, 0xa5a50220
32v_mov_b32_e32 v2, 0xa5a50224
33v_mov_b32_e32 v3, 0xa5a50228
34v_mov_b32_e32 v4, 0xa5a5022c
35v_mov_b32_e32 v5, 0x220
36buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
37v_mov_b32_e32 v1, 0xa5a50230
38v_mov_b32_e32 v2, 0xa5a50234
39v_mov_b32_e32 v3, 0xa5a50238
40v_mov_b32_e32 v4, 0xa5a5023c
41v_mov_b32_e32 v5, 0x230
42buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
43v_mov_b32_e32 v1, 0xa5a50240
44v_mov_b32_e32 v2, 0xa5a50244
45v_mov_b32_e32 v3, 0xa5a50248
46v_mov_b32_e32 v4, 0xa5a5024c
47v_mov_b32_e32 v5, 0x240
48buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
49v_mov_b32_e32 v1, 0xa5a50250
50v_mov_b32_e32 v2, 0xa5a50254
51v_mov_b32_e32 v3, 0xa5a50258
52v_mov_b32_e32 v4, 0xa5a5025c
53v_mov_b32_e32 v5, 0x250
54buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
55v_mov_b32_e32 v1, 0xa5a50260
56v_mov_b32_e32 v2, 0xa5a50264
57v_mov_b32_e32 v3, 0xa5a50268
58v_mov_b32_e32 v4, 0xa5a5026c
59v_mov_b32_e32 v5, 0x260
60buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
61v_mov_b32_e32 v1, 0xa5a50270
62v_mov_b32_e32 v2, 0xa5a50274
63v_mov_b32_e32 v3, 0xa5a50278
64v_mov_b32_e32 v4, 0xa5a5027c
65v_mov_b32_e32 v5, 0x270
66buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
67v_mov_b32_e32 v1, 0xa5a50280
68v_mov_b32_e32 v2, 0xa5a50284
69v_mov_b32_e32 v3, 0xa5a50288
70v_mov_b32_e32 v4, 0xa5a5028c
71v_mov_b32_e32 v5, 0x280
72buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
73v_mov_b32_e32 v1, 0xa5a50290
74v_mov_b32_e32 v2, 0xa5a50294
75v_mov_b32_e32 v3, 0xa5a50298
76v_mov_b32_e32 v4, 0xa5a5029c
77v_mov_b32_e32 v5, 0x290
78buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
79v_mov_b32_e32 v1, 0xa5a502a0
80v_mov_b32_e32 v2, 0xa5a502a4
81v_mov_b32_e32 v3, 0xa5a502a8
82v_mov_b32_e32 v4, 0xa5a502ac
83v_mov_b32_e32 v5, 0x2a0
84buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
85v_mov_b32_e32 v1, 0xa5a502b0
86v_mov_b32_e32 v2, 0xa5a502b4
87v_mov_b32_e32 v3, 0xa5a502b8
88v_mov_b32_e32 v4, 0xa5a502bc
89v_mov_b32_e32 v5, 0x2b0
90buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
91v_mov_b32_e32 v1, 0xa5a502c0
92v_mov_b32_e32 v2, 0xa5a502c4
93v_mov_b32_e32 v3, 0xa5a502c8
94v_mov_b32_e32 v4, 0xa5a502cc
95v_mov_b32_e32 v5, 0x2c0
96buffer_store_dwordx4 v[1:4], v5, s[0:3], 0 offen
97s_waitcnt_vscnt null, 0x0
98s_mov_b32 s4, s0
99s_mov_b32 s5, s1
100; 0x200: tbuffer_store_format_xyzw, xyzw, 32_32_32_32_FLOAT over a V# that says 32_FLOAT: all four dwords
101v_mov_b32_e32 v20, 0x3f800000
102v_mov_b32_e32 v21, 0x40000000
103v_mov_b32_e32 v22, 0x40400000
104v_mov_b32_e32 v23, 0x40800000
105s_mov_b32 s6, 0xffffffff
106s_mov_b32 s7, 0x31016fac
107v_mov_b32_e32 v5, 0x200
108tbuffer_store_format_xyzw v[20:23], v5, s[4:7], 0 format:[BUF_FMT_32_32_32_32_FLOAT] offen
109; 0x210: tbuffer_store_format_xy, xy, 16_16_16_16_FLOAT over a V# that says 32_32_32_32_FLOAT: the 8-byte element, z = w = 0
110v_mov_b32_e32 v20, 0x3f800000
111v_mov_b32_e32 v21, 0x40000000
112s_mov_b32 s6, 0xffffffff
113s_mov_b32 s7, 0x3104dfac
114v_mov_b32_e32 v5, 0x210
115tbuffer_store_format_xy v[20:21], v5, s[4:7], 0 format:[BUF_FMT_16_16_16_16_FLOAT] offen
116; 0x220: tbuffer_store_format_xyz, xyz, 8_8_8_8_UINT over a V# that says 32_FLOAT
117v_mov_b32_e32 v20, 0x1
118v_mov_b32_e32 v21, 0x2
119v_mov_b32_e32 v22, 0x3
120s_mov_b32 s6, 0xffffffff
121s_mov_b32 s7, 0x31016fac
122v_mov_b32_e32 v5, 0x220
123tbuffer_store_format_xyz v[20:22], v5, s[4:7], 0 format:[BUF_FMT_8_8_8_8_UINT] offen
124; 0x230: tbuffer_store_format_x, x, no format modifier (GFX10 default 8_UNORM) at byte 1, over a V# that says 32_32_32_32_FLOAT
125v_mov_b32_e32 v20, 0x3f800000
126s_mov_b32 s6, 0xffffffff
127s_mov_b32 s7, 0x3104dfac
128v_mov_b32_e32 v5, 0x231
129tbuffer_store_format_x v20, v5, s[4:7], 0 offen
130; 0x240: tbuffer_store_format_x, x, 16_FLOAT at byte 2 (the high half)
131v_mov_b32_e32 v20, 0x40000000
132s_mov_b32 s6, 0xffffffff
133s_mov_b32 s7, 0x31016fac
134v_mov_b32_e32 v5, 0x242
135tbuffer_store_format_x v20, v5, s[4:7], 0 format:[BUF_FMT_16_FLOAT] offen
136; 0x250: tbuffer_store_format_xyzw, xyzw, 2_10_10_10_UNORM (1.0, 0.0, 0.25, 1.0)
137v_mov_b32_e32 v20, 0x3f800000
138v_mov_b32_e32 v21, 0x0
139v_mov_b32_e32 v22, 0x3e800000
140v_mov_b32_e32 v23, 0x3f800000
141s_mov_b32 s6, 0xffffffff
142s_mov_b32 s7, 0x31016fac
143v_mov_b32_e32 v5, 0x250
144tbuffer_store_format_xyzw v[20:23], v5, s[4:7], 0 format:[BUF_FMT_2_10_10_10_UNORM] offen
145; 0x260: tbuffer_store_format_xyzw, xyzw into 32_32_FLOAT: only x, y
146v_mov_b32_e32 v20, 0x3f800000
147v_mov_b32_e32 v21, 0x40000000
148v_mov_b32_e32 v22, 0x40400000
149v_mov_b32_e32 v23, 0x40800000
150s_mov_b32 s6, 0xffffffff
151s_mov_b32 s7, 0x3104dfac
152v_mov_b32_e32 v5, 0x260
153tbuffer_store_format_xyzw v[20:23], v5, s[4:7], 0 format:[BUF_FMT_32_32_FLOAT] offen
154; 0x270: tbuffer_store_format_d16_xy, d16_xy, 16_16_FLOAT (packed 1.0, 2.0)
155v_mov_b32_e32 v20, 0x40003c00
156s_mov_b32 s6, 0xffffffff
157s_mov_b32 s7, 0x3104dfac
158v_mov_b32_e32 v5, 0x270
159tbuffer_store_format_d16_xy v20, v5, s[4:7], 0 format:[BUF_FMT_16_16_FLOAT] offen
160; 0x280: tbuffer_store_format_d16_xyzw, d16_xyzw, 8_8_8_8_UNORM (packed 1.0, 0.5, 0.0, 1.0)
161v_mov_b32_e32 v20, 0x38003c00
162v_mov_b32_e32 v21, 0x3c000000
163s_mov_b32 s6, 0xffffffff
164s_mov_b32 s7, 0x31016fac
165v_mov_b32_e32 v5, 0x280
166tbuffer_store_format_d16_xyzw v[20:21], v5, s[4:7], 0 format:[BUF_FMT_8_8_8_8_UNORM] offen
167; 0x290: tbuffer_store_format_xy, xy, 32_32_32_32_FLOAT, NR 0x298 over a V# that says 32_FLOAT: x, y end at 0x298, the element at 0x2a0
168v_mov_b32_e32 v20, 0x3f800000
169v_mov_b32_e32 v21, 0x40000000
170s_mov_b32 s6, 0x298
171s_mov_b32 s7, 0x31016fac
172v_mov_b32_e32 v5, 0x290
173tbuffer_store_format_xy v[20:21], v5, s[4:7], 0 format:[BUF_FMT_32_32_32_32_FLOAT] offen
174; 0x2a0: tbuffer_store_format_x, x, 8_UNORM, NR 0x2a1 over a V# that says 32_32_32_32_FLOAT: the byte fits, the V#'s element would not
175v_mov_b32_e32 v20, 0x3f800000
176s_mov_b32 s6, 0x2a1
177s_mov_b32 s7, 0x3104dfac
178v_mov_b32_e32 v5, 0x2a0
179tbuffer_store_format_x v20, v5, s[4:7], 0 format:[BUF_FMT_8_UNORM] offen
180; 0x2b0: tbuffer_store_format_xyzw, xyzw into 32_FLOAT (one channel) over a V# that says 32_32_32_32_FLOAT: only x
181v_mov_b32_e32 v20, 0x3f800000
182v_mov_b32_e32 v21, 0x40000000
183v_mov_b32_e32 v22, 0x40400000
184v_mov_b32_e32 v23, 0x40800000
185s_mov_b32 s6, 0xffffffff
186s_mov_b32 s7, 0x3104dfac
187v_mov_b32_e32 v5, 0x2b0
188tbuffer_store_format_xyzw v[20:23], v5, s[4:7], 0 format:[BUF_FMT_32_FLOAT] offen
189; 0x2c0: tbuffer_store_format_xy, xy, 32_32_FLOAT over a V# whose FORMAT is 0 (INVALID): nothing
190v_mov_b32_e32 v20, 0x3f800000
191v_mov_b32_e32 v21, 0x40000000
192s_mov_b32 s6, 0xffffffff
193s_mov_b32 s7, 0x31000fac
194v_mov_b32_e32 v5, 0x2c0
195tbuffer_store_format_xy v[20:21], v5, s[4:7], 0 format:[BUF_FMT_32_32_FLOAT] offen
196s_waitcnt_vscnt null, 0x0
197; out[0..3]: the 16 bytes at 0x200
198v_mov_b32_e32 v5, 0x200
199buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
200s_waitcnt vmcnt(0)
201v_mov_b32_e32 v6, 0x0
202buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
203; out[4..7]: the 16 bytes at 0x210
204v_mov_b32_e32 v5, 0x210
205buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
206s_waitcnt vmcnt(0)
207v_mov_b32_e32 v6, 0x10
208buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
209; out[8..11]: the 16 bytes at 0x220
210v_mov_b32_e32 v5, 0x220
211buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
212s_waitcnt vmcnt(0)
213v_mov_b32_e32 v6, 0x20
214buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
215; out[12..15]: the 16 bytes at 0x230
216v_mov_b32_e32 v5, 0x230
217buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
218s_waitcnt vmcnt(0)
219v_mov_b32_e32 v6, 0x30
220buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
221; out[16..19]: the 16 bytes at 0x240
222v_mov_b32_e32 v5, 0x240
223buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
224s_waitcnt vmcnt(0)
225v_mov_b32_e32 v6, 0x40
226buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
227; out[20..23]: the 16 bytes at 0x250
228v_mov_b32_e32 v5, 0x250
229buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
230s_waitcnt vmcnt(0)
231v_mov_b32_e32 v6, 0x50
232buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
233; out[24..27]: the 16 bytes at 0x260
234v_mov_b32_e32 v5, 0x260
235buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
236s_waitcnt vmcnt(0)
237v_mov_b32_e32 v6, 0x60
238buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
239; out[28..31]: the 16 bytes at 0x270
240v_mov_b32_e32 v5, 0x270
241buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
242s_waitcnt vmcnt(0)
243v_mov_b32_e32 v6, 0x70
244buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
245; out[32..35]: the 16 bytes at 0x280
246v_mov_b32_e32 v5, 0x280
247buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
248s_waitcnt vmcnt(0)
249v_mov_b32_e32 v6, 0x80
250buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
251; out[36..39]: the 16 bytes at 0x290
252v_mov_b32_e32 v5, 0x290
253buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
254s_waitcnt vmcnt(0)
255v_mov_b32_e32 v6, 0x90
256buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
257; out[40..43]: the 16 bytes at 0x2a0
258v_mov_b32_e32 v5, 0x2a0
259buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
260s_waitcnt vmcnt(0)
261v_mov_b32_e32 v6, 0xa0
262buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
263; out[44..47]: the 16 bytes at 0x2b0
264v_mov_b32_e32 v5, 0x2b0
265buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
266s_waitcnt vmcnt(0)
267v_mov_b32_e32 v6, 0xb0
268buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
269; out[48..51]: the 16 bytes at 0x2c0
270v_mov_b32_e32 v5, 0x2c0
271buffer_load_dwordx4 v[10:13], v5, s[0:3], 0 offen
272s_waitcnt vmcnt(0)
273v_mov_b32_e32 v6, 0xc0
274buffer_store_dwordx4 v[10:13], v6, s[0:3], 0 offen
275s_endpgm
diff --git a/runtime/test/shaders/ps_imgatomic.asm b/runtime/test/shaders/ps_imgatomic.asm
new file mode 100644
index 000000000..b8f888c13
--- /dev/null
+++ b/runtime/test/shaders/ps_imgatomic.asm
@@ -0,0 +1,44 @@
1; Image atomics in a pixel shader, the forms the game uses (1,018 of its 1,038 image-atomic shaders are pixel shaders:
2; image_atomic_or / umin / umax on a 2D image and umax on a 3D one), through the descriptor table and the set-0
3; r32ui storage arrays (binding 4 for 2D, 7 for 3D). User data s2:s3 is the console VA of a table of four T#s:
4; +0x00 the 2D umax image, +0x20 the 2D umin image, +0x40 the 2D or image, +0x60 the 3D umax image (any 8 dwords:
5; only the key matters). Each of the 64x64 pixels computes px, py from attr0 (vs_ids runs it 0..1 over the target),
6; its id = px + 64 * py, and its texel tx = px >> 3, ty = py >> 3, so 64 pixels contend for each texel of the 8x8
7; images:
8; umax2d[ty][tx] = max(id), umin2d[ty][tx] = min(id), or2d[ty][tx] |= 1 << (id & 31),
9; umax3d[px & 3][ty >> 1][tx >> 1] = max(id) (a 4x4x4 image)
10; After its atomics, every odd px is discarded (v_cmpx). The atomics of a pixel that is discarded afterwards still
11; count, as on hardware: the expected values above are over all 4096 pixels. Even pixels export 1.0.
12; Run: vk_bindless_test vs_ids.spv ps_imgatomic.spv (images cleared to 0, umin to 0xffffffff; checked per texel)
13s_load_dwordx8 s[8:15], s[2:3], 0x0
14s_load_dwordx8 s[16:23], s[2:3], 0x20
15s_load_dwordx8 s[24:31], s[2:3], 0x40
16s_load_dwordx8 s[32:39], s[2:3], 0x60
17s_waitcnt lgkmcnt(0)
18v_interp_p1_f32_e32 v2, v0, attr0.x
19v_interp_p2_f32_e32 v2, v1, attr0.x
20v_interp_p1_f32_e32 v3, v0, attr0.y
21v_interp_p2_f32_e32 v3, v1, attr0.y
22v_mul_f32_e32 v2, 0x42800000, v2
23v_mul_f32_e32 v3, 0x42800000, v3
24v_cvt_u32_f32_e32 v4, v2
25v_cvt_u32_f32_e32 v5, v3
26v_lshlrev_b32_e32 v6, 6, v5
27v_add_nc_u32_e32 v6, v6, v4
28v_lshrrev_b32_e32 v7, 3, v4
29v_lshrrev_b32_e32 v8, 3, v5
30image_atomic_umax v6, v[7:8], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
31image_atomic_umin v6, v[7:8], s[16:23] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
32v_and_b32_e32 v9, 31, v6
33v_lshlrev_b32_e64 v9, v9, 1
34image_atomic_or v9, v[7:8], s[24:31] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
35v_lshrrev_b32_e32 v10, 1, v7
36v_lshrrev_b32_e32 v11, 1, v8
37v_and_b32_e32 v12, 3, v4
38image_atomic_umax v6, v[10:12], s[32:39] dmask:0x1 dim:SQ_RSRC_IMG_3D unorm
39s_waitcnt vmcnt(0)
40v_and_b32_e32 v13, 1, v4
41v_cmpx_eq_u32_e32 0, v13
42v_mov_b32_e32 v14, 1.0
43exp mrt0 v14, v14, v14, v14 done vm
44s_endpgm
diff --git a/runtime/test/shaders/ps_m2_uoff.asm b/runtime/test/shaders/ps_m2_uoff.asm
index 7f1167944..1c96f50d5 100644
--- a/runtime/test/shaders/ps_m2_uoff.asm
+++ b/runtime/test/shaders/ps_m2_uoff.asm
@@ -2,9 +2,12 @@
2; and the fallback sampler give the same pixels; with U + 1 the CLAMP sampler returns the last column and the WRAP one 2; and the fallback sampler give the same pixels; with U + 1 the CLAMP sampler returns the last column and the WRAP one
3; the same texel as without the offset, so the pixels tell which sampler the draw used. Idea and measurements by 3; the same texel as without the offset, so the pixels tell which sampler the draw used. Idea and measurements by
4; @Vonsek (#1489). Run: d3d12_m2_textured_test. 4; @Vonsek (#1489). Run: d3d12_m2_textured_test.
5; The same unbounded SRV table stays bound across both draws. Root constants s4 and s5 hold
6; the descriptor index and byte stride, respectively.
5; fssm-at: 0x10 7; fssm-at: 0x10
6; fssm-data: 0x324d5350 0x4f465520 8; fssm-data: 0x324d5350 0x4f465520
7s_load_dwordx8 s[8:15], s[0:1], 0x0 9s_mul_i32 s20, s4, s5
10s_load_dwordx8 s[8:15], s[0:1], s20
8s_load_dwordx4 s[16:19], s[2:3], 0x0 11s_load_dwordx4 s[16:19], s[2:3], 0x0
9s_waitcnt lgkmcnt(0) 12s_waitcnt lgkmcnt(0)
10v_interp_p1_f32_e32 v2, v0, attr0.x 13v_interp_p1_f32_e32 v2, v0, attr0.x
diff --git a/runtime/test/shaders/ps_mandelbrot.asm b/runtime/test/shaders/ps_mandelbrot.asm
new file mode 100644
index 000000000..98c70f6cc
--- /dev/null
+++ b/runtime/test/shaders/ps_mandelbrot.asm
@@ -0,0 +1,46 @@
1; Mandelbrot set: a divergent backward loop with EXEC masking. Each lane iterates z = z^2 + c until |z|^2 > 4 or
2; 64 iterations, with c from attr0.xy (u, v 0..1 over the image) mapped to [-2.25, 0.75] x [-1.5, 1.5]. A lane that
3; escapes drops out of EXEC (s_and_b32 exec_lo, exec_lo, vcc_lo); s_cbranch_execz leaves the loop once every lane has
4; escaped, else the uniform counter s10 ends it after 64 rounds. EXEC is restored from s20 before the export.
5; Only v_mul/v_add/v_sub (no FMA), so a float32 model on the CPU gives the same counts.
6; Branch offsets are dwords from the next instruction: execz +9 forward to the restore, scc1 -15 back to the loop top.
7; Run: vk_harness vs_ids.spv ps_mandelbrot.spv out.raw
8; -> mrt0 = (sqrt(t), t*t, 4t(1-t), iteration count as raw bits) with t = count / 64
9v_interp_p1_f32_e32 v2, v0, attr0.x
10v_interp_p2_f32_e32 v2, v1, attr0.x
11v_interp_p1_f32_e32 v3, v0, attr0.y
12v_interp_p2_f32_e32 v3, v1, attr0.y
13v_mul_f32_e32 v4, 0x40400000, v2
14v_add_f32_e32 v4, 0xc0100000, v4
15v_mul_f32_e32 v5, 0x40400000, v3
16v_add_f32_e32 v5, 0xbfc00000, v5
17v_mov_b32_e32 v6, 0
18v_mov_b32_e32 v7, 0
19v_mov_b32_e32 v8, 0
20s_mov_b32 s10, 0
21s_mov_b32 s20, exec_lo
22v_mul_f32_e32 v9, v6, v6
23v_mul_f32_e32 v10, v7, v7
24v_add_f32_e32 v11, v9, v10
25v_cmp_ge_f32_e32 vcc_lo, 4.0, v11
26s_and_b32 exec_lo, exec_lo, vcc_lo
27s_cbranch_execz 9
28v_sub_f32_e32 v12, v9, v10
29v_mul_f32_e32 v13, v6, v7
30v_add_f32_e32 v13, v13, v13
31v_add_f32_e32 v6, v12, v4
32v_add_f32_e32 v7, v13, v5
33v_add_nc_u32_e32 v8, 1, v8
34s_add_u32 s10, s10, 1
35s_cmp_lt_u32 s10, 64
36s_cbranch_scc1 -15
37s_mov_b32 exec_lo, s20
38v_cvt_f32_u32_e32 v14, v8
39v_mul_f32_e32 v14, 0x3c800000, v14
40v_sqrt_f32_e32 v15, v14
41v_mul_f32_e32 v16, v14, v14
42v_sub_f32_e32 v17, 1.0, v14
43v_mul_f32_e32 v17, v14, v17
44v_mul_f32_e32 v17, 4.0, v17
45exp mrt0 v15, v16, v17, v8 done vm
46s_endpgm
diff --git a/runtime/test/shaders/ps_scc_logic32.asm b/runtime/test/shaders/ps_scc_logic32.asm
new file mode 100644
index 000000000..3b36f1362
--- /dev/null
+++ b/runtime/test/shaders/ps_scc_logic32.asm
@@ -0,0 +1,44 @@
1; s_nand_b32, s_nor_b32, s_xnor_b32: D = ~(S0 op S1), SCC = (D != 0). Values by hand from the RDNA2 ISA SOP2 text.
2; s2 = 0xf0f0f0f0, s3 = 0xff00ff00: and = 0xf000f000, or = 0xfff0fff0, xor = 0x0ff00ff0.
3; Expected mrt0 bits: nand 0x0fff0fff, nor 0x000f000f, xnor 0xf00ff00f, and an SCC word, bit n = SCC after case n:
4; 0 nand(-1, -1) = 0 -> 0 1 nor(0, 0) = -1 -> 1 2 xnor(x, x) = -1 -> 1
5; 3 xnor(x, ~x) = 0 -> 0 4 nor(0xfffffff0, 0) = 0xf -> 1 5 nand(0x80000000, -1) = 0x7fffffff -> 1
6; so the SCC word is 0x36.
7s_mov_b32 s2, 0xf0f0f0f0
8s_mov_b32 s3, 0xff00ff00
9s_nand_b32 s4, s2, s3
10s_nor_b32 s5, s2, s3
11s_xnor_b32 s6, s2, s3
12s_mov_b32 s8, -1
13s_mov_b32 s9, 0
14s_mov_b32 s10, 0x0f0f0f0f
15s_mov_b32 s11, 0xfffffff0
16s_mov_b32 s12, 0x80000000
17s_nand_b32 s13, s8, s8
18s_cselect_b32 s20, 1, 0
19s_nor_b32 s13, s9, s9
20s_cselect_b32 s21, 1, 0
21s_xnor_b32 s13, s2, s2
22s_cselect_b32 s22, 1, 0
23s_xnor_b32 s13, s2, s10
24s_cselect_b32 s23, 1, 0
25s_nor_b32 s13, s11, s9
26s_cselect_b32 s24, 1, 0
27s_nand_b32 s13, s12, s8
28s_cselect_b32 s25, 1, 0
29s_lshl_b32 s21, s21, 1
30s_lshl_b32 s22, s22, 2
31s_lshl_b32 s23, s23, 3
32s_lshl_b32 s24, s24, 4
33s_lshl_b32 s25, s25, 5
34s_or_b32 s20, s20, s21
35s_or_b32 s20, s20, s22
36s_or_b32 s20, s20, s23
37s_or_b32 s20, s20, s24
38s_or_b32 s20, s20, s25
39v_mov_b32_e32 v0, s4
40v_mov_b32_e32 v1, s5
41v_mov_b32_e32 v2, s6
42v_mov_b32_e32 v3, s20
43exp mrt0 v0, v1, v2, v3 done vm
44s_endpgm
diff --git a/runtime/test/shaders/ps_scc_logic64.asm b/runtime/test/shaders/ps_scc_logic64.asm
new file mode 100644
index 000000000..3ffb677ae
--- /dev/null
+++ b/runtime/test/shaders/ps_scc_logic64.asm
@@ -0,0 +1,49 @@
1; s_nand_b64, s_nor_b64, s_xnor_b64 on plain SGPR pairs: D = ~(S0 op S1), SCC = ((D.lo | D.hi) != 0). By hand from the RDNA2 ISA.
2; A = s[2:3] = (lo 0xf0f0f0f0, hi 0x0000ffff), B = s[4:5] = (lo 0xff00ff00, hi 0x00ff00ff).
3; Expected mrt0 bits: nand.lo 0x0fff0fff, nor.hi 0xff000000 (A.hi | B.hi = 0x00ffffff), xnor.hi 0xff0000ff (A.hi ^ B.hi = 0x00ffff00),
4; and an SCC word, bit n = SCC after case n (X = (-1, 0), Y = (0, -1)):
5; 0 nand(ones, ones) = 0 -> 0 1 nor(X, 0) = (0, -1), only the high dword set -> 1
6; 2 xnor(X, X) = all ones -> 1 3 xnor(X, Y) = 0 -> 0
7; 4 nor(Y, (0xfffffff0, 0)) = (0xf, 0), only the low dword set -> 1
8; so the SCC word is 0x16.
9s_mov_b32 s2, 0xf0f0f0f0
10s_mov_b32 s3, 0x0000ffff
11s_mov_b32 s4, 0xff00ff00
12s_mov_b32 s5, 0x00ff00ff
13s_nand_b64 s[6:7], s[2:3], s[4:5]
14s_nor_b64 s[8:9], s[2:3], s[4:5]
15s_xnor_b64 s[10:11], s[2:3], s[4:5]
16s_mov_b32 s12, -1
17s_mov_b32 s13, -1
18s_mov_b32 s14, -1
19s_mov_b32 s15, 0
20s_mov_b32 s16, 0
21s_mov_b32 s17, -1
22s_mov_b32 s18, 0
23s_mov_b32 s19, 0
24s_mov_b32 s24, 0xfffffff0
25s_mov_b32 s25, 0
26s_nand_b64 s[30:31], s[12:13], s[12:13]
27s_cselect_b32 s40, 1, 0
28s_nor_b64 s[30:31], s[14:15], s[18:19]
29s_cselect_b32 s41, 1, 0
30s_xnor_b64 s[30:31], s[14:15], s[14:15]
31s_cselect_b32 s42, 1, 0
32s_xnor_b64 s[30:31], s[14:15], s[16:17]
33s_cselect_b32 s43, 1, 0
34s_nor_b64 s[30:31], s[16:17], s[24:25]
35s_cselect_b32 s44, 1, 0
36s_lshl_b32 s41, s41, 1
37s_lshl_b32 s42, s42, 2
38s_lshl_b32 s43, s43, 3
39s_lshl_b32 s44, s44, 4
40s_or_b32 s40, s40, s41
41s_or_b32 s40, s40, s42
42s_or_b32 s40, s40, s43
43s_or_b32 s40, s40, s44
44v_mov_b32_e32 v0, s6
45v_mov_b32_e32 v1, s9
46v_mov_b32_e32 v2, s11
47v_mov_b32_e32 v3, s40
48exp mrt0 v0, v1, v2, v3 done vm
49s_endpgm
diff --git a/runtime/test/shaders/vs_w64_a_skip.asm b/runtime/test/shaders/vs_w64_a_skip.asm
new file mode 100644
index 000000000..dac0d885e
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_a_skip.asm
@@ -0,0 +1,45 @@
1; TEST-251 (SHADER-10 tier A, vertex stage): the skip regions and the loop of ps_w64_a_skip in a wave64 vertex shader,
2; without its whole-quad mask (vertex quads are lanes, not pixels). Vertex v (v0 = vertex index) has x = v & 63 and
3; y = v >> 6, so every word is a function of v and not of the lane the vertex landed on. It stores (r0, r1, r2, r3)
4; to its record at heap 0x1000 + 16 * v through the V# in s[0:3].
5; (1) a skip region behind s_cbranch_execz: only lanes with x % 4 == 1 run it. r0 = x % 4 == 1 ? 7 * y + x : 1000 + x.
6; (2) r1 = x % 4 == 1 (the VCC of (1), per lane).
7; (3) s_cbranch_vccz over a region that narrows EXEC to that VCC. r2 = 2000 + y + (y % 4 == 2 ? 9 : 0).
8; (4) a loop closed by s_cbranch_execnz, no scalar state carried. r3 = x % 4 + 1.
9; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
10; vs_w64_a_skip.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32: equal records, and equal
11; to the expected words.
12; mattr: +wavefrontsize64,-wavefrontsize32
13v_and_b32_e32 v2, 63, v0
14v_lshrrev_b32_e32 v3, 6, v0
15s_mov_b64 s[10:11], exec
16v_add_nc_u32_e32 v6, 0x3e8, v2
17v_and_b32_e32 v4, 3, v2
18v_cmp_eq_u32_e32 vcc, 1, v4
19v_cndmask_b32_e64 v7, 0, 1, vcc
20s_and_saveexec_b64 s[12:13], vcc
21s_cbranch_execz 2
22v_mul_u32_u24_e32 v6, 7, v3
23v_add_nc_u32_e32 v6, v6, v2
24s_or_b64 exec, exec, s[12:13]
25v_and_b32_e32 v5, 3, v3
26v_add_nc_u32_e32 v8, 0x7d0, v3
27v_cmp_eq_u32_e32 vcc, 2, v5
28s_cbranch_vccz 3
29s_and_saveexec_b64 s[16:17], vcc
30v_add_nc_u32_e32 v8, 9, v8
31s_or_b64 exec, exec, s[16:17]
32v_add_nc_u32_e32 v10, 1, v4
33v_mov_b32_e32 v9, 0
34v_add_nc_u32_e32 v9, 1, v9
35v_cmp_lt_u32_e32 vcc, v9, v10
36s_and_b64 exec, exec, vcc
37s_cbranch_execnz -4
38s_mov_b64 exec, s[10:11]
39v_lshlrev_b32_e32 v12, 4, v0
40v_add_nc_u32_e32 v12, 0x1000, v12
41buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
42v_mov_b32_e32 v5, 0
43exp pos0 v5, v5, v5, v5 done
44exp param0 v5, v5, v5, v5
45s_endpgm
diff --git a/runtime/test/shaders/vs_w64_b_ballot_atomic.asm b/runtime/test/shaders/vs_w64_b_ballot_atomic.asm
new file mode 100644
index 000000000..f718c25f8
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_b_ballot_atomic.asm
@@ -0,0 +1,42 @@
1; TEST-251 (SHADER-10 tier B, vertex stage): the wave-aggregated atomic of ps_w64_b_ballot_atomic in a wave64 vertex
2; shader. Vertex v (v0 = vertex index) has x = v & 63; vertices with x % 4 == 1 are the "wanted" lanes. EXEC = the
3; wanted lanes; n = s_bcnt1_i32_b64 exec; rank = v_mbcnt_lo/hi of EXEC; the lane of rank 0 does buffer_atomic_add of n
4; to the counter at heap offset 0 and gets the old value back; v_readfirstlane broadcasts it as the base; every wanted
5; vertex stores v + 1 at heap offset 0x100 + 4 * (base + rank). Whatever the wave size and the packing, every wanted
6; vertex gets a slot of its own and the counter ends at the number of wanted vertices (240 of 960); which vertex gets
7; which slot depends on the packing, so the slots are compared as a set. Its record at heap 0x1000 + 16 * v holds
8; (x % 4 == 1, 0, 0, 0).
9; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
10; vs_w64_b_ballot_atomic.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32.
11; mattr: +wavefrontsize64,-wavefrontsize32
12v_and_b32_e32 v2, 63, v0
13v_and_b32_e32 v4, 3, v2
14s_mov_b64 s[10:11], exec
15v_cmp_eq_u32_e32 vcc, 1, v4
16v_cndmask_b32_e64 v6, 0, 1, vcc
17s_and_saveexec_b64 s[12:13], vcc
18s_bcnt1_i32_b64 s6, exec
19v_mbcnt_lo_u32_b32 v10, exec_lo, 0
20v_mbcnt_hi_u32_b32 v10, exec_hi, v10
21v_cmp_eq_u32_e32 vcc, 0, v10
22s_and_saveexec_b64 s[14:15], vcc
23v_mov_b32_e32 v11, s6
24v_mov_b32_e32 v13, 0
25buffer_atomic_add v11, v13, s[0:3], 0 offen glc
26s_or_b64 exec, exec, s[14:15]
27v_readfirstlane_b32 s7, v11
28v_add_nc_u32_e32 v13, s7, v10
29v_lshlrev_b32_e32 v13, 2, v13
30v_add_nc_u32_e32 v14, 1, v0
31buffer_store_dword v14, v13, s[0:3], 0 offen offset:256
32s_mov_b64 exec, s[10:11]
33v_mov_b32_e32 v7, 0
34v_mov_b32_e32 v8, 0
35v_mov_b32_e32 v9, 0
36v_lshlrev_b32_e32 v12, 4, v0
37v_add_nc_u32_e32 v12, 0x1000, v12
38buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
39v_mov_b32_e32 v5, 0
40exp pos0 v5, v5, v5, v5 done
41exp param0 v5, v5, v5, v5
42s_endpgm
diff --git a/runtime/test/shaders/vs_w64_b_readlane_uniform.asm b/runtime/test/shaders/vs_w64_b_readlane_uniform.asm
new file mode 100644
index 000000000..0fb85008d
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_b_readlane_uniform.asm
@@ -0,0 +1,33 @@
1; TEST-251 (SHADER-10 tier B, vertex stage): v_readfirstlane and v_readlane (lanes 40 and 63) of wave-uniform VGPRs
2; in a wave64 vertex shader, the vertex twin of ps_w64_b_readfirstlane and ps_w64_b_readlane_uniform. s4 is a user
3; SGPR (VKH_SGPRS sets it to 123), copied to a VGPR and read back; so is the constant 77. Every lane holds the same
4; value, so the scalar does not depend on which lane is read, on the wave size or on how many vertices a wave got.
5; Vertex v (v0 = vertex index) has x = v & 63. r0 = x + 123 (readfirstlane), r1 = 123 + 77 (readlane 40 and 63),
6; r2 = x + 123 (readlane 40), r3 = 77 * 2 + 123 (readfirstlane), stored to its record at heap 0x1000 + 16 * v
7; through the V# in s[0:3].
8; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000,123 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
9; vs_w64_b_readlane_uniform.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32: equal, and
10; equal to the expected words.
11; mattr: +wavefrontsize64,-wavefrontsize32
12v_and_b32_e32 v2, 63, v0
13s_mov_b64 s[10:11], exec
14v_mov_b32_e32 v5, s4
15v_mov_b32_e32 v4, 77
16v_readfirstlane_b32 s20, v5
17v_add_nc_u32_e32 v6, s20, v2
18v_readlane_b32 s21, v5, 40
19v_readlane_b32 s22, v4, 63
20s_add_u32 s23, s21, s22
21v_mov_b32_e32 v7, s23
22v_add_nc_u32_e32 v8, s21, v2
23v_readfirstlane_b32 s24, v4
24s_lshl_b32 s24, s24, 1
25s_add_u32 s24, s24, s20
26v_mov_b32_e32 v9, s24
27v_lshlrev_b32_e32 v12, 4, v0
28v_add_nc_u32_e32 v12, 0x1000, v12
29buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
30v_mov_b32_e32 v5, 0
31exp pos0 v5, v5, v5, v5 done
32exp param0 v5, v5, v5, v5
33s_endpgm
diff --git a/runtime/test/shaders/vs_w64_b_waterfall.asm b/runtime/test/shaders/vs_w64_b_waterfall.asm
new file mode 100644
index 000000000..814259842
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_b_waterfall.asm
@@ -0,0 +1,35 @@
1; TEST-251 (SHADER-10 tier B, vertex stage): the waterfall loop of ps_w64_b_waterfall in a wave64 vertex shader.
2; Vertex v (v0 = vertex index) has x = v & 63, y = v >> 6 and the key a = x % 4 + 4 * (y % 4). The loop takes
3; v_readfirstlane of the key, runs the lanes holding it (v_cmp_eq, s_and_saveexec), retires them (s_xor exec) and
4; repeats while lanes are left (s_cbranch_execnz); the scalar is used only inside the body. It runs once per distinct
5; key of the wave or of the 32-lane subgroup, and every vertex ends with r0 = 17 * a + x, r1 = a, r2 = r3 = 0, stored
6; to its record at heap 0x1000 + 16 * v through the V# in s[0:3].
7; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
8; vs_w64_b_waterfall.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32: equal, and equal to
9; the expected words.
10; mattr: +wavefrontsize64,-wavefrontsize32
11v_and_b32_e32 v2, 63, v0
12v_lshrrev_b32_e32 v3, 6, v0
13v_and_b32_e32 v4, 3, v2
14v_and_b32_e32 v5, 3, v3
15v_lshl_add_u32 v4, v5, 2, v4
16v_mov_b32_e32 v6, 0
17s_mov_b64 s[10:11], exec
18v_readfirstlane_b32 s20, v4
19v_cmp_eq_u32_e32 vcc, s20, v4
20s_and_saveexec_b64 s[12:13], vcc
21s_mul_i32 s21, s20, 17
22v_add_nc_u32_e32 v6, s21, v2
23s_xor_b64 exec, exec, s[12:13]
24s_cbranch_execnz -7
25s_mov_b64 exec, s[10:11]
26v_mov_b32_e32 v7, v4
27v_mov_b32_e32 v8, 0
28v_mov_b32_e32 v9, 0
29v_lshlrev_b32_e32 v12, 4, v0
30v_add_nc_u32_e32 v12, 0x1000, v12
31buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
32v_mov_b32_e32 v5, 0
33exp pos0 v5, v5, v5, v5 done
34exp param0 v5, v5, v5, v5
35s_endpgm
diff --git a/runtime/test/shaders/vs_w64_c_bcnt_export.asm b/runtime/test/shaders/vs_w64_c_bcnt_export.asm
new file mode 100644
index 000000000..84dd9bf53
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_c_bcnt_export.asm
@@ -0,0 +1,23 @@
1; TEST-251 (SHADER-10 tier C, vertex stage): a lane count used as data. Vertex v (v0 = vertex index) has x = v & 63;
2; s_bcnt1_i32_b64 counts the lanes of its wave with x % 4 == 1, which depends on the wave size and on how many
3; vertices the driver put in the wave. r0 = that count (partition dependent), r1 = x % 4 == 1, r2 = r3 = 0, stored to
4; its record at heap 0x1000 + 16 * v through the V# in s[0:3].
5; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
6; vs_w64_c_bcnt_export.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32: r1 equal, r0
7; differs.
8; mattr: +wavefrontsize64,-wavefrontsize32
9v_and_b32_e32 v2, 63, v0
10v_and_b32_e32 v4, 3, v2
11v_cmp_eq_u32_e32 vcc, 1, v4
12s_bcnt1_i32_b64 s6, vcc
13v_mov_b32_e32 v6, s6
14v_cndmask_b32_e64 v7, 0, 1, vcc
15v_mov_b32_e32 v8, 0
16v_mov_b32_e32 v9, 0
17v_lshlrev_b32_e32 v12, 4, v0
18v_add_nc_u32_e32 v12, 0x1000, v12
19buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
20v_mov_b32_e32 v5, 0
21exp pos0 v5, v5, v5, v5 done
22exp param0 v5, v5, v5, v5
23s_endpgm
diff --git a/runtime/test/shaders/vs_w64_c_lane_id.asm b/runtime/test/shaders/vs_w64_c_lane_id.asm
new file mode 100644
index 000000000..c69850333
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_c_lane_id.asm
@@ -0,0 +1,21 @@
1; TEST-251 (SHADER-10 tier C, vertex stage): the raw lane number (v_mbcnt_lo/hi of -1) used as data. Each vertex v
2; (v0 = vertex index) stores (lane id, lane id & 31, v, 0) to its record at heap 0x1000 + 16 * v through the V# in
3; s[0:3]. In a wave64 VS some vertices get lanes 32..63; in a wave32 VS none do, so r0 and r1 depend on how the driver
4; packed the vertices into waves and r2 does not. w64_graphics.py also uses it as its probe: the largest r0 shows the
5; wave size the driver picked (63 by default on RADV GFX12, 31 with RADV_PERFTEST=gewave32).
6; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
7; vs_w64_c_lane_id.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32 (the triangles have
8; zero area, so nothing is drawn).
9; mattr: +wavefrontsize64,-wavefrontsize32
10v_mbcnt_lo_u32_b32 v6, -1, 0
11v_mbcnt_hi_u32_b32 v6, -1, v6
12v_and_b32_e32 v7, 31, v6
13v_mov_b32_e32 v8, v0
14v_mov_b32_e32 v9, 0
15v_lshlrev_b32_e32 v12, 4, v0
16v_add_nc_u32_e32 v12, 0x1000, v12
17buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
18v_mov_b32_e32 v5, 0
19exp pos0 v5, v5, v5, v5 done
20exp param0 v5, v5, v5, v5
21s_endpgm
diff --git a/runtime/test/shaders/vs_w64_c_readlane.asm b/runtime/test/shaders/vs_w64_c_readlane.asm
new file mode 100644
index 000000000..d472b1ee5
--- /dev/null
+++ b/runtime/test/shaders/vs_w64_c_readlane.asm
@@ -0,0 +1,23 @@
1; TEST-251 (SHADER-10 tier C, vertex stage): v_readlane of a varying value (the vertex index) at lanes 40 and 7. In a
2; wave64 VS every lane gets the vertex in hardware lane 40 (or 7) of its wave; in a wave32 VS lane 40 wraps or is
3; undefined and lane 7 is the vertex of another wave. Vertex v (v0 = vertex index): r0 = readlane 40, r1 = v,
4; r2 = readlane 7 (both partition dependent), r3 = 0, stored to its record at heap 0x1000 + 16 * v through the V# in
5; s[0:3].
6; Run: VKH_VERTICES=960 VKH_SGPRS=0,0,65536,0x30000000 VKH_HEAP=0=0 VKH_HEAP_DUMP=heap.raw vk_harness
7; vs_w64_c_readlane.spv <any fragment shader> out.raw, with and without RADV_PERFTEST=gewave32: r1 equal, r2 differs.
8; mattr: +wavefrontsize64,-wavefrontsize32
9s_mov_b64 s[10:11], exec
10v_mov_b32_e32 v4, v0
11v_readlane_b32 s6, v4, 40
12v_readlane_b32 s7, v4, 7
13v_mov_b32_e32 v6, s6
14v_mov_b32_e32 v7, v4
15v_mov_b32_e32 v8, s7
16v_mov_b32_e32 v9, 0
17v_lshlrev_b32_e32 v12, 4, v0
18v_add_nc_u32_e32 v12, 0x1000, v12
19buffer_store_dwordx4 v[6:9], v12, s[0:3], 0 offen
20v_mov_b32_e32 v5, 0
21exp pos0 v5, v5, v5, v5 done
22exp param0 v5, v5, v5, v5
23s_endpgm
diff --git a/runtime/test/shaders/w64_graphics.py b/runtime/test/shaders/w64_graphics.py
index 91424af99..6e281d4b4 100644
--- a/runtime/test/shaders/w64_graphics.py
+++ b/runtime/test/shaders/w64_graphics.py
@@ -1,5 +1,5 @@
1"""SHADER-10 GPU checks: wave64 pixel shaders on 32-lane subgroups (docs/design.md, "Wave64 graphics: partition 1"""SHADER-10 GPU checks: wave64 pixel and vertex shaders on 32-lane subgroups (docs/design.md, "Wave64 graphics:
2invariance"). 2partition invariance").
3 3
4 python3 -I runtime/test/shaders/w64_graphics.py <build dir with spirv/> [tools dir] [name ...] 4 python3 -I runtime/test/shaders/w64_graphics.py <build dir with spirv/> [tools dir] [name ...]
5 5
@@ -16,6 +16,13 @@ A device that can require only one size (NVIDIA: 32 only) cannot run the compari
16checked against the derived words (tiers A, B), the tier C check is skipped, and two environment variables let a 16checked against the derived words (tiers A, B), the tier C check is skipped, and two environment variables let a
17second device stand in for the missing size: W64G_SAVE_REF=<dir> stores each 64-lane run of a device that can require 17second device stand in for the missing size: W64G_SAVE_REF=<dir> stores each 64-lane run of a device that can require
18it, and W64G_REF=<dir> compares every run of the other device with those files (equal for A and B, different for C). 18it, and W64G_REF=<dir> compares every run of the other device with those files (equal for A and B, different for C).
19
20The vs_w64_* fixtures (TEST-251) are vertex shaders: Vulkan cannot require a vertex subgroup size, so the two sizes
21come from RADV, which runs the VS stage as wave64 by default and as wave32 with RADV_PERFTEST=gewave32 (GFX10+).
22Each draws 960 vertices with zero area (VKH_VERTICES) and stores four words per vertex to the heap; vs_w64_c_lane_id
23doubles as the probe that the wave size really changed, and without RADV only the default-size checks run. RADV packs
2462 or 64 vertices into a wave64 and 30 or 32 into a wave32, so the 32-lane run is a repacking, not the two halves of
25the 64-lane waves: a stricter test of tiers A and B, which key every word on the vertex index.
19""" 26"""
20import os 27import os
21import struct 28import struct
@@ -106,6 +113,25 @@ def _c_execz_sgpr(i):
106 return (7 if _on(i) else None, _on(i), 0, 0) # r0 = s5: 7 only where the active side ran 113 return (7 if _on(i) else None, _on(i), 0, 0) # r0 = s5: 7 only where the active side ran
107 114
108 115
116# vs_w64_* fixtures: i is the vertex index, x = i % 64 and y = i // 64 as for a pixel.
117def _vs_a_skip(i):
118 x, y = _x(i), _y(i)
119 return (7 * y + x if x % 4 == 1 else 1000 + x, int(x % 4 == 1), 2000 + y + (9 if y % 4 == 2 else 0), x % 4 + 1)
120
121
122def _vs_b_readlane_uniform(i):
123 return (_x(i) + 123, 200, _x(i) + 123, 277)
124
125
126def _vs_c_lane_id(i):
127 return (None, None, i, 0) # r0, r1 = the lane the vertex got
128
129
130VS_ENV = {"VKH_SGPRS": "0,0,65536,0x30000000", "VKH_HEAP": "0=0"}
131VS_VERTICES = 960 # 15 rows of 64 vertices: several waves at either size, and partial ones
132VS_RECORDS = 0x1000 // 4 # heap word of vertex 0's record (4 words per vertex); below it, the atomic's counter and slots
133
134
109# name -> (tier, expected words per pixel (None = not fixed), environment of the draw) 135# name -> (tier, expected words per pixel (None = not fixed), environment of the draw)
110FIXTURES = { 136FIXTURES = {
111 "ps_w64_a_skip": ("A", _a_skip, {}), 137 "ps_w64_a_skip": ("A", _a_skip, {}),
@@ -122,13 +148,70 @@ FIXTURES = {
122 "ps_w64_c_vote_else": ("C", _c_vote_else, {}), 148 "ps_w64_c_vote_else": ("C", _c_vote_else, {}),
123 "ps_w64_c_scc_vote": ("C", _c_scc_vote, {}), 149 "ps_w64_c_scc_vote": ("C", _c_scc_vote, {}),
124 "ps_w64_c_execz_sgpr": ("C", _c_execz_sgpr, {}), 150 "ps_w64_c_execz_sgpr": ("C", _c_execz_sgpr, {}),
151 "vs_w64_a_skip": ("A", _vs_a_skip, VS_ENV),
152 "vs_w64_b_waterfall": ("B", _b_waterfall, VS_ENV),
153 "vs_w64_b_readlane_uniform": ("B", _vs_b_readlane_uniform, dict(VS_ENV, VKH_SGPRS=VS_ENV["VKH_SGPRS"] + ",123")),
154 "vs_w64_b_ballot_atomic": ("B", _b_ballot, VS_ENV),
155 "vs_w64_c_bcnt_export": ("C", _c_bcnt, VS_ENV),
156 "vs_w64_c_readlane": ("C", _c_readlane, VS_ENV),
157 "vs_w64_c_lane_id": ("C", _vs_c_lane_id, VS_ENV),
125} 158}
126 159
160VS_PROBE = "vs_w64_c_lane_id"
161_vs_applied = {}
162
163
164def _radv_perftest(size):
165 """RADV_PERFTEST for a vertex draw at `size`. Vulkan cannot require a vertex subgroup size (requiredSubgroupSizeStages
166 has no VERTEX on RADV or on the AMD driver), but RADV runs the VS/GS (NGG) stage as wave32 with gewave32 and as
167 wave64 without it on GFX10+. Other drivers ignore the variable; the probe then finds no change."""
168 flags = [f for f in os.environ.get("RADV_PERFTEST", "").split(",") if f and f != "gewave32"]
169 return ",".join(flags + ["gewave32"] * (size == 32))
170
171
172def _vs_wave_size(tools, spirv, size, tmp):
173 """Whether a vertex draw at `size` really ran at that wave size: the largest lane id of VS_PROBE is 32..63 in a
174 wave64 VS and below 32 in a wave32 one. Size 32 also needs size 64 to work, so that the two draws differ."""
175 if size not in _vs_applied:
176 def top(s):
177 words = _draw_vs(tools, spirv, VS_PROBE, s, tmp)[0]
178 return None if words is None else max(w[0] for w in words)
179 lane64, lane32 = top(64), top(32)
180 _vs_applied[64] = lane64 is not None and 32 <= lane64 < 64
181 _vs_applied[32] = _vs_applied[64] and lane32 is not None and lane32 < 32
182 return _vs_applied[size]
183
184
185def _draw_vs(tools, spirv, name, size, tmp):
186 """(records, heap) of one vertex draw at `size` (None: as the environment says), or (None, message)."""
187 env = dict(os.environ, **FIXTURES[name][2])
188 if size:
189 env["RADV_PERFTEST"] = _radv_perftest(size)
190 raw, heap = Path(tmp) / f"{name}.{size}.raw", Path(tmp) / f"{name}.{size}.heap"
191 env.update(VKH_VERTICES=str(VS_VERTICES), VKH_HEAP_DUMP=str(heap))
192 env.pop("VKH_SUBGROUP_SIZE", None)
193 # The triangles have zero area, so no pixel is drawn and any fragment shader does.
194 cmd = [os.path.join(tools, "vk_harness" + EXE), os.path.join(spirv, name + ".spv"),
195 os.path.join(spirv, "ps_w64_a_skip.spv"), str(raw)]
196 r = subprocess.run(cmd, capture_output=True, text=True, env=env, timeout=120)
197 out = r.stdout + r.stderr
198 if r.returncode == UNSUPPORTED:
199 return None, "unsupported: " + out.strip().splitlines()[-1]
200 if r.returncode or not heap.is_file():
201 return None, f"exit {r.returncode}: {' | '.join(out.strip().splitlines()[-3:])}"
202 words = list(struct.unpack("<%dI" % (65536 // 4), heap.read_bytes()))
203 return [tuple(words[VS_RECORDS + 4 * v:VS_RECORDS + 4 * v + 4]) for v in range(VS_VERTICES)], words
204
127 205
128def draw(tools, spirv, name, size, tmp): 206def draw(tools, spirv, name, size, tmp):
129 """(words per pixel, heap words or None, applied) of one draw. `applied`: the required size took effect (size 207 """(words per pixel, heap words or None, applied) of one draw. `applied`: the required size took effect (size
130 None: no size asked, applied is None). The words are None when the draw failed; then `heap` is the message.""" 208 None: no size asked, applied is None). The words are None when the draw failed; then `heap` is the message."""
131 tier, expect, extra = FIXTURES[name] 209 tier, expect, extra = FIXTURES[name]
210 if name.startswith("vs_"):
211 words, heap = _draw_vs(tools, spirv, name, size, tmp)
212 if words is None:
213 return None, heap, None
214 return words, heap, _vs_wave_size(tools, spirv, size, tmp) if size else None
132 env = dict(os.environ, **extra) 215 env = dict(os.environ, **extra)
133 env.pop("VKH_SUBGROUP_SIZE", None) 216 env.pop("VKH_SUBGROUP_SIZE", None)
134 if size: 217 if size:
@@ -168,15 +251,16 @@ def expected_problem(name, words, heap):
168 if wrong: 251 if wrong:
169 i, w, want = wrong[0] 252 i, w, want = wrong[0]
170 return f"{len(wrong)} of {len(words)} pixels differ from the derived words, first ({_x(i)},{_y(i)}): got {w}, want {want}" 253 return f"{len(wrong)} of {len(words)} pixels differ from the derived words, first ({_x(i)},{_y(i)}): got {w}, want {want}"
171 if name == "ps_w64_b_ballot_atomic": 254 if name.endswith("_b_ballot_atomic"):
172 want = sorted(_y(i) * W + _x(i) + 1 for i in range(W * H) if _x(i) % 4 == 1) 255 want = sorted(i + 1 for i in range(len(words)) if _x(i) % 4 == 1)
173 n = len(want) 256 n = len(want)
174 if heap[0] != n: 257 if heap[0] != n:
175 return f"counter is {heap[0]}, want {n}" 258 return f"counter is {heap[0]}, want {n}"
176 slots = heap[64:64 + n] 259 slots = heap[64:64 + n]
177 if sorted(slots) != want: 260 if sorted(slots) != want:
178 return f"slot words are not the {n} wanted pixel numbers once each ({len(set(slots))} distinct)" 261 return f"slot words are not the {n} wanted pixel numbers once each ({len(set(slots))} distinct)"
179 if any(heap[64 + n:]) or any(heap[1:64]): 262 end = VS_RECORDS if name.startswith("vs_") else len(heap) # the vertex records follow the slots
263 if any(heap[64 + n:end]) or any(heap[1:64]):
180 return "words outside the counter and the slots were written" 264 return "words outside the counter and the slots were written"
181 return "" 265 return ""
182 266
@@ -184,7 +268,7 @@ def expected_problem(name, words, heap):
184def comparable(name, words, heap): 268def comparable(name, words, heap):
185 """What two draws of the same fixture must share when the shader is partition invariant.""" 269 """What two draws of the same fixture must share when the shader is partition invariant."""
186 stable = [tuple(0 if g is None else v for g, v in zip(FIXTURES[name][1](i), w)) for i, w in enumerate(words)] 270 stable = [tuple(0 if g is None else v for g, v in zip(FIXTURES[name][1](i), w)) for i, w in enumerate(words)]
187 if name == "ps_w64_b_ballot_atomic": 271 if name.endswith("_b_ballot_atomic"):
188 return stable, sorted(heap[64:64 + heap[0]]), heap[0] 272 return stable, sorted(heap[64:64 + heap[0]]), heap[0]
189 return stable, None, None 273 return stable, None, None
190 274
@@ -240,7 +324,7 @@ def check(tools, spirv, name):
240 if not partition_dependent(name, ref_words, words): 324 if not partition_dependent(name, ref_words, words):
241 return "tier C but the run equals the 64-lane reference: the detector is wrong" 325 return "tier C but the run equals the 64-lane reference: the detector is wrong"
242 compared = True 326 compared = True
243 elif name != "ps_w64_b_ballot_atomic" and comparable(name, ref_words, None) != comparable(name, words, None): 327 elif not name.endswith("_b_ballot_atomic") and comparable(name, ref_words, None) != comparable(name, words, None):
244 return "the run differs from the 64-lane reference" 328 return "the run differs from the 64-lane reference"
245 if tier == "C" and not compared: 329 if tier == "C" and not compared:
246 return Skip("SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF)") 330 return Skip("SKIP (tier C needs a device that can require both 64 and 32, or W64G_REF)")
diff --git a/runtime/test/typeless_rtv_test.cpp b/runtime/test/typeless_rtv_test.cpp
index be935c123..87fa46acb 100644
--- a/runtime/test/typeless_rtv_test.cpp
+++ b/runtime/test/typeless_rtv_test.cpp
@@ -262,9 +262,27 @@ int main() {
262 EXPECT(rejects(wrong, {1, 0, 1, 2, ColorViewFormat::rgba8_srgb}, ReplayResult::invalid_subresource)); 262 EXPECT(rejects(wrong, {1, 0, 1, 2, ColorViewFormat::rgba8_srgb}, ReplayResult::invalid_subresource));
263 wrong = binding; wrong.volume = true; 263 wrong = binding; wrong.volume = true;
264 EXPECT(rejects(wrong, {1, 0, 0, 1, ColorViewFormat::rgba8_srgb})); 264 EXPECT(rejects(wrong, {1, 0, 0, 1, ColorViewFormat::rgba8_srgb}));
265 wrong = binding; wrong.samples = 4; 265 {
266 EXPECT(rejects(wrong, {1, 0, 0, 1, ColorViewFormat::rgba8_uint})); 266 auto msaa = binding; msaa.samples = 4;
267 checks += 8; 267 for (const auto [format, expected] : formats) {
268 CommandList ms_list;
269 EXPECT(ms_list.clear_render_target({1, 0, 0, 1, format}, color) && ms_list.close());
270 EXPECT(run(ms_list, msaa, vk) == ReplayResult::success);
271 const bool attachment = format != ColorViewFormat::rgba8_unorm;
272 EXPECT(image_clears == (attachment ? 0u : 1u) && attachment_clears == (attachment ? 1u : 0u));
273 EXPECT(!attachment || (requested_format == expected && rendering_layers == 1));
274 ++checks;
275 }
276 auto msaa_layered = layered; msaa_layered.mip_levels = 1; msaa_layered.samples = 4;
277 CommandList ms_layer_list;
278 EXPECT(ms_layer_list.clear_render_target({1, 0, 1, 2, ColorViewFormat::rgba8_srgb}, color) &&
279 ms_layer_list.close());
280 EXPECT(run(ms_layer_list, msaa_layered, vk) == ReplayResult::success);
281 EXPECT(attachment_clears == 1 && requested_format == VK_FORMAT_R8G8B8A8_SRGB);
282 EXPECT(requested_range.baseArrayLayer == 1 && requested_range.layerCount == 2 && rendering_layers == 2);
283 ++checks;
284 }
285 checks += 7;
268 CommandList list; 286 CommandList list;
269 EXPECT(list.clear_render_target({1, 0, 0, 1, ColorViewFormat::rgba8_srgb}, color) && list.close()); 287 EXPECT(list.clear_render_target({1, 0, 0, 1, ColorViewFormat::rgba8_srgb}, color) && list.close());
270 auto unavailable = vk; unavailable.begin_rendering = nullptr; 288 auto unavailable = vk; unavailable.begin_rendering = nullptr;
diff --git a/runtime/test/vk_bc_zero_init_test.cpp b/runtime/test/vk_bc_zero_init_test.cpp
new file mode 100644
index 000000000..6edc36fcb
--- /dev/null
+++ b/runtime/test/vk_bc_zero_init_test.cpp
@@ -0,0 +1,388 @@
1// Committed block-compressed (BC*) texture zero-initialization regression (D3D-220, #1725):
2// D3D12 committed textures start zeroed unless D3D12_HEAP_FLAG_CREATE_NOT_ZEROED is set. Vulkan forbids
3// vkCmdClearColorImage on BC formats, so detail::initialize() must zero-fill them via vkCmdCopyBufferToImage
4// from either the device zero page (vk.zero_buffer) or a zeroed transfer-scratch chunk (vk.copy_scratch).
5//
6// Cases (all on explicitly poisoned 0x5A backing memory when host-visible, plus default device memory):
7// 1. Path A (vk.zero_buffer): CopyTextureRegion R32G32_UINT 2x2 -> BC1 16x16 at (8, 4) — untouched blocks are 0x00.
8// 2. Path A (vk.zero_buffer): CopyResource R32G32_UINT 3x2 -> BC1 12x8, 2 mips — mip 1 untouched block (bytes 56..63) is 0x00.
9// 3. Path A (tiny 32-byte vk.zero_buffer): 32x32 BC7 image tiled in multiple row/column chunks — all 1024 bytes are 0x00.
10// 4. Path B (enable_copy_scratch, no zero_buffer — matches d3d12_copy_xfmt): both D3D-220 cases match bit for bit.
11// 5. not_zeroed = true (CREATE_NOT_ZEROED): zero-fill is skipped.
12// Skips with exit code 77 when no Vulkan 1.3 device with textureCompressionBC is available. No game data.
13#include "vk_test_device.h"
14#include "../src/vulkan_backend.h"
15
16#include <algorithm>
17#include <cstdint>
18#include <cstdio>
19#include <cstring>
20#include <vector>
21
22#define EXPECT(condition) do { \
23 if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \
24} while (0)
25
26namespace {
27
28struct OwnedImage {
29 VkDevice device = VK_NULL_HANDLE;
30 PFN_vkDestroyImage destroy_image = nullptr;
31 PFN_vkFreeMemory free_memory = nullptr;
32 VkImage image = VK_NULL_HANDLE;
33 VkDeviceMemory memory = VK_NULL_HANDLE;
34 bool poisoned = false;
35
36 ~OwnedImage() {
37 if (image && destroy_image) destroy_image(device, image, nullptr);
38 if (memory && free_memory) free_memory(device, memory, nullptr);
39 }
40 OwnedImage(const OwnedImage&) = delete;
41 OwnedImage& operator=(const OwnedImage&) = delete;
42 OwnedImage() = default;
43};
44
45bool create_image(const vktest::Device& d, VkFormat format, std::uint32_t width, std::uint32_t height,
46 std::uint32_t mips, VkBuffer poison_buf, OwnedImage& out) {
47 out.device = d.device;
48 out.destroy_image = d.fn<PFN_vkDestroyImage>("vkDestroyImage");
49 out.free_memory = d.fn<PFN_vkFreeMemory>("vkFreeMemory");
50
51 VkImageCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
52 info.imageType = VK_IMAGE_TYPE_2D;
53 info.format = format;
54 info.extent = {width, height, 1};
55 info.mipLevels = mips;
56 info.arrayLayers = 1;
57 info.samples = VK_SAMPLE_COUNT_1_BIT;
58 info.tiling = VK_IMAGE_TILING_OPTIMAL;
59 info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
60 if (d.fn<PFN_vkCreateImage>("vkCreateImage")(d.device, &info, nullptr, &out.image) != VK_SUCCESS) return false;
61
62 VkMemoryRequirements req{};
63 d.fn<PFN_vkGetImageMemoryRequirements>("vkGetImageMemoryRequirements")(d.device, out.image, &req);
64 VkPhysicalDeviceMemoryProperties mp{};
65 d.instance_fn<PFN_vkGetPhysicalDeviceMemoryProperties>("vkGetPhysicalDeviceMemoryProperties")(d.physical, &mp);
66
67 std::uint32_t type = UINT32_MAX;
68 for (std::uint32_t i = 0; i < mp.memoryTypeCount; ++i) {
69 if (!(req.memoryTypeBits & (1u << i))) continue;
70 if (type == UINT32_MAX) type = i;
71 if (mp.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
72 type = i;
73 break;
74 }
75 }
76 if (type == UINT32_MAX) return false;
77
78 VkMemoryAllocateInfo alloc{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};
79 alloc.allocationSize = req.size;
80 alloc.memoryTypeIndex = type;
81 if (d.fn<PFN_vkAllocateMemory>("vkAllocateMemory")(d.device, &alloc, nullptr, &out.memory) != VK_SUCCESS)
82 return false;
83 if (d.fn<PFN_vkBindImageMemory>("vkBindImageMemory")(d.device, out.image, out.memory, 0) != VK_SUCCESS)
84 return false;
85
86 // Pre-fill every mip on the GPU with 0x5A so stale recycled VRAM is modeled deterministically on every GPU
87 // (discrete and integrated alike), before registering the image in LayoutTracker as UNDEFINED.
88 if (poison_buf) {
89 const bool ok = const_cast<vktest::Device&>(d).run([&](VkCommandBuffer cb) {
90 VkImageMemoryBarrier to_dst{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER};
91 to_dst.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
92 to_dst.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
93 to_dst.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
94 to_dst.srcQueueFamilyIndex = to_dst.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
95 to_dst.image = out.image;
96 to_dst.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, mips, 0, 1};
97 d.fn<PFN_vkCmdPipelineBarrier>("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
98 VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0,
99 nullptr, 1, &to_dst);
100 std::vector<VkBufferImageCopy> regions;
101 for (std::uint32_t m = 0; m < mips; ++m) {
102 VkBufferImageCopy r{};
103 r.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, m, 0, 1};
104 r.imageExtent = {std::max(1u, width >> m), std::max(1u, height >> m), 1};
105 regions.push_back(r);
106 }
107 d.fn<PFN_vkCmdCopyBufferToImage>("vkCmdCopyBufferToImage")(
108 cb, poison_buf, out.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, std::uint32_t(regions.size()),
109 regions.data());
110 return true;
111 });
112 if (!ok) return false;
113 out.poisoned = true;
114 }
115 return true;
116}
117
118VkDeviceMemory allocate_device_local(const vktest::Device& d, const VkMemoryRequirements& req) {
119 VkPhysicalDeviceMemoryProperties mp{};
120 d.instance_fn<PFN_vkGetPhysicalDeviceMemoryProperties>("vkGetPhysicalDeviceMemoryProperties")(d.physical, &mp);
121 std::uint32_t chosen = UINT32_MAX;
122 for (std::uint32_t i = 0; i < mp.memoryTypeCount; ++i) {
123 if (!(req.memoryTypeBits & (1u << i))) continue;
124 if (chosen == UINT32_MAX) chosen = i;
125 if (mp.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
126 chosen = i;
127 break;
128 }
129 }
130 if (chosen == UINT32_MAX) return VK_NULL_HANDLE;
131 VkMemoryAllocateInfo info{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};
132 info.allocationSize = req.size;
133 info.memoryTypeIndex = chosen;
134 VkDeviceMemory mem = VK_NULL_HANDLE;
135 if (d.fn<PFN_vkAllocateMemory>("vkAllocateMemory")(d.device, &info, nullptr, &mem) != VK_SUCCESS)
136 return VK_NULL_HANDLE;
137 return mem;
138}
139
140// Runs the two D3D-220 partial uncompressed -> BC1 copies on a given context/queue:
141// (a) CopyTextureRegion R32G32_UINT 2x2 -> BC1 16x16 at (8, 4)
142// (b) CopyResource R32G32_UINT 3x2 -> BC1 12x8, 2 mips
143int run_d3d220_cases(const vktest::Device& d, leonida::VulkanContext& ctx, leonida::VulkanQueue& q,
144 VkBuffer poison_buf, VkBuffer up_buf, void* up_ptr, VkBuffer rb_buf, void* rb_ptr,
145 const char* label) {
146 using namespace leonida;
147
148 auto* up = static_cast<std::uint8_t*>(up_ptr);
149 auto* rb = static_cast<std::uint8_t*>(rb_ptr);
150 for (std::size_t i = 0; i < 4096; ++i) up[i] = static_cast<std::uint8_t>(i * 7 + 3);
151
152 // Case (a): CopyTextureRegion R32G32_UINT 2x2 -> BC1 16x16 at (8, 4).
153 // Destination has 4x4 BC1 blocks (8 bytes/block). Only blocks (2,1), (3,1), (2,2), (3,2) are written;
154 // the other 12 blocks (including block (0,0) at byte 0) must be 0x00.
155 {
156 OwnedImage src_img, dst_img;
157 EXPECT(create_image(d, VK_FORMAT_R32G32_UINT, 2, 2, 1, VK_NULL_HANDLE, src_img));
158 EXPECT(create_image(d, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 16, 16, 1, poison_buf, dst_img));
159
160 ResourceBinding src_rb{};
161 src_rb.image = src_img.image;
162 src_rb.format = VK_FORMAT_R32G32_UINT;
163 src_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
164 src_rb.width = 2; src_rb.height = 2; src_rb.mip_levels = 1; src_rb.array_layers = 1; src_rb.depth = 1; src_rb.samples = 1;
165
166 ResourceBinding dst_rb{};
167 dst_rb.image = dst_img.image;
168 dst_rb.format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
169 dst_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
170 dst_rb.width = 16; dst_rb.height = 16; dst_rb.mip_levels = 1; dst_rb.array_layers = 1; dst_rb.depth = 1; dst_rb.samples = 1;
171
172 ctx.add_resource(10, src_rb, VK_IMAGE_LAYOUT_UNDEFINED);
173 ctx.add_resource(11, dst_rb, VK_IMAGE_LAYOUT_UNDEFINED);
174 std::memset(rb, 0xCD, 4096);
175
176 CommandList list;
177 CopyLocation up_loc{1, true, 0, 0, 2, 2, 1, 256};
178 CopyLocation src_loc{10, false, 0, 0, 0, 0, 0, 0};
179 CopyLocation dst_loc{11, false, 0, 0, 0, 0, 0, 0};
180 CopyLocation rb_loc{2, true, 0, 0, 16, 16, 1, 256};
181 EXPECT(list.copy_texture({src_loc, 0, 0, 0, up_loc, false, {}}));
182 EXPECT(list.transition({10, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
183 EXPECT(list.copy_texture({dst_loc, 8, 4, 0, src_loc, false, {}}));
184 EXPECT(list.transition({11, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
185 EXPECT(list.copy_texture({rb_loc, 0, 0, 0, dst_loc, false, {}}));
186 EXPECT(list.close());
187
188 const CommandList* ptr = &list;
189 EXPECT(q.execute({&ptr, 1}) == ReplayResult::success);
190 EXPECT(q.idle());
191
192 // Check every 8-byte block across the 4x4 block grid (row pitch 256).
193 for (std::uint32_t by = 0; by < 4; ++by) {
194 for (std::uint32_t bx = 0; bx < 4; ++bx) {
195 const std::uint8_t* got = rb + std::size_t(by) * 256 + std::size_t(bx) * 8;
196 if (bx >= 2 && bx < 4 && by >= 1 && by < 3) {
197 const std::uint8_t* want = up + std::size_t(by - 1) * 256 + std::size_t(bx - 2) * 8;
198 EXPECT(std::memcmp(got, want, 8) == 0);
199 } else {
200 for (int k = 0; k < 8; ++k) EXPECT(got[k] == 0x00);
201 }
202 }
203 }
204 ctx.remove_resource(10);
205 ctx.remove_resource(11);
206 }
207
208 // Case (b): CopyResource R32G32_UINT 3x2 -> BC1 12x8, 2 mips.
209 // Mip 0: 3x2 -> 12x8 (3x2 = 6 blocks written).
210 // Mip 1: 1x1 -> 6x4 (2x1 = 2 blocks; block 0 is written, block 1 at bytes 8..15 of mip 1 is untouched -> 0x00).
211 {
212 OwnedImage src_img, dst_img;
213 EXPECT(create_image(d, VK_FORMAT_R32G32_UINT, 3, 2, 2, VK_NULL_HANDLE, src_img));
214 EXPECT(create_image(d, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 12, 8, 2, poison_buf, dst_img));
215
216 ResourceBinding src_rb{};
217 src_rb.image = src_img.image;
218 src_rb.format = VK_FORMAT_R32G32_UINT;
219 src_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
220 src_rb.width = 3; src_rb.height = 2; src_rb.mip_levels = 2; src_rb.array_layers = 1; src_rb.depth = 1; src_rb.samples = 1;
221
222 ResourceBinding dst_rb{};
223 dst_rb.image = dst_img.image;
224 dst_rb.format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
225 dst_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
226 dst_rb.width = 12; dst_rb.height = 8; dst_rb.mip_levels = 2; dst_rb.array_layers = 1; dst_rb.depth = 1; dst_rb.samples = 1;
227
228 ctx.add_resource(12, src_rb, VK_IMAGE_LAYOUT_UNDEFINED);
229 ctx.add_resource(13, dst_rb, VK_IMAGE_LAYOUT_UNDEFINED);
230 std::memset(rb, 0xCD, 4096);
231
232 // Upload mip 0 at offset 0 (2 rows * 256 = 512 bytes) and mip 1 at offset 512 (1 row * 256).
233 CommandList list;
234 CopyLocation up0{1, true, 0, 0, 3, 2, 1, 256};
235 CopyLocation up1{1, true, 0, 512, 1, 1, 1, 256};
236 CopyLocation src0{12, false, 0, 0, 0, 0, 0, 0};
237 CopyLocation src1{12, false, 1, 0, 0, 0, 0, 0};
238 CopyLocation dst0{13, false, 0, 0, 0, 0, 0, 0};
239 CopyLocation dst1{13, false, 1, 0, 0, 0, 0, 0};
240 CopyLocation rb0{2, true, 0, 0, 12, 8, 1, 256};
241 CopyLocation rb1{2, true, 0, 512, 6, 4, 1, 256};
242 EXPECT(list.copy_texture({src0, 0, 0, 0, up0, false, {}}));
243 EXPECT(list.copy_texture({src1, 0, 0, 0, up1, false, {}}));
244 EXPECT(list.transition({12, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
245 EXPECT(list.copy_resource({13, 12}));
246 EXPECT(list.transition({13, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
247 EXPECT(list.copy_texture({rb0, 0, 0, 0, dst0, false, {}}));
248 EXPECT(list.copy_texture({rb1, 0, 0, 0, dst1, false, {}}));
249 EXPECT(list.close());
250
251 const CommandList* ptr = &list;
252 EXPECT(q.execute({&ptr, 1}) == ReplayResult::success);
253 EXPECT(q.idle());
254
255 // Mip 0: 2 rows of 3 blocks (24 bytes per row).
256 EXPECT(std::memcmp(rb + 0, up + 0, 24) == 0);
257 EXPECT(std::memcmp(rb + 256, up + 256, 24) == 0);
258 // Mip 1: block 0 (bytes 0..7) matches up + 512; untouched block 1 (bytes 8..15) must be 0x00.
259 EXPECT(std::memcmp(rb + 512, up + 512, 8) == 0);
260 for (int k = 8; k < 16; ++k) EXPECT(rb[512 + k] == 0x00);
261
262 ctx.remove_resource(12);
263 ctx.remove_resource(13);
264 }
265
266 (void)up_buf;
267 (void)rb_buf;
268 std::printf("bc zero-init (%s): partial CopyTextureRegion and 2-mip CopyResource ok\n", label);
269 return 0;
270}
271
272} // namespace
273
274int main() {
275 using namespace leonida;
276
277 vktest::Device d;
278 if (!d.create(false) || !d.bc) {
279 std::fprintf(stderr, "vk_bc_zero_init_test: no Vulkan 1.3 device with BC support, skipped\n");
280 return 77;
281 }
282
283 void* up_ptr = nullptr;
284 void* rb_ptr = nullptr;
285 void* zero_ptr = nullptr;
286 void* poison_ptr = nullptr;
287 const VkBuffer up_buf = d.buffer(4096, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &up_ptr);
288 const VkBuffer rb_buf = d.buffer(8192, VK_BUFFER_USAGE_TRANSFER_DST_BIT, &rb_ptr);
289 const VkBuffer zero_buf = d.buffer(65536, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &zero_ptr);
290 const VkBuffer poison_buf = d.buffer(4096, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &poison_ptr);
291 EXPECT(up_buf && rb_buf && zero_buf && poison_buf);
292 std::memset(zero_ptr, 0, 65536);
293 std::memset(poison_ptr, 0x5A, 4096);
294
295 ResourceBinding up_rb{};
296 up_rb.buffer = up_buf;
297 up_rb.size = 4096;
298 ResourceBinding rb_rb{};
299 rb_rb.buffer = rb_buf;
300 rb_rb.size = 8192;
301 rb_rb.host_readable = true;
302
303 // Path A: device arena zero page (vk.zero_buffer).
304 {
305 VulkanContext ctx(d.device_proc, d.device, true);
306 EXPECT(ctx.loaded());
307 ctx.set_zero_page(zero_buf, 0, 65536);
308 ctx.add_resource(1, up_rb);
309 ctx.add_resource(2, rb_rb);
310 VulkanQueue q(ctx, d.queue, d.family);
311 EXPECT(q.ok());
312 EXPECT(run_d3d220_cases(d, ctx, q, poison_buf, up_buf, up_ptr, rb_buf, rb_ptr, "zero_buffer") == 0);
313
314 // Multi-tile chunking: shrink zero_page to 32 bytes (2 BC7 blocks) and zero-init a 32x32 BC7 image (64 blocks).
315 ctx.set_zero_page(zero_buf, 16, 32);
316 OwnedImage bc7_img;
317 EXPECT(create_image(d, VK_FORMAT_BC7_UNORM_BLOCK, 32, 32, 1, poison_buf, bc7_img));
318 ResourceBinding bc7_rb{};
319 bc7_rb.image = bc7_img.image;
320 bc7_rb.format = VK_FORMAT_BC7_UNORM_BLOCK;
321 bc7_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
322 bc7_rb.width = 32; bc7_rb.height = 32; bc7_rb.mip_levels = 1; bc7_rb.array_layers = 1; bc7_rb.depth = 1; bc7_rb.samples = 1;
323 ctx.add_resource(20, bc7_rb, VK_IMAGE_LAYOUT_UNDEFINED);
324 std::memset(rb_ptr, 0xCD, 8192);
325
326 CommandList list;
327 EXPECT(list.transition({20, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
328 CopyLocation bc7_loc{20, false, 0, 0, 0, 0, 0, 0};
329 CopyLocation rb_loc{2, true, 0, 0, 32, 32, 1, 256};
330 EXPECT(list.copy_texture({rb_loc, 0, 0, 0, bc7_loc, false, {}}));
331 EXPECT(list.close());
332 const CommandList* ptr = &list;
333 EXPECT(q.execute({&ptr, 1}) == ReplayResult::success);
334 EXPECT(q.idle());
335
336 auto* rb = static_cast<std::uint8_t*>(rb_ptr);
337 for (std::uint32_t row = 0; row < 8; ++row)
338 for (std::uint32_t x = 0; x < 8 * 16; ++x)
339 EXPECT(rb[row * 256 + x] == 0x00);
340 ctx.remove_resource(20);
341 std::printf("bc zero-init (tiny 32-byte zero_buffer chunking on 32x32 BC7): ok\n");
342
343 // CREATE_NOT_ZEROED (not_zeroed = true) must skip zero-fill.
344 ctx.set_zero_page(zero_buf, 0, 65536);
345 OwnedImage nz_img;
346 EXPECT(create_image(d, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 16, 16, 1, poison_buf, nz_img));
347 EXPECT(nz_img.poisoned);
348 ResourceBinding nz_rb{};
349 nz_rb.image = nz_img.image;
350 nz_rb.format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
351 nz_rb.aspects = VK_IMAGE_ASPECT_COLOR_BIT;
352 nz_rb.width = 16; nz_rb.height = 16; nz_rb.mip_levels = 1; nz_rb.array_layers = 1; nz_rb.depth = 1; nz_rb.samples = 1;
353 nz_rb.not_zeroed = true;
354 ctx.add_resource(21, nz_rb, VK_IMAGE_LAYOUT_UNDEFINED);
355 std::memset(rb_ptr, 0xCD, 8192);
356
357 CommandList nz_list;
358 EXPECT(nz_list.transition({21, all_subresources, d3d12_state::copy_dest, d3d12_state::copy_source}));
359 CopyLocation nz_loc{21, false, 0, 0, 0, 0, 0, 0};
360 CopyLocation nz_rb_loc{2, true, 0, 0, 16, 16, 1, 256};
361 EXPECT(nz_list.copy_texture({nz_rb_loc, 0, 0, 0, nz_loc, false, {}}));
362 EXPECT(nz_list.close());
363 const CommandList* nz_ptr = &nz_list;
364 EXPECT(q.execute({&nz_ptr, 1}) == ReplayResult::success);
365 EXPECT(q.idle());
366 EXPECT(rb[0] == 0x5A);
367 ctx.remove_resource(21);
368 std::printf("bc zero-init (not_zeroed = true skips zero-fill): ok\n");
369 }
370
371 // Path B: copy_scratch + vkCmdFillBuffer fallback (no zero_buffer, matching d3d12_copy_xfmt without BDA).
372 {
373 VulkanContext ctx(d.device_proc, d.device, true);
374 EXPECT(ctx.loaded());
375 ctx.enable_copy_scratch(d.device_proc, [&](const VkMemoryRequirements& req) {
376 return allocate_device_local(d, req);
377 });
378 ctx.add_resource(1, up_rb);
379 ctx.add_resource(2, rb_rb);
380 VulkanQueue q(ctx, d.queue, d.family);
381 EXPECT(q.ok());
382 EXPECT(run_d3d220_cases(d, ctx, q, poison_buf, up_buf, up_ptr, rb_buf, rb_ptr, "copy_scratch") == 0);
383 }
384
385 EXPECT(d.validation_errors() == 0);
386 std::printf("vk_bc_zero_init_test: ok\n");
387 return 0;
388}
diff --git a/runtime/test/vk_bindless_test.cpp b/runtime/test/vk_bindless_test.cpp
index 73ac39013..041f6f648 100644
--- a/runtime/test/vk_bindless_test.cpp
+++ b/runtime/test/vk_bindless_test.cpp
@@ -24,6 +24,7 @@
24#include "vk_shader_fma.h" 24#include "vk_shader_fma.h"
25#include "../src/vulkan_bindless.h" 25#include "../src/vulkan_bindless.h"
26 26
27#include <algorithm>
27#include <array> 28#include <array>
28#include <cmath> 29#include <cmath>
29#include <cstdio> 30#include <cstdio>
@@ -105,7 +106,7 @@ std::uint32_t probe_depth(std::span<const std::uint32_t> table, const Descriptor
105 106
106int main(int argc, char** argv) { 107int main(int argc, char** argv) {
107 if (argc < 3) { 108 if (argc < 3) {
108 std::fprintf(stderr, "usage: vk_bindless_test <vs_ids.spv> <ps_tex.spv>\n"); 109 std::fprintf(stderr, "usage: vk_bindless_test <vs_ids.spv> <ps_tex.spv | ps_imgatomic.spv>\n");
109 return 2; 110 return 2;
110 } 111 }
111 // A bad readback in a single channel must still fail when all three others match. 112 // A bad readback in a single channel must still fail when all three others match.
@@ -225,6 +226,15 @@ int main(int argc, char** argv) {
225 VkPhysicalDeviceFeatures2 enable{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &enable12}; 226 VkPhysicalDeviceFeatures2 enable{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &enable12};
226 enable.features.shaderInt64 = VK_TRUE; 227 enable.features.shaderInt64 = VK_TRUE;
227 enable.features.shaderSampledImageArrayDynamicIndexing = VK_TRUE; 228 enable.features.shaderSampledImageArrayDynamicIndexing = VK_TRUE;
229 // ps_imgatomic: image atomics in a pixel shader need fragment stores and atomics.
230 const bool atomic_mode = std::strstr(argv[2], "imgatomic") != nullptr;
231 if (atomic_mode) {
232 if (!have.features.fragmentStoresAndAtomics) {
233 std::printf("unsupported: fragmentStoresAndAtomics (image atomics in a pixel shader)\n");
234 return unsupported;
235 }
236 enable.features.fragmentStoresAndAtomics = VK_TRUE;
237 }
228 238
229 std::uint32_t qn = 0; 239 std::uint32_t qn = 0;
230 vkGetPhysicalDeviceQueueFamilyProperties(pd, &qn, nullptr); 240 vkGetPhysicalDeviceQueueFamilyProperties(pd, &qn, nullptr);
@@ -260,7 +270,7 @@ int main(int argc, char** argv) {
260 LD(vkDeviceWaitIdle); LD(vkDestroyPipeline); LD(vkDestroyPipelineLayout); 270 LD(vkDeviceWaitIdle); LD(vkDestroyPipeline); LD(vkDestroyPipelineLayout);
261 LD(vkDestroyCommandPool); LD(vkDestroyShaderModule); LD(vkDestroyFramebuffer); LD(vkDestroyRenderPass); 271 LD(vkDestroyCommandPool); LD(vkDestroyShaderModule); LD(vkDestroyFramebuffer); LD(vkDestroyRenderPass);
262 LD(vkDestroySampler); LD(vkDestroyImageView); LD(vkDestroyImage); LD(vkDestroyBuffer); 272 LD(vkDestroySampler); LD(vkDestroyImageView); LD(vkDestroyImage); LD(vkDestroyBuffer);
263 LD(vkFreeMemory); LD(vkDestroyDevice); 273 LD(vkFreeMemory); LD(vkDestroyDevice); LD(vkCmdClearColorImage);
264 VkQueue queue = VK_NULL_HANDLE; 274 VkQueue queue = VK_NULL_HANDLE;
265 vkGetDeviceQueue(dev, qi, 0, &queue); 275 vkGetDeviceQueue(dev, qi, 0, &queue);
266 VkPhysicalDeviceMemoryProperties mp; 276 VkPhysicalDeviceMemoryProperties mp;
@@ -663,6 +673,171 @@ int main(int argc, char** argv) {
663 const std::uint32_t sampler_index = set.add_sampler(nearest); 673 const std::uint32_t sampler_index = set.add_sampler(nearest);
664 EXPECT(decoy_sampler == 1 && sampler_index == 2); 674 EXPECT(decoy_sampler == 1 && sampler_index == 2);
665 675
676 if (atomic_mode) {
677 // ps_imgatomic.asm: image_atomic_umax/umin/or on three 8x8 r32ui images and umax on a 4x4x4 one, from
678 // every pixel of the 64x64 draw (64 pixels per 2D texel), each found through its own T# key. Odd
679 // pixels are discarded after their atomics, which still count.
680 constexpr std::uint32_t atomic_va = 1024, AW = 8, A3 = 4;
681 const std::array<DescriptorKey, 4> keys{{{0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8},
682 {0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8},
683 {0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8},
684 {0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8}}};
685 for (std::uint32_t k = 0; k < 4; ++k)
686 std::memcpy(static_cast<char*>(heap_map) + atomic_va + 32 * k, keys[k].data(), 32);
687 const VkImageUsageFlags atomic_usage =
688 VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
689 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
690 VkImage images[4];
691 VkImageView views[4];
692 for (int k = 0; k < 3; ++k) CHECK(make_image(VK_FORMAT_R32_UINT, AW, AW, atomic_usage, &images[k], &views[k]));
693 { // the 3D image
694 VkImageCreateInfo ii{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
695 ii.imageType = VK_IMAGE_TYPE_3D;
696 ii.format = VK_FORMAT_R32_UINT;
697 ii.extent = {A3, A3, A3};
698 ii.mipLevels = 1;
699 ii.arrayLayers = 1;
700 ii.samples = VK_SAMPLE_COUNT_1_BIT;
701 ii.usage = atomic_usage;
702 CHECK(vkCreateImage(dev, &ii, nullptr, &images[3]));
703 VkMemoryRequirements mr;
704 vkGetImageMemoryRequirements(dev, images[3], &mr);
705 VkMemoryAllocateInfo ai{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};
706 ai.allocationSize = mr.size;
707 ai.memoryTypeIndex = memtype(mr.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
708 VkDeviceMemory m;
709 CHECK(vkAllocateMemory(dev, &ai, nullptr, &m));
710 allocations.push_back(m);
711 CHECK(vkBindImageMemory(dev, images[3], m, 0));
712 VkImageViewCreateInfo vi{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO};
713 vi.image = images[3];
714 vi.viewType = VK_IMAGE_VIEW_TYPE_3D;
715 vi.format = VK_FORMAT_R32_UINT;
716 vi.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
717 CHECK(vkCreateImageView(dev, &vi, nullptr, &views[3]));
718 }
719 std::uint32_t indices[4];
720 for (int k = 0; k < 4; ++k) {
721 StorageViews storage;
722 storage.as_uint = views[k];
723 storage.r32ui = views[k];
724 indices[k] = set.add_image(k == 3 ? ImageDimension::dim_3d : ImageDimension::dim_2d, views[k],
725 VK_IMAGE_LAYOUT_GENERAL, storage);
726 EXPECT(indices[k] != 0);
727 EXPECT(set.insert_key(keys[k], indices[k]));
728 }
729 EXPECT(flush());
730
731 // Clear: umax and or start at 0, umin at all ones; then GENERAL for the shader's atomics.
732 CHECK(vkResetCommandBuffer(cmd, 0));
733 CHECK(vkBeginCommandBuffer(cmd, &begin));
734 if (!set.fallbacks_ready()) set.record_fallback_init(cmd);
735 for (int k = 0; k < 4; ++k) {
736 VkImageMemoryBarrier b{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER};
737 b.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
738 b.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
739 b.newLayout = VK_IMAGE_LAYOUT_GENERAL;
740 b.srcQueueFamilyIndex = b.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
741 b.image = images[k];
742 b.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
743 vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0,
744 nullptr, 0, nullptr, 1, &b);
745 VkClearColorValue value{};
746 for (auto& c : value.uint32) c = k == 1 ? 0xFFFFFFFFu : 0u;
747 vkCmdClearColorImage(cmd, images[k], VK_IMAGE_LAYOUT_GENERAL, &value, 1, &b.subresourceRange);
748 b.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
749 b.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
750 b.oldLayout = b.newLayout = VK_IMAGE_LAYOUT_GENERAL;
751 vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0,
752 nullptr, 0, nullptr, 1, &b);
753 }
754 CHECK(submit());
755
756 // The draw, then the images and the render target read back.
757 const VkDeviceSize image_bytes = 3 * AW * AW * 4 + A3 * A3 * A3 * 4;
758 VkBuffer atomic_readback;
759 void* atomic_map;
760 CHECK(make_buffer(image_bytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT, &atomic_readback, &atomic_map));
761 CHECK(vkResetCommandBuffer(cmd, 0));
762 CHECK(vkBeginCommandBuffer(cmd, &begin));
763 VkClearValue clear{};
764 for (float& channel : clear.color.float32) channel = 0.25f;
765 VkRenderPassBeginInfo rbi{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO};
766 rbi.renderPass = pass;
767 rbi.framebuffer = framebuffer;
768 rbi.renderArea = scissor;
769 rbi.clearValueCount = 1;
770 rbi.pClearValues = &clear;
771 vkCmdBeginRenderPass(cmd, &rbi, VK_SUBPASS_CONTENTS_INLINE);
772 vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
773 const VkDescriptorSet bound = set.set();
774 vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &bound, 0, nullptr);
775 std::uint32_t block[36] = {};
776 block[2] = atomic_va;
777 block[32] = std::uint32_t(heap_base);
778 block[33] = std::uint32_t(heap_base >> 32);
779 vkCmdPushConstants(cmd, pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0,
780 sizeof(block), block);
781 vkCmdDraw(cmd, 3, 1, 0, 0);
782 vkCmdEndRenderPass(cmd);
783 VkMemoryBarrier after{VK_STRUCTURE_TYPE_MEMORY_BARRIER};
784 after.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
785 after.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
786 vkCmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &after,
787 0, nullptr, 0, nullptr);
788 VkDeviceSize offset = 0;
789 for (int k = 0; k < 4; ++k) {
790 VkBufferImageCopy rc{};
791 rc.bufferOffset = offset;
792 rc.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
793 rc.imageExtent = k == 3 ? VkExtent3D{A3, A3, A3} : VkExtent3D{AW, AW, 1};
794 vkCmdCopyImageToBuffer(cmd, images[k], VK_IMAGE_LAYOUT_GENERAL, atomic_readback, 1, &rc);
795 offset += k == 3 ? A3 * A3 * A3 * 4 : AW * AW * 4;
796 }
797 VkBufferImageCopy tc{};
798 tc.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
799 tc.imageExtent = {W, H, 1};
800 vkCmdCopyImageToBuffer(cmd, target, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, readback, 1, &tc);
801 CHECK(submit());
802
803 // The model: every pixel's atomics, discarded or not.
804 std::vector<std::uint32_t> want(3 * AW * AW + A3 * A3 * A3, 0);
805 for (std::uint32_t t = 0; t < AW * AW; ++t) want[AW * AW + t] = 0xFFFFFFFFu;
806 for (std::uint32_t py = 0; py < H; ++py)
807 for (std::uint32_t px = 0; px < W; ++px) {
808 const std::uint32_t id = px + 64 * py, t = (py >> 3) * AW + (px >> 3);
809 want[t] = std::max(want[t], id);
810 want[AW * AW + t] = std::min(want[AW * AW + t], id);
811 want[2 * AW * AW + t] |= 1u << (id & 31);
812 const std::uint32_t v = ((px & 3) * A3 + (py >> 4)) * A3 + (px >> 4);
813 want[3 * AW * AW + v] = std::max(want[3 * AW * AW + v], id);
814 }
815 const auto* got = static_cast<const std::uint32_t*>(atomic_map);
816 const char* names[] = {"2D umax", "2D umin", "2D or", "3D umax"};
817 unsigned wrong = 0;
818 for (std::size_t i = 0; i < want.size(); ++i) {
819 if (got[i] == want[i]) continue;
820 const int k = i < 3 * AW * AW ? int(i / (AW * AW)) : 3;
821 if (wrong++ < 8)
822 std::printf(" %s texel %zu: got 0x%08x, want 0x%08x\n", names[k],
823 k == 3 ? i - 3 * AW * AW : i % (AW * AW), got[i], want[i]);
824 }
825 const float* rt = static_cast<const float*>(readback_map);
826 unsigned bad_rt = 0;
827 for (std::uint32_t py = 0; py < H; ++py)
828 for (std::uint32_t px = 0; px < W; ++px)
829 bad_rt += rt[(py * W + px) * 4] != ((px & 1) ? 0.25f : 1.0f);
830 std::printf("ps_imgatomic: %u of %zu texels wrong (2D umax/umin/or 8x8 each, 3D umax 4x4x4); "
831 "%u of %u render-target pixels wrong (odd columns discarded)\n",
832 wrong, want.size(), bad_rt, W * H);
833 vkDeviceWaitIdle(dev);
834 if (g_validation_errors) {
835 std::printf("ps_imgatomic: %u validation errors\n", g_validation_errors);
836 return 1;
837 }
838 return wrong || bad_rt ? 1 : 0;
839 }
840
666 // A view that comes and goes before the set is flushed is never written: a texture created and destroyed 841 // A view that comes and goes before the set is flushed is never written: a texture created and destroyed
667 // between two submissions. Its slots are written once, with the fallback; a write of the destroyed view 842 // between two submissions. Its slots are written once, with the fallback; a write of the destroyed view
668 // would be a validation error. 843 // would be a validation error.
@@ -727,7 +902,7 @@ int main(int argc, char** argv) {
727 // 2. Without its key the T# is a miss: index 0, the fallback image of zeros. 902 // 2. Without its key the T# is a miss: index 0, the fallback image of zeros.
728 const float zeros[4] = {0, 0, 0, 0}; 903 const float zeros[4] = {0, 0, 0, 0};
729 EXPECT(set.erase_key(tsharp) && !set.erase_key(tsharp)); 904 EXPECT(set.erase_key(tsharp) && !set.erase_key(tsharp));
730 EXPECT(set.flush_needs_idle()); // erasing may move the keys behind it; nothing is running here 905 EXPECT(!set.flush_needs_idle()); // erasing empties its slot only: the three keys ahead stay where they are
731 EXPECT(flush() && !set.flush_needs_idle()); 906 EXPECT(flush() && !set.flush_needs_idle());
732 CHECK(draw()); 907 CHECK(draw());
733 compare("2 miss", zeros); 908 compare("2 miss", zeros);
diff --git a/runtime/test/vk_descriptor_bench.cpp b/runtime/test/vk_descriptor_bench.cpp
index 07be76abb..5f5e721c8 100644
--- a/runtime/test/vk_descriptor_bench.cpp
+++ b/runtime/test/vk_descriptor_bench.cpp
@@ -7,7 +7,7 @@
7// dispatch against CPU DescriptorTable::lookup() before timing. 7// dispatch against CPU DescriptorTable::lookup() before timing.
8// 8//
9// Usage: 9// Usage:
10// vk_descriptor_bench [--sizes 1000,10000,100000] [--groups 4096] [--iters 64] [--reps 25] [--warmup 5] 10// vk_descriptor_bench [--sizes 1000,10000,100000] [--groups 4096] [--iters 64] [--reps 25] [--warmup 5] [--warmup-ms 300]
11// [--memory all|device|host|rebar] [--device N] [--list-devices] [--quick] [--csv] 11// [--memory all|device|host|rebar] [--device N] [--list-devices] [--quick] [--csv]
12// [--dump-spv PREFIX] [--self-test] 12// [--dump-spv PREFIX] [--self-test]
13// LEONIDA_VK_VALIDATION=1 enables VK_LAYER_KHRONOS_validation; any validation error fails the run. 13// LEONIDA_VK_VALIDATION=1 enables VK_LAYER_KHRONOS_validation; any validation error fails the run.
@@ -969,6 +969,7 @@ struct Options {
969 std::uint32_t reps = 25u; 969 std::uint32_t reps = 25u;
970 std::uint32_t warmup = 5u; 970 std::uint32_t warmup = 5u;
971 double max_dispatch_ms = 120.0; 971 double max_dispatch_ms = 120.0;
972 double warmup_ms = 300.0; // keep running the timed dispatch until this much time has passed (0 = off)
972 std::optional<std::uint32_t> device_index; 973 std::optional<std::uint32_t> device_index;
973 MemoryFilter mem_filter = MemoryFilter::All; 974 MemoryFilter mem_filter = MemoryFilter::All;
974 bool list_devices = false; 975 bool list_devices = false;
@@ -985,6 +986,8 @@ void print_usage() {
985 " --iters N lookups per invocation per dispatch (default: 64)\n" 986 " --iters N lookups per invocation per dispatch (default: 64)\n"
986 " --reps N timed repetitions per scenario (default: 25)\n" 987 " --reps N timed repetitions per scenario (default: 25)\n"
987 " --warmup N warmup dispatches before timing (default: 5)\n" 988 " --warmup N warmup dispatches before timing (default: 5)\n"
989 " --warmup-ms F then keep dispatching until F ms have passed, so the GPU clocks are up before the\n"
990 " first timed run, 0=off (default: 300; --quick turns it off)\n"
988 " --max-dispatch-ms F auto-scale slow dispatches to avoid OS TDR, 0=off (default: 120)\n" 991 " --max-dispatch-ms F auto-scale slow dispatches to avoid OS TDR, 0=off (default: 120)\n"
989 " --memory MODE all|device|host|rebar (default: all)\n" 992 " --memory MODE all|device|host|rebar (default: all)\n"
990 " --device N select physical device index from --list-devices\n" 993 " --device N select physical device index from --list-devices\n"
@@ -1031,6 +1034,7 @@ bool parse_args(int argc, const char* const* argv, Options& opt, bool& show_help
1031 opt.groups = 16u; 1034 opt.groups = 16u;
1032 opt.iters = 4u; 1035 opt.iters = 4u;
1033 opt.warmup = 1u; 1036 opt.warmup = 1u;
1037 opt.warmup_ms = 0.0;
1034 opt.reps = 3u; 1038 opt.reps = 3u;
1035 } else if (arg == "--groups") { 1039 } else if (arg == "--groups") {
1036 const char* v = nullptr; 1040 const char* v = nullptr;
@@ -1051,6 +1055,13 @@ bool parse_args(int argc, const char* const* argv, Options& opt, bool& show_help
1051 const double val = std::strtod(v, &end); 1055 const double val = std::strtod(v, &end);
1052 if (*v == '\0' || *end != '\0' || !std::isfinite(val) || val < 0.0) return false; 1056 if (*v == '\0' || *end != '\0' || !std::isfinite(val) || val < 0.0) return false;
1053 opt.max_dispatch_ms = val; 1057 opt.max_dispatch_ms = val;
1058 } else if (arg == "--warmup-ms") {
1059 const char* v = nullptr;
1060 if (!need_val(v)) return false;
1061 char* end = nullptr;
1062 const double val = std::strtod(v, &end);
1063 if (*v == '\0' || *end != '\0' || !std::isfinite(val) || val < 0.0) return false;
1064 opt.warmup_ms = val;
1054 } else if (arg == "--device") { 1065 } else if (arg == "--device") {
1055 const char* v = nullptr; 1066 const char* v = nullptr;
1056 std::uint32_t idx = 0u; 1067 std::uint32_t idx = 0u;
@@ -1164,6 +1175,19 @@ int run_self_test() {
1164 return 1; 1175 return 1;
1165 } 1176 }
1166 1177
1178 {
1179 const char* const ok_args[] = {"vk_descriptor_bench", "--warmup-ms", "0"};
1180 const char* const bad_args[] = {"vk_descriptor_bench", "--warmup-ms", "-1"};
1181 const char* const quick_args[] = {"vk_descriptor_bench", "--quick"};
1182 Options o_ok, o_bad, o_quick, o_default;
1183 bool h = false;
1184 if (o_default.warmup_ms != 300.0 || !parse_args(3, ok_args, o_ok, h) || o_ok.warmup_ms != 0.0 ||
1185 parse_args(3, bad_args, o_bad, h) || !parse_args(2, quick_args, o_quick, h) || o_quick.warmup_ms != 0.0) {
1186 std::fprintf(stderr, "self-test: --warmup-ms parsing or its default is wrong\n");
1187 return 1;
1188 }
1189 }
1190
1167 const struct { 1191 const struct {
1168 const char* name; 1192 const char* name;
1169 ShaderKind kind; 1193 ShaderKind kind;
@@ -2134,6 +2158,22 @@ int main(int argc, char** argv) {
2134 } 2158 }
2135 } 2159 }
2136 2160
2161 // A handful of dispatches is not enough to bring the clocks up on every GPU: with --warmup 5 an idle
2162 // RX 7600 measured the first placement ~1.8x slower than with --warmup 200, and the RTX 4050 ~1.3x
2163 // (TEST-277). Keep running the command that is about to be timed for --warmup-ms.
2164 if (opt.warmup_ms > 0.0) {
2165 const auto w0 = std::chrono::steady_clock::now();
2166 for (;;) {
2167 if (!submit_and_wait(bench_cmd)) {
2168 cleanup_all(keys_buf, map_buf);
2169 return 1;
2170 }
2171 const double spent =
2172 std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - w0).count();
2173 if (spent >= opt.warmup_ms) break;
2174 }
2175 }
2176
2137 std::vector<double> samples_ms; 2177 std::vector<double> samples_ms;
2138 samples_ms.reserve(eff_reps); 2178 samples_ms.reserve(eff_reps);
2139 for (std::uint32_t r = 0; r < eff_reps; ++r) { 2179 for (std::uint32_t r = 0; r < eff_reps; ++r) {
diff --git a/runtime/test/vk_harness.cpp b/runtime/test/vk_harness.cpp
index f7f86fa51..360a20fa7 100644
--- a/runtime/test/vk_harness.cpp
+++ b/runtime/test/vk_harness.cpp
@@ -240,6 +240,17 @@ int main(int argc, char** argv) {
240 return 2; 240 return 2;
241 } 241 }
242 } 242 }
243 // Translated shaders declare a 144-byte push-constant block (user SGPRs, heap base, code base; see VKH_SGPRS /
244 // VKH_HEAP); --mesh-compute modules and their vertex shaders add the output address (152 bytes). A device with
245 // fewer bytes (128, the Vulkan minimum, as on some Intel Arc drivers and AMD's Windows driver for RDNA2 iGPUs)
246 // cannot take that range: declaring it anyway is invalid, and there a shader reading past the limit crashed or
247 // hung the device. 77, as vk_texture_test and vk_bindless_test: a device limit, not a wrong result (D3D-14).
248 const uint32_t pc_bytes = mesh_compute ? 152u : 144u;
249 if (props.limits.maxPushConstantsSize < pc_bytes) {
250 std::fprintf(stderr, "unsupported: need %u push constant bytes, device has %u\n", pc_bytes,
251 props.limits.maxPushConstantsSize);
252 return 77;
253 }
243 // VKH_MESH=1: the first shader is a mesh shader (VK_EXT_mesh_shader), drawn with vkCmdDrawMeshTasksEXT(1,1,1). 254 // VKH_MESH=1: the first shader is a mesh shader (VK_EXT_mesh_shader), drawn with vkCmdDrawMeshTasksEXT(1,1,1).
244 const bool mesh = !mesh_compute && (group_readback || std::getenv("VKH_MESH") != nullptr); 255 const bool mesh = !mesh_compute && (group_readback || std::getenv("VKH_MESH") != nullptr);
245 VkPhysicalDeviceMeshShaderFeaturesEXT meshf{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT}; 256 VkPhysicalDeviceMeshShaderFeaturesEXT meshf{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT};
@@ -454,12 +465,11 @@ int main(int argc, char** argv) {
454 VkPipelineColorBlendAttachmentState cba{}; cba.colorWriteMask = 0xF; 465 VkPipelineColorBlendAttachmentState cba{}; cba.colorWriteMask = 0xF;
455 VkPipelineColorBlendStateCreateInfo cb{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO}; 466 VkPipelineColorBlendStateCreateInfo cb{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO};
456 cb.attachmentCount = 1; cb.pAttachments = &cba; 467 cb.attachmentCount = 1; cb.pAttachments = &cba;
457 // Translated shaders declare a 144-byte push-constant block (user SGPRs, heap base, code base; see VKH_SGPRS / 468 // The push-constant block (pc_bytes, checked against the device limit above).
458 // VKH_HEAP); --mesh-compute modules and their vertex shaders add the output address (152 bytes).
459 const VkShaderStageFlags pcs = (mesh ? VK_SHADER_STAGE_MESH_BIT_EXT : VK_SHADER_STAGE_VERTEX_BIT) | 469 const VkShaderStageFlags pcs = (mesh ? VK_SHADER_STAGE_MESH_BIT_EXT : VK_SHADER_STAGE_VERTEX_BIT) |
460 VK_SHADER_STAGE_FRAGMENT_BIT | (gs_path ? VK_SHADER_STAGE_GEOMETRY_BIT : 0) | 470 VK_SHADER_STAGE_FRAGMENT_BIT | (gs_path ? VK_SHADER_STAGE_GEOMETRY_BIT : 0) |
461 (mesh_compute ? VK_SHADER_STAGE_COMPUTE_BIT : 0); 471 (mesh_compute ? VK_SHADER_STAGE_COMPUTE_BIT : 0);
462 VkPushConstantRange pcr{pcs, 0, mesh_compute ? 152u : 144u}; 472 VkPushConstantRange pcr{pcs, 0, pc_bytes};
463 VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; 473 VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
464 pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr; 474 pli.pushConstantRangeCount = 1; pli.pPushConstantRanges = &pcr;
465 VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl)); 475 VkPipelineLayout pl; CHECK(vkCreatePipelineLayout(dev, &pli, nullptr, &pl));
@@ -564,7 +574,6 @@ int main(int argc, char** argv) {
564 std::memcpy(pc, shifts, sizeof(shifts)); 574 std::memcpy(pc, shifts, sizeof(shifts));
565 } 575 }
566 auto push = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetDeviceProcAddr(dev, "vkCmdPushConstants")); 576 auto push = reinterpret_cast<PFN_vkCmdPushConstants>(vkGetDeviceProcAddr(dev, "vkCmdPushConstants"));
567 const uint32_t pc_bytes = mesh_compute ? 152u : 144u;
568 if (mesh_compute) { 577 if (mesh_compute) {
569 // The mesh shader as compute, then make its stores visible to the vertex shader's reads. 578 // The mesh shader as compute, then make its stores visible to the vertex shader's reads.
570 LOADD(vkCmdDispatch); LOADD(vkCmdPipelineBarrier); 579 LOADD(vkCmdDispatch); LOADD(vkCmdPipelineBarrier);
@@ -591,7 +600,11 @@ int main(int argc, char** argv) {
591 } 600 }
592 vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe); 601 vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe);
593 push(cmd, pl, pcs, 0, pc_bytes, pc); 602 push(cmd, pl, pcs, 0, pc_bytes, pc);
594 if (mesh_compute) 603 // VKH_VERTICES=<n>: draw n vertices instead of one triangle, so a vertex shader fills whole waves (TEST-251).
604 const char* vertices_env = std::getenv("VKH_VERTICES");
605 if (const unsigned vertices = vertices_env ? unsigned(std::strtoul(vertices_env, nullptr, 10)) : 0; vertices && !mesh)
606 vkCmdDraw(cmd, vertices, 1, 0, 0);
607 else if (mesh_compute)
595 vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0); 608 vkCmdDraw(cmd, uint32_t(mesh_groups * mesh_prims * 3), 1, 0, 0);
596 else if (mesh) 609 else if (mesh)
597 reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]); 610 reinterpret_cast<PFN_vkCmdDrawMeshTasksEXT>(vkGetDeviceProcAddr(dev, "vkCmdDrawMeshTasksEXT"))(cmd, groups[0], groups[1], groups[2]);
diff --git a/runtime/test/vk_overlapping_occlusion_test.cpp b/runtime/test/vk_overlapping_occlusion_test.cpp
index cc9372feb..2a510d33a 100644
--- a/runtime/test/vk_overlapping_occlusion_test.cpp
+++ b/runtime/test/vk_overlapping_occlusion_test.cpp
@@ -135,13 +135,14 @@ struct Draws {
135 std::vector<std::uint32_t> extents; 135 std::vector<std::uint32_t> extents;
136 std::size_t next = 0; 136 std::size_t next = 0;
137 bool overflow = false; 137 bool overflow = false;
138 bool every = false; // --bisect: one 1x1 draw before every end, no schedule 138 bool every = false; // --bisect: one 1x1 draw before every end, no schedule
139 bool no_draw = false; // --bisect --no-draw: no draws at all, every query stays empty
139}; 140};
140Draws* draws = nullptr; 141Draws* draws = nullptr;
141 142
142VKAPI_ATTR void VKAPI_CALL end_query_with_draw(VkCommandBuffer cb, VkQueryPool pool, std::uint32_t index) { 143VKAPI_ATTR void VKAPI_CALL end_query_with_draw(VkCommandBuffer cb, VkQueryPool pool, std::uint32_t index) {
143 if (draws->every) { 144 if (draws->every) {
144 draws->fixture.draw(cb, 1); 145 if (!draws->no_draw) draws->fixture.draw(cb, 1);
145 } else if (draws->next == draws->extents.size()) { 146 } else if (draws->next == draws->extents.size()) {
146 draws->overflow = true; 147 draws->overflow = true;
147 } else if (const auto extent = draws->extents[draws->next++]) { 148 } else if (const auto extent = draws->extents[draws->next++]) {
@@ -159,9 +160,13 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_device_proc(VkDevice device, const
159// submission is waited for before the next, so the last "running" line before a hang or a lost device names the 160// submission is waited for before the next, so the last "running" line before a hang or a lost device names the
160// pattern. --gated queues them all behind one semaphore the CPU signals afterwards, as the full test does. Named 161// pattern. --gated queues them all behind one semaphore the CPU signals afterwards, as the full test does. Named
161// phases run only those, in the order below. Only completion is checked, not values. 162// phases run only those, in the order below. Only completion is checked, not values.
163// Two switches separate the draw from the resolve: --no-draw leaves every query empty (no rendering scope inside
164// it), --no-resolve records the queries but never copies or sums their results.
162struct Bisect { 165struct Bisect {
163 bool enabled = false; 166 bool enabled = false;
164 bool gated = false; 167 bool gated = false;
168 bool no_draw = false;
169 bool no_resolve = false;
165 std::vector<std::string> phases; 170 std::vector<std::string> phases;
166 bool wants(const char* name) const { 171 bool wants(const char* name) const {
167 return phases.empty() || std::find(phases.begin(), phases.end(), name) != phases.end(); 172 return phases.empty() || std::find(phases.begin(), phases.end(), name) != phases.end();
@@ -184,8 +189,9 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
184 schedule.extents.insert(schedule.extents.end(), 2 * bursts + 1, 1); 189 schedule.extents.insert(schedule.extents.end(), 2 * bursts + 1, 1);
185 // The statistics lists below: a split query (two segments), two unsplit references and a second split query. 190 // The statistics lists below: a split query (two segments), two unsplit references and a second split query.
186 if (d.pipeline_statistics_query) schedule.extents.insert(schedule.extents.end(), {3, 5, 3, 5, 3, 5}); 191 if (d.pipeline_statistics_query) schedule.extents.insert(schedule.extents.end(), {3, 5, 3, 5, 3, 5});
187 schedule.extents.insert(schedule.extents.end(), {2, 0, 0, 0}); 192 schedule.extents.insert(schedule.extents.end(), {2, 0, 0, 0, 1});
188 schedule.every = bisect.enabled; 193 schedule.every = bisect.enabled;
194 schedule.no_draw = bisect.no_draw;
189 draws = &schedule; 195 draws = &schedule;
190 VulkanContext context(get_device_proc, d.device, true, d.conditional_rendering); 196 VulkanContext context(get_device_proc, d.device, true, d.conditional_rendering);
191 EXPECT(context.loaded()); 197 EXPECT(context.loaded());
@@ -236,30 +242,37 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
236 if (!bisect.wants(name)) return nullptr; 242 if (!bisect.wants(name)) return nullptr;
237 return &lists.emplace_back(name, CommandList{}).second; 243 return &lists.emplace_back(name, CommandList{}).second;
238 }; 244 };
245 const auto resolve = [&](CommandList* l, const ResolveQueries& r) {
246 return bisect.no_resolve || l->resolve_queries(r);
247 };
239 if (auto* l = add("crossing")) { // two queries of one heap overlap; resolve while one is active 248 if (auto* l = add("crossing")) { // two queries of one heap overlap; resolve while one is active
240 EXPECT(l->begin_query({a, occ, 0}) && l->begin_query({a, occ, 1}) && l->end_query({a, occ, 0})); 249 EXPECT(l->begin_query({a, occ, 0}) && l->begin_query({a, occ, 1}) && l->end_query({a, occ, 0}));
241 EXPECT(l->resolve_queries({a, occ, 0, 1, dst_id, 8}) && l->end_query({a, occ, 1})); 250 EXPECT(resolve(l, {a, occ, 0, 1, dst_id, 8}) && l->end_query({a, occ, 1}));
242 EXPECT(l->resolve_queries({a, occ, 0, 2, dst_id, 24})); 251 EXPECT(resolve(l, {a, occ, 0, 2, dst_id, 24}));
252 }
253 if (auto* l = add("active")) { // a resolve inside one active query, without an overlap
254 EXPECT(l->begin_query({a, occ, 0}) && l->end_query({a, occ, 0}) && l->begin_query({a, occ, 3}));
255 EXPECT(resolve(l, {a, occ, 0, 1, dst_id, 128}) && l->end_query({a, occ, 3}));
243 } 256 }
244 if (auto* l = add("nested")) { // the same index in two heaps, one inside the other 257 if (auto* l = add("nested")) { // the same index in two heaps, one inside the other
245 EXPECT(l->begin_query({a, occ, 2}) && l->begin_query({b, occ, 2})); 258 EXPECT(l->begin_query({a, occ, 2}) && l->begin_query({b, occ, 2}));
246 EXPECT(l->end_query({b, occ, 2}) && l->end_query({a, occ, 2})); 259 EXPECT(l->end_query({b, occ, 2}) && l->end_query({a, occ, 2}));
247 EXPECT(l->resolve_queries({a, occ, 2, 1, dst_id, 40}) && l->resolve_queries({b, occ, 2, 1, dst_id, 48})); 260 EXPECT(resolve(l, {a, occ, 2, 1, dst_id, 40}) && resolve(l, {b, occ, 2, 1, dst_id, 48}));
248 } 261 }
249 if (auto* l = add("unwritten")) { // a query never begun: zero fill 262 if (auto* l = add("unwritten")) { // a query never begun: zero fill
250 EXPECT(l->resolve_queries({b, occ, 0, 1, dst_id, 56})); 263 EXPECT(resolve(l, {b, occ, 0, 1, dst_id, 56}));
251 } 264 }
252 if (auto* l = add("binary")) { // the binary-occlusion compute resolve 265 if (auto* l = add("binary")) { // the binary-occlusion compute resolve
253 EXPECT(l->begin_query({a, binary, 3}) && l->end_query({a, binary, 3})); 266 EXPECT(l->begin_query({a, binary, 3}) && l->end_query({a, binary, 3}));
254 EXPECT(l->resolve_queries({a, binary, 3, 1, dst_id, 64})); 267 EXPECT(resolve(l, {a, binary, 3, 1, dst_id, 64}));
255 } 268 }
256 if (d.conditional_rendering) { 269 if (d.conditional_rendering) {
257 if (auto* l = add("predicated")) { // both compute resolves under a false predicate 270 if (auto* l = add("predicated")) { // both compute resolves under a false predicate
258 EXPECT(l->begin_query({a, binary, 3}) && l->end_query({a, binary, 3})); 271 EXPECT(l->begin_query({a, binary, 3}) && l->end_query({a, binary, 3}));
259 EXPECT(l->set_predication({predicate_id, 0, d3d12_predication::equal_zero})); 272 EXPECT(l->set_predication({predicate_id, 0, d3d12_predication::equal_zero}));
260 EXPECT(l->resolve_queries({a, binary, 3, 1, dst_id, 64})); 273 EXPECT(resolve(l, {a, binary, 3, 1, dst_id, 64}));
261 EXPECT(l->resolve_queries({a, occ, 0, 1, dst_id, 72})); 274 EXPECT(resolve(l, {a, occ, 0, 1, dst_id, 72}));
262 EXPECT(l->resolve_queries({a, binary, 3, 1, dst_id, 80})); 275 EXPECT(resolve(l, {a, binary, 3, 1, dst_id, 80}));
263 EXPECT(copy_control.record(*l)); 276 EXPECT(copy_control.record(*l));
264 } 277 }
265 } 278 }
@@ -267,14 +280,24 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
267 EXPECT(l->begin_query({a, occ, 3})); 280 EXPECT(l->begin_query({a, occ, 3}));
268 for (std::uint32_t i = 0; i < bursts; ++i) EXPECT(l->begin_query({b, occ, 0}) && l->end_query({b, occ, 0})); 281 for (std::uint32_t i = 0; i < bursts; ++i) EXPECT(l->begin_query({b, occ, 0}) && l->end_query({b, occ, 0}));
269 EXPECT(l->end_query({a, occ, 3})); 282 EXPECT(l->end_query({a, occ, 3}));
270 EXPECT(l->resolve_queries({a, occ, 3, 1, dst_id, 88}) && l->resolve_queries({b, occ, 0, 1, dst_id, 96})); 283 EXPECT(resolve(l, {a, occ, 3, 1, dst_id, 88}) && resolve(l, {b, occ, 0, 1, dst_id, 96}));
271 } 284 }
272 if (auto* l = add("replace")) { // every heap query begun and ended again, then resolved 285 if (auto* l = add("replace")) { // every heap query begun and ended again, then resolved
273 for (const auto& [heap, index] : {std::pair{a, 0u}, std::pair{a, 1u}, std::pair{a, 2u}, std::pair{b, 2u}}) 286 for (const auto& [heap, index] : {std::pair{a, 0u}, std::pair{a, 1u}, std::pair{a, 2u}, std::pair{b, 2u}})
274 EXPECT(l->begin_query({heap, occ, index}) && l->end_query({heap, occ, index})); 287 EXPECT(l->begin_query({heap, occ, index}) && l->end_query({heap, occ, index}));
275 EXPECT(l->resolve_queries({a, occ, 0, 2, dst_id, 112})); 288 EXPECT(resolve(l, {a, occ, 0, 2, dst_id, 112}));
276 } 289 }
277 EXPECT(!lists.empty()); 290 EXPECT(!lists.empty());
291 std::printf("bisect:%s%s%s\n", bisect.gated ? " gated" : " ungated", bisect.no_draw ? " no-draw" : " draws",
292 bisect.no_resolve ? " no-resolve" : " resolves");
293 // After a TDR, AMD's Windows driver lets vkQueueWaitIdle succeed (#1540); every timeline semaphore then reads
294 // UINT64_MAX, so the gate's value is checked as well as what the context has seen.
295 const auto get_value = d.fn<PFN_vkGetSemaphoreCounterValue>("vkGetSemaphoreCounterValue");
296 const auto lost = [&] {
297 std::uint64_t value = 0;
298 return context.is_device_lost() || get_value(d.device, gate.semaphore(), &value) != VK_SUCCESS ||
299 value == UINT64_MAX;
300 };
278 if (bisect.gated) queue.wait(gate.semaphore(), 1); 301 if (bisect.gated) queue.wait(gate.semaphore(), 1);
279 for (auto& [name, list] : lists) { 302 for (auto& [name, list] : lists) {
280 EXPECT(list.close()); 303 EXPECT(list.close());
@@ -286,15 +309,15 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
286 std::printf("%s: execute returned %d\n", name, int(result)); 309 std::printf("%s: execute returned %d\n", name, int(result));
287 return 1; 310 return 1;
288 } 311 }
289 if (!bisect.gated && !queue.idle()) { 312 if (!bisect.gated && (!queue.idle() || lost())) {
290 std::printf("%s: vkQueueWaitIdle failed (device lost?)\n", name); 313 std::printf("%s: device lost\n", name);
291 return 1; 314 return 1;
292 } 315 }
293 } 316 }
294 if (bisect.gated) { 317 if (bisect.gated) {
295 EXPECT(gate.signal(1)); 318 EXPECT(gate.signal(1));
296 if (!queue.idle()) { 319 if (!queue.idle() || lost()) {
297 std::printf("gated: vkQueueWaitIdle failed (device lost?)\n"); 320 std::printf("gated: device lost\n");
298 return 1; 321 return 1;
299 } 322 }
300 } 323 }
@@ -414,13 +437,22 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
414 EXPECT(replace.close()); 437 EXPECT(replace.close());
415 const CommandList* fourth[] = {&replace}; 438 const CommandList* fourth[] = {&replace};
416 EXPECT(queue.execute(fourth) == ReplayResult::success); 439 EXPECT(queue.execute(fourth) == ReplayResult::success);
440
441 // A resolve inside one active query, with no overlap.
442 CommandList single;
443 EXPECT(single.begin_query({a, occ, 3}));
444 EXPECT(single.resolve_queries({a, occ, 0, 1, dst_id, 128}));
445 EXPECT(single.end_query({a, occ, 3}));
446 EXPECT(single.close());
447 const CommandList* fifth[] = {&single};
448 EXPECT(queue.execute(fifth) == ReplayResult::success);
417 EXPECT(!schedule.overflow && schedule.next == schedule.extents.size()); 449 EXPECT(!schedule.overflow && schedule.next == schedule.extents.size());
418 EXPECT(gate.signal(1)); 450 EXPECT(gate.signal(1));
419 EXPECT(queue.idle()); 451 EXPECT(queue.idle());
420 452
421 std::map<VkDeviceSize, std::uint64_t> expected = { 453 std::map<VkDeviceSize, std::uint64_t> expected = {
422 {8, 80}, {24, 80}, {32, 20}, {40, 84}, {48, 16}, {56, 0}, {64, 1}, {72, 80}, {80, 1}, 454 {8, 80}, {24, 80}, {32, 20}, {40, 84}, {48, 16}, {56, 0}, {64, 1}, {72, 80}, {80, 1},
423 {88, 2 * bursts + 1}, {96, 1}, {112, 4}, {120, 0}, 455 {88, 2 * bursts + 1}, {96, 1}, {112, 4}, {120, 0}, {128, 4},
424 }; 456 };
425 if (fixture.statistics) expected[0] = 2 * bursts + 1; // the sum resolved inside the statistics query 457 if (fixture.statistics) expected[0] = 2 * bursts + 1; // the sum resolved inside the statistics query
426 for (VkDeviceSize offset = 0; offset < size; offset += 8) { 458 for (VkDeviceSize offset = 0; offset < size; offset += 8) {
@@ -460,7 +492,7 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
460 static_cast<unsigned long long>(word(0, 0)), static_cast<unsigned long long>(word(0, 7))); 492 static_cast<unsigned long long>(word(0, 0)), static_cast<unsigned long long>(word(0, 7)));
461 } 493 }
462 std::printf("crossing 80/20; nested 84/16; %u segments summed; alternating binary results 1/1; " 494 std::printf("crossing 80/20; nested 84/16; %u segments summed; alternating binary results 1/1; "
463 "offsets and gated overwrites exact\n", 495 "resolve inside an active query 4; offsets and gated overwrites exact\n",
464 2 * bursts + 1); 496 2 * bursts + 1);
465 EXPECT(copy_control.check()); 497 EXPECT(copy_control.check());
466 return 0; 498 return 0;
@@ -468,13 +500,15 @@ int run(vktest::Device& d, const char* vertex, const char* fragment, const Bisec
468 500
469} // namespace 501} // namespace
470 502
471// vk_overlapping_occlusion_test <vert.spv> <frag.spv> [--bisect [--gated] [phase...]] 503// vk_overlapping_occlusion_test <vert.spv> <frag.spv> [--bisect [--gated] [--no-draw] [--no-resolve] [phase...]]
472int main(int argc, char** argv) { 504int main(int argc, char** argv) {
473 EXPECT(argc >= 3); 505 EXPECT(argc >= 3);
474 Bisect bisect; 506 Bisect bisect;
475 for (int i = 3; i < argc; ++i) { 507 for (int i = 3; i < argc; ++i) {
476 if (std::strcmp(argv[i], "--bisect") == 0) bisect.enabled = true; 508 if (std::strcmp(argv[i], "--bisect") == 0) bisect.enabled = true;
477 else if (std::strcmp(argv[i], "--gated") == 0) bisect.gated = true; 509 else if (std::strcmp(argv[i], "--gated") == 0) bisect.gated = true;
510 else if (std::strcmp(argv[i], "--no-draw") == 0) bisect.no_draw = true;
511 else if (std::strcmp(argv[i], "--no-resolve") == 0) bisect.no_resolve = true;
478 else bisect.phases.emplace_back(argv[i]); 512 else bisect.phases.emplace_back(argv[i]);
479 } 513 }
480 EXPECT(argc == 3 || bisect.enabled); 514 EXPECT(argc == 3 || bisect.enabled);
diff --git a/runtime/test/vk_pipeline_check.cpp b/runtime/test/vk_pipeline_check.cpp
index bdefac894..f11cc37ff 100644
--- a/runtime/test/vk_pipeline_check.cpp
+++ b/runtime/test/vk_pipeline_check.cpp
@@ -22,6 +22,12 @@
22// --cache-feedback count each stage's successful pipelines by VkPipelineCreationFeedback: hits (VALID and 22// --cache-feedback count each stage's successful pipelines by VkPipelineCreationFeedback: hits (VALID and
23// APPLICATION_PIPELINE_CACHE_HIT), no hit reported (VALID only) and unavailable (no VALID bit, or a 23// APPLICATION_PIPELINE_CACHE_HIT), no hit reported (VALID only) and unavailable (no VALID bit, or a
24// pre-1.3 device without VK_EXT_pipeline_creation_feedback). The three add up to the ok count. 24// pre-1.3 device without VK_EXT_pipeline_creation_feedback). The three add up to the ok count.
25// --isolate (POSIX only) check in child processes, --isolate-batch modules at a time (default 256), so a module
26// that kills the driver (SIGFPE, SIGSEGV, ...) is recorded as failed ("MODULE CRASH") and the pass
27// goes on. A crashed batch is bisected to the module. Children run one after the other and share
28// cache.bin. Not compatible with --stats.
29// test hook VK_PIPELINE_CHECK_SIMULATE_CRASH=<module name substring>[:SIGNAL] raises SIGNAL (default SIGFPE)
30// just before the pipeline of a matching module is created. Only for testing --isolate.
25#include "vulkan_loader.h" 31#include "vulkan_loader.h"
26#include "vk_device_pick.h" 32#include "vk_device_pick.h"
27#include "pipeline_cache_file.h" 33#include "pipeline_cache_file.h"
@@ -32,7 +38,10 @@
32#include <cctype> 38#include <cctype>
33#include <charconv> 39#include <charconv>
34#include <chrono> 40#include <chrono>
41#include <cmath>
35#include <condition_variable> 42#include <condition_variable>
43#include <csignal>
44#include <cstdlib>
36#include <cstdio> 45#include <cstdio>
37#include <cstring> 46#include <cstring>
38#include <fstream> 47#include <fstream>
@@ -48,6 +57,13 @@
48#include <utility> 57#include <utility>
49#include <vector> 58#include <vector>
50 59
60#ifndef _WIN32
61#include <sys/wait.h>
62#include <unistd.h>
63#include <cerrno>
64#include <filesystem>
65#endif
66
51static PFN_vkGetInstanceProcAddr gipa; 67static PFN_vkGetInstanceProcAddr gipa;
52 68
53struct VertexInputMeta { 69struct VertexInputMeta {
@@ -275,11 +291,13 @@ struct JsonParser {
275 291
276std::map<std::string, ShaderMeta> read_index(const std::string& path, std::string& err) { 292std::map<std::string, ShaderMeta> read_index(const std::string& path, std::string& err) {
277 std::ifstream f(path, std::ios::binary); 293 std::ifstream f(path, std::ios::binary);
278 std::string s((std::istreambuf_iterator<char>(f)), {});
279 std::map<std::string, ShaderMeta> out; 294 std::map<std::string, ShaderMeta> out;
295 if (!f) { err = "cannot open the file"; return out; } // a missing index must not read as an empty corpus
296 std::string s((std::istreambuf_iterator<char>(f)), {});
297 if (f.bad()) { err = "read error"; return out; }
280 JsonParser p{s, 0}; 298 JsonParser p{s, 0};
281 p.ws(); 299 p.ws();
282 if (p.i >= s.size()) return out; 300 if (p.i >= s.size()) { err = "the file is empty (an intentionally empty index is {})"; return out; }
283 if (!p.consume('{')) { err = "expected '{' at byte " + std::to_string(p.i); return out; } 301 if (!p.consume('{')) { err = "expected '{' at byte " + std::to_string(p.i); return out; }
284 while (!p.error && p.i < s.size()) { 302 while (!p.error && p.i < s.size()) {
285 if (p.consume('}')) return out; 303 if (p.consume('}')) return out;
@@ -375,6 +393,116 @@ static_assert(feedback_outcome(VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT) == 1);
375static_assert(feedback_outcome(VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT | 393static_assert(feedback_outcome(VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT |
376 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT) == 0); 394 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT) == 0);
377 395
396// Test hook (see the header): VK_PIPELINE_CHECK_SIMULATE_CRASH=<module name substring>[:SIGNAL].
397struct SimulatedCrash {
398 bool enabled = false;
399 std::string pattern;
400 int sig = SIGFPE;
401};
402
403int signal_from_name(std::string n) {
404 for (char& c : n) c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
405 if (n.rfind("SIG", 0) == 0) n = n.substr(3);
406 if (n == "FPE") return SIGFPE;
407 if (n == "SEGV") return SIGSEGV;
408 if (n == "ABRT") return SIGABRT;
409 if (n == "ILL") return SIGILL;
410 if (n == "TERM") return SIGTERM;
411#ifndef _WIN32
412 if (n == "BUS") return SIGBUS;
413 if (n == "KILL") return SIGKILL;
414#endif
415 return 0;
416}
417
418SimulatedCrash read_simulated_crash() {
419 SimulatedCrash c;
420 const char* env = std::getenv("VK_PIPELINE_CHECK_SIMULATE_CRASH");
421 if (!env || !*env) return c;
422 std::string v = env;
423 const size_t colon = v.rfind(':');
424 if (colon != std::string::npos) {
425 if (const int sig = signal_from_name(v.substr(colon + 1))) {
426 c.sig = sig;
427 v.resize(colon);
428 }
429 }
430 c.enabled = true;
431 c.pattern = v;
432 return c;
433}
434
435#ifndef _WIN32
436std::string signal_label(int sig) {
437 switch (sig) {
438 case SIGFPE: return "SIGFPE";
439 case SIGSEGV: return "SIGSEGV";
440 case SIGABRT: return "SIGABRT";
441 case SIGILL: return "SIGILL";
442 case SIGBUS: return "SIGBUS";
443 case SIGKILL: return "SIGKILL";
444 case SIGTERM: return "SIGTERM";
445 default: return "signal " + std::to_string(sig);
446 }
447}
448
449// --isolate: one child run of this executable over [start, start + count) of the stage-filtered list.
450struct ChildRun {
451 bool ready = false; // reached the work loop (ISO-READY): Vulkan and the cache were set up
452 bool done = false; // finished the pass and saved the cache (ISO-DONE)
453 bool cache_ok = true;
454 int sig = 0; // killed by this signal
455 int status = 0; // exit status when it exited
456 std::string out; // its stdout
457};
458
459ChildRun run_child(const std::string& exe, const std::string& dir, const std::vector<std::string>& pass,
460 const std::string& cache_path, size_t start, size_t count) {
461 ChildRun r;
462 std::vector<std::string> args = {exe, dir};
463 if (!cache_path.empty()) args.push_back(cache_path);
464 for (const auto& a : pass) args.push_back(a);
465 args.insert(args.end(), {"--isolate-child", "--start", std::to_string(start), "--count", std::to_string(count)});
466 std::vector<char*> argv;
467 for (auto& a : args) argv.push_back(a.data());
468 argv.push_back(nullptr);
469 int fds[2];
470 if (pipe(fds) != 0) { r.status = 127; return r; }
471 std::fflush(nullptr);
472 const pid_t pid = fork();
473 if (pid < 0) { close(fds[0]); close(fds[1]); r.status = 127; return r; }
474 if (pid == 0) {
475 dup2(fds[1], 1);
476 close(fds[0]); close(fds[1]);
477 execv(exe.c_str(), argv.data());
478 _exit(127);
479 }
480 close(fds[1]);
481 char buf[4096];
482 for (;;) {
483 const ssize_t n = read(fds[0], buf, sizeof buf);
484 if (n > 0) r.out.append(buf, size_t(n));
485 else if (n < 0 && errno == EINTR) continue;
486 else break;
487 }
488 close(fds[0]);
489 int st = 0;
490 while (waitpid(pid, &st, 0) < 0 && errno == EINTR) {}
491 if (WIFSIGNALED(st)) r.sig = WTERMSIG(st);
492 else r.status = WIFEXITED(st) ? WEXITSTATUS(st) : 1;
493 size_t pos = 0;
494 while (pos < r.out.size()) {
495 size_t e = r.out.find('\n', pos);
496 if (e == std::string::npos) e = r.out.size();
497 const std::string_view line(r.out.data() + pos, e - pos);
498 if (line == "ISO-READY") r.ready = true;
499 else if (line.rfind("ISO-DONE", 0) == 0) { r.done = true; r.cache_ok = line.find("cache_ok=0") == std::string_view::npos; }
500 pos = e + 1;
501 }
502 return r;
503}
504#endif
505
378} // namespace 506} // namespace
379 507
380int main(int argc, char** argv) { 508int main(int argc, char** argv) {
@@ -382,7 +510,7 @@ int main(int argc, char** argv) {
382 std::fprintf(stderr, 510 std::fprintf(stderr,
383 "usage: vk_pipeline_check <spirv dir> [cache.bin] [--jobs N] [--start I] [--count N] [--slow SEC] " 511 "usage: vk_pipeline_check <spirv dir> [cache.bin] [--jobs N] [--start I] [--count N] [--slow SEC] "
384 "[--max-bytes N] [--large-module-bytes N] [--stage all|cs|graphics | --compute-only | --graphics-only] " 512 "[--max-bytes N] [--large-module-bytes N] [--stage all|cs|graphics | --compute-only | --graphics-only] "
385 "[--stats FILE] [--cache-feedback]\n"); 513 "[--stats FILE] [--cache-feedback] [--isolate [--isolate-batch N]]\n");
386 return 2; 514 return 2;
387 } 515 }
388 std::setvbuf(stdout, nullptr, _IOLBF, 1 << 16); // failures reach a redirected log as they happen 516 std::setvbuf(stdout, nullptr, _IOLBF, 1 << 16); // failures reach a redirected log as they happen
@@ -392,40 +520,67 @@ int main(int argc, char** argv) {
392 size_t large_module_bytes = 4 * 1024 * 1024; 520 size_t large_module_bytes = 4 * 1024 * 1024;
393 double slow = 30.0; 521 double slow = 30.0;
394 std::string stage_filter = "all"; 522 std::string stage_filter = "all";
395 bool cache_feedback = false; 523 bool cache_feedback = false, isolate = false, iso_child = false;
524 size_t isolate_batch = 256;
396 for (int i = 2; i < argc; i++) { 525 for (int i = 2; i < argc; i++) {
397 std::string a = argv[i]; 526 std::string a = argv[i];
398 auto val = [&] { return i + 1 < argc ? std::string(argv[++i]) : std::string("0"); }; 527 auto value = [&]() -> std::string_view {
399 if (a == "--jobs") jobs = std::max(1u, uint32_t(std::stoul(val()))); 528 if (i + 1 == argc || std::string_view(argv[i + 1]).starts_with("--")) return {};
400 else if (a == "--start") start = std::stoull(val()); 529 return argv[++i];
401 else if (a == "--count") count = std::stoull(val()); 530 };
402 else if (a == "--slow") slow = std::stod(val()); 531 auto number = [&](auto& dest) {
403 else if (a == "--stage") stage_filter = val(); 532 const auto text = value();
533 if (text.empty()) return false;
534 const auto end = text.data() + text.size();
535 const auto [ptr, ec] = std::from_chars(text.data(), end, dest);
536 return ec == std::errc{} && ptr == end;
537 };
538 bool valid = true;
539 if (a == "--jobs") {
540 valid = number(jobs);
541 jobs = std::max(1u, jobs);
542 } else if (a == "--start") valid = number(start);
543 else if (a == "--count") valid = number(count);
544 else if (a == "--slow") valid = number(slow) && std::isfinite(slow) && slow >= 0.0;
545 else if (a == "--stage") valid = !(stage_filter = value()).empty();
404 else if (a == "--compute-only") stage_filter = "cs"; 546 else if (a == "--compute-only") stage_filter = "cs";
405 else if (a == "--graphics-only") stage_filter = "graphics"; 547 else if (a == "--graphics-only") stage_filter = "graphics";
406 else if (a == "--max-bytes") max_bytes = std::stoull(val()); 548 else if (a == "--max-bytes") valid = number(max_bytes);
407 else if (a == "--large-module-bytes") { 549 else if (a == "--large-module-bytes") valid = number(large_module_bytes);
408 const std::string_view value = i + 1 < argc ? argv[++i] : ""; 550 else if (a == "--stats") valid = !(stats_path = value()).empty();
409 const auto end = value.data() + value.size();
410 const auto [ptr, ec] = std::from_chars(value.data(), end, large_module_bytes);
411 if (ec != std::errc{} || ptr != end) {
412 std::fprintf(stderr, "--large-module-bytes requires a non-negative byte count\n");
413 return 2;
414 }
415 }
416 else if (a == "--stats") stats_path = val();
417 else if (a == "--cache-feedback") cache_feedback = true; 551 else if (a == "--cache-feedback") cache_feedback = true;
552 else if (a == "--isolate") isolate = true;
553 else if (a == "--isolate-child") iso_child = true; // internal: the parent's child runs
554 else if (a == "--isolate-batch") { // parsed like the other numbers (#1735); at least one per batch
555 valid = number(isolate_batch);
556 isolate_batch = std::max<size_t>(1, isolate_batch);
557 }
418 else cache_path = a; 558 else cache_path = a;
559 if (!valid) {
560 std::fprintf(stderr, "%s requires a valid value\n", a.c_str());
561 return 2;
562 }
419 } 563 }
420 if (stage_filter != "all" && stage_filter != "cs" && stage_filter != "graphics") { 564 if (stage_filter != "all" && stage_filter != "cs" && stage_filter != "graphics") {
421 std::fprintf(stderr, "unknown --stage '%s' (expected: all, cs, graphics)\n", stage_filter.c_str()); 565 std::fprintf(stderr, "unknown --stage '%s' (expected: all, cs, graphics)\n", stage_filter.c_str());
422 return 2; 566 return 2;
423 } 567 }
424 568
569 if (isolate && !stats_path.empty()) {
570 std::fprintf(stderr, "--isolate cannot be combined with --stats\n");
571 return 2;
572 }
573#ifdef _WIN32
574 if (isolate) {
575 std::fprintf(stderr, "--isolate is not supported on Windows (it needs fork/waitpid); run without it\n");
576 return 2;
577 }
578#endif
579
425 std::string index_err; 580 std::string index_err;
426 auto index = read_index(dir + "/index.json", index_err); 581 auto index = read_index(dir + "/index.json", index_err);
427 if (!index_err.empty()) { 582 if (!index_err.empty()) {
428 std::fprintf(stderr, "error: malformed JSON in %s/index.json: %s\n", dir.c_str(), index_err.c_str()); 583 std::fprintf(stderr, "error: cannot use %s/index.json: %s\n", dir.c_str(), index_err.c_str());
429 return 2; 584 return 2;
430 } 585 }
431 std::fprintf(stderr, "%zu shaders in index\n", index.size()); 586 std::fprintf(stderr, "%zu shaders in index\n", index.size());
@@ -441,6 +596,115 @@ int main(int argc, char** argv) {
441 const auto [lo, hi] = shader_slice(all.size(), start, count); 596 const auto [lo, hi] = shader_slice(all.size(), start, count);
442 const std::vector<Item> work(all.begin() + lo, all.begin() + hi); 597 const std::vector<Item> work(all.begin() + lo, all.begin() + hi);
443 598
599#ifndef _WIN32
600 if (isolate) {
601 // Parent: no Vulkan here. Run the check in child processes, one at a time, in batches of --isolate-batch
602 // modules. A child that dies mid-batch has its output discarded and the batch is bisected until the one
603 // module that kills the driver is found; the clean sub-runs partition the rest, so nothing is counted twice.
604 std::string exe = argv[0];
605 std::error_code ec;
606 if (auto self = std::filesystem::read_symlink("/proc/self/exe", ec); !ec) exe = self.string();
607 std::vector<std::string> pass = {"--jobs", std::to_string(jobs), "--slow", std::to_string(slow), "--stage", stage_filter,
608 "--max-bytes", std::to_string(max_bytes),
609 "--large-module-bytes", std::to_string(large_module_bytes)};
610 if (cache_feedback) pass.push_back("--cache-feedback");
611 struct Agg { uint32_t mod_ok = 0, mod_bad = 0, pipe_ok = 0, pipe_bad = 0, pipe_skip = 0, big = 0, crashed = 0, fb[3] = {}; };
612 std::map<std::string, Agg> agg;
613 std::vector<std::string> crashes;
614 bool cache_ok = true, setup_failed = false;
615 size_t unreproduced = 0;
616 const auto t_iso = std::chrono::steady_clock::now();
617 std::fprintf(stderr, "isolating %zu shaders [%zu, %zu) (stage=%s) in child processes, %zu per batch\n",
618 work.size(), lo, hi, stage_filter.c_str(), isolate_batch);
619 auto commit = [&](const ChildRun& r) {
620 size_t pos = 0;
621 while (pos < r.out.size()) {
622 size_t e = r.out.find('\n', pos);
623 if (e == std::string::npos) e = r.out.size();
624 const std::string line = r.out.substr(pos, e - pos);
625 pos = e + 1;
626 // The parent prints one cache line at the end instead of one per child.
627 if (line == "ISO-READY" || line.rfind("ISO-DONE", 0) == 0 || line.rfind("pipeline cache: ", 0) == 0) continue;
628 if (line.rfind("ISO-RESULT ", 0) == 0) {
629 char st[16];
630 unsigned v[9] = {};
631 if (std::sscanf(line.c_str(), "ISO-RESULT %15s %u %u %u %u %u %u %u %u %u", st, v, v + 1, v + 2, v + 3,
632 v + 4, v + 5, v + 6, v + 7, v + 8) == 10) {
633 Agg& a = agg[st];
634 a.mod_ok += v[0]; a.mod_bad += v[1]; a.pipe_ok += v[2]; a.pipe_bad += v[3]; a.pipe_skip += v[4];
635 a.big += v[5]; a.fb[0] += v[6]; a.fb[1] += v[7]; a.fb[2] += v[8];
636 }
637 continue;
638 }
639 std::printf("%s\n", line.c_str());
640 }
641 std::fflush(stdout);
642 if (!r.cache_ok) cache_ok = false;
643 };
644 // Returns the number of failures recorded for [s, s + n): crashed modules, or 1 for a crash that vanished.
645 auto bisect = [&](auto&& self, size_t s, size_t n) -> size_t {
646 if (setup_failed) return 0;
647 const ChildRun r = run_child(exe, dir, pass, cache_path, s, n);
648 if (r.done) { commit(r); return 0; }
649 if (!r.ready) { // died or exited before the work loop: not a module's fault
650 std::fputs(r.out.c_str(), stdout);
651 if (r.sig) std::fprintf(stderr, "error: a child process died during setup (%s)\n", signal_label(r.sig).c_str());
652 else std::fprintf(stderr, "error: a child process failed during setup (exit status %d)\n", r.status);
653 setup_failed = true;
654 return 0;
655 }
656 const std::string why = r.sig ? "driver crashed: " + signal_label(r.sig)
657 : "driver exited with status " + std::to_string(r.status);
658 if (n == 1) {
659 const std::string& name = *all[s].first;
660 const std::string& st = all[s].second->stage;
661 std::printf("MODULE CRASH %s (%s, %s)\n", name.c_str(), st.c_str(), why.c_str());
662 std::fflush(stdout);
663 crashes.push_back(name + " (" + st + ", " + why + ")");
664 agg[st].pipe_bad++;
665 agg[st].crashed++;
666 return 1;
667 }
668 std::fprintf(stderr, "child over [%zu, %zu) died (%s); bisecting\n", s, s + n, why.c_str());
669 const size_t half = n / 2;
670 size_t found = self(self, s, half);
671 found += self(self, s + half, n - half);
672 if (found == 0 && !setup_failed) {
673 std::printf("MODULE CRASH [%zu, %zu) not reproduced when split (%s); counted as failed\n", s, s + n, why.c_str());
674 ++unreproduced;
675 return 1;
676 }
677 return found;
678 };
679 for (size_t s = lo; s < hi && !setup_failed; s += isolate_batch) bisect(bisect, s, std::min(isolate_batch, hi - s));
680 if (setup_failed) return 1;
681 bool failed = !crashes.empty() || unreproduced || !cache_ok;
682 for (const auto& [st, a] : agg) {
683 std::printf("%s: %u modules ok, %u failed\n", st.c_str(), a.mod_ok, a.mod_bad);
684 std::printf("%s pipelines: %u ok, %u failed, %u skipped\n", st.c_str(), a.pipe_ok, a.pipe_bad, a.pipe_skip);
685 if (a.crashed) std::printf(" %s crashed the driver: %u (counted as failed)\n", st.c_str(), a.crashed);
686 if (cache_feedback)
687 std::printf(" %s cache feedback: %u hits, %u no hit reported, %u unavailable\n", st.c_str(), a.fb[0], a.fb[1], a.fb[2]);
688 if (a.mod_bad || a.pipe_bad) failed = true;
689 }
690 uint32_t big_total = 0;
691 for (const auto& [st, a] : agg) big_total += a.big;
692 if (big_total) std::printf("big modules skipped: %u (limit %zu bytes)\n", big_total, max_bytes);
693 if (!crashes.empty()) {
694 std::printf("modules that crashed the driver: %zu\n", crashes.size());
695 for (const auto& c : crashes) std::printf(" %s\n", c.c_str());
696 }
697 if (unreproduced) std::printf("crashes not reproduced after splitting: %zu\n", unreproduced);
698 if (!cache_path.empty()) {
699 const auto sz = std::filesystem::file_size(cache_path, ec);
700 if (!ec) std::printf("pipeline cache: %ju bytes -> %s\n", static_cast<uintmax_t>(sz), cache_path.c_str());
701 }
702 std::printf("wall time: %.1fs (isolated)\n",
703 std::chrono::duration<double>(std::chrono::steady_clock::now() - t_iso).count());
704 return failed ? 1 : 0;
705 }
706#endif
707
444 // Scan selected shaders to request only the optional extensions they actually use. 708 // Scan selected shaders to request only the optional extensions they actually use.
445 bool want_mesh = false, want_bary = false, want_lock = false, want_m8 = false, want_fma = false; 709 bool want_mesh = false, want_bary = false, want_lock = false, want_m8 = false, want_fma = false;
446 for (auto& [_, meta] : work) { 710 for (auto& [_, meta] : work) {
@@ -783,6 +1047,15 @@ int main(int argc, char** argv) {
783 if (n_done % 250 == 0) std::fprintf(stderr, " pipelines %u (%.0fs elapsed)\n", n_done, elapsed()); 1047 if (n_done % 250 == 0) std::fprintf(stderr, " pipelines %u (%.0fs elapsed)\n", n_done, elapsed());
784 }; 1048 };
785 1049
1050 const SimulatedCrash sim_crash = read_simulated_crash();
1051 auto maybe_simulate_crash = [&](const std::string& name) { // test hook, see the header
1052 if (sim_crash.enabled && name.find(sim_crash.pattern) != std::string::npos) {
1053 std::fprintf(stderr, "simulating signal %d before the pipeline of %s\n", sim_crash.sig, name.c_str());
1054 std::fflush(nullptr);
1055 std::raise(sim_crash.sig);
1056 }
1057 };
1058
786 auto worker = [&] { 1059 auto worker = [&] {
787 for (size_t k; (k = next++) < work.size();) { 1060 for (size_t k; (k = next++) < work.size();) {
788 const std::string& name = *work[k].first; 1061 const std::string& name = *work[k].first;
@@ -846,6 +1119,7 @@ int main(int argc, char** argv) {
846 const auto t0 = std::chrono::steady_clock::now(); 1119 const auto t0 = std::chrono::steady_clock::now();
847 { std::lock_guard<std::mutex> g(mu); inflight[std::this_thread::get_id()] = {name, t0}; } 1120 { std::lock_guard<std::mutex> g(mu); inflight[std::this_thread::get_id()] = {name, t0}; }
848 VkPipeline p = VK_NULL_HANDLE; 1121 VkPipeline p = VK_NULL_HANDLE;
1122 maybe_simulate_crash(name);
849 VkResult r = vkCreateComputePipelines(dev, cache, 1, &cpi, nullptr, &p); 1123 VkResult r = vkCreateComputePipelines(dev, cache, 1, &cpi, nullptr, &p);
850 const double sec = std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count(); 1124 const double sec = std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count();
851 if (r == VK_SUCCESS) write_stats(name, stage, VK_SHADER_STAGE_COMPUTE_BIT, p); 1125 if (r == VK_SUCCESS) write_stats(name, stage, VK_SHADER_STAGE_COMPUTE_BIT, p);
@@ -1015,6 +1289,7 @@ int main(int argc, char** argv) {
1015 const auto t0 = std::chrono::steady_clock::now(); 1289 const auto t0 = std::chrono::steady_clock::now();
1016 { std::lock_guard<std::mutex> g(mu); inflight[std::this_thread::get_id()] = {name, t0}; } 1290 { std::lock_guard<std::mutex> g(mu); inflight[std::this_thread::get_id()] = {name, t0}; }
1017 VkPipeline p = VK_NULL_HANDLE; 1291 VkPipeline p = VK_NULL_HANDLE;
1292 maybe_simulate_crash(name);
1018 VkResult r = vkCreateGraphicsPipelines(dev, cache, 1, &gpci, nullptr, &p); 1293 VkResult r = vkCreateGraphicsPipelines(dev, cache, 1, &gpci, nullptr, &p);
1019 const double sec = std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count(); 1294 const double sec = std::chrono::duration<double>(std::chrono::steady_clock::now() - t0).count();
1020 if (r == VK_SUCCESS) write_stats(name, stage, stage_bit(stage), p); 1295 if (r == VK_SUCCESS) write_stats(name, stage, stage_bit(stage), p);
@@ -1032,6 +1307,8 @@ int main(int argc, char** argv) {
1032 } 1307 }
1033 } 1308 }
1034 }; 1309 };
1310 if (iso_child) std::printf("ISO-READY\n");
1311 std::fflush(stdout);
1035 std::vector<std::thread> pool; 1312 std::vector<std::thread> pool;
1036 for (uint32_t t = 0; t < jobs; t++) pool.emplace_back(worker); 1313 for (uint32_t t = 0; t < jobs; t++) pool.emplace_back(worker);
1037 // Watchdog: names every compile running past 60 s (about once a minute) and saves the cache every 10 minutes. 1314 // Watchdog: names every compile running past 60 s (about once a minute) and saves the cache every 10 minutes.
@@ -1070,6 +1347,20 @@ int main(int argc, char** argv) {
1070 for (auto& [st, _] : modules_bad) all_stages.insert(st); 1347 for (auto& [st, _] : modules_bad) all_stages.insert(st);
1071 for (auto& [st, _] : stats) all_stages.insert(st); 1348 for (auto& [st, _] : stats) all_stages.insert(st);
1072 1349
1350 if (iso_child) { // --isolate child: machine-readable counts; the parent prints the summary
1351 for (const auto& st : all_stages) {
1352 const StageStats* s = stats.count(st) ? &stats[st] : nullptr;
1353 uint32_t big = big_skipped.count(st) ? big_skipped[st] : 0;
1354 std::printf("ISO-RESULT %s %u %u %u %u %u %u %u %u %u\n", st.c_str(), modules_ok[st], modules_bad[st],
1355 s ? s->pipes_ok : 0u, s ? s->pipes_bad : 0u, s ? s->pipes_skipped : 0u, big,
1356 s ? s->feedback[0] : 0u, s ? s->feedback[1] : 0u, s ? s->feedback[2] : 0u);
1357 }
1358 const bool saved = save_cache(true);
1359 std::printf("ISO-DONE cache_ok=%d\n", saved ? 1 : 0);
1360 std::fflush(stdout);
1361 return saved ? 0 : 1;
1362 }
1363
1073 bool check_failed = false; 1364 bool check_failed = false;
1074 for (const auto& st : all_stages) { 1365 for (const auto& st : all_stages) {
1075 std::printf("%s: %u modules ok, %u failed\n", st.c_str(), modules_ok[st], modules_bad[st]); 1366 std::printf("%s: %u modules ok, %u failed\n", st.c_str(), modules_ok[st], modules_bad[st]);
diff --git a/runtime/test/vk_presenter_sync_test.cpp b/runtime/test/vk_presenter_sync_test.cpp
index 3748aeec7..8f5c7d7d0 100644
--- a/runtime/test/vk_presenter_sync_test.cpp
+++ b/runtime/test/vk_presenter_sync_test.cpp
@@ -19,10 +19,14 @@
19#include "../src/vulkan_present.h" 19#include "../src/vulkan_present.h"
20 20
21#include <atomic> 21#include <atomic>
22#include <chrono>
22#include <cmath> 23#include <cmath>
24#include <condition_variable>
23#include <cstdint> 25#include <cstdint>
24#include <cstdio> 26#include <cstdio>
25#include <cstdlib> 27#include <cstdlib>
28#include <functional>
29#include <mutex>
26#include <string_view> 30#include <string_view>
27#include <thread> 31#include <thread>
28#include <vector> 32#include <vector>
@@ -49,10 +53,12 @@ namespace driver {
49PFN_vkGetInstanceProcAddr real_get_instance = nullptr; 53PFN_vkGetInstanceProcAddr real_get_instance = nullptr;
50PFN_vkGetDeviceProcAddr real_get_device = nullptr; 54PFN_vkGetDeviceProcAddr real_get_device = nullptr;
51PFN_vkQueueSubmit real_submit = nullptr; 55PFN_vkQueueSubmit real_submit = nullptr;
56PFN_vkQueuePresentKHR real_present = nullptr;
52PFN_vkCmdPipelineBarrier real_barrier = nullptr; 57PFN_vkCmdPipelineBarrier real_barrier = nullptr;
53PFN_vkCmdCopyImageToBuffer real_copy_i2b = nullptr; 58PFN_vkCmdCopyImageToBuffer real_copy_i2b = nullptr;
54 59
55std::atomic<VkResult> fail_next_submit{VK_SUCCESS}; 60std::atomic<VkResult> fail_next_submit{VK_SUCCESS};
61std::function<void()> on_next_present;
56std::atomic<bool> observe_capture{false}; 62std::atomic<bool> observe_capture{false};
57std::atomic<bool> saw_capture_waw{false}; 63std::atomic<bool> saw_capture_waw{false};
58std::atomic<std::uint32_t> capture_copies{0}; 64std::atomic<std::uint32_t> capture_copies{0};
@@ -65,6 +71,15 @@ VKAPI_ATTR VkResult VKAPI_CALL queue_submit(VkQueue queue, std::uint32_t count,
65 return real_submit(queue, count, submits, fence); 71 return real_submit(queue, count, submits, fence);
66} 72}
67 73
74VKAPI_ATTR VkResult VKAPI_CALL queue_present(VkQueue queue, const VkPresentInfoKHR* info) {
75 if (on_next_present) {
76 auto cb = std::move(on_next_present);
77 on_next_present = {};
78 cb();
79 }
80 return real_present(queue, info);
81}
82
68VKAPI_ATTR void VKAPI_CALL cmd_pipeline_barrier(VkCommandBuffer cb, VkPipelineStageFlags src_stage, 83VKAPI_ATTR void VKAPI_CALL cmd_pipeline_barrier(VkCommandBuffer cb, VkPipelineStageFlags src_stage,
69 VkPipelineStageFlags dst_stage, VkDependencyFlags flags, 84 VkPipelineStageFlags dst_stage, VkDependencyFlags flags,
70 std::uint32_t mem_count, const VkMemoryBarrier* mem, 85 std::uint32_t mem_count, const VkMemoryBarrier* mem,
@@ -100,6 +115,7 @@ VKAPI_ATTR void VKAPI_CALL cmd_copy_image_to_buffer(VkCommandBuffer cb, VkImage
100VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_device(VkDevice device, const char* name) { 115VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_device(VkDevice device, const char* name) {
101 const std::string_view n = name; 116 const std::string_view n = name;
102 if (n == "vkQueueSubmit") return reinterpret_cast<PFN_vkVoidFunction>(queue_submit); 117 if (n == "vkQueueSubmit") return reinterpret_cast<PFN_vkVoidFunction>(queue_submit);
118 if (n == "vkQueuePresentKHR") return reinterpret_cast<PFN_vkVoidFunction>(queue_present);
103 if (n == "vkCmdPipelineBarrier") return reinterpret_cast<PFN_vkVoidFunction>(cmd_pipeline_barrier); 119 if (n == "vkCmdPipelineBarrier") return reinterpret_cast<PFN_vkVoidFunction>(cmd_pipeline_barrier);
104 if (n == "vkCmdCopyImageToBuffer") return reinterpret_cast<PFN_vkVoidFunction>(cmd_copy_image_to_buffer); 120 if (n == "vkCmdCopyImageToBuffer") return reinterpret_cast<PFN_vkVoidFunction>(cmd_copy_image_to_buffer);
105 return real_get_device(device, name); 121 return real_get_device(device, name);
@@ -114,6 +130,7 @@ void install(PFN_vkGetInstanceProcAddr instance_proc, VkInstance instance, VkDev
114 real_get_instance = instance_proc; 130 real_get_instance = instance_proc;
115 real_get_device = reinterpret_cast<PFN_vkGetDeviceProcAddr>(instance_proc(instance, "vkGetDeviceProcAddr")); 131 real_get_device = reinterpret_cast<PFN_vkGetDeviceProcAddr>(instance_proc(instance, "vkGetDeviceProcAddr"));
116 real_submit = reinterpret_cast<PFN_vkQueueSubmit>(real_get_device(device, "vkQueueSubmit")); 132 real_submit = reinterpret_cast<PFN_vkQueueSubmit>(real_get_device(device, "vkQueueSubmit"));
133 real_present = reinterpret_cast<PFN_vkQueuePresentKHR>(real_get_device(device, "vkQueuePresentKHR"));
117 real_barrier = reinterpret_cast<PFN_vkCmdPipelineBarrier>(real_get_device(device, "vkCmdPipelineBarrier")); 134 real_barrier = reinterpret_cast<PFN_vkCmdPipelineBarrier>(real_get_device(device, "vkCmdPipelineBarrier"));
118 real_copy_i2b = reinterpret_cast<PFN_vkCmdCopyImageToBuffer>(real_get_device(device, "vkCmdCopyImageToBuffer")); 135 real_copy_i2b = reinterpret_cast<PFN_vkCmdCopyImageToBuffer>(real_get_device(device, "vkCmdCopyImageToBuffer"));
119} 136}
@@ -193,15 +210,52 @@ int main() {
193 EXPECT(presenter.ok()); 210 EXPECT(presenter.ok());
194 EXPECT(presenter.enable_capture()); 211 EXPECT(presenter.enable_capture());
195 212
196 // 1. Failed vkQueueSubmit must NOT commit the UNDEFINED -> GENERAL transition in LayoutTracker. 213 // 1. Failed vkQueueSubmit must NOT commit the UNDEFINED -> GENERAL transition in LayoutTracker (O(1) rollback
214 // even with many live tracked textures), and tracker_mutex_ must be released before vkQueuePresentKHR.
215 for (ResourceId extra = 1000; extra < 1512; ++extra)
216 context.add_resource(extra, side_rb, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
197 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_UNDEFINED); 217 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_UNDEFINED);
198 driver::fail_next_submit.store(VK_ERROR_OUT_OF_HOST_MEMORY); 218 driver::fail_next_submit.store(VK_ERROR_OUT_OF_HOST_MEMORY);
199 EXPECT(presenter.present(1, true) == VK_ERROR_OUT_OF_HOST_MEMORY); 219 EXPECT(presenter.present(1, true) == VK_ERROR_OUT_OF_HOST_MEMORY);
200 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_UNDEFINED); 220 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_UNDEFINED);
201 221 EXPECT(context.layout(1000, 0) == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
202 // Next present succeeds, runs the deferred zero-fill, and commits GENERAL. 222
203 EXPECT(presenter.present(1, true) == VK_SUCCESS); 223 // Next present succeeds, runs the deferred zero-fill, commits GENERAL, and unlocks tracker_mutex_ before
224 // vkQueuePresentKHR so other threads' emit() / layout() calls are not blocked by presentation.
225 std::mutex sync_mutex;
226 std::condition_variable sync_cv;
227 bool reader_started = false;
228 bool read_done = false;
229 VkImageLayout seen_during_present = VK_IMAGE_LAYOUT_UNDEFINED;
230 bool unblocked_during_present = false;
231 std::thread reader;
232 driver::on_next_present = [&] {
233 reader = std::thread([&] {
234 {
235 std::lock_guard lk(sync_mutex);
236 reader_started = true;
237 }
238 sync_cv.notify_all();
239 const VkImageLayout layout = context.layout(1, 0);
240 {
241 std::lock_guard lk(sync_mutex);
242 seen_during_present = layout;
243 read_done = true;
244 }
245 sync_cv.notify_all();
246 });
247 std::unique_lock lk(sync_mutex);
248 const bool started = sync_cv.wait_for(lk, std::chrono::seconds(2), [&] { return reader_started; });
249 unblocked_during_present =
250 started && sync_cv.wait_for(lk, std::chrono::milliseconds(500), [&] { return read_done; });
251 };
252 const VkResult present_rc = presenter.present(1, true);
253 if (reader.joinable()) reader.join();
254 EXPECT(present_rc == VK_SUCCESS);
255 EXPECT(unblocked_during_present);
256 EXPECT(seen_during_present == VK_IMAGE_LAYOUT_GENERAL);
204 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_GENERAL); 257 EXPECT(context.layout(1, 0) == VK_IMAGE_LAYOUT_GENERAL);
258 for (ResourceId extra = 1000; extra < 1512; ++extra) context.remove_resource(extra);
205 std::vector<std::uint8_t> pixels; 259 std::vector<std::uint8_t> pixels;
206 VkExtent2D ext{}; 260 VkExtent2D ext{};
207 VkFormat fmt = VK_FORMAT_UNDEFINED; 261 VkFormat fmt = VK_FORMAT_UNDEFINED;
diff --git a/runtime/test/vk_test_device.h b/runtime/test/vk_test_device.h
index 635a3107b..1e54a9487 100644
--- a/runtime/test/vk_test_device.h
+++ b/runtime/test/vk_test_device.h
@@ -1,10 +1,12 @@
1// Shared setup for the GPU tests of the D3D12 layer: a Vulkan 1.3 device with dynamicRendering, synchronization2, 1// Shared setup for the GPU tests of the D3D12 layer: a Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and
2// timelineSemaphore and separateDepthStencilLayouts, images, buffers and one-shot submissions. 2// VK_KHR_synchronization2) with dynamicRendering, synchronization2, timelineSemaphore and
3// separateDepthStencilLayouts, images, buffers and one-shot submissions.
3// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation; Device::validation_errors() counts errors. 4// Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation; Device::validation_errors() counts errors.
4#pragma once 5#pragma once
5 6
6#include "vulkan_loader.h" 7#include "vulkan_loader.h"
7#include "../src/vulkan_device_filter.h" 8#include "../src/vulkan_device_filter.h"
9#include "../src/vulkan13_features.h"
8#include "vk_device_pick.h" 10#include "vk_device_pick.h"
9#include "../src/subgroup_size.h" 11#include "../src/subgroup_size.h"
10 12
@@ -82,6 +84,12 @@ public:
82 VkDevice device = VK_NULL_HANDLE; 84 VkDevice device = VK_NULL_HANDLE;
83 VkQueue queue = VK_NULL_HANDLE; 85 VkQueue queue = VK_NULL_HANDLE;
84 std::uint32_t family = 0; 86 std::uint32_t family = 0;
87 // Set before initialize(): how many queues of `family` to create (fewer if the family has fewer). `queues` holds the
88 // handles; queues[0] == queue. A test that wants distinct VkQueues for its D3D12 queues passes them on as
89 // VulkanDeviceInfo::command_queues when there is more than one.
90 std::uint32_t queue_count_wanted = 1;
91 std::uint32_t family_queue_count = 1; // the family's queueCount, known after the device is chosen
92 std::vector<VkQueue> queues;
85 bool validation = false; 93 bool validation = false;
86 bool bc = false; // textureCompressionBC enabled 94 bool bc = false; // textureCompressionBC enabled
87 VkPhysicalDeviceFeatures enabled{}; // the core features enabled on `device` 95 VkPhysicalDeviceFeatures enabled{}; // the core features enabled on `device`
@@ -134,9 +142,10 @@ public:
134 reinterpret_cast<PFN_vkDestroyInstance>(instance_proc(instance, "vkDestroyInstance"))(instance, nullptr); 142 reinterpret_cast<PFN_vkDestroyInstance>(instance_proc(instance, "vkDestroyInstance"))(instance, nullptr);
135 } 143 }
136 144
145 // A Vulkan 1.3 function falls back to its KHR name on a 1.2 device.
137 template<typename F> 146 template<typename F>
138 F fn(const char* name) const { 147 F fn(const char* name) const {
139 return reinterpret_cast<F>(device_proc(device, name)); 148 return reinterpret_cast<F>(leonida::device_proc_or_khr(device_proc, device, name));
140 } 149 }
141 150
142 template<typename F> 151 template<typename F>
@@ -263,10 +272,16 @@ public:
263 if (result != VK_SUCCESS) return failure("vkEnumeratePhysicalDevices", result); 272 if (result != VK_SUCCESS) return failure("vkEnumeratePhysicalDevices", result);
264 VkPhysicalDeviceProperties chosen{}; 273 VkPhysicalDeviceProperties chosen{};
265 int best_rank = -1; 274 int best_rank = -1;
275 const auto features2_of = instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2");
276 const auto device_extensions_of =
277 instance_fn<PFN_vkEnumerateDeviceExtensionProperties>("vkEnumerateDeviceExtensionProperties");
278 leonida::Vulkan13Features candidate13;
266 for (auto candidate : devices) { 279 for (auto candidate : devices) {
267 VkPhysicalDeviceProperties props{}; 280 VkPhysicalDeviceProperties props{};
268 properties_of(candidate, &props); 281 properties_of(candidate, &props);
269 if (props.apiVersion < VK_API_VERSION_1_3 || !leonida::vulkan_device_wanted(props.deviceName)) continue; 282 if (!leonida::vulkan_device_wanted(props.deviceName)) continue;
283 candidate13.query(candidate, props.apiVersion, features2_of, device_extensions_of);
284 if (!candidate13.usable()) continue;
270 std::uint32_t family_count = 0; 285 std::uint32_t family_count = 0;
271 families_of(candidate, &family_count, nullptr); 286 families_of(candidate, &family_count, nullptr);
272 std::vector<VkQueueFamilyProperties> families(family_count); 287 std::vector<VkQueueFamilyProperties> families(family_count);
@@ -277,8 +292,10 @@ public:
277 rank > best_rank) { 292 rank > best_rank) {
278 physical = candidate; 293 physical = candidate;
279 family = i; 294 family = i;
295 family_queue_count = families[i].queueCount;
280 chosen = props; 296 chosen = props;
281 best_rank = rank; 297 best_rank = rank;
298 v13_.choose(candidate13);
282 } 299 }
283 break; 300 break;
284 } 301 }
@@ -286,22 +303,25 @@ public:
286 if (!physical) { 303 if (!physical) {
287 if (const std::string filter = leonida::vulkan_device_filter(); !filter.empty()) { 304 if (const std::string filter = leonida::vulkan_device_filter(); !filter.empty()) {
288 // A filter that matches nothing fails the test instead of skipping it. 305 // A filter that matches nothing fails the test instead of skipping it.
289 std::fprintf(stderr, "LEONIDA_VK_DEVICE=%s: no Vulkan 1.3 device with a graphics queue matches\n", 306 std::fprintf(stderr,
307 "LEONIDA_VK_DEVICE=%s: no Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and "
308 "VK_KHR_synchronization2) with a graphics queue matches\n",
290 filter.c_str()); 309 filter.c_str());
291 return DeviceStatus::failed; 310 return DeviceStatus::failed;
292 } 311 }
293 std::fprintf(stderr, "no Vulkan 1.3 device with a graphics queue\n"); 312 std::fprintf(stderr, "no Vulkan 1.3 device (or 1.2 with VK_KHR_dynamic_rendering and "
313 "VK_KHR_synchronization2) with a graphics queue\n");
294 return DeviceStatus::unavailable; 314 return DeviceStatus::unavailable;
295 } 315 }
296 std::printf("device: %s%s\n", chosen.deviceName, validation ? " (validation on)" : ""); 316 std::printf("device: %s%s%s\n", chosen.deviceName, v13_.core ? "" : " (Vulkan 1.2 + KHR extensions)",
317 validation ? " (validation on)" : "");
297 318
298 VkPhysicalDeviceVulkan13Features features13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES}; 319 VkPhysicalDeviceVulkan11Features features11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES};
299 VkPhysicalDeviceVulkan11Features features11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &features13};
300 VkPhysicalDeviceVulkan12Features features12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &features11}; 320 VkPhysicalDeviceVulkan12Features features12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &features11};
301 VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &features12}; 321 VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &features12};
302 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &features); 322 features2_of(physical, &features);
303 if (!features13.dynamicRendering || !features13.synchronization2 || !features12.timelineSemaphore || 323 if (!features12.timelineSemaphore || !features12.separateDepthStencilLayouts ||
304 !features12.separateDepthStencilLayouts || !features12.bufferDeviceAddress) { 324 !features12.bufferDeviceAddress) {
305 std::fprintf(stderr, "the device lacks dynamicRendering, synchronization2, timelineSemaphore or " 325 std::fprintf(stderr, "the device lacks dynamicRendering, synchronization2, timelineSemaphore or "
306 "separateDepthStencilLayouts\n"); 326 "separateDepthStencilLayouts\n");
307 return DeviceStatus::unavailable; 327 return DeviceStatus::unavailable;
@@ -327,14 +347,8 @@ public:
327 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT}; 347 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT};
328 enable_conditional.conditionalRendering = VK_TRUE; 348 enable_conditional.conditionalRendering = VK_TRUE;
329 349
330 VkPhysicalDeviceVulkan13Features enable13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
331 conditional_rendering ? &enable_conditional : nullptr};
332 enable13.dynamicRendering = VK_TRUE;
333 enable13.synchronization2 = VK_TRUE;
334 enable13.subgroupSizeControl = features13.subgroupSizeControl;
335 enable13.computeFullSubgroups = features13.computeFullSubgroups;
336 leonida::query_subgroup_size_caps(instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"), 350 leonida::query_subgroup_size_caps(instance_fn<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2"),
337 physical, features13.subgroupSizeControl, features13.computeFullSubgroups, 351 physical, v13_.subgroup_size_control, v13_.compute_full_subgroups,
338 subgroup); 352 subgroup);
339 std::printf("subgroup sizes: %u..%u (default %u), requirable in stages 0x%x, subgroupSizeControl %s, " 353 std::printf("subgroup sizes: %u..%u (default %u), requirable in stages 0x%x, subgroupSizeControl %s, "
340 "computeFullSubgroups %s\n", 354 "computeFullSubgroups %s\n",
@@ -342,7 +356,8 @@ public:
342 subgroup.subgroup_size_control ? "on" : "off", subgroup.compute_full_subgroups ? "on" : "off"); 356 subgroup.subgroup_size_control ? "on" : "off", subgroup.compute_full_subgroups ? "on" : "off");
343 // shaderDrawParameters, where available: translated vertex shaders will read BaseVertex and BaseInstance once PR 436 357 // shaderDrawParameters, where available: translated vertex shaders will read BaseVertex and BaseInstance once PR 436
344 // (zero-based VS ids) is in; harmless before. 358 // (zero-based VS ids) is in; harmless before.
345 VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &enable13}; 359 VkPhysicalDeviceVulkan11Features enable11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
360 v13_.enable(conditional_rendering ? &enable_conditional : nullptr)};
346 enable11.shaderDrawParameters = features11.shaderDrawParameters; 361 enable11.shaderDrawParameters = features11.shaderDrawParameters;
347 VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; 362 VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11};
348 enable12.timelineSemaphore = VK_TRUE; 363 enable12.timelineSemaphore = VK_TRUE;
@@ -369,11 +384,11 @@ public:
369 enable12.samplerFilterMinmax = sampler_filter_minmax; 384 enable12.samplerFilterMinmax = sampler_filter_minmax;
370 enable12.bufferDeviceAddress = VK_TRUE; 385 enable12.bufferDeviceAddress = VK_TRUE;
371 386
372 const float priority = 1.0f; 387 const std::vector<float> priority(std::max(1u, std::min(queue_count_wanted, family_queue_count)), 1.0f);
373 VkDeviceQueueCreateInfo queue_info{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO}; 388 VkDeviceQueueCreateInfo queue_info{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO};
374 queue_info.queueFamilyIndex = family; 389 queue_info.queueFamilyIndex = family;
375 queue_info.queueCount = 1; 390 queue_info.queueCount = std::max(1u, std::min(queue_count_wanted, family_queue_count));
376 queue_info.pQueuePriorities = &priority; 391 queue_info.pQueuePriorities = priority.data();
377 VkPhysicalDeviceFeatures enable{}; 392 VkPhysicalDeviceFeatures enable{};
378 enable.textureCompressionBC = features.features.textureCompressionBC; // BC uploads, where available 393 enable.textureCompressionBC = features.features.textureCompressionBC; // BC uploads, where available
379 enable.shaderInt64 = features.features.shaderInt64; // translated shaders declare Int64 (index features) 394 enable.shaderInt64 = features.features.shaderInt64; // translated shaders declare Int64 (index features)
@@ -399,8 +414,8 @@ public:
399 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); 414 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query);
400 image_view_min_lod = min_lod.minLod == VK_TRUE; 415 image_view_min_lod = min_lod.minLod == VK_TRUE;
401 if (image_view_min_lod) { 416 if (image_view_min_lod) {
402 min_lod.pNext = enable13.pNext; 417 min_lod.pNext = *v13_.next();
403 enable13.pNext = &min_lod; 418 *v13_.next() = &min_lod;
404 } 419 }
405 } 420 }
406 VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{ 421 VkPhysicalDeviceHostImageCopyFeaturesEXT host_copy{
@@ -413,8 +428,8 @@ public:
413 } 428 }
414 const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME; 429 const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME;
415 if (host_image_copy) { 430 if (host_image_copy) {
416 host_copy.pNext = enable13.pNext; // after the conditional rendering features, if any 431 host_copy.pNext = *v13_.next(); // after the conditional rendering features, if any
417 enable13.pNext = &host_copy; 432 *v13_.next() = &host_copy;
418 } 433 }
419 434
420#ifdef VK_KHR_SHADER_FMA_EXTENSION_NAME 435#ifdef VK_KHR_SHADER_FMA_EXTENSION_NAME
@@ -427,8 +442,8 @@ public:
427 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); 442 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query);
428 shader_fma = fma_features.shaderFmaFloat32 == VK_TRUE; 443 shader_fma = fma_features.shaderFmaFloat32 == VK_TRUE;
429 if (shader_fma) { 444 if (shader_fma) {
430 fma_features.pNext = enable13.pNext; 445 fma_features.pNext = *v13_.next();
431 enable13.pNext = &fma_features; 446 *v13_.next() = &fma_features;
432 } 447 }
433 } 448 }
434#endif 449#endif
@@ -442,6 +457,7 @@ public:
442 device_info.pEnabledFeatures = &enable; 457 device_info.pEnabledFeatures = &enable;
443 enabled = enable; 458 enabled = enable;
444 std::vector<const char*> device_extensions; 459 std::vector<const char*> device_extensions;
460 v13_.add_extensions(device_extensions);
445 if (image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME); 461 if (image_view_min_lod) device_extensions.push_back(VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME);
446 if (conditional_rendering) device_extensions.push_back(conditional_extension); 462 if (conditional_rendering) device_extensions.push_back(conditional_extension);
447 if (host_image_copy) device_extensions.push_back(host_image_copy_name); 463 if (host_image_copy) device_extensions.push_back(host_image_copy_name);
@@ -462,8 +478,8 @@ public:
462 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1}; 478 VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &swapchain_m1};
463 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query); 479 instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query);
464 if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) { 480 if (swapchain_m1.swapchainMaintenance1 == VK_TRUE) {
465 swapchain_m1.pNext = enable13.pNext; 481 swapchain_m1.pNext = *v13_.next();
466 enable13.pNext = &swapchain_m1; 482 *v13_.next() = &swapchain_m1;
467 device_extensions.push_back(name); 483 device_extensions.push_back(name);
468 swapchain_maintenance1 = true; 484 swapchain_maintenance1 = true;
469 } 485 }
@@ -478,7 +494,10 @@ public:
478 result = instance_fn<PFN_vkCreateDevice>("vkCreateDevice")(physical, &device_info, nullptr, &device); 494 result = instance_fn<PFN_vkCreateDevice>("vkCreateDevice")(physical, &device_info, nullptr, &device);
479 if (result != VK_SUCCESS) return failure("vkCreateDevice", result); 495 if (result != VK_SUCCESS) return failure("vkCreateDevice", result);
480 device_proc = instance_fn<PFN_vkGetDeviceProcAddr>("vkGetDeviceProcAddr"); 496 device_proc = instance_fn<PFN_vkGetDeviceProcAddr>("vkGetDeviceProcAddr");
481 fn<PFN_vkGetDeviceQueue>("vkGetDeviceQueue")(device, family, 0, &queue); 497 queues.resize(queue_info.queueCount);
498 for (std::uint32_t i = 0; i < queue_info.queueCount; ++i)
499 fn<PFN_vkGetDeviceQueue>("vkGetDeviceQueue")(device, family, i, &queues[i]);
500 queue = queues[0];
482 instance_fn<PFN_vkGetPhysicalDeviceMemoryProperties>("vkGetPhysicalDeviceMemoryProperties")(physical, 501 instance_fn<PFN_vkGetPhysicalDeviceMemoryProperties>("vkGetPhysicalDeviceMemoryProperties")(physical,
483 &memory_); 502 &memory_);
484 VkCommandPoolCreateInfo pool{VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO}; 503 VkCommandPoolCreateInfo pool{VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO};
@@ -628,6 +647,7 @@ private:
628 VkDebugUtilsMessengerEXT messenger_ = VK_NULL_HANDLE; 647 VkDebugUtilsMessengerEXT messenger_ = VK_NULL_HANDLE;
629 VkCommandPool pool_ = VK_NULL_HANDLE; 648 VkCommandPool pool_ = VK_NULL_HANDLE;
630 VkPhysicalDeviceMemoryProperties memory_{}; 649 VkPhysicalDeviceMemoryProperties memory_{};
650 leonida::Vulkan13Features v13_; // the chosen device's dynamicRendering/synchronization2 path
631 std::vector<std::pair<VkImage, VkDeviceMemory>> images_; 651 std::vector<std::pair<VkImage, VkDeviceMemory>> images_;
632 std::vector<std::pair<VkBuffer, VkDeviceMemory>> buffers_; 652 std::vector<std::pair<VkBuffer, VkDeviceMemory>> buffers_;
633}; 653};
diff --git a/runtime/test/vk_xdxr_build_test.cpp b/runtime/test/vk_xdxr_build_test.cpp
index 136f49f68..1f4686869 100644
--- a/runtime/test/vk_xdxr_build_test.cpp
+++ b/runtime/test/vk_xdxr_build_test.cpp
@@ -6,10 +6,12 @@
6// 6//
7// Cases: one triangle; five (two levels); 1000 random triangles; an indexed R16 grid with a 16-byte vertex stride; 7// Cases: one triangle; five (two levels); 1000 random triangles; an indexed R16 grid with a 16-byte vertex stride;
8// R32 indices with R32G32 vertices; a geometry transform; two geometries with an inactive (NaN) triangle; no 8// R32 indices with R32G32 vertices; a geometry transform; two geometries with an inactive (NaN) triangle; no
9// triangles; 5000 triangles (three radix-sort tiles); and a TLAS of four instances (rotated and scaled, one with mask 0, one with no BLAS). 9// triangles; 5000 triangles (many radix-sort tiles); updates (refits) in place and into another buffer; clones and a
10// compaction (CopyRaytracingAccelerationStructure) with the postbuild size; a TLAS of four instances (rotated and scaled, one with mask 0, one with no BLAS).
10// Exit 77 when there is no Vulkan device with bufferDeviceAddress. 11// Exit 77 when there is no Vulkan device with bufferDeviceAddress.
11// `vk_xdxr_build_test <out dir> <triangles>` instead times BLAS builds of that many random triangles (wall clock of 12// `vk_xdxr_build_test <out dir> <triangles>` instead times BLAS builds of that many random triangles (wall clock of
12// one submission each, after one warm-up; result and scratch in device-local memory) and writes nothing. 13// one submission each, after one warm-up; result and scratch in device-local memory), then in-place updates
14// (refits) of the same structure, and writes nothing.
13#include "vk_test_device.h" 15#include "vk_test_device.h"
14#include "../src/xdxr_build.h" 16#include "../src/xdxr_build.h"
15 17
@@ -117,9 +119,12 @@ struct Built {
117 std::vector<Tri> tris; 119 std::vector<Tri> tris;
118}; 120};
119 121
122// With `moved` (the same geometries with new vertex positions) the BLAS is then updated: refitted in place, or with
123// `into_other` into a second buffer, in which case the untouched source is written too, as <name>_source.
120int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir, const std::string& name, 124int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir, const std::string& name,
121 const std::vector<Geometry>& geometries, Built& built, unsigned rays = 0) { 125 const std::vector<Geometry>& geometries, Built& built, unsigned rays = 0,
122 std::vector<Buffer> keep; 126 const std::vector<Geometry>* moved = nullptr, bool into_other = false) {
127 std::vector<Buffer> keep, vertex_buffers;
123 std::vector<XdxrTriangles> descs; 128 std::vector<XdxrTriangles> descs;
124 std::uint32_t total = 0; 129 std::uint32_t total = 0;
125 for (std::size_t g = 0; g < geometries.size(); ++g) { 130 for (std::size_t g = 0; g < geometries.size(); ++g) {
@@ -134,6 +139,7 @@ int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir
134 d.triangle_count = geo.triangle_count; 139 d.triangle_count = geo.triangle_count;
135 d.flags = 1; 140 d.flags = 1;
136 keep.push_back(v); 141 keep.push_back(v);
142 vertex_buffers.push_back(v);
137 if (!geo.indices.empty()) { 143 if (!geo.indices.empty()) {
138 Buffer ib = make(gpu, geo.indices.size() * 4); 144 Buffer ib = make(gpu, geo.indices.size() * 4);
139 EXPECT(ib.buffer); 145 EXPECT(ib.buffer);
@@ -170,13 +176,41 @@ int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir
170 return recorded; 176 return recorded;
171 })); 177 }));
172 built.address = base; 178 built.address = base;
173 const auto* bytes = static_cast<const char*>(dst.map) + (base - dst.address); 179 auto dump = [&](const std::string& case_name, const Buffer& buffer, std::uint64_t at, const std::vector<Tri>& tris) {
174 EXPECT(write_file(dir + "/" + name + ".bin", bytes, layout.size)); 180 const auto* bytes = static_cast<const char*>(buffer.map) + (at - buffer.address);
175 const std::string json = "{\"kind\": \"blas\", \"address\": " + std::to_string(base) + 181 const std::string json = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) +
176 (rays ? ", \"rays\": " + std::to_string(rays) : std::string()) + 182 (rays ? ", \"rays\": " + std::to_string(rays) : std::string()) +
177 ", \"triangles\": " + tris_json(built.tris) + "}\n"; 183 ", \"triangles\": " + tris_json(tris) + "}\n";
178 EXPECT(write_file(dir + "/" + name + ".json", json.data(), json.size())); 184 return write_file(dir + "/" + case_name + ".bin", bytes, layout.size) &&
179 std::printf("%s: %u triangles, %u bytes, %u nodes\n", name.c_str(), total, layout.size, layout.nodes); 185 write_file(dir + "/" + case_name + ".json", json.data(), json.size());
186 };
187 if (!moved) {
188 EXPECT(dump(name, dst, base, built.tris));
189 std::printf("%s: %u triangles, %u bytes, %u nodes\n", name.c_str(), total, layout.size, layout.nodes);
190 return 0;
191 }
192 // the update: new positions in the same vertex buffers, then a refit of the structure just built
193 EXPECT(moved->size() == geometries.size());
194 std::vector<Tri> moved_tris;
195 for (std::size_t g = 0; g < moved->size(); ++g) {
196 EXPECT((*moved)[g].vertex_data.size() == geometries[g].vertex_data.size());
197 std::memcpy(vertex_buffers[g].map, (*moved)[g].vertex_data.data(), (*moved)[g].vertex_data.size() * 4);
198 expand((*moved)[g], std::uint32_t(g), moved_tris);
199 }
200 Buffer other = into_other ? make(gpu, layout.size + 256) : Buffer{};
201 const std::uint64_t target = into_other ? (other.address + 255) & ~std::uint64_t(255) : base;
202 EXPECT(!into_other || other.buffer);
203 EXPECT(gpu.run([&](VkCommandBuffer cb) {
204 recorded = builder.record_blas(cb, layout, descs, target, scratch.address, base);
205 barrier_to_host(gpu, cb);
206 return recorded;
207 }));
208 if (into_other) EXPECT(dump(name + "_source", dst, base, built.tris)); // a refit must not touch its source
209 EXPECT(dump(name, into_other ? other : dst, target, moved_tris));
210 built.tris = moved_tris;
211 built.address = target;
212 std::printf("%s: %u triangles refitted %s, %u bytes\n", name.c_str(), total,
213 into_other ? "into another buffer" : "in place", layout.size);
180 return 0; 214 return 0;
181} 215}
182 216
@@ -234,8 +268,17 @@ int main(int argc, char** argv) {
234 const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count(); 268 const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();
235 if (rep) best = std::min(best, ms); 269 if (rep) best = std::min(best, ms);
236 } 270 }
237 std::printf("%u triangles: %.2f ms (best of 3), result %u bytes, scratch %llu bytes, sort size %u\n", n, best, 271 double refit = 1e30; // an update of the structure just built, in place
238 layout.size, static_cast<unsigned long long>(layout.scratch), layout.sort_size); 272 for (int rep = 0; rep < 4; ++rep) {
273 const auto t0 = std::chrono::steady_clock::now();
274 EXPECT(gpu.run([&](VkCommandBuffer cb) {
275 return builder.record_blas(cb, layout, {d}, dst.address, scratch.address, dst.address);
276 }));
277 const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();
278 if (rep) refit = std::min(refit, ms);
279 }
280 std::printf("%u triangles: %.2f ms (best of 3), refit %.2f ms, result %u bytes, scratch %llu bytes, sort size %u\n",
281 n, best, refit, layout.size, static_cast<unsigned long long>(layout.scratch), layout.sort_size);
239 return 0; 282 return 0;
240 } 283 }
241 284
@@ -287,10 +330,33 @@ int main(int argc, char** argv) {
287 b.vertex_data[3 * 3 * 7] = std::nanf(""); // triangle 7 of geometry 1: inactive 330 b.vertex_data[3 * 3 * 7] = std::nanf(""); // triangle 7 of geometry 1: inactive
288 if (build_blas(gpu, builder, dir, "blas_two_geometries", {a, b}, multi)) return 1; 331 if (build_blas(gpu, builder, dir, "blas_two_geometries", {a, b}, multi)) return 1;
289 if (build_blas(gpu, builder, dir, "blas_empty", {}, empty)) return 1; 332 if (build_blas(gpu, builder, dir, "blas_empty", {}, empty)) return 1;
290 // three radix-sort tiles of 2048, the last one partial (fewer rays: the reference's brute force is slow) 333 // many radix-sort tiles (RADIX_TILE elements each), the last one partial (fewer rays: the brute force is slow)
291 Built tiles; 334 Built tiles;
292 if (build_blas(gpu, builder, dir, "blas_three_sort_tiles", {soup(5000)}, tiles, 200)) return 1; 335 if (build_blas(gpu, builder, dir, "blas_three_sort_tiles", {soup(5000)}, tiles, 200)) return 1;
293 336
337 // Updates. Every triangle moves (its own offset, and a stretch), so each box changes; the tree is kept.
338 auto move = [&](Geometry g, float amount) {
339 std::uniform_real_distribution<float> d(-amount, amount);
340 const std::uint32_t floats = g.stride / 4;
341 for (std::size_t v = 0; v + 2 < g.vertex_data.size(); v += floats) {
342 const float dx = d(rng), dy = d(rng);
343 g.vertex_data[v] = g.vertex_data[v] * 1.25f + dx;
344 g.vertex_data[v + 1] = g.vertex_data[v + 1] * 0.8f + dy;
345 if (!g.xy) g.vertex_data[v + 2] += d(rng);
346 }
347 return g;
348 };
349 {
350 Built refitted;
351 const Geometry big = soup(3000); // the radix-sort path
352 const std::vector<Geometry> after = {move(big, 1.5f)};
353 if (build_blas(gpu, builder, dir, "blas_refit_in_place", {big}, refitted, 300, &after)) return 1;
354 Built copied;
355 const Geometry g = grid(12, 4, false); // R32 indices, stride 16; the small-sort path
356 const std::vector<Geometry> after_grid = {move(g, 0.3f)};
357 if (build_blas(gpu, builder, dir, "blas_refit_into_other", {g}, copied, 0, &after_grid, true)) return 1;
358 }
359
294 // TLAS: instances over blas_random and blas_grid_u16_stride16. An instance names its BLAS by a 40-bit address 360 // TLAS: instances over blas_random and blas_grid_u16_stride16. An instance names its BLAS by a 40-bit address
295 // (256-byte units in 32 bits), as on the console; device addresses can be wider (llvmpipe's are host pointers). 361 // (256-byte units in 32 bits), as on the console; device addresses can be wider (llvmpipe's are host pointers).
296 // The instances hold application-style addresses, device address - bias, as the layer's address window does. 362 // The instances hold application-style addresses, device address - bias, as the layer's address window does.
@@ -338,6 +404,95 @@ int main(int argc, char** argv) {
338 } 404 }
339 json += "]}\n"; 405 json += "]}\n";
340 EXPECT(write_file(dir + "/tlas.json", json.data(), json.size())); 406 EXPECT(write_file(dir + "/tlas.json", json.data(), json.size()));
407
408 // The TLAS updated in place: every instance moves and turns; the masked and the BLAS-less ones stay so.
409 Inst moved_insts[sizeof insts / sizeof insts[0]];
410 std::memcpy(moved_insts, insts, sizeof insts);
411 const float c2 = std::cos(1.9f), s2 = std::sin(1.9f);
412 const float turned[12] = {c2, 0, s2, 4, 0, 1, 0, -3, -s2, 0, c2, 2};
413 std::memcpy(moved_insts[0].m, turned, sizeof turned);
414 moved_insts[1].m[3] -= 7;
415 moved_insts[1].m[7] += 5;
416 moved_insts[2].m[11] -= 4;
417 for (std::uint32_t i = 0; i < count; ++i) std::memcpy(static_cast<char*>(descs.map) + 64 * i, moved_insts[i].m, 48);
418 EXPECT(gpu.run([&](VkCommandBuffer cb) {
419 recorded = builder.record_tlas(cb, layout, descs.address, base, scratch.address, bias, base);
420 barrier_to_host(gpu, cb);
421 return recorded;
422 }));
423 EXPECT(write_file(dir + "/tlas_refit.bin", static_cast<const char*>(dst.map) + (base - dst.address), layout.size));
424 std::string json2 = "{\"kind\": \"tlas\", \"address\": " + std::to_string(base) + ", \"bias\": " +
425 std::to_string(bias) + ", \"blas\": [\"blas_random\", \"blas_grid_u16_stride16\"], \"instances\": [";
426 for (std::uint32_t i = 0; i < count; ++i) {
427 json2 += i ? ", {" : "{";
428 json2 += "\"transform\": [";
429 for (int k = 0; k < 12; ++k) json2 += (k ? ", " : "") + num(moved_insts[i].m[k]);
430 json2 += "], \"mask\": " + std::to_string(moved_insts[i].id_mask >> 24) + ", \"blas\": " +
431 std::to_string(moved_insts[i].which) + "}";
432 }
433 json2 += "]}\n";
434 EXPECT(write_file(dir + "/tlas_refit.json", json2.data(), json2.size()));
435
436 // CopyRaytracingAccelerationStructure: a clone of blas_random, its COMPACTED_SIZE (postbuild), a compaction into
437 // a buffer of exactly that size, and a clone of the refitted TLAS. The copies are position-independent.
438 {
439 XdxrLayout blas_layout;
440 EXPECT(blas_layout.compute(1000, false));
441 Buffer clone = make(gpu, blas_layout.size + 256), info = make(gpu, 16);
442 EXPECT(clone.buffer && info.buffer);
443 const std::uint64_t clone_at = (clone.address + 255) & ~std::uint64_t(255);
444 std::memset(info.map, 0xab, 16);
445 EXPECT(gpu.run([&](VkCommandBuffer cb) {
446 const bool ok = builder.record_copy(cb, random.address, clone_at, blas_layout.size) &&
447 builder.record_postbuild(cb, random.address, info.address) &&
448 builder.record_postbuild(cb, clone_at, info.address + 8);
449 barrier_to_host(gpu, cb);
450 return ok;
451 }));
452 std::uint64_t compacted = 0, clone_size = 0;
453 std::memcpy(&compacted, info.map, 8);
454 std::memcpy(&clone_size, static_cast<char*>(info.map) + 8, 8);
455 EXPECT(compacted == blas_layout.size); // a build is exactly its layout's size
456 EXPECT(clone_size == compacted);
457 auto dump_blas = [&](const std::string& name, const Buffer& b, std::uint64_t at, std::size_t bytes) {
458 const std::string j = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) +
459 ", \"triangles\": " + tris_json(random.tris) + "}\n";
460 return write_file(dir + "/" + name + ".bin", static_cast<const char*>(b.map) + (at - b.address), bytes) &&
461 write_file(dir + "/" + name + ".json", j.data(), j.size());
462 };
463 EXPECT(dump_blas("blas_clone", clone, clone_at, blas_layout.size));
464 // COMPACT into exactly the compacted size; a guard word after it must survive
465 Buffer packed = make(gpu, std::size_t(compacted) + 256 + 4);
466 EXPECT(packed.buffer);
467 const std::uint64_t packed_at = (packed.address + 255) & ~std::uint64_t(255);
468 const std::uint32_t guard = 0x600dc0deu;
469 std::memcpy(static_cast<char*>(packed.map) + (packed_at - packed.address) + compacted, &guard, 4);
470 EXPECT(gpu.run([&](VkCommandBuffer cb) {
471 const bool ok = builder.record_copy(cb, clone_at, packed_at, compacted + 4); // more room than needed
472 barrier_to_host(gpu, cb);
473 return ok;
474 }));
475 std::uint32_t after = 0;
476 std::memcpy(&after, static_cast<char*>(packed.map) + (packed_at - packed.address) + compacted, 4);
477 EXPECT(after == guard); // the copy stops at the source's own size
478 EXPECT(dump_blas("blas_compacted", packed, packed_at, std::size_t(compacted)));
479
480 Buffer tclone = make(gpu, layout.size + 256);
481 EXPECT(tclone.buffer);
482 const std::uint64_t tclone_at = (tclone.address + 255) & ~std::uint64_t(255);
483 EXPECT(gpu.run([&](VkCommandBuffer cb) {
484 const bool ok = builder.record_copy(cb, base, tclone_at, layout.size);
485 barrier_to_host(gpu, cb);
486 return ok;
487 }));
488 EXPECT(write_file(dir + "/tlas_refit_clone.bin", static_cast<const char*>(tclone.map) + (tclone_at - tclone.address),
489 layout.size));
490 std::string json3 = json2;
491 json3.replace(json3.find(std::to_string(base)), std::to_string(base).size(), std::to_string(tclone_at));
492 EXPECT(write_file(dir + "/tlas_refit_clone.json", json3.data(), json3.size()));
493 std::printf("copies: blas_clone, blas_compacted (%llu bytes), tlas_refit_clone\n",
494 static_cast<unsigned long long>(compacted));
495 }
341 std::printf("tlas: %u instances, %u bytes\nvk_xdxr_build_test: built every case\n", count, layout.size); 496 std::printf("tlas: %u instances, %u bytes\nvk_xdxr_build_test: built every case\n", count, layout.size);
342 return 0; 497 return 0;
343} 498}
diff --git a/runtime/test/xgameruntime_test.cpp b/runtime/test/xgameruntime_test.cpp
index ac36f40d9..8f5057662 100644
--- a/runtime/test/xgameruntime_test.cpp
+++ b/runtime/test/xgameruntime_test.cpp
@@ -51,8 +51,36 @@ using AsyncCompleteFn = void(__stdcall*)(XAsyncBlock*, HRESULT, size_t);
51using AsyncResultSizeFn = HRESULT(__stdcall*)(XAsyncBlock*, size_t*); 51using AsyncResultSizeFn = HRESULT(__stdcall*)(XAsyncBlock*, size_t*);
52using AsyncResultFn = HRESULT(__stdcall*)(XAsyncBlock*, const void*, size_t, void*, size_t*); 52using AsyncResultFn = HRESULT(__stdcall*)(XAsyncBlock*, const void*, size_t, void*, size_t*);
53 53
54struct XVersion {
55 union {
56 struct {
57 uint16_t major;
58 uint16_t minor;
59 uint16_t build;
60 uint16_t revision;
61 };
62 uint64_t Value;
63 };
64};
65static_assert(sizeof(XVersion) == 8, "XVersion must be 8 bytes per GDK spec");
66
67struct XSystemAnalyticsInfo {
68 XVersion osVersion;
69 XVersion hostingOsVersion;
70 char family[64];
71 char form[64];
72};
73static_assert(sizeof(XSystemAnalyticsInfo) == 144, "XSystemAnalyticsInfo must be 144 bytes per GDK spec");
74
75using AnalyticsInfoFn = XSystemAnalyticsInfo(__stdcall*)();
76using PackageIdentifierFn = HRESULT(__stdcall*)(size_t, char*);
77using PackageMountPathFn = HRESULT(__stdcall*)(void*, size_t, char*);
78using PackagedProcessFn = bool(__stdcall*)();
79
54const char* const kNames[] = { 80const char* const kNames[] = {
55 "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId", 81 "XGameRuntimeInitialize", "XGameRuntimeUninitialize", "XSystemGetDeviceType", "XSystemGetConsoleId",
82 "XSystemGetAnalyticsInfo", "XPackageGetCurrentProcessPackageIdentifier", "XPackageGetMountPath",
83 "XPackageIsPackagedProcess",
56 "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle", 84 "XTaskQueueCreate", "XTaskQueueCreateComposite", "XTaskQueueGetPort", "XTaskQueueDuplicateHandle",
57 "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback", 85 "XTaskQueueCloseHandle", "XTaskQueueTerminate", "XTaskQueueDispatch", "XTaskQueueSubmitCallback",
58 "XTaskQueueSubmitDelayedCallback", "XTaskQueueRegisterWaiter", "XTaskQueueUnregisterWaiter", 86 "XTaskQueueSubmitDelayedCallback", "XTaskQueueRegisterWaiter", "XTaskQueueUnregisterWaiter",
@@ -182,6 +210,89 @@ void check_run_time_load() {
182 void* out = reinterpret_cast<void*>(1); 210 void* out = reinterpret_cast<void*>(1);
183 check(query(&some_class, some_class, &out) == static_cast<HRESULT>(0x80070032) && out == nullptr, 211 check(query(&some_class, some_class, &out) == static_cast<HRESULT>(0x80070032) && out == nullptr,
184 "QueryApiImpl refuses a class it doesn't provide yet (HRESULT 0x80070032) and clears the out pointer"); 212 "QueryApiImpl refuses a class it doesn't provide yet (HRESULT 0x80070032) and clears the out pointer");
213
214 // XThreadingImpl and XErrorImpl, driven the way xgameruntime.lib's thunks in the package's DLLs do: QueryApiImpl
215 // with the class id as both ids, one vtable slot with `this` first, then Release (slot 2).
216 const GUID threading = {0x073b7dcb, 0x1fcf, 0x4030, {0x94, 0xbe, 0xe3, 0xc9, 0xeb, 0x62, 0x34, 0x28}};
217 const GUID error_cls = {0x8ca467f7, 0x22e8, 0x4096, {0x84, 0x56, 0xbb, 0x8a, 0xa1, 0x3f, 0x79, 0xd8}};
218 using Fn = void*;
219 auto slot = [](void* obj, int index) { return (*static_cast<Fn* const*>(obj))[index]; };
220 auto release = [&](void* obj) { reinterpret_cast<ULONG(STDMETHODCALLTYPE*)(void*)>(slot(obj, 2))(obj); };
221 auto get = [&](const GUID& cls) {
222 void* p = nullptr;
223 return query(&cls, cls, &p) == S_OK ? p : nullptr;
224 };
225 void* t = get(threading);
226 check(t != nullptr, "QueryApiImpl hands out XThreadingImpl for its class id");
227 if (t) {
228 void* again = get(threading);
229 check(again == t, "XThreadingImpl is one process-wide object");
230 release(again);
231 XTaskQueueHandle queue = nullptr;
232 using Create = HRESULT(STDMETHODCALLTYPE*)(void*, XTaskQueueDispatchMode, XTaskQueueDispatchMode,
233 XTaskQueueHandle*);
234 check(reinterpret_cast<Create>(slot(t, 12))(t, XTaskQueueDispatchMode::Manual, XTaskQueueDispatchMode::Manual,
235 &queue) == S_OK && queue,
236 "slot 12 is XTaskQueueCreate");
237 static std::atomic<int> s_ran{0};
238 using Submit = HRESULT(STDMETHODCALLTYPE*)(void*, XTaskQueueHandle, XTaskQueuePort, void*,
239 XTaskQueueCallback*);
240 XTaskQueueCallback* cb = [](void* ctx, bool canceled) {
241 if (!canceled) static_cast<std::atomic<int>*>(ctx)->fetch_add(1);
242 };
243 check(reinterpret_cast<Submit>(slot(t, 18))(t, queue, XTaskQueuePort::Work, &s_ran, cb) == S_OK,
244 "slot 18 is XTaskQueueSubmitCallback");
245 using Dispatch = bool(STDMETHODCALLTYPE*)(void*, XTaskQueueHandle, XTaskQueuePort, uint32_t);
246 check(reinterpret_cast<Dispatch>(slot(t, 16))(t, queue, XTaskQueuePort::Work, 0) && s_ran.load() == 1,
247 "slot 16 is XTaskQueueDispatch: the callback ran on the work port");
248 XTaskQueueHandle dup = nullptr;
249 using Dup = HRESULT(STDMETHODCALLTYPE*)(void*, XTaskQueueHandle, XTaskQueueHandle*);
250 check(reinterpret_cast<Dup>(slot(t, 15))(t, queue, &dup) == S_OK && dup,
251 "slot 15 is XTaskQueueDuplicateHandle");
252 using Close = void(STDMETHODCALLTYPE*)(void*, XTaskQueueHandle);
253 reinterpret_cast<Close>(slot(t, 17))(t, dup);
254 reinterpret_cast<Close>(slot(t, 17))(t, queue);
255 using SetSensitive = HRESULT(STDMETHODCALLTYPE*)(void*, bool);
256 using IsSensitive = bool(STDMETHODCALLTYPE*)(void*);
257 check(reinterpret_cast<SetSensitive>(slot(t, 27))(t, true) == S_OK &&
258 reinterpret_cast<IsSensitive>(slot(t, 30))(t) &&
259 reinterpret_cast<SetSensitive>(slot(t, 27))(t, false) == S_OK &&
260 !reinterpret_cast<IsSensitive>(slot(t, 30))(t),
261 "slots 27 and 30 set and read this thread's time-sensitive flag");
262 void* unk = nullptr;
263 const GUID iunknown = {0, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
264 using QI = HRESULT(STDMETHODCALLTYPE*)(void*, REFIID, void**);
265 check(reinterpret_cast<QI>(slot(t, 0))(t, iunknown, &unk) == S_OK && unk == t &&
266 reinterpret_cast<QI>(slot(t, 0))(t, error_cls, &unk) == E_NOINTERFACE && !unk,
267 "QueryInterface answers IUnknown and the class id, not another class");
268 release(t);
269 release(t);
270 }
271 void* e = get(error_cls);
272 check(e != nullptr, "QueryApiImpl hands out XErrorImpl for its class id");
273 if (e) {
274 struct Seen {
275 HRESULT hr;
276 char msg[32];
277 } seen{};
278 using Callback = bool(CALLBACK*)(HRESULT, const char*, void*);
279 Callback on_error = [](HRESULT hr, const char* msg, void* ctx) {
280 auto* s = static_cast<Seen*>(ctx);
281 s->hr = hr;
282 strncpy_s(s->msg, msg ? msg : "", _TRUNCATE);
283 return true;
284 };
285 using SetCallback = void(STDMETHODCALLTYPE*)(void*, Callback, void*);
286 using Report = void(STDMETHODCALLTYPE*)(void*, HRESULT, const char*);
287 reinterpret_cast<SetCallback>(slot(e, 4))(e, on_error, &seen);
288 reinterpret_cast<Report>(slot(e, 3))(e, E_FAIL, "offline test");
289 check(seen.hr == E_FAIL && std::strcmp(seen.msg, "offline test") == 0,
290 "slot 3 is XErrorReport and reaches the callback slot 4 (XErrorSetCallback) set");
291 reinterpret_cast<SetCallback>(slot(e, 4))(e, nullptr, nullptr);
292 using SetOptions = HRESULT(STDMETHODCALLTYPE*)(void*, uint32_t, uint32_t);
293 check(reinterpret_cast<SetOptions>(slot(e, 5))(e, 0, 0) == S_OK, "slot 5 is XErrorSetOptions");
294 release(e);
295 }
185 check(uninit_api() == S_OK, "UninitializeApiImpl succeeds"); 296 check(uninit_api() == S_OK, "UninitializeApiImpl succeeds");
186 297
187 HMODULE k32 = load_w(L"kernel32.dll"); 298 HMODULE k32 = load_w(L"kernel32.dll");
@@ -229,6 +340,53 @@ int main() {
229 check(console_id(sizeof(id), id, &used) == S_OK && used == 39 && std::strlen(id) == 38, 340 check(console_id(sizeof(id), id, &used) == S_OK && used == 39 && std::strlen(id) == 38,
230 "XSystemGetConsoleId fills 39 bytes (38 characters and the terminator)"); 341 "XSystemGetConsoleId fills 39 bytes (38 characters and the terminator)");
231 342
343 auto analytics_info = get<AnalyticsInfoFn>("XSystemGetAnalyticsInfo");
344 XSystemAnalyticsInfo info = analytics_info();
345 check(info.osVersion.major == 10 && info.osVersion.minor == 0 && info.osVersion.build == 22000 &&
346 info.osVersion.revision == 0,
347 "XSystemGetAnalyticsInfo returns osVersion 10.0.22000.0");
348 check(info.hostingOsVersion.major == 10 && info.hostingOsVersion.minor == 0 &&
349 info.hostingOsVersion.build == 22000 && info.hostingOsVersion.revision == 0,
350 "XSystemGetAnalyticsInfo returns hostingOsVersion 10.0.22000.0");
351 check(std::strcmp(info.family, "Xbox") == 0, "XSystemGetAnalyticsInfo returns family 'Xbox'");
352 check(std::strcmp(info.form, "Xbox Series X") == 0, "XSystemGetAnalyticsInfo returns form 'Xbox Series X'");
353
354 auto package_id = get<PackageIdentifierFn>("XPackageGetCurrentProcessPackageIdentifier");
355 check(package_id(0, nullptr) == E_INVALIDARG, "XPackageGetCurrentProcessPackageIdentifier rejects null buffer and size 0");
356 char pkg_id[64] = {};
357 check(package_id(0, pkg_id) == E_INVALIDARG, "XPackageGetCurrentProcessPackageIdentifier rejects size 0 with buffer");
358 check(package_id(10, nullptr) == E_INVALIDARG, "XPackageGetCurrentProcessPackageIdentifier rejects null pointer with size");
359 check(package_id(16, pkg_id) == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
360 "XPackageGetCurrentProcessPackageIdentifier rejects insufficient buffer");
361 check(package_id(sizeof(pkg_id), pkg_id) == S_OK && std::strlen(pkg_id) == 32,
362 "XPackageGetCurrentProcessPackageIdentifier fills 33-byte package identifier");
363
364 SetEnvironmentVariableA("LEONIDA_PACKAGE_ID", "CustomTestPackageId_123456789012");
365 check(package_id(sizeof(pkg_id), pkg_id) == S_OK &&
366 std::strcmp(pkg_id, "CustomTestPackageId_123456789012") == 0,
367 "XPackageGetCurrentProcessPackageIdentifier respects LEONIDA_PACKAGE_ID override");
368 SetEnvironmentVariableA("LEONIDA_PACKAGE_ID", nullptr);
369
370 auto mount_path = get<PackageMountPathFn>("XPackageGetMountPath");
371 check(mount_path(nullptr, 0, nullptr) == E_INVALIDARG, "XPackageGetMountPath rejects null buffer and size 0");
372 char mnt_path[MAX_PATH] = {};
373 check(mount_path(nullptr, 0, mnt_path) == E_INVALIDARG, "XPackageGetMountPath rejects size 0 with buffer");
374 check(mount_path(nullptr, 10, nullptr) == E_INVALIDARG, "XPackageGetMountPath rejects null pointer with size");
375
376 SetEnvironmentVariableA("LEONIDA_GAME_DIR", "C:\\LeonidaGameDir");
377 check(mount_path(nullptr, 5, mnt_path) == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
378 "XPackageGetMountPath rejects insufficient buffer");
379 check(mount_path(nullptr, sizeof(mnt_path), mnt_path) == S_OK &&
380 std::strcmp(mnt_path, "C:\\LeonidaGameDir") == 0,
381 "XPackageGetMountPath returns configured game directory");
382 SetEnvironmentVariableA("LEONIDA_GAME_DIR", nullptr);
383
384 auto is_packaged = get<PackagedProcessFn>("XPackageIsPackagedProcess");
385 check(is_packaged() == true, "XPackageIsPackagedProcess returns true by default");
386 SetEnvironmentVariableA("LEONIDA_PACKAGED", "0");
387 check(is_packaged() == false, "XPackageIsPackagedProcess respects LEONIDA_PACKAGED=0 override");
388 SetEnvironmentVariableA("LEONIDA_PACKAGED", nullptr);
389
232 // Work on the thread pool, completions dispatched by the "game loop" on this thread. 390 // Work on the thread pool, completions dispatched by the "game loop" on this thread.
233 auto create = get<QueueCreateFn>("XTaskQueueCreate"); 391 auto create = get<QueueCreateFn>("XTaskQueueCreate");
234 auto close = get<QueueCloseFn>("XTaskQueueCloseHandle"); 392 auto close = get<QueueCloseFn>("XTaskQueueCloseHandle");
diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp
index 429261e98..f115b6655 100644
--- a/runtime/test/xs_proxy_mock_test.cpp
+++ b/runtime/test/xs_proxy_mock_test.cpp
@@ -70,7 +70,7 @@ namespace xs = rt::d3d12_xs;
70 70
71// ---- Mocks ---- 71// ---- Mocks ----
72 72
73enum class Kind { device, queue, fence, resource }; 73enum class Kind { device, queue, fence, resource, allocator };
74 74
75constexpr unsigned kMockSlots = 128; 75constexpr unsigned kMockSlots = 128;
76constexpr std::uint64_t kFenceHandle = 0x1000, kResourceHandle = 0x2000; // the handles the mock device opens 76constexpr std::uint64_t kFenceHandle = 0x1000, kResourceHandle = 0x2000; // the handles the mock device opens
@@ -84,6 +84,7 @@ struct Mock {
84 long refs; 84 long refs;
85 int device_level; // device: highest ID3D12DeviceN it answers (0 = ID3D12Device only) 85 int device_level; // device: highest ID3D12DeviceN it answers (0 = ID3D12Device only)
86 bool fence1; // fence: answers ID3D12Fence1; device: the fences it makes do 86 bool fence1; // fence: answers ID3D12Fence1; device: the fences it makes do
87 bool allocator_tag; // allocator: answers kLeonidaCommandAllocatorTag; device: the allocators it makes do
87 bool create_null; // device: creation returns create_result with no object 88 bool create_null; // device: creation returns create_result with no object
88 HRESULT create_result; // device: what creation returns (S_OK makes the object) 89 HRESULT create_result; // device: what creation returns (S_OK makes the object)
89 Mock* last_child; // device: the object its last creation or open made 90 Mock* last_child; // device: the object its last creation or open made
@@ -126,6 +127,9 @@ bool mock_has(const Mock* m, REFIID iid) {
126 case Kind::fence: 127 case Kind::fence:
127 return IsEqualIID(iid, __uuidof(ID3D12Fence)) || (m->fence1 && IsEqualIID(iid, __uuidof(ID3D12Fence1))); 128 return IsEqualIID(iid, __uuidof(ID3D12Fence)) || (m->fence1 && IsEqualIID(iid, __uuidof(ID3D12Fence1)));
128 case Kind::resource: return IsEqualIID(iid, __uuidof(ID3D12Resource)); 129 case Kind::resource: return IsEqualIID(iid, __uuidof(ID3D12Resource));
130 case Kind::allocator:
131 return IsEqualIID(iid, __uuidof(ID3D12CommandAllocator)) ||
132 (m->allocator_tag && IsEqualIID(iid, xs::kLeonidaCommandAllocatorTag));
129 default: return false; 133 default: return false;
130 } 134 }
131} 135}
@@ -148,6 +152,7 @@ HRESULT mock_create(Mock* device, Kind kind, std::uint64_t riid, std::uint64_t o
148 if (device->create_null || FAILED(device->create_result)) return device->create_result; 152 if (device->create_null || FAILED(device->create_result)) return device->create_result;
149 Mock* child = new_mock(kind); 153 Mock* child = new_mock(kind);
150 child->fence1 = device->fence1; 154 child->fence1 = device->fence1;
155 child->allocator_tag = device->allocator_tag;
151 device->last_child = child; 156 device->last_child = child;
152 return mock_query(child, reinterpret_cast<const IID*>(riid), out); 157 return mock_query(child, reinterpret_cast<const IID*>(riid), out);
153} 158}
@@ -163,6 +168,7 @@ std::uint64_t mock_call(Mock* m, unsigned slot, const std::uint64_t* words) {
163 if (m->kind == Kind::device) { 168 if (m->kind == Kind::device) {
164 switch (slot) { 169 switch (slot) {
165 case 8: return static_cast<std::uint32_t>(mock_create(m, Kind::queue, a2, a3)); // CreateCommandQueue 170 case 8: return static_cast<std::uint32_t>(mock_create(m, Kind::queue, a2, a3)); // CreateCommandQueue
171 case 9: return static_cast<std::uint32_t>(mock_create(m, Kind::allocator, a2, a3)); // CreateCmdAllocator
166 case 75: return static_cast<std::uint32_t>(mock_create(m, Kind::queue, a3, a4)); // CreateCommandQueue1 172 case 75: return static_cast<std::uint32_t>(mock_create(m, Kind::queue, a3, a4)); // CreateCommandQueue1
167 case 36: return static_cast<std::uint32_t>(mock_create(m, Kind::fence, a3, a4)); // CreateFence 173 case 36: return static_cast<std::uint32_t>(mock_create(m, Kind::fence, a3, a4)); // CreateFence
168 case 32: // OpenSharedHandle 174 case 32: // OpenSharedHandle
@@ -248,10 +254,11 @@ const IID kDevice1Iid = __uuidof(ID3D12Device1);
248const D3D12_COMMAND_QUEUE_DESC kQueueDesc{}; 254const D3D12_COMMAND_QUEUE_DESC kQueueDesc{};
249 255
250// A device proxy over a new mock device. The proxy takes the mock's one reference. 256// A device proxy over a new mock device. The proxy takes the mock's one reference.
251void* make_device(Mock*& mock, int level, bool fence1) { 257void* make_device(Mock*& mock, int level, bool fence1, bool allocator_tag = true) {
252 mock = new_mock(Kind::device); 258 mock = new_mock(Kind::device);
253 mock->device_level = level; 259 mock->device_level = level;
254 mock->fence1 = fence1; 260 mock->fence1 = fence1;
261 mock->allocator_tag = allocator_tag;
255 mock->refs = 1; 262 mock->refs = 1;
256 void* device = nullptr; 263 void* device = nullptr;
257 if (FAILED(xs::create_device_proxy(reinterpret_cast<ID3D12Device*>(mock), __uuidof(ID3D12Device), &device))) 264 if (FAILED(xs::create_device_proxy(reinterpret_cast<ID3D12Device*>(mock), __uuidof(ID3D12Device), &device)))
@@ -563,7 +570,85 @@ int check_alloc_failures() {
563 return 0; 570 return 0;
564} 571}
565 572
566// ---- 6. The refused tail and the guard region ---- 573// ---- 6. Command allocators (device slot 9) ----
574
575int check_allocators() {
576 const IID allocator_iid = __uuidof(ID3D12CommandAllocator);
577 // An allocator that answers Leonida's tag (its lists resolve a proxy) comes back wrapped.
578 {
579 Mock* mock = nullptr;
580 void* device = make_device(mock, 9, true, true);
581 EXPECT(device);
582 const unsigned long device_refs = xs::device_proxy_ref_count(device);
583 void* allocator = nullptr;
584 EXPECT(hr_of(raw(device, 9, D3D12_COMMAND_LIST_TYPE_DIRECT, word(&allocator_iid), word(&allocator))) == S_OK);
585 Mock* const real = mock->last_child;
586 EXPECT(xs::is_allocator_proxy(allocator) && word(xs::allocator_proxy_real_allocator(allocator)) == word(real));
587 EXPECT(mock->args[9][0] == D3D12_COMMAND_LIST_TYPE_DIRECT && real->refs == 1);
588 EXPECT(xs::allocator_proxy_slot_count(allocator) == 9 && xs::device_proxy_ref_count(device) == device_refs + 1);
589 // Reset (slot 8) reaches the real allocator; every slot past it up to the table end is refused.
590 EXPECT(hr_of(raw(allocator, 8)) == S_OK && real->calls[8] == 1);
591 for (unsigned slot = 9; slot < xs::allocator_proxy_table_size(); ++slot)
592 EXPECT(hr_of(raw(allocator, slot)) == E_NOTIMPL && real->calls[slot] == 0);
593 // The tag and the real object stay hidden: QueryInterface answers only the modelled interfaces.
594 void* found = reinterpret_cast<void*>(1);
595 EXPECT(hr_of(raw(allocator, 0, word(&xs::kLeonidaCommandAllocatorTag), word(&found))) == E_NOINTERFACE &&
596 !found);
597 EXPECT(hr_of(raw(allocator, 0, word(&allocator_iid), word(&found))) == S_OK && found == allocator);
598 EXPECT(release(found) == 1);
599 // An allocator is a pageable: MakeResident gives the real runtime the real allocator.
600 const std::uint64_t objects[1] = {word(allocator)};
601 EXPECT(hr_of(raw(device, 34, 1, word(objects))) == S_OK && mock->array[34][0] == word(real));
602 EXPECT(release(allocator) == 0 && real->refs == 0);
603 EXPECT(xs::device_proxy_ref_count(device) == device_refs);
604 // Null IID, null output, a failing or empty creation, an IID the allocator lacks.
605 void* out = reinterpret_cast<void*>(1);
606 EXPECT(hr_of(raw(device, 9, 0, 0, word(&out))) == E_POINTER && !out);
607 EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), 0)) == S_FALSE); // the device's own answer
608 mock->create_result = E_OUTOFMEMORY;
609 out = reinterpret_cast<void*>(1);
610 EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), word(&out))) == E_OUTOFMEMORY && !out);
611 mock->create_result = S_OK;
612 mock->create_null = true;
613 out = reinterpret_cast<void*>(1);
614 EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), word(&out))) == E_FAIL && !out);
615 mock->create_null = false;
616 const IID fence_iid = __uuidof(ID3D12Fence);
617 out = reinterpret_cast<void*>(1);
618 EXPECT(hr_of(raw(device, 9, 0, word(&fence_iid), word(&out))) == E_NOINTERFACE && !out);
619 EXPECT(mock->last_child->refs == 0);
620 // A refused allocation for the proxy: E_OUTOFMEMORY, and the real allocator is released.
621 g_fail_news = 1;
622 out = reinterpret_cast<void*>(1);
623 const HRESULT starved = hr_of(raw(device, 9, 0, word(&allocator_iid), word(&out)));
624 g_fail_news = 0;
625 EXPECT(starved == E_OUTOFMEMORY && !out && mock->last_child->refs == 0);
626 EXPECT(xs::device_proxy_ref_count(device) == device_refs);
627 EXPECT(release(device) == 0 && mock->refs == 0);
628 }
629 // An allocator without the tag (a PC runtime allocator, whose lists could not resolve a proxy) comes back as it
630 // is, as the interface asked for.
631 {
632 Mock* mock = nullptr;
633 void* device = make_device(mock, 9, true, false);
634 EXPECT(device);
635 void* allocator = nullptr;
636 EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), word(&allocator))) == S_OK);
637 EXPECT(allocator == mock->last_child && !xs::is_allocator_proxy(allocator) && mock->last_child->refs == 1);
638 Mock* const real = mock->last_child;
639 EXPECT(release(allocator) == 0 && real->refs == 0);
640 const IID fence_iid = __uuidof(ID3D12Fence);
641 void* out = reinterpret_cast<void*>(1);
642 EXPECT(hr_of(raw(device, 9, 0, word(&fence_iid), word(&out))) == E_NOINTERFACE && !out);
643 EXPECT(mock->last_child->refs == 0);
644 EXPECT(release(device) == 0 && mock->refs == 0);
645 }
646 std::printf("%s: allocators answering Leonida's tag are wrapped (Reset forwarded, tail refused, residency "
647 "unwrapped, references balanced); others come back unwrapped; failures leave no reference\n", g_label);
648 return 0;
649}
650
651// ---- 7. The refused tail and the guard region ----
567 652
568int check_tail(bool want_guarded) { 653int check_tail(bool want_guarded) {
569 Mock* mock = nullptr; 654 Mock* mock = nullptr;
@@ -686,7 +771,7 @@ int main(int argc, char** argv) {
686 if (argc == 2) return run_fault_mode(argv[1]); 771 if (argc == 2) return run_fault_mode(argv[1]);
687 if (argc != 1) return 2; 772 if (argc != 1) return 2;
688 if (check_tail(true) || check_levels() || check_fence1() || check_create_failures() || check_open_shared() || 773 if (check_tail(true) || check_levels() || check_fence1() || check_create_failures() || check_open_shared() ||
689 check_alloc_failures()) 774 check_alloc_failures() || check_allocators())
690 return 1; 775 return 1;
691 std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); 776 std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news);
692 return 0; 777 return 0;