From ba626820ec54776fb0faffa2413727285befe85b Mon Sep 17 00:00:00 2001 From: Moriz82 <72836413+Moriz82@users.noreply.github.com> Date: Wed, 25 Nov 2026 03:44:31 -0600 Subject: [PATCH 01/12] Integrate post-story-load memory, queue and Vulkan runtime changes Preserve physical window aliases across remaps, order console list values, and replay bounded indirect graphics with captured draw state. Coordinate pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU and GPU coverage for the integrated paths. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com> --- docs/d3d12_vulkan.md | 110 +- docs/d3d12_xs_console_abi.md | 77 + runtime/CMakeLists.txt | 243 +- runtime/README.md | 6 +- runtime/shims/d3d12_com.cpp | 253 +- runtime/shims/d3d12_com.h | 33 +- runtime/shims/d3d12_com_object.h | 34 +- runtime/shims/d3d12_compile_exit.h | 13 + runtime/shims/d3d12_compute_input_probe.h | 263 +- runtime/shims/d3d12_geometry_views.h | 214 +- runtime/shims/d3d12_indirect_draw_policy.h | 20 + runtime/shims/d3d12_pipeline_compile.h | 260 +- runtime/shims/d3d12_title_buffer_windows.h | 42 +- runtime/shims/d3d12_title_image_upload.h | 150 +- runtime/shims/d3d12_vulkan_device.cpp | 2318 ++- runtime/shims/d3d12_xs_device.cpp | 957 +- runtime/shims/d3d12_xs_device.h | 63 + runtime/shims/d3d12_xs_list_values.h | 1289 ++ runtime/shims/dstorage.cpp | 18 +- runtime/shims/placed_image_map_note.h | 84 + runtime/shims/startup_trace.h | 17 + runtime/shims/xg_xs_layout.h | 8 +- runtime/shims/xmem.cpp | 1734 +- runtime/shims/xmem.h | 49 + runtime/src/arena_blocks.h | 238 + runtime/src/command_list.h | 57 +- runtime/src/fsdraw_probe.h | 8 +- runtime/src/guarded_copy.h | 59 + runtime/src/indirect_clamp.comp | 152 + runtime/src/indirect_clamp_spv.h | 287 + runtime/src/indirect_dispatch_count.comp | 21 +- runtime/src/indirect_dispatch_count_spv.h | 160 +- runtime/src/indirect_draw_stats.h | 45 + runtime/src/main.cpp | 56 +- runtime/src/submit_phases.h | 130 + runtime/src/thread_sampler.h | 401 + runtime/src/title_geometry_watch.h | 29 +- runtime/src/title_page_watch.h | 238 +- runtime/src/title_texture_memory.h | 10 +- runtime/src/title_texture_refresh.h | 32 +- runtime/src/title_va_alias.h | 69 +- runtime/src/title_window_plan.h | 63 + runtime/src/vulkan_aftermath.cpp | 822 + runtime/src/vulkan_aftermath.h | 77 + runtime/src/vulkan_backend.h | 465 +- runtime/src/vulkan_bindless.h | 130 +- runtime/src/vulkan_depth24.h | 4 +- runtime/src/vulkan_device_fault.h | 67 +- runtime/src/vulkan_index_view.h | 21 + runtime/src/vulkan_indirect_clamp.h | 583 + runtime/src/vulkan_indirect_dispatch_count.h | 34 +- runtime/src/vulkan_predicate.h | 2 + runtime/src/vulkan_predicated_copy.h | 2 + runtime/src/vulkan_present.h | 2 + runtime/src/vulkan_present_compose.h | 2 + runtime/src/vulkan_present_splash.h | 15 +- runtime/src/vulkan_replay.h | 389 +- runtime/src/vulkan_scratch.h | 115 +- runtime/src/xdxr_build.comp | 61 +- runtime/src/xdxr_build.h | 30 +- runtime/src/xdxr_build.inc | 15379 ++++++++-------- runtime/test/arena_blocks_test.cpp | 273 + runtime/test/d3d12_bundle_test.cpp | 121 +- runtime/test/d3d12_com_test.cpp | 11 + runtime/test/d3d12_compile_teardown_test.cpp | 662 + runtime/test/d3d12_draw_test.cpp | 45 + .../test/d3d12_graphics_direct_heaps_test.cpp | 268 +- .../d3d12_indirect_dispatch_count_test.cpp | 82 +- runtime/test/d3d12_indirect_rt_test.cpp | 73 +- runtime/test/d3d12_m4_compute_test.cpp | 28 +- runtime/test/d3d12_pipeline_stream.h | 70 + runtime/test/d3d12_state_map_test.cpp | 201 +- .../test/d3d12_stateful_indirect_pixels.cpp | 322 + runtime/test/d3d12_subgroup_test.cpp | 6 +- runtime/test/d3d12_title_va_test.cpp | 117 +- runtime/test/d3d12_unmapped_vsharp_test.cpp | 368 + runtime/test/d3d12_xdxr_rt_test.cpp | 292 + runtime/test/d3d12_xmem_placed_test.cpp | 276 +- runtime/test/dstorage_test.cpp | 103 + runtime/test/geometry_views_test.cpp | 166 + runtime/test/glsl/aftermath_fault.comp | 20 + runtime/test/glsl/cs_null_descriptors.comp | 110 + runtime/test/glsl/cs_user_data.comp | 6 + runtime/test/glsl/ms_user_data_window.mesh | 29 + .../test/glsl/ps_indirect_heap_resource.frag | 26 + .../test/glsl/ps_mesh_user_data_window.frag | 19 + runtime/test/guarded_copy_test.cpp | 99 + runtime/test/indirect_clamp_test.cpp | 385 + .../indirect_dispatch_count_alloc_test.cpp | 2 +- runtime/test/kernel_writes_test.cpp | 117 + runtime/test/title_memory_map_test.cpp | 147 + runtime/test/title_va_alias_test.cpp | 18 + runtime/test/title_window_plan_test.cpp | 154 + runtime/test/vk_aftermath_test.cpp | 243 + runtime/test/vk_null_descriptor_test.cpp | 292 + runtime/test/vk_test_device.h | 61 +- runtime/test/xg_xs_test.cpp | 68 +- runtime/test/xgameruntime_offline_test.cpp | 4 + runtime/test/xmem_geometry_aliases_stub.cpp | 9 + runtime/test/xmem_section_state.h | 10 + runtime/test/xmem_test.cpp | 1030 +- runtime/test/xmem_wine_commit_test.cpp | 123 + runtime/test/xs_proxy_mock_test.cpp | 742 +- tests/semantic/test_null_vsharp.py | 103 + tools/stage_timeline.py | 100 + 105 files changed, 27094 insertions(+), 8817 deletions(-) create mode 100644 runtime/shims/d3d12_compile_exit.h create mode 100644 runtime/shims/d3d12_indirect_draw_policy.h create mode 100644 runtime/shims/d3d12_xs_list_values.h create mode 100644 runtime/shims/placed_image_map_note.h create mode 100644 runtime/src/arena_blocks.h create mode 100644 runtime/src/guarded_copy.h create mode 100644 runtime/src/indirect_clamp.comp create mode 100644 runtime/src/indirect_clamp_spv.h create mode 100644 runtime/src/indirect_draw_stats.h create mode 100644 runtime/src/submit_phases.h create mode 100644 runtime/src/thread_sampler.h create mode 100644 runtime/src/title_window_plan.h create mode 100644 runtime/src/vulkan_aftermath.cpp create mode 100644 runtime/src/vulkan_aftermath.h create mode 100644 runtime/src/vulkan_index_view.h create mode 100644 runtime/src/vulkan_indirect_clamp.h create mode 100644 runtime/test/arena_blocks_test.cpp create mode 100644 runtime/test/d3d12_compile_teardown_test.cpp create mode 100644 runtime/test/d3d12_pipeline_stream.h create mode 100644 runtime/test/d3d12_stateful_indirect_pixels.cpp create mode 100644 runtime/test/d3d12_unmapped_vsharp_test.cpp create mode 100644 runtime/test/geometry_views_test.cpp create mode 100644 runtime/test/glsl/aftermath_fault.comp create mode 100644 runtime/test/glsl/cs_null_descriptors.comp create mode 100644 runtime/test/glsl/ms_user_data_window.mesh create mode 100644 runtime/test/glsl/ps_indirect_heap_resource.frag create mode 100644 runtime/test/glsl/ps_mesh_user_data_window.frag create mode 100644 runtime/test/guarded_copy_test.cpp create mode 100644 runtime/test/indirect_clamp_test.cpp create mode 100644 runtime/test/title_memory_map_test.cpp create mode 100644 runtime/test/title_window_plan_test.cpp create mode 100644 runtime/test/vk_aftermath_test.cpp create mode 100644 runtime/test/vk_null_descriptor_test.cpp create mode 100644 runtime/test/xmem_geometry_aliases_stub.cpp create mode 100644 runtime/test/xmem_section_state.h create mode 100644 runtime/test/xmem_wine_commit_test.cpp create mode 100644 tests/semantic/test_null_vsharp.py create mode 100644 tools/stage_timeline.py diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index d988a45f14..e800c5a572 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -500,8 +500,36 @@ What is implemented (all of it testable without the game): and the initial state or `D3D12_BARRIER_LAYOUT` is not used, because new textures start `UNDEFINED` and move on first use. The newer arguments are answered as the PC runtime answers them. `d3d12_method_variants_test` compares each answer below with the host runtime live, measured on an RTX 4090 (driver 621.14): - - `CreateCommandSignature` (`ID3D12CommandSignature`) and `ID3D12GraphicsCommandList::ExecuteIndirect` (including - GPU-written `CountBuffer` via Vulkan 1.2 core `vkCmdDrawIndirectCount` / `vkCmdDrawIndexedIndirectCount`). + - `CreateCommandSignature` and `ExecuteIndirect`: a signature consisting of a single DRAW or DRAW_INDEXED + operation inherits the graphics state of its command list. The Vulkan replay snapshots the same pipeline, root + data, render targets, IA bindings and raster state as a direct draw, then reads the records on the GPU inside + that draw's rendering scope. A padded stride is supported; it is not evidence that a signature is simple. + A compound graphics signature still emits no draw, but its written VB/IB and root bindings are reset for the + next command, even if no record is interpreted. Untouched slots and previously recorded draws retain their state. + See the [D3D12 state-leakage contract](https://microsoft.github.io/DirectX-Specs/d3d/IndirectDrawing.html#state-leakage). + Fixed- and GPU-counted batches use the device's enabled indirect features and limits. The current graphics + path covers triangle lists on direct command lists. A bundle can defer a single operation with no count + buffer: its argument-buffer identity and byte offset are recorded once; each `ExecuteBundle` captures the + direct parent's state at that call. Count buffers and compound signatures remain invalid in bundles. + `d3d12_bundle_indirect_warp` and `d3d12_bundle_indirect_layer` compare DRAW and DRAW_INDEXED against direct + pixels with two different parent bindings; the layer fixture also checks marker order and captured views. + Compound graphics signatures, non-unit instance divisors + and unsupported capabilities stay guarded. A GPU-counted draw currently requires + `maxDrawIndirectCount == UINT32_MAX`: Vulkan also limits the raw counter value, not just the caller's maximum. + To omit indirect graphics without changing direct drawing or compute, set + `LEONIDA_INDIRECT_DRAWS=off` before starting the process. This applies to the Vulkan-backed D3D12 + command list, including ordinary bundle draws when replayed on a parent. Validation and compound + root/IA resets still happen. Only exact lowercase `off` disables drawing; unset, empty, and other + values (including the old `raw` spelling) retain the normal capability-checked path. There is no + bare draw mode. The former `raw` setting logs an obsolescence notice on first policy use. + Each skip reason logs once. Progress lines give cumulative recorded commands, Vulkan emissions, + recording skips and replay skips. Replaying a command list can emit a recorded command more than once. + By default, a GPU pass bounds draw vertex/index and instance counts, dispatch group counts, and total + work across each command list (2^27 units). Unfilled all-ones records produce zero work and spend no budget. + Cumulative observed clamp and zero counts are reported every 60 presented frames. Counted calls read at most MaxCommandCount records. The stateful draw or dispatch reads + private scratch. Exhausting the diagnostic counter slots only disables readback of those counters. + `LEONIDA_INDIRECT_CLAMP=0` disables this pass. `LEONIDA_INDIRECT_GROUP_BUDGET=N` further bounds each + indirect dispatch, preserving X first, then Y and Z (1–65535 groups). It also works with the clamp disabled. - Optional `VK_KHR_acceleration_structure` + `VK_KHR_deferred_host_operations` + `VK_KHR_ray_query`: `ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo`, `ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure` (BLAS + TLAS), `vkGetBufferDeviceAddress` in `ID3D12Resource::GetGPUVirtualAddress()`, and RT-aware `UAV` @@ -674,7 +702,16 @@ side inwards: storage view gets an index the storage arrays hold, and a read-only one goes above where there is room. Index 0 is reserved, so 256 descriptors hold 255 live views in each 1D-array storage binding. - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss is - index 0. + index 0. It stands for a null descriptor (a zero T#, an empty heap slot, a view the layer refused) and is of + the kind the instruction asks for: the translator picks the binding by the instruction's dimension (a cube + reads the 2D-array binding) and the view by the T#'s class, so each dimension and class reads zeros. The + storage arrays' fallbacks never share an image with the sampled ones, so a store or atomic through a null + UAV cannot show in a later read through a null SRV. Where the device has `VK_EXT_robustness2`'s + `nullDescriptor` (`VulkanDeviceInfo::null_descriptor`, enabled alone) they are null descriptors, and the + store or atomic is dropped and a load reads zero, as on the console; without it they are 1x1 images of their + own. A null V# (all zeros) needs no fallback: every access through it is out of range (`NUM_RECORDS` 0), so + loads give 0 and stores and atomics do nothing (`tests/semantic/test_null_vsharp.py`). Checked on the GPU by + `vk_null_descriptor_test` (every dimension and class, both kinds of storage fallback). - Changes are queued and written by `flush()`, one write a slot, so a view that is removed before the next flush is never written. - `flush()` also uploads the table to its buffer: device-local memory, written from a mapped staging copy when @@ -835,6 +872,17 @@ The compute path, end to end: `LEONIDA_ARENA_LOG=1` also logs one line per VA handed out, per refused allocation, and per upload or readback buffer VA outside the arena. - Default-heap buffers are 64 KiB-aligned ranges in it, zeroed through its mapping; their console VA is the offset. + - Every access to its free-block map is under the arena's mutex, and a walk holds no iterator across a call + (`runtime/src/arena_blocks.h`): each step reads a block's offset and size, lets its iterator go, looks the next + block up from the map again, and re-finds a candidate by offset before it cuts it. A map access outside the lock + makes a concurrent walk step into a node an insert rebalanced away or a release freed — measured once: an access + violation reading the nil flag of a null map child at 0x19, inside `arena_allocate` for a slot-133 shadow buffer + (the arena's first block used to be inserted by `create_arena` with no lock, and an insert rewrites child links). + The arena checks `free + live == size - reserved` on every allocation and release (O(1)) and walks the whole + block map only when that fails or `LEONIDA_ARENA_CHECK=1` is set; a `double_free` or a release of a range past + the arena (`outside_arena`) is reported instead of being let into the map, and those lines are rate-limited to + one per 5 s. `arena_blocks_test` (CPU) covers first fit, coalescing, a title keep-out, the walk cut under it, the + bad releases and one lock with many threads. - Shader-visible descriptor heaps also live in it: the CPU handle is its host mapping and the GPU handle is the VA, so descriptor bytes the application writes itself are what shaders load. - Upload and readback buffers keep their own memory, and their VA is their device address minus the heap base. @@ -1221,8 +1269,12 @@ and any validation error fails them. `IDXGIFactory4::CreateSwapChainForHwnd`, `IDXGISwapChain3::GetCurrentBackBufferIndex`, `GetBuffer` + `GetDesc()`, backbuffer `CreateRenderTargetView` + clear + readback verification + `Present`, and `ResizeBuffers` with 0 validation errors. -- `d3d12_indirect_rt_test`: validates `ID3D12Device::CreateCommandSignature` + `ExecuteIndirect` with a GPU - `CountBuffer` (`vkCmdDrawIndirectCount`, `count = 0` skipped and `count = 1` rendered) and optional +- `d3d12_stateful_indirect_pixels`, `d3d12_stateful_indirect_multi_pixels` and + `d3d12_stateful_indirect_counted_pixels`: positive D3D12-to-Vulkan graphics tests. Compare every readback + pixel with both a direct-draw reference and a known pattern for each draw kind; the counted variant fills + its argument and count buffers by GPU copy before use. +- `d3d12_indirect_rt_test`: a native Vulkan counted-draw reference (count 0 leaves the clear colour, + count 1 renders), a D3D12 command-signature creation check, and optional `VK_KHR_acceleration_structure` + `VK_KHR_ray_query` (`GetRaytracingAccelerationStructurePrebuildInfo`, BLAS + TLAS `BuildRaytracingAccelerationStructure`, and a `RayQueryKHR` compute shader verifying hit vs. miss; clean SKIP on GPUs without RT). @@ -1621,6 +1673,18 @@ The copies: cannot fit between the title's address reservations can use a separate mapped buffer. The buffer's device address must fit as a positive 47-bit offset from the arena base. The same window cap and dirty-page refresh apply. `LEONIDA_STREAM_BUFFER_WINDOWS=0` requires the window to fit in the arena. +- A **window that is refused** (the budget is spent, the arena is full, or the pages are not committed yet) is backed + by a persistent geometry copy of exactly the requested range (`LEONIDA_GEOMETRY_MB`) instead; when no copy can be + made either, the view is written with **no base and no records** — loads return 0 and stores are dropped. A raw + title address is never left in a V# or a root view: `heap_base + a raw VA` is not an allocation, and a store there + loses the device. The refusal and the count of zero-size views are logged. +- A **stream pool** (the title's CPU view paired with a 16-24 GiB GPU-only + alias) is not windowed per request. The GPU-only pages are translated to the CPU view of the same frames (rule B in + that note), and **one mapping serves a page-aligned readable run** of the pool (at most 1 MiB, a geometry copy when + the cap allows, a window otherwise). Both addresses of the pair are entered in the table, so a V# naming either + reaches that one mapping instead of asking for a second one; `LEONIDA_GEOMETRY_MB` is the preferred backing. + Acceleration-structure destinations and scratch also resolve through the table, and a structure no window holds + whole gets a copy of its whole range, so the BVH builder's commands are recorded. - `LEONIDA_GEOMETRY_MB` sets the device-local memory cap for streamed buffer views. The default is 0. A positive cap enables persistent copies of placed buffer SRVs and buffer descriptors in title memory. A GPU-only reservation uses its paired CPU mapping. Matching source ranges share one copy. @@ -1769,11 +1833,18 @@ The game can use D3D12 descriptors in three ways, and the layer must handle all and mesh from s16 (issue #14, comment 7143020922, on a `boot-prototype` run; not reproduced in this repository). A mesh signature that fills the window leaves no room there: a heap past s31 of the mesh shader (push dword 24 or later) is logged once. A signature that keeps the s0 graphics layout, or whose arguments fill - s31, gets none (logged once). `d3d12_graphics_direct_heaps_test` checks the recorded draws and what a vertex - and a pixel shader read, with and without the flags; `d3d12_mesh_test` checks that a mesh draw records the - vertex draw's dwords, a resource-only rebind, a signature ending at s30 and one on the s0 layout (recorded - arguments only; no GPU read through a mesh shader). Set `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` to restore the - previous draw arguments. + s31, gets none (logged once). `d3d12_graphics_direct_heaps_test` checks the recorded draws and reads back + what vertex and pixel shaders saw with and without the flags. On a mesh-capable device it also checks the + heap pointers read by the mesh and pixel stages after a rebind. `d3d12_mesh_test` checks the recorded dwords + for a vertex draw, a resource-only rebind, a signature ending at s30 and one on the s0 layout. + Set `LEONIDA_GRAPHICS_DIRECT_HEAPS=0` to restore the previous draw arguments. + Missing console V# backing leaves a settled zero descriptor. Every 32 submissions a heap probes up to + eight of these slots in round-robin order, including independent UAV-counter failures. + Console resource heap copies and shader-visible CBV/SRV/UAV heaps with at least 65,536 slots request + 64 MiB of zeroed padding after their last descriptor. `LEONIDA_HEAP_GUARD_MB` sets the padding in MiB + (0 disables it). When arena space is tight, allocation can fall back to the heap alone. Only indices + inside the reserved padding read null slots. Console slots containing data instead of a recognized image + or buffer descriptor have their first 16 bytes cleared in the GPU copy. The title keeps its original bytes. 3. **Game-built descriptor memory.** The game writes raw T#/S# bytes into a heap itself, without calling `CreateShaderResourceView`. The shaders then read those bytes exactly as in case 1. @@ -2303,6 +2374,14 @@ Pipeline creation: Replay skips a draw or dispatch while its pipeline is pending. Later uses find the completed handle. A skipped dispatch can lose a one-time resource update. Synchronous first use is the default and strict replay always uses it. `LEONIDA_COMPUTE_WARMUP=0` restricts the worker to pipelines requested by the title. + A queued build holds no reference to its PSO or device (`PipelineCompiler`, `runtime/shims/d3d12_pipeline_compile.h`). + A PSO's last release drops its queued builds and returns at once; one already running is left to finish, and the + worker deletes the PSO after it (`PipelineState::last_release`). The PSO's device reference goes at the release, so + the release that tears the device down waits for that build, drops the device's cache checkpoint, and the last + device stops and joins the worker before any Vulkan object goes; the session cache is written after that. gta6rt, + which ends with the device alive, drops the queue and waits up to 2 s for a running build before `ExitProcess` and on + a console Ctrl+C, Ctrl+Break or close; after that nothing is queued, and a first use builds in place + (`d3d12_compile_teardown_test`). `GetCachedBlob` records the vendor, device, driver version, `pipelineCacheUUID` and a SHA-256 of the description without `Flags`, sealed by a checksum (`runtime/src/cached_pso.h`). The answers are the host's, measured on an RTX 3060 and WARP: the same description is accepted; another @@ -2804,6 +2883,12 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv allocations. `LEONIDA_TITLE_IMAGE_POOL=0` selects individual allocation for every image. With `LEONIDA_MEM_PROBE` enabled, the texture census also reports logical Vulkan backing bytes for the registered slot-70 and slot-133 images and the portion on non-device-local types. +- A refresh pass visits a snapshot of the title-image registry, taken under its mutex, instead of walking the + registry itself. Filling a texture can submit, a submission destroys a retired image, and that image's destructor + erases its registry entry. Windows' mutex is recursive for its owner, so the erase lands inside the pass, and a walk + over the map itself would step into a freed node (measured: an access violation reading the nil flag of a null + child, 0x19, in `Device::refresh_title_textures`). The snapshot also holds a reference to each entry, so an entry + retired during the pass is still alive when its turn comes. - Sampled title images can use device-local memory even when Vulkan host image copies require a host-visible memory type. The runtime queries the same image with and without host-transfer usage. When only the latter permits plain device-local backing, it detiles the complete image into a reusable @@ -4068,8 +4153,9 @@ struct entry { // 10 uints = 40 bytes the rebuild, at a point where no in-flight command buffer reads the old table. - Insert on `CreateShaderResourceView`, `CreateUnorderedAccessView`, `CreateSampler`, `CopyDescriptors` and heap scans. A duplicate key updates the index in place. -- Index 0 is the fallback: a 1×1 texture and a default sampler (and a valid dummy storage image for the storage - arrays). The translator returns 0 on a miss, so index 0 must always be valid. +- Index 0 is the fallback: a 1×1 texture and a default sampler (and, for the storage arrays, a null descriptor + with `VK_EXT_robustness2` `nullDescriptor` or else a storage image apart from the sampled ones). The translator + returns 0 on a miss, so index 0 must always be valid. - The table buffer is a normal storage buffer, not part of the arena. It can be host-visible and updated directly (host-coherent, or flushed before submit); if the game is sensitive to PCIe traffic, stage it like any other upload. The shader only reads it. diff --git a/docs/d3d12_xs_console_abi.md b/docs/d3d12_xs_console_abi.md index e1ec05fc7d..b14410c431 100644 --- a/docs/d3d12_xs_console_abi.md +++ b/docs/d3d12_xs_console_abi.md @@ -161,6 +161,7 @@ end; on a full buffer they call the vtable method the record stands for (Package | 41, 43, 45 | `Set*RootDescriptor*` / table | Package + sibling layer | | 48 | `IASetVertexBuffers` | Sibling layer | | 51 | `ClearDepthStencilView` | Sibling layer | +| 71-74 | memory writes and waits (newer layout; 69-72 older) | **Measured here**, §5.5 | | 80 | `ExecuteIndirect` | Sibling layer (note: the package measured slot 80 as a console-only call, a `Dispatch`-with-extra-word shape; slot assignments past 61 differ between the two sources — unconfirmed) | | 83 | `CopyTextureRegionX` (older layout) | Sibling layer; the package measured a `CopyTextureRegion`-shaped call at slot 85 — consistent with the newer layout (+2) | | 108 | `ResolveSubresourceRegion` | Sibling layer | @@ -189,6 +190,82 @@ console-shaped either way. | 12 | `CopyTextureRegion` | Sibling layer | | 13 | `CopyResource` | Sibling layer | +### 5.5 Memory writes and waits + +The list has bottom-of-pipe writes of a 32- or 64-bit value into title memory and waits that stop the queue until +a 32- or 64-bit value in memory compares true against a reference. Neither has a D3D12 or Vulkan command; the +runtime models both (`runtime/shims/d3d12_xs_list_values.h`, the list cut and `execute_with_values` in +`d3d12_xs_device.cpp`). + +| Older slot | Newer slot | Method | Evidence | +|---:|---:|---|---| +| 68 | 70 | depth bounds `(min, max)` as floats | Sibling layer; the retail title calls 70 (unmodelled, a no-op) | +| 69 | 71 | `write32(address, value, flush, flags)` | Sibling layer; **measured here** on retail 1.0.2.1 | +| 70 | 72 | `write64(address, value, flush, flags)`: flags 1 stores the GPU timestamp, 2 the system one (QPC) | Sibling layer; **measured here** (flags 1 and 0 seen) | +| 71 | 73 | `wait32(address, comparison, reference, word)` | Sibling layer; not called by the retail title in the boots measured | +| 72 | 74 | `wait64(address, comparison, reference, word)` | Sibling layer; **measured here** | +| 73 | 75 | pixel-shader depth order (state) | Sibling layer; the retail title calls 75 (a no-op) | + +Measured here (retail 1.0.2.1, boots to the story load; temporary per-call logging, not committed): + +- The lists record before the queue proxy has detected the layout (§1.1): the first value calls arrive with the + layout still unknown. The runtime takes an undetected layout as the newer one, the title's, as it already does for + `ExecuteIndirect` at 61. +- Up to the story load (~150 s): about 12 000 `write32` (small counters and a constant tag in a ring of 72-byte + records), 16 000 `write64` (all with flags 1, GPU timestamps, in begin/end pairs) and 4 100 `wait64`, one per + frame, `>=` a reference that rises by one each frame, at the start of a direct list, always met when the list is + submitted (the CPU writes that value). +- From the story load on: job chains across the queues. Compute lists (the title uses five compute queues) and + direct lists `wait64(address, >=, tag)`, mostly as their first calls and sometimes after two to five calls of + work, for addresses that other lists `write64(address, tag)` with flags 0: direct lists write tags as their first + calls and wait for compute results; compute lists wait for those tags and write theirs near their end. Before + this runtime modelled the writes, every such wait was unmet at submission and ran on. +- Comparison code 7 is the only one seen; the codes are taken as `D3D12_COMPARISON_FUNC` (memory OP reference, as + the sibling layer does). The wait's fourth word had 1 in its low 32 bits each time; it is not used. + +The runtime's model: + +- A write lands after the list part it was recorded in has run: the queue proxy signals a fence of its own behind + the part and a pump thread stores the value with the CPU once the fence is reached + (`leonida::kernel_writes::store`: one locked access for an aligned value, so a title thread polling it never + reads half of it, and pinned like any host write, so the slot-133 shadows see it). Later than the console, never + earlier. Writes land in submission order across queues: the pump reads the fences newest write first, so a write + whose work waited for an older one is never seen done before it. +- `write64` flags 1 and 2 take the GPU's timestamp at the write's place in the list: an `EndQuery(TIMESTAMP)` on + the real list (the Vulkan layer writes it at the bottom of the pipe) and a `ResolveQueryData` of that one slot into + a readback ring of the device's, read when the write lands. Flag 1 lands those ticks, which count at the queue's + `GetTimestampFrequency` (what the queue proxy answers the title's frequency query with, newer layout slot 18); + flag 2 lands the `QueryPerformanceCounter` value at which the GPU took them, through the queue's clock + calibration (renewed every second), never later than the landing. A write that lands before its part has run + (recorded before a wait whose gate holds the part) takes the CPU's clock at landing instead, as before. The + title's GPU timing reads these values back, in begin/end pairs. +- A wait recorded before any work of the part stands at the part's start; writes recorded before that first wait + land before the queue stands at it (behind the work submitted before the part), as the title's frame lists and + job-tag writers need. A wait recorded after work, or after a write that follows a wait, cuts the list: + the real list so far is closed as a part, recording goes on in a spare real list on the same allocator, and the + state set so far (heaps, root signatures and arguments, pipeline, viewports, scissors, targets, vertex and index + buffers, blend factor, stencil reference, predication; what an executed bundle set, and nothing from before a + `ClearState`) is set on it again. A cut that would split an open query waits for the query's `EndQuery`. + Bundles record neither method (`ExecuteBundle` names one real list, so a bundle cannot be cut). +- At submission each part's waits are checked: met ones cost nothing; one that a write still in flight will meet + becomes a queue `Wait` on that write's fence (the GPU orders the two queues); any other makes the queue `Wait` on + a gate fence that is signalled once memory compares true. The Vulkan layer holds the queue's later work behind + that wait without blocking the submitting thread (`src/queue_holds.h`). The pump only decides; a second thread, + the releaser, signals the gates, because that Signal runs the work the layer held behind them (the held + submission, the shadow refresh, a deferred Present), and the pump keeps landing writes and timing gates out + meanwhile. +- A gate opens after `LEONIDA_VALUE_WAIT_TIMEOUT_MS` (default 200) whatever memory holds, counted from when the + gates before it on its queue opened, and logged once per address. An address that timed out three times in a row + (the last 256 addresses are counted) gets 4 ms. Once four gates in a row timed out, so does every wait for an + address no wait was ever met for, until a gate cut short is met within its 4 ms; a wait cut short that memory + meets within the rest of the full timeout gives its address the full timeout from then on. + `LEONIDA_LIST_VALUES=0` drops both methods, as before. After `stop_list_values` (the process is ending) nothing + new is landed or opened. +- Queue slot 31 (`CopyPageMappingsBatchX`, section 4) waits at most 16 ms for the queue's earlier work. Work held + behind a gate takes longer: the remap is then deferred to the releaser, which runs it once the queue's write + fence passes the call's point and only then opens a gate the queue's later work waits on, so the GPU sees the + order of the call and the title's thread does not wait (the console's CPU does not either). + ## 6. Root arguments Sibling-layer measurements on retail titles: diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 14cc5fbf23..6de387c1a3 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -292,16 +292,18 @@ if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME) # xmem shim ABI test: resolves the registered xmem.dll exports itself, so xmem.cpp and registry.cpp are compiled # into this executable instead of reusing gta6rt's objects (which would duplicate their symbols). - add_executable(xmem_test - test/xmem_test.cpp - shims/xmem.cpp - shims/registry.cpp - ) - target_include_directories(xmem_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shims) - target_compile_definitions(xmem_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) - target_compile_options(xmem_test PRIVATE /W4 /permissive- /utf-8 $<$:/EHa>) - target_link_options(xmem_test PRIVATE /OPT:NOREF) - target_link_libraries(xmem_test PRIVATE psapi) + foreach(target IN ITEMS xmem_test xmem_wine_commit_test) + add_executable(${target} + test/${target}.cpp + shims/xmem.cpp + shims/registry.cpp + ) + target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shims) + target_compile_definitions(${target} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + target_compile_options(${target} PRIVATE /W4 /permissive- /utf-8 $<$:/EHa>) + target_link_options(${target} PRIVATE /OPT:NOREF) + target_link_libraries(${target} PRIVATE psapi) + endforeach() # The title's CLZERO loops rewritten to stubs on a CPU without CLZERO (src/clzero_patch.h): both loop shapes are # found, patched and run, so the test runs on any x86-64 CPU. @@ -522,11 +524,21 @@ if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME) target_compile_definitions(kernel_writes_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE) target_compile_options(kernel_writes_test PRIVATE /W4 /permissive- /utf-8) + # guarded_copy (src/guarded_copy.h): a fault in a copy made under __try reaches its __except, under Wine too. + add_executable(guarded_copy_test test/guarded_copy_test.cpp) + target_compile_definitions(guarded_copy_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + target_compile_options(guarded_copy_test PRIVATE /W4 /permissive- /utf-8) + # title_write_watch (src/title_page_watch.h): the journal that shares write-watch answers between trackers. add_executable(title_write_watch_test test/title_write_watch_test.cpp) target_compile_definitions(title_write_watch_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE) target_compile_options(title_write_watch_test PRIVATE /W4 /permissive- /utf-8) + # title_memory_map (src/title_page_watch.h): map changes by range, and the texture pass that probes only what they hit. + add_executable(title_memory_map_test test/title_memory_map_test.cpp) + target_compile_definitions(title_memory_map_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE) + target_compile_options(title_memory_map_test PRIVATE /W4 /permissive- /utf-8) + # Console model in the registry (ConsoleMode) against LEONIDA_DEVICE_TYPE. add_executable(console_registry_test test/console_registry_test.cpp @@ -1497,6 +1509,10 @@ if(BUILD_TESTING) endif() if(WIN32 AND TARGET xmem_test) add_test(NAME xmem COMMAND xmem_test) + # The pool read test executes its read from a PE at the title's image base. + target_link_options(xmem_test PRIVATE /BASE:0x140000000 /DYNAMICBASE:NO) + add_test(NAME xmem_pool_zero_read COMMAND xmem_test --pool-zero-read) + add_test(NAME xmem_wine_commit COMMAND xmem_wine_commit_test) # The same with write watching off: no reservation is write-watched for the shadows. add_test(NAME xmem_no_write_watch COMMAND xmem_test) set_tests_properties(xmem_no_write_watch PROPERTIES ENVIRONMENT "LEONIDA_WRITE_WATCH=0") @@ -1552,6 +1568,12 @@ if(BUILD_TESTING) if(WIN32 AND TARGET kernel_writes_test) add_test(NAME kernel_writes COMMAND kernel_writes_test) endif() + if(WIN32 AND TARGET guarded_copy_test) + add_test(NAME guarded_copy COMMAND guarded_copy_test) + endif() + if(WIN32 AND TARGET title_memory_map_test) + add_test(NAME title_memory_map COMMAND title_memory_map_test) + endif() if(WIN32 AND TARGET title_write_watch_test) add_test(NAME title_write_watch COMMAND title_write_watch_test) add_test(NAME title_write_watch_on COMMAND title_write_watch_test) @@ -1809,6 +1831,17 @@ if(TARGET Vulkan::Headers) target_compile_definitions(${tool} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) endif() endforeach() + # The ExecuteIndirect argument clamp's compute pass (runtime/src/vulkan_indirect_clamp.h): every argument kind and + # the counted variants, with garbage records bounded and the batch budget saturating, read back from the scratch + # the replay would use. 77 without a Vulkan device. + add_executable(indirect_clamp_test test/indirect_clamp_test.cpp) + target_link_libraries(indirect_clamp_test PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS}) + if(WIN32) + target_compile_definitions(indirect_clamp_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + endif() + if(MSVC) + target_compile_options(indirect_clamp_test PRIVATE /W4 /permissive- /utf-8) + endif() # OpFmaKHR width gate of vk_shader_fma.h (shaderFmaFloat32 / shaderFmaFloat64): no Vulkan instance, no GPU. add_executable(vk_shader_fma_test test/vk_shader_fma_test.cpp) target_link_libraries(vk_shader_fma_test PRIVATE Vulkan::Headers) @@ -1873,7 +1906,7 @@ if(TARGET Vulkan::Headers) add_test(NAME depth24_convert COMMAND depth24_convert_test) set_tests_properties(depth24_convert PROPERTIES SKIP_RETURN_CODE 77) # Self-checking Vulkan tests with no shaders or game data; each exits 77 without a Vulkan device (TEST-514). - foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue) + foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue indirect_clamp) add_test(NAME ${test} COMMAND ${test}_test) set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77) endforeach() @@ -2015,6 +2048,35 @@ if(TARGET Vulkan::Headers) add_test(NAME vk_bindless_grow COMMAND vk_bindless_grow_test) set_tests_properties(vk_bindless_grow PROPERTIES SKIP_RETURN_CODE 77) endif() + # Null descriptors of every kind through the bindless set's fallbacks: zero T#s and unanswered T#s of each dimension + # read zeros, and stores and atomics through a null UAV never reach a null SRV (dropped with nullDescriptor). The + # shader is GLSL; without glslangValidator the test skips. + add_executable(vk_null_descriptor_test test/vk_null_descriptor_test.cpp) + target_link_libraries(vk_null_descriptor_test PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS}) + if(WIN32) + target_compile_definitions(vk_null_descriptor_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + endif() + if(MSVC) + target_compile_options(vk_null_descriptor_test PRIVATE /W4 /permissive- /utf-8) + endif() + find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE glslangValidator HINTS "$ENV{VULKAN_SDK}/Bin" "$ENV{VULKAN_SDK}/bin") + if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) + set(_null_descriptors_spv ${CMAKE_CURRENT_BINARY_DIR}/generated/cs_null_descriptors.spv) + add_custom_command(OUTPUT ${_null_descriptors_spv} + COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.3 -o ${_null_descriptors_spv} + ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/cs_null_descriptors.comp + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/cs_null_descriptors.comp + COMMENT "Compiling the null descriptor test shader" VERBATIM) + target_sources(vk_null_descriptor_test PRIVATE ${_null_descriptors_spv}) + target_compile_definitions(vk_null_descriptor_test PRIVATE + LEONIDA_TEST_NULL_DESCRIPTORS_SPV="${_null_descriptors_spv}") + else() + message(STATUS "glslangValidator not found: vk_null_descriptor_test skips") + endif() + if(BUILD_TESTING) + add_test(NAME vk_null_descriptor COMMAND vk_null_descriptor_test) + set_tests_properties(vk_null_descriptor PROPERTIES SKIP_RETURN_CODE 77) + endif() # CPU-only: the bindless set's array sizes from synthetic device limits. add_executable(bindless_sizing_test test/bindless_sizing_test.cpp) target_link_libraries(bindless_sizing_test PRIVATE Vulkan::Headers) @@ -2171,20 +2233,72 @@ if(TARGET Vulkan::Headers) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../tools/gen_d3d12_stubs.py ${LEONIDA_D3D12_HEADER} COMMENT "Generating D3D12 COM stubs" VERBATIM) - add_library(gta6rt_d3d12_com STATIC shims/d3d12_com.cpp shims/d3d12_vulkan_device.cpp shims/d3d12_xs_device.cpp shims/d3d12_xs_pso_stream.cpp shims/xbox_present.cpp + # Optional NVIDIA Nsight Aftermath GPU crash dumps (LEONIDA_AFTERMATH=1, src/vulkan_aftermath.h). Nothing of the SDK + # is in the repository or linked: -DLEONIDA_AFTERMATH_SDK= points at an unpacked Nsight Aftermath SDK (include/, + # lib/x64/GFSDK_Aftermath_Lib.x64.dll). Its headers are used at build time; the DLL is loaded at run time, from + # LEONIDA_AFTERMATH_DLL or else that SDK's lib/x64. Without the option the functions do nothing. + set(LEONIDA_AFTERMATH_SDK "" CACHE PATH "Nsight Aftermath SDK directory (include/, lib/x64/) for LEONIDA_AFTERMATH=1") + add_library(gta6rt_aftermath STATIC src/vulkan_aftermath.cpp) + target_include_directories(gta6rt_aftermath PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_link_libraries(gta6rt_aftermath PUBLIC Vulkan::Headers) + target_compile_definitions(gta6rt_aftermath PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS) + target_compile_options(gta6rt_aftermath PRIVATE /W4 /permissive- /utf-8) + if(LEONIDA_AFTERMATH_SDK) + file(TO_CMAKE_PATH "${LEONIDA_AFTERMATH_SDK}" _aftermath_sdk) + if(NOT EXISTS "${_aftermath_sdk}/include/GFSDK_Aftermath_GpuCrashDumpDecoding.h") + message(FATAL_ERROR "LEONIDA_AFTERMATH_SDK=${_aftermath_sdk}: no include/GFSDK_Aftermath_GpuCrashDumpDecoding.h") + endif() + execute_process(COMMAND git -C "${CMAKE_CURRENT_SOURCE_DIR}" describe --always --dirty + OUTPUT_VARIABLE _aftermath_version OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + if(NOT _aftermath_version) + set(_aftermath_version "unknown") + endif() + target_include_directories(gta6rt_aftermath PRIVATE "${_aftermath_sdk}/include") + target_compile_definitions(gta6rt_aftermath PRIVATE LEONIDA_HAVE_AFTERMATH + LEONIDA_AFTERMATH_DLL_DEFAULT="${_aftermath_sdk}/lib/x64/GFSDK_Aftermath_Lib.x64.dll" + LEONIDA_AFTERMATH_APP_VERSION="${_aftermath_version}") + message(STATUS "Nsight Aftermath SDK: ${_aftermath_sdk} (crash dumps with LEONIDA_AFTERMATH=1)") + endif() + + # xmem.cpp and registry.cpp: d3d12_vulkan_device.cpp's compute-input probe asks the xmem shim for the other views + # of a title address (rt::xmem::geometry_aliases), and xmem.cpp registers its table through the shim registry, so + # the test targets that link this library need both. gta6rt compiles the two files itself and never pulls these + # members. psapi is what xmem.cpp's working-set call needs. + add_library(gta6rt_d3d12_com STATIC shims/d3d12_com.cpp shims/d3d12_vulkan_device.cpp shims/d3d12_xs_device.cpp shims/d3d12_xs_pso_stream.cpp shims/xbox_present.cpp shims/xmem.cpp shims/registry.cpp shims/dxgi_com.cpp shims/package_splash.cpp ${LEONIDA_STUBS}) # d3d12_vulkan_device.cpp reads the PC device behind the proxy (#224) target_include_directories(gta6rt_d3d12_com PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated) - target_link_libraries(gta6rt_d3d12_com PUBLIC Vulkan::Headers gta6rt_root_signature PRIVATE ole32 windowscodecs xmllite shlwapi user32 gdi32) + target_link_libraries(gta6rt_d3d12_com PUBLIC Vulkan::Headers gta6rt_root_signature gta6rt_aftermath PRIVATE ole32 windowscodecs xmllite shlwapi user32 gdi32 psapi) target_compile_definitions(gta6rt_d3d12_com PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) # /bigobj: a Debug build of d3d12_vulkan_device.cpp has more sections than a COFF object holds by default # (fatal error C1128), because without optimisation every inline function keeps its own COMDAT. target_compile_options(gta6rt_d3d12_com PRIVATE /W4 /permissive- /utf-8 /bigobj) + # A compute shader that writes through a bogus buffer device address on an Aftermath-enabled device: the dump appears + # and the decoder names the shader. It loses the device on purpose, so it runs only with LEONIDA_AFTERMATH_FAULT_TEST=1 + # (else exit 77, as without the DLL or an NVIDIA GPU). + if(LEONIDA_AFTERMATH_SDK AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) + set(_aftermath_spv ${CMAKE_CURRENT_BINARY_DIR}/generated/aftermath_fault.comp.spv) + add_custom_command(OUTPUT ${_aftermath_spv} + COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.3 -o ${_aftermath_spv} + ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/aftermath_fault.comp + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/aftermath_fault.comp COMMENT "Compiling aftermath_fault.comp" VERBATIM) + add_executable(vk_aftermath_test test/vk_aftermath_test.cpp ${_aftermath_spv}) + target_link_libraries(vk_aftermath_test PRIVATE gta6rt_aftermath) + target_compile_definitions(vk_aftermath_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS + LEONIDA_AFTERMATH_FAULT_SPV="${_aftermath_spv}") + target_compile_options(vk_aftermath_test PRIVATE /W4 /permissive- /utf-8) + add_test(NAME vk_aftermath COMMAND vk_aftermath_test) + set_tests_properties(vk_aftermath PROPERTIES SKIP_RETURN_CODE 77) + endif() + add_executable(d3d12_com_test test/d3d12_com_test.cpp) target_link_libraries(d3d12_com_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(d3d12_com_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) target_compile_options(d3d12_com_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_com COMMAND d3d12_com_test) + foreach(_policy IN ITEMS off unset raw uppercase off-with-suffix) + add_test(NAME d3d12_indirect_policy_${_policy} COMMAND d3d12_com_test --indirect-policy ${_policy}) + endforeach() set_tests_properties(d3d12_com PROPERTIES SKIP_RETURN_CODE 77) # Where the device finds its translated shaders (shader_path.txt, a path that is not UTF-8). No GPU. @@ -2303,7 +2417,7 @@ if(TARGET Vulkan::Headers) # XDXR acceleration structures through BuildRaytracingAccelerationStructure (docs/d3d12_vulkan.md 4.8): the # device builds them, tools/xdxr_bvh.py checks them. - add_executable(d3d12_xdxr_rt_test test/d3d12_xdxr_rt_test.cpp) + add_executable(d3d12_xdxr_rt_test test/d3d12_xdxr_rt_test.cpp test/xmem_geometry_aliases_stub.cpp) target_link_libraries(d3d12_xdxr_rt_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(d3d12_xdxr_rt_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) target_compile_options(d3d12_xdxr_rt_test PRIVATE /W4 /permissive- /utf-8) @@ -2374,7 +2488,7 @@ if(TARGET Vulkan::Headers) FAIL_REGULAR_EXPRESSION "Validation Error;VUID-") # DXR acceleration-structure prebuild and command-list recording validation parity test. - add_executable(d3d12_dxr_validation_test test/d3d12_dxr_validation_test.cpp) + add_executable(d3d12_dxr_validation_test test/d3d12_dxr_validation_test.cpp test/xmem_geometry_aliases_stub.cpp) target_link_libraries(d3d12_dxr_validation_test PRIVATE gta6rt_d3d12_com d3d12 dxgi) target_compile_definitions(d3d12_dxr_validation_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) target_compile_options(d3d12_dxr_validation_test PRIVATE /W4 /permissive- /utf-8) @@ -2679,6 +2793,9 @@ if(TARGET Vulkan::Headers) LEONIDA_TEST_INDIRECT_COUNT_SPV="${_indirect_count_spv}") target_compile_options(d3d12_indirect_dispatch_count_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_indirect_dispatch_count COMMAND d3d12_indirect_dispatch_count_test) + add_test(NAME d3d12_indirect_group_budget COMMAND d3d12_indirect_dispatch_count_test --clamp) + set_tests_properties(d3d12_indirect_group_budget PROPERTIES SKIP_RETURN_CODE 77 + ENVIRONMENT "LEONIDA_INDIRECT_GROUP_BUDGET=2") set_tests_properties(d3d12_indirect_dispatch_count PROPERTIES SKIP_RETURN_CODE 77) endif() @@ -3312,6 +3429,14 @@ if(TARGET Vulkan::Headers) target_compile_options(d3d12_console_descriptor_heap_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_console_descriptor_heap COMMAND d3d12_console_descriptor_heap_test) set_tests_properties(d3d12_console_descriptor_heap PROPERTIES SKIP_RETURN_CODE 77) + # Buffer descriptors naming memory nothing backs are written zero-size (created views, inline table V#s, console + # heap copies), and resource heaps are followed by null slots. + add_executable(d3d12_unmapped_vsharp_test test/d3d12_unmapped_vsharp_test.cpp shims/d3d12_xs_device.cpp) + target_link_libraries(d3d12_unmapped_vsharp_test PRIVATE gta6rt_d3d12_com d3d12 dxgi) + target_compile_definitions(d3d12_unmapped_vsharp_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX LEONIDA_VULKAN_DEVICE) + target_compile_options(d3d12_unmapped_vsharp_test PRIVATE /W4 /permissive- /utf-8) + add_test(NAME d3d12_unmapped_vsharp COMMAND d3d12_unmapped_vsharp_test) + set_tests_properties(d3d12_unmapped_vsharp PROPERTIES SKIP_RETURN_CODE 77 ENVIRONMENT "LEONIDA_CONSOLE_FIX_US=0") add_executable(d3d12_indirect_zero_test test/d3d12_indirect_zero_test.cpp) target_link_libraries(d3d12_indirect_zero_test PRIVATE gta6rt_d3d12_com d3d12 dxgi) target_compile_definitions(d3d12_indirect_zero_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) @@ -3455,13 +3580,24 @@ if(TARGET Vulkan::Headers) target_compile_options(d3d12_compute_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_compute COMMAND d3d12_compute_test) set_tests_properties(d3d12_compute PROPERTIES SKIP_RETURN_CODE 77) + # Device teardown with background pipeline builds queued or running: dropped, waited for, the worker joined. + add_executable(d3d12_compile_teardown_test test/d3d12_compile_teardown_test.cpp shims/d3d12_xs_device.cpp shims/d3d12_xs_pso_stream.cpp ${LEONIDA_TEST_CS}) + target_link_libraries(d3d12_compile_teardown_test PRIVATE gta6rt_d3d12_com) + target_compile_definitions(d3d12_compile_teardown_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX + LEONIDA_TEST_CS_SPV="${LEONIDA_TEST_CS}") + target_compile_options(d3d12_compile_teardown_test PRIVATE /W4 /permissive- /utf-8) + add_test(NAME d3d12_compile_teardown COMMAND d3d12_compile_teardown_test) + set_tests_properties(d3d12_compile_teardown PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 300) # A buffer at the title's own VA (device slot 133) read by the same shader through a root view and a V#. - add_executable(d3d12_title_va_test test/d3d12_title_va_test.cpp shims/d3d12_xs_device.cpp ${LEONIDA_TEST_CS}) + add_executable(d3d12_title_va_test test/d3d12_title_va_test.cpp shims/d3d12_xs_device.cpp + test/xmem_geometry_aliases_stub.cpp ${LEONIDA_TEST_CS}) target_link_libraries(d3d12_title_va_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(d3d12_title_va_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX LEONIDA_TEST_CS_SPV="${LEONIDA_TEST_CS}") target_compile_options(d3d12_title_va_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_title_va COMMAND d3d12_title_va_test) + add_test(NAME d3d12_title_va_shadow COMMAND d3d12_title_va_test) + set_tests_properties(d3d12_title_va_shadow PROPERTIES ENVIRONMENT "LEONIDA_TEST_CONSOLE_SHADOW=1;LEONIDA_GEOMETRY_MB=0" SKIP_RETURN_CODE 77) add_test(NAME d3d12_geometry_views COMMAND d3d12_title_va_test) set_tests_properties(d3d12_geometry_views PROPERTIES ENVIRONMENT "LEONIDA_GEOMETRY_MB=16" SKIP_RETURN_CODE 77) set_tests_properties(d3d12_title_va PROPERTIES SKIP_RETURN_CODE 77) @@ -3503,7 +3639,8 @@ if(TARGET Vulkan::Headers) COMMENT "Compiling the draw test shader ${source}" VERBATIM) endforeach() - add_executable(d3d12_draw_test test/d3d12_draw_test.cpp shims/d3d12_xs_device.cpp shims/d3d12_xs_pso_stream.cpp ${LEONIDA_TEST_VS} + add_executable(d3d12_draw_test test/d3d12_draw_test.cpp test/d3d12_stateful_indirect_pixels.cpp + shims/d3d12_xs_device.cpp shims/d3d12_xs_pso_stream.cpp ${LEONIDA_TEST_VS} ${LEONIDA_TEST_PS} ${LEONIDA_TEST_PS_UINT} ${LEONIDA_TEST_VS_FULLSCREEN} ${LEONIDA_TEST_VS_INT}) target_link_libraries(d3d12_draw_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(d3d12_draw_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX @@ -3515,6 +3652,16 @@ if(TARGET Vulkan::Headers) add_test(NAME d3d12_draw COMMAND d3d12_draw_test) add_test(NAME xbox_geometry_upload_batch COMMAND d3d12_draw_test) set_tests_properties(xbox_geometry_upload_batch PROPERTIES ENVIRONMENT "LEONIDA_TEST_GEOMETRY_BATCH=1" SKIP_RETURN_CODE 77 TIMEOUT 40) + add_test(NAME d3d12_stateful_indirect_pixels COMMAND d3d12_draw_test --stateful-indirect-pixels) + add_test(NAME d3d12_stateful_indirect_multi_pixels COMMAND d3d12_draw_test --stateful-indirect-multi-pixels) + add_test(NAME d3d12_stateful_indirect_counted_pixels COMMAND d3d12_draw_test --stateful-indirect-counted-pixels) + # A device without robust indexed views can still validate each ordinary DRAW pixel oracle. + add_test(NAME d3d12_stateful_indirect_nonindexed_pixels COMMAND d3d12_draw_test --stateful-indirect-pixels --nonindexed-only) + add_test(NAME d3d12_stateful_indirect_nonindexed_multi_pixels COMMAND d3d12_draw_test --stateful-indirect-multi-pixels --nonindexed-only) + add_test(NAME d3d12_stateful_indirect_nonindexed_counted_pixels COMMAND d3d12_draw_test --stateful-indirect-counted-pixels --nonindexed-only) + set_tests_properties(d3d12_stateful_indirect_pixels d3d12_stateful_indirect_multi_pixels d3d12_stateful_indirect_counted_pixels + d3d12_stateful_indirect_nonindexed_pixels d3d12_stateful_indirect_nonindexed_multi_pixels + d3d12_stateful_indirect_nonindexed_counted_pixels PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 60) add_test(NAME d3d12_title_index_window COMMAND d3d12_draw_test --title-index-window) add_test(NAME d3d12_title_vertex_window COMMAND d3d12_draw_test --title-vertex-window) # LEONIDA_STUB_PIPELINES: a pipeline with no translated shader is a no-op stub when the switch is on. @@ -3536,11 +3683,11 @@ if(TARGET Vulkan::Headers) LEONIDA_TEST_CS_SPV="${LEONIDA_TEST_CS}") target_compile_options(d3d12_pso_validation_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_pso_validation COMMAND d3d12_pso_validation_test) - # LEONIDA_COMPUTE_WARMUP=0: the warm-up thread of lazy compute pipelines (9d15c13a0) may still be building one - # when this test releases its device and exits, and the process then dies after its PASS line (exit 3 under - # Wine). The race is the warm-up thread's, not the validation's; see MERGE-NOTES. + # Runs with the compute warm-up thread on: it used to outlive the device this test releases (the process died + # after its PASS line); a released device now drops or waits for its builds and joins + # the thread (d3d12_compile_teardown_test). set_tests_properties(d3d12_pso_validation PROPERTIES SKIP_RETURN_CODE 77 - FAIL_REGULAR_EXPRESSION "Validation Error;VUID-" ENVIRONMENT "LEONIDA_COMPUTE_WARMUP=0") + FAIL_REGULAR_EXPRESSION "Validation Error;VUID-") # Conservative raster Tier 1, with geometric coverage bounds and host D3D12 references. set(LEONIDA_CONSERVATIVE_VS ${CMAKE_CURRENT_BINARY_DIR}/generated/vs_conservative.spv) set(LEONIDA_CONSERVATIVE_PS ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_conservative.spv) @@ -3615,29 +3762,44 @@ if(TARGET Vulkan::Headers) target_compile_options(d3d12_geometry_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_geometry COMMAND d3d12_geometry_test) set_tests_properties(d3d12_geometry PROPERTIES SKIP_RETURN_CODE 77) - # Directly indexed heaps for draws: the VS and PS read the heap dwords after the explicit root arguments. + # Directly indexed heaps for draws: the VS, PS and mesh stage read the heap dwords after the explicit root + # arguments. The mesh shader needs Vulkan 1.2 (SPIR-V 1.5), as the translator targets: 1.3 emits LocalSizeId. set(LEONIDA_TEST_VS_USER_DATA_WINDOW ${CMAKE_CURRENT_BINARY_DIR}/generated/vs_user_data_window.spv) set(LEONIDA_TEST_PS_USER_DATA_WINDOW ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_user_data_window.spv) - foreach(pair "vs_user_data_window.vert;${LEONIDA_TEST_VS_USER_DATA_WINDOW}" - "ps_user_data_window.frag;${LEONIDA_TEST_PS_USER_DATA_WINDOW}") + set(LEONIDA_TEST_PS_INDIRECT_HEAP ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_indirect_heap_resource.spv) + set(LEONIDA_TEST_MS_USER_DATA_WINDOW ${CMAKE_CURRENT_BINARY_DIR}/generated/ms_user_data_window.spv) + set(LEONIDA_TEST_PS_MESH_USER_DATA_WINDOW ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_mesh_user_data_window.spv) + foreach(pair "ps_indirect_heap_resource.frag;${LEONIDA_TEST_PS_INDIRECT_HEAP};vulkan1.3" + "vs_user_data_window.vert;${LEONIDA_TEST_VS_USER_DATA_WINDOW};vulkan1.3" + "ps_user_data_window.frag;${LEONIDA_TEST_PS_USER_DATA_WINDOW};vulkan1.3" + "ms_user_data_window.mesh;${LEONIDA_TEST_MS_USER_DATA_WINDOW};vulkan1.2" + "ps_mesh_user_data_window.frag;${LEONIDA_TEST_PS_MESH_USER_DATA_WINDOW};vulkan1.3") list(GET pair 0 source) list(GET pair 1 output) + list(GET pair 2 target_env) add_custom_command( OUTPUT ${output} - COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.3 -o ${output} + COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env ${target_env} -o ${output} ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/${source} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/${source} COMMENT "Compiling the direct heaps test shader ${source}" VERBATIM) endforeach() add_executable(d3d12_graphics_direct_heaps_test test/d3d12_graphics_direct_heaps_test.cpp - shims/d3d12_xs_device.cpp ${LEONIDA_TEST_VS_USER_DATA_WINDOW} ${LEONIDA_TEST_PS_USER_DATA_WINDOW}) + shims/d3d12_xs_device.cpp ${LEONIDA_TEST_VS_USER_DATA_WINDOW} ${LEONIDA_TEST_PS_USER_DATA_WINDOW} + ${LEONIDA_TEST_MS_USER_DATA_WINDOW} ${LEONIDA_TEST_PS_MESH_USER_DATA_WINDOW} + ${LEONIDA_TEST_PS_INDIRECT_HEAP}) target_link_libraries(d3d12_graphics_direct_heaps_test PRIVATE gta6rt_d3d12_com) target_compile_definitions(d3d12_graphics_direct_heaps_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX LEONIDA_TEST_VS_SPV="${LEONIDA_TEST_VS_USER_DATA_WINDOW}" - LEONIDA_TEST_PS_SPV="${LEONIDA_TEST_PS_USER_DATA_WINDOW}") + LEONIDA_TEST_PS_SPV="${LEONIDA_TEST_PS_USER_DATA_WINDOW}" + LEONIDA_TEST_MS_SPV="${LEONIDA_TEST_MS_USER_DATA_WINDOW}" + LEONIDA_TEST_PS_MESH_SPV="${LEONIDA_TEST_PS_MESH_USER_DATA_WINDOW}" + LEONIDA_TEST_PS_INDIRECT_HEAP="${LEONIDA_TEST_PS_INDIRECT_HEAP}") target_compile_options(d3d12_graphics_direct_heaps_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_graphics_direct_heaps COMMAND d3d12_graphics_direct_heaps_test) + add_test(NAME d3d12_graphics_indirect_heap_resources COMMAND d3d12_graphics_direct_heaps_test --indirect-resources) + set_tests_properties(d3d12_graphics_indirect_heap_resources PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 60) add_test(NAME d3d12_graphics_direct_heaps_off COMMAND d3d12_graphics_direct_heaps_test --off) set_tests_properties(d3d12_graphics_direct_heaps d3d12_graphics_direct_heaps_off PROPERTIES SKIP_RETURN_CODE 77) set_tests_properties(d3d12_graphics_direct_heaps_off PROPERTIES ENVIRONMENT LEONIDA_GRAPHICS_DIRECT_HEAPS=0) @@ -3737,6 +3899,11 @@ if(TARGET Vulkan::Headers) LEONIDA_TEST_VS_SPV="${LEONIDA_TEST_VS}" LEONIDA_TEST_PS_SPV="${LEONIDA_TEST_PS}") target_compile_options(d3d12_bundle_test PRIVATE /W4 /permissive- /utf-8) add_test(NAME d3d12_bundle COMMAND d3d12_bundle_test) + add_test(NAME d3d12_bundle_indirect_warp COMMAND d3d12_bundle_test --indirect-bundle-warp) + add_test(NAME d3d12_bundle_indirect_layer COMMAND d3d12_bundle_test --indirect-bundle-layer) + add_test(NAME d3d12_bundle_indirect_off COMMAND d3d12_bundle_test --indirect-bundle-off) + set_tests_properties(d3d12_bundle_indirect_warp d3d12_bundle_indirect_layer d3d12_bundle_indirect_off + PROPERTIES SKIP_RETURN_CODE 77) set_tests_properties(d3d12_bundle PROPERTIES SKIP_RETURN_CODE 77) add_test(NAME d3d12_root_layout_compact COMMAND d3d12_bundle_test --compact) add_test(NAME d3d12_root_layout_legacy COMMAND d3d12_bundle_test --legacy) @@ -4093,6 +4260,7 @@ if(TARGET Vulkan::Headers) target_compile_definitions(d3d12_state_map_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) endif() add_test(NAME d3d12_state_map COMMAND d3d12_state_map_test) + add_test(NAME d3d12_bounded_index_view COMMAND d3d12_state_map_test --bounded-index-view) add_executable(vulkan_title_image_pool_test test/vulkan_title_image_pool_test.cpp) target_link_libraries(vulkan_title_image_pool_test PRIVATE Vulkan::Headers) if(WIN32) @@ -4157,6 +4325,13 @@ if(TARGET Vulkan::Headers) add_executable(arena_size_test test/arena_size_test.cpp) target_link_libraries(arena_size_test PRIVATE Vulkan::Headers) add_test(NAME arena_size COMMAND arena_size_test) + # The GPU address arena's free-block map: first fit, coalescing, and a walk a nested call re-cuts on the same + # thread (src/arena_blocks.h). + add_executable(arena_blocks_test test/arena_blocks_test.cpp) + if(WIN32 AND MSVC) + target_compile_options(arena_blocks_test PRIVATE /W4 /permissive- /utf-8) + endif() + add_test(NAME arena_blocks COMMAND arena_blocks_test) # Queue construction cleans its Vulkan handles if holder registration runs out of host memory. add_executable(vk_host_texture_order_test test/vk_host_texture_order_test.cpp) target_link_libraries(vk_host_texture_order_test PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS}) @@ -4187,6 +4362,20 @@ if(TARGET Vulkan::Headers) # Title-placed buffer VAs (device slot 133) and the console VA shaders reach them by (src/title_va_alias.h). add_executable(title_va_alias_test test/title_va_alias_test.cpp) add_test(NAME title_va_alias COMMAND title_va_alias_test) + if(WIN32) + # A refused title window never hands a shader a raw address, and a stream pool's GPU-only alias and CPU view + # share one mapping (src/title_window_plan.h, src/title_page_watch.h title_gpu_views). + add_executable(title_window_plan_test test/title_window_plan_test.cpp) + target_compile_definitions(title_window_plan_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + target_compile_options(title_window_plan_test PRIVATE /W4 /permissive- /utf-8) + add_test(NAME title_window_plan COMMAND title_window_plan_test) + # Geometry copies refreshed by the 64 KiB tiles the title wrote (shims/d3d12_geometry_views.h). + add_executable(geometry_views_test test/geometry_views_test.cpp) + target_link_libraries(geometry_views_test PRIVATE Vulkan::Headers) + target_compile_definitions(geometry_views_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) + target_compile_options(geometry_views_test PRIVATE /W4 /permissive- /EHsc /utf-8) + add_test(NAME geometry_views COMMAND geometry_views_test) + endif() endif() else() include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/vulkan_headers_missing.cmake") diff --git a/runtime/README.md b/runtime/README.md index aa9b2d3081..9f353f72f0 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -269,7 +269,11 @@ Current limits, by design: depth views, committed resources and copies (uploads, readbacks, BC textures), root signatures, graphics and compute pipeline states, draws, dispatches and `ExecuteIndirect`; see `docs/d3d12_vulkan.md` for what is missing. `LEONIDA_DEVICE_FAULT=1` enables a stderr report with supported Vulkan fault information and queue - checkpoints on the first observed device loss. + checkpoints on the first observed device loss. On NVIDIA, a build configured with + `-DLEONIDA_AFTERMATH_SDK=` also takes `LEONIDA_AFTERMATH=1`: GPU crash dumps + (`.nv-gpudmp`, plus `.nvdbg` shader debug info) in `LEONIDA_AFTERMATH_DIR`, and a decoded summary on stderr that + names the faulting shader by its library name, the page fault and the active shaders (`src/vulkan_aftermath.h`). + The SDK is not part of the repository; its DLL is loaded at run time (`LEONIDA_AFTERMATH_DLL` overrides the path). - `dstorage_xs.dll` / `xcrdapi.dll` / `dstorage.dll` — `DStorageGetFactory`: the console DirectStorage API (`shims/dstorage.cpp`, declarations in `shims/dstorage_xs_abi.h`). Files open through the `GAME:` mapping and the diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index 883cce32a1..6dee464a8f 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp @@ -4,10 +4,13 @@ #include "d3d12_stubs.h" // generated #include "d3d12_com_object.h" #include "d3d12_fence_waiter.h" +#include "d3d12_feature_compat.h" +#include "d3d12_indirect_draw_policy.h" #include "d3d12_trace.h" #include "d3d12_xs_device.h" #include "../src/gfx10_descriptors.h" #include "../src/title_va_alias.h" +#include "../src/title_page_watch.h" // title_gpu_views::to_host_view #include "../src/fsdraw_probe.h" // LOCAL DIAGNOSTIC #include "../src/local_diagnostics.h" @@ -144,15 +147,26 @@ class CommandSignature final // {9a4e1c2b-55d8-4f7a-b012-3c8e7a1f6d90} static constexpr GUID kTag{0x9a4e1c2b, 0x55d8, 0x4f7a, {0xb0, 0x12, 0x3c, 0x8e, 0x7a, 0x1f, 0x6d, 0x90}}; - CommandSignature(leonida::IndirectKind kind, UINT byte_stride) : kind_(kind), stride_(byte_stride) {} + CommandSignature(leonida::IndirectKind kind, UINT byte_stride, UINT packed_size, + std::span prefix) + : kind_(kind), stride_(byte_stride), packed_size_(packed_size), terminal_only_(prefix.empty()) { + // The caller may free the description immediately. Single-operation signatures allocate nothing. + if (!prefix.empty() && (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed)) + graphics_writes_.assign(prefix.begin(), prefix.end()); + } leonida::IndirectKind kind() const { return kind_; } UINT stride() const { return stride_; } + UINT packed_size() const { return packed_size_; } + bool terminal_only() const { return terminal_only_; } + const auto& graphics_writes() const { return graphics_writes_; } static CommandSignature* from(IUnknown* object) { return Child::from(object); } private: leonida::IndirectKind kind_; - UINT stride_; + UINT stride_, packed_size_; + bool terminal_only_; // no root, vertex, or index updates before the terminal operation + std::vector graphics_writes_; }; class CommandAllocator final @@ -552,6 +566,7 @@ class GraphicsCommandList final if (!any_nonempty_viewport()) return; // as record_draw: nothing is rasterized leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, {}, 0, viewport_, scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0}; + note_direct_heap_indexing(graphics_.layout); draw.mesh = true; draw.viewports = draw_viewports(); check(list_.draw(std::move(draw))); @@ -954,11 +969,16 @@ class GraphicsCommandList final void STDMETHODCALLTYPE ExecuteIndirect(ID3D12CommandSignature* signature, UINT max_command_count, ID3D12Resource* argument_buffer, UINT64 argument_buffer_offset, ID3D12Resource* count_buffer, UINT64 count_buffer_offset) override { - if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); - leonida::IndirectKind kind = leonida::IndirectKind::draw; - UINT stride = 0; - if (!command_signature_info(signature, kind, stride) || !argument_buffer) + if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT && type_ != D3D12_COMMAND_LIST_TYPE_COMPUTE && + type_ != D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); + const auto* sig = CommandSignature::from(signature); + if (!sig || !argument_buffer) return check(false); + const auto kind = sig->kind(); + const UINT stride = sig->stride(); + const bool terminal_only = sig->terminal_only(); + if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE && (count_buffer || !terminal_only)) + return check(false); // only a fixed count and one operation are legal in a bundle const auto arg_desc = argument_buffer->GetDesc(); if (arg_desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || argument_buffer_offset % 4 != 0) return check(false); @@ -991,29 +1011,33 @@ class GraphicsCommandList final if (argument_buffer_offset > arg_desc.Width || arg_desc.Width - argument_buffer_offset < required) return check(false); } + if (!leonida::indirect_records_fit(arg_desc.Width, argument_buffer_offset, max_command_count, + stride, sig->packed_size())) + return check(false); if (kind == leonida::IndirectKind::dispatch_mesh) { // Not replayed yet (#3777 replays it as vkCmdDrawMeshTasksIndirectEXT): nothing is recorded, and the // first such call says so. The list stays valid. - static std::atomic logged{false}; - if (!logged.exchange(true, std::memory_order_relaxed)) - std::fprintf(stderr, "[rt] d3d12: ExecuteIndirect with a DISPATCH_MESH signature is not replayed yet; " - "nothing was recorded\n"); + leonida::indirect_stats::skip(leonida::indirect_stats::Event::record_skip, leonida::indirect_stats::mesh); return; } - leonida::ExecuteIndirect cmd{}; - cmd.kind = kind; - cmd.stride = stride; - cmd.max_count = max_command_count; - cmd.argument_buffer = resource_id(argument_buffer); - cmd.argument_offset = argument_buffer_offset; - cmd.count_buffer = count_buffer ? resource_id(count_buffer) : 0; - cmd.count_offset = count_buffer ? count_buffer_offset : 0; - if (kind == leonida::IndirectKind::dispatch && max_command_count) { // the pipeline and root arguments a Dispatch would record - if (!compute_pipeline_ || !compute_.layout) return check(false); - cmd.pipeline = compute_pipeline_; - cmd.user_data = compute_user_data(); + if (!terminal_only && (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed)) { + if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); + // Compound draw emission is not yet supported. Reset the written bindings even if no + // records execute. Bundle nesting and prefixes were already rejected above for bundles. + leonida::indirect_stats::skip(leonida::indirect_stats::Event::record_skip, leonida::indirect_stats::compound); + if (!list_.closed()) reset_indirect_graphics_bindings(sig->graphics_writes()); + return; } - check(list_.execute_indirect(cmd)); + const leonida::IndirectDrawArgs args{resource_id(argument_buffer), argument_buffer_offset, stride, + max_command_count, count_buffer ? resource_id(count_buffer) : 0, + count_buffer_offset}; + // Preserve call position, not the bundle's incomplete draw state. No COM pointer is dereferenced + // later: the signature is decoded now, and the app owns resource lifetimes through GPU completion. + if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) { + defer([kind, args](GraphicsCommandList& parent) { parent.record_indirect(kind, true, args); }, true); + return; + } + record_indirect(kind, terminal_only, args); } void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure( @@ -1086,6 +1110,14 @@ class GraphicsCommandList final } } const std::uint64_t built = cmd.dst_va; + // The D3D12 rules (alignment, a source for an update) on the addresses as the title gave them. + if (!cmd.dst_va || cmd.dst_va % 256 || !cmd.scratch_va || cmd.scratch_va % 256 || + (cmd.update && (!cmd.src_va || cmd.src_va % 256))) + return check(false); + // The addresses the builder reaches the memory by. One with no GPU copy (logged by the device) leaves the + // build out, with its postbuild values: the list stays valid, nothing is written through heap_base + a title + // address, and the destination keeps what it had. + if (!resolve_acceleration_structure_build(attached_device(), cmd)) return; const bool recorded = list_.build_acceleration_structure(std::move(cmd)); check(recorded); if (!recorded) return; @@ -1095,6 +1127,8 @@ class GraphicsCommandList final info.dest_va = postbuild[i].DestBuffer; info.type = static_cast(postbuild[i].InfoType); info.sources = {built}; + if (!info.dest_va || info.dest_va % 8) return check(false); + if (!resolve_acceleration_structure_postbuild(attached_device(), info)) continue; const bool ok = list_.acceleration_structure_postbuild(std::move(info)); check(ok); if (!ok) return; @@ -1110,6 +1144,10 @@ class GraphicsCommandList final info.dest_va = desc->DestBuffer; info.type = static_cast(desc->InfoType); info.sources.assign(sources, sources + count); + if (!info.dest_va || info.dest_va % 8) return check(false); + for (const auto va : info.sources) + if (!va || va % 256) return check(false); + if (!resolve_acceleration_structure_postbuild(attached_device(), info)) return; // logged; left out check(list_.acceleration_structure_postbuild(std::move(info))); } @@ -1118,7 +1156,10 @@ class GraphicsCommandList final D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode) override { if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false); if (!valid_copy_mode(mode)) return check(false); - check(list_.copy_acceleration_structure({dest, source, static_cast(mode)})); + leonida::CopyAccelerationStructure copy{dest, source, static_cast(mode)}; + if (!copy.dst_va || !copy.src_va || copy.dst_va % 256 || copy.src_va % 256) return check(false); + if (!resolve_acceleration_structure_copy(attached_device(), copy)) return; // logged; left out + check(list_.copy_acceleration_structure(copy)); } bool xbox_label(const leonida::label::Write& op) { return list_.write_gpu_label(op); } @@ -1486,16 +1527,16 @@ class GraphicsCommandList final // copy of it, so the shader's heap_base + VA reaches it (src/title_va_alias.h). A descriptor table is in one // of the layer's heaps: kept, and its buffer V#s are rewritten the same way before each submission. // A table in a console descriptor heap is read from the heap's arena copy (console_descriptor_table_va). - if (type == rt::rootsig::ParamType::Descriptor) + if (type == rt::rootsig::ParamType::Descriptor) { + const std::uint64_t raw = va; va = leonida::title_va_aliases().resolve(va, kRootViewBytes, leonida::TitleVaAliases::root_view); - else + // No copy for the title's memory: the root view is 0, so the shader reads the arena's zero page instead + // of storing at heap_base + a raw title address. + if (!va && raw) leonida::note_unbacked_view("root view", raw, kRootViewBytes); + } else va = console_descriptor_table_va(va); - if (type != rt::rootsig::ParamType::Descriptor && va && p->table_descriptors) { - if (!tables_.empty() && tables_.back().first == va) - tables_.back().second = std::max(tables_.back().second, p->table_descriptors); - else - tables_.emplace_back(va, p->table_descriptors); - } + if (type != rt::rootsig::ParamType::Descriptor && va && p->table_descriptors) + remember_table(va, p->table_descriptors); const std::uint32_t first = first_dword(state, *p); if (first == rt::rootsig::kNoSgpr) return spilled(); write(state, first, std::uint32_t(va)); @@ -1613,13 +1654,22 @@ class GraphicsCommandList final if ((cbv && cbv != cbv_srv_uav_heap_) || (smp && smp != sampler_heap_)) check(false); } - void note_direct_heap_indexing(const RootArgumentLayout* layout) const { + void remember_table(uint64_t base, uint32_t slots) { + if (!tables_.empty() && tables_.back().first == base) + tables_.back().second = std::max(tables_.back().second, slots); + else + tables_.emplace_back(base, slots); + } + + void note_direct_heap_indexing(const RootArgumentLayout* layout) { if (!layout) return; if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) { if (!cbv_srv_uav_heap_) note_once("draw/dispatch uses CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED with no CBV/SRV/UAV heap bound"); - else + else { + remember_table(cbv_srv_uav_base_, cbv_srv_uav_heap_->GetDesc().NumDescriptors); note_once("CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED heap base tracked on list"); + } } if (layout->flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) { if (!sampler_heap_) @@ -1656,21 +1706,61 @@ class GraphicsCommandList final set_pipeline(state); } + void reset_indirect_graphics_bindings(std::span writes) { + static constexpr std::array zeros{}; + for (const auto& arg : writes) { + switch (arg.Type) { + case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW: + if (arg.VertexBuffer.Slot >= vertex_buffers_.size()) return check(false); + set_vertex_buffers(arg.VertexBuffer.Slot, 1, nullptr); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW: set_index_buffer(nullptr); break; + case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: + if (arg.Constant.Num32BitValuesToSet > zeros.size()) return check(false); + constants(graphics_, arg.Constant.RootParameterIndex, arg.Constant.Num32BitValuesToSet, + zeros.data(), arg.Constant.DestOffsetIn32BitValues); + break; + case compat::kIndirectArgumentIncrementingConstant: + // The two leading UINTs have the same ABI on SDKs predating IncrementingConstant. + constants(graphics_, arg.Constant.RootParameterIndex, 1, zeros.data(), arg.Constant.DestOffsetIn32BitValues); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW: + address(graphics_, arg.ConstantBufferView.RootParameterIndex, 0, rt::rootsig::ParamType::Descriptor); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW: + address(graphics_, arg.ShaderResourceView.RootParameterIndex, 0, rt::rootsig::ParamType::Descriptor); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW: + address(graphics_, arg.UnorderedAccessView.RootParameterIndex, 0, rt::rootsig::ParamType::Descriptor); + break; + default: return check(false); // signature creation excludes other non-terminal arguments + } + } + } + void set_vertex_buffers(UINT start, UINT count, const D3D12_VERTEX_BUFFER_VIEW* views) { if (count) draw_views_stale_ = true; for (UINT i = 0; i < count; ++i) { - if (views) leonida::title_va_aliases().note(views[i].BufferLocation, leonida::TitleVaAliases::vertex_view); - if (views) leonida::title_va_aliases().want_buffer(views[i].BufferLocation, views[i].SizeInBytes); - vertex_buffers_[start + i] = views ? leonida::VertexBufferView{views[i].BufferLocation, views[i].SizeInBytes, + // A stream pool's GPU-only alias becomes the CPU view of the same pages (rule B, gfxgeom section 6): the + // buffer made for it, and every other view naming that range, then use one host-readable address. + const std::uint64_t va = views + ? leonida::title_gpu_views::to_host_view(views[i].BufferLocation, + views[i].SizeInBytes) + : 0; + if (views) leonida::title_va_aliases().note(va, leonida::TitleVaAliases::vertex_view); + if (views) leonida::title_va_aliases().want_buffer(va, views[i].SizeInBytes); + vertex_buffers_[start + i] = views ? leonida::VertexBufferView{va, views[i].SizeInBytes, views[i].StrideInBytes} : leonida::VertexBufferView{}; } } void set_index_buffer(const D3D12_INDEX_BUFFER_VIEW* view) { - if (view) leonida::title_va_aliases().note(view->BufferLocation, leonida::TitleVaAliases::index_view); - if (view) leonida::title_va_aliases().want_buffer(view->BufferLocation, view->SizeInBytes); - index_ = view ? leonida::IndexBufferView{view->BufferLocation, view->SizeInBytes, u(view->Format)} + const std::uint64_t va = + view ? leonida::title_gpu_views::to_host_view(view->BufferLocation, view->SizeInBytes) : 0; + if (view) leonida::title_va_aliases().note(va, leonida::TitleVaAliases::index_view); + if (view) leonida::title_va_aliases().want_buffer(va, view->SizeInBytes); + index_ = view ? leonida::IndexBufferView{va, view->SizeInBytes, u(view->Format)} : leonida::IndexBufferView{}; } @@ -1678,14 +1768,19 @@ class GraphicsCommandList final // 32-bit shader VA, then the sampler heap's, each only when the signature has its flag. `slot` is the first // dword after the arguments (RootArgumentLayout::*_arguments_end). The heaps are snapshotted for each command, // so rebinding a heap cannot change a recorded draw or dispatch. - std::array with_direct_heaps(const RootState& state, - std::uint32_t slot) const { - auto data = state.data; + void write_direct_heaps(const RootState& state, std::uint32_t slot, + std::array& data) const { const auto flags = state.layout->flags; if ((flags & D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED) && slot < data.size()) data[slot++] = static_cast(cbv_srv_uav_base_); if ((flags & D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED) && slot < data.size()) data[slot] = static_cast(sampler_base_); + } + + std::array with_direct_heaps(const RootState& state, + std::uint32_t slot) const { + auto data = state.data; + write_direct_heaps(state, slot, data); return data; } @@ -1697,7 +1792,7 @@ class GraphicsCommandList final // Direct and indirect dispatches. Putting the resource heap first and the sampler heap next is a hypothesis // with partial evidence (docs/d3d12_vulkan.md section 3.4, tools/compute_heap_layout_census.py). A heap with no // inline user-data dword left is reported once per heap kind and the explicit arguments are kept. - std::array compute_user_data() const { + std::array compute_user_data() { note_direct_heap_indexing(compute_.layout); static const bool enabled = direct_heaps_enabled("LEONIDA_COMPUTE_DIRECT_HEAPS"); if (!enabled) return compute_.data; @@ -1754,8 +1849,8 @@ class GraphicsCommandList final end + (resource ? 1u : 0u)); std::fprintf(stderr, "[rt] d3d12: graphics direct heaps: resource heap %s, sampler heap %s, after %u dwords of " - "explicit arguments from s8 (first draw; LEONIDA_GRAPHICS_DIRECT_HEAPS=0 restores the " - "old arguments)\n", + "explicit arguments from s8 (first draw; LEONIDA_GRAPHICS_DIRECT_HEAPS=0 " + "restores the old arguments)\n", resource_at, sampler_at, end - 8); } return with_direct_heaps(graphics_, end); @@ -1817,6 +1912,51 @@ class GraphicsCommandList final return draw_viewports_; } + void record_indirect(leonida::IndirectKind kind, bool terminal_only, const leonida::IndirectDrawArgs& args) { + if (kind == leonida::IndirectKind::draw || kind == leonida::IndirectKind::draw_indexed) { + if (type_ != D3D12_COMMAND_LIST_TYPE_DIRECT) return check(false); + // A valid zero-count call records nothing, even if graphics state has not been set. + if (!args.max_count) return; + // Both direct-list calls and deferred bundle calls reach this point after validation. + // Compound signatures already applied their root/IA postconditions in ExecuteIndirect. + if (indirect_draws_disabled()) { + leonida::indirect_stats::skip(leonida::indirect_stats::Event::record_skip, leonida::indirect_stats::disabled); + return check(!list_.closed()); + } + const bool indexed = kind == leonida::IndirectKind::draw_indexed; + // Only single-operation signatures inherit all graphics state. A padded stride alone cannot + // distinguish one of those from a signature with root or IA arguments before the DRAW. + namespace stats = leonida::indirect_stats; + const auto skip = [](stats::Reason reason) { stats::skip(stats::Event::record_skip, reason); }; + if (!terminal_only) return skip(stats::compound); + if (!graphics_pipeline_) return skip(stats::pipeline); + if (!graphics_.layout) return skip(stats::root_layout); + if (topology_ != D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST) return skip(stats::topology); + if (indexed && (!index_.va || !index_.size || + (index_.format != DXGI_FORMAT_R16_UINT && index_.format != DXGI_FORMAT_R32_UINT))) + return skip(stats::index_view); + if (!(viewport_.width > 0) || !(viewport_.height > 0)) return skip(stats::viewport); + note_direct_heap_indexing(graphics_.layout); + record_raster_draw(indexed, 0, 0, 0, 0, 0, &args); + return; + } + leonida::ExecuteIndirect cmd{}; + cmd.kind = kind; + cmd.stride = args.stride; + cmd.max_count = args.max_count; + cmd.argument_buffer = args.argument_buffer; + cmd.argument_offset = args.argument_offset; + cmd.count_buffer = args.count_buffer; + cmd.count_offset = args.count_offset; + if (kind == leonida::IndirectKind::dispatch && args.max_count) { // the pipeline and root arguments a Dispatch would record + if (!compute_pipeline_ || !compute_.layout) return check(false); + note_direct_heap_indexing(compute_.layout); + cmd.pipeline = compute_pipeline_; + cmd.user_data = compute_user_data(); + } + check(list_.execute_indirect(cmd)); + } + // A draw needs a graphics pipeline, a graphics root signature and a topology. void record_draw(bool indexed, UINT count, UINT instances, UINT first, INT base_vertex, UINT first_instance) { if (!graphics_pipeline_ || !graphics_.layout || !topology_) return check(false); @@ -1904,11 +2044,20 @@ class GraphicsCommandList final } } if (!any_nonempty_viewport()) return; + record_raster_draw(indexed, count, instances, first, base_vertex, first_instance); + } + + // The same bindings and dynamic state must be frozen at the call for both APIs. Only the source of the + // draw arguments differs: values here for a direct draw, or a GPU buffer read later at execution. + void record_raster_draw(bool indexed, UINT count, UINT instances, UINT first, INT base_vertex, UINT first_instance, + const leonida::IndirectDrawArgs* indirect = nullptr) { leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, index_, topology_, viewport_, scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances, first, base_vertex, first_instance}; draw.viewports = draw_viewports(); - check(list_.draw(std::move(draw))); + const bool recorded = indirect ? list_.draw_indirect(std::move(draw), *indirect) : list_.draw(std::move(draw)); + if (indirect && recorded) leonida::indirect_stats::note(leonida::indirect_stats::Event::recorded); + check(recorded); } }; @@ -2625,20 +2774,22 @@ bool queue_uses_calibrated_timestamps(ID3D12CommandQueue* queue) { return q && q->uses_calibrated_timestamps(); } -HRESULT create_command_signature(leonida::IndirectKind kind, UINT byte_stride, REFIID riid, void** out, - IUnknown* device) { +HRESULT create_command_signature(leonida::IndirectKind kind, UINT byte_stride, UINT packed_size, REFIID riid, void** out, + IUnknown* device, std::span prefix) { if (!out) return E_POINTER; *out = nullptr; - auto* sig = new CommandSignature(kind, byte_stride); + auto* sig = new CommandSignature(kind, byte_stride, packed_size, prefix); sig->attach_device(device); return hand_out(sig, riid, out); } -bool command_signature_info(ID3D12CommandSignature* signature, leonida::IndirectKind& kind, UINT& byte_stride) { +bool command_signature_info(ID3D12CommandSignature* signature, leonida::IndirectKind& kind, UINT& byte_stride, + bool& terminal_only) { const CommandSignature* s = CommandSignature::from(signature); if (!s) return false; kind = s->kind(); byte_stride = s->stride(); + terminal_only = s->terminal_only(); return true; } diff --git a/runtime/shims/d3d12_com.h b/runtime/shims/d3d12_com.h index 928d91a9a4..849791a262 100644 --- a/runtime/shims/d3d12_com.h +++ b/runtime/shims/d3d12_com.h @@ -60,9 +60,10 @@ HRESULT create_command_list(D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator void** out, IUnknown* device = nullptr, ID3D12PipelineState* initial_state = nullptr); HRESULT create_fence(leonida::VulkanContext& context, UINT64 initial_value, D3D12_FENCE_FLAGS flags, REFIID riid, void** out, IUnknown* device = nullptr); -HRESULT create_command_signature(leonida::IndirectKind kind, UINT byte_stride, REFIID riid, void** out, - IUnknown* device = nullptr); -bool command_signature_info(ID3D12CommandSignature* signature, leonida::IndirectKind& kind, UINT& byte_stride); +HRESULT create_command_signature(leonida::IndirectKind kind, UINT byte_stride, UINT packed_size, REFIID riid, void** out, + IUnknown* device, std::span prefix); +bool command_signature_info(ID3D12CommandSignature* signature, leonida::IndirectKind& kind, UINT& byte_stride, + bool& terminal_only); // ID3D12Device1::SetEventOnMultipleFenceCompletion on fences from create_fence: sets `event` once every fence // (D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL) or any fence (_ANY) has reached its value; a null event blocks until then. @@ -171,6 +172,10 @@ struct VulkanDeviceInfo { bool swapchain_colorspace = false; // VK_EXT_image_view_min_lod and its minLod feature are enabled on the logical device. bool image_view_min_lod = false; + // VK_EXT_robustness2 with nullDescriptor is enabled on `device`: set 0's storage-array fallbacks are null + // descriptors, so stores and atomics through a null UAV are dropped (src/vulkan_bindless.h). Without it they are + // 1x1 images of their own, apart from the sampled fallbacks the null SRVs read. + bool null_descriptor = false; // VK_KHR_vertex_attribute_divisor or VK_EXT_vertex_attribute_divisor with vertexAttributeInstanceRateDivisor. bool vertex_attribute_divisor = false; // Pixel-shader extensions translated shaders can declare, each enabled with its feature where the GPU has it: @@ -228,6 +233,13 @@ struct VulkanDeviceInfo { // minImportedHostPointerAlignment): OpenExistingHeapFromAddress backs a heap with the caller's own committed // memory. Zero: existing heaps stay unsupported. VkDeviceSize host_pointer_alignment = 0; + // Must describe the feature enabled on this logical device, not merely advertised by the GPU. + bool draw_indirect_first_instance = false; + bool multi_draw_indirect = false; + bool draw_indirect_count_enabled = false; + // Both VK_KHR_maintenance5 and robustBufferAccess2 (with core robustBufferAccess) are enabled. + bool robust_index_view = false; + std::uint32_t max_draw_indirect_count = 1; }; // A Vulkan-backed ID3D12Device (PC ABI, up to ID3D12Device11) on caller-owned Vulkan objects, which must outlive @@ -337,6 +349,9 @@ bool device_sparse_buffer_tiles(ID3D12Device* device); // The size in bytes of the device's GPU address arena, or 0 without one. For tests. std::uint64_t device_arena_size(ID3D12Device* device); +// Copies `bytes` of the device's GPU address arena at console VA `va` (what shaders read there: a heap's GPU copy, +// the null slots after it) into `out`. False without an arena or when the range is not inside it. For tests. +bool read_arena(ID3D12Device* device, std::uint64_t va, void* out, std::size_t bytes); // The blocks of device memory that textures share (src/image_memory.h): how many, their bytes, and the textures in // them. For tests. @@ -505,6 +520,8 @@ std::uintptr_t compute_pipeline_id(ID3D12PipelineState* pipeline); std::uintptr_t graphics_pipeline_id(ID3D12PipelineState* pipeline); // What each stage of a Vulkan device's PSO asked for (src/subgroup_size.h), in creation order; null for another PSO. const std::vector* pipeline_subgroup_requests(ID3D12PipelineState* pipeline); +// PSOs of any Vulkan device not yet deleted, counting one whose deletion waits for its running build (tests). +long live_pipeline_states(); // Unwraps an Xbox-ABI heap proxy if needed and inspects one of this module's descriptor heaps; returns its owning // device identity pointer, or nullptr when `heap` is null or belongs to another implementation. @@ -529,6 +546,16 @@ bool write_placed_texture_view(ID3D12Device* device, bool unordered, const std:: // lies elsewhere, the matching VA in that copy; any other VA unchanged. D3D12_GPU_VIRTUAL_ADDRESS console_descriptor_table_va(D3D12_GPU_VIRTUAL_ADDRESS va); +// XDXR acceleration-structure commands (docs/d3d12_vulkan.md 4.8) of a list of `device`: every address the command +// writes or reads, as the title named it, becomes the VA shaders reach that memory by (src/title_va_alias.h: a +// slot-133 buffer's import or shadow, a window of the title's memory, a geometry copy), checked to hold every byte the +// builder touches there. False (logged by the device) when an address has no such copy: the command must not be +// recorded, since heap_base + a title address is no allocation. True and unchanged when `device` is not a Vulkan +// device of this module or builds KHR structures. +bool resolve_acceleration_structure_build(IUnknown* device, leonida::BuildAccelerationStructure& build); +bool resolve_acceleration_structure_copy(IUnknown* device, leonida::CopyAccelerationStructure& copy); +bool resolve_acceleration_structure_postbuild(IUnknown* device, leonida::AccelerationStructurePostbuild& info); + // Reads the shader-visible descriptor heap GPU base addresses currently bound on `list` (0 when unbound). // Returns false when `list` is not one of this module's command lists. bool bound_descriptor_heap_bases(ID3D12GraphicsCommandList* list, D3D12_GPU_VIRTUAL_ADDRESS& cbv_srv_uav, diff --git a/runtime/shims/d3d12_com_object.h b/runtime/shims/d3d12_com_object.h index f1af871b11..27102cde4e 100644 --- a/runtime/shims/d3d12_com_object.h +++ b/runtime/shims/d3d12_com_object.h @@ -24,9 +24,27 @@ void stub(const char* method); template class Object : public Stubs { public: - ULONG STDMETHODCALLTYPE AddRef() override { return ++refs_; } - // Adds a reference unless the count already reached zero (the object is being destroyed). For a caller that found - // the object through a registry it does not own a reference to; the registry entry must still be locked then. + ULONG STDMETHODCALLTYPE AddRef() override { + if constexpr (requires(Derived& object) { object.last_release(); }) { + // Such an object can outlive its last Release (its deletion deferred): a reference taken from zero would + // bring it back, and its next last Release would delete it a second time. Refused, and logged once. + ULONG refs = refs_.load(); + do { + if (!refs) { + static std::atomic logged{false}; + if (!logged.exchange(true)) + std::fprintf(stderr, "[rt] d3d12: AddRef on an object already released (ignored)\n"); + return 0; + } + } while (!refs_.compare_exchange_weak(refs, refs + 1)); + return refs + 1; + } else { + return ++refs_; + } + } + // At zero, a class with a last_release() decides when it is deleted (PipelineState: after its running build). + // Adds a reference unless the count already reached zero. Registry callers must hold their registry lock while + // taking this reference. bool try_add_ref() { ULONG count = refs_.load(); while (count) { @@ -36,7 +54,12 @@ class Object : public Stubs { } ULONG STDMETHODCALLTYPE Release() override { const ULONG left = --refs_; - if (!left) delete static_cast(this); + if (!left) { + if constexpr (requires(Derived& object) { object.last_release(); }) + static_cast(this)->last_release(); + else + delete static_cast(this); + } return left; } @@ -185,6 +208,9 @@ class Child : public Object { IUnknown* attached_device() const { return device_; } + // Takes the device reference out, for a child that lets it go before it is deleted; the caller releases it. + IUnknown* detach_device() { return std::exchange(device_, nullptr); } + HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, void** out) override { if (!out) return E_POINTER; *out = nullptr; diff --git a/runtime/shims/d3d12_compile_exit.h b/runtime/shims/d3d12_compile_exit.h new file mode 100644 index 0000000000..181049b8f5 --- /dev/null +++ b/runtime/shims/d3d12_compile_exit.h @@ -0,0 +1,13 @@ +// The process is ending with the Vulkan device still alive (gta6rt's ExitProcess after the title's run, a console +// Ctrl+C, Ctrl+Break or close). Without this, ExitProcess ends the pipeline compiler's thread wherever it is, +// possibly inside the driver's compiler with its locks held. A device released normally needs none of this: ~Device +// cancels and joins its background builds (PipelineCompiler in d3d12_pipeline_compile.h). +#pragma once + +namespace rt::d3d12 { + +// Drops the queued background pipeline builds, refuses new ones and waits up to `wait_ms` for the running one. +// False when one was still running at the deadline. Defined with the Vulkan device (d3d12_vulkan_device.cpp). +bool stop_pipeline_compiles(unsigned wait_ms); + +} // namespace rt::d3d12 diff --git a/runtime/shims/d3d12_compute_input_probe.h b/runtime/shims/d3d12_compute_input_probe.h index 2b4c5e9ab3..34042ebc13 100644 --- a/runtime/shims/d3d12_compute_input_probe.h +++ b/runtime/shims/d3d12_compute_input_probe.h @@ -4,12 +4,18 @@ #include "../src/fsdraw_probe.h" #include "../src/title_va_alias.h" #include "../src/title_page_watch.h" +#include "xmem.h" #include #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -93,14 +99,12 @@ Backing backing(State& state, std::uint64_t base) { const bool alias = aliases.source_of_vsharp(base, source, room); if (base < state.arena.size) { std::lock_guard lock(state.arena.mutex); - auto next = state.arena.free.upper_bound(base); - if (next != state.arena.free.begin()) { - const auto [at, size] = *std::prev(next); - if (base - at < size) return {"arena-free"}; - } - const auto end = next == state.arena.free.end() ? state.arena.size : next->first; + // The block map's own reader (src/arena_blocks.h): whether base is inside a free block, and where the next + // block after it starts, without holding an iterator the block map could cut. + std::uint64_t block_offset = 0, block_size = 0, next = state.arena.size; + if (state.arena.blocks.free_at(base, block_offset, block_size, next)) return {"arena-free"}; return {alias ? "arena-shadow" : "arena", source, reinterpret_cast(state.arena.mapped) + base, - alias ? std::min(room, end - base) : end - base}; + alias ? std::min(room, next - base) : next - base}; } if (alias) { std::uint64_t host{}, bytes{}; @@ -127,9 +131,138 @@ Backing backing(State& state, std::uint64_t base) { return {"unknown"}; } +// LEONIDA_COMPUTE_HEAP_RECORDS=/:::[::][,...] +// Records of `stride` bytes in the buffer at table root s
, descriptor , whose dword holds a +// directly indexed resource-heap index in its low 24 bits; s holds the heap's 32-bit shader VA. and +// name the root dwords that hold the dispatch's first record and record count; without them the first +// records of the buffer are read. +struct HeapRecordSpec { + unsigned table{}, slot{}, stride{}, dword{}, heap{}; + unsigned first = ~0u, count = ~0u; +}; +inline const auto& heap_record_specs() { + static const auto specs = [] { + std::vector result; + const char* p = std::getenv("LEONIDA_COMPUTE_HEAP_RECORDS"); + if (!p) return result; + const char* end = p + std::strlen(p); + while (p != end && result.size() < 8) { + unsigned v[7]{}; + unsigned n = 0; + for (; n < 7; ++n) { + auto r = std::from_chars(p, end, v[n]); + if (r.ec != std::errc{}) break; + p = r.ptr; + const char want = n == 0 ? '/' : ':'; + if (p == end || *p == ',' || *p != want) { ++n; break; } + ++p; + } + if ((n == 5 || n == 7) && v[0] < 32 && v[4] < 32 && v[2] >= 4 && v[3] < v[2] / 4 && + (n == 5 || (v[5] < 32 && v[6] < 32))) + result.push_back({v[0], v[1], v[2], v[3], v[4], n == 7 ? v[5] : ~0u, n == 7 ? v[6] : ~0u}); + while (p != end && *p != ',') ++p; + if (p != end) ++p; + } + return result; + }(); + return specs; +} + +// Every descriptor the probe read, by shader address, with the GPU-visible words it saw at submission. After a device +// loss they are read again: a slot rewritten while a dispatch that names it was still queued shows up there. +struct Seen { + std::uint64_t seq{}; + std::size_t cmd{}; + unsigned reg{}, slot{}; + std::array words{}; +}; +inline std::mutex& seen_mutex() { static std::mutex m; return m; } +inline std::map& seen() { static std::map m; return m; } +inline void remember(std::uint64_t at, std::uint64_t seq, std::size_t cmd, unsigned reg, unsigned slot, + const std::array& words) { + std::lock_guard lock(seen_mutex()); + auto& m = seen(); + if (m.size() >= 65536 && !m.count(at)) return; + m[at] = {seq, cmd, reg, slot, words}; +} + +template +bool gpu_words_now(State& state, std::uint64_t at, std::array& out) { + if (at >= state.arena.size) { + std::unique_lock lock(state.console_heap_mutex, std::try_to_lock); // a lost device may hold it + if (lock.owns_lock()) + for (const auto& heap : state.console_heaps) { + const auto delta = at - heap->shader_va; + if (heap->copy && delta <= heap->bytes && sizeof(out) <= heap->bytes - delta) { + std::memcpy(out.data(), heap->copy + delta, sizeof(out)); + return true; + } + } + } + return leonida::fsdraw::arena_words(at, out.data(), out.size()); +} + +template +void recheck(State& state) { + std::lock_guard lock(seen_mutex()); + std::size_t same = 0, changed = 0, unreadable = 0; + for (const auto& [at, s] : seen()) { + std::array now{}; + if (!gpu_words_now(state, at, now)) { ++unreadable; continue; } + if (std::equal(now.begin(), now.begin() + 4, s.words.begin())) { ++same; continue; } + ++changed; + // No backing lookup here: the thread that saw the loss may hold the arena or window locks. + std::fprintf(stderr, "[rt] compute-input: after loss, s%u/%u (last seen execute=%llu cmd=%zu) changed: " + "was [%s] now [%s]\n", s.reg, s.slot, (unsigned long long)s.seq, s.cmd, + leonida::fsdraw::hex_words(s.words.data(), 4).c_str(), + leonida::fsdraw::hex_words(now.data(), 4).c_str()); + } + std::fprintf(stderr, "[rt] compute-input: after loss, %zu probed descriptor(s) unchanged, %zu changed, " + "%zu unreadable\n", same, changed, unreadable); + // Every GPU-visible descriptor heap, for buffer V#s whose base is still the title's own memory: heap_base + that + // address is no allocation, so a shader that writes through one loses the device. + auto& aliases = leonida::title_va_aliases(); + auto scan = [&](const char* what, std::uint64_t shader_va, const std::uint8_t* words, std::uint64_t bytes) { + std::size_t raw = 0; + for (std::uint64_t at = 0; at + 32 <= bytes; at += 32) { + std::uint32_t w[4]; + std::memcpy(w, words + at, sizeof(w)); + if (!w[2] || (w[3] >> 30)) continue; // no records: every access is out of bounds + const auto base = std::uint64_t(w[0]) | (std::uint64_t(w[1] & 0xffff) << 32); + std::uint64_t lo{}, hi{}, title{}, room{}; + if (base < state.arena.size || !aliases.title_memory(base, lo, hi) || + aliases.source_of_vsharp(base, title, room)) + continue; + const auto stride = (w[1] >> 16) & 0x3fffu; + if (++raw <= 2048) + std::fprintf(stderr, "[rt] compute-input: after loss, raw title V# in %s heap 0x%llx slot %llu: " + "[%08x %08x %08x %08x] base=0x%llx end=0x%llx\n", what, (unsigned long long)shader_va, + (unsigned long long)(at / 32), w[0], w[1], w[2], w[3], (unsigned long long)base, + (unsigned long long)(base + std::uint64_t(w[2]) * (stride ? stride : 1))); + } + std::fprintf(stderr, "[rt] compute-input: after loss, %s heap 0x%llx (%llu KiB): %zu raw title V#s\n", what, + (unsigned long long)shader_va, (unsigned long long)(bytes >> 10), raw); + }; + { + std::unique_lock lock(state.console_heap_mutex, std::try_to_lock); + if (!lock.owns_lock()) std::fputs("[rt] compute-input: after loss, console heaps locked\n", stderr); + else + for (const auto& heap : state.console_heaps) + if (heap->copy) scan("console", heap->shader_va, heap->copy, heap->bytes); + } + { + std::unique_lock lock(state.cbv_heap_mutex, std::try_to_lock); + if (!lock.owns_lock()) std::fputs("[rt] compute-input: after loss, arena heaps locked\n", stderr); + else + for (const auto& [offset, end] : state.cbv_heaps) + if (end <= state.arena.size) scan("arena", offset, state.arena.mapped + offset, end - offset); + } +} + template Backing descriptor(State& state, std::uint64_t seq, std::size_t list, std::size_t cmd, - const std::array& roots, unsigned reg, unsigned slot) { + const std::array& roots, unsigned reg, unsigned slot, + std::array* words = nullptr) { const auto at = std::uint64_t(roots[reg]) + std::uint32_t(slot * 32u); std::array raw{}, gpu{}; const char* origin = "no-heap"; @@ -166,12 +299,14 @@ Backing descriptor(State& state, std::uint64_t seq, std::size_t list, std::size_ } } if (!have_gpu) have_gpu = leonida::fsdraw::arena_words(at, gpu.data(), gpu.size()); + if (have_gpu) remember(at, seq, cmd, reg, slot, gpu); const auto prefix = "[rt] compute-input: execute=%llu list=%zu cmd=%zu s%u/%u "; std::fprintf(stderr, prefix, (unsigned long long)seq, list, cmd, reg, slot); if (!have_gpu) { std::fprintf(stderr, "table=0x%llx no GPU-visible bytes\n", (unsigned long long)at); return {"missing-table"}; } + if (words) *words = gpu; std::fprintf(stderr, "heap-slot=%llu table-title=0x%llx writer=%s words=[%s] ", (unsigned long long)index, (unsigned long long)title_at, origin, leonida::fsdraw::hex_words(gpu.data(), gpu.size()).c_str()); @@ -214,6 +349,117 @@ Backing descriptor(State& state, std::uint64_t seq, std::size_t list, std::size_ return b; } +// What a heap V# whose base no backing claimed points at: the title range that holds it, how its pages are mapped +// (MEM_MAPPED: xmem physical pages, the pool CopyPageMappingsBatchX remaps; MEM_PRIVATE: plain title memory), how +// many other addresses share its first page, and whether the layer knows a buffer or a GPU copy there. +template +void heap_target(State& state, std::uint64_t base, std::uint64_t span) { + const auto cpu = leonida::title_gpu_views::to_cpu(base, span); + std::uint64_t lo{}, hi{}; + const bool title = leonida::title_va_aliases().title_memory(cpu, lo, hi); + MEMORY_BASIC_INFORMATION region{}; + const bool queried = VirtualQuery(reinterpret_cast(cpu), ®ion, sizeof(region)) != 0; + std::vector peers; + rt::xmem::geometry_aliases(cpu & ~std::uint64_t(0xffff), peers); + std::uint64_t host{}, room{}; + const bool buffer = state.context->diagnostic_buffer(cpu, host, room); + const auto copy = state.geometry.cap() ? state.geometry.find(cpu, span) : 0; + std::fprintf(stderr, " target: cpu=0x%llx other-view=0x%llx title-range=%s", (unsigned long long)cpu, + (unsigned long long)leonida::title_gpu_views::other_view(cpu), title ? "yes" : "no"); + if (title) + std::fprintf(stderr, " range=[0x%llx,+0x%llx) offset=0x%llx", (unsigned long long)lo, + (unsigned long long)(hi - lo), (unsigned long long)(cpu - lo)); + if (queried) + std::fprintf(stderr, " state=0x%lx type=%s protect=0x%lx alloc-base=0x%llx region=0x%llx", region.State, + region.Type == MEM_MAPPED ? "mapped" : region.Type == MEM_PRIVATE ? "private" : + region.Type == MEM_IMAGE ? "image" : "none", region.Protect, + (unsigned long long)reinterpret_cast(region.AllocationBase), + (unsigned long long)region.RegionSize); + std::fprintf(stderr, " page-peers=%zu layer-buffer=%s known-va=%s geometry-copy=0x%llx span-fits-range=%s", + peers.size(), buffer ? "yes" : "no", state.context->knows_buffer_va(base) ? "yes" : "no", + (unsigned long long)copy, title && span <= hi - cpu ? "yes" : "no"); +} + +// The heap slots a table of records selects for one dispatch (LEONIDA_COMPUTE_HEAP_RECORDS). Records are read on +// the CPU from the title's copy when the table has one (the GPU copy can lag it by a submission), at most 64 distinct +// heap indices per dispatch. +template +void heap_records(State& state, std::uint64_t seq, std::size_t list, std::size_t cmd, + const std::array& roots, const HeapRecordSpec& spec) { + constexpr std::size_t kMaxIndices = 64, kMaxRecordLines = 16, kMaxRecords = 4096; + std::fprintf(stderr, "[rt] compute-heap-record: execute=%llu cmd=%zu spec=s%u/%u stride=%u dword=%u heap=s%u " + "table follows\n", (unsigned long long)seq, cmd, spec.table, spec.slot, spec.stride, spec.dword, + spec.heap); + const Backing table = descriptor(state, seq, list, cmd, roots, spec.table, spec.slot); + if (!table.host && !table.title) return; + const std::uint64_t available = table.available; + const std::uint64_t records = available / spec.stride; + std::uint64_t first = 0, count = std::min(records, kMaxRecords); + if (spec.first < 32 && spec.count < 32) { + first = roots[spec.first]; + count = std::min(roots[spec.count], kMaxRecords); + } + if (first >= records) count = 0; + else count = std::min(count, records - first); + struct Use { std::uint64_t first_record = 0, records = 0; std::set high; }; + std::map uses; + std::uint64_t read = 0, unreadable = 0, differs = 0, skipped = 0; + std::vector words(spec.stride / 4), gpu(spec.stride / 4); + for (std::uint64_t r = first; r < first + count; ++r) { + const auto at = r * spec.stride; + const bool from_title = table.title && read_cpu(table.title + at, words.data(), spec.stride); + const bool from_gpu = read_backing(table, at, gpu.data(), spec.stride); + if (!from_title && !from_gpu) { ++unreadable; continue; } + if (!from_title) words = gpu; + else differs += from_gpu && words != gpu; + ++read; + const auto value = words[spec.dword]; + const unsigned index = value & 0xffffffu; + if (read <= kMaxRecordLines && spec.first < 32) + std::fprintf(stderr, "[rt] compute-heap-record: execute=%llu cmd=%zu record=%llu from=%s value=0x%08x " + "index=%u high=%u words=[%s]\n", (unsigned long long)seq, cmd, (unsigned long long)r, + from_title ? "title" : "gpu-copy", value, index, value >> 24, + leonida::fsdraw::hex_words(words.data(), words.size()).c_str()); + auto it = uses.find(index); + if (it == uses.end()) { + if (uses.size() >= kMaxIndices) { ++skipped; continue; } + it = uses.emplace(index, Use{r}).first; + } + ++it->second.records; + it->second.high.insert(value >> 24); + } + std::map classes; + for (const auto& [index, use] : uses) { + std::fprintf(stderr, "[rt] compute-heap-record: execute=%llu cmd=%zu heap-index=%u records=%llu " + "first-record=%llu high=", (unsigned long long)seq, cmd, index, + (unsigned long long)use.records, (unsigned long long)use.first_record); + for (unsigned h : use.high) std::fprintf(stderr, "%u;", h); + std::fputc('\n', stderr); + std::array v{}; + const Backing b = descriptor(state, seq, list, cmd, roots, spec.heap, index, &v); + std::string kind = b.kind; + const auto base = std::uint64_t(v[0]) | (std::uint64_t(v[1] & 0xffff) << 32); + const auto stride = (v[1] >> 16) & 0x3fffu; + const bool buffer = (v[0] | v[1] | v[2] | v[3]) && !(v[3] >> 30); + if (buffer && kind != "arena" && kind != "arena-shadow" && kind != "import" && kind != "geometry" && + kind != "window-shadow") { + std::fprintf(stderr, "[rt] compute-heap-record: execute=%llu cmd=%zu heap-index=%u base=0x%llx", + (unsigned long long)seq, cmd, index, (unsigned long long)base); + heap_target(state, base, std::uint64_t(v[2]) * (stride ? stride : 1)); + std::fputc('\n', stderr); + } + ++classes[kind]; + } + std::fprintf(stderr, "[rt] compute-heap-summary: execute=%llu cmd=%zu spec=s%u/%u:%u:%u:s%u records=%llu+%llu " + "read=%llu unreadable=%llu title-differs-from-copy=%llu distinct=%zu over-cap=%llu classes:", + (unsigned long long)seq, cmd, spec.table, spec.slot, spec.stride, spec.dword, spec.heap, + (unsigned long long)first, (unsigned long long)count, (unsigned long long)read, + (unsigned long long)unreadable, (unsigned long long)differs, uses.size(), + (unsigned long long)skipped); + for (const auto& [kind, n] : classes) std::fprintf(stderr, " %s=%u", kind.c_str(), n); + std::fputc('\n', stderr); +} + // The two measured culling kernels share this record format. Read a bounded CPU snapshot // of the actual int offsets for each dispatched group. A prior GPU writer can still be in flight. template @@ -291,6 +537,7 @@ void inspect(State& state, std::span lists, s if (reg == 5 && slot == 0) indices = b; if (reg == 4 && slot == 86) records = b; } + for (const auto& spec : heap_record_specs()) heap_records(state, seq, l, i, roots, spec); if (d && (std::string_view(name).ends_with("lib_cs_01405") || std::string_view(name).ends_with("lib_cs_01410"))) culling_records(state, seq, l, i, roots, d->x, indices, records); } diff --git a/runtime/shims/d3d12_geometry_views.h b/runtime/shims/d3d12_geometry_views.h index ef7af22029..a9299d38cb 100644 --- a/runtime/shims/d3d12_geometry_views.h +++ b/runtime/shims/d3d12_geometry_views.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include namespace rt::d3d12 { @@ -32,15 +35,56 @@ class GeometryViews { bool retry = false; }; mutable std::mutex mutex_; + std::mutex refresh_mutex_; // refresh() only, held for its whole run, before mutex_ TitleBufferWindows pool_; std::map, std::size_t> keys_; + // What resolve() and find() answer for a key already in keys_ (0 when refused), readable without mutex_: refresh() + // holds mutex_ for its whole pass over the watched tiles (up to tens of milliseconds a submission), and the title's + // Subrender workers resolve their root views while they record (SetGraphicsRoot*View), so they waited for it + // (speed-26). Written under mutex_ and then fast_mutex_ (in that order), read under fast_mutex_ alone. + struct KeyHash { + std::size_t operator()(const std::pair& k) const { + return std::hash{}(std::uint64_t(k.first) * 0x9E3779B97F4A7C15ull ^ k.second); + } + }; + // keys_, views_ (the vector itself, and each view's source, size, dst and va) and by_address_ change only in + // resolve(), under mutex_ and then structure_mutex_ exclusively. lookup() and find() read them under + // structure_mutex_ shared, so they do not wait for a refresh() in progress (which holds mutex_ and changes only a + // view's ready/zeroed flags and its bytes), on the submit thread's heaps refresh among others. + mutable std::shared_mutex structure_mutex_; + mutable std::shared_mutex fast_mutex_; + std::unordered_map, VkDeviceSize, KeyHash> fast_; + void publish(const std::pair& key, VkDeviceSize va) { // mutex_ held + std::unique_lock lock(fast_mutex_); + fast_[key] = va; + } + bool fast_find(const std::pair& key, VkDeviceSize& va) const { + std::shared_lock lock(fast_mutex_); + const auto it = fast_.find(key); + if (it == fast_.end()) return false; + va = it->second; + return true; + } std::vector views_; std::map by_address_; std::map tiles_; static constexpr auto refused = SIZE_MAX; std::uint64_t serial_{}, bytes_{}, cap_refusals_{}, allocation_failures_{}, ready_{}, uploads_{}, uploaded_{}; - std::uint64_t submissions_{}, dirty_refreshes_{}, refilled_{}; + std::uint64_t submissions_{}, dirty_refreshes_{}, refilled_{}, tile_fills_{}; + std::unordered_map tile_reads_; // refresh(): offset in tile_scratch_, SIZE_MAX unreadable + // refresh() scratch: per view, whether it waits on a tile (pinned), is filled whole, was touched, was counted; + // and the tiles found written, in address order. + enum : std::uint8_t { kPinned = 1, kWhole = 2, kTouched = 4, kCounted = 8 }; + std::vector marks_; + std::vector written_; + std::vector
written_vas_; + std::vector tile_scratch_; std::chrono::steady_clock::duration refresh_time_{}; + struct Window { // since the last periodic line + std::uint64_t refreshes = 0, tiles = 0, views = 0, bytes = 0; + std::chrono::steady_clock::duration time{}; + std::chrono::steady_clock::time_point since = std::chrono::steady_clock::now(); + } window_; std::uint64_t cleared_{}; bool retry_{}; @@ -67,6 +111,21 @@ class GeometryViews { retry_ |= t.retry; return !t.retry; } + // The tile's 64 KiB as this refresh read it, or null when it could not be read whole. Read at most once a refresh. + template + const std::uint8_t* read_tile(Address tile, Copy& copy) { + auto [it, fresh] = tile_reads_.try_emplace(tile, SIZE_MAX); + if (fresh) { + const std::size_t at = tile_scratch_.size(); + tile_scratch_.resize(at + tile_size); + if (copy(tile_scratch_.data() + at, reinterpret_cast(tile), tile_size) == + GeometryCopy::copied) + it->second = at; + else + tile_scratch_.resize(at); + } + return it->second == SIZE_MAX ? nullptr : tile_scratch_.data() + it->second; + } template void fill(View& v, Copy& copy) { const auto result = copy(v.dst, reinterpret_cast(v.source), v.size); @@ -99,7 +158,8 @@ class GeometryViews { } std::uint64_t find(Address cpu, std::size_t bytes) const { - std::lock_guard lock(mutex_); + if (VkDeviceSize va = 0; fast_find({cpu, bytes}, va)) return va; + std::shared_lock lock(structure_mutex_); const auto it = keys_.find({cpu, bytes}); return it == keys_.end() || it->second == refused ? 0 : views_[it->second].va; } @@ -107,16 +167,24 @@ class GeometryViews { template std::uint64_t resolve(Device& device, Address cpu, std::size_t bytes, Copy copy) { if (!bytes || bytes > UINTPTR_MAX - cpu) return 0; - std::lock_guard lock(mutex_); const auto key = std::make_pair(cpu, bytes); - if (const auto it = keys_.find(key); it != keys_.end()) - return it->second == refused ? 0 : views_[it->second].va; + if (VkDeviceSize known = 0; fast_find(key, known)) return known; + std::lock_guard lock(mutex_); + if (const auto it = keys_.find(key); it != keys_.end()) { + const VkDeviceSize known = it->second == refused ? 0 : views_[it->second].va; + publish(key, known); + return known; + } std::uint8_t* mapped{}; VkDeviceSize va{}; bool at_cap = false; if (bytes > cap() - bytes_ || !pool_.allocate(device, bytes, va, mapped, true, cap(), &at_cap)) { if (at_cap || bytes > cap() - bytes_) { - keys_.emplace(key, refused); + { + std::unique_lock structure(structure_mutex_); + keys_.emplace(key, refused); + } + publish(key, 0); if (++cap_refusals_ <= 4) std::fprintf(stderr, "[rt] geometry buffer cap refused %zu bytes, %llu bytes already reserved\n", bytes, static_cast(pool_.reserved())); @@ -126,9 +194,12 @@ class GeometryViews { return 0; } auto id = views_.size(); - keys_[key] = id; - by_address_.emplace(device.arena.address + va, id); - views_.push_back({cpu, bytes, mapped, va}); + { + std::unique_lock structure(structure_mutex_); + keys_[key] = id; + by_address_.emplace(device.arena.address + va, id); + views_.push_back({cpu, bytes, mapped, va}); + } bytes_ += bytes; bool ready = true; for (auto p = cpu & ~(tile_size - 1); p < cpu + bytes; p += tile_size) { @@ -144,13 +215,16 @@ class GeometryViews { cleared_ += bytes; views_.back().zeroed = true; } + publish(key, va); return va; } template void refresh(Copy copy) { if (!cap()) return; - std::lock_guard lock(mutex_); + // One refresh at a time (its scratch members, and mutex_ is let go during the walk below); taken before mutex_. + std::lock_guard serial(refresh_mutex_); + std::unique_lock lock(mutex_); ++submissions_; auto now = leonida::geometry_writes::state().serial.load(std::memory_order_acquire); if (serial_ == now && !retry_) return; @@ -158,24 +232,114 @@ class GeometryViews { const auto before = uploaded_; serial_ = now; retry_ = false; - std::set changed; - for (auto& [va, tile] : tiles_) - if (update(va, tile)) changed.insert(tile.views.begin(), tile.views.end()); - for (auto id : changed) { - auto& view = views_[id]; - bool pinned = false; - for (auto p = view.source & ~(tile_size - 1); p < view.source + view.size; p += tile_size) - if (tiles_.at(p).retry) { pinned = true; break; } - if (!pinned) fill(view, copy); + // The views over each tile written since, with those tiles (in address order, as tiles_ is): a ready view + // copies only them, 64 KiB each, not the whole view again (LEONIDA_GEOMETRY_WHOLE_VIEWS=1: whole views). + static const bool whole = [] { + const char* v = std::getenv("LEONIDA_GEOMETRY_WHOLE_VIEWS"); + return v && *v && *v != '0'; + }(); + // One pass over the tiles: each written tile is read once and copied into every view over it, not view by + // view (speed-16: up to 63 written tiles under 918 views a refresh, ~58,000 per-view lookups and copies, + // 30-80 ms). A view over a tile that cannot be guarded yet (retry) is left as it is this time; a view not + // filled yet is filled whole, once. + marks_.assign(views_.size(), 0); + written_.clear(); + // The pass over the watched tiles makes a VirtualQuery and a VirtualProtect for each written one (tens of + // milliseconds to a few hundred under Wine). resolve() waits for mutex_, and a new V# resolved while a + // submission fixes its console heap slots then waited for the whole pass (speed-35: 116 ms of fixing a + // submission with indirect draws on). So the lock is let go every 64 tiles. A view resolved meanwhile is + // filled whole by resolve() and has no mark here; tiles_ is a std::map, so the walk survives its inserts. + std::size_t walked = 0; + for (auto& [va, tile] : tiles_) { + if (!(++walked & 63)) { + lock.unlock(); + lock.lock(); + } + const bool written = update(va, tile); + if (tile.retry) + for (auto id : tile.views) + if (id < marks_.size()) marks_[id] |= kPinned; + if (written) { + written_.push_back(&tile); + written_vas_.push_back(va); + } + } + const std::size_t changed_tiles = written_vas_.size(); + tile_reads_.clear(); + tile_scratch_.clear(); + std::size_t changed_views = 0; + for (std::size_t w = 0; w < written_vas_.size(); ++w) { + const Address va = written_vas_[w]; + const Tile& tile = *written_[w]; + const std::uint8_t* read = nullptr; + bool read_done = false; + for (const auto id : tile.views) { + if (id >= marks_.size()) continue; // made by resolve() during the walk above: filled whole there + std::uint8_t& mark = marks_[id]; + if (mark & (kPinned | kWhole)) continue; + View& v = views_[id]; + if (!(mark & kTouched)) { + mark |= kTouched; + ++changed_views; + } + if (whole || !v.ready) { + mark |= kWhole; + continue; + } + if (!read_done) { + read = read_tile(va, copy); + read_done = true; + } + const Address from = (std::max)(va, v.source), to = (std::min)(va + tile_size, v.source + v.size); + if (from >= to) continue; + if (read) { + std::memcpy(v.dst + (from - v.source), read + (from - va), to - from); + } else if (copy(v.dst + (from - v.source), reinterpret_cast(from), to - from) != + GeometryCopy::copied) { + mark |= kWhole; // filled whole below, which zeroes it if that fails too + continue; + } + uploaded_ += to - from; + if (!(mark & kCounted)) { + mark |= kCounted; + ++uploads_; + ++tile_fills_; + } + } } + for (std::size_t id = 0; id < marks_.size(); ++id) + if ((marks_[id] & (kWhole | kPinned)) == kWhole) fill(views_[id], copy); + written_.clear(); + written_vas_.clear(); if (uploaded_ != before) ++dirty_refreshes_; refilled_ += uploaded_ - before; - refresh_time_ += std::chrono::steady_clock::now() - start; + const auto end = std::chrono::steady_clock::now(); + refresh_time_ += end - start; + // Every 10 s: what the refreshes since the last line did. + window_.refreshes += 1; + window_.tiles += changed_tiles; + window_.views += changed_views; + window_.bytes += uploaded_ - before; + window_.time += end - start; + if (end - window_.since >= std::chrono::seconds(10)) { + std::fprintf(stderr, + "[rt] geometry refresh: %llu refreshes with writes in %.0f s: %.1f written tiles and %.1f views " + "each, %.1f KiB copied each, %.3f ms each; %zu tiles watched, %zu views\n", + static_cast(window_.refreshes), + std::chrono::duration(end - window_.since).count(), + double(window_.tiles) / double(window_.refreshes), + double(window_.views) / double(window_.refreshes), + double(window_.bytes) / 1024.0 / double(window_.refreshes), + std::chrono::duration(window_.time).count() / double(window_.refreshes), + tiles_.size(), views_.size()); + window_ = {}; + window_.since = end; + } } bool lookup(VkDeviceAddress bda, std::uint64_t& host, std::uint64_t& bytes, std::uint64_t* source = nullptr, bool* populated = nullptr) const { - std::lock_guard lock(mutex_); + std::shared_lock lock(structure_mutex_); auto it = by_address_.upper_bound(bda); if (it == by_address_.begin()) return false; --it; @@ -197,11 +361,11 @@ class GeometryViews { (unsigned long long)(cap() >> 20), (unsigned long long)cap_refusals_, (unsigned long long)allocation_failures_, (unsigned long long)uploads_, (unsigned long long)uploaded_, tiles_.size(), static_cast(pool_.reserved())); - std::fprintf(stderr, "[rt] geometry refresh: %llu/%llu submissions uploaded dirty views, %llu bytes; " - "%.3f s checking and refreshing sources, %llu bytes cleared\n", + std::fprintf(stderr, "[rt] geometry refresh: %llu/%llu submissions uploaded dirty views, %llu bytes (%llu views by " + "their written tiles only); %.3f s checking and refreshing sources, %llu bytes cleared\n", static_cast(dirty_refreshes_), static_cast(submissions_), - static_cast(refilled_), std::chrono::duration(refresh_time_).count(), - static_cast(cleared_)); + static_cast(refilled_), static_cast(tile_fills_), + std::chrono::duration(refresh_time_).count(), static_cast(cleared_)); } template void release(Device& d) { diff --git a/runtime/shims/d3d12_indirect_draw_policy.h b/runtime/shims/d3d12_indirect_draw_policy.h new file mode 100644 index 0000000000..dc2461512c --- /dev/null +++ b/runtime/shims/d3d12_indirect_draw_policy.h @@ -0,0 +1,20 @@ +// Process-local policy for this shim's ordinary indirect graphics recorder, not a device feature. +#pragma once + +#include +#include +#include + +namespace rt::d3d12 { +inline bool indirect_draws_disabled() { + static const bool disabled = [] { + wchar_t value[4] = {}; + // GetEnvironmentVariableW returns the required size (including NUL) on overflow. + if (GetEnvironmentVariableW(L"LEONIDA_INDIRECT_DRAWS", value, 4) != 3) return false; + if (std::wmemcmp(value, L"raw", 3) == 0) + std::fprintf(stderr, "[rt] LEONIDA_INDIRECT_DRAWS=raw is obsolete; using guarded stateful draws\n"); + return std::wmemcmp(value, L"off", 3) == 0; + }(); + return disabled; +} +} // namespace rt::d3d12 diff --git a/runtime/shims/d3d12_pipeline_compile.h b/runtime/shims/d3d12_pipeline_compile.h index 6ef257f0b8..3a5e045840 100644 --- a/runtime/shims/d3d12_pipeline_compile.h +++ b/runtime/shims/d3d12_pipeline_compile.h @@ -3,6 +3,7 @@ #include "../src/vulkan_replay.h" #include +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include namespace rt::d3d12 { inline bool trace_pipeline_compile() { @@ -84,23 +86,58 @@ struct CompileTrace { // Demanded work has priority zero, speculative work is ordered by module size, and -// an idle checkpoint runs last. Jobs own their object until they finish. No Vulkan -// call runs with the queue lock held. The worker outlives individual D3D12 devices. +// an idle checkpoint runs last. No Vulkan call runs with the queue lock held. +// +// Lifetime. A job names its owner (the PSO it builds, or the device for a cache checkpoint) and the device whose +// Vulkan objects it uses, and holds no reference to either: a reference kept the device alive past the title's last +// Release until the worker reached the job, so a released device's builds ran on (a test that then destroyed its +// VkDevice crashed). +// - A PSO's last Release does not wait for its running build, which can be a dispatch-worker build of a module the +// driver takes minutes over: after_running() drops its queued jobs and hands the PSO's deletion to the worker, +// to run when that build returns (PipelineState::last_release). The PSO lets its device reference go at once. +// - A device's teardown waits: cancel() drops its queued jobs (by owner or device) and waits for its running one +// and what runs after it, so an in-flight vkCreate*Pipelines finishes before the device's objects go. +// - The worker thread runs while a device is alive (retain/release): the last device's release stops and joins it. +// - stop_for_exit() is for a process that ends with its device alive (main.cpp: the title's exit, a console Ctrl+C +// or close). After it nothing more is queued: submit() refuses, and the callers build in place or not at all. class PipelineCompiler { public: static PipelineCompiler& instance() { - static auto* pool = new PipelineCompiler; + static auto* pool = new PipelineCompiler; // never destroyed: static destruction must not race the worker return *pool; } - void submit(std::size_t priority, std::function work) { + + struct Stats { + std::uint64_t submitted = 0; + std::uint64_t completed = 0; // jobs the worker ran + std::uint64_t dropped = 0; // queued jobs thrown away by cancel, after_running, release or stop_for_exit + std::uint64_t refused = 0; // submissions after stop_for_exit + std::uint64_t waited = 0; // cancel calls that waited for a running job + std::uint64_t deferred = 0; // after_running calls that left something to run after a running job + }; + + // False, with nothing queued, after stop_for_exit. + bool submit(const void* owner, const void* device, std::size_t priority, std::function work) { std::lock_guard lock(mutex_); - if (!started_) { - std::thread([this] { run(); }).detach(); - started_ = true; + if (closed_) { + ++stats_.refused; + return false; + } + if (!worker_.joinable()) { + const std::uint64_t generation = ++generation_; + worker_ = std::thread([this, generation] { run(generation); }); } - jobs_.emplace(priority, std::move(work)); + jobs_.emplace(priority, Job{owner, device, std::move(work)}); + ++stats_.submitted; wake_.notify_one(); + return true; + } + + bool closed() { + std::lock_guard lock(mutex_); + return closed_; } + bool has_compile_waiter() { std::lock_guard lock(mutex_); return !jobs_.empty() && jobs_.begin()->first != SIZE_MAX; @@ -109,35 +146,202 @@ class PipelineCompiler { // finishes; a caller that counts references (rt::d3d12_xs::device_proxy_ref_count) waits here first. void wait_idle() { std::unique_lock wait(mutex_); - idle_.wait(wait, [this] { return jobs_.empty() && !running_; }); + done_.wait(wait, [this] { return jobs_.empty() && running_.empty(); }); + } + + // Drops the queued jobs whose owner or device is `key` and waits for the running ones, with what runs after them + // (after_running), unless one is on this thread. Jobs a running one queues for `key` meanwhile are dropped too. + // Returns how many were dropped. + std::size_t cancel(const void* key) { + std::vector dropped; + { + std::unique_lock lock(mutex_); + const auto me = std::this_thread::get_id(); + bool counted = false; + for (;;) { + drop_locked(dropped, [key](const Job& job) { return job.owner == key || job.device == key; }); + const bool busy = std::any_of(running_.begin(), running_.end(), [&](const Running& r) { + return (r.owner == key || r.device == key) && r.thread != me; + }); + if (!busy) break; + if (!counted) ++stats_.waited; + counted = true; + done_.wait(lock); + } + } + return dropped.size(); // the dropped jobs' captures are destroyed here, outside the lock + } + + // Drops the queued jobs filed under `owner`. When one of its jobs is running, `last` is run on the worker after it + // returns, before the job counts as done (a device's cancel waits for both), and the answer is true; otherwise + // false, and `last` is not kept. On the worker inside that job itself, `last` runs after the job returns too. + bool after_running(const void* owner, std::function last) { + std::vector dropped; + std::lock_guard lock(mutex_); + drop_locked(dropped, [owner](const Job& job) { return job.owner == owner; }); + for (Running& r : running_) { + if (r.owner != owner || r.finished) continue; + r.after = r.after ? [first = std::move(r.after), then = std::move(last)] { first(); then(); } + : std::move(last); + ++stats_.deferred; + return true; + } + return false; + } + + // True on the worker while it runs a job whose owner or device is `key` (not what runs after it). + bool running_here(const void* key) { + std::lock_guard lock(mutex_); + const auto me = std::this_thread::get_id(); + return std::any_of(running_.begin(), running_.end(), [&](const Running& r) { + return r.thread == me && !r.finished && (r.owner == key || r.device == key); + }); + } + + // A device holds the worker while it lives. The last release drops whatever is still queued, stops the worker + // and joins it; a release on the worker itself lets it return after the job it is in. + void retain() { + std::lock_guard lock(mutex_); + ++users_; + } + void release() { + std::vector dropped; + std::thread worker; + { + std::lock_guard lock(mutex_); + if (users_ && --users_) return; + worker = stop_locked(dropped); + } + finish(std::move(worker), true); } + + // Process exit with a device still alive: drops the queue, refuses new jobs and waits up to `wait` for a running + // one, so ExitProcess does not end the worker inside the driver. False when a job was still running. + bool stop_for_exit(std::chrono::milliseconds wait) { + std::vector dropped; + std::thread worker; + bool idle = true; + { + std::unique_lock lock(mutex_); + closed_ = true; + worker = stop_locked(dropped); + const auto me = std::this_thread::get_id(); + idle = done_.wait_for(lock, wait, [&] { + return std::none_of(running_.begin(), running_.end(), [&](const Running& r) { return r.thread != me; }); + }); + } + finish(std::move(worker), idle); + return idle; + } + + Stats stats() { + std::lock_guard lock(mutex_); + return stats_; + } + bool worker_running() { + std::lock_guard lock(mutex_); + return worker_.joinable(); + } + // Tests: called on the worker with each job's owner, once the job counts as running and before its work. + void set_job_probe(std::function probe) { + std::lock_guard lock(mutex_); + probe_ = std::move(probe); + } + private: - void run() { + struct Job { + const void* owner = nullptr; + const void* device = nullptr; + std::function work; + }; + struct Running { + const void* owner; + const void* device; + std::thread::id thread; + std::function after; // after_running + bool finished = false; // the job returned; `after` may be running + }; + + template void drop_locked(std::vector& dropped, const Match& match) { + for (auto it = jobs_.begin(); it != jobs_.end();) { + if (match(it->second)) { + dropped.push_back(std::move(it->second)); + it = jobs_.erase(it); + ++stats_.dropped; + } else { + ++it; + } + } + } + + std::thread stop_locked(std::vector& dropped) { + drop_locked(dropped, [](const Job&) { return true; }); + ++generation_; // the worker returns when it next looks: after the job it is running, if any + wake_.notify_all(); + return std::move(worker_); + } + + static void finish(std::thread worker, bool join) { + if (!worker.joinable()) return; + if (join && worker.get_id() != std::this_thread::get_id()) worker.join(); + else worker.detach(); + } + + Running& mine(std::thread::id me) { + return *std::find_if(running_.begin(), running_.end(), [me](const Running& r) { return r.thread == me; }); + } + + void run(std::uint64_t generation) { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); + const auto me = std::this_thread::get_id(); + std::unique_lock lock(mutex_); for (;;) { - std::function job; - { - std::unique_lock wait(mutex_); - wake_.wait(wait, [this] { return !jobs_.empty(); }); - auto first = jobs_.begin(); - job = std::move(first->second); - jobs_.erase(first); - running_ = true; + wake_.wait(lock, [&] { return generation_ != generation || !jobs_.empty(); }); + if (generation_ != generation) return; + auto first = jobs_.begin(); + Job job = std::move(first->second); + jobs_.erase(first); + running_.push_back({job.owner, job.device, me}); + const auto probe = probe_; + lock.unlock(); + try { + if (probe) probe(job.owner); + job.work(); + } catch (...) { + std::fprintf(stderr, "[rt] pipeline compile worker: a job threw\n"); } - job(); - job = nullptr; // what the job captured goes before the pool reports itself idle - { - std::lock_guard done(mutex_); - running_ = false; + job.work = nullptr; // its captures go before the job counts as done + lock.lock(); + ++stats_.completed; + Running& self = mine(me); + self.finished = true; + if (std::function after = std::move(self.after)) { + lock.unlock(); + try { + after(); + } catch (...) { + std::fprintf(stderr, "[rt] pipeline compile worker: work after a job threw\n"); + } + after = nullptr; + lock.lock(); } - idle_.notify_all(); + running_.erase(std::find_if(running_.begin(), running_.end(), [me](const Running& r) { + return r.thread == me; + })); + done_.notify_all(); } } + std::mutex mutex_; std::condition_variable wake_; - std::condition_variable idle_; - bool running_ = false; - std::multimap> jobs_; - bool started_ = false; + std::condition_variable done_; + std::multimap jobs_; + std::vector running_; // one per worker; a stopped worker may still be finishing one + std::thread worker_; + std::uint64_t generation_ = 0; // a worker runs while this is the value it started with + unsigned users_ = 0; // live devices (retain/release) + bool closed_ = false; // stop_for_exit: nothing more is queued + Stats stats_; + std::function probe_; }; } // namespace rt::d3d12 diff --git a/runtime/shims/d3d12_title_buffer_windows.h b/runtime/shims/d3d12_title_buffer_windows.h index 5531d29a43..c940d6138f 100644 --- a/runtime/shims/d3d12_title_buffer_windows.h +++ b/runtime/shims/d3d12_title_buffer_windows.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -20,6 +21,15 @@ class TitleBufferWindows { }; std::vector blocks_; VkDeviceSize reserved_{}; + // A new block's allocation failed at this time: none is tried again for kRetryAfter. After the story load the + // driver refused every 4 MiB block (VK_ERROR_OUT_OF_HOST_MEMORY), and each V# that wanted a copy tried again, + // through DeviceState::allocate's sleeping retries under the device's memory lock: one submission spent 28-35 s + // there (speed-8, speed-9). A view refused meanwhile goes without a copy, as one past the cap does. + static constexpr auto kRetryAfter = std::chrono::seconds(2); + std::chrono::steady_clock::time_point failed_at_{}; + bool failed_ = false; + bool local_refused_ = false; // device-local blocks refused once: host memory from then on + std::uint64_t quick_refusals_ = 0; public: VkDeviceSize reserved() const { return reserved_; } @@ -45,6 +55,15 @@ class TitleBufferWindows { if (take(blocks_[i - 1])) return true; auto& vk = d.context->vk; if (!vk.vkGetBufferDeviceAddress) return false; + if (failed_ && std::chrono::steady_clock::now() - failed_at_ < kRetryAfter) { + ++quick_refusals_; + return false; + } + const auto failed = [&] { + failed_ = true; + failed_at_ = std::chrono::steady_clock::now(); + return false; + }; Block b{}; b.capacity = std::max(bytes, block_size); if (b.capacity > cap - reserved_) { @@ -55,7 +74,7 @@ class TitleBufferWindows { info.size = b.capacity; info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; d.share(info); - if (vk.vkCreateBuffer(d.info.device, &info, nullptr, &b.buffer) != VK_SUCCESS) return false; + if (vk.vkCreateBuffer(d.info.device, &info, nullptr, &b.buffer) != VK_SUCCESS) return failed(); VkMemoryRequirements req{}; vk.vkGetBufferMemoryRequirements(d.info.device, b.buffer, &req); if (req.size > cap - reserved_) { @@ -63,9 +82,20 @@ class TitleBufferWindows { vk.vkDestroyBuffer(d.info.device, b.buffer, nullptr); return false; } - b.memory = d.allocate(req, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - (device_local ? VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0), - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, nullptr, true); + // Device-local (Resizable BAR) when asked and while the driver gives it; host memory otherwise. After the + // story load the driver refused every 4 MiB device-local, host-visible block with a device address + // (VK_ERROR_OUT_OF_HOST_MEMORY, speed-8/-9) while host memory still served: once that happens, later blocks + // go straight to host memory instead of through DeviceState::allocate's sleeping retries first. + VkMemoryPropertyFlags chosen = 0; + const bool want_local = device_local && !local_refused_; + b.memory = d.allocate(req, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + want_local ? VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0, &chosen, true); + if (b.memory && want_local && !(chosen & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { + local_refused_ = true; + std::fprintf(stderr, "[rt] d3d12: title buffer windows: device-local memory refused a %llu KiB block; " + "this and later blocks are in host memory\n", + static_cast(req.size >> 10)); + } void* host{}; if (b.memory && vk.vkBindBufferMemory(d.info.device, b.buffer, b.memory, 0) == VK_SUCCESS && vk.vkMapMemory(d.info.device, b.memory, 0, VK_WHOLE_SIZE, 0, &host) == VK_SUCCESS) { @@ -89,8 +119,10 @@ class TitleBufferWindows { } vk.vkDestroyBuffer(d.info.device, b.buffer, nullptr); if (b.memory) vk.vkFreeMemory(d.info.device, b.memory, nullptr); - return false; + return failed(); } + // Allocations refused at once because a new block failed less than kRetryAfter ago. + std::uint64_t quick_refusals() const { return quick_refusals_; } bool lookup(VkDeviceAddress address, std::uint64_t& host, std::uint64_t& remaining) const { for (const auto& b : blocks_) { diff --git a/runtime/shims/d3d12_title_image_upload.h b/runtime/shims/d3d12_title_image_upload.h index 7b7dcb8e6e..2bb092f999 100644 --- a/runtime/shims/d3d12_title_image_upload.h +++ b/runtime/shims/d3d12_title_image_upload.h @@ -5,21 +5,33 @@ namespace rt::d3d12 { -// One upload buffer and command buffer per device, used under the title-texture registry lock. -// A whole image (including arrays and compressed mip tails) is detiled into the mapped buffer. +// A ring of upload buffers and command buffers per device, used under the title-texture registry lock. +// A whole image (including arrays and compressed mip tails) is detiled into the mapped buffer of the next slot. // The transfer never re-enters the D3D12 queue's pre-submit callbacks. +// +// A write no longer waits for its own transfer: the caller (a title thread creating a slot-70 view) waited for the +// GPU at every texture fill, behind all earlier work on the queue, with tracker_mutex_ and submit_mutex_ held, so +// every other submission waited too (speed-26: a title thread 68-88 % inside slot 70). A slot's buffer is reused, +// resized or freed only after its last transfer completed (the slot's timeline value). The image needs no CPU wait: +// later submissions on the queue are ordered after the transfer, other queues wait for it on the GPU, and a retired +// image is destroyed through the deferred queue, after later submissions retire. class TitleImageUpload { public: - VkDeviceSize capacity() const { return capacity_; } + VkDeviceSize capacity() const { + VkDeviceSize total = 0; + for (const auto& slot : slots_) total += slot.capacity; + return total; + } template void release(Device& d) { auto& vk = d.context->vk; - release_buffer(d); + wait_all(d); + for (auto& slot : slots_) release_buffer(d, slot); if (pool_) vk.vkDestroyCommandPool(d.info.device, pool_, nullptr); if (ready_) vk.vkDestroySemaphore(d.info.device, ready_, nullptr); pool_ = VK_NULL_HANDLE; - command_ = VK_NULL_HANDLE; + for (auto& slot : slots_) slot.command = VK_NULL_HANDLE; ready_ = VK_NULL_HANDLE; } @@ -55,12 +67,14 @@ class TitleImageUpload { regions_.push_back(copy); } } - if (!prepare(d, bytes)) return false; + Slot& slot = slots_[next_]; + if (!prepare(d, slot, bytes)) return false; + next_ = (next_ + 1) % kSlots; for (const auto& copy : regions_) { const auto level = copy.imageSubresource.mipLevel; const auto& mip = layout.layout.plane[0].mips[level]; const auto row = mip.width_elements * block.bytes, slice = row * mip.height_elements; - auto* dst = mapped_ + copy.bufferOffset; + auto* dst = slot.mapped + copy.bufferOffset; xg_xs::copy_elements(layout, level, copy.imageSubresource.baseArrayLayer, tiled, dst, row, slice, columns); if (inspect && !nonzero) nonzero = std::any_of(dst, dst + VkDeviceSize(slice) * copy.imageExtent.depth, @@ -71,42 +85,79 @@ class TitleImageUpload { const auto result = d.context->write_staged_title_image(id, range, [&](const leonida::ReplayFunctions& replay, const leonida::LayoutPieces& pieces) { auto& vk = d.context->vk; - VkResult r = vk.vkResetCommandBuffer(command_, 0); + VkResult r = vk.vkResetCommandBuffer(slot.command, 0); if (r != VK_SUCCESS) return r; VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - if ((r = vk.vkBeginCommandBuffer(command_, &begin)) != VK_SUCCESS) return r; - // All texels of every mip/layer named in range are overwritten. Prior reads already finished. - leonida::detail::image_barrier(replay, command_, image, range, VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 0, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + if ((r = vk.vkBeginCommandBuffer(slot.command, &begin)) != VK_SUCCESS) return r; + // All texels of every mip/layer named in range are overwritten. The CPU no longer waits for a transfer, + // so the barrier orders this one after all earlier work on the queue: earlier reads of the image and an + // earlier transfer into it, still running. + leonida::detail::image_barrier(replay, slot.command, image, range, VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT); - vk.vkCmdCopyBufferToImage(command_, buffer_, image.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + vk.vkCmdCopyBufferToImage(slot.command, slot.buffer, image.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, static_cast(regions_.size()), regions_.data()); for (const auto& piece : pieces) - leonida::detail::image_barrier(replay, command_, image, piece.range, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + leonida::detail::image_barrier(replay, slot.command, image, piece.range, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, piece.layout == VK_IMAGE_LAYOUT_UNDEFINED ? VK_IMAGE_LAYOUT_GENERAL : piece.layout, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); - if ((r = vk.vkEndCommandBuffer(command_)) != VK_SUCCESS) return r; - return submit(d); + if ((r = vk.vkEndCommandBuffer(slot.command)) != VK_SUCCESS) return r; + return submit(d, slot); }); return result == VK_SUCCESS; } private: + static constexpr unsigned kSlots = 4; + struct Slot { + VkBuffer buffer{}; + VkDeviceMemory memory{}; + std::uint8_t* mapped = nullptr; + VkDeviceSize capacity = 0; + VkCommandBuffer command{}; + std::uint64_t value = 0; // the ready_ value its last transfer signals; 0: none submitted + }; + + // Waits (outside every lock but the registry's) until the slot's last transfer has completed. + template + bool wait_slot(Device& d, Slot& slot) { + if (!slot.value || !ready_) return true; + auto& vk = d.context->vk; + std::uint64_t reached = 0; + if (vk.vkGetSemaphoreCounterValue && vk.vkGetSemaphoreCounterValue(d.info.device, ready_, &reached) == VK_SUCCESS && + reached >= slot.value) { + slot.value = 0; + return true; + } + VkSemaphoreWaitInfo done{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO}; + done.semaphoreCount = 1; + done.pSemaphores = &ready_; + done.pValues = &slot.value; + if (vk.vkWaitSemaphores(d.info.device, &done, UINT64_MAX) != VK_SUCCESS) return false; + slot.value = 0; + return true; + } + + template + void wait_all(Device& d) { + for (auto& slot : slots_) wait_slot(d, slot); + } + template - void release_buffer(Device& d) { + void release_buffer(Device& d, Slot& slot) { auto& vk = d.context->vk; - if (buffer_) vk.vkDestroyBuffer(d.info.device, buffer_, nullptr); - if (memory_) vk.vkFreeMemory(d.info.device, memory_, nullptr); - buffer_ = VK_NULL_HANDLE; - memory_ = VK_NULL_HANDLE; - mapped_ = nullptr; - capacity_ = 0; + if (slot.buffer) vk.vkDestroyBuffer(d.info.device, slot.buffer, nullptr); + if (slot.memory) vk.vkFreeMemory(d.info.device, slot.memory, nullptr); + slot.buffer = VK_NULL_HANDLE; + slot.memory = VK_NULL_HANDLE; + slot.mapped = nullptr; + slot.capacity = 0; } template - bool prepare(Device& d, VkDeviceSize size) { + bool prepare(Device& d, Slot& slot, VkDeviceSize size) { auto& vk = d.context->vk; const auto dev = d.info.device; if (!pool_) { @@ -115,12 +166,12 @@ class TitleImageUpload { pool.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; if (vk.vkCreateCommandPool(dev, &pool, nullptr, &pool_) != VK_SUCCESS) return false; } - if (!command_) { + if (!slot.command) { VkCommandBufferAllocateInfo alloc{VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO}; alloc.commandPool = pool_; alloc.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; alloc.commandBufferCount = 1; - if (vk.vkAllocateCommandBuffers(dev, &alloc, &command_) != VK_SUCCESS) return false; + if (vk.vkAllocateCommandBuffers(dev, &alloc, &slot.command) != VK_SUCCESS) return false; } if (!ready_) { VkSemaphoreTypeCreateInfo timeline{VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO}; @@ -132,28 +183,32 @@ class TitleImageUpload { if (q && q != d.info.queue && std::find(consumers_.begin(), consumers_.end(), q) == consumers_.end()) consumers_.push_back(q); } - if (size <= capacity_) return true; - release_buffer(d); + // The slot's buffer and command buffer are rewritten below and in write(): its last transfer must be done. + if (!wait_slot(d, slot)) return false; + if (size <= slot.capacity) return true; + release_buffer(d, slot); VkBufferCreateInfo buffer{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; buffer.size = size; buffer.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - if (vk.vkCreateBuffer(dev, &buffer, nullptr, &buffer_) != VK_SUCCESS) return false; + if (vk.vkCreateBuffer(dev, &buffer, nullptr, &slot.buffer) != VK_SUCCESS) return false; VkMemoryRequirements req{}; - vk.vkGetBufferMemoryRequirements(dev, buffer_, &req); - memory_ = d.allocate(req, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 0); + vk.vkGetBufferMemoryRequirements(dev, slot.buffer, &req); + slot.memory = d.allocate(req, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 0); void* map = nullptr; - if (!memory_ || vk.vkBindBufferMemory(dev, buffer_, memory_, 0) != VK_SUCCESS || - vk.vkMapMemory(dev, memory_, 0, VK_WHOLE_SIZE, 0, &map) != VK_SUCCESS) { - release_buffer(d); + if (!slot.memory || vk.vkBindBufferMemory(dev, slot.buffer, slot.memory, 0) != VK_SUCCESS || + vk.vkMapMemory(dev, slot.memory, 0, VK_WHOLE_SIZE, 0, &map) != VK_SUCCESS) { + release_buffer(d, slot); return false; } - mapped_ = static_cast(map); - capacity_ = size; + slot.mapped = static_cast(map); + slot.capacity = size; return true; } + // Under tracker_mutex_ and submit_mutex_ (write_staged_title_image): submits the transfer and the other queues' + // GPU-side waits for it, and returns without waiting for it on the CPU. template - VkResult submit(Device& d) { + VkResult submit(Device& d, Slot& slot) { auto& vk = d.context->vk; ++value_; VkTimelineSemaphoreSubmitInfo timeline{VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO}; @@ -161,17 +216,15 @@ class TitleImageUpload { timeline.pSignalSemaphoreValues = &value_; VkSubmitInfo transfer{VK_STRUCTURE_TYPE_SUBMIT_INFO, &timeline}; transfer.commandBufferCount = 1; - transfer.pCommandBuffers = &command_; + transfer.pCommandBuffers = &slot.command; transfer.signalSemaphoreCount = 1; transfer.pSignalSemaphores = &ready_; auto r = vk.vkQueueSubmit(d.info.queue, 1, &transfer, VK_NULL_HANDLE); - if (r != VK_SUCCESS) return r; - // The registry may reuse these mapped bytes or retire the image as soon as write() returns. - VkSemaphoreWaitInfo done{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO}; - done.semaphoreCount = 1; - done.pSemaphores = &ready_; - done.pValues = &value_; - if ((r = vk.vkWaitSemaphores(d.info.device, &done, UINT64_MAX)) != VK_SUCCESS) return r; + if (r != VK_SUCCESS) { + --value_; + return r; + } + slot.value = value_; // GPU writes become visible to later submissions on every other queue. The primary queue has the image barrier. VkTimelineSemaphoreSubmitInfo acquire{VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO}; acquire.waitSemaphoreValueCount = 1; @@ -186,12 +239,9 @@ class TitleImageUpload { return VK_SUCCESS; } - VkBuffer buffer_{}; - VkDeviceMemory memory_{}; - std::uint8_t* mapped_ = nullptr; - VkDeviceSize capacity_ = 0; + Slot slots_[kSlots]; + unsigned next_ = 0; VkCommandPool pool_{}; - VkCommandBuffer command_{}; VkSemaphore ready_{}; std::uint64_t value_ = 0; std::vector consumers_; diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 5dd6b42e47..0b80f053bc 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -10,6 +10,7 @@ #endif #include "../src/vulkan_graphics_shader_modules.h" #include "d3d12_com.h" +#include "d3d12_compile_exit.h" #include "d3d12_pipeline_compile.h" #include "d3d12_pipeline_checkpoint.h" #include "d3d12_feature_compat.h" @@ -23,10 +24,12 @@ #include "d3d12_title_image_upload.h" #include "d3d12_title_buffer_windows.h" #include "d3d12_geometry_views.h" +#include "placed_image_map_note.h" #include "d3d12_title_image_census.h" #include "d3d12_xs_native_pso.h" #include "dxgi_com.h" #include "../src/arena_size.h" +#include "../src/arena_blocks.h" #include "../src/gfx10_descriptors.h" #include "../src/depth24_fragment.h" #include "../src/rgba4_fragment.h" @@ -39,6 +42,7 @@ #include "../src/cached_pso.h" #include "../src/pipeline_cache_file.h" #include "../src/pipeline_profile.h" +#include "../src/submit_phases.h" #include "../src/pipeline_cache_store.h" #include "../src/conservative_raster.h" #include "../src/resource_detile.h" @@ -46,6 +50,7 @@ #include "../src/shader_library.h" #include "../src/dstorage_trace.h" #include "../src/title_page_watch.h" +#include "../src/guarded_copy.h" #include "../src/title_geometry_watch.h" #include "../src/title_texture_memory.h" #include "../src/title_texture_refresh.h" @@ -53,13 +58,16 @@ #include "../src/spirv_f16_halves.h" #include "../src/spirv_stores.h" #include "../src/title_va_alias.h" +#include "../src/title_window_plan.h" #include "../src/vulkan_present.h" #include "../src/vulkan_device_filter.h" #include "../src/vulkan13_features.h" +#include "../src/vulkan_index_view.h" #include "d3d12_compute_input_probe.h" #include "../src/fsdraw_probe.h" // LOCAL DIAGNOSTIC #include "../src/local_diagnostics.h" #include "../src/mem_probe.h" // LOCAL DIAGNOSTIC +#include "../src/vulkan_aftermath.h" #include #ifdef _MSC_VER @@ -86,6 +94,8 @@ #include #include #include +#include +#include #include #include #include @@ -137,55 +147,60 @@ void log_once(const char* what, int value) { if (first_diagnostic(what, value)) std::fprintf(stderr, "[rt] d3d12: %s %d\n", what, value); } -// The base address a V# gets for a buffer address: in the title's own memory (a slot-133 buffer, a constant ring), -// the console VA of a GPU copy of it (src/title_va_alias.h, docs/d3d12_vulkan.md section 3.3); anything else -// unchanged. A V# keeps 48 address bits. An arena copy always fits; an imported buffer's address is its device -// address minus heap_base, which wraps when the driver put it below the arena: logged, and written as before. -std::uint64_t vsharp_address(std::uint64_t va, std::uint64_t bytes, - leonida::TitleVaAliases::Kind kind = leonida::TitleVaAliases::created_view) { - const std::uint64_t to = leonida::title_va_aliases().resolve(va, bytes, kind); - if (to != va && (to >> 48)) { - log_once("a V# names a title-placed buffer whose GPU copy lies below heap_base, out of a V#'s 48 bits; " - "address bits 48-63:", - int(to >> 48)); - // Which buffers: a shader that zero-extends the 48 bits reads such a V# 2^48 above the buffer (measured - // natively: garbage, or a lost device). Each distinct 64 KiB-aligned title address once, the first 32. - static std::mutex mutex; - static std::set seen; - std::lock_guard lock(mutex); - if (seen.size() < 32 && seen.insert(va >> 16).second) - std::fprintf(stderr, - "[rt] d3d12: wrapped V#: title address 0x%llx (%llu bytes, view kind %d) -> offset 0x%llx " - "from heap_base\n", - static_cast(va), static_cast(bytes), int(kind), - static_cast(to)); +// Matches the offset interpretation of the selected shader pack. +bool signed_vsharp_offsets() { + static const bool on = [] { + wchar_t value[2]{}; + return GetEnvironmentVariableW(L"LEONIDA_IMPORT_BELOW_ARENA", value, 2) == 1 && value[0] == L'1'; + }(); + return on; +} + +// The CBV/SRV/UAV slots a descriptor table declares: the end of its furthest range (D3D12 appends a range at +// D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND), an unbounded range limited by the registered heap. 0 for a sampler table or no table. +std::uint32_t table_view_descriptors(const rt::rootsig::RootParameter& param) { + if (param.type != rt::rootsig::ParamType::Table) return 0; + constexpr std::uint32_t kUnbounded = UINT_MAX; + std::uint64_t next = 0, end = 0; + for (const auto& range : param.ranges) { + const std::uint64_t start = range.offset_in_table == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ? next + : range.offset_in_table; + next = start + range.num_descriptors; + if (range.range_type != D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER) end = std::max(end, next); } - return to; + return std::uint32_t(std::min(end, kUnbounded)); } -// memcpy that a page fault ends instead of killing the process: the title may decommit a page between the -// VirtualQuery that saw it committed and the read. No C++ objects here: it is a __try frame. -// `streaming` reads with MOVNTDQA, for write-combined pages: ordinary loads from them are not cached, and memcpy -// read 64 MiB of them in 253 ms on a Core i9-13900K (253 MiB/s), MOVNTDQA in 13 to 17 ms (4 to 5 GiB/s). Paid at every submission. +// The streaming copy of copy_guarded, in a frame of its own so that a fault in it reaches copy_guarded's __except +// (src/guarded_copy.h: not in the CRT, which Wine's unwinding does not get out of, and not inline, which clang-cl does +// not cover without /EHa). MOVNTDQA, for write-combined pages: ordinary loads from them are not cached, and memcpy +// read 64 MiB of them in 253 ms on a Core i9-13900K (253 MiB/s), MOVNTDQA in 13 to 17 ms (4 to 5 GiB/s). #if defined(__clang__) && defined(_M_X64) __attribute__((target("sse4.1"))) #endif +__declspec(noinline) LEONIDA_GUARDED_NO_BUILTIN void copy_streaming(std::uint8_t* to, const std::uint8_t* from, + std::size_t bytes) { + const std::size_t head = std::min(bytes, (0 - reinterpret_cast(from)) & 63); + __movsb(to, from, head); + to += head, from += head, bytes -= head; + for (; bytes >= 64; to += 64, from += 64, bytes -= 64) { + const auto* in = reinterpret_cast(from); + const __m128i a = _mm_stream_load_si128(in), b = _mm_stream_load_si128(in + 1); + const __m128i c = _mm_stream_load_si128(in + 2), d = _mm_stream_load_si128(in + 3); + auto* out = reinterpret_cast<__m128i*>(to); + _mm_storeu_si128(out, a), _mm_storeu_si128(out + 1, b); + _mm_storeu_si128(out + 2, c), _mm_storeu_si128(out + 3, d); + } + __movsb(to, from, bytes); +} + +// A copy that a page fault ends instead of killing the process: the title may decommit or remap a page between the +// VirtualQuery that saw it committed and the read. No C++ objects here: it is a __try frame. `streaming`: for +// write-combined pages (copy_streaming). Paid at every submission. bool copy_guarded(std::uint8_t* to, const std::uint8_t* from, std::size_t bytes, bool streaming) { __try { - if (streaming) { - const std::size_t head = std::min(bytes, (0 - reinterpret_cast(from)) & 63); - std::memcpy(to, from, head); - to += head, from += head, bytes -= head; - for (; bytes >= 64; to += 64, from += 64, bytes -= 64) { - const auto* in = reinterpret_cast(from); - const __m128i a = _mm_stream_load_si128(in), b = _mm_stream_load_si128(in + 1); - const __m128i c = _mm_stream_load_si128(in + 2), d = _mm_stream_load_si128(in + 3); - auto* out = reinterpret_cast<__m128i*>(to); - _mm_storeu_si128(out, a), _mm_storeu_si128(out + 1, b); - _mm_storeu_si128(out + 2, c), _mm_storeu_si128(out + 3, d); - } - } - std::memcpy(to, from, bytes); + if (streaming) copy_streaming(to, from, bytes); + else leonida::guarded::copy(to, from, bytes); return true; } __except (EXCEPTION_EXECUTE_HANDLER) { return false; @@ -207,20 +222,25 @@ inline std::uint64_t mix_words(std::uint64_t h, const std::uint8_t* at, std::siz } return h; } +// The reads of hash_guarded, in a frame of its own: an inline load inside the __try is not covered by clang-cl +// without /EHa (src/guarded_copy.h). +__declspec(noinline) std::uint64_t hash_bytes(const std::uint8_t* p, std::size_t bytes, bool every_byte) { + std::uint64_t h = 0x9e3779b97f4a7c15ull ^ bytes; + if (bytes <= (256u << 10) || every_byte) { + h = mix_words(h, p, bytes & ~std::size_t(7)); + for (std::size_t i = bytes & ~std::size_t(7); i < bytes; ++i) h = (h ^ p[i]) * 0x100000001b3ull; + } else { + for (std::size_t page = 0; page + 4096 <= bytes; page += 4096) { + h = mix_words(h, p + page, 64); + h = mix_words(h, p + page + 2048, 64); + } + h = mix_words(h, p + bytes - 64, 64); + } + return h; +} bool hash_guarded(const std::uint8_t* p, std::size_t bytes, std::uint64_t& out, bool every_byte = false) { __try { - std::uint64_t h = 0x9e3779b97f4a7c15ull ^ bytes; - if (bytes <= (256u << 10) || every_byte) { - h = mix_words(h, p, bytes & ~std::size_t(7)); - for (std::size_t i = bytes & ~std::size_t(7); i < bytes; ++i) h = (h ^ p[i]) * 0x100000001b3ull; - } else { - for (std::size_t page = 0; page + 4096 <= bytes; page += 4096) { - h = mix_words(h, p + page, 64); - h = mix_words(h, p + page + 2048, 64); - } - h = mix_words(h, p + bytes - 64, 64); - } - out = h; + out = hash_bytes(p, bytes, every_byte); return true; } __except (EXCEPTION_EXECUTE_HANDLER) { return false; @@ -359,10 +379,13 @@ class ShadowPages { for (const Job& job : zeroed_) f(job.offset, job.bytes); } - // Brings every target up to date with the pages. Returns the bytes copied into them. - std::size_t refresh() { + // Brings every target up to date with the pages. Returns the bytes copied into them. With copy_aliased false, pages + // xmem maps at another address too are left as they are this time (DeviceState::refresh_shadows throttles them). + std::size_t refresh(bool copy_aliased = true) { + copy_aliased_ = copy_aliased; jobs_.clear(); zeroed_.clear(); + copy_bytes_ = {}; std::uint64_t queries = 0; const std::uint64_t generation = leonida::title_page_aliases::generation(); // LEONIDA_SHADOW_FULL_WALK=1 queries every page at every refresh, as before the generation skip. @@ -373,8 +396,19 @@ class ShadowPages { value[0] != '0'; }(); AcquireSRWLockExclusive(&lock_); - const std::uint64_t map_generation = leonida::title_memory_map::generation(); - const bool full_walk = always_full_walk || map_generation != map_generation_; + // Pages whose mapping, commitment or protection changed since the last walk are queried again (kRequery); the + // rest keep what is known of them. A tracker that never walked, or whose changes the journal no longer holds, + // walks everything. + std::uint64_t map_generation = leonida::title_memory_map::generation(); + bool full_walk = always_full_walk || map_generation_ == ~std::uint64_t(0); + if (!full_walk && map_generation != map_generation_ && + !leonida::title_memory_map::changes_since( + map_generation_, map_generation, first_, last_, [&](std::uintptr_t from, std::uintptr_t to) { + for (std::size_t i = (from - first_) / kPage, i1 = (to - first_ + kPage - 1) / kPage; + i < i1 && i < state_.size(); ++i) + state_[i] |= kRequery; + })) + full_walk = true; refresh_walked_all_ = full_walk; refresh_protects_ = 0; if (generation != alias_generation_) { @@ -435,9 +469,18 @@ class ShadowPages { at = first_ + i * kPage; continue; } - if (!full_walk && unchanged(state_[i0])) { + // Between the refreshes that copy aliased pages (copy_aliased_, LEONIDA_SHADOW_ALIAS_MS), pages that are + // only aliased, and pages that were not mapped or committed when last looked at (zero in the copies), are + // passed over like unchanged ones and queried at the next such refresh: a mapping change over them is in + // the journal (kRequery) anyway. speed-16/17/18: 730-820 VirtualQuery calls a refresh, ~19 us each under + // Wine (NtQueryVirtualMemory waits for Wine's virtual-memory lock, which the mapping threads hold), a + // fifth of the submitting thread's time. + const auto skip = [&](std::uint8_t s) { + return unchanged(s) || (!copy_aliased_ && (s == kAliased || s == kZero || s == (kZero | kAliased))); + }; + if (!full_walk && skip(state_[i0])) { std::size_t i = i0 + 1; - while (i < state_.size() && unchanged(state_[i])) ++i; + while (i < state_.size() && skip(state_[i])) ++i; at = first_ + i * kPage; continue; } @@ -481,11 +524,11 @@ class ShadowPages { case Watch::written: // write-watched: written since, or not known yet for (std::size_t k = i; k < j; ++k) state_[k] = std::uint8_t((state_[k] & ~(kZero | kProtected)) | kClean); - add_job(i, j, streaming); + add_job(i, j, streaming, Copy::write_watched); break; case Watch::open: // write-watched, but pinned for a kernel write: copied until the pin ends for (std::size_t k = i; k < j; ++k) state_[k] &= ~(kZero | kProtected | kClean); - add_job(i, j, streaming); + add_job(i, j, streaming, Copy::write_watched); break; case Watch::guard: if (kind == Kind::writable) @@ -499,9 +542,10 @@ class ShadowPages { break; case Kind::unwatched: for (std::size_t i = i0; i < i1; ++i) state_[i] &= kAliased | kPinned | kWatched; - add_job(i0, i1, streaming); + add_job(i0, i1, streaming, Copy::copy_on_write); break; } + for (std::size_t i = i0; i < i1; ++i) state_[i] &= std::uint8_t(~kRequery); // queried now at = next; } // Remember the generation from before the walk, so a change during the walk triggers another one. @@ -701,12 +745,22 @@ class ShadowPages { kWatched = 16, // in a write-watched reservation (leonida::title_write_watch) kClean = 32, // hot, and not written since it was copied after an asking kHot = 64, // write-watched and asked about at every refresh, never guarded + kRequery = 128, // its mapping, commitment or protection changed (title_memory_map): queried at the next walk }; // Refreshes a hot block may go without a write before it is guarded again. static constexpr std::uint8_t kCool = 64; // Hot runs this close in one reservation are asked about as one (a call costs about as much as 300 pages). static constexpr std::uintptr_t kMergeGap = 0x40000; enum class Kind { zero, writable, read_only, unwatched }; + +public: + // Why the last refresh() copied the bytes it did (copy_bytes): pages guarded now (written since, or new), pages left + // writable (no guard possible), pages xmem maps at another address too, pages pinned for a kernel write, + // read-only pages that are not this tracker's, copy-on-write pages, write-watched pages found written. + enum class Copy { guarded, unguarded, aliased, pinned, read_only, copy_on_write, write_watched, count }; + const std::array& copy_bytes() const { return copy_bytes_; } + +private: // How a committed, readable page is watched: by the kernel (clean, written or, pinned or aliased, open) or by // a guard. enum class Watch { clean, written, open, guard }; @@ -753,7 +807,14 @@ class ShadowPages { while (j < i1 && bool(state_[j] & (kAliased | kPinned)) == unwatched) ++j; for (std::size_t k = i; k < j; ++k) state_[k] &= ~(kZero | kProtected); if (!unwatched && watch_) protect(i, j, current); - add_job(i, j, streaming); + if (unwatched && !copy_aliased_ && (state_[i] & kAliased)) { + i = j; + continue; + } + add_job(i, j, streaming, + !unwatched ? (watch_ && (state_[i] & kProtected) ? Copy::guarded : Copy::unguarded) + : (state_[i] & kAliased) ? Copy::aliased + : Copy::pinned); i = j; } } @@ -765,9 +826,12 @@ class ShadowPages { const bool clean = (state_[i] & (kProtected | kAliased | kPinned)) == kProtected; std::size_t j = i + 1; while (j < i1 && ((state_[j] & (kProtected | kAliased | kPinned)) == kProtected) == clean) ++j; - if (!clean) { + if (!clean && !(!copy_aliased_ && (state_[i] & kAliased))) { for (std::size_t k = i; k < j; ++k) state_[k] &= ~kZero; - add_job(i, j, streaming); + add_job(i, j, streaming, + state_[i] & kAliased ? Copy::aliased + : state_[i] & kPinned ? Copy::pinned + : Copy::read_only); } i = j; } @@ -864,8 +928,9 @@ class ShadowPages { return {from - begin_, to - from}; } - void add_job(std::size_t i, std::size_t j, bool streaming) { + void add_job(std::size_t i, std::size_t j, bool streaming, Copy why) { const auto [offset, bytes] = span_of(i, j); + copy_bytes_[unsigned(why)] += bytes; if (!jobs_.empty() && jobs_.back().streaming == streaming && jobs_.back().offset + jobs_.back().bytes == offset) { jobs_.back().bytes += bytes; @@ -973,6 +1038,8 @@ class ShadowPages { Vector jobs_; // refresh() only, which DeviceState::shadow_mutex serializes Vector zeroed_; // likewise DWORD protect_error_ = 0; // a VirtualProtect refusal of this refresh(), logged after it + std::array copy_bytes_{}; // refresh() only, likewise + bool copy_aliased_ = true; // likewise std::uint64_t refresh_queries_ = 0; std::uint64_t refresh_protects_ = 0; // VirtualProtect calls of the last refresh() bool refresh_walked_all_ = false; // the last refresh() queried every page (the title memory map changed) @@ -999,23 +1066,47 @@ leonida::host_heap::vector& shadow_pages_list() { // A write to a page a shadow made read-only: the page is made writable again and the write retried. First in the // handler chain, so a startup trace doesn't log these as exceptions; any other access violation goes on down it. +// Whatever thread wrote: the title's, or a host thread of the runtime's (a DirectStorage queue's copy). +// +// A physical page xmem maps at two addresses (a stream pool's CPU view and its GPU-only twin) has a protection per +// address: a guard on one view never faults a write through the other, which the shadows see by copying aliased +// pages at every submission (title_page_aliases), so the guard to look for is the faulting address's own. When none +// answers for it (each guard reopens only what it protected), xmem makes the page writable again if its window is +// (kernel_writes' unguarder): a read-only page nobody reopens would fault that write, and every later one, for good. LONG CALLBACK shadow_write_fault(EXCEPTION_POINTERS* info) { const EXCEPTION_RECORD* record = info ? info->ExceptionRecord : nullptr; if (!record || record->ExceptionCode != EXCEPTION_ACCESS_VIOLATION || record->NumberParameters < 2 || record->ExceptionInformation[0] != 1) return EXCEPTION_CONTINUE_SEARCH; const auto address = static_cast(record->ExceptionInformation[1]); - bool retry = leonida::geometry_writes::notify(address, address + 1, leonida::geometry_writes::Event::fault); + bool tile_reopened = false; + bool retry = leonida::geometry_writes::notify(address, address + 1, leonida::geometry_writes::Event::fault, + &tile_reopened); + // The geometry watch reopened the whole 64 KiB tile around the address: the shadows over it reopen it too, so a + // page both guarded is not left writable while its shadow takes it for unchanged. + constexpr std::uintptr_t kTile = leonida::geometry_writes::tile_size; + const std::uintptr_t tile = address & ~(kTile - 1); AcquireSRWLockShared(&g_shadow_pages_lock); - for (ShadowPages* pages : shadow_pages_list()) + for (ShadowPages* pages : shadow_pages_list()) { if (pages->contains(address)) retry |= pages->reopen(address); // reopened, or another thread's fault did + if (tile_reopened && pages->first() < tile + kTile && tile < pages->last()) pages->reopen_range(tile, tile + kTile); + } ReleaseSRWLockShared(&g_shadow_pages_lock); + if (!retry) + if (const auto unguard = leonida::kernel_writes::state().unguarder.load(std::memory_order_acquire)) + retry = unguard(address, address + 1); return retry ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH; } // leonida::kernel_writes' opener: a file shim is about to let the kernel write [from, to). void open_shadow_pages(std::uintptr_t from, std::uintptr_t to) { - leonida::geometry_writes::notify(from, to, leonida::geometry_writes::Event::open); + bool tiles_reopened = false; + leonida::geometry_writes::notify(from, to, leonida::geometry_writes::Event::open, &tiles_reopened); + if (tiles_reopened) { // whole tiles were reopened: so are the shadows' pages there (see shadow_write_fault) + constexpr std::uintptr_t kTile = leonida::geometry_writes::tile_size; + from &= ~(kTile - 1); + to = (to + kTile - 1) & ~(kTile - 1); + } AcquireSRWLockShared(&g_shadow_pages_lock); for (ShadowPages* pages : shadow_pages_list()) pages->reopen_range(from, to); ReleaseSRWLockShared(&g_shadow_pages_lock); @@ -1965,6 +2056,8 @@ struct DeviceState { std::uint64_t shadow_walks = 0; // trackers that queried every page (the title memory map changed), likewise std::uint64_t shadow_asks = 0; // GetWriteWatch calls, likewise std::uint64_t shadow_written = 0; // write-watched pages they found written, likewise + std::array shadow_copy_bytes{}; // by cause, likewise + std::chrono::steady_clock::time_point shadow_alias_time{}; // the last refresh that copied aliased pages double shadow_ms = 0; // spent since the last log line double shadow_max_ms = 0; // the longest refresh since the last log line double heap_ms = 0; // spent in refresh_console_heaps since the last log line @@ -2015,24 +2108,42 @@ struct DeviceState { return; } } - void refresh_shadows() { + // heaps / pages: whether this submission refreshes the console heaps and the slot-133 shadows and title windows + // (LEONIDA_REFRESH_PER_FRAME leaves some submissions without them). + void refresh_shadows(bool heaps = true, bool pages = true) { using clock = std::chrono::steady_clock; // First, and without shadow_mutex: fixing a console heap's slots can make a title window (add_shadow). const auto heaps_start = clock::now(); - refresh_console_heaps(); + if (heaps) { + const leonida::submit_phases::Scope timed(leonida::submit_phases::heaps); + refresh_console_heaps(); + } heap_ms += std::chrono::duration(clock::now() - heaps_start).count(); probe_census(); // LOCAL DIAGNOSTIC + if (!pages) return; + const leonida::submit_phases::Scope timed(leonida::submit_phases::shadows); std::lock_guard lock(shadow_mutex); if (shadows.empty()) return; const auto start = clock::now(); + // LEONIDA_SHADOW_ALIAS_MS (0 by default: every submission): pages xmem maps at two addresses, which no guard + // can watch, are copied at most this often. After the story load they were 59 MiB a submission (speed-6); a + // GPU read of them is at most this many milliseconds behind the title's writes. + static const auto alias_period = std::chrono::milliseconds([] { + char text[16] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_SHADOW_ALIAS_MS", text, sizeof(text)); + return n > 0 && n < sizeof(text) ? std::strtoull(text, nullptr, 10) : 0ull; + }()); + const bool copy_aliased = alias_period.count() == 0 || start - shadow_alias_time >= alias_period; + if (copy_aliased) shadow_alias_time = start; std::uint64_t copied = 0; for (const ShadowPagesPtr& s : shadows) { - copied += s->refresh(); + copied += s->refresh(copy_aliased); shadow_queries += s->refresh_queries(); shadow_protects += s->refresh_protects(); shadow_walks += s->refresh_walked_all(); shadow_asks += s->refresh_asks(); shadow_written += s->refresh_written(); + for (unsigned k = 0; k < shadow_copy_bytes.size(); ++k) shadow_copy_bytes[k] += s->copy_bytes()[k]; } const auto now = clock::now(); const double ms = std::chrono::duration(now - start).count(); @@ -2061,6 +2172,14 @@ struct DeviceState { double(shadow_protects) / count, double(shadow_asks) / count, double(shadow_written) / count, double(shadow_walks) / count, static_cast(faults >= shadow_faults ? faults - shadow_faults : faults)); + const auto kib = [&](ShadowPages::Copy c) { return double(shadow_copy_bytes[unsigned(c)]) / 1024.0 / count; }; + std::fprintf(stderr, + "[rt] d3d12: slot-133 shadow copies by cause, KiB a submission: guarded now %.1f, unguarded %.1f, " + "aliased %.1f, pinned %.1f, read-only (not ours) %.1f, copy-on-write %.1f, write-watched %.1f\n", + kib(ShadowPages::Copy::guarded), kib(ShadowPages::Copy::unguarded), kib(ShadowPages::Copy::aliased), + kib(ShadowPages::Copy::pinned), kib(ShadowPages::Copy::read_only), + kib(ShadowPages::Copy::copy_on_write), kib(ShadowPages::Copy::write_watched)); + shadow_copy_bytes = {}; shadow_logged = shadow_submissions; shadow_log_time = now; shadow_bytes = shadow_queries = shadow_protects = shadow_walks = shadow_asks = shadow_written = 0; @@ -2084,19 +2203,36 @@ struct DeviceState { // slot-133 buffer (a per-frame constant ring, #8862 section 3.5) gets a copy of the 64 KiB-aligned pages it // covers, refreshed before every submission like a slot-133 shadow, and the address of that copy. Windows are // kept until the device goes (the ring comes round to the same pages), up to LEONIDA_TITLE_WINDOWS_MB (64 MiB - // by default); past that, or with the arena full, the address is left as it was and counted. + // by default). A window that does not fit is not made: the range is backed by a geometry copy instead, or the + // view written with a zero-size range (src/title_window_plan.h). struct TitleWindow { std::uint64_t start; std::uint64_t shader_va; }; static constexpr std::uint64_t kTitleWindowAlign = 65536; static constexpr std::uint64_t kTitleWindowMax = 16ull << 20; // the most one address pulls in + // One mapping serves this much of a stream pool: the readable run of a 16-24 GiB reservation, whose frames the + // title remaps per request, so a whole-pool allocation is not possible. + static constexpr std::uint64_t kPoolExtentMax = 1ull << 20; std::mutex title_window_mutex; // taken before shadow_mutex, never under it rt::d3d12::TitleBufferWindows external_windows; std::vector title_windows; std::atomic title_window_count{0}; // title_windows.size(), read without the mutex std::uint64_t title_window_bytes = 0; std::uint64_t title_window_cap = 64ull << 20; + // The stream pools' mappings (title_gpu_views): one per readable run of a pool, kept for the device's life. + struct PoolSpan { + std::uint64_t source; // the readable side of the pair the copy is made from + std::uint64_t twin; // the extent's address in the pair's other view (0 when there is none) + std::uint64_t shader_va; + std::uint64_t size; + bool geometry; // a geometry copy, not charged to the title-window budget + }; + std::vector pool_spans; + std::atomic pool_span_count{0}; + std::uint64_t pool_span_bytes = 0; + std::uint64_t title_window_refusals = 0; // windows neither the budget nor the arena allowed + std::uint64_t unbacked_requests = 0; // title addresses no backing could be made for (zero-size views) rt::d3d12::GeometryViews geometry; static rt::d3d12::GeometryCopy copy_geometry(std::uint8_t* to, const std::uint8_t* from, std::size_t size) { @@ -2123,14 +2259,179 @@ struct DeviceState { return geometry.resolve(*this, cpu, span, copy_geometry); } + // LEONIDA_STREAM_BUFFER_WINDOWS=0: a window may not come from a block outside the arena. + static bool stream_windows() { + static const bool enabled = [] { + const char* flag = std::getenv("LEONIDA_STREAM_BUFFER_WINDOWS"); + return !flag || std::string_view(flag) != "0"; + }(); + return enabled; + } + + // A committed page the host may read: the title's reservations start uncommitted. + static bool readable_page(std::uint64_t address) { + MEMORY_BASIC_INFORMATION region{}; + return VirtualQuery(reinterpret_cast(static_cast(address)), ®ion, + sizeof(region)) && + region.State == MEM_COMMIT && region.Protect && !(region.Protect & (PAGE_NOACCESS | PAGE_GUARD)); + } + + // The end of the readable run that starts at the page `address`, at most `end` (a pool's frames are mapped per + // request, so its range is read until the first page the title has not committed). + static std::uint64_t readable_run_end(std::uint64_t address, std::uint64_t end) { + std::uint64_t at = address; + while (at < end) { + MEMORY_BASIC_INFORMATION region{}; + if (!VirtualQuery(reinterpret_cast(static_cast(at)), ®ion, + sizeof(region)) || + region.State != MEM_COMMIT || !region.Protect || (region.Protect & (PAGE_NOACCESS | PAGE_GUARD))) + break; + const auto region_end = reinterpret_cast(region.BaseAddress) + region.RegionSize; + if (region_end <= at) break; + at = region_end; + } + return std::min(at, end); + } + + // One line per call site (and then at 2, 4, 8... of it): a view the layer had to write with no backing, and how + // many so far. It is written with a zero-size range, so a shader never adds heap_base to a raw title address. + void note_unbacked(const char* site, std::uint64_t va, std::uint64_t bytes) { + static std::mutex mutex; + static std::map counts; + std::lock_guard lock(mutex); + std::uint64_t& seen = counts[site]; + ++seen; + if (seen != 1 && (seen & (seen - 1))) return; + std::fprintf(stderr, + "[rt] d3d12: %s: title address 0x%llx (%llu bytes) got no GPU copy: the view is written with no " + "records (loads 0, stores dropped); %llu so far\n", + site, static_cast(va), static_cast(bytes), + static_cast(seen)); + } + + // A window for [start, start + size): an arena range or a block outside the arena, charged to + // LEONIDA_TITLE_WINDOWS_MB and refreshed before every submission by the tracker of its pages. 0 when neither the + // budget nor the arena has room. title_window_mutex held. + std::uint64_t make_title_window(std::uint64_t start, std::uint64_t size) { + if (!leonida::title_window_fits(title_window_cap, title_window_bytes, size)) { + ++title_window_refusals; + log_once("title memory named by a shader address is past LEONIDA_TITLE_WINDOWS_MB, no window; MiB copied " + "so far:", + int(title_window_bytes >> 20)); + return 0; + } + VkDeviceSize offset = 0; + std::uint8_t* mapped{}; + if (arena_allocate(size, kTitleWindowAlign, offset, arena_buffer)) { + mapped = arena.mapped + offset; + } else if (!stream_windows() || !external_windows.allocate(*this, size, offset, mapped)) { + ++title_window_refusals; + log_once("GPU address arena full (raise LEONIDA_ARENA_MB): title memory has no window; window KiB:", + int(std::min(size >> 10, INT_MAX))); + return 0; + } + if (offset >= arena.size) backing(arena.address + offset, size, start, true); + const auto* pages = reinterpret_cast(static_cast(start)); + add_shadow(pages, mapped, std::size_t(size)); + title_windows.push_back({start, offset}); + title_window_count.store(title_windows.size(), std::memory_order_relaxed); + title_window_bytes += size; + if (title_windows.size() <= 4 || !(title_windows.size() & (title_windows.size() - 1))) + std::fprintf(stderr, "[rt] d3d12: a %llu KiB window of the title's memory, named by a shader address, is " + "mirrored before every submission (%zu windows, %llu KiB)\n", + static_cast(size >> 10), title_windows.size(), + static_cast(title_window_bytes >> 10)); + return offset; + } + + // A stream pool's address (a CPU view paired with a GPU-only alias). Rule B + // first: the CPU view is where the host reads the frames, so that is what the copy is made from; the GPU-only + // pages are the same frames through the title's queue slot 31 and are read only when the CPU view is not + // committed. One mapping serves a page-aligned readable run (kPoolExtentMax at most), not one 128 KiB window per + // vertex buffer, and both of the pair's addresses are entered in the table, so a V# naming either view reaches + // the same bytes instead of asking for a second mapping. + // True when `va` is in a pool (out = its shader VA, or 0 when nothing could back the run). title_window_mutex + // held. + bool resolve_pool_memory(std::uint64_t va, std::uint64_t bytes, std::uint64_t& out) { + leonida::title_gpu_views::Range view{}; + if (!leonida::title_gpu_views::view_at(static_cast(va), + static_cast(std::max(bytes, 1)), view)) + return false; + const std::uint64_t offset = va >= view.gpu && va - view.gpu < view.size ? va - view.gpu : va - view.cpu; + // Rule B: the CPU view where the host reads the frames, the GPU-only pages only when that view has none. + const std::uint64_t source = leonida::title_gpu_views::to_host_view(static_cast(va), + static_cast( + std::max(bytes, 1))); + const std::uint64_t twin = leonida::title_gpu_views::other_view(static_cast(source)); + const std::uint64_t twin_view = twin ? twin : source; // the pair always has two addresses + if (!readable_page(source)) { + out = 0; + ++unbacked_requests; + note_unbacked("stream pool", va, bytes); + return true; + } + const std::uint64_t pool_end = (source >= view.gpu && source - view.gpu < view.size ? view.gpu : view.cpu) + + view.size; + const std::uint64_t run_end = + readable_run_end(source & ~(kTitleWindowAlign - 1), std::min(pool_end, source + kPoolExtentMax)); + leonida::TitleWindowRange extent{}; + if (!leonida::title_pool_extent(source - offset, pool_end, source, run_end, kTitleWindowAlign, kPoolExtentMax, + extent)) { + out = 0; + ++unbacked_requests; + note_unbacked("stream pool", va, bytes); + return true; + } + const std::uint64_t twin_start = twin_view - (source - extent.start); // the same pages in the other view + auto& aliases = leonida::title_va_aliases(); + // A mapping that already holds the extent's start (a buffer made over these pages, or a window from another + // request) serves the request only as far as it reaches: claim that much, never bytes it does not cover. + std::uint64_t shader = 0, available = 0; + if (aliases.range_of(extent.start, shader, available) || + aliases.range_of(twin_start, shader, available)) { + if (available < extent.size) { + if (available <= source - extent.start) shader = 0; + else extent.size = available; + } + } + if (shader) { + // Both addresses must reach it. The address the mapping was found at keeps its own (possibly wider) + // range: adding a shorter one over it would drop bytes another view still uses. + if (aliases.shader_va(twin_start) == twin_start) aliases.add(twin_start, extent.size, shader); + if (aliases.shader_va(extent.start) == extent.start) aliases.add(extent.start, extent.size, shader); + } else { + bool geometry_copy = false; + if (geometry.cap() && watch_shadow_writes() && !context->knows_buffer_va(extent.start, extent.size)) + shader = geometry.resolve(*this, extent.start, extent.size, copy_geometry), geometry_copy = shader != 0; + if (!shader) shader = make_title_window(extent.start, extent.size); + if (!shader) { + out = 0; + ++unbacked_requests; + note_unbacked("stream pool", va, bytes); + return true; + } + aliases.add_twin(extent.start, twin_start, extent.size, shader); + pool_spans.push_back({extent.start, twin_start, shader, extent.size, geometry_copy}); + pool_span_count.store(pool_spans.size(), std::memory_order_relaxed); + pool_span_bytes += extent.size; + if (pool_spans.size() <= 4 || !(pool_spans.size() & (pool_spans.size() - 1))) + std::fprintf(stderr, + "[rt] d3d12: a %llu KiB stream-pool extent is one %s mapping (alias 0x%llx and CPU view " + "0x%llx share shader VA 0x%llx; %zu extents, %llu KiB)\n", + static_cast(extent.size >> 10), + geometry_copy ? "geometry-copy" : "window", static_cast(twin_view), + static_cast(source), static_cast(shader), + pool_spans.size(), static_cast(pool_span_bytes >> 10)); + } + out = shader + (source - extent.start); + return true; + } + // Called through title_va_aliases().resolve for an address with no copy yet. False: not the title's memory. + // True: it is, and `out` is its shader VA, 0 when no backing could be made (never the raw address). bool resolve_title_memory(std::uint64_t va, std::uint64_t bytes, std::uint64_t& out) { out = va; if (!arena.mapped || !context) return false; - static const bool stream_windows = [] { - const char* flag = std::getenv("LEONIDA_STREAM_BUFFER_WINDOWS"); - return !flag || std::string_view(flag) != "0"; - }(); if (context->knows_buffer_va(va)) return false; // an upload or readback buffer's biased VA, say if (va < arena.size) { // Below the arena's size an address is an arena address unless the title's own memory is there (its @@ -2139,59 +2440,283 @@ struct DeviceState { if (!leonida::title_va_aliases().title_memory(va, lo, hi)) return false; } auto& aliases = leonida::title_va_aliases(); - // Only the title's own memory gets a copy (xmem's ranges): an address anywhere else, the runtime's or a host - // DLL's memory included, is left as it was and counted. + // Only title memory can request a new copy. Elsewhere, require existing GPU backing. std::uint64_t title_lo = 0, title_hi = 0; - if (!aliases.title_memory(va, title_lo, title_hi)) return true; - MEMORY_BASIC_INFORMATION mbi{}; - if (!VirtualQuery(reinterpret_cast(static_cast(va)), &mbi, sizeof(mbi)) || - mbi.State != MEM_COMMIT || !mbi.Protect || (mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD))) + if (!aliases.title_memory(va, title_lo, title_hi)) { + // Root descriptors carry a pointer without a declared length. Validate the base. + out = vsharp_address(va, 1, leonida::TitleVaAliases::root_view, false); return true; + } + const std::uint64_t want = std::max(bytes, 1); std::lock_guard lock(title_window_mutex); if (const std::uint64_t made = aliases.shader_va(va); made != va) { // another thread made it meanwhile out = made; return true; } - std::uint64_t lo = 0, hi = UINT64_MAX; - aliases.gap(va, lo, hi); // never over a slot-133 buffer's range or another window - lo = std::max(lo, title_lo); // nor past the title's range - hi = std::min(hi, title_hi); - const std::uint64_t want = std::clamp(bytes, 1, kTitleWindowMax); - const std::uint64_t start = std::max(va & ~(kTitleWindowAlign - 1), lo); - std::uint64_t end = va > UINT64_MAX - want - kTitleWindowAlign ? UINT64_MAX - : (va + want + kTitleWindowAlign - 1) & - ~(kTitleWindowAlign - 1); - end = std::min(end, hi); - if (end <= va) return true; - const std::uint64_t size = end - start; - if (title_window_bytes + size > title_window_cap) { - log_once("title memory named by a shader address is past LEONIDA_TITLE_WINDOWS_MB, left untranslated; " - "MiB copied so far:", - int(title_window_bytes >> 20)); + // A stream pool's address: one mapping for its readable run, shared by both of its views. + if (resolve_pool_memory(va, bytes, out)) return true; + if (readable_page(va)) { + std::uint64_t lo = 0, hi = UINT64_MAX; + aliases.gap(va, lo, hi); // never over a slot-133 buffer's range or another window + lo = std::max(lo, title_lo); // nor past the title's range + hi = std::min(hi, title_hi); + leonida::TitleWindowRange range{}; + if (leonida::title_window_range(va, want, lo, hi, kTitleWindowAlign, kTitleWindowMax, title_window_cap, + title_window_bytes, range)) { + if (const std::uint64_t offset = make_title_window(range.start, range.size)) { + aliases.add(range.start, range.size, offset); + out = offset + (va - range.start); + return true; + } + } + } + // No window (the budget or the arena is full, or the page is not committed yet): the persistent geometry + // copy backs the range instead, refreshed when its source pages change. A raw address never comes out of + // this; when neither backing is available the view is written with no records. + if (const std::uint64_t copy = geometry_va(va, want, false)) { + aliases.add(va, want, copy); + out = copy; return true; } - VkDeviceSize offset = 0; - std::uint8_t* mapped{}; - if (arena_allocate(size, kTitleWindowAlign, offset, arena_buffer)) { - mapped = arena.mapped + offset; - } else if (!stream_windows || !external_windows.allocate(*this, size, offset, mapped)) { - log_once("GPU address arena full (raise LEONIDA_ARENA_MB): title memory left untranslated; window KiB:", - int(std::min(size >> 10, INT_MAX))); + out = 0; + ++unbacked_requests; + note_unbacked("title memory", va, bytes); + return true; + } + + // ---- Acceleration-structure addresses (XDXR builds, docs/d3d12_vulkan.md 4.8) ---- + // A BuildRaytracingAccelerationStructure, CopyRaytracingAccelerationStructure or postbuild names its memory by the + // title's GPU VAs, and the builder reaches each at heap_base + VA. A VA in the title's own memory (a slot-133 + // buffer, or pages no resource covers: the retail title builds into its own heap) is past the arena, so heap_base + // + VA is no allocation, and the first write of a build there lost the device (measured natively with Nsight + // Aftermath: xdxr_build.comp MODE_INIT, an MMU write fault at heap_base + a title address). So every address goes + // through the same resolver as the root views and V#s (src/title_va_alias.h): it becomes the VA of the memory's + // GPU copy, and the copy must hold every byte the builder touches from it. An address that has no such copy is + // refused, and the command is not recorded: nothing is written through it, and the destination keeps what it had. + enum BvhField : unsigned { bvh_dst, bvh_scratch, bvh_source, bvh_instances, bvh_vertices, bvh_indices, + bvh_transform, bvh_copy_dst, bvh_copy_src, bvh_postbuild_dst, bvh_postbuild_src, + bvh_layout, bvh_field_count }; + static constexpr const char* kBvhFieldNames[bvh_field_count] = { + "destination", "scratch", "update source", "instance descs", "vertices", "indices", "transform", + "copy destination", "copy source", "postbuild destination", "postbuild source", "instance pointer array"}; + std::array, bvh_field_count> bvh_refused{}; + std::atomic bvh_refused_total{0}, bvh_resolved_builds{0}, bvh_translated{0}; + // Each structure's layout size by the title VA it was built at, so a copy of it knows how much to pull in. + std::mutex bvh_size_mutex; + std::map bvh_sizes; + + // The VA shaders reach [va, va + bytes) by, in `out`; `room` (when given) gets the bytes the copy has from `va` + // on when it is one of the title's ranges, and 0 for an arena VA (the replay sizes it by its buffer). `gpu`: the + // builder writes the bytes, or they are a structure it wrote (a destination, scratch, an update or copy source): + // only the title-memory copies the GPU's writes stay in (a slot-133 import or shadow, a title window). Otherwise + // they are inputs the title wrote (vertices, indices, a transform, instance descs), which a geometry copy can also + // answer, as for a placed buffer view. False: no copy holds all of the bytes. + // A persistent copy of exactly [va, va + bytes) from the title's pages, entered in the alias table, so a shader + // or a build reaches the whole range by one address. A GPU-written structure (a BVH destination or its scratch) + // keeps the GPU's writes in the copy: that is the only place the structure is read from afterwards, so the copy + // is the structure. It is made even when a shorter range already maps the start: spreading a window's address over + // bytes it does not cover would be a lie. 0 when geometry copies are off (LEONIDA_GEOMETRY_MB), their cap refuses + // it, or the range is not the title's memory. + std::uint64_t copy_title_range(std::uint64_t va, std::uint64_t bytes) { + const std::uint64_t span = std::max(bytes, 1); + auto& aliases = leonida::title_va_aliases(); + std::uint64_t lo = 0, hi = 0; + if (!geometry.cap() || !watch_shadow_writes() || !aliases.title_memory(va, lo, hi) || span > hi - va) return 0; + const auto cpu = leonida::title_gpu_views::to_host_view(static_cast(va), + static_cast(span)); + if (context->knows_buffer_va(cpu, span)) return 0; + const std::uint64_t copy = geometry.resolve(*this, cpu, span, copy_geometry); + if (!copy) return 0; + std::lock_guard lock(title_window_mutex); + aliases.add(va, span, copy); + return copy; + } + + bool bvh_va(std::uint64_t va, std::uint64_t bytes, bool gpu, std::uint64_t& out, std::uint64_t* room = nullptr) { + out = va; + if (room) *room = 0; + if (!va) return true; + bytes = std::max(bytes, 1); + if (va > UINT64_MAX - bytes) return false; + auto& aliases = leonida::title_va_aliases(); + if (!gpu) { + if (const std::uint64_t copy = geometry_va(va, bytes, true)) { + out = copy; + if (room) *room = bytes; + if (copy != va) bvh_translated.fetch_add(1, std::memory_order_relaxed); + return true; + } + } + const std::uint64_t to = aliases.resolve(va, bytes, leonida::TitleVaAliases::bvh_address); + std::uint64_t shader = 0, available = 0; + if (aliases.range_of(va, shader, available)) { + // The range the address is in must be the one it was translated by, and reach past the last byte: a + // window is at most kTitleWindowMax and stops at the next range, so a large structure can outrun it. + if (shader == to && available >= bytes) { + out = shader; + if (room) *room = available; + bvh_translated.fetch_add(1, std::memory_order_relaxed); + return true; + } + } + // No range holds all of it (no window at all after the budget ran out, or one that ends early): a copy of + // the whole structure backs it, so the command is recorded and its destination or scratch is reachable. + if (const std::uint64_t copy = copy_title_range(va, bytes)) { + out = copy; + if (room) *room = bytes; + bvh_translated.fetch_add(1, std::memory_order_relaxed); return true; } - const auto* pages = reinterpret_cast(static_cast(start)); - // Filled now and refreshed before every submission with the slot-133 shadows, by the tracker of its pages. - add_shadow(pages, mapped, std::size_t(size)); - aliases.add(start, size, offset); - title_windows.push_back({start, offset}); - title_window_count.store(title_windows.size(), std::memory_order_relaxed); - title_window_bytes += size; - if (title_windows.size() <= 4 || !(title_windows.size() & (title_windows.size() - 1))) - std::fprintf(stderr, "[rt] d3d12: a %llu KiB window of the title's memory, named by a shader address, is " - "mirrored before every submission (%zu windows, %llu KiB)\n", - static_cast(size >> 10), title_windows.size(), - static_cast(title_window_bytes >> 10)); - out = offset + (va - start); + if (to != va) return false; + // Not in a range: an arena VA, or one of the layer's buffers outside the arena (an upload or readback heap, + // whose VA is its device address minus heap_base). The title's own memory without a copy is neither. + std::uint64_t lo = 0, hi = 0; + if (aliases.title_memory(va, lo, hi)) return false; + if (va + bytes <= arena.size) return true; + return context && context->knows_buffer_va(va, bytes); + } + + void bvh_refuse(BvhField field, std::uint64_t va, std::uint64_t bytes) { + const std::uint64_t first = bvh_refused[field].fetch_add(1, std::memory_order_relaxed); + const std::uint64_t total = bvh_refused_total.fetch_add(1, std::memory_order_relaxed) + 1; + if (!first) + std::fprintf(stderr, + "[rt] d3d12: an acceleration-structure command was not recorded: its %s at 0x%llx (%llu " + "bytes) has no GPU copy that holds all of it (title memory without a window, past " + "LEONIDA_TITLE_WINDOWS_MB, a window that ends early, or no allocation); nothing is written " + "through it\n", + kBvhFieldNames[field], static_cast(va), + static_cast(bytes)); + if (total & (total - 1)) return; + char counts[512]; + int at = 0; + for (unsigned f = 0; f < bvh_field_count && at < int(sizeof counts) - 64; ++f) + if (const std::uint64_t n = bvh_refused[f].load(std::memory_order_relaxed)) + at += std::snprintf(counts + at, sizeof counts - std::size_t(at), "%s%s %llu", at ? ", " : "", + kBvhFieldNames[f], static_cast(n)); + std::fprintf(stderr, + "[rt] d3d12: %llu acceleration-structure commands not recorded for an unresolved address (%s); " + "%llu builds resolved, %llu addresses translated to GPU copies\n", + static_cast(total), counts, + static_cast(bvh_resolved_builds.load(std::memory_order_relaxed)), + static_cast(bvh_translated.load(std::memory_order_relaxed))); + } + + void bvh_note_size(std::uint64_t title_va, std::uint64_t bytes) { + if (!title_va || !bytes) return; + std::lock_guard lock(bvh_size_mutex); + if (bvh_sizes.size() >= (1u << 16)) bvh_sizes.clear(); // a guess only: it sizes a copy's window + bvh_sizes[title_va] = bytes; + } + std::uint64_t bvh_known_size(std::uint64_t title_va) { + std::lock_guard lock(bvh_size_mutex); + const auto it = bvh_sizes.find(title_va); + return it == bvh_sizes.end() ? 0 : it->second; + } + + // BuildRaytracingAccelerationStructure: every address of `b` in place, or false (logged) when one has no copy. + // Unchanged on a device that builds KHR structures (they are named by their resources' VAs) or none. + bool resolve_xdxr_build(leonida::BuildAccelerationStructure& b) { + if (!context || !context->xdxr_acceleration_structures()) return true; + leonida::XdxrLayout layout; + // A count the format cannot hold: left as it was, and refused when the list is prepared (xdxr_check). + if (!layout.compute(leonida::VulkanContext::xdxr_elements(b), b.is_tlas, + leonida::VulkanContext::xdxr_box16(b))) + return true; + const std::uint64_t title_dst = b.dst_va; + std::uint64_t out = 0; + // The destination holds the records the traversal shaders find by a 256-byte-unit address (an INSTANCE + // record's BLAS, a BVH descriptor's base), so its copy must keep that alignment. + if (!bvh_va(b.dst_va, layout.size, true, out) || (out & 255)) + return bvh_refuse(bvh_dst, b.dst_va, layout.size), false; + b.dst_va = out; + // The other addresses keep the alignment D3D12 gives them too (CommandList checks it again). + if (!bvh_va(b.scratch_va, layout.scratch, true, out) || (out & 255)) + return bvh_refuse(bvh_scratch, b.scratch_va, layout.scratch), false; + b.scratch_va = out; + if (b.update && b.src_va) { + if (b.src_va == title_dst) { + b.src_va = b.dst_va; + } else { + if (!bvh_va(b.src_va, layout.size, true, out) || (out & 255)) + return bvh_refuse(bvh_source, b.src_va, layout.size), false; + b.src_va = out; + } + } + if (b.is_tlas) { + // The builder reads 64-byte descs one after another (xdxr_build.comp MODE_INSTANCES); a pointer array + // would be read as descs, past its end. + if (b.instance_count && b.instance_pointers) + return bvh_refuse(bvh_layout, b.instances_va, 8ull * b.instance_count), false; + if (b.instance_count) { + if (!bvh_va(b.instances_va, 64ull * b.instance_count, false, out)) + return bvh_refuse(bvh_instances, b.instances_va, 64ull * b.instance_count), false; + b.instances_va = out; + } + } else { + for (auto& t : b.triangles) { + const std::uint64_t triangles = (t.index_type ? t.index_count : t.vertex_count) / 3; + if (!triangles) continue; + // Unindexed: three vertices a triangle. Indexed: the VertexCount the title declared (indices past + // it read past the buffer, as on the console). + const std::uint64_t vertices = t.index_type ? t.vertex_count : 3 * triangles; + const std::uint64_t element = t.vertex_format == VK_FORMAT_R32G32_SFLOAT ? 8 : 12; + const std::uint64_t vertex_bytes = vertices ? (vertices - 1) * t.vertex_stride + element : 0; + if (vertex_bytes && !bvh_va(t.vertex_va, vertex_bytes, false, out)) + return bvh_refuse(bvh_vertices, t.vertex_va, vertex_bytes), false; + t.vertex_va = out; + if (t.index_type && t.index_va) { + const std::uint64_t index_bytes = 3 * triangles * (t.index_type == 1 ? 2 : 4); + if (!bvh_va(t.index_va, index_bytes, false, out)) + return bvh_refuse(bvh_indices, t.index_va, index_bytes), false; + t.index_va = out; + } + if (t.transform_va) { + if (!bvh_va(t.transform_va, 48, false, out)) + return bvh_refuse(bvh_transform, t.transform_va, 48), false; + t.transform_va = out; + } + } + } + bvh_note_size(title_dst, layout.size); + bvh_resolved_builds.fetch_add(1, std::memory_order_relaxed); + return true; + } + + // CopyRaytracingAccelerationStructure: both addresses, with the room their copies have (the replay bounds the + // copy by it). The source's size comes from its build when the layer saw it, else from its header only. + bool resolve_xdxr_copy(leonida::CopyAccelerationStructure& c) { + if (!context || !context->xdxr_acceleration_structures()) return true; + const std::uint64_t known = bvh_known_size(c.src_va); + const std::uint64_t want = known ? known : leonida::XdxrLayout::header_size; + const std::uint64_t title_dst = c.dst_va; + std::uint64_t out = 0, room = 0; + if (!bvh_va(c.src_va, want, true, out, &room) || (out & 255)) + return bvh_refuse(bvh_copy_src, c.src_va, want), false; + c.src_va = out; + c.src_room = room; + if (!bvh_va(c.dst_va, want, true, out, &room) || (out & 255)) + return bvh_refuse(bvh_copy_dst, c.dst_va, want), false; + c.dst_va = out; + c.dst_room = room; + if (known) bvh_note_size(title_dst, known); + return true; + } + + // A postbuild: its destination (8 bytes a source) and each source structure's header, which it reads. + bool resolve_xdxr_postbuild(leonida::AccelerationStructurePostbuild& info) { + if (!context || !context->xdxr_acceleration_structures()) return true; + std::uint64_t out = 0, room = 0; + const std::uint64_t bytes = 8ull * info.sources.size(); + if (!bvh_va(info.dest_va, bytes, true, out, &room) || (out & 7)) + return bvh_refuse(bvh_postbuild_dst, info.dest_va, bytes), false; + info.dest_va = out; + info.dest_room = room; + for (auto& source : info.sources) { + if (!bvh_va(source, leonida::XdxrLayout::header_size, true, out) || (out & 255)) + return bvh_refuse(bvh_postbuild_src, source, leonida::XdxrLayout::header_size), false; + source = out; + } return true; } @@ -2219,6 +2744,9 @@ struct DeviceState { --it; return addr < it->second && (addr-it->first) % kDescriptorSize == 0; } + // The shader-visible CBV/SRV/UAV heaps (arena offset -> end), for the scan of bound tables before a submission. + std::mutex cbv_heap_mutex; + std::map cbv_heaps; // The buffer V#s of the table at `table_va` whose base is in the title's own memory get the address of a copy, // written in place: the title wrote them itself (or copied them), so no Create*View saw them. Images (T#s) and @@ -2286,10 +2814,98 @@ struct DeviceState { return true; } + // Indexed by actual Vulkan address, never by a placed buffer's CPU address. + std::atomic released_backings{}; + std::mutex backing_mutex; + leonida::BufferVaIndex gpu_backings; + void backing(VkDeviceAddress address, uint64_t bytes, uint64_t id, bool add) { + std::lock_guard lock(backing_mutex); + if (add) gpu_backings.insert(address, bytes, id); + else { + gpu_backings.erase(address, id); + released_backings.fetch_add(1, std::memory_order_release); + } + } + + enum class VsharpPath { table, shadow, scratch }; + enum class VsharpResult { unchanged, rebased, empty }; + + uint64_t vsharp_address(uint64_t base, uint64_t bytes, leonida::TitleVaAliases::Kind kind = leonida::TitleVaAliases::created_view, + bool make_window = true, bool try_geometry = false) { + if (!base || !bytes) return 0; + auto& aliases = leonida::title_va_aliases(); + constexpr uint64_t mask = (1ull << 48) - 1; + const auto encodable = [&](uint64_t offset) { + const uint64_t limit = signed_vsharp_offsets() ? mask / 2 : mask; + if (offset <= limit) return bytes - 1 <= limit - offset; + return signed_vsharp_offsets() && offset >= UINT64_MAX - limit && + bytes - 1 <= limit - offset; // unsigned distance across zero + }; + const auto backed = [&](uint64_t offset) { + if (!encodable(offset)) return false; + const auto bda = arena.address + offset; + { + std::lock_guard lock(backing_mutex); + if (gpu_backings.covers(bda, bytes)) return true; + } + uint64_t host{}, room{}; + return geometry.cap() && geometry.lookup(bda, host, room) && room >= bytes; + }; + uint64_t to{}, room{}; + if (aliases.range_of(base, to, room)) { + if (!to || room < bytes || !backed(to)) return 0; + aliases.note_translation(kind); + return to; + } + // An already rewritten descriptor carries only the low 48 bits. + uint64_t offset = base; + if (signed_vsharp_offsets() && base <= mask && (base & (1ull << 47))) offset |= ~mask; + if (backed(offset)) return offset; + if (try_geometry) { + to = geometry_va(base, bytes, false); + if (to && encodable(to)) return to; + } + uint64_t lo{}, hi{}; + if (make_window && aliases.title_memory(base, lo, hi) && bytes <= hi - base) { + to = aliases.resolve(base, bytes, kind); + uint64_t mapped{}; + if (to && aliases.range_of(base, mapped, room) && mapped == to && room >= bytes && backed(to)) return to; + } + return 0; + } + + VsharpResult fix_vsharp(uint32_t* w, VsharpPath path) { + if ((w[3] >> 30) || !w[2]) return VsharpResult::unchanged; // image, empty slot or raw pointer + const uint64_t base = uint64_t(w[0]) | (uint64_t(w[1] & 0xffff) << 32); + const uint32_t stride = (w[1] >> 16) & 0x3fffu; + const uint64_t span = uint64_t(w[2]) * (stride ? stride : 1); + const leonida::gfx10::BufferWords words{w[0], w[1], w[2], w[3]}; + leonida::gfx10::Buffer desc{}; + const bool copy_geometry = leonida::gfx10::decode(words, desc) && + (path != VsharpPath::scratch || span <= kTitleWindowMax || (desc.format && leonida::gfx10::encode(desc) == words)); + const auto to = vsharp_address(base, span, leonida::TitleVaAliases::table_view, + path != VsharpPath::scratch, copy_geometry); + if (!to) { + static std::atomic_flag noted[3]{}; + if (!noted[unsigned(path)].test_and_set(std::memory_order_relaxed)) { + const char* where = path == VsharpPath::table ? "inline table" : + path == VsharpPath::shadow ? "console shadow" : "console scratch"; + std::fprintf(stderr, "[rt] d3d12: %s V# at 0x%llx (%llu bytes) has no GPU backing; zero records\n", + where, (unsigned long long)base, (unsigned long long)span); + } + w[0] = w[1] = w[2] = 0; + return VsharpResult::empty; + } + if ((to & ((1ull << 48) - 1)) == base) return VsharpResult::unchanged; + w[0] = uint32_t(to); + w[1] = (w[1] & 0xffff0000u) | uint32_t((to >> 32) & 0xffff); + return VsharpResult::rebased; + } // WriteToSubresource/ReadFromSubresource without host image copy: one staging copy at a time, submitted to // the device's VkQueue and waited for. Created on first use. - rt::d3d12::TitleImageUpload title_upload; // accessed with title_texture_mutex held + rt::d3d12::TitleImageUpload title_upload; // accessed with title_upload_mutex held + std::mutex title_upload_mutex; // after title_texture_mutex when both are taken (the fill worker takes it alone) std::mutex staging_mutex; std::unique_ptr staging_queue; @@ -2300,13 +2916,18 @@ struct DeviceState { // (src/arena_size.h). The first 64 KiB are never handed out, so no resource has VA 0. struct Arena { VkBuffer buffer = VK_NULL_HANDLE; + bool indirect_arguments = false; VkDeviceMemory memory = VK_NULL_HANDLE; std::uint8_t* mapped = nullptr; VkDeviceAddress address = 0; VkDeviceSize size = 0; std::uint32_t memory_type = 0; std::mutex mutex; - std::map free; // offset -> size + leonida::ArenaBlocks blocks; // offset -> size, guarded by mutex (src/arena_blocks.h) + // Diagnostics: a fault line is rate-limited, and the full block walk runs only on a fault or LEONIDA_ARENA_CHECK=1. + ULONGLONG fault_report_ms = 0; + std::uint64_t faults_suppressed = 0; + bool check_all = false; // The high-water mark (D3D-55, open question 5): the arena's size is a guess until a run measures it. // `peak_end` is the highest end offset ever handed out, the size the arena must have; `peak_in_use` is the @@ -2342,44 +2963,91 @@ struct DeviceState { // What an arena range holds, for the high-water report (D3D-55). enum ArenaUse { arena_buffer, arena_descriptor_heap, arena_shader, arena_heap }; static constexpr const char* kArenaUseNames[4] = {"buffer", "descriptor heap", "shader", "heap"}; + // A fault line about the arena is rate-limited to this interval: the walk behind it costs a pass over every + // free block, and a persistent fault would otherwise print on every allocation of a streaming frame. + static constexpr ULONGLONG kArenaReportMs = 5000; + + // One arena line per interval, so a fault that persists does not flood the log and a second, different fault + // still gets its own line later (a one-shot flag would have hidden it). The count of suppressed lines is + // printed with the next one. + bool arena_report_due() { + const ULONGLONG now = GetTickCount64(); + if (arena.fault_report_ms && now - arena.fault_report_ms < kArenaReportMs) { + ++arena.faults_suppressed; + return false; + } + arena.fault_report_ms = now; + return true; + } + + void arena_report_suppressed(const char* what) { + if (!arena.faults_suppressed) return; + std::fprintf(stderr, "[rt] d3d12: GPU address arena: %llu earlier line(s) about %s were rate-limited\n", + static_cast(arena.faults_suppressed), what); + arena.faults_suppressed = 0; + } + + // The free bytes and the live bytes must add up to the arena: a range released twice, or released without ever + // having been allocated, breaks it. That check is O(1) and runs on every call; the whole block map is walked + // only when it fails or LEONIDA_ARENA_CHECK=1 asks for it, since a walk costs a pass over every free block. + void check_arena(const char* what) { + const bool consistent = arena.blocks.consistent(arena.in_use); + if (consistent && !arena.check_all) return; + const auto fault = arena.blocks.check(); + if (fault == leonida::ArenaBlocks::Fault::none && consistent) return; + if (!arena_report_due()) return; + const char* why = fault != leonida::ArenaBlocks::Fault::none + ? leonida::ArenaBlocks::kFaultNames[static_cast(fault)] + : "free + live does not add up to the arena"; + std::fprintf(stderr, + "[rt] d3d12: GPU address arena: %s left %llu KiB free and %llu KiB live of %llu the arena has " + "minus %llu reserved (%s; %zu free blocks, %llu faults so far)\n", + what, static_cast(arena.blocks.free_bytes() >> 10), + static_cast(arena.in_use >> 10), + static_cast(arena.size >> 10), + static_cast(arena.blocks.reserved() >> 10), why, arena.blocks.count(), + static_cast(arena.blocks.faults())); + arena_report_suppressed(what); + } // A zero-size range is refused: it would share its offset with the next range, and its release would collide // with that range's free entry. The fit test cannot wrap: free blocks lie inside the arena (below 4 GiB). bool arena_allocate(VkDeviceSize bytes, VkDeviceSize alignment, VkDeviceSize& out, ArenaUse use) { if (!bytes || bytes > arena.size) return false; std::lock_guard lock(arena.mutex); - for (auto it = arena.free.begin(); it != arena.free.end(); ++it) { - VkDeviceSize start = (it->first + alignment - 1) / alignment * alignment; - const VkDeviceSize end = it->first + it->second; - // Not over a range of the title's own memory: the title's heap can lie below the arena's size, and a - // view that names an address there must mean the title's bytes (TitleVaAliases::want_buffer). - while (start < end && bytes <= end - start) { - const std::uint64_t title_end = leonida::title_va_aliases().title_overlap_end(start, start + bytes); - if (!title_end) break; - start = (title_end + alignment - 1) / alignment * alignment; - } - if (start >= end || bytes > end - start) continue; - const VkDeviceSize block = it->first; - arena.free.erase(it); - if (start > block) arena.free[block] = start - block; - if (start + bytes < end) arena.free[start + bytes] = end - (start + bytes); - out = start; - ++arena.allocations; - arena.in_use += bytes; - arena.peak_in_use = std::max(arena.peak_in_use, arena.in_use); - arena.peak_end = std::max(arena.peak_end, start + bytes); - arena.use_in_use[use] += bytes; - arena.use_peak[use] = std::max(arena.use_peak[use], arena.use_in_use[use]); + // Not over a range of the title's own memory: the title's heap can lie below the arena's size, and a view + // that names an address there must mean the title's bytes (TitleVaAliases::want_buffer). The walk holds no + // iterator across this call, so a cut made under it cannot invalidate it (src/arena_blocks.h). + const bool found = arena.blocks.allocate( + bytes, alignment, + [](std::uint64_t lo, std::uint64_t hi) { return leonida::title_va_aliases().title_overlap_end(lo, hi); }, + out); + if (!found) { + ++arena.failures; if (arena.log) - std::fprintf(stderr, "[rt] d3d12: arena %s VA 0x%llx + 0x%llx\n", kArenaUseNames[use], - (unsigned long long)start, (unsigned long long)bytes); - return true; + std::fprintf(stderr, "[rt] d3d12: arena %s: no room for 0x%llx bytes\n", kArenaUseNames[use], + (unsigned long long)bytes); + // The search restarted to its limit: say so, since the request may have been refusable anyway. + if (arena.blocks.interrupted() && arena_report_due()) + std::fprintf(stderr, "[rt] d3d12: GPU address arena: the block map was cut under a search %d times; " + "a %llu KiB request was refused (live %llu KiB, free %llu KiB)\n", + leonida::ArenaBlocks::kAttempts, static_cast(bytes >> 10), + static_cast(arena.in_use >> 10), + static_cast(arena.blocks.free_bytes() >> 10)); + return false; } - ++arena.failures; + backing(arena.address + out, bytes, out, true); + ++arena.allocations; + arena.in_use += bytes; + arena.peak_in_use = std::max(arena.peak_in_use, arena.in_use); + arena.peak_end = std::max(arena.peak_end, out + bytes); + arena.use_in_use[use] += bytes; + arena.use_peak[use] = std::max(arena.use_peak[use], arena.use_in_use[use]); if (arena.log) - std::fprintf(stderr, "[rt] d3d12: arena %s: no room for 0x%llx bytes\n", kArenaUseNames[use], - (unsigned long long)bytes); - return false; + std::fprintf(stderr, "[rt] d3d12: arena %s VA 0x%llx + 0x%llx\n", kArenaUseNames[use], + (unsigned long long)out, (unsigned long long)bytes); + check_arena("an allocation"); + return true; } // A console VA outside the arena (an upload or readback buffer: its device address minus heap_base). @@ -2396,30 +3064,54 @@ struct DeviceState { const double mib = 1.0 / (1 << 20); std::fprintf(stderr, "[rt] d3d12: GPU address arena: peak end %.1f of %.1f MiB (%.1f%%), peak live %.1f MiB " - "(buffers %.1f, descriptor heaps %.1f, shaders %.1f, heaps %.1f), %llu allocations, %llu refused\n", + "(buffers %.1f, descriptor heaps %.1f, shaders %.1f, heaps %.1f), %llu allocations, %llu refused; " + "%zu free blocks (largest %.1f MiB, %.1f MiB free)\n", arena.peak_end * mib, arena.size * mib, 100.0 * double(arena.peak_end) / double(arena.size), arena.peak_in_use * mib, arena.use_peak[arena_buffer] * mib, arena.use_peak[arena_descriptor_heap] * mib, arena.use_peak[arena_shader] * mib, arena.use_peak[arena_heap] * mib, - (unsigned long long)arena.allocations, (unsigned long long)arena.failures); + (unsigned long long)arena.allocations, (unsigned long long)arena.failures, arena.blocks.count(), + arena.blocks.largest().size * mib, arena.blocks.free_bytes() * mib); + { + std::lock_guard windows(title_window_mutex); + const auto geometry_spans = std::count_if(pool_spans.begin(), pool_spans.end(), + [](const PoolSpan& span) { return span.geometry; }); + std::fprintf(stderr, + "[rt] d3d12: title memory: %zu windows (%llu KiB of a %llu MiB budget, %llu refused), %zu " + "stream-pool extents (one mapping each, %llu KiB; %lld by geometry copy), %llu addresses " + "given a zero-size view\n", + title_windows.size(), static_cast(title_window_bytes >> 10), + static_cast(title_window_cap >> 20), + static_cast(title_window_refusals), pool_spans.size(), + static_cast(pool_span_bytes >> 10), + static_cast(geometry_spans), + static_cast(unbacked_requests)); + } } void arena_release(VkDeviceSize offset, VkDeviceSize bytes, ArenaUse use) { if (!bytes) return; std::lock_guard lock(arena.mutex); - arena.in_use -= bytes; - arena.use_in_use[use] -= bytes; - auto it = arena.free.emplace(offset, bytes).first; - if (auto next = std::next(it); next != arena.free.end() && it->first + it->second == next->first) { - it->second += next->second; - arena.free.erase(next); - } - if (it != arena.free.begin()) { - if (auto previous = std::prev(it); previous->first + previous->second == it->first) { - previous->second += it->second; - arena.free.erase(it); - } + // The range is validated and merged before the live-byte counters move: a release of a range the arena never + // had must not change them, and a double free must not count the bytes twice. + const auto fault = arena.blocks.release(offset, bytes); + if (fault != leonida::ArenaBlocks::Fault::outside_arena) { + backing(arena.address + offset, bytes, offset, false); + arena.in_use -= bytes; + arena.use_in_use[use] -= bytes; + } + if (fault != leonida::ArenaBlocks::Fault::none && arena_report_due()) { + std::fprintf(stderr, + "[rt] d3d12: GPU address arena: %s at VA 0x%llx + 0x%llx (live %llu KiB, free %llu KiB, " + "%llu faults so far)\n", + leonida::ArenaBlocks::kFaultNames[static_cast(fault)], + static_cast(offset), static_cast(bytes), + static_cast(arena.in_use >> 10), + static_cast(arena.blocks.free_bytes() >> 10), + static_cast(arena.blocks.faults())); + arena_report_suppressed("arena releases"); } + check_arena("a release"); } // Console descriptor heaps (Xbox slot 14, docs/d3d12_vulkan.md section 3.4). The title gives the heap's address @@ -2453,6 +3145,8 @@ struct DeviceState { std::uint64_t console_va = 0; VkDeviceSize bytes = 0; std::uint64_t shader_va = 0; // where shaders read it + VkDeviceSize guard = 0; + bool resource_heap = false; bool imported = false; std::uint8_t* copy = nullptr; // writable GPU mirror of the console heap // Keep large scratch allocations out of the low addresses the title can use for its heap. @@ -2464,6 +3158,7 @@ struct DeviceState { VkDeviceMemory memory = VK_NULL_HANDLE; std::uint64_t pin = 0; // the imported pages' leonida::kernel_writes pin while `memory` lives std::size_t scan_at = 0; // the next slot the T# scan reads + uint64_t checked_generation{}, alias_generation{}; // copy bool identity = false; ShadowPagesPtr pages; @@ -2471,28 +3166,41 @@ struct DeviceState { std::vector made; // the title's bytes each arena slot was last made from std::vector retry; // per slot: not settled yet (fix_console_slot), in `retries` std::vector retries; - std::uint64_t refreshes = 0; + std::set empty_slots; + std::uint32_t next_empty = 0; + std::size_t retry_at = 0; // where retry_console_slots goes on + // fix_console_slots' budget, for the current refresh, and the slots it nulled since the last log line + std::chrono::steady_clock::time_point fix_start{}; + bool fix_over = false; + std::uint32_t fix_count = 0; + std::uint64_t deferred_fixes = 0; + std::uint64_t refreshes = 0, logged = 0; + std::chrono::steady_clock::time_point log_time{}; // Since the last log line. - std::uint64_t copied = 0, scanned = 0, vsharps = 0; + std::uint64_t copied = 0, vsharps = 0, unbacked = 0, retried = 0; std::uint64_t images[5] = {}; // by TitleImage - double ms = 0; + double ms = 0, pages_ms = 0, fix_ms = 0, retry_ms = 0; // ms: all; the others its parts }; std::mutex console_heap_mutex; // taken before title_window_mutex, shadow_mutex and descriptor_mutex std::vector> console_heaps; - static constexpr std::size_t kConsoleScanSlots = 65536; // per submission: 2 MiB, the whole retail heap in 19 + + static constexpr VkDeviceSize kHeapIndexReach = VkDeviceSize(1) << 26; // 2^21 slots of 32 bytes + static VkDeviceSize heap_guard_bytes() { + static const VkDeviceSize bytes = [] { + char text[16] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_HEAP_GUARD_MB", text, sizeof(text)); + if (n == 0 || n >= sizeof(text)) return kHeapIndexReach; + return VkDeviceSize(std::min(std::strtoull(text, nullptr, 10), 1024)) << 20; + }(); + return bytes; + } // [start, start + bytes) of the arena, exactly. False when any of it is taken or past the arena. bool arena_allocate_at(VkDeviceSize start, VkDeviceSize bytes, ArenaUse use) { if (!bytes || start > arena.size || bytes > arena.size - start) return false; std::lock_guard lock(arena.mutex); - auto it = arena.free.upper_bound(start); - if (it == arena.free.begin()) return false; - --it; - const VkDeviceSize block = it->first, end = it->first + it->second; - if (start + bytes > end) return false; - arena.free.erase(it); - if (start > block) arena.free[block] = start - block; - if (start + bytes < end) arena.free[start + bytes] = end - (start + bytes); + if (!arena.blocks.allocate_at(start, bytes)) return false; + backing(arena.address + start, bytes, start, true); ++arena.allocations; arena.in_use += bytes; arena.peak_in_use = std::max(arena.peak_in_use, arena.in_use); @@ -2504,45 +3212,76 @@ struct DeviceState { // Slot `slot` of a heap copy, as the title wrote it, fixed up as described above. True when it is settled: not a // T# whose texture is still to come, nor a V# into the title's memory that got no copy. - bool fix_console_slot(ConsoleHeap& heap, std::size_t slot, leonida::TitleVaAliases& aliases) { + bool fix_console_slot(ConsoleHeap& heap, std::size_t slot) { std::uint32_t w[kDescriptorSize / 4]; std::memcpy(w, heap.previous + slot * kDescriptorSize, kDescriptorSize); - bool settled = true; - if (!(w[0] | w[1] | w[2] | w[3])) { - } else if (!(w[3] >> 30)) { - if (rebase_title_vsharp(w, aliases, !heap.scratch)) { - ++heap.vsharps; - } else { - // The title's memory with no copy yet (a page not committed when it was looked at) is tried again. - const std::uint64_t base = std::uint64_t(w[0]) | (std::uint64_t(w[1] & 0xFFFFu) << 32); - std::uint64_t lo = 0, hi = 0; - settled = heap.scratch || base < arena.size || !aliases.title_memory(base, lo, hi) || - (geometry.cap() && geometry.lookup(arena.address + base, lo, hi)); + bool settled = true, empty = false; + if (!(w[3] >> 30)) { + const auto path = heap.scratch ? VsharpPath::scratch : VsharpPath::shadow; + const auto result = fix_vsharp(w, path); + const auto counter = fix_vsharp(w + 4, path); + if (result == VsharpResult::rebased) ++heap.vsharps; + if (result == VsharpResult::empty || counter == VsharpResult::empty) { + ++heap.unbacked; + empty = true; } } else { leonida::gfx10::ImageWords words; std::memcpy(words.data(), w, sizeof(words)); if (leonida::gfx10::is_image(words)) { - const TitleImage result = bind_title_image(*this, words); + const char* why = nullptr; + const TitleImage result = bind_title_image(*this, words, &why); + if (result == TitleImage::unknown || result == TitleImage::refused) + note_refused_tsharp(heap, slot * kDescriptorSize, words, why); ++heap.images[unsigned(result)]; settled = result != TitleImage::unknown && result != TitleImage::refused; + if (result == TitleImage::not_tsharp) std::memset(w, 0, 16); + } else { + ++heap.images[unsigned(TitleImage::not_tsharp)]; + std::memset(w, 0, 16); } } + if (empty) heap.empty_slots.insert(std::uint32_t(slot)); + else if (!heap.empty_slots.empty()) heap.empty_slots.erase(std::uint32_t(slot)); std::memcpy(heap.copy + slot * kDescriptorSize, w, kDescriptorSize); return settled; } // The slots on [offset, offset + bytes) of a heap copy's mirror, just brought up to date: each that differs from // what its arena slot was made from is written there and fixed up. + // Past LEONIDA_CONSOLE_FIX_US of fixing in one submission (4000 by default, 0: no limit), a changed slot is written + // as a null descriptor and left to retry_console_slots: after the story load the title rewrote up to 3.7 MiB of + // its heap at once and one submission spent 28 s fixing it (speed-8). A shader reads such a slot as empty until + // its turn comes. void fix_console_slots(ConsoleHeap& heap, std::size_t offset, std::size_t bytes) { - auto& aliases = leonida::title_va_aliases(); + static const std::uint64_t budget_us = [] { + char text[16] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_CONSOLE_FIX_US", text, sizeof(text)); + return n > 0 && n < sizeof(text) ? std::strtoull(text, nullptr, 10) : 4000ull; + }(); const std::size_t end = std::min(offset + bytes, std::size_t(heap.bytes)); + if (!heap.resource_heap) { + std::memcpy(heap.copy + offset, heap.input + offset, end - offset); + return; + } for (std::size_t at = offset & ~std::size_t(kDescriptorSize - 1); at + kDescriptorSize <= end; at += kDescriptorSize) { const std::size_t slot = at / kDescriptorSize; if (!std::memcmp(heap.previous + at, heap.input + at, kDescriptorSize)) continue; std::memcpy(heap.previous + at, heap.input + at, kDescriptorSize); - if (fix_console_slot(heap, slot, aliases)) { + if (budget_us && !heap.fix_over && !(++heap.fix_count & 15) && + std::chrono::steady_clock::now() - heap.fix_start >= std::chrono::microseconds(budget_us)) + heap.fix_over = true; + if (heap.fix_over) { + std::memset(heap.copy + at, 0, kDescriptorSize); + ++heap.deferred_fixes; + if (!heap.retry[slot]) { + heap.retry[slot] = 1; + heap.retries.push_back(std::uint32_t(slot)); + } + continue; + } + if (fix_console_slot(heap, slot)) { heap.retry[slot] = 0; } else if (!heap.retry[slot]) { heap.retry[slot] = 1; @@ -2551,36 +3290,38 @@ struct DeviceState { } } - // The slots of a heap copy not settled yet: fixed again, and kept while they are still not. + // The slots of a heap copy not settled yet: fixed again, and kept while they are still not. Round robin, for at + // most LEONIDA_CONSOLE_RETRY_US a submission (500 by default, 0: all of them every time): during the story load + // thousands of T#s name textures that come much later, and trying them all at every submission cost hundreds of + // milliseconds each. One not reached waits a few submissions more for its texture. void retry_console_slots(ConsoleHeap& heap) { - auto& aliases = leonida::title_va_aliases(); - std::erase_if(heap.retries, [&](std::uint32_t slot) { - if (!heap.retry[slot]) return true; // rewritten or zeroed since - if (!fix_console_slot(heap, slot, aliases)) return false; - heap.retry[slot] = 0; - return true; - }); - } - - // An imported heap: the next kConsoleScanSlots slots, for T#s no Create*View registered. A V# is read as the - // title wrote it (its base cannot be rewritten in the title's own memory). - void scan_console_slots(ConsoleHeap& heap) { - const std::size_t slots = std::size_t(heap.bytes / kDescriptorSize); - const auto* base = reinterpret_cast(static_cast(heap.console_va)); - for (std::size_t n = 0; n < std::min(slots, kConsoleScanSlots); ++n) { - if (heap.scan_at >= slots) heap.scan_at = 0; - const auto* w = reinterpret_cast(base + heap.scan_at++ * kDescriptorSize); - if (leonida::gfx10::detail::get(w[3], 28, 4) < 8) continue; // not an image's TYPE - leonida::gfx10::ImageWords words; - std::memcpy(words.data(), w, sizeof(words)); - const char* why = nullptr; - const TitleImage result = bind_title_image(*this, words, &why); - ++heap.images[unsigned(result)]; - if (result == TitleImage::unknown) why = "names no registered texture"; - if (result == TitleImage::refused || result == TitleImage::unknown) - note_refused_tsharp(heap, (heap.scan_at - 1) * kDescriptorSize, words, why); + static const std::uint64_t budget_us = [] { + char text[16] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_CONSOLE_RETRY_US", text, sizeof(text)); + return n > 0 && n < sizeof(text) ? std::strtoull(text, nullptr, 10) : 500ull; + }(); + const auto start = std::chrono::steady_clock::now(); + std::size_t i = heap.retry_at, visited = 0; + const std::size_t total = heap.retries.size(); + while (visited < total && !heap.retries.empty()) { + if (i >= heap.retries.size()) i = 0; + const std::uint32_t slot = heap.retries[i]; + ++visited; + // Rewritten or zeroed since, or settled now: out of the list (the last one takes its place, seen later). + const bool settled = !heap.retry[slot] || fix_console_slot(heap, slot); + if (settled) { + heap.retry[slot] = 0; + heap.retries[i] = heap.retries.back(); + heap.retries.pop_back(); + } else { + ++i; + } + if (budget_us && !(visited & 31) && + std::chrono::steady_clock::now() - start >= std::chrono::microseconds(budget_us)) + break; } - heap.scanned += std::min(slots, kConsoleScanSlots); + heap.retry_at = i; + heap.retried += visited; } // The first refused T#s of each reason, with where they sit in the heap and their words, and a count of the @@ -2604,61 +3345,121 @@ struct DeviceState { } void refresh_console_heap(ConsoleHeap& heap) { // console_heap_mutex held - if (heap.imported) return scan_console_slots(heap); + if (heap.imported) return; // directly imported sampler heap + using clock = std::chrono::steady_clock; + const auto ms = [](clock::time_point a, clock::time_point b) { + return std::chrono::duration(b - a).count(); + }; + const auto t0 = clock::now(); heap.copied += heap.pages->refresh(); heap.pages->for_each_zeroed([&](std::size_t offset, std::size_t bytes) { std::memset(heap.copy + offset, 0, bytes); std::memset(heap.previous + offset, 0, bytes); - for (std::size_t slot = offset / kDescriptorSize; slot * kDescriptorSize < offset + bytes; ++slot) - heap.retry[slot] = 0; + const auto first = std::uint32_t(offset / kDescriptorSize); + const auto end = std::uint32_t((offset + bytes) / kDescriptorSize); + heap.empty_slots.erase(heap.empty_slots.lower_bound(first), heap.empty_slots.lower_bound(end)); + for (auto slot = first; slot < end; ++slot) heap.retry[slot] = 0; }); + const auto t1 = clock::now(); + heap.fix_start = t1; + heap.fix_over = false; + heap.fix_count = 0; heap.pages->for_each_copied([&](std::size_t offset, std::size_t bytes) { fix_console_slots(heap, offset, bytes); }); + const auto generation = released_backings.load(std::memory_order_acquire); + const auto alias_generation = leonida::title_va_aliases().invalidations(); + if (heap.resource_heap && (generation != heap.checked_generation || alias_generation != heap.alias_generation)) { + heap.alias_generation = alias_generation; + heap.checked_generation = generation; + // Even an unchanged title slot may name a buffer released since the last submission. + for (size_t at = 0; at + kDescriptorSize <= heap.bytes; at += kDescriptorSize) { + auto* w = reinterpret_cast(heap.copy + at); + if (!(w[3] >> 30) && (w[2] || w[6])) { + const auto slot = at / kDescriptorSize; + if (!fix_console_slot(heap, slot) && !heap.retry[slot]) { + heap.retry[slot] = 1; + heap.retries.push_back(uint32_t(slot)); + } + } + } + } + const auto t2 = clock::now(); + // A settled zero can acquire GPU backing without a CPU map event. Probe at most eight in + // round-robin order every 32 submissions. Keep texture and copy-budget retries independent. + if ((heap.refreshes & 31) == 31 && !heap.empty_slots.empty()) { + auto it = heap.empty_slots.lower_bound(heap.next_empty); + const auto count = (std::min)(std::size_t{8}, heap.empty_slots.size()); + for (std::size_t n = 0; n < count && !heap.empty_slots.empty(); ++n) { + if (it == heap.empty_slots.end()) it = heap.empty_slots.begin(); + const auto slot = *it++; + heap.next_empty = slot + 1; + if (!heap.retry[slot]) { + fix_console_slot(heap, slot); + ++heap.retried; + } + } + } if (!heap.retries.empty()) retry_console_slots(heap); + const auto t3 = clock::now(); + heap.pages_ms += ms(t0, t1); + heap.fix_ms += ms(t1, t2); + heap.retry_ms += ms(t2, t3); } // Before every submission, ahead of the slot-133 shadows. void refresh_console_heaps() { - constexpr std::uint64_t kLogEvery = 4096; std::lock_guard lock(console_heap_mutex); for (const auto& heap : console_heaps) { const auto start = std::chrono::steady_clock::now(); refresh_console_heap(*heap); heap->ms += std::chrono::duration(std::chrono::steady_clock::now() - start).count(); ++heap->refreshes; - if (heap->refreshes != 1 && heap->refreshes != 64 && heap->refreshes % kLogEvery) continue; - const double count = double(heap->refreshes == 1 ? 1 : heap->refreshes == 64 ? 63 : kLogEvery); + // A line at the first and 64th submission, then every 10 s (a crawl logs as often as a fast run). + const bool logged = heap->refreshes == 1 || heap->refreshes == 64 || + (heap->refreshes > 64 && start - heap->log_time >= std::chrono::seconds(10)); + if (!logged) continue; + const double count = double(std::max(1, heap->refreshes - heap->logged)); + heap->logged = heap->refreshes; + heap->log_time = start; std::fprintf(stderr, "[rt] d3d12: console descriptor heap 0x%llx (%s): submissions up to %llu %s %.1f KiB each " - "in %.3f ms on average, %llu write faults; %llu title V#s rebased, T#s %llu known, %llu " - "bound, %llu naming no texture, %llu refused, %llu words that are no T# (data)\n", + "in %.3f ms on average (pages %.3f, fixing copied slots %.3f, %llu left to retries past the " + "budget, retrying %.3f: %.1f slots a " + "submission, %zu waiting), %llu write faults; %llu title V#s rebased, %llu with no copy given " + "no records, T#s %llu known, %llu bound, %llu naming no texture, %llu refused, %llu words " + "that are no T# (data)\n", static_cast(heap->console_va), heap->imported ? "imported" : "copy", - static_cast(heap->refreshes), heap->imported ? "scanned" : "copied", - double(heap->imported ? heap->scanned * kDescriptorSize : heap->copied) / 1024.0 / count, - heap->ms / count, + static_cast(heap->refreshes), "copied", + double(heap->copied) / 1024.0 / count, + heap->ms / count, heap->pages_ms / count, heap->fix_ms / count, + static_cast(heap->deferred_fixes), heap->retry_ms / count, + double(heap->retried) / count, heap->retries.size(), static_cast(heap->pages ? heap->pages->faults() : 0), static_cast(heap->vsharps), + static_cast(heap->unbacked), static_cast(heap->images[unsigned(TitleImage::known)]), static_cast(heap->images[unsigned(TitleImage::bound)]), static_cast(heap->images[unsigned(TitleImage::unknown)]), static_cast(heap->images[unsigned(TitleImage::refused)]), static_cast(heap->images[unsigned(TitleImage::not_tsharp)])); - heap->copied = heap->scanned = heap->vsharps = 0; + heap->copied = heap->vsharps = heap->unbacked = heap->retried = heap->deferred_fixes = 0; for (auto& n : heap->images) n = 0; - heap->ms = 0; + heap->ms = heap->pages_ms = heap->fix_ms = heap->retry_ms = 0; } } // The heap's pages imported as host memory (see above): true with `heap` filled in, false when they cannot be // (no VK_EXT_external_memory_host, a page not committed or write-combined, a driver refusal, or a device address // shaders could not reach with 32 bits). - bool import_console_heap(ConsoleHeap& heap, std::uintptr_t host_va) { + // `span`: the bytes to import from host_va (0: the heap's), its copy and null guard for a scratch backing. + bool import_console_heap(ConsoleHeap& heap, std::uintptr_t host_va, VkDeviceSize span = 0) { auto& vk = context->vk; const VkDeviceSize alignment = info.host_pointer_alignment; + if (!span) span = heap.bytes; if (!get_host_pointer_properties || !alignment || !arena.address || (host_va % alignment) || - (heap.bytes % alignment)) + (span % alignment)) return false; const auto* pages = reinterpret_cast(static_cast(host_va)); - for (VkDeviceSize at = 0; at < heap.bytes;) { + for (VkDeviceSize at = 0; at < span;) { MEMORY_BASIC_INFORMATION region{}; if (!VirtualQuery(pages + at, ®ion, sizeof(region)) || region.State != MEM_COMMIT || (region.Protect & (PAGE_WRITECOMBINE | PAGE_NOCACHE | PAGE_GUARD))) @@ -2668,7 +3469,7 @@ struct DeviceState { VkExternalMemoryBufferCreateInfo external{VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO}; external.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; VkBufferCreateInfo create{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, &external}; - create.size = heap.bytes; + create.size = span; create.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; @@ -2689,7 +3490,7 @@ struct DeviceState { const_cast(pages), &host) != VK_SUCCESS) return fail(); const std::uint32_t types = host.memoryTypeBits & requirements.memoryTypeBits; - if (!types || heap.bytes < requirements.size) return fail(); + if (!types || span < requirements.size) return fail(); VkImportMemoryHostPointerInfoEXT import{VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT}; import.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; import.pHostPointer = const_cast(pages); @@ -2702,7 +3503,7 @@ struct DeviceState { for (std::uint32_t i = 0; i < memory.memoryTypeCount && !heap.memory; ++i) { if (!(types & (1u << i)) || (memory.memoryTypes[i].propertyFlags & want) != want) continue; VkMemoryAllocateInfo allocate{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, &flags}; - allocate.allocationSize = heap.bytes; + allocate.allocationSize = span; allocate.memoryTypeIndex = i; if (vk.vkAllocateMemory(info.device, &allocate, nullptr, &heap.memory) != VK_SUCCESS) heap.memory = VK_NULL_HANDLE; @@ -2715,7 +3516,7 @@ struct DeviceState { bda.buffer = heap.buffer; const VkDeviceAddress address = vk.vkGetBufferDeviceAddress(info.device, &bda); const std::uint64_t shader_va = address - arena.address; // mod 2^64, as for an imported slot-133 buffer - if (!address || shader_va > (std::uint64_t(1) << 32) - heap.bytes) { + if (!address || shader_va > (std::uint64_t(1) << 32) - span) { std::fprintf(stderr, "[rt] d3d12: console descriptor heap 0x%llx: its import lies at heap_base + 0x%llx, which " "32-bit descriptor-table pointers cannot reach; copied instead\n", @@ -2736,36 +3537,60 @@ struct DeviceState { heap->bytes = bytes; // Self-written V#s must be rebased without changing the title's descriptor bytes. // A directly indexed heap can lie outside the main arena and still fit in a 32-bit shader offset. + heap->resource_heap = resource_heap; + // Round the guarded import up to Wine's allocation granularity. + if (bytes > (1ull << 32)) return false; + const VkDeviceSize requested = resource_heap ? heap_guard_bytes() : 0; + const VkDeviceSize guard = requested && bytes + requested <= (1ull << 32) + ? ((bytes + requested + 65535) & ~VkDeviceSize(65535)) - bytes : 0; if (resource_heap && geometry.cap()) { - if (bytes > SIZE_MAX / 3) return false; - heap->scratch.reset(static_cast(VirtualAlloc(nullptr, bytes * 3, MEM_TOP_DOWN | + if (bytes > (SIZE_MAX - guard) / 3) return false; + // [copy | guard | input | previous]: the import covers the copy and its guard. + heap->scratch.reset(static_cast(VirtualAlloc(nullptr, bytes * 3 + guard, MEM_TOP_DOWN | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE))); if (heap->scratch) { auto* backing = heap->scratch.get(); - if (import_console_heap(*heap, reinterpret_cast(backing))) heap->copy = backing; - heap->input = backing + bytes; - heap->previous = backing + 2 * bytes; + if (import_console_heap(*heap, reinterpret_cast(backing), bytes + guard)) { + heap->copy = backing; + heap->guard = guard; + } + heap->input = backing + bytes + guard; + heap->previous = backing + 2 * bytes + guard; } heap->imported = false; // the imported storage holds the rewritten descriptors - } else { + } else if (!resource_heap) { import_console_heap(*heap, console_va); } if (!heap->imported) { if (!heap->copy) { VkDeviceSize offset = 0; - heap->identity = arena_allocate_at(console_va, bytes, arena_descriptor_heap); - if (heap->identity) { - offset = console_va; - } else if (!arena_allocate(bytes, 65536, offset, arena_descriptor_heap)) { + // At the console VA itself when the arena reaches that far, else anywhere: with the guard first. + bool placed = false; + for (int attempt = 0; attempt < (guard ? 2 : 1) && !placed; ++attempt) { + const VkDeviceSize size = attempt ? bytes : bytes + guard; + heap->identity = arena_allocate_at(console_va, size, arena_descriptor_heap); + if (heap->identity) { + offset = console_va; + } else if (!arena_allocate(size, 65536, offset, arena_descriptor_heap)) { + continue; + } + heap->guard = size - bytes; + placed = true; + } + if (!placed) { log_once("GPU address arena full (raise LEONIDA_ARENA_MB): console descriptor heap left in title " "memory only; KiB", int(std::min(bytes >> 10, INT_MAX))); return false; } + if (guard && !heap->guard) + log_once("GPU address arena has no room for a console heap's null guard (raise LEONIDA_ARENA_MB): " + "a heap index past it reads the arena's next bytes; guard MiB", + int(guard >> 20)); heap->shader_va = offset; heap->copy = arena.mapped + offset; } - std::memset(heap->copy, 0, std::size_t(bytes)); + std::memset(heap->copy, 0, std::size_t(bytes + heap->guard)); if (!heap->input) { heap->mirror.assign(std::size_t(bytes), 0); heap->made.assign(std::size_t(bytes), 0); @@ -2779,24 +3604,36 @@ struct DeviceState { shader_va = heap->shader_va; if (shader_va != console_va) console_heap_ranges().add(console_va, bytes, shader_va); const bool imported = heap->imported; + const VkDeviceSize guarded = heap->guard; { std::lock_guard lock(console_heap_mutex); if (!imported) refresh_console_heap(*heap); + if (heap->copy) { + std::unique_lock ranges(console_copy_ranges_mutex); + console_copy_ranges.emplace_back(heap->console_va, heap->bytes); + } console_heaps.push_back(std::move(heap)); } std::fprintf(stderr, - "[rt] d3d12: console descriptor heap 0x%llx (%llu KiB): shaders read it at heap_base + 0x%llx, %s\n", + "[rt] d3d12: console descriptor heap 0x%llx (%llu KiB): shaders read it at heap_base + 0x%llx, %s; " + "%llu KiB of null slots after it\n", static_cast(console_va), static_cast(bytes >> 10), static_cast(shader_va), imported ? "the title's pages imported as host memory" - : "a descriptor copy brought up to date before every submission"); + : "a descriptor copy brought up to date before every submission", + static_cast(guarded >> 10)); return true; } + // Called by the title's threads as they write buffer views (the Subrender workers among them). Not under + // console_heap_mutex, which the submit thread holds for every refresh of the heaps (3-7 ms a submission after the + // load, speed-27): the heaps with a copy, as ranges, under a lock of their own. + std::shared_mutex console_copy_ranges_mutex; + std::vector> console_copy_ranges; // console VA, bytes bool has_console_descriptor_copy(std::uintptr_t destination) { - std::lock_guard lock(console_heap_mutex); - for (const auto& heap : console_heaps) - if (heap->copy && destination - heap->console_va < heap->bytes) return true; + std::shared_lock lock(console_copy_ranges_mutex); + for (const auto& [va, bytes] : console_copy_ranges) + if (destination - va < bytes) return true; return false; } @@ -2809,6 +3646,8 @@ struct DeviceState { if (it == console_heaps.end()) return; heap = std::move(*it); console_heaps.erase(it); + std::unique_lock ranges(console_copy_ranges_mutex); + std::erase_if(console_copy_ranges, [console_va](const auto& r) { return r.first == console_va; }); } console_heap_ranges().remove(console_va); heap->pages.reset(); @@ -2820,7 +3659,7 @@ struct DeviceState { context->vk.vkFreeMemory(info.device, heap->memory, nullptr); leonida::kernel_writes::release(std::exchange(heap->pin, 0)); } else { - arena_release(heap->shader_va, heap->bytes, arena_descriptor_heap); + arena_release(heap->shader_va, heap->bytes + heap->guard, arena_descriptor_heap); } } @@ -3974,12 +4813,29 @@ struct DeviceState { // and then while other threads import host pointers that the kernel module cannot pin (journal: "Cannot // map memory with base addr ..."), with gigabytes free. The title asserts on the texture it loses. So // allocations and imports take turns (memory_mutex), and that answer is retried before it is believed. + // + // The retries are only worth their sleeps while some of them succeed: after the load a title placement + // that fails this way failed every retry (speed-25/26: none recovered), and each failing memory type cost + // the caller 15 ms of Sleep (the title's Subrender workers, slot 133), before the next type succeeded. So + // while fewer than one in 16 of the recent retried allocations recovered (both counts are halved every 64 + // retried allocations, so one recovery at boot does not keep them on), one attempt per type is made; one + // failure in 64 still retries, to notice when they help again. + static std::atomic retried{0}, recovered_total{0}, failures{0}; + const std::uint32_t recent = retried.load(std::memory_order_relaxed); + const bool retry = recent < 32 || recovered_total.load(std::memory_order_relaxed) * 16 >= recent || + failures.load(std::memory_order_relaxed) % 64 == 0; VkResult allocated = VK_ERROR_OUT_OF_HOST_MEMORY; - for (int attempt = 0; attempt < 6 && allocated == VK_ERROR_OUT_OF_HOST_MEMORY; ++attempt) { + for (int attempt = 0; attempt < (retry ? 6 : 1) && allocated == VK_ERROR_OUT_OF_HOST_MEMORY; ++attempt) { if (attempt) Sleep(attempt); std::lock_guard serial(memory_mutex()); allocated = context->vk.vkAllocateMemory(info.device, &allocate, nullptr, &out); + if (attempt == 1 && retried.fetch_add(1, std::memory_order_relaxed) + 1 >= 64) { + retried.store(32, std::memory_order_relaxed); // halve both (racy, approximate is enough) + recovered_total.store(recovered_total.load(std::memory_order_relaxed) / 2, + std::memory_order_relaxed); + } if (attempt && allocated == VK_SUCCESS) { + recovered_total.fetch_add(1, std::memory_order_relaxed); static std::atomic recovered{0}; if (recovered.fetch_add(1, std::memory_order_relaxed) < 8) std::fprintf(stderr, @@ -3988,6 +4844,7 @@ struct DeviceState { attempt, static_cast(requirements.size), i); } } + if (allocated == VK_ERROR_OUT_OF_HOST_MEMORY) failures.fetch_add(1, std::memory_order_relaxed); if (allocated != VK_SUCCESS) { static std::atomic logged{0}; if (logged.fetch_add(1, std::memory_order_relaxed) < 16) @@ -4409,18 +5266,31 @@ class DescriptorHeap final return; } if ((desc_.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE) && device.arena.mapped) { - if (!device.arena_allocate(bytes, 256, arena_offset_, DeviceState::arena_descriptor_heap)) { + // A bindless-sized resource heap (64Ki slots or more: what a shader indexes directly) is followed by null + // slots, as a console heap's copy is (DeviceState::heap_guard_bytes); a smaller one, or one the arena has + // no room for with them, is not. + const VkDeviceSize guard = desc_.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV && + desc_.NumDescriptors >= 65536 + ? DeviceState::heap_guard_bytes() + : 0; + if (guard && device.arena_allocate(bytes + guard, 256, arena_offset_, DeviceState::arena_descriptor_heap)) + guard_ = guard; + else if (!device.arena_allocate(bytes, 256, arena_offset_, DeviceState::arena_descriptor_heap)) { log_once("GPU address arena full (raise LEONIDA_ARENA_MB); shader-visible heap size in KiB:", int(std::min(bytes / 1024, INT_MAX))); return; } in_arena_ = true; cpu_ = device.arena.mapped + arena_offset_; - std::memset(cpu_, 0, std::size_t(bytes)); + std::memset(cpu_, 0, std::size_t(bytes + guard_)); if (desc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV || desc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER) { std::lock_guard lock(device.visible_heap_mutex); device.visible_heaps[arena_offset_] = {arena_offset_ + bytes, desc.Type}; } + if (desc.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV) { + std::lock_guard lock(device.cbv_heap_mutex); + device.cbv_heaps[arena_offset_] = arena_offset_ + bytes; + } } else { storage_.reset(new std::byte[std::size_t(bytes)]()); cpu_ = reinterpret_cast(storage_.get()); @@ -4444,7 +5314,8 @@ class DescriptorHeap final std::lock_guard lock(device_.visible_heap_mutex); device_.visible_heaps.erase(arena_offset_); } - if (in_arena_) device_.arena_release(arena_offset_, VkDeviceSize(desc_.NumDescriptors) * kDescriptorSize, + if (in_arena_) device_.arena_release(arena_offset_, + VkDeviceSize(desc_.NumDescriptors) * kDescriptorSize + guard_, DeviceState::arena_descriptor_heap); } @@ -4486,6 +5357,7 @@ class DescriptorHeap final std::unique_ptr storage_; std::uint8_t* cpu_ = nullptr; VkDeviceSize arena_offset_ = 0; + VkDeviceSize guard_ = 0; // null bytes after the heap in its arena range bool in_arena_ = false; std::uint64_t console_address_ = 0; std::uint64_t console_size_ = 0; @@ -4557,6 +5429,7 @@ class Resource final storage_->Release(); } if (title_texture_) device_.title_texture_gone(this, reinterpret_cast(title_address_)); + if (indexed_bda_) device_.backing(indexed_bda_, desc_.Width, id(), false); if (aliased_) leonida::title_va_aliases().remove(va_, title_alias_); if (accel_) { device_.context->unregister_acceleration_structure(gpu_va_); @@ -4598,6 +5471,13 @@ class Resource final device_.context->defer_destroy(leonida::DeferredDeletionQueue::Kind::image_memory, image_range_.release()); } + VkDeviceAddress indexed_bda_{}; + void index_shader_backing(VkDeviceAddress address) { + if (address) { + device_.backing(address, desc_.Width, id(), true); + indexed_bda_ = address; + } + } leonida::ResourceId id() const { return resource_id(this); } VkImage image() const { return deferred_attachment_ && !deferred_attachment_->ensure() ? VK_NULL_HANDLE : image_; } // A sampled placement can publish views of its shared, correctly sized zero image while its own image is unbound. @@ -4663,6 +5543,7 @@ class Resource final bool staged_title() const { return staged_title_; } bool upload_staged_title(const rt::xg_xs::Texture& layout, const std::uint8_t* tiled, std::vector& columns, bool inspect, bool& nonzero) { + std::lock_guard lock(device_.title_upload_mutex); return device_.title_upload.write(device_, id(), binding_, layout, tiled, columns, inspect, nonzero); } // Map and the destructor notify the registry for a slot-133 placement. @@ -4699,6 +5580,7 @@ class Resource final va_ = arena_offset_; binding.va = va_; binding.buffer = device_.arena.buffer; + binding.indirect_arguments = device_.arena.indirect_arguments; binding.buffer_offset = arena_offset_; // No host pointer: this is DEFAULT-heap arena memory the GPU may write, so its mapped bytes can be // stale. host_at() must not treat it as a CPU-written instance pointer list. @@ -4791,12 +5673,14 @@ class Resource final } } binding.buffer = buffer_; + binding.indirect_arguments = (info.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0; binding.size = desc_.Width; binding.host = cpu_writable() ? static_cast(mapped_) : nullptr; binding.host_readable = (heap_.Type == D3D12_HEAP_TYPE_READBACK || (heap_.Type == D3D12_HEAP_TYPE_CUSTOM && heap_.CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)); binding.va = va_; + index_shader_backing(addressable ? device_.arena.address + va_ : buffer_va_); device_.context->add_resource(id(), binding); // Committed resources start zeroed unless the heap says otherwise; the host cannot reach device-local memory, // so the next submission fills it (D3D-71). @@ -4813,6 +5697,13 @@ class Resource final // heap_base instead (alias_title_va, docs/d3d12_vulkan.md section 3.3 "Title-placed buffers"); V#s the title // writes into memory itself keep its VA. The pages stay the caller's: nothing is zeroed. HRESULT create_host_buffer(void* address) { + // LEONIDA_SLOT133_IMPORT=0 (diagnostic): no title-placed buffer is imported; each takes the shadow fallback, + // so no GPU store can reach title memory through an import. + static const bool no_import = [] { + const char* v = std::getenv("LEONIDA_SLOT133_IMPORT"); + return v && std::strcmp(v, "0") == 0; + }(); + if (no_import) return E_NOTIMPL; auto& vk = device_.context->vk; const VkDeviceSize alignment = device_.info.host_pointer_alignment; if (!device_.get_host_pointer_properties || !alignment) return E_NOTIMPL; @@ -4942,11 +5833,7 @@ class Resource final // logs the same wrap). Such an import is not used: the shadow buffer in the arena answers, as when the // import is refused. LEONIDA_IMPORT_BELOW_ARENA=1 keeps the import (for a shader library whose programs // sign-extend the address). - static const bool keep_low_imports = [] { - wchar_t value[2]{}; - return GetEnvironmentVariableW(L"LEONIDA_IMPORT_BELOW_ARENA", value, 2) == 1 && value[0] == L'1'; - }(); - if (buffer_va_ && buffer_va_ < device_.arena.address && !keep_low_imports) { + if (buffer_va_ && buffer_va_ < device_.arena.address && !signed_vsharp_offsets()) { static std::atomic logged{0}; if (logged.fetch_add(1, std::memory_order_relaxed) < 8) std::fprintf(stderr, @@ -4961,12 +5848,26 @@ class Resource final host_import_ = true; va_ = start; device_.log_va("title-placed buffer", va_, desc_.Width); + { + // Which title ranges a GPU store can reach through an import (the first 256, then every 256th). + static std::atomic imports{0}; + const std::uint64_t n = imports.fetch_add(1, std::memory_order_relaxed) + 1; + if (n <= 256 || n % 256 == 0) + std::fprintf(stderr, "[rt] d3d12: slot-133 import #%llu: title 0x%llx-0x%llx (%llu bytes), device " + "address 0x%llx, flags 0x%x\n", + static_cast(n), static_cast(start), + static_cast(start + desc_.Width), + static_cast(desc_.Width), static_cast(buffer_va_), + unsigned(desc_.Flags)); + } leonida::ResourceBinding binding{}; binding.buffer = buffer_; + binding.indirect_arguments = (info.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0; binding.size = desc_.Width; binding.host = static_cast(address); binding.host_readable = true; binding.va = va_; + index_shader_backing(buffer_va_); device_.context->add_resource(id(), binding); // Shaders reach the imported pages by their device address (src/title_va_alias.h). if (buffer_va_) alias_title_va(buffer_va_ - device_.arena.address); @@ -5012,6 +5913,7 @@ class Resource final device_.log_va("title-placed buffer (arena shadow)", va_, desc_.Width); leonida::ResourceBinding binding{}; binding.buffer = device_.arena.buffer; + binding.indirect_arguments = device_.arena.indirect_arguments; binding.buffer_offset = arena_offset_; binding.size = desc_.Width; binding.host = shadow_; @@ -5061,11 +5963,13 @@ class Resource final device_.log_va("title-placed buffer (shadow)", va_, desc_.Width); leonida::ResourceBinding binding{}; binding.buffer = buffer_; + binding.indirect_arguments = (info.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0; binding.size = desc_.Width; // CPU-side reads take the shadow, not the title's pages: it is as fresh as what the GPU reads and every byte // of it can be read, which the pages do not promise. Not host_readable: GPU writes are not handed back. binding.host = shadow_; binding.va = va_; + index_shader_backing(buffer_va_); device_.context->add_resource(id(), binding); if (buffer_va_) alias_title_va(buffer_va_ - device_.arena.address); return S_OK; @@ -5091,8 +5995,10 @@ class Resource final va_ = vk.vkGetBufferDeviceAddress(device_.info.device, &address) - device_.arena.address; leonida::ResourceBinding binding{}; binding.buffer = sparse->buffer; + binding.indirect_arguments = (info.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0; binding.size = desc_.Width; binding.va = va_; + index_shader_backing(va_ + device_.arena.address); binding.sparse_buffer = true; device_.context->add_sparse_resource(id(), binding, std::move(sparse)); return S_OK; @@ -5164,6 +6070,7 @@ class Resource final leonida::ResourceBinding binding{}; binding.size = desc_.Width; binding.buffer = device_.arena.buffer; + binding.indirect_arguments = device_.arena.indirect_arguments; binding.buffer_offset = va_; binding.va = va_; binding.host = cpu_writable() ? device_.arena.mapped + va_ : nullptr; @@ -5786,7 +6693,12 @@ class Resource final return map_title_texture(subresource, read, data); } if (image_ && title_address_) { // place_at_title_address: the console answers with the texture's memory - if (data) *data = title_address_; + if (data) { + *data = title_address_; + rt::placed_image_map_note::note(title_address_, subresource, read, + desc_.Width == 1 && desc_.Height == 1 && desc_.Format == DXGI_FORMAT_R32G32B32A32_FLOAT); + read_back_on_map(subresource); + } // From now on the CPU may write its texels whenever it likes (video planes are mapped once): the // registry checks this texture's bytes before submissions (Device::refresh_title_textures). if (title_texture_ && !title_mapped_.exchange(true, std::memory_order_relaxed)) @@ -5809,6 +6721,51 @@ class Resource final if (data) *data = mapped_; return S_OK; } + // LEONIDA_MAP_READBACK=1: the GPU's texels of a small render target the title placed are written into the title's + // pages when it maps the target. The title reads its exposure statistics that way every frame (a 1x1 and a 5x1 + // RGBA32F target, Map at 0x5121690 from 0xb96aa0: team/exposure-readback.md); the GPU renders into our image, + // never into those pages, so the CPU read zeros and the exposure went to ~0 (a frame crushed to black, peak + // 0.008). Only a single-row, single-mip, single-layer 2D target of at most 4 KiB: the console's linear layout + // puts that row at offset 0 (xg-rt-layout), so the row pitch does not matter. The copy waits for the GPU + // (ReadFromSubresource's staging copy, behind the work already submitted), and lands through a guarded copy: a + // page that is not writable now is left as it is. + void read_back_on_map(UINT subresource) { + static const bool on = [] { + const char* v = std::getenv("LEONIDA_MAP_READBACK"); + return v && std::strcmp(v, "1") == 0; + }(); + if (!on || subresource != 0) return; + if (!(desc_.Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS))) + return; + if (desc_.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || desc_.Height != 1 || desc_.DepthOrArraySize != 1 || + desc_.MipLevels > 1 || binding_.samples > 1) + return; + const auto block = leonida::copy_block_format(binding_, VK_IMAGE_ASPECT_COLOR_BIT); + if (!block.bytes || block.block != 1) return; + const std::uint64_t row = desc_.Width * block.bytes; + if (!row || row > 4096) return; + std::uint8_t texels[4096]; + const HRESULT hr = cpu_copy(false, 0, nullptr, texels, UINT(row), UINT(row)); + static std::atomic done{0}, failed{0}; + if (FAILED(hr) || !copy_guarded(static_cast(title_address_), texels, std::size_t(row), false)) { + const std::uint64_t n = failed.fetch_add(1, std::memory_order_relaxed) + 1; + if (n <= 4 || !(n & (n - 1))) + std::fprintf(stderr, "[rt] d3d12: map read-back of a %llux1 target at %p failed (hr 0x%08lx; %llu so far)\n", + static_cast(desc_.Width), title_address_, static_cast(hr), + static_cast(n)); + return; + } + const std::uint64_t n = done.fetch_add(1, std::memory_order_relaxed) + 1; + if (n <= 8 || !(n & (n - 1))) { + float f[4] = {}; + std::memcpy(f, texels, (std::min)(sizeof(f), std::size_t(row))); + std::fprintf(stderr, "[rt] d3d12: map read-back #%llu: %llux1 format %d target at %p, first texel %g %g %g " + "%g\n", + static_cast(n), static_cast(desc_.Width), + int(desc_.Format), title_address_, f[0], f[1], f[2], f[3]); + } + } + // A texture the title placed: Unmap ends its CPU writes (the title's lock passes the range it wrote), so its // image is filled again before the next submission (TitleTexture). void STDMETHODCALLTYPE Unmap(UINT sub, const D3D12_RANGE* written) override { @@ -6994,18 +7951,45 @@ HRESULT parse_pipeline_stream(const D3D12_PIPELINE_STATE_STREAM_DESC& desc, Pipe // A pipeline state, compute (create_compute) or graphics (create_graphics): each shader is found by the SHA-256 of // its FSSM program in the translator's index, and the FSSM blob is copied into the arena as the shader's code base. +std::atomic live_pipeline_state_count{0}; // live_pipeline_states() + class PipelineState final : public Child { public: // {8d2f6c14-b0e7-4a93-9c58-1f4a7e3b6d20} static constexpr GUID kTag{0x8d2f6c14, 0xb0e7, 0x4a93, {0x9c, 0x58, 0x1f, 0x4a, 0x7e, 0x3b, 0x6d, 0x20}}; - explicit PipelineState(DeviceState& device) : device_(device) {} + explicit PipelineState(DeviceState& device) : device_(device) { ++live_pipeline_state_count; } + + // Object::Release at zero references. Background builds hold no reference to the PSO: its queued ones are dropped + // here. One already running (a vkCreate*Pipelines in the driver, minutes for some modules) is not waited for: the + // PSO is deleted on the worker when that build returns, so the title's Release returns now. The device reference + // goes now, so a device released with its last PSO is torn down here, and ~Device waits for the build and the + // deletion (PipelineCompiler::cancel). Released on the worker inside its own build, both wait for its return. + void last_release() { + // The registry's build callback reaches this PSO by a raw pointer: unregistered first, so nothing queues a + // build for it after the queued ones are dropped. + unregister(); + IUnknown* const device = detach_device(); + auto& compiler = PipelineCompiler::instance(); + const bool own_build = compiler.running_here(compile_owner()); + IUnknown* const release_after = own_build ? device : nullptr; + if (compiler.after_running(compile_owner(), [this, release_after] { + delete this; + if (release_after) release_after->Release(); + })) { + if (device && !own_build) device->Release(); + return; + } + delete this; + if (device) device->Release(); + } ~PipelineState() override { + unregister(); + PipelineCompiler::instance().cancel(compile_owner()); // nothing left in practice (last_release) auto& vk = device_.context->vk; const VkDevice dev = device_.info.device; - if (registered_) device_.context->remove_pipeline(id()); if (pipeline_.pipeline) vk.vkDestroyPipeline(dev, pipeline_.pipeline, nullptr); if (pipeline_.layout) vk.vkDestroyPipelineLayout(dev, pipeline_.layout, nullptr); if (module_) vk.vkDestroyShaderModule(dev, module_, nullptr); @@ -7014,6 +7998,7 @@ class PipelineState final if (graphics_.layout) vk.vkDestroyPipelineLayout(dev, graphics_.layout, nullptr); modules_.clear(); if (code_bytes_) device_.arena_release(code_base_, code_bytes_, DeviceState::arena_shader); + --live_pipeline_state_count; } // Pipeline layouts declare the whole 144-byte block as one push-constant range. A device whose @@ -7056,6 +8041,14 @@ class PipelineState final }); return native_source_ready_; } + // What its PipelineCompiler jobs are filed under: the interface pointer the title holds. + const void* compile_owner() const { return static_cast(this); } + // Out of the context's pipeline registry (and its build callback), once. + void unregister() { + if (!registered_ || unregistered_) return; + device_.context->remove_pipeline(id()); + unregistered_ = true; + } void set_cache_key(leonida::cached_pso::Key key) { cache_key_ = std::move(key); } // A null pointer is accepted with S_OK, as by the PC runtime (measured on an RTX 3060 and WARP). @@ -7557,6 +8550,7 @@ class PipelineState final if (!(divisor_slots & (1u << element.InputSlot))) { divisor_slots |= 1u << element.InputSlot; divisors.push_back({element.InputSlot, element.InstanceDataStepRate}); + graphics_.nonunit_vertex_divisor = true; } } if (!(graphics_.vertex_slots & (1u << element.InputSlot))) { @@ -8056,7 +9050,10 @@ class PipelineState final module_info.codeSize = words.size() * 4; module_info.pCode = words.data(); VkShaderModule module = VK_NULL_HANDLE; - if (vk.vkCreateShaderModule(dev, &module_info, nullptr, &module) != VK_SUCCESS) return VK_NULL_HANDLE; + { + const leonida::aftermath::ShaderName named(entry->name); + if (vk.vkCreateShaderModule(dev, &module_info, nullptr, &module) != VK_SUCCESS) return VK_NULL_HANDLE; + } const auto bytes = module_info.codeSize; std::vector().swap(words); // vkCreateShaderModule consumed pCode VkComputePipelineCreateInfo pipeline_info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; @@ -8097,33 +9094,39 @@ class PipelineState final // Lazy compute pipelines are also built in the background, smallest module first, so most exist before their // first dispatch. One low-priority thread; modules over LEONIDA_COMPUTE_WARMUP_MAX_BYTES of SPIR-V (default // 1 MiB) are left to their first dispatch, since some take the driver minutes each. LEONIDA_COMPUTE_WARMUP=0 - // turns the thread off. A queued PSO is kept alive by a reference until it is built. + // turns the thread off. A queued build holds no reference: a PSO released first drops it (last_release). + // The startup cache checkpoint is the device's job, not this PSO's: ~Device cancels it before the cache goes. void maybe_checkpoint(VkPipelineCache cache) { if (!cache || !startup_cache_checkpoints_enabled()) return; auto now = GetTickCount64(); auto next = device_.next_checkpoint.load(); if (now < next || !device_.next_checkpoint.compare_exchange_strong(next, ULLONG_MAX)) return; - AddRef(); + DeviceState* const state = &device_; + bool queued = false; try { - PipelineCompiler::instance().submit(SIZE_MAX, [this, cache] { + queued = PipelineCompiler::instance().submit(state, state, SIZE_MAX, [state, cache] { try { - if (!device_.active_compiles.load() && !PipelineCompiler::instance().has_compile_waiter()) - save_session_pipeline_cache(device_.context->vk, device_.info.device, cache, true); + if (!state->active_compiles.load() && !PipelineCompiler::instance().has_compile_waiter()) + save_session_pipeline_cache(state->context->vk, state->info.device, cache, true); } catch (const std::exception& e) { std::fprintf(stderr, "[rt] pipeline cache checkpoint failed: %s\n", e.what()); } - device_.next_checkpoint.store(GetTickCount64() + 120000); - Release(); + state->next_checkpoint.store(GetTickCount64() + 120000); }); } catch (...) { - device_.next_checkpoint.store(now + 120000); - Release(); } + if (!queued) device_.next_checkpoint.store(now + 120000); // refused after an exit stop, or out of memory } VkPipeline queue_build(bool compute, std::uint32_t unbound, std::size_t warm_bytes = 0) { static std::mutex publication; // ready handles only; no compiler call holds this lock const bool warm = warm_bytes != 0; + // After an exit stop (stop_pipeline_compiles) nothing is queued: a warm-up is skipped, and a draw or dispatch + // builds in place, as without LEONIDA_ASYNC_PIPELINES, rather than waiting for a build that never comes. + if (PipelineCompiler::instance().closed()) { + if (warm) return VK_NULL_HANDLE; + return compute ? build_compute("dispatch") : variant(unbound, "draw"); + } std::lock_guard lock(publication); if (!warm) { if (!requested_) requested_ = std::make_unique(); @@ -8131,9 +9134,9 @@ class PipelineState final if (!it->second.handle) ++it->second.skips; if (!inserted) return it->second.handle; } - AddRef(); + bool queued = false; try { - PipelineCompiler::instance().submit(warm_bytes, [this, compute, warm, unbound] { + queued = PipelineCompiler::instance().submit(compile_owner(), &device_, warm_bytes, [this, compute, warm, unbound] { VkPipeline built{}; try { built = compute ? build_compute(warm ? "warmup" : "dispatch-worker") @@ -8154,12 +9157,12 @@ class PipelineState final } catch (const std::exception& e) { std::fprintf(stderr, "[rt] pipeline compile worker failed: %s\n", e.what()); } - Release(); }); } catch (...) { - if (!warm) requested_->erase(unbound); - Release(); } + // Not queued (refused by a stop that came after the check above, or out of memory): no request stays + // recorded, so the next use asks again instead of waiting for a build that never comes. + if (!queued && !warm) requested_->erase(unbound); return VK_NULL_HANDLE; } @@ -8288,6 +9291,10 @@ class PipelineState final bytes += module_info.codeSize; module_info.pCode = words[i].data(); VkShaderModule module = VK_NULL_HANDLE; + const leonida::aftermath::ShaderName named( + sources_[i].entry ? sources_[i].entry->name.c_str() + : sources_[i].kind == StageSource::rect_list ? "(rect-list geometry)" + : "(depth24 depth-only fragment)"); if (device_.context->vk.vkCreateShaderModule(device_.info.device, &module_info, nullptr, &module) != VK_SUCCESS) { drop_modules(); @@ -8497,6 +9504,7 @@ class PipelineState final VkDeviceSize code_base_ = 0; VkDeviceSize code_bytes_ = 0; bool registered_ = false; + bool unregistered_ = false; // taken out of the context's registry (unregister) bool is_graphics_ = false; std::vector subgroup_requests_; // one per stage, in creation order unsigned pending_stream_kind_=0; @@ -8996,6 +10004,7 @@ struct TitleTexture { bool layout_known = false; bool layout_guessed = false; // a slot-133 texture's own description (Layout 0), no slot-70 view yet bool layout_from_xg = false; // the title's XG computer of its shape (title_xg_layout) + std::chrono::steady_clock::time_point view_checked{}; // refresh_title_texture's last look (a view's), throttled Resource* resource = nullptr; // Snapshot at registration. A diagnostic census then need not fault in each Resource to count its image memory. VkDeviceSize backing_bytes = 0, unbound_bytes = 0; @@ -9590,8 +10599,10 @@ class Device final for (std::uint32_t f : {info.queue_family, info.compute_family, info.copy_family}) if (f != UINT32_MAX && std::find(state_.families.begin(), state_.families.end(), f) == state_.families.end()) state_.families.push_back(f); - const auto get_device = reinterpret_cast( - info.get_instance_proc(info.instance, "vkGetDeviceProcAddr")); + // LEONIDA_AFTERMATH: every function table loaded through it (the context's, the helpers' own) creates its + // shader modules through the wrapper that maps Aftermath shader hashes to names (src/vulkan_aftermath.h). + const auto get_device = leonida::aftermath::wrap_get_device_proc_addr(reinterpret_cast( + info.get_instance_proc(info.instance, "vkGetDeviceProcAddr"))); state_.format_properties = reinterpret_cast( info.get_instance_proc(info.instance, "vkGetPhysicalDeviceFormatProperties")); state_.format_properties2 = reinterpret_cast( @@ -9717,11 +10728,16 @@ class Device final } } + const leonida::GraphicsIndirectCapabilities indirect{ + .first_instance = info.draw_indirect_first_instance, .multiple = info.multi_draw_indirect, + .count_buffer = info.draw_indirect_count_enabled, .max_count = info.max_draw_indirect_count, + .robust_index_view = info.robust_index_view, .require_clamp = leonida::indirect_clamp_enabled()}; state_.context = std::make_unique(get_device, info.device, info.separate_depth_stencil_layouts, info.conditional_rendering, info.ray_tracing, info.xdxr_acceleration_structures && - info.buffer_device_address); + info.buffer_device_address, + indirect); if (info.device_fault_diagnostics) { state_.context->configure_device_fault(get_device, {info.device_fault_info, info.device_checkpoints, info.device_diagnostics_config}); @@ -9731,13 +10747,46 @@ class Device final for (auto queue : info.copy_queues) state_.context->add_diagnostic_queue(queue); } leonida::mem_probe::install(state_.context->vk); // LOCAL DIAGNOSTIC: before anything allocates - if (info.device_fault_diagnostics && rt::compute_probe::enabled()) + if (info.device_fault_diagnostics && rt::compute_probe::enabled()) { state_.context->set_input_probe([this](auto lists, auto sequence, auto queue) { rt::compute_probe::inspect(state_, lists, sequence, queue); }); + if (auto* fault = state_.context->device_fault()) + fault->set_lost_hook([this] { rt::compute_probe::recheck(state_); }); + } state_.context->set_before_execute([this] { - state_.refresh_shadows(); - state_.geometry.refresh(DeviceState::copy_geometry); + namespace phases = leonida::submit_phases; + // LEONIDA_REFRESH_PER_FRAME (for runs that only need the title to go on): 1 = the slot-133 shadows, title + // windows and geometry copies are brought up to date only by the first submission after each present, + // not by every one of the ~24 submissions of a title frame (speed-18: ~30 ms of them a submission, one + // title frame a second); 2 = the console heaps too. A GPU read of them is then up to a frame behind the + // title's writes: wrong pixels, nothing the title waits for (the copies are one way). 0 (default): all + // at every submission, as before. + static const int per_frame = [] { + const char* v = std::getenv("LEONIDA_REFRESH_PER_FRAME"); + return v && *v ? std::atoi(v) : 0; + }(); + bool full = true; + if (per_frame) { + const std::uint64_t serial = phases::totals().present_serial.load(std::memory_order_relaxed); + full = refreshed_present_.exchange(serial, std::memory_order_relaxed) != serial; + } + state_.refresh_shadows(full || per_frame < 2, full); + // LEONIDA_GEOMETRY_ASYNC=1 (for runs that only need the title to go on): the geometry copies are brought + // up to date on a worker of ours, started here and not waited for, instead of on the title's GPU submit + // thread (speed-27: 230-330 ms a refresh after the load, a VirtualQuery and VirtualProtect per written + // tile under Wine). A draw may then read a copy the worker is still writing: wrong vertices for a frame. + static const bool geometry_async = [] { + const char* v = std::getenv("LEONIDA_GEOMETRY_ASYNC"); + return v && std::strcmp(v, "1") == 0; + }(); + if (full && geometry_async) { + kick_geometry_refresh(); + } else if (full) { + const phases::Scope timed(phases::geometry); + state_.geometry.refresh(DeviceState::copy_geometry); + } + const phases::Scope timed(phases::textures); refresh_title_textures(); }); { @@ -9913,6 +10962,14 @@ class Device final get_props(info.physical, &props); state_.context->configure_counted_dispatch(get_device, state_.memory, props.limits); state_.context->configure_quad_indices(get_device, props.limits); + // ExecuteIndirect arguments are clamped on the GPU before every indirect command (vulkan_indirect_clamp.h). + // Its record scratch is device-local memory with a device address, like the arena's. + state_.context->enable_indirect_clamp(get_device, state_.memory, props.limits, + [this](const VkMemoryRequirements& requirements) { + return state_.allocate(requirements, 0, + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, + nullptr, /*device_address=*/true); + }); } } // The copies of a D24 texture stored as D32 convert on the GPU (vulkan_depth24.h), and so do the copies of @@ -10017,6 +11074,7 @@ class Device final leonida::BindlessFeatures features{}; features.update_after_bind = true; // VulkanDeviceInfo::bindless promises it features.partially_bound = state_.info.bindless_partially_bound; + features.null_descriptor = state_.info.null_descriptor; // The descriptor-table hash kind every shader of this device probes with, chosen once here, before the table's // first key: each loaded module's index.json meta may say `descriptor_hash` (descriptor_table.h), and when the // library mixes kinds the majority wins; LEONIDA_DESCRIPTOR_HASH overrides. The module index is read here @@ -10231,6 +11289,7 @@ class Device final return false; } vk.vkGetBufferMemoryRequirements(state_.info.device, arena.buffer, &requirements); + arena.indirect_arguments = (info.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0; return true; }; if (!create_buffer()) return false; @@ -10267,26 +11326,53 @@ class Device final return false; } arena.mapped = static_cast(mapped); - std::memset(arena.mapped, 0, kZeroPage); // the zero page unbound vertex and index buffers read - auto* indices = reinterpret_cast(arena.mapped + kZeroPage); - for (std::uint32_t i = 0; i < kQuadIndexCount; i += kQuadIndicesPerQuad) { - const std::uint32_t base = i / kQuadIndicesPerQuad * 4; - std::transform(leonida::quad_triangle_indices.begin(), leonida::quad_triangle_indices.end(), indices + i, - [base](std::uint32_t index) { return base + index; }); + // LEONIDA_ARENA_NULL_MB= (for compute-on boots): the first n MiB of the arena, at heap_base + 0, are zeroed + // and never handed out, and the zero page and the quad indices move above them. A translated shader whose + // address arithmetic starts from a null base (a scalar or flat load the translator does not bounds-check) + // reads or writes there, not in a buffer of the title's or the shared zero page and quad indices, which sat + // at offset 0 (world-start compute faults read heap_base + ~0 on both platforms). + const VkDeviceSize null_bytes = [&] { + char text[16] = {}; + std::size_t n = 0; + if (getenv_s(&n, text, "LEONIDA_ARENA_NULL_MB") != 0 || n <= 1) return VkDeviceSize(0); + const VkDeviceSize bytes = VkDeviceSize(std::strtoull(text, nullptr, 10)) << 20; + return bytes + kArenaReserved < info.size / 2 ? bytes : VkDeviceSize(0); + }(); + std::memset(arena.mapped, 0, std::size_t(null_bytes + kZeroPage)); // the null region and the zero page + { + auto* indices = reinterpret_cast(arena.mapped + null_bytes + kZeroPage); + for (std::uint32_t i = 0; i < kQuadIndexCount; i += kQuadIndicesPerQuad) { + const std::uint32_t base = i / kQuadIndicesPerQuad * 4; + std::transform(leonida::quad_triangle_indices.begin(), leonida::quad_triangle_indices.end(), indices + i, + [base](std::uint32_t index) { return base + index; }); + } } + if (null_bytes) + std::fprintf(stderr, "[rt] d3d12: arena null region: the first %llu MiB at heap_base are zeroed and never " + "allocated (LEONIDA_ARENA_NULL_MB)\n", + static_cast(null_bytes >> 20)); VkBufferDeviceAddressInfo address{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; address.buffer = arena.buffer; arena.address = vk.vkGetBufferDeviceAddress(state_.info.device, &address); arena.size = info.size; - arena.free[kArenaReserved] = arena.size - kArenaReserved; - arena.peak_end = kArenaReserved; + { + // Under the arena's lock: an insert rebalances the tree and rewrites child links, which a walk on + // another thread must not see half done. + std::lock_guard lock(arena.mutex); + arena.blocks.reset(null_bytes + kArenaReserved, arena.size); + char check[2] = {}; + size_t check_length = 0; + arena.check_all = getenv_s(&check_length, check, "LEONIDA_ARENA_CHECK") == 0 && check_length > 1 && + check[0] != '0'; + } + arena.peak_end = null_bytes + kArenaReserved; char log[4] = {}; length = 0; arena.log = getenv_s(&length, log, "LEONIDA_ARENA_LOG") == 0 && length > 1 && log[0] != '0'; - state_.context->set_heap_base(arena.address); + state_.context->set_heap_base(arena.address, arena.size); leonida::fsdraw::note_arena(arena.mapped, arena.size); // LOCAL DIAGNOSTIC - state_.context->set_zero_page(arena.buffer, 0, kZeroPage); - state_.context->set_quad_indices(arena.buffer, kZeroPage, kQuadIndexCount); + state_.context->set_zero_page(arena.buffer, null_bytes, kZeroPage); + state_.context->set_quad_indices(arena.buffer, null_bytes + kZeroPage, kQuadIndexCount); // Copy only registered title data. Each immutable upload stays alive in the queue command slot // until that submission's timeline value completes; a large indexed frame cannot wrap over itself. state_.context->set_geometry_provider([st=&state_](std::uint64_t va,std::uint64_t bytes, @@ -10322,6 +11408,23 @@ class Device final ~Device() override { raw_images_.clear(); + geometry_refresher_.reset(); // its refresh uses state_.geometry + title_filler_.reset(); // its fills use the title-texture registry + // Background pipeline work first, before anything it uses goes. Every PSO is gone (each held this device), + // but a PSO released while its build ran is deleted on the worker after that build; the device's startup + // cache checkpoint may also be queued or running. cancel() drops what is queued and waits for both. The last + // device then stops and joins the compiler's thread. + { + auto& compiler = PipelineCompiler::instance(); + if (compiler.running_here(&state_)) { + // A build job of this device released the device's last reference from inside the build, which + // goes on using the device when this returns. Nothing does this; stop rather than free under it. + std::fprintf(stderr, "[rt] d3d12: device released from inside one of its own pipeline builds\n"); + std::abort(); + } + compiler.cancel(&state_); + compiler_use_.release(); + } leonida::title_va_aliases().clear_hooks(&state_); { std::lock_guard lock(state_.title_window_mutex); @@ -10345,6 +11448,7 @@ class Device final if (state_.context) { state_.geometry.release(state_); state_.external_windows.release(state_); + std::lock_guard upload(state_.title_upload_mutex); state_.title_upload.release(state_); } state_.staging_queue.reset(); // it uses the context @@ -10364,7 +11468,13 @@ class Device final if (state_.arena.memory) vk.vkFreeMemory(state_.info.device, state_.arena.memory, nullptr); } if (state_.pipeline_cache_handle) { - save_session_pipeline_cache(state_.context->vk, state_.info.device, state_.pipeline_cache_handle); + // Nothing should be building into the cache now (the compiler's jobs for this device are gone, and so + // is every PSO). If something is, its pipelines are half in the cache: keep the previous session file. + if (const unsigned building = state_.active_compiles.load()) + std::fprintf(stderr, "[rt] d3d12: %u pipeline build(s) still running at device teardown; " + "pipeline_cache.session.bin not written\n", building); + else + save_session_pipeline_cache(state_.context->vk, state_.info.device, state_.pipeline_cache_handle); state_.context->vk.vkDestroyPipelineCache(state_.info.device, state_.pipeline_cache_handle, nullptr); } state_.context.reset(); @@ -10493,6 +11603,12 @@ class Device final } bool bind_sampler(const leonida::gfx10::SamplerWords& words) { return state_.bind_sampler(words); } // Xbox device slots 70/71 (rt::d3d12::write_placed_buffer_view): the slot is zeroed first, as Create*View does. + bool resolve_xdxr_build(leonida::BuildAccelerationStructure& build) { return state_.resolve_xdxr_build(build); } + bool resolve_xdxr_copy(leonida::CopyAccelerationStructure& copy) { return state_.resolve_xdxr_copy(copy); } + bool resolve_xdxr_postbuild(leonida::AccelerationStructurePostbuild& info) { + return state_.resolve_xdxr_postbuild(info); + } + bool write_placed_buffer_view(bool unordered, const void* view, std::uint64_t address, std::uint64_t width, D3D12_CPU_DESCRIPTOR_HANDLE destination) { struct PlacedWrite { @@ -10664,6 +11780,8 @@ class Device final static const auto period = std::chrono::milliseconds(setting("LEONIDA_TITLE_TEXTURE_PERIOD_MS", 16)); static const std::uint64_t check_budget = setting("LEONIDA_TITLE_TEXTURE_CHECK_KB", 4096) << 10; static const std::uint64_t fill_budget = setting("LEONIDA_TITLE_TEXTURE_FILL_MB", 32) << 20; + // And at most this long filling a pass (0: no limit); a texture already started is finished. + static const std::uint64_t fill_budget_ns = setting("LEONIDA_TITLE_TEXTURE_FILL_MS", 8) * 1000000; // Stop the background sweep at a texture boundary. Zero keeps the byte budget alone. static const std::uint64_t hash_budget_us = setting("LEONIDA_TEXTURE_HASH_BUDGET_US", 400); // Residency checks and uploads also cost time. Limit background work between textures; @@ -10680,13 +11798,29 @@ class Device final const InTitleTextures inside; TitleTextureStats& stats = title_stats_; ++stats.passes; - std::uint64_t checked = 0, filled = 0; + // A fill this pass makes can submit, and a submission destroys a retired image, whose destructor erases its + // registry entry (title_texture_gone). The registry mutex is recursive for its owner on Windows, so that + // erase lands inside this pass: every walk below visits a snapshot, never an iterator into the registry. + const auto entries = leonida::title_texture_snapshot(state_.title_textures); + title_pass_ = true; + std::uint64_t checked = 0, filled = 0, fill_pass_ns = 0; const auto visit = [&](TitleTexture& t) { // A slot-133 texture's guessed layout (no slot-70 view yet) is only used once the title maps it. if (t.gpu_written || !t.layout_known || !t.resource || ((t.layout_guessed || t.layout_from_xg) && !t.mapped && !t.stale)) return; const std::uint64_t span = t.layout.layout.size; + const bool always = t.mapped && refresh_mapped_pages(); + // Out of this pass's fill budget (bytes or time): a texture known to need a fill (stale) waits for the + // next pass unprobed and unhashed; hashing it now would only find it changed again (measured: 10,000 + // deferred textures, 600 MiB hashed a pass, during the story load). + const auto out_of_budget = [&] { + return (filled && filled + span > fill_budget) || (fill_budget_ns && fill_pass_ns >= fill_budget_ns); + }; + if (t.stale && !always && out_of_budget()) { + ++stats.deferred; + return; + } std::uint64_t hash = 0; if (!title_texture_readable(t)) return; checked += hashed_bytes(span); @@ -10713,38 +11847,66 @@ class Device final if (t.full_hashed && full == t.full_hash) return; } ++stats.changed; - if (!(t.mapped && refresh_mapped_pages()) && filled && filled + span > fill_budget) { + if (!always && out_of_budget()) { t.stale = true; ++stats.deferred; return; } + const auto fill_start = clock::now(); filled += fill_title_texture(t, false); + const std::uint64_t fill_ns = + std::chrono::duration_cast(clock::now() - fill_start).count(); + stats.fill_ns += fill_ns; + fill_pass_ns += fill_ns; }; bool overflow = false; auto written = leonida::title_texel_writes::take(overflow); - if (!written.empty() || overflow) { + // What the title memory map changed since the last pass: a texture over a change is probed again (its pages + // may have come or gone), the others keep their last answer (TextureReadability). Every kRetryAll, or when the + // journal lost some changes, all are probed again, for whatever no change reports. + constexpr auto kRetryAll = std::chrono::seconds(30); + title_map_changes_.clear(); + std::uint64_t map_now = 0; + bool map_all = !leonida::title_memory_map::changes_since( + title_map_generation_, map_now, 0, UINTPTR_MAX, + [&](std::uintptr_t from, std::uintptr_t to) { title_map_changes_.emplace_back(from, to); }); + title_map_generation_ = map_now; + if (now - title_retry_all_ >= kRetryAll) map_all = true; + if (map_all) title_retry_all_ = now; + leonida::merge_title_writes(title_map_changes_); + stats.map_ranges += title_map_changes_.size(); + stats.map_all += map_all; + if (!written.empty() || overflow || map_all || !title_map_changes_.empty()) { stats.written_ranges += written.size(); leonida::merge_title_writes(written); - for (auto& [address, t] : state_.title_textures) { - if (t->gpu_written || !t->layout_known) continue; - const std::uint64_t begin = t->cpu, end = t->cpu + t->layout.layout.size; + for (const auto& entry : entries) { + TitleTexture& t = *entry.second; + if (t.gpu_written || !t.layout_known) continue; + const std::uint64_t begin = t.cpu, end = t.cpu + t.layout.layout.size; + if (map_all || leonida::title_write_overlaps(title_map_changes_, begin, end)) t.memory.retry(); if (leonida::title_write_overlaps(written, begin, end)) { - t->memory.retry(); - t->stale = true; + t.memory.retry(); + t.stale = true; } if (overflow) { - t->memory.retry(); - t->hashed = false; + t.memory.retry(); + t.hashed = false; } } } - for (auto& [address, t] : state_.title_textures) - if (t->mapped || t->stale) visit(*t); + const auto every_start = clock::now(); + stats.written_ns += std::chrono::duration_cast(every_start - now).count(); + for (const auto& entry : entries) + if (entry.second->mapped || entry.second->stale) { + ++stats.every_pass_visits; + visit(*entry.second); + } + stats.every_pass_ns += std::chrono::duration_cast(clock::now() - every_start).count(); // The budget is the round robin's: mapped and stale textures above are checked every pass whatever it is. const auto first_bytes = checked, first_hash_ns = stats.hash_ns; if (check_budget) { const auto sweep_start = clock::now(); - leonida::poll_title_textures(state_.title_textures, title_refresh_cursor_, visit, [&] { + leonida::poll_title_textures(entries, title_refresh_cursor_, visit, [&] { if (checked - first_bytes >= check_budget || (hash_budget_us && (stats.hash_ns - first_hash_ns) / 1000 >= hash_budget_us)) return true; if (!sweep_budget_us) return false; @@ -10762,7 +11924,10 @@ class Device final release.push_back(r.second); return true; }); - stats.refresh_ns += std::chrono::duration_cast(clock::now() - now).count(); + title_pass_ = false; + const std::uint64_t pass_ns = std::chrono::duration_cast(clock::now() - now).count(); + stats.refresh_ns += pass_ns; + stats.max_refresh_ns = std::max(stats.max_refresh_ns, pass_ns); if (now - stats.last_log >= std::chrono::seconds(10)) { stats.last_log = now; log_title_census("refresh"); @@ -10782,12 +11947,225 @@ class Device final std::uint64_t staged_fills = 0, staged_ns = 0; // refresh_title_textures, since the last log line std::uint64_t passes = 0, checked = 0, hashed = 0, changed = 0, deferred = 0, filled_bytes = 0, - max_pass_bytes = 0, hash_ns = 0, refresh_ns = 0; + max_pass_bytes = 0, hash_ns = 0, refresh_ns = 0, max_refresh_ns = 0; + // Split of refresh_ns: taking and matching the XG-written ranges, the mapped and stale textures visited every + // pass (and how many), and the fills inside both. + std::uint64_t written_ns = 0, every_pass_ns = 0, every_pass_visits = 0, fill_ns = 0; + std::uint64_t map_ranges = 0, map_all = 0; // title memory map changes taken, passes that retried all + // Readability probes (texture_memory_readable) since the last log line: [0] in refresh passes, [1] elsewhere + // (slot-70 views, new images). A recheck is a probe of a texture whose memory was not readable at its last + // probe; readable_now counts the rechecks that found it readable. + std::array probes{}, probe_ns{}, rechecks{}, readable_now{}; std::chrono::steady_clock::time_point last_log{}; }; TitleTextureStats title_stats_; // under title_texture_mutex + bool title_pass_ = false; // in refresh_title_textures, likewise std::atomic title_refreshed_{0}; // steady_clock ticks of the last pass + std::atomic refreshed_present_{~std::uint64_t(0)}; // LEONIDA_REFRESH_PER_FRAME: present of the last full refresh + + // LEONIDA_TITLE_FILL_ASYNC=1 (for runs that only need the title to go on): slot-70 views no longer fill or hash + // the texture they name on the title's thread (speed-26/27: a title thread 68-88 % inside slot 70, in hashing, + // copying and staged uploads). The texture's address is queued, and a worker of ours fills it, taking the registry + // lock for one texture at a time. Until then a shader samples the image as it is: empty, or a frame behind. + static bool title_fill_async() { + static const bool on = [] { + const char* v = std::getenv("LEONIDA_TITLE_FILL_ASYNC"); + return v && std::strcmp(v, "1") == 0; + }(); + return on; + } + struct TitleFiller { + std::mutex mutex; + std::condition_variable wake; + std::deque queue; // texture addresses + std::unordered_set queued; + bool stop = false; + std::thread thread; + std::uint64_t filled = 0, skipped = 0; + std::vector tiled; // the worker's own snapshot of a texture's bytes (fill_unlocked) + std::vector columns; // its detiling scratch + ~TitleFiller() { + { + std::lock_guard lock(mutex); + stop = true; + } + wake.notify_one(); + if (thread.joinable()) thread.join(); + } + }; + std::unique_ptr title_filler_; + std::once_flag title_filler_once_; + void queue_title_fill(std::uint64_t address) { + std::call_once(title_filler_once_, [this] { + title_filler_ = std::make_unique(); + TitleFiller* f = title_filler_.get(); + f->thread = std::thread([this, f] { run_title_filler(*f); }); + }); + { + std::lock_guard lock(title_filler_->mutex); + if (!title_filler_->queued.insert(address).second) return; + title_filler_->queue.push_back(address); + } + title_filler_->wake.notify_one(); + } + void run_title_filler(TitleFiller& f) { + using clock = std::chrono::steady_clock; + auto since = clock::now(); + for (;;) { + std::uint64_t address = 0; + { + std::unique_lock lock(f.mutex); + f.wake.wait(lock, [&] { return f.stop || !f.queue.empty(); }); + if (f.stop) return; + address = f.queue.front(); + f.queue.pop_front(); + f.queued.erase(address); + } + bool filled = false; + // A staged texture is filled without the registry lock (the title's threads creating views wait for + // it: speed-31, 12 % of the main thread): its bytes, layout and resource are taken under the lock, the + // copy, hash and upload are made outside it, and the result is recorded under it again if the texture + // still has that resource. Others (host copies, unbound memory) are filled under the lock as before. + Resource* r = nullptr; + rt::xg_xs::Texture layout{}; + std::uint64_t cpu = 0, fills = 0; + bool every_byte = false; + { + std::lock_guard lock(state_.title_texture_mutex); + const InTitleTextures inside; + const auto it = state_.title_textures.find(address); + if (it != state_.title_textures.end()) { + TitleTexture& t = *it->second; + if (t.resource && t.layout_known && !t.gpu_written && (t.stale || !t.hashed) && + title_texture_readable(t)) { + t.stale = false; + if (t.resource->staged_title() && !t.unbound_bytes) { + r = t.resource; + r->AddRef(); + layout = t.layout; + cpu = t.cpu; + fills = t.fills; + every_byte = t.every_byte(); + } else { + filled = fill_title_texture(t, true) != 0; + } + } + } + } + if (r) { + filled = fill_unlocked(address, *r, layout, cpu, fills, every_byte, f); + r->Release(); + } + std::size_t left = 0; + { + std::lock_guard lock(f.mutex); + (filled ? f.filled : f.skipped) += 1; + left = f.queue.size(); + } + if (const auto now = clock::now(); now - since >= std::chrono::seconds(10)) { + std::fprintf(stderr, "[rt] d3d12: title texture fill worker: %llu filled, %llu skipped in %.0f s, %zu " + "queued\n", + static_cast(f.filled), static_cast(f.skipped), + std::chrono::duration(now - since).count(), left); + std::lock_guard lock(f.mutex); + f.filled = f.skipped = 0; + since = now; + } + } + } + + // The fill worker's fill of a staged texture: copy, hash and upload without the registry lock, then the result + // under it, if the registry still names `r` at `address` and nobody filled it meanwhile. + bool fill_unlocked(std::uint64_t address, Resource& r, const rt::xg_xs::Texture& layout, std::uint64_t cpu, + std::uint64_t fills, bool every_byte, TitleFiller& f) { + const std::uint64_t span = layout.layout.size; + f.tiled.resize(std::size_t(span)); + const bool copied = copy_guarded(f.tiled.data(), reinterpret_cast(cpu), std::size_t(span), + title_memory_write_combined(cpu)); + std::uint64_t hash = 0, full = 0; + bool full_hashed = false, ok = false, nonzero = false; + std::uint64_t staged_ns = 0; + if (copied) { + hash_guarded(f.tiled.data(), f.tiled.size(), hash); + full_hashed = every_byte && hash_guarded(f.tiled.data(), f.tiled.size(), full, true); + const auto start = std::chrono::steady_clock::now(); + ok = r.upload_staged_title(layout, f.tiled.data(), f.columns, false, nonzero); + staged_ns = std::chrono::duration_cast(std::chrono::steady_clock::now() - start) + .count(); + } + std::lock_guard lock(state_.title_texture_mutex); + const InTitleTextures inside; + const auto it = state_.title_textures.find(address); + if (it == state_.title_textures.end() || it->second->resource != &r) return false; // retired meanwhile + TitleTexture& t = *it->second; + if (!copied) { + t.memory.defer(); + t.stale = true; + return false; + } + title_stats_.staged_ns += staged_ns; + if (!ok) { + log_once("staged title texture upload failed, format", int(r.format())); + ++title_stats_.fill_failures; + t.stale = true; + return false; + } + ++title_stats_.staged_fills; + if (t.fills != fills) return true; // another fill recorded itself in between: its hash is as good + if (t.owned && !t.fills) r.publish_streamed_texture(); + t.hash = hash; + t.hashed = true; + t.full_hash = full; + t.full_hashed = full_hashed; + ++t.fills; + ++title_stats_.fills; + title_stats_.fill_bytes += span; + return true; + } + + // LEONIDA_GEOMETRY_ASYNC: one worker runs GeometryViews::refresh whenever a submission asks and none is running. + struct GeometryRefresher { + std::mutex mutex; + std::condition_variable wake; + bool kick = false, stop = false; + std::thread thread; + ~GeometryRefresher() { + { + std::lock_guard lock(mutex); + stop = true; + } + wake.notify_one(); + if (thread.joinable()) thread.join(); + } + }; + std::unique_ptr geometry_refresher_; + std::once_flag geometry_refresher_once_; // submissions of several queues may ask at once + void kick_geometry_refresh() { + std::call_once(geometry_refresher_once_, [this] { + geometry_refresher_ = std::make_unique(); + GeometryRefresher* r = geometry_refresher_.get(); + r->thread = std::thread([this, r] { + for (;;) { + { + std::unique_lock lock(r->mutex); + r->wake.wait(lock, [r] { return r->kick || r->stop; }); + if (r->stop) return; + r->kick = false; + } + state_.geometry.refresh(DeviceState::copy_geometry); + } + }); + }); + { + std::lock_guard lock(geometry_refresher_->mutex); + geometry_refresher_->kick = true; + } + geometry_refresher_->wake.notify_one(); + } std::uint64_t title_refresh_cursor_ = 0; // under title_texture_mutex + std::uint64_t title_map_generation_ = 0; // likewise: the map changes the passes have seen + std::chrono::steady_clock::time_point title_retry_all_{}; // likewise + leonida::TitleWriteRanges title_map_changes_; // likewise, scratch VkDeviceSize retired_backing_ = 0; std::vector> retired_title_textures_; // likewise std::vector title_tiled_, title_linear_; // scratch, under title_texture_mutex @@ -10930,8 +12308,8 @@ class Device final const std::uint64_t span = entry->layout.layout.size; entry->cpu = leonida::title_gpu_views::to_cpu(address); // A streamed texture can have views before its pages arrive. Keep the descriptor stable across its first fill. - entry->memory.check(leonida::title_memory_map::generation(), check_pages_before_read(), - [&] { return leonida::texture_memory_readable(entry->cpu, span); }); + entry->memory.check(0, check_pages_before_read(), + [&] { return probe_title_memory(entry->cpu, span, false); }); title_stats_.unreadable += entry->memory.pending(); // The image takes the view's format too when the element is the same size (five-star-recomp does the same); // views in other formats of the same description add theirs (place_title_view). @@ -10989,10 +12367,15 @@ class Device final entry->set_resource(r); entry->owned = true; entry->formats = std::move(formats); - if (!entry->memory.pending()) fill_title_texture(*entry, true); + if (title_fill_async()) { + entry->stale = true; // filled by the fill worker (queued below, once it is in the registry) + } else if (!entry->memory.pending()) { + fill_title_texture(*entry, true); + } ++title_stats_.made; TitleTexture* t = entry.get(); state_.title_textures[address] = std::move(entry); + if (title_fill_async() && !t->memory.pending()) queue_title_fill(address); return t; } @@ -11031,17 +12414,55 @@ class Device final return enabled; } + // texture_memory_readable, timed and counted (TitleTextureStats::probes). + bool probe_title_memory(std::uint64_t cpu, std::uint64_t span, bool waited, + leonida::TexturePageCommitter commit = nullptr) { + const auto start = std::chrono::steady_clock::now(); + const bool readable = leonida::texture_memory_readable(cpu, span, commit); + const std::size_t where = title_pass_ ? 0 : 1; + TitleTextureStats& s = title_stats_; + s.probe_ns[where] += std::chrono::duration_cast( + std::chrono::steady_clock::now() - start).count(); + ++s.probes[where]; + s.rechecks[where] += waited; + s.readable_now[where] += waited && readable; + return readable; + } + // A mapped texture can lose its pages between views or between refreshes. - static bool title_texture_readable(TitleTexture& t) { + bool title_texture_readable(TitleTexture& t) { const bool guard = check_pages_before_read(); if (!guard && !t.memory.pending()) return true; const bool mapped = t.mapped && refresh_mapped_pages(); const auto commit = mapped ? leonida::kernel_writes::state().committer.load(std::memory_order_acquire) : nullptr; - return t.memory.check(leonida::title_memory_map::generation(), guard && !mapped, - [&] { return leonida::texture_memory_readable(t.cpu, t.layout.layout.size, commit); }); - } - + const bool waited = t.memory.pending(); + // The answer is kept (generation 0) until a map change over the texture, a write into it or the periodic + // retry of refresh_title_textures asks again. + return t.memory.check(0, guard && !mapped, + [&] { return probe_title_memory(t.cpu, t.layout.layout.size, waited, commit); }, + guard && !mapped); + } + + // LEONIDA_TITLE_VIEW_REFRESH_MS (0 by default: at every view): a texture's bytes are checked when a slot-70 view of + // it is written at most this often (the refresh pass still looks at it on its own period, and a stale texture is + // checked at once). After the load a title thread spent a fifth of its time hashing textures here, view by view + // (speed-24 wait sampler: refresh_title_texture < write_placed_texture_view < slot 70). void refresh_title_texture(TitleTexture& t) { + // LEONIDA_TITLE_FILL_ASYNC=1: a view neither hashes nor fills. A texture never filled or known stale goes to + // the fill worker; later changes are found by the periodic pass and the write journal, as before. + if (title_fill_async()) { + if (!t.hashed || t.stale) queue_title_fill(t.address); + return; + } + static const auto period = std::chrono::milliseconds([] { + const char* v = std::getenv("LEONIDA_TITLE_VIEW_REFRESH_MS"); + return v && *v ? std::strtoll(v, nullptr, 10) : 0ll; + }()); + if (period.count() && t.hashed && !t.stale) { + const auto now = std::chrono::steady_clock::now(); + if (now - t.view_checked < period) return; + t.view_checked = now; + } std::uint64_t hash = 0; if (!title_texture_readable(t)) return; if (!hash_guarded(reinterpret_cast(static_cast(t.cpu)), @@ -11261,9 +12682,41 @@ class Device final const double ms_per_ns_per_pass = 1e-6 / double(s.passes); std::fprintf(stderr, "[rt] title texture hash time %.3f ms/pass; refresh total %.3f ms/pass\n", double(s.hash_ns) * ms_per_ns_per_pass, double(s.refresh_ns) * ms_per_ns_per_pass); + // What the passes cost and why: the probes of memory (texture_memory_readable) and the textures that + // wait for readable memory, now. + std::size_t waiting = 0, waiting_stale = 0, waiting_mapped = 0, stale = 0; + for (const auto& [address, t] : state_.title_textures) { + if (t->gpu_written || !t->layout_known || !t->resource) continue; + stale += t->stale; + if (!t->memory.pending()) continue; + ++waiting; + waiting_stale += t->stale; + waiting_mapped += t->mapped; + } + const double per_pass = 1.0 / double(s.passes); + std::fprintf(stderr, + "[rt] title texture rechecks: %.1f probes a pass (%.3f ms/pass), %.1f of waiting textures a " + "pass (%llu found readable now); %zu textures wait for readable memory (%zu stale, %zu " + "mapped), %zu stale in all; max pass %.3f ms; outside passes %llu probes (%.3f ms), %llu of " + "waiting textures, %llu found readable\n", + double(s.probes[0]) * per_pass, double(s.probe_ns[0]) * ms_per_ns_per_pass, + double(s.rechecks[0]) * per_pass, static_cast(s.readable_now[0]), waiting, + waiting_stale, waiting_mapped, stale, double(s.max_refresh_ns) * 1e-6, + static_cast(s.probes[1]), double(s.probe_ns[1]) * 1e-6, + static_cast(s.rechecks[1]), + static_cast(s.readable_now[1])); s.passes = s.checked = s.hashed = s.changed = s.deferred = s.filled_bytes = s.max_pass_bytes = 0; - s.hash_ns = s.refresh_ns = 0; + std::fprintf(stderr, + "[rt] title texture pass split: written ranges and map changes %.3f ms/pass (%.1f map ranges a " + "pass, %llu passes probed all), mapped and stale textures %.3f ms/pass (%.1f visited a pass), " + "fills %.3f ms/pass\n", + double(s.written_ns) * ms_per_ns_per_pass, double(s.map_ranges) * per_pass, + static_cast(s.map_all), double(s.every_pass_ns) * ms_per_ns_per_pass, + double(s.every_pass_visits) * per_pass, double(s.fill_ns) * ms_per_ns_per_pass); + s.written_ns = s.every_pass_ns = s.every_pass_visits = s.fill_ns = s.map_ranges = s.map_all = 0; + s.hash_ns = s.refresh_ns = s.max_refresh_ns = 0; s.written_ranges = 0; + s.probes = s.probe_ns = s.rechecks = s.readable_now = {}; } } @@ -11707,7 +13160,8 @@ class Device final // arguments, and a stride that is a multiple of 4 and holds every argument. if (!desc || desc->NumArgumentDescs == 0 || !desc->pArgumentDescs || (desc->NodeMask & ~1u)) return E_INVALIDARG; - UINT64 size = 0; // 64-bit: a large Num32BitValuesToSet must not wrap past ByteStride + UINT64 size = 0; // packed bytes; a large Num32BitValuesToSet must not wrap past ByteStride + UINT64 creation_padding = 0; for (UINT i = 0; i < desc->NumArgumentDescs; ++i) { const D3D12_INDIRECT_ARGUMENT_DESC& arg = desc->pArgumentDescs[i]; switch (arg.Type) { @@ -11719,12 +13173,15 @@ class Device final case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW: size += sizeof(D3D12_VERTEX_BUFFER_VIEW); break; case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW: size += sizeof(D3D12_INDEX_BUFFER_VIEW); break; case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: size += UINT64{4} * arg.Constant.Num32BitValuesToSet; break; - case compat::kIndirectArgumentIncrementingConstant: size += 4; break; + // Tier 1.1 generates the incrementing value: it occupies no argument-buffer bytes. + // Preserve the existing creation-time stride check on this tier-1.0 device; this is not tier-1.1 support. + case compat::kIndirectArgumentIncrementingConstant: creation_padding += 4; break; case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW: case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW: case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW: size += sizeof(D3D12_GPU_VIRTUAL_ADDRESS); break; default: return E_INVALIDARG; } + if (size + creation_padding > desc->ByteStride) return E_INVALIDARG; const bool draw = arg.Type <= D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH || arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS || arg.Type == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH; @@ -11732,7 +13189,7 @@ class Device final arg.Type != D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW; if (draw != (i + 1 == desc->NumArgumentDescs) || (root_argument && !root_signature)) return E_INVALIDARG; } - if (desc->ByteStride % 4 || desc->ByteStride < size) return E_INVALIDARG; + if (desc->ByteStride % 4) return E_INVALIDARG; if (!out) return E_UNEXPECTED; // the host's answer for a valid description and no output leonida::IndirectKind kind; switch (desc->pArgumentDescs[desc->NumArgumentDescs - 1].Type) { @@ -11746,7 +13203,8 @@ class Device final break; default: return E_NOTIMPL; } - return create_command_signature(kind, desc->ByteStride, riid, out, identity()); + return create_command_signature(kind, desc->ByteStride, static_cast(size), riid, out, identity(), + {desc->pArgumentDescs, desc->NumArgumentDescs - 1}); } void STDMETHODCALLTYPE GetRaytracingAccelerationStructurePrebuildInfo( @@ -12412,7 +13870,18 @@ class Device final buffer.num_records = indexed ? desc->SizeInBytes / 16u : desc->SizeInBytes; buffer.format = leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT); buffer.oob_select = indexed ? leonida::gfx10::OobSelect::structured_with_offset : leonida::gfx10::OobSelect::raw; - buffer.address = vsharp_address(buffer.address, desc->SizeInBytes); + static const bool console_form = [] { + wchar_t value[2]{}; + return !(GetEnvironmentVariableW(L"LEONIDA_CBV_RAW", value, 2) == 1 && value[0] == L'1'); + }(); + const uint64_t rows = (uint64_t(desc->SizeInBytes) + 15) / 16; + buffer.address = state_.vsharp_address(buffer.address, console_form ? rows * 16 : desc->SizeInBytes); + // No backing for the title's memory: a zero-size V# (loads 0, stores dropped), never the raw address. + const bool backed = buffer.address != 0; + if (!backed) { + buffer.stride = 0, buffer.num_records = 0; + leonida::note_unbacked_view("constant-buffer view", desc->BufferLocation, desc->SizeInBytes); + } leonida::gfx10::BufferWords words = leonida::gfx10::encode(buffer); // The console's constant-buffer V# is a table of 16-byte rows: the title's own inline form of this descriptor // (it writes one itself instead of calling here, depending on a device flag) is {base, stride 16, records @@ -12420,13 +13889,9 @@ class Device final // the stride: the batched Scaleform vertex shader reads its X and Y transform rows as base + index * stride. // With the raw form (stride 0) both rows are the same 16 bytes and every batched triangle collapses onto the // line x = y. LEONIDA_CBV_RAW=1 restores the raw form. - static const bool console_form = [] { - wchar_t value[2]{}; - return !(GetEnvironmentVariableW(L"LEONIDA_CBV_RAW", value, 2) == 1 && value[0] == L'1'); - }(); - if (console_form) { + if (console_form && backed) { words[1] = (words[1] & 0xFFFFu) | (16u << 16); - words[2] = (desc->SizeInBytes + 15) / 16; + words[2] = UINT(rows); words[3] = 0x0002403Cu; } std::memcpy(reinterpret_cast(destination.ptr), words.data(), sizeof(words)); @@ -12514,7 +13979,13 @@ class Device final // rewrites it at the original slot, just as it does for a descriptor written by the title. if (!state_.has_console_descriptor_copy(destination.ptr)) buffer.address = copy; } else { - buffer.address = vsharp_address(buffer.address, bytes); + const std::uint64_t target = buffer.address; + buffer.address = state_.vsharp_address(buffer.address, bytes); + // No backing: no records, so loads return 0 and stores are dropped (never a raw title base). + if (!buffer.address) { + buffer.stride = 0, buffer.num_records = 0; + leonida::note_unbacked_view("buffer SRV", target, bytes); + } } const leonida::gfx10::BufferWords words = leonida::gfx10::encode(buffer); std::memcpy(reinterpret_cast(destination.ptr), words.data(), sizeof(words)); @@ -12733,14 +14204,21 @@ class Device final buffer.swizzle = channels; buffer.oob_select = typed ? g::OobSelect::structured : structured ? g::OobSelect::structured_with_offset : g::OobSelect::raw; - buffer.address = vsharp_address(buffer.address, + const std::uint64_t target = buffer.address; + buffer.address = state_.vsharp_address(buffer.address, std::uint64_t(buffer.num_records) * (buffer.stride ? buffer.stride : 1)); + // No backing: no records, so loads return 0 and stores are dropped (never a raw title base). + if (!buffer.address) { + buffer.stride = 0, buffer.num_records = 0; + leonida::note_unbacked_view("buffer UAV", target, std::uint64_t(view.NumElements) * (unit ? unit : 1)); + } const g::BufferWords words = g::encode(buffer); std::memcpy(reinterpret_cast(destination.ptr), words.data(), sizeof(words)); if (counter_va) { g::Buffer counter_buffer{}; - counter_buffer.address = vsharp_address(counter_va, 4); - counter_buffer.num_records = 4; + counter_buffer.address = state_.vsharp_address(counter_va, 4); + counter_buffer.num_records = counter_buffer.address ? 4 : 0; + if (!counter_buffer.address) leonida::note_unbacked_view("UAV counter", counter_va, 4); counter_buffer.oob_select = g::OobSelect::raw; const g::BufferWords counter_words = g::encode(counter_buffer); std::memcpy(reinterpret_cast(destination.ptr) + sizeof(words), counter_words.data(), @@ -13269,6 +14747,11 @@ class Device final wchar_t flag[2]{}; return !(GetEnvironmentVariableW(L"LEONIDA_TITLE_BUFFER_COVERAGE", flag, 2) == 1 && flag[0] == L'0'); }(); + // A stream pool's GPU-only alias: the buffer is made over the CPU view of the same pages (rule B), where the + // host reads the frames, so it is host-importable and shared with every other view naming that range instead + // of leaving a second, queue-mapped copy of it behind. + va = leonida::title_gpu_views::to_host_view(static_cast(va), + static_cast(std::max(bytes, 1))); const auto covered = [&] { return state_.context->knows_buffer_va(va, check_size ? bytes : 1); }; @@ -15203,6 +16686,23 @@ class Device final return desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER && (region.Width || region.Height || region.Depth); } + // Holds the pipeline compiler's worker for the device's life (PipelineCompiler::retain). Released early by + // ~Device, after its cancel; a constructor that throws releases it through this member's destructor. + class CompilerUse { + public: + CompilerUse() { PipelineCompiler::instance().retain(); } + ~CompilerUse() { release(); } + CompilerUse(const CompilerUse&) = delete; + CompilerUse& operator=(const CompilerUse&) = delete; + void release() { + if (!held_) return; + held_ = false; + PipelineCompiler::instance().release(); + } + private: + bool held_ = true; + }; + CompilerUse compiler_use_; std::mutex queue_mutex_; // Live D3D12 queues per VkQueue of info.command_queues, compute_queues and copy_queues (pick_queue_slot). std::vector queue_users_; @@ -15227,6 +16727,14 @@ class Device final } // namespace +bool stop_pipeline_compiles(unsigned wait_ms) { + const bool idle = PipelineCompiler::instance().stop_for_exit(std::chrono::milliseconds(wait_ms)); + if (!idle) + std::fprintf(stderr, "[rt] d3d12: a background pipeline build was still running after %u ms at exit\n", + wait_ms); + return idle; +} + HRESULT create_vulkan_device(const VulkanDeviceInfo& info, REFIID riid, void** out) { if (!out) return E_POINTER; *out = nullptr; @@ -15368,6 +16876,8 @@ const std::vector* pipeline_subgroup_requests(ID3D12Pi return p && (p->compute() || p->graphics()) ? &p->subgroup_requests() : nullptr; } +long live_pipeline_states() { return live_pipeline_state_count.load(); } + bool write_placed_buffer_view(ID3D12Device* device, bool unordered, const void* view, std::uint64_t address, std::uint64_t width, D3D12_CPU_DESCRIPTOR_HANDLE destination) { Device* d = Device::from(device); @@ -15388,6 +16898,50 @@ D3D12_GPU_VIRTUAL_ADDRESS console_descriptor_table_va(D3D12_GPU_VIRTUAL_ADDRESS return console_heap_ranges().shader_va(va); } +// The device a command list of this module belongs to: its attached device is the d3d12_xs proxy when the title made +// the list through one (Device::identity), which does not answer Device's tag itself. +Device* list_device(IUnknown* device) { + if (!device) return nullptr; + if (Device* d = Device::from(device)) return d; + if (ID3D12Device* real = rt::d3d12_xs::device_proxy_real_device(device)) return Device::from(real); + static std::atomic logged{false}; + if (!logged.exchange(true)) + std::fprintf(stderr, "[rt] d3d12: an acceleration-structure command on a list whose device is not this " + "layer's: its addresses are left as the title gave them\n"); + return nullptr; +} + +// LEONIDA_RT_AS=off (diagnostic): acceleration-structure builds and copies are not recorded at all, so no BVH is +// written; traversal finds whatever the structures' memory holds. For telling a device loss in the builds apart from +// one elsewhere. +bool acceleration_structures_off() { + static const bool off = [] { + char value[8] = {}; + std::size_t length = 0; + const bool set = getenv_s(&length, value, "LEONIDA_RT_AS") == 0 && length > 1 && !std::strcmp(value, "off"); + if (set) std::fprintf(stderr, "[rt] d3d12: LEONIDA_RT_AS=off: acceleration-structure builds and copies are dropped\n"); + return set; + }(); + return off; +} + +bool resolve_acceleration_structure_build(IUnknown* device, leonida::BuildAccelerationStructure& build) { + if (acceleration_structures_off()) return false; + Device* d = list_device(device); + return !d || d->resolve_xdxr_build(build); +} + +bool resolve_acceleration_structure_copy(IUnknown* device, leonida::CopyAccelerationStructure& copy) { + if (acceleration_structures_off()) return false; + Device* d = list_device(device); + return !d || d->resolve_xdxr_copy(copy); +} + +bool resolve_acceleration_structure_postbuild(IUnknown* device, leonida::AccelerationStructurePostbuild& info) { + Device* d = list_device(device); + return !d || d->resolve_xdxr_postbuild(info); +} + IUnknown* descriptor_heap_info(ID3D12DescriptorHeap* heap, D3D12_DESCRIPTOR_HEAP_DESC& desc, D3D12_GPU_VIRTUAL_ADDRESS& gpu_base) { if (!heap) return nullptr; @@ -15605,6 +17159,16 @@ ImageMemoryStats image_memory_stats(ID3D12Device* device) { return {stats.blocks, stats.block_bytes, stats.ranges}; } +bool read_arena(ID3D12Device* device, std::uint64_t va, void* out, std::size_t bytes) { + if (!device || !out) return false; + ID3D12Device* real = rt::d3d12_xs::device_proxy_real_device(device); + if (!real) real = device; + const Device* d = Device::from(real); + if (!d || !d->state().arena.mapped || va > d->state().arena.size || bytes > d->state().arena.size - va) return false; + std::memcpy(out, d->state().arena.mapped + va, bytes); + return true; +} + namespace { const leonida::BindlessSet* bindless_of(ID3D12Device* device) { if (!device) return nullptr; @@ -15855,6 +17419,8 @@ HRESULT create_dxgi_factory(ID3D12Device* device, REFIID riid, void** out) { HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettings queue_test_settings) { if (!out) return E_POINTER; *out = nullptr; + // LEONIDA_AFTERMATH=1: GPU crash dumps on before the Vulkan instance and device exist (src/vulkan_aftermath.h). + leonida::aftermath::enable(); static const HMODULE library = LoadLibraryA("vulkan-1.dll"); const auto get = library ? reinterpret_cast( reinterpret_cast(GetProcAddress(library, "vkGetInstanceProcAddr"))) @@ -16159,6 +17725,8 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin if (!chosen_draw_params) std::fprintf(stderr, "[rt] d3d12: the GPU has no shaderDrawParameters\n"); VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; enable12.timelineSemaphore = VK_TRUE; + enable12.drawIndirectCount = chosen12.drawIndirectCount; + info.draw_indirect_count_enabled = enable12.drawIndirectCount == VK_TRUE; enable12.separateDepthStencilLayouts = VK_TRUE; info.buffer_device_address = chosen12.bufferDeviceAddress == VK_TRUE; enable12.bufferDeviceAddress = info.buffer_device_address ? VK_TRUE : VK_FALSE; @@ -16250,6 +17818,11 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin enable.samplerAnisotropy = info.sampler_anisotropy; enable.occlusionQueryPrecise = chosen_features.occlusionQueryPrecise; // exact D3D12 occlusion counts enable.pipelineStatisticsQuery = chosen_features.pipelineStatisticsQuery; + enable.drawIndirectFirstInstance = chosen_features.drawIndirectFirstInstance; + enable.multiDrawIndirect = chosen_features.multiDrawIndirect; + info.draw_indirect_first_instance = enable.drawIndirectFirstInstance == VK_TRUE; + info.multi_draw_indirect = enable.multiDrawIndirect == VK_TRUE; + info.max_draw_indirect_count = chosen.limits.maxDrawIndirectCount; info.occlusion_query_precise = chosen_features.occlusionQueryPrecise == VK_TRUE; info.pipeline_statistics_query = chosen_features.pipelineStatisticsQuery == VK_TRUE; if (!chosen_bc) std::fprintf(stderr, "[rt] d3d12: the GPU has no BC texture support\n"); @@ -16381,23 +17954,20 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin #endif #ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME - // VK_KHR_maintenance5 brings VK_FORMAT_A8_UNORM_KHR (VulkanDeviceInfo::a8_render_target). It is enabled only where + // VK_KHR_maintenance5 also supplies vkCmdBindIndexBuffer2KHR. A8 support is checked separately: only where // that format can be sampled, copied (every texture is a transfer source and destination) and is a colour - // attachment the GPU can blend; nothing else here relies on it. + // attachment the GPU can blend do we also use that format for A8 render targets. VkPhysicalDeviceMaintenance5FeaturesKHR maintenance5{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR}; - if (has_device_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME) && vkGetPhysicalDeviceFormatProperties) { + if (has_device_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME)) { VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &maintenance5}; vkGetPhysicalDeviceFeatures2(info.physical, &query); VkFormatProperties a8{}; - vkGetPhysicalDeviceFormatProperties(info.physical, VK_FORMAT_A8_UNORM_KHR, &a8); + if (vkGetPhysicalDeviceFormatProperties) + vkGetPhysicalDeviceFormatProperties(info.physical, VK_FORMAT_A8_UNORM_KHR, &a8); const VkFormatFeatureFlags needed = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; info.a8_render_target = maintenance5.maintenance5 == VK_TRUE && (a8.optimalTilingFeatures & needed) == needed; - if (info.a8_render_target) { - maintenance5.pNext = *v13.next(); - *v13.next() = &maintenance5; - } } #endif @@ -16474,7 +18044,6 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin // whose shader needs a missing one is refused (PipelineState::create_graphics). enable.fragmentStoresAndAtomics = chosen_features.fragmentStoresAndAtomics; enable.vertexPipelineStoresAndAtomics = chosen_features.vertexPipelineStoresAndAtomics; - info.features = enable; // GetClockCalibration reads both clocks at once with calibrated timestamps (KHR, or the older EXT). const char* calibrated = nullptr; @@ -16537,6 +18106,40 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin "[rt] d3d12: no VK_EXT_custom_border_color; custom sampler border colours fall back to transparent black\n"); } + // Optional: VK_EXT_robustness2's nullDescriptor makes set 0's storage fallbacks null descriptors, so a store or + // atomic through a null UAV (a zero T#, or one the layer refused) is dropped and a load reads zero, as on the + // console (vulkan_bindless.h). Robust buffer access is selected independently for bounded indexed indirect draws. + VkPhysicalDeviceRobustness2FeaturesEXT robustness2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; + if (std::any_of(extensions.begin(), extensions.end(), [](const auto& e) { + return std::strcmp(e.extensionName, VK_EXT_ROBUSTNESS_2_EXTENSION_NAME) == 0; + })) { + VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &robustness2}; + vkGetPhysicalDeviceFeatures2(info.physical, &query); + info.null_descriptor = robustness2.nullDescriptor == VK_TRUE; +#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME + info.robust_index_view = leonida::can_enable_robust_index_view( + info.physical, vkGetPhysicalDeviceProperties2, info.draw_indirect_first_instance && maintenance5.maintenance5, + chosen_features.robustBufferAccess && robustness2.robustBufferAccess2, info.bindless); +#endif + if (info.null_descriptor || info.robust_index_view) { + robustness2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; + robustness2.nullDescriptor = info.null_descriptor; + robustness2.robustBufferAccess2 = info.robust_index_view; + enable.robustBufferAccess = info.robust_index_view; + robustness2.pNext = *v13.next(); + *v13.next() = &robustness2; + } + } +#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME + if (info.a8_render_target || info.robust_index_view) { + maintenance5.pNext = *v13.next(); + *v13.next() = &maintenance5; + } +#endif + if (!info.null_descriptor) + std::fprintf(stderr, "[rt] d3d12: no VK_EXT_robustness2 nullDescriptor; stores through null UAVs land in " + "storage fallback images instead of being dropped\n"); + // Optional: VK_EXT_external_memory_host lets OpenExistingHeapFromAddress import the caller's committed memory as // the heap's backing, so the GPU reads what the CPU writes there without a copy. if (std::any_of(extensions.begin(), extensions.end(), [](const auto& e) { @@ -16553,6 +18156,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin device_info.queueCreateInfoCount = std::uint32_t(queue_infos.size()); device_info.pQueueCreateInfos = queue_infos.data(); device_info.pEnabledFeatures = &enable; + info.features = enable; std::vector device_extensions; v13.add_extensions(device_extensions); if (info.depth_range_unrestricted) device_extensions.push_back(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME); @@ -16574,7 +18178,7 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin // Under its own guard only: headers or a driver without VK_KHR_maintenance8 still have the A8 path, and // a8_render_target is never set without this extension being enabled. #ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME - if (info.a8_render_target) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); + if (info.a8_render_target || info.robust_index_view) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); #endif #ifdef VK_KHR_MAINTENANCE_10_EXTENSION_NAME if (info.maintenance10) device_extensions.push_back(VK_KHR_MAINTENANCE_10_EXTENSION_NAME); @@ -16597,18 +18201,30 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin info.presentation = has_swapchain && instance_has_surface; info.swapchain_colorspace = info.presentation && swapchain_colorspace_enabled; if (info.custom_border_color) device_extensions.push_back(custom_border_name); + if (info.null_descriptor || info.robust_index_view) device_extensions.push_back(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME); if (info.host_pointer_alignment) device_extensions.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME); leonida::DeviceFaultFeatures fault_features; + const bool aftermath = leonida::aftermath::enable(); // already on, before the instance: see above char device_fault[2]{}; if (GetEnvironmentVariableA("LEONIDA_DEVICE_FAULT", device_fault, sizeof(device_fault)) == 1 && device_fault[0] == '1') { info.device_fault_diagnostics = true; const auto fault = fault_features.enable(info.physical, vkGetPhysicalDeviceFeatures2, extensions, - device_extensions, device_info); + device_extensions, device_info, + {true, true, leonida::aftermath::extra_config_flags()}); info.device_fault_info = fault.fault; info.device_checkpoints = fault.checkpoints; info.device_diagnostics_config = fault.diagnostics_config; + } else if (aftermath) { + // The diagnostics config alone: shader debug info, resource tracking and automatic checkpoints in the dump. + const auto fault = fault_features.enable(info.physical, vkGetPhysicalDeviceFeatures2, extensions, + device_extensions, device_info, + {false, true, leonida::aftermath::extra_config_flags()}); + info.device_diagnostics_config = fault.diagnostics_config; } + if (aftermath && !info.device_diagnostics_config) + std::fprintf(stderr, "[rt] aftermath: VK_NV_device_diagnostics_config unavailable; the dump has no shader " + "debug info, resource tracking or checkpoints\n"); device_info.enabledExtensionCount = std::uint32_t(device_extensions.size()); device_info.ppEnabledExtensionNames = device_extensions.empty() ? nullptr : device_extensions.data(); if (vkCreateDevice(info.physical, &device_info, nullptr, &owned.device) != VK_SUCCESS) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index f4611ca449..55113b8c3d 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -25,6 +25,7 @@ // behind the device before a presenter exists, so WaitFrameEventX returns at once with a fresh non-zero token. #include "../src/title_va_alias.h" #include "d3d12_xs_device.h" +#include "xmem.h" #ifdef LEONIDA_VULKAN_DEVICE #include "d3d12_com.h" // rt::d3d12::create_console_descriptor_heap for slot 14 #include "../src/vulkan_gpu_labels.h" @@ -35,6 +36,8 @@ #include "xmem.h" // rt::xmem::copy_page_mappings_fn for queue slot 31 #include "d3d12_xs_alloc_size.h" #include "d3d12_xs_desc_clean.h" +#include "d3d12_xs_list_values.h" +#include "xmem.h" // PageBatch, PageRange (queue slot 31) #include "../src/frame_pacer.h" #include "../src/local_diagnostics.h" #include "d3d12_xs_pso_stream.h" @@ -48,10 +51,10 @@ #include "title_window.h" #include "package_splash.h" #include "startup_trace.h" -#include #endif #include +#include #include #include @@ -66,7 +69,11 @@ #include // _ReturnAddress: slot 61 serves a console caller differently from a host one #include #include +#include #include +#include +#include +#include #include #include #include @@ -91,6 +98,7 @@ std::atomic g_reference_settler{nullptr}; // registers xmem's commit_physical_range, which leaves memory other than mapped physical pages alone). std::atomic g_placed_at_va_pages{nullptr}; std::atomic g_pin_texture_pages{nullptr}; +std::atomic g_copy_page_mappings{nullptr}; // True while this thread forwards a console caller's CheckFeatureSupport (device slot 13). thread_local bool g_console_feature_query = false; static_assert(kMaxSlots > 83, "the proxy table must cover ID3D12Device14 (83 slots)"); @@ -141,6 +149,11 @@ struct DeviceProxy { std::atomic frame_latency{1}; std::atomic frame_event_scheduled{false}; std::atomic frame_event_offset_us{0}; + // The timestamp query heap and readback of list write64 flags 1 and 2 (d3d12_xs_list_values.h Timestamps), made + // at the first such write; null when the real device cannot make them. + std::mutex timestamps_mutex; + std::shared_ptr timestamps; + bool timestamps_tried = false; std::shared_ptr frame_tokens = std::make_shared(); // Optional presentation wiring attached via set_presentation_handler (guarded by presentation_lock). SRWLOCK presentation_lock = SRWLOCK_INIT; @@ -1053,6 +1066,18 @@ static_assert(kFenceCompletedValueSlot >= kFence1PublicSlots && kFenceCompletedV struct FenceMirror; +// Queue slots that take queue_order: the ones that may put work on the queue or change page mappings. Not the debug +// markers (SetMarker, BeginEvent, EndEvent: 11-13 in both layouts) and not slot 18, a getter in both layouts (the +// older layout's GetDesc, the newer one's GetTimestampFrequency). The title's render thread calls slot 18 every frame +// (t+0x2484180, vtable +0x90, then 1/frequency), and under queue_order it waited for whole submissions on the submit +// thread (15-20 ms each, ~24 a frame): 44 % of its samples in speed-26. Slots 16-17 and 19-20 keep the lock: which of +// them are getters depends on the layout (16-17 are Signal/Wait in the newer one). +constexpr bool queue_slot_orders_work(unsigned slot) { + if (slot < 8 || slot > kQueueExecuteCommandListsX) return false; + if (slot >= 11 && slot <= 13) return false; // SetMarker, BeginEvent, EndEvent + return slot != 18; +} + struct ChildProxy { void** vtable; // offset 0: the caller's ID3D12CommandQueue* / ID3D12Fence* points here IUnknown* real; // offset 8: the PC or Vulkan-layer object every thunk forwards to @@ -1067,11 +1092,19 @@ struct ChildProxy { static constexpr unsigned char kQueueLayoutUnknown = 0; static constexpr unsigned char kQueueLayoutOlder = 1; // PC order; PresentX 30, SignalX 23 static constexpr unsigned char kQueueLayoutNewer = 2; // +2 shift; PresentX 32, SignalX 25 + std::mutex queue_order; // serializes queue work across a host-side page remap + // Queue slot 31's fence, made at its first call and signalled with a rising value at each (under queue_order); + // kept for the queue's life. It was a new fence a call: a Vulkan timeline semaphore made and destroyed per batch. + Microsoft::WRL::ComPtr map_fence; + std::uint64_t map_fence_value = 0; std::atomic queue_layout{kQueueLayoutUnknown}; // Allocators only: callback and context recorded by console slot 9 (SetAllocatorCallbackX). std::atomic allocator_callback{0}; std::atomic allocator_callback_context{0}; std::atomic mirror{nullptr}; // fence: slot 12's completed value, made on its first call + // Queues only: the gate and write fences of list memory waits and writes (d3d12_xs_list_values.h), made at the + // first submission that needs them, under queue_order. + std::shared_ptr values; }; template @@ -1205,8 +1238,31 @@ void wait_for_fence_progress(FenceMirror* mirror) { SetThreadpoolWait(mirror->wait, mirror->event, &timeout); } +// Every 10 s: how many fence mirrors are live and how often their thread-pool waits ran (on a completion event or on +// the 10 ms timeout). Each run is a wake of Wine's wait-queue thread and a callback on a pool worker. +std::atomic g_mirrors_live{0}, g_mirror_signals{0}, g_mirror_timeouts{0}; +std::atomic g_mirror_report{0}; + +void note_mirror_run(TP_WAIT_RESULT result) { + (result == WAIT_OBJECT_0 ? g_mirror_signals : g_mirror_timeouts).fetch_add(1, std::memory_order_relaxed); + const ULONGLONG now = GetTickCount64(); + ULONGLONG last = g_mirror_report.load(std::memory_order_relaxed); + if (!last) { + g_mirror_report.compare_exchange_strong(last, now, std::memory_order_relaxed); + return; + } + if (now - last < 10000 || !g_mirror_report.compare_exchange_strong(last, now, std::memory_order_relaxed)) return; + std::fprintf(stderr, "[rt] d3d12_xs: fence slot 12 mirrors: %llu live; in %.0f s %llu waits ended on an event, " + "%llu on the 10 ms timeout\n", + static_cast(g_mirrors_live.load(std::memory_order_relaxed)), + double(now - last) / 1000.0, + static_cast(g_mirror_signals.exchange(0, std::memory_order_relaxed)), + static_cast(g_mirror_timeouts.exchange(0, std::memory_order_relaxed))); +} + VOID CALLBACK on_fence_progress(PTP_CALLBACK_INSTANCE, PVOID context, PTP_WAIT, TP_WAIT_RESULT result) { auto* mirror = static_cast(context); + note_mirror_run(result); const std::uint64_t value = refresh_mirror(mirror); if (value == ~std::uint64_t{0}) return; if (result == WAIT_OBJECT_0) { @@ -1233,6 +1289,7 @@ FenceMirror* fence_mirror(ChildProxy* self) { m->event = CreateEventW(nullptr, FALSE, FALSE, nullptr); if (m->event) m->wait = CreateThreadpoolWait(on_fence_progress, m, nullptr); if (m->wait) { + g_mirrors_live.fetch_add(1, std::memory_order_relaxed); wait_for_fence_progress(m); SetEvent(m->event); // the callback makes the first SetEventOnCompletion } else { @@ -1284,6 +1341,7 @@ void destroy_child(ChildProxy* self) { ReleaseSRWLockExclusive(&mirror->lock); WaitForThreadpoolWaitCallbacks(mirror->wait, TRUE); CloseThreadpoolWait(mirror->wait); + g_mirrors_live.fetch_sub(1, std::memory_order_relaxed); } delete self; const unsigned long left = real ? real->Release() : 0; @@ -1716,15 +1774,20 @@ std::uint64_t queue_present_x(ChildProxy*, std::uint64_t, std::uint64_t, std::ui #endif +// Defined with the list proxy: a submission naming a list with memory writes or waits (or one cut at a wait) goes +// part by part. False when no list of the submission has any, and the plain path of queue_execute_command_lists runs. +bool execute_with_values(ChildProxy* self, UINT count, void* const* lists); + // Queue slots 10 and 35 (the console's ExecuteCommandLists(count, lists) variant). The array is copied with each // list proxy replaced by its real list (a bundle on the list side unwraps the same way at the console's // ExecuteBundle); the real queue never sees a proxy. std::uint64_t queue_execute_command_lists(ChildProxy* self, std::uint64_t count_word, std::uint64_t lists_word) { - // The array holds what the title got from the proxy: list proxies are replaced by the real lists in a copy, as - // for every other array of objects the real device or queue reads. - UnwrappedArray unwrapped_lists; - if (!unwrapped_lists.fill(lists_word, static_cast(count_word))) return hr_to_u64(E_OUTOFMEMORY); - if (unwrapped_lists.data()) lists_word = unwrapped_lists.data(); + if (lists_word && + execute_with_values(self, static_cast(count_word), reinterpret_cast(lists_word))) + return 0; + UnwrappedArray unwrapped; + if (!unwrapped.fill(lists_word, count_word)) return hr_to_u64(E_OUTOFMEMORY); + if (unwrapped.data()) lists_word = unwrapped.data(); // Pass zero-extended UINT in 64-bit RDX so both 32-bit PC implementations and 64-bit mock thunks see clean count. using ExecuteFn = void(WINAPI*)(void*, std::uint64_t, ID3D12CommandList* const*); reinterpret_cast(self->real_vtable[kQueueExecuteCommandLists])( @@ -1845,6 +1908,328 @@ const XboxQueueSlotRoutes& xbox_queue_slot_routes() { }(); return routes; } +// LEONIDA_SLOT31_ASYNC=1 (for runs that only need the title to go on): queue slot 31 signals the queue, hands a +// copy of the batches to one worker thread and returns; the worker waits for that signal and maps, in call order. The +// caller (the title's streaming of its GPU pool) no longer waits for the mapping: after the load it spent 2.4-4.0 s of +// every 10 s in it (speed-23), and the title's render thread waited on it. Copies of the GPU-only window made before +// the worker gets there read the old pages: wrong pixels for a moment (each mapping change is journalled, so they are +// copied again after it). +bool slot31_async() { + static const bool on = [] { + const char* v = std::getenv("LEONIDA_SLOT31_ASYNC"); + return v && std::strcmp(v, "1") == 0; + }(); + return on; +} + +struct AsyncMapping { + CopyPageMappingsHook map; + Microsoft::WRL::ComPtr fence; + std::uint64_t value; + std::vector batches; + std::vector> ranges; + std::uintptr_t pool; + UINT pages, flags; +}; + +struct AsyncMapper { + std::mutex mutex; + std::condition_variable wake; + std::deque jobs; + bool started = false; + std::uint64_t done = 0, failed = 0; + std::chrono::steady_clock::duration wait{}, map{}; + std::chrono::steady_clock::time_point since = std::chrono::steady_clock::now(); + + void run() { + using clock = std::chrono::steady_clock; + for (;;) { + AsyncMapping job; + { + std::unique_lock lock(mutex); + wake.wait(lock, [&] { return !jobs.empty(); }); + job = std::move(jobs.front()); + jobs.pop_front(); + } + const auto t0 = clock::now(); + HRESULT hr = job.fence->SetEventOnCompletion(job.value, nullptr); + const auto t1 = clock::now(); + bool ok = SUCCEEDED(hr) && + job.map(std::uint32_t(job.batches.size()), job.batches.data(), job.pool, job.pages, job.flags); + const auto t2 = clock::now(); + std::lock_guard lock(mutex); + ++done; + failed += !ok; + wait += t1 - t0; + map += t2 - t1; + if (!ok && failed <= 8) + std::fprintf(stderr, "[rt] d3d12_xs: queue slot 31 (async): a batch could not be mapped (hr 0x%08x, " + "error %lu)\n", unsigned(hr), GetLastError()); + if (t2 - since >= std::chrono::seconds(10)) { + const auto ms = [](clock::duration d) { return std::chrono::duration(d).count(); }; + std::fprintf(stderr, "[rt] d3d12_xs: queue slot 31 (async worker): %llu calls mapped in %.0f s " + "(%llu failed): %.1f ms waiting for the queue, %.1f ms mapping; %zu queued\n", + static_cast(done), std::chrono::duration(t2 - since).count(), + static_cast(failed), ms(wait), ms(map), jobs.size()); + done = failed = 0; + wait = map = {}; + since = t2; + } + } + } + + void push(AsyncMapping job) { + std::lock_guard lock(mutex); + jobs.push_back(std::move(job)); + if (!started) { + started = true; + std::thread([this] { run(); }).detach(); + } + wake.notify_one(); + } +}; + +AsyncMapper& async_mapper() { + static AsyncMapper* mapper = new AsyncMapper; // never destroyed: its thread runs to the process's end + return *mapper; +} + +// The caller frees its batch and range arrays on return. Complete earlier work on this queue +// (including held waits), then update the aliases while later submissions are still excluded. +// CopyPageMappingsBatchX's batches, copied: the remap of a deferred call runs after the caller freed its arrays. +struct PageMappingCopy { + std::vector batches; + std::vector> ranges; + std::uintptr_t pool = 0; + UINT pages = 0, flags = 0; + + PageMappingCopy(UINT count, const xmem::PageBatch* in, std::uintptr_t pool_, UINT pages_, UINT flags_) + : batches(in, in + count), ranges(count), pool(pool_), pages(pages_), flags(flags_) { + for (UINT b = 0; b < count; ++b) { + if (!in[b].ranges) continue; // xmem refuses a batch with ranges but no array; it still sees none + ranges[b].assign(in[b].ranges, in[b].ranges + in[b].count); + batches[b].ranges = ranges[b].data(); + } + } +}; + +// How long CopyPageMappingsBatchX waits at the call for the queue's earlier work before the remap is deferred. +constexpr unsigned kPageMappingWaitMs = 16; + +// The production xmem seam is a range callback. Adapt it to the queue's copied batch shape when no test hook has +// been installed; the explicit hook remains useful for proxy-only tests and alternate backends. +bool copy_page_mappings_default(std::uint32_t count, const xmem::PageBatch* batches, std::uintptr_t pool, + std::uint32_t pool_pages, std::uint32_t flags) { + const auto copy = rt::xmem::copy_page_mappings_fn; + if (!copy || !count) return true; + if (!batches || flags) { + SetLastError(ERROR_INVALID_PARAMETER); + return false; + } + constexpr std::uint64_t page_size = 0x10000; + bool all = true; + for (std::uint32_t b = 0; b < count; ++b) { + if (!batches[b].ranges) continue; + std::uint64_t destination = batches[b].destination; + for (std::uint32_t r = 0; r < batches[b].count; ++r) { + const xmem::PageRange& range = batches[b].ranges[r]; + bool ok = false; + switch (range.kind) { + case 0: + ok = std::uint64_t(range.start) + range.count <= pool_pages && + copy(reinterpret_cast(destination), + reinterpret_cast(pool + std::uint64_t(range.start) * page_size), + range.count, false); + break; + case 1: + ok = range.start < pool_pages && + copy(reinterpret_cast(destination), + reinterpret_cast(pool + std::uint64_t(range.start) * page_size), + range.count, true); + break; + case 2: + ok = copy(reinterpret_cast(destination), nullptr, range.count, false); + break; + case 3: + ok = true; + break; + default: + SetLastError(ERROR_INVALID_PARAMETER); + ok = false; + break; + } + if (!ok) all = false; + destination += std::uint64_t(range.count) * page_size; + } + } + return all; +} + +// The caller frees its batch and range arrays on return. The aliases change after the queue's earlier work (which +// reads the old ones) and before its later work (which reads the new ones): the console orders the call on the +// queue's timeline, and its CPU does not wait for it. +// - Normally that earlier work is done within a few milliseconds: the call waits for it and remaps here, while the +// queue's later submissions are still excluded (queue_order). +// - Work held behind a list memory wait (d3d12_xs_list_values.h) can take up to the wait's timeout, and work behind +// it on another queue as long. After kPageMappingWaitMs the remap is deferred and the call returns: the queue's +// write fence marks the point, the list-value releaser remaps once the GPU passes it and only then signals the +// gate fence the queue's later work waits on, so the GPU's order is the same as at the call. Only the CPU sees the +// call return before the remap, as on the console; an error is logged and counted then, not returned. +// With LEONIDA_LIST_VALUES=0 (no gates), without the value fences or the list-value threads, or when the queue's Wait +// for the remap cannot be submitted, the call waits for the earlier work, however long, as it did before. +HRESULT queue_copy_page_mappings(ChildProxy* self, UINT count, const xmem::PageBatch* batches, + std::uintptr_t pool, UINT pages, UINT flags) { + auto map = g_copy_page_mappings.load(std::memory_order_acquire); + if (!map && rt::xmem::copy_page_mappings_fn) map = ©_page_mappings_default; + if (!map || !count) return S_OK; + if (!batches || flags) return E_INVALIDARG; + auto* queue = reinterpret_cast(self->real); + if (list_values::enabled() && !self->values) + self->values = list_values::QueueValues::create(self->device->real, queue); + if (list_values::QueueValues* values = list_values::enabled() ? self->values.get() : nullptr) { + auto& counters = list_values::counters(); + list_values::Pump& pump = list_values::Pump::get(); + const std::uint64_t point = ++values->written_value; + HRESULT hr = queue->Signal(values->written, point); + if (FAILED(hr)) return hr; + // The bound is kept with a high-resolution timer: a plain timed wait rounds to the system tick (15.6 ms), + // which would defer at once or hold queue_order for two ticks. Neither handle is ever closed: a fence may still + // set the event after a wait here gave up (auto-reset, so a late set costs one more look at the fence). + static thread_local const HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr); + static thread_local const HANDLE timer = + CreateWaitableTimerExW(nullptr, nullptr, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); + using Clock = std::chrono::steady_clock; + const auto started = Clock::now(); + const auto deadline = started + std::chrono::milliseconds(kPageMappingWaitMs); + bool reached = values->written->GetCompletedValue() >= point; + if (!reached && event && SUCCEEDED(values->written->SetEventOnCompletion(point, event))) { + for (;;) { + reached = values->written->GetCompletedValue() >= point; + const auto now = Clock::now(); + if (reached || now >= deadline) break; + const auto left = std::chrono::duration_cast(deadline - now).count(); + LARGE_INTEGER due{}; + due.QuadPart = -(std::max)(LONGLONG{1}, static_cast(left / 100)); // relative, 100 ns units + if (timer && SetWaitableTimer(timer, &due, 0, nullptr, nullptr, FALSE)) { + const HANDLE handles[2] = {event, timer}; + WaitForMultipleObjects(2, handles, FALSE, INFINITE); + } else { + WaitForSingleObject(event, static_cast((left + 999999) / 1000000)); + } + } + } + list_values::raise_to(counters.remap_wait_us_max, + static_cast(std::chrono::duration_cast( + Clock::now() - started) + .count())); + // After stop_list_values (the process is ending) the queue's gates are not signalled any more and its earlier + // work may never run: the remap is done now rather than holding queue_order until ExitProcess. + if (!reached && !pump.stopped()) { + std::shared_ptr copy; + try { + copy = std::make_shared(count, batches, pool, pages, flags); + } catch (const std::bad_alloc&) { + } + const std::uint64_t gate = values->gate_value + 1; + // The queue's Wait first: unless its later work is held behind the remap, the remap is not deferred (a + // later call could remap at once, and this one, run last, would win). + if (copy && pump.start() && SUCCEEDED(queue->Wait(values->gate, gate))) { + values->gate_value = gate; + values->written->SetEventOnCompletion(point, pump.wake()); + if (pump.add_action(self->values, gate, point, [copy, map] { + if (map(static_cast(copy->batches.size()), copy->batches.data(), copy->pool, + copy->pages, copy->flags)) + return; + const DWORD error = GetLastError(); + list_values::bump(list_values::counters().remaps_failed); + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] CopyPageMappingsBatchX (deferred) failed: error %lu " + "batches=%zu pool=%p pages=%u\n", + error, copy->batches.size(), reinterpret_cast(copy->pool), + copy->pages); + })) { + const std::uint64_t deferred = + counters.remaps_deferred.fetch_add(1, std::memory_order_relaxed) + 1; + if (deferred == 1 || (deferred & (deferred - 1)) == 0) + std::fprintf(stderr, "[rt] d3d12_xs: CopyPageMappingsBatchX waits behind held queue work: " + "the remap runs when the queue gets there (%llu deferred so far)\n", + static_cast(deferred)); + return S_OK; + } + // stop_list_values came in between: nothing opens the gate any more; the remap is done now. + } else { + hr = values->written->SetEventOnCompletion(point, nullptr); // not deferred: wait, as before + if (FAILED(hr)) return hr; + } + } + if (values->written->GetCompletedValue() == UINT64_MAX) return DXGI_ERROR_DEVICE_REMOVED; + list_values::bump(counters.remaps_now); + if (!map(count, batches, pool, pages, flags)) { + const DWORD error = GetLastError(); + return error ? HRESULT_FROM_WIN32(error) : E_FAIL; + } + return S_OK; + } + HRESULT hr = S_OK; + if (!self->map_fence) { + hr = self->device->real->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(self->map_fence.GetAddressOf())); + if (FAILED(hr)) return hr; + if (!self->map_fence) return E_FAIL; + } + ID3D12Fence* const fence = self->map_fence.Get(); + const std::uint64_t value = ++self->map_fence_value; + using clock = std::chrono::steady_clock; + const auto t0 = clock::now(); + hr = queue->Signal(fence, value); + if (SUCCEEDED(hr) && slot31_async()) { + AsyncMapping job{map, self->map_fence, value, {}, {}, pool, pages, flags}; + job.batches.assign(batches, batches + count); + job.ranges.resize(count); + for (UINT b = 0; b < count; ++b) { + if (batches[b].count && batches[b].ranges) + job.ranges[b].assign(batches[b].ranges, batches[b].ranges + batches[b].count); + job.batches[b].ranges = job.ranges[b].data(); + } + async_mapper().push(std::move(job)); + return S_OK; + } + if (SUCCEEDED(hr)) hr = fence->SetEventOnCompletion(value, nullptr); + if (SUCCEEDED(hr) && fence->GetCompletedValue() == UINT64_MAX) hr = DXGI_ERROR_DEVICE_REMOVED; + const auto t1 = clock::now(); + if (SUCCEEDED(hr) && !map(count, batches, pool, pages, flags)) { + const DWORD error = GetLastError(); + hr = error ? HRESULT_FROM_WIN32(error) : E_FAIL; + } + const auto t2 = clock::now(); + // Every 10 s: how long the calls of slot 31 kept the caller (the title's render thread) waiting for the queue's + // earlier work, and then mapping. + static std::mutex stats_mutex; + static struct { + std::uint64_t calls = 0, ranges = 0; + clock::duration wait{}, map{}, max{}; + clock::time_point since = clock::now(); + } stats; + { + std::lock_guard lock(stats_mutex); + ++stats.calls; + stats.ranges += count; + stats.wait += t1 - t0; + stats.map += t2 - t1; + stats.max = (std::max)(stats.max, t2 - t0); + if (t2 - stats.since >= std::chrono::seconds(10)) { + const auto ms = [](clock::duration d) { return std::chrono::duration(d).count(); }; + std::fprintf(stderr, "[rt] d3d12_xs: queue slot 31: %llu calls (%llu batches) in %.0f s: %.1f ms waiting " + "for the queue, %.1f ms mapping, %.1f ms the longest call\n", + static_cast(stats.calls), static_cast(stats.ranges), + std::chrono::duration(t2 - stats.since).count(), ms(stats.wait), ms(stats.map), + ms(stats.max)); + stats = {}; + stats.since = t2; + } + } + return hr; +} template std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, @@ -1870,6 +2255,20 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_ return fence_completed_value_address(self, a1, a2, a3); } else { note_child_slot(Slot); + std::unique_lock queue_order; + if constexpr (K == ChildKind::queue && queue_slot_orders_work(Slot)) + queue_order = std::unique_lock(self->queue_order); + if constexpr (K == ChildKind::queue && Slot == kQueueCopyPageMappingsBatchX) { + const HRESULT hr = queue_copy_page_mappings(self, UINT(a1), reinterpret_cast(a2), + a3, UINT(a4), UINT(a5)); + if (FAILED(hr)) { + static std::atomic failures{0}; + if (failures.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] CopyPageMappingsBatchX failed: hr=0x%08x batches=%u pool=%p pages=%u flags=%u\n", + unsigned(hr), UINT(a1), reinterpret_cast(a3), UINT(a4), UINT(a5)); + } + return hr_to_u64(d3d12_trace::result(child_trace_name(Slot), hr)); + } if constexpr (K == ChildKind::queue && Slot == kQueueExecuteCommandListsX) { d3d12_trace::record(child_trace_name(Slot)); return queue_execute_command_lists(self, a1, a2); @@ -2356,6 +2755,37 @@ struct ListProxy { std::vector vb_scratch; // slot-48 views with their VAs translated std::vector so_scratch; // slot-49 views, same treatment + // Memory writes and waits (d3d12_xs_list_values.h, "list cut" below). A wait recorded after work cuts the + // recording: the real list so far is closed and kept in `parts`, and the title's calls go on into a spare real + // list, which `real` then names, with the state the title had set replayed on it. The queue proxy submits the + // parts in order with the waits between them. `primary` is the real list the proxy was made with; each Reset + // makes it `real` again and puts the other lists back with the spares. Every list here holds one reference. + struct Part { + ID3D12GraphicsCommandList* list; + std::vector pre_writes; // recorded before the gate: land before the queue stands at it + std::vector gate; // the queue stands at these before the part runs + std::vector writes; // land once the part has run + }; + ID3D12GraphicsCommandList* primary = nullptr; + ID3D12CommandAllocator* allocator = nullptr; // real allocator of the current recording (no reference) + std::vector parts; // closed parts before `real` + std::vector pre_writes; // `real`'s part + std::vector gate; + std::vector writes; + std::vector deferred; // waits recorded while a query was open: cut at its end + std::vector spares; // closed real lists for later cuts + list_values::ListState state; + unsigned open_queries = 0; // BeginQuery without its EndQuery yet: no cut may split them + bool part_has_work = false; // `real` has recorded something a wait must follow + bool real_closed = false; // `real` was closed (Close succeeded) since its last Reset + // Set at creation. LEONIDA_LIST_VALUES=0 leaves both off and the list as it was before list values. A bundle + // keeps its state (what it sets stays set in the list executing it) but no writes or waits: ExecuteBundle names + // one real list, so a bundle is never cut. + bool track_state = false; + bool track_values = false; + bool bundle = false; + bool has_values() const { return !parts.empty() || !gate.empty() || !writes.empty() || !pre_writes.empty(); } + void pin_cursor_at_limit() { const std::uint64_t at_limit = static_cast( reinterpret_cast(this) + 0x18 + 0x500); @@ -2403,8 +2833,11 @@ void note_list_slot(unsigned slot, std::uint64_t a1, std::uint64_t a2, std::uint unsigned char console_layout = 0) { if (slot >= kListSlots) return; ListStats::hits[slot].fetch_add(1, std::memory_order_relaxed); + // A plain load first: a compare-exchange on a flag already set still takes its cache line exclusively, at every + // list call from all of the title's recording threads. bool expected = false; - if (ListStats::first[slot].compare_exchange_strong(expected, true, std::memory_order_relaxed)) { + if (!ListStats::first[slot].load(std::memory_order_relaxed) && + ListStats::first[slot].compare_exchange_strong(expected, true, std::memory_order_relaxed)) { const char* name = list_tail_name(slot, console_layout); std::fprintf(stderr, "[rt] d3d12_xs: list slot %u%s%s%s first call (args 0x%llx 0x%llx 0x%llx 0x%llx)\n", slot, name ? " (" : "", name ? name : "", name ? ")" : "", static_cast(a1), @@ -2438,10 +2871,15 @@ bool is_list_iid(const IID& iid) { unsigned long list_add_ref(ListProxy* self) { return self->refs.fetch_add(1, std::memory_order_relaxed) + 1; } void destroy_list(ListProxy* self) { - IUnknown* real = self->real; + // No reference to the proxy is left: its real lists go first (the primary, the one recording if a cut made + // another, the earlier parts and the spares), then the proxy and its device reference. + for (const ListProxy::Part& part : self->parts) + if (part.list != self->primary) part.list->Release(); + for (ID3D12GraphicsCommandList* spare : self->spares) spare->Release(); + if (self->real && self->real != self->primary) self->real->Release(); + if (self->primary) self->primary->Release(); DeviceProxy* device = self->device; delete self; - if (real) real->Release(); if (device) proxy_release(device); } @@ -2486,6 +2924,250 @@ unsigned detect_list_slot_count(IUnknown* real) { return 9; } +// ---- List memory writes and waits: recording and the list cut (d3d12_xs_list_values.h) ---------------------- +// +// A write joins the part being recorded and lands once that part has run. A wait recorded before any work of the part +// (the retail title's usual place: the first calls after Reset) joins the part's gate: the queue stands at it before +// the part. Writes recorded before the part's first wait become its pre-writes, which land before the queue stands at +// the gate (behind the work submitted before the part): the title's frame lists write a counter and a timestamp and +// then wait, and its direct lists write job tags as their first calls and then wait for compute results whose lists +// wait for those tags, so a gate ahead of those writes would hold both queues until the timeout. A wait after work, +// or after a write that follows a wait, cuts the list (cut_list): the real list so far becomes a closed part, and the +// title's calls go on into a spare real list with the state replayed, so what was recorded before the wait is done +// before the queue stands at it and the work after it waits, as on the console. A query open across the wait would +// be split by the cut (D3D12 lists must end the queries they begin; the layer refuses such a list): the cut then +// waits for the query's EndQuery. Bundles record neither (note_bundle_value_op). + +bool is_list_proxy_impl(const void* list); + +// Console list slots whose PC call only sets state (replayed on the next part after a cut). Every other forwarded +// call but Close, Reset and the event marker is work a later wait must follow. +constexpr bool is_list_state_slot(unsigned slot) { + return (slot >= 20 && slot <= 25) || (slot >= 32 && slot <= 50) || slot == 59; +} +constexpr unsigned kConsoleBeginQuery = 56, kConsoleEndQuery = 57, kConsoleEndEvent = 60; + +// The state a forwarded call set, as the real list received it (the slots with their own translation note theirs +// in place: 32, 47-50). +template +void note_list_state(ListProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, std::uint64_t a4) { + using State = list_values::ListState; + State& state = self->state; + if constexpr (Slot == 20) { + state.topology(a1); + } else if constexpr (Slot == 21) { + state.viewports(static_cast(a1), reinterpret_cast(a2)); + } else if constexpr (Slot == 22) { + state.scissors(static_cast(a1), reinterpret_cast(a2)); + } else if constexpr (Slot == 23) { + state.blend_factor(reinterpret_cast(a1)); + } else if constexpr (Slot == 24) { + state.stencil_ref(a1); + } else if constexpr (Slot == 25) { + state.pipeline(a1); + } else if constexpr (Slot == 33 || Slot == 34) { + state.root_signature(Slot == 34, a1); + } else if constexpr (Slot == 35 || Slot == 36) { + state.root_arg(Slot == 36, static_cast(a1), State::kTable, a2); + } else if constexpr (Slot == 37 || Slot == 38) { + const auto value = static_cast(a2); + state.root_constants(Slot == 38, static_cast(a1), 1, &value, static_cast(a3)); + } else if constexpr (Slot == 39 || Slot == 40) { + state.root_constants(Slot == 40, static_cast(a1), static_cast(a2), + reinterpret_cast(a3), static_cast(a4)); + } else if constexpr (Slot >= 41 && Slot <= 46) { + // 41/42 CBV, 43/44 SRV, 45/46 UAV; the even slot is the graphics one. + state.root_arg(Slot % 2 == 0, static_cast(a1), + static_cast(State::kCbv + (Slot - 41) / 2), a2); + } else if constexpr (Slot == 47) { + state.index_buffer(reinterpret_cast(a1)); + } else if constexpr (Slot == 48) { + state.vertex_buffers(static_cast(a1), static_cast(a2), + reinterpret_cast(a3)); + } else if constexpr (Slot == 49) { + state.so_targets(static_cast(a1), static_cast(a2), + reinterpret_cast(a3)); + } else if constexpr (Slot == 59) { + state.predication(a1, a2, a3); + } + (void)self, (void)a1, (void)a2, (void)a3, (void)a4; +} + +// A new recording (Reset): the primary list records again; the other real lists of the last recording are closed and +// wait with the spares for later cuts. +void restart_recording(ListProxy* self) { + for (const ListProxy::Part& part : self->parts) + if (part.list != self->primary) self->spares.push_back(part.list); + self->parts.clear(); + if (self->real != self->primary) { + // A title resets a list it closed; one still open (a D3D12 error, which the real Reset reports) is closed + // here so that a later cut can Reset it. + if (!self->real_closed) self->real->Close(); + self->spares.push_back(self->real); + self->real = self->primary; + } + self->pre_writes.clear(); + self->gate.clear(); + self->writes.clear(); + self->deferred.clear(); + self->open_queries = 0; + self->part_has_work = false; +} + +// The list cut (the comment above): false when no spare real list could be had, and the caller keeps the wait in the +// current part's gate, ahead of its work and writes (stricter than the console; a deadlock on the part's own write is +// bounded by the wait's timeout). +bool cut_list(ListProxy* self, const list_values::Wait& wait) { + auto log_failure = [](const char* what, HRESULT hr) { + list_values::bump(list_values::counters().cut_failures); + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 4) + std::fprintf(stderr, "[rt] d3d12_xs: a list waits for a memory value after work, but %s (hr=0x%08x)\n", + what, static_cast(hr)); + }; + if (!self->allocator) { + log_failure("its allocator is not known: the wait stands before the part", E_FAIL); + return false; + } + // One list records into an allocator at a time: the part closes before the next list opens on it. + const HRESULT closed = self->real->Close(); + if (FAILED(closed)) log_failure("the part before it does not close (it stays refused, as it was)", closed); + ID3D12GraphicsCommandList* next = nullptr; + HRESULT hr = E_FAIL; + if (!self->spares.empty()) { + next = self->spares.back(); + hr = next->Reset(self->allocator, nullptr); + if (SUCCEEDED(hr)) { + self->spares.pop_back(); + } else { + next = nullptr; + } + } + if (!next) { + void* created = nullptr; + hr = self->device->real->CreateCommandList(0, self->real->GetType(), self->allocator, nullptr, + __uuidof(ID3D12GraphicsCommandList), &created); + next = SUCCEEDED(hr) ? static_cast(created) : nullptr; + } + if (!next) { + // The part is closed and nothing records: the title's next calls fail as on a closed list, and its Close + // reports it. Not expected short of running out of memory. + log_failure("no list can record the part after it", hr); + self->real_closed = SUCCEEDED(closed); + return false; + } + self->parts.push_back({self->real, std::move(self->pre_writes), std::move(self->gate), std::move(self->writes)}); + self->pre_writes.clear(); + self->gate.clear(); + self->writes.clear(); + self->gate.push_back(wait); + self->real = next; + self->real_closed = false; + self->part_has_work = false; + self->state.replay(next); + const std::uint64_t cuts = list_values::counters().cuts.fetch_add(1, std::memory_order_relaxed) + 1; + if (cuts == 1 || (cuts & (cuts - 1)) == 0) // the first cut, then at powers of two + std::fprintf(stderr, "[rt] d3d12_xs: a list is cut at a wait for a memory value (%llu cuts so far)\n", + static_cast(cuts)); + return true; +} + +void record_wait(ListProxy* self, const list_values::Wait& wait) { + list_values::bump(list_values::counters().waits_recorded); + if (!self->part_has_work && (self->writes.empty() || self->gate.empty())) { + // Nothing recorded to stand behind but writes before the part's first wait: the wait gates the part, and the + // writes land before it. + self->pre_writes.insert(self->pre_writes.end(), self->writes.begin(), self->writes.end()); + self->writes.clear(); + self->gate.push_back(wait); + } else if (self->open_queries) { + self->deferred.push_back(wait); + list_values::bump(list_values::counters().cuts_deferred); + } else if (!cut_list(self, wait)) { + self->gate.push_back(wait); + } +} + +// EndQuery closed the last open query: the waits recorded meanwhile cut the list here. +void apply_deferred_waits(ListProxy* self) { + if (self->deferred.empty() || self->open_queries) return; + std::vector waits = std::move(self->deferred); + self->deferred.clear(); + for (const list_values::Wait& wait : waits) { + if ((!self->part_has_work && self->writes.empty()) || !cut_list(self, wait)) self->gate.push_back(wait); + } +} + +// write64 with flag 1 (the GPU's timestamp) or 2 (the system's): the GPU takes its timestamp here, at the write's +// place in the list (the title's GPU timing reads these back: a begin/end pair must be its work's, not one landing +// time). Without the device's timestamp heap the write lands the CPU's clock, as before. +void take_timestamp(ListProxy* self, list_values::Write& write) { + DeviceProxy* device = self->device; + std::shared_ptr stamps; + { + std::lock_guard lock(device->timestamps_mutex); + if (!device->timestamps_tried) { + device->timestamps_tried = true; + device->timestamps = list_values::Timestamps::create(device->real); + std::fprintf(stderr, device->timestamps + ? "[rt] d3d12_xs: list timestamp writes take the GPU's timestamp at their place\n" + : "[rt] d3d12_xs: no timestamp query heap: list timestamp writes take the CPU's " + "clock when they land\n"); + } + stamps = device->timestamps; + } + if (!stamps) return; + const std::uint32_t slot = stamps->take(); + self->real->EndQuery(stamps->heap(), D3D12_QUERY_TYPE_TIMESTAMP, slot); + self->real->ResolveQueryData(stamps->heap(), D3D12_QUERY_TYPE_TIMESTAMP, slot, 1, stamps->readback(), + std::uint64_t{slot} * sizeof(std::uint64_t)); + write.stamps = std::move(stamps); + write.slot = slot; +} + +// Console list slots 71-74 (69-72 on the older layout): write32/write64(address, value, flush, flags) and +// wait32/wait64(address, comparison, reference, ?). The flush word and the wait's fourth word are not used. +void record_value_op(ListProxy* self, ConsoleValueOp op, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, + std::uint64_t a4) { + if (!a1) return; // nothing to write or read + if (op == ConsoleValueOp::write32 || op == ConsoleValueOp::write64) { + list_values::Write write{a1, a2, 8, list_values::WriteKind::value}; + if (op == ConsoleValueOp::write32) { + write.value = a2 & 0xffffffffu; + write.bytes = 4; + } else if (static_cast(a4) == 1) { + write.kind = list_values::WriteKind::gpu_timestamp; + take_timestamp(self, write); + } else if (static_cast(a4) == 2) { + write.kind = list_values::WriteKind::system_timestamp; + take_timestamp(self, write); + } + self->writes.push_back(write); + list_values::bump(list_values::counters().writes_recorded); + return; + } + const auto comparison = static_cast(a2); + if (comparison < 2 || comparison > 7) { // always, never or unknown: met (console_value_met), never held + static std::atomic logged{false}; + if (!logged.exchange(true, std::memory_order_relaxed)) + std::fprintf(stderr, "[rt] d3d12_xs: a list waits for a memory value with comparison %u, taken as met\n", + comparison); + return; + } + record_wait(self, {a1, a3, comparison, op == ConsoleValueOp::wait64}); +} + +// A write or wait recorded on a bundle: a no-op, as before list values. A wait after work would cut the bundle, and +// the list executing it would run only the last part (ExecuteBundle names one real list); the title has not been +// seen doing this. +void note_bundle_value_op(ConsoleValueOp op) { + list_values::bump(list_values::counters().bundle_ops); + static std::atomic logged{false}; + if (!logged.exchange(true, std::memory_order_relaxed)) + std::fprintf(stderr, "[rt] d3d12_xs: a bundle records a memory %s; bundles do not model them (no-op)\n", + op == ConsoleValueOp::write32 || op == ConsoleValueOp::write64 ? "write" : "wait"); +} + template std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7, @@ -2510,7 +3192,8 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t return hr_to_u64(proxy_query_interface(self->device, reinterpret_cast(a1), reinterpret_cast(a2))); } else { - note_list_slot(Slot, a1, a2, a3, a4, self->device->console_layout.load(std::memory_order_relaxed)); + const unsigned char layout = self->device->console_layout.load(std::memory_order_relaxed); + note_list_slot(Slot, a1, a2, a3, a4, layout); constexpr unsigned pc = console_to_pc_list_slot(Slot); if constexpr (pc == kListNotForwarded) { #ifdef LEONIDA_VULKAN_DEVICE @@ -2528,6 +3211,15 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t if constexpr (Slot == kConsoleAllocateUpload) { return upload_alloc(self->device, a1, a2); // (size, alignment); the comment at UploadChunk } + if constexpr (Slot >= 69 && Slot <= 74) { // memory writes and waits, by the layout (console_value_op) + const ConsoleValueOp op = console_value_op(Slot, layout); + if (op != ConsoleValueOp::none) { + if (self->track_values) + record_value_op(self, op, a1, a2, a3, a4); + else if (self->bundle && self->track_state) + note_bundle_value_op(op); + } + } return 0; // unmodelled console slot: recorded above, never a PC call } else { if (pc >= self->pc_slot_count) { @@ -2553,8 +3245,48 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t // its allocator proxy; the real list takes the real one (and a wrapped pipeline state the same way). a1 = unwrap_object(a1); a2 = unwrap_object(a2); + restart_recording(self); self->pin_cursor_at_limit(); // a reset list starts its records again: keep the title on the API path + const std::uint64_t result = reinterpret_cast((*reinterpret_cast(self->real))[pc])( + self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); + if (SUCCEEDED(static_cast(result))) { + self->allocator = reinterpret_cast(a1); + self->real_closed = false; + if (self->track_state) { + self->state.clear(); + if (a2) self->state.pipeline(a2); // the initial pipeline state + } + } + return result; + } + if constexpr (Slot == 9) { // Close + self->deferred.clear(); // a query still open: the real list refuses itself anyway + const std::uint64_t result = reinterpret_cast(real_vtable[pc])( + self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); + if (SUCCEEDED(static_cast(result))) self->real_closed = true; + return result; + } + if constexpr (!is_list_state_slot(Slot) && Slot != kConsoleEndEvent) self->part_has_work = true; + if constexpr (Slot == kConsoleBeginQuery) { + if (static_cast(a2) != D3D12_QUERY_TYPE_TIMESTAMP) ++self->open_queries; + } else if constexpr (Slot == kConsoleEndQuery) { + const std::uint64_t result = reinterpret_cast(real_vtable[pc])( + self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); + if (static_cast(a2) != D3D12_QUERY_TYPE_TIMESTAMP && self->open_queries && + --self->open_queries == 0) + apply_deferred_waits(self); + return result; + } + if constexpr (Slot == 11) { + // ClearState(pipeline): the list is back to its state at creation, with this pipeline state. + if (self->track_state) { + self->state.clear(); + if (a1) self->state.pipeline(a1); + } } else if constexpr (Slot == kConsoleExecuteBundle) { + // What the bundle set stays set here: a later cut replays it. + if (self->track_state && is_list_proxy_impl(reinterpret_cast(a1))) + self->state.inherit(reinterpret_cast(a1)->state); a1 = unwrap_object(a1); // the bundle is a list proxy too } else if constexpr (Slot >= 41 && Slot <= 46) { // The six root descriptor setters (index, GPU VA): an upload-arena CPU pointer becomes the @@ -2567,6 +3299,7 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t if (a1) { auto view = *reinterpret_cast(a1); view.BufferLocation = upload_translate(self->device, view.BufferLocation); + if (self->track_state) self->state.index_buffer(&view); return reinterpret_cast(real_vtable[pc])( self->real, reinterpret_cast(&view), a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); @@ -2579,6 +3312,9 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t self->vb_scratch.assign(in, in + a2); for (auto& view : self->vb_scratch) view.BufferLocation = upload_translate(self->device, view.BufferLocation); + if (self->track_state) + self->state.vertex_buffers(static_cast(a1), static_cast(a2), + self->vb_scratch.data()); return reinterpret_cast(real_vtable[pc])( self->real, a1, a2, reinterpret_cast(self->vb_scratch.data()), a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); @@ -2593,6 +3329,8 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t view.BufferFilledSizeLocation = upload_translate(self->device, view.BufferFilledSizeLocation); } + if (self->track_state) + self->state.so_targets(static_cast(a1), static_cast(a2), self->so_scratch.data()); return reinterpret_cast(real_vtable[pc])( self->real, a1, a2, reinterpret_cast(self->so_scratch.data()), a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); @@ -2601,6 +3339,8 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t UnwrappedArray heaps; if (!heaps.fill(a2, a1)) return 0; // void on the PC side; the call simply does not happen const std::uint64_t real_heaps = heaps.data() ? heaps.data() : a2; + if (self->track_state) + self->state.heaps(static_cast(a1), reinterpret_cast(real_heaps)); return reinterpret_cast(real_vtable[pc])(self->real, a1, real_heaps, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); } else if constexpr (Slot == kConsoleOMSetRenderTargets) { @@ -2628,6 +3368,7 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t dsv = translate_cpu_handle(self->device, *in_dsv); out_dsv = &dsv; } + if (self->track_state) self->state.render_targets(count, out_rtvs, single_range, out_dsv); return reinterpret_cast(real_vtable[pc])( self->real, a1, reinterpret_cast(out_rtvs), a3, reinterpret_cast(out_dsv), a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); @@ -2641,6 +3382,9 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t a2 = static_cast( translate_cpu_handle(self->device, D3D12_CPU_DESCRIPTOR_HANDLE{static_cast(a2)}).ptr); } + if constexpr (is_list_state_slot(Slot)) { + if (self->track_state) note_list_state(self, a1, a2, a3, a4); + } return reinterpret_cast(real_vtable[pc])(self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); } @@ -2668,6 +3412,7 @@ void WINAPI list_clear_depth_stencil_view(ListProxy* self, D3D12_CPU_DESCRIPTOR_ kConsoleClearDepthStencilView, pc, self->pc_slot_count); return; } + self->part_has_work = true; const D3D12_CPU_DESCRIPTOR_HANDLE translated = translate_cpu_handle(self->device, dsv); using ClearDsvFn = void(WINAPI*)(ID3D12GraphicsCommandList*, D3D12_CPU_DESCRIPTOR_HANDLE, D3D12_CLEAR_FLAGS, FLOAT, UINT8, UINT, const D3D12_RECT*); @@ -2699,9 +3444,147 @@ IUnknown* list_real_or_null(const void* object) { : nullptr; } +// ---- A submission with memory writes and waits (queue ExecuteCommandLists, d3d12_xs_list_values.h) ---------- +// +// The lists' parts run in order. Consecutive parts with no wait between them go to the real queue in one +// ExecuteCommandLists (a group); a group whose parts write is followed by a Signal of the queue's `written` fence, +// whose value the pump lands the writes at. At a part's gate the group so far is submitted first, then each unmet +// wait becomes a queue Wait: on the fence of a write in flight that will meet it (relay), else on the queue's gate +// fence, which the pump signals once memory compares true or the wait timed out. The caller holds the queue's order +// lock, so the fence values rise in submission order. +class ValueSubmission { +public: + explicit ValueSubmission(ChildProxy* queue) : queue_(queue) {} + + void add(ID3D12CommandList* list) { group_.push_back(list); } + + void part(ID3D12CommandList* list, const std::vector& pre_writes, + const std::vector& gate, const std::vector& writes) { + // Pre-writes land with the group before the gate: behind the work submitted so far, before the queue stands + // at the gate (stand_at submits the group first when a wait is unmet). A met gate is no gate: they then land + // behind the part, with its writes. The memory is read once here, for both. + bool met = true; + for (const list_values::Wait& w : gate) met = met && list_values::met_now(w); + for (const list_values::Write& write : pre_writes) { + writes_.push_back(write); + // Landing before the part has run, a GPU timestamp of the part's would not be written yet: the CPU's + // clock then (the work before the part is done by then, as at the write's place). + if (!met) writes_.back().stamps.reset(); + } + if (!gate.empty()) stand_at(gate, met); + group_.push_back(list); + writes_.insert(writes_.end(), writes.begin(), writes.end()); + } + + void flush() { + if (!group_.empty()) { + using ExecuteFn = void(WINAPI*)(void*, std::uint64_t, ID3D12CommandList* const*); + reinterpret_cast(queue_->real_vtable[kQueueExecuteCommandLists])( + queue_->real, static_cast(group_.size()), group_.data()); + group_.clear(); + } + if (writes_.empty()) return; + list_values::QueueValues* values = queue_->values.get(); + if (values) { + const std::uint64_t value = ++values->written_value; + if (SUCCEEDED(signal(values->written, value))) { + values->written->SetEventOnCompletion(value, list_values::Pump::get().wake()); + list_values::Pump::get().add_writes(queue_->values, value, std::move(writes_)); + } else { + // Nothing would ever say when they may land: dropped, as without fences. + list_values::bump(list_values::counters().writes_failed, writes_.size()); + } + } else { + list_values::bump(list_values::counters().writes_failed, writes_.size()); + } + writes_.clear(); + } + +private: + HRESULT signal(ID3D12Fence* fence, std::uint64_t value) { + using Fn = HRESULT(WINAPI*)(void*, ID3D12Fence*, UINT64); + return reinterpret_cast(queue_->real_vtable[kQueueSignal])(queue_->real, fence, value); + } + HRESULT wait(ID3D12Fence* fence, std::uint64_t value) { + using Fn = HRESULT(WINAPI*)(void*, ID3D12Fence*, UINT64); + return reinterpret_cast(queue_->real_vtable[kQueueWait])(queue_->real, fence, value); + } + + // `met`: every wait compared true when the part was taken (ValueSubmission::part). + void stand_at(const std::vector& waits, bool met) { + auto& counters = list_values::counters(); + if (met) { + list_values::bump(counters.waits_met_at_submit, waits.size()); + return; + } + // The work before the wait goes first; its writes are in flight from here on, so a relay can find them. + flush(); + list_values::QueueValues* values = queue_->values.get(); + if (!values) return; // no fences: the wait runs on, as before + std::vector unmet; + for (const list_values::Wait& w : waits) { + if (list_values::met_now(w)) { + list_values::bump(counters.waits_met_at_submit); + continue; + } + ID3D12Fence* fence = nullptr; + std::uint64_t value = 0; + if (list_values::Pump::get().relay(w, fence, value) && SUCCEEDED(wait(fence, value))) { + const std::uint64_t relayed = counters.waits_relayed.fetch_add(1, std::memory_order_relaxed) + 1; + if (relayed <= 4) // the first few, to show the model at work in a boot log + std::fprintf(stderr, "[rt] d3d12_xs: a wait for 0x%llx is relayed onto a write in flight (fence " + "value %llu)\n", + static_cast(w.address), static_cast(value)); + continue; + } + unmet.push_back(w); + } + if (unmet.empty()) return; + const std::uint64_t value = ++values->gate_value; + list_values::bump(counters.gates_held); + list_values::Pump::get().add_gate(queue_->values, value, std::move(unmet)); + wait(values->gate, value); + } + + ChildProxy* queue_; + std::vector group_; + std::vector writes_; +}; + +bool execute_with_values(ChildProxy* self, UINT count, void* const* lists) { + bool any = false; + for (UINT i = 0; i < count && !any; ++i) + any = is_list_proxy_impl(lists[i]) && static_cast(lists[i])->has_values(); + if (!any) return false; + if (!self->values) { + self->values = list_values::QueueValues::create(self->device->real, + reinterpret_cast(self->real)); + static std::atomic logged{false}; + if (!self->values && !logged.exchange(true, std::memory_order_relaxed)) + std::fprintf(stderr, "[rt] d3d12_xs: no fences for list memory writes and waits: their parts run " + "without them\n"); + } + ValueSubmission submission(self); + for (UINT i = 0; i < count; ++i) { + if (!is_list_proxy_impl(lists[i])) { + const std::uint64_t entry = unwrap_object(reinterpret_cast(lists[i])); + submission.add(reinterpret_cast(entry)); + continue; + } + const auto* list = static_cast(lists[i]); + for (const ListProxy::Part& part : list->parts) + submission.part(part.list, part.pre_writes, part.gate, part.writes); + submission.part(list->real, list->pre_writes, list->gate, list->writes); + } + submission.flush(); + return true; +} + // Wraps `created` (one reference, owned by the proxy on success, released on failure) and returns `riid` from the // proxy through `out`. -HRESULT wrap_list(IUnknown* created, DeviceProxy* device, const IID* riid, void** out) { +HRESULT wrap_list(IUnknown* created, DeviceProxy* device, const IID* riid, void** out, + ID3D12CommandAllocator* allocator = nullptr, std::uint64_t pso = 0, + D3D12_COMMAND_LIST_TYPE type = D3D12_COMMAND_LIST_TYPE_DIRECT) { if (!created) return E_FAIL; ListProxy* proxy = new (std::nothrow) ListProxy(); // (): the console body starts zeroed if (!proxy) { @@ -2710,6 +3593,12 @@ HRESULT wrap_list(IUnknown* created, DeviceProxy* device, const IID* riid, void* } proxy->vtable = get_list_vtable(); proxy->real = static_cast(created); + proxy->primary = proxy->real; + proxy->allocator = allocator; // a created list records into it, as after a Reset + proxy->bundle = type == D3D12_COMMAND_LIST_TYPE_BUNDLE; + proxy->track_state = list_values::enabled(); + proxy->track_values = proxy->track_state && !proxy->bundle; + if (pso && proxy->track_state) proxy->state.pipeline(pso); proxy->device = device; proxy->refs.store(1, std::memory_order_relaxed); proxy->pc_slot_count = detect_list_slot_count(created); @@ -2755,7 +3644,9 @@ HRESULT proxy_create_command_list(DeviceProxy* self, std::uint64_t node_mask, st reinterpret_cast(pso), __uuidof(ID3D12GraphicsCommandList), &created); if (FAILED(hr)) return hr; if (!created) return E_FAIL; - return wrap_list(static_cast(created), self, riid, out); + return wrap_list(static_cast(created), self, riid, out, + reinterpret_cast(unwrap_object(allocator)), pso, + static_cast(type)); } // Calls the real device's slot `Slot` with these five words in the positions the thunk received them (see "A thunk @@ -5528,6 +6419,10 @@ void set_placed_at_va_pages_hook(PlacedAtVaPagesHook hook) { g_placed_at_va_pages.store(hook, std::memory_order_release); } +void set_copy_page_mappings_hook(CopyPageMappingsHook hook) { + g_copy_page_mappings.store(hook, std::memory_order_release); +} + void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler) { g_console_descriptor_heap.store(handler, std::memory_order_release); } @@ -5580,6 +6475,44 @@ ID3D12CommandList* list_proxy_real_list(const void* list) { const char* list_tail_slot_name(unsigned slot, unsigned char console_layout) { return list_tail_name(slot, console_layout); } + +// Every counter of list_values::Counters, by name: the stats and their reset stay in step. +#define LEONIDA_LIST_VALUE_COUNTERS(X) \ + X(writes_recorded) X(writes_landed) X(writes_failed) X(waits_recorded) X(waits_met_at_submit) \ + X(waits_relayed) X(gates_held) X(gates_met) X(gates_timed_out) X(cuts) X(cuts_deferred) X(cut_failures) \ + X(gates_short) X(demotions) X(late_met) X(bundle_ops) X(releases) X(release_us) X(release_us_max) \ + X(pass_us_max) X(release_stalls) X(remaps_now) X(remaps_deferred) X(remaps_failed) X(remap_wait_us_max) \ + X(stamps_gpu) X(stamps_cpu) + +ListValueStats list_value_stats() { + const list_values::Counters& c = list_values::counters(); + ListValueStats stats{}; +#define LEONIDA_GET(name) stats.name = c.name.load(std::memory_order_relaxed); + LEONIDA_LIST_VALUE_COUNTERS(LEONIDA_GET) +#undef LEONIDA_GET + return stats; +} + +void reset_list_value_stats() { + list_values::Counters& c = list_values::counters(); +#define LEONIDA_RESET(name) c.name.store(0, std::memory_order_relaxed); + LEONIDA_LIST_VALUE_COUNTERS(LEONIDA_RESET) +#undef LEONIDA_RESET +} +#undef LEONIDA_LIST_VALUE_COUNTERS + +void set_list_value_wait_timeout_ms(unsigned ms) { list_values::Pump::get().set_timeout_ms(ms); } + +void set_list_values_enabled(bool on) { list_values::set_enabled(on); } + +void stop_list_values(unsigned ms) { list_values::Pump::get().stop(ms); } + +bool list_values_idle(unsigned ms) { return list_values::Pump::get().idle(ms); } + +unsigned list_proxy_part_count(const void* list) { + if (!is_list_proxy_impl(list)) return 0; + return static_cast(static_cast(list)->parts.size()) + 1; +} bool is_fence_proxy(const void* fence) { return is_child_proxy(fence); } bool is_allocator_proxy(const void* allocator) { return is_child_proxy(allocator); } diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 7e4660953b..7b5a3b35fa 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -132,6 +132,8 @@ class FrameTokenSource; namespace leonida::native_pso { struct GraphicsDesc; } +namespace rt::xmem { struct PageBatch; } + namespace rt::d3d12_xs { // Wraps `real` and returns the requested device interface through `out`. Takes ownership of one reference to @@ -281,6 +283,11 @@ void set_placed_at_va_handler(PlacedAtVaHandler handler); // called. With none registered nothing is done. using PlacedAtVaPagesHook = bool (*)(const void* va, std::size_t bytes); void set_placed_at_va_pages_hook(PlacedAtVaPagesHook hook); +// Test/backend seam for queue slot 31. The proxy serializes the mapping after earlier queue work and before later +// submissions. A null hook leaves the console-only call as a successful no-op when xmem is not linked. +using CopyPageMappingsHook = bool (*)(std::uint32_t, const rt::xmem::PageBatch*, std::uintptr_t, + std::uint32_t, std::uint32_t); +void set_copy_page_mappings_hook(CopyPageMappingsHook hook); using PinnedTexturePages = std::shared_ptr (*)(const void*, std::size_t); void set_texture_page_provider(PinnedTexturePages hook); std::shared_ptr pin_texture_pages(const void* address, std::size_t size); @@ -425,6 +432,62 @@ inline constexpr unsigned console_to_pc_list_slot(unsigned slot) { return kListNotForwarded; } +// Console list memory writes and waits (docs/d3d12_xs_console_abi.md §5.5; the runtime side is +// d3d12_xs_list_values.h). `write32(address, value, flush, flags)` and `write64(address, value, flush, flags)` store a +// value once the work before them has run (write64 flag 1 stores the GPU timestamp, 2 the system one); +// `wait32/wait64(address, comparison, reference, ?)` hold the queue until memory compares true. The newer layout +// (this package's title: the list tail sits two slots later) has them at 71-74, the older at 69-72; a layout not +// detected yet is taken as the newer one, as for ExecuteIndirect at 61. +enum class ConsoleValueOp : unsigned char { none, write32, write64, wait32, wait64 }; +inline constexpr ConsoleValueOp console_value_op(unsigned slot, unsigned char console_layout) { + const unsigned first = console_layout == kConsoleLayoutOlder ? 69 : 71; + if (slot < first || slot > first + 3) return ConsoleValueOp::none; + return static_cast(slot - first + 1); +} +// A wait's comparison codes are the D3D12_COMPARISON_FUNC values, memory OP reference: 2 less, 3 equal, 4 less or +// equal, 5 greater, 6 not equal, 7 greater or equal (the title's, with a rising reference). 8 (always), 1 (never) +// and any other code count as met: a wait nothing can meet would only hold the queue to its timeout. A 32-bit wait +// compares the low 32 bits of both. +inline constexpr bool console_value_met(std::uint32_t comparison, std::uint64_t value, std::uint64_t reference, + bool wide) { + if (!wide) { + value &= 0xffffffffu; + reference &= 0xffffffffu; + } + switch (comparison) { + case 2: return value < reference; + case 3: return value == reference; + case 4: return value <= reference; + case 5: return value > reference; + case 6: return value != reference; + case 7: return value >= reference; + default: return true; + } +} +struct ListValueStats { + std::uint64_t writes_recorded, writes_landed, writes_failed; + std::uint64_t waits_recorded, waits_met_at_submit, waits_relayed; // relayed: a GPU wait on a write in flight + std::uint64_t gates_held, gates_met, gates_timed_out; // gate: opened from the CPU + std::uint64_t cuts, cuts_deferred, cut_failures; // a list split at a wait after work + std::uint64_t gates_short, demotions, late_met; // short timeouts, every wait demoted, short waits met later + std::uint64_t bundle_ops; // writes and waits on bundles, not modelled + std::uint64_t releases, release_us, release_us_max, pass_us_max; // the releaser's signals, the pump's passes + std::uint64_t release_stalls; // gate Signals still running after a second + std::uint64_t remaps_now, remaps_deferred, remaps_failed, remap_wait_us_max; // queue slot 31 + std::uint64_t stamps_gpu, stamps_cpu; // write64 flags 1/2 landed with the GPU's timestamp, the CPU's clock +}; +ListValueStats list_value_stats(); +void reset_list_value_stats(); +// How long a queue stands at an unmet wait before it runs on (LEONIDA_VALUE_WAIT_TIMEOUT_MS, default 200 ms). +void set_list_value_wait_timeout_ms(unsigned ms); +// Test helper: LEONIDA_LIST_VALUES as if set to 0 (false) or unset (true), for lists made afterwards. +void set_list_values_enabled(bool on); +// Before the process exits: the threads that land list writes and open gates finish and end (up to `ms`). +void stop_list_values(unsigned ms); +// Test helper: true once every write landed and every gate opened, waiting up to `ms`. +bool list_values_idle(unsigned ms); +// Test helper: the real lists a list proxy's recording is in (1 + its cuts), 0 for anything else. +unsigned list_proxy_part_count(const void* list); // Number of live references on a device proxy. Test helper for the heap's GetDevice/lifetime checks. References the // layer under the proxy holds for background work of its own are waited out first (set_reference_settler), so the diff --git a/runtime/shims/d3d12_xs_list_values.h b/runtime/shims/d3d12_xs_list_values.h new file mode 100644 index 0000000000..eefca7e23b --- /dev/null +++ b/runtime/shims/d3d12_xs_list_values.h @@ -0,0 +1,1289 @@ +#pragma once +// Console command-list memory writes and waits (docs/d3d12_xs_console_abi.md §5.5): the runtime half of list slots +// 71-74 (newer layout; 69-72 in the older one). Included by d3d12_xs_device.cpp only; the list and queue proxies +// there record and submit, this header keeps what has to outlive a call: the writes and waits in flight and the +// threads that settle them. +// +// What the console does. `WriteValueBottomOfPipeX`-style writes store 32 or 64 bits into title memory once the GPU +// work recorded before them has finished; a wait stops the queue's command processor until the 32 or 64 bits at an +// address compare true against a reference. The title chains jobs across its queues this way: a compute list waits +// at its start for a value a direct list writes as its first calls, and a direct list waits for values compute lists +// write near their end (measured on the retail title at the story load: `wait64(address, >=, tag)` on addresses +// other lists `write64(address, tag)`). +// +// What this runtime does. Neither has a D3D12 or Vulkan command. The proxy records them per list part (a list is +// cut at a wait recorded after work, d3d12_xs_device.cpp "list cut"), and the queue proxy submits part by part +// (writes recorded before a part's first wait land before it): +// - A part's writes land after the part has run: the queue proxy signals the queue's `written` fence behind the +// lists of a group and the pump, a thread of its own, stores the values with the CPU once that fence is reached +// (kernel_writes::store: one locked access for an aligned value, as any host write into title memory, so the +// slot-133 shadows see it). Later than the console, never earlier: a write in the middle of a part lands when the +// whole part is done. Writes land in the order they were submitted, across queues too: the fences are read newest +// first, so a write whose work waited for an older one (a relay, a title fence) is never seen done before it. +// A timestamp write (write64 flags 1 and 2) lands the GPU's timestamp for its place in the list (Timestamps). +// - A wait that is met when its part is submitted costs nothing. One that a write still in flight will meet is +// turned into a GPU wait on that write's fence (relay: the queue waits on the writer's `written` value, so the +// GPU orders the two queues without a CPU round trip). Any other wait makes the queue wait on its `gate` fence, +// which is signalled from the CPU once the memory compares true or the wait has timed out. The Vulkan layer +// holds a queue's later work, Signals included, behind an unsatisfied fence wait without blocking the caller +// (src/queue_holds.h), so the submitting thread never waits here. +// - The thread that signals a gate runs the work the layer held behind it (QueueHolds: the held lists' submission, +// the shadow refresh, a deferred Present). That is the releaser, a second thread: the pump only decides, so +// writes keep landing and other gates keep timing out while held work runs. +// Bounded: a gate is signalled after LEONIDA_VALUE_WAIT_TIMEOUT_MS (default 200 ms) whatever memory holds, counted +// from when the gates before it on its queue opened, and logged once per address. Short timeouts (4 ms) go to an +// address that timed out three times in a row, and, once four gates in a row timed out (the title waits for values +// no modelled write stores, a new address each frame), to every wait whose address was never met: a frame then pays +// a few milliseconds, not the full timeout, per such wait. A wait cut short is watched for the rest of the full +// timeout: met in that time, its address keeps the full timeout from then on. A gate cut short that is met within +// its short timeout gives every wait the full timeout again. +// LEONIDA_LIST_VALUES=0 drops both methods (the behaviour before this file). + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "d3d12_xs_device.h" // console_value_met, ListValueStats +#include "../src/title_page_watch.h" // leonida::kernel_writes::store + +namespace rt::d3d12_xs::list_values { + +struct Wait { + std::uint64_t address; + std::uint64_t reference; + std::uint32_t comparison; + bool wide; // 64 bits; else the low 32 bits of memory and reference are compared +}; + +enum class WriteKind : std::uint8_t { value, gpu_timestamp, system_timestamp }; + +// The GPU timestamps of write64 flags 1 and 2: one timestamp query heap and one readback buffer per device, used as +// a ring of slots. A timestamp write takes a slot where the title records it: EndQuery(TIMESTAMP) on the real list +// (the Vulkan layer writes it at the bottom of the pipe, after the work recorded before it) and a ResolveQueryData of +// that one slot into the readback right after. The pump reads the slot once the part's fence has passed. The ticks +// are those of the queue's GetTimestampFrequency, which is what the queue proxy answers the title's frequency query +// with (newer layout slot 18). +class Timestamps { +public: + static constexpr std::uint32_t kSlots = 4096; // a few per frame: a slot comes back after hundreds of frames + + Timestamps(const Timestamps&) = delete; + Timestamps& operator=(const Timestamps&) = delete; + ~Timestamps() { + if (readback_) { + if (values_) readback_->Unmap(0, nullptr); + readback_->Release(); + } + if (heap_) heap_->Release(); + } + + // Null when the device cannot make the heap or the buffer: timestamps then come from the CPU clock at landing. + static std::shared_ptr create(ID3D12Device* device) { + if (!device) return nullptr; + auto stamps = std::shared_ptr(new (std::nothrow) Timestamps); + if (!stamps) return nullptr; + D3D12_QUERY_HEAP_DESC heap{}; + heap.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP; + heap.Count = kSlots; + if (FAILED(device->CreateQueryHeap(&heap, __uuidof(ID3D12QueryHeap), + reinterpret_cast(&stamps->heap_))) || + !stamps->heap_) + return nullptr; + D3D12_HEAP_PROPERTIES readback{}; + readback.Type = D3D12_HEAP_TYPE_READBACK; + D3D12_RESOURCE_DESC buffer{}; + buffer.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + buffer.Width = kSlots * sizeof(std::uint64_t); + buffer.Height = 1; + buffer.DepthOrArraySize = 1; + buffer.MipLevels = 1; + buffer.SampleDesc.Count = 1; + buffer.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + void* mapped = nullptr; + if (FAILED(device->CreateCommittedResource(&readback, D3D12_HEAP_FLAG_NONE, &buffer, + D3D12_RESOURCE_STATE_COPY_DEST, nullptr, __uuidof(ID3D12Resource), + reinterpret_cast(&stamps->readback_))) || + !stamps->readback_ || FAILED(stamps->readback_->Map(0, nullptr, &mapped)) || !mapped) + return nullptr; + stamps->values_ = static_cast(mapped); + return stamps; + } + + // A slot for a timestamp recorded now, its readback value cleared (a slot the GPU has not written reads 0). + std::uint32_t take() { + const std::uint32_t slot = next_.fetch_add(1, std::memory_order_relaxed) % kSlots; + values_[slot] = 0; + return slot; + } + + ID3D12QueryHeap* heap() const { return heap_; } + ID3D12Resource* readback() const { return readback_; } + std::uint64_t read(std::uint32_t slot) const { return slot < kSlots ? values_[slot] : 0; } + +private: + Timestamps() = default; + ID3D12QueryHeap* heap_ = nullptr; + ID3D12Resource* readback_ = nullptr; + volatile std::uint64_t* values_ = nullptr; + std::atomic next_{0}; +}; + +struct Write { + std::uint64_t address; + std::uint64_t value; + std::uint8_t bytes; // 4 or 8 + WriteKind kind; + // A timestamp the GPU takes at the write's place in its list (null: the CPU clock at landing; a write that lands + // before its part has run drops it, see ValueSubmission::part). + std::shared_ptr stamps = nullptr; + std::uint32_t slot = 0; +}; + +struct Counters { + std::atomic writes_recorded{0}, writes_landed{0}, writes_failed{0}; + std::atomic waits_recorded{0}, waits_met_at_submit{0}, waits_relayed{0}; + std::atomic gates_held{0}, gates_met{0}, gates_timed_out{0}; + std::atomic cuts{0}, cuts_deferred{0}, cut_failures{0}; + // Gates given the short timeout, times every wait was demoted to it, short waits met in the rest of the full + // timeout (late), writes and waits on bundles (not modelled: a bundle is never cut). + std::atomic gates_short{0}, demotions{0}, late_met{0}, bundle_ops{0}; + // The releaser's gate signals and the time they took (the held work they ran), the pump's longest pass. + std::atomic releases{0}, release_us{0}, release_us_max{0}, pass_us_max{0}, release_stalls{0}; + // Queue slot 31 (CopyPageMappingsBatchX): applied at the call, deferred behind held work, deferred ones that + // failed, and the longest the call waited for the queue's earlier work. + std::atomic remaps_now{0}, remaps_deferred{0}, remaps_failed{0}, remap_wait_us_max{0}; + // Timestamp writes (write64 flags 1 and 2) landed with the GPU's timestamp, and with the CPU clock at landing. + std::atomic stamps_gpu{0}, stamps_cpu{0}; +}; + +inline Counters& counters() { + static Counters* c = new Counters; // immortal: the threads may still count during teardown + return *c; +} + +inline void bump(std::atomic& counter, std::uint64_t by = 1) { + counter.fetch_add(by, std::memory_order_relaxed); +} + +inline void raise_to(std::atomic& counter, std::uint64_t value) { + std::uint64_t seen = counter.load(std::memory_order_relaxed); + while (seen < value && !counter.compare_exchange_weak(seen, value, std::memory_order_relaxed)) { + } +} + +// LEONIDA_LIST_VALUES=0 turns both methods back into the no-ops they were. Read once; a test can set it (lists made +// afterwards follow it). +inline std::atomic& enabled_state() { + static std::atomic state{-1}; + return state; +} +inline bool enabled() { + int state = enabled_state().load(std::memory_order_relaxed); + if (state < 0) { + char value[8] = {}; + std::size_t length = 0; + state = getenv_s(&length, value, sizeof(value), "LEONIDA_LIST_VALUES") != 0 || std::strcmp(value, "0") != 0; + enabled_state().store(state, std::memory_order_relaxed); + } + return state != 0; +} +inline void set_enabled(bool on) { enabled_state().store(on ? 1 : 0, std::memory_order_relaxed); } + +// The value a wait looks at, read through the kernel: memory that is not there is reported instead of faulting (a +// fault would run every vectored handler of the process, the D3D12 layer's write-fault handler among them, from a +// thread that may hold the pump's lock). The kernel's copy is not one access, so a value read while another thread +// stores it could mix the two: it is read until two reads agree. +inline bool read_value(std::uint64_t address, bool wide, std::uint64_t& value) { + value = 0; + if (!address) return false; + const SIZE_T bytes = wide ? 8 : 4; + const auto* at = reinterpret_cast(static_cast(address)); + std::uint64_t last = 0; + for (int attempt = 0; attempt < 4; ++attempt) { + std::uint64_t now = 0; + SIZE_T got = 0; + if (!ReadProcessMemory(GetCurrentProcess(), at, &now, bytes, &got) || got != bytes) return false; + if (attempt && now == last) break; + last = now; + } + value = last; + return true; +} + +// Memory that cannot be read meets the wait: nothing could ever change it for the GPU either. +inline bool met_now(const Wait& wait) { + std::uint64_t value = 0; + if (!read_value(wait.address, wait.wide, value)) return true; + return console_value_met(wait.comparison, value, wait.reference, wait.wide); +} + +// One per queue proxy, made at its first submission of a list part with writes or an unmet wait. The fences are the +// real device's; their values only rise. `gate_value` and `written_value` are advanced by the submitting thread +// under the queue proxy's order lock; the threads only read the values they were handed. +struct QueueValues { + ID3D12Fence* gate = nullptr; // the queue waits on it at an unmet wait; the releaser signals it + ID3D12Fence* written = nullptr; // the queue signals it behind a group of parts that write + std::uint64_t gate_value = 0; + std::uint64_t written_value = 0; + std::uint64_t last_gpu_stamp = 0; // the pump's only: the last GPU timestamp landed for this queue + + QueueValues() = default; + QueueValues(const QueueValues&) = delete; + QueueValues& operator=(const QueueValues&) = delete; + ~QueueValues() { + if (gate) gate->Release(); + if (written) written->Release(); + if (queue_) queue_->Release(); + } + + // Null when a fence cannot be made: the caller then submits as before (waits run on, writes are dropped). + static std::shared_ptr create(ID3D12Device* device, ID3D12CommandQueue* queue) { + if (!device) return nullptr; + auto values = std::shared_ptr(new (std::nothrow) QueueValues); + if (!values) return nullptr; + if (FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence), + reinterpret_cast(&values->gate))) || + !values->gate || + FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence), + reinterpret_cast(&values->written))) || + !values->written) + return nullptr; + LARGE_INTEGER frequency{}; + QueryPerformanceFrequency(&frequency); + values->qpc_frequency_ = static_cast(frequency.QuadPart); + UINT64 gpu_frequency = 0; + if (queue && SUCCEEDED(queue->GetTimestampFrequency(&gpu_frequency)) && gpu_frequency) { + values->gpu_frequency_ = gpu_frequency; + queue->AddRef(); + values->queue_ = queue; + const auto started = std::chrono::steady_clock::now(); + values->calibrate(); + // A queue without calibrated timestamps answers by stalling itself (the layer's fallback): such a queue + // is calibrated once, here, and not again from the pump. + values->recalibrate_ = std::chrono::steady_clock::now() - started < std::chrono::milliseconds(2); + } + return values; + } + + // The GPU's timestamp (in the queue's GetTimestampFrequency ticks) for a QueryPerformanceCounter value, from the + // queue's clock calibration: gpu0 + (qpc - cpu0) * gpu_frequency / qpc_frequency. Without one, the QPC value. + std::uint64_t gpu_ticks_at(std::uint64_t qpc) { + const Calibration c = calibration(); + if (!c.cpu0 || !gpu_frequency_ || !qpc_frequency_) return qpc; + return qpc >= c.cpu0 ? c.gpu0 + scale(qpc - c.cpu0, gpu_frequency_, qpc_frequency_) + : c.gpu0 - (std::min)(c.gpu0, scale(c.cpu0 - qpc, gpu_frequency_, qpc_frequency_)); + } + + // The QueryPerformanceCounter value at which the GPU's clock read `ticks`, the other way round. 0 without a + // calibration. + std::uint64_t qpc_at(std::uint64_t ticks) { + const Calibration c = calibration(); + if (!c.cpu0 || !gpu_frequency_ || !qpc_frequency_) return 0; + return ticks >= c.gpu0 ? c.cpu0 + scale(ticks - c.gpu0, qpc_frequency_, gpu_frequency_) + : c.cpu0 - (std::min)(c.cpu0, scale(c.gpu0 - ticks, qpc_frequency_, gpu_frequency_)); + } + + std::uint64_t gpu_frequency() const { return gpu_frequency_; } + +private: + struct Calibration { + std::uint64_t gpu0 = 0, cpu0 = 0; + }; + + // value * to / from without overflowing 64 bits for any uptime. + static std::uint64_t scale(std::uint64_t value, std::uint64_t to, std::uint64_t from) { + const std::uint64_t whole = value / from, part = value % from; + return whole * to + part * to / from; + } + + void calibrate() { + UINT64 gpu = 0, cpu = 0; + if (!queue_ || FAILED(queue_->GetClockCalibration(&gpu, &cpu)) || !cpu) return; + std::lock_guard lock(clock_mutex_); + calibration_ = {gpu, cpu}; + calibrated_at_ = std::chrono::steady_clock::now(); + } + + // The two clocks drift apart by some parts per million: the pump calibrates again once a second. + Calibration calibration() { + if (recalibrate_ && std::chrono::steady_clock::now() - calibrated_at_.load() > std::chrono::seconds(1)) + calibrate(); + std::lock_guard lock(clock_mutex_); + return calibration_; + } + + ID3D12CommandQueue* queue_ = nullptr; // the real queue (one reference), for GetClockCalibration + std::uint64_t gpu_frequency_ = 0, qpc_frequency_ = 0; + bool recalibrate_ = false; + std::mutex clock_mutex_; + Calibration calibration_; + std::atomic calibrated_at_{}; +}; + +// The two threads that land writes and open gates. One pair per process, made on first use; stop() ends them before +// the process exits, so neither is cut off inside the layer (holding QueueHolds' pump lock, say). +// - The pump lands writes whose fence was reached and decides which gates open (met, timed out, or an action's +// turn). It never signals a gate: it hands them, in each queue's order, to +// - the releaser, which signals them (after running the action of an action gate). The Signal runs the work the +// layer held behind the gate, which can take a while; the pump goes on meanwhile. +class Pump { +public: + static Pump& get() { + static Pump* pump = new Pump; // immortal: a late submission may still reach it during teardown + return *pump; + } + + // Writes that land once `queue->written` reaches `value`. The caller signalled that value on the queue and + // asked the fence to set wake() on it (SetEventOnCompletion), so the pump needs no polling for writes. + void add_writes(std::shared_ptr queue, std::uint64_t value, std::vector writes) { + if (writes.empty() || exiting_.load(std::memory_order_relaxed)) return; // stop(): see there + { + std::lock_guard lock(mutex_); + writes_.push_back({std::move(queue), value, std::move(writes)}); + } + start_or_settle(); + } + + // The queue waits on `queue->gate` for `value`: signalled once every wait is met, or the gate timed out. Its + // time starts when the gates before it on its queue have opened (start_gate). + void add_gate(std::shared_ptr queue, std::uint64_t value, std::vector waits) { + if (exiting_.load(std::memory_order_relaxed)) return; // stop(): never signalled, see there + { + std::lock_guard lock(mutex_); + Gate gate; + gate.queue = std::move(queue); + gate.value = value; + gate.waits = std::move(waits); + gates_.push_back(std::move(gate)); + } + start_or_settle(); + } + + // The queue waits on `queue->gate` for `value`, which the releaser signals after running `action`, once + // `queue->written` reaches `after` (the caller signalled it on the queue and set wake() on it): something the + // CPU does at a point of the queue's timeline, after the work before it and before the work after it. No + // timeout. False when the threads do not run (the caller then does it the synchronous way). + bool add_action(std::shared_ptr queue, std::uint64_t value, std::uint64_t after, + std::function action) { + if (!start()) return false; + { + std::lock_guard lock(mutex_); + Gate gate; + gate.queue = std::move(queue); + gate.value = value; + gate.started = true; + gate.since = Clock::now(); + gate.deadline = Clock::time_point::max(); + gate.after = after; + gate.action = std::move(action); + gates_.push_back(std::move(gate)); + } + SetEvent(wake_); + return true; + } + + // A write still in flight that will meet `wait` when it lands: the fence and value whose completion lands it + // (the earliest such write). False when there is none. + bool relay(const Wait& wait, ID3D12Fence*& fence, std::uint64_t& value) { + std::lock_guard lock(mutex_); + const std::uint8_t need = wait.wide ? 8 : 4; + for (const WriteGroup& group : writes_) + for (const Write& write : group.writes) + if (write.kind == WriteKind::value && write.address == wait.address && write.bytes >= need && + console_value_met(wait.comparison, write.value, wait.reference, wait.wide)) { + fence = group.queue->written; + value = group.value; + return true; + } + return false; + } + + HANDLE wake() const { return wake_; } + + // stop() ran: nothing new is landed or opened (the process is ending). + bool stopped() const { return exiting_.load(std::memory_order_relaxed); } + + // Starts the threads if they are not running yet; true while they run. + bool start() { + std::call_once(start_, [this] { + if (wake_) { + thread_ = CreateThread(nullptr, 0, &Pump::pump_main, this, 0, nullptr); + if (thread_) releaser_ = CreateThread(nullptr, 0, &Pump::releaser_main, this, 0, nullptr); + if (thread_ && !releaser_) { // the pump alone would wait for a releaser forever + stop_.store(true, std::memory_order_relaxed); + SetEvent(wake_); + WaitForSingleObject(thread_, INFINITE); + CloseHandle(thread_); + thread_ = nullptr; + } + } + if (!releaser_) + std::fprintf(stderr, "[rt] d3d12_xs: no threads for list memory writes and waits (error %lu): " + "writes land at submission and waits run on\n", GetLastError()); + else + std::fprintf(stderr, "[rt] d3d12_xs: list memory writes land after their part ran, waits hold their " + "queue (timeout %u ms)\n", timeout_ms_.load(std::memory_order_relaxed)); + }); + return releaser_ && !stop_.load(std::memory_order_relaxed); + } + + void set_timeout_ms(unsigned ms) { timeout_ms_.store(ms ? ms : 1, std::memory_order_relaxed); } + + // Test helper: true once nothing is in flight, polling for up to `ms`. + bool idle(unsigned ms) { + const auto until = Clock::now() + std::chrono::milliseconds(ms); + for (;;) { + { + std::lock_guard lock(mutex_); + std::lock_guard release(release_mutex_); + if (writes_.empty() && gates_.empty() && !busy_ && releases_.empty() && !releasing_) return true; + } + if (Clock::now() >= until) return false; + if (wake_) SetEvent(wake_); + Sleep(1); + } + } + + // Before the process exits: both threads finish what they are doing (a held submission the releaser is running, + // say) and end, waiting up to `ms` for them. Gates not signalled yet stay shut and their actions do not run, and + // writes and gates added afterwards are dropped: signalling any of them from another thread could open a gate + // whose remap was skipped, or signal a gate value above one still to come. The queues' held work is not run at + // exit. + void stop(unsigned ms) { + if (exiting_.exchange(true, std::memory_order_relaxed)) return; + stop_.store(true, std::memory_order_relaxed); + if (wake_) SetEvent(wake_); + { + std::lock_guard release(release_mutex_); + } + release_ready_.notify_all(); + HANDLE threads[2]; + DWORD count = 0; + if (thread_) threads[count++] = thread_; + if (releaser_) threads[count++] = releaser_; + if (count && WaitForMultipleObjects(count, threads, TRUE, ms) == WAIT_TIMEOUT) + std::fprintf(stderr, "[rt] d3d12_xs: list value threads still busy after %u ms at exit\n", ms); + } + +private: + using Clock = std::chrono::steady_clock; + static constexpr unsigned kDemoteAfter = 3; // timeouts in a row before an address gets the short timeout + static constexpr unsigned kDemoteAllAfter = 4; // gates timed out in a row before every wait gets it + static constexpr unsigned kDemotedTimeoutMs = 4; + static constexpr unsigned kPollMs = 1; // while a gate waits for memory nobody tells us about + static constexpr std::size_t kMaxStreaks = 256; // addresses whose timeouts are counted (least recently used go) + static constexpr std::size_t kMaxLate = 64; // waits cut short watched for the rest of the full timeout + static constexpr std::uint64_t kStallMs = 1000; // a gate Signal this long is reported (watch_releaser) + + struct WriteGroup { + std::shared_ptr queue; + std::uint64_t value; + std::vector writes; + }; + struct Gate { + std::shared_ptr queue; + std::uint64_t value = 0; + std::vector waits; + Clock::time_point deadline; // set by start_gate + Clock::time_point since; + bool started = false; // the gates before it on its queue have opened: its time runs + bool cut_short = false; // given the short timeout + std::uint64_t after = 0; // action gates: the queue's `written` value the action runs behind + std::function action; // null: a memory wait + }; + struct Release { + std::shared_ptr queue; + std::uint64_t value; + std::function action; + }; + struct Streak { + std::uint64_t address; + unsigned timeouts; // in a row + bool logged; + bool met; // a wait for it was met once (in time or late): it keeps the full timeout when every + // wait is demoted + std::uint64_t used; // use_clock_ at its last use + }; + struct Late { + Wait wait; + Clock::time_point until; + }; + + Pump() { + wake_ = CreateEventW(nullptr, FALSE, FALSE, nullptr); + timer_ = CreateWaitableTimerExW(nullptr, nullptr, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); + unsigned timeout = 200; + char text[16] = {}; + std::size_t length = 0; + if (getenv_s(&length, text, sizeof(text), "LEONIDA_VALUE_WAIT_TIMEOUT_MS") == 0 && text[0]) { + const unsigned long parsed = std::strtoul(text, nullptr, 10); + if (parsed > 0 && parsed < 600000) timeout = static_cast(parsed); + } + timeout_ms_.store(timeout, std::memory_order_relaxed); + } + + // Without the threads (none could be made, or stop() ran) nothing could land later: what is queued is settled + // right here, writes at once and gates opened, which is the order before this file, not a hang. + void start_or_settle() { + if (start()) { + SetEvent(wake_); + return; + } + if (exiting_.load(std::memory_order_relaxed)) return; + // One thread at a time, so that the gates are signalled in order. + std::lock_guard settle(settle_mutex_); + pass(true); + } + + static DWORD WINAPI pump_main(LPVOID self) { + static_cast(self)->run(); + return 0; + } + static DWORD WINAPI releaser_main(LPVOID self) { + static_cast(self)->release_loop(); + return 0; + } + + void run() { + while (!stop_.load(std::memory_order_relaxed)) { + bool polling = false, writes = false; + { + std::lock_guard lock(mutex_); + polling = !gates_.empty() || !late_.empty(); + writes = !writes_.empty(); + } + if (polling && timer_) { + LARGE_INTEGER due{}; + due.QuadPart = -static_cast(kPollMs) * 10000; // relative, 100 ns units + SetWaitableTimer(timer_, &due, 0, nullptr, nullptr, FALSE); + const HANDLE handles[2] = {wake_, timer_}; + WaitForMultipleObjects(2, handles, FALSE, INFINITE); + } else { + // Writes wake us through SetEventOnCompletion; the timeout is only a safety net (and, while the + // releaser is inside a Signal, how often watch_releaser looks at it). + const bool releasing = signal_since_ms_.load(std::memory_order_relaxed) != 0; + WaitForSingleObject(wake_, polling ? kPollMs : writes ? 50 : releasing ? 500 : INFINITE); + } + if (stop_.load(std::memory_order_relaxed)) break; + pass(false); + watch_releaser(); + summarize(); + } + } + + // A gate Signal that does not return holds every later gate of every queue (the releaser signals them in turn): + // said once per stall, with the thread, for a debugger. + void watch_releaser() { + const std::uint64_t since = signal_since_ms_.load(std::memory_order_relaxed); + if (!since) { + stall_logged_ = false; + return; + } + const std::uint64_t ms = GetTickCount64() - since; + if (ms < kStallMs || stall_logged_) return; + stall_logged_ = true; + bump(counters().release_stalls); + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] d3d12_xs: the releaser (thread %lu) has been inside one gate Signal (value " + "%llu) for %llu ms: the work the layer held behind the gate has not run\n", + releaser_tid_.load(std::memory_order_relaxed), + static_cast(signal_value_.load(std::memory_order_relaxed)), + static_cast(ms)); + } + + // Signals the gates the pump opened, in the order it opened them (each queue's gate values rise in that order). + void release_loop() { + releaser_tid_.store(GetCurrentThreadId(), std::memory_order_relaxed); + for (;;) { + std::deque batch; + { + std::unique_lock lock(release_mutex_); + release_ready_.wait(lock, [this] { + return !releases_.empty() || stop_.load(std::memory_order_relaxed); + }); + if (stop_.load(std::memory_order_relaxed)) return; + batch.swap(releases_); + releasing_ = true; + } + SetEvent(wake_); // the pump may be in an untimed wait: it watches the Signals from here on + for (Release& release : batch) { + if (stop_.load(std::memory_order_relaxed)) break; + signal_value_.store(release.value, std::memory_order_relaxed); + signal_since_ms_.store(GetTickCount64() | 1, std::memory_order_relaxed); // never 0 while inside + signal(release); + signal_since_ms_.store(0, std::memory_order_relaxed); + } + std::lock_guard lock(release_mutex_); + releasing_ = false; + } + } + + // The action (if any), then the gate's Signal, which runs whatever the layer held behind it. + static void signal(const Release& release) { + const auto started = Clock::now(); + if (release.action) release.action(); + release.queue->gate->Signal(release.value); + const auto us = static_cast( + std::chrono::duration_cast(Clock::now() - started).count()); + Counters& c = counters(); + bump(c.releases); + bump(c.release_us, us); + raise_to(c.release_us_max, us); + } + + Streak* find_streak(std::uint64_t address) { + for (Streak& streak : streaks_) + if (streak.address == address) { + streak.used = ++use_clock_; + return &streak; + } + return nullptr; + } + + Streak* add_streak(std::uint64_t address) { + if (streaks_.size() < kMaxStreaks) { + streaks_.push_back({address, 0, false, false, ++use_clock_}); + return &streaks_.back(); + } + Streak* oldest = &*std::min_element(streaks_.begin(), streaks_.end(), + [](const Streak& a, const Streak& b) { return a.used < b.used; }); + *oldest = {address, 0, false, false, ++use_clock_}; + return oldest; + } + + // Write groups whose fence was reached, taken off the list in submission order (per queue, up to the first one + // not reached). The fences are read newest group first, a fence again for an older group its last reading does + // not cover: if a group's work waited for an older group's (on another queue), the older group's reading comes + // later than the newer one's, so it cannot read as not done while the newer one reads as done. Called with + // mutex_ held. + void take_landed(bool force, std::vector& landing) { + const std::size_t count = writes_.size(); + if (!count) return; + std::vector reached(count, force ? 1 : 0); + if (!force) { + struct Reading { + const QueueValues* queue; + std::uint64_t completed; + }; + std::vector readings; + for (std::size_t i = count; i-- > 0;) { + const WriteGroup& group = writes_[i]; + auto it = std::find_if(readings.begin(), readings.end(), + [&](const Reading& r) { return r.queue == group.queue.get(); }); + if (it == readings.end()) { + readings.push_back({group.queue.get(), group.queue->written->GetCompletedValue()}); + it = readings.end() - 1; + } else if (it->completed < group.value) { + it->completed = group.queue->written->GetCompletedValue(); + } + reached[i] = it->completed >= group.value; + } + } + std::deque rest; + std::vector blocked; + for (std::size_t i = 0; i < count; ++i) { + WriteGroup& group = writes_[i]; + const QueueValues* queue = group.queue.get(); + const bool queue_blocked = std::find(blocked.begin(), blocked.end(), queue) != blocked.end(); + if (reached[i] && !queue_blocked) { + landing.push_back(std::move(group)); + } else { + if (!queue_blocked) blocked.push_back(queue); + rest.push_back(std::move(group)); + } + } + writes_.swap(rest); + } + + // The gates whose waits are met, whose time is up or whose action's turn has come, taken off the list in each + // queue's order (a queue's gate values rise in submission order, so a later one must not be signalled first: it + // would open the earlier one too). `force` (no threads): every gate, now. Called with mutex_ held. + void take_open(bool force, std::vector& opening) { + std::vector blocked; + const auto now = Clock::now(); + for (auto it = gates_.begin(); it != gates_.end();) { + const QueueValues* queue = it->queue.get(); + if (std::find(blocked.begin(), blocked.end(), queue) != blocked.end()) { + ++it; + continue; + } + bool open = force; + if (it->action) { + open = open || queue->written->GetCompletedValue() >= it->after; + } else { + if (!it->started) start_gate(*it, now); + bool met = true; + for (const Wait& wait : it->waits) met = met && met_now(wait); + open = open || met || now >= it->deadline; + if (open) note_outcome(*it, met || force); + } + if (open) { + opening.push_back({std::move(it->queue), it->value, std::move(it->action)}); + it = gates_.erase(it); + } else { + blocked.push_back(queue); + ++it; + } + } + } + + // Writes landed, then gates opened: the pump's one step. `force` runs on the caller's thread when the threads do + // not, and signals there too. + void pass(bool force) { + const auto started = Clock::now(); + std::vector landing; + { + std::lock_guard lock(mutex_); + busy_ = true; + take_landed(force, landing); + } + for (const WriteGroup& group : landing) land(group); + std::vector opening; + { + std::lock_guard lock(mutex_); + watch_late(); + take_open(force, opening); + } + if (!opening.empty()) { + if (force) { + for (const Release& release : opening) signal(release); + } else { + { + std::lock_guard release(release_mutex_); + for (Release& r : opening) releases_.push_back(std::move(r)); + } + release_ready_.notify_one(); + } + } + if (!force) + raise_to(counters().pass_us_max, + static_cast( + std::chrono::duration_cast(Clock::now() - started).count())); + std::lock_guard lock(mutex_); + busy_ = false; + } + + // One line every 10 s while there is traffic, for boot logs. + void summarize() { + const auto now = Clock::now(); + if (now < next_summary_) return; + next_summary_ = now + std::chrono::seconds(10); + const Counters& c = counters(); + const auto get = [](const std::atomic& v) { + return static_cast(v.load(std::memory_order_relaxed)); + }; + std::fprintf(stderr, + "[rt] d3d12_xs: list values so far: %llu writes recorded, %llu landed, %llu failed; %llu waits " + "recorded, %llu met at submission, %llu relayed; %llu gates held, %llu met, %llu timed out " + "(%llu short, %llu demotions, %llu met late); %llu cuts (%llu deferred to a query's end, %llu " + "failed), %llu on bundles; releaser %llu signals, %.1f ms, longest %.2f ms, %llu stalls; longest pump pass " + "%.2f ms; %llu page remaps at the call (longest wait %.2f ms), %llu deferred (%llu failed); " + "timestamps %llu from the GPU, %llu from the CPU clock\n", + get(c.writes_recorded), get(c.writes_landed), get(c.writes_failed), get(c.waits_recorded), + get(c.waits_met_at_submit), get(c.waits_relayed), get(c.gates_held), get(c.gates_met), + get(c.gates_timed_out), get(c.gates_short), get(c.demotions), get(c.late_met), get(c.cuts), + get(c.cuts_deferred), get(c.cut_failures), get(c.bundle_ops), get(c.releases), + get(c.release_us) / 1000.0, get(c.release_us_max) / 1000.0, get(c.release_stalls), + get(c.pass_us_max) / 1000.0, + get(c.remaps_now), get(c.remap_wait_us_max) / 1000.0, get(c.remaps_deferred), + get(c.remaps_failed), get(c.stamps_gpu), get(c.stamps_cpu)); + } + + // A timestamp write's value: the GPU's timestamp for the write's place in its list when the GPU wrote one, else + // the CPU's clock now. Flag 1 is in the queue's GetTimestampFrequency ticks; flag 2 (the system timestamp) is a + // QueryPerformanceCounter value, the GPU's timestamp turned into one through the queue's clock calibration (never + // later than now: the GPU got there before its fence was seen passed). + static std::uint64_t stamp(QueueValues& queue, const Write& write) { + LARGE_INTEGER now{}; + QueryPerformanceCounter(&now); + const auto qpc = static_cast(now.QuadPart); + const std::uint64_t ticks = write.stamps ? write.stamps->read(write.slot) : 0; + Counters& c = counters(); + if (write.kind == WriteKind::gpu_timestamp) { + if (ticks) { + bump(c.stamps_gpu); + return ticks; + } + bump(c.stamps_cpu); + return queue.gpu_ticks_at(qpc); + } + if (ticks) { + if (const std::uint64_t at = queue.qpc_at(ticks)) { + bump(c.stamps_gpu); + return (std::min)(at, qpc); + } + } + bump(c.stamps_cpu); + return qpc; + } + + // The first few groups with two GPU timestamps or more, and then one in 1000: how far apart the GPU took them, to + // show in a boot log that the title's begin and end timestamps are its GPU work's, not one landing time. + static void note_stamps(QueueValues& queue, const WriteGroup& group) { + std::uint64_t first = 0, last = 0; + unsigned count = 0; + for (const Write& write : group.writes) { + if (write.kind != WriteKind::gpu_timestamp || !write.stamps) continue; + const std::uint64_t ticks = write.stamps->read(write.slot); + if (!ticks) continue; + if (!count++) first = ticks; + last = ticks; + } + if (!count) return; + const std::uint64_t previous = queue.last_gpu_stamp; + queue.last_gpu_stamp = last; + static std::atomic groups{0}; + const std::uint64_t n = groups.fetch_add(1, std::memory_order_relaxed); + if (count < 2 || (n >= 6 && n % 1000 != 0)) return; + const double ms_per_tick = queue.gpu_frequency() ? 1000.0 / static_cast(queue.gpu_frequency()) : 0.0; + std::fprintf(stderr, "[rt] d3d12_xs: %u GPU timestamps landed together span %.3f ms (the first %.3f ms after " + "the queue's previous one)\n", + count, static_cast(last - first) * ms_per_tick, + previous && first >= previous ? static_cast(first - previous) * ms_per_tick : 0.0); + } + + void land(const WriteGroup& group) { + note_stamps(*group.queue, group); + for (const Write& write : group.writes) { + const std::uint64_t value = write.kind == WriteKind::value ? write.value : stamp(*group.queue, write); + if (leonida::kernel_writes::store(reinterpret_cast(static_cast(write.address)), + value, write.bytes)) { + bump(counters().writes_landed); + continue; + } + bump(counters().writes_failed); + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 4) + std::fprintf(stderr, "[rt] d3d12_xs: a list's %u-byte write to 0x%llx faulted; it is dropped\n", + unsigned(write.bytes), static_cast(write.address)); + } + } + + // The gates before it on its queue have opened: its time starts now. The short timeout goes to a gate with an + // address that timed out three times in a row, and, while every wait is demoted, to one with an address no wait + // was ever met for (an address the title waits on and some write does meet keeps its full timeout). Called with + // mutex_ held. + void start_gate(Gate& gate, Clock::time_point now) { + const unsigned full = timeout_ms_.load(std::memory_order_relaxed); + bool cut_short = false, unknown = false; + for (const Wait& wait : gate.waits) { + const Streak* streak = find_streak(wait.address); + if (streak && streak->timeouts >= kDemoteAfter) cut_short = true; + if (!streak || !streak->met) unknown = true; + } + cut_short = (cut_short || (demoted_ && unknown)) && kDemotedTimeoutMs < full; + if (cut_short) bump(counters().gates_short); + gate.started = true; + gate.cut_short = cut_short; + gate.since = now; + gate.deadline = now + std::chrono::milliseconds(cut_short ? kDemotedTimeoutMs : full); + } + + // A wait for `address` was met (in time, or late): the address has met history and its timeouts in a row end. + // Called with mutex_ held. + void note_met(std::uint64_t address) { + Streak* streak = find_streak(address); + if (!streak) streak = add_streak(address); + streak->met = true; + streak->timeouts = 0; + } + + // A gate cut short by the demotion of every wait was met within its short timeout: waits are met again, every + // wait gets the full timeout. (Not a gate with the full timeout, nor a late meet: those leave the waits that + // nothing meets cut short.) Called with mutex_ held. + void lift_demotion(std::uint64_t address) { + if (!demoted_) return; + demoted_ = false; + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] d3d12_xs: a wait for 0x%llx cut short was met: waits get %u ms again\n", + static_cast(address), timeout_ms_.load(std::memory_order_relaxed)); + } + + // The waits cut short, watched until their full timeout would have run out. Called with mutex_ held. + void watch_late() { + if (late_.empty()) return; + const auto now = Clock::now(); + for (auto it = late_.begin(); it != late_.end();) { + if (met_now(it->wait)) { + bump(counters().late_met); + note_met(it->wait.address); + it = late_.erase(it); + } else if (now >= it->until) { + it = late_.erase(it); + } else { + ++it; + } + } + } + + // Called with mutex_ held. + void note_outcome(const Gate& gate, bool met) { + if (met) { + bump(counters().gates_met); + timeouts_in_a_row_ = 0; + for (const Wait& wait : gate.waits) note_met(wait.address); + if (gate.cut_short && !gate.waits.empty()) lift_demotion(gate.waits.front().address); + if (logged_met_ < 4) { // the first few, to show the model at work in a boot log + ++logged_met_; + const double ms = std::chrono::duration(Clock::now() - gate.since).count(); + std::fprintf(stderr, "[rt] d3d12_xs: a queue's wait for 0x%llx was met after %.2f ms\n", + static_cast(gate.waits.front().address), ms); + } + return; + } + bump(counters().gates_timed_out); + const unsigned full = timeout_ms_.load(std::memory_order_relaxed); + if (++timeouts_in_a_row_ >= kDemoteAllAfter && !demoted_ && kDemotedTimeoutMs < full) { + demoted_ = true; + bump(counters().demotions); + static std::atomic logged{0}; + if (logged.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] d3d12_xs: %u waits in a row timed out: every wait gets %u ms until one " + "cut short is met (addresses met before keep %u ms)\n", timeouts_in_a_row_, + kDemotedTimeoutMs, full); + } + bool watched = false; + for (const Wait& wait : gate.waits) { + if (met_now(wait)) continue; + if (gate.cut_short && !watched && late_.size() < kMaxLate) { + late_.push_back({wait, gate.since + std::chrono::milliseconds(full)}); + watched = true; + } + Streak* streak = find_streak(wait.address); + if (!streak) streak = add_streak(wait.address); + ++streak->timeouts; + std::uint64_t now = 0; + read_value(wait.address, wait.wide, now); + if (!streak->logged) { + streak->logged = true; + static std::atomic addresses{0}; + if (addresses.fetch_add(1, std::memory_order_relaxed) < 16) + std::fprintf(stderr, + "[rt] d3d12_xs: a queue stood %u ms at a wait for 0x%llx (%u-bit, comparison %u, " + "reference 0x%llx, memory 0x%llx); it runs on (logged once per address)\n", + gate.cut_short ? kDemotedTimeoutMs : full, + static_cast(wait.address), wait.wide ? 64u : 32u, + wait.comparison, static_cast(wait.reference), + static_cast(now)); + } + if (streak->timeouts == kDemoteAfter) { + static std::atomic demoted{0}; + if (demoted.fetch_add(1, std::memory_order_relaxed) < 16) + std::fprintf(stderr, "[rt] d3d12_xs: the wait for 0x%llx timed out %u times in a row; it gets " + "%u ms until it is met again\n", + static_cast(wait.address), kDemoteAfter, kDemotedTimeoutMs); + } + } + } + + std::mutex mutex_; // the lists below; never held while a fence is signalled or a write lands + std::once_flag start_; + HANDLE wake_ = nullptr; + HANDLE timer_ = nullptr; + HANDLE thread_ = nullptr; + HANDLE releaser_ = nullptr; + std::atomic timeout_ms_{200}; + std::deque writes_; + std::deque gates_; + std::vector streaks_; + std::vector late_; + std::uint64_t use_clock_ = 0; + unsigned timeouts_in_a_row_ = 0; // gates that timed out since one was met + bool demoted_ = false; // every wait gets the short timeout until one is met + bool busy_ = false; // a pass is landing or handing over what it took off the lists + unsigned logged_met_ = 0; + Clock::time_point next_summary_ = Clock::now() + std::chrono::seconds(10); // the pump thread's only + std::mutex release_mutex_; // releases_ and releasing_ + std::condition_variable release_ready_; + std::deque releases_; + bool releasing_ = false; + std::atomic signal_since_ms_{0}; // GetTickCount64 when the releaser's current Signal began, or 0 + std::atomic signal_value_{0}; + std::atomic releaser_tid_{0}; + bool stall_logged_ = false; // the pump thread's only + std::mutex settle_mutex_; // the caller's-thread settling without threads (start_or_settle) + std::atomic exiting_{false}; // stop() ran + std::atomic stop_{false}; // the threads end +}; + +// What a console list set since its last Reset, so the next part of a list cut at a wait starts with it: a D3D12 +// list starts from defaults, and a draw after the wait would otherwise run without the pipeline, root arguments, +// targets or viewports the title set before the wait. Every value is what the real list received (already translated +// by the proxy: real heaps, device addresses, layer descriptor handles). A bundle's state is kept too: what it sets +// stays set in the list that executes it (inherit). +// shortcut: render targets are set again from their descriptor handles, so a descriptor the title rewrote since it +// set the targets names the new view, not the one set. +class ListState { +public: + enum RootKind : std::uint8_t { kNone, kTable, kCbv, kSrv, kUav }; + + ListState() = default; + ListState(const ListState&) = delete; + ListState& operator=(const ListState&) = delete; + + void clear() { + set_ = 0; + viewport_count_ = scissor_count_ = heap_count_ = 0; + vb_mask_ = so_mask_ = 0; + for (Side& side : sides_) side.clear(); + } + + void pipeline(std::uint64_t pso) { + pso_ = pso; + set_ |= kPipeline; + } + void topology(std::uint64_t topology) { + topology_ = topology; + set_ |= kTopology; + } + void stencil_ref(std::uint64_t ref) { + stencil_ = ref; + set_ |= kStencil; + } + void blend_factor(const FLOAT* factor) { + set_ |= kBlend; + blend_null_ = !factor; + if (factor) std::memcpy(blend_, factor, sizeof(blend_)); + } + void viewports(UINT count, const D3D12_VIEWPORT* viewports) { + viewport_count_ = viewports ? (std::min)(count, UINT(kMaxViewports)) : 0; + if (viewport_count_) std::memcpy(viewports_, viewports, viewport_count_ * sizeof(D3D12_VIEWPORT)); + } + void scissors(UINT count, const D3D12_RECT* rects) { + scissor_count_ = rects ? (std::min)(count, UINT(kMaxViewports)) : 0; + if (scissor_count_) std::memcpy(scissors_, rects, scissor_count_ * sizeof(D3D12_RECT)); + } + void heaps(UINT count, const std::uint64_t* real_heaps) { + heap_count_ = real_heaps ? (std::min)(count, 2u) : 0; + for (UINT i = 0; i < heap_count_; ++i) heaps_[i] = reinterpret_cast(real_heaps[i]); + } + // A different root signature leaves the side's arguments undefined (D3D12): they are forgotten. + void root_signature(bool graphics, std::uint64_t signature) { + Side& side = sides_[graphics]; + if (!side.signature_set || side.signature != signature) side.clear(); + side.signature_set = true; + side.signature = signature; + } + void root_arg(bool graphics, UINT index, RootKind kind, std::uint64_t value) { + if (index >= kMaxRootArgs) return; + Side& side = sides_[graphics]; + side.kinds[index] = kind; + side.values[index] = value; + side.arg_mask |= std::uint64_t{1} << index; + } + // A root signature holds at most 64 DWORDs, so no constant sits at an offset of 64 or more. + void root_constants(bool graphics, UINT index, UINT count, const std::uint32_t* values, UINT offset) { + if (!values || index >= kMaxRootArgs || offset >= kMaxConstants) return; + count = (std::min)(count, kMaxConstants - offset); + if (!count) return; + Side& side = sides_[graphics]; + std::unique_ptr& row = side.constants[index]; + if (!row) row.reset(new (std::nothrow) std::uint32_t[kMaxConstants]); + if (!row) return; + std::memcpy(row.get() + offset, values, count * sizeof(std::uint32_t)); + side.constant_mask[index] |= (count == 64 ? ~std::uint64_t{0} : ((std::uint64_t{1} << count) - 1)) << offset; + side.constant_params |= std::uint64_t{1} << index; + } + void index_buffer(const D3D12_INDEX_BUFFER_VIEW* view) { + set_ |= kIndexBuffer; + ib_null_ = !view; + if (view) ib_ = *view; + } + void vertex_buffers(UINT start, UINT count, const D3D12_VERTEX_BUFFER_VIEW* views) { + for (UINT i = 0; i < count && start + i < kMaxVertexBuffers; ++i) { + vbs_[start + i] = views ? views[i] : D3D12_VERTEX_BUFFER_VIEW{}; + vb_mask_ |= 1u << (start + i); + } + } + void so_targets(UINT start, UINT count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) { + for (UINT i = 0; i < count && start + i < kMaxSoTargets; ++i) { + so_[start + i] = views ? views[i] : D3D12_STREAM_OUTPUT_BUFFER_VIEW{}; + so_mask_ |= 1u << (start + i); + } + } + void render_targets(UINT count, const D3D12_CPU_DESCRIPTOR_HANDLE* rtvs, BOOL single, + const D3D12_CPU_DESCRIPTOR_HANDLE* dsv) { + set_ |= kTargets; + rt_single_ = single; + rt_count_ = rtvs ? (std::min)(count, UINT(D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT)) : 0; + const UINT handles = rt_single_ ? (rt_count_ ? 1u : 0u) : rt_count_; + for (UINT i = 0; i < handles; ++i) rtvs_[i] = rtvs[i]; + rt_has_dsv_ = dsv != nullptr; + if (dsv) dsv_ = *dsv; + } + void predication(std::uint64_t resource, std::uint64_t offset, std::uint64_t operation) { + set_ |= kPredication; + predication_[0] = resource; + predication_[1] = offset; + predication_[2] = operation; + } + + // ExecuteBundle: what the bundle set stays set in this list afterwards (its pipeline, topology, blend factor, + // stencil reference, input buffers, root signatures and root arguments; a bundle starts with this list's + // descriptor heaps and cannot set targets, viewports, stream output or predication). A bundle that sets no root + // signature works on this list's, whose arguments it changes. + void inherit(const ListState& bundle) { + if (bundle.set_ & kPipeline) pipeline(bundle.pso_); + if (bundle.set_ & kTopology) topology(bundle.topology_); + if (bundle.set_ & kStencil) stencil_ref(bundle.stencil_); + if (bundle.set_ & kBlend) blend_factor(bundle.blend_null_ ? nullptr : bundle.blend_); + if (bundle.set_ & kIndexBuffer) index_buffer(bundle.ib_null_ ? nullptr : &bundle.ib_); + for (UINT i = 0; i < kMaxVertexBuffers; ++i) + if (bundle.vb_mask_ >> i & 1) vertex_buffers(i, 1, &bundle.vbs_[i]); + for (int graphics = 0; graphics < 2; ++graphics) { + const Side& from = bundle.sides_[graphics]; + if (from.signature_set) root_signature(graphics, from.signature); + for (UINT index = 0; index < kMaxRootArgs; ++index) + if (from.arg_mask >> index & 1) + root_arg(graphics, index, static_cast(from.kinds[index]), from.values[index]); + for (UINT index = 0; index < kMaxRootArgs; ++index) { + const std::uint64_t mask = from.constant_mask[index]; + if (!(from.constant_params >> index & 1) || !mask) continue; + for (UINT offset = 0; offset < kMaxConstants; ++offset) + if (mask >> offset & 1) root_constants(graphics, index, 1, &from.constants[index][offset], offset); + } + } + } + + // Sets everything recorded on `list`, a list fresh from Reset: heaps and root signatures before the arguments + // that depend on them. + void replay(ID3D12GraphicsCommandList* list) const { + if (heap_count_) list->SetDescriptorHeaps(heap_count_, heaps_); + for (int graphics = 0; graphics < 2; ++graphics) { + const Side& side = sides_[graphics]; + if (side.signature_set) { + auto* signature = reinterpret_cast(side.signature); + graphics ? list->SetGraphicsRootSignature(signature) : list->SetComputeRootSignature(signature); + } + for (UINT index = 0; index < kMaxRootArgs; ++index) { + if (!(side.arg_mask >> index & 1)) continue; + const std::uint64_t value = side.values[index]; + switch (side.kinds[index]) { + case kTable: + graphics ? list->SetGraphicsRootDescriptorTable(index, D3D12_GPU_DESCRIPTOR_HANDLE{value}) + : list->SetComputeRootDescriptorTable(index, D3D12_GPU_DESCRIPTOR_HANDLE{value}); + break; + case kCbv: + graphics ? list->SetGraphicsRootConstantBufferView(index, value) + : list->SetComputeRootConstantBufferView(index, value); + break; + case kSrv: + graphics ? list->SetGraphicsRootShaderResourceView(index, value) + : list->SetComputeRootShaderResourceView(index, value); + break; + case kUav: + graphics ? list->SetGraphicsRootUnorderedAccessView(index, value) + : list->SetComputeRootUnorderedAccessView(index, value); + break; + default: + break; + } + } + // Each run of constants set in one call (one constant: the single setter). + for (UINT index = 0; index < kMaxRootArgs; ++index) { + const std::uint64_t mask = side.constant_mask[index]; + if (!(side.constant_params >> index & 1) || !mask) continue; + const std::uint32_t* row = side.constants[index].get(); + for (UINT offset = 0; offset < kMaxConstants;) { + if (!(mask >> offset & 1)) { + ++offset; + continue; + } + UINT end = offset + 1; + while (end < kMaxConstants && (mask >> end & 1)) ++end; + if (end - offset == 1) { + graphics ? list->SetGraphicsRoot32BitConstant(index, row[offset], offset) + : list->SetComputeRoot32BitConstant(index, row[offset], offset); + } else { + graphics ? list->SetGraphicsRoot32BitConstants(index, end - offset, row + offset, offset) + : list->SetComputeRoot32BitConstants(index, end - offset, row + offset, offset); + } + offset = end; + } + } + } + if (set_ & kPipeline) list->SetPipelineState(reinterpret_cast(pso_)); + if (set_ & kTopology) list->IASetPrimitiveTopology(static_cast(topology_)); + if (viewport_count_) list->RSSetViewports(viewport_count_, viewports_); + if (scissor_count_) list->RSSetScissorRects(scissor_count_, scissors_); + if (set_ & kBlend) list->OMSetBlendFactor(blend_null_ ? nullptr : blend_); + if (set_ & kStencil) list->OMSetStencilRef(static_cast(stencil_)); + if (set_ & kIndexBuffer) list->IASetIndexBuffer(ib_null_ ? nullptr : &ib_); + for (UINT i = 0; i < kMaxVertexBuffers; ++i) + if (vb_mask_ >> i & 1) list->IASetVertexBuffers(i, 1, &vbs_[i]); + for (UINT i = 0; i < kMaxSoTargets; ++i) + if (so_mask_ >> i & 1) list->SOSetTargets(i, 1, &so_[i]); + if (set_ & kTargets) + list->OMSetRenderTargets(rt_count_, rt_count_ ? rtvs_ : nullptr, rt_single_, + rt_has_dsv_ ? &dsv_ : nullptr); + if (set_ & kPredication) + list->SetPredication(reinterpret_cast(predication_[0]), predication_[1], + static_cast(predication_[2])); + } + +private: + static constexpr UINT kMaxViewports = D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; + static constexpr UINT kMaxRootArgs = 64; + static constexpr UINT kMaxConstants = 64; // DWORDs of one root parameter + static constexpr UINT kMaxVertexBuffers = 32; + static constexpr UINT kMaxSoTargets = 4; + enum : std::uint32_t { + kPipeline = 1, kTopology = 2, kStencil = 4, kBlend = 8, kIndexBuffer = 16, kTargets = 32, kPredication = 64, + }; + struct Side { + bool signature_set = false; + std::uint64_t signature = 0; + std::uint64_t arg_mask = 0; + std::uint64_t values[kMaxRootArgs]; + std::uint8_t kinds[kMaxRootArgs]; + // Root constants by parameter and offset: a row of 64 DWORDs per parameter, made at its first constant and + // kept across Resets; `constant_mask` says which DWORDs of it are set. + std::uint64_t constant_params = 0; + std::uint64_t constant_mask[kMaxRootArgs] = {}; + std::unique_ptr constants[kMaxRootArgs]; + void clear() { + signature_set = false; + arg_mask = 0; + for (UINT index = 0; index < kMaxRootArgs; ++index) + if (constant_params >> index & 1) constant_mask[index] = 0; + constant_params = 0; + } + }; + + std::uint32_t set_ = 0; + std::uint64_t pso_ = 0, topology_ = 0, stencil_ = 0; + FLOAT blend_[4] = {}; + bool blend_null_ = false, ib_null_ = false, rt_has_dsv_ = false; + BOOL rt_single_ = FALSE; + UINT viewport_count_ = 0, scissor_count_ = 0, heap_count_ = 0, rt_count_ = 0; + D3D12_VIEWPORT viewports_[kMaxViewports]; + D3D12_RECT scissors_[kMaxViewports]; + ID3D12DescriptorHeap* heaps_[2] = {}; + Side sides_[2]; + D3D12_INDEX_BUFFER_VIEW ib_{}; + std::uint32_t vb_mask_ = 0, so_mask_ = 0; + D3D12_VERTEX_BUFFER_VIEW vbs_[kMaxVertexBuffers]; + D3D12_STREAM_OUTPUT_BUFFER_VIEW so_[kMaxSoTargets]; + D3D12_CPU_DESCRIPTOR_HANDLE rtvs_[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT] = {}; + D3D12_CPU_DESCRIPTOR_HANDLE dsv_{}; + std::uint64_t predication_[3] = {}; +}; + +} // namespace rt::d3d12_xs::list_values diff --git a/runtime/shims/dstorage.cpp b/runtime/shims/dstorage.cpp index 7f4cef9d94..fe800fe686 100644 --- a/runtime/shims/dstorage.cpp +++ b/runtime/shims/dstorage.cpp @@ -34,6 +34,7 @@ #include "../src/shader_library.h" // leonida::zlib_inflate #include "../src/title_page_watch.h" // title_gpu_views, title_texel_writes, kernel_writes #include "../src/bcpack.h" +#include "../src/guarded_copy.h" #include "../src/shader_directory.h" #include "../src/dstorage_swizzle.h" #include "../src/dstorage_trace.h" @@ -405,10 +406,11 @@ File* live_file(IDStorageFileX* p) { // ---- Reads -------------------------------------------------------------------------------------------------------- // memmove that turns an access violation into an error instead of ending the process. No C++ objects here: a -// function with __try cannot have any that need unwinding. +// function with __try cannot have any that need unwinding. The bytes move in leonida::guarded::move, not the CRT's +// memmove: under Wine a fault inside ucrtbase never reaches this __except (src/guarded_copy.h). bool guarded_move(void* destination, const void* source, size_t size) { __try { - std::memmove(destination, source, size); + leonida::guarded::move(destination, source, size); return true; } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { @@ -429,6 +431,14 @@ void touch_pages(void* buffer, size_t size) { } } +// A copy into a request's destination, title memory: through kernel_writes like the file reads into it, so a page the +// D3D12 layer keeps read-only (a slot-133 shadow's guard, a geometry tile's) is opened and pinned first, and the GPU +// copies of it take the bytes at the next submission. A copy that faults anyway is retried once after the range is +// reopened (title_page_watch.h); false only when it still faults. +bool title_write(void* destination, const void* source, size_t size) { + return leonida::kernel_writes::write(destination, source, size); +} + HRESULT read_error(DWORD error) { switch (error) { case ERROR_NOACCESS: @@ -1042,7 +1052,7 @@ class Queue final : public IDStorageQueueX2 { void* const destination = cpu_destination(r); if (memory) { const auto begin = Timing::start(); - const auto hr = written(r, guarded_move(destination, r.Source, r.SourceSize) ? S_OK : E_DSTORAGE_ACCESS_VIOLATION); + const auto hr = written(r, title_write(destination, r.Source, r.SourceSize) ? S_OK : E_DSTORAGE_ACCESS_VIOLATION); e.timing.copy = Timing::elapsed(begin); if (FAILED(hr)) e.reason = "copy"; return hr; @@ -1187,7 +1197,7 @@ class Queue final : public IDStorageQueueX2 { e.reason = "destination-commit"; return E_DSTORAGE_ACCESS_VIOLATION; } - hr = written(r, guarded_move(dest, data.data(), data.size()) ? S_OK : E_DSTORAGE_ACCESS_VIOLATION); + hr = written(r, title_write(dest, data.data(), data.size()) ? S_OK : E_DSTORAGE_ACCESS_VIOLATION); } e.timing.copy = Timing::elapsed(copy_begin); if (FAILED(hr)) e.reason = "publish"; diff --git a/runtime/shims/placed_image_map_note.h b/runtime/shims/placed_image_map_note.h new file mode 100644 index 0000000000..602cfe9eda --- /dev/null +++ b/runtime/shims/placed_image_map_note.h @@ -0,0 +1,84 @@ +// Diagnostics for the address a title reads after mapping a placed image. +// The exposure lock passes its computed mip offset in D3D12_RANGE::Begin. +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace rt::placed_image_map_note { + +// XMem writers are serialized by the fault lock. Never wait for that lock in +// a diagnostic; a concurrent reservation change is reported as unknown. +inline std::atomic generation{}, gpu{}, cpu{}, size{}; +inline void publish_pair(uint64_t gpu_base, uint64_t cpu_base, uint64_t bytes) { + ++generation; + gpu = gpu_base; + cpu = cpu_base; + size = bytes; + ++generation; +} + +inline bool title_pointer(uintptr_t address, uintptr_t& result) { + const auto before = generation.load(); + const auto g = gpu.load(), c = cpu.load(), n = size.load(); + result = g && address >= g && address - g < n ? c + (address - g) : address; + return !(before & 1) && generation.load() == before; +} + +enum class Reason { readable, unbacked, inaccessible, invalid, empty, unspecified, unknown, count }; + +inline Reason classify(uintptr_t start, size_t bytes) { + if (!bytes) return Reason::empty; + if (bytes - 1 > UINTPTR_MAX - start) return Reason::invalid; + // Bound query cost on fragmented reservations. Never probe the bytes. + for (unsigned i = 0; i < 8; ++i) { + MEMORY_BASIC_INFORMATION m{}; + if (!VirtualQuery(reinterpret_cast(start), &m, sizeof(m))) return Reason::unknown; + if (m.State != MEM_COMMIT) return Reason::unbacked; + if ((m.Protect & PAGE_GUARD) || !(m.Protect & (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | + PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY))) return Reason::inaccessible; + const auto remaining = m.RegionSize - (start - reinterpret_cast(m.BaseAddress)); + if (bytes <= remaining) return Reason::readable; + bytes -= remaining; + start += remaining; + } + return Reason::unknown; +} + +inline void note(void* pointer, unsigned subresource, const D3D12_RANGE* range, bool exposure_shape) { + const DWORD saved_error = GetLastError(); + const auto raw = reinterpret_cast(pointer); + const auto begin = range ? range->Begin : 0, end = range ? range->End : 0; + uintptr_t title{}; + Reason why = Reason::unspecified; + if (range) { + if (begin > UINTPTR_MAX - raw) why = Reason::invalid; + else if (!title_pointer(raw + begin, title)) why = Reason::unknown; + else if (begin > end) why = Reason::invalid; + else why = classify(title, end - begin); + } + // Common images must not exhaust the exposure samples before world start. + static std::atomic counts[2][unsigned(Reason::count)]{}; + auto& count = counts[exposure_shape][unsigned(why)]; + if (count.load(std::memory_order_relaxed) < 16 && count.fetch_add(1, std::memory_order_relaxed) < 16) { + constexpr std::string_view names[]{"readable", "uncommitted", "inaccessible", "invalid-range", + "empty-range", "unspecified-range", "unknown"}; + char line[320]; + char* p = line; + auto put = [&](std::string_view s) { for (char ch : s) *p++ = ch; }; + auto hex = [&](uintptr_t n) { put("0x"); p = std::to_chars(p, line + sizeof(line), n, 16).ptr; }; + put("[rt] placed-image Map "); put(names[unsigned(why)]); + put(exposure_shape ? " exposure-shape raw=" : " raw="); hex(raw); + put(" subresource="); hex(subresource); + put(" begin="); hex(begin); put(" end="); hex(end); + put(" title="); hex(title); put("\n"); + DWORD written{}; + WriteFile(GetStdHandle(STD_ERROR_HANDLE), line, static_cast(p - line), &written, nullptr); + } + SetLastError(saved_error); +} +} // namespace rt::placed_image_map_note diff --git a/runtime/shims/startup_trace.h b/runtime/shims/startup_trace.h index e6dd3c4737..6be16118be 100644 --- a/runtime/shims/startup_trace.h +++ b/runtime/shims/startup_trace.h @@ -227,6 +227,23 @@ inline void log_exception(const EXCEPTION_POINTERS& info) { ",\"allocation_base\":" + quote(hex(reinterpret_cast(m.AllocationBase))) + ",\"size\":" + quote(hex(m.RegionSize)) + ",\"state\":" + quote(hex(m.State)) + ",\"protect\":" + quote(hex(m.Protect)) + ",\"type\":" + quote(hex(m.Type)) + "}"; + // The runs the fault page's neighbours sit in: a writable run that ends mid-granule is a commit + // shorter than the console's 64 KiB granule, a run that ends at a granule boundary is not. VirtualQuery + // reports each from the page asked about (its BaseAddress is that page), so a run is the page, the + // allocation it belongs to and how far the run goes from there ("size"). + std::string runs; + const uintptr_t page = static_cast(r.ExceptionInformation[1]) & ~uintptr_t(0xfff); + for (int i = -1; i <= 1; ++i) { + const uintptr_t at = page + static_cast(static_cast(i)) * 0x1000; + MEMORY_BASIC_INFORMATION n{}; + if (!VirtualQuery(reinterpret_cast(at), &n, sizeof(n))) continue; + if (!runs.empty()) runs += ","; + runs += "{\"at\":" + quote(hex(at)) + ",\"allocation_base\":" + + quote(hex(reinterpret_cast(n.AllocationBase))) + ",\"size\":" + + quote(hex(n.RegionSize)) + ",\"state\":" + quote(hex(n.State)) + ",\"protect\":" + + quote(hex(n.Protect)) + ",\"type\":" + quote(hex(n.Type)) + "}"; + } + if (!runs.empty()) f += ",\"runs\":[" + runs + "]"; } if (r.ExceptionCode == kCppException) f += ",\"cpp\":true"; if (info.ContextRecord) { diff --git a/runtime/shims/xg_xs_layout.h b/runtime/shims/xg_xs_layout.h index 57492f9337..36d6c0db30 100644 --- a/runtime/shims/xg_xs_layout.h +++ b/runtime/shims/xg_xs_layout.h @@ -115,11 +115,17 @@ inline uint32_t align_up(uint32_t value, uint32_t alignment) { // the base extent in elements. A slice stores the tail block, then its // unpacked mips from smallest to largest. inline bool build_texture(const ResourceDesc& desc, Texture& texture) { + // Exposure readback uses the explicit linear Series layout, including the + // console flag set by its render-target descriptor builder. + const bool linear_readback_target = (desc.flags & ~0x300000u) == kRenderTarget && + desc.dimension == kTexture2D && desc.format == DXGI_FORMAT_R32G32B32A32_FLOAT && + desc.layout == (kSwizzled | kLinear) && desc.width == 1 && desc.height == 1 && + desc.depth_or_array == 1 && desc.mips == 1; if (desc.dimension < kTexture1D || desc.dimension > kTexture3D || desc.width == 0 || desc.width > 16384 || desc.height == 0 || desc.height > 16384 || (desc.dimension == kTexture1D && desc.height != 1) || desc.depth_or_array == 0 || desc.depth_or_array > 2048 || desc.samples != 1 || desc.quality || - (desc.flags & (kRenderTarget | kDepthStencil)) || + ((desc.flags & (kRenderTarget | kDepthStencil)) && !linear_readback_target) || (desc.layout > 1 && (desc.layout & ~0x1fu) != kSwizzled)) return false; diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp index 3ccdabfe94..299ac6da79 100644 --- a/runtime/shims/xmem.cpp +++ b/runtime/shims/xmem.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include "shims.h" #include "startup_trace.h" #include "xmem.h" +#include "placed_image_map_note.h" #include "../src/dstorage_trace.h" #include "../src/gpu_label_memory.h" #include "../src/title_page_watch.h" @@ -75,7 +77,50 @@ void note_attributes(const char* api, uint64_t attributes, size_t size, const vo rt::startup_trace::event("xmem_attributes", fields); } -void* allocate_block(size_t size) { return _aligned_malloc(size ? size : 1, kAlign); } +// LEONIDA_TITLE_HEAP=1: the title's XMemAlloc blocks come from a heap of their own instead of the CRT heap. Slot-133 +// imports pin title memory page by page for the GPU, and on the CRT heap a pinned page also holds the runtime's own +// objects (g_pages' nodes among them): a GPU store past a buffer's end, or into a block freed while its import still +// lived, then corrupted the runtime (speed-30/41/49-52: g_pages found corrupt under g_phys_mutex). Each block keeps its +// size and the heap allocation it sits in just below it. +struct TitleHeapHeader { + void* raw; + size_t size; +}; +HANDLE title_heap() { + static const HANDLE heap = [] { + const char* v = std::getenv("LEONIDA_TITLE_HEAP"); + if (!v || std::strcmp(v, "1") != 0) return HANDLE(nullptr); + const HANDLE h = HeapCreate(0, 0, 0); + std::fprintf(stderr, "[rt] xmem: XMemAlloc blocks come from a heap of their own (%p)\n", h); + return h; + }(); + return heap; +} +void* allocate_block(size_t size) { + size = size ? size : 1; + const HANDLE heap = title_heap(); + if (!heap) return _aligned_malloc(size, kAlign); + const size_t extra = kAlign + sizeof(TitleHeapHeader); + if (size > SIZE_MAX - extra) return nullptr; + void* raw = HeapAlloc(heap, 0, size + extra); + if (!raw) return nullptr; + const uintptr_t user = (reinterpret_cast(raw) + sizeof(TitleHeapHeader) + kAlign - 1) & ~(kAlign - 1); + auto* header = reinterpret_cast(user) - 1; + header->raw = raw; + header->size = size; + return reinterpret_cast(user); +} +size_t block_size(void* p) { + if (!p) return 0; + if (!title_heap()) return _aligned_msize(p, kAlign, 0); + return (reinterpret_cast(p) - 1)->size; +} +void free_block(void* p) { + if (!p) return; + const HANDLE heap = title_heap(); + if (!heap) return _aligned_free(p); + HeapFree(heap, 0, (reinterpret_cast(p) - 1)->raw); +} // Every block and range the title gets here is recorded as the title's memory (src/title_va_alias.h): a shader // address into it can be given a GPU copy, and an address anywhere else cannot. @@ -85,9 +130,10 @@ void track_label_data(void* p,std::size_t bytes,bool heap) { leonida::label::memory().track(reinterpret_cast(p),bytes,reinterpret_cast(info.AllocationBase),heap); } +// A new block is no change to the title memory map: the heap's pages under it were committed and readable already, or +// were uncommitted (which the readers query again at every look) after a free that the map recorded. void* title_block(size_t size) { void* p = allocate_block(size); - if (p) leonida::title_memory_map::changed(); leonida::title_va_aliases().add_title_memory(reinterpret_cast(p), size ? size : 1); track_label_data(p,size?size:1,true); return p; @@ -96,8 +142,9 @@ void* title_block(size_t size) { void free_title_block(void* p) { if(p)leonida::label::memory().release_heap(reinterpret_cast(p)); if (p) leonida::title_va_aliases().remove_title_memory(reinterpret_cast(p)); - _aligned_free(p); - if (p) leonida::title_memory_map::changed(); + const size_t size = block_size(p); + free_block(p); + if (p) leonida::title_memory_map::changed(p, size ? size : 1); } void* __stdcall XMemAlloc(size_t size, uint64_t attributes) { @@ -311,17 +358,17 @@ HANDLE file_backed_section(std::uint64_t bytes) { return section; } +// A section and its scratch view: the whole section mapped once at an address the host picks, through which xmem +// commits, fills and copies the pages. The scratch view is recorded (g_scratch_views) while it is mapped. struct Section { HANDLE handle; void* scratch; bool file_backed; - Section(HANDLE h, bool use_file) : handle(h), scratch(MapViewOfFile(h, FILE_MAP_WRITE, 0, 0, 0)), file_backed(use_file) {} + std::vector> frames; + Section(HANDLE h, bool use_file = false); Section(const Section&) = delete; Section& operator=(const Section&) = delete; - ~Section() { - if (scratch) UnmapViewOfFile(scratch); - CloseHandle(handle); - } + ~Section(); }; struct PhysicalPage { @@ -336,22 +383,53 @@ constexpr uint64_t kPhysicalPageSize = 0x10000; constexpr uint64_t kFramesPerPage = kPhysicalPageSize / 0x1000; constexpr uint64_t kPageSlotLimit = uint64_t{1} << 21; +constexpr uintptr_t kTitleImage = 0x140000000; +// Only the reservations consumed by gfx_stream_pool_init_cpu_and_gpu_alias. +// Both locks protect writes; queue readers hold the physical lock, handlers the fault lock. +uintptr_t stream_cpu, stream_gpu, stream_size; +bool mirror_stream; +leonida::host_heap::map stream_offsets; std::mutex g_phys_mutex; std::map g_windows; // base -> window +// The same table for the fault handler, which may not wait for g_phys_mutex: a holder of that mutex allocates +// (g_mapped, g_windows) and the faulting title thread can hold the process heap's lock (see g_fault_lock). Host heap, +// read and written under g_fault_lock. +leonida::host_heap::map g_fault_windows; +// The title's own MEM_RESERVE_PLACEHOLDER reservations (XMemVirtualAlloc), base -> extent, under g_fault_lock and kept +// until the title releases them (TitleVirtualFree). With the windows these are the title's reserved memory: the only +// place the fault handler commits a mapped section page it has no view of (commit_title_section_page). +leonida::host_heap::map g_title_placeholders; std::unordered_map g_pages; // page number -> backing std::vector g_free_slots; uint64_t g_next_slot = 1; // A mapped run: `count` pages of one section at consecutive offsets, mapped as one view at its base. One view per run // rather than per page: under Wine each view costs a placeholder split and a section map whose time grows with the // number of views, and the retail title maps about 100,000 pages in one call. +enum class MapOwner { physical, scatter, slot31, mirror }; struct View { uint64_t count; std::shared_ptr
section; // kept for remapping part of the run after its pages are freed uint64_t offset; // section offset of the first page DWORD protect; + // The title changed the protection of some of it (VirtualProtect): reopen_unowned leaves it as it is. + bool title_protected = false; + // A zero page the fault handler planted in a window placeholder the title never mapped (map_zero_page); a mapping + // that replaces it returns its page to the zero section's free list. + bool zero = false; + MapOwner owner = MapOwner::physical; + uint64_t tick = GetTickCount64(); }; leonida::host_heap::map g_views; // view base -> view; host_heap: see g_fault_lock +// The zero page a planted view holds, freed when a mapping replaces or unmaps it (ZeroPages, below). +void zero_page_release(const View& view); + +// Logs what the fault handler noted since the last call (FaultNote, below). +void drain_fault_notes(); + +// The fault race seam (rt::xmem::set_fault_race_hook), defined with the handler. +void fault_race_point(int stage); + // The views (g_views) as the fault handler reads them, which is all it reads: physical_page_fault takes it shared at // every access violation in the process, xmem's own or not, and so does commit_physical_range. A title thread can // take an access violation while it holds the process heap's lock (XMemAlloc is _aligned_malloc, so HeapAlloc and @@ -362,21 +440,82 @@ leonida::host_heap::map g_views; // view base -> view; host_he // and nothing under it reads title memory, which could fault into the handler on the same thread. SRWLOCK g_fault_lock = SRWLOCK_INIT; +// This thread's hold on g_fault_lock. The lock is not recursive: a fault this thread takes while it holds it (shared +// or exclusive) is left to the next handler rather than waited for, which would wait for itself; and a Section dropped +// under the exclusive lock unregisters its scratch view without taking it again. +thread_local int t_fault_lock_held = 0; +thread_local bool t_fault_lock_exclusive = false; + struct FaultLockExclusive { - FaultLockExclusive() { AcquireSRWLockExclusive(&g_fault_lock); } - ~FaultLockExclusive() { ReleaseSRWLockExclusive(&g_fault_lock); } + FaultLockExclusive() { + AcquireSRWLockExclusive(&g_fault_lock); + ++t_fault_lock_held; + t_fault_lock_exclusive = true; + } + ~FaultLockExclusive() { + t_fault_lock_exclusive = false; + --t_fault_lock_held; + ReleaseSRWLockExclusive(&g_fault_lock); + } FaultLockExclusive(const FaultLockExclusive&) = delete; FaultLockExclusive& operator=(const FaultLockExclusive&) = delete; }; struct FaultLockShared { - FaultLockShared() { AcquireSRWLockShared(&g_fault_lock); } - ~FaultLockShared() { ReleaseSRWLockShared(&g_fault_lock); } + FaultLockShared() { + AcquireSRWLockShared(&g_fault_lock); + ++t_fault_lock_held; + } + ~FaultLockShared() { + --t_fault_lock_held; + ReleaseSRWLockShared(&g_fault_lock); + } FaultLockShared(const FaultLockShared&) = delete; FaultLockShared& operator=(const FaultLockShared&) = delete; - }; +// The scratch views of xmem's sections (Section::scratch: each physical-page allocation's whole section, and the zero +// pool's), by base, under g_fault_lock. Host memory, not the title's: the fault handler never commits a page of one +// (commit_title_section_page), so a wild write into a section's pages through its mirror still faults. +// Never destroyed: the sections the tables declared before it hold (g_pages, g_views) drop their scratch views from it +// during the static destruction at exit, after a table declared here would be gone. +using AddressTable = std::set, leonida::host_heap::Allocator>; +alignas(AddressTable) unsigned char g_scratch_views_storage[sizeof(AddressTable)]; +AddressTable& g_scratch_views = *new (g_scratch_views_storage) AddressTable(); + +// With g_fault_lock held exclusively. +void note_scratch_locked(void* scratch, bool mapped) { + if (!scratch) return; + if (mapped) + g_scratch_views.insert(reinterpret_cast(scratch)); + else + g_scratch_views.erase(reinterpret_cast(scratch)); +} + +// From any thread: under the exclusive lock already held (a zero section made in the fault handler, a section whose +// last view an unmap drops), or by taking it. A thread holding it shared never makes or drops a section. +void note_scratch(void* scratch, bool mapped) { + if (t_fault_lock_exclusive) { + note_scratch_locked(scratch, mapped); + } else if (!t_fault_lock_held) { + const FaultLockExclusive lock; + note_scratch_locked(scratch, mapped); + } +} + +Section::Section(HANDLE h, bool use_file) + : handle(h), scratch(MapViewOfFile(h, FILE_MAP_WRITE, 0, 0, 0)), file_backed(use_file) { + note_scratch(scratch, true); +} + +Section::~Section() { + if (scratch) { + note_scratch(scratch, false); // before the address can be handed out again + UnmapViewOfFile(scratch); + } + CloseHandle(handle); +} + // With g_phys_mutex held; changed under g_fault_lock too (unmap_range), so they allocate from host_heap. template using HostUnorderedMap = @@ -384,6 +523,14 @@ using HostUnorderedMap = using AddressSet = std::set, leonida::host_heap::Allocator>; HostUnorderedMap g_mapped; // mapped 64 KiB address -> page number HostUnorderedMap g_page_addresses; // page number -> the addresses it is mapped at +// The same aliases, for readers that must not wait behind g_phys_mutex (geometry_aliases, from the D3D12 layer's +// submission thread: speed-16 and re-1 had it waiting there behind the streaming workers' scatter batches and the +// render thread's queue slot 31, which hold g_phys_mutex through every MapViewOfFile3). Only addresses whose page is +// mapped at another address too are in it, each with those other addresses. Written by note_mapping (g_phys_mutex +// held) under g_alias_lock exclusive, read under it shared. +std::shared_mutex g_alias_lock; +using AddressList = std::vector>; +HostUnorderedMap g_alias_peers; // With g_phys_mutex held. Keeps leonida::title_page_aliases in step: a page mapped at two or more addresses is // aliased at each of them (the D3D12 layer's slot-133 shadows copy those pages at every submission instead of @@ -404,21 +551,63 @@ void note_mapping(uint64_t page, uintptr_t address, bool mapped) { } const bool aliased = addresses.size() > 1; for (const uintptr_t at : addresses) leonida::title_page_aliases::set(at, aliased); + const std::unique_lock aliases(g_alias_lock); + if (!mapped) g_alias_peers.erase(address); + for (const uintptr_t at : addresses) { + if (!aliased) { + g_alias_peers.erase(at); + continue; + } + AddressList& peers = g_alias_peers[at]; + peers.clear(); + for (const uintptr_t other : addresses) + if (other != at) peers.push_back(other); + } if (addresses.empty()) g_page_addresses.erase(page); } -// With g_phys_mutex held. A window replaces every window it overlaps: the title released those regions before -// the host could hand the addresses out again. -void record_window(void* base, SIZE_T size, DWORD protect) { - const uintptr_t start = reinterpret_cast(base); - const uintptr_t end = start + size; - auto it = g_windows.lower_bound(start); - if (it != g_windows.begin()) { - const auto prev = std::prev(it); - if (prev->first + prev->second.size > start) it = prev; - } - while (it != g_windows.end() && it->first < end) it = g_windows.erase(it); - g_windows[start] = Window{size, protect}; +// Appends `value` in hex (with 0x) or decimal at `at`, which has room for it: no CRT, so no lock and no allocation. +char* append_number(char* at, unsigned long long value, bool hex) { + char digits[24]; + int count = 0; + do { + const unsigned digit = static_cast(value % (hex ? 16 : 10)); + digits[count++] = static_cast(digit < 10 ? '0' + digit : 'a' + digit - 10); + value /= hex ? 16 : 10; + } while (value); + if (hex) { + *at++ = '0'; + *at++ = 'x'; + } + while (count) *at++ = digits[--count]; + return at; +} + +char* append_text(char* at, const char* text) { + while (*text) *at++ = *text++; + return at; +} + +// Fixed labels and at most three ranges per line fit in the caller's 512-byte buffer. +char* append_window(char* out, uintptr_t base, const Window& window) { + out = append_number(append_text(out, "["), base, true); + out = append_number(append_text(out, ","), base + window.size, true); + return append_number(append_text(out, ") prot="), window.protect, true); +} + +void write_window_note(char* line, char* end) { + *end++ = '\n'; + DWORD written; + WriteFile(GetStdHandle(STD_ERROR_HANDLE), line, static_cast(end - line), &written, nullptr); +} + +void note_window_change(uintptr_t old_base, const Window& old_window, uintptr_t start, SIZE_T size, + DWORD protect, const void* caller, bool release = false) { + char line[512]; + char* out = append_window(append_text(line, "[rt] xmem: old window "), old_base, old_window); + out = append_window(append_text(out, release ? " release " : " new window "), start, Window{size, protect}); + out = append_number(append_text(out, " caller="), reinterpret_cast(caller), true); + write_window_note(line, out); } // With g_phys_mutex held: the window holding [address, address + bytes), if one does. @@ -431,6 +620,76 @@ const Window* find_window(uintptr_t address, uint64_t bytes) { return &it->second; } +// The entry of a base -> Window table that holds `address`, if one does. +template +const Window* table_entry(const Table& table, uintptr_t address) { + auto it = table.upper_bound(address); + if (it == table.begin()) return nullptr; + --it; + return address - it->first < it->second.size ? &it->second : nullptr; +} + +// Does an entry of `table` overlap [start, end)? +template +bool table_overlaps(const Table& table, uintptr_t start, uintptr_t end) { + auto it = table.lower_bound(end); + if (it == table.begin()) return false; + --it; + return it->first + it->second.size > start; +} + +// Removes [start, end) from `table`: an entry inside it goes, one reaching past either end keeps the part outside. +template +void forget_range(Table& table, uintptr_t start, uintptr_t end, bool keep_outside = true) { + auto it = table.upper_bound(start); + if (it != table.begin()) { + const auto prev = std::prev(it); + if (prev->first + prev->second.size > start) it = prev; + } + while (it != table.end() && it->first < end) { + const uintptr_t base = it->first; + const Window entry = it->second; + const uintptr_t entry_end = base + entry.size; + it = table.erase(it); + if (keep_outside && base < start) table.emplace(base, Window{static_cast(start - base), entry.protect}); + if (keep_outside && entry_end > end) { + table.emplace(end, Window{static_cast(entry_end - end), entry.protect}); + break; + } + } +} + +// A reserve-only replacement carves a live placeholder. Its neighbours still have their original protection. +// A fresh host reservation can instead reuse an address from a stale table entry. +template +void replace_window(Table& table, uintptr_t start, SIZE_T size, DWORD protect, bool carve) { + forget_range(table, start, start + size, carve); + table.emplace(start, Window{size, protect}); +} + +// With g_phys_mutex held. The fault table is changed under exclusive ownership across the host split. +void record_window(void* base, SIZE_T size, DWORD protect, const void* caller, bool carve) { + const uintptr_t start = reinterpret_cast(base); + auto it = g_windows.lower_bound(start); + if (it != g_windows.begin()) --it; + for (; it != g_windows.end() && it->first < start + size; ++it) + if (it->first + it->second.size > start) + note_window_change(it->first, it->second, start, size, protect, caller); + replace_window(g_windows, start, size, protect, carve); +} + +// The window table the fault handler reads, kept in step with g_windows (declared with it above). +// With g_fault_lock held: the window holding `address`, if one does. +const Window* fault_window(uintptr_t address) { return table_entry(g_fault_windows, address); } + +// With g_fault_lock held: is `address` inside a window? +bool in_window(uintptr_t address) { return fault_window(address) != nullptr; } + +// With g_fault_lock held: is `address` in memory the title reserved, a window or a placeholder of its own? +bool in_title_reservation(uintptr_t address) { + return in_window(address) || table_entry(g_title_placeholders, address) != nullptr; +} + // [address, address + size) as one placeholder of its own: split it out of the placeholder that holds it. Fails when // the range is not inside one placeholder. bool isolate_placeholder(void* address, SIZE_T size) { @@ -441,7 +700,7 @@ bool isolate_placeholder(void* address, SIZE_T size) { } if (info.AllocationBase == address && info.RegionSize == size) return true; if (!VirtualFree(address, size, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)) return false; - leonida::title_memory_map::changed(); + leonida::title_memory_map::changed(address, size); return true; } @@ -503,15 +762,25 @@ void note_unwatched_change(const void* address, SIZE_T size, DWORD type, bool de // XMemMapPhysicalPages. The guest page size sets the alignment and rounding of the region; the host's own pages stay // 4 KiB (host large pages need SeLockMemoryPrivilege). A 2 MiB region the host places is reserved 2 MiB-aligned through // VirtualAlloc2. -void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect); +void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect, const void* caller); void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect) { + drain_fault_notes(); note_attributes("XMemVirtualAlloc", attributes, size, _ReturnAddress()); - void* result = xmem_virtual_alloc(address, size, allocation_type, attributes, protect); + void* result = xmem_virtual_alloc(address, size, allocation_type, attributes, protect, _ReturnAddress()); + // Diagnostic: the title's large regions (windows and placeholders log their own), so a fault left to the title can + // be matched to the region it is in. + static std::atomic shown{0}; + const bool logs_itself = (allocation_type & MEM_RESERVE_PLACEHOLDER) || + ((allocation_type & kXmemPageModeMask) && !(allocation_type & MEM_COMMIT)); + if (result && size >= (64u << 20) && !logs_itself && shown.fetch_add(1, std::memory_order_relaxed) < 64) + std::fprintf(stderr, "[rt] xmem: XMemVirtualAlloc %p size %llu type 0x%lx protect 0x%lx\n", result, + static_cast(size), static_cast(allocation_type), + static_cast(protect)); // The title's memory (src/title_va_alias.h). Never forgotten: a released range is no longer committed, which // the copy also checks. if (result) { - leonida::title_memory_map::changed(); + leonida::title_memory_map::changed(result, size); leonida::title_va_aliases().add_title_memory(reinterpret_cast(result), size); note_unwatched_change(address, size, allocation_type, false); if (allocation_type & MEM_RESERVE) { @@ -519,6 +788,9 @@ void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type, leonida::geometry_writes::notify(from, from + size, leonida::geometry_writes::Event::replaced); } } + if (result && allocation_type == 0x20402000) + rt::xmem::note_stream_reservation(reinterpret_cast(result), size, + reinterpret_cast(_ReturnAddress()) - kTitleImage); // A reservation: a GPU-only one (no CPU access, PAGE_GRAPHICS_* bits) is paired with the CPU-mappable one of the // same size made just before it (src/title_page_watch.h, title_gpu_views). const DWORD host_type = allocation_type & kXmemHostAllocationTypeMask; @@ -536,7 +808,7 @@ void* WINAPI XMemVirtualAlloc(void* address, SIZE_T size, DWORD allocation_type, return result; } -void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect) { +void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULONGLONG attributes, DWORD protect, const void* caller) { if (size == 0) { SetLastError(ERROR_INVALID_PARAMETER); return nullptr; @@ -611,20 +883,46 @@ void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULON if (replace) { const std::lock_guard lock(g_phys_mutex); - if (!isolate_placeholder(address, size)) return nullptr; - if (window) { - // A reserve-only replacement stays a placeholder: the physical pages are mapped into it. - record_window(address, size, host_prot); - return address; + void* replaced = nullptr; + { + // The split, and the replacement, change pages of a placeholder of the title's: under the exclusive lock, + // as every change of xmem's to the title's reservations is, so the fault handler never decides on a page + // the host is part way through changing. + const FaultLockExclusive view_lock; + if (!isolate_placeholder(address, size)) return nullptr; + if (window) + replace_window(g_fault_windows, reinterpret_cast(address), size, host_prot, true); + else + replaced = placeholder_api().virtual_alloc2(GetCurrentProcess(), address, size, host_type | MEM_RESERVE, + host_prot, nullptr, 0); } - return placeholder_api().virtual_alloc2(GetCurrentProcess(), address, size, host_type | MEM_RESERVE, host_prot, - nullptr, 0); + if (!window) return replaced; + // A reserve-only replacement stays a placeholder: the physical pages are mapped into it. + record_window(address, size, host_prot, caller, true); + return address; } if (new_placeholder || window) { void* const result = reserve_placeholder(address, size, base_granularity); if (result && window) { const std::lock_guard lock(g_phys_mutex); - record_window(result, size, host_prot); + record_window(result, size, host_prot, caller, false); + { + const FaultLockExclusive faults; + replace_window(g_fault_windows, reinterpret_cast(result), size, host_prot, false); + } + // Diagnostic (temporary): the windows a fault can be inside. + std::fprintf(stderr, "[rt] xmem: window reserve %p size %llu protect 0x%lx\n", result, + static_cast(size), static_cast(host_prot)); + } + if (result && new_placeholder) { + const uintptr_t base = reinterpret_cast(result); + { + const FaultLockExclusive lock; + forget_range(g_title_placeholders, base, base + size); // a release the table missed + g_title_placeholders[base] = Window{size, host_prot}; + } + std::fprintf(stderr, "[rt] xmem: placeholder reserve %p size %llu\n", result, + static_cast(size)); } return result; } @@ -648,17 +946,45 @@ void* xmem_virtual_alloc(void* address, SIZE_T size, DWORD allocation_type, ULON // page inside a long run only remaps the rest of one capped view, not the whole run. constexpr uint64_t kMaxViewPages = 1024; // 64 MiB +// Caller checked this is a private zero plant and holds the exclusive fault lock. +bool remove_zero_view(decltype(g_views)::iterator planted) { + const uintptr_t base = planted->first; + if (!placeholder_api().unmap_view2(GetCurrentProcess(), reinterpret_cast(base), MEM_PRESERVE_PLACEHOLDER)) + return false; + zero_page_release(planted->second); + g_views.erase(planted); + leonida::title_memory_map::changed(base, base + kPhysicalPageSize); + leonida::geometry_writes::notify(base, base + kPhysicalPageSize, leonida::geometry_writes::Event::replaced); + return true; +} -bool map_view(uintptr_t address, const View& view) { +// `done`, when given, is set to the pages of the run mapped so far, which stay mapped when a later view fails. +bool map_view(uintptr_t address, const View& view, uint64_t* done = nullptr) { + if (done) *done = 0; for (uint64_t mapped = 0; mapped < view.count;) { const uintptr_t base = address + mapped * kPhysicalPageSize; void* const target = reinterpret_cast(base); MEMORY_BASIC_INFORMATION info{}; - if (!VirtualQuery(target, &info, sizeof(info)) || info.State != MEM_RESERVE || - info.RegionSize < kPhysicalPageSize) { + if (!VirtualQuery(target, &info, sizeof(info)) || info.RegionSize < kPhysicalPageSize) { SetLastError(ERROR_INVALID_ADDRESS); return false; } + if (info.State != MEM_RESERVE) { + // A zero page a fault planted here. Only a planted one: the caller unmaps a physical-page view of this run + // first, so a mapping never displaces a real one. This mapping replaces it, and its section page goes back + // to the zero pool. + const auto planted = g_views.find(base); + if (planted == g_views.end() || planted->first != base || !planted->second.zero) { + SetLastError(ERROR_INVALID_ADDRESS); + return false; + } + if (!remove_zero_view(planted)) return false; + if (!VirtualQuery(target, &info, sizeof(info)) || info.State != MEM_RESERVE || + info.RegionSize < kPhysicalPageSize) { + SetLastError(ERROR_INVALID_ADDRESS); + return false; + } + } const uint64_t available = info.RegionSize / kPhysicalPageSize; const uint64_t remaining = view.count - mapped; const uint64_t count = (std::min)({available, remaining, kMaxViewPages}); @@ -669,20 +995,41 @@ bool map_view(uintptr_t address, const View& view) { MEM_REPLACE_PLACEHOLDER, view.protect, nullptr, 0)) { return false; } - leonida::title_memory_map::changed(); - g_views.emplace(base, View{count, view.section, offset, view.protect}); + leonida::title_memory_map::changed(target, size); + View part = view; + part.count = count; + part.offset = offset; + g_views.emplace(base, std::move(part)); mapped += count; + if (done) *done = mapped; } return true; } -// With g_phys_mutex held. Unmaps every page in [start, end); the addresses become placeholders again. A view that -// reaches outside the range is unmapped whole, and its pages outside the range are mapped again, so neighbours keep -// their pages. +// The last unmaps (diagnostic): which range, when, and on whose behalf, for the read-fault report in +// physical_page_fault. Protected by g_fault_lock. +struct UnmapRecord { + uintptr_t start, end; + ULONGLONG tick; + const char* cause; +}; +constexpr size_t kUnmapRecords = 1024; +UnmapRecord g_unmaps[kUnmapRecords]; +uint64_t g_unmap_count = 0; +thread_local const char* t_unmap_cause = "unmap"; +struct UnmapCause { + const char* was; + explicit UnmapCause(const char* cause) : was(std::exchange(t_unmap_cause, cause)) {} + ~UnmapCause() { t_unmap_cause = was; } +}; + +// With g_fault_lock held exclusively. Unmaps every page in [start, end); the addresses become placeholders again. A +// view that reaches outside the range is unmapped whole, and its pages outside the range are mapped again, so +// neighbours keep their pages. // There is no rollback: if mapping a remainder again fails, those neighbouring pages stay unmapped and the caller only // sees the failure. -bool unmap_range(uintptr_t start, uintptr_t end) { - const FaultLockExclusive lock; // faults on neighbouring pages wait through the split and remap +bool unmap_range_locked(uintptr_t start, uintptr_t end) { + g_unmaps[g_unmap_count++ % kUnmapRecords] = {start, end, GetTickCount64(), t_unmap_cause}; auto it = g_views.upper_bound(start); if (it != g_views.begin()) { const auto prev = std::prev(it); @@ -696,7 +1043,7 @@ bool unmap_range(uintptr_t start, uintptr_t end) { MEM_PRESERVE_PLACEHOLDER)) { return false; } - leonida::title_memory_map::changed(); + leonida::title_memory_map::changed(base, view_end); leonida::geometry_writes::notify(base, view_end, leonida::geometry_writes::Event::replaced); it = g_views.erase(it); // The pages of [start, end) this view held are unmapped now; the ones outside it are mapped again below. @@ -706,6 +1053,9 @@ bool unmap_range(uintptr_t start, uintptr_t end) { g_mapped.erase(mapped); } } + // A planted zero page the range unmaps whole is free again; the section page is reused, zeroed, for the next + // plant. A partial unmap keeps it: the remainder still maps it. + if (base >= start && view_end <= end) zero_page_release(view); if (base < start) { View left = view; left.count = (start - base) / kPhysicalPageSize; @@ -722,29 +1072,148 @@ bool unmap_range(uintptr_t start, uintptr_t end) { return true; } +bool unmap_range(uintptr_t start, uintptr_t end) { + const FaultLockExclusive lock; // faults on neighbouring pages wait through the split and remap + return unmap_range_locked(start, end); +} + +bool unmap_page_locked(uintptr_t address) { return unmap_range_locked(address, address + kPhysicalPageSize); } + bool unmap_page(uintptr_t address) { return unmap_range(address, address + kPhysicalPageSize); } // With g_phys_mutex held. Maps physical page `page` (0: unmap) at the 64 KiB-aligned `address`, replacing what was // mapped there. The caller has found the window. -bool map_page(uintptr_t address, uint64_t page, DWORD protect) { - if (!unmap_page(address)) return false; - if (page == 0) return true; - const auto it = g_pages.find(page); - if (it == g_pages.end()) { +bool map_page(uintptr_t address, uint64_t page, DWORD protect, MapOwner owner) { + const auto backing = page ? g_pages.find(page) : g_pages.end(); + if (page && backing == g_pages.end()) { SetLastError(ERROR_INVALID_PARAMETER); return false; } { + // One exclusive section across the unmap and the map: a write fault on this page waits here and then sees the + // mapping, instead of landing in the gap where the page is a placeholder and planting a zero page the map + // would then discard. const FaultLockExclusive lock; - if (!map_view(address, View{1, it->second.section, it->second.offset, protect})) return false; + if (!unmap_page_locked(address)) return false; + if (!page) return true; + fault_race_point(rt::xmem::kRemapBetween); + if (!map_view(address, View{1, backing->second.section, backing->second.offset, protect, false, false, owner})) return false; } g_mapped[address] = page; note_mapping(page, address, true); return true; } +bool on_wine() { + static const bool wine = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr; + return wine; +} + +// Physical-page sections committed whole (under Wine, unless LEONIDA_XMEM_SEC_COMMIT=0), or reserved and committed on +// first touch (Windows, and Wine with the switch off). +bool sections_committed() { + static const bool committed = [] { + char v[4] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_XMEM_SEC_COMMIT", v, sizeof(v)); + return on_wine() && !(n == 1 && v[0] == '0'); + }(); + return committed; +} + enum class PageCommit { not_ours, committed_before, committed_now, failed }; +// Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still +// GPU memory, which the D3D12 layer reads on the CPU. +DWORD view_protect(const Window& window) { + // A view takes no cache modifier. Three of the measured windows carry PAGE_WRITECOMBINE (0x400) next to + // PAGE_READWRITE: Wine's MapViewOfFile3 refuses it, and PAGE_NOCACHE, with ERROR_INVALID_PARAMETER, and on Windows + // the view comes out write-combined, which an import of those pages as a GPU buffer refuses (#7218). PAGE_GUARD + // is an access alarm, not a cache modifier, so it is left as the window has it. + const DWORD protect = window.protect & ~static_cast(PAGE_WRITECOMBINE | PAGE_NOCACHE); + return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect; +} + +// A page of a window the title reserved and has not mapped yet: the console's window pages are zeroed memory it may +// write whenever it likes (measured: a title clears a 288 KiB grid at a story-load step into a window granule that it +// never passed to XMemMapPhysicalPages, and on the host the placeholder there is PAGE_NOACCESS). So the page the title +// reaches is backed by one page of a demand-zero section, mapped into the placeholder and committed. A page a mapping +// replaces goes back to the free list and is zeroed again before it is handed out, so a long run of plant-and-replace +// costs no more section pages than the plants alive at once. +// +// When a section's pages are all handed out the pool moves on to a new one; the old one lives on in the plants that +// still use it, and a page of it a mapping replaces is not reused (its offset means nothing in the new section). +struct ZeroPages { + std::shared_ptr
section; // pagefile-backed SEC_RESERVE, kZeroPagesPages pages, and its view + uint64_t next = 0; // next page of the section never handed out + leonida::host_heap::vector freed; // pages of `section` a mapping replaced, zeroed before reuse +}; +constexpr uint64_t kZeroPagesPages = 1024; // 64 MiB per section + +// At namespace scope, made before main: the fault handler that first uses it must not construct a static (MSVC +// registers its destructor with atexit, which takes the CRT's lock and the process heap). +ZeroPages g_zero_pages; + +// With g_fault_lock held exclusively, and `freed`/`next` under it: a fresh or reused zeroed page of the zero section. +// False when a new section is needed but cannot be made. +bool zero_page_take(uint64_t& offset) { + ZeroPages& pages = g_zero_pages; + if (!pages.section || (pages.freed.empty() && pages.next >= kZeroPagesPages)) { + const HANDLE handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, + static_cast(kZeroPagesPages * kPhysicalPageSize >> 32), + static_cast(kZeroPagesPages * kPhysicalPageSize), nullptr); + if (!handle) return false; + auto section = std::allocate_shared
(leonida::host_heap::Allocator
{}, handle); + if (!section->scratch) return false; // the Section closes the handle + pages.section = std::move(section); + pages.next = 0; + pages.freed.clear(); // the old section stays alive in the views that still use it + } + if (!pages.freed.empty()) { + offset = pages.freed.back(); + pages.freed.pop_back(); + // A replaced plant kept whatever was written into it: the next title to reach this page expects zeroes. + std::memset(static_cast(pages.section->scratch) + offset, 0, kPhysicalPageSize); + } else { + offset = pages.next * kPhysicalPageSize; + ++pages.next; + } + return VirtualAlloc(static_cast(pages.section->scratch) + offset, kPhysicalPageSize, MEM_COMMIT, + PAGE_READWRITE) != nullptr; +} + +// With g_fault_lock held exclusively: the page of the zero section a replaced plant used is free again, if that +// section is still the pool's. +void zero_page_release(const View& view) { + if (view.zero && view.section == g_zero_pages.section) g_zero_pages.freed.push_back(view.offset); +} + +// With g_fault_lock held exclusively. `address` is the 64 KiB-aligned page of a physical-page window that holds no +// mapping. Maps a zeroed page there, with the window's protection; false when the address is not such a page or the +// map fails. Only a title-code read takes g_phys_mutex before the fault lock. +bool map_zero_page(uintptr_t address, bool read_only) { + MEMORY_BASIC_INFORMATION info{}; + if (!VirtualQuery(reinterpret_cast(address), &info, sizeof(info)) || info.State != MEM_RESERVE || + info.Type != MEM_PRIVATE || info.RegionSize < kPhysicalPageSize) + return false; + const Window* const window = fault_window(address); + if (!window) return false; + const DWORD protect = read_only ? PAGE_READONLY : view_protect(*window); + uint64_t offset = 0; + if (!zero_page_take(offset)) return false; + View planted{1, g_zero_pages.section, offset, protect}; + planted.zero = true; + if (!isolate_placeholder(reinterpret_cast(address), kPhysicalPageSize) || + !placeholder_api().map_view3(planted.section->handle, GetCurrentProcess(), reinterpret_cast(address), + offset, kPhysicalPageSize, MEM_REPLACE_PLACEHOLDER, protect, nullptr, 0)) { + zero_page_release(planted); + return false; + } + g_views[address] = planted; + leonida::geometry_writes::notify(address, address + kPhysicalPageSize, leonida::geometry_writes::Event::mapping); + leonida::title_memory_map::changed(address, address + kPhysicalPageSize); + return true; +} + PageCommit commit_mapped_page(uintptr_t address, uintptr_t accessed, DWORD& protect) { auto it = g_views.upper_bound(address); if (it == g_views.begin()) return PageCommit::not_ours; @@ -755,14 +1224,15 @@ PageCommit commit_mapped_page(uintptr_t address, uintptr_t accessed, DWORD& prot if (!VirtualQuery(reinterpret_cast(accessed), &info, sizeof(info)) || info.Type != MEM_MAPPED) { return PageCommit::not_ours; } - if (info.State == MEM_COMMIT) { + // The fault handler needs the current protection of the accessed host page to decide whether to retry. + if (sections_committed() || info.State == MEM_COMMIT) { protect = info.Protect; return PageCommit::committed_before; } void* const backing = static_cast(it->second.section->scratch) + it->second.offset + within; if (!VirtualAlloc(backing, kPhysicalPageSize, MEM_COMMIT, PAGE_READWRITE)) return PageCommit::failed; leonida::geometry_writes::notify(address, address + kPhysicalPageSize, leonida::geometry_writes::Event::mapping); - leonida::title_memory_map::changed(); + leonida::title_memory_map::changed(address, address + kPhysicalPageSize); return PageCommit::committed_now; } @@ -786,44 +1256,432 @@ bool access_allowed(DWORD protect, ULONG_PTR access) { } } -LONG CALLBACK physical_page_fault(EXCEPTION_POINTERS* info) { - thread_local bool busy = false; - const EXCEPTION_RECORD* record = info ? info->ExceptionRecord : nullptr; - if (busy || !record || record->ExceptionCode != EXCEPTION_ACCESS_VIOLATION || record->NumberParameters < 2) { - return EXCEPTION_CONTINUE_SEARCH; +// What the fault handler did with a fault in the title's reserved memory, or with a write it left to the title in any +// memory that is only reserved, kept for drain_fault_notes to log: the handler itself may not log (the faulting thread +// can hold the CRT's or the process heap's lock). Lock-free and bounded: each kind keeps its first few, so routine +// faults cannot use up the room the rare ones need. +struct FaultNote { + uintptr_t accessed; + uint32_t kind; // FaultKind + uint32_t access; + int32_t result; // PageCommit + uint32_t where; // FaultWhere + uint32_t state, protect, type, allocation_protect; + uintptr_t allocation_base, region_end; // who reserved the page, and where its run ends + bool written; // written out by the handler already (write_refusal_now): drain_fault_notes skips it +}; +enum FaultKind : uint32_t { kPlanted, kCommitted, kRefused, kFaultKinds }; +enum FaultWhere : uint32_t { kNoReservation, kInWindow, kInPlaceholder }; +constexpr uint32_t kFaultNoteCaps[kFaultKinds] = {20, 20, 100}; +constexpr uint32_t kFaultNoteSlots = 20 + 20 + 100; +FaultNote g_fault_notes[kFaultNoteSlots]; +std::atomic g_fault_note_ready[kFaultNoteSlots]; +std::atomic g_fault_notes_taken{0}; +std::atomic g_fault_notes_shown{0}; +std::atomic g_fault_kind_counts[kFaultKinds]; + +// Faults left to the title past the first kFaultNoteCaps[kRefused] are counted, not noted: drain_fault_notes says how +// many there were when the count reaches this (doubled each time it is said). +std::atomic g_refused_report_at{kFaultNoteCaps[kRefused] + 1}; + + +bool g_pool_zero_pages; + +bool title_code(uintptr_t pc) { + if (pc < kTitleImage) return false; + __try { + const auto* dos = reinterpret_cast(kTitleImage); + if (dos->e_magic != IMAGE_DOS_SIGNATURE) return false; + const auto* nt = reinterpret_cast(kTitleImage + dos->e_lfanew); + return nt->Signature == IMAGE_NT_SIGNATURE && pc - kTitleImage < nt->OptionalHeader.SizeOfImage; + } __except (EXCEPTION_EXECUTE_HANDLER) { + return false; + } +} + +// Under the fault lock, including the mapping identity and time across view splits. +const View* covering_view(uintptr_t address, uintptr_t& base) { + auto it = g_views.upper_bound(address); + if (it == g_views.begin()) return nullptr; + --it; + base = it->first; + return address - base < it->second.count * kPhysicalPageSize ? &it->second : nullptr; +} + +char* describe_twin(char* out, uintptr_t at) { + if (!stream_gpu || at < stream_cpu || at - stream_cpu >= stream_size) + return append_text(out, ", outside stream CPU window"); + const auto offset = (at - stream_cpu) & ~(kPhysicalPageSize - 1); + const auto gpu = stream_gpu + offset; + out = append_number(append_text(out, ", GPU twin "), gpu, true); + if (!table_overlaps(stream_offsets, offset, offset + kPhysicalPageSize)) return append_text(out, " released"); + uintptr_t base = 0; + const auto* view = covering_view(gpu, base); + if (!view || view->zero) return append_text(out, view ? " zero plant, no frame" : " unmapped"); + const auto index = (view->offset + gpu - base) / kPhysicalPageSize; + out = append_text(out, view->owner == MapOwner::slot31 ? " slot31" : + view->owner == MapOwner::scatter ? " scatter" : " physical"); + out = append_number(append_text(out, " frame "), view->section->frames[index], true); + return append_number(append_text(out, " mapped tick_ms "), view->tick, false); +} + +// Snapshot the history under the shared lock. Write the stack buffer after releasing it. +DWORD describe_read(char* line, uintptr_t pc, uintptr_t at, const MEMORY_BASIC_INFORMATION& seen) { + + char* out = append_number(append_text(line, "[rt] xmem: title read fault at t+"), pc - kTitleImage, true); + out = append_number(append_text(out, " on "), at, true); + out = append_number(append_text(out, " state "), seen.State, true); + out = append_number(append_text(out, " protect "), seen.Protect, true); + out = append_number(append_text(out, " type "), seen.Type, true); + out = append_number(append_text(out, " allocation "), reinterpret_cast(seen.AllocationBase), true); + out = describe_twin(out, at); + const auto n = g_unmap_count; + out = append_number(append_text(out, ", unmaps "), n, false); + unsigned hits = 0; + for (uint64_t k = 0; k < n && k < kUnmapRecords && hits < 4; ++k) { + const auto& r = g_unmaps[(n - 1 - k) % kUnmapRecords]; + if (at < r.start || at >= r.end) continue; + ++hits; + out = append_text(append_text(out, "\n "), r.cause); + out = append_number(append_text(out, " ["), r.start, true); + out = append_number(append_text(out, ", "), r.end, true); + out = append_number(append_text(out, ") ms ago "), GetTickCount64() - r.tick, false); + } + if (!hits) out = append_text(out, ", no recent matching unmap"); + *out++ = '\n'; + return static_cast(out - line); +} + +// A fault in the title's reserved memory left to the title is usually the last thing the title does: its own +// handler, or none, ends the process before the next XMem call would log the note. So the handler writes that note +// out itself, outside the fault lock, straight to the standard error handle: no CRT (whose stream lock the faulting +// thread may hold), no allocation, one WriteFile of a line built on the stack. +void write_refusal_now(const FaultNote& n) { + const HANDLE out = GetStdHandle(STD_ERROR_HANDLE); + if (!out || out == INVALID_HANDLE_VALUE) return; + char line[384]; + char* at = line; + at = append_text(at, "[rt] xmem: fault at "); + at = append_number(at, n.accessed, true); + at = append_text(at, " (access "); + at = append_number(at, n.access, false); + at = append_text(at, ") left to the title: commit "); + at = append_number(at, static_cast(n.result), false); + at = append_text(at, n.where == kInWindow ? ", in a window" : ", in a title placeholder"); + at = append_text(at, ", host state "); + at = append_number(at, n.state, true); + at = append_text(at, " protect "); + at = append_number(at, n.protect, true); + at = append_text(at, " type "); + at = append_number(at, n.type, true); + at = append_text(at, ", allocation base "); + at = append_number(at, n.allocation_base, true); + at = append_text(at, ", run ends "); + at = append_number(at, n.region_end, true); + at = append_text(at, "\n"); + DWORD wrote = 0; + WriteFile(out, line, static_cast(at - line), &wrote, nullptr); +} + +// `seen` is the page as the handler's decision saw it (its last query of `accessed`), not as it is once the handler is +// done with it: after a plant, or another thread's map, that would say why a different fault was left alone. +void note_fault(FaultKind kind, uintptr_t accessed, ULONG_PTR access, PageCommit result, FaultWhere where, + const MEMORY_BASIC_INFORMATION& seen) { + if (g_fault_kind_counts[kind].fetch_add(1, std::memory_order_relaxed) >= kFaultNoteCaps[kind]) return; + const uint32_t slot = g_fault_notes_taken.fetch_add(1, std::memory_order_relaxed); + if (slot >= kFaultNoteSlots) return; + const MEMORY_BASIC_INFORMATION& q = seen; + FaultNote& n = g_fault_notes[slot]; + n.accessed = accessed; + n.kind = kind; + n.access = static_cast(access); + n.result = static_cast(result); + n.where = where; + n.state = q.State; + n.protect = q.Protect; + n.type = q.Type; + n.allocation_protect = q.AllocationProtect; + n.allocation_base = reinterpret_cast(q.AllocationBase); + n.region_end = reinterpret_cast(q.BaseAddress) + q.RegionSize; + n.written = kind == kRefused && where != kNoReservation; + if (n.written) write_refusal_now(n); + g_fault_note_ready[slot].store(true, std::memory_order_release); +} + +// Logs the faults the handler noted since the last call. Called on the way into the XMem calls, never under a lock. +void drain_fault_notes() { + if (g_fault_notes_shown.load(std::memory_order_relaxed) == g_fault_notes_taken.load(std::memory_order_relaxed) && + g_fault_kind_counts[kRefused].load(std::memory_order_relaxed) < + g_refused_report_at.load(std::memory_order_relaxed)) + return; + static std::mutex mutex; + const std::lock_guard lock(mutex); + if (const uint64_t refused = g_fault_kind_counts[kRefused].load(std::memory_order_relaxed); + refused >= g_refused_report_at.load(std::memory_order_relaxed)) { + std::fprintf(stderr, + "[rt] xmem: %llu faults left to the title so far; the first %u are noted below, the rest only " + "counted\n", + static_cast(refused), kFaultNoteCaps[kRefused]); + g_refused_report_at.store(refused * 2, std::memory_order_relaxed); + } + uint32_t shown = g_fault_notes_shown.load(std::memory_order_relaxed); + for (; shown < kFaultNoteSlots && g_fault_note_ready[shown].load(std::memory_order_acquire); ++shown) { + const FaultNote& n = g_fault_notes[shown]; + const unsigned long long page = n.accessed & ~static_cast(kPhysicalPageSize - 1); + if (n.written) { + continue; // the handler wrote it out at the fault + } else if (n.kind == kPlanted) { + std::fprintf(stderr, "[rt] xmem: window page 0x%llx now has a zero page: the title never mapped it\n", page); + } else if (n.kind == kCommitted) { + std::fprintf(stderr, + "[rt] xmem: mapped page 0x%llx committed at the fault: a section page in the title's " + "reservation with no view of xmem's\n", + page); + } else { + const char* const where = n.where == kInWindow ? "a window" + : n.where == kInPlaceholder ? "a title placeholder" + : "no title reservation"; + std::fprintf(stderr, + "[rt] xmem: fault at 0x%llx (page 0x%llx, access %u) left to the title: commit %d, in %s, " + "host state 0x%lx protect 0x%lx type 0x%lx, allocation base 0x%llx (protect 0x%lx), run " + "ends 0x%llx\n", + static_cast(n.accessed), page, n.access, n.result, where, + static_cast(n.state), static_cast(n.protect), + static_cast(n.type), static_cast(n.allocation_base), + static_cast(n.allocation_protect), + static_cast(n.region_end)); + } } - busy = true; + g_fault_notes_shown.store(shown, std::memory_order_relaxed); +} + +// With g_fault_lock held: does a view of g_views cover `address`? +bool view_covers(uintptr_t address) { + auto it = g_views.upper_bound(address); + if (it == g_views.begin()) return false; + --it; + return address - it->first < it->second.count * kPhysicalPageSize; +} + +// With g_fault_lock held exclusively. The host page at `accessed` is a reserved page of a section view xmem has no +// view of (g_views), in the title's reserved memory (a window or a placeholder of its own): commit it where the title +// reached. Not a scratch view of xmem's sections, which are host memory, nor anything outside the title's +// reservations (a driver's or another library's SEC_RESERVE view): a wild write there faults as it would without xmem. +bool commit_title_section_page(uintptr_t accessed) { + MEMORY_BASIC_INFORMATION q{}; + if (!VirtualQuery(reinterpret_cast(accessed), &q, sizeof(q)) || q.State != MEM_RESERVE || + q.Type != MEM_MAPPED || !in_title_reservation(accessed) || + g_scratch_views.count(reinterpret_cast(q.AllocationBase))) + return false; + const uintptr_t at = accessed & ~uintptr_t(0xfff); + if (!VirtualAlloc(reinterpret_cast(at), 0x1000, MEM_COMMIT, PAGE_READWRITE)) return false; + leonida::geometry_writes::notify(at, at + 0x1000, leonida::geometry_writes::Event::mapping); + leonida::title_memory_map::changed(at, at + 0x1000); + return true; +} + +// Test seam (rt::xmem::set_fault_race_hook): called where another thread's map, unmap or plant of the faulting page can +// interleave with the handler (rt::xmem::FaultRaceStage). +std::atomic g_fault_race_hook{nullptr}; + +void fault_race_point(int stage) { + if (const auto hook = g_fault_race_hook.load(std::memory_order_acquire)) hook(stage); +} + +// Test seam (rt::xmem::fault_exits): one count per exit of the handler, so a test can match the faults that reached +// the next handler against the ones the handler left to the title (and noted). +std::atomic g_fault_exits[static_cast(rt::xmem::FaultExit::count)]; + +LONG fault_exit(rt::xmem::FaultExit exit, LONG verdict) { + g_fault_exits[static_cast(exit)].fetch_add(1, std::memory_order_relaxed); + return verdict; +} + +bool commit_answers(PageCommit result, DWORD protect, ULONG_PTR access) { + return result == PageCommit::committed_now || (result == PageCommit::committed_before && access_allowed(protect, access)); +} + +// Only the handler's read-only plant can be replaced on a write. Respect window and title-set protections. +bool writable_read_plant(uintptr_t address) { + const auto view = g_views.find(address); + if (view == g_views.end() || !view->second.zero || view->second.title_protected || + view->second.protect != PAGE_READONLY) return false; + const auto* window = fault_window(address); + return window && access_allowed(view_protect(*window), 1); +} + +// A page of the title's reservation with no view of xmem's, found committed with a protection that allows the access: +// another thread committed it between the fault and the look (commit_title_section_page). The access runs again and +// goes through. Bounded: a thread that keeps faulting on one page this way (the query and the page tables disagreeing, +// which no Windows build is known to do) is left to the title after kMeanwhileRetries back-to-back retries, so it is +// noted instead of spinning silently. +constexpr unsigned kMeanwhileRetries = 8; +thread_local uintptr_t t_meanwhile_page = 0; +thread_local unsigned t_meanwhile_retries = 0; +bool committed_meanwhile(const MEMORY_BASIC_INFORMATION& page, ULONG_PTR access, uintptr_t accessed) { + if (page.State != MEM_COMMIT || !access_allowed(page.Protect, access)) return false; + const uintptr_t at = accessed & ~uintptr_t(0xfff); + if (at != t_meanwhile_page) { + t_meanwhile_page = at; + t_meanwhile_retries = 0; + } + return ++t_meanwhile_retries <= kMeanwhileRetries; +} + +// This thread is in physical_page_fault: a fault it takes there is passed on, not answered. +thread_local bool t_in_fault_handler = false; + +// Every access violation in the process comes here first. The common ones (a first touch of a mapped physical page, a +// guard of the D3D12 layer's on a mapped page) are answered or passed on under the shared lock; only a write into a +// page of the title's reserved memory that is still a reservation on the host (State MEM_RESERVE, which no routine +// guard fault is) takes the exclusive lock. +// +// Every decision is made on what was read under the lock. Each map, unmap and plant of xmem's holds the lock +// exclusively from before it changes a page until the page is in its final state, and on Windows a page read during +// MapViewOfFile3 or UnmapViewOfFile2 can read as MEM_FREE, or as the mapping it is about to lose: a query made with no +// lock held could see a mapping that is gone by the time the handler acts on it, or a free page that is a mapped one +// a moment later, and leave a write into a mapped window page to the title. +LONG CALLBACK physical_page_fault(EXCEPTION_POINTERS* info) { + using rt::xmem::FaultExit; + const EXCEPTION_RECORD* const record = info ? info->ExceptionRecord : nullptr; + // Before anything of this thread's is touched: most exceptions in the process are no access violation. + if (!record || record->ExceptionCode != EXCEPTION_ACCESS_VIOLATION) return EXCEPTION_CONTINUE_SEARCH; + if (record->NumberParameters < 2) return fault_exit(FaultExit::passed_foreign, EXCEPTION_CONTINUE_SEARCH); + // A fault this thread takes while it holds g_fault_lock is not xmem's to answer: waiting for the lock again would + // wait for itself. + if (t_in_fault_handler || t_fault_lock_held) return fault_exit(FaultExit::nested, EXCEPTION_CONTINUE_SEARCH); + t_in_fault_handler = true; const uintptr_t accessed = static_cast(record->ExceptionInformation[1]); const uintptr_t address = accessed & ~static_cast(kPhysicalPageSize - 1); + const ULONG_PTR access = record->ExceptionInformation[0]; DWORD protect = 0; PageCommit result; + FaultWhere where = kNoReservation; + MEMORY_BASIC_INFORMATION seen{}; // the page as the decision saw it + char read_note[1024]; + DWORD read_note_size = 0; + bool plant_read = false, promote = false; + bool queried = false; { const FaultLockShared lock; result = commit_mapped_page(address, accessed, protect); + promote = access == 1 && result == PageCommit::committed_before && protect == PAGE_READONLY && + writable_read_plant(address); + if (result == PageCommit::not_ours || result == PageCommit::failed || promote) { + if (in_window(address)) + where = kInWindow; + else if (in_title_reservation(accessed)) + where = kInPlaceholder; + // Read under the lock, so it stays true until the lock is released: no page of a window or a placeholder of + // the title's changes while it is held shared (each change of xmem's holds it exclusively, and a view of + // xmem's at this page would have been found above). A committed mapped page with no view here is someone + // else's view, not a mapping of xmem's in flight. + if (where != kNoReservation || access == 1) + queried = VirtualQuery(reinterpret_cast(accessed), &seen, sizeof(seen)) != 0; + const auto pc = reinterpret_cast(record->ExceptionAddress); + if (access == 0 && result == PageCommit::not_ours && title_code(pc)) { + if (!queried) queried = VirtualQuery(reinterpret_cast(accessed), &seen, sizeof(seen)) != 0; + read_note_size = describe_read(read_note, pc, accessed, seen); + plant_read = where == kInWindow && g_pool_zero_pages; + } + if (where != kNoReservation) fault_race_point(rt::xmem::kFaultDecided); + } } - busy = false; - if (result == PageCommit::committed_now) return EXCEPTION_CONTINUE_EXECUTION; - if (result == PageCommit::committed_before && access_allowed(protect, record->ExceptionInformation[0])) { - return EXCEPTION_CONTINUE_EXECUTION; + if (read_note_size) { + DWORD written; + WriteFile(GetStdHandle(STD_ERROR_HANDLE), read_note, read_note_size, &written, nullptr); + } + const bool title_page = where != kNoReservation; + // A write into memory that is only reserved: never a routine fault (a guard is committed), so noted below. + const bool reserved_write = queried && access == 1 && seen.State == MEM_RESERVE; + bool answered = commit_answers(result, protect, access); + char plant_note[256]; + DWORD plant_note_size = 0; + bool planted = false, committed = false, escalated = false; + if (!answered && title_page && queried) { + if (access == 1) fault_race_point(rt::xmem::kFaultAfterLook); + if (committed_meanwhile(seen, access, accessed)) { + answered = true; + } else if ((access == 1 || plant_read) && (seen.State == MEM_RESERVE || seen.State == MEM_FREE || promote)) { + // Only reserved: a window page the title never mapped, or a section page of the title's own not committed + // yet. Free, under the shared lock, in memory the tables still name as the title's: not a change of xmem's + // (none can be in flight), but decided again under the exclusive lock rather than passed on. + fault_race_point(rt::xmem::kFaultBeforeExclusive); + // Only title-code pool reads can wait for the whole physical mapping batch to publish its frames. + std::unique_lock physical(g_phys_mutex, std::defer_lock); + if (plant_read) physical.lock(); + const FaultLockExclusive lock; + escalated = true; + // Between the look and this lock another thread may have mapped, planted, committed or unmapped the page. + queried = VirtualQuery(reinterpret_cast(accessed), &seen, sizeof(seen)) != 0; + if (view_covers(address)) { + // Mapped, or planted by another thread's fault, since the look: answered as that view is. One that + // still refuses is a protection the title set, not a page it never mapped. + result = commit_mapped_page(address, accessed, protect); + answered = commit_answers(result, protect, access); + if (!answered && access == 1 && protect == PAGE_READONLY && writable_read_plant(address)) { + planted = remove_zero_view(g_views.find(address)) && map_zero_page(address, false); + answered = planted; + } + } else if (queried && seen.State == MEM_RESERVE) { + // A write into a window page the title never mapped: back it with a zeroed page (map_zero_page). No + // remap of this page is in flight while the lock is held. + if (!plant_read || g_mapped.find(address) == g_mapped.end()) + planted = map_zero_page(address, plant_read); + committed = access == 1 && !planted && commit_title_section_page(accessed); + answered = planted || committed; + } else if (queried && committed_meanwhile(seen, access, accessed)) { + answered = true; + } + if (planted) { + auto* out = append_number(append_text(plant_note, "[rt] xmem: zero plant "), address, true); + out = describe_twin(out, address); + *out++ = '\n'; + plant_note_size = static_cast(out - plant_note); + } + // Otherwise free with no change of xmem's in flight (released behind the tables), or committed with a + // protection that refuses the write: the title's. + } + } + const LONG verdict = answered ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH; + FaultExit exit; + if (planted) { + DWORD written; + WriteFile(GetStdHandle(STD_ERROR_HANDLE), plant_note, plant_note_size, &written, nullptr); + note_fault(kPlanted, accessed, access, result, where, seen); + exit = FaultExit::planted; + } else if (committed) { + note_fault(kCommitted, accessed, access, result, where, seen); + exit = FaultExit::committed; + } else if (answered) { + exit = FaultExit::answered; + } else if (result == PageCommit::committed_before && !escalated) { + exit = FaultExit::passed_guarded; // a guard's (the D3D12 layer's), routine: not noted + } else if (title_page || reserved_write) { + note_fault(kRefused, accessed, access, result, where, seen); + exit = FaultExit::left_to_title; + } else { + exit = FaultExit::passed_foreign; } - return EXCEPTION_CONTINUE_SEARCH; + t_in_fault_handler = false; + return fault_exit(exit, verdict); } bool install_physical_page_fault_handler() { - static const bool installed = AddVectoredExceptionHandler(1, &physical_page_fault) != nullptr; + static const bool installed = [] { + // The function-local statics the handler reaches are made here, before it can run: a first construction in the + // handler, under the exclusive lock, would take the CRT's lock for the static's guard, allocate, and register + // the destructor with atexit, all of which a faulting thread can be inside. + placeholder_api(); + leonida::host_heap::handle(); + leonida::geometry_writes::state(); + char flag[4]{}; + g_pool_zero_pages = GetEnvironmentVariableA("LEONIDA_POOL_ZERO_PAGES", flag, sizeof(flag)) == 1 && flag[0] == '1'; + return AddVectoredExceptionHandler(1, &physical_page_fault) != nullptr; + }(); return installed; } -// Two of the measured windows are reserved PAGE_NOACCESS for the CPU and the GPU alike; pages mapped there are still -// GPU memory, which the D3D12 layer reads on the CPU. -DWORD view_protect(const Window& window) { - // A view takes no cache modifier. Three of the measured windows carry PAGE_WRITECOMBINE (0x400) next to - // PAGE_READWRITE: Wine's MapViewOfFile3 refuses it, and PAGE_NOCACHE, with ERROR_INVALID_PARAMETER, and on Windows - // the view comes out write-combined, which an import of those pages as a GPU buffer refuses (#7218). PAGE_GUARD - // is an access alarm, not a cache modifier, so it is left as the window has it. - const DWORD protect = window.protect & ~static_cast(PAGE_WRITECOMBINE | PAGE_NOCACHE); - return protect == PAGE_NOACCESS ? PAGE_READWRITE : protect; -} bool aligned_page_address(uintptr_t address) { return (address & (kPhysicalPageSize - 1)) == 0; } @@ -849,11 +1707,12 @@ void note_physical_attributes(uint64_t attributes, uint64_t count, const void* c // a 32-bit BOOL. After success every caller compares the count with the one it asked for and frees the pages if they // differ, so the count is in/out. // -// Each call is backed by one pagefile-backed section of count * 64 KiB: committed (charged) on touch, given physical -// memory as it is touched, zero-filled. Pages keep their contents while unmapped or mapped elsewhere, and one page can +// Each call is backed by one pagefile-backed section of count * 64 KiB: on Windows reserved and committed (charged) on +// touch, under Wine committed whole (a sparse temp file), given physical memory as it is touched, zero-filled. Pages keep their contents while unmapped or mapped elsewhere, and one page can // be mapped at several addresses. ASSUMPTION: the attribute word (memory type, perhaps the page size) is not decoded; // every page is 64 KiB, which all four callers' arithmetic agrees with. BOOL WINAPI XMemAllocatePhysicalPages(uint64_t attributes, uint64_t* page_count, uint64_t* page_array) { + drain_fault_notes(); note_physical_attributes(attributes, page_count ? *page_count : 0, _ReturnAddress()); if (!page_count || (*page_count && !page_array)) { SetLastError(ERROR_INVALID_PARAMETER); @@ -876,7 +1735,11 @@ BOOL WINAPI XMemAllocatePhysicalPages(uint64_t attributes, uint64_t* page_count, const uint64_t bytes = count * kPhysicalPageSize; // below 2^37: count is below 2^21 HANDLE handle = file_backed_section(bytes); const bool use_file = handle != nullptr; - if (!handle) handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, + // As in VIctory's xmem.rs, commit the section on Wine: its sparse temp file costs no RAM for untouched pages. + // Querying or protecting reserved views takes a wineserver round trip under the process-wide virtual memory lock. + // Windows charges committed sections against the commit limit (errors 1455/1450), so reserve them there. + const DWORD flags = PAGE_READWRITE | (sections_committed() ? SEC_COMMIT : SEC_RESERVE); + if (!handle) handle = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, flags, static_cast(bytes >> 32), static_cast(bytes), nullptr); if (!handle) { *page_count = 0; @@ -888,6 +1751,12 @@ BOOL WINAPI XMemAllocatePhysicalPages(uint64_t attributes, uint64_t* page_count, *page_count = 0; return FALSE; } + // Diagnostic: where the host put each large section's scratch view, host memory a title write must never reach. + static std::atomic scratch_shown{0}; + if (count >= 256 && scratch_shown.fetch_add(1, std::memory_order_relaxed) < 64) + std::fprintf(stderr, "[rt] xmem: %llu physical pages, scratch view %p size %llu\n", + static_cast(count), section->scratch, static_cast(bytes)); + section->frames.resize(count); for (uint64_t i = 0; i < count; ++i) { uint64_t slot; if (!g_free_slots.empty()) { @@ -898,6 +1767,7 @@ BOOL WINAPI XMemAllocatePhysicalPages(uint64_t attributes, uint64_t* page_count, } const uint64_t page = slot * kFramesPerPage; g_pages[page] = PhysicalPage{section, i * kPhysicalPageSize}; + section->frames[i] = static_cast(page); page_array[i] = page; } return TRUE; @@ -916,14 +1786,14 @@ BOOL WINAPI XMemFreePhysicalPages(uint64_t page_count, const uint64_t* page_arra for (uint64_t i = 0; i < page_count; ++i) { const auto it = g_pages.find(page_array[i]); if (it == g_pages.end()) { - if (i != 0) leonida::title_memory_map::changed(); SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } g_pages.erase(it); g_free_slots.push_back(page_array[i] / kFramesPerPage); } - if (page_count != 0) leonida::title_memory_map::changed(); + // No change to what any address shows (title_memory_map): the pages were unmapped first, and one still mapped + // keeps its memory until it is. return TRUE; } @@ -934,7 +1804,8 @@ BOOL WINAPI XMemFreePhysicalPages(uint64_t page_count, const uint64_t* page_arra // // Consecutive pages of one allocation are mapped as one view (MapViewOfFile3 into a placeholder of their size); a // page remapped or unmapped later splits its view, and its neighbours stay mapped. The range is unmapped first, so a -// page number that is not a live page fails with the pages before it mapped and the rest of the range unmapped. +// page number that is not a live page fails with the pages before it mapped (and recorded as mapped) and the rest of the +// range unmapped. void* WINAPI XMemMapPhysicalPages(void* address, uint64_t page_count, const uint64_t* page_array) { const uintptr_t start = reinterpret_cast(address); if (!aligned_page_address(start) || page_count > (std::numeric_limits::max)() / kPhysicalPageSize || @@ -946,82 +1817,151 @@ void* WINAPI XMemMapPhysicalPages(void* address, uint64_t page_count, const uint SetLastError(ERROR_NOT_SUPPORTED); return nullptr; } + drain_fault_notes(); const std::lock_guard lock(g_phys_mutex); const uintptr_t end = start + page_count * kPhysicalPageSize; - if (!page_array) return unmap_range(start, end) ? address : nullptr; + const UnmapCause cause(page_array ? "XMemMapPhysicalPages (remap)" : "XMemMapPhysicalPages (unmap)"); + if (!page_array) { + const FaultLockExclusive view_lock; + return unmap_range_locked(start, end) ? address : nullptr; + } const Window* const window = find_window(start, page_count * kPhysicalPageSize); if (!window) { + std::fprintf(stderr, "[rt] xmem: map physical pages %p REFUSED: the range is not in one window\n", address); SetLastError(ERROR_INVALID_ADDRESS); return nullptr; } const DWORD protect = view_protect(*window); - if (!unmap_range(start, end)) return nullptr; - for (uint64_t i = 0; i < page_count;) { - if (page_array[i] == 0) { - ++i; - continue; - } - const auto it = g_pages.find(page_array[i]); - if (it == g_pages.end()) { - SetLastError(ERROR_INVALID_PARAMETER); - return nullptr; - } - View view{1, it->second.section, it->second.offset, protect}; - while (i + view.count < page_count) { - const auto next = g_pages.find(page_array[i + view.count]); - if (next == g_pages.end() || next->second.section != view.section || - next->second.offset != view.offset + view.count * kPhysicalPageSize) { + // The page numbers are the title's memory: copied once the window bounds their count, and before the fault lock, + // because a read of them that faults would wait for that lock on this very thread. (The fault handler never takes + // g_phys_mutex.) + leonida::host_heap::vector pages(page_array, page_array + page_count); + // One exclusive section across the whole range: unmapped first, then mapped run by run, so a write fault on any of + // these pages waits here and then sees its mapping instead of landing on a placeholder. Not split into chunks: a + // fault in a part not mapped yet would plant a zero page that the map then discards, with the write in it. The + // retail title's largest call (about 100,000 pages, once at load) holds it for about 100 capped views. + uint64_t failed_i = 0, failed_done = 0; + bool failed = false; + DWORD failed_error = ERROR_SUCCESS; + { + const FaultLockExclusive view_lock; + if (!unmap_range_locked(start, end)) return nullptr; + fault_race_point(rt::xmem::kRemapBetween); + for (uint64_t i = 0; i < page_count;) { + if (pages[i] == 0) { + ++i; + continue; + } + const auto it = g_pages.find(pages[i]); + if (it == g_pages.end()) { + failed = true; + failed_i = i; + failed_error = ERROR_INVALID_PARAMETER; break; } - ++view.count; - } - { - const FaultLockExclusive view_lock; - if (!map_view(start + i * kPhysicalPageSize, view)) return nullptr; - } - // After the fault lock: page_array is the title's memory, and a read of it that faults would wait for the - // lock on this thread. g_mapped and the aliases are g_phys_mutex's; the fault handler reads neither. - for (uint64_t k = 0; k < view.count; ++k) { - const uintptr_t at = start + (i + k) * kPhysicalPageSize; - g_mapped[at] = page_array[i + k]; - note_mapping(page_array[i + k], at, true); + View view{1, it->second.section, it->second.offset, protect}; + while (i + view.count < page_count) { + const auto next = g_pages.find(pages[i + view.count]); + if (next == g_pages.end() || next->second.section != view.section || + next->second.offset != view.offset + view.count * kPhysicalPageSize) { + break; + } + ++view.count; + } + uint64_t done = 0; + if (!map_view(start + i * kPhysicalPageSize, view, &done)) { + failed = true; + failed_i = i; + failed_done = done; + failed_error = GetLastError(); + if (failed_error == ERROR_SUCCESS) failed_error = ERROR_INVALID_ADDRESS; + break; + } + i += view.count; } - i += view.count; + } + // g_mapped and the aliases: host_heap, outside the fault lock. On a failure, for every page that did get mapped (the + // ones before the failing page, and the part of its run that was): they stay mapped, and copy_page_mappings and + // transfer_physical find them only here. + const uint64_t mapped_end = failed ? failed_i + failed_done : page_count; + for (uint64_t i = 0; i < mapped_end; ++i) { + if (pages[i] == 0) continue; + const uintptr_t at = start + i * kPhysicalPageSize; + g_mapped[at] = pages[i]; + note_mapping(pages[i], at, true); + } + if (failed) { + std::fprintf(stderr, + "[rt] xmem: map physical pages %p REFUSED: page %llu at %p (error %lu)\n", address, + static_cast(pages[failed_i]), + reinterpret_cast(start + failed_i * kPhysicalPageSize), failed_error); + SetLastError(failed_error); + return nullptr; } return address; } +enum class ScatterFailure { missing_addresses, unsupported, unaligned, no_window, unmap, unknown_page, map }; + +// All callers hold g_phys_mutex. Preserve the API error even if the diagnostic write fails. +BOOL scatter_refused(ScatterFailure reason, uintptr_t address, DWORD error) { + static constexpr const char* names[] = {"missing addresses", "unsupported", "unaligned", "no window", + "unmap failed", "unknown page", "map failed"}; + static unsigned shown[std::size(names)]{}; + const auto index = static_cast(reason); + if (shown[index] < 16) { + ++shown[index]; + char line[512]; + char* out = append_text(append_text(line, "[rt] xmem: scatter refused: "), names[index]); + out = append_number(append_text(out, " address="), address, true); + out = append_number(append_text(out, " error="), error, false); + auto next = g_windows.upper_bound(address); + out = append_text(out, " window at/below="); + if (next == g_windows.begin()) out = append_text(out, "none"); + else { + const auto prev = std::prev(next); + out = append_window(out, prev->first, prev->second); + } + out = append_text(out, " next="); + out = next == g_windows.end() ? append_text(out, "none") : append_window(out, next->first, next->second); + write_window_note(line, out); + } + SetLastError(error); + return FALSE; +} + // BOOL XMemMapPhysicalPagesScatter(PVOID* addresses, UINT32 pageCount, UINT64* pageArray). Measured at two call sites: // RCX is an array of addresses, EDX a 32-bit count, R8 the page for each address (an entry of 0, or a null array, // unmaps). The result is tested as a 32-bit BOOL. Like MapUserPhysicalPagesScatter: entry i maps pageArray[i] at // addresses[i]. BOOL WINAPI XMemMapPhysicalPagesScatter(void* const* addresses, uint32_t page_count, const uint64_t* page_array) { + drain_fault_notes(); + const std::lock_guard lock(g_phys_mutex); if (page_count && !addresses) { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + return scatter_refused(ScatterFailure::missing_addresses, 0, ERROR_INVALID_PARAMETER); } if (!placeholder_api().available()) { - SetLastError(ERROR_NOT_SUPPORTED); - return FALSE; + return scatter_refused(ScatterFailure::unsupported, page_count ? reinterpret_cast(addresses[0]) : 0, ERROR_NOT_SUPPORTED); } - const std::lock_guard lock(g_phys_mutex); for (uint32_t i = 0; i < page_count; ++i) { const uintptr_t address = reinterpret_cast(addresses[i]); if (!aligned_page_address(address)) { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + return scatter_refused(ScatterFailure::unaligned, address, ERROR_INVALID_PARAMETER); } const uint64_t page = page_array ? page_array[i] : 0; if (page == 0) { - if (!unmap_page(address)) return FALSE; + if (!unmap_page(address)) return scatter_refused(ScatterFailure::unmap, address, GetLastError()); continue; } const Window* const window = find_window(address, kPhysicalPageSize); if (!window) { - SetLastError(ERROR_INVALID_ADDRESS); - return FALSE; + return scatter_refused(ScatterFailure::no_window, address, ERROR_INVALID_ADDRESS); + } + if (!map_page(address, page, view_protect(*window), MapOwner::scatter)) { + const DWORD error = GetLastError(); + return scatter_refused(g_pages.count(page) ? ScatterFailure::map : ScatterFailure::unknown_page, + address, error); } - if (!map_page(address, page, view_protect(*window))) return FALSE; } return TRUE; } @@ -1075,8 +2015,8 @@ bool copy_page_mappings(void* destination, const void* source, uint64_t pages, b const DWORD cpu_protect = cpu_window ? view_protect(*cpu_window) : 0; for (uint64_t i = 0; i < pages; ++i) { const uint64_t page = found[static_cast(i)]; - if (!map_page(to + i * kPhysicalPageSize, page, protect)) return false; - if (cpu_window && !map_page(cpu_to + i * kPhysicalPageSize, page, cpu_protect)) return false; + if (!map_page(to + i * kPhysicalPageSize, page, protect, MapOwner::slot31)) return false; + if (cpu_window && !map_page(cpu_to + i * kPhysicalPageSize, page, cpu_protect, MapOwner::mirror)) return false; } return true; } @@ -1166,7 +2106,7 @@ LPVOID WINAPI TitleVirtualAlloc(LPVOID address, SIZE_T size, DWORD allocation_ty LPVOID result = reserve_watched(type, address, size, [&](DWORD t) { return VirtualAlloc(address, size, t, host_prot); }); if (result) { - leonida::title_memory_map::changed(); + leonida::title_memory_map::changed(result, size); leonida::title_va_aliases().add_title_memory(reinterpret_cast(result), size); note_unwatched_change(address, size, type, false); if (type & MEM_RESERVE) { @@ -1175,37 +2115,155 @@ LPVOID WINAPI TitleVirtualAlloc(LPVOID address, SIZE_T size, DWORD allocation_ty } } if(result)track_label_data(result,size,false); + // Diagnostic: the title's large reservations, so a fault the handler leaves to the title can be matched to the + // reservation it is in (its allocation base). + static std::atomic shown{0}; + if (result && (type & MEM_RESERVE) && size >= (64u << 20) && shown.fetch_add(1, std::memory_order_relaxed) < 64) + std::fprintf(stderr, "[rt] xmem: title VirtualAlloc reserve %p size %llu type 0x%lx protect 0x%lx\n", result, + static_cast(size), static_cast(allocation_type), + static_cast(protect)); + return result; +} + +// The allocation a MEM_RELEASE at `address` frees: [address, end) over every region with that allocation base. False +// when `address` is not an allocation's base (VirtualFree then fails anyway). +bool allocation_extent(const void* address, uintptr_t& end) { + MEMORY_BASIC_INFORMATION info{}; + if (!VirtualQuery(address, &info, sizeof(info)) || info.State == MEM_FREE || info.AllocationBase != address) + return false; + end = reinterpret_cast(info.BaseAddress) + info.RegionSize; + for (int regions = 0; regions < 4096; ++regions) { + MEMORY_BASIC_INFORMATION next{}; + if (!VirtualQuery(reinterpret_cast(end), &next, sizeof(next)) || next.State == MEM_FREE || + next.AllocationBase != address) + break; + end = reinterpret_cast(next.BaseAddress) + next.RegionSize; + } + return true; +} + +// A release of memory the title reserved as a window or a placeholder: the address range is the host's again, so it +// leaves the window and placeholder tables (a scratch view or a driver's view the host puts there later is not the +// title's). Under g_phys_mutex and the exclusive fault lock across the free and the tables: no section of xmem's (made +// under one of them) can land in the range while the tables still name it. A split (MEM_PRESERVE_PLACEHOLDER) or a +// merge (MEM_COALESCE_PLACEHOLDERS) keeps the reservation and is passed through. +BOOL title_release(void* address, SIZE_T size, DWORD free_type, const void* caller) { + uintptr_t end = 0; + const uintptr_t start = reinterpret_cast(address); + bool tracked = false; + if (allocation_extent(address, end)) { + const FaultLockShared lock; + tracked = table_overlaps(g_fault_windows, start, end) || table_overlaps(g_title_placeholders, start, end); + } + if (!tracked) return VirtualFree(address, size, free_type); + BOOL result; + { + const std::lock_guard lock(g_phys_mutex); + { + const FaultLockExclusive view_lock; + result = VirtualFree(address, size, free_type); + if (result) { + if (stream_gpu) { + for (const auto base : {stream_cpu, stream_gpu}) { + if (end > base && start < base + stream_size) + forget_range(stream_offsets, (std::max)(start, base) - base, + (std::min)(end - base, stream_size)); + } + } + forget_range(g_fault_windows, start, end); + forget_range(g_title_placeholders, start, end); + } + } + if (result) { + auto it = g_windows.lower_bound(start); + if (it != g_windows.begin()) --it; + for (; it != g_windows.end() && it->first < end; ++it) + if (it->first + it->second.size > start) + note_window_change(it->first, it->second, start, end - start, 0, caller, true); + forget_range(g_windows, start, end); + } + } + static std::atomic shown{0}; + if (result && shown.fetch_add(1, std::memory_order_relaxed) < 64) + std::fprintf(stderr, "[rt] xmem: the title released %p size %llu of its windows/placeholders\n", address, + static_cast(end - start)); return result; } // The pages are freed with the GPU label regions locked (src/gpu_label_memory.h), so a completed label is never // stored into pages that are going away. -BOOL WINAPI TitleVirtualFree(LPVOID address, SIZE_T size, DWORD free_type) { - DWORD saved=0; - const bool result=leonida::label::memory().release_pages(reinterpret_cast(address),size,(free_type&MEM_RELEASE)!=0,[&]{ - const BOOL r=::VirtualFree(address,size,free_type);saved=GetLastError();return !!r; - }); - if (result) leonida::title_memory_map::changed(); +BOOL title_free_impl(LPVOID address, SIZE_T size, DWORD free_type) { + drain_fault_notes(); + const bool releases = (free_type & MEM_RELEASE) && !(free_type & (MEM_PRESERVE_PLACEHOLDER | MEM_COALESCE_PLACEHOLDERS)); + BOOL result; + if (releases) { + result = title_release(address, size, free_type, _ReturnAddress()); + } else if (free_type & (MEM_PRESERVE_PLACEHOLDER | MEM_COALESCE_PLACEHOLDERS)) { + // A split or a merge of placeholders, which may be the title's windows: the pages it touches are part way + // through changing until it returns, so the fault handler waits for it as it waits for a remap of xmem's. + const FaultLockExclusive lock; + result = VirtualFree(address, size, free_type); + } else { + result = VirtualFree(address, size, free_type); + } + // A release of size 0 frees the whole reservation, whose extent is not known here: a change anywhere. + if (result && size) leonida::title_memory_map::changed(address, size); + else if (result) leonida::title_memory_map::changed(); if (result && (free_type & MEM_DECOMMIT)) note_unwatched_change(address, size, 0, true); if (result && (free_type & MEM_RELEASE) && !(free_type & MEM_PRESERVE_PLACEHOLDER)) leonida::title_write_watch::remove(reinterpret_cast(address)); + return result; +} + +BOOL WINAPI TitleVirtualFree(LPVOID address, SIZE_T size, DWORD free_type) { + DWORD saved = ERROR_SUCCESS; + const bool ok = leonida::label::memory().release_pages( + reinterpret_cast(address), size, (free_type & MEM_RELEASE) != 0, [&] { + const BOOL result = title_free_impl(address, size, free_type); + saved = GetLastError(); + return !!result; + }); SetLastError(saved); - return result ? TRUE : FALSE; + return ok ? TRUE : FALSE; } BOOL WINAPI TitleVirtualFreeEx(HANDLE process,LPVOID address,SIZE_T size,DWORD flags) { if(GetProcessId(process)!=GetCurrentProcessId())return ::VirtualFreeEx(process,address,size,flags); - DWORD saved=0; - const bool ok=leonida::label::memory().release_pages(reinterpret_cast(address),size,(flags&MEM_RELEASE)!=0,[&]{ - const BOOL r=::VirtualFreeEx(process,address,size,flags);saved=GetLastError();return !!r; - }); + DWORD saved = ERROR_SUCCESS; + const bool ok = leonida::label::memory().release_pages( + reinterpret_cast(address), size, (flags & MEM_RELEASE) != 0, [&] { + const BOOL result = title_free_impl(address, size, flags); + saved = GetLastError(); + return !!result; + }); SetLastError(saved);return ok?TRUE:FALSE; } +// The title makes pages of physical-page views in [start, start + size) read-only (or no-access) itself: those views +// are left as they are by reopen_unowned, which otherwise takes a read-only page there for a guard nobody reopened. +// Kept per view (a run of pages mapped together) and never cleared: coarse, but it only ever turns that safety net +// off for the view, never the title's protection. +void note_title_protect(uintptr_t start, SIZE_T size, DWORD protect) { + switch (protect & 0xff) { + case PAGE_READWRITE: + case PAGE_EXECUTE_READWRITE: + case PAGE_WRITECOPY: + case PAGE_EXECUTE_WRITECOPY: return; // writable: nothing for reopen_unowned to keep + default: break; + } + const uintptr_t end = start + size; + const FaultLockExclusive lock; // the field only: no allocation, no title memory + auto it = g_views.upper_bound(start); + if (it != g_views.begin() && std::prev(it)->first + std::prev(it)->second.count * kPhysicalPageSize > start) --it; + for (; it != g_views.end() && it->first < end; ++it) it->second.title_protected = true; +} + BOOL WINAPI TitleVirtualProtect(LPVOID address, SIZE_T size, DWORD protect, PDWORD old) { + const auto start = reinterpret_cast(address); + // Before the call: a fault on another thread in between must not take the title's protection for a lost guard. + note_title_protect(start, size, protect); const BOOL result = VirtualProtect(address, size, protect, old); if (result) { - leonida::title_memory_map::changed(); - const auto start = reinterpret_cast(address); + leonida::title_memory_map::changed(start, start + size); leonida::geometry_writes::notify(start, start + size, leonida::geometry_writes::Event::replaced); } return result; @@ -1215,13 +2273,300 @@ BOOL WINAPI TitleVirtualProtect(LPVOID address, SIZE_T size, DWORD protect, PDWO namespace rt::xmem { +void note_stream_reservation(uintptr_t base, size_t size, uintptr_t caller_rva) { + if (caller_rva != 0x1e1d00f && caller_rva != 0x1e1d03e) return; + const std::lock_guard physical(g_phys_mutex); + const FaultLockExclusive faults; + if (caller_rva == 0x1e1d00f) { + stream_cpu = base; + stream_size = size; + stream_gpu = 0; + stream_offsets.clear(); + } else if (stream_cpu && size == stream_size && !stream_gpu) { + stream_gpu = base; + stream_offsets.emplace(0, Window{size, 0}); + char value[2]{}; + mirror_stream = GetEnvironmentVariableA("LEONIDA_SLOT31_CPU_TWIN", value, sizeof(value)) == 1 && value[0] == '1'; + } + rt::placed_image_map_note::publish_pair(stream_gpu, stream_cpu, stream_size); +} + +bool queue_page_mappings_enabled() { + static const bool enabled = [] { + const char* value = std::getenv("LEONIDA_QUEUE_PAGE_MAPPINGS"); + return !value || std::strcmp(value, "0") != 0; + }(); + return enabled; +} + +// Snapshot all source frame numbers under the physical-map lock before replacing a destination. +// This also permits the source pool and destinations to overlap. Unmap/skip ranges never read start. +bool slot31_runs() { + static const bool on = [] { + const char* v = std::getenv("LEONIDA_SLOT31_RUNS"); + return v && std::strcmp(v, "1") == 0; + }(); + return on; +} + +bool copy_page_mappings(std::uint32_t count, const PageBatch* batches, std::uintptr_t pool, + std::uint32_t pool_pages, std::uint32_t flags) { + // Each refusal says why (the first 16): the queue call above it reports only E_FAIL. + uint32_t at_batch = 0, at_range = 0; + const auto refuse = [&](DWORD error, int site, uintptr_t address, uint32_t kind) { + static std::atomic shown{0}; + if (shown.fetch_add(1, std::memory_order_relaxed) < 16) { + MEMORY_BASIC_INFORMATION q{}; + VirtualQuery(reinterpret_cast(address), &q, sizeof(q)); + std::fprintf(stderr, + "[rt] xmem: copy page mappings refused (check %d): batch %u range %u kind %u at 0x%llx, " + "error %lu; host state 0x%lx type 0x%lx allocation base %p, %s window, %s view\n", + site, at_batch, at_range, kind, static_cast(address), error, + static_cast(q.State), static_cast(q.Type), q.AllocationBase, + find_window(address, kPhysicalPageSize) ? "in a" : "no", [&] { + const FaultLockShared lock; + return view_covers(address); + }() ? "a" : "no"); + } + SetLastError(error); + return false; + }; + const auto fail = [](DWORD error) { SetLastError(error); return false; }; + if (flags || (count && !batches)) return fail(ERROR_INVALID_PARAMETER); + if (!count) return true; + if (!placeholder_api().available()) return fail(ERROR_NOT_SUPPORTED); + struct Range { + uintptr_t at; + PageRange spec; + size_t first_frame; + DWORD protect; + }; + std::vector plan; + std::vector frames; + drain_fault_notes(); + const std::lock_guard lock(g_phys_mutex); + try { + for (uint32_t b = 0; b < count; ++b) { + const auto& batch = batches[b]; + auto at = batch.destination; + at_batch = b; + at_range = 0; + if (!aligned_page_address(at) || (batch.count && !batch.ranges)) + return refuse(ERROR_INVALID_PARAMETER, 1, at, 0); + for (uint32_t i = 0; i < batch.count; ++i) { + const auto r = batch.ranges[i]; + const auto bytes = uint64_t(r.count) * kPhysicalPageSize; + at_range = i; + if (r.kind > 3 || at > UINTPTR_MAX - bytes) return refuse(ERROR_INVALID_PARAMETER, 2, at, r.kind); + if (r.count && r.kind != 3) { + // A single queue range can span both sides of a carved window. Validate all fragments + // before changing any mappings, and give each run its own window protection. + for (uint32_t offset = 0; offset < r.count;) { + const auto dest = at + uint64_t(offset) * kPhysicalPageSize; + auto it = g_windows.upper_bound(dest); + if (it == g_windows.begin()) return refuse(ERROR_INVALID_ADDRESS, 3, dest, r.kind); + --it; + const auto end = it->first + it->second.size; + if (dest >= end || end - dest < kPhysicalPageSize) + return refuse(ERROR_INVALID_ADDRESS, 3, dest, r.kind); + const auto pages = static_cast((std::min)(uint64_t(r.count - offset), + (end - dest) / kPhysicalPageSize)); + plan.push_back({dest, {r.kind, r.start, pages}, frames.size() + (r.kind == 0 ? offset : 0), + view_protect(it->second)}); + offset += pages; + } + if (r.kind < 2) { + const uint32_t n = r.kind == 1 ? 1 : r.count; + if (!pool || !aligned_page_address(pool) || r.start > pool_pages || n > pool_pages - r.start || + pool > UINTPTR_MAX - (uint64_t(r.start) + n) * kPhysicalPageSize) + return refuse(ERROR_INVALID_PARAMETER, 4, pool + uint64_t(r.start) * kPhysicalPageSize, + r.kind); + const auto source = pool + uint64_t(r.start) * kPhysicalPageSize; + for (uint32_t j = 0; j < n; ++j) { + const auto src = source + uint64_t(j) * kPhysicalPageSize; + const auto it = g_mapped.find(src); + if (it == g_mapped.end()) { + // A hole in a valid source window unmaps the destination (CLHelper, RT-QUEUE31). + if (!find_window(src, kPhysicalPageSize)) + return refuse(ERROR_INVALID_ADDRESS, 5, src, r.kind); + frames.push_back(0); + } else { + if (!g_pages.contains(it->second)) return refuse(ERROR_INVALID_ADDRESS, 6, src, r.kind); + frames.push_back(it->second); + } + } + } + } + at += bytes; + } + } + at_batch = at_range = UINT32_MAX; // a map refusal names its address only + // The mirror reads the published GPU frames, including any prefix left by a host failure. + const auto apply = [&](const Range& r, uintptr_t gpu_source) { + const bool mirror = gpu_source != 0; + const auto bytes = uint64_t(r.spec.count) * kPhysicalPageSize; + bool ok = true; + bool changed_mirror = false; + uintptr_t failed_at = r.at; + if (!mirror && r.spec.kind == 2) { + const UnmapCause cause("CopyPageMappingsBatchX (unmap range)"); + ok = unmap_range(r.at, r.at + bytes); + } else if (!mirror && !slot31_runs()) { + for (uint32_t j = 0; j < r.spec.count; ++j) { + const auto at = r.at + uint64_t(j) * kPhysicalPageSize; + const auto frame = frames[r.first_frame + (r.spec.kind == 0 ? j : 0)]; + const auto existing = g_mapped.find(at); + if (existing != g_mapped.end() && existing->second == frame) continue; + const UnmapCause cause(frame ? "CopyPageMappingsBatchX (remap)" : "CopyPageMappingsBatchX (hole)"); + if (!map_page(at, frame, r.protect, MapOwner::slot31)) { + ok = false; + break; + } + } + } else { + // LEONIDA_SLOT31_RUNS=1 (off by default: speed-19 spent 1.6-6.3 s a call mapping with it, and its + // load had not ended by 340 s): runs of pages whose mapping changes are unmapped once and mapped as + // one view for each stretch of + // consecutive pages of one section, not page by page: unmapping one page out of a larger view + // unmaps that view and maps its remainder again, so a page-by-page remap of a run cost several + // MapViewOfFile3 and UnmapViewOfFile2 calls a page (each a wineserver round trip under Wine), all under + // g_phys_mutex, which the streaming workers and the D3D12 layer wait for. + const auto frame_at = [&](uint32_t j) -> uint64_t { + if (!mirror) return frames[r.first_frame + (r.spec.kind == 0 ? j : 0)]; + const auto it = g_mapped.find(gpu_source + uint64_t(j) * kPhysicalPageSize); + return it == g_mapped.end() ? 0 : it->second; + }; + const auto changes = [&](uint32_t j) { + const auto existing = g_mapped.find(r.at + uint64_t(j) * kPhysicalPageSize); + if (mirror) { + const auto frame = frame_at(j); + if (existing == g_mapped.end()) return frame != 0; + if (existing->second == frame) return false; + const FaultLockShared faults; + uintptr_t base = 0; + const auto* v = covering_view(existing->first, base); + if (!v || v->owner != MapOwner::mirror) return false; + } + // Even without a frame number the fault handler may have planted a zero page. + return existing == g_mapped.end() || existing->second != frame_at(j); + }; + for (uint32_t j = 0; j < r.spec.count && ok;) { + if (!changes(j)) { + ++j; + continue; + } + uint32_t end = j + 1; + while (end < r.spec.count && changes(end)) ++end; + const uintptr_t from = r.at + uint64_t(j) * kPhysicalPageSize; + failed_at = from; + changed_mirror = mirror; + const FaultLockExclusive faults; + { + const UnmapCause cause("CopyPageMappingsBatchX (remap run)"); + ok = unmap_range_locked(from, r.at + uint64_t(end) * kPhysicalPageSize); + } + for (uint32_t k = j; k < end && ok;) { + const uint64_t frame = frame_at(k); + if (!frame) { // a hole: left unmapped + ++k; + continue; + } + const auto first = g_pages.find(frame); + if (first == g_pages.end()) { + SetLastError(ERROR_INVALID_PARAMETER); + ok = false; + break; + } + uint32_t n = 1; + while (k + n < end && n < kMaxViewPages) { + const auto next = g_pages.find(frame_at(k + n)); + if (next == g_pages.end() || next->second.section != first->second.section || + next->second.offset != first->second.offset + uint64_t(n) * kPhysicalPageSize) + break; + ++n; + } + const uintptr_t at = r.at + uint64_t(k) * kPhysicalPageSize; + uint64_t done = 0; + ok = map_view(at, View{n, first->second.section, first->second.offset, r.protect, false, false, + mirror ? MapOwner::mirror : MapOwner::slot31}, &done); + const DWORD map_error = ok ? ERROR_SUCCESS : GetLastError(); + for (uint32_t i = 0; i < done; ++i) { + g_mapped[at + uint64_t(i) * kPhysicalPageSize] = frame_at(k + i); + note_mapping(frame_at(k + i), at + uint64_t(i) * kPhysicalPageSize, true); + } + if (!ok) { + failed_at = at + done * kPhysicalPageSize; + SetLastError(map_error); + break; + } + k += n; + } + j = end; + } + } + const DWORD error = ok ? ERROR_SUCCESS : GetLastError(); + // Publish after changing the mapping, including partial host failures. + if (!mirror || changed_mirror) leonida::title_texel_writes::note(reinterpret_cast(r.at), bytes); + if (!ok) return refuse(error, 7, failed_at, r.spec.kind); + return true; + }; + for (const auto& r : plan) { + const bool ok = apply(r, 0); + const auto error = ok ? ERROR_SUCCESS : GetLastError(); + const auto end = r.at + uint64_t(r.spec.count) * kPhysicalPageSize; + if (mirror_stream && stream_gpu && end > stream_gpu && r.at < stream_gpu + stream_size) { + for (const auto& [offset, extent] : stream_offsets) { + auto gpu = (std::max)(r.at, stream_gpu + offset); + const auto stop = (std::min)(end, stream_gpu + offset + extent.size); + while (gpu < stop) { + const auto cpu = stream_cpu + (gpu - stream_gpu); + auto it = g_windows.upper_bound(cpu); + if (it == g_windows.begin()) return refuse(ERROR_INVALID_ADDRESS, 8, cpu, r.spec.kind); + --it; + const auto cpu_end = it->first + it->second.size; + if (cpu >= cpu_end) return refuse(ERROR_INVALID_ADDRESS, 8, cpu, r.spec.kind); + const auto bytes = (std::min)(stop - gpu, cpu_end - cpu); + if (bytes < kPhysicalPageSize) return refuse(ERROR_INVALID_ADDRESS, 8, cpu, r.spec.kind); + Range twin{cpu, {0, 0, static_cast(bytes / kPhysicalPageSize)}, 0, view_protect(it->second)}; + if (!apply(twin, gpu)) return false; + gpu += bytes; + } + } + } + if (!ok) return fail(error); + } + } catch (const std::bad_alloc&) { + return fail(ERROR_NOT_ENOUGH_MEMORY); + } + return true; +} + void geometry_aliases(std::uintptr_t va, std::vector& addresses) { - std::lock_guard lock(g_phys_mutex); - const auto mapped = g_mapped.find(va); - if (mapped == g_mapped.end()) return; - const auto peers = g_page_addresses.find(mapped->second); - if (peers != g_page_addresses.end()) - for (auto other : peers->second) if (other != va) addresses.push_back(other); + AddressList snapshot; + { + const std::shared_lock aliases(g_alias_lock); + const auto peers = g_alias_peers.find(va); + if (peers == g_alias_peers.end()) return; + snapshot = peers->second; + } + // The caller's vector may allocate on the process heap. Fault-side writers wait for the alias lock. + addresses.insert(addresses.end(), snapshot.begin(), snapshot.end()); +} + +std::uint64_t zero_pages_taken() { return g_zero_pages.next; } + +void set_fault_race_hook(FaultRaceHook hook) { g_fault_race_hook.store(hook, std::memory_order_release); } + +std::uint64_t fault_exits(FaultExit exit) { + const int at = static_cast(exit); + return at >= 0 && at < static_cast(FaultExit::count) ? g_fault_exits[at].load(std::memory_order_relaxed) : 0; +} + +std::uintptr_t physical_page_scratch(std::uint64_t page) { + const std::lock_guard lock(g_phys_mutex); + const auto it = g_pages.find(page); + if (it == g_pages.end() || !it->second.section->scratch) return 0; + return reinterpret_cast(it->second.section->scratch) + it->second.offset; } bool commit_physical_range(const void* address, size_t size) { @@ -1231,6 +2576,7 @@ bool commit_physical_range(const void* address, size_t size) { SetLastError(ERROR_INVALID_PARAMETER); return false; } + if (sections_committed()) return true; const uintptr_t mask = ~static_cast(kPhysicalPageSize - 1); const uintptr_t first = start & mask; const uintptr_t pages = (((start + (size - 1)) & mask) - first) / kPhysicalPageSize + 1; @@ -1295,6 +2641,10 @@ static bool commit_pages_locked(const uint64_t* page_array, size_t count) { SetLastError(ERROR_INVALID_PARAMETER); return false; } + if (sections_committed()) { + ++first; // Already committed, but transfer_physical still needs every page number validated. + continue; + } size_t last = first + 1; while (last < count) { const auto next = g_pages.find(page_array[last]); @@ -1306,6 +2656,7 @@ static bool commit_pages_locked(const uint64_t* page_array, size_t count) { } void* const backing = static_cast(it->second.section->scratch) + it->second.offset; if (!it->second.section->file_backed && !VirtualAlloc(backing, (last - first) * kPhysicalPageSize, MEM_COMMIT, PAGE_READWRITE)) return false; + // Committing the scratch backing affects every title alias. Their addresses are unknown here. leonida::title_memory_map::changed(); first = last; } @@ -1323,8 +2674,41 @@ bool transfer_physical(std::span pages, uint16_t offset, std::sp SetLastError(ERROR_INVALID_PARAMETER); return false; } + // A write goes through the section, which no guard sees: a slot-133 shadow that keeps one of the page's addresses + // read-only, and so takes it for unchanged, would miss it. So every address the pages are mapped at is pinned and + // opened first, as for a kernel write (the shadows copy it until the pin ends, then guard it again). Without + // g_phys_mutex: opening waits for the shadows' locks, which a refresh holds for its walk, and XMem calls would + // wait as long. An address mapped in between is a new mapping, which the shadows and the geometry watch copy anyway. + std::vector pins; + if (write) { + std::vector> ranges; + { + const std::lock_guard lock(g_phys_mutex); + size_t left = staging.size(); + uint16_t at = offset; + for (const auto page : pages) { + const size_t bytes = (std::min)(left, size_t(kPhysicalPageSize - at)); + if (auto mapped = g_page_addresses.find(page); mapped != g_page_addresses.end()) + for (uintptr_t address : mapped->second) ranges.emplace_back(address + at, bytes); + left -= bytes; + at = 0; + } + } + for (const auto& [address, bytes] : ranges) + if (const uint64_t pin = leonida::kernel_writes::begin_write(reinterpret_cast(address), bytes, + nullptr)) + pins.push_back(pin); + } + const auto end_pins = [&] { + for (const uint64_t pin : pins) leonida::kernel_writes::end_write(pin, false); + }; const std::lock_guard lock(g_phys_mutex); - if (!commit_pages_locked(pages.data(), pages.size())) return false; + if (!commit_pages_locked(pages.data(), pages.size())) { // also: every page is still allocated + const DWORD error = GetLastError(); + end_pins(); + SetLastError(error); + return false; + } for (const auto page : pages) { const auto& backing = g_pages.at(page); auto* ptr = static_cast(backing.section->scratch) + backing.offset + offset; @@ -1347,9 +2731,59 @@ bool transfer_physical(std::span pages, uint16_t offset, std::sp staging = staging.subspan(bytes); offset = 0; } + end_pins(); return true; } +// kernel_writes' unguarder (src/title_page_watch.h): the pages of [begin, end) in physical-page views whose window is +// writable but that are read-only now are made writable again. A page there is read-only only while a guard of the +// D3D12 layer (a slot-133 shadow, a geometry tile) keeps it so, and that guard reopens it at a write fault or before a +// kernel write; one still read-only after those had no guard left to answer for it, and would fail every write into it +// for good. Views the title protected itself (note_title_protect) are left alone. The shadows walk their pages again +// and the geometry tiles over the range count as written. True when a page of a writable view in the range is writable +// now. Called from the write-fault handler: under g_fault_lock shared, no allocation and nothing logged. +bool reopen_unowned(std::uintptr_t begin, std::uintptr_t end) { + if (begin >= end) return false; + constexpr uintptr_t kHostPage = 0x1000; + bool writable = false, opened = false; + { + const FaultLockShared lock; + auto it = g_views.upper_bound(begin); + if (it != g_views.begin() && std::prev(it)->first + std::prev(it)->second.count * kPhysicalPageSize > begin) + --it; + for (; it != g_views.end() && it->first < end; ++it) { + const View& view = it->second; + if (view.title_protected || view.protect != PAGE_READWRITE && view.protect != PAGE_EXECUTE_READWRITE) + continue; // the title's protection, or a view no write may reach + const DWORD read_only = view.protect == PAGE_READWRITE ? PAGE_READONLY : PAGE_EXECUTE_READ; + const uintptr_t view_end = it->first + view.count * kPhysicalPageSize; + const uintptr_t to = (std::min)(view_end, (end + kHostPage - 1) & ~(kHostPage - 1)); + for (uintptr_t at = (std::max)(it->first, begin & ~(kHostPage - 1)); at < to;) { + MEMORY_BASIC_INFORMATION info{}; + if (!VirtualQuery(reinterpret_cast(at), &info, sizeof(info))) break; + const uintptr_t next = (std::min)(to, reinterpret_cast(info.BaseAddress) + info.RegionSize); + if (next <= at) break; + if (info.State == MEM_COMMIT && info.Type == MEM_MAPPED) { + DWORD old = 0; + if (info.Protect == read_only && + VirtualProtect(reinterpret_cast(at), next - at, view.protect, &old)) { + opened = writable = true; + } else if (info.Protect == view.protect) { + writable = true; // opened meanwhile (by its guard, or by another thread's call) + } + } + at = next; + } + } + } + if (opened) { + // A shadow that kept such a page read-only and clean walks it again; a geometry tile over it is refilled. + leonida::title_memory_map::changed(begin, end); + leonida::geometry_writes::notify(begin, end, leonida::geometry_writes::Event::write); + } + return writable; +} + } #define TITLE_VIRTUAL_MEMORY(dll) \ diff --git a/runtime/shims/xmem.h b/runtime/shims/xmem.h index 6352274505..329766f6b2 100644 --- a/runtime/shims/xmem.h +++ b/runtime/shims/xmem.h @@ -8,11 +8,60 @@ namespace rt::xmem { +// CopyPageMappingsBatchX, Xbox queue slot 31. Measured x64 layout (also documented by VIctory). +struct PageRange { + std::uint32_t kind, start, count; +}; +struct PageBatch { + std::uintptr_t destination; + std::uint32_t count; + const PageRange* ranges; +}; +static_assert(sizeof(PageRange) == 12 && sizeof(PageBatch) == 24 && offsetof(PageBatch, ranges) == 16); + +// Record the two measured stream-pool reservation return sites; other callers are ignored. +void note_stream_reservation(std::uintptr_t base, std::size_t size, std::uintptr_t caller_rva); +bool queue_page_mappings_enabled(); +bool copy_page_mappings(std::uint32_t count, const PageBatch* batches, std::uintptr_t pool, + std::uint32_t pool_pages, std::uint32_t flags); + void geometry_aliases(std::uintptr_t va, std::vector& addresses); bool commit_physical_range(const void* address, std::size_t size); // A lifetime-pinned alias of a contiguous range of the title's writable mapped physical pages. std::shared_ptr pin_mapped_data(const void* address, std::size_t size); +// Test seam: section pages the zero-page pool has handed out. A replaced plant returns its page, so a +// plant-and-replace loop does not grow this. +std::uint64_t zero_pages_taken(); +// Test seam: the address of physical page `page` in its section's scratch view (xmem's own mirror of the section), or +// 0 for a page that is not live. A write there must fault: it is not the title's memory. +std::uintptr_t physical_page_scratch(std::uint64_t page); +// Test seam: called at the points of a fault where another thread's map, unmap or plant of the faulting page can +// interleave with it (FaultRaceStage). Null: none. The hook runs on the thread named by the stage, with the locks that +// stage says are held: it may wait on an event, but must not allocate, log or fault. +enum FaultRaceStage : int { + kFaultAfterLook = 0, // the handler, after the shared look, with its lock released + kFaultBeforeExclusive = 1, // the handler, just before the exclusive lock (a write the look left to it) + kFaultDecided = 2, // the handler, inside the shared look after the query it decides on: the lock still held + kRemapBetween = 3, // XMemMapPhysicalPages, between the unmap and the map, the exclusive lock held +}; +using FaultRaceHook = void (*)(int stage); +void set_fault_race_hook(FaultRaceHook hook); +// Test seam: how the fault handler left the access violations it saw, one count per exit (all since the start). +enum class FaultExit : int { + nested, // taken while this thread held the fault lock, or inside the handler: passed on unanswered + answered, // a mapped page committed, or found committed and allowed (another thread's map or commit) + planted, // a window page the title never mapped, backed by a zero page + committed, // a section page in the title's reservation with no view of xmem's, committed + passed_guarded, // a committed page of xmem's views whose protection refuses the access: its guard's to answer + passed_foreign, // memory that is not the title's reservation and not only reserved: someone else's fault + left_to_title, // the title's reservation, or a write into memory that is only reserved: noted (FaultNote) + count +}; +std::uint64_t fault_exits(FaultExit exit); bool commit_physical_pages(const std::uint64_t* page_array, std::size_t count); +// leonida::kernel_writes' unguarder (src/title_page_watch.h): pages of physical-page views in [begin, end) left +// read-only with no guard to reopen them are made writable again. True when such a page there is writable now. +bool reopen_unowned(std::uintptr_t begin, std::uintptr_t end); // Copy a validated DirectStorage staging buffer through the page table. The page list has // one frame number per 64 KiB page. All pages are resolved before a write starts. diff --git a/runtime/src/arena_blocks.h b/runtime/src/arena_blocks.h new file mode 100644 index 0000000000..f6b379e2f5 --- /dev/null +++ b/runtime/src/arena_blocks.h @@ -0,0 +1,238 @@ +#pragma once +// The GPU address arena's free-block map (docs/d3d12_vulkan.md section 3.3). +// +// One map of free blocks, offset -> size, first fit at a requested alignment. Every access is made under the +// device's arena mutex, and a walk holds no iterator across a call: each step reads a block's offset and size and +// lets its iterator go, so a block cut under the walk cannot leave the next step reading a freed node. A freed +// node reads as garbage (seen once in arena_allocate: an access violation reading the nil flag of a null map child +// at 0x19 -- the freed block's first two pointers reused by the heap's free list, while the rest of the node still +// looked like a node). A map access outside the lock does that to a concurrent walk: the arena's first block used +// to be inserted by create_arena with no lock, and an insert rebalances the tree, writing child links under a +// walker on another thread. It is locked now, and the walk is immune either way. +// +// The class keeps no lock of its own (the device's arena mutex is the lock), so a test can drive it directly. +#include +#include +#include +#include +#include +#include + +namespace leonida { + +class ArenaBlocks { +public: + struct Block { + std::uint64_t offset; + std::uint64_t size; + }; + + // What a release found wrong with the range it was given: a range the arena never had, or bytes that are free + // already (a double free, which would otherwise double-count them and let two live ranges overlap). + enum class Fault { none, outside_arena, double_free, bytes_mismatch, broken_map }; + static constexpr const char* kFaultNames[] = {"none", "range outside the arena", "double free", + "free bytes disagree with the live bytes", "block map broken"}; + + // [reserved, size) is the one free block: the arena's first bytes hold the zero page and the quad index list + // (kArenaReserved in the device), which no resource may have. + void reset(std::uint64_t reserved, std::uint64_t size) { + blocks_.clear(); + reserved_ = reserved; + size_ = size; + free_bytes_ = size > reserved ? size - reserved : 0; + if (free_bytes_) blocks_.emplace(reserved, free_bytes_); + cuts_ = 0; + fault_ = Fault::none; + faults_ = 0; + interrupted_ = false; + } + + // First fit of `bytes` at `alignment`: `keep_out(lo, hi)` returns the end of a range of the arena no + // allocation may cover that overlaps [lo, hi), or 0 when there is none (the device passes the title's own + // memory through src/title_va_alias.h). False when no free block holds the request. + template + bool allocate(std::uint64_t bytes, std::uint64_t alignment, KeepOut&& keep_out, std::uint64_t& out) { + if (!bytes || !alignment || bytes > size_) return false; + interrupted_ = false; + // Blocks in offset order. A step carries only a block's offset and size; the iterator is gone before + // keep_out() runs and the next block is looked up from the map again, so a cut made under the walk + // (cuts() changed) is seen, and the search starts over on the map as it is now. + for (int attempt = 0; attempt < kAttempts; ++attempt) { + const std::uint64_t cuts = cuts_; + std::uint64_t cursor = reserved_; + for (;;) { + const auto next = blocks_.lower_bound(cursor); + if (next == blocks_.end()) return false; + const std::uint64_t block = next->first; + const std::uint64_t block_size = next->second; + const std::uint64_t end = block + block_size; + std::uint64_t start = align_up(block, alignment); + while (start < end && bytes <= end - start) { + const std::uint64_t keep_out_end = keep_out(start, start + bytes); + if (!keep_out_end) break; + start = align_up(keep_out_end, alignment); + } + if (cuts_ != cuts) break; // the map moved under the walk: search the new one + if (start < end && bytes <= end - start) { + const auto target = blocks_.find(block); // nothing held between steps + if (target == blocks_.end() || target->second != block_size) break; + cut(target, start, bytes); + out = start; + return true; + } + cursor = end; + } + if (cuts_ == cuts) return false; // nothing moved: a genuine refusal + } + interrupted_ = true; // cut under the search kAttempts times: reported by the device + return false; + } + + // [offset, offset + bytes) exactly, inside one free block (a console descriptor heap whose address shaders + // already use). False when any of it is taken or past the arena. + bool allocate_at(std::uint64_t offset, std::uint64_t bytes) { + if (!bytes || offset < reserved_ || offset > size_ || bytes > size_ - offset) return false; + auto it = blocks_.upper_bound(offset); + if (it == blocks_.begin()) return false; + --it; + if (offset + bytes > it->first + it->second) return false; + cut(it, offset, bytes); + return true; + } + + // Gives [offset, offset + bytes) back and merges it with the blocks it touches. A range that is partly free + // already is merged as its union and reported as a double free, so the accounting cannot count a byte twice. + Fault release(std::uint64_t offset, std::uint64_t bytes) { + if (!bytes) return Fault::none; + if (offset < reserved_ || offset > size_ || bytes > size_ - offset) return note_fault(Fault::outside_arena); + const std::uint64_t released_end = offset + bytes; + std::uint64_t begin = offset; + std::uint64_t end = released_end; + bool already_free = false; + auto it = blocks_.lower_bound(offset); + if (it != blocks_.begin()) { + const auto previous = std::prev(it); + const std::uint64_t previous_end = previous->first + previous->second; + if (previous_end >= offset) { // the released bytes start inside a free block, or right after it + if (previous_end > offset) already_free = true; + begin = previous->first; + end = std::max(end, previous_end); + free_bytes_ -= previous->second; + it = blocks_.erase(previous); + } + } + while (it != blocks_.end() && it->first <= end) { + if (it->first < released_end) already_free = true; + end = std::max(end, it->first + it->second); + free_bytes_ -= it->second; + it = blocks_.erase(it); + } + blocks_.emplace(begin, end - begin); + free_bytes_ += end - begin; + ++cuts_; + return note_fault(already_free ? Fault::double_free : Fault::none); + } + + // The arena's bytes: the size it was created with and the first block no resource may have. + std::uint64_t size() const { return size_; } + std::uint64_t reserved() const { return reserved_; } + std::uint64_t free_bytes() const { return free_bytes_; } + std::size_t count() const { return blocks_.size(); } + + // Every free block in offset order: a report, or a diagnostic that prints what is free. + std::vector blocks() const { + std::vector out; + out.reserve(blocks_.size()); + for (const auto& [offset, size] : blocks_) out.push_back({offset, size}); + return out; + } + + // The free block that holds `offset` (if one does) and the offset of the next block after it: what the compute + // input probe reads to tell a free range from a live one without walking the map itself + // (d3d12_compute_input_probe.h backing()). + bool free_at(std::uint64_t offset, std::uint64_t& block_offset, std::uint64_t& block_size, + std::uint64_t& next_offset) const { + auto it = blocks_.upper_bound(offset); + bool inside = false; + if (it != blocks_.begin()) { + const auto previous = std::prev(it); + if (offset >= previous->first && offset < previous->first + previous->second) { + inside = true; + block_offset = previous->first; + block_size = previous->second; + } + } + next_offset = it == blocks_.end() ? size_ : it->first; + return inside; + } + + // The largest free block, for the high-water report (D3D-55). + Block largest() const { + Block best{0, 0}; + for (const auto& [offset, size] : blocks_) + if (size > best.size) best = {offset, size}; + return best; + } + + // The block map is a partition of the arena's free bytes: sorted, inside the arena, no overlap, and summing to + // free_bytes(). Walked for a report, and by the device when its cheap check (free_bytes + live == size - + // reserved) fails or LEONIDA_ARENA_CHECK=1 is set. + Fault check() const { + std::uint64_t sum = 0, last_end = reserved_; + for (const auto& [offset, size] : blocks_) { + if (!size || offset < last_end || offset > size_ || size > size_ - offset) return Fault::broken_map; + sum += size; + last_end = offset + size; + } + return sum == free_bytes_ ? Fault::none : Fault::bytes_mismatch; + } + + // Whether the map's free bytes and the device's live bytes add up to the arena: a byte released twice, or a + // released range that was never allocated, breaks this. O(1), so the device checks it on every call. + bool consistent(std::uint64_t live_bytes) const { return free_bytes_ + live_bytes == size_ - reserved_; } + + // Faults reported so far, and the last one this call reported. + std::uint64_t faults() const { return faults_; } + Fault last_fault() const { return fault_; } + // Cuts made so far: how often a block was split, taken whole or merged. A cut changes it under a walk. + std::uint64_t cuts() const { return cuts_; } + // The last allocate gave up because the map was cut under its search kAttempts times; the request may have been + // refusable anyway, so the device reports it rather than counting it as a fault. + bool interrupted() const { return interrupted_; } + static constexpr int kAttempts = 8; + +private: + static std::uint64_t align_up(std::uint64_t value, std::uint64_t alignment) { + return (value + alignment - 1) / alignment * alignment; + } + + Fault note_fault(Fault fault) { + fault_ = fault; + if (fault != Fault::none) ++faults_; + return fault; + } + + using Map = std::map; + void cut(Map::iterator it, std::uint64_t start, std::uint64_t bytes) { + const std::uint64_t offset = it->first; + const std::uint64_t end = offset + it->second; + blocks_.erase(it); + free_bytes_ -= end - offset; + if (start > offset) { + blocks_.emplace(offset, start - offset); + free_bytes_ += start - offset; + } + if (start + bytes < end) { + blocks_.emplace(start + bytes, end - (start + bytes)); + free_bytes_ += end - (start + bytes); + } + ++cuts_; + } + + Map blocks_; // offset -> size + std::uint64_t reserved_ = 0, size_ = 0, free_bytes_ = 0, cuts_ = 0, faults_ = 0; + Fault fault_ = Fault::none; + bool interrupted_ = false; +}; + +} // namespace leonida diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h index 010abbbc01..3d7ed093bb 100644 --- a/runtime/src/command_list.h +++ b/runtime/src/command_list.h @@ -424,6 +424,17 @@ struct DrawViewports { std::uint32_t scissor_count = 0; }; +// Simple DRAW or DRAW_INDEXED records. The GPU consumes the action's arguments; +// the IR retains an ordinary record-time graphics-state snapshot alongside them. +struct IndirectDrawArgs { + ResourceId argument_buffer = 0; + std::uint64_t argument_offset = 0; + std::uint32_t stride = 0; + std::uint32_t max_count = 1; + ResourceId count_buffer = 0; // zero: fixed draw count; otherwise, a GPU-written uint32 + std::uint64_t count_offset = 0; +}; + // DrawInstanced / DrawIndexedInstanced / DispatchMesh, with everything they use captured when they are recorded: // D3D12 reads render-target and depth descriptors at OMSetRenderTargets, and every other piece of state is the // list's state at the draw. resource 0 marks an unbound render-target slot or no depth buffer. A mesh draw @@ -453,6 +464,14 @@ struct Draw { std::shared_ptr viewports; // non-null when >1 viewport or >1 scissor was bound }; +// Only indirect draws allocate this extra payload. Copies of the IR share both its +// immutable state and the usual cached DrawViews; direct draws and barriers stay compact. +struct IndirectRasterPayload { + Draw state; + IndirectDrawArgs arguments; +}; +using IndirectRasterDraw = std::shared_ptr; + // D3D12_TEXTURE_DATA_PITCH_ALIGNMENT and D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT. inline constexpr std::uint32_t texture_data_pitch_alignment = 256; inline constexpr std::uint32_t texture_data_placement_alignment = 512; @@ -604,6 +623,17 @@ enum class IndirectKind : std::uint8_t { dispatch_mesh = 3, }; +// For a creation-validated signature, commands are stride bytes apart, but no padding follows the +// last packed payload. A zero maximum reads no records (offset alignment is checked separately). +constexpr bool indirect_records_fit(std::uint64_t buffer_size, std::uint64_t offset, std::uint32_t max_count, + std::uint32_t stride, std::uint32_t packed_size) { + if (!packed_size || packed_size > stride || stride % 4) return false; + if (!max_count) return true; + // All factors are UINT32 and packed_size <= stride: required <= UINT32_MAX squared. + const auto required = std::uint64_t(max_count - 1) * stride + packed_size; + return offset <= buffer_size && required <= buffer_size - offset; +} + struct ExecuteIndirect { IndirectKind kind = IndirectKind::draw; std::uint32_t stride = 0; @@ -655,6 +685,11 @@ struct CopyAccelerationStructure { std::uint64_t dst_va = 0; std::uint64_t src_va = 0; std::uint32_t mode = 0; + // Set where the layer resolved a VA in the title's memory to the copy shaders reach it by (an XDXR build, at + // record time): the bytes that copy has from the VA on. 0: the VA names one of the layer's buffers, sized at + // replay by its binding. + std::uint64_t dst_room = 0; + std::uint64_t src_room = 0; }; // EmitRaytracingAccelerationStructurePostbuildInfo, and each postbuild desc of BuildRaytracingAccelerationStructure: @@ -664,6 +699,7 @@ struct AccelerationStructurePostbuild { std::uint64_t dest_va = 0; std::uint32_t type = 0; std::vector sources; + std::uint64_t dest_room = 0; // as CopyAccelerationStructure::dst_room }; using Command = std::variant; + AccelerationStructurePostbuild, IndirectRasterDraw>; + +struct DrawCommandView { + const Draw* state = nullptr; + const IndirectDrawArgs* arguments = nullptr; +}; + +// Queries, shader-work detection and replay all see the same captured graphics state. +inline DrawCommandView draw_command(const Command& command) noexcept { + if (const auto* draw = std::get_if(&command)) return {draw, nullptr}; + if (const auto* indirect = std::get_if(&command); indirect && *indirect) + return {&(*indirect)->state, &(*indirect)->arguments}; + return {}; +} class CommandList { public: @@ -771,6 +820,12 @@ class CommandList { return append(std::move(draw)); } + bool draw_indirect(Draw&& state, const IndirectDrawArgs& arguments) { + if (closed_ || !state.pipeline) return false; + if (!arguments.max_count) return true; + return append(std::make_shared(std::move(state), arguments)); + } + // ClearRenderTargetView; the resource must be in render_target state at execution. No rects: the whole view. bool clear_render_target(const TargetView& target, const ClearColor& color, std::span rects = {}) { if (!valid(target)) return false; diff --git a/runtime/src/fsdraw_probe.h b/runtime/src/fsdraw_probe.h index 38c0ca58cd..180b02b369 100644 --- a/runtime/src/fsdraw_probe.h +++ b/runtime/src/fsdraw_probe.h @@ -5,6 +5,8 @@ // CPU and what the GPU address arena holds at the same VA (the shader's heap_base + VA), which T#s have a bindless // entry, and which render targets the present-probe should read back as well. +#include "title_va_alias.h" + #include #include #include @@ -192,7 +194,11 @@ inline void describe_table(const char* tag, std::uint64_t va, std::uint32_t slot tag, i, static_cast(base), stride, w[2], in_arena ? "arena" : "outside the arena buffer", in_arena ? hex_words(data, 16).c_str() : "", nonzero, made ? "" : " (no CreateConstantBufferView made this V#)"); - if (made && !in_arena && location) { // the CB as the title wrote it (title memory, CPU view) + // The CB as the title wrote it, when its location is the title's memory (CPU view): an upload buffer's + // VA, also outside the arena, is no CPU address. + std::uint64_t title_lo = 0, title_hi = 0; + if (made && !in_arena && location && title_va_aliases().title_memory(location, title_lo, title_hi) && + title_hi - location >= 64) { std::uint32_t cb[16]{}; std::memcpy(cb, reinterpret_cast(static_cast(location)), sizeof cb); std::fprintf(stderr, "[rt] fsdraw: %s slot %u CB at title 0x%llx: [%s]\n", tag, i, diff --git a/runtime/src/guarded_copy.h b/runtime/src/guarded_copy.h new file mode 100644 index 0000000000..60914d1691 --- /dev/null +++ b/runtime/src/guarded_copy.h @@ -0,0 +1,59 @@ +#pragma once +// Copies and reads made inside a __try frame that must turn an access violation into an error (the shadow and +// title-texture copies of the D3D12 layer, DirectStorage request copies, the kernel-write retry). +// +// The faulting access has to happen in a function of ours, not inlined into the frame with the __try: +// - Under Wine an access violation raised inside the CRT's memcpy or memmove (Wine's ucrtbase) never reaches the +// __except of the frame that called it, and the process ends ("Unhandled page fault ... starting debugger"). +// guarded_copy_test --crt shows it: the same fault raised in a function of ours is caught. A Linux boot ended that way +// in the slot-133 shadow refresh, reading a title page the title was remapping (CopyPageMappingsBatchX). +// - clang-cl, without /EHa, catches only what a call inside the __try raises, not an inline load or store. +// So the bytes move here: never inlined, and no_builtin keeps the compiler from turning a loop back into a call to +// memcpy or memmove. +#include +#include +#include + +// clang-cl: no_builtin keeps the loops below from becoming CRT calls. MSVC has no such attribute (and accepts no +// __attribute__ at all); it does not turn __movsb or a loop over volatile bytes into memcpy/memmove, so nothing is needed. +#if defined(__clang__) +#define LEONIDA_GUARDED_NO_BUILTIN __attribute__((no_builtin)) +#else +#define LEONIDA_GUARDED_NO_BUILTIN +#endif + +namespace leonida::guarded { + +// Forward copy, REP MOVSB: the source and destination do not overlap, or the destination is below the source. +__declspec(noinline) LEONIDA_GUARDED_NO_BUILTIN inline void copy(void* to, const void* from, std::size_t bytes) { + __movsb(static_cast(to), static_cast(from), bytes); +} + +// memmove: forward when that is safe, else from the end down, byte by byte (rare: only an overlapping move upwards). +__declspec(noinline) LEONIDA_GUARDED_NO_BUILTIN inline void move(void* to, const void* from, std::size_t bytes) { + auto* d = static_cast(to); + const auto* s = static_cast(from); + const auto dst = reinterpret_cast(to), src = reinterpret_cast(from); + if (dst <= src || dst >= src + bytes) { + __movsb(static_cast(to), static_cast(from), bytes); + return; + } + for (std::size_t i = bytes; i-- > 0;) d[i] = s[i]; +} + +// An aligned 32- or 64-bit store in one locked access (XCHG): a thread polling the value, or reading it with one +// load, sees the old value or the new one, never half of each (a REP MOVSB may store byte by byte). +__declspec(noinline) inline void store32(void* to, std::uint32_t value) { + _InterlockedExchange(static_cast(to), static_cast(value)); +} +__declspec(noinline) inline void store64(void* to, std::uint64_t value) { + _InterlockedExchange64(static_cast(to), static_cast(value)); +} + +// One word read: for a __try that only asks whether memory still holds what it did (an OVERLAPPED the title may have +// freed). +__declspec(noinline) inline std::uintptr_t read_word(const void* at) { + return *static_cast(at); +} + +} // namespace leonida::guarded diff --git a/runtime/src/indirect_clamp.comp b/runtime/src/indirect_clamp.comp new file mode 100644 index 0000000000..565a19463d --- /dev/null +++ b/runtime/src/indirect_clamp.comp @@ -0,0 +1,152 @@ +// Clamp the arguments of one D3D12 ExecuteIndirect batch on the GPU before the indirect command reads them. +// The title's own compute passes write most of these arguments; a pass the replay drops (async pipeline skip, a stub +// pipeline, LEONIDA_SKIP_COMPUTE) or mistranslates leaves whatever the memory held, and a dispatch of billions of +// groups or a draw of four billion vertices runs until the host resets the display driver. So the active records are +// copied into scratch with their values bounded, and the indirect command reads that scratch (vulkan_indirect_clamp.h). +// One invocation per record, one tiny dispatch per ExecuteIndirect call; nothing is read back by the CPU. +// +// When a count buffer is given, threads at or past min(max_command_count, count) return an empty record without +// charging the list budget. The command list charges its work (vertices, indices, or groups * 64) against 2^27 units with +// an atomic CAS, so thousands of garbage records cannot run for seconds either. +// +// The bounds cut legitimate work beyond them, so they are generous: 2^24 vertices (or indices), 2^26 vertex instances, +// 65 535 groups per dimension, 2^20 groups per dispatch, and mesh dispatches charged 128 threads per group. The +// console's mesh dispatch is one-dimensional; the output uses one group in y and z. +#version 460 +#extension GL_EXT_buffer_reference : require +layout(local_size_x = 64) in; + +layout(buffer_reference, std430, buffer_reference_align = 4) readonly buffer ArgsIn { uint data[]; }; +layout(buffer_reference, std430, buffer_reference_align = 4) readonly buffer CountIn { uint data[]; }; +layout(buffer_reference, std430, buffer_reference_align = 4) buffer ArgsOut { uint data[]; }; +layout(buffer_reference, std430, buffer_reference_align = 4) buffer CountOut { uint data[]; }; +layout(buffer_reference, std430, buffer_reference_align = 4) buffer Stats { uint data[]; }; + +layout(push_constant) uniform Params { + ArgsIn arguments; // the first record of this chunk + CountIn count; // the D3D12 count buffer, or 0 + ArgsOut records_out; // this chunk's clamped records, compact + CountOut count_out; // the clamped count word for a counted draw + Stats stats; // clamped records, bounded counts, over-budget records, zeroed records + Stats list_budget; + uint kind; // 0 draw, 1 draw indexed, 2 dispatch, 3 mesh dispatch (leonida::IndirectKind) + uint stride_words; // the D3D12 record stride in words + uint records; // records in this chunk + uint first_record; // the record index this chunk starts at + uint max_records; // max_command_count of the ExecuteIndirect call + uint flags; // bit 0: counted; bits 1..16: optional per-dispatch group budget +} p; + +// One ExecuteIndirect batch's limits. A record that asks for more runs empty instead of for seconds. +const uint max_vertices = 1u << 24u; // vertices or indices in one draw +const uint max_vertex_instances = 1u << 26u; // vertex (or index) count times instance count +const uint max_group_dimension = 65535u; // groups in x, y or z +const uint max_groups = 1u << 20u; // groups in one dispatch or mesh dispatch +const uint budget = 1u << 27u; // work in the whole command list: vertices, indices, or groups * 64 + +// Charges `cost` units to the batch's budget. Saturating: a record that no longer fits runs empty, so the batch never +// stops the GPU for longer than the budget allows. +bool charge(uint cost) { + if (cost == 0u) return true; + uint before = atomicAdd(p.list_budget.data[0], 0u); + while (before < budget) { + const uint room = budget - before; + if (cost > room) return false; + const uint next = before + cost; + const uint previous = atomicCompSwap(p.list_budget.data[0], before, next); + if (previous == before) return true; + before = previous; + } + return false; +} + +void main() { + const uint local = gl_GlobalInvocationID.x; + if (local >= p.records) return; + const uint global = p.first_record + local; + const uint out_words = p.kind <= 1u ? (p.kind == 0u ? 4u : 5u) : 3u; + const uint out_base = local * out_words; + + const bool counted = (p.flags & 1u) != 0u; + // The count is clamped to max_command_count (VUID-vkCmdDrawIndirectCount-countBuffer-02717), so a *Count draw + // reads a count no larger than the records whose scratch this pass wrote. + uint effective = p.max_records; + if (counted) { + const uint asked = p.count.data[0]; + effective = min(effective, asked); + if (global == 0u) { + p.count_out.data[0] = effective; + if (asked != effective) atomicAdd(p.stats.data[1], 1u); // the count asked past max_command_count + } + } + if (global >= effective) { + for (uint i = 0u; i < out_words; ++i) p.records_out.data[out_base + i] = 0u; + return; + } + + const uint src = local * p.stride_words; + bool unfilled = true; + for (uint i = 0u; i < out_words; ++i) + unfilled = unfilled && p.arguments.data[src + i] == 0xffffffffu; + if (unfilled || (p.kind == 3u && p.arguments.data[src] == 0xffffffffu)) { + for (uint i = 0u; i < out_words; ++i) p.records_out.data[out_base + i] = 0u; + atomicAdd(p.stats.data[0], 1u); + atomicAdd(p.stats.data[3], 1u); + return; + } + uint words[5] = uint[5](0u, 0u, 0u, 0u, 0u); + uint cost = 0u; + uint clamped = 0u; + if (p.kind <= 1u) { + // A draw or an indexed draw: count, instances, then the two (or three) locations, copied as they are. + const uint count = p.arguments.data[src]; + const uint instances = p.arguments.data[src + 1u]; + uint index_count = min(count, max_vertices); + uint instance_count = min(instances, max_vertex_instances / max(index_count, 1u)); + if (index_count == 0u) instance_count = 0u; + clamped = index_count != count || instance_count != instances ? 1u : 0u; + cost = index_count * instance_count; + words[0] = index_count; + words[1] = instance_count; + words[2] = p.arguments.data[src + 2u]; + words[3] = p.arguments.data[src + 3u]; + if (p.kind == 1u) words[4] = p.arguments.data[src + 4u]; + } else { + // A dispatch or a mesh dispatch: three group counts. x * y fits 32 bits (each is at most 65 535); the whole + // group count may not, so an oversized product runs empty. + const uint asked_x = p.arguments.data[src]; + const uint asked_y = p.arguments.data[src + 1u]; + const uint asked_z = p.arguments.data[src + 2u]; + uint x = min(asked_x, max_group_dimension); + uint y = min(asked_y, max_group_dimension); + uint z = min(asked_z, max_group_dimension); + if (p.kind == 3u) { y = 1u; z = 1u; } + const uint groups = p.flags >> 1u; + if (groups != 0u && x != 0u && y != 0u && z != 0u) { + x = min(x, groups); + y = min(y, groups / x); + z = min(z, groups / x / y); + } + if (z != 0u && x * y > max_groups / z) { + x = 0u; + y = 0u; + z = 0u; + } + clamped = x != asked_x || y != asked_y || z != asked_z ? 1u : 0u; + cost = x * y * z * (p.kind == 3u ? 128u : 64u); + words[0] = x; + words[1] = y; + words[2] = z; + } + + if (cost != 0u && !charge(cost)) { + clamped = 1u; + atomicAdd(p.stats.data[2], 1u); + words = uint[5](0u, 0u, 0u, 0u, 0u); + } + if (clamped != 0u) { + atomicAdd(p.stats.data[0], 1u); + if (words[0] == 0u) atomicAdd(p.stats.data[3], 1u); + } + for (uint i = 0u; i < out_words; ++i) p.records_out.data[out_base + i] = words[i]; +} diff --git a/runtime/src/indirect_clamp_spv.h b/runtime/src/indirect_clamp_spv.h new file mode 100644 index 0000000000..50253df78b --- /dev/null +++ b/runtime/src/indirect_clamp_spv.h @@ -0,0 +1,287 @@ +// Generated with glslangValidator -V --target-env vulkan1.2 -Os --spirv-val indirect_clamp.comp +#pragma once +#include +namespace leonida { +inline constexpr std::uint32_t indirect_clamp_spirv[] = { + 0x07230203u, 0x00010500u, 0x0008000bu, 0x000002d0u, 0x00000000u, 0x00020011u, 0x00000001u, 0x00020011u, + 0x000014e3u, 0x0006000bu, 0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, + 0x000014e4u, 0x00000001u, 0x0007000fu, 0x00000005u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000026u, + 0x0000005au, 0x00060010u, 0x00000004u, 0x00000011u, 0x00000040u, 0x00000001u, 0x00000001u, 0x00030003u, + 0x00000002u, 0x000001ccu, 0x00070004u, 0x455f4c47u, 0x625f5458u, 0x65666675u, 0x65725f72u, 0x65726566u, + 0x0065636eu, 0x00040005u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00040005u, 0x0000001au, 0x61726150u, + 0x0000736du, 0x00060006u, 0x0000001au, 0x00000000u, 0x75677261u, 0x746e656du, 0x00000073u, 0x00050006u, + 0x0000001au, 0x00000001u, 0x6e756f63u, 0x00000074u, 0x00060006u, 0x0000001au, 0x00000002u, 0x6f636572u, + 0x5f736472u, 0x0074756fu, 0x00060006u, 0x0000001au, 0x00000003u, 0x6e756f63u, 0x756f5f74u, 0x00000074u, + 0x00050006u, 0x0000001au, 0x00000004u, 0x74617473u, 0x00000073u, 0x00060006u, 0x0000001au, 0x00000005u, + 0x7473696cu, 0x6475625fu, 0x00746567u, 0x00050006u, 0x0000001au, 0x00000006u, 0x646e696bu, 0x00000000u, + 0x00070006u, 0x0000001au, 0x00000007u, 0x69727473u, 0x775f6564u, 0x7364726fu, 0x00000000u, 0x00050006u, + 0x0000001au, 0x00000008u, 0x6f636572u, 0x00736472u, 0x00070006u, 0x0000001au, 0x00000009u, 0x73726966u, + 0x65725f74u, 0x64726f63u, 0x00000000u, 0x00060006u, 0x0000001au, 0x0000000au, 0x5f78616du, 0x6f636572u, + 0x00736472u, 0x00050006u, 0x0000001au, 0x0000000bu, 0x67616c66u, 0x00000073u, 0x00040005u, 0x0000001cu, + 0x73677241u, 0x00006e49u, 0x00050006u, 0x0000001cu, 0x00000000u, 0x61746164u, 0x00000000u, 0x00040005u, + 0x0000001eu, 0x6e756f43u, 0x006e4974u, 0x00050006u, 0x0000001eu, 0x00000000u, 0x61746164u, 0x00000000u, + 0x00040005u, 0x00000020u, 0x73677241u, 0x0074754fu, 0x00050006u, 0x00000020u, 0x00000000u, 0x61746164u, + 0x00000000u, 0x00050005u, 0x00000022u, 0x6e756f43u, 0x74754f74u, 0x00000000u, 0x00050006u, 0x00000022u, + 0x00000000u, 0x61746164u, 0x00000000u, 0x00040005u, 0x00000024u, 0x74617453u, 0x00000073u, 0x00050006u, + 0x00000024u, 0x00000000u, 0x61746164u, 0x00000000u, 0x00030005u, 0x00000026u, 0x00000070u, 0x00080005u, + 0x0000005au, 0x475f6c67u, 0x61626f6cu, 0x766e496cu, 0x7461636fu, 0x496e6f69u, 0x00000044u, 0x00040005u, + 0x00000116u, 0x64726f77u, 0x00000073u, 0x00030047u, 0x0000001au, 0x00000002u, 0x00050048u, 0x0000001au, + 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x0000001au, 0x00000001u, 0x00000023u, 0x00000008u, + 0x00050048u, 0x0000001au, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u, 0x0000001au, 0x00000003u, + 0x00000023u, 0x00000018u, 0x00050048u, 0x0000001au, 0x00000004u, 0x00000023u, 0x00000020u, 0x00050048u, + 0x0000001au, 0x00000005u, 0x00000023u, 0x00000028u, 0x00050048u, 0x0000001au, 0x00000006u, 0x00000023u, + 0x00000030u, 0x00050048u, 0x0000001au, 0x00000007u, 0x00000023u, 0x00000034u, 0x00050048u, 0x0000001au, + 0x00000008u, 0x00000023u, 0x00000038u, 0x00050048u, 0x0000001au, 0x00000009u, 0x00000023u, 0x0000003cu, + 0x00050048u, 0x0000001au, 0x0000000au, 0x00000023u, 0x00000040u, 0x00050048u, 0x0000001au, 0x0000000bu, + 0x00000023u, 0x00000044u, 0x00040047u, 0x0000001bu, 0x00000006u, 0x00000004u, 0x00030047u, 0x0000001cu, + 0x00000002u, 0x00040048u, 0x0000001cu, 0x00000000u, 0x00000018u, 0x00050048u, 0x0000001cu, 0x00000000u, + 0x00000023u, 0x00000000u, 0x00040047u, 0x0000001du, 0x00000006u, 0x00000004u, 0x00030047u, 0x0000001eu, + 0x00000002u, 0x00040048u, 0x0000001eu, 0x00000000u, 0x00000018u, 0x00050048u, 0x0000001eu, 0x00000000u, + 0x00000023u, 0x00000000u, 0x00040047u, 0x0000001fu, 0x00000006u, 0x00000004u, 0x00030047u, 0x00000020u, + 0x00000002u, 0x00050048u, 0x00000020u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00040047u, 0x00000021u, + 0x00000006u, 0x00000004u, 0x00030047u, 0x00000022u, 0x00000002u, 0x00050048u, 0x00000022u, 0x00000000u, + 0x00000023u, 0x00000000u, 0x00040047u, 0x00000023u, 0x00000006u, 0x00000004u, 0x00030047u, 0x00000024u, + 0x00000002u, 0x00050048u, 0x00000024u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00040047u, 0x0000005au, + 0x0000000bu, 0x0000001cu, 0x00040047u, 0x00000209u, 0x0000000bu, 0x00000019u, 0x00020013u, 0x00000002u, + 0x00030021u, 0x00000003u, 0x00000002u, 0x00040015u, 0x00000006u, 0x00000020u, 0x00000000u, 0x00040020u, + 0x00000007u, 0x00000007u, 0x00000006u, 0x00020014u, 0x00000008u, 0x0004002bu, 0x00000006u, 0x0000000eu, + 0x00000000u, 0x00030029u, 0x00000008u, 0x00000012u, 0x00030027u, 0x00000015u, 0x000014e5u, 0x00030027u, + 0x00000016u, 0x000014e5u, 0x00030027u, 0x00000017u, 0x000014e5u, 0x00030027u, 0x00000018u, 0x000014e5u, + 0x00030027u, 0x00000019u, 0x000014e5u, 0x000e001eu, 0x0000001au, 0x00000015u, 0x00000016u, 0x00000017u, + 0x00000018u, 0x00000019u, 0x00000019u, 0x00000006u, 0x00000006u, 0x00000006u, 0x00000006u, 0x00000006u, + 0x00000006u, 0x0003001du, 0x0000001bu, 0x00000006u, 0x0003001eu, 0x0000001cu, 0x0000001bu, 0x00040020u, + 0x00000015u, 0x000014e5u, 0x0000001cu, 0x0003001du, 0x0000001du, 0x00000006u, 0x0003001eu, 0x0000001eu, + 0x0000001du, 0x00040020u, 0x00000016u, 0x000014e5u, 0x0000001eu, 0x0003001du, 0x0000001fu, 0x00000006u, + 0x0003001eu, 0x00000020u, 0x0000001fu, 0x00040020u, 0x00000017u, 0x000014e5u, 0x00000020u, 0x0003001du, + 0x00000021u, 0x00000006u, 0x0003001eu, 0x00000022u, 0x00000021u, 0x00040020u, 0x00000018u, 0x000014e5u, + 0x00000022u, 0x0003001du, 0x00000023u, 0x00000006u, 0x0003001eu, 0x00000024u, 0x00000023u, 0x00040020u, + 0x00000019u, 0x000014e5u, 0x00000024u, 0x00040020u, 0x00000025u, 0x00000009u, 0x0000001au, 0x0004003bu, + 0x00000025u, 0x00000026u, 0x00000009u, 0x00040015u, 0x00000027u, 0x00000020u, 0x00000001u, 0x0004002bu, + 0x00000027u, 0x00000028u, 0x00000005u, 0x00040020u, 0x00000029u, 0x00000009u, 0x00000019u, 0x0004002bu, + 0x00000027u, 0x0000002cu, 0x00000000u, 0x00040020u, 0x0000002du, 0x000014e5u, 0x00000006u, 0x0004002bu, + 0x00000006u, 0x0000002fu, 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000037u, 0x08000000u, 0x0003002au, + 0x00000008u, 0x00000041u, 0x00040017u, 0x00000058u, 0x00000006u, 0x00000003u, 0x00040020u, 0x00000059u, + 0x00000001u, 0x00000058u, 0x0004003bu, 0x00000059u, 0x0000005au, 0x00000001u, 0x00040020u, 0x0000005bu, + 0x00000001u, 0x00000006u, 0x0004002bu, 0x00000027u, 0x0000005fu, 0x00000008u, 0x00040020u, 0x00000060u, + 0x00000009u, 0x00000006u, 0x0004002bu, 0x00000027u, 0x00000068u, 0x00000009u, 0x0004002bu, 0x00000027u, + 0x0000006eu, 0x00000006u, 0x0004002bu, 0x00000006u, 0x00000078u, 0x00000004u, 0x0004002bu, 0x00000006u, + 0x00000079u, 0x00000005u, 0x0004002bu, 0x00000006u, 0x0000007cu, 0x00000003u, 0x0004002bu, 0x00000027u, + 0x00000084u, 0x0000000bu, 0x0004002bu, 0x00000027u, 0x0000008au, 0x0000000au, 0x0004002bu, 0x00000027u, + 0x00000091u, 0x00000001u, 0x00040020u, 0x00000092u, 0x00000009u, 0x00000016u, 0x0004002bu, 0x00000027u, + 0x0000009eu, 0x00000003u, 0x00040020u, 0x0000009fu, 0x00000009u, 0x00000018u, 0x0004002bu, 0x00000027u, + 0x000000a9u, 0x00000004u, 0x0004002bu, 0x00000027u, 0x000000bcu, 0x00000002u, 0x00040020u, 0x000000bdu, + 0x00000009u, 0x00000017u, 0x0004002bu, 0x00000027u, 0x000000c9u, 0x00000007u, 0x00040020u, 0x000000dau, + 0x00000009u, 0x00000015u, 0x0004002bu, 0x00000006u, 0x000000e2u, 0xffffffffu, 0x0004001cu, 0x00000114u, + 0x00000006u, 0x00000079u, 0x00040020u, 0x00000115u, 0x00000007u, 0x00000114u, 0x0008002cu, 0x00000114u, + 0x00000117u, 0x0000000eu, 0x0000000eu, 0x0000000eu, 0x0000000eu, 0x0000000eu, 0x0004002bu, 0x00000006u, + 0x0000012eu, 0x01000000u, 0x0004002bu, 0x00000006u, 0x00000132u, 0x04000000u, 0x0004002bu, 0x00000006u, + 0x0000014du, 0x00000002u, 0x0004002bu, 0x00000006u, 0x0000017cu, 0x0000ffffu, 0x0004002bu, 0x00000006u, + 0x000001b0u, 0x00100000u, 0x0004002bu, 0x00000006u, 0x000001cbu, 0x00000080u, 0x0004002bu, 0x00000006u, + 0x000001ccu, 0x00000040u, 0x0006002cu, 0x00000058u, 0x00000209u, 0x000001ccu, 0x0000002fu, 0x0000002fu, + 0x00030001u, 0x00000008u, 0x00000288u, 0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, + 0x000200f8u, 0x00000005u, 0x0004003bu, 0x00000115u, 0x00000116u, 0x00000007u, 0x000300f7u, 0x0000020au, + 0x00000000u, 0x000300fbu, 0x0000000eu, 0x0000020bu, 0x000200f8u, 0x0000020bu, 0x00050041u, 0x0000005bu, + 0x0000005cu, 0x0000005au, 0x0000000eu, 0x0004003du, 0x00000006u, 0x0000005du, 0x0000005cu, 0x00050041u, + 0x00000060u, 0x00000061u, 0x00000026u, 0x0000005fu, 0x0004003du, 0x00000006u, 0x00000062u, 0x00000061u, + 0x000500aeu, 0x00000008u, 0x00000063u, 0x0000005du, 0x00000062u, 0x000300f7u, 0x00000065u, 0x00000000u, + 0x000400fau, 0x00000063u, 0x00000064u, 0x00000065u, 0x000200f8u, 0x00000064u, 0x000200f9u, 0x0000020au, + 0x000200f8u, 0x00000065u, 0x00050041u, 0x00000060u, 0x00000069u, 0x00000026u, 0x00000068u, 0x0004003du, + 0x00000006u, 0x0000006au, 0x00000069u, 0x00050080u, 0x00000006u, 0x0000006cu, 0x0000006au, 0x0000005du, + 0x00050041u, 0x00000060u, 0x0000006fu, 0x00000026u, 0x0000006eu, 0x0004003du, 0x00000006u, 0x00000070u, + 0x0000006fu, 0x000500b2u, 0x00000008u, 0x00000071u, 0x00000070u, 0x0000002fu, 0x000300f7u, 0x00000074u, + 0x00000000u, 0x000400fau, 0x00000071u, 0x00000073u, 0x0000007bu, 0x000200f8u, 0x00000073u, 0x000500aau, + 0x00000008u, 0x00000077u, 0x00000070u, 0x0000000eu, 0x000600a9u, 0x00000006u, 0x0000007au, 0x00000077u, + 0x00000078u, 0x00000079u, 0x000200f9u, 0x00000074u, 0x000200f8u, 0x0000007bu, 0x000200f9u, 0x00000074u, + 0x000200f8u, 0x00000074u, 0x000700f5u, 0x00000006u, 0x00000246u, 0x0000007au, 0x00000073u, 0x0000007cu, + 0x0000007bu, 0x00050084u, 0x00000006u, 0x00000081u, 0x0000005du, 0x00000246u, 0x00050041u, 0x00000060u, + 0x00000085u, 0x00000026u, 0x00000084u, 0x0004003du, 0x00000006u, 0x00000086u, 0x00000085u, 0x000500c7u, + 0x00000006u, 0x00000087u, 0x00000086u, 0x0000002fu, 0x000500abu, 0x00000008u, 0x00000088u, 0x00000087u, + 0x0000000eu, 0x00050041u, 0x00000060u, 0x0000008bu, 0x00000026u, 0x0000008au, 0x0004003du, 0x00000006u, + 0x0000008cu, 0x0000008bu, 0x000300f7u, 0x0000008fu, 0x00000000u, 0x000400fau, 0x00000088u, 0x0000008eu, + 0x0000008fu, 0x000200f8u, 0x0000008eu, 0x00050041u, 0x00000092u, 0x00000093u, 0x00000026u, 0x00000091u, + 0x0004003du, 0x00000016u, 0x00000094u, 0x00000093u, 0x00060041u, 0x0000002du, 0x00000095u, 0x00000094u, + 0x0000002cu, 0x0000002cu, 0x0006003du, 0x00000006u, 0x00000096u, 0x00000095u, 0x00000002u, 0x00000004u, + 0x0007000cu, 0x00000006u, 0x00000099u, 0x00000001u, 0x00000026u, 0x0000008cu, 0x00000096u, 0x000500aau, + 0x00000008u, 0x0000009bu, 0x0000006cu, 0x0000000eu, 0x000300f7u, 0x0000009du, 0x00000000u, 0x000400fau, + 0x0000009bu, 0x0000009cu, 0x0000009du, 0x000200f8u, 0x0000009cu, 0x00050041u, 0x0000009fu, 0x000000a0u, + 0x00000026u, 0x0000009eu, 0x0004003du, 0x00000018u, 0x000000a1u, 0x000000a0u, 0x00060041u, 0x0000002du, + 0x000000a3u, 0x000000a1u, 0x0000002cu, 0x0000002cu, 0x0005003eu, 0x000000a3u, 0x00000099u, 0x00000002u, + 0x00000004u, 0x000500abu, 0x00000008u, 0x000000a6u, 0x00000096u, 0x00000099u, 0x000300f7u, 0x000000a8u, + 0x00000000u, 0x000400fau, 0x000000a6u, 0x000000a7u, 0x000000a8u, 0x000200f8u, 0x000000a7u, 0x00050041u, + 0x00000029u, 0x000000aau, 0x00000026u, 0x000000a9u, 0x0004003du, 0x00000019u, 0x000000abu, 0x000000aau, + 0x00060041u, 0x0000002du, 0x000000acu, 0x000000abu, 0x0000002cu, 0x00000091u, 0x000700eau, 0x00000006u, + 0x000000adu, 0x000000acu, 0x0000002fu, 0x0000000eu, 0x0000002fu, 0x000200f9u, 0x000000a8u, 0x000200f8u, + 0x000000a8u, 0x000200f9u, 0x0000009du, 0x000200f8u, 0x0000009du, 0x000200f9u, 0x0000008fu, 0x000200f8u, + 0x0000008fu, 0x000700f5u, 0x00000006u, 0x0000024cu, 0x0000008cu, 0x00000074u, 0x00000099u, 0x0000009du, + 0x000500aeu, 0x00000008u, 0x000000b0u, 0x0000006cu, 0x0000024cu, 0x000300f7u, 0x000000b2u, 0x00000000u, + 0x000400fau, 0x000000b0u, 0x000000b1u, 0x000000b2u, 0x000200f8u, 0x000000b1u, 0x000200f9u, 0x000000b4u, + 0x000200f8u, 0x000000b4u, 0x000700f5u, 0x00000006u, 0x000002c2u, 0x0000000eu, 0x000000b1u, 0x000000c5u, + 0x000000b5u, 0x000500b0u, 0x00000008u, 0x000000bbu, 0x000002c2u, 0x00000246u, 0x000400f6u, 0x000000b6u, + 0x000000b5u, 0x00000000u, 0x000400fau, 0x000000bbu, 0x000000b5u, 0x000000b6u, 0x000200f8u, 0x000000b5u, + 0x00050041u, 0x000000bdu, 0x000000beu, 0x00000026u, 0x000000bcu, 0x0004003du, 0x00000017u, 0x000000bfu, + 0x000000beu, 0x00050080u, 0x00000006u, 0x000000c2u, 0x00000081u, 0x000002c2u, 0x00060041u, 0x0000002du, + 0x000000c3u, 0x000000bfu, 0x0000002cu, 0x000000c2u, 0x0005003eu, 0x000000c3u, 0x0000000eu, 0x00000002u, + 0x00000004u, 0x00050080u, 0x00000006u, 0x000000c5u, 0x000002c2u, 0x00000091u, 0x000200f9u, 0x000000b4u, + 0x000200f8u, 0x000000b6u, 0x000200f9u, 0x0000020au, 0x000200f8u, 0x000000b2u, 0x00050041u, 0x00000060u, + 0x000000cau, 0x00000026u, 0x000000c9u, 0x0004003du, 0x00000006u, 0x000000cbu, 0x000000cau, 0x00050084u, + 0x00000006u, 0x000000ccu, 0x0000005du, 0x000000cbu, 0x000200f9u, 0x000000cfu, 0x000200f8u, 0x000000cfu, + 0x000700f5u, 0x00000008u, 0x00000257u, 0x00000012u, 0x000000b2u, 0x000000e4u, 0x000000d2u, 0x000700f5u, + 0x00000006u, 0x00000252u, 0x0000000eu, 0x000000b2u, 0x000000e6u, 0x000000d2u, 0x000500b0u, 0x00000008u, + 0x000000d6u, 0x00000252u, 0x00000246u, 0x000400f6u, 0x000000d1u, 0x000000d2u, 0x00000000u, 0x000400fau, + 0x000000d6u, 0x000000d0u, 0x000000d1u, 0x000200f8u, 0x000000d0u, 0x000300f7u, 0x000000d9u, 0x00000000u, + 0x000400fau, 0x00000257u, 0x000000d8u, 0x000000d9u, 0x000200f8u, 0x000000d8u, 0x00050041u, 0x000000dau, + 0x000000dbu, 0x00000026u, 0x0000002cu, 0x0004003du, 0x00000015u, 0x000000dcu, 0x000000dbu, 0x00050080u, + 0x00000006u, 0x000000dfu, 0x000000ccu, 0x00000252u, 0x00060041u, 0x0000002du, 0x000000e0u, 0x000000dcu, + 0x0000002cu, 0x000000dfu, 0x0006003du, 0x00000006u, 0x000000e1u, 0x000000e0u, 0x00000002u, 0x00000004u, + 0x000500aau, 0x00000008u, 0x000000e3u, 0x000000e1u, 0x000000e2u, 0x000200f9u, 0x000000d9u, 0x000200f8u, + 0x000000d9u, 0x000700f5u, 0x00000008u, 0x000000e4u, 0x00000257u, 0x000000d0u, 0x000000e3u, 0x000000d8u, + 0x000200f9u, 0x000000d2u, 0x000200f8u, 0x000000d2u, 0x00050080u, 0x00000006u, 0x000000e6u, 0x00000252u, + 0x00000091u, 0x000200f9u, 0x000000cfu, 0x000200f8u, 0x000000d1u, 0x000400a8u, 0x00000008u, 0x000000e8u, + 0x00000257u, 0x000300f7u, 0x000000eau, 0x00000000u, 0x000400fau, 0x000000e8u, 0x000000e9u, 0x000000eau, + 0x000200f8u, 0x000000e9u, 0x000500aau, 0x00000008u, 0x000000edu, 0x00000070u, 0x0000007cu, 0x000300f7u, + 0x000000efu, 0x00000000u, 0x000400fau, 0x000000edu, 0x000000eeu, 0x000000efu, 0x000200f8u, 0x000000eeu, + 0x00050041u, 0x000000dau, 0x000000f0u, 0x00000026u, 0x0000002cu, 0x0004003du, 0x00000015u, 0x000000f1u, + 0x000000f0u, 0x00060041u, 0x0000002du, 0x000000f3u, 0x000000f1u, 0x0000002cu, 0x000000ccu, 0x0006003du, + 0x00000006u, 0x000000f4u, 0x000000f3u, 0x00000002u, 0x00000004u, 0x000500aau, 0x00000008u, 0x000000f5u, + 0x000000f4u, 0x000000e2u, 0x000200f9u, 0x000000efu, 0x000200f8u, 0x000000efu, 0x000700f5u, 0x00000008u, + 0x000000f6u, 0x000000edu, 0x000000e9u, 0x000000f5u, 0x000000eeu, 0x000200f9u, 0x000000eau, 0x000200f8u, + 0x000000eau, 0x000700f5u, 0x00000008u, 0x000000f7u, 0x00000257u, 0x000000d1u, 0x000000f6u, 0x000000efu, + 0x000300f7u, 0x000000f9u, 0x00000000u, 0x000400fau, 0x000000f7u, 0x000000f8u, 0x000000f9u, 0x000200f8u, + 0x000000f8u, 0x000200f9u, 0x000000fbu, 0x000200f8u, 0x000000fbu, 0x000700f5u, 0x00000006u, 0x000002beu, + 0x0000000eu, 0x000000f8u, 0x0000010au, 0x000000fcu, 0x000500b0u, 0x00000008u, 0x00000102u, 0x000002beu, + 0x00000246u, 0x000400f6u, 0x000000fdu, 0x000000fcu, 0x00000000u, 0x000400fau, 0x00000102u, 0x000000fcu, + 0x000000fdu, 0x000200f8u, 0x000000fcu, 0x00050041u, 0x000000bdu, 0x00000103u, 0x00000026u, 0x000000bcu, + 0x0004003du, 0x00000017u, 0x00000104u, 0x00000103u, 0x00050080u, 0x00000006u, 0x00000107u, 0x00000081u, + 0x000002beu, 0x00060041u, 0x0000002du, 0x00000108u, 0x00000104u, 0x0000002cu, 0x00000107u, 0x0005003eu, + 0x00000108u, 0x0000000eu, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x0000010au, 0x000002beu, + 0x00000091u, 0x000200f9u, 0x000000fbu, 0x000200f8u, 0x000000fdu, 0x00050041u, 0x00000029u, 0x0000010bu, + 0x00000026u, 0x000000a9u, 0x0004003du, 0x00000019u, 0x0000010cu, 0x0000010bu, 0x00060041u, 0x0000002du, + 0x0000010du, 0x0000010cu, 0x0000002cu, 0x0000002cu, 0x000700eau, 0x00000006u, 0x0000010eu, 0x0000010du, + 0x0000002fu, 0x0000000eu, 0x0000002fu, 0x00060041u, 0x0000002du, 0x00000111u, 0x0000010cu, 0x0000002cu, + 0x0000009eu, 0x000700eau, 0x00000006u, 0x00000112u, 0x00000111u, 0x0000002fu, 0x0000000eu, 0x0000002fu, + 0x000200f9u, 0x0000020au, 0x000200f8u, 0x000000f9u, 0x0003003eu, 0x00000116u, 0x00000117u, 0x000300f7u, + 0x0000011eu, 0x00000000u, 0x000400fau, 0x00000071u, 0x0000011du, 0x00000165u, 0x000200f8u, 0x0000011du, + 0x00050041u, 0x000000dau, 0x00000120u, 0x00000026u, 0x0000002cu, 0x0004003du, 0x00000015u, 0x00000121u, + 0x00000120u, 0x00060041u, 0x0000002du, 0x00000123u, 0x00000121u, 0x0000002cu, 0x000000ccu, 0x0006003du, + 0x00000006u, 0x00000124u, 0x00000123u, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000129u, + 0x000000ccu, 0x0000002fu, 0x00060041u, 0x0000002du, 0x0000012au, 0x00000121u, 0x0000002cu, 0x00000129u, + 0x0006003du, 0x00000006u, 0x0000012bu, 0x0000012au, 0x00000002u, 0x00000004u, 0x0007000cu, 0x00000006u, + 0x0000012fu, 0x00000001u, 0x00000026u, 0x00000124u, 0x0000012eu, 0x0007000cu, 0x00000006u, 0x00000134u, + 0x00000001u, 0x00000029u, 0x0000012fu, 0x0000002fu, 0x00050086u, 0x00000006u, 0x00000135u, 0x00000132u, + 0x00000134u, 0x0007000cu, 0x00000006u, 0x00000136u, 0x00000001u, 0x00000026u, 0x0000012bu, 0x00000135u, + 0x000500aau, 0x00000008u, 0x00000138u, 0x0000012fu, 0x0000000eu, 0x000600a9u, 0x00000006u, 0x000002c9u, + 0x00000138u, 0x0000000eu, 0x00000136u, 0x000500abu, 0x00000008u, 0x0000013du, 0x0000012fu, 0x00000124u, + 0x000500abu, 0x00000008u, 0x00000140u, 0x000002c9u, 0x0000012bu, 0x000500a6u, 0x00000008u, 0x00000141u, + 0x0000013du, 0x00000140u, 0x000600a9u, 0x00000006u, 0x00000142u, 0x00000141u, 0x0000002fu, 0x0000000eu, + 0x00050084u, 0x00000006u, 0x00000145u, 0x0000012fu, 0x000002c9u, 0x00050041u, 0x00000007u, 0x00000147u, + 0x00000116u, 0x0000002cu, 0x0003003eu, 0x00000147u, 0x0000012fu, 0x00050041u, 0x00000007u, 0x00000149u, + 0x00000116u, 0x00000091u, 0x0003003eu, 0x00000149u, 0x000002c9u, 0x00050080u, 0x00000006u, 0x0000014eu, + 0x000000ccu, 0x0000014du, 0x00060041u, 0x0000002du, 0x0000014fu, 0x00000121u, 0x0000002cu, 0x0000014eu, + 0x0006003du, 0x00000006u, 0x00000150u, 0x0000014fu, 0x00000002u, 0x00000004u, 0x00050041u, 0x00000007u, + 0x00000151u, 0x00000116u, 0x000000bcu, 0x0003003eu, 0x00000151u, 0x00000150u, 0x00050080u, 0x00000006u, + 0x00000155u, 0x000000ccu, 0x0000007cu, 0x00060041u, 0x0000002du, 0x00000156u, 0x00000121u, 0x0000002cu, + 0x00000155u, 0x0006003du, 0x00000006u, 0x00000157u, 0x00000156u, 0x00000002u, 0x00000004u, 0x00050041u, + 0x00000007u, 0x00000158u, 0x00000116u, 0x0000009eu, 0x0003003eu, 0x00000158u, 0x00000157u, 0x000500aau, + 0x00000008u, 0x0000015bu, 0x00000070u, 0x0000002fu, 0x000300f7u, 0x0000015du, 0x00000000u, 0x000400fau, + 0x0000015bu, 0x0000015cu, 0x0000015du, 0x000200f8u, 0x0000015cu, 0x00050080u, 0x00000006u, 0x00000161u, + 0x000000ccu, 0x00000078u, 0x00060041u, 0x0000002du, 0x00000162u, 0x00000121u, 0x0000002cu, 0x00000161u, + 0x0006003du, 0x00000006u, 0x00000163u, 0x00000162u, 0x00000002u, 0x00000004u, 0x00050041u, 0x00000007u, + 0x00000164u, 0x00000116u, 0x000000a9u, 0x0003003eu, 0x00000164u, 0x00000163u, 0x000200f9u, 0x0000015du, + 0x000200f8u, 0x0000015du, 0x000200f9u, 0x0000011eu, 0x000200f8u, 0x00000165u, 0x00050041u, 0x000000dau, + 0x00000167u, 0x00000026u, 0x0000002cu, 0x0004003du, 0x00000015u, 0x00000168u, 0x00000167u, 0x00060041u, + 0x0000002du, 0x0000016au, 0x00000168u, 0x0000002cu, 0x000000ccu, 0x0006003du, 0x00000006u, 0x0000016bu, + 0x0000016au, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000170u, 0x000000ccu, 0x0000002fu, + 0x00060041u, 0x0000002du, 0x00000171u, 0x00000168u, 0x0000002cu, 0x00000170u, 0x0006003du, 0x00000006u, + 0x00000172u, 0x00000171u, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000177u, 0x000000ccu, + 0x0000014du, 0x00060041u, 0x0000002du, 0x00000178u, 0x00000168u, 0x0000002cu, 0x00000177u, 0x0006003du, + 0x00000006u, 0x00000179u, 0x00000178u, 0x00000002u, 0x00000004u, 0x0007000cu, 0x00000006u, 0x0000017du, + 0x00000001u, 0x00000026u, 0x0000016bu, 0x0000017cu, 0x0007000cu, 0x00000006u, 0x00000180u, 0x00000001u, + 0x00000026u, 0x00000172u, 0x0000017cu, 0x0007000cu, 0x00000006u, 0x00000183u, 0x00000001u, 0x00000026u, + 0x00000179u, 0x0000017cu, 0x000500aau, 0x00000008u, 0x00000186u, 0x00000070u, 0x0000007cu, 0x000600a9u, + 0x00000006u, 0x000002cau, 0x00000186u, 0x0000002fu, 0x00000183u, 0x000600a9u, 0x00000006u, 0x000002cbu, + 0x00000186u, 0x0000002fu, 0x00000180u, 0x000500c2u, 0x00000006u, 0x0000018cu, 0x00000086u, 0x0000002fu, + 0x000500abu, 0x00000008u, 0x0000018eu, 0x0000018cu, 0x0000000eu, 0x000500abu, 0x00000008u, 0x00000190u, + 0x0000017du, 0x0000000eu, 0x000500a7u, 0x00000008u, 0x00000191u, 0x0000018eu, 0x00000190u, 0x000500abu, + 0x00000008u, 0x00000193u, 0x000002cbu, 0x0000000eu, 0x000500a7u, 0x00000008u, 0x00000194u, 0x00000191u, + 0x00000193u, 0x000500abu, 0x00000008u, 0x00000196u, 0x000002cau, 0x0000000eu, 0x000500a7u, 0x00000008u, + 0x00000197u, 0x00000194u, 0x00000196u, 0x000300f7u, 0x00000199u, 0x00000000u, 0x000400fau, 0x00000197u, + 0x00000198u, 0x00000199u, 0x000200f8u, 0x00000198u, 0x0007000cu, 0x00000006u, 0x0000019cu, 0x00000001u, + 0x00000026u, 0x0000017du, 0x0000018cu, 0x00050086u, 0x00000006u, 0x000001a0u, 0x0000018cu, 0x0000019cu, + 0x0007000cu, 0x00000006u, 0x000001a1u, 0x00000001u, 0x00000026u, 0x000002cbu, 0x000001a0u, 0x00050086u, + 0x00000006u, 0x000001a7u, 0x000001a0u, 0x000001a1u, 0x0007000cu, 0x00000006u, 0x000001a8u, 0x00000001u, + 0x00000026u, 0x000002cau, 0x000001a7u, 0x000200f9u, 0x00000199u, 0x000200f8u, 0x00000199u, 0x000700f5u, + 0x00000006u, 0x00000260u, 0x000002cbu, 0x00000165u, 0x000001a1u, 0x00000198u, 0x000700f5u, 0x00000006u, + 0x0000025fu, 0x0000017du, 0x00000165u, 0x0000019cu, 0x00000198u, 0x000700f5u, 0x00000006u, 0x0000025eu, + 0x000002cau, 0x00000165u, 0x000001a8u, 0x00000198u, 0x000500abu, 0x00000008u, 0x000001aau, 0x0000025eu, + 0x0000000eu, 0x000300f7u, 0x000001acu, 0x00000000u, 0x000400fau, 0x000001aau, 0x000001abu, 0x000001acu, + 0x000200f8u, 0x000001abu, 0x00050084u, 0x00000006u, 0x000001afu, 0x0000025fu, 0x00000260u, 0x00050086u, + 0x00000006u, 0x000001b2u, 0x000001b0u, 0x0000025eu, 0x000500acu, 0x00000008u, 0x000001b3u, 0x000001afu, + 0x000001b2u, 0x000200f9u, 0x000001acu, 0x000200f8u, 0x000001acu, 0x000700f5u, 0x00000008u, 0x000001b4u, + 0x000001aau, 0x00000199u, 0x000001b3u, 0x000001abu, 0x000600a9u, 0x00000006u, 0x000002ccu, 0x000001b4u, + 0x0000000eu, 0x0000025eu, 0x000600a9u, 0x00000006u, 0x000002cdu, 0x000001b4u, 0x0000000eu, 0x00000260u, + 0x000600a9u, 0x00000006u, 0x000002ceu, 0x000001b4u, 0x0000000eu, 0x0000025fu, 0x000500abu, 0x00000008u, + 0x000001b9u, 0x000002ceu, 0x0000016bu, 0x000500abu, 0x00000008u, 0x000001bcu, 0x000002cdu, 0x00000172u, + 0x000500a6u, 0x00000008u, 0x000001bdu, 0x000001b9u, 0x000001bcu, 0x000500abu, 0x00000008u, 0x000001c0u, + 0x000002ccu, 0x00000179u, 0x000500a6u, 0x00000008u, 0x000001c1u, 0x000001bdu, 0x000001c0u, 0x000600a9u, + 0x00000006u, 0x000001c2u, 0x000001c1u, 0x0000002fu, 0x0000000eu, 0x00050084u, 0x00000006u, 0x000001c5u, + 0x000002ceu, 0x000002cdu, 0x00050084u, 0x00000006u, 0x000001c7u, 0x000001c5u, 0x000002ccu, 0x000600a9u, + 0x00000006u, 0x000001cdu, 0x00000186u, 0x000001cbu, 0x000001ccu, 0x00050084u, 0x00000006u, 0x000001ceu, + 0x000001c7u, 0x000001cdu, 0x00050041u, 0x00000007u, 0x000001d0u, 0x00000116u, 0x0000002cu, 0x0003003eu, + 0x000001d0u, 0x000002ceu, 0x00050041u, 0x00000007u, 0x000001d2u, 0x00000116u, 0x00000091u, 0x0003003eu, + 0x000001d2u, 0x000002cdu, 0x00050041u, 0x00000007u, 0x000001d4u, 0x00000116u, 0x000000bcu, 0x0003003eu, + 0x000001d4u, 0x000002ccu, 0x000200f9u, 0x0000011eu, 0x000200f8u, 0x0000011eu, 0x000700f5u, 0x00000006u, + 0x00000292u, 0x00000142u, 0x0000015du, 0x000001c2u, 0x000001acu, 0x000700f5u, 0x00000006u, 0x00000278u, + 0x00000145u, 0x0000015du, 0x000001ceu, 0x000001acu, 0x000500abu, 0x00000008u, 0x000001d6u, 0x00000278u, + 0x0000000eu, 0x000300f7u, 0x000001d8u, 0x00000000u, 0x000400fau, 0x000001d6u, 0x000001d7u, 0x000001d8u, + 0x000200f8u, 0x000001d7u, 0x000300f7u, 0x00000244u, 0x00000000u, 0x000300fbu, 0x0000000eu, 0x0000021cu, + 0x000200f8u, 0x0000021cu, 0x000500aau, 0x00000008u, 0x0000021eu, 0x00000278u, 0x0000000eu, 0x000300f7u, + 0x00000220u, 0x00000000u, 0x000400fau, 0x0000021eu, 0x0000021fu, 0x00000220u, 0x000200f8u, 0x0000021fu, + 0x000200f9u, 0x00000244u, 0x000200f8u, 0x00000220u, 0x00050041u, 0x00000029u, 0x00000221u, 0x00000026u, + 0x00000028u, 0x0004003du, 0x00000019u, 0x00000222u, 0x00000221u, 0x00060041u, 0x0000002du, 0x00000223u, + 0x00000222u, 0x0000002cu, 0x0000002cu, 0x000700eau, 0x00000006u, 0x00000224u, 0x00000223u, 0x0000002fu, + 0x0000000eu, 0x0000000eu, 0x000200f9u, 0x00000225u, 0x000200f8u, 0x00000225u, 0x000700f5u, 0x00000006u, + 0x0000027au, 0x00000224u, 0x00000220u, 0x00000239u, 0x00000240u, 0x000500b0u, 0x00000008u, 0x00000228u, + 0x0000027au, 0x00000037u, 0x000400f6u, 0x00000241u, 0x00000240u, 0x00000000u, 0x000400fau, 0x00000228u, + 0x00000229u, 0x00000241u, 0x000200f8u, 0x00000229u, 0x00050082u, 0x00000006u, 0x0000022bu, 0x00000037u, + 0x0000027au, 0x000500acu, 0x00000008u, 0x0000022eu, 0x00000278u, 0x0000022bu, 0x000300f7u, 0x00000230u, + 0x00000000u, 0x000400fau, 0x0000022eu, 0x0000022fu, 0x00000230u, 0x000200f8u, 0x0000022fu, 0x000200f9u, + 0x00000241u, 0x000200f8u, 0x00000230u, 0x00050080u, 0x00000006u, 0x00000233u, 0x0000027au, 0x00000278u, + 0x000900e6u, 0x00000006u, 0x00000239u, 0x00000223u, 0x0000002fu, 0x0000000eu, 0x0000000eu, 0x00000233u, + 0x0000027au, 0x000500aau, 0x00000008u, 0x0000023cu, 0x00000239u, 0x0000027au, 0x000300f7u, 0x0000023eu, + 0x00000000u, 0x000400fau, 0x0000023cu, 0x0000023du, 0x0000023eu, 0x000200f8u, 0x0000023du, 0x000200f9u, + 0x00000241u, 0x000200f8u, 0x0000023eu, 0x000200f9u, 0x00000240u, 0x000200f8u, 0x00000240u, 0x000200f9u, + 0x00000225u, 0x000200f8u, 0x00000241u, 0x000900f5u, 0x00000008u, 0x0000027fu, 0x00000288u, 0x00000225u, + 0x00000041u, 0x0000022fu, 0x00000012u, 0x0000023du, 0x000900f5u, 0x00000008u, 0x0000027cu, 0x00000041u, + 0x00000225u, 0x00000012u, 0x0000022fu, 0x00000012u, 0x0000023du, 0x000300f7u, 0x00000243u, 0x00000000u, + 0x000400fau, 0x0000027cu, 0x00000244u, 0x00000243u, 0x000200f8u, 0x00000243u, 0x000200f9u, 0x00000244u, + 0x000200f8u, 0x00000244u, 0x000900f5u, 0x00000008u, 0x0000027eu, 0x00000012u, 0x0000021fu, 0x0000027fu, + 0x00000241u, 0x00000041u, 0x00000243u, 0x000400a8u, 0x00000008u, 0x000001dcu, 0x0000027eu, 0x000200f9u, + 0x000001d8u, 0x000200f8u, 0x000001d8u, 0x000700f5u, 0x00000008u, 0x000001ddu, 0x000001d6u, 0x0000011eu, + 0x000001dcu, 0x00000244u, 0x000300f7u, 0x000001dfu, 0x00000000u, 0x000400fau, 0x000001ddu, 0x000001deu, + 0x000001dfu, 0x000200f8u, 0x000001deu, 0x00050041u, 0x00000029u, 0x000001e0u, 0x00000026u, 0x000000a9u, + 0x0004003du, 0x00000019u, 0x000001e1u, 0x000001e0u, 0x00060041u, 0x0000002du, 0x000001e2u, 0x000001e1u, + 0x0000002cu, 0x000000bcu, 0x000700eau, 0x00000006u, 0x000001e3u, 0x000001e2u, 0x0000002fu, 0x0000000eu, + 0x0000002fu, 0x0003003eu, 0x00000116u, 0x00000117u, 0x000200f9u, 0x000001dfu, 0x000200f8u, 0x000001dfu, + 0x000600a9u, 0x00000006u, 0x000002cfu, 0x000001ddu, 0x0000002fu, 0x00000292u, 0x000500abu, 0x00000008u, + 0x000001e5u, 0x000002cfu, 0x0000000eu, 0x000300f7u, 0x000001e7u, 0x00000000u, 0x000400fau, 0x000001e5u, + 0x000001e6u, 0x000001e7u, 0x000200f8u, 0x000001e6u, 0x00050041u, 0x00000029u, 0x000001e8u, 0x00000026u, + 0x000000a9u, 0x0004003du, 0x00000019u, 0x000001e9u, 0x000001e8u, 0x00060041u, 0x0000002du, 0x000001eau, + 0x000001e9u, 0x0000002cu, 0x0000002cu, 0x000700eau, 0x00000006u, 0x000001ebu, 0x000001eau, 0x0000002fu, + 0x0000000eu, 0x0000002fu, 0x00050041u, 0x00000007u, 0x000001ecu, 0x00000116u, 0x0000002cu, 0x0004003du, + 0x00000006u, 0x000001edu, 0x000001ecu, 0x000500aau, 0x00000008u, 0x000001eeu, 0x000001edu, 0x0000000eu, + 0x000300f7u, 0x000001f0u, 0x00000000u, 0x000400fau, 0x000001eeu, 0x000001efu, 0x000001f0u, 0x000200f8u, + 0x000001efu, 0x00060041u, 0x0000002du, 0x000001f3u, 0x000001e9u, 0x0000002cu, 0x0000009eu, 0x000700eau, + 0x00000006u, 0x000001f4u, 0x000001f3u, 0x0000002fu, 0x0000000eu, 0x0000002fu, 0x000200f9u, 0x000001f0u, + 0x000200f8u, 0x000001f0u, 0x000200f9u, 0x000001e7u, 0x000200f8u, 0x000001e7u, 0x000200f9u, 0x000001f6u, + 0x000200f8u, 0x000001f6u, 0x000700f5u, 0x00000006u, 0x00000297u, 0x0000000eu, 0x000001e7u, 0x00000208u, + 0x000001f7u, 0x000500b0u, 0x00000008u, 0x000001fdu, 0x00000297u, 0x00000246u, 0x000400f6u, 0x000001f8u, + 0x000001f7u, 0x00000000u, 0x000400fau, 0x000001fdu, 0x000001f7u, 0x000001f8u, 0x000200f8u, 0x000001f7u, + 0x00050041u, 0x000000bdu, 0x000001feu, 0x00000026u, 0x000000bcu, 0x0004003du, 0x00000017u, 0x000001ffu, + 0x000001feu, 0x00050080u, 0x00000006u, 0x00000202u, 0x00000081u, 0x00000297u, 0x00050041u, 0x00000007u, + 0x00000204u, 0x00000116u, 0x00000297u, 0x0004003du, 0x00000006u, 0x00000205u, 0x00000204u, 0x00060041u, + 0x0000002du, 0x00000206u, 0x000001ffu, 0x0000002cu, 0x00000202u, 0x0005003eu, 0x00000206u, 0x00000205u, + 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000208u, 0x00000297u, 0x00000091u, 0x000200f9u, + 0x000001f6u, 0x000200f8u, 0x000001f8u, 0x000200f9u, 0x0000020au, 0x000200f8u, 0x0000020au, 0x000100fdu, + 0x00010038u, +}; +} // namespace leonida diff --git a/runtime/src/indirect_dispatch_count.comp b/runtime/src/indirect_dispatch_count.comp index 9cbc371d9a..aafae093ba 100644 --- a/runtime/src/indirect_dispatch_count.comp +++ b/runtime/src/indirect_dispatch_count.comp @@ -16,16 +16,29 @@ layout(push_constant) uniform Params { uint stride_words; uint first_record; uint records; + uint budget; + uint has_count; } p; void main() { const uint local_record = gl_GlobalInvocationID.x; if (local_record >= p.records) return; const uint target = local_record * 3u; - if (p.first_record + local_record < p.count.data[0]) { + if (p.has_count == 0u || p.first_record + local_record < p.count.data[0]) { const uint source = local_record * p.stride_words; - p.output_words.data[target] = p.arguments.data[source]; - p.output_words.data[target + 1u] = p.arguments.data[source + 1u]; - p.output_words.data[target + 2u] = p.arguments.data[source + 2u]; + uvec3 groups = uvec3(p.arguments.data[source], p.arguments.data[source + 1u], + p.arguments.data[source + 2u]); + if (p.budget != 0u) { + if (any(equal(groups, uvec3(0u)))) groups = uvec3(0u); + else { + groups.x = min(groups.x, p.budget); + uint remaining = p.budget / groups.x; + groups.y = min(groups.y, remaining); + groups.z = min(groups.z, remaining / groups.y); + } + } + p.output_words.data[target] = groups.x; + p.output_words.data[target + 1u] = groups.y; + p.output_words.data[target + 2u] = groups.z; } else { p.output_words.data[target] = 0u; p.output_words.data[target + 1u] = 0u; diff --git a/runtime/src/indirect_dispatch_count_spv.h b/runtime/src/indirect_dispatch_count_spv.h index 9cf7bbae53..dd317b27b8 100644 --- a/runtime/src/indirect_dispatch_count_spv.h +++ b/runtime/src/indirect_dispatch_count_spv.h @@ -3,7 +3,7 @@ #include namespace leonida { inline constexpr std::uint32_t indirect_dispatch_count_spirv[] = { - 0x07230203u, 0x00010500u, 0x0008000bu, 0x00000074u, 0x00000000u, 0x00020011u, 0x00000001u, 0x00020011u, + 0x07230203u, 0x00010500u, 0x0008000bu, 0x000000c5u, 0x00000000u, 0x00020011u, 0x00000001u, 0x00020011u, 0x000014e3u, 0x0006000bu, 0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x000014e4u, 0x00000001u, 0x0007000fu, 0x00000005u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x0000000bu, 0x00000019u, 0x00060010u, 0x00000004u, 0x00000011u, 0x00000040u, 0x00000001u, 0x00000001u, 0x00030003u, @@ -14,71 +14,97 @@ inline constexpr std::uint32_t indirect_dispatch_count_spirv[] = { 0x00000013u, 0x00000001u, 0x6e756f63u, 0x00000074u, 0x00070006u, 0x00000013u, 0x00000002u, 0x7074756fu, 0x775f7475u, 0x7364726fu, 0x00000000u, 0x00070006u, 0x00000013u, 0x00000003u, 0x69727473u, 0x775f6564u, 0x7364726fu, 0x00000000u, 0x00070006u, 0x00000013u, 0x00000004u, 0x73726966u, 0x65725f74u, 0x64726f63u, - 0x00000000u, 0x00050006u, 0x00000013u, 0x00000005u, 0x6f636572u, 0x00736472u, 0x00040005u, 0x00000015u, - 0x64726f57u, 0x006e4973u, 0x00050006u, 0x00000015u, 0x00000000u, 0x61746164u, 0x00000000u, 0x00050005u, - 0x00000017u, 0x64726f57u, 0x74754f73u, 0x00000000u, 0x00050006u, 0x00000017u, 0x00000000u, 0x61746164u, - 0x00000000u, 0x00030005u, 0x00000019u, 0x00000070u, 0x00040047u, 0x0000000bu, 0x0000000bu, 0x0000001cu, - 0x00030047u, 0x00000013u, 0x00000002u, 0x00050048u, 0x00000013u, 0x00000000u, 0x00000023u, 0x00000000u, - 0x00050048u, 0x00000013u, 0x00000001u, 0x00000023u, 0x00000008u, 0x00050048u, 0x00000013u, 0x00000002u, - 0x00000023u, 0x00000010u, 0x00050048u, 0x00000013u, 0x00000003u, 0x00000023u, 0x00000018u, 0x00050048u, - 0x00000013u, 0x00000004u, 0x00000023u, 0x0000001cu, 0x00050048u, 0x00000013u, 0x00000005u, 0x00000023u, - 0x00000020u, 0x00040047u, 0x00000014u, 0x00000006u, 0x00000004u, 0x00030047u, 0x00000015u, 0x00000002u, - 0x00040048u, 0x00000015u, 0x00000000u, 0x00000018u, 0x00050048u, 0x00000015u, 0x00000000u, 0x00000023u, - 0x00000000u, 0x00040047u, 0x00000016u, 0x00000006u, 0x00000004u, 0x00030047u, 0x00000017u, 0x00000002u, - 0x00050048u, 0x00000017u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00040047u, 0x00000071u, 0x0000000bu, - 0x00000019u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, 0x00040015u, 0x00000006u, - 0x00000020u, 0x00000000u, 0x00040017u, 0x00000009u, 0x00000006u, 0x00000003u, 0x00040020u, 0x0000000au, - 0x00000001u, 0x00000009u, 0x0004003bu, 0x0000000au, 0x0000000bu, 0x00000001u, 0x0004002bu, 0x00000006u, - 0x0000000cu, 0x00000000u, 0x00040020u, 0x0000000du, 0x00000001u, 0x00000006u, 0x00030027u, 0x00000011u, - 0x000014e5u, 0x00030027u, 0x00000012u, 0x000014e5u, 0x0008001eu, 0x00000013u, 0x00000011u, 0x00000011u, - 0x00000012u, 0x00000006u, 0x00000006u, 0x00000006u, 0x0003001du, 0x00000014u, 0x00000006u, 0x0003001eu, - 0x00000015u, 0x00000014u, 0x00040020u, 0x00000011u, 0x000014e5u, 0x00000015u, 0x0003001du, 0x00000016u, - 0x00000006u, 0x0003001eu, 0x00000017u, 0x00000016u, 0x00040020u, 0x00000012u, 0x000014e5u, 0x00000017u, - 0x00040020u, 0x00000018u, 0x00000009u, 0x00000013u, 0x0004003bu, 0x00000018u, 0x00000019u, 0x00000009u, - 0x00040015u, 0x0000001au, 0x00000020u, 0x00000001u, 0x0004002bu, 0x0000001au, 0x0000001bu, 0x00000005u, - 0x00040020u, 0x0000001cu, 0x00000009u, 0x00000006u, 0x00020014u, 0x0000001fu, 0x0004002bu, 0x00000006u, - 0x00000026u, 0x00000003u, 0x0004002bu, 0x0000001au, 0x00000028u, 0x00000004u, 0x0004002bu, 0x0000001au, - 0x0000002du, 0x00000001u, 0x00040020u, 0x0000002eu, 0x00000009u, 0x00000011u, 0x0004002bu, 0x0000001au, - 0x00000031u, 0x00000000u, 0x00040020u, 0x00000032u, 0x000014e5u, 0x00000006u, 0x0004002bu, 0x0000001au, - 0x0000003au, 0x00000003u, 0x0004002bu, 0x0000001au, 0x0000003eu, 0x00000002u, 0x00040020u, 0x0000003fu, - 0x00000009u, 0x00000012u, 0x0004002bu, 0x00000006u, 0x0000004cu, 0x00000001u, 0x0004002bu, 0x00000006u, - 0x00000058u, 0x00000002u, 0x0004002bu, 0x00000006u, 0x00000070u, 0x00000040u, 0x0006002cu, 0x00000009u, - 0x00000071u, 0x00000070u, 0x0000004cu, 0x0000004cu, 0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u, - 0x00000003u, 0x000200f8u, 0x00000005u, 0x000300f7u, 0x00000072u, 0x00000000u, 0x000300fbu, 0x0000000cu, - 0x00000073u, 0x000200f8u, 0x00000073u, 0x00050041u, 0x0000000du, 0x0000000eu, 0x0000000bu, 0x0000000cu, - 0x0004003du, 0x00000006u, 0x0000000fu, 0x0000000eu, 0x00050041u, 0x0000001cu, 0x0000001du, 0x00000019u, - 0x0000001bu, 0x0004003du, 0x00000006u, 0x0000001eu, 0x0000001du, 0x000500aeu, 0x0000001fu, 0x00000020u, - 0x0000000fu, 0x0000001eu, 0x000300f7u, 0x00000022u, 0x00000000u, 0x000400fau, 0x00000020u, 0x00000021u, - 0x00000022u, 0x000200f8u, 0x00000021u, 0x000200f9u, 0x00000072u, 0x000200f8u, 0x00000022u, 0x00050084u, - 0x00000006u, 0x00000027u, 0x0000000fu, 0x00000026u, 0x00050041u, 0x0000001cu, 0x00000029u, 0x00000019u, - 0x00000028u, 0x0004003du, 0x00000006u, 0x0000002au, 0x00000029u, 0x00050080u, 0x00000006u, 0x0000002cu, - 0x0000002au, 0x0000000fu, 0x00050041u, 0x0000002eu, 0x0000002fu, 0x00000019u, 0x0000002du, 0x0004003du, - 0x00000011u, 0x00000030u, 0x0000002fu, 0x00060041u, 0x00000032u, 0x00000033u, 0x00000030u, 0x00000031u, - 0x00000031u, 0x0006003du, 0x00000006u, 0x00000034u, 0x00000033u, 0x00000002u, 0x00000004u, 0x000500b0u, - 0x0000001fu, 0x00000035u, 0x0000002cu, 0x00000034u, 0x000300f7u, 0x00000037u, 0x00000000u, 0x000400fau, - 0x00000035u, 0x00000036u, 0x00000061u, 0x000200f8u, 0x00000036u, 0x00050041u, 0x0000001cu, 0x0000003bu, - 0x00000019u, 0x0000003au, 0x0004003du, 0x00000006u, 0x0000003cu, 0x0000003bu, 0x00050084u, 0x00000006u, - 0x0000003du, 0x0000000fu, 0x0000003cu, 0x00050041u, 0x0000003fu, 0x00000040u, 0x00000019u, 0x0000003eu, - 0x0004003du, 0x00000012u, 0x00000041u, 0x00000040u, 0x00050041u, 0x0000002eu, 0x00000043u, 0x00000019u, - 0x00000031u, 0x0004003du, 0x00000011u, 0x00000044u, 0x00000043u, 0x00060041u, 0x00000032u, 0x00000046u, - 0x00000044u, 0x00000031u, 0x0000003du, 0x0006003du, 0x00000006u, 0x00000047u, 0x00000046u, 0x00000002u, - 0x00000004u, 0x00060041u, 0x00000032u, 0x00000048u, 0x00000041u, 0x00000031u, 0x00000027u, 0x0005003eu, - 0x00000048u, 0x00000047u, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x0000004du, 0x00000027u, - 0x0000004cu, 0x00050080u, 0x00000006u, 0x00000051u, 0x0000003du, 0x0000004cu, 0x00060041u, 0x00000032u, - 0x00000052u, 0x00000044u, 0x00000031u, 0x00000051u, 0x0006003du, 0x00000006u, 0x00000053u, 0x00000052u, - 0x00000002u, 0x00000004u, 0x00060041u, 0x00000032u, 0x00000054u, 0x00000041u, 0x00000031u, 0x0000004du, - 0x0005003eu, 0x00000054u, 0x00000053u, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000059u, - 0x00000027u, 0x00000058u, 0x00050080u, 0x00000006u, 0x0000005du, 0x0000003du, 0x00000058u, 0x00060041u, - 0x00000032u, 0x0000005eu, 0x00000044u, 0x00000031u, 0x0000005du, 0x0006003du, 0x00000006u, 0x0000005fu, - 0x0000005eu, 0x00000002u, 0x00000004u, 0x00060041u, 0x00000032u, 0x00000060u, 0x00000041u, 0x00000031u, - 0x00000059u, 0x0005003eu, 0x00000060u, 0x0000005fu, 0x00000002u, 0x00000004u, 0x000200f9u, 0x00000037u, - 0x000200f8u, 0x00000061u, 0x00050041u, 0x0000003fu, 0x00000062u, 0x00000019u, 0x0000003eu, 0x0004003du, - 0x00000012u, 0x00000063u, 0x00000062u, 0x00060041u, 0x00000032u, 0x00000065u, 0x00000063u, 0x00000031u, - 0x00000027u, 0x0005003eu, 0x00000065u, 0x0000000cu, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, - 0x00000069u, 0x00000027u, 0x0000004cu, 0x00060041u, 0x00000032u, 0x0000006au, 0x00000063u, 0x00000031u, - 0x00000069u, 0x0005003eu, 0x0000006au, 0x0000000cu, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, - 0x0000006eu, 0x00000027u, 0x00000058u, 0x00060041u, 0x00000032u, 0x0000006fu, 0x00000063u, 0x00000031u, - 0x0000006eu, 0x0005003eu, 0x0000006fu, 0x0000000cu, 0x00000002u, 0x00000004u, 0x000200f9u, 0x00000037u, - 0x000200f8u, 0x00000037u, 0x000200f9u, 0x00000072u, 0x000200f8u, 0x00000072u, 0x000100fdu, 0x00010038u, + 0x00000000u, 0x00050006u, 0x00000013u, 0x00000005u, 0x6f636572u, 0x00736472u, 0x00050006u, 0x00000013u, + 0x00000006u, 0x67647562u, 0x00007465u, 0x00060006u, 0x00000013u, 0x00000007u, 0x5f736168u, 0x6e756f63u, + 0x00000074u, 0x00040005u, 0x00000015u, 0x64726f57u, 0x006e4973u, 0x00050006u, 0x00000015u, 0x00000000u, + 0x61746164u, 0x00000000u, 0x00050005u, 0x00000017u, 0x64726f57u, 0x74754f73u, 0x00000000u, 0x00050006u, + 0x00000017u, 0x00000000u, 0x61746164u, 0x00000000u, 0x00030005u, 0x00000019u, 0x00000070u, 0x00040047u, + 0x0000000bu, 0x0000000bu, 0x0000001cu, 0x00030047u, 0x00000013u, 0x00000002u, 0x00050048u, 0x00000013u, + 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000013u, 0x00000001u, 0x00000023u, 0x00000008u, + 0x00050048u, 0x00000013u, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u, 0x00000013u, 0x00000003u, + 0x00000023u, 0x00000018u, 0x00050048u, 0x00000013u, 0x00000004u, 0x00000023u, 0x0000001cu, 0x00050048u, + 0x00000013u, 0x00000005u, 0x00000023u, 0x00000020u, 0x00050048u, 0x00000013u, 0x00000006u, 0x00000023u, + 0x00000024u, 0x00050048u, 0x00000013u, 0x00000007u, 0x00000023u, 0x00000028u, 0x00040047u, 0x00000014u, + 0x00000006u, 0x00000004u, 0x00030047u, 0x00000015u, 0x00000002u, 0x00040048u, 0x00000015u, 0x00000000u, + 0x00000018u, 0x00050048u, 0x00000015u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00040047u, 0x00000016u, + 0x00000006u, 0x00000004u, 0x00030047u, 0x00000017u, 0x00000002u, 0x00050048u, 0x00000017u, 0x00000000u, + 0x00000023u, 0x00000000u, 0x00040047u, 0x000000a9u, 0x0000000bu, 0x00000019u, 0x00020013u, 0x00000002u, + 0x00030021u, 0x00000003u, 0x00000002u, 0x00040015u, 0x00000006u, 0x00000020u, 0x00000000u, 0x00040017u, + 0x00000009u, 0x00000006u, 0x00000003u, 0x00040020u, 0x0000000au, 0x00000001u, 0x00000009u, 0x0004003bu, + 0x0000000au, 0x0000000bu, 0x00000001u, 0x0004002bu, 0x00000006u, 0x0000000cu, 0x00000000u, 0x00040020u, + 0x0000000du, 0x00000001u, 0x00000006u, 0x00030027u, 0x00000011u, 0x000014e5u, 0x00030027u, 0x00000012u, + 0x000014e5u, 0x000a001eu, 0x00000013u, 0x00000011u, 0x00000011u, 0x00000012u, 0x00000006u, 0x00000006u, + 0x00000006u, 0x00000006u, 0x00000006u, 0x0003001du, 0x00000014u, 0x00000006u, 0x0003001eu, 0x00000015u, + 0x00000014u, 0x00040020u, 0x00000011u, 0x000014e5u, 0x00000015u, 0x0003001du, 0x00000016u, 0x00000006u, + 0x0003001eu, 0x00000017u, 0x00000016u, 0x00040020u, 0x00000012u, 0x000014e5u, 0x00000017u, 0x00040020u, + 0x00000018u, 0x00000009u, 0x00000013u, 0x0004003bu, 0x00000018u, 0x00000019u, 0x00000009u, 0x00040015u, + 0x0000001au, 0x00000020u, 0x00000001u, 0x0004002bu, 0x0000001au, 0x0000001bu, 0x00000005u, 0x00040020u, + 0x0000001cu, 0x00000009u, 0x00000006u, 0x00020014u, 0x0000001fu, 0x0004002bu, 0x00000006u, 0x00000026u, + 0x00000003u, 0x0004002bu, 0x0000001au, 0x00000028u, 0x00000007u, 0x0004002bu, 0x0000001au, 0x0000002fu, + 0x00000004u, 0x0004002bu, 0x0000001au, 0x00000034u, 0x00000001u, 0x00040020u, 0x00000035u, 0x00000009u, + 0x00000011u, 0x0004002bu, 0x0000001au, 0x00000038u, 0x00000000u, 0x00040020u, 0x00000039u, 0x000014e5u, + 0x00000006u, 0x0004002bu, 0x0000001au, 0x00000042u, 0x00000003u, 0x0004002bu, 0x00000006u, 0x00000050u, + 0x00000001u, 0x0004002bu, 0x00000006u, 0x00000057u, 0x00000002u, 0x0004002bu, 0x0000001au, 0x0000005cu, + 0x00000006u, 0x0006002cu, 0x00000009u, 0x00000063u, 0x0000000cu, 0x0000000cu, 0x0000000cu, 0x00040017u, + 0x00000064u, 0x0000001fu, 0x00000003u, 0x0004002bu, 0x0000001au, 0x00000083u, 0x00000002u, 0x00040020u, + 0x00000084u, 0x00000009u, 0x00000012u, 0x0004002bu, 0x00000006u, 0x000000a8u, 0x00000040u, 0x0006002cu, + 0x00000009u, 0x000000a9u, 0x000000a8u, 0x00000050u, 0x00000050u, 0x00050036u, 0x00000002u, 0x00000004u, + 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x000300f7u, 0x000000aau, 0x00000000u, 0x000300fbu, + 0x0000000cu, 0x000000abu, 0x000200f8u, 0x000000abu, 0x00050041u, 0x0000000du, 0x0000000eu, 0x0000000bu, + 0x0000000cu, 0x0004003du, 0x00000006u, 0x0000000fu, 0x0000000eu, 0x00050041u, 0x0000001cu, 0x0000001du, + 0x00000019u, 0x0000001bu, 0x0004003du, 0x00000006u, 0x0000001eu, 0x0000001du, 0x000500aeu, 0x0000001fu, + 0x00000020u, 0x0000000fu, 0x0000001eu, 0x000300f7u, 0x00000022u, 0x00000000u, 0x000400fau, 0x00000020u, + 0x00000021u, 0x00000022u, 0x000200f8u, 0x00000021u, 0x000200f9u, 0x000000aau, 0x000200f8u, 0x00000022u, + 0x00050084u, 0x00000006u, 0x00000027u, 0x0000000fu, 0x00000026u, 0x00050041u, 0x0000001cu, 0x00000029u, + 0x00000019u, 0x00000028u, 0x0004003du, 0x00000006u, 0x0000002au, 0x00000029u, 0x000500aau, 0x0000001fu, + 0x0000002bu, 0x0000002au, 0x0000000cu, 0x000400a8u, 0x0000001fu, 0x0000002cu, 0x0000002bu, 0x000300f7u, + 0x0000002eu, 0x00000000u, 0x000400fau, 0x0000002cu, 0x0000002du, 0x0000002eu, 0x000200f8u, 0x0000002du, + 0x00050041u, 0x0000001cu, 0x00000030u, 0x00000019u, 0x0000002fu, 0x0004003du, 0x00000006u, 0x00000031u, + 0x00000030u, 0x00050080u, 0x00000006u, 0x00000033u, 0x00000031u, 0x0000000fu, 0x00050041u, 0x00000035u, + 0x00000036u, 0x00000019u, 0x00000034u, 0x0004003du, 0x00000011u, 0x00000037u, 0x00000036u, 0x00060041u, + 0x00000039u, 0x0000003au, 0x00000037u, 0x00000038u, 0x00000038u, 0x0006003du, 0x00000006u, 0x0000003bu, + 0x0000003au, 0x00000002u, 0x00000004u, 0x000500b0u, 0x0000001fu, 0x0000003cu, 0x00000033u, 0x0000003bu, + 0x000200f9u, 0x0000002eu, 0x000200f8u, 0x0000002eu, 0x000700f5u, 0x0000001fu, 0x0000003du, 0x0000002bu, + 0x00000022u, 0x0000003cu, 0x0000002du, 0x000300f7u, 0x0000003fu, 0x00000000u, 0x000400fau, 0x0000003du, + 0x0000003eu, 0x00000099u, 0x000200f8u, 0x0000003eu, 0x00050041u, 0x0000001cu, 0x00000043u, 0x00000019u, + 0x00000042u, 0x0004003du, 0x00000006u, 0x00000044u, 0x00000043u, 0x00050084u, 0x00000006u, 0x00000045u, + 0x0000000fu, 0x00000044u, 0x00050041u, 0x00000035u, 0x00000048u, 0x00000019u, 0x00000038u, 0x0004003du, + 0x00000011u, 0x00000049u, 0x00000048u, 0x00060041u, 0x00000039u, 0x0000004bu, 0x00000049u, 0x00000038u, + 0x00000045u, 0x0006003du, 0x00000006u, 0x0000004cu, 0x0000004bu, 0x00000002u, 0x00000004u, 0x00050080u, + 0x00000006u, 0x00000051u, 0x00000045u, 0x00000050u, 0x00060041u, 0x00000039u, 0x00000052u, 0x00000049u, + 0x00000038u, 0x00000051u, 0x0006003du, 0x00000006u, 0x00000053u, 0x00000052u, 0x00000002u, 0x00000004u, + 0x00050080u, 0x00000006u, 0x00000058u, 0x00000045u, 0x00000057u, 0x00060041u, 0x00000039u, 0x00000059u, + 0x00000049u, 0x00000038u, 0x00000058u, 0x0006003du, 0x00000006u, 0x0000005au, 0x00000059u, 0x00000002u, + 0x00000004u, 0x00060050u, 0x00000009u, 0x0000005bu, 0x0000004cu, 0x00000053u, 0x0000005au, 0x00050041u, + 0x0000001cu, 0x0000005du, 0x00000019u, 0x0000005cu, 0x0004003du, 0x00000006u, 0x0000005eu, 0x0000005du, + 0x000500abu, 0x0000001fu, 0x0000005fu, 0x0000005eu, 0x0000000cu, 0x000300f7u, 0x00000061u, 0x00000000u, + 0x000400fau, 0x0000005fu, 0x00000060u, 0x00000061u, 0x000200f8u, 0x00000060u, 0x000500aau, 0x00000064u, + 0x00000065u, 0x0000005bu, 0x00000063u, 0x0004009au, 0x0000001fu, 0x00000066u, 0x00000065u, 0x000300f7u, + 0x00000068u, 0x00000000u, 0x000400fau, 0x00000066u, 0x00000067u, 0x00000069u, 0x000200f8u, 0x00000067u, + 0x000200f9u, 0x00000068u, 0x000200f8u, 0x00000069u, 0x0007000cu, 0x00000006u, 0x0000006eu, 0x00000001u, + 0x00000026u, 0x0000004cu, 0x0000005eu, 0x00050086u, 0x00000006u, 0x00000075u, 0x0000005eu, 0x0000006eu, + 0x0007000cu, 0x00000006u, 0x00000079u, 0x00000001u, 0x00000026u, 0x00000053u, 0x00000075u, 0x00050086u, + 0x00000006u, 0x00000080u, 0x00000075u, 0x00000079u, 0x0007000cu, 0x00000006u, 0x00000081u, 0x00000001u, + 0x00000026u, 0x0000005au, 0x00000080u, 0x00060050u, 0x00000009u, 0x000000c4u, 0x0000006eu, 0x00000079u, + 0x00000081u, 0x000200f9u, 0x00000068u, 0x000200f8u, 0x00000068u, 0x000700f5u, 0x00000009u, 0x000000c3u, + 0x00000063u, 0x00000067u, 0x000000c4u, 0x00000069u, 0x000200f9u, 0x00000061u, 0x000200f8u, 0x00000061u, + 0x000700f5u, 0x00000009u, 0x000000c2u, 0x0000005bu, 0x0000003eu, 0x000000c3u, 0x00000068u, 0x00050041u, + 0x00000084u, 0x00000085u, 0x00000019u, 0x00000083u, 0x0004003du, 0x00000012u, 0x00000086u, 0x00000085u, + 0x00050051u, 0x00000006u, 0x00000089u, 0x000000c2u, 0x00000000u, 0x00060041u, 0x00000039u, 0x0000008au, + 0x00000086u, 0x00000038u, 0x00000027u, 0x0005003eu, 0x0000008au, 0x00000089u, 0x00000002u, 0x00000004u, + 0x00050080u, 0x00000006u, 0x0000008eu, 0x00000027u, 0x00000050u, 0x00050051u, 0x00000006u, 0x00000090u, + 0x000000c2u, 0x00000001u, 0x00060041u, 0x00000039u, 0x00000091u, 0x00000086u, 0x00000038u, 0x0000008eu, + 0x0005003eu, 0x00000091u, 0x00000090u, 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x00000095u, + 0x00000027u, 0x00000057u, 0x00050051u, 0x00000006u, 0x00000097u, 0x000000c2u, 0x00000002u, 0x00060041u, + 0x00000039u, 0x00000098u, 0x00000086u, 0x00000038u, 0x00000095u, 0x0005003eu, 0x00000098u, 0x00000097u, + 0x00000002u, 0x00000004u, 0x000200f9u, 0x0000003fu, 0x000200f8u, 0x00000099u, 0x00050041u, 0x00000084u, + 0x0000009au, 0x00000019u, 0x00000083u, 0x0004003du, 0x00000012u, 0x0000009bu, 0x0000009au, 0x00060041u, + 0x00000039u, 0x0000009du, 0x0000009bu, 0x00000038u, 0x00000027u, 0x0005003eu, 0x0000009du, 0x0000000cu, + 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x000000a1u, 0x00000027u, 0x00000050u, 0x00060041u, + 0x00000039u, 0x000000a2u, 0x0000009bu, 0x00000038u, 0x000000a1u, 0x0005003eu, 0x000000a2u, 0x0000000cu, + 0x00000002u, 0x00000004u, 0x00050080u, 0x00000006u, 0x000000a6u, 0x00000027u, 0x00000057u, 0x00060041u, + 0x00000039u, 0x000000a7u, 0x0000009bu, 0x00000038u, 0x000000a6u, 0x0005003eu, 0x000000a7u, 0x0000000cu, + 0x00000002u, 0x00000004u, 0x000200f9u, 0x0000003fu, 0x000200f8u, 0x0000003fu, 0x000200f9u, 0x000000aau, + 0x000200f8u, 0x000000aau, 0x000100fdu, 0x00010038u, }; } // namespace leonida diff --git a/runtime/src/indirect_draw_stats.h b/runtime/src/indirect_draw_stats.h new file mode 100644 index 0000000000..39ed09b358 --- /dev/null +++ b/runtime/src/indirect_draw_stats.h @@ -0,0 +1,45 @@ +// Process-wide counts of calls recorded and replay attempts. A command list can replay more than once. +#pragma once +#include +#include + +namespace leonida::indirect_stats { +enum class Event { recorded, emitted, record_skip, replay_skip }; +struct Counts { + std::atomic values[4]{}; + void report() const { + std::fprintf(stderr, "[rt] indirect graphics: recorded=%llu emitted=%llu record_skips=%llu replay_skips=%llu\n", + values[0].load(), values[1].load(), values[2].load(), values[3].load()); + } + ~Counts() { + for (const auto& value : values) { + if (value.load()) { + report(); + break; + } + } + } +}; +inline void note(Event event) { + static Counts counts; + const auto n = 1 + counts.values[static_cast(event)].fetch_add(1, std::memory_order_relaxed); + if ((n & (n - 1)) == 0) counts.report(); +} +// One flag per reason, shared across resolver instantiations. +enum Reason { compound, disabled, pipeline, root_layout, viewport, mesh, topology, first_instance, entry, robust_index, + count_limit, multi_draw, count_feature, raw_count_limit, argument_usage, count_usage, + divisor, pending_pipeline, index_view, index_range, stateless, reason_count }; +inline void skip(Event event, Reason reason) { + static constexpr const char* names[]{"compound signature", "opt-out", "missing pipeline", "missing root signature", + "empty viewport", "mesh indirect", "topology", "drawIndirectFirstInstance", "missing Vulkan entry point", + "robust sized index binding", "maxDrawIndirectCount", "multiDrawIndirect", "drawIndirectCount", + "counted draw requires maxDrawIndirectCount == UINT32_MAX", "argument buffer lacks indirect creation usage", + "count buffer lacks indirect creation usage", "nonunit vertex divisor", "pipeline pending", + "invalid index view", "index view outside buffer or misaligned", "legacy command has no graphics state"}; + static_assert(sizeof(names) / sizeof(*names) == reason_count); + static std::atomic_flag shown[reason_count]{}; + if (!shown[reason].test_and_set(std::memory_order_relaxed)) + std::fprintf(stderr, "[rt] indirect graphics skipped: %s\n", names[reason]); + note(event); +} +} diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 8e37677400..aec5114148 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -72,7 +72,8 @@ void keep_title_watchdog_kicked(std::uint8_t* base) { } // LEONIDA_PEEK="0x9e1dac0:3,0x7446510,0x98f828c" (diagnostic): a thread prints the 8-byte values at these RVAs of the -// title's image (":n" = n consecutive values) every LEONIDA_PEEK_SECONDS (default 10). For answering "what does this +// title's image (":n" = n consecutive values, at most 32; "RVA>OFF" reads through the pointer stored at the RVA, at +// pointer + OFF, both hex) every LEONIDA_PEEK_SECONDS (default 10). For answering "what does this // global hold at run time" without a debugger: the reverse-engineering notes (docs/re/requests.md) ask for exactly // that. Reads are checked; nothing is written. void start_title_peek(std::uint8_t* base) { @@ -93,15 +94,35 @@ void start_title_peek(std::uint8_t* base) { char* end = nullptr; const std::uint64_t rva = std::strtoull(at, &end, 16); if (end == at) break; + // "RVA>OFF": the 8-byte pointer at the RVA, then the values at pointer + OFF (both hex). + bool deref = false; + std::uint64_t offset = 0; + if (*end == '>') { + deref = true; + offset = std::strtoull(end + 1, &end, 16); + } unsigned count = 1; if (*end == ':') count = static_cast(std::strtoul(end + 1, &end, 10)); - char text[40]; - std::snprintf(text, sizeof(text), " 0x%llx=", static_cast(rva)); + char text[48]; + if (deref) + std::snprintf(text, sizeof(text), " 0x%llx>%llx=", static_cast(rva), + static_cast(offset)); + else + std::snprintf(text, sizeof(text), " 0x%llx=", static_cast(rva)); line += text; - for (unsigned i = 0; i < count && i < 16; ++i) { + const std::uint8_t* from = image + rva; + if (deref) { + std::uint64_t pointer = 0; + SIZE_T got = 0; + if (!ReadProcessMemory(GetCurrentProcess(), from, &pointer, sizeof(pointer), &got) || + got != sizeof(pointer) || !pointer) + count = 0, line += "?"; + from = reinterpret_cast(pointer + offset); + } + for (unsigned i = 0; i < count && i < 32; ++i) { std::uint64_t value = 0; SIZE_T got = 0; - const bool ok = ReadProcessMemory(GetCurrentProcess(), image + rva + 8ull * i, &value, + const bool ok = ReadProcessMemory(GetCurrentProcess(), from + 8ull * i, &value, sizeof(value), &got) && got == sizeof(value); std::snprintf(text, sizeof(text), ok ? "%s%llx" : "%s?", i ? "," : "", static_cast(value)); @@ -127,12 +148,14 @@ void start_title_peek(std::uint8_t* base) { #include "mods.h" #include "pe_loader.h" #include "thread_stacks.h" +#include "thread_sampler.h" #include "title_page_watch.h" #include "title_geometry_watch.h" #include "../shims/d3d12_trace.h" #include "../shims/d3d12_xs_device.h" #include "../shims/file_system.h" #ifdef LEONIDA_VULKAN_DEVICE +#include "../shims/d3d12_compile_exit.h" #include "../shims/package_splash.h" #endif #include "../shims/process_shim.h" @@ -205,6 +228,18 @@ int usage() { } // namespace #ifdef LEONIDA_VULKAN_DEVICE +// The run ends with the title's Vulkan device alive, so no ~Device stops the background pipeline compiler: stop it +// here, before ExitProcess ends its thread, maybe inside the driver's compiler (rt::d3d12::stop_pipeline_compiles). +constexpr unsigned kExitCompileWaitMs = 2000; // a console close gives the whole process 5 s + +static BOOL WINAPI stop_compiles_on_console_exit(DWORD event) { + if (event == CTRL_C_EVENT || event == CTRL_BREAK_EVENT || event == CTRL_CLOSE_EVENT) { + rt::d3d12_xs::stop_list_values(500); // as at the run's end: no list-value thread cut off inside the layer + rt::d3d12::stop_pipeline_compiles(kExitCompileWaitMs); + } + return FALSE; // the next handler (the default one: ExitProcess) ends the process, as before +} + static BOOL WINAPI show_package_window(HWND window, int command) { const BOOL previous = ShowWindow(window, command); const DWORD error = GetLastError(); @@ -357,6 +392,7 @@ int wmain(int argc, wchar_t** argv) { leonida::geometry_writes::aliases.store(&rt::xmem::geometry_aliases); leonida::kernel_writes::set_committer(&rt::xmem::commit_physical_range); rt::d3d12_xs::set_texture_page_provider(&rt::xmem::pin_mapped_data); + leonida::kernel_writes::set_unguarder(&rt::xmem::reopen_unowned); if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" : "error: cannot create the trace file\n"); @@ -477,6 +513,10 @@ int wmain(int argc, wchar_t** argv) { std::fflush(stdout); keep_title_watchdog_kicked(main_module.base); start_title_peek(main_module.base); + leonida::thread_sampler::start(main_module.base, main_module.size); // LEONIDA_SAMPLE_MS (diagnostic) +#ifdef LEONIDA_VULKAN_DEVICE + SetConsoleCtrlHandler(&stop_compiles_on_console_exit, TRUE); +#endif int code; { auto stacks = rt::start_thread_stacks(); @@ -491,6 +531,12 @@ int wmain(int argc, wchar_t** argv) { // Not `return`: a normal host exit runs the CRT's atexit table, which the game shares with gta6rt (its // handlers would run against a game that has stopped) and whose last word decides the exit status. // ExitProcess also skips atexit, so the TLS clone cleanup registered there is run here instead. + // The list-value threads end first: ExitProcess must not cut one off inside the layer (in a held submission, + // holding its queues' lock). + rt::d3d12_xs::stop_list_values(500); +#ifdef LEONIDA_VULKAN_DEVICE + rt::d3d12::stop_pipeline_compiles(kExitCompileWaitMs); +#endif rt::cleanup_tls_clones(); ExitProcess(static_cast(code)); } catch (const std::exception& e) { diff --git a/runtime/src/submit_phases.h b/runtime/src/submit_phases.h new file mode 100644 index 0000000000..790c7e0981 --- /dev/null +++ b/runtime/src/submit_phases.h @@ -0,0 +1,130 @@ +#pragma once +// Where a submission's CPU time goes, always on and cheap: each phase of VulkanQueue::execute_now adds its time here +// (two steady_clock reads and two relaxed atomic adds), and every LEONIDA_SUBMIT_PHASES_SECONDS (5 by default, 0 turns +// the line off) one line says, since the last line, how many submissions there were, how many per second, the +// milliseconds per submission of each phase with the largest single one, and the share of the wall time the +// submitting threads spent in them. The time is the process's age (GetProcessTimes), so it lines up with the boot. +#ifdef _WIN32 +#include +#endif +#include +#include +#include +#include +#include + +namespace leonida::submit_phases { + +enum Phase : unsigned { + wait_room, // VulkanQueue::wait_for_room: the queue at its cap waits for the GPU + heaps, // DeviceState::refresh_console_heaps + shadows, // slot-133 shadow buffers and title windows (ShadowPages::refresh) + geometry, // GeometryViews::refresh + textures, // Device::refresh_title_textures + replay, // the rest of execute_now: preparing, recording and submitting the lists + kCount +}; + +inline const char* name(unsigned p) { + static const char* const names[kCount] = {"wait", "heaps", "shadows", "geometry", "textures", "replay"}; + return p < kCount ? names[p] : "?"; +} + +struct Totals { + std::atomic ns[kCount]{}; + std::atomic max_ns[kCount]{}; + std::atomic submissions{0}, all_submissions{0}; + std::atomic last_log{0}; + std::atomic presents{0}; // frames the presenter showed (VulkanPresenter), since the last line + std::atomic present_serial{0}; // the same, never reset (LEONIDA_REFRESH_PER_FRAME) + std::atomic thread{0}; // the thread of the last submission (the thread sampler reports it apart) +}; +inline Totals& totals() { + static Totals t; + return t; +} + +inline std::int64_t now_ns() { + return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()) + .count(); +} + +// Seconds since the process started. +inline double process_age() { +#ifdef _WIN32 + FILETIME created{}, exited{}, kernel{}, user{}, now{}; + if (!GetProcessTimes(GetCurrentProcess(), &created, &exited, &kernel, &user)) return 0; + GetSystemTimeAsFileTime(&now); + const auto ticks = [](const FILETIME& f) { return (std::uint64_t(f.dwHighDateTime) << 32) | f.dwLowDateTime; }; + return double(ticks(now) - ticks(created)) * 1e-7; +#else + return 0; +#endif +} + +inline std::int64_t period_ns() { + static const std::int64_t value = [] { + const char* text = std::getenv("LEONIDA_SUBMIT_PHASES_SECONDS"); + const unsigned long long s = text && *text ? std::strtoull(text, nullptr, 10) : 5; + return std::int64_t(s) * 1000000000; + }(); + return value; +} + +inline void add(Phase p, std::uint64_t ns) { + Totals& t = totals(); + t.ns[p].fetch_add(ns, std::memory_order_relaxed); + std::uint64_t m = t.max_ns[p].load(std::memory_order_relaxed); + while (ns > m && !t.max_ns[p].compare_exchange_weak(m, ns, std::memory_order_relaxed)) { + } +} + +// Times its own lifetime into a phase. +struct Scope { + Phase phase; + std::int64_t start = now_ns(); + explicit Scope(Phase p) : phase(p) {} + ~Scope() { add(phase, std::uint64_t(now_ns() - start)); } + Scope(const Scope&) = delete; + Scope& operator=(const Scope&) = delete; +}; + +// After each submission: counts it, and prints the line when the period has passed. One thread wins the line. +inline void submitted() { + Totals& t = totals(); + t.submissions.fetch_add(1, std::memory_order_relaxed); + t.all_submissions.fetch_add(1, std::memory_order_relaxed); +#ifdef _WIN32 + t.thread.store(GetCurrentThreadId(), std::memory_order_relaxed); +#endif + const std::int64_t period = period_ns(); + if (!period) return; + const std::int64_t now = now_ns(); + std::int64_t last = t.last_log.load(std::memory_order_relaxed); + if (!last) { + t.last_log.compare_exchange_strong(last, now, std::memory_order_relaxed); + return; + } + if (now - last < period || !t.last_log.compare_exchange_strong(last, now, std::memory_order_relaxed)) return; + const double seconds = double(now - last) * 1e-9; + const std::uint64_t n = t.submissions.exchange(0, std::memory_order_relaxed); + const std::uint64_t frames = t.presents.exchange(0, std::memory_order_relaxed); + double ms[kCount], max_ms[kCount], all = 0; + for (unsigned p = 0; p < kCount; ++p) { + const double total = double(t.ns[p].exchange(0, std::memory_order_relaxed)) * 1e-6; + max_ms[p] = double(t.max_ns[p].exchange(0, std::memory_order_relaxed)) * 1e-6; + ms[p] = n ? total / double(n) : 0; + all += total; + } + std::fprintf(stderr, + "[rt] submit phases t=%.0fs: %llu submissions in %.1f s (%.2f/s, %llu in all), %.2f frames/s; ms per submission " + "(max): %s %.2f (%.0f) %s %.2f (%.0f) %s %.2f (%.0f) %s %.2f (%.0f) %s %.2f (%.0f) %s %.2f (%.0f); " + "%.0f%% of the wall time\n", + process_age(), static_cast(n), seconds, double(n) / seconds, + static_cast(t.all_submissions.load(std::memory_order_relaxed)), + double(frames) / seconds, name(0), ms[0], + max_ms[0], name(1), ms[1], max_ms[1], name(2), ms[2], max_ms[2], name(3), ms[3], max_ms[3], name(4), + ms[4], max_ms[4], name(5), ms[5], max_ms[5], 100.0 * all * 1e-3 / seconds); +} + +} // namespace leonida::submit_phases diff --git a/runtime/src/thread_sampler.h b/runtime/src/thread_sampler.h new file mode 100644 index 0000000000..9166fe5523 --- /dev/null +++ b/runtime/src/thread_sampler.h @@ -0,0 +1,401 @@ +#pragma once +// LEONIDA_SAMPLE_MS= (diagnostic, off by default): where the process's busy threads spend their CPU, without a +// debugger or perf. A thread wakes every , and for each thread of the process that used CPU since its last look +// suspends it, copies its context and resumes it at once; the stack is then unwound outside the suspension (through +// the .pdata every module registers, the title's included), under __try, since the thread runs on meanwhile. Every +// LEONIDA_SAMPLE_REPORT_S seconds (10) one block lists the busiest threads (CPU share) and the most frequent call +// chains (up to eight frames, innermost first): title frames as t+RVA of the function, others as module+RVA. Nothing is +// allocated or logged while a thread is suspended, so a suspended thread's locks are never waited for. +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "submit_phases.h" + +namespace leonida::thread_sampler { + +constexpr int kFrames = 8; +using Chain = std::array; // function starts (or addresses), innermost first +// LEONIDA_SAMPLE_SHIMS=1 (with LEONIDA_SAMPLE_MS): each sample is unwound this deep to tell whether a title thread +// is inside our runtime (a frame of this executable called, at any depth, from title code), and where. +constexpr int kDeepFrames = 48; +using DeepChain = std::array; + + +struct Sampler { + std::uint8_t* title = nullptr; + std::uint64_t title_size = 0; + DWORD period_ms = 10; + DWORD report_ms = 10000; + bool waits = false; // LEONIDA_SAMPLE_WAITS=1: every thread, busy or waiting (where the wall time goes) + bool shims = false; // LEONIDA_SAMPLE_SHIMS=1: per title thread, the share of its samples inside our runtime + std::uint64_t self_base = 0, self_size = 0; // this executable (the runtime) + // LEONIDA_SAMPLE_DETAIL=[,...]: for these threads, the 10 most frequent chains, 16 frames deep, each as a + // share of that thread's samples (thread ids are stable from boot to boot: the title's main, render and submit). + std::vector detail; +}; + +// Per title thread (one with a title frame in its chain): how many samples were inside our runtime, and through which +// entry (the runtime frame the title called) and which runtime function was innermost. +struct ShimCounts { + std::uint64_t title = 0; // samples with a title frame + std::uint64_t ours = 0; // ... of which inside our runtime + std::uint64_t ours_busy = 0; // ... while the thread used CPU since the previous look + std::uint64_t busy = 0; // samples with a title frame while the thread used CPU + std::map, std::uint64_t> entries; // (our entry, title caller) -> samples + std::map inner; // innermost runtime function -> samples + std::map leaves; // innermost frame (any module) -> samples +}; + +// Classifies one deep chain (innermost first) for LEONIDA_SAMPLE_SHIMS. +inline void count_shims(const Sampler& s, const DeepChain& chain, int n, bool moved, ShimCounts& c) { + const auto title = reinterpret_cast(s.title); + const auto in_title = [&](std::uint64_t a) { return a >= title && a < title + s.title_size; }; + const auto in_self = [&](std::uint64_t a) { return a >= s.self_base && a < s.self_base + s.self_size; }; + int first_title = -1; + for (int i = 0; i < n; ++i) + if (in_title(chain[i])) { + first_title = i; + break; + } + if (first_title < 0) return; + ++c.title; + c.busy += moved; + int entry = -1, innermost = -1; + for (int i = 0; i < first_title; ++i) + if (in_self(chain[i])) { + if (innermost < 0) innermost = i; + entry = i; // the outermost runtime frame below the title's + } + if (entry < 0) return; + ++c.ours; + c.ours_busy += moved; + ++c.entries[{chain[entry], chain[first_title]}]; + ++c.inner[chain[innermost]]; + ++c.leaves[chain[0]]; +} + +// The chain of a context copied from a suspended thread: unwound under __try (its stack may be changing). +template +inline int unwind(CONTEXT context, std::array& chain) { + int n = 0; + __try { + for (; n < int(N); ++n) { + const DWORD64 pc = context.Rip; + if (!pc) break; + DWORD64 image = 0; + PRUNTIME_FUNCTION entry = RtlLookupFunctionEntry(pc, &image, nullptr); + chain[n] = entry ? image + entry->BeginAddress : pc; + if (!entry) { // a leaf, or code with no unwind data: take the return address at the stack pointer + context.Rip = *reinterpret_cast(context.Rsp); + context.Rsp += 8; + continue; + } + void* handler_data = nullptr; + DWORD64 frame = 0; + RtlVirtualUnwind(UNW_FLAG_NHANDLER, image, pc, entry, &context, &handler_data, &frame, nullptr); + } + } __except (EXCEPTION_EXECUTE_HANDLER) { + } + return n; +} + +inline std::string name_of(const Sampler& s, std::uint64_t at) { + char text[96]; + const auto title = reinterpret_cast(s.title); + if (at >= title && at < title + s.title_size) { + std::snprintf(text, sizeof(text), "t+%llx", static_cast(at - title)); + return text; + } + HMODULE module = nullptr; + if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + reinterpret_cast(at), &module) && + module) { + wchar_t path[MAX_PATH] = {}; + GetModuleFileNameW(module, path, MAX_PATH); + const wchar_t* base = path; + for (const wchar_t* p = path; *p; ++p) + if (*p == L'\\' || *p == L'/') base = p + 1; + std::snprintf(text, sizeof(text), "%ls+%llx", base, + static_cast(at - reinterpret_cast(module))); + return text; + } + std::snprintf(text, sizeof(text), "0x%llx", static_cast(at)); + return text; +} + +inline DWORD WINAPI run(LPVOID parameter) { + const Sampler s = *static_cast(parameter); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + const DWORD self = GetCurrentThreadId(), pid = GetCurrentProcessId(); + struct Thread { + HANDLE handle = nullptr; + std::uint64_t cpu = 0; // 100 ns, at the last look + std::uint64_t used = 0; // since the last report + std::uint64_t samples = 0; + }; + std::map threads; + std::map, std::uint64_t> chains; + std::map shim_counts; + constexpr int kDetailFrames = 16; + using DetailChain = std::array; + std::map, std::uint64_t> detail_chains; + std::uint64_t total = 0; + ULONGLONG listed = 0, reported = GetTickCount64(); + const auto cpu_of = [](HANDLE h) { + FILETIME created{}, exited{}, kernel{}, user{}; + if (!GetThreadTimes(h, &created, &exited, &kernel, &user)) return std::uint64_t(0); + const auto ticks = [](const FILETIME& f) { return (std::uint64_t(f.dwHighDateTime) << 32) | f.dwLowDateTime; }; + return ticks(kernel) + ticks(user); + }; + for (;;) { + Sleep(s.period_ms); + const ULONGLONG now = GetTickCount64(); + if (now - listed >= 2000) { // the thread list, every 2 s + listed = now; + const HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); + if (snap != INVALID_HANDLE_VALUE) { + THREADENTRY32 e{sizeof(e)}; + for (BOOL ok = Thread32First(snap, &e); ok; ok = Thread32Next(snap, &e)) { + if (e.th32OwnerProcessID != pid || e.th32ThreadID == self || threads.count(e.th32ThreadID)) continue; + const HANDLE h = OpenThread(THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, + FALSE, e.th32ThreadID); + if (h) threads[e.th32ThreadID] = {h, cpu_of(h)}; + e.dwSize = sizeof(e); + } + CloseHandle(snap); + } + } + for (auto it = threads.begin(); it != threads.end();) { + Thread& t = it->second; + const std::uint64_t cpu = cpu_of(t.handle); + DWORD code = 0; + if (GetExitCodeThread(t.handle, &code) && code != STILL_ACTIVE) { + CloseHandle(t.handle); + it = threads.erase(it); + continue; + } + const bool moved = cpu != t.cpu; + const bool busy = moved || s.waits; + t.used += cpu - t.cpu; + t.cpu = cpu; + if (busy) { + CONTEXT context{}; + context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; + bool got = false; + if (SuspendThread(t.handle) != DWORD(-1)) { + got = GetThreadContext(t.handle, &context) != FALSE; + ResumeThread(t.handle); + } + if (got) { + Chain chain{}; + if (std::find(s.detail.begin(), s.detail.end(), it->first) != s.detail.end()) { + DetailChain deep{}; + unwind(context, deep); + ++detail_chains[{it->first, deep}]; + } + if (s.shims) { + DeepChain deep{}; + const int n = unwind(context, deep); + std::copy_n(deep.begin(), kFrames, chain.begin()); + count_shims(s, deep, n, moved, shim_counts[it->first]); + } else { + unwind(context, chain); + } + ++chains[{it->first, chain}]; + ++t.samples; + ++total; + } + } + ++it; + } + if (now - reported < s.report_ms || !total) continue; + const double seconds = double(now - reported) / 1000.0; + reported = now; + std::vector> busiest; + for (auto& [id, t] : threads) + if (t.used) busiest.emplace_back(t.used, id); + std::sort(busiest.rbegin(), busiest.rend()); + std::string line; + for (std::size_t i = 0; i < busiest.size() && i < 8; ++i) { + char text[64]; + std::snprintf(text, sizeof(text), "%s%lu %.0f%%", i ? ", " : "", busiest[i].second, + double(busiest[i].first) * 1e-5 / seconds); + line += text; + } + std::fprintf(stderr, "[rt] sampler: %llu samples in %.0f s; CPU by thread: %s\n", + static_cast(total), seconds, line.c_str()); + std::vector*>> top; + for (const auto& c : chains) top.emplace_back(c.second, &c.first); + std::sort(top.begin(), top.end(), [](const auto& a, const auto& b) { return a.first > b.first; }); + const auto print = [&](const auto& entry, std::uint64_t of, const char* what) { + std::string frames; + for (int f = 0; f < kFrames && entry.second->second[f]; ++f) + frames += (f ? " < " : "") + name_of(s, entry.second->second[f]); + std::fprintf(stderr, "[rt] sampler: %s %5.1f%% thread %lu: %s\n", what, 100.0 * double(entry.first) / double(of), + entry.second->first, frames.c_str()); + }; + for (std::size_t i = 0; i < top.size() && i < 16; ++i) print(top[i], total, " "); + // Apart: the submitting thread's chains, and the two busiest threads', each as a share of that thread's samples. + std::vector apart; + if (const DWORD submitter = submit_phases::totals().thread.load(std::memory_order_relaxed)) apart.push_back(submitter); + for (std::size_t i = 0; i < busiest.size() && i < 2; ++i) + if (std::find(apart.begin(), apart.end(), busiest[i].second) == apart.end()) apart.push_back(busiest[i].second); + // With waiting threads sampled: each thread's own most frequent chain, busiest first, so a thread that waits + // (the title's main thread behind its render thread, a render thread behind a lock) shows where. + if (s.waits) { + std::vector> all; + for (auto& [id, t] : threads) + if (t.samples) all.emplace_back(t.used, id); + std::sort(all.rbegin(), all.rend()); + std::size_t listed = 0; + for (const auto& [used, id] : all) { + if (listed++ >= 24) break; + const auto it = threads.find(id); + if (it == threads.end() || !it->second.samples) continue; + for (const auto& entry : top) + if (entry.second->first == id) { + print(entry, it->second.samples, "thread"); + break; + } + } + } + for (const DWORD id : apart) { + const auto it = threads.find(id); + if (it == threads.end() || !it->second.samples) continue; + std::size_t shown = 0; + for (const auto& entry : top) + if (entry.second->first == id && shown++ < 8) + print(entry, it->second.samples, id == apart.front() && submit_phases::totals().thread.load() == id + ? "submit" + : "busy "); + } + for (const DWORD id : s.detail) { + std::vector> mine; + std::uint64_t all = 0; + for (const auto& [key, n] : detail_chains) + if (key.first == id) { + mine.emplace_back(n, &key.second); + all += n; + } + std::sort(mine.begin(), mine.end(), [](const auto& a, const auto& b) { return a.first > b.first; }); + for (std::size_t i = 0; i < mine.size() && i < 10; ++i) { + std::string frames; + for (int f = 0; f < kDetailFrames && (*mine[i].second)[f]; ++f) + frames += (f ? " < " : "") + name_of(s, (*mine[i].second)[f]); + std::fprintf(stderr, "[rt] sampler: detail thread %lu %5.1f%%: %s\n", id, + 100.0 * double(mine[i].first) / double(all), frames.c_str()); + } + } + detail_chains.clear(); + if (s.shims) { + // Title threads by their samples inside our runtime: where the title's own threads (its main, render and + // Subrender workers, streaming) spend time in our shims, waiting or running. + const auto top_of = [&](const auto& counts, std::size_t limit, bool pair_key) { + std::vector> v; + for (const auto& [key, n] : counts) { + std::string name; + if constexpr (requires { key.first; }) { + name = name_of(s, key.first) + "<-" + name_of(s, key.second); + } else { + name = name_of(s, key); + } + v.emplace_back(n, std::move(name)); + } + (void)pair_key; + std::sort(v.begin(), v.end(), [](const auto& a, const auto& b) { return a.first > b.first; }); + std::string text; + for (std::size_t i = 0; i < v.size() && i < limit; ++i) { + char n[24]; + std::snprintf(n, sizeof(n), " %llu", static_cast(v[i].first)); + text += (i ? ", " : "") + v[i].second + n; + } + return text; + }; + std::vector> order; + ShimCounts all; + for (const auto& [id, c] : shim_counts) { + if (!c.title) continue; + order.emplace_back(c.ours, id); + all.title += c.title; + all.ours += c.ours; + all.ours_busy += c.ours_busy; + all.busy += c.busy; + for (const auto& [k, n] : c.entries) all.entries[k] += n; + for (const auto& [k, n] : c.inner) all.inner[k] += n; + for (const auto& [k, n] : c.leaves) all.leaves[k] += n; + } + std::sort(order.rbegin(), order.rend()); + std::fprintf(stderr, "[rt] sampler: shims: title-thread samples inside our runtime %llu of %llu (%.1f%%), " + "%llu of them while the thread used CPU\n", + static_cast(all.ours), static_cast(all.title), + all.title ? 100.0 * double(all.ours) / double(all.title) : 0.0, + static_cast(all.ours_busy)); + for (std::size_t i = 0; i < order.size() && i < 12 && order[i].first; ++i) { + const ShimCounts& c = shim_counts[order[i].second]; + std::fprintf(stderr, "[rt] sampler: shims thread %lu: %llu of %llu samples ours (%.0f%%; %llu busy), " + "thread busy in %llu; entries: %s; innermost ours: %s; leaves: %s\n", + order[i].second, static_cast(c.ours), + static_cast(c.title), 100.0 * double(c.ours) / double(c.title), + static_cast(c.ours_busy), static_cast(c.busy), + top_of(c.entries, 5, true).c_str(), top_of(c.inner, 5, false).c_str(), + top_of(c.leaves, 3, false).c_str()); + } + std::fprintf(stderr, "[rt] sampler: shims all: entries: %s\n", top_of(all.entries, 16, true).c_str()); + std::fprintf(stderr, "[rt] sampler: shims all: innermost ours: %s\n", top_of(all.inner, 16, false).c_str()); + std::fprintf(stderr, "[rt] sampler: shims all: leaves: %s\n", top_of(all.leaves, 12, false).c_str()); + shim_counts.clear(); + } + chains.clear(); + total = 0; + for (auto& [id, t] : threads) t.used = t.samples = 0; + } +} + +// From main, once the title is mapped. Does nothing without LEONIDA_SAMPLE_MS. +inline void start(std::uint8_t* title, std::uint64_t title_size) { + char text[16] = {}; + const DWORD n = GetEnvironmentVariableA("LEONIDA_SAMPLE_MS", text, sizeof(text)); + if (!n || n >= sizeof(text)) return; + static Sampler s; + s.title = title; + s.title_size = title_size; + s.period_ms = (std::max)(1ul, std::strtoul(text, nullptr, 10)); + char report[16] = {}; + if (GetEnvironmentVariableA("LEONIDA_SAMPLE_REPORT_S", report, sizeof(report)) > 0) + s.report_ms = (std::max)(1ul, std::strtoul(report, nullptr, 10)) * 1000; + char waits[4] = {}; + s.waits = GetEnvironmentVariableA("LEONIDA_SAMPLE_WAITS", waits, sizeof(waits)) == 1 && waits[0] == '1'; + char detail[128] = {}; + if (const DWORD n = GetEnvironmentVariableA("LEONIDA_SAMPLE_DETAIL", detail, sizeof(detail)); n && n < sizeof(detail)) + for (char* at = detail; *at;) { + char* end = nullptr; + const unsigned long id = std::strtoul(at, &end, 10); + if (end == at) break; + if (id) s.detail.push_back(DWORD(id)); + at = *end == ',' ? end + 1 : end; + } + char shims[4] = {}; + s.shims = GetEnvironmentVariableA("LEONIDA_SAMPLE_SHIMS", shims, sizeof(shims)) == 1 && shims[0] == '1'; + if (const auto self = reinterpret_cast(GetModuleHandleW(nullptr))) { + const auto* dos = reinterpret_cast(self); + const auto* nt = reinterpret_cast(self + dos->e_lfanew); + s.self_base = reinterpret_cast(self); + s.self_size = nt->OptionalHeader.SizeOfImage; + } + if (const HANDLE h = CreateThread(nullptr, 0, &run, &s, 0, nullptr)) { + CloseHandle(h); + std::fprintf(stderr, "[rt] sampler: every %lu ms, report every %lu s%s%s\n", s.period_ms, s.report_ms / 1000, + s.waits ? ", waiting threads too" : "", s.shims ? ", title threads inside our runtime" : ""); + } +} + +} // namespace leonida::thread_sampler diff --git a/runtime/src/title_geometry_watch.h b/runtime/src/title_geometry_watch.h index ddc21d218f..d01439776d 100644 --- a/runtime/src/title_geometry_watch.h +++ b/runtime/src/title_geometry_watch.h @@ -40,30 +40,40 @@ inline DWORD read_only(DWORD protection) { default: return 0; } } -inline void reopen(std::uintptr_t va, Cell& c) { +// True when it made a page writable again. +inline bool reopen(std::uintptr_t va, Cell& c) { + bool opened = false; for (std::size_t i = 0; i < c.restore.size(); ++i) { if (!c.restore[i]) continue; void* p = reinterpret_cast(va + i * page_size); MEMORY_BASIC_INFORMATION m{}; DWORD old{}; if (!VirtualQuery(p, &m, sizeof m)) continue; - if (m.State == MEM_COMMIT && m.Protect == read_only(c.restore[i]) && - !VirtualProtect(p, page_size, c.restore[i], &old)) continue; + if (m.State == MEM_COMMIT && m.Protect == read_only(c.restore[i])) { + if (!VirtualProtect(p, page_size, c.restore[i], &old)) continue; + opened = true; + } c.restore[i] = 0; } + return opened; } inline void release(std::uintptr_t va) { auto& s = state(); std::lock_guard lock(s.mutex); auto it = s.cells.find(va); if (it != s.cells.end() && !--it->second.refs) { - reopen(va, it->second); + // A page reopened here may also be one a slot-133 shadow keeps read-only (both guard the title's geometry): + // it is writable now with no fault to tell that shadow, which then walks its pages again. + if (reopen(va, it->second)) title_memory_map::changed(va, va + tile_size); s.cells.erase(it); s.count.store(s.cells.size(), std::memory_order_release); } } enum class Event { write, open, fault, mapping, replaced }; -inline bool notify(std::uintptr_t begin, std::uintptr_t end, Event event) { +// `restored` (open and fault): set when a tile's pages were made writable again. A tile reopens all of its pages, and +// a page of it a slot-133 shadow also keeps read-only (both can guard one page: each queries, then protects, under its +// own lock) is writable then without that shadow knowing; the caller has the shadows reopen the whole tiles too. +inline bool notify(std::uintptr_t begin, std::uintptr_t end, Event event, bool* restored = nullptr) { auto& s = state(); if (!s.count.load(std::memory_order_acquire) || end <= begin) return false; std::lock_guard lock(s.mutex); @@ -74,7 +84,7 @@ inline bool notify(std::uintptr_t begin, std::uintptr_t end, Event event) { for (; it != s.cells.end() && it->first < end; ++it) { auto& cell = it->second; if (event == Event::open || event == Event::fault) { - reopen(it->first, cell); + if (reopen(it->first, cell) && restored) *restored = true; if (event == Event::fault) { MEMORY_BASIC_INFORMATION m{}; opened = VirtualQuery(reinterpret_cast(begin), &m, sizeof m) && @@ -114,7 +124,12 @@ inline bool arm(std::uintptr_t va, Cell& c) { if (m.State == MEM_COMMIT && !(m.Protect & PAGE_GUARD) && guarded) { DWORD old{}; if (!VirtualProtect(reinterpret_cast(p), end - p, guarded, &old)) return false; - for (auto j = i; j < next; ++j) c.restore[j] = old; + // What the query saw, not `old`: VirtualProtect returns the first page's protection only, and a slot-133 + // shadow (which guards these pages under its own lock) may have made that page read-only in between. A + // read-only `old` then marked every page of the run as read-only already, so reopen() never gave them back + // and they stayed read-only with no guard to answer for them: title writes and kernel writes into them + // failed for good. Such a page has two guards now; reopening it tells the shadows (notify's `restored`). + for (auto j = i; j < next; ++j) c.restore[j] = m.Protect; } i = next; } diff --git a/runtime/src/title_page_watch.h b/runtime/src/title_page_watch.h index 580edf6220..2592f57cec 100644 --- a/runtime/src/title_page_watch.h +++ b/runtime/src/title_page_watch.h @@ -21,8 +21,21 @@ // // Any other host code that has the kernel write title memory (a DirectStorage queue that ReadFiles straight into // a request's destination, for one) does the same: kernel_writes::read_file instead of ::ReadFile, or -// begin_write(destination, bytes, overlapped) before the call and end_write(id, pending) after it. A user-mode -// copy into title memory needs nothing: it faults like the title's own writes. +// begin_write(destination, bytes, overlapped) before the call and end_write(id, pending) after it. A host thread's +// own copy into title memory (a DirectStorage request decompressed into its destination) goes through +// kernel_writes::write: pinned the same way, so it takes no write fault per guarded block and is retried once after +// reopen() if it faults anyway. +// +// A pin made with an OVERLAPPED lasts until the call returns, whatever the OVERLAPPED says meanwhile: until +// ReadFile stores STATUS_PENDING in it, it reads as a completed request (zero, or the status of the title's last +// request through it), and a refresh that dropped the pin then could guard the destination again before the kernel +// wrote it (natively, DirectStorage reads failing with E_DSTORAGE_ACCESS_VIOLATION on a read-only destination). +// +// A page left read-only with no guard to answer for it (each guard reopens only what it protected) would fail every +// kernel write and fault every write for good. In xmem's physical-page views, where the protection a page should +// have is known (its window's), kernel_writes' unguarder (rt::xmem::reopen_unowned) makes such a page writable +// again: reopen() calls it before a retry, and the D3D12 layer's write-fault handler when no guard reopened the +// faulting page. // // Successful title memory map changes also invalidate the shadows' cached protection state. The shadows' own // protection changes stay local to their trackers. @@ -34,11 +47,14 @@ // Header-only, so the D3D12 layer, xmem and the file shims share one state in a process without linking each other. #include +#include "guarded_copy.h" + #include #include #include #include #include +#include #include #include #include @@ -93,12 +109,68 @@ using map = std::map, Allocator>>; } // namespace leonida::host_heap +// Changes to what the title's address space shows (a view mapped or unmapped, pages committed, decommitted, allocated, +// freed or given another protection by the title), each numbered by the generation it moved to, with its address +// range. A reader that remembers the generation it last looked at asks which ranges changed since (changes_since): +// only what overlaps its own pages needs looking at again, where a bare generation said "everything". The last +// kJournal changes are kept; a reader further behind is told so and looks at everything, as before. changed() with no +// range is a change anywhere. namespace leonida::title_memory_map { inline std::atomic map_generation{0}; +struct Change { + std::uintptr_t from, to; +}; +constexpr std::size_t kJournal = 1 << 16; // 1 MiB +struct Journal { + SRWLOCK lock = SRWLOCK_INIT; + Change at[kJournal] = {}; +}; +inline Journal& journal() { + static Journal j; + return j; +} + inline std::uint64_t generation() { return map_generation.load(std::memory_order_acquire); } -inline void changed() { map_generation.fetch_add(1, std::memory_order_release); } + +// [from, to) changed. No allocation and no title memory touched: the write-fault handler calls it. +inline void changed(std::uintptr_t from, std::uintptr_t to) { + if (from >= to) return; + from &= ~std::uintptr_t(0xfff); // whole host pages, as the kernel changes them + to = to > UINTPTR_MAX - 0xfff ? UINTPTR_MAX : (to + 0xfff) & ~std::uintptr_t(0xfff); + Journal& j = journal(); + AcquireSRWLockExclusive(&j.lock); + const std::uint64_t next = map_generation.load(std::memory_order_relaxed) + 1; + j.at[next % kJournal] = {from, to}; + map_generation.store(next, std::memory_order_release); + ReleaseSRWLockExclusive(&j.lock); +} +inline void changed(const void* at, std::size_t bytes) { + const auto from = reinterpret_cast(at); + changed(from, bytes > UINTPTR_MAX - from ? UINTPTR_MAX : from + bytes); +} +inline void changed() { changed(std::uintptr_t(0), std::uintptr_t(UINTPTR_MAX)); } + +// The changes after generation `since` that overlap [from, to): f(begin, end) for each, clipped to [from, to), with +// `now` set to the generation they go up to. False, with nothing called, when the journal no longer holds them all +// (the caller takes everything as changed). +template +bool changes_since(std::uint64_t since, std::uint64_t& now, std::uintptr_t from, std::uintptr_t to, F&& f) { + Journal& j = journal(); + AcquireSRWLockShared(&j.lock); + now = map_generation.load(std::memory_order_relaxed); + if (now < since || now - since > kJournal) { + ReleaseSRWLockShared(&j.lock); + return false; + } + for (std::uint64_t g = since + 1; g <= now; ++g) { + const Change c = j.at[g % kJournal]; + if (c.from < to && from < c.to) f((std::max)(c.from, from), (std::min)(c.to, to)); + } + ReleaseSRWLockShared(&j.lock); + return true; +} } // namespace leonida::title_memory_map @@ -155,6 +227,7 @@ namespace leonida::title_gpu_views { struct View { std::uintptr_t gpu, cpu, size; + bool independent_pages; // queue slot 31 maps physical pages at the GPU address itself }; struct State { @@ -170,7 +243,7 @@ inline State& state() { } // xmem: a reservation the title made, GPU-only or not. Returns true when it paired a GPU-only one. -inline bool note_reservation(std::uintptr_t base, std::uintptr_t size, bool gpu_only) { +inline bool note_reservation(std::uintptr_t base, std::uintptr_t size, bool gpu_only, bool independent_pages = false) { State& s = state(); std::unique_lock lock(s.mutex); if (!gpu_only) { @@ -179,22 +252,55 @@ inline bool note_reservation(std::uintptr_t base, std::uintptr_t size, bool gpu_ return false; } if (!s.last_cpu || s.last_cpu_size != size) return false; - s.views.push_back({base, s.last_cpu, size}); + s.views.push_back({base, s.last_cpu, size, independent_pages}); s.count.store(s.views.size(), std::memory_order_release); s.last_cpu = s.last_cpu_size = 0; return true; } -// Where the CPU reads the memory a GPU address names: the paired CPU range for a GPU-only view, else the address. +// Where the host reads a GPU address. Slot 31 maps its window directly; legacy pairs use the CPU view. inline std::uintptr_t to_cpu(std::uintptr_t va, std::uintptr_t bytes = 1) { State& s = state(); if (!s.count.load(std::memory_order_acquire)) return va; std::shared_lock lock(s.mutex); for (const View& v : s.views) - if (va >= v.gpu && va - v.gpu < v.size && bytes <= v.size - (va - v.gpu)) return va - v.gpu + v.cpu; + if (va >= v.gpu && va - v.gpu < v.size && bytes <= v.size - (va - v.gpu)) + return v.independent_pages ? va : va - v.gpu + v.cpu; return va; } +// A host-pointer import would pin the old physical pages across a queue remap. Use the +// ordinary dirty-page shadow for buffers in these GPU windows. +inline bool independently_mapped(std::uintptr_t va, std::uint64_t bytes) { + State& s = state(); + if (!bytes || !s.count.load(std::memory_order_acquire)) return false; + std::shared_lock lock(s.mutex); + for (const View& v : s.views) + if (v.independent_pages && (va >= v.gpu ? va - v.gpu < v.size : v.gpu - va < bytes)) return true; + return false; +} + +// A paired range: [gpu, gpu + size) and [cpu, cpu + size) are the title's two names for the same pages. +struct Range { + std::uintptr_t gpu, cpu, size; + bool independent_pages; +}; + +// The paired reservation that holds [va, va + bytes), from either of its addresses. False outside every pair. +inline bool view_at(std::uintptr_t va, std::uintptr_t bytes, Range& out) { + State& s = state(); + if (!s.count.load(std::memory_order_acquire)) return false; + std::shared_lock lock(s.mutex); + for (const View& v : s.views) { + if ((va >= v.gpu && va - v.gpu < v.size && bytes <= v.size - (va - v.gpu)) || + (va >= v.cpu && va - v.cpu < v.size && bytes <= v.size - (va - v.cpu))) { + out = {v.gpu, v.cpu, v.size, v.independent_pages}; + return true; + } + } + return false; +} + // The other address of memory in a paired range: the CPU view's address for a GPU-only one and the GPU-only // address for a CPU view's; 0 outside every pair. inline std::uintptr_t other_view(std::uintptr_t va) { @@ -208,6 +314,25 @@ inline std::uintptr_t other_view(std::uintptr_t va) { return 0; } +// The address of the pages at `va` through the CPU view of their pair (the stream-pool rule B described in +// docs/d3d12_vulkan.md): +// the host reads the frames there, so a buffer made over them is host-importable and shared with every other view +// naming that range, and a copy made from them reads what the title wrote. `va` itself when it is in no pair, or when +// the CPU view has no committed page and the GPU-only one has (queue slot 31 maps the frames at the alias). +inline std::uintptr_t to_host_view(std::uintptr_t va, std::uintptr_t bytes = 1) { + Range range{}; + if (!view_at(va, bytes, range)) return va; + const auto offset = va >= range.gpu && va - range.gpu < range.size ? va - range.gpu : va - range.cpu; + const auto cpu = range.cpu + offset, gpu = range.gpu + offset; + const auto readable = [](std::uintptr_t address) { + MEMORY_BASIC_INFORMATION region{}; + return VirtualQuery(reinterpret_cast(address), ®ion, sizeof(region)) && + region.State == MEM_COMMIT && region.Protect && !(region.Protect & (PAGE_NOACCESS | PAGE_GUARD)); + }; + if (cpu != va && readable(cpu)) return cpu; + return readable(gpu) ? gpu : va; +} + } // namespace leonida::title_gpu_views // 4. Texel writes (title_texel_writes). The title writes texels into its own texture memory through XG's @@ -562,15 +687,22 @@ using Opener = void (*)(std::uintptr_t begin, std::uintptr_t end); // touch (rt::xmem::commit_physical_range; pages xmem does not map are left as they are). gta6rt sets it at start. using Committer = bool (*)(const void* address, std::size_t bytes); +// xmem's side: makes the pages of its physical-page views in [begin, end) that are read-only although their window is +// writable, with no guard left to reopen them, writable again (rt::xmem::reopen_unowned). True when such a page there +// is writable now. Called from the write-fault handler: it must not wait for the process heap or g_phys_mutex. +using Unguarder = bool (*)(std::uintptr_t begin, std::uintptr_t end); + struct Pin { std::uintptr_t begin, end; const OVERLAPPED* overlapped; // null: ends when the call returns std::uint64_t id; + bool returned; // the call returned with the request pending: from now on the OVERLAPPED says when it ends }; struct State { std::atomic opener{nullptr}; std::atomic committer{nullptr}; + std::atomic unguarder{nullptr}; std::mutex mutex; host_heap::vector pins; // host_heap: see there std::uint64_t next_id = 1; @@ -584,25 +716,28 @@ inline State& state() { inline void set_opener(Opener opener) { state().opener.store(opener, std::memory_order_release); } inline void set_committer(Committer committer) { state().committer.store(committer, std::memory_order_release); } +inline void set_unguarder(Unguarder unguarder) { state().unguarder.store(unguarder, std::memory_order_release); } // Whether an overlapped request is still in flight. Its OVERLAPPED is the title's and may be gone by now: a read that // faults counts as completed (the title doesn't free an OVERLAPPED it is still waiting on). inline bool overlapped_pending(const OVERLAPPED* overlapped) { - __try { - return overlapped->Internal == static_cast(STATUS_PENDING); + __try { // the read is a call (src/guarded_copy.h): clang-cl does not cover an inline load without /EHa + return guarded::read_word(&overlapped->Internal) == static_cast(STATUS_PENDING); } __except (EXCEPTION_EXECUTE_HANDLER) { return false; } } -// The pinned ranges overlapping [begin, end), for the layer's refresh. Overlapped pins whose request completed are -// dropped first. +// The pinned ranges overlapping [begin, end), for the layer's refresh. Overlapped pins whose call returned and whose +// request completed since are dropped first; one whose call is still running stays (see the top of this file). template void for_each_pin(std::uintptr_t begin, std::uintptr_t end, F&& f) { State& s = state(); if (!s.count.load(std::memory_order_acquire)) return; std::lock_guard lock(s.mutex); - std::erase_if(s.pins, [](const Pin& pin) { return pin.overlapped && !overlapped_pending(pin.overlapped); }); + std::erase_if(s.pins, [](const Pin& pin) { + return pin.overlapped && pin.returned && !overlapped_pending(pin.overlapped); + }); s.count.store(s.pins.size(), std::memory_order_release); for (const Pin& pin : s.pins) if (pin.begin < end && begin < pin.end) f((std::max)(pin.begin, begin), (std::min)(pin.end, end)); @@ -619,7 +754,7 @@ inline std::uint64_t begin_write(const void* buffer, std::size_t bytes, const OV { std::lock_guard lock(s.mutex); id = s.next_id++; - s.pins.push_back({begin, begin + bytes, overlapped, id}); + s.pins.push_back({begin, begin + bytes, overlapped, id, false}); s.count.store(s.pins.size(), std::memory_order_release); } // After the pin: a refresh that runs from here on leaves the range writable. @@ -632,7 +767,14 @@ inline void end_write(std::uint64_t id, bool pending) { if (!id) return; State& s = state(); std::lock_guard lock(s.mutex); - std::erase_if(s.pins, [id, pending](const Pin& pin) { return pin.id == id && !(pending && pin.overlapped); }); + for (auto it = s.pins.begin(); it != s.pins.end(); ++it) { + if (it->id != id) continue; + if (pending && it->overlapped) + it->returned = true; + else + s.pins.erase(it); + break; + } s.count.store(s.pins.size(), std::memory_order_release); } @@ -662,18 +804,76 @@ inline std::uint64_t hold(const void* buffer, std::size_t bytes) { inline void release(std::uint64_t id) { end_write(id, false); } // Readies [buffer, buffer + bytes) for a retry after ERROR_NOACCESS: commits xmem's pages that wait for their first -// touch (the kernel's write does not fault them in) and opens watched pages again. false: neither side is set. +// touch (the kernel's write does not fault them in), opens watched pages again, and then makes xmem's pages that are +// still read-only with no guard to answer for it writable. false: no side is set. inline bool reopen(const void* buffer, std::size_t bytes) { if (!buffer || !bytes) return false; const State& s = state(); const Committer committer = s.committer.load(std::memory_order_acquire); const Opener opener = s.opener.load(std::memory_order_acquire); + const Unguarder unguarder = s.unguarder.load(std::memory_order_acquire); + const auto begin = reinterpret_cast(buffer); if (committer) committer(buffer, bytes); - if (opener) { - const auto begin = reinterpret_cast(buffer); - opener(begin, begin + bytes); + if (opener) opener(begin, begin + bytes); + if (unguarder) unguarder(begin, begin + bytes); + return committer || opener || unguarder; +} + +namespace detail { +// memmove that reports an access violation instead of raising it (after the vectored handlers declined it). No C++ +// objects here: a function with __try cannot have any that need unwinding. leonida::guarded::move, not the CRT's +// memmove: under Wine a fault inside ucrtbase never reaches this __except (src/guarded_copy.h). +inline bool move_guarded(void* destination, const void* source, std::size_t bytes) { + __try { + guarded::move(destination, source, bytes); + return true; + } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return false; } - return committer || opener; +} + +// An aligned 4- or 8-byte store (guarded::store32/store64) that reports an access violation the same way. +inline bool store_guarded(void* destination, std::uint64_t value, std::size_t bytes) { + __try { + if (bytes == 8) + guarded::store64(destination, value); + else + guarded::store32(destination, static_cast(value)); + return true; + } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return false; + } +} +} // namespace detail + +// A host thread's copy of `bytes` from `source` into the title's memory at `destination`: pinned and opened as a +// kernel write is, so the guards over it are lifted first, the copies take the bytes at the next submission and no +// refresh guards it again mid-copy; retried once after reopen() if it faults anyway (not when the two ranges overlap: +// the part copied before the fault changed the source). False when it still faults (the destination, or the source, +// is not memory it can copy). +inline bool write(void* destination, const void* source, std::size_t bytes) { + if (!bytes) return true; + const auto to = reinterpret_cast(destination), from = reinterpret_cast(source); + const bool overlap = to < from + bytes && from < to + bytes; + const std::uint64_t pin = begin_write(destination, bytes, nullptr); + bool ok = detail::move_guarded(destination, source, bytes); + if (!ok && !overlap && reopen(destination, bytes)) ok = detail::move_guarded(destination, source, bytes); + end_write(pin, false); + return ok; +} + +// write() of a 4- or 8-byte value (the low `bytes` of `value`). Aligned, it is stored in one locked access, so a +// title thread polling it never reads a mix of the old and the new value; pinned and retried the same way. +inline bool store(void* destination, std::uint64_t value, std::size_t bytes) { + const auto to = reinterpret_cast(destination); + if ((bytes != 4 && bytes != 8) || to % bytes) return write(destination, &value, bytes); + const std::uint64_t pin = begin_write(destination, bytes, nullptr); + bool ok = detail::store_guarded(destination, value, bytes); + if (!ok && reopen(destination, bytes)) ok = detail::store_guarded(destination, value, bytes); + end_write(pin, false); + return ok; } // The file shims' reads into title memory (file_system.cpp): ReadFile, ReadFileEx and ReadFileScatter with their diff --git a/runtime/src/title_texture_memory.h b/runtime/src/title_texture_memory.h index d592029c25..a97e5bed66 100644 --- a/runtime/src/title_texture_memory.h +++ b/runtime/src/title_texture_memory.h @@ -6,14 +6,18 @@ namespace leonida { -// Keep negative probes until the title changes the map or a writer reports this footprint. +// Keep negative probes until the title changes the map or a writer reports this footprint. With cache_success, +// positive ones too: a caller that is told of every map change over the footprint (retry) and reads it under a guard +// (a page gone since faults into a defer) need not walk the pages before every read. class TextureReadability { public: template - bool check(std::uint64_t generation, bool cache_failure, Probe probe) { + bool check(std::uint64_t generation, bool cache_failure, Probe probe, bool cache_success = false) { if (cache_failure && pending_ && !retry_ && generation_ == generation) return false; + if (cache_success && probed_ && !pending_ && !retry_ && generation_ == generation) return true; generation_ = generation; // snapshot before the probe so a concurrent map change is noticed retry_ = false; + probed_ = true; pending_ = !probe(); return !pending_; } @@ -22,7 +26,7 @@ class TextureReadability { bool pending() const { return pending_; } private: std::uint64_t generation_ = 0; - bool pending_ = false, retry_ = false; + bool pending_ = false, retry_ = false, probed_ = false; }; using TexturePageCommitter = bool (*)(const void*, std::size_t); diff --git a/runtime/src/title_texture_refresh.h b/runtime/src/title_texture_refresh.h index 21a88d2796..ed7c0f2b67 100644 --- a/runtime/src/title_texture_refresh.h +++ b/runtime/src/title_texture_refresh.h @@ -28,17 +28,35 @@ inline bool title_write_overlaps(const TitleWriteRanges& writes, std::uintptr_t return begin < end && it != writes.end() && it->first < end; } -// Poll unmarked textures in placement order. A time or byte limit resumes the next pass at +// The registry's entries as one pass will visit them, in placement order. A pass cannot walk the registry itself: a +// fill it makes can submit, a submission destroys a retired image, and that image's destructor erases its entry +// (DeviceState::title_texture_gone). Windows' mutex is recursive for its owner, so the erase lands inside the pass and +// the walk would step through a freed node. The list holds a reference to each entry, so an entry erased during the +// pass is still alive when its turn comes. +template +std::vector> title_texture_snapshot(const Registry& textures) { + std::vector> entries; + entries.reserve(textures.size()); + for (const auto& [address, texture] : textures) entries.emplace_back(address, texture); + return entries; +} + +// Poll unmarked textures of a snapshot in placement order. A time or byte limit resumes the next pass at // the following address. The cursor also survives insertion or removal between passes. -template -void poll_title_textures(Registry& textures, std::uint64_t& cursor, Visit visit, Exhausted exhausted) { - auto it = textures.lower_bound(cursor); - for (auto left = textures.size(); left; --left) { - if (it == textures.end()) it = textures.begin(); - auto& [address, texture] = *it++; +template +void poll_title_textures(const std::vector& entries, std::uint64_t& cursor, Visit visit, Exhausted exhausted) { + if (entries.empty()) return; + // A snapshot of a std::map comes out sorted by address. + const auto first = std::lower_bound(entries.begin(), entries.end(), cursor, + [](const Entry& entry, std::uint64_t at) { return entry.first < at; }); + auto index = std::size_t(first - entries.begin()); + if (index == entries.size()) index = 0; // the cursor is past the last address: resume at the first + for (auto left = entries.size(); left; --left) { + const auto& [address, texture] = entries[index]; cursor = address + 1; if (!texture->mapped && !texture->stale) visit(*texture); if (exhausted()) break; // advance at least one registry entry even if a deadline already passed + index = index + 1 == entries.size() ? 0 : index + 1; } } diff --git a/runtime/src/title_va_alias.h b/runtime/src/title_va_alias.h index 6e97d7f1d1..b3de5ce706 100644 --- a/runtime/src/title_va_alias.h +++ b/runtime/src/title_va_alias.h @@ -33,12 +33,13 @@ namespace leonida { class TitleVaAliases { public: // Where the layer saw the address, for the counters. - enum Kind : unsigned { root_view, created_view, table_view, vertex_view, index_view, kind_count }; + enum Kind : unsigned { root_view, created_view, table_view, vertex_view, index_view, bvh_address, kind_count }; static constexpr const char* kKindNames[kind_count] = {"root view", "created view", "table V#", "vertex view", - "index view"}; + "index view", "BVH build address"}; - // An address in the title's memory: true, with `shader_va` what a shader must be given (the address itself when - // no copy could be made). False: not the title's memory (an arena VA, a buffer of the layer's). + // An address in the title's memory: true, with `shader_va` what a shader must be given (0 when no copy can be + // made: the view is then written with a zero-size range, never with the raw address). False: not the title's + // memory (an arena VA, a buffer of the layer's). using Resolver = bool (*)(void* context, std::uint64_t va, std::uint64_t bytes, std::uint64_t& shader_va); using TableScanner = void (*)(void* context, std::uint64_t table_va, std::uint32_t descriptors); @@ -53,12 +54,23 @@ class TitleVaAliases { return true; } + // The two addresses of one stream-pool extent (a GPU-only alias and the CPU view of the same pages, gfxgeom + // section 3): both name the same shader VA, so a title view carrying either resolves to the one mapping. + bool add_twin(std::uint64_t va, std::uint64_t twin, std::uint64_t bytes, std::uint64_t shader_va) { + if (va == twin) return add(va, bytes, shader_va); + const bool first = add(va, bytes, shader_va); + return add(twin, bytes, shader_va) && first; + } + // Forgets the range that starts at title_va, if it still maps to shader_va (a newer range at the same VA keeps // its own entry). void remove(std::uint64_t title_va, std::uint64_t shader_va) { std::unique_lock lock(mutex_); const auto it = ranges_.find(title_va); - if (it != ranges_.end() && it->second.shader_va == shader_va) ranges_.erase(it); + if (it != ranges_.end() && it->second.shader_va == shader_va) { + ranges_.erase(it); + invalidations_.fetch_add(1, std::memory_order_release); + } count_.store(ranges_.size(), std::memory_order_release); } @@ -74,6 +86,33 @@ class TitleVaAliases { return it->second.shader_va + (va - it->first); } + // The range that holds `va`: true with `shader_va` what `va` becomes and `available` the bytes from `va` to the + // range's end, all reached through the one copy. False when no range holds `va`. + bool range_of(std::uint64_t va, std::uint64_t& shader_va, std::uint64_t& available) const { + if (!count_.load(std::memory_order_acquire)) return false; + std::shared_lock lock(mutex_); + auto it = ranges_.upper_bound(va); + if (it == ranges_.begin()) return false; + --it; + if (va >= it->second.end) return false; + shader_va = it->second.shader_va + (va - it->first); + available = it->second.end - va; + return true; + } + + // Every range, in title-VA order (they never overlap): what a GPU pass that finds title addresses in memory + // (the BLAS address of a TLAS build's instance descs) translates them with. + struct Mapping { + std::uint64_t title_va, end, shader_va; + }; + void mappings(std::vector& out) const { + out.clear(); + if (!count_.load(std::memory_order_acquire)) return; + std::shared_lock lock(mutex_); + out.reserve(ranges_.size()); + for (const auto& [start, range] : ranges_) out.push_back({start, range.end, range.shader_va}); + } + // Debug-only inverse lookup. V#s retain 48 bits, so an import below heap_base wraps. bool source_of_vsharp(std::uint64_t base, std::uint64_t& title, std::uint64_t& available) const { constexpr std::uint64_t mask = (1ull << 48) - 1; @@ -100,7 +139,9 @@ class TitleVaAliases { } // shader_va, and when `va` is in the title's memory with no copy yet, a copy made by the device's resolver. - // Counted by kind: translated, or in the title's memory and left as it was. + // A resolver that cannot back the address (no window or geometry copy fits) answers 0: the view is then written + // with a zero-size range, never with the raw title address (heap_base + a raw VA is no allocation a shader can + // read or write). Counted by kind: translated, or in the title's memory and left as it was. std::uint64_t resolve(std::uint64_t va, std::uint64_t bytes, Kind kind) { if (!va) return va; std::uint64_t to = shader_va(va); @@ -272,6 +313,8 @@ class TitleVaAliases { void clear_resolver(void* context) { clear_hooks(context); } std::size_t size() const { return count_.load(std::memory_order_acquire); } + std::uint64_t invalidations() const { return invalidations_.load(std::memory_order_acquire); } + void note_translation(Kind kind) { translated_[kind].fetch_add(1, std::memory_order_relaxed); } std::uint64_t translated(Kind kind) const { return translated_[kind].load(std::memory_order_relaxed); } std::uint64_t untranslated(Kind kind) const { return untranslated_[kind].load(std::memory_order_relaxed); } @@ -287,12 +330,14 @@ class TitleVaAliases { auto previous = std::prev(it); if (previous->second.end > begin) it = previous; } + if (it != ranges_.end() && it->first < end) invalidations_.fetch_add(1, std::memory_order_release); while (it != ranges_.end() && it->first < end) it = ranges_.erase(it); } mutable std::shared_mutex mutex_; std::map ranges_; // by title VA std::atomic count_{0}; + std::atomic invalidations_{}; std::mutex hook_mutex_; void* hook_context_ = nullptr; void* maker_context_ = nullptr; @@ -315,4 +360,16 @@ inline TitleVaAliases& title_va_aliases() { return aliases; } +// One diagnostic per descriptor-writing path. +inline void note_unbacked_view(const char* site, std::uint64_t va, std::uint64_t bytes) { + static std::mutex mutex; + static std::map sites; + { + std::lock_guard lock(mutex); + if (!sites.emplace(site, true).second) return; + } + std::fprintf(stderr, "[rt] d3d12: %s: address 0x%llx (%llu bytes) has no GPU copy; zero records\n", + site, static_cast(va), static_cast(bytes)); +} + } // namespace leonida diff --git a/runtime/src/title_window_plan.h b/runtime/src/title_window_plan.h new file mode 100644 index 0000000000..807641df15 --- /dev/null +++ b/runtime/src/title_window_plan.h @@ -0,0 +1,63 @@ +#pragma once +// Where a title-window mapping sits and how much of a stream pool one mapping serves, without a device +// (docs/d3d12_vulkan.md section 3.3 "Title-chosen addresses"). +// +// The device's resolve_title_memory makes the mapping; these decide its range first, so a test can count mappings +// without Vulkan. Two rules matter here: +// - a window is page-aligned, capped at one request's maximum and charged to LEONIDA_TITLE_WINDOWS_MB; one that +// does not fit is not made, and the address is backed another way or written as a zero-size view, never raw; +// - a stream pool (the title's CPU view paired with a GPU-only alias, gfxgeom section 3) is one reservation of +// 16-24 GiB, so it cannot be one allocation: one mapping serves a page-aligned readable run of it, and every +// request inside that run reuses it instead of asking for a 128 KiB window each. +#include +#include + +namespace leonida { + +// A page-aligned mapping of the title's memory: [start, start + size). +struct TitleWindowRange { + std::uint64_t start{}; + std::uint64_t size{}; +}; + +// `size` bytes more fit in the title-window budget [used, cap). +inline bool title_window_fits(std::uint64_t cap, std::uint64_t used, std::uint64_t size) { + return used <= cap && size <= cap - used; +} + +// The page-aligned range a window made for [va, va + bytes) covers: inside the free span [lo, hi), aligned to +// `align`, at most `most` bytes of the request, and charged against [used, cap). False when the span holds no page +// for it or the budget has no room. +inline bool title_window_range(std::uint64_t va, std::uint64_t bytes, std::uint64_t lo, std::uint64_t hi, + std::uint64_t align, std::uint64_t most, std::uint64_t cap, std::uint64_t used, + TitleWindowRange& out) { + if (!align || hi <= va) return false; + const std::uint64_t want = std::clamp(bytes ? bytes : 1, 1, most); + const std::uint64_t start = (std::max)(va & ~(align - 1), lo); + std::uint64_t end = va > UINT64_MAX - want - align ? UINT64_MAX : (va + want + align - 1) & ~(align - 1); + end = (std::min)(end, hi); + if (end <= start) return false; + const TitleWindowRange range{start, end - start}; + if (!title_window_fits(cap, used, range.size)) return false; + out = range; + return true; +} + +// The extent of a stream pool one mapping serves for the request at `va`: from its page to the end of the readable +// run (`readable_end`, exclusive), at most `most` bytes, inside the pool [pool_lo, pool_hi). The same extent comes +// back for every request inside it, so each extent costs one mapping, not one per request. +inline bool title_pool_extent(std::uint64_t pool_lo, std::uint64_t pool_hi, std::uint64_t va, + std::uint64_t readable_end, std::uint64_t align, std::uint64_t most, + TitleWindowRange& out) { + if (!align || pool_hi <= pool_lo || va < pool_lo || va >= pool_hi) return false; + const std::uint64_t start = (std::max)(va & ~(align - 1), pool_lo); + std::uint64_t end = (std::min)(readable_end, pool_hi); + if (most) end = (std::min)(end, start > UINT64_MAX - most ? UINT64_MAX : start + most); + end = end > UINT64_MAX - (align - 1) ? UINT64_MAX : (end + align - 1) & ~(align - 1); + end = (std::min)(end, pool_hi); + if (end <= va) return false; + out = {start, end - start}; + return true; +} + +} // namespace leonida diff --git a/runtime/src/vulkan_aftermath.cpp b/runtime/src/vulkan_aftermath.cpp new file mode 100644 index 0000000000..82c1661367 --- /dev/null +++ b/runtime/src/vulkan_aftermath.cpp @@ -0,0 +1,822 @@ +// NVIDIA Nsight Aftermath GPU crash dumps for the Vulkan device (vulkan_aftermath.h). Without LEONIDA_HAVE_AFTERMATH +// (no -DLEONIDA_AFTERMATH_SDK at configure time) this file only has the do-nothing versions. +#include "vulkan_aftermath.h" + +#include "vulkan_device_fault.h" + +#ifdef LEONIDA_HAVE_AFTERMATH + +#include "shader_library.h" // leonida::Json, leonida::JsonReader + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef LEONIDA_AFTERMATH_DLL_DEFAULT +#define LEONIDA_AFTERMATH_DLL_DEFAULT "" +#endif +#ifndef LEONIDA_AFTERMATH_APP_VERSION +#define LEONIDA_AFTERMATH_APP_VERSION "unknown" +#endif + +namespace leonida::aftermath { +namespace { + +using Clock = std::chrono::steady_clock; +constexpr auto wait_limit = std::chrono::seconds(10); + +std::wstring env_w(const wchar_t* name) { + wchar_t buffer[32768]; + const DWORD n = GetEnvironmentVariableW(name, buffer, DWORD(std::size(buffer))); + return n && n < std::size(buffer) ? std::wstring(buffer, n) : std::wstring(); +} + +bool env_is(const wchar_t* name, wchar_t value) { + const std::wstring v = env_w(name); + return v.size() == 1 && v[0] == value; +} + +std::filesystem::path from_utf8(std::string_view text) { + return std::filesystem::path(std::u8string(reinterpret_cast(text.data()), text.size())); +} + +std::string narrow(const std::filesystem::path& path) { + const std::u8string s = path.u8string(); + return std::string(s.begin(), s.end()); +} + +struct Library { + HMODULE module = nullptr; + PFN_GFSDK_Aftermath_EnableGpuCrashDumps EnableGpuCrashDumps = nullptr; + PFN_GFSDK_Aftermath_GetCrashDumpStatus GetCrashDumpStatus = nullptr; + PFN_GFSDK_Aftermath_GetShaderHashSpirv GetShaderHashSpirv = nullptr; + PFN_GFSDK_Aftermath_GetShaderDebugInfoIdentifier GetShaderDebugInfoIdentifier = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_CreateDecoder CreateDecoder = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_DestroyDecoder DestroyDecoder = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetBaseInfo GetBaseInfo = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo GetDeviceInfo = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo GetPageFaultInfo = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo GetPageFaultResourceInfo = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount GetActiveShadersInfoCount = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo GetActiveShadersInfo = nullptr; + PFN_GFSDK_Aftermath_GetShaderHashForShaderInfo GetShaderHashForShaderInfo = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GenerateJSON GenerateJSON = nullptr; + PFN_GFSDK_Aftermath_GpuCrashDump_GetJSON GetJSON = nullptr; + + bool load(const std::wstring& path) { + module = path.find_first_of(L"\\/") != std::wstring::npos + ? LoadLibraryExW(path.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH) + : LoadLibraryW(path.c_str()); + if (!module) return false; + bool ok = true; + const auto get = [&](auto& fn, const char* name) { + fn = reinterpret_cast>(GetProcAddress(module, name)); + if (!fn) { + std::fprintf(stderr, "[rt] aftermath: %s is missing from the library\n", name); + ok = false; + } + }; + get(EnableGpuCrashDumps, "GFSDK_Aftermath_EnableGpuCrashDumps"); + get(GetCrashDumpStatus, "GFSDK_Aftermath_GetCrashDumpStatus"); + get(GetShaderHashSpirv, "GFSDK_Aftermath_GetShaderHashSpirv"); + get(GetShaderDebugInfoIdentifier, "GFSDK_Aftermath_GetShaderDebugInfoIdentifier"); + get(CreateDecoder, "GFSDK_Aftermath_GpuCrashDump_CreateDecoder"); + get(DestroyDecoder, "GFSDK_Aftermath_GpuCrashDump_DestroyDecoder"); + get(GetBaseInfo, "GFSDK_Aftermath_GpuCrashDump_GetBaseInfo"); + get(GetDeviceInfo, "GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo"); + get(GetPageFaultInfo, "GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo"); + get(GetPageFaultResourceInfo, "GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo"); + get(GetActiveShadersInfoCount, "GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount"); + get(GetActiveShadersInfo, "GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo"); + get(GetShaderHashForShaderInfo, "GFSDK_Aftermath_GetShaderHashForShaderInfo"); + get(GenerateJSON, "GFSDK_Aftermath_GpuCrashDump_GenerateJSON"); + get(GetJSON, "GFSDK_Aftermath_GpuCrashDump_GetJSON"); + return ok; + } +}; + +struct Shader { + std::string name; + std::vector words; // only with LEONIDA_AFTERMATH_KEEP_SPIRV=1 +}; + +struct State { + Library lib; + std::filesystem::path dir; + std::filesystem::path shader_dir; // LEONIDA_SHADERS: where a module's SPIR-V is read back for the decoder + bool keep_spirv = false; + VkDeviceDiagnosticsConfigFlagsNV extra_flags = 0; + std::atomic enabled{false}; + std::atomic real_create{nullptr}; + std::atomic real_get{nullptr}; + + std::mutex shaders_mutex; // leaf + std::unordered_map shaders; + std::atomic registered{0}, hash_failures{0}; + + std::mutex debug_mutex; // leaf + std::map, std::vector> debug_info; + + std::mutex dump_mutex; // leaf, guards everything below + std::condition_variable dump_cv; + std::vector dump; + std::filesystem::path dump_path; + bool have_dump = false, decoded = false; + std::string summary; + + std::mutex wait_mutex; // held by the first device-loss waiter; later ones queue behind it + bool waited = false; +}; + +State& state() { + static State* s = new State; // never destroyed: Aftermath's threads may call back during exit + return *s; +} + +std::string hex64(std::uint64_t v) { + char buffer[24]; + std::snprintf(buffer, sizeof buffer, "%016" PRIx64, v); + return buffer; +} + +std::string stamp() { + SYSTEMTIME t{}; + GetLocalTime(&t); + char buffer[64]; + std::snprintf(buffer, sizeof buffer, "%04u%02u%02u-%02u%02u%02u-%03u-pid%lu", t.wYear, t.wMonth, t.wDay, t.wHour, + t.wMinute, t.wSecond, t.wMilliseconds, GetCurrentProcessId()); + return buffer; +} + +bool write_file(const std::filesystem::path& path, const void* data, std::size_t size) { + std::error_code ec; + std::filesystem::create_directories(path.parent_path(), ec); + std::ofstream out(path, std::ios::binary | std::ios::trunc); + out.write(static_cast(data), std::streamsize(size)); + return bool(out); +} + +std::uint64_t spirv_hash(const void* code, std::size_t bytes) { + State& s = state(); + GFSDK_Aftermath_SpirvCode spirv{}; + spirv.pData = code; + spirv.size = std::uint32_t(bytes); + GFSDK_Aftermath_ShaderBinaryHash hash{}; + if (!GFSDK_Aftermath_SUCCEED(s.lib.GetShaderHashSpirv(GFSDK_Aftermath_Version_API, &spirv, &hash))) return 0; + return hash.hash; +} + +const char* status_name(GFSDK_Aftermath_Device_Status status) { + switch (status) { + case GFSDK_Aftermath_Device_Status_Active: return "Active"; + case GFSDK_Aftermath_Device_Status_Timeout: return "Timeout"; + case GFSDK_Aftermath_Device_Status_OutOfMemory: return "OutOfMemory"; + case GFSDK_Aftermath_Device_Status_PageFault: return "PageFault"; + case GFSDK_Aftermath_Device_Status_Stopped: return "Stopped"; + case GFSDK_Aftermath_Device_Status_Reset: return "Reset"; + case GFSDK_Aftermath_Device_Status_DmaFault: return "DmaFault"; + case GFSDK_Aftermath_Device_Status_DeviceRemovedNoGpuFault: return "DeviceRemovedNoGpuFault"; + default: return "Unknown"; + } +} + +const char* fault_name(GFSDK_Aftermath_FaultType type) { + switch (type) { + case GFSDK_Aftermath_FaultType_AddressTranslationError: return "AddressTranslationError"; + case GFSDK_Aftermath_FaultType_IllegalAccessError: return "IllegalAccessError"; + default: return "Unknown"; + } +} + +const char* access_name(GFSDK_Aftermath_AccessType type) { + switch (type) { + case GFSDK_Aftermath_AccessType_Read: return "Read"; + case GFSDK_Aftermath_AccessType_Write: return "Write"; + case GFSDK_Aftermath_AccessType_Atomic: return "Atomic"; + default: return "Unknown"; + } +} + +const char* engine_name(GFSDK_Aftermath_Engine engine) { + switch (engine) { + case GFSDK_Aftermath_Engine_Graphics: return "Graphics"; + case GFSDK_Aftermath_Engine_GraphicsCompute: return "GraphicsCompute"; + case GFSDK_Aftermath_Engine_Display: return "Display"; + case GFSDK_Aftermath_Engine_CopyEngine: return "CopyEngine"; + case GFSDK_Aftermath_Engine_VideoDecoder: return "VideoDecoder"; + case GFSDK_Aftermath_Engine_VideoEncoder: return "VideoEncoder"; + case GFSDK_Aftermath_Engine_Other: return "Other"; + default: return "Unknown"; + } +} + +const char* client_name(GFSDK_Aftermath_Client client) { + switch (client) { + case GFSDK_Aftermath_Client_HostInterface: return "HostInterface"; + case GFSDK_Aftermath_Client_FrontEnd: return "FrontEnd"; + case GFSDK_Aftermath_Client_PrimitiveDistributor: return "PrimitiveDistributor"; + case GFSDK_Aftermath_Client_GraphicsProcessingCluster: return "GraphicsProcessingCluster"; + case GFSDK_Aftermath_Client_PolymorphEngine: return "PolymorphEngine"; + case GFSDK_Aftermath_Client_RasterEngine: return "RasterEngine"; + case GFSDK_Aftermath_Client_Rasterizer2D: return "Rasterizer2D"; + case GFSDK_Aftermath_Client_RenderOutputUnit: return "RenderOutputUnit"; + case GFSDK_Aftermath_Client_TextureProcessingCluster: return "TextureProcessingCluster"; + case GFSDK_Aftermath_Client_CopyEngine: return "CopyEngine"; + case GFSDK_Aftermath_Client_VideoDecoder: return "VideoDecoder"; + case GFSDK_Aftermath_Client_VideoEncoder: return "VideoEncoder"; + case GFSDK_Aftermath_Client_Other: return "Other"; + default: return "Unknown"; + } +} + +const char* shader_type_name(GFSDK_Aftermath_ShaderType type) { + switch (type) { + case GFSDK_Aftermath_ShaderType_Vertex: return "vertex"; + case GFSDK_Aftermath_ShaderType_Tessellation_Control: return "hull"; + case GFSDK_Aftermath_ShaderType_Tessellation_Evaluation: return "domain"; + case GFSDK_Aftermath_ShaderType_Geometry: return "geometry"; + case GFSDK_Aftermath_ShaderType_Fragment: return "pixel"; + case GFSDK_Aftermath_ShaderType_Compute: return "compute"; + case GFSDK_Aftermath_ShaderType_Mesh: return "mesh"; + case GFSDK_Aftermath_ShaderType_Task: return "task"; + default: return type >= GFSDK_Aftermath_ShaderType_RayTracing_RayGeneration && + type <= GFSDK_Aftermath_ShaderType_RayTracing_Internal + ? "ray tracing" + : "unknown"; + } +} + +const char* residency_name(GFSDK_Aftermath_ResourceResidency residency) { + switch (residency) { + case GFSDK_Aftermath_ResourceResidency_FullyResident: return "resident"; + case GFSDK_Aftermath_ResourceResidency_Evicted: return "evicted"; + case GFSDK_Aftermath_ResourceResidency_MemoryFreed: return "memory freed"; + case GFSDK_Aftermath_ResourceResidency_MemoryUnbound: return "memory unbound"; + default: return "unknown"; + } +} + +std::string shader_name(std::uint64_t hash) { + State& s = state(); + std::lock_guard lock(s.shaders_mutex); + const auto it = s.shaders.find(hash); + return it == s.shaders.end() ? "unregistered" : it->second.name; +} + +// ---- decoding ---- + +struct DecodeContext { + std::map> binaries; // alive until the decoder is destroyed + std::vector written; +}; + +// The module's SPIR-V for the decoder: the kept copy, else /.spv when its hash matches (a +// patched module, such as a depth24 pixel shader, does not). +std::vector find_binary(std::uint64_t hash) { + State& s = state(); + std::string name; + { + std::lock_guard lock(s.shaders_mutex); + const auto it = s.shaders.find(hash); + if (it == s.shaders.end()) return {}; + if (!it->second.words.empty()) return it->second.words; + name = it->second.name; + } + if (s.shader_dir.empty() || name.empty() || name.front() == '(') return {}; + const std::filesystem::path path = s.shader_dir / from_utf8(name + ".spv"); + std::ifstream file(path, std::ios::binary | std::ios::ate); + if (!file) return {}; + const auto size = std::size_t(file.tellg()); + if (!size || size % 4 || size > (256u << 20)) return {}; + std::vector words(size / 4); + file.seekg(0); + file.read(reinterpret_cast(words.data()), std::streamsize(size)); + if (!file || spirv_hash(words.data(), size) != hash) return {}; + return words; +} + +void GFSDK_AFTERMATH_CALL lookup_debug_info(const GFSDK_Aftermath_ShaderDebugInfoIdentifier* id, + PFN_GFSDK_Aftermath_SetData set, void*) { + State& s = state(); + std::lock_guard lock(s.debug_mutex); + const auto it = s.debug_info.find({id->id[0], id->id[1]}); + if (it != s.debug_info.end()) set(it->second.data(), std::uint32_t(it->second.size())); +} + +void GFSDK_AFTERMATH_CALL lookup_shader(const GFSDK_Aftermath_ShaderBinaryHash* hash, PFN_GFSDK_Aftermath_SetData set, + void* user) { + auto& context = *static_cast(user); + auto it = context.binaries.find(hash->hash); + if (it == context.binaries.end()) { + it = context.binaries.emplace(hash->hash, find_binary(hash->hash)).first; + if (!it->second.empty()) { + // Next to the dump, for nv-aftermath-format -b and Nsight Graphics. + const auto path = state().dir / (hex64(hash->hash) + ".spv"); + if (write_file(path, it->second.data(), it->second.size() * 4)) context.written.push_back(narrow(path)); + } + } + if (!it->second.empty()) set(it->second.data(), std::uint32_t(it->second.size() * 4)); +} + +std::string lower(std::string_view text) { + std::string out(text); + for (char& c : out) c = char(std::tolower(static_cast(c))); + return out; +} + +std::string scalar(const Json& value) { + switch (value.kind) { + case Json::Kind::string: return value.string; + case Json::Kind::boolean: return value.boolean ? "true" : "false"; + case Json::Kind::number: { + char buffer[32]; + if (value.number >= 0 && value.number < 18446744073709551616.0 && value.number == double(std::uint64_t(value.number))) + std::snprintf(buffer, sizeof buffer, "%" PRIu64, std::uint64_t(value.number)); + else + std::snprintf(buffer, sizeof buffer, "%g", value.number); + return buffer; + } + default: return {}; + } +} + +// One line per object: its scalar fields, and the scalars of objects nested one level down. +std::string flatten(const Json& object) { + std::string out; + const auto add = [&out](std::string_view key, std::string value) { + for (char& c : value) + if (c == '\n' || c == '\r') c = ' '; + if (!value.empty()) out += (out.empty() ? "" : " ") + std::string(key) + "=" + value; + }; + for (const auto& [key, value] : object.object) { + if (value.kind == Json::Kind::object) + for (const auto& [inner_key, inner] : value.object) add(key + "." + inner_key, scalar(inner)); + else if (value.kind != Json::Kind::array) + add(key, scalar(value)); + } + return out; +} + +// The decoder writes 64-bit values (shader hashes, pointers) as JSON integers, which a double cannot hold. Every +// unsigned integer literal of 16 or more digits is quoted, so it reaches the reader exactly, as a string. +std::string quote_big_integers(std::string_view json) { + std::string out; + out.reserve(json.size() + 256); + bool in_string = false, escaped = false; + for (std::size_t i = 0; i < json.size();) { + const char c = json[i]; + if (in_string) { + out += c; + ++i; + if (escaped) escaped = false; + else if (c == '\\') escaped = true; + else if (c == '"') in_string = false; + continue; + } + if (c == '"') { + in_string = true; + out += c; + ++i; + continue; + } + if (c >= '0' && c <= '9') { + std::size_t j = i; + while (j < json.size() && json[j] >= '0' && json[j] <= '9') ++j; + const bool integer = j == json.size() || (json[j] != '.' && json[j] != 'e' && json[j] != 'E'); + const bool quote = integer && j - i >= 16 && (i == 0 || json[i - 1] != '-'); + if (quote) out += '"'; + out.append(json.substr(i, j - i)); + if (quote) out += '"'; + i = j; + continue; + } + out += c; + ++i; + } + return out; +} + +const Json* field(const Json& object, std::string_view needle) { + for (const auto& [key, value] : object.object) + if (lower(key).find(needle) != std::string::npos) return &value; + return nullptr; +} + +// Records under a key naming warps ("Faulted Warps", "Active Warps"), and the shader table entries ("Shader infos": +// objects with a "Shader name" and a "Shader hash"). The SDK does not specify the JSON layout; this is the one the +// 2026.3 decoder writes, read loosely. +void walk(const Json& node, std::string_view key, std::vector>& warps, + std::map& shader_hashes, int depth = 0) { + if (depth > 16) return; + if (node.kind == Json::Kind::array) { + if (lower(key).find("warp") != std::string::npos) + for (const Json& item : node.array) + if (item.kind == Json::Kind::object) warps.emplace_back(std::string(key), &item); + for (const Json& item : node.array) walk(item, key, warps, shader_hashes, depth + 1); + } else if (node.kind == Json::Kind::object) { + const Json* name = node.find("Shader name"); + const Json* hash = node.find("Shader hash"); + if (name && hash) shader_hashes[scalar(*name)] = std::strtoull(scalar(*hash).c_str(), nullptr, 0); + for (const auto& [k, v] : node.object) walk(v, k, warps, shader_hashes, depth + 1); + } +} + +void decode_and_report() noexcept { + State& s = state(); + std::vector dump; + std::filesystem::path dump_path; + { + std::lock_guard lock(s.dump_mutex); + if (s.decoded || !s.have_dump) return; + dump = s.dump; + dump_path = s.dump_path; + } + std::string summary; + const auto line = [&summary](const char* format, auto... args) { + char buffer[1024]; + std::snprintf(buffer, sizeof buffer, format, args...); + summary += "[rt] aftermath: "; + summary += buffer; + summary += '\n'; + }; + try { + GFSDK_Aftermath_GpuCrashDump_Decoder decoder = nullptr; + const auto created = + s.lib.CreateDecoder(GFSDK_Aftermath_Version_API, dump.data(), std::uint32_t(dump.size()), &decoder); + if (!GFSDK_Aftermath_SUCCEED(created)) { + line("GPU crash dump %s could not be decoded (0x%x)", narrow(dump_path).c_str(), unsigned(created)); + } else { + GFSDK_Aftermath_GpuCrashDump_DeviceInfo device{}; + const bool have_device = GFSDK_Aftermath_SUCCEED(s.lib.GetDeviceInfo(decoder, &device)); + line("GPU crash dump %s (%zu bytes): device status %s, adapter reset %s, engine reset %s", + narrow(dump_path).c_str(), dump.size(), have_device ? status_name(device.status) : "unknown", + have_device && device.adapterReset ? "yes" : "no", have_device && device.engineReset ? "yes" : "no"); + + // Active shaders, by our module names. + std::uint32_t count = 0; + std::vector shaders; + if (GFSDK_Aftermath_SUCCEED(s.lib.GetActiveShadersInfoCount(decoder, &count)) && count) { + shaders.resize(count); + if (!GFSDK_Aftermath_SUCCEED(s.lib.GetActiveShadersInfo(decoder, count, shaders.data()))) shaders.clear(); + } + struct Named { + std::string name; // our module name + std::string binary; // Aftermath shader binary hash, hex + }; + std::unordered_map by_dump_hash; // ShaderInfo::shaderHash -> module + std::vector active; + for (const auto& info : shaders) { + GFSDK_Aftermath_ShaderBinaryHash hash{}; + const bool mapped = GFSDK_Aftermath_SUCCEED(s.lib.GetShaderHashForShaderInfo(decoder, &info, &hash)); + const std::string name = info.isInternal ? "(driver internal)" + : mapped ? shader_name(hash.hash) + : "unmapped"; + by_dump_hash[info.shaderHash] = {name, mapped ? hex64(hash.hash) : "-"}; + char buffer[512]; + std::snprintf(buffer, sizeof buffer, "%s %s hash=%s", shader_type_name(info.shaderType), name.c_str(), + mapped ? hex64(hash.hash).c_str() : "-"); + active.emplace_back(buffer); + } + + // Warps, from the JSON (the C API has no per-warp pc). Shader mapping info asks lookup_shader for binaries. + DecodeContext context; + std::uint32_t json_size = 0; + std::string json; + const auto generated = s.lib.GenerateJSON( + decoder, GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO, + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_UTF8_OUTPUT, lookup_debug_info, lookup_shader, nullptr, + &context, &json_size); + if (GFSDK_Aftermath_SUCCEED(generated) && json_size) { + json.resize(json_size); + if (!GFSDK_Aftermath_SUCCEED(s.lib.GetJSON(decoder, json_size, json.data()))) json.clear(); + while (!json.empty() && json.back() == '\0') json.pop_back(); + } + std::filesystem::path json_path = dump_path; + json_path.replace_extension(".json"); + if (!json.empty()) write_file(json_path, json.data(), json.size()); + + Json root; + std::vector> warps; + std::map shader_hashes; // the dump's shader name ("compute_02") -> dump hash + if (!json.empty() && JsonReader(quote_big_integers(json)).parse(root)) + walk(root, {}, warps, shader_hashes); + std::stable_partition(warps.begin(), warps.end(), + [](const auto& warp) { return lower(warp.first).find("fault") != std::string::npos; }); + if (warps.empty()) line("no warp records in the dump (%s)", json.empty() ? "no JSON" : "see the JSON"); + std::size_t shown = 0; + for (const auto& [key, warp] : warps) { + if (shown++ == 16) { + line("... %zu more warp records in %s", warps.size() - 16, narrow(json_path).c_str()); + break; + } + // "GPU PC Address": " @ 0x", the name keyed in the shader table. + const Json* pc_field = field(*warp, "pc address"); + const std::string address = pc_field ? scalar(*pc_field) : std::string(); + const auto at = address.find(" @ "); + const std::string dump_name = at == std::string::npos ? address : address.substr(0, at); + const std::string pc = at == std::string::npos ? "?" : address.substr(at + 3); + Named module{"?", "-"}; + if (const auto h = shader_hashes.find(dump_name); h != shader_hashes.end()) + if (const auto m = by_dump_hash.find(h->second); m != by_dump_hash.end()) module = m->second; + const Json* mapping = field(*warp, "mapping"); + const Json* warp_count = field(*warp, "count"); + const Json* fault_name = field(*warp, "fault name"); + const bool faulted = lower(key).find("fault") != std::string::npos; + if (!pc_field) { + line("%s: %s", key.c_str(), flatten(*warp).c_str()); + } else if (faulted) { + line("faulting shader %s (hash %s, %s) pc %s spirv %s: %s", module.name.c_str(), + module.binary.c_str(), dump_name.c_str(), pc.c_str(), + mapping ? scalar(*mapping).c_str() : "-", fault_name ? scalar(*fault_name).c_str() : key.c_str()); + } else { + line("%s: shader %s (hash %s, %s) pc %s spirv %s warps %s", key.c_str(), module.name.c_str(), + module.binary.c_str(), dump_name.c_str(), pc.c_str(), + mapping ? scalar(*mapping).c_str() : "-", warp_count ? scalar(*warp_count).c_str() : "?"); + } + } + + GFSDK_Aftermath_GpuCrashDump_PageFaultInfo fault{}; + if (GFSDK_Aftermath_SUCCEED(s.lib.GetPageFaultInfo(decoder, &fault))) { + line("page fault va=0x%016" PRIx64 " fault=%s access=%s engine=%s client=%s resources=%u", + fault.faultingGpuVA, fault_name(fault.faultType), access_name(fault.accessType), + engine_name(fault.engine), client_name(fault.client), fault.resourceInfoCount); + std::vector resources(fault.resourceInfoCount); + if (!resources.empty() && + GFSDK_Aftermath_SUCCEED(s.lib.GetPageFaultResourceInfo(decoder, fault.resourceInfoCount, + resources.data()))) + for (std::size_t i = 0; i < resources.size(); ++i) { + const auto& r = resources[i]; + line("page fault resource[%zu] va=0x%016" PRIx64 " size=0x%" PRIx64 + " %ux%ux%u mips=%u format=%u handle=0x%016" PRIx64 + " name=\"%s\" %s%s%s%s", + i, r.gpuVa, r.size, r.width, r.height, r.depth, r.mipLevels, r.format, r.apiResource, + r.debugName, residency_name(r.residency), r.bWasDestroyed ? ", destroyed" : "", + r.bPlacedResource ? ", placed" : "", r.bIsBufferHeap ? ", buffer heap" : ""); + } + } else { + line("no page fault information in the dump"); + } + for (std::size_t i = 0; i < active.size(); ++i) line("active shader[%zu] %s", i, active[i].c_str()); + { + // The hash -> name table next to the dump, for matching it offline (nv-aftermath-format, Nsight). + std::string table; + std::lock_guard lock(s.shaders_mutex); + for (const auto& [hash, shader] : s.shaders) table += hex64(hash) + '\t' + shader.name + '\n'; + std::filesystem::path table_path = dump_path; + table_path.replace_extension(".shaders.tsv"); + const bool table_written = write_file(table_path, table.data(), table.size()); + line("%llu SPIR-V modules registered (%zu distinct, table %s), %llu not hashed", + static_cast(s.registered.load()), s.shaders.size(), + table_written ? narrow(table_path).c_str() : "not written", + static_cast(s.hash_failures.load())); + } + for (const auto& path : context.written) line("wrote %s", path.c_str()); + if (!json.empty()) line("decoded JSON %s", narrow(json_path).c_str()); + s.lib.DestroyDecoder(decoder); + } + } catch (...) { + line("decoding failed"); + } + std::fputs(summary.c_str(), stderr); + std::fflush(stderr); + std::lock_guard lock(s.dump_mutex); + s.summary = std::move(summary); + s.decoded = true; + s.dump_cv.notify_all(); +} + +// ---- callbacks (free-threaded, on Aftermath's threads) ---- + +void GFSDK_AFTERMATH_CALL on_crash_dump(const void* data, const std::uint32_t size, void*) { + State& s = state(); + const auto path = s.dir / (stamp() + ".nv-gpudmp"); + const bool written = write_file(path, data, size); + std::fprintf(stderr, "[rt] aftermath: GPU crash dump, %u bytes%s %s\n", size, written ? " written to" : ", cannot write", + narrow(path).c_str()); + { + std::lock_guard lock(s.dump_mutex); + if (s.have_dump) return; // one decode per process: the first crash is the one that matters + const auto bytes = static_cast(data); + s.dump.assign(bytes, bytes + size); + s.dump_path = path; + s.have_dump = true; + } + // Decode once Aftermath is done (the deferred shader debug info callbacks may still follow this one). + std::thread([] { + State& st = state(); + const auto start = Clock::now(); + for (;;) { + GFSDK_Aftermath_CrashDump_Status status = GFSDK_Aftermath_CrashDump_Status_Unknown; + st.lib.GetCrashDumpStatus(&status); + if (status == GFSDK_Aftermath_CrashDump_Status_Finished || + status == GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed || + status == GFSDK_Aftermath_CrashDump_Status_NotStarted || Clock::now() - start > std::chrono::seconds(5)) + break; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } + decode_and_report(); + }).detach(); +} + +void GFSDK_AFTERMATH_CALL on_shader_debug_info(const void* data, const std::uint32_t size, void*) { + State& s = state(); + GFSDK_Aftermath_ShaderDebugInfoIdentifier id{}; + if (!GFSDK_Aftermath_SUCCEED(s.lib.GetShaderDebugInfoIdentifier(GFSDK_Aftermath_Version_API, data, size, &id))) + return; + write_file(s.dir / ("shader-" + hex64(id.id[0]) + "-" + hex64(id.id[1]) + ".nvdbg"), data, size); + const auto bytes = static_cast(data); + std::lock_guard lock(s.debug_mutex); + s.debug_info[{id.id[0], id.id[1]}].assign(bytes, bytes + size); +} + +void GFSDK_AFTERMATH_CALL on_description(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription add, void*) { + add(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName, "Leonida gta6rt"); + add(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationVersion, LEONIDA_AFTERMATH_APP_VERSION); +} + +VKAPI_ATTR VkResult VKAPI_CALL create_shader_module(VkDevice device, const VkShaderModuleCreateInfo* info, + const VkAllocationCallbacks* allocator, VkShaderModule* module) { + const VkResult result = state().real_create.load(std::memory_order_relaxed)(device, info, allocator, module); + if (result == VK_SUCCESS && info) register_spirv(info->pCode, info->codeSize, detail::shader_name); + return result; +} + +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_device_proc_addr(VkDevice device, const char* name) { + const PFN_vkVoidFunction function = state().real_get.load(std::memory_order_relaxed)(device, name); + if (!function || !name || std::strcmp(name, "vkCreateShaderModule") != 0) return function; + return reinterpret_cast( + wrap_create_shader_module(reinterpret_cast(function))); +} + +void device_lost() noexcept { wait_for_dump(); } + +} // namespace + +bool available() noexcept { return true; } + +bool enable() noexcept { + static const bool on = []() noexcept { + if (!env_is(L"LEONIDA_AFTERMATH", L'1')) return false; + try { + State& s = state(); + std::wstring dll = env_w(L"LEONIDA_AFTERMATH_DLL"); + if (dll.empty()) { + const std::filesystem::path built = from_utf8(LEONIDA_AFTERMATH_DLL_DEFAULT); + std::error_code ec; + dll = !built.empty() && std::filesystem::exists(built, ec) ? built.wstring() + : L"GFSDK_Aftermath_Lib.x64.dll"; + } + if (!s.lib.load(dll)) { + std::fprintf(stderr, "[rt] aftermath: cannot load %s (error %lu); crash dumps are off\n", + narrow(dll).c_str(), GetLastError()); + return false; + } + const std::wstring dir = env_w(L"LEONIDA_AFTERMATH_DIR"); + s.dir = dir.empty() ? std::filesystem::temp_directory_path() / L"leonida-aftermath" : std::filesystem::path(dir); + std::error_code ec; + std::filesystem::create_directories(s.dir, ec); + s.shader_dir = env_w(L"LEONIDA_SHADERS"); + s.keep_spirv = env_is(L"LEONIDA_AFTERMATH_KEEP_SPIRV", L'1'); + if (env_is(L"LEONIDA_AFTERMATH_SHADER_ERRORS", L'1')) + s.extra_flags |= VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV; + const auto result = s.lib.EnableGpuCrashDumps( + GFSDK_Aftermath_Version_API, GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_Vulkan, + GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks, on_crash_dump, on_shader_debug_info, + on_description, nullptr, nullptr); + if (!GFSDK_Aftermath_SUCCEED(result)) { + std::fprintf(stderr, "[rt] aftermath: GFSDK_Aftermath_EnableGpuCrashDumps failed (0x%x)\n", + unsigned(result)); + return false; + } + s.enabled.store(true, std::memory_order_release); + device_lost_hook.store(device_lost, std::memory_order_release); + std::fprintf(stderr, "[rt] aftermath: GPU crash dumps on (%s), written to %s%s\n", narrow(dll).c_str(), + narrow(s.dir).c_str(), s.keep_spirv ? ", SPIR-V kept" : ""); + return true; + } catch (...) { + std::fprintf(stderr, "[rt] aftermath: setup failed\n"); + return false; + } + }(); + return on; +} + +bool enabled() noexcept { return state().enabled.load(std::memory_order_acquire); } + +VkDeviceDiagnosticsConfigFlagsNV extra_config_flags() noexcept { return enabled() ? state().extra_flags : 0; } + +PFN_vkCreateShaderModule wrap_create_shader_module(PFN_vkCreateShaderModule real) noexcept { + if (!enabled() || !real || real == create_shader_module) return real; + PFN_vkCreateShaderModule expected = nullptr; + State& s = state(); + if (!s.real_create.compare_exchange_strong(expected, real) && expected != real) return real; + return create_shader_module; +} + +PFN_vkGetDeviceProcAddr wrap_get_device_proc_addr(PFN_vkGetDeviceProcAddr real) noexcept { + if (!enabled() || !real || real == get_device_proc_addr) return real; + PFN_vkGetDeviceProcAddr expected = nullptr; + State& s = state(); + if (!s.real_get.compare_exchange_strong(expected, real) && expected != real) return real; + return get_device_proc_addr; +} + +void register_spirv(const void* code, std::size_t bytes, const char* name) noexcept { + if (!enabled() || !code || !bytes) return; + try { + State& s = state(); + const std::uint64_t hash = spirv_hash(code, bytes); + if (!hash) { + s.hash_failures.fetch_add(1, std::memory_order_relaxed); + return; + } + s.registered.fetch_add(1, std::memory_order_relaxed); + std::vector words; + // The runtime's own modules are few and small, and not in LEONIDA_SHADERS: always kept for the decoder. + if (s.keep_spirv || (name && std::strncmp(name, "(runtime)", 9) == 0)) { + const auto first = static_cast(code); + words.assign(first, first + bytes / 4); + } + std::lock_guard lock(s.shaders_mutex); + auto& shader = s.shaders[hash]; + if (shader.name.empty() || name) shader.name = name ? name : "(runtime)"; + if (!words.empty()) shader.words = std::move(words); + } catch (...) { + } +} + +void wait_for_dump() noexcept { + if (!enabled()) return; + State& s = state(); + std::lock_guard wait(s.wait_mutex); + if (s.waited) return; + s.waited = true; + std::fprintf(stderr, "[rt] aftermath: device lost, waiting for the GPU crash dump (at most %lld s)\n", + static_cast(wait_limit.count())); + const auto deadline = Clock::now() + wait_limit; + GFSDK_Aftermath_CrashDump_Status status = GFSDK_Aftermath_CrashDump_Status_Unknown; + for (;;) { + { + std::unique_lock lock(s.dump_mutex); + if (s.dump_cv.wait_for(lock, std::chrono::milliseconds(50), [&s] { return s.decoded; })) break; + if (Clock::now() >= deadline) break; + if (status == GFSDK_Aftermath_CrashDump_Status_Finished && !s.have_dump) break; + } + s.lib.GetCrashDumpStatus(&status); + if (status == GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed) break; + } + std::lock_guard lock(s.dump_mutex); + if (!s.decoded) + std::fprintf(stderr, "[rt] aftermath: no GPU crash dump after the wait (status %u%s)\n", unsigned(status), + s.have_dump ? ", dump written but not decoded yet" : ""); +} + +std::string last_dump_path() { + State& s = state(); + std::lock_guard lock(s.dump_mutex); + return s.have_dump ? narrow(s.dump_path) : std::string(); +} + +std::string last_summary() { + State& s = state(); + std::lock_guard lock(s.dump_mutex); + return s.summary; +} + +} // namespace leonida::aftermath + +#else // !LEONIDA_HAVE_AFTERMATH + +namespace leonida::aftermath { + +bool available() noexcept { return false; } +bool enable() noexcept { return false; } +bool enabled() noexcept { return false; } +VkDeviceDiagnosticsConfigFlagsNV extra_config_flags() noexcept { return 0; } +PFN_vkCreateShaderModule wrap_create_shader_module(PFN_vkCreateShaderModule real) noexcept { return real; } +PFN_vkGetDeviceProcAddr wrap_get_device_proc_addr(PFN_vkGetDeviceProcAddr real) noexcept { return real; } +void register_spirv(const void*, std::size_t, const char*) noexcept {} +void wait_for_dump() noexcept {} +std::string last_dump_path() { return {}; } +std::string last_summary() { return {}; } + +} // namespace leonida::aftermath + +#endif diff --git a/runtime/src/vulkan_aftermath.h b/runtime/src/vulkan_aftermath.h new file mode 100644 index 0000000000..ebf95ed4d1 --- /dev/null +++ b/runtime/src/vulkan_aftermath.h @@ -0,0 +1,77 @@ +#pragma once + +// Optional NVIDIA Nsight Aftermath GPU crash dumps (LEONIDA_AFTERMATH=1). The SDK is never part of the build unless +// CMake is given -DLEONIDA_AFTERMATH_SDK=; then vulkan_aftermath.cpp is compiled with LEONIDA_HAVE_AFTERMATH and +// loads GFSDK_Aftermath_Lib.x64.dll at run time (LEONIDA_AFTERMATH_DLL, else the SDK's lib/x64, else the DLL search +// path). Without the SDK, or without the DLL or an NVIDIA driver, every function here does nothing. +// +// Environment: +// LEONIDA_AFTERMATH=1 enable GPU crash dumps for the Vulkan device (before vkCreateDevice) +// LEONIDA_AFTERMATH_DIR= where dumps go (default leonida-aftermath under the system temp directory): .nv-gpudmp, the decoded +// .json, shader-.nvdbg debug info, and .spv for the active shaders +// LEONIDA_AFTERMATH_DLL= the Aftermath library to load +// LEONIDA_AFTERMATH_SHADER_ERRORS=1 also set VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV +// (reports more shader errors, so it can fault where a run does not) +// LEONIDA_AFTERMATH_KEEP_SPIRV=1 keep a copy of every SPIR-V module created, for the decoder (it needs the binary +// to map a pc to a SPIR-V instruction). Off by default, as the game creates GBs of +// them: the decoder then reads /.spv back when its hash +// matches the module's (true for unpatched library shaders) + +#include + +#include +#include +#include + +namespace leonida::aftermath { + +// True when this build has the Aftermath integration (LEONIDA_HAVE_AFTERMATH). +bool available() noexcept; + +// LEONIDA_AFTERMATH=1: loads the library and calls GFSDK_Aftermath_EnableGpuCrashDumps for Vulkan. Must run before +// vkCreateDevice. The first call decides; returns whether crash dumps are enabled. Also installs the device-lost hook +// of vulkan_device_fault.h. +bool enable() noexcept; +bool enabled() noexcept; + +// VK_NV_device_diagnostics_config flags to add to the device-fault defaults (shader debug info, resource tracking, +// automatic checkpoints), 0 when Aftermath is off. +VkDeviceDiagnosticsConfigFlagsNV extra_config_flags() noexcept; + +// Returns a vkCreateShaderModule that also records the module's Aftermath shader hash under the name in +// ShaderName, or `real` itself when Aftermath is off. Process-wide: the first `real` wins. +PFN_vkCreateShaderModule wrap_create_shader_module(PFN_vkCreateShaderModule real) noexcept; + +// Returns a vkGetDeviceProcAddr that hands out the wrapper above for "vkCreateShaderModule", so every function table +// loaded through it (the runtime's helpers load their own) records its modules; `real` itself when Aftermath is off. +PFN_vkGetDeviceProcAddr wrap_get_device_proc_addr(PFN_vkGetDeviceProcAddr real) noexcept; + +// Records a SPIR-V module created outside the wrapper. +void register_spirv(const void* code, std::size_t bytes, const char* name) noexcept; + +// Blocks until Aftermath has written and decoded the GPU crash dump, at most ~10 s. Any thread, any number of times: +// the first device loss waits, later calls return at once (or wait for the first one to finish). +void wait_for_dump() noexcept; + +// For tests: the last dump written and the summary printed for it (empty before a dump). +std::string last_dump_path(); +std::string last_summary(); + +namespace detail { +inline thread_local const char* shader_name = nullptr; +} + +// Names the shader modules this thread creates while it is in scope (the wrapper above reads it). +class ShaderName { +public: + explicit ShaderName(const char* name) noexcept : previous_(detail::shader_name) { detail::shader_name = name; } + explicit ShaderName(const std::string& name) noexcept : ShaderName(name.c_str()) {} + ~ShaderName() { detail::shader_name = previous_; } + ShaderName(const ShaderName&) = delete; + ShaderName& operator=(const ShaderName&) = delete; + +private: + const char* previous_; +}; + +} // namespace leonida::aftermath diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index 9946331f96..00a93f34a3 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h @@ -15,6 +15,7 @@ #include "image_memory.h" #include "occlusion_sum_spirv.h" #include "pipeline_workers.h" +#include "vulkan_aftermath.h" #include "queue_holds.h" #include "retire_tickets.h" #include "statistics_sum_spirv.h" @@ -22,11 +23,14 @@ #include "vulkan_depth24.h" #include "vulkan_title_image_pool.h" #include "vulkan_indirect_dispatch_count.h" +#include "vulkan_indirect_clamp.h" #include "vulkan_scratch.h" #include "vulkan_replay.h" #include "queue_families.h" #include "resource_tiling.h" #include "pipeline_profile.h" +#include "submit_phases.h" +#include "title_va_alias.h" #include "xdxr_build.h" #include @@ -34,12 +38,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -62,11 +68,13 @@ inline ReplayResult queue_unsupported(int line) { // A CPU-written Vulkan-address instance pointer array, kept until the submission that builds with it completes. // Completed stages are pooled per queue and reused, so a per-frame TLAS build does not allocate memory each frame. +// The same stages carry the title-memory translation table of an XDXR TLAS build (VulkanQueue::stage_xdxr_table). struct KhrInstanceStage { VkBuffer buffer = VK_NULL_HANDLE; VkDeviceMemory memory = VK_NULL_HANDLE; VkDeviceAddress address = 0; std::uint64_t size = 0; // bytes available in buffer, so a larger later list can be refused for a new stage + VkBufferUsageFlags usage = 0; // a pooled stage is reused only for the same usage }; // One per-queue query pool of VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR, retained on the @@ -367,6 +375,7 @@ class OcclusionResolve { module.codeSize = code.size_bytes(); module.pCode = code.data(); VkShaderModule shader = VK_NULL_HANDLE; + const aftermath::ShaderName aftermath_name("(runtime) occlusion resolve"); if (vk_.vkCreateShaderModule(device_, &module, nullptr, &shader) != VK_SUCCESS) return false; VkComputePipelineCreateInfo pipeline{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; pipeline.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, @@ -588,6 +597,82 @@ inline bool set_device_lost(std::atomic& flag, const char* where) noexcept where); return true; } +// LEONIDA_GPU_LATENCY=1 (diagnostic): for each queue kind, how long the GPU took from a submission's vkQueueSubmit to +// the dispatcher seeing it done, and how much of the wall time the queue had work (in-order queue: a submission is +// busy from the later of its submit and the previous one's completion to its own). One line per kind every 10 s. +namespace gpu_latency { +inline bool enabled() { + static const bool on = [] { + const char* v = std::getenv("LEONIDA_GPU_LATENCY"); + return v && std::strcmp(v, "1") == 0; + }(); + return on; +} +struct Stats { + std::mutex mutex; + std::uint64_t count = 0; + double sum_ms = 0, max_ms = 0, busy_ms = 0; + std::chrono::steady_clock::time_point last_done{}, since = std::chrono::steady_clock::now(); +}; +inline Stats& stats(int kind) { + static Stats s[3]; + return s[kind < 0 || kind > 2 ? 0 : kind]; +} +inline void done(int kind, std::chrono::steady_clock::time_point submitted) { + using clock = std::chrono::steady_clock; + const auto now = clock::now(); + const auto ms = [](clock::duration d) { return std::chrono::duration(d).count(); }; + Stats& s = stats(kind); + std::lock_guard lock(s.mutex); + const double latency = ms(now - submitted); + ++s.count; + s.sum_ms += latency; + s.max_ms = (std::max)(s.max_ms, latency); + s.busy_ms += ms(now - (std::max)(submitted, s.last_done)); + s.last_done = now; + if (now - s.since >= std::chrono::seconds(10)) { + const double wall = ms(now - s.since); + std::fprintf(stderr, "[rt] gpu latency (%s): %llu submissions in %.0f s, submit to done %.2f ms on average, " + "%.1f ms the longest; the queue had work %.1f%% of the time\n", + kind == 0 ? "direct" : kind == 1 ? "compute" : "copy", + static_cast(s.count), wall / 1000.0, s.sum_ms / double(s.count), s.max_ms, + 100.0 * s.busy_ms / wall); + s.count = 0; + s.sum_ms = s.max_ms = s.busy_ms = 0; + s.since = now; + } +} +// A held queue operation (Wait before Signal), released: how long it waited on the CPU before it could run. +inline void held(int kind, int op, std::chrono::steady_clock::time_point at) { + using clock = std::chrono::steady_clock; + struct Held { + std::mutex mutex; + std::uint64_t count[3] = {}; + double sum_ms = 0, max_ms = 0; + clock::time_point since = clock::now(); + }; + static Held h[3]; + Held& s = h[kind < 0 || kind > 2 ? 0 : kind]; + const auto now = clock::now(); + const double ms = std::chrono::duration(now - at).count(); + std::lock_guard lock(s.mutex); + ++s.count[op < 0 || op > 2 ? 0 : op]; + s.sum_ms += ms; + s.max_ms = (std::max)(s.max_ms, ms); + if (now - s.since >= std::chrono::seconds(10)) { + const std::uint64_t all = s.count[0] + s.count[1] + s.count[2]; + std::fprintf(stderr, "[rt] gpu latency (%s): %llu held operations released in %.0f s (%llu batches, %llu " + "signals, %llu markers), held %.2f ms on average, %.1f ms the longest\n", + kind == 0 ? "direct" : kind == 1 ? "compute" : "copy", static_cast(all), + std::chrono::duration(now - s.since).count(), static_cast(s.count[0]), + static_cast(s.count[1]), static_cast(s.count[2]), + all ? s.sum_ms / double(all) : 0.0, s.max_ms); + s.count[0] = s.count[1] = s.count[2] = 0; + s.sum_ms = s.max_ms = 0; + s.since = now; + } +} +} // namespace gpu_latency // Centralized single-thread fence dispatcher using Vulkan 1.2 vkWaitSemaphores(VK_SEMAPHORE_WAIT_ANY_BIT). // Eliminates per-fence OS threads and 10ms polling: a synthetic timeline semaphore (wakeup_sem_) at index 0 @@ -982,6 +1067,15 @@ struct TileRange { #pragma warning(push) #pragma warning(disable : 4324) // intentional alignas(64) cache-line padding to prevent false sharing #endif +struct GraphicsIndirectCapabilities { + bool first_instance = false; + bool multiple = false; + bool count_buffer = false; + std::uint32_t max_count = 1; + bool robust_index_view = false; + bool require_clamp = false; +}; + class VulkanContext { public: // mesh_queries: VK_EXT_mesh_shader's meshShaderQueries feature is enabled on `device`, so a mesh segment's @@ -992,7 +1086,8 @@ class VulkanContext { // ray_tracing: VK_KHR_acceleration_structure + VK_KHR_ray_query are enabled on `device`. // xdxr: acceleration-structure builds write XDXR BVH4 records (xdxr_build.h) instead; needs bufferDeviceAddress. VulkanContext(PFN_vkGetDeviceProcAddr get, VkDevice device, bool separate_depth_stencil_layouts, - bool conditional_rendering = false, bool ray_tracing = false, bool xdxr = false) + bool conditional_rendering = false, bool ray_tracing = false, bool xdxr = false, + GraphicsIndirectCapabilities indirect = {}) : device_(device), tracker_(separate_depth_stencil_layouts), ray_tracing_(ray_tracing) { loaded_ = vk.load(get, device); if (loaded_ && gpu_labels_.initialize(device, get)) { @@ -1015,6 +1110,11 @@ class VulkanContext { replay_.update_buffer = vk.vkCmdUpdateBuffer; replay_.draw_indirect = vk.vkCmdDrawIndirect; replay_.draw_indexed_indirect = vk.vkCmdDrawIndexedIndirect; + replay_.draw_indirect_first_instance = indirect.first_instance; + replay_.multi_draw_indirect = indirect.multiple; + replay_.draw_indirect_count_enabled = indirect.count_buffer; + replay_.max_draw_indirect_count = indirect.max_count; + replay_.require_indirect_clamp = indirect.require_clamp; replay_.draw_indirect_count = vk.vkCmdDrawIndirectCount; replay_.draw_indexed_indirect_count = vk.vkCmdDrawIndexedIndirectCount; replay_.dispatch_indirect = vk.vkCmdDispatchIndirect; @@ -1037,6 +1137,9 @@ class VulkanContext { }; replay_.bind_vertex_buffers2 = vk.vkCmdBindVertexBuffers2; replay_.bind_index_buffer = vk.vkCmdBindIndexBuffer; + if (indirect.robust_index_view) + replay_.bind_robust_index_view = reinterpret_cast( + get(device, "vkCmdBindIndexBuffer2KHR")); replay_.set_viewport = vk.vkCmdSetViewport; replay_.set_scissor = vk.vkCmdSetScissor; replay_.set_viewport_with_count = vk.vkCmdSetViewportWithCount; @@ -1091,9 +1194,12 @@ class VulkanContext { b.dst_va && b.scratch_va && (!b.is_tlas || !b.instance_count || b.instances_va) && (!b.update || (b.build_flags & VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR) != 0); }; - replay_.xdxr_record = [this](VkCommandBuffer cb, const BuildAccelerationStructure& b) { - // Every address is a console VA in the GPU address arena: the device address is heap_base + VA, - // and the BLAS addresses in instance descs get the same bias. + replay_.xdxr_record = [this](VkCommandBuffer cb, const BuildAccelerationStructure& b, + const XdxrBlasTable& blases) { + // Every address is the VA shaders reach the memory by: an arena VA, or for the title's own memory + // the VA of its GPU copy, resolved when the build was recorded (Device::resolve_xdxr_build). The + // device address is heap_base + VA, and the BLAS addresses in instance descs, which are the + // title's, go through `blases` and get the same bias. const std::uint64_t base = replay_.heap_base; XdxrLayout layout; layout.compute(xdxr_elements(b), b.is_tlas, xdxr_box16(b)); @@ -1102,7 +1208,7 @@ class VulkanContext { const std::uint64_t from = b.update ? base + (b.src_va ? b.src_va : b.dst_va) : 0; if (b.is_tlas) { xdxr_->record_tlas(cb, layout, b.instances_va ? base + b.instances_va : 0, base + b.dst_va, - base + b.scratch_va, base, from); + base + b.scratch_va, base, from, &blases); } else { std::vector geometries; xdxr_inputs(b, &geometries, base); @@ -1211,6 +1317,30 @@ class VulkanContext { void configure_quad_indices(PFN_vkGetDeviceProcAddr get, const VkPhysicalDeviceLimits& limits) { std::unique_lock lock(resource_mutex_); quad_indices_ = std::make_unique(get, device_, limits); + + } + + // Every ExecuteIndirect's arguments are clamped on the GPU into scratch before the indirect command reads them + // (vulkan_indirect_clamp.h), so a stale or garbage record from a skipped compute pass cannot reset the display + // driver. Needs bufferDeviceAddress and a compute-capable queue; `allocate` gives the record scratch + // device-local memory, and must set VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT. LEONIDA_INDIRECT_CLAMP=0 turns the + // pass off at replay time. + void enable_indirect_clamp(PFN_vkGetDeviceProcAddr get, const VkPhysicalDeviceMemoryProperties& memory, + const VkPhysicalDeviceLimits& limits, ScratchBuffers::Allocate allocate) { + std::unique_lock lock(resource_mutex_); + replay_.require_indirect_clamp = indirect_clamp_enabled(); + if (!replay_.require_indirect_clamp) return; + indirect_clamp_ = std::make_unique(get, device_, memory, limits, std::move(allocate), + device_fault_.get()); + if (!indirect_clamp_->loaded()) { + indirect_clamp_.reset(); + return; + } + // The preparation callback needs this submission's counter-slot batch, so it is set per ExecuteCommandLists + // (execute()); recording the pass has no per-submission state. + replay_.emit_indirect_clamp = [this](VkCommandBuffer command_buffer, const ClampedIndirect& job) { + indirect_clamp_->emit(command_buffer, job); + }; } VkDevice device() const { return device_; } @@ -1357,9 +1487,12 @@ class VulkanContext { // The device address of the GPU address arena: console VAs are offsets from it (docs section 3.3). // execute() copies replay_ under a shared resource_mutex_, so writers hold it uniquely. - void set_heap_base(std::uint64_t heap_base) { + // `heap_size`: the arena's bytes, below which a VA a GPU pass finds in memory (a TLAS instance's BLAS) is an arena + // VA; 0 when unknown (such a VA is then taken as one whatever its value). + void set_heap_base(std::uint64_t heap_base, std::uint64_t heap_size = 0) { std::unique_lock lock(resource_mutex_); replay_.heap_base = heap_base; + replay_.heap_size = heap_size; } // Zeroed memory for unbound vertex and index buffers to read (ReplayFunctions::zero_buffer). @@ -1794,6 +1927,7 @@ class VulkanContext { void mark_device_lost(const char* where = "a Vulkan call returned VK_ERROR_DEVICE_LOST") noexcept { set_device_lost(device_lost_, where); + run_device_lost_hook(); // LEONIDA_AFTERMATH: the GPU crash dump is written before waiters wake if (fence_dispatcher_) { try { fence_dispatcher_->notify_device_lost(); @@ -1985,6 +2119,31 @@ class VulkanContext { } // A failed counter query does not measure GPU progress. if (result != VK_SUCCESS) state = Watch::State::idle; + // LEONIDA_HANG_EXIT_S= (for boots): work pending and retirement still for s seconds is a GPU hang + // the driver may recover from without Vulkan ever reporting the device lost (Xid 109: the title then + // waits forever, the window frozen). The stall is reported (with the checkpoints under + // LEONIDA_STALL_CHECKPOINTS=1) and the process ends, so the boot does not sit to its time limit. + { + static const long hang_exit_s = [] { + const char* v = std::getenv("LEONIDA_HANG_EXIT_S"); + return v && *v ? std::strtol(v, nullptr, 10) : 0l; + }(); + static std::uint64_t last_retired = ~std::uint64_t(0); + static auto still_since = Watch::Clock::now(); + const auto now = Watch::Clock::now(); + if (state != Watch::State::pending || retired != last_retired) { + last_retired = retired; + still_since = now; + } else if (hang_exit_s > 0 && now - still_since >= std::chrono::seconds(hang_exit_s)) { + std::fprintf(stderr, "[rt] hang watchdog: queue retirement still for %ld s with work pending " + "(submitted ticket %llu, retired %llu): ending the process\n", + hang_exit_s, static_cast(submitted), + static_cast(retired)); + device_fault_->report_stall("hang watchdog", submitted, retired); + std::fflush(stderr); + std::_Exit(0x47); // 'HANG' (portable immediate process termination) + } + } if (watch.sample(state, retired, Watch::Clock::now())) device_fault_->report_stall(state == Watch::State::pending ? "queue retirement has not advanced" : "could not sample the submit lock", @@ -2063,6 +2222,7 @@ class VulkanContext { std::unique_ptr predicated_copier_; std::unique_ptr counted_dispatch_; std::unique_ptr quad_indices_; + std::unique_ptr indirect_clamp_; std::uint32_t predicate_family_ = UINT32_MAX; std::uint32_t transfer_only_family_ = UINT32_MAX; std::uint32_t graphics_family_ = UINT32_MAX; @@ -2237,6 +2397,7 @@ class VulkanQueue : private QueueHolds::Holder { std::lock_guard lock(context_.tracker_mutex_); if (context_.depth24_) context_.depth24_->forget(progress_); // its scratch is idle now if (context_.scratch_) context_.scratch_->forget(progress_); + if (context_.indirect_clamp_) context_.indirect_clamp_->forget(progress_); } if (progress_) { // This queue is idle, so whatever initialisation it published (storage images, zero-filled buffers) has @@ -2448,6 +2609,7 @@ class VulkanQueue : private QueueHolds::Holder { // state_mutex_ (including the deferred/held release paths), so no extra lock is needed. std::vector khr_stage_pool_; std::vector khr_as_query_pool_; + std::vector xdxr_ranges_; // stage_xdxr_table's snapshot, kept for its capacity void destroy_khr_stages(std::vector& stages) { for (const auto& stage : stages) { @@ -2516,6 +2678,122 @@ class VulkanQueue : private QueueHolds::Holder { return true; } + void destroy_stage(KhrInstanceStage& stage) { + if (stage.memory) context_.vk.vkFreeMemory(context_.device(), stage.memory, nullptr); + if (stage.buffer) context_.vk.vkDestroyBuffer(context_.device(), stage.buffer, nullptr); + stage = {}; + } + + // A host-visible, device-addressable stage of at least `bytes`: a completed one of the same usage from the pool + // when one is large enough (a per-frame TLAS rebuild then reuses the same buffer and memory instead of making a + // new vkAllocateMemory call every frame), a new one otherwise. False, with `stage` empty, when none can be made. + bool acquire_stage(std::uint64_t bytes, VkBufferUsageFlags usage, KhrInstanceStage& stage) { + const auto& funcs = context_.vk; + stage = {}; + if (!funcs.vkCreateBuffer || !funcs.vkDestroyBuffer || !funcs.vkGetBufferMemoryRequirements || + !funcs.vkAllocateMemory || !funcs.vkFreeMemory || !funcs.vkBindBufferMemory || !bytes) + return false; + for (auto it = khr_stage_pool_.begin(); it != khr_stage_pool_.end(); ++it) { + if (it->size >= bytes && it->usage == usage) { + stage = std::move(*it); + khr_stage_pool_.erase(it); + return true; + } + } + VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; + info.size = bytes; + info.usage = usage; + if (funcs.vkCreateBuffer(context_.device(), &info, nullptr, &stage.buffer) != VK_SUCCESS) { + stage = {}; + return false; + } + VkMemoryRequirements requirements{}; + funcs.vkGetBufferMemoryRequirements(context_.device(), stage.buffer, &requirements); + const auto& memory = context_.occlusion_resolve_memory_; + constexpr VkMemoryPropertyFlags host_flags = + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + std::uint32_t type = memory.memoryTypeCount; + for (std::uint32_t i = 0; i < memory.memoryTypeCount; ++i) { + if (!(requirements.memoryTypeBits & (1u << i))) continue; + if ((memory.memoryTypes[i].propertyFlags & host_flags) == host_flags) { + type = i; + break; + } + } + VkMemoryAllocateFlagsInfo flags{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO}; + flags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT; + VkMemoryAllocateInfo allocation{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, &flags}; + allocation.allocationSize = requirements.size; + allocation.memoryTypeIndex = type; + if (type == memory.memoryTypeCount || + funcs.vkAllocateMemory(context_.device(), &allocation, nullptr, &stage.memory) != VK_SUCCESS || + funcs.vkBindBufferMemory(context_.device(), stage.buffer, stage.memory, 0) != VK_SUCCESS) { + destroy_stage(stage); + return false; + } + stage.size = bytes; + stage.usage = usage; + return true; + } + + // The table an XDXR TLAS build translates its instances' BLAS addresses with (xdxr_build.comp blas_address): + // every range of the title's memory the layer reaches through a copy (src/title_va_alias.h), as 24-byte entries + // {title VA, end, shader VA} in title-VA order, staged like the KHR pointer lists and kept until the submission + // completes. `count` 0 and `address` 0 when there are no ranges, or the stage could not be made. + ReplayResult stage_xdxr_table(std::vector& stages, VkDeviceAddress& address, + std::uint32_t& count) { + const auto& funcs = context_.vk; + address = 0; + count = 0; + // Without a table the build still runs: a BLAS in the title's memory is then unreachable (an instance with + // no BLAS), never read through heap_base + its title address. + const auto none = [] { + static std::atomic logged{false}; + if (!logged.exchange(true)) + std::fprintf(stderr, "[rt] d3d12: could not stage the title-memory table of an XDXR TLAS build; its " + "instances in the title's memory get no BLAS\n"); + return ReplayResult::success; + }; + // A member, not thread_local: a C++ thread_local with a destructor in gta6rt.exe adds TLS callbacks to the + // image the loader's TLS index-0 move must not have (pe_loader.cpp reserve_tls_index0). + auto& ranges = xdxr_ranges_; + title_va_aliases().mappings(ranges); + if (ranges.empty()) return ReplayResult::success; + if (ranges.size() > 0xffffffffull / 24 || !funcs.vkMapMemory || !funcs.vkUnmapMemory || + !funcs.vkGetBufferDeviceAddress) + return none(); + const std::uint64_t bytes = 24ull * ranges.size(); + KhrInstanceStage stage{}; + if (!acquire_stage(bytes, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + stage)) + return none(); + void* mapped = nullptr; + if (funcs.vkMapMemory(context_.device(), stage.memory, 0, bytes, 0, &mapped) != VK_SUCCESS) { + destroy_stage(stage); + return none(); + } + auto* out = static_cast(mapped); + for (const auto& range : ranges) { + const std::uint64_t entry[3] = {range.title_va, range.end, range.shader_va}; + std::memcpy(out, entry, sizeof(entry)); + out += sizeof(entry); + } + funcs.vkUnmapMemory(context_.device(), stage.memory); + if (!stage.address) { + VkBufferDeviceAddressInfo info{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; + info.buffer = stage.buffer; + stage.address = funcs.vkGetBufferDeviceAddress(context_.device(), &info); + } + if (!stage.address) { + destroy_stage(stage); + return none(); + } + address = stage.address; + count = std::uint32_t(ranges.size()); + stages.push_back(std::move(stage)); + return ReplayResult::success; + } + // A KHR TLAS built with D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS holds console VAs in its pointer list; Vulkan // reads those 8-byte entries as device addresses. Stage a translated copy in our own host-visible buffer instead // of editing the guest's input. The caller keeps the stage until the submission that builds with it completes. @@ -2534,55 +2812,12 @@ class VulkanQueue : private QueueHolds::Holder { if (status != HostReadStatus::ok) return ReplayResult::invalid_copy; KhrInstanceStage stage{}; - const auto discard = [&] { - if (stage.memory) funcs.vkFreeMemory(context_.device(), stage.memory, nullptr); - if (stage.buffer) funcs.vkDestroyBuffer(context_.device(), stage.buffer, nullptr); - }; - // Reuse a completed stage that is already large enough. A per-frame TLAS rebuild then reuses the same buffer - // and memory instead of making a new vkAllocateMemory call every frame. - for (auto it = khr_stage_pool_.begin(); it != khr_stage_pool_.end(); ++it) { - if (it->size >= bytes) { - stage = std::move(*it); - khr_stage_pool_.erase(it); - break; - } - } - if (!stage.buffer) { - VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; - info.size = bytes; - info.usage = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | - VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; - if (funcs.vkCreateBuffer(context_.device(), &info, nullptr, &stage.buffer) != VK_SUCCESS) - return queue_unsupported(__LINE__); - VkMemoryRequirements requirements{}; - funcs.vkGetBufferMemoryRequirements(context_.device(), stage.buffer, &requirements); - const auto& memory = context_.occlusion_resolve_memory_; - constexpr VkMemoryPropertyFlags host_flags = - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; - std::uint32_t type = memory.memoryTypeCount; - for (std::uint32_t i = 0; i < memory.memoryTypeCount; ++i) { - if (!(requirements.memoryTypeBits & (1u << i))) continue; - if ((memory.memoryTypes[i].propertyFlags & host_flags) == host_flags) { - type = i; - break; - } - } - if (type == memory.memoryTypeCount) { - discard(); - return queue_unsupported(__LINE__); - } - VkMemoryAllocateFlagsInfo flags{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO}; - flags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT; - VkMemoryAllocateInfo allocation{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, &flags}; - allocation.allocationSize = requirements.size; - allocation.memoryTypeIndex = type; - if (funcs.vkAllocateMemory(context_.device(), &allocation, nullptr, &stage.memory) != VK_SUCCESS || - funcs.vkBindBufferMemory(context_.device(), stage.buffer, stage.memory, 0) != VK_SUCCESS) { - discard(); - return queue_unsupported(__LINE__); - } - stage.size = bytes; - } + const auto discard = [&] { destroy_stage(stage); }; + if (!acquire_stage(bytes, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | + VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR, + stage)) + return queue_unsupported(__LINE__); void* mapped = nullptr; if (funcs.vkMapMemory(context_.device(), stage.memory, 0, bytes, 0, &mapped) != VK_SUCCESS) { @@ -2621,8 +2856,19 @@ class VulkanQueue : private QueueHolds::Holder { } ReplayResult execute_now(std::span lists, std::uint64_t execute_call) { - if (context_.is_device_lost() || !wait_for_room()) return queue_unsupported(__LINE__); + { + const submit_phases::Scope waited(submit_phases::wait_room); + if (context_.is_device_lost() || !wait_for_room()) return queue_unsupported(__LINE__); + } if (context_.before_execute_) context_.before_execute_(); + // The rest of this call is the replay phase; the submission is counted when it returns, however it returns. + struct Replayed { + std::int64_t start = submit_phases::now_ns(); + ~Replayed() { + submit_phases::add(submit_phases::replay, std::uint64_t(submit_phases::now_ns() - start)); + submit_phases::submitted(); + } + } replayed; if (context_.input_probe_) context_.input_probe_(lists, execute_call, kind_ == QueueKind::direct ? "direct" : kind_ == QueueKind::compute ? "compute" : "copy"); @@ -2667,6 +2913,14 @@ class VulkanQueue : private QueueHolds::Holder { if (active && scratch) scratch->retire(progress, 0); } } scratch_guard{context_.scratch_.get(), progress_, false}; + struct ClampGuard { // and for the ExecuteIndirect clamp's record scratch + IndirectArgumentClamp* clamp = nullptr; + VkSemaphore progress = VK_NULL_HANDLE; + bool active = false; + ~ClampGuard() { + if (active && clamp) clamp->retire(progress, 0); + } + } clamp_guard{context_.indirect_clamp_.get(), progress_, false}; const bool transfer_only = family_ == context_.transfer_only_family_; if (!transfer_only) bindless_commit = context_.bindless_commit_; // Kept between executions: prepare refills each list's entries in the storage the last execution left, where @@ -2703,6 +2957,9 @@ class VulkanQueue : private QueueHolds::Holder { VkDeviceAddress& address) { return stage_khr_instances(replay, build, khr_guard.stages, address); }; + replay.prepare_xdxr_table = [this, &khr_guard](VkDeviceAddress& address, std::uint32_t& count) { + return stage_xdxr_table(khr_guard.stages, address, count); + }; if (replay.write_acceleration_structures_properties) { replay.prepare_khr_postbuild = [this, &khr_guard](std::uint32_t count, VkQueryPool& pool, std::uint32_t& first) { @@ -2716,6 +2973,7 @@ class VulkanQueue : private QueueHolds::Holder { std::unique_ptr batch; std::unique_ptr copy_batch; std::unique_ptr counted_batch; + std::unique_ptr clamp_batch; if (captures) { if (kind_ == QueueKind::copy || !context_.predicate_reducer_ || family_ != context_.predicate_family_) return queue_unsupported(__LINE__); @@ -2753,6 +3011,24 @@ class VulkanQueue : private QueueHolds::Holder { return context_.scratch_->get(bytes, buffer, offset); }; } + if (kind_ != QueueKind::copy && context_.indirect_clamp_) { + // The record scratch belongs to this submission: collected here, retired below with its ticket. The + // counter slots are read back once that ticket completes (the batch's destructor). + replay.prepare_indirect_clamp = [this, &tracker_lock, &clamp_batch, &clamp_guard]( + VkBuffer arguments, VkDeviceSize argument_offset, VkBuffer count, + VkDeviceSize count_offset, std::uint32_t kind, std::uint32_t stride, + std::uint32_t max_count, ClampedIndirect& out) { + // Pipeline creation is lazy and shared across queues; serialize it with other replay preparation. + if (!tracker_lock.owns_lock()) tracker_lock.lock(); + if (!clamp_batch) clamp_batch = context_.indirect_clamp_->batch(); + if (!clamp_guard.active) { + context_.indirect_clamp_->collect(); + clamp_guard.active = true; + } + return clamp_batch->prepare(arguments, argument_offset, count, count_offset, kind, stride, max_count, + out); + }; + } if (kind_ != QueueKind::copy && context_.counted_dispatch_) { replay.prepare_counted_dispatch = [this, &tracker_lock, &counted_batch]( VkBuffer args, VkDeviceSize args_offset, VkBuffer count, VkDeviceSize count_offset, @@ -2977,19 +3253,33 @@ class VulkanQueue : private QueueHolds::Holder { context_.scratch_->retire(progress_, 0); scratch_guard.active = false; } + if (clamp_guard.active) { + context_.indirect_clamp_->retire(progress_, 0); + clamp_guard.active = false; + } if (bindless_commit) bindless_commit(submitted); tracker_lock.unlock(); return queue_unsupported(__LINE__); } replay.bindless_set = context_.bindless_current_ ? context_.bindless_current_() : VK_NULL_HANDLE; const bool bindless_uploaded = std::exchange(context_.bindless_upload_pending_, false); - auto next_tracker = context_.tracker_; + // Layout changes go into the tracker itself, journalled, and are undone unless the submission reaches the + // queue (tracker_mutex_ is held from here to the commit, so nothing else sees them meanwhile). + auto& next_tracker = context_.tracker_; + next_tracker.begin(); + struct TrackerTransaction { + LayoutTracker& tracker; + bool done = false; + ~TrackerTransaction() { + if (!done) tracker.rollback(); + } + } tracker_transaction{next_tracker}; // Bindless images that may already be visible to shaders are initialized on a submission that runs shaders. // initialize() zeroes committed storage images and only transitions sparse images. bool runs_shaders = false; for (const CommandList* list : lists) for (const auto& command : list->commands()) - runs_shaders |= std::holds_alternative(command) || std::holds_alternative(command) || + runs_shaders |= std::holds_alternative(command) || draw_command(command).state || std::holds_alternative(command); std::vector storage_images; std::vector zero_buffers; @@ -3122,14 +3412,18 @@ class VulkanQueue : private QueueHolds::Holder { wait_values_.pop_back(); } if (submitted) { - context_.tracker_ = std::move(next_tracker); + next_tracker.commit(); + tracker_transaction.done = true; slot->predicate = std::move(batch); slot->predicated_copy = std::move(copy_batch); slot->counted_dispatch = std::move(counted_batch); + slot->indirect_clamp = std::move(clamp_batch); queries.commit(); slot->segments = std::move(queries.retained); slot->geometry = std::move(geometry); } else { + next_tracker.rollback(); // here, under tracker_mutex_ (unlocked below, before the guard's scope ends) + tracker_transaction.done = true; discard(); } if (depth24_guard.active) { @@ -3140,6 +3434,10 @@ class VulkanQueue : private QueueHolds::Holder { context_.scratch_->retire(progress_, submitted ? submitted_ : 0); scratch_guard.active = false; } + if (clamp_guard.active) { + context_.indirect_clamp_->retire(progress_, submitted ? submitted_ : 0); + clamp_guard.active = false; + } // Under tracker_mutex_, so no other flush comes between this submit and the set's note of whether it reached // the queue (it keeps a single upload obligation). if (bindless_commit) bindless_commit(submitted); @@ -3184,6 +3482,7 @@ class VulkanQueue : private QueueHolds::Holder { // signatures of the lists (the application may release them right after the call). std::vector> pins; std::vector> wait_pins; // the fences of `waits` + std::chrono::steady_clock::time_point held_at{}; // LEONIDA_GPU_LATENCY: when it was held }; bool waits_pending(const std::vector& semaphores, const std::vector& values) const { @@ -3237,6 +3536,7 @@ class VulkanQueue : private QueueHolds::Holder { wait_values_.clear(); wait_pins_.clear(); } + if (gpu_latency::enabled()) op.held_at = std::chrono::steady_clock::now(); held_.push_back(std::move(op)); context_.holds().held_changed(1); } @@ -3293,6 +3593,7 @@ class VulkanQueue : private QueueHolds::Holder { Deferred op = std::move(held_.front()); held_.pop_front(); context_.holds().held_changed(-1); + if (gpu_latency::enabled()) gpu_latency::held(int(kind_), int(op.kind), op.held_at); if (!context_.is_device_lost()) run(op); released = true; } @@ -3361,6 +3662,7 @@ class VulkanQueue : private QueueHolds::Holder { std::vector events; // order_timestamp_copy's, reset and reused once the slot completes std::unique_ptr predicated_copy; std::unique_ptr counted_dispatch; + std::unique_ptr indirect_clamp; // counter slots, read once this slot completes std::unique_ptr predicate; // retained until this slot completes std::vector khr_instances; // KHR ARRAY_OF_POINTERS staging, same lifetime std::vector khr_as_queries; // KHR postbuild COMPACTED_SIZE query pools, same lifetime @@ -3589,6 +3891,7 @@ class VulkanQueue : private QueueHolds::Holder { reuse->predicate.reset(); reuse->predicated_copy.reset(); reuse->counted_dispatch.reset(); + reuse->indirect_clamp.reset(); reuse->ticket = UINT64_MAX; // in use until submitted return reuse; } @@ -3617,6 +3920,41 @@ class VulkanQueue : private QueueHolds::Holder { return event; } + static void pass_trace(const CheckpointSubmission& d) { + static const std::uint64_t every = [] { + const char* v = std::getenv("LEONIDA_PASS_TRACE"); + return v && *v ? std::strtoull(v, nullptr, 10) : 0ull; + }(); + if (!every) return; + const std::uint64_t present = submit_phases::totals().present_serial.load(std::memory_order_relaxed); + if (present % every != 1 % every) return; + std::string line; + const char* last = nullptr; + unsigned run = 0; + const auto flush = [&] { + if (!last) return; + char text[96]; + std::snprintf(text, sizeof(text), run > 1 ? " %s x%u" : " %s", last, run); + line += text; + }; + for (const auto& x : d.dispatches) { + const char* name = x.shader ? x.shader : "-"; + if (const char* slash = std::strrchr(name, '/')) name = slash + 1; + if (last && std::strcmp(last, name) == 0) { + ++run; + continue; + } + flush(); + last = name; + run = 1; + } + flush(); + std::fprintf(stderr, "[rt] passes: present %llu execute %llu (%s) %zu dispatches%s:%s\n", + static_cast(present), static_cast(d.execute_call), + d.queue_kind ? d.queue_kind : "?", d.dispatch_count, + d.dispatch_count > d.dispatches.size() ? " (last 64)" : "", line.empty() ? " none" : line.c_str()); + } + bool submit(VkCommandBuffer command_buffer, VkSemaphore fence, std::uint64_t value, CheckpointSubmission* diagnostics = nullptr) { if (context_.is_device_lost()) return false; @@ -3667,6 +4005,9 @@ class VulkanQueue : private QueueHolds::Holder { submit.pCommandBuffers = &command_buffer; submit.signalSemaphoreCount = signal_count; submit.pSignalSemaphores = signals; + // LEONIDA_PASS_TRACE= (with LEONIDA_DEVICE_FAULT=1): in the frame after every n-th present, each + // submission logs its compute programs in order (repeats folded), for the frame's pass order. + if (diagnostics) pass_trace(*diagnostics); // Publish before the driver can execute a marker or a concurrent fence wait can see the loss. if (diagnostics) context_.device_fault()->publish(std::move(*diagnostics)); const auto label_fence=context_.gpu_labels_.submit_fence(command_buffer); @@ -3684,6 +4025,12 @@ class VulkanQueue : private QueueHolds::Holder { return false; } const bool ok = (res == VK_SUCCESS); + if (ok && gpu_latency::enabled()) { + // LEONIDA_GPU_LATENCY=1: when the GPU finished this submission, measured from the submit. + const auto kind = int(kind_); + const auto at = std::chrono::steady_clock::now(); + context_.enqueue_fence_callback(progress_, ticket, [kind, at] { gpu_latency::done(kind, at); }); + } if (ok) { submitted_ = ticket; clear_waits(ticket); diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h index 589cadffd4..e72225396b 100644 --- a/runtime/src/vulkan_bindless.h +++ b/runtime/src/vulkan_bindless.h @@ -25,6 +25,14 @@ // and samplers it adds and keeps them alive while they are in the set; this class owns only the fallbacks and the // table's buffer. // +// The fallbacks stand for the console's null descriptors (a zero T#, a T# whose image the layer refused or never +// saw): each is of the kind the instruction asks for, since the translator picks the binding by the instruction's +// dimension and the view by the T#'s numeric class, and a miss at any of them reads zeros. On the console a store or +// atomic through a null descriptor is dropped and a later read still gives zeros. So the storage fallbacks never +// share an image with the sampled ones (a store through a null UAV would otherwise show in every null SRV of that +// dimension), and with BindlessFeatures::null_descriptor (VK_EXT_robustness2 nullDescriptor) they are null +// descriptors, whose stores Vulkan discards and whose reads are zero. +// // Device features: runtimeDescriptorArray for the shaders. With BindlessFeatures::update_after_bind // (descriptorBindingSampledImageUpdateAfterBind, ...StorageImage..., ...StorageBuffer...) flush() may run while // command buffers that use the set are pending, as long as no descriptor they use changes and @@ -90,6 +98,10 @@ constexpr std::array default_counts(); struct BindlessFeatures { bool update_after_bind = false; bool partially_bound = false; + // VK_EXT_robustness2's nullDescriptor is enabled on the device: the storage arrays' fallbacks are null + // descriptors (stores and atomics through them are discarded, loads read zero). Without it they are 1x1 images + // of their own, apart from the sampled fallbacks, which no store reaches. + bool null_descriptor = false; // Fallback sample counts for RGBA8_UNORM, R32_UINT, R32_SINT. A single sample omits that class's MS bindings. std::array ms_samples{ VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT}; @@ -372,10 +384,12 @@ class BindlessSet { destroy(table_buffers_); if (fallback_sampler_) vk_.vkDestroySampler(device_, fallback_sampler_, nullptr); for (const VkImageView view : fallback_views_) vk_.vkDestroyImageView(device_, view, nullptr); - for (const auto& image : fallback_images_) { + const auto destroy_image = [&](const FallbackImage& image) { if (image.image) vk_.vkDestroyImage(device_, image.image, nullptr); if (image.memory) vk_.vkFreeMemory(device_, image.memory, nullptr); - } + }; + for (const auto& image : fallback_images_) destroy_image(image); + for (const auto& image : storage_fallback_images_) destroy_image(image); if (pool_) vk_.vkDestroyDescriptorPool(device_, pool_, nullptr); // frees the set if (layout_) vk_.vkDestroyDescriptorSetLayout(device_, layout_, nullptr); } @@ -418,8 +432,12 @@ class BindlessSet { void record_fallback_init(VkCommandBuffer command_buffer) { fallbacks_ready_ = true; std::vector barriers; - for (const auto& image : fallback_images_) { - if (!image.image) continue; // unsupported multisample component class + std::vector images; + for (const auto& image : fallback_images_) images.push_back(&image); + for (const auto& image : storage_fallback_images_) images.push_back(&image); + for (const FallbackImage* fallback : images) { + const FallbackImage& image = *fallback; + if (!image.image) continue; // an unused class, or a storage fallback that is a null descriptor VkImageMemoryBarrier barrier{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; @@ -829,62 +847,82 @@ class BindlessSet { vk_.vkUpdateDescriptorSets(device_, std::uint32_t(writes.size()), writes.data(), 0, nullptr); } - // One 1x1 image for each image type and component class, and the views of them every binding needs. + // The fallbacks of every binding (the class comment): a 1x1 sampled image for each image type (each MS class + // its own), and the storage arrays' 1x1 images of each type and component class, or null descriptors with + // features_.null_descriptor. A sampled and a storage fallback never share an image. bool create_fallbacks() { - // Each MS class shares one sampled-only fallback between its 2D and 2D-array views. + // Each MS class shares one sampled-only fallback between its 2D and 2D-array views; so does each single-sample + // type between its 2D and 2D-array views, sampled and storage alike. constexpr VkImageType types[] = {VK_IMAGE_TYPE_2D, VK_IMAGE_TYPE_3D, VK_IMAGE_TYPE_1D, VK_IMAGE_TYPE_2D}; constexpr std::uint32_t ms_type = 3; constexpr VkFormat formats[classes] = {VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT}; // dimension -> (index into types, view type) constexpr std::uint32_t type_of[dimensions] = {0, 0, 1, 2, 2, ms_type, ms_type}; constexpr VkImageViewType view_types[dimensions] = {VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_VIEW_TYPE_2D_ARRAY, - VK_IMAGE_VIEW_TYPE_3D, VK_IMAGE_VIEW_TYPE_1D, - VK_IMAGE_VIEW_TYPE_1D_ARRAY, - VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_VIEW_TYPE_2D_ARRAY}; + VK_IMAGE_VIEW_TYPE_3D, VK_IMAGE_VIEW_TYPE_1D, + VK_IMAGE_VIEW_TYPE_1D_ARRAY, VK_IMAGE_VIEW_TYPE_2D, + VK_IMAGE_VIEW_TYPE_2D_ARRAY}; + const auto create_image = [&](FallbackImage& image, std::uint32_t t, std::uint32_t c, VkImageUsageFlags usage) { + VkImageCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO}; + info.imageType = types[t]; + info.format = formats[c]; + info.extent = {1, 1, 1}; + info.mipLevels = 1; + info.arrayLayers = 1; + info.samples = t == ms_type ? features_.ms_samples[c] : VK_SAMPLE_COUNT_1_BIT; + info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | usage; + share_across_queue_families(info, families_); + if (vk_.vkCreateImage(device_, &info, nullptr, &image.image) != VK_SUCCESS) return false; + VkMemoryRequirements requirements{}; + vk_.vkGetImageMemoryRequirements(device_, image.image, &requirements); + VkMemoryAllocateInfo allocation{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO}; + allocation.allocationSize = requirements.size; + allocation.memoryTypeIndex = memory_type(requirements.memoryTypeBits, 0); + return allocation.memoryTypeIndex != 0xffffffffu && + vk_.vkAllocateMemory(device_, &allocation, nullptr, &image.memory) == VK_SUCCESS && + vk_.vkBindImageMemory(device_, image.image, image.memory, 0) == VK_SUCCESS; + }; + const auto create_view = [&](const FallbackImage& image, std::uint32_t d, std::uint32_t c, VkImageView& view) { + VkImageViewCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; + info.image = image.image; + info.viewType = view_types[d]; + info.format = formats[c]; + info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + if (vk_.vkCreateImageView(device_, &info, nullptr, &view) != VK_SUCCESS) return false; + fallback_views_.push_back(view); + return true; + }; for (std::uint32_t t = 0; t < std::size(types); ++t) { for (std::uint32_t c = 0; c < classes; ++c) { - if (t == ms_type && !supports_ms_class(c)) continue; - VkImageCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO}; - info.imageType = types[t]; - info.format = formats[c]; - info.extent = {1, 1, 1}; - info.mipLevels = 1; - info.arrayLayers = 1; - info.samples = t == ms_type ? features_.ms_samples[c] : VK_SAMPLE_COUNT_1_BIT; - info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; - if (t != ms_type) info.usage |= VK_IMAGE_USAGE_STORAGE_BIT; - if (t == ms_type || c == 0) info.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; - FallbackImage& image = fallback_images_[t * classes + c]; - share_across_queue_families(info, families_); - if (vk_.vkCreateImage(device_, &info, nullptr, &image.image) != VK_SUCCESS) return false; - VkMemoryRequirements requirements{}; - vk_.vkGetImageMemoryRequirements(device_, image.image, &requirements); - VkMemoryAllocateInfo allocation{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO}; - allocation.allocationSize = requirements.size; - allocation.memoryTypeIndex = memory_type(requirements.memoryTypeBits, 0); - if (allocation.memoryTypeIndex == 0xffffffffu || - vk_.vkAllocateMemory(device_, &allocation, nullptr, &image.memory) != VK_SUCCESS || - vk_.vkBindImageMemory(device_, image.image, image.memory, 0) != VK_SUCCESS) + // Sampled: class 0 of the single-sample types (the translator reads a miss through the float view), + // every supported class of MS. + if (t == ms_type ? supports_ms_class(c) : c == 0) { + if (!create_image(fallback_images_[t * classes + c], t, c, VK_IMAGE_USAGE_SAMPLED_BIT)) return false; + } + if (t != ms_type && !features_.null_descriptor && + !create_image(storage_fallback_images_[t * classes + c], t, c, VK_IMAGE_USAGE_STORAGE_BIT)) return false; } } for (std::uint32_t d = 0; d < dimensions; ++d) { const ImageDimension dimension{d}; for (std::uint32_t c = 0; c < classes; ++c) { - VkImageViewCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; - info.image = fallback_images_[type_of[d] * classes + c].image; - if (!info.image) continue; - info.viewType = view_types[d]; - info.format = formats[c]; - info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; - VkImageView view = VK_NULL_HANDLE; - if (vk_.vkCreateImageView(device_, &info, nullptr, &view) != VK_SUCCESS) return false; - fallback_views_.push_back(view); - const auto sampled_at = bindless::sampled_binding(dimension, c); - if (sampled_at != bindless::no_binding && (c == 0 || bindless::multisampled(dimension))) - fallback_by_binding_[sampled_at] = view; + const FallbackImage& sampled = fallback_images_[type_of[d] * classes + c]; + if (sampled.image) { + VkImageView view = VK_NULL_HANDLE; + if (!create_view(sampled, d, c, view)) return false; + const auto sampled_at = bindless::sampled_binding(dimension, c); + if (sampled_at != bindless::no_binding && (c == 0 || bindless::multisampled(dimension))) + fallback_by_binding_[sampled_at] = view; + } const auto storage_at = bindless::storage_binding(dimension, c); - if (storage_at != bindless::no_binding) fallback_by_binding_[storage_at] = view; + if (storage_at == bindless::no_binding) continue; // MS: no storage arrays + // With null_descriptor the storage fallbacks stay VK_NULL_HANDLE: null descriptors. + VkImageView view = VK_NULL_HANDLE; + if (!features_.null_descriptor && + !create_view(storage_fallback_images_[type_of[d] * classes + c], d, c, view)) + return false; + fallback_by_binding_[storage_at] = view; const auto r32ui_at = bindless::r32ui_binding(dimension); if (c == 1 && r32ui_at != bindless::no_binding) fallback_by_binding_[r32ui_at] = view; } @@ -1236,7 +1274,9 @@ class BindlessSet { VkDescriptorSetLayout layout_ = VK_NULL_HANDLE; VkDescriptorPool pool_ = VK_NULL_HANDLE; VkDescriptorSet set_ = VK_NULL_HANDLE; - std::array fallback_images_{}; // [2D, 3D, 1D, 2D MS][class] + std::array fallback_images_{}; // sampled: [2D, 3D, 1D, 2D MS][class] + // Storage, without null_descriptor: [2D, 3D, 1D][class]. Never the image of a sampled fallback. + std::array storage_fallback_images_{}; std::vector fallback_views_; std::array fallback_by_binding_{}; VkSampler fallback_sampler_ = VK_NULL_HANDLE; diff --git a/runtime/src/vulkan_depth24.h b/runtime/src/vulkan_depth24.h index a46177dd4d..3c8a13cf73 100644 --- a/runtime/src/vulkan_depth24.h +++ b/runtime/src/vulkan_depth24.h @@ -22,6 +22,7 @@ #include "depth24.h" #include "depth24_convert_spv.h" +#include "vulkan_aftermath.h" namespace leonida { @@ -230,7 +231,8 @@ class Depth24Converter { bool ok = vk_.vkCreateDescriptorSetLayout(device_, &set_info, nullptr, &set_layout_) == VK_SUCCESS; layout_info.pSetLayouts = &set_layout_; ok = ok && vk_.vkCreatePipelineLayout(device_, &layout_info, nullptr, &pipeline_layout_) == VK_SUCCESS && - vk_.vkCreateShaderModule(device_, &module_info, nullptr, &module) == VK_SUCCESS; + (aftermath::ShaderName("(runtime) depth24_convert.comp"), + vk_.vkCreateShaderModule(device_, &module_info, nullptr, &module) == VK_SUCCESS); if (ok) { VkComputePipelineCreateInfo info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, diff --git a/runtime/src/vulkan_device_fault.h b/runtime/src/vulkan_device_fault.h index f51edb360b..d60367491d 100644 --- a/runtime/src/vulkan_device_fault.h +++ b/runtime/src/vulkan_device_fault.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,14 @@ struct DeviceFaultExtensions { bool diagnostics_config = false; }; +// What a device asks for. LEONIDA_DEVICE_FAULT=1 wants all of it; LEONIDA_AFTERMATH=1 alone (vulkan_aftermath.h) only +// needs the NVIDIA diagnostics config, whose flags turn on the Aftermath features of the GPU crash dump. +struct DeviceFaultRequest { + bool fault = true; // VK_EXT_device_fault and VK_NV_device_diagnostic_checkpoints + bool diagnostics_config = true; // VK_NV_device_diagnostics_config + VkDeviceDiagnosticsConfigFlagsNV extra_flags = 0; // added to the default config flags below +}; + // Owns the feature structures until vkCreateDevice returns. struct DeviceFaultFeatures { VkPhysicalDeviceFaultFeaturesEXT fault{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT}; @@ -35,14 +44,15 @@ struct DeviceFaultFeatures { DeviceFaultExtensions enable(VkPhysicalDevice physical, PFN_vkGetPhysicalDeviceFeatures2 query, std::span advertised, - std::vector& extensions, VkDeviceCreateInfo& device) { + std::vector& extensions, VkDeviceCreateInfo& device, + DeviceFaultRequest request = {}) { const auto has = [&](const char* name) { return std::any_of(advertised.begin(), advertised.end(), [name](const auto& ext) { return std::strcmp(ext.extensionName, name) == 0; }); }; - const bool has_fault = has(VK_EXT_DEVICE_FAULT_EXTENSION_NAME); - const bool has_config = has(VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME); + const bool has_fault = request.fault && has(VK_EXT_DEVICE_FAULT_EXTENSION_NAME); + const bool has_config = request.diagnostics_config && has(VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME); if (has_fault || has_config) { diagnostics.pNext = nullptr; fault.pNext = has_config ? &diagnostics : nullptr; @@ -51,7 +61,7 @@ struct DeviceFaultFeatures { query(physical, &features); } const DeviceFaultExtensions enabled{has_fault && fault.deviceFault == VK_TRUE, - has(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME), + request.fault && has(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME), has_config && diagnostics.diagnosticsConfig == VK_TRUE}; if (enabled.fault) { extensions.push_back(VK_EXT_DEVICE_FAULT_EXTENSION_NAME); @@ -65,7 +75,7 @@ struct DeviceFaultFeatures { config.pNext = &diagnostics; config.flags = VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV | VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV | - VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV; + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV | request.extra_flags; device.pNext = &config; } return enabled; @@ -225,6 +235,15 @@ class SubmissionProgressWatch { bool reported_ = false; }; +// Runs on every VK_ERROR_DEVICE_LOST that DeviceFaultDiagnostics::observe or VulkanContext::mark_device_lost sees, +// with or without LEONIDA_DEVICE_FAULT. Set before the device exists by the Aftermath integration +// (vulkan_aftermath.h), which blocks there until its GPU crash dump is written. +inline std::atomic device_lost_hook{nullptr}; + +inline void run_device_lost_hook() noexcept { + if (const auto hook = device_lost_hook.load(std::memory_order_acquire)) hook(); +} + class DeviceFaultDiagnostics { public: DeviceFaultDiagnostics(PFN_vkGetDeviceProcAddr get, VkDevice device, DeviceFaultExtensions enabled) @@ -272,7 +291,10 @@ class DeviceFaultDiagnostics { } static VkResult observe(DeviceFaultDiagnostics* diagnostics, VkResult result, const char* operation) noexcept { - if (result == VK_ERROR_DEVICE_LOST && diagnostics) diagnostics->report(operation); + if (result == VK_ERROR_DEVICE_LOST) { + if (diagnostics) diagnostics->report(operation); + run_device_lost_hook(); + } return result; } @@ -281,6 +303,20 @@ class DeviceFaultDiagnostics { ", last observed retired ticket %" PRIu64 "\n", reason, submitted, retired); // NV checkpoints and EXT fault data require a lost device. The CPU ring is valid at any time. dump_dispatches(); + // LEONIDA_STALL_CHECKPOINTS=1 (diagnostic): ask for the checkpoints anyway. A hang (Xid 109) the driver + // recovers from without losing the device otherwise names no program; outside the lost state the call is + // out of the extension's contract, which the NVIDIA driver has answered so far. + static const bool stall_checkpoints = [] { + const char* v = std::getenv("LEONIDA_STALL_CHECKPOINTS"); + return v && std::strcmp(v, "1") == 0; + }(); + if (!stall_checkpoints || !vkGetQueueCheckpointDataNV) return; + try { + std::lock_guard lock(mutex_); + for (VkQueue queue : queues_) report_queue(queue); + } catch (...) { + std::fprintf(stderr, "[rt] device-fault: checkpoint collection failed\n"); + } } private: @@ -305,10 +341,29 @@ class DeviceFaultDiagnostics { } } +public: + // LOCAL DIAGNOSTIC: run once after a loss is reported (the compute input probe rechecks the descriptors it saw). + void set_lost_hook(std::function hook) { + std::lock_guard lock(mutex_); + lost_hook_ = std::move(hook); + } + +private: + std::function lost_hook_; + void report(const char* operation) noexcept { if (reported_.exchange(true, std::memory_order_relaxed)) return; std::fprintf(stderr, "[rt] device-fault: VK_ERROR_DEVICE_LOST from %s\n", operation); dump_dispatches(); + try { + std::function hook; + { + std::lock_guard lock(mutex_); + hook = lost_hook_; + } + if (hook) hook(); + } catch (...) { + } try { if (vkGetDeviceFaultInfoEXT) report_fault(); } catch (...) { diff --git a/runtime/src/vulkan_index_view.h b/runtime/src/vulkan_index_view.h new file mode 100644 index 0000000000..b9e72349b7 --- /dev/null +++ b/runtime/src/vulkan_index_view.h @@ -0,0 +1,21 @@ +// Device creation policy for bounded D3D12 indexed-indirect draws. No work per draw. +#pragma once + +#include + +namespace leonida { + +inline bool can_enable_robust_index_view(VkPhysicalDevice device, PFN_vkGetPhysicalDeviceProperties2 properties, + bool sized_indirect, bool robust_access, bool storage_update_after_bind) { + if (!sized_indirect || !robust_access) return false; + if (!storage_update_after_bind) return true; + // VUID-VkDeviceCreateInfo-robustBufferAccess-10247: preserve bindless rather than disabling + // descriptorBindingStorageBufferUpdateAfterBind on a device that cannot combine the two. + if (!properties) return false; + VkPhysicalDeviceVulkan12Properties indexed{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES}; + VkPhysicalDeviceProperties2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &indexed}; + properties(device, &query); + return indexed.robustBufferAccessUpdateAfterBind == VK_TRUE; +} + +} // namespace leonida diff --git a/runtime/src/vulkan_indirect_clamp.h b/runtime/src/vulkan_indirect_clamp.h new file mode 100644 index 0000000000..e510e3b0ca --- /dev/null +++ b/runtime/src/vulkan_indirect_clamp.h @@ -0,0 +1,583 @@ +// GPU-side clamping of D3D12 ExecuteIndirect arguments, for the replay (vulkan_replay.h). +// +// The title's own compute passes write most of these arguments, and a pass the replay drops (an async pipeline that +// is not built yet, a stub pipeline, LEONIDA_SKIP_COMPUTE) or mistranslates leaves whatever the memory held: a stale +// or garbage record makes a dispatch of billions of groups or a draw of four billion vertices run until the host +// resets the display driver (TDR, device loss). So, just before the indirect command, one tiny compute pass copies +// the active records into device-local scratch with their values bounded - 2^24 vertices or indices, 2^26 vertex +// instances, 65 535 groups per dimension, 2^20 groups per dispatch, and a 2^27-unit work budget per command +// list (the shader is indirect_clamp.comp) - and the indirect command reads that scratch. The application's argument +// and count buffers are left untouched, so values within the limits replay bit-identically. +// +// One pass covers all four argument kinds the layer can emit (draw, draw indexed, dispatch, mesh dispatch) and the +// counted variants, whose count is clamped to max_command_count as well (a *Count draw then reads a count the scratch +// really holds). +// +// LEONIDA_INDIRECT_CLAMP=0 disables it: the indirect command reads the application's argument buffer, as before. +// +// The pass is recorded before anything reads the arguments, and before the drawing scope an indirect draw opens +// around itself (vkCmdCopyBuffer and a memory barrier with a transfer access are not allowed inside a +// dynamic-rendering scope, VUID-vkCmdCopyBuffer-renderpass / VUID-vkCmdPipelineBarrier-None-09586). That is where +// `vulkan_replay.h` emits it for the legacy ExecuteIndirect commands, and where a stateful indirect draw - the +// workspace branch that records a Draw with the arguments it reads, opening its own rendering scope - emits it too: +// the same prepare/emit pair, from `Prepared` or its own prepared draw, before vkCmdBeginRendering. Nothing here +// depends on that branch. +// +// Scratch comes from a per-submission pool (vulkan_scratch.h): handed out while a list is prepared, retired with the +// submission's timeline ticket, reused once the GPU is past it - so a list with many indirect calls allocates no +// buffer per call. The only other state per call is a 16-byte counter slot in one persistent host-visible buffer, +// read (and logged rate-limited) once the submission that used it has completed. The counters are diagnostics: a call +// that finds no free slot is still clamped, without its counters. +#pragma once +#ifndef VK_NO_PROTOTYPES +#define VK_NO_PROTOTYPES +#endif +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "submit_phases.h" +#include "indirect_clamp_spv.h" +#include "vulkan_indirect_dispatch_count.h" +#include "vulkan_aftermath.h" +#include "vulkan_memory.h" +#include "vulkan_scratch.h" + +namespace leonida { + +// Argument kinds, numbered as leonida::IndirectKind (command_list.h): the shader reads them. +inline constexpr std::uint32_t indirect_clamp_draw = 0; +inline constexpr std::uint32_t indirect_clamp_draw_indexed = 1; +inline constexpr std::uint32_t indirect_clamp_dispatch = 2; +inline constexpr std::uint32_t indirect_clamp_mesh = 3; + +// What the pass bounds, as indirect_clamp.comp states them. +inline constexpr std::uint32_t indirect_clamp_max_vertices = 1u << 24; +inline constexpr std::uint32_t indirect_clamp_max_vertex_instances = 1u << 26; +inline constexpr std::uint32_t indirect_clamp_max_group_dimension = 65535u; +inline constexpr std::uint32_t indirect_clamp_max_groups = 1u << 20; +inline constexpr std::uint32_t indirect_clamp_budget = 1u << 27; + +// The largest scratch allocation accepted for one ExecuteIndirect call. +inline constexpr std::uint64_t indirect_clamp_max_scratch_bytes = std::uint64_t(64) << 20; + +// Read once: LEONIDA_INDIRECT_CLAMP=0 leaves the application's argument buffer to the indirect command. +inline bool indirect_clamp_enabled() { + static const bool enabled = [] { +#ifdef _WIN32 + char value[3]{}; + std::size_t length = 0; + if (getenv_s(&length, value, sizeof value, "LEONIDA_INDIRECT_CLAMP") != 0 || !length) return true; + return !(length == 2 && value[0] == '0' && !value[1]); +#else + const char* value = std::getenv("LEONIDA_INDIRECT_CLAMP"); + return !value || value[0] != '0' || value[1]; +#endif + }(); + return enabled; +} + +// The record size of each kind, as Vulkan's indirect commands define it and D3D12's argument structs match. +inline constexpr std::uint32_t indirect_clamp_record_size(std::uint32_t kind) { + return kind == indirect_clamp_draw ? 4u * 4u : kind == indirect_clamp_draw_indexed ? 5u * 4u : 3u * 4u; +} + +// Where a clamped ExecuteIndirect call's arguments are, and what its clamp pass needs to record it. +struct ClampedIndirect { + // The command the replay then emits: the clamped records, and for a counted draw the clamped count word. + VkBuffer buffer = VK_NULL_HANDLE; + VkDeviceSize offset = 0; + VkBuffer count_buffer = VK_NULL_HANDLE; + VkDeviceSize count_offset = 0; + std::uint32_t stride = 0; // bytes per clamped record: 3, 4 or 5 words by kind + std::uint32_t records = 0; // max_command_count + bool counted = false; + + // The clamp pass itself (emit_indirect_clamp). + VkDeviceAddress arguments = 0; // the application's first record + VkDeviceAddress count = 0; // the application's count word, 0 when uncounted + VkDeviceAddress records_out = 0; + VkDeviceAddress count_out = 0; + VkDeviceAddress stats = 0; + VkDeviceAddress list_budget = 0; + void share_list_budget(VkDeviceAddress& first) { + if (!first) first = list_budget; + list_budget = first; + } + VkBuffer stats_buffer = VK_NULL_HANDLE; // the host-visible counter slot the pass copies its counters to + VkDeviceSize stats_offset = 0; + VkDeviceSize stats_scratch_offset = 0; // where in `buffer` the pass's own counters are + std::uint32_t kind = 0; + std::uint32_t stride_words = 0; + std::uint32_t max_records = 0; +}; + +// One device's clamp: the pass's pipeline (made on the first call), the per-submission record pool, and the counter +// slots. Single-threaded per list, as the replay's preparation is: the caller holds the context's tracker lock for +// prepare and emit, and the batch destructor only touches the slot bookkeeping under `mutex_`. +class IndirectArgumentClamp { +private: + struct Slot { + std::uint32_t area; + std::uint32_t index; + }; + static constexpr std::uint32_t no_slot = UINT32_MAX; // Slot::area of a call clamped without counters + +public: + using Allocate = ScratchBuffers::Allocate; + + IndirectArgumentClamp(PFN_vkGetDeviceProcAddr get, VkDevice device, const VkPhysicalDeviceMemoryProperties& memory, + const VkPhysicalDeviceLimits& limits, Allocate allocate, + DeviceFaultDiagnostics* diagnostics = nullptr); + ~IndirectArgumentClamp(); + IndirectArgumentClamp(const IndirectArgumentClamp&) = delete; + IndirectArgumentClamp& operator=(const IndirectArgumentClamp&) = delete; + + // False when the pass cannot run on this device (no device addresses, no compute): the replay then keeps the + // application's buffer. + bool loaded() const { return scratch_.loaded() && limits_.maxComputeWorkGroupCount[0] != 0; } + + // The record pool's life cycle, as the copy scratch's (vulkan_scratch.h). + void collect() { scratch_.collect(); } + void retire(VkSemaphore timeline, std::uint64_t ticket) { scratch_.retire(timeline, ticket); } + void forget(VkSemaphore timeline) { scratch_.forget(timeline); } + + // What the pass found since the process started. `records_clamped` counts the records whose values the pass + // changed (the ones it emptied included). + struct Counters { + std::uint64_t calls = 0; + std::uint64_t records = 0; + std::uint64_t records_clamped = 0; + std::uint64_t counts_clamped = 0; + std::uint64_t over_budget = 0; + std::uint64_t zeroed = 0; + std::uint64_t unclamped_calls = 0; // the fallbacks: calls the pool or the limits left to the replay + std::uint64_t uncounted_calls = 0; // clamped with no counter slot free: their counters are not read back + }; + + // One submission's clamp state: the counter slots its calls claimed, read and released together once that + // submission has completed. Retained by the command-buffer slot until its timeline ticket does. + class Batch { + public: + explicit Batch(IndirectArgumentClamp& owner) : owner_(owner) {} + ~Batch() { owner_.release(slots_, true); } + Batch(const Batch&) = delete; + Batch& operator=(const Batch&) = delete; + + // Reserve scratch for one command. A host-visible counter slot is optional. + bool prepare(VkBuffer arguments, VkDeviceSize argument_offset, VkBuffer count, VkDeviceSize count_offset, + std::uint32_t kind, std::uint32_t stride, std::uint32_t max_count, ClampedIndirect& out) { + // LOCAL FIX (post-load device loss): a submission after the story load carries thousands of + // ExecuteIndirect calls, far more than the counter slots, and each call that found none used to fall back + // to the application's buffer - unclamped, over arguments that skipped compute never wrote, while one + // submission blocked in the driver for 10 s and the device was lost. Out of slots, the call is clamped all + // the same; only its counters are not read back. + Slot slot{}; + const bool counted = owner_.claim_slot(slot); + if (!counted) { + owner_.note_uncounted(); + slot = Slot{no_slot, 0}; + } + if (!owner_.prepare(arguments, argument_offset, count, count_offset, kind, stride, max_count, slot, out)) { + if (counted) owner_.release_one(slot); + return false; + } + if (counted) slots_.push_back(slot); + return true; + } + + std::size_t calls() const { return slots_.size(); } + + private: + IndirectArgumentClamp& owner_; + std::vector slots_; + }; + + std::unique_ptr batch() { return std::make_unique(*this); } + + // Records one clamp pass: its counters filled, the dispatch, and the counters copied back to their slot. Emitted + // before the indirect command that reads `job`, and before any rendering scope that command runs in. + void emit(VkCommandBuffer cb, const ClampedIndirect& job); + + Counters counters() const { + std::lock_guard lock(mutex_); + return counters_; + } + +private: + // A host-visible buffer of counter slots: what the pass's counters are copied into, 16 bytes each. + struct HostArea { + VkBuffer buffer = VK_NULL_HANDLE; + VkDeviceMemory memory = VK_NULL_HANDLE; + std::uint8_t* host = nullptr; + std::uint32_t slots = 0; + static constexpr std::uint32_t slot_bytes = 32; // 16 bytes of counters, 16 of padding + }; + static constexpr std::uint32_t slots_per_area = 64; + // 4,096 slots (128 KiB of host memory): enough for a submission's ExecuteIndirect calls after the load, and the + // calls past them are still clamped (no_slot). + static constexpr std::uint32_t max_areas = 64; + + template T fn(const char* name) const { return reinterpret_cast(get_(device_, name)); } + bool make_pipeline(); + bool make_area(); + bool claim_slot(Slot& out); + void release_one(Slot slot); + void release(std::vector& slots, bool read); + bool prepare(VkBuffer arguments, VkDeviceSize argument_offset, VkBuffer count, VkDeviceSize count_offset, + std::uint32_t kind, std::uint32_t stride, std::uint32_t max_count, Slot slot, ClampedIndirect& out); + void fallback(const char* reason); + void note_uncounted(); + + PFN_vkGetDeviceProcAddr get_; + VkDevice device_; + VkPhysicalDeviceMemoryProperties memory_{}; + VkPhysicalDeviceLimits limits_{}; + DeviceFaultDiagnostics* diagnostics_ = nullptr; + ScratchBuffers scratch_; + VkPipelineLayout layout_ = VK_NULL_HANDLE; + VkPipeline pipeline_ = VK_NULL_HANDLE; + + mutable std::mutex mutex_; // the slot bookkeeping and the counters + std::vector areas_; + std::vector free_slots_; + Counters counters_{}; + std::uint64_t next_report_frame_ = 0; +}; + +namespace detail { + +// One clamp pass's push-constant block. The shader's block is the same: five device addresses, then the six words. +struct IndirectClampPush { + VkDeviceAddress arguments; + VkDeviceAddress count; + VkDeviceAddress records_out; + VkDeviceAddress count_out; + VkDeviceAddress stats; + VkDeviceAddress list_budget; + std::uint32_t kind; + std::uint32_t stride_words; + std::uint32_t records; + std::uint32_t first_record; + std::uint32_t max_records; + std::uint32_t flags; +}; +static_assert(sizeof(IndirectClampPush) == 72); + +inline constexpr VkBufferUsageFlags indirect_clamp_scratch_usage = + VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; + +} // namespace detail + +inline IndirectArgumentClamp::IndirectArgumentClamp(PFN_vkGetDeviceProcAddr get, VkDevice device, + const VkPhysicalDeviceMemoryProperties& memory, + const VkPhysicalDeviceLimits& limits, Allocate allocate, + DeviceFaultDiagnostics* diagnostics) + : get_(get), device_(device), memory_(memory), limits_(limits), diagnostics_(diagnostics), + scratch_(get, device, std::move(allocate), diagnostics, detail::indirect_clamp_scratch_usage) {} + +inline IndirectArgumentClamp::~IndirectArgumentClamp() { + const auto destroy_pipeline = fn("vkDestroyPipeline"); + const auto destroy_layout = fn("vkDestroyPipelineLayout"); + if (pipeline_ && destroy_pipeline) destroy_pipeline(device_, pipeline_, nullptr); + if (layout_ && destroy_layout) destroy_layout(device_, layout_, nullptr); + const auto destroy_buffer = fn("vkDestroyBuffer"); + const auto free_memory = fn("vkFreeMemory"); + for (auto& area : areas_) { + if (area.buffer && destroy_buffer) destroy_buffer(device_, area.buffer, nullptr); + if (area.memory && free_memory) free_memory(device_, area.memory, nullptr); + } +} + +inline bool IndirectArgumentClamp::make_pipeline() { + if (pipeline_) return true; + for (const char* name : {"vkCreateBuffer", "vkDestroyBuffer", "vkGetBufferMemoryRequirements", + "vkAllocateMemory", "vkFreeMemory", "vkBindBufferMemory", "vkMapMemory", "vkUnmapMemory", + "vkGetBufferDeviceAddress", "vkCreateShaderModule", "vkDestroyShaderModule", "vkCreatePipelineLayout", + "vkDestroyPipelineLayout", "vkCreateComputePipelines", "vkDestroyPipeline", "vkCmdPipelineBarrier", + "vkCmdBindPipeline", "vkCmdPushConstants", "vkCmdDispatch", "vkCmdFillBuffer", "vkCmdCopyBuffer"}) + if (!get_(device_, name)) return false; + VkShaderModule module = VK_NULL_HANDLE; + VkShaderModuleCreateInfo shader{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; + shader.codeSize = sizeof(indirect_clamp_spirv); + shader.pCode = indirect_clamp_spirv; + const aftermath::ShaderName aftermath_name("(runtime) indirect_clamp"); + bool ok = fn("vkCreateShaderModule")(device_, &shader, nullptr, &module) == VK_SUCCESS; + VkPipelineLayout layout = VK_NULL_HANDLE; + const VkPushConstantRange range{VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(detail::IndirectClampPush)}; + VkPipelineLayoutCreateInfo layout_info{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; + layout_info.pushConstantRangeCount = 1; + layout_info.pPushConstantRanges = ⦥ + ok = ok && fn("vkCreatePipelineLayout")(device_, &layout_info, nullptr, &layout) == + VK_SUCCESS; + VkPipeline pipeline = VK_NULL_HANDLE; + VkComputePipelineCreateInfo info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; + info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO}; + info.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT; + info.stage.module = module; + info.stage.pName = "main"; + info.layout = layout; + ok = ok && fn("vkCreateComputePipelines")(device_, VK_NULL_HANDLE, 1, &info, nullptr, + &pipeline) == VK_SUCCESS; + if (module) fn("vkDestroyShaderModule")(device_, module, nullptr); + if (!ok) { + if (pipeline) fn("vkDestroyPipeline")(device_, pipeline, nullptr); + if (layout) fn("vkDestroyPipelineLayout")(device_, layout, nullptr); + return false; + } + layout_ = layout; + pipeline_ = pipeline; + return true; +} + +// One host-visible buffer of counter slots: a coherent mapping the pass's counters are copied into. +inline bool IndirectArgumentClamp::make_area() { + if (areas_.size() >= max_areas) return false; + const auto create_buffer = fn("vkCreateBuffer"); + const auto requirements_fn = fn("vkGetBufferMemoryRequirements"); + const auto bind_fn = fn("vkBindBufferMemory"); + const auto allocate_fn = fn("vkAllocateMemory"); + const auto map_fn = fn("vkMapMemory"); + if (!create_buffer || !requirements_fn || !bind_fn || !allocate_fn || !map_fn || !memory_.memoryTypeCount) + return false; + HostArea area{}; + area.slots = slots_per_area; + VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; + info.size = VkDeviceSize(area.slots) * HostArea::slot_bytes; + info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; + if (create_buffer(device_, &info, nullptr, &area.buffer) != VK_SUCCESS) return false; + VkMemoryRequirements requirements{}; + requirements_fn(device_, area.buffer, &requirements); + VkMemoryAllocateInfo allocation{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO}; + allocation.allocationSize = requirements.size; + bool bound = false; + for (const std::uint32_t type : memory_type_order(memory_, requirements.memoryTypeBits, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + 0, requirements.size)) { + allocation.memoryTypeIndex = type; + if (allocate_fn(device_, &allocation, nullptr, &area.memory) != VK_SUCCESS) { + area.memory = VK_NULL_HANDLE; + continue; + } + bound = bind_fn(device_, area.buffer, area.memory, 0) == VK_SUCCESS; + if (bound) break; + } + if (!bound || map_fn(device_, area.memory, 0, info.size, 0, reinterpret_cast(&area.host)) != VK_SUCCESS) { + const auto destroy_buffer = fn("vkDestroyBuffer"); + const auto free_memory = fn("vkFreeMemory"); + if (area.buffer && destroy_buffer) destroy_buffer(device_, area.buffer, nullptr); + if (area.memory && free_memory) free_memory(device_, area.memory, nullptr); + return false; + } + std::memset(area.host, 0, size_t(info.size)); + for (std::uint32_t i = 0; i < area.slots; ++i) free_slots_.push_back({std::uint32_t(areas_.size()), i}); + areas_.push_back(area); + return true; +} + +inline bool IndirectArgumentClamp::claim_slot(Slot& out) { + std::lock_guard lock(mutex_); + if (free_slots_.empty() && !make_area()) return false; + out = free_slots_.back(); + free_slots_.pop_back(); + return true; +} + +inline void IndirectArgumentClamp::release_one(Slot slot) { + std::lock_guard lock(mutex_); + free_slots_.push_back(slot); +} + +// Reads the counters a submission's clamp passes wrote, adds them to the process totals, and hands the slots back. +// Called when the submission's timeline ticket has been reached, so the GPU is past the copies. +inline void IndirectArgumentClamp::release(std::vector& slots, bool read) { + Counters delta{}; + const std::size_t calls = slots.size(); + { + std::lock_guard lock(mutex_); + for (const Slot& slot : slots) { + if (read && slot.area < areas_.size() && slot.index < areas_[slot.area].slots) { + const HostArea& area = areas_[slot.area]; + const std::uint32_t* words = + reinterpret_cast(area.host + std::size_t(slot.index) * HostArea::slot_bytes); + delta.records_clamped += words[0]; + delta.counts_clamped += words[1]; + delta.over_budget += words[2]; + delta.zeroed += words[3]; + } + free_slots_.push_back(slot); + } + counters_.records_clamped += delta.records_clamped; + counters_.counts_clamped += delta.counts_clamped; + counters_.over_budget += delta.over_budget; + counters_.zeroed += delta.zeroed; + const auto frame = submit_phases::totals().present_serial.load(std::memory_order_relaxed); + if (read && calls && frame >= next_report_frame_) { + next_report_frame_ = frame + 60; + std::fprintf(stderr, "[rt] indirect clamp: frame %llu, observed %llu records clamped, %llu zeroed, %llu over list budget\n", + static_cast(frame), static_cast(counters_.records_clamped), + static_cast(counters_.zeroed), static_cast(counters_.over_budget)); + } + } + slots.clear(); +} + +// A call clamped with no counter slot free: logged at the 1st, 2nd, 4th... such call. +inline void IndirectArgumentClamp::note_uncounted() { + std::uint64_t total = 0; + { + std::lock_guard lock(mutex_); + total = ++counters_.uncounted_calls; + } + if (total & (total - 1)) return; + std::fprintf(stderr, "[rt] indirect clamp: %llu execute-indirect call(s) clamped without counters (no counter slot " + "free); the clamp still bounds them\n", static_cast(total)); +} + +// A call the pass leaves to the replay: logged at the 1st, 2nd, 4th... fallback. +inline void IndirectArgumentClamp::fallback(const char* reason) { + std::uint64_t total = 0; + { + std::lock_guard lock(mutex_); + total = ++counters_.unclamped_calls; + } + if (total & (total - 1)) return; + std::fprintf(stderr, "[rt] indirect clamp: %llu execute-indirect call(s) not clamped (%s); the replay refuses the " + "indirect command\n", static_cast(total), reason); +} + +inline bool IndirectArgumentClamp::prepare(VkBuffer arguments, VkDeviceSize argument_offset, VkBuffer count, + VkDeviceSize count_offset, std::uint32_t kind, std::uint32_t stride, + std::uint32_t max_count, Slot slot, ClampedIndirect& out) { + out = {}; + const std::uint32_t record_size = indirect_clamp_record_size(kind); + if (kind > indirect_clamp_mesh || !arguments || !max_count || stride < record_size || stride % 4) { + fallback("an argument stride this pass does not handle"); + return false; + } + const VkDeviceSize records_bytes = VkDeviceSize(max_count) * record_size; + // The clamped records start the slice (the indirect command reads them there), then the clamped count word and + // the pass's counters, each on a cache line of its own. + const VkDeviceSize count_scratch = (records_bytes + 63) / 64 * 64; + const VkDeviceSize stats_scratch = count_scratch + 64; + if (stats_scratch + 64 > indirect_clamp_max_scratch_bytes) { + fallback("an argument batch past the scratch cap"); + return false; + } + VkBuffer buffer = VK_NULL_HANDLE; + VkDeviceSize offset = 0; + VkDeviceAddress address = 0; + if (!scratch_.get(stats_scratch + 64, buffer, offset, address)) { + fallback("no scratch"); + return false; + } + const auto arguments_address = [&](VkBuffer b) { + VkBufferDeviceAddressInfo info{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; + info.buffer = b; + return fn("vkGetBufferDeviceAddress")(device_, &info); + }; + if (!make_pipeline()) { + fallback("no compute pipeline"); + return false; + } + const VkDeviceAddress arguments_va = arguments_address(arguments); + const VkDeviceAddress count_va = count ? arguments_address(count) : 0; + if (!arguments_va || (count && !count_va) || argument_offset > UINT64_MAX - arguments_va || + (count && count_offset > UINT64_MAX - count_va)) { + fallback("an argument buffer without a device address"); + return false; + } + out.kind = kind; + out.stride_words = stride / 4; + out.max_records = max_count; + out.records = max_count; + out.stride = record_size; + out.counted = count != VK_NULL_HANDLE; + out.buffer = buffer; + out.offset = offset; // the clamped records, compact + out.count_buffer = count ? buffer : VK_NULL_HANDLE; + out.count_offset = count ? offset + count_scratch : 0; + out.arguments = arguments_va + argument_offset; + out.count = count_va ? count_va + count_offset : 0; + out.records_out = address; + out.count_out = address + count_scratch; + out.stats = address + stats_scratch; + out.list_budget = out.stats + 4 * sizeof(std::uint32_t); + out.stats_scratch_offset = offset + stats_scratch; + out.stats_buffer = slot.area == no_slot ? VK_NULL_HANDLE : areas_[slot.area].buffer; // no_slot: no copy-back + out.stats_offset = slot.area == no_slot ? 0 : VkDeviceSize(slot.index) * HostArea::slot_bytes; + { + std::lock_guard lock(mutex_); + ++counters_.calls; + counters_.records += max_count; + } + return true; +} + +inline void IndirectArgumentClamp::emit(VkCommandBuffer cb, const ClampedIndirect& job) { + const auto barrier = fn("vkCmdPipelineBarrier"); + const auto bind = fn("vkCmdBindPipeline"); + const auto push = fn("vkCmdPushConstants"); + const auto dispatch = fn("vkCmdDispatch"); + // The counters start at zero: the budget's compare-and-swap and the record counts accumulate into them. A + // transfer write, ordered to the compute stage by the barrier below, like the arguments' own writes. + fn("vkCmdFillBuffer")(cb, job.buffer, job.stats_scratch_offset, job.list_budget == job.stats + 16 ? 20 : 16, 0); + VkMemoryBarrier before{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + before.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT; // every earlier write: the compute that wrote these arguments + before.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; + barrier(cb, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 1, &before, 0, nullptr, 0, + nullptr); + bind(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_); + const VkDeviceSize dispatch_limit = VkDeviceSize(limits_.maxComputeWorkGroupCount[0]) * 64; + // Bound per-dispatch indexing to 32 bits, even when the D3D12 stride is very large. + const std::uint32_t index_limit = (UINT32_MAX - 4u) / std::max(1u, job.stride_words); + const VkDeviceSize chunk_limit = std::max(1, std::min(dispatch_limit, VkDeviceSize(index_limit))); + const std::uint32_t tags = job.kind <= indirect_clamp_draw_indexed ? (job.kind == indirect_clamp_draw ? 4u : 5u) + : 3u; + for (VkDeviceSize first = 0; first < job.max_records;) { + const std::uint32_t records = std::uint32_t(std::min(chunk_limit, job.max_records - first)); + // Use local word offsets within each chunk. Only the count comparison needs the global record index. + const detail::IndirectClampPush constants{job.arguments + first * job.stride_words * 4, + job.count, + job.records_out + first * tags * 4, + job.count_out, + job.stats, + job.list_budget, + job.kind, + job.stride_words, + records, + std::uint32_t(first), + job.max_records, + (job.kind == indirect_clamp_dispatch ? indirect_group_budget() << 1 : 0u) | + (job.counted ? 1u : 0u)}; + push(cb, layout_, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(constants), &constants); + dispatch(cb, (records - 1u) / 64u + 1u, 1, 1); + first += records; + } + if (job.stats_buffer) { // none for a call clamped without a counter slot + VkMemoryBarrier after_copy{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + after_copy.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + after_copy.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + barrier(cb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &after_copy, 0, nullptr, + 0, nullptr); + VkBufferCopy copy{job.stats_scratch_offset, job.stats_offset, 4 * sizeof(std::uint32_t)}; + fn("vkCmdCopyBuffer")(cb, job.buffer, job.stats_buffer, 1, ©); + } + // The indirect command reads the records, and nothing else may read them while it does. + VkMemoryBarrier done{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + done.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT; + done.dstAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_MEMORY_READ_BIT; + barrier(cb, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1, &done, 0, nullptr, 0, + nullptr); +} +} // namespace leonida diff --git a/runtime/src/vulkan_indirect_dispatch_count.h b/runtime/src/vulkan_indirect_dispatch_count.h index 510a4dcad6..8e0f7d4aab 100644 --- a/runtime/src/vulkan_indirect_dispatch_count.h +++ b/runtime/src/vulkan_indirect_dispatch_count.h @@ -8,14 +8,33 @@ #include #include #include +#include +#include +#include #include #include #include #include "indirect_dispatch_count_spv.h" +#include "vulkan_aftermath.h" #include "vulkan_memory.h" namespace leonida { +// Vulkan guarantees at least 65535 groups along each axis. A total budget +// at or below it bounds both the workload and every dimension. +inline std::uint32_t indirect_group_budget() { + static const auto budget = []() -> std::uint32_t { + const char* value = std::getenv("LEONIDA_INDIRECT_GROUP_BUDGET"); + if (!value) return 0; + const std::string_view text(value); + std::uint32_t groups{}; + const auto end = value + text.size(); + const auto parsed = std::from_chars(value, end, groups); + return parsed.ec == std::errc{} && parsed.ptr == end ? std::min(groups, 65535u) : 0; + }(); + return budget; +} + struct CountedDispatch { VkBuffer indirect = VK_NULL_HANDLE; VkDeviceSize offset = 0; @@ -61,7 +80,7 @@ class IndirectDispatchCounter { CountedDispatch& out) { out = {}; constexpr VkDeviceSize record_bytes = 3 * sizeof(std::uint32_t); - if (!arguments || !count || stride < record_bytes || stride % 4 || + if (!arguments || (!count && !indirect_group_budget()) || stride < record_bytes || stride % 4 || (argument_offset % 4) != 0 || (count_offset % 4) != 0 || !max_count || !owner.limits_.maxComputeWorkGroupCount[0] || !owner.make_pipeline()) return false; if (VkDeviceSize(max_count) > std::numeric_limits::max() / record_bytes) @@ -100,10 +119,10 @@ class IndirectDispatchCounter { addr.buffer = arguments; const VkDeviceAddress args_va = address(owner.device_, &addr); addr.buffer = count; - const VkDeviceAddress count_va = address(owner.device_, &addr); + const VkDeviceAddress count_va = count ? address(owner.device_, &addr) : 0; addr.buffer = a.buffer; const VkDeviceAddress output_va = address(owner.device_, &addr); - if (!args_va || !count_va || !output_va || + if (!args_va || (count && !count_va) || !output_va || argument_offset > UINT64_MAX - args_va || count_offset > UINT64_MAX - count_va) return false; out = {a.buffer, 0, args_va + argument_offset, count_va + count_offset, @@ -124,9 +143,9 @@ class IndirectDispatchCounter { fn("vkCmdBindPipeline")(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline_); struct Push { VkDeviceAddress arguments, count, output; - std::uint32_t stride_words, first_record, records; + std::uint32_t stride_words, first_record, records, budget, has_count; }; - static_assert(sizeof(Push) == 40); + static_assert(sizeof(Push) == 48); const VkDeviceSize dispatch_limit = VkDeviceSize(limits_.maxComputeWorkGroupCount[0]) * 64; // Bound per-dispatch indexing to 32 bits, even when the D3D12 stride is very large. // The shader loads and stores three consecutive dwords per record, so leave room for the final +2. @@ -136,7 +155,7 @@ class IndirectDispatchCounter { for (VkDeviceSize first = 0; first < job.max_count;) { const std::uint32_t count = std::uint32_t(std::min(chunk_limit, job.max_count - first)); const Push push{job.arguments + first * job.stride, job.count, job.output + first * 12, - job.stride / 4, std::uint32_t(first), count}; + job.stride / 4, std::uint32_t(first), count, indirect_group_budget(), job.count != 0}; fn("vkCmdPushConstants")(cb, layout_, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(push), &push); fn("vkCmdDispatch")(cb, (count - 1u) / 64u + 1u, 1, 1); @@ -166,8 +185,9 @@ class IndirectDispatchCounter { VkShaderModuleCreateInfo shader{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; shader.codeSize = sizeof(indirect_dispatch_count_spirv); shader.pCode = indirect_dispatch_count_spirv; + const aftermath::ShaderName aftermath_name("(runtime) indirect_dispatch_count"); bool ok = fn("vkCreateShaderModule")(device_, &shader, nullptr, &module) == VK_SUCCESS; - const VkPushConstantRange range{VK_SHADER_STAGE_COMPUTE_BIT, 0, 40}; + const VkPushConstantRange range{VK_SHADER_STAGE_COMPUTE_BIT, 0, 48}; VkPipelineLayoutCreateInfo layout_info{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; layout_info.pushConstantRangeCount = 1; layout_info.pPushConstantRanges = ⦥ diff --git a/runtime/src/vulkan_predicate.h b/runtime/src/vulkan_predicate.h index cedb8af819..87d58b5467 100644 --- a/runtime/src/vulkan_predicate.h +++ b/runtime/src/vulkan_predicate.h @@ -8,6 +8,7 @@ #include #include #include "predicate_reduce_spv.h" +#include "vulkan_aftermath.h" namespace leonida { struct PredicateCapture { @@ -156,6 +157,7 @@ class PredicateReducer { ok = ok && fn("vkCreatePipelineLayout")(device_, &layout_info, nullptr, &layout) == VK_SUCCESS; VkShaderModuleCreateInfo module{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; module.codeSize = sizeof(predicate_reduce_spirv); module.pCode = predicate_reduce_spirv; + const aftermath::ShaderName aftermath_name("(runtime) predicate_reduce"); ok = ok && fn("vkCreateShaderModule")(device_, &module, nullptr, &shader) == VK_SUCCESS; VkComputePipelineCreateInfo info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO}; diff --git a/runtime/src/vulkan_predicated_copy.h b/runtime/src/vulkan_predicated_copy.h index 6a225ced7b..1da4f8f6ae 100644 --- a/runtime/src/vulkan_predicated_copy.h +++ b/runtime/src/vulkan_predicated_copy.h @@ -10,6 +10,7 @@ #include #include #include "predicated_copy_spv.h" +#include "vulkan_aftermath.h" namespace leonida { struct PredicatedCopyDispatch { VkDescriptorSet set = VK_NULL_HANDLE; @@ -128,6 +129,7 @@ class PredicatedBufferCopier { ok = ok && fn("vkCreatePipelineLayout")(device_, &layout_info, nullptr, &layout) == VK_SUCCESS; VkShaderModuleCreateInfo module{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; module.codeSize = sizeof(predicated_copy_spirv); module.pCode = predicated_copy_spirv; + const aftermath::ShaderName aftermath_name("(runtime) predicated_copy"); ok = ok && fn("vkCreateShaderModule")(device_, &module, nullptr, &shader) == VK_SUCCESS; VkComputePipelineCreateInfo info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO}; diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h index f01167cf4a..d494233d3a 100644 --- a/runtime/src/vulkan_present.h +++ b/runtime/src/vulkan_present.h @@ -659,6 +659,8 @@ class VulkanPresenter { // is recreated next time, and the caller sees VK_SUCCESS, since its work was submitted. if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) { const auto shown = ++presented_; + submit_phases::totals().presents.fetch_add(1, std::memory_order_relaxed); // frames a second, phase line + submit_phases::totals().present_serial.fetch_add(1, std::memory_order_relaxed); if (dump_.due(shown - 1)) { // Presentation is already queued and the queue/tracker locks are released. A sampled frame // may stall here for its transfer fence and a private CPU copy. PNG and disk I/O run on a worker. diff --git a/runtime/src/vulkan_present_compose.h b/runtime/src/vulkan_present_compose.h index 3b2bb2b8ea..c71c060218 100644 --- a/runtime/src/vulkan_present_compose.h +++ b/runtime/src/vulkan_present_compose.h @@ -8,6 +8,7 @@ #include "vulkan_backend.h" #include "present_compose_spv.h" +#include "vulkan_aftermath.h" #include #include @@ -98,6 +99,7 @@ class PresentComposer { module_info.codeSize = sizeof(present_compose_spirv); module_info.pCode = present_compose_spirv; VkShaderModule module = VK_NULL_HANDLE; + const aftermath::ShaderName aftermath_name("(runtime) present_compose"); if (vk.vkCreateShaderModule(device, &module_info, nullptr, &module) != VK_SUCCESS) return false; VkComputePipelineCreateInfo pipeline_info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; pipeline_info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, diff --git a/runtime/src/vulkan_present_splash.h b/runtime/src/vulkan_present_splash.h index 9dd94a313e..affc9a92b2 100644 --- a/runtime/src/vulkan_present_splash.h +++ b/runtime/src/vulkan_present_splash.h @@ -44,9 +44,20 @@ inline VkResult VulkanPresenter::finish_startup_frame(Frame& frame, std::uint32_ if (result != VK_SUCCESS) return result; const bool ten_bit = format_ == VK_FORMAT_A2B10G10R10_UNORM_PACK32 || format_ == VK_FORMAT_A2R10G10B10_UNORM_PACK32; const std::uint32_t rgb = ten_bit ? 0x3fffffffu : 0xffffffu; + // Every 8th pixel of every 8th row: the capture is read back from host-visible memory, and reading all of it at + // every present while the title's frames are black took 75-90 % of the present thread under Proton and doubled + // the title's start-up (speed-3: 2 M pixels a present, under the submit lock). Content smaller than 8x8 pixels + // keeps the splash a few frames longer. const auto* pixels = reinterpret_cast(capture_ptr_); - const auto count = std::size_t(extent_.width) * extent_.height; - show_title = std::any_of(pixels, pixels + count, [rgb](auto pixel) { return (pixel & rgb) != 0; }); + show_title = false; + for (std::uint32_t y = 0; y < extent_.height && !show_title; y += 8) { + const std::uint32_t* row = pixels + std::size_t(y) * extent_.width; + for (std::uint32_t x = 0; x < extent_.width; x += 8) + if (row[x] & rgb) { + show_title = true; + break; + } + } VkSubmitInfo ready{VK_STRUCTURE_TYPE_SUBMIT_INFO}; ready.signalSemaphoreCount = 1; ready.pSignalSemaphores = &ready_[image]; diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index 6d1d60f033..e20a291057 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h @@ -34,6 +34,7 @@ // A list that needs a missing function fails with ReplayResult::unsupported before anything is written. #include "command_list.h" +#include "indirect_draw_stats.h" #include "deferred_image_binding.h" #include "vulkan_device_fault.h" #include "depth24.h" @@ -45,6 +46,8 @@ #include "vulkan_predicate.h" #include "vulkan_predicated_copy.h" #include "vulkan_indirect_dispatch_count.h" +#include "vulkan_indirect_clamp.h" +#include "xdxr_build.h" #include #include @@ -57,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -116,6 +120,7 @@ struct ResourceBinding { void* residency_owner = nullptr; bool (*ensure_residency)(void*) = nullptr; ResourceId depth_conversion = 0; // R32_FLOAT transfer image for a widened Xbox D16+S8 attachment + bool indirect_arguments = false; // the backing VkBuffer was created with INDIRECT_BUFFER usage }; struct VulkanAccess { @@ -662,13 +667,40 @@ class LayoutTracker { bool separate_depth_stencil_layouts() const { return separate_; } void track(ResourceId id, const ResourceBinding& resource, VkImageLayout layout) { + save(id); Entry entry{resource.mip_levels, resource.array_layers, two_planes(resource) ? 2u : 1u, separate_ && two_planes(resource), {}}; entry.layouts.assign(std::size_t(entry.mips) * entry.layers * (entry.two_planes ? 2 : 1), layout); entries_[id] = std::move(entry); } - void forget(ResourceId id) { entries_.erase(id); } + void forget(ResourceId id) { + save(id); + entries_.erase(id); + } + + // A submission records its layout changes into the tracker itself and undoes them when it does not reach the + // queue. Between begin() and commit()/rollback(), the first change to each image keeps its earlier state, so a + // rollback restores exactly what was there (the queue once copied the whole map, every image of the title, at + // each submission: ~20,000-30,000 entries and two allocations each, under tracker_mutex_). + void begin() { + journal_.clear(); + journaling_ = true; + } + void commit() { + journal_.clear(); + journaling_ = false; + } + void rollback() { + journaling_ = false; + for (auto& [id, old] : journal_) { + if (old) + entries_[id] = std::move(*old); + else + entries_.erase(id); + } + journal_.clear(); + } bool tracked(ResourceId id) const { return entries_.count(id) != 0; } // Current layout of one D3D12 subresource; UNDEFINED when the resource or index is unknown. @@ -711,6 +743,7 @@ class LayoutTracker { void set(ResourceId id, const VkImageSubresourceRange& range, VkImageLayout layout) { const auto it = entries_.find(id); if (it == entries_.end()) return; + if (journaling_ && !journal_.contains(id)) journal_.emplace(id, it->second); Entry& e = it->second; visit(e, range, [&](std::size_t index, VkImageAspectFlags, std::uint32_t, std::uint32_t) { e.layouts[index] = layout; @@ -745,8 +778,16 @@ class LayoutTracker { } } + void save(ResourceId id) { + if (!journaling_ || journal_.contains(id)) return; + const auto it = entries_.find(id); + journal_.emplace(id, it == entries_.end() ? std::optional() : std::optional(it->second)); + } + bool separate_; std::unordered_map entries_; + bool journaling_ = false; + std::unordered_map> journal_; // state before the open submission's first change }; // Each physical slot records one non-overlapping interval. Logical queries can share slots. @@ -840,6 +881,7 @@ struct GraphicsPipeline { bool large = false; // as ComputePipeline::large std::uint32_t samples = 1; // rasterizationSamples; every bound attachment must have this count bool async_build = false; + bool nonunit_vertex_divisor = false; // an actual instance divisor > 1, not a zero-stride emulation }; // The 144-byte push-constant block every translated shader declares: s0..s31, heap base, code base. @@ -1042,6 +1084,9 @@ struct ReplayFunctions { std::function compute_pipeline; PFN_vkCmdBindVertexBuffers2 bind_vertex_buffers2 = nullptr; // draws PFN_vkCmdBindIndexBuffer bind_index_buffer = nullptr; + // vkCmdBindIndexBuffer2KHR, installed only with maintenance5 and robustBufferAccess2 enabled. + // Spell out the signature so a build with pre-maintenance5 headers can still use the direct path. + void (VKAPI_PTR *bind_robust_index_view)(VkCommandBuffer, VkBuffer, VkDeviceSize, VkDeviceSize, VkIndexType) = nullptr; PFN_vkCmdSetViewport set_viewport = nullptr; PFN_vkCmdSetScissor set_scissor = nullptr; PFN_vkCmdSetViewportWithCount set_viewport_with_count = nullptr; @@ -1075,6 +1120,7 @@ struct ReplayFunctions { VkDeviceSize quad_indices_offset = 0; std::uint32_t quad_index_count = 0; std::uint64_t heap_base = 0; // device address of the GPU address arena (push-constant dwords 32-33) + std::uint64_t heap_size = 0; // its bytes (0: unknown) // Resolves available binary-occlusion queries to 64-bit 0/1 values, outside conditional rendering. std::function resolve_binary_occlusion; @@ -1097,6 +1143,10 @@ struct ReplayFunctions { PFN_vkCmdEndDebugUtilsLabelEXT end_label = nullptr; // ExecuteIndirect (Vulkan 1.0/1.2 core). PFN_vkCmdDrawIndirect draw_indirect = nullptr; + bool draw_indirect_first_instance = false; // enabled device feature, not just physical-device support + bool multi_draw_indirect = false; + bool draw_indirect_count_enabled = false; + std::uint32_t max_draw_indirect_count = 1; PFN_vkCmdDrawIndexedIndirect draw_indexed_indirect = nullptr; PFN_vkCmdDrawIndirectCount draw_indirect_count = nullptr; PFN_vkCmdDrawIndexedIndirectCount draw_indexed_indirect_count = nullptr; @@ -1114,6 +1164,14 @@ struct ReplayFunctions { std::function prepare_quad_indices; std::function emit_quad_indices; + // ExecuteIndirect arguments clamped on the GPU before the indirect command reads them (vulkan_indirect_clamp.h): + // `prepare_indirect_clamp` claims scratch for one call (arguments, their offset, count buffer, its offset, the + // IndirectKind, the argument stride and max_command_count), `emit_indirect_clamp` records its pass. Both unset, or + // LEONIDA_INDIRECT_CLAMP=0: the indirect command reads the application's argument buffer. + std::function prepare_indirect_clamp; + std::function emit_indirect_clamp; + bool require_indirect_clamp = false; // an enabled device refuses an indirect if scratch preparation fails // Optional VK_KHR_acceleration_structure: BuildRaytracingAccelerationStructure. PFN_vkCmdBuildAccelerationStructuresKHR build_acceleration_structures = nullptr; // A KHR TLAS built from D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS needs a pointer array whose entries are Vulkan @@ -1122,8 +1180,11 @@ struct ReplayFunctions { std::function prepare_khr_instances; // XDXR BVH4 builds (xdxr_build.h), used instead of the KHR ones when set: `xdxr_check` refuses inputs the builder // cannot read while the list is prepared, `xdxr_record` records the build. + // `xdxr_record` gets the title-memory table a TLAS build translates its instances' BLAS addresses with + // (`prepare_xdxr_table` stages it at prepare; a BLAS build gets an empty one). std::function xdxr_check; - std::function xdxr_record; + std::function xdxr_record; + std::function prepare_xdxr_table; // CopyRaytracingAccelerationStructure (CLONE, COMPACT) of XDXR structures: `bytes` is the room the destination // resource has; and one postbuild value (COMPACTED_SIZE, CURRENT_SIZE) of the structure at `src` to `dest`. std::function xdxr_copy; @@ -1214,6 +1275,7 @@ struct Prepared { PredicateCapture predicate; std::vector predicated_copy; CountedDispatch counted_dispatch; + ClampedIndirect indirect_clamp; // ExecuteIndirect: the clamped arguments the command reads, or null ResourceBinding binding; VkImageSubresourceRange range{}; // the barrier range, or the cleared view (cleared aspects only) VkImageView view = VK_NULL_HANDLE; @@ -1262,6 +1324,7 @@ struct Prepared { VkAccelerationStructureKHR accel_dst = VK_NULL_HANDLE; VkDeviceAddress khr_instances = 0; // staged ARRAY_OF_POINTERS instance list for a KHR TLAS; 0: use the VA directly std::uint64_t xdxr_bytes = 0; // CopyAccelerationStructure: the most bytes the copy may write + XdxrBlasTable xdxr_blases; // an XDXR TLAS build: how its instances' BLAS addresses are translated VkAccelerationStructureKHR accel_src = VK_NULL_HANDLE; std::uint32_t khr_postbuild = ~0u; // index into PreparedList::khr_postbuilds; ~0u: skipped or XDXR }; @@ -1311,6 +1374,10 @@ struct PreparedDraw { VkDeviceSize index_size = 0; // the bytes of the index buffer view inside its buffer; 0 with no index buffer VkIndexType index_type = VK_INDEX_TYPE_UINT16; QuadIndexExpansion quad_indices; // an indexed quad list: the triangle indices its draw binds instead + VkBuffer indirect_buffer = VK_NULL_HANDLE; + VkDeviceSize indirect_offset = 0; + VkBuffer indirect_count_buffer = VK_NULL_HANDLE; + VkDeviceSize indirect_count_offset = 0; VkExtent2D area{}; std::uint32_t layers = 1; // the fewest layers any bound attachment view has // The draw is dropped at emit: its pipeline, a vertex buffer or its index buffer could not be resolved (see @@ -1334,6 +1401,10 @@ struct PreparedDraw { index_size = 0; index_type = VK_INDEX_TYPE_UINT16; quad_indices = {}; + indirect_buffer = VK_NULL_HANDLE; + indirect_offset = 0; + indirect_count_buffer = VK_NULL_HANDLE; + indirect_count_offset = 0; area = {}; layers = 1; } @@ -2456,7 +2527,55 @@ namespace detail { // Resolves a draw's pipeline, attachments and buffers. Attachment views take the pipeline's formats, so a // typeless texture is viewed as the format the pipeline renders. template -ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunctions& vk, PreparedDraw& p) { +ReplayResult prepare_draw(const Draw& draw, const IndirectDrawArgs* arguments, Resolve&& resolve, + const ReplayFunctions& vk, PreparedDraw& p) { + if (arguments) { + const IndirectDrawArgs& arg = *arguments; + const VkDeviceSize record_size = draw.indexed ? sizeof(VkDrawIndexedIndirectCommand) : sizeof(VkDrawIndirectCommand); + if (!arg.argument_buffer || !arg.max_count || arg.stride < record_size || + (arg.stride | arg.argument_offset | arg.count_offset) % 4 || (!arg.count_buffer && arg.count_offset)) + return ReplayResult::invalid_indirect_arguments; + // No CPU peek or readback. VUID-countBuffer-02717 limits the *raw* uint32 at execution, + // independently of the supplied maxDrawCount. On a device with a smaller limit an + // arbitrary D3D12 count requires a GPU clamp pass; keep that case guarded for now. + const bool counted = arg.count_buffer != 0; + const bool entry_available = counted ? (draw.indexed ? vk.draw_indexed_indirect_count : vk.draw_indirect_count) != nullptr + : (draw.indexed ? vk.draw_indexed_indirect : vk.draw_indirect) != nullptr; + // The GPU supplies firstIndex/indexCount at execution (VUID-08798). A sized binding alone + // does not guarantee a robust fetch, and the legacy binding covers the backing buffer's tail. + const auto skip = [&](indirect_stats::Reason reason) { + indirect_stats::skip(indirect_stats::Event::replay_skip, reason); + p.skipped = true; + return ReplayResult::success; + }; + if (draw.mesh) return skip(indirect_stats::mesh); + if (draw.topology != 4) return skip(indirect_stats::topology); + if (!vk.draw_indirect_first_instance) return skip(indirect_stats::first_instance); + if (!entry_available) return skip(indirect_stats::entry); + if (draw.indexed && !vk.bind_robust_index_view) return skip(indirect_stats::robust_index); + if (arg.max_count > vk.max_draw_indirect_count) return skip(indirect_stats::count_limit); + if (!counted && arg.max_count > 1 && !vk.multi_draw_indirect) return skip(indirect_stats::multi_draw); + if (counted && !vk.draw_indirect_count_enabled) return skip(indirect_stats::count_feature); + if (counted && vk.max_draw_indirect_count != UINT32_MAX) return skip(indirect_stats::raw_count_limit); + const ResourceBinding* binding = resolve(arg.argument_buffer); + if (!binding || !binding->buffer) return unresolved_at(__LINE__); + // Both factors are uint32_t and the cast precedes multiplication; the last + // record only needs its payload, not trailing stride padding. + const VkDeviceSize bytes = VkDeviceSize(arg.max_count - 1) * arg.stride + record_size; + if (!indirect_range(*binding, arg.argument_offset, bytes)) return ReplayResult::invalid_indirect_arguments; + if (!binding->indirect_arguments) return skip(indirect_stats::argument_usage); + p.indirect_buffer = binding->buffer; + p.indirect_offset = binding->buffer_offset + arg.argument_offset; + if (counted) { + const ResourceBinding* count = resolve(arg.count_buffer); + if (!count || !count->buffer) return unresolved_at(__LINE__); + if (!indirect_range(*count, arg.count_offset, sizeof(std::uint32_t))) + return ReplayResult::invalid_indirect_arguments; + if (!count->indirect_arguments) return skip(indirect_stats::count_usage); + p.indirect_count_buffer = count->buffer; + p.indirect_count_offset = count->buffer_offset + arg.count_offset; + } + } if (!vk.graphics_pipeline || !vk.buffer_at || !vk.image_view || !vk.begin_rendering || !vk.end_rendering || !vk.bind_vertex_buffers2 || !vk.bind_index_buffer || !vk.set_viewport || !vk.set_scissor || !vk.set_primitive_topology || !vk.set_primitive_restart_enable || !vk.set_stencil_reference || @@ -2466,6 +2585,11 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct const GraphicsPipeline* pipeline = vk.graphics_pipeline(draw.pipeline); // A null pipeline with a variant builder is one built at its first draw: variant 0 (all slots bound). if (!pipeline || (!pipeline->pipeline && !pipeline->variant)) return unresolved_at(__LINE__); + if (arguments && pipeline->nonunit_vertex_divisor) { + indirect_stats::skip(indirect_stats::Event::replay_skip, indirect_stats::divisor); + p.skipped = true; + return ReplayResult::success; + } if (pipeline->mesh != draw.mesh) return ReplayResult::invalid_draw; if (draw.mesh && !vk.draw_mesh_tasks) return unsupported_at(__LINE__); if (pipeline->viewport_with_count && (!vk.set_viewport_with_count || !vk.set_scissor_with_count)) @@ -2547,6 +2671,7 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct } else { p.pipeline = pipeline->variant ? pipeline->variant(unbound) : VK_NULL_HANDLE; if (!p.pipeline && pipeline->async_build && !strict_replay()) { + if (arguments) indirect_stats::skip(indirect_stats::Event::replay_skip, indirect_stats::pending_pipeline); p.skipped = true; return ReplayResult::success; } @@ -2592,6 +2717,13 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct if (!draw.indexed && !draw.mesh && draw.topology == topology_quad_list && !vk.quad_indices) return unresolved_at(__LINE__); if (draw.indexed) { + if (arguments && (!draw.index.va || (draw.index.format != 57 && draw.index.format != 42) || + draw.index.size < (draw.index.format == 57 ? 2u : 4u) || + !within(draw.index.va, draw.index.size, UINT64_MAX))) { + indirect_stats::skip(indirect_stats::Event::replay_skip, indirect_stats::index_view); + p.skipped = true; + return ReplayResult::success; + } if (draw.index.format == 57) p.index_type = VK_INDEX_TYPE_UINT16; else if (draw.index.format == 42) p.index_type = VK_INDEX_TYPE_UINT32; else if (draw.index.va) return unsupported_at(__LINE__); @@ -2613,6 +2745,13 @@ ReplayResult prepare_draw(const Draw& draw, Resolve&& resolve, const ReplayFunct } } p.index_size = size; + if (arguments && (!p.index_buffer || size < draw.index.size || + !within(p.index_offset, draw.index.size, UINT64_MAX) || + p.index_offset % (draw.index.format == 57 ? 2u : 4u))) { + indirect_stats::skip(indirect_stats::Event::replay_skip, indirect_stats::index_range); + p.skipped = true; + return ReplayResult::success; + } } } return ReplayResult::success; @@ -2866,13 +3005,13 @@ inline void plan_statistics_segments(PreparedList& out) { const auto commands = out.list->commands(); for (std::size_t i = 0; i < out.commands.size(); ++i) { auto& p = out.commands[i]; - if (begin && has_helper_dispatch(out, i)) { + if (begin && (has_helper_dispatch(out, i) || p.indirect_clamp.buffer)) { inner.push_back({&p.statistics_end, &p.statistics_begin, -1}); splits = true; } if (begin) { int kind = -1; - if (const auto* draw = std::get_if(&commands[i])) kind = draw->mesh ? 1 : 0; + if (const auto* draw = draw_command(commands[i]).state) kind = draw->mesh ? 1 : 0; else if (const auto* indirect = std::get_if(&commands[i])) kind = indirect->kind == IndirectKind::dispatch ? -1 : 0; if (kind >= 0) inner.push_back({&p.statistics_end, &p.statistics_begin, kind}); @@ -2928,8 +3067,8 @@ inline void plan_statistics_segments(PreparedList& out) { } // Overlapping pipeline-statistics queries (D3D-252): the same physical-segment layout the occlusion planner -// builds, in the statistics pool. Each Begin and End of a statistics query — and every non-timestamp resolve -// while one runs, because its helper dispatch would be counted — closes the one open physical query and opens +// builds, in the statistics pool. Each Begin and End of a statistics query — and every non-timestamp resolve +// while one runs, because its helper dispatch would be counted — closes the one open physical query and opens // a new one, so each logical query keeps a contiguous slot range and its result is the sum of that range // (statistics_sum.comp). A Begin or End of another query kind leaves the segments alone. inline ReplayResult plan_overlapping_statistics_segments(PreparedList& out) { @@ -2957,10 +3096,17 @@ inline ReplayResult plan_overlapping_statistics_segments(PreparedList& out) { p.statistics_end = current; current = open(); p.statistics_begin = current; + } else if (!active.empty() && p.indirect_clamp.buffer) { + p.statistics_end = current; + current = open(); + p.statistics_begin = current; + // A clamped draw is also the first vertex draw of this segment. + if (draw_command(commands[i]).state) kind = 0; + continue; } // A draw of the other kind than the open segment's starts a segment in its own pool (D3D-291). int draw = -1; - if (const auto* d = std::get_if(&commands[i])) draw = d->mesh ? 1 : 0; + if (const auto* d = draw_command(commands[i]).state) draw = d->mesh ? 1 : 0; else if (const auto* indirect = std::get_if(&commands[i])) draw = indirect->kind == IndirectKind::dispatch ? -1 : 0; if (!active.empty() && draw >= 0) { @@ -3098,6 +3244,7 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun // segment pool, and overlapping statistics split into the statistics pool (D3D-252); a physical query of a // type is still open at most once at any point, because each event closes the one open slot and opens a new // one. The occlusion kinds share their D3D12 heap, statistics have their own, so their states are separate. + VkDeviceAddress indirect_list_budget = 0; std::size_t ordinary_active = 0, binary_active = 0, statistics_active_count = 0; bool overlaps = false, statistics_overlaps = false, statistics_active = false; out.wrote_readback = false; @@ -3400,6 +3547,20 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun } // A depth plane footprint of a D24 texture stored as D32: words of 24-bit UNORM, floats in the image. const bool upload = texture_copy->src.footprint; + // Diagnostic: a texture-to-buffer copy into a buffer whose GPU writes are not handed back (a slot-133 + // shadow: host bytes but not host_readable). The title would read zeros in its own memory there + // (upstream's GPU-to-title read-back case). + if (result == ReplayResult::success && !upload && p.binding.buffer && p.binding.host && + !p.binding.host_readable) { + static std::atomic one_way{0}; + const std::uint64_t n = one_way.fetch_add(1, std::memory_order_relaxed) + 1; + if (n <= 8 || !(n & (n - 1))) + std::fprintf(stderr, "[rt] replay: texture copy into a one-way shadow buffer (title va 0x%llx, " + "%llu bytes; %llu so far): the title does not see these texels\n", + static_cast(p.binding.va), + static_cast(p.binding.size), + static_cast(n)); + } const ResourceBinding& image = upload ? p.binding : p.source; if (result == ReplayResult::success && texture_copy->tile_footprint && !p.buffer_image_copies.empty()) { const auto& region = p.buffer_image_copies.front(); @@ -3668,24 +3829,6 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun if (!detail::indirect_range(*cnt, ind->count_offset, sizeof(std::uint32_t))) return ReplayResult::invalid_indirect_arguments; p.source = *cnt; - if (ind->kind == IndirectKind::dispatch) { - // Vulkan lacks vkCmdDispatchIndirectCount. Copy the GPU-visible commands to private scratch - // and replace commands past min(count, max_count) with zero-group dispatches. - if (!ind->pipeline || !vk.dispatch_indirect || !vk.prepare_counted_dispatch || - !vk.emit_counted_dispatch || (statistics_active && !statistics_helpers) || - !vk.prepare_counted_dispatch(p.binding.buffer, p.binding.buffer_offset + ind->argument_offset, - p.source.buffer, p.source.buffer_offset + ind->count_offset, - ind->stride, ind->max_count, p.counted_dispatch)) - return unsupported_at(__LINE__); - } else if ((ind->kind == IndirectKind::draw && !vk.draw_indirect_count) || - (ind->kind == IndirectKind::draw_indexed && !vk.draw_indexed_indirect_count)) { - return unsupported_at(__LINE__); - } - } else { - if ((ind->kind == IndirectKind::draw && !vk.draw_indirect) || - (ind->kind == IndirectKind::draw_indexed && !vk.draw_indexed_indirect) || - (ind->kind == IndirectKind::dispatch && !vk.dispatch_indirect)) - return unsupported_at(__LINE__); } if (ind->kind == IndirectKind::dispatch && ind->pipeline) { // the pipeline and root arguments it was recorded if (!vk.bind_pipeline || !vk.push_constants || !vk.compute_pipeline) return unsupported_at(__LINE__); @@ -3698,10 +3841,43 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun if (!found) return unresolved_at(__LINE__); if (pipeline->bindless_set && !vk.bind_descriptor_sets) return unsupported_at(__LINE__); } + if (ind->kind == IndirectKind::dispatch && vk.require_indirect_clamp) { + if (!ind->pipeline || !vk.dispatch_indirect || !vk.prepare_indirect_clamp || !vk.emit_indirect_clamp || + (statistics_active && !statistics_helpers) || + !vk.prepare_indirect_clamp(p.binding.buffer, p.binding.buffer_offset + ind->argument_offset, + p.source.buffer, p.source.buffer_offset + ind->count_offset, indirect_clamp_dispatch, + ind->stride, ind->max_count, p.indirect_clamp)) + return unsupported_at(__LINE__); + p.indirect_clamp.share_list_budget(indirect_list_budget); + } else if (ind->kind == IndirectKind::dispatch && (ind->count_buffer || indirect_group_budget())) { + // Vulkan lacks vkCmdDispatchIndirectCount. Copy the GPU-visible commands to private scratch + // and replace commands past min(count, max_count) with zero-group dispatches. + if (!ind->pipeline || !vk.dispatch_indirect || !vk.prepare_counted_dispatch || + !vk.emit_counted_dispatch || (statistics_active && !statistics_helpers) || + !vk.prepare_counted_dispatch(p.binding.buffer, p.binding.buffer_offset + ind->argument_offset, + p.source.buffer, p.source.buffer_offset + ind->count_offset, + ind->stride, ind->max_count, p.counted_dispatch)) + return unsupported_at(__LINE__); + } else if (ind->kind == IndirectKind::dispatch && !vk.dispatch_indirect) { + return unsupported_at(__LINE__); + } + // Legacy graphics IR carries no graphics state. Validate its resource ranges above, + // but never emit it; stateful graphics indirects use Draw and its rendering scope. } else if (const auto* build = std::get_if(&command)) { p.khr_instances = 0; if (vk.xdxr_check) { if (!vk.xdxr_check(*build)) return unsupported_at(__LINE__); + p.xdxr_blases = {}; + if (build->is_tlas && build->instance_count) { + // The BLAS addresses in the instance descs are the title's: in its own memory they are reached + // through the copies the layer made, and past the arena through nothing (xdxr_build.comp). + p.xdxr_blases.translate = true; + p.xdxr_blases.bound = vk.heap_size; + if (vk.prepare_xdxr_table) { + const ReplayResult staged = vk.prepare_xdxr_table(p.xdxr_blases.address, p.xdxr_blases.count); + if (staged != ReplayResult::success) return staged; + } + } } else { if (!vk.build_acceleration_structures || !vk.resolve_acceleration_structure) return unsupported_at(__LINE__); @@ -3718,14 +3894,16 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun } } else if (const auto* copy = std::get_if(&command)) { if (vk.xdxr_copy) { - // XDXR structures: the destination's room bounds the copy, as the size is only known to the GPU. + // XDXR structures: the destination's room bounds the copy, as the size is only known to the GPU. A + // side the layer resolved into a copy of the title's memory brings its room (CopyAccelerationStructure). if (!vk.buffer_at || copy->mode > 1) return unsupported_at(__LINE__); - std::uint64_t room = ~std::uint64_t(0); + std::uint64_t room = copy->dst_room ? copy->dst_room : ~std::uint64_t(0); VkBuffer buffer = VK_NULL_HANDLE; VkDeviceSize offset = 0; - if (!vk.buffer_at(copy->dst_va, room, buffer, offset)) return unresolved_at(__LINE__); - std::uint64_t source = ~std::uint64_t(0); - if (!vk.buffer_at(copy->src_va, source, buffer, offset)) return unresolved_at(__LINE__); + if (!copy->dst_room && !vk.buffer_at(copy->dst_va, room, buffer, offset)) return unresolved_at(__LINE__); + std::uint64_t source = copy->src_room ? copy->src_room : ~std::uint64_t(0); + if (!copy->src_room && !vk.buffer_at(copy->src_va, source, buffer, offset)) + return unresolved_at(__LINE__); p.xdxr_bytes = std::min(room, source); } else { if (vk.queue_stages == detail::queue_stages_copy || !vk.copy_acceleration_structure || @@ -3740,10 +3918,11 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun } else if (const auto* info = std::get_if(&command)) { if (vk.xdxr_postbuild) { if (!vk.buffer_at || (info->type != 0 && info->type != 3)) return unsupported_at(__LINE__); - std::uint64_t room = 8 * info->sources.size(); + std::uint64_t room = info->dest_room ? info->dest_room : 8 * info->sources.size(); VkBuffer buffer = VK_NULL_HANDLE; VkDeviceSize offset = 0; - if (!vk.buffer_at(info->dest_va, room, buffer, offset)) return unresolved_at(__LINE__); + if (!info->dest_room && !vk.buffer_at(info->dest_va, room, buffer, offset)) + return unresolved_at(__LINE__); if (room < 8 * info->sources.size()) return ReplayResult::invalid_copy; if (!info->sources.empty()) { // dest_va is resolved by VA and may target a host-readable buffer; XDXR postbuild writes from compute. @@ -3808,21 +3987,36 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun continue; } if (pipeline->bindless_set && !vk.bind_descriptor_sets) return unsupported_at(__LINE__); - } else if (const auto* draw = std::get_if(&command)) { + } else if (const auto draw = draw_command(command); draw.state) { if (out.draw_count == out.draws.size()) out.draws.emplace_back(); auto& prepared_draw = out.draws[out.draw_count]; prepared_draw.reset(); p.draw = std::uint32_t(out.draw_count++); - if (const auto r = detail::prepare_draw(*draw, resolve, vk, prepared_draw); r != ReplayResult::success) { + if (const auto r = detail::prepare_draw(*draw.state, draw.arguments, resolve, vk, prepared_draw); + r != ReplayResult::success) { const bool strict = strict_replay(); if (r != ReplayResult::unresolved_resource || strict) return r; prepared_draw.skipped = true; // dropped at emit (see the dispatch branch above) - } else if (draw->indexed && !draw->mesh && draw->topology == topology_quad_list) { + } else if (draw.state->indexed && !draw.state->mesh && draw.state->topology == topology_quad_list) { // The index expansion is a helper dispatch: inside a statistics query it needs the segment pool. - if (statistics_active && !statistics_helpers && draw->count >= 4) return ReplayResult::unsupported; - if (const auto r = detail::prepare_quad_indices(*draw, vk, prepared_draw); r != ReplayResult::success) + if (statistics_active && !statistics_helpers && draw.state->count >= 4) return ReplayResult::unsupported; + if (const auto r = detail::prepare_quad_indices(*draw.state, vk, prepared_draw); r != ReplayResult::success) return r; } + if (draw.arguments && !prepared_draw.skipped && vk.require_indirect_clamp) { + const auto& arg = *draw.arguments; + if (!vk.prepare_indirect_clamp || !vk.emit_indirect_clamp || (statistics_active && !statistics_helpers) || + !vk.prepare_indirect_clamp(prepared_draw.indirect_buffer, prepared_draw.indirect_offset, + prepared_draw.indirect_count_buffer, prepared_draw.indirect_count_offset, + draw.state->indexed ? indirect_clamp_draw_indexed : indirect_clamp_draw, + arg.stride, arg.max_count, p.indirect_clamp)) + return unsupported_at(__LINE__); + p.indirect_clamp.share_list_budget(indirect_list_budget); + prepared_draw.indirect_buffer = p.indirect_clamp.buffer; + prepared_draw.indirect_offset = p.indirect_clamp.offset; + prepared_draw.indirect_count_buffer = p.indirect_clamp.count_buffer; + prepared_draw.indirect_count_offset = p.indirect_clamp.count_offset; + } } } if (ordinary_active || binary_active) return ReplayResult::invalid_query; @@ -4125,6 +4319,7 @@ inline void emit_commands(const PreparedList& prepared, VkCommandBuffer command_ for (std::size_t i = 0; i < commands.size(); ++i) { const auto& command = commands[i]; const auto& p = prepared.commands[i]; + const auto raster = draw_command(command); if (next_query < prepared.queries.size() && prepared.queries[next_query].command == i) { if constexpr (Checkpoints) if (std::holds_alternative(command)) @@ -4143,9 +4338,15 @@ inline void emit_commands(const PreparedList& prepared, VkCommandBuffer command_ // draw's own rendering scope begins. The index expansion of an indexed quad list runs here too: outside the // rendering scope, and between the segments so that no query counts its dispatch (D3D-162). It stays inside // the predicate, which skips it together with its draw. - if (std::holds_alternative(command) || std::holds_alternative(command)) { + if (p.indirect_clamp.buffer) { + end_statistics(); + if (predicate.buffer) vk.end_conditional_rendering(command_buffer); + vk.emit_indirect_clamp(command_buffer, p.indirect_clamp); + if (predicate.buffer) vk.begin_conditional_rendering(command_buffer, &predicate); + begin_statistics(); + } else if (!p.counted_dispatch.indirect && (raster.state || std::holds_alternative(command))) { end_statistics(); - if (std::holds_alternative(command) && prepared.draws[p.draw].quad_indices.buffer) + if (raster.state && prepared.draws[p.draw].quad_indices.buffer) vk.emit_quad_indices(command_buffer, prepared.draws[p.draw].quad_indices); begin_statistics(); } @@ -4728,64 +4929,47 @@ inline void emit_commands(const PreparedList& prepared, VkCommandBuffer command_ VK_PIPELINE_STAGE_TRANSFER_BIT); vk.copy_buffer(command_buffer, p.source.buffer, p.binding.buffer, 1, p.buffer_copies.data()); } else if (const auto* ind = std::get_if(&command)) { - if (ind->kind == IndirectKind::dispatch && ind->pipeline && !p.pipeline.pipeline && - (p.pipeline.async_build || p.pipeline.skipped)) + if (ind->kind != IndirectKind::dispatch) { + indirect_stats::skip(indirect_stats::Event::replay_skip, indirect_stats::stateless); continue; - if constexpr (Checkpoints) { - if (ind->kind == IndirectKind::dispatch) - checkpoints->dispatch(command_buffer, i, p.pipeline.pipeline, ind->pipeline, ind->user_data, {}, true, - ind->argument_buffer, ind->argument_offset, ind->count_buffer, - ind->count_offset, ind->max_count, ind->stride); - else - checkpoints->record(command_buffer, i, CheckpointKind::draw); } + if (ind->pipeline && !p.pipeline.pipeline && (p.pipeline.async_build || p.pipeline.skipped)) continue; + if constexpr (Checkpoints) + checkpoints->dispatch(command_buffer, i, p.pipeline.pipeline, ind->pipeline, ind->user_data, {}, true, + ind->argument_buffer, ind->argument_offset, ind->count_buffer, + ind->count_offset, ind->max_count, ind->stride); const VkDeviceSize arguments = p.binding.buffer_offset + ind->argument_offset; - if (ind->count_buffer && ind->kind != IndirectKind::dispatch) { - const VkDeviceSize count = p.source.buffer_offset + ind->count_offset; - if (ind->kind == IndirectKind::draw) { - vk.draw_indirect_count(command_buffer, p.binding.buffer, arguments, p.source.buffer, - count, ind->max_count, ind->stride); - } else if (ind->kind == IndirectKind::draw_indexed) { - vk.draw_indexed_indirect_count(command_buffer, p.binding.buffer, arguments, - p.source.buffer, count, ind->max_count, ind->stride); - } - } else { - if (ind->kind == IndirectKind::draw) { - vk.draw_indirect(command_buffer, p.binding.buffer, arguments, ind->max_count, ind->stride); - } else if (ind->kind == IndirectKind::draw_indexed) { - vk.draw_indexed_indirect(command_buffer, p.binding.buffer, arguments, ind->max_count, ind->stride); - } else if (ind->kind == IndirectKind::dispatch) { - if (ind->count_buffer) { - // No D3D12 query must count this internal compute pass as an application dispatch. - end_statistics(); - vk.emit_counted_dispatch(command_buffer, p.counted_dispatch); - begin_statistics(); - } - if (ind->pipeline) { - ShaderUserData data{}; - std::copy(ind->user_data.begin(), ind->user_data.end(), data.s); - data.heap_base = vk.heap_base; - data.code_base = p.pipeline.code_base; - vk.bind_pipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.pipeline); - if (p.pipeline.bindless_set) { - const VkDescriptorSet set0 = vk.bindless_set ? vk.bindless_set : p.pipeline.bindless_set; - vk.bind_descriptor_sets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.layout, 0, - 1, &set0, 0, nullptr); - } - vk.push_constants(command_buffer, p.pipeline.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(data), - &data); - } - for (std::uint32_t k = 0; k < ind->max_count; ++k) { - vk.dispatch_indirect(command_buffer, - ind->count_buffer ? p.counted_dispatch.indirect : p.binding.buffer, - (ind->count_buffer ? p.counted_dispatch.offset + VkDeviceSize(k) * 12 - : arguments + VkDeviceSize(k) * ind->stride)); - } + if (p.counted_dispatch.indirect) { + // No D3D12 query must count this internal compute pass as an application dispatch. + end_statistics(); + vk.emit_counted_dispatch(command_buffer, p.counted_dispatch); + begin_statistics(); + } + if (ind->pipeline) { + ShaderUserData data{}; + std::copy(ind->user_data.begin(), ind->user_data.end(), data.s); + data.heap_base = vk.heap_base; + data.code_base = p.pipeline.code_base; + vk.bind_pipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.pipeline); + if (p.pipeline.bindless_set) { + const VkDescriptorSet set0 = vk.bindless_set ? vk.bindless_set : p.pipeline.bindless_set; + vk.bind_descriptor_sets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, p.pipeline.layout, 0, + 1, &set0, 0, nullptr); } + vk.push_constants(command_buffer, p.pipeline.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(data), + &data); + } + for (std::uint32_t k = 0; k < ind->max_count; ++k) { + vk.dispatch_indirect(command_buffer, + p.indirect_clamp.buffer ? p.indirect_clamp.buffer : + p.counted_dispatch.indirect ? p.counted_dispatch.indirect : p.binding.buffer, + (p.indirect_clamp.buffer ? p.indirect_clamp.offset + VkDeviceSize(k) * p.indirect_clamp.stride + : p.counted_dispatch.indirect ? p.counted_dispatch.offset + VkDeviceSize(k) * 12 + : arguments + VkDeviceSize(k) * ind->stride)); } } else if (const auto* xdxr_build = std::get_if(&command); xdxr_build && vk.xdxr_record) { - vk.xdxr_record(command_buffer, *xdxr_build); + vk.xdxr_record(command_buffer, *xdxr_build, p.xdxr_blases); } else if (const auto* copy = std::get_if(&command)) { if constexpr (Checkpoints) checkpoints->record(command_buffer, i, CheckpointKind::copy); if (vk.xdxr_copy) { @@ -4899,7 +5083,8 @@ inline void emit_commands(const PreparedList& prepared, VkCommandBuffer command_ } vk.push_constants(command_buffer, p.pipeline.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(data), &data); vk.dispatch(command_buffer, dispatch->x, dispatch->y, dispatch->z); - } else if (const auto* draw = std::get_if(&command)) { + } else if (raster.state) { + const Draw* draw = raster.state; const detail::PreparedDraw& d = prepared.draws[p.draw]; if (d.skipped) continue; // could not be resolved in prepare: dropped if constexpr (Checkpoints) @@ -5016,7 +5201,25 @@ inline void emit_commands(const PreparedList& prepared, VkCommandBuffer command_ vk.bind_vertex_buffers2(command_buffer, slot, 1, &d.vertex_buffers[slot], &d.vertex_offsets[slot], &d.vertex_sizes[slot], &d.vertex_strides[slot]); } - if (draw->mesh) { + if (raster.arguments) { + indirect_stats::note(indirect_stats::Event::emitted); + const auto& arg = *raster.arguments; + if (draw->indexed) { + // Bind only complete indices in the captured D3D12 view, never any trailing storage. + const VkDeviceSize width = d.index_type == VK_INDEX_TYPE_UINT16 ? 2 : 4; + const VkDeviceSize bytes = draw->index.size - draw->index.size % width; + vk.bind_robust_index_view(command_buffer, d.index_buffer, d.index_offset, bytes, d.index_type); + } + const auto stride = p.indirect_clamp.buffer ? p.indirect_clamp.stride : arg.stride; + if (arg.count_buffer) { + const auto emit_counted = draw->indexed ? vk.draw_indexed_indirect_count : vk.draw_indirect_count; + emit_counted(command_buffer, d.indirect_buffer, d.indirect_offset, d.indirect_count_buffer, + d.indirect_count_offset, arg.max_count, stride); + } else { + const auto emit_fixed = draw->indexed ? vk.draw_indexed_indirect : vk.draw_indirect; + emit_fixed(command_buffer, d.indirect_buffer, d.indirect_offset, arg.max_count, stride); + } + } else if (draw->mesh) { vk.draw_mesh_tasks(command_buffer, draw->count, draw->instances, draw->first); if (vk.mesh_draw_count) ++*vk.mesh_draw_count; } else if (draw->topology == topology_quad_list) { diff --git a/runtime/src/vulkan_scratch.h b/runtime/src/vulkan_scratch.h index 753701e1c4..3e6a8eab8d 100644 --- a/runtime/src/vulkan_scratch.h +++ b/runtime/src/vulkan_scratch.h @@ -1,7 +1,8 @@ // Scratch buffers that live until the submission that used them has completed: device-local chunks handed out // while a list is prepared, retired with the submission's timeline value, and reused (or freed) once the GPU is past // it. The replay stages copies Vulkan cannot do in one command through them (vulkan_replay.h, depth <-> colour -// copies). Single-threaded: the caller holds the context's lock. The same life cycle as the depth24 converter's own +// copies), and the ExecuteIndirect argument clamp keeps its record scratch in one too (vulkan_indirect_clamp.h). +// Single-threaded: the caller holds the context's lock. The same life cycle as the depth24 converter's own // scratch (vulkan_depth24.h), which also needs descriptor pools and exists only on GPUs without D24. // The chunks are transfer sources and destinations; `extra_usage` adds what another user needs (the expanded indices // of quad lists, quad_index_expand.h: an index buffer written through its device address). @@ -27,12 +28,28 @@ class ScratchBuffers { public: // A device-local allocation for a chunk; null on failure. using Allocate = std::function; + // What the copy staging needs: transfer both ways. + static constexpr VkBufferUsageFlags transfer_usage = + VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + // Legacy copy-scratch constructor. `extra_usage` is added to the transfer usage, and + // `families` keeps retired chunks shareable across queue families. ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate, VkBufferUsageFlags extra_usage = 0, std::vector families = {}, DeviceFaultDiagnostics* diagnostics = nullptr) - : device_(device), diagnostics_(diagnostics), allocate_(std::move(allocate)), extra_usage_(extra_usage), - families_(std::move(families)) { - loaded_ = vk_.load(get, device); + : device_(device), diagnostics_(diagnostics), allocate_(std::move(allocate)), + usage_(transfer_usage | extra_usage), families_(std::move(families)) { + loaded_ = vk_.load(get, device, false); + addressable_ = (usage_ & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) && vk_.vkGetBufferDeviceAddress; + } + + // `usage` is what the chunks are created with. A chunk that declares VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT + // gets its device address from get() as well, and its memory must have been allocated with + // VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT (the allocate callback's job). + ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate, + DeviceFaultDiagnostics* diagnostics, VkBufferUsageFlags usage) + : device_(device), diagnostics_(diagnostics), allocate_(std::move(allocate)), usage_(usage), + addressable_((usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) != 0) { + loaded_ = vk_.load(get, device, addressable_); } ~ScratchBuffers() { @@ -48,36 +65,14 @@ class ScratchBuffers { bool loaded() const { return loaded_; } - // `bytes` of transfer scratch for the next submission, at a 256-byte aligned offset (more than any copy needs). + // `bytes` of scratch for the next submission, at a 256-byte aligned offset (more than any copy needs). bool get(std::uint64_t bytes, VkBuffer& buffer, VkDeviceSize& offset) { - constexpr VkDeviceSize alignment = 256, minimum = 4u << 20; - if (!loaded_ || !bytes) return false; - for (auto& chunk : current_.chunks) { - const VkDeviceSize rem = chunk.used % alignment; - const VkDeviceSize pad = rem ? alignment - rem : 0; - if (pad <= chunk.size - chunk.used) { - const VkDeviceSize start = chunk.used + pad; - if (bytes <= chunk.size - start) { - chunk.used = start + bytes; - buffer = chunk.buffer; - offset = start; - return true; - } - } - } - Chunk chunk; - for (std::size_t i = 0; i < spare_.size(); ++i) - if (spare_[i].size >= bytes) { - chunk = spare_[i]; - spare_.erase(spare_.begin() + std::ptrdiff_t(i)); - break; - } - if (!chunk.buffer && !make_chunk(std::max(bytes, minimum), chunk)) return false; - chunk.used = bytes; - buffer = chunk.buffer; - offset = 0; - current_.chunks.push_back(chunk); - return true; + return claim(bytes, buffer, offset, nullptr); + } + + // The same for chunks created with a device address: `address` is the device address of the returned offset. + bool get(std::uint64_t bytes, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceAddress& address) { + return claim(bytes, buffer, offset, &address); } // The chunks handed out since the last call belong to a submission that `timeline` reaches `ticket` for @@ -145,8 +140,9 @@ class ScratchBuffers { #define LEONIDA_SCRATCH_MEMBER(name) PFN_##name name = nullptr; LEONIDA_SCRATCH_FUNCTIONS(LEONIDA_SCRATCH_MEMBER) #undef LEONIDA_SCRATCH_MEMBER + PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress = nullptr; // optional: addressable pools only - bool load(PFN_vkGetDeviceProcAddr get, VkDevice device) { + bool load(PFN_vkGetDeviceProcAddr get, VkDevice device, bool addressable) { bool all = true; #define LEONIDA_SCRATCH_LOAD(name) \ name = reinterpret_cast(get(device, #name)); \ @@ -154,14 +150,58 @@ class ScratchBuffers { LEONIDA_SCRATCH_FUNCTIONS(LEONIDA_SCRATCH_LOAD) #undef LEONIDA_SCRATCH_LOAD #undef LEONIDA_SCRATCH_FUNCTIONS - return all; + // Only an addressable pool (the indirect clamp's) needs the addresses: a Vulkan 1.0/1.1 device without + // bufferDeviceAddress keeps the transfer scratch. + this->vkGetBufferDeviceAddress = + reinterpret_cast(get(device, "vkGetBufferDeviceAddress")); + return all && (!addressable || this->vkGetBufferDeviceAddress != nullptr); } }; + // Hands out `bytes` from this submission's chunks, making a new chunk where none fits. + bool claim(std::uint64_t bytes, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceAddress* address) { + constexpr VkDeviceSize alignment = 256, minimum = 4u << 20; + if (!loaded_ || !bytes) return false; + if (address && !addressable_) return false; + for (auto& chunk : current_.chunks) { + const VkDeviceSize rem = chunk.used % alignment; + const VkDeviceSize pad = rem ? alignment - rem : 0; + if (pad > chunk.size - chunk.used) continue; + const VkDeviceSize start = chunk.used + pad; + if (bytes <= chunk.size - start) { + chunk.used = start + bytes; + buffer = chunk.buffer; + offset = start; + if (address) *address = device_address(chunk.buffer) + start; + return true; + } + } + Chunk chunk; + for (std::size_t i = 0; i < spare_.size(); ++i) + if (spare_[i].size >= bytes) { + chunk = spare_[i]; + spare_.erase(spare_.begin() + std::ptrdiff_t(i)); + break; + } + if (!chunk.buffer && !make_chunk(std::max(bytes, minimum), chunk)) return false; + chunk.used = bytes; + buffer = chunk.buffer; + offset = 0; + current_.chunks.push_back(chunk); + if (address) *address = device_address(buffer); + return true; + } + + VkDeviceAddress device_address(VkBuffer buffer) const { + VkBufferDeviceAddressInfo info{VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO}; + info.buffer = buffer; + return vk_.vkGetBufferDeviceAddress(device_, &info); + } + bool make_chunk(std::uint64_t size, Chunk& out) { VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; info.size = size; - info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | extra_usage_; + info.usage = usage_; // A retired chunk can be reused by a submission on a different queue family. share_across_queue_families(info, families_); if (vk_.vkCreateBuffer(device_, &info, nullptr, &out.buffer) != VK_SUCCESS) return false; @@ -188,8 +228,9 @@ class ScratchBuffers { VkDevice device_; DeviceFaultDiagnostics* diagnostics_; Allocate allocate_; - VkBufferUsageFlags extra_usage_ = 0; + VkBufferUsageFlags usage_ = transfer_usage; std::vector families_; + bool addressable_ = false; Functions vk_; bool loaded_ = false; Batch current_; // handed out, not yet submitted diff --git a/runtime/src/xdxr_build.comp b/runtime/src/xdxr_build.comp index 22a3a1334b..dcbeca14db 100644 --- a/runtime/src/xdxr_build.comp +++ b/runtime/src/xdxr_build.comp @@ -84,7 +84,7 @@ const uint INVALID = 0xffffffffu; const uint TRI0 = 0u, TRI1 = 1u, BOX16 = 4u, BOX32 = 5u, INSTANCE = 6u; const uint LEAF = 0x80000000u; // a binary child that is a sorted element, not an inner node const uint REMAP_IDENTITY = 0x09u; -const uint FLAG_TLAS = 1u, FLAG_BOX16 = 2u, FLAG_PAIR = 4u; // pc.flags; xdxr_build.h XdxrBuilder flag_* +const uint FLAG_TLAS = 1u, FLAG_BOX16 = 2u, FLAG_PAIR = 4u, FLAG_TRANSLATE = 8u; // pc.flags; xdxr_build.h flag_* const uint FLAG_BOTTOM_LEVEL = 0x80000000u, VERSION_2403 = 6u, INST_IDENTITY_ROTATION = 0x80000000u, INST_FLAGS_MASK = 0xc0000000u; @@ -92,14 +92,14 @@ layout(push_constant) uniform Push { uvec2 dst; // the acceleration structure (header at byte 0) uvec2 scratch; // xdxr_build.h XdxrLayout scratch words uvec2 src0; // triangles: vertices; instances: the instance descs - uvec2 src1; // triangles: indices (0 = none) - uvec2 src2; // triangles: 3x4 transform (0 = none) + uvec2 src1; // triangles: indices (0 = none); instances with FLAG_TRANSLATE: the BLAS address table + uvec2 src2; // triangles: 3x4 transform (0 = none); instances with FLAG_TRANSLATE: the arena bound uvec2 bias; // added to addresses read from memory uint mode; uint count; // threads of this dispatch uint first; // triangles: first element; radix: the pass (0..7) uint arg0; // triangles: vertex stride; otherwise the most nodes the layout has room for - uint arg1; // triangles: 0 = R32G32B32_FLOAT, 1 = R32G32_FLOAT + uint arg1; // triangles: 0 = R32G32B32_FLOAT, 1 = R32G32_FLOAT; instances: table entries uint arg2; // triangles: index type (0 none, 1 u16, 2 u32); header: 1 = an update (bounds only) uint geometry; // triangles: geometry index << 8 | D3D12_RAYTRACING_GEOMETRY_FLAGS uint elements; // element count N @@ -109,7 +109,8 @@ layout(push_constant) uniform Push { uint parents_off; uint total_size; uint flags; // FLAG_TLAS: elements are 128-byte instances; FLAG_BOX16: inner nodes are 64-byte BOX16; - // FLAG_PAIR: pair sibling triangles that share an edge into TRI0/TRI1 leaves + // FLAG_PAIR: pair sibling triangles that share an edge into TRI0/TRI1 leaves; + // FLAG_TRANSLATE (instances): BLAS addresses go through blas_address } pc; // ---- 64-bit addresses as uvec2 ---- @@ -128,6 +129,12 @@ uint load(uvec2 base, uint byte_offset) { return at(base, byte_offset).w[0]; } void store(uvec2 base, uint byte_offset, uint v) { at(base, byte_offset).w[0] = v; } void storef(uvec2 base, uint byte_offset, float v) { store(base, byte_offset, floatBitsToUint(v)); } bool is_null(uvec2 a) { return a.x == 0u && a.y == 0u; } +bool less64(uvec2 a, uvec2 b) { return a.y < b.y || (a.y == b.y && a.x < b.x); } +uvec2 sub64(uvec2 a, uvec2 b) { + uint borrow; + uint lo = usubBorrow(a.x, b.x, borrow); + return uvec2(lo, a.y - b.y - borrow); +} // ---- scratch: centroid bounds (6 ordered words at 0) and the node count (word 6), keys and element indices twice // (the radix sort's two sides; the sorted result is back in the first after an even number of passes), digit @@ -273,6 +280,38 @@ void build_triangle(uint t) { } // ---- MODE_INSTANCES ---- +// The VA shaders reach the BLAS at the application's VA `va` by (xdxr_build.h XdxrBlasTable). Without +// FLAG_TRANSLATE, `va` itself. With it: inside a range of the table at src1 (arg1 entries of 6 words {title VA, end, +// shader VA}, in title-VA order), that range's shader VA, when its 64-byte header lies in the range; outside every +// range, `va` when the header lies below the arena bound src2 (0: no bound). Anything else, and a VA the INSTANCE +// record cannot hold (40 bits in 256-byte units), is not reachable (false): nothing is read through it. +bool blas_address(uvec2 va, out uvec2 shader_va) { + shader_va = va; + if ((pc.flags & FLAG_TRANSLATE) == 0u) return true; + uint lo = 0u, hi = pc.arg1; // the first entry that starts past va + while (lo < hi) { + uint mid = (lo + hi) >> 1u; + uvec2 start = uvec2(load(pc.src1, 24u * mid), load(pc.src1, 24u * mid + 4u)); + if (less64(va, start)) hi = mid; else lo = mid + 1u; + } + uvec2 last = add(va, 64u); + if (less64(last, va)) return false; // wraps + bool found = false; + if (lo > 0u) { + uint e = 24u * (lo - 1u); + uvec2 end = uvec2(load(pc.src1, e + 8u), load(pc.src1, e + 12u)); + if (less64(va, end)) { + if (less64(end, last)) return false; // the header runs past the copy + uvec2 start = uvec2(load(pc.src1, e), load(pc.src1, e + 4u)); + uvec2 to = uvec2(load(pc.src1, e + 16u), load(pc.src1, e + 20u)); + shader_va = add64(to, sub64(va, start)); + found = true; + } + } + if (!found && !is_null(pc.src2) && less64(pc.src2, last)) return false; + return (shader_va.x & 255u) == 0u && shader_va.y < 256u; +} + void build_instance(uint i) { uint d = 64u * i; float m[12]; @@ -285,8 +324,10 @@ void build_instance(uint i) { store(pc.dst, o + 52u, contrib); vec3 lo = vec3(uintBitsToFloat(0x7f800000u)), hi = -lo; uint root = INVALID; - if (!is_null(blas_va)) { - uvec2 blas = add64(blas_va, pc.bias); + uvec2 blas_sva = blas_va; + bool reached = !is_null(blas_va) && blas_address(blas_va, blas_sva); + if (reached) { + uvec2 blas = add64(blas_sva, pc.bias); root = load(blas, 48u); vec3 blo = vec3(uintBitsToFloat(load(blas, 16u)), uintBitsToFloat(load(blas, 20u)), uintBitsToFloat(load(blas, 24u))); vec3 bhi = vec3(uintBitsToFloat(load(blas, 28u)), uintBitsToFloat(load(blas, 32u)), uintBitsToFloat(load(blas, 36u))); @@ -303,8 +344,10 @@ void build_instance(uint i) { bool identity = m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[4] == 0.0 && m[5] == 1.0 && m[6] == 0.0 && m[8] == 0.0 && m[9] == 0.0 && m[10] == 1.0; store(pc.dst, o + 56u, (root & ~INST_FLAGS_MASK) | (identity ? INST_IDENTITY_ROTATION : 0u)); - // The record holds the BLAS address in 256-byte units: the application's address, as the game wrote it. - store(pc.dst, o + 60u, (blas_va.x >> 8) | (blas_va.y << 24)); + // The record holds the BLAS address in 256-byte units: the application's address, as the game wrote it, or with + // FLAG_TRANSLATE the one shaders reach it by (0 when there is none: a null BLAS). + if (!reached) blas_sva = uvec2(0u); + store(pc.dst, o + 60u, (blas_sva.x >> 8) | (blas_sva.y << 24)); // world-to-object: the inverse of the affine transform mat3 a = mat3(m[0], m[4], m[8], m[1], m[5], m[9], m[2], m[6], m[10]); // columns float det = determinant(a); diff --git a/runtime/src/xdxr_build.h b/runtime/src/xdxr_build.h index e1c1a233e0..08623f52a8 100644 --- a/runtime/src/xdxr_build.h +++ b/runtime/src/xdxr_build.h @@ -24,6 +24,7 @@ #include +#include "vulkan_aftermath.h" #include "xdxr_build_spv.h" namespace leonida { @@ -105,6 +106,20 @@ struct XdxrTriangles { std::uint32_t flags = 0; // D3D12_RAYTRACING_GEOMETRY_FLAGS (bit 0 opaque) }; +// How a top-level build reaches the BLAS addresses its instance descs hold (xdxr_build.comp blas_address). They are +// the application's GPU VAs; with `translate`, one inside a range of `address` (`count` 24-byte entries {title VA, +// end, shader VA}, in title-VA order, none overlapping: src/title_va_alias.h) becomes that range's shader VA, one +// outside every range is kept below `bound` (an arena VA; `bound` 0: any VA is kept), and any other is not reachable: +// that instance is built with no BLAS (an empty box, never hit) and nothing is read through its address. The record +// then holds the shader VA, which is what the traversal shaders add heap_base to. Without `translate` every address +// is kept, as before. +struct XdxrBlasTable { + bool translate = false; + std::uint64_t address = 0; // device address of the entries + std::uint32_t count = 0; + std::uint64_t bound = 0; +}; + class XdxrBuilder { public: XdxrBuilder(PFN_vkGetDeviceProcAddr get, VkDevice device) : device_(device) { @@ -166,9 +181,11 @@ class XdxrBuilder { } // Records a top-level build from `count` D3D12_RAYTRACING_INSTANCE_DESCs at `instances`. - // `update_from`: as for record_blas; the instances may move, and name other BLASes. + // `update_from`: as for record_blas; the instances may move, and name other BLASes. `blases`: how the BLAS + // addresses in the descs are reached (XdxrBlasTable); null keeps them as they are. bool record_tlas(VkCommandBuffer cb, const XdxrLayout& layout, std::uint64_t instances, std::uint64_t dst, - std::uint64_t scratch, std::uint64_t bias = 0, std::uint64_t update_from = 0) { + std::uint64_t scratch, std::uint64_t bias = 0, std::uint64_t update_from = 0, + const XdxrBlasTable* blases = nullptr) { if (!loaded_ || !layout.tlas || !layout.size || !dst || !scratch || (layout.elements && !instances)) return false; Push p = base(layout, dst, scratch); @@ -179,6 +196,12 @@ class XdxrBuilder { t.mode = mode_instances; t.count = layout.elements; t.src0 = split(instances); + if (blases && blases->translate) { + t.flags |= flag_translate; + t.src1 = split(blases->count ? blases->address : 0); + t.arg1 = blases->address ? blases->count : 0; + t.src2 = split(blases->bound); + } dispatch(cb, t, t.count); } if (update_from) refit_finish(cb, layout, p); else finish(cb, layout, p); @@ -231,7 +254,7 @@ class XdxrBuilder { std::uint32_t mode = 0, count = 0, first = 0, arg0 = 0, arg1 = 0, arg2 = 0, geometry = 0, elements = 0, sort_size = 0, elements_off = 0, nodes_off = 0, parents_off = 0, total_size = 0, flags = 0; }; - enum : std::uint32_t { flag_tlas = 1, flag_box16 = 2, flag_pair = 4 }; // xdxr_build.comp FLAG_* + enum : std::uint32_t { flag_tlas = 1, flag_box16 = 2, flag_pair = 4, flag_translate = 8 }; // xdxr_build.comp FLAG_* static_assert(sizeof(Push) == 104, "push constants must match xdxr_build.comp"); static Addr split(std::uint64_t a) { return {std::uint32_t(a), std::uint32_t(a >> 32)}; } @@ -388,6 +411,7 @@ class XdxrBuilder { module_info.codeSize = sizeof(xdxr_build_spirv); module_info.pCode = xdxr_build_spirv; VkShaderModule module = VK_NULL_HANDLE; + const aftermath::ShaderName aftermath_name("(runtime) xdxr_build.comp"); if (vk_.vkCreateShaderModule(device_, &module_info, nullptr, &module) != VK_SUCCESS) return false; VkComputePipelineCreateInfo info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, diff --git a/runtime/src/xdxr_build.inc b/runtime/src/xdxr_build.inc index f6b8f949c0..e17aecfeaa 100644 --- a/runtime/src/xdxr_build.inc +++ b/runtime/src/xdxr_build.inc @@ -1,46 +1,46 @@ -{0x07230203,0x00010500,0x000d000b,0x00005ce9, +{0x07230203,0x00010500,0x000d000b,0x00006129, 0x00000000,0x00020011,0x00000001,0x00020011, 0x000014e3,0x0006000b,0x00000001,0x4c534c47, 0x6474732e,0x3035342e,0x00000000,0x0003000e, 0x000014e4,0x00000001,0x0011000f,0x00000005, -0x00000004,0x6e69616d,0x00000000,0x00000180, -0x00000825,0x0000083a,0x00000919,0x00000980, -0x000009d5,0x00000a2e,0x00000d70,0x00000e00, -0x000011db,0x000011e4,0x000011e5,0x00060010, +0x00000004,0x6e69616d,0x00000000,0x000001b9, +0x00000924,0x00000939,0x00000a18,0x00000a7f, +0x00000ad4,0x00000b2d,0x00000e6f,0x00000eff, +0x000012da,0x000012e3,0x000012e4,0x00060010, 0x00000004,0x00000011,0x00000040,0x00000001, 0x00000001,0x00040047,0x00000015,0x00000006, 0x00000004,0x00030047,0x00000016,0x00000002, 0x00050048,0x00000016,0x00000000,0x00000023, -0x00000000,0x00030047,0x0000017e,0x00000002, -0x00050048,0x0000017e,0x00000000,0x00000023, -0x00000000,0x00050048,0x0000017e,0x00000001, -0x00000023,0x00000008,0x00050048,0x0000017e, +0x00000000,0x00030047,0x000001b7,0x00000002, +0x00050048,0x000001b7,0x00000000,0x00000023, +0x00000000,0x00050048,0x000001b7,0x00000001, +0x00000023,0x00000008,0x00050048,0x000001b7, 0x00000002,0x00000023,0x00000010,0x00050048, -0x0000017e,0x00000003,0x00000023,0x00000018, -0x00050048,0x0000017e,0x00000004,0x00000023, -0x00000020,0x00050048,0x0000017e,0x00000005, -0x00000023,0x00000028,0x00050048,0x0000017e, +0x000001b7,0x00000003,0x00000023,0x00000018, +0x00050048,0x000001b7,0x00000004,0x00000023, +0x00000020,0x00050048,0x000001b7,0x00000005, +0x00000023,0x00000028,0x00050048,0x000001b7, 0x00000006,0x00000023,0x00000030,0x00050048, -0x0000017e,0x00000007,0x00000023,0x00000034, -0x00050048,0x0000017e,0x00000008,0x00000023, -0x00000038,0x00050048,0x0000017e,0x00000009, -0x00000023,0x0000003c,0x00050048,0x0000017e, +0x000001b7,0x00000007,0x00000023,0x00000034, +0x00050048,0x000001b7,0x00000008,0x00000023, +0x00000038,0x00050048,0x000001b7,0x00000009, +0x00000023,0x0000003c,0x00050048,0x000001b7, 0x0000000a,0x00000023,0x00000040,0x00050048, -0x0000017e,0x0000000b,0x00000023,0x00000044, -0x00050048,0x0000017e,0x0000000c,0x00000023, -0x00000048,0x00050048,0x0000017e,0x0000000d, -0x00000023,0x0000004c,0x00050048,0x0000017e, +0x000001b7,0x0000000b,0x00000023,0x00000044, +0x00050048,0x000001b7,0x0000000c,0x00000023, +0x00000048,0x00050048,0x000001b7,0x0000000d, +0x00000023,0x0000004c,0x00050048,0x000001b7, 0x0000000e,0x00000023,0x00000050,0x00050048, -0x0000017e,0x0000000f,0x00000023,0x00000054, -0x00050048,0x0000017e,0x00000010,0x00000023, -0x00000058,0x00050048,0x0000017e,0x00000011, -0x00000023,0x0000005c,0x00050048,0x0000017e, +0x000001b7,0x0000000f,0x00000023,0x00000054, +0x00050048,0x000001b7,0x00000010,0x00000023, +0x00000058,0x00050048,0x000001b7,0x00000011, +0x00000023,0x0000005c,0x00050048,0x000001b7, 0x00000012,0x00000023,0x00000060,0x00050048, -0x0000017e,0x00000013,0x00000023,0x00000064, -0x00040047,0x000011db,0x0000000b,0x0000001c, -0x00040047,0x000011e4,0x0000000b,0x0000001a, -0x00040047,0x000011e5,0x0000000b,0x0000001b, -0x00040047,0x000012fc,0x0000000b,0x00000019, +0x000001b7,0x00000013,0x00000023,0x00000064, +0x00040047,0x000012da,0x0000000b,0x0000001c, +0x00040047,0x000012e3,0x0000000b,0x0000001a, +0x00040047,0x000012e4,0x0000000b,0x0000001b, +0x00040047,0x000013fb,0x0000000b,0x00000019, 0x00020013,0x00000002,0x00030021,0x00000003, 0x00000002,0x00040015,0x00000006,0x00000020, 0x00000000,0x00040017,0x00000007,0x00000006, @@ -51,7530 +51,7849 @@ 0x000014e5,0x00000016,0x00030016,0x00000027, 0x00000020,0x00040020,0x00000028,0x00000007, 0x00000027,0x00020014,0x0000002f,0x00040017, -0x00000063,0x00000027,0x00000003,0x00040020, -0x00000064,0x00000007,0x00000063,0x00040020, -0x0000008d,0x00000007,0x0000002f,0x00040017, -0x000000d2,0x00000006,0x00000003,0x00040020, -0x000000d8,0x00000007,0x000000d2,0x0004002b, -0x00000006,0x000000df,0x00000004,0x0004001c, -0x000000e0,0x00000006,0x000000df,0x00040020, -0x000000e1,0x00000007,0x000000e0,0x00040015, -0x000000e7,0x00000020,0x00000001,0x0004002b, -0x00000006,0x0000012b,0x00000000,0x0004001e, -0x00000130,0x00000006,0x00000006,0x0004002b, -0x00000006,0x00000135,0x00000001,0x0004002b, -0x000000e7,0x0000015e,0x00000000,0x00040020, -0x0000015f,0x000014e5,0x00000006,0x0016001e, -0x0000017e,0x00000007,0x00000007,0x00000007, +0x0000006c,0x00000027,0x00000003,0x00040020, +0x0000006d,0x00000007,0x0000006c,0x00040020, +0x00000096,0x00000007,0x0000002f,0x00040017, +0x000000df,0x00000006,0x00000003,0x00040020, +0x000000e5,0x00000007,0x000000df,0x0004002b, +0x00000006,0x000000ec,0x00000004,0x0004001c, +0x000000ed,0x00000006,0x000000ec,0x00040020, +0x000000ee,0x00000007,0x000000ed,0x00040015, +0x000000f4,0x00000020,0x00000001,0x0004002b, +0x00000006,0x00000138,0x00000000,0x0004001e, +0x0000013d,0x00000006,0x00000006,0x0004002b, +0x00000006,0x00000142,0x00000001,0x0004002b, +0x000000f4,0x0000016b,0x00000000,0x00040020, +0x0000016c,0x000014e5,0x00000006,0x0016001e, +0x000001b7,0x00000007,0x00000007,0x00000007, 0x00000007,0x00000007,0x00000007,0x00000006, 0x00000006,0x00000006,0x00000006,0x00000006, 0x00000006,0x00000006,0x00000006,0x00000006, 0x00000006,0x00000006,0x00000006,0x00000006, -0x00000006,0x00040020,0x0000017f,0x00000009, -0x0000017e,0x0004003b,0x0000017f,0x00000180, -0x00000009,0x0004002b,0x000000e7,0x00000181, -0x0000000e,0x00040020,0x00000182,0x00000009, -0x00000006,0x0004002b,0x00000006,0x00000185, -0x00000100,0x0004002b,0x00000006,0x0000018b, -0x00000040,0x0004002b,0x00000006,0x00000194, -0x00000008,0x0004002b,0x00000006,0x0000019b, -0x0000000c,0x0004002b,0x00000006,0x000001a2, -0x00000010,0x0004002b,0x00000006,0x000001b6, -0x00000018,0x0004002b,0x000000e7,0x000001b7, -0x0000000d,0x0004002b,0x00000006,0x000001cc, -0x00000020,0x0004002b,0x000000e7,0x000001cd, -0x00000009,0x0004002b,0x00000006,0x00000208, -0x80000000,0x0004002b,0x00000006,0x0000021d, -0x7fffffff,0x0004002b,0x000000e7,0x0000022b, -0x00000001,0x00040020,0x0000022d,0x00000009, -0x00000007,0x0004002b,0x00000006,0x00000247, -0x00000002,0x0004002b,0x00000006,0x00000260, -0x00000014,0x0004002b,0x00000027,0x000002c4, -0x3f000000,0x0004002b,0x000000e7,0x000002dc, -0x00000002,0x0004002b,0x000000e7,0x000002e4, -0x00000003,0x0004002b,0x000000e7,0x000002ec, -0x00000004,0x0004002b,0x000000e7,0x000002f4, -0x00000005,0x0004002b,0x000000e7,0x000002fb, -0x00000013,0x0004002b,0x00000006,0x00000309, -0x00000080,0x0004002b,0x000000e7,0x00000311, -0x0000000f,0x0004002b,0x000000e7,0x00000318, -0x00000006,0x0004002b,0x00000006,0x0000031c, -0x00000006,0x0004002b,0x000000e7,0x00000321, -0x00000010,0x0004002b,0x00000006,0x0000032b, -0x00000005,0x0004002b,0x00000006,0x0000033a, -0x00008000,0x0004002b,0x00000006,0x00000345, -0x7f800000,0x0004002b,0x00000006,0x0000034a, -0x00007e00,0x0004002b,0x000000e7,0x00000355, -0x00000017,0x0004002b,0x000000e7,0x00000358, -0x0000007f,0x0004002b,0x00000006,0x00000360, -0x00007c00,0x0004002b,0x00000006,0x00000361, -0x00007bff,0x0004002b,0x000000e7,0x00000366, -0xfffffff2,0x0004002b,0x00000006,0x0000036f, -0x00000400,0x0004002b,0x00000006,0x00000377, -0x007fffff,0x0004002b,0x000000e7,0x0000037d, -0x0000000a,0x0004002b,0x00000006,0x00000386, -0x00001fff,0x0003002a,0x0000002f,0x00000393, -0x00030029,0x0000002f,0x000003ae,0x0004002b, -0x00000027,0x000003ed,0x00000000,0x0004002b, -0x000000e7,0x000003fb,0x0000000b,0x0004002b, -0x00000006,0x00000423,0x0000ffff,0x0004002b, -0x00000006,0x00000437,0x00000003,0x00040017, -0x0000043c,0x00000027,0x00000004,0x0004001c, -0x00000476,0x00000063,0x00000437,0x00040020, -0x00000477,0x00000007,0x00000476,0x0004002b, -0x000000e7,0x00000488,0x00000008,0x0004002b, -0x00000006,0x000004c7,0x00000024,0x0004002b, -0x00000006,0x000004d2,0x00000028,0x0004002b, -0x00000006,0x000004dd,0x0000002c,0x0004002b, -0x00000006,0x000004e8,0x00000030,0x0004002b, -0x000000e7,0x000004ea,0x0000000c,0x0004002b, -0x00000006,0x000004f4,0x00000034,0x0004002b, -0x00000006,0x000004fe,0x00000038,0x0004002b, -0x00000006,0x00000500,0xffffffff,0x0004002b, -0x00000006,0x00000508,0x0000003c,0x0004002b, -0x00000006,0x0000050a,0x00000009,0x00040017, -0x00000514,0x0000002f,0x00000003,0x0004002b, -0x00000027,0x0000053c,0x7f800000,0x0006002c, -0x00000063,0x0000053d,0x0000053c,0x0000053c, -0x0000053c,0x0004001c,0x00000557,0x00000027, -0x0000019b,0x00040020,0x00000558,0x00000007, -0x00000557,0x0004002b,0x00000006,0x000005df, -0x0000001c,0x0004002b,0x000000e7,0x000005f9, -0x00000018,0x0004002b,0x000000e7,0x00000653, -0x00000007,0x0004002b,0x00000027,0x00000677, -0x3f800000,0x0004002b,0x00000006,0x000006ac, -0x3fffffff,0x00040018,0x000006c6,0x00000063, -0x00000003,0x00040020,0x000006c7,0x00000007, -0x000006c6,0x0006002c,0x00000063,0x000006eb, -0x000003ed,0x000003ed,0x000003ed,0x0006002c, -0x000006c6,0x000006ec,0x000006eb,0x000006eb, -0x000006eb,0x0004002b,0x00000006,0x00000712, -0x00000044,0x0004002b,0x00000006,0x00000721, -0x00000048,0x0004002b,0x00000006,0x00000730, -0x0000004c,0x0004002b,0x00000006,0x00000741, -0x00000070,0x0004002b,0x00000006,0x0000074b, -0x00000074,0x0004002b,0x00000006,0x00000754, -0x00000078,0x0004002b,0x00000006,0x0000075d, -0x0000007c,0x0004002b,0x00000006,0x00000777, -0x000003ff,0x0004002b,0x00000006,0x0000077e, -0x030000ff,0x0004002b,0x00000006,0x00000784, -0x0300f00f,0x0004002b,0x00000006,0x0000078a, -0x030c30c3,0x0004002b,0x00000006,0x00000790, -0x09249249,0x0004002b,0x00000027,0x000007d3, -0x0da24260,0x0006002c,0x00000063,0x000007d4, -0x000007d3,0x000007d3,0x000007d3,0x0004002b, -0x00000027,0x000007e2,0x447fc000,0x0004001c, -0x00000823,0x00000006,0x0000036f,0x00040020, -0x00000824,0x00000004,0x00000823,0x0004003b, -0x00000824,0x00000825,0x00000004,0x00040020, -0x00000838,0x00000004,0x00000006,0x0004003b, -0x00000824,0x0000083a,0x00000004,0x0004002b, -0x00000006,0x00000850,0x00000108,0x0004002b, -0x00000006,0x0000090f,0x0000000f,0x0004001c, -0x00000917,0x00000006,0x000001a2,0x00040020, -0x00000918,0x00000004,0x00000917,0x0004003b, -0x00000918,0x00000919,0x00000004,0x0004002b, -0x00000006,0x00000957,0x0000003f,0x0004001c, -0x0000097e,0x00000006,0x0000018b,0x00040020, -0x0000097f,0x00000004,0x0000097e,0x0004003b, -0x0000097f,0x00000980,0x00000004,0x0004003b, -0x00000918,0x000009d5,0x00000004,0x0004001c, -0x00000a2c,0x0000097e,0x000001a2,0x00040020, -0x00000a2d,0x00000004,0x00000a2c,0x0004003b, -0x00000a2d,0x00000a2e,0x00000004,0x00040020, -0x00000a4a,0x00000007,0x00000917,0x0004002b, -0x000000e7,0x00000a9c,0x0000003f,0x0004001c, -0x00000af6,0x0000002f,0x000000df,0x00040020, -0x00000af7,0x00000007,0x00000af6,0x0004001c, -0x00000b09,0x000000d2,0x00000437,0x0004001c, -0x00000b0a,0x00000b09,0x000000df,0x00040020, -0x00000b0b,0x00000007,0x00000b0a,0x0006002c, -0x000000d2,0x00000b0f,0x0000012b,0x0000012b, -0x0000012b,0x0004002b,0x00000006,0x00000c2c, -0x00000007,0x0004002b,0x00000006,0x00000c46, -0xfffffff8,0x0004002b,0x000000e7,0x00000c68, -0xffffffff,0x0004002b,0x000000e7,0x00000c77, -0x00000040,0x0004002b,0x000000e7,0x00000c7f, -0x0000001f,0x0004003b,0x00000838,0x00000d70, -0x00000004,0x0004003b,0x0000097f,0x00000e00, -0x00000004,0x0007002c,0x000000e0,0x00000ed6, -0x00000500,0x00000500,0x00000500,0x00000500, -0x0004001c,0x00000f0e,0x00000006,0x00000247, -0x00040020,0x00000f0f,0x00000007,0x00000f0e, -0x0004002b,0x000000e7,0x00000fbf,0x00000011, -0x0004001c,0x00001031,0x00000006,0x0000031c, -0x00040020,0x00001032,0x00000007,0x00001031, -0x00040020,0x000011da,0x00000001,0x000000d2, -0x0004003b,0x000011da,0x000011db,0x00000001, -0x00040020,0x000011dc,0x00000001,0x00000006, -0x0004003b,0x000011da,0x000011e4,0x00000001, -0x0004003b,0x000011da,0x000011e5,0x00000001, -0x0004002b,0x00000006,0x0000120f,0x0000000a, -0x0004002b,0x00000006,0x0000121a,0x0000000e, -0x0004002b,0x00000006,0x00001258,0x0000000d, -0x0004002b,0x00000006,0x000012eb,0x00000011, -0x0004002b,0x00000006,0x000012f5,0x00000012, -0x0006002c,0x000000d2,0x000012fc,0x0000018b, -0x00000135,0x00000135,0x0006002c,0x00000063, -0x00005cc0,0x00000677,0x00000677,0x00000677, -0x0004002b,0x00000027,0x00005cc1,0xff800000, -0x0006002c,0x00000063,0x00005cc2,0x00005cc1, -0x00005cc1,0x00005cc1,0x0004002b,0x00000006, -0x00005cc3,0x000000ff,0x0004002b,0x000000e7, -0x00005cc4,0xffffff90,0x0004002b,0x00000006, -0x00005cc5,0xff800000,0x0004002b,0x00000006, -0x00005cd3,0x80000006,0x0004002b,0x00000006, -0x00005cd7,0x7bff7bff,0x0004002b,0x00000006, -0x00005cd9,0xfbff7bff,0x0004002b,0x00000006, -0x00005cda,0xfbfffbff,0x00050036,0x00000002, -0x00000004,0x00000000,0x00000003,0x000200f8, -0x00000005,0x0004003b,0x00001032,0x00005579, -0x00000007,0x0004003b,0x00000af7,0x000041c5, -0x00000007,0x0004003b,0x00000af7,0x000041c6, -0x00000007,0x0004003b,0x000000e1,0x000041c7, -0x00000007,0x0004003b,0x00000b0b,0x000041c9, -0x00000007,0x0004003b,0x000000e1,0x00003c67, -0x00000007,0x0004003b,0x000000e1,0x00003c68, -0x00000007,0x0004003b,0x00000f0f,0x00003c72, -0x00000007,0x0004003b,0x00000f0f,0x00003c79, -0x00000007,0x0004003b,0x000000e1,0x00003c82, -0x00000007,0x0004003b,0x000000e1,0x00003c83, -0x00000007,0x0004003b,0x00000558,0x00002b2c, -0x00000007,0x0004003b,0x000006c7,0x00002b6d, -0x00000007,0x0004003b,0x00000064,0x00002b70, -0x00000007,0x0004003b,0x00000064,0x000026bf, -0x00000007,0x0004003b,0x00000477,0x000024d6, -0x00000007,0x0004003b,0x00001032,0x0000202d, -0x00000007,0x0004003b,0x00000a4a,0x00001508, -0x00000007,0x000300f7,0x000012fe,0x00000000, -0x000300fb,0x0000012b,0x000012ff,0x000200f8, -0x000012ff,0x00050041,0x000011dc,0x000011dd, -0x000011db,0x0000012b,0x0004003d,0x00000006, -0x000011de,0x000011dd,0x00050041,0x00000182, -0x000011df,0x00000180,0x00000318,0x0004003d, -0x00000006,0x000011e0,0x000011df,0x000500aa, -0x0000002f,0x000011e1,0x000011e0,0x00000c2c, -0x000300f7,0x000011e3,0x00000000,0x000400fa, -0x000011e1,0x000011e2,0x000011e3,0x000200f8, -0x000011e2,0x00050041,0x000011dc,0x000011e7, -0x000011e4,0x0000012b,0x0004003d,0x00000006, -0x000011e8,0x000011e7,0x00050041,0x000011dc, -0x000011ea,0x000011e5,0x0000012b,0x0004003d, -0x00000006,0x000011eb,0x000011ea,0x000500b0, -0x0000002f,0x00001339,0x000011eb,0x000001a2, -0x000300f7,0x0000133d,0x00000000,0x000400fa, -0x00001339,0x0000133a,0x0000133d,0x000200f8, -0x0000133a,0x00050041,0x00000838,0x0000133c, -0x00000919,0x000011eb,0x0003003e,0x0000133c, -0x0000012b,0x000200f9,0x0000133d,0x000200f8, -0x0000133d,0x000400e0,0x00000247,0x00000247, -0x00000850,0x00050084,0x00000006,0x0000133f, -0x000011e8,0x00000185,0x00050080,0x00000006, -0x00001341,0x0000133f,0x00000185,0x00050041, -0x00000182,0x00001342,0x00000180,0x00000181, -0x0004003d,0x00000006,0x00001343,0x00001342, -0x0007000c,0x00000006,0x00001344,0x00000001, -0x00000026,0x00001341,0x00001343,0x00050080, -0x00000006,0x00001347,0x0000133f,0x000011eb, -0x000200f9,0x00001348,0x000200f8,0x00001348, -0x000700f5,0x00000006,0x00005ba2,0x00001347, -0x0000133d,0x0000135a,0x00001358,0x000500b0, -0x0000002f,0x0000134c,0x00005ba2,0x00001344, -0x000400f6,0x0000135b,0x00001358,0x00000000, -0x000400fa,0x0000134c,0x0000134d,0x0000135b, -0x000200f8,0x0000134d,0x00050041,0x00000182, -0x00001371,0x00000180,0x00000488,0x0004003d, -0x00000006,0x00001372,0x00001371,0x000500c7, -0x00000006,0x00001373,0x00001372,0x00000135, -0x000500aa,0x0000002f,0x00001374,0x00001373, -0x0000012b,0x000300f7,0x00001379,0x00000000, -0x000400fa,0x00001374,0x00001375,0x00001377, -0x000200f8,0x00001377,0x00050084,0x00000006, -0x00001381,0x00000194,0x00001343,0x00050080, -0x00000006,0x00001382,0x0000018b,0x00001381, -0x000200f9,0x00001379,0x000200f8,0x00001375, -0x000200f9,0x00001379,0x000200f8,0x00001379, -0x000700f5,0x00000006,0x00005ba3,0x0000018b, -0x00001375,0x00001382,0x00001377,0x00050084, -0x00000006,0x00001350,0x000000df,0x00005ba2, -0x00050080,0x00000006,0x00001351,0x00005ba3, -0x00001350,0x00050041,0x0000022d,0x00001352, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x00001353,0x00001352,0x00050051,0x00000006, -0x00001399,0x00001353,0x00000000,0x00050095, -0x00000130,0x0000139b,0x00001399,0x00001351, -0x00050051,0x00000006,0x0000139c,0x0000139b, -0x00000001,0x00050051,0x00000006,0x0000139d, -0x0000139b,0x00000000,0x00050051,0x00000006, -0x000013a0,0x00001353,0x00000001,0x00050080, -0x00000006,0x000013a2,0x000013a0,0x0000139c, -0x00050050,0x00000007,0x000013a3,0x0000139d, -0x000013a2,0x0004007c,0x00000014,0x00001393, -0x000013a3,0x00060041,0x0000015f,0x0000138a, -0x00001393,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x0000138b,0x0000138a,0x00000002, -0x00000004,0x00050084,0x00000006,0x000013a9, -0x000000df,0x00001372,0x000500c2,0x00000006, -0x000013aa,0x0000138b,0x000013a9,0x000500c7, -0x00000006,0x000013ab,0x000013aa,0x0000090f, -0x00050041,0x00000838,0x00001356,0x00000919, -0x000013ab,0x000700ea,0x00000006,0x00001357, -0x00001356,0x00000135,0x0000012b,0x00000135, -0x000200f9,0x00001358,0x000200f8,0x00001358, -0x00050080,0x00000006,0x0000135a,0x00005ba2, -0x0000018b,0x000200f9,0x00001348,0x000200f8, -0x0000135b,0x000400e0,0x00000247,0x00000247, -0x00000850,0x000300f7,0x0000136d,0x00000000, -0x000400fa,0x00001339,0x0000135e,0x0000136d, -0x000200f8,0x0000135e,0x00050084,0x00000006, -0x000013b0,0x000001a2,0x00001343,0x00050080, -0x00000006,0x000013b1,0x0000018b,0x000013b0, -0x00050080,0x00000006,0x000013b7,0x00001343, -0x00005cc3,0x00050086,0x00000006,0x000013b8, -0x000013b7,0x00000185,0x00050084,0x00000006, -0x00001362,0x000011eb,0x000013b8,0x00050080, -0x00000006,0x00001364,0x00001362,0x000011e8, -0x00050084,0x00000006,0x00001365,0x000000df, -0x00001364,0x00050080,0x00000006,0x00001366, -0x000013b1,0x00001365,0x00050041,0x0000022d, -0x00001368,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00001369,0x00001368,0x00050041, -0x00000838,0x0000136a,0x00000919,0x000011eb, -0x0004003d,0x00000006,0x0000136b,0x0000136a, -0x00050051,0x00000006,0x000013ce,0x00001369, -0x00000000,0x00050095,0x00000130,0x000013d0, -0x000013ce,0x00001366,0x00050051,0x00000006, -0x000013d1,0x000013d0,0x00000001,0x00050051, -0x00000006,0x000013d2,0x000013d0,0x00000000, -0x00050051,0x00000006,0x000013d5,0x00001369, -0x00000001,0x00050080,0x00000006,0x000013d7, -0x000013d5,0x000013d1,0x00050050,0x00000007, -0x000013d8,0x000013d2,0x000013d7,0x0004007c, -0x00000014,0x000013c8,0x000013d8,0x00060041, -0x0000015f,0x000013c0,0x000013c8,0x0000015e, -0x0000015e,0x0005003e,0x000013c0,0x0000136b, -0x00000002,0x00000004,0x000200f9,0x0000136d, -0x000200f8,0x0000136d,0x000200f9,0x000012fe, -0x000200f8,0x000011e3,0x000500aa,0x0000002f, -0x000011f0,0x000011e0,0x00000194,0x000300f7, -0x000011f2,0x00000000,0x000400fa,0x000011f0, -0x000011f1,0x000011f2,0x000200f8,0x000011f1, -0x00050041,0x00000182,0x000013db,0x00000180, -0x00000181,0x0004003d,0x00000006,0x000013dc, -0x000013db,0x00050084,0x00000006,0x000013dd, -0x000001a2,0x000013dc,0x00050080,0x00000006, -0x000013de,0x0000018b,0x000013dd,0x00050080, -0x00000006,0x000013f0,0x000013dc,0x00005cc3, -0x00050086,0x00000006,0x000013f1,0x000013f0, -0x00000185,0x00050084,0x00000006,0x000013e3, -0x0000018b,0x000013f1,0x00050080,0x00000006, -0x000013e4,0x000013de,0x000013e3,0x00050084, -0x00000006,0x000011f6,0x000001a2,0x000013f1, -0x00050041,0x000011dc,0x000011f8,0x000011e5, -0x0000012b,0x0004003d,0x00000006,0x000011f9, -0x000011f8,0x00050080,0x00000006,0x00001410, -0x000011f6,0x00000957,0x00050086,0x00000006, -0x00001411,0x00001410,0x0000018b,0x00050084, -0x00000006,0x00001414,0x000011f9,0x00001411, -0x0007000c,0x00000006,0x00001416,0x00000001, -0x00000026,0x00001414,0x000011f6,0x00050080, -0x00000006,0x00001419,0x00001416,0x00001411, -0x0007000c,0x00000006,0x0000141b,0x00000001, -0x00000026,0x00001419,0x000011f6,0x000200f9, -0x0000141d,0x000200f8,0x0000141d,0x000700f5, -0x00000006,0x00005b9d,0x0000012b,0x000011f1, -0x0000142b,0x00001422,0x000700f5,0x00000006, -0x00005b9c,0x00001416,0x000011f1,0x0000142e, -0x00001422,0x000500b0,0x0000002f,0x00001421, -0x00005b9c,0x0000141b,0x000400f6,0x0000142f, -0x00001422,0x00000000,0x000400fa,0x00001421, -0x00001422,0x0000142f,0x000200f8,0x00001422, -0x00050084,0x00000006,0x00001425,0x000000df, -0x00005b9c,0x00050080,0x00000006,0x00001426, -0x000013de,0x00001425,0x00050041,0x0000022d, -0x00001427,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00001428,0x00001427,0x00050051, -0x00000006,0x00001488,0x00001428,0x00000000, -0x00050095,0x00000130,0x0000148a,0x00001488, -0x00001426,0x00050051,0x00000006,0x0000148b, -0x0000148a,0x00000001,0x00050051,0x00000006, -0x0000148c,0x0000148a,0x00000000,0x00050051, -0x00000006,0x0000148f,0x00001428,0x00000001, -0x00050080,0x00000006,0x00001491,0x0000148f, -0x0000148b,0x00050050,0x00000007,0x00001492, -0x0000148c,0x00001491,0x0004007c,0x00000014, -0x00001482,0x00001492,0x00060041,0x0000015f, -0x00001479,0x00001482,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x0000147a,0x00001479, +0x00000006,0x00040020,0x000001b8,0x00000009, +0x000001b7,0x0004003b,0x000001b8,0x000001b9, +0x00000009,0x0004002b,0x000000f4,0x000001ba, +0x0000000e,0x00040020,0x000001bb,0x00000009, +0x00000006,0x0004002b,0x00000006,0x000001be, +0x00000100,0x0004002b,0x00000006,0x000001c4, +0x00000040,0x0004002b,0x00000006,0x000001cd, +0x00000008,0x0004002b,0x00000006,0x000001d4, +0x0000000c,0x0004002b,0x00000006,0x000001db, +0x00000010,0x0004002b,0x00000006,0x000001ef, +0x00000018,0x0004002b,0x000000f4,0x000001f0, +0x0000000d,0x0004002b,0x00000006,0x00000205, +0x00000020,0x0004002b,0x000000f4,0x00000206, +0x00000009,0x0004002b,0x00000006,0x00000241, +0x80000000,0x0004002b,0x00000006,0x00000256, +0x7fffffff,0x0004002b,0x000000f4,0x00000264, +0x00000001,0x00040020,0x00000266,0x00000009, +0x00000007,0x0004002b,0x00000006,0x00000280, +0x00000002,0x0004002b,0x00000006,0x00000299, +0x00000014,0x0004002b,0x00000027,0x000002fd, +0x3f000000,0x0004002b,0x000000f4,0x00000315, +0x00000002,0x0004002b,0x000000f4,0x0000031d, +0x00000003,0x0004002b,0x000000f4,0x00000325, +0x00000004,0x0004002b,0x000000f4,0x0000032d, +0x00000005,0x0004002b,0x000000f4,0x00000334, +0x00000013,0x0004002b,0x00000006,0x00000342, +0x00000080,0x0004002b,0x000000f4,0x0000034a, +0x0000000f,0x0004002b,0x000000f4,0x00000351, +0x00000006,0x0004002b,0x00000006,0x00000355, +0x00000006,0x0004002b,0x000000f4,0x0000035a, +0x00000010,0x0004002b,0x00000006,0x00000364, +0x00000005,0x0004002b,0x00000006,0x00000373, +0x00008000,0x0004002b,0x00000006,0x0000037e, +0x7f800000,0x0004002b,0x00000006,0x00000383, +0x00007e00,0x0004002b,0x000000f4,0x0000038e, +0x00000017,0x0004002b,0x000000f4,0x00000391, +0x0000007f,0x0004002b,0x00000006,0x00000399, +0x00007c00,0x0004002b,0x00000006,0x0000039a, +0x00007bff,0x0004002b,0x000000f4,0x0000039f, +0xfffffff2,0x0004002b,0x00000006,0x000003a8, +0x00000400,0x0004002b,0x00000006,0x000003b0, +0x007fffff,0x0004002b,0x000000f4,0x000003b6, +0x0000000a,0x0004002b,0x00000006,0x000003bf, +0x00001fff,0x0003002a,0x0000002f,0x000003cc, +0x00030029,0x0000002f,0x000003e7,0x0004002b, +0x00000027,0x00000426,0x00000000,0x0004002b, +0x000000f4,0x00000434,0x0000000b,0x0004002b, +0x00000006,0x0000045c,0x0000ffff,0x0004002b, +0x00000006,0x00000470,0x00000003,0x00040017, +0x00000475,0x00000027,0x00000004,0x0004001c, +0x000004af,0x0000006c,0x00000470,0x00040020, +0x000004b0,0x00000007,0x000004af,0x0004002b, +0x000000f4,0x000004c1,0x00000008,0x0004002b, +0x00000006,0x00000500,0x00000024,0x0004002b, +0x00000006,0x0000050b,0x00000028,0x0004002b, +0x00000006,0x00000516,0x0000002c,0x0004002b, +0x00000006,0x00000521,0x00000030,0x0004002b, +0x000000f4,0x00000523,0x0000000c,0x0004002b, +0x00000006,0x0000052d,0x00000034,0x0004002b, +0x00000006,0x00000537,0x00000038,0x0004002b, +0x00000006,0x00000539,0xffffffff,0x0004002b, +0x00000006,0x00000541,0x0000003c,0x0004002b, +0x00000006,0x00000543,0x00000009,0x00040017, +0x0000054d,0x0000002f,0x00000003,0x0004002b, +0x00000027,0x00000575,0x7f800000,0x0006002c, +0x0000006c,0x00000576,0x00000575,0x00000575, +0x00000575,0x0004002b,0x00000006,0x0000062f, +0x000000ff,0x0004001c,0x00000645,0x00000027, +0x000001d4,0x00040020,0x00000646,0x00000007, +0x00000645,0x0004002b,0x00000006,0x000006d9, +0x0000001c,0x0004002b,0x000000f4,0x000006f3, +0x00000018,0x0004002b,0x000000f4,0x0000074d, +0x00000007,0x0004002b,0x00000027,0x00000771, +0x3f800000,0x0004002b,0x00000006,0x000007a6, +0x3fffffff,0x0005002c,0x00000007,0x000007b5, +0x00000138,0x00000138,0x00040018,0x000007c5, +0x0000006c,0x00000003,0x00040020,0x000007c6, +0x00000007,0x000007c5,0x0006002c,0x0000006c, +0x000007ea,0x00000426,0x00000426,0x00000426, +0x0006002c,0x000007c5,0x000007eb,0x000007ea, +0x000007ea,0x000007ea,0x0004002b,0x00000006, +0x00000811,0x00000044,0x0004002b,0x00000006, +0x00000820,0x00000048,0x0004002b,0x00000006, +0x0000082f,0x0000004c,0x0004002b,0x00000006, +0x00000840,0x00000070,0x0004002b,0x00000006, +0x0000084a,0x00000074,0x0004002b,0x00000006, +0x00000853,0x00000078,0x0004002b,0x00000006, +0x0000085c,0x0000007c,0x0004002b,0x00000006, +0x00000876,0x000003ff,0x0004002b,0x00000006, +0x0000087d,0x030000ff,0x0004002b,0x00000006, +0x00000883,0x0300f00f,0x0004002b,0x00000006, +0x00000889,0x030c30c3,0x0004002b,0x00000006, +0x0000088f,0x09249249,0x0004002b,0x00000027, +0x000008d2,0x0da24260,0x0006002c,0x0000006c, +0x000008d3,0x000008d2,0x000008d2,0x000008d2, +0x0004002b,0x00000027,0x000008e1,0x447fc000, +0x0004001c,0x00000922,0x00000006,0x000003a8, +0x00040020,0x00000923,0x00000004,0x00000922, +0x0004003b,0x00000923,0x00000924,0x00000004, +0x00040020,0x00000937,0x00000004,0x00000006, +0x0004003b,0x00000923,0x00000939,0x00000004, +0x0004002b,0x00000006,0x0000094f,0x00000108, +0x0004002b,0x00000006,0x00000a0e,0x0000000f, +0x0004001c,0x00000a16,0x00000006,0x000001db, +0x00040020,0x00000a17,0x00000004,0x00000a16, +0x0004003b,0x00000a17,0x00000a18,0x00000004, +0x0004002b,0x00000006,0x00000a56,0x0000003f, +0x0004001c,0x00000a7d,0x00000006,0x000001c4, +0x00040020,0x00000a7e,0x00000004,0x00000a7d, +0x0004003b,0x00000a7e,0x00000a7f,0x00000004, +0x0004003b,0x00000a17,0x00000ad4,0x00000004, +0x0004001c,0x00000b2b,0x00000a7d,0x000001db, +0x00040020,0x00000b2c,0x00000004,0x00000b2b, +0x0004003b,0x00000b2c,0x00000b2d,0x00000004, +0x00040020,0x00000b49,0x00000007,0x00000a16, +0x0004002b,0x000000f4,0x00000b9b,0x0000003f, +0x0004001c,0x00000bf5,0x0000002f,0x000000ec, +0x00040020,0x00000bf6,0x00000007,0x00000bf5, +0x0004001c,0x00000c08,0x000000df,0x00000470, +0x0004001c,0x00000c09,0x00000c08,0x000000ec, +0x00040020,0x00000c0a,0x00000007,0x00000c09, +0x0006002c,0x000000df,0x00000c0e,0x00000138, +0x00000138,0x00000138,0x0004002b,0x00000006, +0x00000d2b,0x00000007,0x0004002b,0x00000006, +0x00000d45,0xfffffff8,0x0004002b,0x000000f4, +0x00000d67,0xffffffff,0x0004002b,0x000000f4, +0x00000d76,0x00000040,0x0004002b,0x000000f4, +0x00000d7e,0x0000001f,0x0004003b,0x00000937, +0x00000e6f,0x00000004,0x0004003b,0x00000a7e, +0x00000eff,0x00000004,0x0007002c,0x000000ed, +0x00000fd5,0x00000539,0x00000539,0x00000539, +0x00000539,0x0004001c,0x0000100d,0x00000006, +0x00000280,0x00040020,0x0000100e,0x00000007, +0x0000100d,0x0004002b,0x000000f4,0x000010be, +0x00000011,0x0004001c,0x00001130,0x00000006, +0x00000355,0x00040020,0x00001131,0x00000007, +0x00001130,0x00040020,0x000012d9,0x00000001, +0x000000df,0x0004003b,0x000012d9,0x000012da, +0x00000001,0x00040020,0x000012db,0x00000001, +0x00000006,0x0004003b,0x000012d9,0x000012e3, +0x00000001,0x0004003b,0x000012d9,0x000012e4, +0x00000001,0x0004002b,0x00000006,0x0000130e, +0x0000000a,0x0004002b,0x00000006,0x00001319, +0x0000000e,0x0004002b,0x00000006,0x00001357, +0x0000000d,0x0004002b,0x00000006,0x000013ea, +0x00000011,0x0004002b,0x00000006,0x000013f4, +0x00000012,0x0006002c,0x000000df,0x000013fb, +0x000001c4,0x00000142,0x00000142,0x0006002c, +0x0000006c,0x000060fc,0x00000771,0x00000771, +0x00000771,0x0004002b,0x00000027,0x000060fd, +0xff800000,0x0006002c,0x0000006c,0x000060fe, +0x000060fd,0x000060fd,0x000060fd,0x0004002b, +0x000000f4,0x000060ff,0xffffff90,0x0004002b, +0x00000006,0x00006100,0xff800000,0x0004002b, +0x00000006,0x0000610e,0x80000006,0x0004002b, +0x00000006,0x00006112,0x7bff7bff,0x0004002b, +0x00000006,0x00006114,0xfbff7bff,0x0004002b, +0x00000006,0x00006115,0xfbfffbff,0x00040017, +0x0000611e,0x0000002f,0x00000002,0x00050036, +0x00000002,0x00000004,0x00000000,0x00000003, +0x000200f8,0x00000005,0x0004003b,0x00001131, +0x00005905,0x00000007,0x0004003b,0x00000bf6, +0x00004551,0x00000007,0x0004003b,0x00000bf6, +0x00004552,0x00000007,0x0004003b,0x000000ee, +0x00004553,0x00000007,0x0004003b,0x00000c0a, +0x00004555,0x00000007,0x0004003b,0x000000ee, +0x00003ff3,0x00000007,0x0004003b,0x000000ee, +0x00003ff4,0x00000007,0x0004003b,0x0000100e, +0x00003ffe,0x00000007,0x0004003b,0x0000100e, +0x00004005,0x00000007,0x0004003b,0x000000ee, +0x0000400e,0x00000007,0x0004003b,0x000000ee, +0x0000400f,0x00000007,0x0004003b,0x00000646, +0x00002c30,0x00000007,0x0004003b,0x000007c6, +0x00002c75,0x00000007,0x0004003b,0x0000006d, +0x00002c78,0x00000007,0x0004003b,0x0000006d, +0x000027c3,0x00000007,0x0004003b,0x000004b0, +0x000025da,0x00000007,0x0004003b,0x00001131, +0x00002131,0x00000007,0x0004003b,0x00000b49, +0x0000160c,0x00000007,0x000300f7,0x000013fd, +0x00000000,0x000300fb,0x00000138,0x000013fe, +0x000200f8,0x000013fe,0x00050041,0x000012db, +0x000012dc,0x000012da,0x00000138,0x0004003d, +0x00000006,0x000012dd,0x000012dc,0x00050041, +0x000001bb,0x000012de,0x000001b9,0x00000351, +0x0004003d,0x00000006,0x000012df,0x000012de, +0x000500aa,0x0000002f,0x000012e0,0x000012df, +0x00000d2b,0x000300f7,0x000012e2,0x00000000, +0x000400fa,0x000012e0,0x000012e1,0x000012e2, +0x000200f8,0x000012e1,0x00050041,0x000012db, +0x000012e6,0x000012e3,0x00000138,0x0004003d, +0x00000006,0x000012e7,0x000012e6,0x00050041, +0x000012db,0x000012e9,0x000012e4,0x00000138, +0x0004003d,0x00000006,0x000012ea,0x000012e9, +0x000500b0,0x0000002f,0x0000143d,0x000012ea, +0x000001db,0x000300f7,0x00001441,0x00000000, +0x000400fa,0x0000143d,0x0000143e,0x00001441, +0x000200f8,0x0000143e,0x00050041,0x00000937, +0x00001440,0x00000a18,0x000012ea,0x0003003e, +0x00001440,0x00000138,0x000200f9,0x00001441, +0x000200f8,0x00001441,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x00050084,0x00000006, +0x00001443,0x000012e7,0x000001be,0x00050080, +0x00000006,0x00001445,0x00001443,0x000001be, +0x00050041,0x000001bb,0x00001446,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00001447, +0x00001446,0x0007000c,0x00000006,0x00001448, +0x00000001,0x00000026,0x00001445,0x00001447, +0x00050080,0x00000006,0x0000144b,0x00001443, +0x000012ea,0x000200f9,0x0000144c,0x000200f8, +0x0000144c,0x000700f5,0x00000006,0x00005fd2, +0x0000144b,0x00001441,0x0000145e,0x0000145c, +0x000500b0,0x0000002f,0x00001450,0x00005fd2, +0x00001448,0x000400f6,0x0000145f,0x0000145c, +0x00000000,0x000400fa,0x00001450,0x00001451, +0x0000145f,0x000200f8,0x00001451,0x00050041, +0x000001bb,0x00001475,0x000001b9,0x000004c1, +0x0004003d,0x00000006,0x00001476,0x00001475, +0x000500c7,0x00000006,0x00001477,0x00001476, +0x00000142,0x000500aa,0x0000002f,0x00001478, +0x00001477,0x00000138,0x000300f7,0x0000147d, +0x00000000,0x000400fa,0x00001478,0x00001479, +0x0000147b,0x000200f8,0x0000147b,0x00050084, +0x00000006,0x00001485,0x000001cd,0x00001447, +0x00050080,0x00000006,0x00001486,0x000001c4, +0x00001485,0x000200f9,0x0000147d,0x000200f8, +0x00001479,0x000200f9,0x0000147d,0x000200f8, +0x0000147d,0x000700f5,0x00000006,0x00005fd3, +0x000001c4,0x00001479,0x00001486,0x0000147b, +0x00050084,0x00000006,0x00001454,0x000000ec, +0x00005fd2,0x00050080,0x00000006,0x00001455, +0x00005fd3,0x00001454,0x00050041,0x00000266, +0x00001456,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x00001457,0x00001456,0x00050051, +0x00000006,0x0000149d,0x00001457,0x00000000, +0x00050095,0x0000013d,0x0000149f,0x0000149d, +0x00001455,0x00050051,0x00000006,0x000014a0, +0x0000149f,0x00000001,0x00050051,0x00000006, +0x000014a1,0x0000149f,0x00000000,0x00050051, +0x00000006,0x000014a4,0x00001457,0x00000001, +0x00050080,0x00000006,0x000014a6,0x000014a4, +0x000014a0,0x00050050,0x00000007,0x000014a7, +0x000014a1,0x000014a6,0x0004007c,0x00000014, +0x00001497,0x000014a7,0x00060041,0x0000016c, +0x0000148e,0x00001497,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x0000148f,0x0000148e, +0x00000002,0x00000004,0x00050084,0x00000006, +0x000014ad,0x000000ec,0x00001476,0x000500c2, +0x00000006,0x000014ae,0x0000148f,0x000014ad, +0x000500c7,0x00000006,0x000014af,0x000014ae, +0x00000a0e,0x00050041,0x00000937,0x0000145a, +0x00000a18,0x000014af,0x000700ea,0x00000006, +0x0000145b,0x0000145a,0x00000142,0x00000138, +0x00000142,0x000200f9,0x0000145c,0x000200f8, +0x0000145c,0x00050080,0x00000006,0x0000145e, +0x00005fd2,0x000001c4,0x000200f9,0x0000144c, +0x000200f8,0x0000145f,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x000300f7,0x00001471, +0x00000000,0x000400fa,0x0000143d,0x00001462, +0x00001471,0x000200f8,0x00001462,0x00050084, +0x00000006,0x000014b4,0x000001db,0x00001447, +0x00050080,0x00000006,0x000014b5,0x000001c4, +0x000014b4,0x00050080,0x00000006,0x000014bb, +0x00001447,0x0000062f,0x00050086,0x00000006, +0x000014bc,0x000014bb,0x000001be,0x00050084, +0x00000006,0x00001466,0x000012ea,0x000014bc, +0x00050080,0x00000006,0x00001468,0x00001466, +0x000012e7,0x00050084,0x00000006,0x00001469, +0x000000ec,0x00001468,0x00050080,0x00000006, +0x0000146a,0x000014b5,0x00001469,0x00050041, +0x00000266,0x0000146c,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x0000146d,0x0000146c, +0x00050041,0x00000937,0x0000146e,0x00000a18, +0x000012ea,0x0004003d,0x00000006,0x0000146f, +0x0000146e,0x00050051,0x00000006,0x000014d2, +0x0000146d,0x00000000,0x00050095,0x0000013d, +0x000014d4,0x000014d2,0x0000146a,0x00050051, +0x00000006,0x000014d5,0x000014d4,0x00000001, +0x00050051,0x00000006,0x000014d6,0x000014d4, +0x00000000,0x00050051,0x00000006,0x000014d9, +0x0000146d,0x00000001,0x00050080,0x00000006, +0x000014db,0x000014d9,0x000014d5,0x00050050, +0x00000007,0x000014dc,0x000014d6,0x000014db, +0x0004007c,0x00000014,0x000014cc,0x000014dc, +0x00060041,0x0000016c,0x000014c4,0x000014cc, +0x0000016b,0x0000016b,0x0005003e,0x000014c4, +0x0000146f,0x00000002,0x00000004,0x000200f9, +0x00001471,0x000200f8,0x00001471,0x000200f9, +0x000013fd,0x000200f8,0x000012e2,0x000500aa, +0x0000002f,0x000012ef,0x000012df,0x000001cd, +0x000300f7,0x000012f1,0x00000000,0x000400fa, +0x000012ef,0x000012f0,0x000012f1,0x000200f8, +0x000012f0,0x00050041,0x000001bb,0x000014df, +0x000001b9,0x000001ba,0x0004003d,0x00000006, +0x000014e0,0x000014df,0x00050084,0x00000006, +0x000014e1,0x000001db,0x000014e0,0x00050080, +0x00000006,0x000014e2,0x000001c4,0x000014e1, +0x00050080,0x00000006,0x000014f4,0x000014e0, +0x0000062f,0x00050086,0x00000006,0x000014f5, +0x000014f4,0x000001be,0x00050084,0x00000006, +0x000014e7,0x000001c4,0x000014f5,0x00050080, +0x00000006,0x000014e8,0x000014e2,0x000014e7, +0x00050084,0x00000006,0x000012f5,0x000001db, +0x000014f5,0x00050041,0x000012db,0x000012f7, +0x000012e4,0x00000138,0x0004003d,0x00000006, +0x000012f8,0x000012f7,0x00050080,0x00000006, +0x00001514,0x000012f5,0x00000a56,0x00050086, +0x00000006,0x00001515,0x00001514,0x000001c4, +0x00050084,0x00000006,0x00001518,0x000012f8, +0x00001515,0x0007000c,0x00000006,0x0000151a, +0x00000001,0x00000026,0x00001518,0x000012f5, +0x00050080,0x00000006,0x0000151d,0x0000151a, +0x00001515,0x0007000c,0x00000006,0x0000151f, +0x00000001,0x00000026,0x0000151d,0x000012f5, +0x000200f9,0x00001521,0x000200f8,0x00001521, +0x000700f5,0x00000006,0x00005fcd,0x00000138, +0x000012f0,0x0000152f,0x00001526,0x000700f5, +0x00000006,0x00005fcc,0x0000151a,0x000012f0, +0x00001532,0x00001526,0x000500b0,0x0000002f, +0x00001525,0x00005fcc,0x0000151f,0x000400f6, +0x00001533,0x00001526,0x00000000,0x000400fa, +0x00001525,0x00001526,0x00001533,0x000200f8, +0x00001526,0x00050084,0x00000006,0x00001529, +0x000000ec,0x00005fcc,0x00050080,0x00000006, +0x0000152a,0x000014e2,0x00001529,0x00050041, +0x00000266,0x0000152b,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x0000152c,0x0000152b, +0x00050051,0x00000006,0x0000158c,0x0000152c, +0x00000000,0x00050095,0x0000013d,0x0000158e, +0x0000158c,0x0000152a,0x00050051,0x00000006, +0x0000158f,0x0000158e,0x00000001,0x00050051, +0x00000006,0x00001590,0x0000158e,0x00000000, +0x00050051,0x00000006,0x00001593,0x0000152c, +0x00000001,0x00050080,0x00000006,0x00001595, +0x00001593,0x0000158f,0x00050050,0x00000007, +0x00001596,0x00001590,0x00001595,0x0004007c, +0x00000014,0x00001586,0x00001596,0x00060041, +0x0000016c,0x0000157d,0x00001586,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000157e, +0x0000157d,0x00000002,0x00000004,0x00050080, +0x00000006,0x0000152f,0x00005fcd,0x0000157e, +0x00050080,0x00000006,0x00001532,0x00005fcc, +0x00000264,0x000200f9,0x00001521,0x000200f8, +0x00001533,0x00050041,0x00000937,0x00001536, +0x00000a7f,0x000012f8,0x0003003e,0x00001536, +0x00005fcd,0x000400e0,0x00000280,0x00000280, +0x0000094f,0x000500aa,0x0000002f,0x00001538, +0x000012f8,0x00000138,0x000300f7,0x00001555, +0x00000000,0x000400fa,0x00001538,0x00001539, +0x00001555,0x000200f8,0x00001539,0x000200f9, +0x0000153a,0x000200f8,0x0000153a,0x000700f5, +0x00000006,0x00005fcf,0x00000138,0x00001539, +0x00001547,0x0000153e,0x000700f5,0x00000006, +0x00005fce,0x00000138,0x00001539,0x0000154a, +0x0000153e,0x000500b0,0x0000002f,0x0000153d, +0x00005fce,0x000001c4,0x000400f6,0x0000154b, +0x0000153e,0x00000000,0x000400fa,0x0000153d, +0x0000153e,0x0000154b,0x000200f8,0x0000153e, +0x00050041,0x00000937,0x00001540,0x00000a7f, +0x00005fce,0x0004003d,0x00000006,0x00001541, +0x00001540,0x0003003e,0x00001540,0x00005fcf, +0x00050080,0x00000006,0x00001547,0x00005fcf, +0x00001541,0x00050080,0x00000006,0x0000154a, +0x00005fce,0x00000264,0x000200f9,0x0000153a, +0x000200f8,0x0000154b,0x000200f9,0x00001555, +0x000200f8,0x00001555,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x0004003d,0x00000006, +0x00001558,0x00001536,0x000200f9,0x0000155a, +0x000200f8,0x0000155a,0x000700f5,0x00000006, +0x00005fd1,0x00001558,0x00001555,0x00001571, +0x0000155f,0x000700f5,0x00000006,0x00005fd0, +0x0000151a,0x00001555,0x00001574,0x0000155f, +0x000500b0,0x0000002f,0x0000155e,0x00005fd0, +0x0000151f,0x000400f6,0x00001575,0x0000155f, +0x00000000,0x000400fa,0x0000155e,0x0000155f, +0x00001575,0x000200f8,0x0000155f,0x00050084, +0x00000006,0x00001562,0x000000ec,0x00005fd0, +0x00050080,0x00000006,0x00001563,0x000014e2, +0x00001562,0x00050041,0x00000266,0x00001564, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x00001565,0x00001564,0x00050051,0x00000006, +0x000015cd,0x00001565,0x00000000,0x00050095, +0x0000013d,0x000015cf,0x000015cd,0x00001563, +0x00050051,0x00000006,0x000015d0,0x000015cf, +0x00000001,0x00050051,0x00000006,0x000015d1, +0x000015cf,0x00000000,0x00050051,0x00000006, +0x000015d4,0x00001565,0x00000001,0x00050080, +0x00000006,0x000015d6,0x000015d4,0x000015d0, +0x00050050,0x00000007,0x000015d7,0x000015d1, +0x000015d6,0x0004007c,0x00000014,0x000015c7, +0x000015d7,0x00060041,0x0000016c,0x000015be, +0x000015c7,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000015bf,0x000015be,0x00000002, +0x00000004,0x00050080,0x00000006,0x0000156a, +0x000014e8,0x00001562,0x00050095,0x0000013d, +0x000015ef,0x000015cd,0x0000156a,0x00050051, +0x00000006,0x000015f0,0x000015ef,0x00000001, +0x00050051,0x00000006,0x000015f1,0x000015ef, +0x00000000,0x00050080,0x00000006,0x000015f6, +0x000015d4,0x000015f0,0x00050050,0x00000007, +0x000015f7,0x000015f1,0x000015f6,0x0004007c, +0x00000014,0x000015e7,0x000015f7,0x00060041, +0x0000016c,0x000015df,0x000015e7,0x0000016b, +0x0000016b,0x0005003e,0x000015df,0x00005fd1, 0x00000002,0x00000004,0x00050080,0x00000006, -0x0000142b,0x00005b9d,0x0000147a,0x00050080, -0x00000006,0x0000142e,0x00005b9c,0x0000022b, -0x000200f9,0x0000141d,0x000200f8,0x0000142f, -0x00050041,0x00000838,0x00001432,0x00000980, -0x000011f9,0x0003003e,0x00001432,0x00005b9d, -0x000400e0,0x00000247,0x00000247,0x00000850, -0x000500aa,0x0000002f,0x00001434,0x000011f9, -0x0000012b,0x000300f7,0x00001451,0x00000000, -0x000400fa,0x00001434,0x00001435,0x00001451, -0x000200f8,0x00001435,0x000200f9,0x00001436, -0x000200f8,0x00001436,0x000700f5,0x00000006, -0x00005b9f,0x0000012b,0x00001435,0x00001443, -0x0000143a,0x000700f5,0x00000006,0x00005b9e, -0x0000012b,0x00001435,0x00001446,0x0000143a, -0x000500b0,0x0000002f,0x00001439,0x00005b9e, -0x0000018b,0x000400f6,0x00001447,0x0000143a, -0x00000000,0x000400fa,0x00001439,0x0000143a, -0x00001447,0x000200f8,0x0000143a,0x00050041, -0x00000838,0x0000143c,0x00000980,0x00005b9e, -0x0004003d,0x00000006,0x0000143d,0x0000143c, -0x0003003e,0x0000143c,0x00005b9f,0x00050080, -0x00000006,0x00001443,0x00005b9f,0x0000143d, -0x00050080,0x00000006,0x00001446,0x00005b9e, -0x0000022b,0x000200f9,0x00001436,0x000200f8, -0x00001447,0x000200f9,0x00001451,0x000200f8, -0x00001451,0x000400e0,0x00000247,0x00000247, -0x00000850,0x0004003d,0x00000006,0x00001454, -0x00001432,0x000200f9,0x00001456,0x000200f8, -0x00001456,0x000700f5,0x00000006,0x00005ba1, -0x00001454,0x00001451,0x0000146d,0x0000145b, -0x000700f5,0x00000006,0x00005ba0,0x00001416, -0x00001451,0x00001470,0x0000145b,0x000500b0, -0x0000002f,0x0000145a,0x00005ba0,0x0000141b, -0x000400f6,0x00001471,0x0000145b,0x00000000, -0x000400fa,0x0000145a,0x0000145b,0x00001471, -0x000200f8,0x0000145b,0x00050084,0x00000006, -0x0000145e,0x000000df,0x00005ba0,0x00050080, -0x00000006,0x0000145f,0x000013de,0x0000145e, -0x00050041,0x0000022d,0x00001460,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x00001461, -0x00001460,0x00050051,0x00000006,0x000014c9, -0x00001461,0x00000000,0x00050095,0x00000130, -0x000014cb,0x000014c9,0x0000145f,0x00050051, -0x00000006,0x000014cc,0x000014cb,0x00000001, -0x00050051,0x00000006,0x000014cd,0x000014cb, -0x00000000,0x00050051,0x00000006,0x000014d0, -0x00001461,0x00000001,0x00050080,0x00000006, -0x000014d2,0x000014d0,0x000014cc,0x00050050, -0x00000007,0x000014d3,0x000014cd,0x000014d2, -0x0004007c,0x00000014,0x000014c3,0x000014d3, -0x00060041,0x0000015f,0x000014ba,0x000014c3, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x000014bb,0x000014ba,0x00000002,0x00000004, -0x00050080,0x00000006,0x00001466,0x000013e4, -0x0000145e,0x00050095,0x00000130,0x000014eb, -0x000014c9,0x00001466,0x00050051,0x00000006, -0x000014ec,0x000014eb,0x00000001,0x00050051, -0x00000006,0x000014ed,0x000014eb,0x00000000, -0x00050080,0x00000006,0x000014f2,0x000014d0, -0x000014ec,0x00050050,0x00000007,0x000014f3, -0x000014ed,0x000014f2,0x0004007c,0x00000014, -0x000014e3,0x000014f3,0x00060041,0x0000015f, -0x000014db,0x000014e3,0x0000015e,0x0000015e, -0x0005003e,0x000014db,0x00005ba1,0x00000002, -0x00000004,0x00050080,0x00000006,0x0000146d, -0x00005ba1,0x000014bb,0x00050080,0x00000006, -0x00001470,0x00005ba0,0x0000022b,0x000200f9, -0x00001456,0x000200f8,0x00001471,0x000200f9, -0x000012fe,0x000200f8,0x000011f2,0x000500aa, -0x0000002f,0x00001202,0x000011e0,0x0000050a, -0x000300f7,0x00001204,0x00000000,0x000400fa, -0x00001202,0x00001203,0x00001204,0x000200f8, -0x00001203,0x00050041,0x000011dc,0x00001206, -0x000011e4,0x0000012b,0x0004003d,0x00000006, -0x00001207,0x00001206,0x00050041,0x000011dc, -0x00001209,0x000011e5,0x0000012b,0x0004003d, -0x00000006,0x0000120a,0x00001209,0x000500b0, -0x0000002f,0x00001514,0x0000120a,0x000001a2, -0x000300f7,0x00001523,0x00000000,0x000400fa, -0x00001514,0x00001515,0x00001523,0x000200f8, -0x00001515,0x00050041,0x00000182,0x000015cb, -0x00000180,0x00000181,0x0004003d,0x00000006, -0x000015cc,0x000015cb,0x00050084,0x00000006, -0x000015cd,0x000001a2,0x000015cc,0x00050080, -0x00000006,0x000015ce,0x0000018b,0x000015cd, -0x00050080,0x00000006,0x000015d4,0x000015cc, -0x00005cc3,0x00050086,0x00000006,0x000015d5, -0x000015d4,0x00000185,0x00050084,0x00000006, -0x000015c7,0x0000018b,0x000015d5,0x00050080, -0x00000006,0x000015c8,0x000015ce,0x000015c7, -0x00050084,0x00000006,0x0000151a,0x0000120a, -0x000015d5,0x00050080,0x00000006,0x0000151c, -0x0000151a,0x00001207,0x00050084,0x00000006, -0x0000151d,0x000000df,0x0000151c,0x00050080, -0x00000006,0x0000151e,0x000015c8,0x0000151d, -0x00050041,0x0000022d,0x0000151f,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x00001520, -0x0000151f,0x00050051,0x00000006,0x000015f3, -0x00001520,0x00000000,0x00050095,0x00000130, -0x000015f5,0x000015f3,0x0000151e,0x00050051, -0x00000006,0x000015f6,0x000015f5,0x00000001, -0x00050051,0x00000006,0x000015f7,0x000015f5, -0x00000000,0x00050051,0x00000006,0x000015fa, -0x00001520,0x00000001,0x00050080,0x00000006, -0x000015fc,0x000015fa,0x000015f6,0x00050050, -0x00000007,0x000015fd,0x000015f7,0x000015fc, -0x0004007c,0x00000014,0x000015ed,0x000015fd, -0x00060041,0x0000015f,0x000015e4,0x000015ed, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x000015e5,0x000015e4,0x00000002,0x00000004, -0x00050041,0x00000838,0x00001522,0x000009d5, -0x0000120a,0x0003003e,0x00001522,0x000015e5, -0x000200f9,0x00001523,0x000200f8,0x00001523, -0x00050084,0x00000006,0x00001525,0x00001207, -0x00000185,0x00050080,0x00000006,0x00001527, -0x00001525,0x00000185,0x00050041,0x00000182, -0x00001528,0x00000180,0x00000181,0x0004003d, -0x00000006,0x00001529,0x00001528,0x0007000c, -0x00000006,0x0000152a,0x00000001,0x00000026, -0x00001527,0x00001529,0x000200f9,0x0000152c, -0x000200f8,0x0000152c,0x000700f5,0x00000006, -0x00005b83,0x00001525,0x00001523,0x000015c1, -0x000015bf,0x000500b0,0x0000002f,0x00001530, -0x00005b83,0x0000152a,0x000400f6,0x000015c2, -0x000015bf,0x00000000,0x000400fa,0x00001530, -0x00001531,0x000015c2,0x000200f8,0x00001531, -0x00050080,0x00000006,0x00001534,0x00005b83, -0x0000120a,0x000500b0,0x0000002f,0x00001537, -0x00001534,0x0000152a,0x000300f7,0x00001542, -0x00000000,0x000400fa,0x00001537,0x00001539, -0x00001541,0x000200f8,0x00001541,0x000200f9, -0x00001542,0x000200f8,0x00001539,0x00050041, -0x00000182,0x00001601,0x00000180,0x00000488, -0x0004003d,0x00000006,0x00001602,0x00001601, -0x000500c7,0x00000006,0x00001603,0x00001602, -0x00000135,0x000500aa,0x0000002f,0x00001604, -0x00001603,0x0000012b,0x000300f7,0x00001609, -0x00000000,0x000400fa,0x00001604,0x00001605, -0x00001607,0x000200f8,0x00001607,0x00050084, -0x00000006,0x00001611,0x00000194,0x00001529, -0x00050080,0x00000006,0x00001612,0x0000018b, -0x00001611,0x000200f9,0x00001609,0x000200f8, -0x00001605,0x000200f9,0x00001609,0x000200f8, -0x00001609,0x000700f5,0x00000006,0x00005b84, -0x0000018b,0x00001605,0x00001612,0x00001607, -0x00050084,0x00000006,0x0000153c,0x000000df, -0x00001534,0x00050080,0x00000006,0x0000153d, -0x00005b84,0x0000153c,0x00050041,0x0000022d, -0x0000153e,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x0000153f,0x0000153e,0x00050051, -0x00000006,0x00001629,0x0000153f,0x00000000, -0x00050095,0x00000130,0x0000162b,0x00001629, -0x0000153d,0x00050051,0x00000006,0x0000162c, -0x0000162b,0x00000001,0x00050051,0x00000006, -0x0000162d,0x0000162b,0x00000000,0x00050051, -0x00000006,0x00001630,0x0000153f,0x00000001, -0x00050080,0x00000006,0x00001632,0x00001630, -0x0000162c,0x00050050,0x00000007,0x00001633, -0x0000162d,0x00001632,0x0004007c,0x00000014, -0x00001623,0x00001633,0x00060041,0x0000015f, -0x0000161a,0x00001623,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x0000161b,0x0000161a, -0x00000002,0x00000004,0x000200f9,0x00001542, -0x000200f8,0x00001542,0x000700f5,0x00000006, -0x00005b85,0x0000161b,0x00001609,0x0000012b, -0x00001541,0x000300f7,0x0000154e,0x00000000, -0x000400fa,0x00001537,0x00001545,0x0000154d, -0x000200f8,0x0000154d,0x000200f9,0x0000154e, -0x000200f8,0x00001545,0x00050041,0x00000182, -0x00001637,0x00000180,0x00000488,0x0004003d, -0x00000006,0x00001638,0x00001637,0x000500c7, -0x00000006,0x00001639,0x00001638,0x00000135, -0x000500aa,0x0000002f,0x0000163a,0x00001639, -0x0000012b,0x000300f7,0x0000163f,0x00000000, -0x000400fa,0x0000163a,0x0000163b,0x0000163d, -0x000200f8,0x0000163d,0x00050084,0x00000006, -0x0000164b,0x0000019b,0x00001529,0x00050080, -0x00000006,0x0000164c,0x0000018b,0x0000164b, -0x000200f9,0x0000163f,0x000200f8,0x0000163b, -0x00050084,0x00000006,0x00001645,0x000000df, -0x00001529,0x00050080,0x00000006,0x00001646, -0x0000018b,0x00001645,0x000200f9,0x0000163f, -0x000200f8,0x0000163f,0x000700f5,0x00000006, -0x00005b86,0x00001646,0x0000163b,0x0000164c, -0x0000163d,0x00050084,0x00000006,0x00001548, -0x000000df,0x00001534,0x00050080,0x00000006, -0x00001549,0x00005b86,0x00001548,0x00050041, -0x0000022d,0x0000154a,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x0000154b,0x0000154a, -0x00050051,0x00000006,0x00001663,0x0000154b, -0x00000000,0x00050095,0x00000130,0x00001665, -0x00001663,0x00001549,0x00050051,0x00000006, -0x00001666,0x00001665,0x00000001,0x00050051, -0x00000006,0x00001667,0x00001665,0x00000000, -0x00050051,0x00000006,0x0000166a,0x0000154b, -0x00000001,0x00050080,0x00000006,0x0000166c, -0x0000166a,0x00001666,0x00050050,0x00000007, -0x0000166d,0x00001667,0x0000166c,0x0004007c, -0x00000014,0x0000165d,0x0000166d,0x00060041, -0x0000015f,0x00001654,0x0000165d,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00001655, -0x00001654,0x00000002,0x00000004,0x000200f9, -0x0000154e,0x000200f8,0x0000154e,0x000700f5, -0x00000006,0x00005b87,0x00001655,0x0000163f, -0x0000012b,0x0000154d,0x00050041,0x00000182, -0x00001671,0x00000180,0x00000488,0x0004003d, -0x00000006,0x00001672,0x00001671,0x00050084, -0x00000006,0x00001673,0x000000df,0x00001672, -0x000500c2,0x00000006,0x00001674,0x00005b85, -0x00001673,0x000500c7,0x00000006,0x00001675, -0x00001674,0x0000090f,0x000200f9,0x00001552, -0x000200f8,0x00001552,0x000700f5,0x00000006, -0x00005b88,0x0000012b,0x0000154e,0x00001562, -0x00001556,0x000500b0,0x0000002f,0x00001555, -0x00005b88,0x000001a2,0x000400f6,0x00001563, -0x00001556,0x00000000,0x000400fa,0x00001555, -0x00001556,0x00001563,0x000200f8,0x00001556, -0x000500aa,0x0000002f,0x0000155c,0x00005b88, -0x00001675,0x000500a7,0x0000002f,0x0000155d, -0x00001537,0x0000155c,0x000600a9,0x00000006, -0x0000155e,0x0000155d,0x00000135,0x0000012b, -0x00060041,0x00000838,0x0000155f,0x00000a2e, -0x00005b88,0x0000120a,0x0003003e,0x0000155f, -0x0000155e,0x00050080,0x00000006,0x00001562, -0x00005b88,0x0000022b,0x000200f9,0x00001552, -0x000200f8,0x00001563,0x000400e0,0x00000247, -0x00000247,0x00000850,0x000200f9,0x00001564, -0x000200f8,0x00001564,0x000700f5,0x00000006, -0x00005b89,0x00000135,0x00001563,0x00001595, -0x00001593,0x000500b0,0x0000002f,0x00001567, -0x00005b89,0x0000018b,0x000400f6,0x00001596, -0x00001593,0x00000000,0x000400fa,0x00001567, -0x00001568,0x00001596,0x000200f8,0x00001568, -0x000200f9,0x00001569,0x000200f8,0x00001569, -0x000700f5,0x00000006,0x00005b96,0x0000012b, -0x00001568,0x0000157f,0x0000157d,0x000500b0, -0x0000002f,0x0000156c,0x00005b96,0x000001a2, -0x000400f6,0x00001580,0x0000157d,0x00000000, -0x000400fa,0x0000156c,0x0000156d,0x00001580, -0x000200f8,0x0000156d,0x000500ae,0x0000002f, -0x00001571,0x0000120a,0x00005b89,0x000300f7, -0x0000157a,0x00000000,0x000400fa,0x00001571, -0x00001572,0x00001579,0x000200f8,0x00001579, -0x000200f9,0x0000157a,0x000200f8,0x00001572, -0x00050082,0x00000006,0x00001576,0x0000120a, -0x00005b89,0x00060041,0x00000838,0x00001577, -0x00000a2e,0x00005b96,0x00001576,0x0004003d, -0x00000006,0x00001578,0x00001577,0x000200f9, -0x0000157a,0x000200f8,0x0000157a,0x000700f5, -0x00000006,0x00005b9a,0x00001578,0x00001572, -0x0000012b,0x00001579,0x00050041,0x00000009, -0x0000157c,0x00001508,0x00005b96,0x0003003e, -0x0000157c,0x00005b9a,0x000200f9,0x0000157d, -0x000200f8,0x0000157d,0x00050080,0x00000006, -0x0000157f,0x00005b96,0x0000022b,0x000200f9, -0x00001569,0x000200f8,0x00001580,0x000400e0, -0x00000247,0x00000247,0x00000850,0x000200f9, -0x00001581,0x000200f8,0x00001581,0x000700f5, -0x00000006,0x00005b97,0x0000012b,0x00001580, -0x00001591,0x00001585,0x000500b0,0x0000002f, -0x00001584,0x00005b97,0x000001a2,0x000400f6, -0x00001592,0x00001585,0x00000000,0x000400fa, -0x00001584,0x00001585,0x00001592,0x000200f8, -0x00001585,0x00050041,0x00000009,0x00001589, -0x00001508,0x00005b97,0x0004003d,0x00000006, -0x0000158a,0x00001589,0x00060041,0x00000838, -0x0000158b,0x00000a2e,0x00005b97,0x0000120a, -0x0004003d,0x00000006,0x0000158c,0x0000158b, -0x00050080,0x00000006,0x0000158d,0x0000158c, -0x0000158a,0x0003003e,0x0000158b,0x0000158d, -0x00050080,0x00000006,0x00001591,0x00005b97, -0x0000022b,0x000200f9,0x00001581,0x000200f8, -0x00001592,0x000400e0,0x00000247,0x00000247, -0x00000850,0x000200f9,0x00001593,0x000200f8, -0x00001593,0x000500c4,0x00000006,0x00001595, -0x00005b89,0x0000022b,0x000200f9,0x00001564, -0x000200f8,0x00001596,0x000300f7,0x000015b2, -0x00000000,0x000400fa,0x00001537,0x00001598, -0x000015b2,0x000200f8,0x00001598,0x00050041, -0x00000838,0x0000159a,0x000009d5,0x00001675, -0x0004003d,0x00000006,0x0000159b,0x0000159a, -0x00060041,0x00000838,0x0000159e,0x00000a2e, -0x00001675,0x0000120a,0x0004003d,0x00000006, -0x0000159f,0x0000159e,0x00050080,0x00000006, -0x000015a0,0x0000159b,0x0000159f,0x00050082, -0x00000006,0x000015a1,0x000015a0,0x00000135, -0x000500c7,0x00000006,0x0000167b,0x00001672, -0x00000135,0x000500aa,0x0000002f,0x0000167c, -0x0000167b,0x0000012b,0x000300f7,0x00001681, -0x00000000,0x000400fa,0x0000167c,0x0000167d, -0x0000167f,0x000200f8,0x0000167f,0x000200f9, -0x00001681,0x000200f8,0x0000167d,0x00050084, -0x00000006,0x00001687,0x00000194,0x00001529, -0x00050080,0x00000006,0x00001688,0x0000018b, -0x00001687,0x000200f9,0x00001681,0x000200f8, -0x00001681,0x000700f5,0x00000006,0x00005b8a, -0x00001688,0x0000167d,0x0000018b,0x0000167f, -0x00050084,0x00000006,0x000015a4,0x000000df, -0x000015a1,0x00050080,0x00000006,0x000015a5, -0x00005b8a,0x000015a4,0x00050041,0x0000022d, -0x000015a6,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x000015a7,0x000015a6,0x00050051, -0x00000006,0x000016a0,0x000015a7,0x00000000, -0x00050095,0x00000130,0x000016a2,0x000016a0, -0x000015a5,0x00050051,0x00000006,0x000016a3, -0x000016a2,0x00000001,0x00050051,0x00000006, -0x000016a4,0x000016a2,0x00000000,0x00050051, -0x00000006,0x000016a7,0x000015a7,0x00000001, -0x00050080,0x00000006,0x000016a9,0x000016a7, -0x000016a3,0x00050050,0x00000007,0x000016aa, -0x000016a4,0x000016a9,0x0004007c,0x00000014, -0x0000169a,0x000016aa,0x00060041,0x0000015f, -0x00001692,0x0000169a,0x0000015e,0x0000015e, -0x0005003e,0x00001692,0x00005b85,0x00000002, -0x00000004,0x000300f7,0x000016b6,0x00000000, -0x000400fa,0x0000167c,0x000016b2,0x000016b4, -0x000200f8,0x000016b4,0x00050084,0x00000006, -0x000016c2,0x000000df,0x00001529,0x00050080, -0x00000006,0x000016c3,0x0000018b,0x000016c2, -0x000200f9,0x000016b6,0x000200f8,0x000016b2, -0x00050084,0x00000006,0x000016bc,0x0000019b, -0x00001529,0x00050080,0x00000006,0x000016bd, -0x0000018b,0x000016bc,0x000200f9,0x000016b6, -0x000200f8,0x000016b6,0x000700f5,0x00000006, -0x00005b8b,0x000016bd,0x000016b2,0x000016c3, -0x000016b4,0x00050080,0x00000006,0x000015ad, -0x00005b8b,0x000015a4,0x00050095,0x00000130, -0x000016db,0x000016a0,0x000015ad,0x00050051, -0x00000006,0x000016dc,0x000016db,0x00000001, -0x00050051,0x00000006,0x000016dd,0x000016db, -0x00000000,0x00050080,0x00000006,0x000016e2, -0x000016a7,0x000016dc,0x00050050,0x00000007, -0x000016e3,0x000016dd,0x000016e2,0x0004007c, -0x00000014,0x000016d3,0x000016e3,0x00060041, -0x0000015f,0x000016cb,0x000016d3,0x0000015e, -0x0000015e,0x0005003e,0x000016cb,0x00005b87, -0x00000002,0x00000004,0x000200f9,0x000015b2, -0x000200f8,0x000015b2,0x000400e0,0x00000247, -0x00000247,0x00000850,0x000300f7,0x000015be, -0x00000000,0x000400fa,0x00001514,0x000015b5, -0x000015be,0x000200f8,0x000015b5,0x00060041, -0x00000838,0x000015b8,0x00000a2e,0x0000120a, -0x00000a9c,0x0004003d,0x00000006,0x000015b9, -0x000015b8,0x00050041,0x00000838,0x000015ba, -0x000009d5,0x0000120a,0x0004003d,0x00000006, -0x000015bb,0x000015ba,0x00050080,0x00000006, -0x000015bc,0x000015bb,0x000015b9,0x0003003e, -0x000015ba,0x000015bc,0x000200f9,0x000015be, -0x000200f8,0x000015be,0x000400e0,0x00000247, -0x00000247,0x00000850,0x000200f9,0x000015bf, -0x000200f8,0x000015bf,0x00050080,0x00000006, -0x000015c1,0x00005b83,0x0000018b,0x000200f9, -0x0000152c,0x000200f8,0x000015c2,0x000200f9, -0x000012fe,0x000200f8,0x00001204,0x000500aa, -0x0000002f,0x00001210,0x000011e0,0x0000120f, -0x000300f7,0x00001212,0x00000000,0x000400fa, -0x00001210,0x00001211,0x00001212,0x000200f8, -0x00001211,0x00050041,0x000011dc,0x00001214, -0x000011e5,0x0000012b,0x0004003d,0x00000006, -0x00001215,0x00001214,0x00050041,0x00000182, -0x000016fe,0x00000180,0x00000181,0x0004003d, -0x00000006,0x000016ff,0x000016fe,0x000200f9, -0x00001700,0x000200f8,0x00001700,0x000700f5, -0x00000006,0x00005b6e,0x00000135,0x00001211, -0x00001707,0x00001705,0x000500b0,0x0000002f, -0x00001704,0x00005b6e,0x000016ff,0x000400f6, -0x00001709,0x00001705,0x00000000,0x000400fa, -0x00001704,0x00001705,0x00001709,0x000200f8, -0x00001705,0x000500c4,0x00000006,0x00001707, -0x00005b6e,0x0000022b,0x000200f9,0x00001700, -0x000200f8,0x00001709,0x000200f9,0x0000170b, -0x000200f8,0x0000170b,0x000700f5,0x00000006, -0x00005b6f,0x00001215,0x00001709,0x00001733, -0x00001731,0x000500b0,0x0000002f,0x0000170f, -0x00005b6f,0x00005b6e,0x000400f6,0x00001734, -0x00001731,0x00000000,0x000400fa,0x0000170f, -0x00001710,0x00001734,0x000200f8,0x00001710, -0x000500b0,0x0000002f,0x00001714,0x00005b6f, -0x000016ff,0x000300f7,0x0000171e,0x00000000, -0x000400fa,0x00001714,0x00001715,0x0000171d, -0x000200f8,0x0000171d,0x000200f9,0x0000171e, -0x000200f8,0x00001715,0x00050084,0x00000006, -0x00001718,0x000000df,0x00005b6f,0x00050080, -0x00000006,0x00001719,0x0000018b,0x00001718, -0x00050041,0x0000022d,0x0000171a,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x0000171b, -0x0000171a,0x00050051,0x00000006,0x000017c2, -0x0000171b,0x00000000,0x00050095,0x00000130, -0x000017c4,0x000017c2,0x00001719,0x00050051, -0x00000006,0x000017c5,0x000017c4,0x00000001, -0x00050051,0x00000006,0x000017c6,0x000017c4, -0x00000000,0x00050051,0x00000006,0x000017c9, -0x0000171b,0x00000001,0x00050080,0x00000006, -0x000017cb,0x000017c9,0x000017c5,0x00050050, -0x00000007,0x000017cc,0x000017c6,0x000017cb, -0x0004007c,0x00000014,0x000017bc,0x000017cc, -0x00060041,0x0000015f,0x000017b3,0x000017bc, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x000017b4,0x000017b3,0x00000002,0x00000004, -0x000200f9,0x0000171e,0x000200f8,0x0000171e, -0x000700f5,0x00000006,0x00005b7f,0x000017b4, -0x00001715,0x00000500,0x0000171d,0x00050041, -0x00000838,0x00001720,0x00000825,0x00005b6f, -0x0003003e,0x00001720,0x00005b7f,0x000300f7, -0x0000172e,0x00000000,0x000400fa,0x00001714, -0x00001725,0x0000172d,0x000200f8,0x0000172d, -0x000200f9,0x0000172e,0x000200f8,0x00001725, -0x00050084,0x00000006,0x000017d1,0x000000df, -0x000016ff,0x00050080,0x00000006,0x000017d2, -0x0000018b,0x000017d1,0x00050084,0x00000006, -0x00001728,0x000000df,0x00005b6f,0x00050080, -0x00000006,0x00001729,0x000017d2,0x00001728, -0x00050041,0x0000022d,0x0000172a,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x0000172b, -0x0000172a,0x00050051,0x00000006,0x000017e9, -0x0000172b,0x00000000,0x00050095,0x00000130, -0x000017eb,0x000017e9,0x00001729,0x00050051, -0x00000006,0x000017ec,0x000017eb,0x00000001, -0x00050051,0x00000006,0x000017ed,0x000017eb, -0x00000000,0x00050051,0x00000006,0x000017f0, -0x0000172b,0x00000001,0x00050080,0x00000006, -0x000017f2,0x000017f0,0x000017ec,0x00050050, -0x00000007,0x000017f3,0x000017ed,0x000017f2, -0x0004007c,0x00000014,0x000017e3,0x000017f3, -0x00060041,0x0000015f,0x000017da,0x000017e3, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x000017db,0x000017da,0x00000002,0x00000004, -0x000200f9,0x0000172e,0x000200f8,0x0000172e, -0x000700f5,0x00000006,0x00005b81,0x000017db, -0x00001725,0x00000500,0x0000172d,0x00050041, -0x00000838,0x00001730,0x0000083a,0x00005b6f, -0x0003003e,0x00001730,0x00005b81,0x000200f9, -0x00001731,0x000200f8,0x00001731,0x00050080, -0x00000006,0x00001733,0x00005b6f,0x0000018b, -0x000200f9,0x0000170b,0x000200f8,0x00001734, -0x000400e0,0x00000247,0x00000247,0x00000850, -0x000200f9,0x00001735,0x000200f8,0x00001735, -0x000700f5,0x00000006,0x00005b71,0x00000247, -0x00001734,0x00001789,0x00001787,0x000500b2, -0x0000002f,0x00001739,0x00005b71,0x00005b6e, -0x000400f6,0x0000178a,0x00001787,0x00000000, -0x000400fa,0x00001739,0x0000173a,0x0000178a, -0x000200f8,0x0000173a,0x000500c2,0x00000006, -0x0000173c,0x00005b71,0x0000022b,0x000200f9, -0x0000173d,0x000200f8,0x0000173d,0x000700f5, -0x00000006,0x00005b74,0x0000173c,0x0000173a, -0x00001785,0x00001783,0x000500ac,0x0000002f, -0x00001740,0x00005b74,0x0000012b,0x000400f6, -0x00001786,0x00001783,0x00000000,0x000400fa, -0x00001740,0x00001741,0x00001786,0x000200f8, -0x00001741,0x000200f9,0x00001743,0x000200f8, -0x00001743,0x000700f5,0x00000006,0x00005b76, -0x00001215,0x00001741,0x00001781,0x0000177f, -0x000500b0,0x0000002f,0x00001747,0x00005b76, -0x00005b6e,0x000400f6,0x00001782,0x0000177f, -0x00000000,0x000400fa,0x00001747,0x00001748, -0x00001782,0x000200f8,0x00001748,0x000500c6, -0x00000006,0x0000174b,0x00005b76,0x00005b74, -0x000500ac,0x0000002f,0x0000174e,0x0000174b, -0x00005b76,0x000300f7,0x0000177e,0x00000000, -0x000400fa,0x0000174e,0x0000174f,0x0000177e, -0x000200f8,0x0000174f,0x00050041,0x00000838, -0x00001751,0x00000825,0x00005b76,0x0004003d, -0x00000006,0x00001752,0x00001751,0x00050041, -0x00000838,0x00001754,0x00000825,0x0000174b, -0x0004003d,0x00000006,0x00001755,0x00001754, -0x00050041,0x00000838,0x00001757,0x0000083a, -0x00005b76,0x0004003d,0x00000006,0x00001758, -0x00001757,0x00050041,0x00000838,0x0000175a, -0x0000083a,0x0000174b,0x0004003d,0x00000006, -0x0000175b,0x0000175a,0x000500ac,0x0000002f, -0x0000175e,0x00001752,0x00001755,0x000400a8, -0x0000002f,0x0000175f,0x0000175e,0x000300f7, -0x00001768,0x00000000,0x000400fa,0x0000175f, -0x00001760,0x00001768,0x000200f8,0x00001760, -0x000500aa,0x0000002f,0x00001763,0x00001752, -0x00001755,0x000500ac,0x0000002f,0x00001766, -0x00001758,0x0000175b,0x000500a7,0x0000002f, -0x00001767,0x00001763,0x00001766,0x000200f9, -0x00001768,0x000200f8,0x00001768,0x000700f5, -0x0000002f,0x00001769,0x0000175e,0x0000174f, -0x00001767,0x00001760,0x000500c7,0x00000006, -0x0000176d,0x00005b76,0x00005b71,0x000500aa, -0x0000002f,0x0000176e,0x0000176d,0x0000012b, -0x000500a4,0x0000002f,0x0000176f,0x00001769, -0x0000176e,0x000300f7,0x0000177d,0x00000000, -0x000400fa,0x0000176f,0x00001770,0x0000177d, -0x000200f8,0x00001770,0x0003003e,0x00001751, -0x00001755,0x0003003e,0x00001754,0x00001752, -0x0003003e,0x00001757,0x0000175b,0x0003003e, -0x0000175a,0x00001758,0x000200f9,0x0000177d, -0x000200f8,0x0000177d,0x000200f9,0x0000177e, -0x000200f8,0x0000177e,0x000200f9,0x0000177f, -0x000200f8,0x0000177f,0x00050080,0x00000006, -0x00001781,0x00005b76,0x0000018b,0x000200f9, -0x00001743,0x000200f8,0x00001782,0x000400e0, -0x00000247,0x00000247,0x00000850,0x000200f9, -0x00001783,0x000200f8,0x00001783,0x000500c2, -0x00000006,0x00001785,0x00005b74,0x0000022b, -0x000200f9,0x0000173d,0x000200f8,0x00001786, -0x000200f9,0x00001787,0x000200f8,0x00001787, -0x000500c4,0x00000006,0x00001789,0x00005b71, -0x0000022b,0x000200f9,0x00001735,0x000200f8, -0x0000178a,0x000200f9,0x0000178c,0x000200f8, -0x0000178c,0x000700f5,0x00000006,0x00005b73, -0x00001215,0x0000178a,0x000017a8,0x00001791, -0x000500b0,0x0000002f,0x00001790,0x00005b73, -0x000016ff,0x000400f6,0x000017a9,0x00001791, -0x00000000,0x000400fa,0x00001790,0x00001791, -0x000017a9,0x000200f8,0x00001791,0x00050084, -0x00000006,0x00001794,0x000000df,0x00005b73, -0x00050080,0x00000006,0x00001795,0x0000018b, -0x00001794,0x00050041,0x0000022d,0x00001797, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x00001798,0x00001797,0x00050041,0x00000838, -0x00001799,0x00000825,0x00005b73,0x0004003d, -0x00000006,0x0000179a,0x00001799,0x00050051, -0x00000006,0x0000180b,0x00001798,0x00000000, -0x00050095,0x00000130,0x0000180d,0x0000180b, -0x00001795,0x00050051,0x00000006,0x0000180e, -0x0000180d,0x00000001,0x00050051,0x00000006, -0x0000180f,0x0000180d,0x00000000,0x00050051, -0x00000006,0x00001812,0x00001798,0x00000001, -0x00050080,0x00000006,0x00001814,0x00001812, -0x0000180e,0x00050050,0x00000007,0x00001815, -0x0000180f,0x00001814,0x0004007c,0x00000014, -0x00001805,0x00001815,0x00060041,0x0000015f, -0x000017fd,0x00001805,0x0000015e,0x0000015e, -0x0005003e,0x000017fd,0x0000179a,0x00000002, -0x00000004,0x00050084,0x00000006,0x0000181a, -0x000000df,0x000016ff,0x00050080,0x00000006, -0x0000181b,0x0000018b,0x0000181a,0x00050080, -0x00000006,0x0000179f,0x0000181b,0x00001794, -0x00050041,0x00000838,0x000017a3,0x0000083a, -0x00005b73,0x0004003d,0x00000006,0x000017a4, -0x000017a3,0x00050095,0x00000130,0x00001833, -0x0000180b,0x0000179f,0x00050051,0x00000006, -0x00001834,0x00001833,0x00000001,0x00050051, -0x00000006,0x00001835,0x00001833,0x00000000, -0x00050080,0x00000006,0x0000183a,0x00001812, -0x00001834,0x00050050,0x00000007,0x0000183b, -0x00001835,0x0000183a,0x0004007c,0x00000014, -0x0000182b,0x0000183b,0x00060041,0x0000015f, -0x00001823,0x0000182b,0x0000015e,0x0000015e, -0x0005003e,0x00001823,0x000017a4,0x00000002, -0x00000004,0x00050080,0x00000006,0x000017a8, -0x00005b73,0x0000018b,0x000200f9,0x0000178c, -0x000200f8,0x000017a9,0x000200f9,0x000012fe, -0x000200f8,0x00001212,0x000500aa,0x0000002f, -0x0000121b,0x000011e0,0x0000121a,0x000300f7, -0x0000121d,0x00000000,0x000400fa,0x0000121b, -0x0000121c,0x0000121d,0x000200f8,0x0000121c, -0x00050041,0x000011dc,0x0000121f,0x000011e4, -0x0000012b,0x0004003d,0x00000006,0x00001220, -0x0000121f,0x00050041,0x000011dc,0x00001222, -0x000011e5,0x0000012b,0x0004003d,0x00000006, -0x00001223,0x00001222,0x000500aa,0x0000002f, -0x0000184f,0x00001223,0x0000012b,0x000300f7, -0x00001851,0x00000000,0x000400fa,0x0000184f, -0x00001850,0x00001851,0x000200f8,0x00001850, -0x0003003e,0x00000d70,0x0000012b,0x000200f9, -0x00001851,0x000200f8,0x00001851,0x000400e0, -0x00000247,0x00000247,0x00000850,0x00050084, -0x00000006,0x00001853,0x00001220,0x00000185, -0x00050080,0x00000006,0x00001855,0x00001853, -0x00000185,0x00050041,0x00000182,0x000018a1, -0x00000180,0x000001b7,0x0004003d,0x00000006, -0x000018a2,0x000018a1,0x000500ac,0x0000002f, -0x000018a3,0x000018a2,0x00000135,0x000300f7, -0x000018a9,0x00000000,0x000400fa,0x000018a3, -0x000018a4,0x000018a8,0x000200f8,0x000018a8, -0x000200f9,0x000018a9,0x000200f8,0x000018a4, -0x00050082,0x00000006,0x000018a7,0x000018a2, -0x00000135,0x000200f9,0x000018a9,0x000200f8, -0x000018a9,0x000700f5,0x00000006,0x00005b50, -0x000018a7,0x000018a4,0x0000012b,0x000018a8, -0x0007000c,0x00000006,0x00001857,0x00000001, -0x00000026,0x00001855,0x00005b50,0x00050080, -0x00000006,0x0000185a,0x00001853,0x00001223, -0x000200f9,0x0000185b,0x000200f8,0x0000185b, -0x000700f5,0x00000006,0x00005b51,0x0000185a, -0x000018a9,0x00001890,0x0000188e,0x000500b0, -0x0000002f,0x0000185f,0x00005b51,0x00001857, -0x000400f6,0x00001891,0x0000188e,0x00000000, -0x000400fa,0x0000185f,0x00001860,0x00001891, -0x000200f8,0x00001860,0x00050041,0x00000182, -0x000018d3,0x00000180,0x00000181,0x0004003d, -0x00000006,0x000018d4,0x000018d3,0x00050084, -0x00000006,0x000018d5,0x000001a2,0x000018d4, -0x00050080,0x00000006,0x000018d6,0x0000018b, -0x000018d5,0x00050080,0x00000006,0x000018dc, -0x000018d4,0x00005cc3,0x00050086,0x00000006, -0x000018dd,0x000018dc,0x00000185,0x00050084, -0x00000006,0x000018cf,0x0000018b,0x000018dd, -0x00050080,0x00000006,0x000018d0,0x000018d6, -0x000018cf,0x00050080,0x00000006,0x000018ca, -0x000018d0,0x000018cf,0x00050084,0x00000006, -0x000018c3,0x000001b6,0x000018a2,0x00050080, -0x00000006,0x000018c4,0x000018ca,0x000018c3, -0x00050041,0x00000182,0x000018ba,0x00000180, -0x000001cd,0x0004003d,0x00000006,0x000018bb, -0x000018ba,0x00050084,0x00000006,0x000018bc, -0x000001cc,0x000018bb,0x00050080,0x00000006, -0x000018bd,0x000018c4,0x000018bc,0x000300f7, -0x000018f0,0x00000000,0x000400fa,0x000018a3, -0x000018eb,0x000018ef,0x000200f8,0x000018ef, -0x000200f9,0x000018f0,0x000200f8,0x000018eb, -0x00050082,0x00000006,0x000018ee,0x000018a2, -0x00000135,0x000200f9,0x000018f0,0x000200f8, -0x000018f0,0x000700f5,0x00000006,0x00005b57, -0x000018ee,0x000018eb,0x0000012b,0x000018ef, -0x00050084,0x00000006,0x000018b5,0x000000df, -0x00005b57,0x00050080,0x00000006,0x000018b6, -0x000018bd,0x000018b5,0x000300f7,0x000018fd, -0x00000000,0x000400fa,0x000018a3,0x000018f8, -0x000018fc,0x000200f8,0x000018fc,0x000200f9, -0x000018fd,0x000200f8,0x000018f8,0x00050082, -0x00000006,0x000018fb,0x000018a2,0x00000135, -0x000200f9,0x000018fd,0x000200f8,0x000018fd, -0x000700f5,0x00000006,0x00005b58,0x000018fb, -0x000018f8,0x0000012b,0x000018fc,0x00050084, -0x00000006,0x000018af,0x000000df,0x00005b58, -0x00050080,0x00000006,0x000018b0,0x000018b6, -0x000018af,0x00050084,0x00000006,0x00001863, -0x000000df,0x00005b51,0x00050080,0x00000006, -0x00001864,0x000018b0,0x00001863,0x00050041, -0x0000022d,0x00001865,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00001866,0x00001865, -0x00050051,0x00000006,0x00001915,0x00001866, -0x00000000,0x00050095,0x00000130,0x00001917, -0x00001915,0x00001864,0x00050051,0x00000006, -0x00001918,0x00001917,0x00000001,0x00050051, -0x00000006,0x00001919,0x00001917,0x00000000, -0x00050051,0x00000006,0x0000191c,0x00001866, -0x00000001,0x00050080,0x00000006,0x0000191e, -0x0000191c,0x00001918,0x00050050,0x00000007, -0x0000191f,0x00001919,0x0000191e,0x0004007c, -0x00000014,0x0000190f,0x0000191f,0x00060041, -0x0000015f,0x00001906,0x0000190f,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00001907, -0x00001906,0x00000002,0x00000004,0x000200f9, -0x00001868,0x000200f8,0x00001868,0x000700f5, -0x00000006,0x00005b5d,0x0000012b,0x000018fd, -0x00001871,0x00001879,0x000700f5,0x00000006, -0x00005b5c,0x0000012b,0x000018fd,0x0000187b, -0x00001879,0x000700f5,0x00000006,0x00005b5b, -0x00001907,0x000018fd,0x0000197c,0x00001879, -0x000500ab,0x0000002f,0x0000186b,0x00005b5b, -0x00000500,0x000500b0,0x0000002f,0x0000186d, -0x00005b5c,0x00000309,0x000500a7,0x0000002f, -0x0000186e,0x0000186b,0x0000186d,0x000400f6, -0x0000187c,0x00001879,0x00000000,0x000400fa, -0x0000186e,0x0000186f,0x0000187c,0x000200f8, -0x0000186f,0x00050080,0x00000006,0x00001871, -0x00005b5d,0x0000022b,0x000300f7,0x00001965, -0x00000000,0x000400fa,0x000018a3,0x00001960, -0x00001964,0x000200f8,0x00001964,0x000200f9, -0x00001965,0x000200f8,0x00001960,0x00050082, -0x00000006,0x00001963,0x000018a2,0x00000135, -0x000200f9,0x00001965,0x000200f8,0x00001965, -0x000700f5,0x00000006,0x00005b68,0x00001963, -0x00001960,0x0000012b,0x00001964,0x00050084, -0x00000006,0x0000192a,0x000000df,0x00005b68, -0x00050080,0x00000006,0x0000192b,0x000018bd, -0x0000192a,0x000300f7,0x00001972,0x00000000, -0x000400fa,0x000018a3,0x0000196d,0x00001971, -0x000200f8,0x00001971,0x000200f9,0x00001972, -0x000200f8,0x0000196d,0x00050082,0x00000006, -0x00001970,0x000018a2,0x00000135,0x000200f9, -0x00001972,0x000200f8,0x00001972,0x000700f5, -0x00000006,0x00005b69,0x00001970,0x0000196d, -0x0000012b,0x00001971,0x00050084,0x00000006, -0x00001924,0x000000df,0x00005b69,0x00050080, -0x00000006,0x00001925,0x0000192b,0x00001924, -0x00050084,0x00000006,0x00001874,0x000000df, -0x00005b5b,0x00050080,0x00000006,0x00001875, -0x00001925,0x00001874,0x00050095,0x00000130, -0x0000198c,0x00001915,0x00001875,0x00050051, -0x00000006,0x0000198d,0x0000198c,0x00000001, -0x00050051,0x00000006,0x0000198e,0x0000198c, -0x00000000,0x00050080,0x00000006,0x00001993, -0x0000191c,0x0000198d,0x00050050,0x00000007, -0x00001994,0x0000198e,0x00001993,0x0004007c, -0x00000014,0x00001984,0x00001994,0x00060041, -0x0000015f,0x0000197b,0x00001984,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x0000197c, -0x0000197b,0x00000002,0x00000004,0x000200f9, -0x00001879,0x000200f8,0x00001879,0x00050080, -0x00000006,0x0000187b,0x00005b5c,0x0000022b, -0x000200f9,0x00001868,0x000200f8,0x0000187c, -0x000500c7,0x00000006,0x0000187e,0x00005b5d, -0x00000135,0x000500aa,0x0000002f,0x0000187f, -0x0000187e,0x0000012b,0x000600a9,0x00000006, -0x00001880,0x0000187f,0x00000135,0x0000012b, -0x000300f7,0x000019e0,0x00000000,0x000400fa, -0x000018a3,0x000019db,0x000019df,0x000200f8, -0x000019df,0x000200f9,0x000019e0,0x000200f8, -0x000019db,0x00050082,0x00000006,0x000019de, -0x000018a2,0x00000135,0x000200f9,0x000019e0, -0x000200f8,0x000019e0,0x000700f5,0x00000006, -0x00005b60,0x000019de,0x000019db,0x0000012b, -0x000019df,0x00050084,0x00000006,0x000019a5, -0x000000df,0x00005b60,0x00050080,0x00000006, -0x000019a6,0x000018bd,0x000019a5,0x000300f7, -0x000019ed,0x00000000,0x000400fa,0x000018a3, -0x000019e8,0x000019ec,0x000200f8,0x000019ec, -0x000200f9,0x000019ed,0x000200f8,0x000019e8, -0x00050082,0x00000006,0x000019eb,0x000018a2, -0x00000135,0x000200f9,0x000019ed,0x000200f8, -0x000019ed,0x000700f5,0x00000006,0x00005b61, -0x000019eb,0x000019e8,0x0000012b,0x000019ec, -0x00050084,0x00000006,0x0000199f,0x000000df, -0x00005b61,0x00050080,0x00000006,0x000019a0, -0x000019a6,0x0000199f,0x000300f7,0x000019fa, -0x00000000,0x000400fa,0x000018a3,0x000019f5, -0x000019f9,0x000200f8,0x000019f9,0x000200f9, -0x000019fa,0x000200f8,0x000019f5,0x00050082, -0x00000006,0x000019f8,0x000018a2,0x00000135, -0x000200f9,0x000019fa,0x000200f8,0x000019fa, -0x000700f5,0x00000006,0x00005b62,0x000019f8, -0x000019f5,0x0000012b,0x000019f9,0x00050084, -0x00000006,0x00001999,0x000000df,0x00005b62, -0x00050080,0x00000006,0x0000199a,0x000019a0, -0x00001999,0x00050080,0x00000006,0x00001884, -0x0000199a,0x00001863,0x00050095,0x00000130, -0x00001a13,0x00001915,0x00001884,0x00050051, -0x00000006,0x00001a14,0x00001a13,0x00000001, -0x00050051,0x00000006,0x00001a15,0x00001a13, -0x00000000,0x00050080,0x00000006,0x00001a1a, -0x0000191c,0x00001a14,0x00050050,0x00000007, -0x00001a1b,0x00001a15,0x00001a1a,0x0004007c, -0x00000014,0x00001a0b,0x00001a1b,0x00060041, -0x0000015f,0x00001a03,0x00001a0b,0x0000015e, -0x0000015e,0x0005003e,0x00001a03,0x00001880, -0x00000002,0x00000004,0x000300f7,0x0000188d, -0x00000000,0x000400fa,0x0000187f,0x0000188b, -0x0000188d,0x000200f8,0x0000188b,0x000700ea, -0x00000006,0x0000188c,0x00000d70,0x00000135, -0x0000012b,0x00000135,0x000200f9,0x0000188d, -0x000200f8,0x0000188d,0x000200f9,0x0000188e, -0x000200f8,0x0000188e,0x00050080,0x00000006, -0x00001890,0x00005b51,0x0000018b,0x000200f9, -0x0000185b,0x000200f8,0x00001891,0x000400e0, -0x00000247,0x00000247,0x00000850,0x000300f7, -0x0000189d,0x00000000,0x000400fa,0x0000184f, -0x00001894,0x0000189d,0x000200f8,0x00001894, -0x00050041,0x00000182,0x00001a56,0x00000180, -0x00000181,0x0004003d,0x00000006,0x00001a57, -0x00001a56,0x00050084,0x00000006,0x00001a58, -0x000001a2,0x00001a57,0x00050080,0x00000006, -0x00001a59,0x0000018b,0x00001a58,0x00050080, -0x00000006,0x00001a5f,0x00001a57,0x00005cc3, -0x00050086,0x00000006,0x00001a60,0x00001a5f, -0x00000185,0x00050084,0x00000006,0x00001a52, -0x0000018b,0x00001a60,0x00050080,0x00000006, -0x00001a53,0x00001a59,0x00001a52,0x00050080, -0x00000006,0x00001a4d,0x00001a53,0x00001a52, -0x00050084,0x00000006,0x00001a46,0x000001b6, -0x000018a2,0x00050080,0x00000006,0x00001a47, -0x00001a4d,0x00001a46,0x00050041,0x00000182, -0x00001a3d,0x00000180,0x000001cd,0x0004003d, -0x00000006,0x00001a3e,0x00001a3d,0x00050084, -0x00000006,0x00001a3f,0x000001cc,0x00001a3e, -0x00050080,0x00000006,0x00001a40,0x00001a47, -0x00001a3f,0x000300f7,0x00001a73,0x00000000, -0x000400fa,0x000018a3,0x00001a6e,0x00001a72, -0x000200f8,0x00001a72,0x000200f9,0x00001a73, -0x000200f8,0x00001a6e,0x00050082,0x00000006, -0x00001a71,0x000018a2,0x00000135,0x000200f9, -0x00001a73,0x000200f8,0x00001a73,0x000700f5, -0x00000006,0x00005b52,0x00001a71,0x00001a6e, -0x0000012b,0x00001a72,0x00050084,0x00000006, -0x00001a38,0x000000df,0x00005b52,0x00050080, -0x00000006,0x00001a39,0x00001a40,0x00001a38, -0x000300f7,0x00001a80,0x00000000,0x000400fa, -0x000018a3,0x00001a7b,0x00001a7f,0x000200f8, -0x00001a7f,0x000200f9,0x00001a80,0x000200f8, -0x00001a7b,0x00050082,0x00000006,0x00001a7e, -0x000018a2,0x00000135,0x000200f9,0x00001a80, -0x000200f8,0x00001a80,0x000700f5,0x00000006, -0x00005b53,0x00001a7e,0x00001a7b,0x0000012b, -0x00001a7f,0x00050084,0x00000006,0x00001a32, -0x000000df,0x00005b53,0x00050080,0x00000006, -0x00001a33,0x00001a39,0x00001a32,0x000300f7, -0x00001a8d,0x00000000,0x000400fa,0x000018a3, -0x00001a88,0x00001a8c,0x000200f8,0x00001a8c, -0x000200f9,0x00001a8d,0x000200f8,0x00001a88, -0x00050082,0x00000006,0x00001a8b,0x000018a2, -0x00000135,0x000200f9,0x00001a8d,0x000200f8, -0x00001a8d,0x000700f5,0x00000006,0x00005b54, -0x00001a8b,0x00001a88,0x0000012b,0x00001a8c, -0x00050084,0x00000006,0x00001a2c,0x000000df, -0x00005b54,0x00050080,0x00000006,0x00001a2d, -0x00001a33,0x00001a2c,0x000300f7,0x00001a9a, -0x00000000,0x000400fa,0x000018a3,0x00001a95, -0x00001a99,0x000200f8,0x00001a99,0x000200f9, -0x00001a9a,0x000200f8,0x00001a95,0x00050082, -0x00000006,0x00001a98,0x000018a2,0x00000135, -0x000200f9,0x00001a9a,0x000200f8,0x00001a9a, -0x000700f5,0x00000006,0x00005b55,0x00001a98, -0x00001a95,0x0000012b,0x00001a99,0x00050084, -0x00000006,0x00001a26,0x000000df,0x00005b55, -0x00050080,0x00000006,0x00001a27,0x00001a2d, -0x00001a26,0x000300f7,0x00001aa7,0x00000000, -0x000400fa,0x000018a3,0x00001aa2,0x00001aa6, -0x000200f8,0x00001aa6,0x000200f9,0x00001aa7, -0x000200f8,0x00001aa2,0x00050082,0x00000006, -0x00001aa5,0x000018a2,0x00000135,0x000200f9, -0x00001aa7,0x000200f8,0x00001aa7,0x000700f5, -0x00000006,0x00005b56,0x00001aa5,0x00001aa2, -0x0000012b,0x00001aa6,0x00050084,0x00000006, -0x00001a20,0x000000df,0x00005b56,0x00050080, -0x00000006,0x00001a21,0x00001a27,0x00001a20, -0x00050084,0x00000006,0x00001897,0x000000df, -0x00001220,0x00050080,0x00000006,0x00001898, -0x00001a21,0x00001897,0x00050041,0x0000022d, -0x00001899,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x0000189a,0x00001899,0x0004003d, -0x00000006,0x0000189b,0x00000d70,0x00050051, -0x00000006,0x00001abe,0x0000189a,0x00000000, -0x00050095,0x00000130,0x00001ac0,0x00001abe, -0x00001898,0x00050051,0x00000006,0x00001ac1, -0x00001ac0,0x00000001,0x00050051,0x00000006, -0x00001ac2,0x00001ac0,0x00000000,0x00050051, -0x00000006,0x00001ac5,0x0000189a,0x00000001, -0x00050080,0x00000006,0x00001ac7,0x00001ac5, -0x00001ac1,0x00050050,0x00000007,0x00001ac8, -0x00001ac2,0x00001ac7,0x0004007c,0x00000014, -0x00001ab8,0x00001ac8,0x00060041,0x0000015f, -0x00001ab0,0x00001ab8,0x0000015e,0x0000015e, -0x0005003e,0x00001ab0,0x0000189b,0x00000002, -0x00000004,0x000200f9,0x0000189d,0x000200f8, -0x0000189d,0x000200f9,0x000012fe,0x000200f8, -0x0000121d,0x000500aa,0x0000002f,0x00001228, -0x000011e0,0x0000090f,0x000300f7,0x0000122a, -0x00000000,0x000400fa,0x00001228,0x00001229, -0x0000122a,0x000200f8,0x00001229,0x00050041, -0x00000182,0x00001b03,0x00000180,0x00000181, -0x0004003d,0x00000006,0x00001b04,0x00001b03, -0x00050084,0x00000006,0x00001b05,0x000001a2, -0x00001b04,0x00050080,0x00000006,0x00001b06, -0x0000018b,0x00001b05,0x00050080,0x00000006, -0x00001b0c,0x00001b04,0x00005cc3,0x00050086, -0x00000006,0x00001b0d,0x00001b0c,0x00000185, -0x00050084,0x00000006,0x00001aff,0x0000018b, -0x00001b0d,0x00050080,0x00000006,0x00001b00, -0x00001b06,0x00001aff,0x00050080,0x00000006, -0x00001afa,0x00001b00,0x00001aff,0x00050041, -0x00000182,0x00001af1,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x00001af2,0x00001af1, -0x00050084,0x00000006,0x00001af3,0x000001b6, -0x00001af2,0x00050080,0x00000006,0x00001af4, -0x00001afa,0x00001af3,0x00050041,0x00000182, -0x00001aea,0x00000180,0x000001cd,0x0004003d, -0x00000006,0x00001aeb,0x00001aea,0x00050084, -0x00000006,0x00001aec,0x000001cc,0x00001aeb, -0x00050080,0x00000006,0x00001aed,0x00001af4, -0x00001aec,0x000500ac,0x0000002f,0x00001b1a, -0x00001af2,0x00000135,0x000300f7,0x00001b20, -0x00000000,0x000400fa,0x00001b1a,0x00001b1b, -0x00001b1f,0x000200f8,0x00001b1f,0x000200f9, -0x00001b20,0x000200f8,0x00001b1b,0x00050082, -0x00000006,0x00001b1e,0x00001af2,0x00000135, -0x000200f9,0x00001b20,0x000200f8,0x00001b20, -0x000700f5,0x00000006,0x00005b3e,0x00001b1e, -0x00001b1b,0x0000012b,0x00001b1f,0x00050084, -0x00000006,0x00001ae5,0x000000df,0x00005b3e, -0x00050080,0x00000006,0x00001ae6,0x00001aed, -0x00001ae5,0x000300f7,0x00001b2d,0x00000000, -0x000400fa,0x00001b1a,0x00001b28,0x00001b2c, -0x000200f8,0x00001b2c,0x000200f9,0x00001b2d, -0x000200f8,0x00001b28,0x00050082,0x00000006, -0x00001b2b,0x00001af2,0x00000135,0x000200f9, -0x00001b2d,0x000200f8,0x00001b2d,0x000700f5, -0x00000006,0x00005b3f,0x00001b2b,0x00001b28, -0x0000012b,0x00001b2c,0x00050084,0x00000006, -0x00001adf,0x000000df,0x00005b3f,0x00050080, -0x00000006,0x00001ae0,0x00001ae6,0x00001adf, -0x000300f7,0x00001b3a,0x00000000,0x000400fa, -0x00001b1a,0x00001b35,0x00001b39,0x000200f8, -0x00001b39,0x000200f9,0x00001b3a,0x000200f8, -0x00001b35,0x00050082,0x00000006,0x00001b38, -0x00001af2,0x00000135,0x000200f9,0x00001b3a, -0x000200f8,0x00001b3a,0x000700f5,0x00000006, -0x00005b40,0x00001b38,0x00001b35,0x0000012b, -0x00001b39,0x00050084,0x00000006,0x00001ad9, -0x000000df,0x00005b40,0x00050080,0x00000006, -0x00001ada,0x00001ae0,0x00001ad9,0x000300f7, -0x00001b47,0x00000000,0x000400fa,0x00001b1a, -0x00001b42,0x00001b46,0x000200f8,0x00001b46, -0x000200f9,0x00001b47,0x000200f8,0x00001b42, -0x00050082,0x00000006,0x00001b45,0x00001af2, -0x00000135,0x000200f9,0x00001b47,0x000200f8, -0x00001b47,0x000700f5,0x00000006,0x00005b41, -0x00001b45,0x00001b42,0x0000012b,0x00001b46, -0x00050084,0x00000006,0x00001ad3,0x000000df, -0x00005b41,0x00050080,0x00000006,0x00001ad4, -0x00001ada,0x00001ad3,0x000300f7,0x00001b54, -0x00000000,0x000400fa,0x00001b1a,0x00001b4f, -0x00001b53,0x000200f8,0x00001b53,0x000200f9, -0x00001b54,0x000200f8,0x00001b4f,0x00050082, -0x00000006,0x00001b52,0x00001af2,0x00000135, -0x000200f9,0x00001b54,0x000200f8,0x00001b54, -0x000700f5,0x00000006,0x00005b42,0x00001b52, -0x00001b4f,0x0000012b,0x00001b53,0x00050084, -0x00000006,0x00001acd,0x000000df,0x00005b42, -0x00050080,0x00000006,0x00001ace,0x00001ad4, -0x00001acd,0x000300f7,0x00001bb3,0x00000000, -0x000400fa,0x00001b1a,0x00001bae,0x00001bb2, -0x000200f8,0x00001bb2,0x000200f9,0x00001bb3, -0x000200f8,0x00001bae,0x00050082,0x00000006, -0x00001bb1,0x00001af2,0x00000135,0x000200f9, -0x00001bb3,0x000200f8,0x00001bb3,0x000700f5, -0x00000006,0x00005b43,0x00001bb1,0x00001bae, -0x0000012b,0x00001bb2,0x00050084,0x00000006, -0x00001b78,0x000000df,0x00005b43,0x00050080, -0x00000006,0x00001b79,0x00001aed,0x00001b78, -0x000300f7,0x00001bc0,0x00000000,0x000400fa, -0x00001b1a,0x00001bbb,0x00001bbf,0x000200f8, -0x00001bbf,0x000200f9,0x00001bc0,0x000200f8, -0x00001bbb,0x00050082,0x00000006,0x00001bbe, -0x00001af2,0x00000135,0x000200f9,0x00001bc0, -0x000200f8,0x00001bc0,0x000700f5,0x00000006, -0x00005b44,0x00001bbe,0x00001bbb,0x0000012b, -0x00001bbf,0x00050084,0x00000006,0x00001b72, -0x000000df,0x00005b44,0x00050080,0x00000006, -0x00001b73,0x00001b79,0x00001b72,0x000300f7, -0x00001bcd,0x00000000,0x000400fa,0x00001b1a, -0x00001bc8,0x00001bcc,0x000200f8,0x00001bcc, -0x000200f9,0x00001bcd,0x000200f8,0x00001bc8, -0x00050082,0x00000006,0x00001bcb,0x00001af2, -0x00000135,0x000200f9,0x00001bcd,0x000200f8, -0x00001bcd,0x000700f5,0x00000006,0x00005b45, -0x00001bcb,0x00001bc8,0x0000012b,0x00001bcc, -0x00050084,0x00000006,0x00001b6c,0x000000df, -0x00005b45,0x00050080,0x00000006,0x00001b6d, -0x00001b73,0x00001b6c,0x000300f7,0x00001bda, -0x00000000,0x000400fa,0x00001b1a,0x00001bd5, -0x00001bd9,0x000200f8,0x00001bd9,0x000200f9, -0x00001bda,0x000200f8,0x00001bd5,0x00050082, -0x00000006,0x00001bd8,0x00001af2,0x00000135, -0x000200f9,0x00001bda,0x000200f8,0x00001bda, -0x000700f5,0x00000006,0x00005b46,0x00001bd8, -0x00001bd5,0x0000012b,0x00001bd9,0x00050084, -0x00000006,0x00001b66,0x000000df,0x00005b46, -0x00050080,0x00000006,0x00001b67,0x00001b6d, -0x00001b66,0x000300f7,0x00001be7,0x00000000, -0x000400fa,0x00001b1a,0x00001be2,0x00001be6, -0x000200f8,0x00001be6,0x000200f9,0x00001be7, -0x000200f8,0x00001be2,0x00050082,0x00000006, -0x00001be5,0x00001af2,0x00000135,0x000200f9, -0x00001be7,0x000200f8,0x00001be7,0x000700f5, -0x00000006,0x00005b47,0x00001be5,0x00001be2, -0x0000012b,0x00001be6,0x00050084,0x00000006, -0x00001b60,0x000000df,0x00005b47,0x00050080, -0x00000006,0x00001b61,0x00001b67,0x00001b60, -0x000300f7,0x00001bfa,0x00000000,0x000400fa, -0x00001b1a,0x00001bf5,0x00001bf9,0x000200f8, -0x00001bf9,0x000200f9,0x00001bfa,0x000200f8, -0x00001bf5,0x00050082,0x00000006,0x00001bf8, -0x00001af2,0x00000135,0x000200f9,0x00001bfa, -0x000200f8,0x00001bfa,0x000700f5,0x00000006, -0x00005b48,0x00001bf8,0x00001bf5,0x0000012b, -0x00001bf9,0x00050080,0x00000006,0x00001bed, -0x00005b48,0x00005cc3,0x00050086,0x00000006, -0x00001bee,0x00001bed,0x00000185,0x00050084, -0x00000006,0x00001b5a,0x000000df,0x00001bee, -0x00050080,0x00000006,0x00001b5b,0x00001b61, -0x00001b5a,0x000300f7,0x00001c0d,0x00000000, -0x000400fa,0x00001b1a,0x00001c08,0x00001c0c, -0x000200f8,0x00001c0c,0x000200f9,0x00001c0d, -0x000200f8,0x00001c08,0x00050082,0x00000006, -0x00001c0b,0x00001af2,0x00000135,0x000200f9, -0x00001c0d,0x000200f8,0x00001c0d,0x000700f5, -0x00000006,0x00005b49,0x00001c0b,0x00001c08, -0x0000012b,0x00001c0c,0x00050080,0x00000006, -0x00001c00,0x00005b49,0x00005cc3,0x00050086, -0x00000006,0x00001c01,0x00001c00,0x00000185, -0x00050041,0x000011dc,0x0000122f,0x000011e5, -0x0000012b,0x0004003d,0x00000006,0x00001230, -0x0000122f,0x00050080,0x00000006,0x00001c26, -0x00001c01,0x00000957,0x00050086,0x00000006, -0x00001c27,0x00001c26,0x0000018b,0x00050084, -0x00000006,0x00001c2a,0x00001230,0x00001c27, -0x0007000c,0x00000006,0x00001c2c,0x00000001, -0x00000026,0x00001c2a,0x00001c01,0x00050080, -0x00000006,0x00001c2f,0x00001c2c,0x00001c27, -0x0007000c,0x00000006,0x00001c31,0x00000001, -0x00000026,0x00001c2f,0x00001c01,0x000200f9, -0x00001c33,0x000200f8,0x00001c33,0x000700f5, -0x00000006,0x00005b4b,0x0000012b,0x00001c0d, -0x00001c41,0x00001c38,0x000700f5,0x00000006, -0x00005b4a,0x00001c2c,0x00001c0d,0x00001c44, -0x00001c38,0x000500b0,0x0000002f,0x00001c37, -0x00005b4a,0x00001c31,0x000400f6,0x00001c45, -0x00001c38,0x00000000,0x000400fa,0x00001c37, -0x00001c38,0x00001c45,0x000200f8,0x00001c38, -0x00050084,0x00000006,0x00001c3b,0x000000df, -0x00005b4a,0x00050080,0x00000006,0x00001c3c, -0x00001ace,0x00001c3b,0x00050041,0x0000022d, -0x00001c3d,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00001c3e,0x00001c3d,0x00050051, -0x00000006,0x00001c9e,0x00001c3e,0x00000000, -0x00050095,0x00000130,0x00001ca0,0x00001c9e, -0x00001c3c,0x00050051,0x00000006,0x00001ca1, -0x00001ca0,0x00000001,0x00050051,0x00000006, -0x00001ca2,0x00001ca0,0x00000000,0x00050051, -0x00000006,0x00001ca5,0x00001c3e,0x00000001, -0x00050080,0x00000006,0x00001ca7,0x00001ca5, -0x00001ca1,0x00050050,0x00000007,0x00001ca8, -0x00001ca2,0x00001ca7,0x0004007c,0x00000014, -0x00001c98,0x00001ca8,0x00060041,0x0000015f, -0x00001c8f,0x00001c98,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00001c90,0x00001c8f, +0x00001571,0x00005fd1,0x000015bf,0x00050080, +0x00000006,0x00001574,0x00005fd0,0x00000264, +0x000200f9,0x0000155a,0x000200f8,0x00001575, +0x000200f9,0x000013fd,0x000200f8,0x000012f1, +0x000500aa,0x0000002f,0x00001301,0x000012df, +0x00000543,0x000300f7,0x00001303,0x00000000, +0x000400fa,0x00001301,0x00001302,0x00001303, +0x000200f8,0x00001302,0x00050041,0x000012db, +0x00001305,0x000012e3,0x00000138,0x0004003d, +0x00000006,0x00001306,0x00001305,0x00050041, +0x000012db,0x00001308,0x000012e4,0x00000138, +0x0004003d,0x00000006,0x00001309,0x00001308, +0x000500b0,0x0000002f,0x00001618,0x00001309, +0x000001db,0x000300f7,0x00001627,0x00000000, +0x000400fa,0x00001618,0x00001619,0x00001627, +0x000200f8,0x00001619,0x00050041,0x000001bb, +0x000016cf,0x000001b9,0x000001ba,0x0004003d, +0x00000006,0x000016d0,0x000016cf,0x00050084, +0x00000006,0x000016d1,0x000001db,0x000016d0, +0x00050080,0x00000006,0x000016d2,0x000001c4, +0x000016d1,0x00050080,0x00000006,0x000016d8, +0x000016d0,0x0000062f,0x00050086,0x00000006, +0x000016d9,0x000016d8,0x000001be,0x00050084, +0x00000006,0x000016cb,0x000001c4,0x000016d9, +0x00050080,0x00000006,0x000016cc,0x000016d2, +0x000016cb,0x00050084,0x00000006,0x0000161e, +0x00001309,0x000016d9,0x00050080,0x00000006, +0x00001620,0x0000161e,0x00001306,0x00050084, +0x00000006,0x00001621,0x000000ec,0x00001620, +0x00050080,0x00000006,0x00001622,0x000016cc, +0x00001621,0x00050041,0x00000266,0x00001623, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x00001624,0x00001623,0x00050051,0x00000006, +0x000016f7,0x00001624,0x00000000,0x00050095, +0x0000013d,0x000016f9,0x000016f7,0x00001622, +0x00050051,0x00000006,0x000016fa,0x000016f9, +0x00000001,0x00050051,0x00000006,0x000016fb, +0x000016f9,0x00000000,0x00050051,0x00000006, +0x000016fe,0x00001624,0x00000001,0x00050080, +0x00000006,0x00001700,0x000016fe,0x000016fa, +0x00050050,0x00000007,0x00001701,0x000016fb, +0x00001700,0x0004007c,0x00000014,0x000016f1, +0x00001701,0x00060041,0x0000016c,0x000016e8, +0x000016f1,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000016e9,0x000016e8,0x00000002, +0x00000004,0x00050041,0x00000937,0x00001626, +0x00000ad4,0x00001309,0x0003003e,0x00001626, +0x000016e9,0x000200f9,0x00001627,0x000200f8, +0x00001627,0x00050084,0x00000006,0x00001629, +0x00001306,0x000001be,0x00050080,0x00000006, +0x0000162b,0x00001629,0x000001be,0x00050041, +0x000001bb,0x0000162c,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x0000162d,0x0000162c, +0x0007000c,0x00000006,0x0000162e,0x00000001, +0x00000026,0x0000162b,0x0000162d,0x000200f9, +0x00001630,0x000200f8,0x00001630,0x000700f5, +0x00000006,0x00005fb3,0x00001629,0x00001627, +0x000016c5,0x000016c3,0x000500b0,0x0000002f, +0x00001634,0x00005fb3,0x0000162e,0x000400f6, +0x000016c6,0x000016c3,0x00000000,0x000400fa, +0x00001634,0x00001635,0x000016c6,0x000200f8, +0x00001635,0x00050080,0x00000006,0x00001638, +0x00005fb3,0x00001309,0x000500b0,0x0000002f, +0x0000163b,0x00001638,0x0000162e,0x000300f7, +0x00001646,0x00000000,0x000400fa,0x0000163b, +0x0000163d,0x00001645,0x000200f8,0x00001645, +0x000200f9,0x00001646,0x000200f8,0x0000163d, +0x00050041,0x000001bb,0x00001705,0x000001b9, +0x000004c1,0x0004003d,0x00000006,0x00001706, +0x00001705,0x000500c7,0x00000006,0x00001707, +0x00001706,0x00000142,0x000500aa,0x0000002f, +0x00001708,0x00001707,0x00000138,0x000300f7, +0x0000170d,0x00000000,0x000400fa,0x00001708, +0x00001709,0x0000170b,0x000200f8,0x0000170b, +0x00050084,0x00000006,0x00001715,0x000001cd, +0x0000162d,0x00050080,0x00000006,0x00001716, +0x000001c4,0x00001715,0x000200f9,0x0000170d, +0x000200f8,0x00001709,0x000200f9,0x0000170d, +0x000200f8,0x0000170d,0x000700f5,0x00000006, +0x00005fb4,0x000001c4,0x00001709,0x00001716, +0x0000170b,0x00050084,0x00000006,0x00001640, +0x000000ec,0x00001638,0x00050080,0x00000006, +0x00001641,0x00005fb4,0x00001640,0x00050041, +0x00000266,0x00001642,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00001643,0x00001642, +0x00050051,0x00000006,0x0000172d,0x00001643, +0x00000000,0x00050095,0x0000013d,0x0000172f, +0x0000172d,0x00001641,0x00050051,0x00000006, +0x00001730,0x0000172f,0x00000001,0x00050051, +0x00000006,0x00001731,0x0000172f,0x00000000, +0x00050051,0x00000006,0x00001734,0x00001643, +0x00000001,0x00050080,0x00000006,0x00001736, +0x00001734,0x00001730,0x00050050,0x00000007, +0x00001737,0x00001731,0x00001736,0x0004007c, +0x00000014,0x00001727,0x00001737,0x00060041, +0x0000016c,0x0000171e,0x00001727,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000171f, +0x0000171e,0x00000002,0x00000004,0x000200f9, +0x00001646,0x000200f8,0x00001646,0x000700f5, +0x00000006,0x00005fb5,0x0000171f,0x0000170d, +0x00000138,0x00001645,0x000300f7,0x00001652, +0x00000000,0x000400fa,0x0000163b,0x00001649, +0x00001651,0x000200f8,0x00001651,0x000200f9, +0x00001652,0x000200f8,0x00001649,0x00050041, +0x000001bb,0x0000173b,0x000001b9,0x000004c1, +0x0004003d,0x00000006,0x0000173c,0x0000173b, +0x000500c7,0x00000006,0x0000173d,0x0000173c, +0x00000142,0x000500aa,0x0000002f,0x0000173e, +0x0000173d,0x00000138,0x000300f7,0x00001743, +0x00000000,0x000400fa,0x0000173e,0x0000173f, +0x00001741,0x000200f8,0x00001741,0x00050084, +0x00000006,0x0000174f,0x000001d4,0x0000162d, +0x00050080,0x00000006,0x00001750,0x000001c4, +0x0000174f,0x000200f9,0x00001743,0x000200f8, +0x0000173f,0x00050084,0x00000006,0x00001749, +0x000000ec,0x0000162d,0x00050080,0x00000006, +0x0000174a,0x000001c4,0x00001749,0x000200f9, +0x00001743,0x000200f8,0x00001743,0x000700f5, +0x00000006,0x00005fb6,0x0000174a,0x0000173f, +0x00001750,0x00001741,0x00050084,0x00000006, +0x0000164c,0x000000ec,0x00001638,0x00050080, +0x00000006,0x0000164d,0x00005fb6,0x0000164c, +0x00050041,0x00000266,0x0000164e,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x0000164f, +0x0000164e,0x00050051,0x00000006,0x00001767, +0x0000164f,0x00000000,0x00050095,0x0000013d, +0x00001769,0x00001767,0x0000164d,0x00050051, +0x00000006,0x0000176a,0x00001769,0x00000001, +0x00050051,0x00000006,0x0000176b,0x00001769, +0x00000000,0x00050051,0x00000006,0x0000176e, +0x0000164f,0x00000001,0x00050080,0x00000006, +0x00001770,0x0000176e,0x0000176a,0x00050050, +0x00000007,0x00001771,0x0000176b,0x00001770, +0x0004007c,0x00000014,0x00001761,0x00001771, +0x00060041,0x0000016c,0x00001758,0x00001761, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00001759,0x00001758,0x00000002,0x00000004, +0x000200f9,0x00001652,0x000200f8,0x00001652, +0x000700f5,0x00000006,0x00005fb7,0x00001759, +0x00001743,0x00000138,0x00001651,0x00050041, +0x000001bb,0x00001775,0x000001b9,0x000004c1, +0x0004003d,0x00000006,0x00001776,0x00001775, +0x00050084,0x00000006,0x00001777,0x000000ec, +0x00001776,0x000500c2,0x00000006,0x00001778, +0x00005fb5,0x00001777,0x000500c7,0x00000006, +0x00001779,0x00001778,0x00000a0e,0x000200f9, +0x00001656,0x000200f8,0x00001656,0x000700f5, +0x00000006,0x00005fb8,0x00000138,0x00001652, +0x00001666,0x0000165a,0x000500b0,0x0000002f, +0x00001659,0x00005fb8,0x000001db,0x000400f6, +0x00001667,0x0000165a,0x00000000,0x000400fa, +0x00001659,0x0000165a,0x00001667,0x000200f8, +0x0000165a,0x000500aa,0x0000002f,0x00001660, +0x00005fb8,0x00001779,0x000500a7,0x0000002f, +0x00001661,0x0000163b,0x00001660,0x000600a9, +0x00000006,0x00001662,0x00001661,0x00000142, +0x00000138,0x00060041,0x00000937,0x00001663, +0x00000b2d,0x00005fb8,0x00001309,0x0003003e, +0x00001663,0x00001662,0x00050080,0x00000006, +0x00001666,0x00005fb8,0x00000264,0x000200f9, +0x00001656,0x000200f8,0x00001667,0x000400e0, +0x00000280,0x00000280,0x0000094f,0x000200f9, +0x00001668,0x000200f8,0x00001668,0x000700f5, +0x00000006,0x00005fb9,0x00000142,0x00001667, +0x00001699,0x00001697,0x000500b0,0x0000002f, +0x0000166b,0x00005fb9,0x000001c4,0x000400f6, +0x0000169a,0x00001697,0x00000000,0x000400fa, +0x0000166b,0x0000166c,0x0000169a,0x000200f8, +0x0000166c,0x000200f9,0x0000166d,0x000200f8, +0x0000166d,0x000700f5,0x00000006,0x00005fc6, +0x00000138,0x0000166c,0x00001683,0x00001681, +0x000500b0,0x0000002f,0x00001670,0x00005fc6, +0x000001db,0x000400f6,0x00001684,0x00001681, +0x00000000,0x000400fa,0x00001670,0x00001671, +0x00001684,0x000200f8,0x00001671,0x000500ae, +0x0000002f,0x00001675,0x00001309,0x00005fb9, +0x000300f7,0x0000167e,0x00000000,0x000400fa, +0x00001675,0x00001676,0x0000167d,0x000200f8, +0x0000167d,0x000200f9,0x0000167e,0x000200f8, +0x00001676,0x00050082,0x00000006,0x0000167a, +0x00001309,0x00005fb9,0x00060041,0x00000937, +0x0000167b,0x00000b2d,0x00005fc6,0x0000167a, +0x0004003d,0x00000006,0x0000167c,0x0000167b, +0x000200f9,0x0000167e,0x000200f8,0x0000167e, +0x000700f5,0x00000006,0x00005fca,0x0000167c, +0x00001676,0x00000138,0x0000167d,0x00050041, +0x00000009,0x00001680,0x0000160c,0x00005fc6, +0x0003003e,0x00001680,0x00005fca,0x000200f9, +0x00001681,0x000200f8,0x00001681,0x00050080, +0x00000006,0x00001683,0x00005fc6,0x00000264, +0x000200f9,0x0000166d,0x000200f8,0x00001684, +0x000400e0,0x00000280,0x00000280,0x0000094f, +0x000200f9,0x00001685,0x000200f8,0x00001685, +0x000700f5,0x00000006,0x00005fc7,0x00000138, +0x00001684,0x00001695,0x00001689,0x000500b0, +0x0000002f,0x00001688,0x00005fc7,0x000001db, +0x000400f6,0x00001696,0x00001689,0x00000000, +0x000400fa,0x00001688,0x00001689,0x00001696, +0x000200f8,0x00001689,0x00050041,0x00000009, +0x0000168d,0x0000160c,0x00005fc7,0x0004003d, +0x00000006,0x0000168e,0x0000168d,0x00060041, +0x00000937,0x0000168f,0x00000b2d,0x00005fc7, +0x00001309,0x0004003d,0x00000006,0x00001690, +0x0000168f,0x00050080,0x00000006,0x00001691, +0x00001690,0x0000168e,0x0003003e,0x0000168f, +0x00001691,0x00050080,0x00000006,0x00001695, +0x00005fc7,0x00000264,0x000200f9,0x00001685, +0x000200f8,0x00001696,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x000200f9,0x00001697, +0x000200f8,0x00001697,0x000500c4,0x00000006, +0x00001699,0x00005fb9,0x00000264,0x000200f9, +0x00001668,0x000200f8,0x0000169a,0x000300f7, +0x000016b6,0x00000000,0x000400fa,0x0000163b, +0x0000169c,0x000016b6,0x000200f8,0x0000169c, +0x00050041,0x00000937,0x0000169e,0x00000ad4, +0x00001779,0x0004003d,0x00000006,0x0000169f, +0x0000169e,0x00060041,0x00000937,0x000016a2, +0x00000b2d,0x00001779,0x00001309,0x0004003d, +0x00000006,0x000016a3,0x000016a2,0x00050080, +0x00000006,0x000016a4,0x0000169f,0x000016a3, +0x00050082,0x00000006,0x000016a5,0x000016a4, +0x00000142,0x000500c7,0x00000006,0x0000177f, +0x00001776,0x00000142,0x000500aa,0x0000002f, +0x00001780,0x0000177f,0x00000138,0x000300f7, +0x00001785,0x00000000,0x000400fa,0x00001780, +0x00001781,0x00001783,0x000200f8,0x00001783, +0x000200f9,0x00001785,0x000200f8,0x00001781, +0x00050084,0x00000006,0x0000178b,0x000001cd, +0x0000162d,0x00050080,0x00000006,0x0000178c, +0x000001c4,0x0000178b,0x000200f9,0x00001785, +0x000200f8,0x00001785,0x000700f5,0x00000006, +0x00005fba,0x0000178c,0x00001781,0x000001c4, +0x00001783,0x00050084,0x00000006,0x000016a8, +0x000000ec,0x000016a5,0x00050080,0x00000006, +0x000016a9,0x00005fba,0x000016a8,0x00050041, +0x00000266,0x000016aa,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x000016ab,0x000016aa, +0x00050051,0x00000006,0x000017a4,0x000016ab, +0x00000000,0x00050095,0x0000013d,0x000017a6, +0x000017a4,0x000016a9,0x00050051,0x00000006, +0x000017a7,0x000017a6,0x00000001,0x00050051, +0x00000006,0x000017a8,0x000017a6,0x00000000, +0x00050051,0x00000006,0x000017ab,0x000016ab, +0x00000001,0x00050080,0x00000006,0x000017ad, +0x000017ab,0x000017a7,0x00050050,0x00000007, +0x000017ae,0x000017a8,0x000017ad,0x0004007c, +0x00000014,0x0000179e,0x000017ae,0x00060041, +0x0000016c,0x00001796,0x0000179e,0x0000016b, +0x0000016b,0x0005003e,0x00001796,0x00005fb5, +0x00000002,0x00000004,0x000300f7,0x000017ba, +0x00000000,0x000400fa,0x00001780,0x000017b6, +0x000017b8,0x000200f8,0x000017b8,0x00050084, +0x00000006,0x000017c6,0x000000ec,0x0000162d, +0x00050080,0x00000006,0x000017c7,0x000001c4, +0x000017c6,0x000200f9,0x000017ba,0x000200f8, +0x000017b6,0x00050084,0x00000006,0x000017c0, +0x000001d4,0x0000162d,0x00050080,0x00000006, +0x000017c1,0x000001c4,0x000017c0,0x000200f9, +0x000017ba,0x000200f8,0x000017ba,0x000700f5, +0x00000006,0x00005fbb,0x000017c1,0x000017b6, +0x000017c7,0x000017b8,0x00050080,0x00000006, +0x000016b1,0x00005fbb,0x000016a8,0x00050095, +0x0000013d,0x000017df,0x000017a4,0x000016b1, +0x00050051,0x00000006,0x000017e0,0x000017df, +0x00000001,0x00050051,0x00000006,0x000017e1, +0x000017df,0x00000000,0x00050080,0x00000006, +0x000017e6,0x000017ab,0x000017e0,0x00050050, +0x00000007,0x000017e7,0x000017e1,0x000017e6, +0x0004007c,0x00000014,0x000017d7,0x000017e7, +0x00060041,0x0000016c,0x000017cf,0x000017d7, +0x0000016b,0x0000016b,0x0005003e,0x000017cf, +0x00005fb7,0x00000002,0x00000004,0x000200f9, +0x000016b6,0x000200f8,0x000016b6,0x000400e0, +0x00000280,0x00000280,0x0000094f,0x000300f7, +0x000016c2,0x00000000,0x000400fa,0x00001618, +0x000016b9,0x000016c2,0x000200f8,0x000016b9, +0x00060041,0x00000937,0x000016bc,0x00000b2d, +0x00001309,0x00000b9b,0x0004003d,0x00000006, +0x000016bd,0x000016bc,0x00050041,0x00000937, +0x000016be,0x00000ad4,0x00001309,0x0004003d, +0x00000006,0x000016bf,0x000016be,0x00050080, +0x00000006,0x000016c0,0x000016bf,0x000016bd, +0x0003003e,0x000016be,0x000016c0,0x000200f9, +0x000016c2,0x000200f8,0x000016c2,0x000400e0, +0x00000280,0x00000280,0x0000094f,0x000200f9, +0x000016c3,0x000200f8,0x000016c3,0x00050080, +0x00000006,0x000016c5,0x00005fb3,0x000001c4, +0x000200f9,0x00001630,0x000200f8,0x000016c6, +0x000200f9,0x000013fd,0x000200f8,0x00001303, +0x000500aa,0x0000002f,0x0000130f,0x000012df, +0x0000130e,0x000300f7,0x00001311,0x00000000, +0x000400fa,0x0000130f,0x00001310,0x00001311, +0x000200f8,0x00001310,0x00050041,0x000012db, +0x00001313,0x000012e4,0x00000138,0x0004003d, +0x00000006,0x00001314,0x00001313,0x00050041, +0x000001bb,0x00001802,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x00001803,0x00001802, +0x000200f9,0x00001804,0x000200f8,0x00001804, +0x000700f5,0x00000006,0x00005f9e,0x00000142, +0x00001310,0x0000180b,0x00001809,0x000500b0, +0x0000002f,0x00001808,0x00005f9e,0x00001803, +0x000400f6,0x0000180d,0x00001809,0x00000000, +0x000400fa,0x00001808,0x00001809,0x0000180d, +0x000200f8,0x00001809,0x000500c4,0x00000006, +0x0000180b,0x00005f9e,0x00000264,0x000200f9, +0x00001804,0x000200f8,0x0000180d,0x000200f9, +0x0000180f,0x000200f8,0x0000180f,0x000700f5, +0x00000006,0x00005f9f,0x00001314,0x0000180d, +0x00001837,0x00001835,0x000500b0,0x0000002f, +0x00001813,0x00005f9f,0x00005f9e,0x000400f6, +0x00001838,0x00001835,0x00000000,0x000400fa, +0x00001813,0x00001814,0x00001838,0x000200f8, +0x00001814,0x000500b0,0x0000002f,0x00001818, +0x00005f9f,0x00001803,0x000300f7,0x00001822, +0x00000000,0x000400fa,0x00001818,0x00001819, +0x00001821,0x000200f8,0x00001821,0x000200f9, +0x00001822,0x000200f8,0x00001819,0x00050084, +0x00000006,0x0000181c,0x000000ec,0x00005f9f, +0x00050080,0x00000006,0x0000181d,0x000001c4, +0x0000181c,0x00050041,0x00000266,0x0000181e, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x0000181f,0x0000181e,0x00050051,0x00000006, +0x000018c6,0x0000181f,0x00000000,0x00050095, +0x0000013d,0x000018c8,0x000018c6,0x0000181d, +0x00050051,0x00000006,0x000018c9,0x000018c8, +0x00000001,0x00050051,0x00000006,0x000018ca, +0x000018c8,0x00000000,0x00050051,0x00000006, +0x000018cd,0x0000181f,0x00000001,0x00050080, +0x00000006,0x000018cf,0x000018cd,0x000018c9, +0x00050050,0x00000007,0x000018d0,0x000018ca, +0x000018cf,0x0004007c,0x00000014,0x000018c0, +0x000018d0,0x00060041,0x0000016c,0x000018b7, +0x000018c0,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000018b8,0x000018b7,0x00000002, +0x00000004,0x000200f9,0x00001822,0x000200f8, +0x00001822,0x000700f5,0x00000006,0x00005faf, +0x000018b8,0x00001819,0x00000539,0x00001821, +0x00050041,0x00000937,0x00001824,0x00000924, +0x00005f9f,0x0003003e,0x00001824,0x00005faf, +0x000300f7,0x00001832,0x00000000,0x000400fa, +0x00001818,0x00001829,0x00001831,0x000200f8, +0x00001831,0x000200f9,0x00001832,0x000200f8, +0x00001829,0x00050084,0x00000006,0x000018d5, +0x000000ec,0x00001803,0x00050080,0x00000006, +0x000018d6,0x000001c4,0x000018d5,0x00050084, +0x00000006,0x0000182c,0x000000ec,0x00005f9f, +0x00050080,0x00000006,0x0000182d,0x000018d6, +0x0000182c,0x00050041,0x00000266,0x0000182e, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x0000182f,0x0000182e,0x00050051,0x00000006, +0x000018ed,0x0000182f,0x00000000,0x00050095, +0x0000013d,0x000018ef,0x000018ed,0x0000182d, +0x00050051,0x00000006,0x000018f0,0x000018ef, +0x00000001,0x00050051,0x00000006,0x000018f1, +0x000018ef,0x00000000,0x00050051,0x00000006, +0x000018f4,0x0000182f,0x00000001,0x00050080, +0x00000006,0x000018f6,0x000018f4,0x000018f0, +0x00050050,0x00000007,0x000018f7,0x000018f1, +0x000018f6,0x0004007c,0x00000014,0x000018e7, +0x000018f7,0x00060041,0x0000016c,0x000018de, +0x000018e7,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000018df,0x000018de,0x00000002, +0x00000004,0x000200f9,0x00001832,0x000200f8, +0x00001832,0x000700f5,0x00000006,0x00005fb1, +0x000018df,0x00001829,0x00000539,0x00001831, +0x00050041,0x00000937,0x00001834,0x00000939, +0x00005f9f,0x0003003e,0x00001834,0x00005fb1, +0x000200f9,0x00001835,0x000200f8,0x00001835, +0x00050080,0x00000006,0x00001837,0x00005f9f, +0x000001c4,0x000200f9,0x0000180f,0x000200f8, +0x00001838,0x000400e0,0x00000280,0x00000280, +0x0000094f,0x000200f9,0x00001839,0x000200f8, +0x00001839,0x000700f5,0x00000006,0x00005fa1, +0x00000280,0x00001838,0x0000188d,0x0000188b, +0x000500b2,0x0000002f,0x0000183d,0x00005fa1, +0x00005f9e,0x000400f6,0x0000188e,0x0000188b, +0x00000000,0x000400fa,0x0000183d,0x0000183e, +0x0000188e,0x000200f8,0x0000183e,0x000500c2, +0x00000006,0x00001840,0x00005fa1,0x00000264, +0x000200f9,0x00001841,0x000200f8,0x00001841, +0x000700f5,0x00000006,0x00005fa4,0x00001840, +0x0000183e,0x00001889,0x00001887,0x000500ac, +0x0000002f,0x00001844,0x00005fa4,0x00000138, +0x000400f6,0x0000188a,0x00001887,0x00000000, +0x000400fa,0x00001844,0x00001845,0x0000188a, +0x000200f8,0x00001845,0x000200f9,0x00001847, +0x000200f8,0x00001847,0x000700f5,0x00000006, +0x00005fa6,0x00001314,0x00001845,0x00001885, +0x00001883,0x000500b0,0x0000002f,0x0000184b, +0x00005fa6,0x00005f9e,0x000400f6,0x00001886, +0x00001883,0x00000000,0x000400fa,0x0000184b, +0x0000184c,0x00001886,0x000200f8,0x0000184c, +0x000500c6,0x00000006,0x0000184f,0x00005fa6, +0x00005fa4,0x000500ac,0x0000002f,0x00001852, +0x0000184f,0x00005fa6,0x000300f7,0x00001882, +0x00000000,0x000400fa,0x00001852,0x00001853, +0x00001882,0x000200f8,0x00001853,0x00050041, +0x00000937,0x00001855,0x00000924,0x00005fa6, +0x0004003d,0x00000006,0x00001856,0x00001855, +0x00050041,0x00000937,0x00001858,0x00000924, +0x0000184f,0x0004003d,0x00000006,0x00001859, +0x00001858,0x00050041,0x00000937,0x0000185b, +0x00000939,0x00005fa6,0x0004003d,0x00000006, +0x0000185c,0x0000185b,0x00050041,0x00000937, +0x0000185e,0x00000939,0x0000184f,0x0004003d, +0x00000006,0x0000185f,0x0000185e,0x000500ac, +0x0000002f,0x00001862,0x00001856,0x00001859, +0x000400a8,0x0000002f,0x00001863,0x00001862, +0x000300f7,0x0000186c,0x00000000,0x000400fa, +0x00001863,0x00001864,0x0000186c,0x000200f8, +0x00001864,0x000500aa,0x0000002f,0x00001867, +0x00001856,0x00001859,0x000500ac,0x0000002f, +0x0000186a,0x0000185c,0x0000185f,0x000500a7, +0x0000002f,0x0000186b,0x00001867,0x0000186a, +0x000200f9,0x0000186c,0x000200f8,0x0000186c, +0x000700f5,0x0000002f,0x0000186d,0x00001862, +0x00001853,0x0000186b,0x00001864,0x000500c7, +0x00000006,0x00001871,0x00005fa6,0x00005fa1, +0x000500aa,0x0000002f,0x00001872,0x00001871, +0x00000138,0x000500a4,0x0000002f,0x00001873, +0x0000186d,0x00001872,0x000300f7,0x00001881, +0x00000000,0x000400fa,0x00001873,0x00001874, +0x00001881,0x000200f8,0x00001874,0x0003003e, +0x00001855,0x00001859,0x0003003e,0x00001858, +0x00001856,0x0003003e,0x0000185b,0x0000185f, +0x0003003e,0x0000185e,0x0000185c,0x000200f9, +0x00001881,0x000200f8,0x00001881,0x000200f9, +0x00001882,0x000200f8,0x00001882,0x000200f9, +0x00001883,0x000200f8,0x00001883,0x00050080, +0x00000006,0x00001885,0x00005fa6,0x000001c4, +0x000200f9,0x00001847,0x000200f8,0x00001886, +0x000400e0,0x00000280,0x00000280,0x0000094f, +0x000200f9,0x00001887,0x000200f8,0x00001887, +0x000500c2,0x00000006,0x00001889,0x00005fa4, +0x00000264,0x000200f9,0x00001841,0x000200f8, +0x0000188a,0x000200f9,0x0000188b,0x000200f8, +0x0000188b,0x000500c4,0x00000006,0x0000188d, +0x00005fa1,0x00000264,0x000200f9,0x00001839, +0x000200f8,0x0000188e,0x000200f9,0x00001890, +0x000200f8,0x00001890,0x000700f5,0x00000006, +0x00005fa3,0x00001314,0x0000188e,0x000018ac, +0x00001895,0x000500b0,0x0000002f,0x00001894, +0x00005fa3,0x00001803,0x000400f6,0x000018ad, +0x00001895,0x00000000,0x000400fa,0x00001894, +0x00001895,0x000018ad,0x000200f8,0x00001895, +0x00050084,0x00000006,0x00001898,0x000000ec, +0x00005fa3,0x00050080,0x00000006,0x00001899, +0x000001c4,0x00001898,0x00050041,0x00000266, +0x0000189b,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x0000189c,0x0000189b,0x00050041, +0x00000937,0x0000189d,0x00000924,0x00005fa3, +0x0004003d,0x00000006,0x0000189e,0x0000189d, +0x00050051,0x00000006,0x0000190f,0x0000189c, +0x00000000,0x00050095,0x0000013d,0x00001911, +0x0000190f,0x00001899,0x00050051,0x00000006, +0x00001912,0x00001911,0x00000001,0x00050051, +0x00000006,0x00001913,0x00001911,0x00000000, +0x00050051,0x00000006,0x00001916,0x0000189c, +0x00000001,0x00050080,0x00000006,0x00001918, +0x00001916,0x00001912,0x00050050,0x00000007, +0x00001919,0x00001913,0x00001918,0x0004007c, +0x00000014,0x00001909,0x00001919,0x00060041, +0x0000016c,0x00001901,0x00001909,0x0000016b, +0x0000016b,0x0005003e,0x00001901,0x0000189e, +0x00000002,0x00000004,0x00050084,0x00000006, +0x0000191e,0x000000ec,0x00001803,0x00050080, +0x00000006,0x0000191f,0x000001c4,0x0000191e, +0x00050080,0x00000006,0x000018a3,0x0000191f, +0x00001898,0x00050041,0x00000937,0x000018a7, +0x00000939,0x00005fa3,0x0004003d,0x00000006, +0x000018a8,0x000018a7,0x00050095,0x0000013d, +0x00001937,0x0000190f,0x000018a3,0x00050051, +0x00000006,0x00001938,0x00001937,0x00000001, +0x00050051,0x00000006,0x00001939,0x00001937, +0x00000000,0x00050080,0x00000006,0x0000193e, +0x00001916,0x00001938,0x00050050,0x00000007, +0x0000193f,0x00001939,0x0000193e,0x0004007c, +0x00000014,0x0000192f,0x0000193f,0x00060041, +0x0000016c,0x00001927,0x0000192f,0x0000016b, +0x0000016b,0x0005003e,0x00001927,0x000018a8, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00001c41,0x00005b4b,0x00001c90,0x00050080, -0x00000006,0x00001c44,0x00005b4a,0x0000022b, -0x000200f9,0x00001c33,0x000200f8,0x00001c45, -0x00050041,0x00000838,0x00001c48,0x00000980, -0x00001230,0x0003003e,0x00001c48,0x00005b4b, -0x000400e0,0x00000247,0x00000247,0x00000850, -0x000500aa,0x0000002f,0x00001c4a,0x00001230, -0x0000012b,0x000300f7,0x00001c67,0x00000000, -0x000400fa,0x00001c4a,0x00001c4b,0x00001c67, -0x000200f8,0x00001c4b,0x000200f9,0x00001c4c, -0x000200f8,0x00001c4c,0x000700f5,0x00000006, -0x00005b4d,0x0000012b,0x00001c4b,0x00001c59, -0x00001c50,0x000700f5,0x00000006,0x00005b4c, -0x0000012b,0x00001c4b,0x00001c5c,0x00001c50, -0x000500b0,0x0000002f,0x00001c4f,0x00005b4c, -0x0000018b,0x000400f6,0x00001c5d,0x00001c50, -0x00000000,0x000400fa,0x00001c4f,0x00001c50, -0x00001c5d,0x000200f8,0x00001c50,0x00050041, -0x00000838,0x00001c52,0x00000980,0x00005b4c, -0x0004003d,0x00000006,0x00001c53,0x00001c52, -0x0003003e,0x00001c52,0x00005b4d,0x00050080, -0x00000006,0x00001c59,0x00005b4d,0x00001c53, -0x00050080,0x00000006,0x00001c5c,0x00005b4c, -0x0000022b,0x000200f9,0x00001c4c,0x000200f8, -0x00001c5d,0x00050041,0x0000022d,0x00001c61, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x00001c62,0x00001c61,0x00050051,0x00000006, -0x00001cbe,0x00001c62,0x00000000,0x00050095, -0x00000130,0x00001cc0,0x00001cbe,0x000001b6, -0x00050051,0x00000006,0x00001cc1,0x00001cc0, -0x00000001,0x00050051,0x00000006,0x00001cc2, -0x00001cc0,0x00000000,0x00050051,0x00000006, -0x00001cc5,0x00001c62,0x00000001,0x00050080, -0x00000006,0x00001cc7,0x00001cc5,0x00001cc1, -0x00050050,0x00000007,0x00001cc8,0x00001cc2, -0x00001cc7,0x0004007c,0x00000014,0x00001cb8, -0x00001cc8,0x00060041,0x0000015f,0x00001cb0, -0x00001cb8,0x0000015e,0x0000015e,0x0005003e, -0x00001cb0,0x00005b4d,0x00000002,0x00000004, -0x000200f9,0x00001c67,0x000200f8,0x00001c67, -0x000400e0,0x00000247,0x00000247,0x00000850, -0x0004003d,0x00000006,0x00001c6a,0x00001c48, -0x000200f9,0x00001c6c,0x000200f8,0x00001c6c, -0x000700f5,0x00000006,0x00005b4f,0x00001c6a, -0x00001c67,0x00001c83,0x00001c71,0x000700f5, -0x00000006,0x00005b4e,0x00001c2c,0x00001c67, -0x00001c86,0x00001c71,0x000500b0,0x0000002f, -0x00001c70,0x00005b4e,0x00001c31,0x000400f6, -0x00001c87,0x00001c71,0x00000000,0x000400fa, -0x00001c70,0x00001c71,0x00001c87,0x000200f8, -0x00001c71,0x00050084,0x00000006,0x00001c74, -0x000000df,0x00005b4e,0x00050080,0x00000006, -0x00001c75,0x00001ace,0x00001c74,0x00050041, -0x0000022d,0x00001c76,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00001c77,0x00001c76, -0x00050051,0x00000006,0x00001cdf,0x00001c77, -0x00000000,0x00050095,0x00000130,0x00001ce1, -0x00001cdf,0x00001c75,0x00050051,0x00000006, -0x00001ce2,0x00001ce1,0x00000001,0x00050051, -0x00000006,0x00001ce3,0x00001ce1,0x00000000, -0x00050051,0x00000006,0x00001ce6,0x00001c77, -0x00000001,0x00050080,0x00000006,0x00001ce8, -0x00001ce6,0x00001ce2,0x00050050,0x00000007, -0x00001ce9,0x00001ce3,0x00001ce8,0x0004007c, -0x00000014,0x00001cd9,0x00001ce9,0x00060041, -0x0000015f,0x00001cd0,0x00001cd9,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00001cd1, -0x00001cd0,0x00000002,0x00000004,0x00050080, -0x00000006,0x00001c7c,0x00001b5b,0x00001c74, -0x00050095,0x00000130,0x00001d01,0x00001cdf, -0x00001c7c,0x00050051,0x00000006,0x00001d02, -0x00001d01,0x00000001,0x00050051,0x00000006, -0x00001d03,0x00001d01,0x00000000,0x00050080, -0x00000006,0x00001d08,0x00001ce6,0x00001d02, -0x00050050,0x00000007,0x00001d09,0x00001d03, -0x00001d08,0x0004007c,0x00000014,0x00001cf9, -0x00001d09,0x00060041,0x0000015f,0x00001cf1, -0x00001cf9,0x0000015e,0x0000015e,0x0005003e, -0x00001cf1,0x00005b4f,0x00000002,0x00000004, -0x00050080,0x00000006,0x00001c83,0x00005b4f, -0x00001cd1,0x00050080,0x00000006,0x00001c86, -0x00005b4e,0x0000022b,0x000200f9,0x00001c6c, -0x000200f8,0x00001c87,0x000200f9,0x000012fe, -0x000200f8,0x0000122a,0x000500aa,0x0000002f, -0x00001239,0x000011e0,0x000001a2,0x000300f7, -0x0000123b,0x00000000,0x000400fa,0x00001239, -0x0000123a,0x0000123b,0x000200f8,0x0000123a, -0x00050041,0x000011dc,0x0000123d,0x000011e4, -0x0000012b,0x0004003d,0x00000006,0x0000123e, -0x0000123d,0x00050041,0x000011dc,0x00001240, -0x000011e5,0x0000012b,0x0004003d,0x00000006, -0x00001241,0x00001240,0x00050041,0x00000182, -0x00001db8,0x00000180,0x00000181,0x0004003d, -0x00000006,0x00001db9,0x00001db8,0x00050084, -0x00000006,0x00001dba,0x000001a2,0x00001db9, -0x00050080,0x00000006,0x00001dbb,0x0000018b, -0x00001dba,0x00050080,0x00000006,0x00001dc1, -0x00001db9,0x00005cc3,0x00050086,0x00000006, -0x00001dc2,0x00001dc1,0x00000185,0x00050084, -0x00000006,0x00001db4,0x0000018b,0x00001dc2, -0x00050080,0x00000006,0x00001db5,0x00001dbb, -0x00001db4,0x00050080,0x00000006,0x00001daf, -0x00001db5,0x00001db4,0x00050041,0x00000182, -0x00001da6,0x00000180,0x000001b7,0x0004003d, -0x00000006,0x00001da7,0x00001da6,0x00050084, -0x00000006,0x00001da8,0x000001b6,0x00001da7, -0x00050080,0x00000006,0x00001da9,0x00001daf, -0x00001da8,0x00050041,0x00000182,0x00001d9f, -0x00000180,0x000001cd,0x0004003d,0x00000006, -0x00001da0,0x00001d9f,0x00050084,0x00000006, -0x00001da1,0x000001cc,0x00001da0,0x00050080, -0x00000006,0x00001da2,0x00001da9,0x00001da1, -0x000500ac,0x0000002f,0x00001dcf,0x00001da7, -0x00000135,0x000300f7,0x00001dd5,0x00000000, -0x000400fa,0x00001dcf,0x00001dd0,0x00001dd4, -0x000200f8,0x00001dd4,0x000200f9,0x00001dd5, -0x000200f8,0x00001dd0,0x00050082,0x00000006, -0x00001dd3,0x00001da7,0x00000135,0x000200f9, -0x00001dd5,0x000200f8,0x00001dd5,0x000700f5, -0x00000006,0x00005b15,0x00001dd3,0x00001dd0, -0x0000012b,0x00001dd4,0x00050084,0x00000006, -0x00001d9a,0x000000df,0x00005b15,0x00050080, -0x00000006,0x00001d9b,0x00001da2,0x00001d9a, -0x000300f7,0x00001de2,0x00000000,0x000400fa, -0x00001dcf,0x00001ddd,0x00001de1,0x000200f8, -0x00001de1,0x000200f9,0x00001de2,0x000200f8, -0x00001ddd,0x00050082,0x00000006,0x00001de0, -0x00001da7,0x00000135,0x000200f9,0x00001de2, -0x000200f8,0x00001de2,0x000700f5,0x00000006, -0x00005b16,0x00001de0,0x00001ddd,0x0000012b, -0x00001de1,0x00050084,0x00000006,0x00001d94, -0x000000df,0x00005b16,0x00050080,0x00000006, -0x00001d95,0x00001d9b,0x00001d94,0x000300f7, -0x00001def,0x00000000,0x000400fa,0x00001dcf, -0x00001dea,0x00001dee,0x000200f8,0x00001dee, -0x000200f9,0x00001def,0x000200f8,0x00001dea, -0x00050082,0x00000006,0x00001ded,0x00001da7, -0x00000135,0x000200f9,0x00001def,0x000200f8, -0x00001def,0x000700f5,0x00000006,0x00005b17, -0x00001ded,0x00001dea,0x0000012b,0x00001dee, -0x00050084,0x00000006,0x00001d8e,0x000000df, -0x00005b17,0x00050080,0x00000006,0x00001d8f, -0x00001d95,0x00001d8e,0x000300f7,0x00001dfc, -0x00000000,0x000400fa,0x00001dcf,0x00001df7, -0x00001dfb,0x000200f8,0x00001dfb,0x000200f9, -0x00001dfc,0x000200f8,0x00001df7,0x00050082, -0x00000006,0x00001dfa,0x00001da7,0x00000135, -0x000200f9,0x00001dfc,0x000200f8,0x00001dfc, -0x000700f5,0x00000006,0x00005b18,0x00001dfa, -0x00001df7,0x0000012b,0x00001dfb,0x00050084, -0x00000006,0x00001d88,0x000000df,0x00005b18, -0x00050080,0x00000006,0x00001d89,0x00001d8f, -0x00001d88,0x000300f7,0x00001e09,0x00000000, -0x000400fa,0x00001dcf,0x00001e04,0x00001e08, -0x000200f8,0x00001e08,0x000200f9,0x00001e09, -0x000200f8,0x00001e04,0x00050082,0x00000006, -0x00001e07,0x00001da7,0x00000135,0x000200f9, -0x00001e09,0x000200f8,0x00001e09,0x000700f5, -0x00000006,0x00005b19,0x00001e07,0x00001e04, -0x0000012b,0x00001e08,0x00050084,0x00000006, -0x00001d82,0x000000df,0x00005b19,0x00050080, -0x00000006,0x00001d83,0x00001d89,0x00001d82, -0x000300f7,0x00001e1c,0x00000000,0x000400fa, -0x00001dcf,0x00001e17,0x00001e1b,0x000200f8, -0x00001e1b,0x000200f9,0x00001e1c,0x000200f8, -0x00001e17,0x00050082,0x00000006,0x00001e1a, -0x00001da7,0x00000135,0x000200f9,0x00001e1c, -0x000200f8,0x00001e1c,0x000700f5,0x00000006, -0x00005b1a,0x00001e1a,0x00001e17,0x0000012b, -0x00001e1b,0x00050080,0x00000006,0x00001e0f, -0x00005b1a,0x00005cc3,0x00050086,0x00000006, -0x00001e10,0x00001e0f,0x00000185,0x00050084, -0x00000006,0x00001d7c,0x000000df,0x00001e10, -0x00050080,0x00000006,0x00001d7d,0x00001d83, -0x00001d7c,0x00050084,0x00000006,0x00001d1e, -0x000000df,0x0000123e,0x00050080,0x00000006, -0x00001d1f,0x00001d7d,0x00001d1e,0x00050041, -0x0000022d,0x00001d20,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00001d21,0x00001d20, -0x00050051,0x00000006,0x00001e34,0x00001d21, -0x00000000,0x00050095,0x00000130,0x00001e36, -0x00001e34,0x00001d1f,0x00050051,0x00000006, -0x00001e37,0x00001e36,0x00000001,0x00050051, -0x00000006,0x00001e38,0x00001e36,0x00000000, -0x00050051,0x00000006,0x00001e3b,0x00001d21, -0x00000001,0x00050080,0x00000006,0x00001e3d, -0x00001e3b,0x00001e37,0x00050050,0x00000007, -0x00001e3e,0x00001e38,0x00001e3d,0x0004007c, -0x00000014,0x00001e2e,0x00001e3e,0x00060041, -0x0000015f,0x00001e25,0x00001e2e,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00001e26, -0x00001e25,0x00000002,0x00000004,0x00050084, -0x00000006,0x00001d24,0x0000123e,0x00000185, -0x00050080,0x00000006,0x00001d26,0x00001d24, -0x00000185,0x000300f7,0x00001e4a,0x00000000, -0x000400fa,0x00001dcf,0x00001e45,0x00001e49, -0x000200f8,0x00001e49,0x000200f9,0x00001e4a, -0x000200f8,0x00001e45,0x00050082,0x00000006, -0x00001e48,0x00001da7,0x00000135,0x000200f9, -0x00001e4a,0x000200f8,0x00001e4a,0x000700f5, -0x00000006,0x00005b1b,0x00001e48,0x00001e45, -0x0000012b,0x00001e49,0x0007000c,0x00000006, -0x00001d28,0x00000001,0x00000026,0x00001d26, -0x00005b1b,0x000200f9,0x00001d2a,0x000200f8, -0x00001d2a,0x000700f5,0x00000006,0x00005b2f, -0x00001e26,0x00001e4a,0x00001d73,0x00001d74, -0x000700f5,0x00000006,0x00005b1c,0x00001d24, -0x00001e4a,0x00001d76,0x00001d74,0x000500b0, -0x0000002f,0x00001d2e,0x00005b1c,0x00001d28, -0x000400f6,0x00001d77,0x00001d74,0x00000000, -0x000400fa,0x00001d2e,0x00001d2f,0x00001d77, -0x000200f8,0x00001d2f,0x00050080,0x00000006, -0x00001d32,0x00005b1c,0x00001241,0x000500b0, -0x0000002f,0x00001d35,0x00001d32,0x00001d28, -0x000300f7,0x00001d3f,0x00000000,0x000400fa, -0x00001d35,0x00001d36,0x00001d3e,0x000200f8, -0x00001d3e,0x000200f9,0x00001d3f,0x000200f8, -0x00001d36,0x000300f7,0x00001e97,0x00000000, -0x000400fa,0x00001dcf,0x00001e92,0x00001e96, -0x000200f8,0x00001e96,0x000200f9,0x00001e97, -0x000200f8,0x00001e92,0x00050082,0x00000006, -0x00001e95,0x00001da7,0x00000135,0x000200f9, -0x00001e97,0x000200f8,0x00001e97,0x000700f5, -0x00000006,0x00005b1d,0x00001e95,0x00001e92, -0x0000012b,0x00001e96,0x00050084,0x00000006, -0x00001e5c,0x000000df,0x00005b1d,0x00050080, -0x00000006,0x00001e5d,0x00001da2,0x00001e5c, -0x000300f7,0x00001ea4,0x00000000,0x000400fa, -0x00001dcf,0x00001e9f,0x00001ea3,0x000200f8, -0x00001ea3,0x000200f9,0x00001ea4,0x000200f8, -0x00001e9f,0x00050082,0x00000006,0x00001ea2, -0x00001da7,0x00000135,0x000200f9,0x00001ea4, -0x000200f8,0x00001ea4,0x000700f5,0x00000006, -0x00005b1e,0x00001ea2,0x00001e9f,0x0000012b, -0x00001ea3,0x00050084,0x00000006,0x00001e56, -0x000000df,0x00005b1e,0x00050080,0x00000006, -0x00001e57,0x00001e5d,0x00001e56,0x000300f7, -0x00001eb1,0x00000000,0x000400fa,0x00001dcf, -0x00001eac,0x00001eb0,0x000200f8,0x00001eb0, -0x000200f9,0x00001eb1,0x000200f8,0x00001eac, -0x00050082,0x00000006,0x00001eaf,0x00001da7, -0x00000135,0x000200f9,0x00001eb1,0x000200f8, -0x00001eb1,0x000700f5,0x00000006,0x00005b1f, -0x00001eaf,0x00001eac,0x0000012b,0x00001eb0, -0x00050084,0x00000006,0x00001e50,0x000000df, -0x00005b1f,0x00050080,0x00000006,0x00001e51, -0x00001e57,0x00001e50,0x00050084,0x00000006, -0x00001d39,0x000000df,0x00001d32,0x00050080, -0x00000006,0x00001d3a,0x00001e51,0x00001d39, -0x00050095,0x00000130,0x00001ecb,0x00001e34, -0x00001d3a,0x00050051,0x00000006,0x00001ecc, -0x00001ecb,0x00000001,0x00050051,0x00000006, -0x00001ecd,0x00001ecb,0x00000000,0x00050080, -0x00000006,0x00001ed2,0x00001e3b,0x00001ecc, -0x00050050,0x00000007,0x00001ed3,0x00001ecd, -0x00001ed2,0x0004007c,0x00000014,0x00001ec3, -0x00001ed3,0x00060041,0x0000015f,0x00001eba, -0x00001ec3,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00001ebb,0x00001eba,0x00000002, -0x00000004,0x000200f9,0x00001d3f,0x000200f8, -0x00001d3f,0x000700f5,0x00000006,0x00005b20, -0x00001ebb,0x00001eb1,0x0000012b,0x00001d3e, -0x00050041,0x00000838,0x00001d43,0x00000e00, -0x00001241,0x0003003e,0x00001d43,0x00005b20, -0x000400e0,0x00000247,0x00000247,0x00000850, -0x000200f9,0x00001d44,0x000200f8,0x00001d44, -0x000700f5,0x00000006,0x00005b21,0x00000135, -0x00001d3f,0x00001d5d,0x00001d5b,0x000500b0, -0x0000002f,0x00001d47,0x00005b21,0x0000018b, -0x000400f6,0x00001d5e,0x00001d5b,0x00000000, -0x000400fa,0x00001d47,0x00001d48,0x00001d5e, -0x000200f8,0x00001d48,0x000500ae,0x0000002f, -0x00001d4b,0x00001241,0x00005b21,0x000300f7, -0x00001d53,0x00000000,0x000400fa,0x00001d4b, -0x00001d4c,0x00001d52,0x000200f8,0x00001d52, -0x000200f9,0x00001d53,0x000200f8,0x00001d4c, -0x00050082,0x00000006,0x00001d4f,0x00001241, -0x00005b21,0x00050041,0x00000838,0x00001d50, -0x00000e00,0x00001d4f,0x0004003d,0x00000006, -0x00001d51,0x00001d50,0x000200f9,0x00001d53, -0x000200f8,0x00001d53,0x000700f5,0x00000006, -0x00005b3c,0x00001d51,0x00001d4c,0x0000012b, -0x00001d52,0x000400e0,0x00000247,0x00000247, -0x00000850,0x0004003d,0x00000006,0x00001d58, -0x00001d43,0x00050080,0x00000006,0x00001d59, -0x00001d58,0x00005b3c,0x0003003e,0x00001d43, -0x00001d59,0x000400e0,0x00000247,0x00000247, -0x00000850,0x000200f9,0x00001d5b,0x000200f8, -0x00001d5b,0x000500c4,0x00000006,0x00001d5d, -0x00005b21,0x0000022b,0x000200f9,0x00001d44, -0x000200f8,0x00001d5e,0x000500ab,0x0000002f, -0x00001d60,0x00005b20,0x0000012b,0x000300f7, -0x00001d6f,0x00000000,0x000400fa,0x00001d60, -0x00001d61,0x00001d6f,0x000200f8,0x00001d61, -0x000300f7,0x00001f25,0x00000000,0x000400fa, -0x00001dcf,0x00001f20,0x00001f24,0x000200f8, -0x00001f24,0x000200f9,0x00001f25,0x000200f8, -0x00001f20,0x00050082,0x00000006,0x00001f23, -0x00001da7,0x00000135,0x000200f9,0x00001f25, -0x000200f8,0x00001f25,0x000700f5,0x00000006, -0x00005b22,0x00001f23,0x00001f20,0x0000012b, -0x00001f24,0x00050084,0x00000006,0x00001eea, -0x000000df,0x00005b22,0x00050080,0x00000006, -0x00001eeb,0x00001da2,0x00001eea,0x000300f7, -0x00001f32,0x00000000,0x000400fa,0x00001dcf, -0x00001f2d,0x00001f31,0x000200f8,0x00001f31, -0x000200f9,0x00001f32,0x000200f8,0x00001f2d, -0x00050082,0x00000006,0x00001f30,0x00001da7, -0x00000135,0x000200f9,0x00001f32,0x000200f8, -0x00001f32,0x000700f5,0x00000006,0x00005b23, -0x00001f30,0x00001f2d,0x0000012b,0x00001f31, -0x00050084,0x00000006,0x00001ee4,0x000000df, -0x00005b23,0x00050080,0x00000006,0x00001ee5, -0x00001eeb,0x00001ee4,0x000300f7,0x00001f3f, -0x00000000,0x000400fa,0x00001dcf,0x00001f3a, -0x00001f3e,0x000200f8,0x00001f3e,0x000200f9, -0x00001f3f,0x000200f8,0x00001f3a,0x00050082, -0x00000006,0x00001f3d,0x00001da7,0x00000135, -0x000200f9,0x00001f3f,0x000200f8,0x00001f3f, -0x000700f5,0x00000006,0x00005b24,0x00001f3d, -0x00001f3a,0x0000012b,0x00001f3e,0x00050084, -0x00000006,0x00001ede,0x000000df,0x00005b24, -0x00050080,0x00000006,0x00001edf,0x00001ee5, -0x00001ede,0x000300f7,0x00001f4c,0x00000000, -0x000400fa,0x00001dcf,0x00001f47,0x00001f4b, -0x000200f8,0x00001f4b,0x000200f9,0x00001f4c, -0x000200f8,0x00001f47,0x00050082,0x00000006, -0x00001f4a,0x00001da7,0x00000135,0x000200f9, -0x00001f4c,0x000200f8,0x00001f4c,0x000700f5, -0x00000006,0x00005b25,0x00001f4a,0x00001f47, -0x0000012b,0x00001f4b,0x00050084,0x00000006, -0x00001ed8,0x000000df,0x00005b25,0x00050080, -0x00000006,0x00001ed9,0x00001edf,0x00001ed8, -0x00050084,0x00000006,0x00001d64,0x000000df, -0x00001d32,0x00050080,0x00000006,0x00001d65, -0x00001ed9,0x00001d64,0x0004003d,0x00000006, -0x00001d69,0x00001d43,0x00050080,0x00000006, -0x00001d6a,0x00005b2f,0x00001d69,0x00050082, -0x00000006,0x00001d6b,0x00001d6a,0x00000135, -0x00050095,0x00000130,0x00001f65,0x00001e34, -0x00001d65,0x00050051,0x00000006,0x00001f66, -0x00001f65,0x00000001,0x00050051,0x00000006, -0x00001f67,0x00001f65,0x00000000,0x00050080, -0x00000006,0x00001f6c,0x00001e3b,0x00001f66, -0x00050050,0x00000007,0x00001f6d,0x00001f67, -0x00001f6c,0x0004007c,0x00000014,0x00001f5d, -0x00001f6d,0x00060041,0x0000015f,0x00001f55, -0x00001f5d,0x0000015e,0x0000015e,0x0005003e, -0x00001f55,0x00001d6b,0x00000002,0x00000004, -0x000200f9,0x00001d6f,0x000200f8,0x00001d6f, -0x00050041,0x00000838,0x00001d70,0x00000e00, -0x00000a9c,0x0004003d,0x00000006,0x00001d71, -0x00001d70,0x00050080,0x00000006,0x00001d73, -0x00005b2f,0x00001d71,0x000400e0,0x00000247, -0x00000247,0x00000850,0x000200f9,0x00001d74, -0x000200f8,0x00001d74,0x00050080,0x00000006, -0x00001d76,0x00005b1c,0x0000018b,0x000200f9, -0x00001d2a,0x000200f8,0x00001d77,0x000200f9, -0x000012fe,0x000200f8,0x0000123b,0x000500aa, -0x0000002f,0x00001246,0x000011e0,0x0000031c, -0x000300f7,0x00001248,0x00000000,0x000400fa, -0x00001246,0x00001247,0x00001248,0x000200f8, -0x00001247,0x000500aa,0x0000002f,0x0000124a, -0x000011de,0x0000012b,0x000300f7,0x0000124c, -0x00000000,0x000400fa,0x0000124a,0x0000124b, -0x0000124c,0x000200f8,0x0000124b,0x000300f7, -0x00002028,0x00000000,0x000300fb,0x0000012b, -0x00001faf,0x000200f8,0x00001faf,0x000300f7, -0x00002063,0x00000000,0x000300fb,0x0000012b, -0x00002035,0x000200f8,0x00002035,0x00050041, -0x00000182,0x00002084,0x00000180,0x00000181, -0x0004003d,0x00000006,0x00002085,0x00002084, -0x00050084,0x00000006,0x00002086,0x000001a2, -0x00002085,0x00050080,0x00000006,0x00002087, -0x0000018b,0x00002086,0x00050080,0x00000006, -0x0000208d,0x00002085,0x00005cc3,0x00050086, -0x00000006,0x0000208e,0x0000208d,0x00000185, -0x00050084,0x00000006,0x00002080,0x0000018b, -0x0000208e,0x00050080,0x00000006,0x00002081, -0x00002087,0x00002080,0x00050080,0x00000006, -0x0000207b,0x00002081,0x00002080,0x00050041, -0x00000182,0x00002072,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x00002073,0x00002072, -0x00050084,0x00000006,0x00002074,0x000001b6, -0x00002073,0x00050080,0x00000006,0x00002075, -0x0000207b,0x00002074,0x00050041,0x0000022d, -0x0000206c,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x0000206d,0x0000206c,0x00050051, -0x00000006,0x000020a3,0x0000206d,0x00000000, -0x00050095,0x00000130,0x000020a5,0x000020a3, -0x00002075,0x00050051,0x00000006,0x000020a6, -0x000020a5,0x00000001,0x00050051,0x00000006, -0x000020a7,0x000020a5,0x00000000,0x00050051, -0x00000006,0x000020aa,0x0000206d,0x00000001, -0x00050080,0x00000006,0x000020ac,0x000020aa, -0x000020a6,0x00050050,0x00000007,0x000020ad, -0x000020a7,0x000020ac,0x0004007c,0x00000014, -0x0000209d,0x000020ad,0x000200f9,0x00002038, -0x000200f8,0x00002038,0x000700f5,0x00000006, -0x00005b05,0x0000012b,0x00002035,0x00002046, -0x0000203c,0x000500b0,0x0000002f,0x0000203b, -0x00005b05,0x0000031c,0x000400f6,0x00002047, -0x0000203c,0x00000000,0x000400fa,0x0000203b, -0x0000203c,0x00002047,0x000200f8,0x0000203c, -0x00050080,0x00000006,0x00002040,0x00000135, -0x00005b05,0x00060041,0x0000015f,0x00002041, -0x0000209d,0x0000015e,0x00002040,0x000700f1, -0x00000006,0x00002042,0x00002041,0x00000135, -0x0000012b,0x0000012b,0x00050041,0x00000009, -0x00002043,0x0000202d,0x00005b05,0x0003003e, -0x00002043,0x00002042,0x00050080,0x00000006, -0x00002046,0x00005b05,0x0000022b,0x000200f9, -0x00002038,0x000200f8,0x00002047,0x00050041, -0x00000009,0x00002048,0x0000202d,0x0000015e, -0x0004003d,0x00000006,0x00002049,0x00002048, -0x000500aa,0x0000002f,0x0000204a,0x00002049, -0x00000500,0x000300f7,0x0000204e,0x00000000, -0x000400fa,0x0000204a,0x0000204b,0x0000204e, -0x000200f8,0x0000204b,0x000200f9,0x00002063, -0x000200f8,0x0000204e,0x0004003d,0x00000006, -0x00002050,0x00002048,0x000500c7,0x00000006, -0x000020b2,0x00002050,0x00000208,0x000500ab, -0x0000002f,0x000020b3,0x000020b2,0x0000012b, -0x000300f7,0x000020ba,0x00000000,0x000400fa, -0x000020b3,0x000020b4,0x000020b7,0x000200f8, -0x000020b7,0x000400c8,0x00000006,0x000020b9, -0x00002050,0x000200f9,0x000020ba,0x000200f8, -0x000020b4,0x000500c7,0x00000006,0x000020b6, -0x00002050,0x0000021d,0x000200f9,0x000020ba, -0x000200f8,0x000020ba,0x000700f5,0x00000006, -0x00005b06,0x000020b6,0x000020b4,0x000020b9, -0x000020b7,0x0004007c,0x00000027,0x000020bc, -0x00005b06,0x00050041,0x00000009,0x00002052, -0x0000202d,0x0000022b,0x0004003d,0x00000006, -0x00002053,0x00002052,0x000500c7,0x00000006, -0x000020c1,0x00002053,0x00000208,0x000500ab, -0x0000002f,0x000020c2,0x000020c1,0x0000012b, -0x000300f7,0x000020c9,0x00000000,0x000400fa, -0x000020c2,0x000020c3,0x000020c6,0x000200f8, -0x000020c6,0x000400c8,0x00000006,0x000020c8, -0x00002053,0x000200f9,0x000020c9,0x000200f8, -0x000020c3,0x000500c7,0x00000006,0x000020c5, -0x00002053,0x0000021d,0x000200f9,0x000020c9, -0x000200f8,0x000020c9,0x000700f5,0x00000006, -0x00005b07,0x000020c5,0x000020c3,0x000020c8, -0x000020c6,0x0004007c,0x00000027,0x000020cb, -0x00005b07,0x00050041,0x00000009,0x00002055, -0x0000202d,0x000002dc,0x0004003d,0x00000006, -0x00002056,0x00002055,0x000500c7,0x00000006, -0x000020d0,0x00002056,0x00000208,0x000500ab, -0x0000002f,0x000020d1,0x000020d0,0x0000012b, -0x000300f7,0x000020d8,0x00000000,0x000400fa, -0x000020d1,0x000020d2,0x000020d5,0x000200f8, -0x000020d5,0x000400c8,0x00000006,0x000020d7, -0x00002056,0x000200f9,0x000020d8,0x000200f8, -0x000020d2,0x000500c7,0x00000006,0x000020d4, -0x00002056,0x0000021d,0x000200f9,0x000020d8, -0x000200f8,0x000020d8,0x000700f5,0x00000006, -0x00005b08,0x000020d4,0x000020d2,0x000020d7, -0x000020d5,0x0004007c,0x00000027,0x000020da, -0x00005b08,0x00060050,0x00000063,0x00002058, -0x000020bc,0x000020cb,0x000020da,0x00050041, -0x00000009,0x00002059,0x0000202d,0x000002e4, -0x0004003d,0x00000006,0x0000205a,0x00002059, -0x000500c7,0x00000006,0x000020df,0x0000205a, -0x00000208,0x000500ab,0x0000002f,0x000020e0, -0x000020df,0x0000012b,0x000300f7,0x000020e7, -0x00000000,0x000400fa,0x000020e0,0x000020e1, -0x000020e4,0x000200f8,0x000020e4,0x000400c8, -0x00000006,0x000020e6,0x0000205a,0x000200f9, -0x000020e7,0x000200f8,0x000020e1,0x000500c7, -0x00000006,0x000020e3,0x0000205a,0x0000021d, -0x000200f9,0x000020e7,0x000200f8,0x000020e7, -0x000700f5,0x00000006,0x00005b09,0x000020e3, -0x000020e1,0x000020e6,0x000020e4,0x0004007c, -0x00000027,0x000020e9,0x00005b09,0x00050041, -0x00000009,0x0000205c,0x0000202d,0x000002ec, -0x0004003d,0x00000006,0x0000205d,0x0000205c, -0x000500c7,0x00000006,0x000020ee,0x0000205d, -0x00000208,0x000500ab,0x0000002f,0x000020ef, -0x000020ee,0x0000012b,0x000300f7,0x000020f6, -0x00000000,0x000400fa,0x000020ef,0x000020f0, -0x000020f3,0x000200f8,0x000020f3,0x000400c8, -0x00000006,0x000020f5,0x0000205d,0x000200f9, -0x000020f6,0x000200f8,0x000020f0,0x000500c7, -0x00000006,0x000020f2,0x0000205d,0x0000021d, -0x000200f9,0x000020f6,0x000200f8,0x000020f6, -0x000700f5,0x00000006,0x00005b0a,0x000020f2, -0x000020f0,0x000020f5,0x000020f3,0x0004007c, -0x00000027,0x000020f8,0x00005b0a,0x00050041, -0x00000009,0x0000205f,0x0000202d,0x000002f4, -0x0004003d,0x00000006,0x00002060,0x0000205f, -0x000500c7,0x00000006,0x000020fd,0x00002060, -0x00000208,0x000500ab,0x0000002f,0x000020fe, -0x000020fd,0x0000012b,0x000300f7,0x00002105, -0x00000000,0x000400fa,0x000020fe,0x000020ff, -0x00002102,0x000200f8,0x00002102,0x000400c8, -0x00000006,0x00002104,0x00002060,0x000200f9, -0x00002105,0x000200f8,0x000020ff,0x000500c7, -0x00000006,0x00002101,0x00002060,0x0000021d, -0x000200f9,0x00002105,0x000200f8,0x00002105, -0x000700f5,0x00000006,0x00005b0b,0x00002101, -0x000020ff,0x00002104,0x00002102,0x0004007c, -0x00000027,0x00002107,0x00005b0b,0x00060050, -0x00000063,0x00002062,0x000020e9,0x000020f8, -0x00002107,0x000200f9,0x00002063,0x000200f8, -0x00002063,0x000700f5,0x00000063,0x00005b10, -0x00005cc2,0x0000204b,0x00002062,0x00002105, -0x000700f5,0x00000063,0x00005b0c,0x0000053d, -0x0000204b,0x00002058,0x00002105,0x00050041, -0x0000022d,0x00001fb3,0x00000180,0x0000015e, -0x0004003d,0x00000007,0x00001fb4,0x00001fb3, -0x00050051,0x00000027,0x00001fb6,0x00005b0c, -0x00000000,0x0004007c,0x00000006,0x0000210d, -0x00001fb6,0x00050051,0x00000006,0x00002126, -0x00001fb4,0x00000000,0x00050095,0x00000130, -0x00002128,0x00002126,0x000001a2,0x00050051, -0x00000006,0x00002129,0x00002128,0x00000001, -0x00050051,0x00000006,0x0000212a,0x00002128, -0x00000000,0x00050051,0x00000006,0x0000212d, -0x00001fb4,0x00000001,0x00050080,0x00000006, -0x0000212f,0x0000212d,0x00002129,0x00050050, -0x00000007,0x00002130,0x0000212a,0x0000212f, -0x0004007c,0x00000014,0x00002120,0x00002130, -0x00060041,0x0000015f,0x00002118,0x00002120, -0x0000015e,0x0000015e,0x0005003e,0x00002118, -0x0000210d,0x00000002,0x00000004,0x00050051, -0x00000027,0x00001fbb,0x00005b0c,0x00000001, -0x0004007c,0x00000006,0x00002136,0x00001fbb, -0x00050095,0x00000130,0x00002151,0x00002126, -0x00000260,0x00050051,0x00000006,0x00002152, -0x00002151,0x00000001,0x00050051,0x00000006, -0x00002153,0x00002151,0x00000000,0x00050080, -0x00000006,0x00002158,0x0000212d,0x00002152, -0x00050050,0x00000007,0x00002159,0x00002153, -0x00002158,0x0004007c,0x00000014,0x00002149, -0x00002159,0x00060041,0x0000015f,0x00002141, -0x00002149,0x0000015e,0x0000015e,0x0005003e, -0x00002141,0x00002136,0x00000002,0x00000004, -0x00050051,0x00000027,0x00001fc0,0x00005b0c, -0x00000002,0x0004007c,0x00000006,0x0000215f, -0x00001fc0,0x00050095,0x00000130,0x0000217a, -0x00002126,0x000001b6,0x00050051,0x00000006, -0x0000217b,0x0000217a,0x00000001,0x00050051, -0x00000006,0x0000217c,0x0000217a,0x00000000, -0x00050080,0x00000006,0x00002181,0x0000212d, -0x0000217b,0x00050050,0x00000007,0x00002182, -0x0000217c,0x00002181,0x0004007c,0x00000014, -0x00002172,0x00002182,0x00060041,0x0000015f, -0x0000216a,0x00002172,0x0000015e,0x0000015e, -0x0005003e,0x0000216a,0x0000215f,0x00000002, -0x00000004,0x00050051,0x00000027,0x00001fc5, -0x00005b10,0x00000000,0x0004007c,0x00000006, -0x00002188,0x00001fc5,0x00050095,0x00000130, -0x000021a3,0x00002126,0x000005df,0x00050051, -0x00000006,0x000021a4,0x000021a3,0x00000001, -0x00050051,0x00000006,0x000021a5,0x000021a3, -0x00000000,0x00050080,0x00000006,0x000021aa, -0x0000212d,0x000021a4,0x00050050,0x00000007, -0x000021ab,0x000021a5,0x000021aa,0x0004007c, -0x00000014,0x0000219b,0x000021ab,0x00060041, -0x0000015f,0x00002193,0x0000219b,0x0000015e, -0x0000015e,0x0005003e,0x00002193,0x00002188, +0x000018ac,0x00005fa3,0x000001c4,0x000200f9, +0x00001890,0x000200f8,0x000018ad,0x000200f9, +0x000013fd,0x000200f8,0x00001311,0x000500aa, +0x0000002f,0x0000131a,0x000012df,0x00001319, +0x000300f7,0x0000131c,0x00000000,0x000400fa, +0x0000131a,0x0000131b,0x0000131c,0x000200f8, +0x0000131b,0x00050041,0x000012db,0x0000131e, +0x000012e3,0x00000138,0x0004003d,0x00000006, +0x0000131f,0x0000131e,0x00050041,0x000012db, +0x00001321,0x000012e4,0x00000138,0x0004003d, +0x00000006,0x00001322,0x00001321,0x000500aa, +0x0000002f,0x00001953,0x00001322,0x00000138, +0x000300f7,0x00001955,0x00000000,0x000400fa, +0x00001953,0x00001954,0x00001955,0x000200f8, +0x00001954,0x0003003e,0x00000e6f,0x00000138, +0x000200f9,0x00001955,0x000200f8,0x00001955, +0x000400e0,0x00000280,0x00000280,0x0000094f, +0x00050084,0x00000006,0x00001957,0x0000131f, +0x000001be,0x00050080,0x00000006,0x00001959, +0x00001957,0x000001be,0x00050041,0x000001bb, +0x000019a5,0x000001b9,0x000001f0,0x0004003d, +0x00000006,0x000019a6,0x000019a5,0x000500ac, +0x0000002f,0x000019a7,0x000019a6,0x00000142, +0x000300f7,0x000019ad,0x00000000,0x000400fa, +0x000019a7,0x000019a8,0x000019ac,0x000200f8, +0x000019ac,0x000200f9,0x000019ad,0x000200f8, +0x000019a8,0x00050082,0x00000006,0x000019ab, +0x000019a6,0x00000142,0x000200f9,0x000019ad, +0x000200f8,0x000019ad,0x000700f5,0x00000006, +0x00005f80,0x000019ab,0x000019a8,0x00000138, +0x000019ac,0x0007000c,0x00000006,0x0000195b, +0x00000001,0x00000026,0x00001959,0x00005f80, +0x00050080,0x00000006,0x0000195e,0x00001957, +0x00001322,0x000200f9,0x0000195f,0x000200f8, +0x0000195f,0x000700f5,0x00000006,0x00005f81, +0x0000195e,0x000019ad,0x00001994,0x00001992, +0x000500b0,0x0000002f,0x00001963,0x00005f81, +0x0000195b,0x000400f6,0x00001995,0x00001992, +0x00000000,0x000400fa,0x00001963,0x00001964, +0x00001995,0x000200f8,0x00001964,0x00050041, +0x000001bb,0x000019d7,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x000019d8,0x000019d7, +0x00050084,0x00000006,0x000019d9,0x000001db, +0x000019d8,0x00050080,0x00000006,0x000019da, +0x000001c4,0x000019d9,0x00050080,0x00000006, +0x000019e0,0x000019d8,0x0000062f,0x00050086, +0x00000006,0x000019e1,0x000019e0,0x000001be, +0x00050084,0x00000006,0x000019d3,0x000001c4, +0x000019e1,0x00050080,0x00000006,0x000019d4, +0x000019da,0x000019d3,0x00050080,0x00000006, +0x000019ce,0x000019d4,0x000019d3,0x00050084, +0x00000006,0x000019c7,0x000001ef,0x000019a6, +0x00050080,0x00000006,0x000019c8,0x000019ce, +0x000019c7,0x00050041,0x000001bb,0x000019be, +0x000001b9,0x00000206,0x0004003d,0x00000006, +0x000019bf,0x000019be,0x00050084,0x00000006, +0x000019c0,0x00000205,0x000019bf,0x00050080, +0x00000006,0x000019c1,0x000019c8,0x000019c0, +0x000300f7,0x000019f4,0x00000000,0x000400fa, +0x000019a7,0x000019ef,0x000019f3,0x000200f8, +0x000019f3,0x000200f9,0x000019f4,0x000200f8, +0x000019ef,0x00050082,0x00000006,0x000019f2, +0x000019a6,0x00000142,0x000200f9,0x000019f4, +0x000200f8,0x000019f4,0x000700f5,0x00000006, +0x00005f87,0x000019f2,0x000019ef,0x00000138, +0x000019f3,0x00050084,0x00000006,0x000019b9, +0x000000ec,0x00005f87,0x00050080,0x00000006, +0x000019ba,0x000019c1,0x000019b9,0x000300f7, +0x00001a01,0x00000000,0x000400fa,0x000019a7, +0x000019fc,0x00001a00,0x000200f8,0x00001a00, +0x000200f9,0x00001a01,0x000200f8,0x000019fc, +0x00050082,0x00000006,0x000019ff,0x000019a6, +0x00000142,0x000200f9,0x00001a01,0x000200f8, +0x00001a01,0x000700f5,0x00000006,0x00005f88, +0x000019ff,0x000019fc,0x00000138,0x00001a00, +0x00050084,0x00000006,0x000019b3,0x000000ec, +0x00005f88,0x00050080,0x00000006,0x000019b4, +0x000019ba,0x000019b3,0x00050084,0x00000006, +0x00001967,0x000000ec,0x00005f81,0x00050080, +0x00000006,0x00001968,0x000019b4,0x00001967, +0x00050041,0x00000266,0x00001969,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x0000196a, +0x00001969,0x00050051,0x00000006,0x00001a19, +0x0000196a,0x00000000,0x00050095,0x0000013d, +0x00001a1b,0x00001a19,0x00001968,0x00050051, +0x00000006,0x00001a1c,0x00001a1b,0x00000001, +0x00050051,0x00000006,0x00001a1d,0x00001a1b, +0x00000000,0x00050051,0x00000006,0x00001a20, +0x0000196a,0x00000001,0x00050080,0x00000006, +0x00001a22,0x00001a20,0x00001a1c,0x00050050, +0x00000007,0x00001a23,0x00001a1d,0x00001a22, +0x0004007c,0x00000014,0x00001a13,0x00001a23, +0x00060041,0x0000016c,0x00001a0a,0x00001a13, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00001a0b,0x00001a0a,0x00000002,0x00000004, +0x000200f9,0x0000196c,0x000200f8,0x0000196c, +0x000700f5,0x00000006,0x00005f8d,0x00000138, +0x00001a01,0x00001975,0x0000197d,0x000700f5, +0x00000006,0x00005f8c,0x00000138,0x00001a01, +0x0000197f,0x0000197d,0x000700f5,0x00000006, +0x00005f8b,0x00001a0b,0x00001a01,0x00001a80, +0x0000197d,0x000500ab,0x0000002f,0x0000196f, +0x00005f8b,0x00000539,0x000500b0,0x0000002f, +0x00001971,0x00005f8c,0x00000342,0x000500a7, +0x0000002f,0x00001972,0x0000196f,0x00001971, +0x000400f6,0x00001980,0x0000197d,0x00000000, +0x000400fa,0x00001972,0x00001973,0x00001980, +0x000200f8,0x00001973,0x00050080,0x00000006, +0x00001975,0x00005f8d,0x00000264,0x000300f7, +0x00001a69,0x00000000,0x000400fa,0x000019a7, +0x00001a64,0x00001a68,0x000200f8,0x00001a68, +0x000200f9,0x00001a69,0x000200f8,0x00001a64, +0x00050082,0x00000006,0x00001a67,0x000019a6, +0x00000142,0x000200f9,0x00001a69,0x000200f8, +0x00001a69,0x000700f5,0x00000006,0x00005f98, +0x00001a67,0x00001a64,0x00000138,0x00001a68, +0x00050084,0x00000006,0x00001a2e,0x000000ec, +0x00005f98,0x00050080,0x00000006,0x00001a2f, +0x000019c1,0x00001a2e,0x000300f7,0x00001a76, +0x00000000,0x000400fa,0x000019a7,0x00001a71, +0x00001a75,0x000200f8,0x00001a75,0x000200f9, +0x00001a76,0x000200f8,0x00001a71,0x00050082, +0x00000006,0x00001a74,0x000019a6,0x00000142, +0x000200f9,0x00001a76,0x000200f8,0x00001a76, +0x000700f5,0x00000006,0x00005f99,0x00001a74, +0x00001a71,0x00000138,0x00001a75,0x00050084, +0x00000006,0x00001a28,0x000000ec,0x00005f99, +0x00050080,0x00000006,0x00001a29,0x00001a2f, +0x00001a28,0x00050084,0x00000006,0x00001978, +0x000000ec,0x00005f8b,0x00050080,0x00000006, +0x00001979,0x00001a29,0x00001978,0x00050095, +0x0000013d,0x00001a90,0x00001a19,0x00001979, +0x00050051,0x00000006,0x00001a91,0x00001a90, +0x00000001,0x00050051,0x00000006,0x00001a92, +0x00001a90,0x00000000,0x00050080,0x00000006, +0x00001a97,0x00001a20,0x00001a91,0x00050050, +0x00000007,0x00001a98,0x00001a92,0x00001a97, +0x0004007c,0x00000014,0x00001a88,0x00001a98, +0x00060041,0x0000016c,0x00001a7f,0x00001a88, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00001a80,0x00001a7f,0x00000002,0x00000004, +0x000200f9,0x0000197d,0x000200f8,0x0000197d, +0x00050080,0x00000006,0x0000197f,0x00005f8c, +0x00000264,0x000200f9,0x0000196c,0x000200f8, +0x00001980,0x000500c7,0x00000006,0x00001982, +0x00005f8d,0x00000142,0x000500aa,0x0000002f, +0x00001983,0x00001982,0x00000138,0x000600a9, +0x00000006,0x00001984,0x00001983,0x00000142, +0x00000138,0x000300f7,0x00001ae4,0x00000000, +0x000400fa,0x000019a7,0x00001adf,0x00001ae3, +0x000200f8,0x00001ae3,0x000200f9,0x00001ae4, +0x000200f8,0x00001adf,0x00050082,0x00000006, +0x00001ae2,0x000019a6,0x00000142,0x000200f9, +0x00001ae4,0x000200f8,0x00001ae4,0x000700f5, +0x00000006,0x00005f90,0x00001ae2,0x00001adf, +0x00000138,0x00001ae3,0x00050084,0x00000006, +0x00001aa9,0x000000ec,0x00005f90,0x00050080, +0x00000006,0x00001aaa,0x000019c1,0x00001aa9, +0x000300f7,0x00001af1,0x00000000,0x000400fa, +0x000019a7,0x00001aec,0x00001af0,0x000200f8, +0x00001af0,0x000200f9,0x00001af1,0x000200f8, +0x00001aec,0x00050082,0x00000006,0x00001aef, +0x000019a6,0x00000142,0x000200f9,0x00001af1, +0x000200f8,0x00001af1,0x000700f5,0x00000006, +0x00005f91,0x00001aef,0x00001aec,0x00000138, +0x00001af0,0x00050084,0x00000006,0x00001aa3, +0x000000ec,0x00005f91,0x00050080,0x00000006, +0x00001aa4,0x00001aaa,0x00001aa3,0x000300f7, +0x00001afe,0x00000000,0x000400fa,0x000019a7, +0x00001af9,0x00001afd,0x000200f8,0x00001afd, +0x000200f9,0x00001afe,0x000200f8,0x00001af9, +0x00050082,0x00000006,0x00001afc,0x000019a6, +0x00000142,0x000200f9,0x00001afe,0x000200f8, +0x00001afe,0x000700f5,0x00000006,0x00005f92, +0x00001afc,0x00001af9,0x00000138,0x00001afd, +0x00050084,0x00000006,0x00001a9d,0x000000ec, +0x00005f92,0x00050080,0x00000006,0x00001a9e, +0x00001aa4,0x00001a9d,0x00050080,0x00000006, +0x00001988,0x00001a9e,0x00001967,0x00050095, +0x0000013d,0x00001b17,0x00001a19,0x00001988, +0x00050051,0x00000006,0x00001b18,0x00001b17, +0x00000001,0x00050051,0x00000006,0x00001b19, +0x00001b17,0x00000000,0x00050080,0x00000006, +0x00001b1e,0x00001a20,0x00001b18,0x00050050, +0x00000007,0x00001b1f,0x00001b19,0x00001b1e, +0x0004007c,0x00000014,0x00001b0f,0x00001b1f, +0x00060041,0x0000016c,0x00001b07,0x00001b0f, +0x0000016b,0x0000016b,0x0005003e,0x00001b07, +0x00001984,0x00000002,0x00000004,0x000300f7, +0x00001991,0x00000000,0x000400fa,0x00001983, +0x0000198f,0x00001991,0x000200f8,0x0000198f, +0x000700ea,0x00000006,0x00001990,0x00000e6f, +0x00000142,0x00000138,0x00000142,0x000200f9, +0x00001991,0x000200f8,0x00001991,0x000200f9, +0x00001992,0x000200f8,0x00001992,0x00050080, +0x00000006,0x00001994,0x00005f81,0x000001c4, +0x000200f9,0x0000195f,0x000200f8,0x00001995, +0x000400e0,0x00000280,0x00000280,0x0000094f, +0x000300f7,0x000019a1,0x00000000,0x000400fa, +0x00001953,0x00001998,0x000019a1,0x000200f8, +0x00001998,0x00050041,0x000001bb,0x00001b5a, +0x000001b9,0x000001ba,0x0004003d,0x00000006, +0x00001b5b,0x00001b5a,0x00050084,0x00000006, +0x00001b5c,0x000001db,0x00001b5b,0x00050080, +0x00000006,0x00001b5d,0x000001c4,0x00001b5c, +0x00050080,0x00000006,0x00001b63,0x00001b5b, +0x0000062f,0x00050086,0x00000006,0x00001b64, +0x00001b63,0x000001be,0x00050084,0x00000006, +0x00001b56,0x000001c4,0x00001b64,0x00050080, +0x00000006,0x00001b57,0x00001b5d,0x00001b56, +0x00050080,0x00000006,0x00001b51,0x00001b57, +0x00001b56,0x00050084,0x00000006,0x00001b4a, +0x000001ef,0x000019a6,0x00050080,0x00000006, +0x00001b4b,0x00001b51,0x00001b4a,0x00050041, +0x000001bb,0x00001b41,0x000001b9,0x00000206, +0x0004003d,0x00000006,0x00001b42,0x00001b41, +0x00050084,0x00000006,0x00001b43,0x00000205, +0x00001b42,0x00050080,0x00000006,0x00001b44, +0x00001b4b,0x00001b43,0x000300f7,0x00001b77, +0x00000000,0x000400fa,0x000019a7,0x00001b72, +0x00001b76,0x000200f8,0x00001b76,0x000200f9, +0x00001b77,0x000200f8,0x00001b72,0x00050082, +0x00000006,0x00001b75,0x000019a6,0x00000142, +0x000200f9,0x00001b77,0x000200f8,0x00001b77, +0x000700f5,0x00000006,0x00005f82,0x00001b75, +0x00001b72,0x00000138,0x00001b76,0x00050084, +0x00000006,0x00001b3c,0x000000ec,0x00005f82, +0x00050080,0x00000006,0x00001b3d,0x00001b44, +0x00001b3c,0x000300f7,0x00001b84,0x00000000, +0x000400fa,0x000019a7,0x00001b7f,0x00001b83, +0x000200f8,0x00001b83,0x000200f9,0x00001b84, +0x000200f8,0x00001b7f,0x00050082,0x00000006, +0x00001b82,0x000019a6,0x00000142,0x000200f9, +0x00001b84,0x000200f8,0x00001b84,0x000700f5, +0x00000006,0x00005f83,0x00001b82,0x00001b7f, +0x00000138,0x00001b83,0x00050084,0x00000006, +0x00001b36,0x000000ec,0x00005f83,0x00050080, +0x00000006,0x00001b37,0x00001b3d,0x00001b36, +0x000300f7,0x00001b91,0x00000000,0x000400fa, +0x000019a7,0x00001b8c,0x00001b90,0x000200f8, +0x00001b90,0x000200f9,0x00001b91,0x000200f8, +0x00001b8c,0x00050082,0x00000006,0x00001b8f, +0x000019a6,0x00000142,0x000200f9,0x00001b91, +0x000200f8,0x00001b91,0x000700f5,0x00000006, +0x00005f84,0x00001b8f,0x00001b8c,0x00000138, +0x00001b90,0x00050084,0x00000006,0x00001b30, +0x000000ec,0x00005f84,0x00050080,0x00000006, +0x00001b31,0x00001b37,0x00001b30,0x000300f7, +0x00001b9e,0x00000000,0x000400fa,0x000019a7, +0x00001b99,0x00001b9d,0x000200f8,0x00001b9d, +0x000200f9,0x00001b9e,0x000200f8,0x00001b99, +0x00050082,0x00000006,0x00001b9c,0x000019a6, +0x00000142,0x000200f9,0x00001b9e,0x000200f8, +0x00001b9e,0x000700f5,0x00000006,0x00005f85, +0x00001b9c,0x00001b99,0x00000138,0x00001b9d, +0x00050084,0x00000006,0x00001b2a,0x000000ec, +0x00005f85,0x00050080,0x00000006,0x00001b2b, +0x00001b31,0x00001b2a,0x000300f7,0x00001bab, +0x00000000,0x000400fa,0x000019a7,0x00001ba6, +0x00001baa,0x000200f8,0x00001baa,0x000200f9, +0x00001bab,0x000200f8,0x00001ba6,0x00050082, +0x00000006,0x00001ba9,0x000019a6,0x00000142, +0x000200f9,0x00001bab,0x000200f8,0x00001bab, +0x000700f5,0x00000006,0x00005f86,0x00001ba9, +0x00001ba6,0x00000138,0x00001baa,0x00050084, +0x00000006,0x00001b24,0x000000ec,0x00005f86, +0x00050080,0x00000006,0x00001b25,0x00001b2b, +0x00001b24,0x00050084,0x00000006,0x0000199b, +0x000000ec,0x0000131f,0x00050080,0x00000006, +0x0000199c,0x00001b25,0x0000199b,0x00050041, +0x00000266,0x0000199d,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x0000199e,0x0000199d, +0x0004003d,0x00000006,0x0000199f,0x00000e6f, +0x00050051,0x00000006,0x00001bc2,0x0000199e, +0x00000000,0x00050095,0x0000013d,0x00001bc4, +0x00001bc2,0x0000199c,0x00050051,0x00000006, +0x00001bc5,0x00001bc4,0x00000001,0x00050051, +0x00000006,0x00001bc6,0x00001bc4,0x00000000, +0x00050051,0x00000006,0x00001bc9,0x0000199e, +0x00000001,0x00050080,0x00000006,0x00001bcb, +0x00001bc9,0x00001bc5,0x00050050,0x00000007, +0x00001bcc,0x00001bc6,0x00001bcb,0x0004007c, +0x00000014,0x00001bbc,0x00001bcc,0x00060041, +0x0000016c,0x00001bb4,0x00001bbc,0x0000016b, +0x0000016b,0x0005003e,0x00001bb4,0x0000199f, +0x00000002,0x00000004,0x000200f9,0x000019a1, +0x000200f8,0x000019a1,0x000200f9,0x000013fd, +0x000200f8,0x0000131c,0x000500aa,0x0000002f, +0x00001327,0x000012df,0x00000a0e,0x000300f7, +0x00001329,0x00000000,0x000400fa,0x00001327, +0x00001328,0x00001329,0x000200f8,0x00001328, +0x00050041,0x000001bb,0x00001c07,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00001c08, +0x00001c07,0x00050084,0x00000006,0x00001c09, +0x000001db,0x00001c08,0x00050080,0x00000006, +0x00001c0a,0x000001c4,0x00001c09,0x00050080, +0x00000006,0x00001c10,0x00001c08,0x0000062f, +0x00050086,0x00000006,0x00001c11,0x00001c10, +0x000001be,0x00050084,0x00000006,0x00001c03, +0x000001c4,0x00001c11,0x00050080,0x00000006, +0x00001c04,0x00001c0a,0x00001c03,0x00050080, +0x00000006,0x00001bfe,0x00001c04,0x00001c03, +0x00050041,0x000001bb,0x00001bf5,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00001bf6, +0x00001bf5,0x00050084,0x00000006,0x00001bf7, +0x000001ef,0x00001bf6,0x00050080,0x00000006, +0x00001bf8,0x00001bfe,0x00001bf7,0x00050041, +0x000001bb,0x00001bee,0x000001b9,0x00000206, +0x0004003d,0x00000006,0x00001bef,0x00001bee, +0x00050084,0x00000006,0x00001bf0,0x00000205, +0x00001bef,0x00050080,0x00000006,0x00001bf1, +0x00001bf8,0x00001bf0,0x000500ac,0x0000002f, +0x00001c1e,0x00001bf6,0x00000142,0x000300f7, +0x00001c24,0x00000000,0x000400fa,0x00001c1e, +0x00001c1f,0x00001c23,0x000200f8,0x00001c23, +0x000200f9,0x00001c24,0x000200f8,0x00001c1f, +0x00050082,0x00000006,0x00001c22,0x00001bf6, +0x00000142,0x000200f9,0x00001c24,0x000200f8, +0x00001c24,0x000700f5,0x00000006,0x00005f6e, +0x00001c22,0x00001c1f,0x00000138,0x00001c23, +0x00050084,0x00000006,0x00001be9,0x000000ec, +0x00005f6e,0x00050080,0x00000006,0x00001bea, +0x00001bf1,0x00001be9,0x000300f7,0x00001c31, +0x00000000,0x000400fa,0x00001c1e,0x00001c2c, +0x00001c30,0x000200f8,0x00001c30,0x000200f9, +0x00001c31,0x000200f8,0x00001c2c,0x00050082, +0x00000006,0x00001c2f,0x00001bf6,0x00000142, +0x000200f9,0x00001c31,0x000200f8,0x00001c31, +0x000700f5,0x00000006,0x00005f6f,0x00001c2f, +0x00001c2c,0x00000138,0x00001c30,0x00050084, +0x00000006,0x00001be3,0x000000ec,0x00005f6f, +0x00050080,0x00000006,0x00001be4,0x00001bea, +0x00001be3,0x000300f7,0x00001c3e,0x00000000, +0x000400fa,0x00001c1e,0x00001c39,0x00001c3d, +0x000200f8,0x00001c3d,0x000200f9,0x00001c3e, +0x000200f8,0x00001c39,0x00050082,0x00000006, +0x00001c3c,0x00001bf6,0x00000142,0x000200f9, +0x00001c3e,0x000200f8,0x00001c3e,0x000700f5, +0x00000006,0x00005f70,0x00001c3c,0x00001c39, +0x00000138,0x00001c3d,0x00050084,0x00000006, +0x00001bdd,0x000000ec,0x00005f70,0x00050080, +0x00000006,0x00001bde,0x00001be4,0x00001bdd, +0x000300f7,0x00001c4b,0x00000000,0x000400fa, +0x00001c1e,0x00001c46,0x00001c4a,0x000200f8, +0x00001c4a,0x000200f9,0x00001c4b,0x000200f8, +0x00001c46,0x00050082,0x00000006,0x00001c49, +0x00001bf6,0x00000142,0x000200f9,0x00001c4b, +0x000200f8,0x00001c4b,0x000700f5,0x00000006, +0x00005f71,0x00001c49,0x00001c46,0x00000138, +0x00001c4a,0x00050084,0x00000006,0x00001bd7, +0x000000ec,0x00005f71,0x00050080,0x00000006, +0x00001bd8,0x00001bde,0x00001bd7,0x000300f7, +0x00001c58,0x00000000,0x000400fa,0x00001c1e, +0x00001c53,0x00001c57,0x000200f8,0x00001c57, +0x000200f9,0x00001c58,0x000200f8,0x00001c53, +0x00050082,0x00000006,0x00001c56,0x00001bf6, +0x00000142,0x000200f9,0x00001c58,0x000200f8, +0x00001c58,0x000700f5,0x00000006,0x00005f72, +0x00001c56,0x00001c53,0x00000138,0x00001c57, +0x00050084,0x00000006,0x00001bd1,0x000000ec, +0x00005f72,0x00050080,0x00000006,0x00001bd2, +0x00001bd8,0x00001bd1,0x000300f7,0x00001cb7, +0x00000000,0x000400fa,0x00001c1e,0x00001cb2, +0x00001cb6,0x000200f8,0x00001cb6,0x000200f9, +0x00001cb7,0x000200f8,0x00001cb2,0x00050082, +0x00000006,0x00001cb5,0x00001bf6,0x00000142, +0x000200f9,0x00001cb7,0x000200f8,0x00001cb7, +0x000700f5,0x00000006,0x00005f73,0x00001cb5, +0x00001cb2,0x00000138,0x00001cb6,0x00050084, +0x00000006,0x00001c7c,0x000000ec,0x00005f73, +0x00050080,0x00000006,0x00001c7d,0x00001bf1, +0x00001c7c,0x000300f7,0x00001cc4,0x00000000, +0x000400fa,0x00001c1e,0x00001cbf,0x00001cc3, +0x000200f8,0x00001cc3,0x000200f9,0x00001cc4, +0x000200f8,0x00001cbf,0x00050082,0x00000006, +0x00001cc2,0x00001bf6,0x00000142,0x000200f9, +0x00001cc4,0x000200f8,0x00001cc4,0x000700f5, +0x00000006,0x00005f74,0x00001cc2,0x00001cbf, +0x00000138,0x00001cc3,0x00050084,0x00000006, +0x00001c76,0x000000ec,0x00005f74,0x00050080, +0x00000006,0x00001c77,0x00001c7d,0x00001c76, +0x000300f7,0x00001cd1,0x00000000,0x000400fa, +0x00001c1e,0x00001ccc,0x00001cd0,0x000200f8, +0x00001cd0,0x000200f9,0x00001cd1,0x000200f8, +0x00001ccc,0x00050082,0x00000006,0x00001ccf, +0x00001bf6,0x00000142,0x000200f9,0x00001cd1, +0x000200f8,0x00001cd1,0x000700f5,0x00000006, +0x00005f75,0x00001ccf,0x00001ccc,0x00000138, +0x00001cd0,0x00050084,0x00000006,0x00001c70, +0x000000ec,0x00005f75,0x00050080,0x00000006, +0x00001c71,0x00001c77,0x00001c70,0x000300f7, +0x00001cde,0x00000000,0x000400fa,0x00001c1e, +0x00001cd9,0x00001cdd,0x000200f8,0x00001cdd, +0x000200f9,0x00001cde,0x000200f8,0x00001cd9, +0x00050082,0x00000006,0x00001cdc,0x00001bf6, +0x00000142,0x000200f9,0x00001cde,0x000200f8, +0x00001cde,0x000700f5,0x00000006,0x00005f76, +0x00001cdc,0x00001cd9,0x00000138,0x00001cdd, +0x00050084,0x00000006,0x00001c6a,0x000000ec, +0x00005f76,0x00050080,0x00000006,0x00001c6b, +0x00001c71,0x00001c6a,0x000300f7,0x00001ceb, +0x00000000,0x000400fa,0x00001c1e,0x00001ce6, +0x00001cea,0x000200f8,0x00001cea,0x000200f9, +0x00001ceb,0x000200f8,0x00001ce6,0x00050082, +0x00000006,0x00001ce9,0x00001bf6,0x00000142, +0x000200f9,0x00001ceb,0x000200f8,0x00001ceb, +0x000700f5,0x00000006,0x00005f77,0x00001ce9, +0x00001ce6,0x00000138,0x00001cea,0x00050084, +0x00000006,0x00001c64,0x000000ec,0x00005f77, +0x00050080,0x00000006,0x00001c65,0x00001c6b, +0x00001c64,0x000300f7,0x00001cfe,0x00000000, +0x000400fa,0x00001c1e,0x00001cf9,0x00001cfd, +0x000200f8,0x00001cfd,0x000200f9,0x00001cfe, +0x000200f8,0x00001cf9,0x00050082,0x00000006, +0x00001cfc,0x00001bf6,0x00000142,0x000200f9, +0x00001cfe,0x000200f8,0x00001cfe,0x000700f5, +0x00000006,0x00005f78,0x00001cfc,0x00001cf9, +0x00000138,0x00001cfd,0x00050080,0x00000006, +0x00001cf1,0x00005f78,0x0000062f,0x00050086, +0x00000006,0x00001cf2,0x00001cf1,0x000001be, +0x00050084,0x00000006,0x00001c5e,0x000000ec, +0x00001cf2,0x00050080,0x00000006,0x00001c5f, +0x00001c65,0x00001c5e,0x000300f7,0x00001d11, +0x00000000,0x000400fa,0x00001c1e,0x00001d0c, +0x00001d10,0x000200f8,0x00001d10,0x000200f9, +0x00001d11,0x000200f8,0x00001d0c,0x00050082, +0x00000006,0x00001d0f,0x00001bf6,0x00000142, +0x000200f9,0x00001d11,0x000200f8,0x00001d11, +0x000700f5,0x00000006,0x00005f79,0x00001d0f, +0x00001d0c,0x00000138,0x00001d10,0x00050080, +0x00000006,0x00001d04,0x00005f79,0x0000062f, +0x00050086,0x00000006,0x00001d05,0x00001d04, +0x000001be,0x00050041,0x000012db,0x0000132e, +0x000012e4,0x00000138,0x0004003d,0x00000006, +0x0000132f,0x0000132e,0x00050080,0x00000006, +0x00001d2a,0x00001d05,0x00000a56,0x00050086, +0x00000006,0x00001d2b,0x00001d2a,0x000001c4, +0x00050084,0x00000006,0x00001d2e,0x0000132f, +0x00001d2b,0x0007000c,0x00000006,0x00001d30, +0x00000001,0x00000026,0x00001d2e,0x00001d05, +0x00050080,0x00000006,0x00001d33,0x00001d30, +0x00001d2b,0x0007000c,0x00000006,0x00001d35, +0x00000001,0x00000026,0x00001d33,0x00001d05, +0x000200f9,0x00001d37,0x000200f8,0x00001d37, +0x000700f5,0x00000006,0x00005f7b,0x00000138, +0x00001d11,0x00001d45,0x00001d3c,0x000700f5, +0x00000006,0x00005f7a,0x00001d30,0x00001d11, +0x00001d48,0x00001d3c,0x000500b0,0x0000002f, +0x00001d3b,0x00005f7a,0x00001d35,0x000400f6, +0x00001d49,0x00001d3c,0x00000000,0x000400fa, +0x00001d3b,0x00001d3c,0x00001d49,0x000200f8, +0x00001d3c,0x00050084,0x00000006,0x00001d3f, +0x000000ec,0x00005f7a,0x00050080,0x00000006, +0x00001d40,0x00001bd2,0x00001d3f,0x00050041, +0x00000266,0x00001d41,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00001d42,0x00001d41, +0x00050051,0x00000006,0x00001da2,0x00001d42, +0x00000000,0x00050095,0x0000013d,0x00001da4, +0x00001da2,0x00001d40,0x00050051,0x00000006, +0x00001da5,0x00001da4,0x00000001,0x00050051, +0x00000006,0x00001da6,0x00001da4,0x00000000, +0x00050051,0x00000006,0x00001da9,0x00001d42, +0x00000001,0x00050080,0x00000006,0x00001dab, +0x00001da9,0x00001da5,0x00050050,0x00000007, +0x00001dac,0x00001da6,0x00001dab,0x0004007c, +0x00000014,0x00001d9c,0x00001dac,0x00060041, +0x0000016c,0x00001d93,0x00001d9c,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00001d94, +0x00001d93,0x00000002,0x00000004,0x00050080, +0x00000006,0x00001d45,0x00005f7b,0x00001d94, +0x00050080,0x00000006,0x00001d48,0x00005f7a, +0x00000264,0x000200f9,0x00001d37,0x000200f8, +0x00001d49,0x00050041,0x00000937,0x00001d4c, +0x00000a7f,0x0000132f,0x0003003e,0x00001d4c, +0x00005f7b,0x000400e0,0x00000280,0x00000280, +0x0000094f,0x000500aa,0x0000002f,0x00001d4e, +0x0000132f,0x00000138,0x000300f7,0x00001d6b, +0x00000000,0x000400fa,0x00001d4e,0x00001d4f, +0x00001d6b,0x000200f8,0x00001d4f,0x000200f9, +0x00001d50,0x000200f8,0x00001d50,0x000700f5, +0x00000006,0x00005f7d,0x00000138,0x00001d4f, +0x00001d5d,0x00001d54,0x000700f5,0x00000006, +0x00005f7c,0x00000138,0x00001d4f,0x00001d60, +0x00001d54,0x000500b0,0x0000002f,0x00001d53, +0x00005f7c,0x000001c4,0x000400f6,0x00001d61, +0x00001d54,0x00000000,0x000400fa,0x00001d53, +0x00001d54,0x00001d61,0x000200f8,0x00001d54, +0x00050041,0x00000937,0x00001d56,0x00000a7f, +0x00005f7c,0x0004003d,0x00000006,0x00001d57, +0x00001d56,0x0003003e,0x00001d56,0x00005f7d, +0x00050080,0x00000006,0x00001d5d,0x00005f7d, +0x00001d57,0x00050080,0x00000006,0x00001d60, +0x00005f7c,0x00000264,0x000200f9,0x00001d50, +0x000200f8,0x00001d61,0x00050041,0x00000266, +0x00001d65,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x00001d66,0x00001d65,0x00050051, +0x00000006,0x00001dc2,0x00001d66,0x00000000, +0x00050095,0x0000013d,0x00001dc4,0x00001dc2, +0x000001ef,0x00050051,0x00000006,0x00001dc5, +0x00001dc4,0x00000001,0x00050051,0x00000006, +0x00001dc6,0x00001dc4,0x00000000,0x00050051, +0x00000006,0x00001dc9,0x00001d66,0x00000001, +0x00050080,0x00000006,0x00001dcb,0x00001dc9, +0x00001dc5,0x00050050,0x00000007,0x00001dcc, +0x00001dc6,0x00001dcb,0x0004007c,0x00000014, +0x00001dbc,0x00001dcc,0x00060041,0x0000016c, +0x00001db4,0x00001dbc,0x0000016b,0x0000016b, +0x0005003e,0x00001db4,0x00005f7d,0x00000002, +0x00000004,0x000200f9,0x00001d6b,0x000200f8, +0x00001d6b,0x000400e0,0x00000280,0x00000280, +0x0000094f,0x0004003d,0x00000006,0x00001d6e, +0x00001d4c,0x000200f9,0x00001d70,0x000200f8, +0x00001d70,0x000700f5,0x00000006,0x00005f7f, +0x00001d6e,0x00001d6b,0x00001d87,0x00001d75, +0x000700f5,0x00000006,0x00005f7e,0x00001d30, +0x00001d6b,0x00001d8a,0x00001d75,0x000500b0, +0x0000002f,0x00001d74,0x00005f7e,0x00001d35, +0x000400f6,0x00001d8b,0x00001d75,0x00000000, +0x000400fa,0x00001d74,0x00001d75,0x00001d8b, +0x000200f8,0x00001d75,0x00050084,0x00000006, +0x00001d78,0x000000ec,0x00005f7e,0x00050080, +0x00000006,0x00001d79,0x00001bd2,0x00001d78, +0x00050041,0x00000266,0x00001d7a,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00001d7b, +0x00001d7a,0x00050051,0x00000006,0x00001de3, +0x00001d7b,0x00000000,0x00050095,0x0000013d, +0x00001de5,0x00001de3,0x00001d79,0x00050051, +0x00000006,0x00001de6,0x00001de5,0x00000001, +0x00050051,0x00000006,0x00001de7,0x00001de5, +0x00000000,0x00050051,0x00000006,0x00001dea, +0x00001d7b,0x00000001,0x00050080,0x00000006, +0x00001dec,0x00001dea,0x00001de6,0x00050050, +0x00000007,0x00001ded,0x00001de7,0x00001dec, +0x0004007c,0x00000014,0x00001ddd,0x00001ded, +0x00060041,0x0000016c,0x00001dd4,0x00001ddd, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00001dd5,0x00001dd4,0x00000002,0x00000004, +0x00050080,0x00000006,0x00001d80,0x00001c5f, +0x00001d78,0x00050095,0x0000013d,0x00001e05, +0x00001de3,0x00001d80,0x00050051,0x00000006, +0x00001e06,0x00001e05,0x00000001,0x00050051, +0x00000006,0x00001e07,0x00001e05,0x00000000, +0x00050080,0x00000006,0x00001e0c,0x00001dea, +0x00001e06,0x00050050,0x00000007,0x00001e0d, +0x00001e07,0x00001e0c,0x0004007c,0x00000014, +0x00001dfd,0x00001e0d,0x00060041,0x0000016c, +0x00001df5,0x00001dfd,0x0000016b,0x0000016b, +0x0005003e,0x00001df5,0x00005f7f,0x00000002, +0x00000004,0x00050080,0x00000006,0x00001d87, +0x00005f7f,0x00001dd5,0x00050080,0x00000006, +0x00001d8a,0x00005f7e,0x00000264,0x000200f9, +0x00001d70,0x000200f8,0x00001d8b,0x000200f9, +0x000013fd,0x000200f8,0x00001329,0x000500aa, +0x0000002f,0x00001338,0x000012df,0x000001db, +0x000300f7,0x0000133a,0x00000000,0x000400fa, +0x00001338,0x00001339,0x0000133a,0x000200f8, +0x00001339,0x00050041,0x000012db,0x0000133c, +0x000012e3,0x00000138,0x0004003d,0x00000006, +0x0000133d,0x0000133c,0x00050041,0x000012db, +0x0000133f,0x000012e4,0x00000138,0x0004003d, +0x00000006,0x00001340,0x0000133f,0x00050041, +0x000001bb,0x00001ebc,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x00001ebd,0x00001ebc, +0x00050084,0x00000006,0x00001ebe,0x000001db, +0x00001ebd,0x00050080,0x00000006,0x00001ebf, +0x000001c4,0x00001ebe,0x00050080,0x00000006, +0x00001ec5,0x00001ebd,0x0000062f,0x00050086, +0x00000006,0x00001ec6,0x00001ec5,0x000001be, +0x00050084,0x00000006,0x00001eb8,0x000001c4, +0x00001ec6,0x00050080,0x00000006,0x00001eb9, +0x00001ebf,0x00001eb8,0x00050080,0x00000006, +0x00001eb3,0x00001eb9,0x00001eb8,0x00050041, +0x000001bb,0x00001eaa,0x000001b9,0x000001f0, +0x0004003d,0x00000006,0x00001eab,0x00001eaa, +0x00050084,0x00000006,0x00001eac,0x000001ef, +0x00001eab,0x00050080,0x00000006,0x00001ead, +0x00001eb3,0x00001eac,0x00050041,0x000001bb, +0x00001ea3,0x000001b9,0x00000206,0x0004003d, +0x00000006,0x00001ea4,0x00001ea3,0x00050084, +0x00000006,0x00001ea5,0x00000205,0x00001ea4, +0x00050080,0x00000006,0x00001ea6,0x00001ead, +0x00001ea5,0x000500ac,0x0000002f,0x00001ed3, +0x00001eab,0x00000142,0x000300f7,0x00001ed9, +0x00000000,0x000400fa,0x00001ed3,0x00001ed4, +0x00001ed8,0x000200f8,0x00001ed8,0x000200f9, +0x00001ed9,0x000200f8,0x00001ed4,0x00050082, +0x00000006,0x00001ed7,0x00001eab,0x00000142, +0x000200f9,0x00001ed9,0x000200f8,0x00001ed9, +0x000700f5,0x00000006,0x00005f45,0x00001ed7, +0x00001ed4,0x00000138,0x00001ed8,0x00050084, +0x00000006,0x00001e9e,0x000000ec,0x00005f45, +0x00050080,0x00000006,0x00001e9f,0x00001ea6, +0x00001e9e,0x000300f7,0x00001ee6,0x00000000, +0x000400fa,0x00001ed3,0x00001ee1,0x00001ee5, +0x000200f8,0x00001ee5,0x000200f9,0x00001ee6, +0x000200f8,0x00001ee1,0x00050082,0x00000006, +0x00001ee4,0x00001eab,0x00000142,0x000200f9, +0x00001ee6,0x000200f8,0x00001ee6,0x000700f5, +0x00000006,0x00005f46,0x00001ee4,0x00001ee1, +0x00000138,0x00001ee5,0x00050084,0x00000006, +0x00001e98,0x000000ec,0x00005f46,0x00050080, +0x00000006,0x00001e99,0x00001e9f,0x00001e98, +0x000300f7,0x00001ef3,0x00000000,0x000400fa, +0x00001ed3,0x00001eee,0x00001ef2,0x000200f8, +0x00001ef2,0x000200f9,0x00001ef3,0x000200f8, +0x00001eee,0x00050082,0x00000006,0x00001ef1, +0x00001eab,0x00000142,0x000200f9,0x00001ef3, +0x000200f8,0x00001ef3,0x000700f5,0x00000006, +0x00005f47,0x00001ef1,0x00001eee,0x00000138, +0x00001ef2,0x00050084,0x00000006,0x00001e92, +0x000000ec,0x00005f47,0x00050080,0x00000006, +0x00001e93,0x00001e99,0x00001e92,0x000300f7, +0x00001f00,0x00000000,0x000400fa,0x00001ed3, +0x00001efb,0x00001eff,0x000200f8,0x00001eff, +0x000200f9,0x00001f00,0x000200f8,0x00001efb, +0x00050082,0x00000006,0x00001efe,0x00001eab, +0x00000142,0x000200f9,0x00001f00,0x000200f8, +0x00001f00,0x000700f5,0x00000006,0x00005f48, +0x00001efe,0x00001efb,0x00000138,0x00001eff, +0x00050084,0x00000006,0x00001e8c,0x000000ec, +0x00005f48,0x00050080,0x00000006,0x00001e8d, +0x00001e93,0x00001e8c,0x000300f7,0x00001f0d, +0x00000000,0x000400fa,0x00001ed3,0x00001f08, +0x00001f0c,0x000200f8,0x00001f0c,0x000200f9, +0x00001f0d,0x000200f8,0x00001f08,0x00050082, +0x00000006,0x00001f0b,0x00001eab,0x00000142, +0x000200f9,0x00001f0d,0x000200f8,0x00001f0d, +0x000700f5,0x00000006,0x00005f49,0x00001f0b, +0x00001f08,0x00000138,0x00001f0c,0x00050084, +0x00000006,0x00001e86,0x000000ec,0x00005f49, +0x00050080,0x00000006,0x00001e87,0x00001e8d, +0x00001e86,0x000300f7,0x00001f20,0x00000000, +0x000400fa,0x00001ed3,0x00001f1b,0x00001f1f, +0x000200f8,0x00001f1f,0x000200f9,0x00001f20, +0x000200f8,0x00001f1b,0x00050082,0x00000006, +0x00001f1e,0x00001eab,0x00000142,0x000200f9, +0x00001f20,0x000200f8,0x00001f20,0x000700f5, +0x00000006,0x00005f4a,0x00001f1e,0x00001f1b, +0x00000138,0x00001f1f,0x00050080,0x00000006, +0x00001f13,0x00005f4a,0x0000062f,0x00050086, +0x00000006,0x00001f14,0x00001f13,0x000001be, +0x00050084,0x00000006,0x00001e80,0x000000ec, +0x00001f14,0x00050080,0x00000006,0x00001e81, +0x00001e87,0x00001e80,0x00050084,0x00000006, +0x00001e22,0x000000ec,0x0000133d,0x00050080, +0x00000006,0x00001e23,0x00001e81,0x00001e22, +0x00050041,0x00000266,0x00001e24,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00001e25, +0x00001e24,0x00050051,0x00000006,0x00001f38, +0x00001e25,0x00000000,0x00050095,0x0000013d, +0x00001f3a,0x00001f38,0x00001e23,0x00050051, +0x00000006,0x00001f3b,0x00001f3a,0x00000001, +0x00050051,0x00000006,0x00001f3c,0x00001f3a, +0x00000000,0x00050051,0x00000006,0x00001f3f, +0x00001e25,0x00000001,0x00050080,0x00000006, +0x00001f41,0x00001f3f,0x00001f3b,0x00050050, +0x00000007,0x00001f42,0x00001f3c,0x00001f41, +0x0004007c,0x00000014,0x00001f32,0x00001f42, +0x00060041,0x0000016c,0x00001f29,0x00001f32, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00001f2a,0x00001f29,0x00000002,0x00000004, +0x00050084,0x00000006,0x00001e28,0x0000133d, +0x000001be,0x00050080,0x00000006,0x00001e2a, +0x00001e28,0x000001be,0x000300f7,0x00001f4e, +0x00000000,0x000400fa,0x00001ed3,0x00001f49, +0x00001f4d,0x000200f8,0x00001f4d,0x000200f9, +0x00001f4e,0x000200f8,0x00001f49,0x00050082, +0x00000006,0x00001f4c,0x00001eab,0x00000142, +0x000200f9,0x00001f4e,0x000200f8,0x00001f4e, +0x000700f5,0x00000006,0x00005f4b,0x00001f4c, +0x00001f49,0x00000138,0x00001f4d,0x0007000c, +0x00000006,0x00001e2c,0x00000001,0x00000026, +0x00001e2a,0x00005f4b,0x000200f9,0x00001e2e, +0x000200f8,0x00001e2e,0x000700f5,0x00000006, +0x00005f5f,0x00001f2a,0x00001f4e,0x00001e77, +0x00001e78,0x000700f5,0x00000006,0x00005f4c, +0x00001e28,0x00001f4e,0x00001e7a,0x00001e78, +0x000500b0,0x0000002f,0x00001e32,0x00005f4c, +0x00001e2c,0x000400f6,0x00001e7b,0x00001e78, +0x00000000,0x000400fa,0x00001e32,0x00001e33, +0x00001e7b,0x000200f8,0x00001e33,0x00050080, +0x00000006,0x00001e36,0x00005f4c,0x00001340, +0x000500b0,0x0000002f,0x00001e39,0x00001e36, +0x00001e2c,0x000300f7,0x00001e43,0x00000000, +0x000400fa,0x00001e39,0x00001e3a,0x00001e42, +0x000200f8,0x00001e42,0x000200f9,0x00001e43, +0x000200f8,0x00001e3a,0x000300f7,0x00001f9b, +0x00000000,0x000400fa,0x00001ed3,0x00001f96, +0x00001f9a,0x000200f8,0x00001f9a,0x000200f9, +0x00001f9b,0x000200f8,0x00001f96,0x00050082, +0x00000006,0x00001f99,0x00001eab,0x00000142, +0x000200f9,0x00001f9b,0x000200f8,0x00001f9b, +0x000700f5,0x00000006,0x00005f4d,0x00001f99, +0x00001f96,0x00000138,0x00001f9a,0x00050084, +0x00000006,0x00001f60,0x000000ec,0x00005f4d, +0x00050080,0x00000006,0x00001f61,0x00001ea6, +0x00001f60,0x000300f7,0x00001fa8,0x00000000, +0x000400fa,0x00001ed3,0x00001fa3,0x00001fa7, +0x000200f8,0x00001fa7,0x000200f9,0x00001fa8, +0x000200f8,0x00001fa3,0x00050082,0x00000006, +0x00001fa6,0x00001eab,0x00000142,0x000200f9, +0x00001fa8,0x000200f8,0x00001fa8,0x000700f5, +0x00000006,0x00005f4e,0x00001fa6,0x00001fa3, +0x00000138,0x00001fa7,0x00050084,0x00000006, +0x00001f5a,0x000000ec,0x00005f4e,0x00050080, +0x00000006,0x00001f5b,0x00001f61,0x00001f5a, +0x000300f7,0x00001fb5,0x00000000,0x000400fa, +0x00001ed3,0x00001fb0,0x00001fb4,0x000200f8, +0x00001fb4,0x000200f9,0x00001fb5,0x000200f8, +0x00001fb0,0x00050082,0x00000006,0x00001fb3, +0x00001eab,0x00000142,0x000200f9,0x00001fb5, +0x000200f8,0x00001fb5,0x000700f5,0x00000006, +0x00005f4f,0x00001fb3,0x00001fb0,0x00000138, +0x00001fb4,0x00050084,0x00000006,0x00001f54, +0x000000ec,0x00005f4f,0x00050080,0x00000006, +0x00001f55,0x00001f5b,0x00001f54,0x00050084, +0x00000006,0x00001e3d,0x000000ec,0x00001e36, +0x00050080,0x00000006,0x00001e3e,0x00001f55, +0x00001e3d,0x00050095,0x0000013d,0x00001fcf, +0x00001f38,0x00001e3e,0x00050051,0x00000006, +0x00001fd0,0x00001fcf,0x00000001,0x00050051, +0x00000006,0x00001fd1,0x00001fcf,0x00000000, +0x00050080,0x00000006,0x00001fd6,0x00001f3f, +0x00001fd0,0x00050050,0x00000007,0x00001fd7, +0x00001fd1,0x00001fd6,0x0004007c,0x00000014, +0x00001fc7,0x00001fd7,0x00060041,0x0000016c, +0x00001fbe,0x00001fc7,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00001fbf,0x00001fbe, +0x00000002,0x00000004,0x000200f9,0x00001e43, +0x000200f8,0x00001e43,0x000700f5,0x00000006, +0x00005f50,0x00001fbf,0x00001fb5,0x00000138, +0x00001e42,0x00050041,0x00000937,0x00001e47, +0x00000eff,0x00001340,0x0003003e,0x00001e47, +0x00005f50,0x000400e0,0x00000280,0x00000280, +0x0000094f,0x000200f9,0x00001e48,0x000200f8, +0x00001e48,0x000700f5,0x00000006,0x00005f51, +0x00000142,0x00001e43,0x00001e61,0x00001e5f, +0x000500b0,0x0000002f,0x00001e4b,0x00005f51, +0x000001c4,0x000400f6,0x00001e62,0x00001e5f, +0x00000000,0x000400fa,0x00001e4b,0x00001e4c, +0x00001e62,0x000200f8,0x00001e4c,0x000500ae, +0x0000002f,0x00001e4f,0x00001340,0x00005f51, +0x000300f7,0x00001e57,0x00000000,0x000400fa, +0x00001e4f,0x00001e50,0x00001e56,0x000200f8, +0x00001e56,0x000200f9,0x00001e57,0x000200f8, +0x00001e50,0x00050082,0x00000006,0x00001e53, +0x00001340,0x00005f51,0x00050041,0x00000937, +0x00001e54,0x00000eff,0x00001e53,0x0004003d, +0x00000006,0x00001e55,0x00001e54,0x000200f9, +0x00001e57,0x000200f8,0x00001e57,0x000700f5, +0x00000006,0x00005f6c,0x00001e55,0x00001e50, +0x00000138,0x00001e56,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x0004003d,0x00000006, +0x00001e5c,0x00001e47,0x00050080,0x00000006, +0x00001e5d,0x00001e5c,0x00005f6c,0x0003003e, +0x00001e47,0x00001e5d,0x000400e0,0x00000280, +0x00000280,0x0000094f,0x000200f9,0x00001e5f, +0x000200f8,0x00001e5f,0x000500c4,0x00000006, +0x00001e61,0x00005f51,0x00000264,0x000200f9, +0x00001e48,0x000200f8,0x00001e62,0x000500ab, +0x0000002f,0x00001e64,0x00005f50,0x00000138, +0x000300f7,0x00001e73,0x00000000,0x000400fa, +0x00001e64,0x00001e65,0x00001e73,0x000200f8, +0x00001e65,0x000300f7,0x00002029,0x00000000, +0x000400fa,0x00001ed3,0x00002024,0x00002028, +0x000200f8,0x00002028,0x000200f9,0x00002029, +0x000200f8,0x00002024,0x00050082,0x00000006, +0x00002027,0x00001eab,0x00000142,0x000200f9, +0x00002029,0x000200f8,0x00002029,0x000700f5, +0x00000006,0x00005f52,0x00002027,0x00002024, +0x00000138,0x00002028,0x00050084,0x00000006, +0x00001fee,0x000000ec,0x00005f52,0x00050080, +0x00000006,0x00001fef,0x00001ea6,0x00001fee, +0x000300f7,0x00002036,0x00000000,0x000400fa, +0x00001ed3,0x00002031,0x00002035,0x000200f8, +0x00002035,0x000200f9,0x00002036,0x000200f8, +0x00002031,0x00050082,0x00000006,0x00002034, +0x00001eab,0x00000142,0x000200f9,0x00002036, +0x000200f8,0x00002036,0x000700f5,0x00000006, +0x00005f53,0x00002034,0x00002031,0x00000138, +0x00002035,0x00050084,0x00000006,0x00001fe8, +0x000000ec,0x00005f53,0x00050080,0x00000006, +0x00001fe9,0x00001fef,0x00001fe8,0x000300f7, +0x00002043,0x00000000,0x000400fa,0x00001ed3, +0x0000203e,0x00002042,0x000200f8,0x00002042, +0x000200f9,0x00002043,0x000200f8,0x0000203e, +0x00050082,0x00000006,0x00002041,0x00001eab, +0x00000142,0x000200f9,0x00002043,0x000200f8, +0x00002043,0x000700f5,0x00000006,0x00005f54, +0x00002041,0x0000203e,0x00000138,0x00002042, +0x00050084,0x00000006,0x00001fe2,0x000000ec, +0x00005f54,0x00050080,0x00000006,0x00001fe3, +0x00001fe9,0x00001fe2,0x000300f7,0x00002050, +0x00000000,0x000400fa,0x00001ed3,0x0000204b, +0x0000204f,0x000200f8,0x0000204f,0x000200f9, +0x00002050,0x000200f8,0x0000204b,0x00050082, +0x00000006,0x0000204e,0x00001eab,0x00000142, +0x000200f9,0x00002050,0x000200f8,0x00002050, +0x000700f5,0x00000006,0x00005f55,0x0000204e, +0x0000204b,0x00000138,0x0000204f,0x00050084, +0x00000006,0x00001fdc,0x000000ec,0x00005f55, +0x00050080,0x00000006,0x00001fdd,0x00001fe3, +0x00001fdc,0x00050084,0x00000006,0x00001e68, +0x000000ec,0x00001e36,0x00050080,0x00000006, +0x00001e69,0x00001fdd,0x00001e68,0x0004003d, +0x00000006,0x00001e6d,0x00001e47,0x00050080, +0x00000006,0x00001e6e,0x00005f5f,0x00001e6d, +0x00050082,0x00000006,0x00001e6f,0x00001e6e, +0x00000142,0x00050095,0x0000013d,0x00002069, +0x00001f38,0x00001e69,0x00050051,0x00000006, +0x0000206a,0x00002069,0x00000001,0x00050051, +0x00000006,0x0000206b,0x00002069,0x00000000, +0x00050080,0x00000006,0x00002070,0x00001f3f, +0x0000206a,0x00050050,0x00000007,0x00002071, +0x0000206b,0x00002070,0x0004007c,0x00000014, +0x00002061,0x00002071,0x00060041,0x0000016c, +0x00002059,0x00002061,0x0000016b,0x0000016b, +0x0005003e,0x00002059,0x00001e6f,0x00000002, +0x00000004,0x000200f9,0x00001e73,0x000200f8, +0x00001e73,0x00050041,0x00000937,0x00001e74, +0x00000eff,0x00000b9b,0x0004003d,0x00000006, +0x00001e75,0x00001e74,0x00050080,0x00000006, +0x00001e77,0x00005f5f,0x00001e75,0x000400e0, +0x00000280,0x00000280,0x0000094f,0x000200f9, +0x00001e78,0x000200f8,0x00001e78,0x00050080, +0x00000006,0x00001e7a,0x00005f4c,0x000001c4, +0x000200f9,0x00001e2e,0x000200f8,0x00001e7b, +0x000200f9,0x000013fd,0x000200f8,0x0000133a, +0x000500aa,0x0000002f,0x00001345,0x000012df, +0x00000355,0x000300f7,0x00001347,0x00000000, +0x000400fa,0x00001345,0x00001346,0x00001347, +0x000200f8,0x00001346,0x000500aa,0x0000002f, +0x00001349,0x000012dd,0x00000138,0x000300f7, +0x0000134b,0x00000000,0x000400fa,0x00001349, +0x0000134a,0x0000134b,0x000200f8,0x0000134a, +0x000300f7,0x0000212c,0x00000000,0x000300fb, +0x00000138,0x000020b3,0x000200f8,0x000020b3, +0x000300f7,0x00002167,0x00000000,0x000300fb, +0x00000138,0x00002139,0x000200f8,0x00002139, +0x00050041,0x000001bb,0x00002188,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00002189, +0x00002188,0x00050084,0x00000006,0x0000218a, +0x000001db,0x00002189,0x00050080,0x00000006, +0x0000218b,0x000001c4,0x0000218a,0x00050080, +0x00000006,0x00002191,0x00002189,0x0000062f, +0x00050086,0x00000006,0x00002192,0x00002191, +0x000001be,0x00050084,0x00000006,0x00002184, +0x000001c4,0x00002192,0x00050080,0x00000006, +0x00002185,0x0000218b,0x00002184,0x00050080, +0x00000006,0x0000217f,0x00002185,0x00002184, +0x00050041,0x000001bb,0x00002176,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00002177, +0x00002176,0x00050084,0x00000006,0x00002178, +0x000001ef,0x00002177,0x00050080,0x00000006, +0x00002179,0x0000217f,0x00002178,0x00050041, +0x00000266,0x00002170,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00002171,0x00002170, +0x00050051,0x00000006,0x000021a7,0x00002171, +0x00000000,0x00050095,0x0000013d,0x000021a9, +0x000021a7,0x00002179,0x00050051,0x00000006, +0x000021aa,0x000021a9,0x00000001,0x00050051, +0x00000006,0x000021ab,0x000021a9,0x00000000, +0x00050051,0x00000006,0x000021ae,0x00002171, +0x00000001,0x00050080,0x00000006,0x000021b0, +0x000021ae,0x000021aa,0x00050050,0x00000007, +0x000021b1,0x000021ab,0x000021b0,0x0004007c, +0x00000014,0x000021a1,0x000021b1,0x000200f9, +0x0000213c,0x000200f8,0x0000213c,0x000700f5, +0x00000006,0x00005f35,0x00000138,0x00002139, +0x0000214a,0x00002140,0x000500b0,0x0000002f, +0x0000213f,0x00005f35,0x00000355,0x000400f6, +0x0000214b,0x00002140,0x00000000,0x000400fa, +0x0000213f,0x00002140,0x0000214b,0x000200f8, +0x00002140,0x00050080,0x00000006,0x00002144, +0x00000142,0x00005f35,0x00060041,0x0000016c, +0x00002145,0x000021a1,0x0000016b,0x00002144, +0x000700f1,0x00000006,0x00002146,0x00002145, +0x00000142,0x00000138,0x00000138,0x00050041, +0x00000009,0x00002147,0x00002131,0x00005f35, +0x0003003e,0x00002147,0x00002146,0x00050080, +0x00000006,0x0000214a,0x00005f35,0x00000264, +0x000200f9,0x0000213c,0x000200f8,0x0000214b, +0x00050041,0x00000009,0x0000214c,0x00002131, +0x0000016b,0x0004003d,0x00000006,0x0000214d, +0x0000214c,0x000500aa,0x0000002f,0x0000214e, +0x0000214d,0x00000539,0x000300f7,0x00002152, +0x00000000,0x000400fa,0x0000214e,0x0000214f, +0x00002152,0x000200f8,0x0000214f,0x000200f9, +0x00002167,0x000200f8,0x00002152,0x0004003d, +0x00000006,0x00002154,0x0000214c,0x000500c7, +0x00000006,0x000021b6,0x00002154,0x00000241, +0x000500ab,0x0000002f,0x000021b7,0x000021b6, +0x00000138,0x000300f7,0x000021be,0x00000000, +0x000400fa,0x000021b7,0x000021b8,0x000021bb, +0x000200f8,0x000021bb,0x000400c8,0x00000006, +0x000021bd,0x00002154,0x000200f9,0x000021be, +0x000200f8,0x000021b8,0x000500c7,0x00000006, +0x000021ba,0x00002154,0x00000256,0x000200f9, +0x000021be,0x000200f8,0x000021be,0x000700f5, +0x00000006,0x00005f36,0x000021ba,0x000021b8, +0x000021bd,0x000021bb,0x0004007c,0x00000027, +0x000021c0,0x00005f36,0x00050041,0x00000009, +0x00002156,0x00002131,0x00000264,0x0004003d, +0x00000006,0x00002157,0x00002156,0x000500c7, +0x00000006,0x000021c5,0x00002157,0x00000241, +0x000500ab,0x0000002f,0x000021c6,0x000021c5, +0x00000138,0x000300f7,0x000021cd,0x00000000, +0x000400fa,0x000021c6,0x000021c7,0x000021ca, +0x000200f8,0x000021ca,0x000400c8,0x00000006, +0x000021cc,0x00002157,0x000200f9,0x000021cd, +0x000200f8,0x000021c7,0x000500c7,0x00000006, +0x000021c9,0x00002157,0x00000256,0x000200f9, +0x000021cd,0x000200f8,0x000021cd,0x000700f5, +0x00000006,0x00005f37,0x000021c9,0x000021c7, +0x000021cc,0x000021ca,0x0004007c,0x00000027, +0x000021cf,0x00005f37,0x00050041,0x00000009, +0x00002159,0x00002131,0x00000315,0x0004003d, +0x00000006,0x0000215a,0x00002159,0x000500c7, +0x00000006,0x000021d4,0x0000215a,0x00000241, +0x000500ab,0x0000002f,0x000021d5,0x000021d4, +0x00000138,0x000300f7,0x000021dc,0x00000000, +0x000400fa,0x000021d5,0x000021d6,0x000021d9, +0x000200f8,0x000021d9,0x000400c8,0x00000006, +0x000021db,0x0000215a,0x000200f9,0x000021dc, +0x000200f8,0x000021d6,0x000500c7,0x00000006, +0x000021d8,0x0000215a,0x00000256,0x000200f9, +0x000021dc,0x000200f8,0x000021dc,0x000700f5, +0x00000006,0x00005f38,0x000021d8,0x000021d6, +0x000021db,0x000021d9,0x0004007c,0x00000027, +0x000021de,0x00005f38,0x00060050,0x0000006c, +0x0000215c,0x000021c0,0x000021cf,0x000021de, +0x00050041,0x00000009,0x0000215d,0x00002131, +0x0000031d,0x0004003d,0x00000006,0x0000215e, +0x0000215d,0x000500c7,0x00000006,0x000021e3, +0x0000215e,0x00000241,0x000500ab,0x0000002f, +0x000021e4,0x000021e3,0x00000138,0x000300f7, +0x000021eb,0x00000000,0x000400fa,0x000021e4, +0x000021e5,0x000021e8,0x000200f8,0x000021e8, +0x000400c8,0x00000006,0x000021ea,0x0000215e, +0x000200f9,0x000021eb,0x000200f8,0x000021e5, +0x000500c7,0x00000006,0x000021e7,0x0000215e, +0x00000256,0x000200f9,0x000021eb,0x000200f8, +0x000021eb,0x000700f5,0x00000006,0x00005f39, +0x000021e7,0x000021e5,0x000021ea,0x000021e8, +0x0004007c,0x00000027,0x000021ed,0x00005f39, +0x00050041,0x00000009,0x00002160,0x00002131, +0x00000325,0x0004003d,0x00000006,0x00002161, +0x00002160,0x000500c7,0x00000006,0x000021f2, +0x00002161,0x00000241,0x000500ab,0x0000002f, +0x000021f3,0x000021f2,0x00000138,0x000300f7, +0x000021fa,0x00000000,0x000400fa,0x000021f3, +0x000021f4,0x000021f7,0x000200f8,0x000021f7, +0x000400c8,0x00000006,0x000021f9,0x00002161, +0x000200f9,0x000021fa,0x000200f8,0x000021f4, +0x000500c7,0x00000006,0x000021f6,0x00002161, +0x00000256,0x000200f9,0x000021fa,0x000200f8, +0x000021fa,0x000700f5,0x00000006,0x00005f3a, +0x000021f6,0x000021f4,0x000021f9,0x000021f7, +0x0004007c,0x00000027,0x000021fc,0x00005f3a, +0x00050041,0x00000009,0x00002163,0x00002131, +0x0000032d,0x0004003d,0x00000006,0x00002164, +0x00002163,0x000500c7,0x00000006,0x00002201, +0x00002164,0x00000241,0x000500ab,0x0000002f, +0x00002202,0x00002201,0x00000138,0x000300f7, +0x00002209,0x00000000,0x000400fa,0x00002202, +0x00002203,0x00002206,0x000200f8,0x00002206, +0x000400c8,0x00000006,0x00002208,0x00002164, +0x000200f9,0x00002209,0x000200f8,0x00002203, +0x000500c7,0x00000006,0x00002205,0x00002164, +0x00000256,0x000200f9,0x00002209,0x000200f8, +0x00002209,0x000700f5,0x00000006,0x00005f3b, +0x00002205,0x00002203,0x00002208,0x00002206, +0x0004007c,0x00000027,0x0000220b,0x00005f3b, +0x00060050,0x0000006c,0x00002166,0x000021ed, +0x000021fc,0x0000220b,0x000200f9,0x00002167, +0x000200f8,0x00002167,0x000700f5,0x0000006c, +0x00005f40,0x000060fe,0x0000214f,0x00002166, +0x00002209,0x000700f5,0x0000006c,0x00005f3c, +0x00000576,0x0000214f,0x0000215c,0x00002209, +0x00050041,0x00000266,0x000020b7,0x000001b9, +0x0000016b,0x0004003d,0x00000007,0x000020b8, +0x000020b7,0x00050051,0x00000027,0x000020ba, +0x00005f3c,0x00000000,0x0004007c,0x00000006, +0x00002211,0x000020ba,0x00050051,0x00000006, +0x0000222a,0x000020b8,0x00000000,0x00050095, +0x0000013d,0x0000222c,0x0000222a,0x000001db, +0x00050051,0x00000006,0x0000222d,0x0000222c, +0x00000001,0x00050051,0x00000006,0x0000222e, +0x0000222c,0x00000000,0x00050051,0x00000006, +0x00002231,0x000020b8,0x00000001,0x00050080, +0x00000006,0x00002233,0x00002231,0x0000222d, +0x00050050,0x00000007,0x00002234,0x0000222e, +0x00002233,0x0004007c,0x00000014,0x00002224, +0x00002234,0x00060041,0x0000016c,0x0000221c, +0x00002224,0x0000016b,0x0000016b,0x0005003e, +0x0000221c,0x00002211,0x00000002,0x00000004, +0x00050051,0x00000027,0x000020bf,0x00005f3c, +0x00000001,0x0004007c,0x00000006,0x0000223a, +0x000020bf,0x00050095,0x0000013d,0x00002255, +0x0000222a,0x00000299,0x00050051,0x00000006, +0x00002256,0x00002255,0x00000001,0x00050051, +0x00000006,0x00002257,0x00002255,0x00000000, +0x00050080,0x00000006,0x0000225c,0x00002231, +0x00002256,0x00050050,0x00000007,0x0000225d, +0x00002257,0x0000225c,0x0004007c,0x00000014, +0x0000224d,0x0000225d,0x00060041,0x0000016c, +0x00002245,0x0000224d,0x0000016b,0x0000016b, +0x0005003e,0x00002245,0x0000223a,0x00000002, +0x00000004,0x00050051,0x00000027,0x000020c4, +0x00005f3c,0x00000002,0x0004007c,0x00000006, +0x00002263,0x000020c4,0x00050095,0x0000013d, +0x0000227e,0x0000222a,0x000001ef,0x00050051, +0x00000006,0x0000227f,0x0000227e,0x00000001, +0x00050051,0x00000006,0x00002280,0x0000227e, +0x00000000,0x00050080,0x00000006,0x00002285, +0x00002231,0x0000227f,0x00050050,0x00000007, +0x00002286,0x00002280,0x00002285,0x0004007c, +0x00000014,0x00002276,0x00002286,0x00060041, +0x0000016c,0x0000226e,0x00002276,0x0000016b, +0x0000016b,0x0005003e,0x0000226e,0x00002263, 0x00000002,0x00000004,0x00050051,0x00000027, -0x00001fca,0x00005b10,0x00000001,0x0004007c, -0x00000006,0x000021b1,0x00001fca,0x00050095, -0x00000130,0x000021cc,0x00002126,0x000001cc, -0x00050051,0x00000006,0x000021cd,0x000021cc, -0x00000001,0x00050051,0x00000006,0x000021ce, -0x000021cc,0x00000000,0x00050080,0x00000006, -0x000021d3,0x0000212d,0x000021cd,0x00050050, -0x00000007,0x000021d4,0x000021ce,0x000021d3, -0x0004007c,0x00000014,0x000021c4,0x000021d4, -0x00060041,0x0000015f,0x000021bc,0x000021c4, -0x0000015e,0x0000015e,0x0005003e,0x000021bc, -0x000021b1,0x00000002,0x00000004,0x00050051, -0x00000027,0x00001fcf,0x00005b10,0x00000002, -0x0004007c,0x00000006,0x000021da,0x00001fcf, -0x00050095,0x00000130,0x000021f5,0x00002126, -0x000004c7,0x00050051,0x00000006,0x000021f6, -0x000021f5,0x00000001,0x00050051,0x00000006, -0x000021f7,0x000021f5,0x00000000,0x00050080, -0x00000006,0x000021fc,0x0000212d,0x000021f6, -0x00050050,0x00000007,0x000021fd,0x000021f7, -0x000021fc,0x0004007c,0x00000014,0x000021ed, -0x000021fd,0x00060041,0x0000015f,0x000021e5, -0x000021ed,0x0000015e,0x0000015e,0x0005003e, -0x000021e5,0x000021da,0x00000002,0x00000004, -0x00050041,0x00000182,0x00001fd1,0x00000180, -0x000003fb,0x0004003d,0x00000006,0x00001fd2, -0x00001fd1,0x000500aa,0x0000002f,0x00001fd3, -0x00001fd2,0x00000135,0x000300f7,0x00001fd5, -0x00000000,0x000400fa,0x00001fd3,0x00001fd4, -0x00001fd5,0x000200f8,0x00001fd4,0x000200f9, -0x00002028,0x000200f8,0x00001fd5,0x000500b2, -0x0000002f,0x00001fd8,0x00002073,0x00000135, -0x000300f7,0x00001fde,0x00000000,0x000400fa, -0x00001fd8,0x00001fd9,0x00001fda,0x000200f8, -0x00001fda,0x00050095,0x00000130,0x00002216, -0x000020a3,0x000001b6,0x00050051,0x00000006, -0x00002217,0x00002216,0x00000001,0x00050051, -0x00000006,0x00002218,0x00002216,0x00000000, -0x00050080,0x00000006,0x0000221d,0x000020aa, -0x00002217,0x00050050,0x00000007,0x0000221e, -0x00002218,0x0000221d,0x0004007c,0x00000014, -0x0000220e,0x0000221e,0x00060041,0x0000015f, -0x00002205,0x0000220e,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00002206,0x00002205, -0x00000002,0x00000004,0x000200f9,0x00001fde, -0x000200f8,0x00001fd9,0x000200f9,0x00001fde, -0x000200f8,0x00001fde,0x000700f5,0x00000006, -0x00005b11,0x00000135,0x00001fd9,0x00002206, -0x00001fda,0x00050041,0x00000182,0x00001fe0, -0x00000180,0x00000321,0x0004003d,0x00000006, -0x00001fe1,0x00001fe0,0x00050041,0x00000182, -0x00002225,0x00000180,0x000002fb,0x0004003d, -0x00000006,0x00002226,0x00002225,0x000500c7, -0x00000006,0x00002227,0x00002226,0x00000247, -0x000500ab,0x0000002f,0x00002228,0x00002227, -0x0000012b,0x000600a9,0x00000006,0x00002222, -0x00002228,0x0000018b,0x00000309,0x00050084, -0x00000006,0x00001fe4,0x00002222,0x00005b11, -0x00050080,0x00000006,0x00001fe5,0x00001fe1, -0x00001fe4,0x000300f7,0x00001ffa,0x00000000, -0x000400fa,0x00002228,0x00001fe7,0x00001ffa, -0x000200f8,0x00001fe7,0x000200f9,0x00001fe8, -0x000200f8,0x00001fe8,0x000700f5,0x00000006, -0x00005b12,0x0000012b,0x00001fe7,0x00001ff6, -0x00001fec,0x000500b0,0x0000002f,0x00001feb, -0x00005b12,0x000001a2,0x000400f6,0x00001ff7, -0x00001fec,0x00000000,0x000400fa,0x00001feb, -0x00001fec,0x00001ff7,0x000200f8,0x00001fec, -0x00050084,0x00000006,0x00001fef,0x000000df, -0x00005b12,0x00050080,0x00000006,0x00001ff0, -0x00001fe5,0x00001fef,0x00050095,0x00000130, -0x00002246,0x00002126,0x00001ff0,0x00050051, -0x00000006,0x00002247,0x00002246,0x00000001, -0x00050051,0x00000006,0x00002248,0x00002246, -0x00000000,0x00050080,0x00000006,0x0000224d, -0x0000212d,0x00002247,0x00050050,0x00000007, -0x0000224e,0x00002248,0x0000224d,0x0004007c, -0x00000014,0x0000223e,0x0000224e,0x00060041, -0x0000015f,0x00002236,0x0000223e,0x0000015e, -0x0000015e,0x0005003e,0x00002236,0x0000012b, -0x00000002,0x00000004,0x00050080,0x00000006, -0x00001ff6,0x00005b12,0x0000022b,0x000200f9, -0x00001fe8,0x000200f8,0x00001ff7,0x00050080, -0x00000006,0x00001ff9,0x00001fe5,0x0000018b, -0x000200f9,0x00001ffa,0x000200f8,0x00001ffa, -0x000700f5,0x00000006,0x00005b14,0x00001fe5, -0x00001fde,0x00001ff9,0x00001ff7,0x000500c7, -0x00000006,0x00002253,0x00002226,0x00000135, -0x000500ab,0x0000002f,0x00002254,0x00002253, -0x0000012b,0x000600a9,0x00000006,0x00001ffd, -0x00002254,0x0000031c,0x00005cd3,0x00050095, -0x00000130,0x0000226c,0x00002126,0x0000012b, -0x00050051,0x00000006,0x0000226d,0x0000226c, -0x00000001,0x00050051,0x00000006,0x0000226e, -0x0000226c,0x00000000,0x00050080,0x00000006, -0x00002273,0x0000212d,0x0000226d,0x00050050, -0x00000007,0x00002274,0x0000226e,0x00002273, -0x0004007c,0x00000014,0x00002264,0x00002274, -0x00060041,0x0000015f,0x0000225c,0x00002264, -0x0000015e,0x0000015e,0x0005003e,0x0000225c, -0x00001ffd,0x00000002,0x00000004,0x00050086, -0x00000006,0x00002002,0x00005b14,0x0000018b, -0x00050082,0x00000006,0x00002003,0x00002002, -0x00000135,0x00050095,0x00000130,0x0000228c, -0x00002126,0x000000df,0x00050051,0x00000006, -0x0000228d,0x0000228c,0x00000001,0x00050051, -0x00000006,0x0000228e,0x0000228c,0x00000000, -0x00050080,0x00000006,0x00002293,0x0000212d, -0x0000228d,0x00050050,0x00000007,0x00002294, -0x0000228e,0x00002293,0x0004007c,0x00000014, -0x00002284,0x00002294,0x00060041,0x0000015f, -0x0000227c,0x00002284,0x0000015e,0x0000015e, -0x0005003e,0x0000227c,0x00002003,0x00000002, -0x00000004,0x00050095,0x00000130,0x000022ac, -0x00002126,0x00000194,0x00050051,0x00000006, -0x000022ad,0x000022ac,0x00000001,0x00050051, -0x00000006,0x000022ae,0x000022ac,0x00000000, -0x00050080,0x00000006,0x000022b3,0x0000212d, -0x000022ad,0x00050050,0x00000007,0x000022b4, -0x000022ae,0x000022b3,0x0004007c,0x00000014, -0x000022a4,0x000022b4,0x00060041,0x0000015f, -0x0000229c,0x000022a4,0x0000015e,0x0000015e, -0x0005003e,0x0000229c,0x0000012b,0x00000002, -0x00000004,0x00050095,0x00000130,0x000022cc, -0x00002126,0x0000019b,0x00050051,0x00000006, -0x000022cd,0x000022cc,0x00000001,0x00050051, -0x00000006,0x000022ce,0x000022cc,0x00000000, -0x00050080,0x00000006,0x000022d3,0x0000212d, -0x000022cd,0x00050050,0x00000007,0x000022d4, -0x000022ce,0x000022d3,0x0004007c,0x00000014, -0x000022c4,0x000022d4,0x00060041,0x0000015f, -0x000022bc,0x000022c4,0x0000015e,0x0000015e, -0x0005003e,0x000022bc,0x00002073,0x00000002, -0x00000004,0x00050095,0x00000130,0x000022ec, -0x00002126,0x000004d2,0x00050051,0x00000006, -0x000022ed,0x000022ec,0x00000001,0x00050051, -0x00000006,0x000022ee,0x000022ec,0x00000000, -0x00050080,0x00000006,0x000022f3,0x0000212d, -0x000022ed,0x00050050,0x00000007,0x000022f4, -0x000022ee,0x000022f3,0x0004007c,0x00000014, -0x000022e4,0x000022f4,0x00060041,0x0000015f, -0x000022dc,0x000022e4,0x0000015e,0x0000015e, -0x0005003e,0x000022dc,0x00001fe1,0x00000002, -0x00000004,0x00050095,0x00000130,0x0000230c, -0x00002126,0x000004dd,0x00050051,0x00000006, -0x0000230d,0x0000230c,0x00000001,0x00050051, -0x00000006,0x0000230e,0x0000230c,0x00000000, -0x00050080,0x00000006,0x00002313,0x0000212d, -0x0000230d,0x00050050,0x00000007,0x00002314, -0x0000230e,0x00002313,0x0004007c,0x00000014, -0x00002304,0x00002314,0x00060041,0x0000015f, -0x000022fc,0x00002304,0x0000015e,0x0000015e, -0x0005003e,0x000022fc,0x0000012b,0x00000002, -0x00000004,0x000500c2,0x00000006,0x0000231d, -0x00001fe1,0x00000318,0x000500c4,0x00000006, -0x0000231e,0x0000231d,0x000002e4,0x000600a9, -0x00000006,0x00002320,0x00002228,0x000000df, -0x0000032b,0x000500c5,0x00000006,0x00002321, -0x0000231e,0x00002320,0x00050095,0x00000130, -0x00002349,0x00002126,0x000004e8,0x00050051, -0x00000006,0x0000234a,0x00002349,0x00000001, -0x00050051,0x00000006,0x0000234b,0x00002349, -0x00000000,0x00050080,0x00000006,0x00002350, -0x0000212d,0x0000234a,0x00050050,0x00000007, -0x00002351,0x0000234b,0x00002350,0x0004007c, -0x00000014,0x00002341,0x00002351,0x00060041, -0x0000015f,0x00002339,0x00002341,0x0000015e, -0x0000015e,0x0005003e,0x00002339,0x00002321, -0x00000002,0x00000004,0x00050041,0x00000182, -0x0000201d,0x00000180,0x00000311,0x0004003d, -0x00000006,0x0000201e,0x0000201d,0x00050095, -0x00000130,0x00002369,0x00002126,0x000004f4, -0x00050051,0x00000006,0x0000236a,0x00002369, -0x00000001,0x00050051,0x00000006,0x0000236b, -0x00002369,0x00000000,0x00050080,0x00000006, -0x00002370,0x0000212d,0x0000236a,0x00050050, -0x00000007,0x00002371,0x0000236b,0x00002370, -0x0004007c,0x00000014,0x00002361,0x00002371, -0x00060041,0x0000015f,0x00002359,0x00002361, -0x0000015e,0x0000015e,0x0005003e,0x00002359, -0x0000201e,0x00000002,0x00000004,0x00050041, -0x00000182,0x00002022,0x00000180,0x00000fbf, -0x0004003d,0x00000006,0x00002023,0x00002022, -0x00050095,0x00000130,0x00002389,0x00002126, -0x000004fe,0x00050051,0x00000006,0x0000238a, -0x00002389,0x00000001,0x00050051,0x00000006, -0x0000238b,0x00002389,0x00000000,0x00050080, -0x00000006,0x00002390,0x0000212d,0x0000238a, -0x00050050,0x00000007,0x00002391,0x0000238b, -0x00002390,0x0004007c,0x00000014,0x00002381, -0x00002391,0x00060041,0x0000015f,0x00002379, -0x00002381,0x0000015e,0x0000015e,0x0005003e, -0x00002379,0x00002023,0x00000002,0x00000004, -0x00050095,0x00000130,0x000023a9,0x00002126, -0x00000508,0x00050051,0x00000006,0x000023aa, -0x000023a9,0x00000001,0x00050051,0x00000006, -0x000023ab,0x000023a9,0x00000000,0x00050080, -0x00000006,0x000023b0,0x0000212d,0x000023aa, -0x00050050,0x00000007,0x000023b1,0x000023ab, -0x000023b0,0x0004007c,0x00000014,0x000023a1, -0x000023b1,0x00060041,0x0000015f,0x00002399, -0x000023a1,0x0000015e,0x0000015e,0x0005003e, -0x00002399,0x0000012b,0x00000002,0x00000004, -0x000200f9,0x00002028,0x000200f8,0x00002028, -0x000200f9,0x0000124c,0x000200f8,0x0000124c, -0x000200f9,0x000012fe,0x000200f8,0x00001248, -0x00050041,0x00000182,0x00001250,0x00000180, -0x00000653,0x0004003d,0x00000006,0x00001251, -0x00001250,0x000500ae,0x0000002f,0x00001252, -0x000011de,0x00001251,0x000300f7,0x00001254, -0x00000000,0x000400fa,0x00001252,0x00001253, -0x00001254,0x000200f8,0x00001253,0x000200f9, -0x000012fe,0x000200f8,0x00001254,0x000500aa, -0x0000002f,0x00001259,0x000011e0,0x00001258, -0x000300f7,0x0000125b,0x00000000,0x000400fa, -0x00001259,0x0000125a,0x0000125b,0x000200f8, -0x0000125a,0x000500aa,0x0000002f,0x0000125d, -0x000011de,0x0000012b,0x000300f7,0x0000125f, -0x00000000,0x000400fa,0x0000125d,0x0000125e, -0x0000125f,0x000200f8,0x0000125e,0x00050041, -0x0000022d,0x00001261,0x00000180,0x000002dc, -0x0004003d,0x00000007,0x00001262,0x00001261, -0x00050051,0x00000006,0x000023c8,0x00001262, -0x00000000,0x00050095,0x00000130,0x000023ca, -0x000023c8,0x000000df,0x00050051,0x00000006, -0x000023cb,0x000023ca,0x00000001,0x00050051, -0x00000006,0x000023cc,0x000023ca,0x00000000, -0x00050051,0x00000006,0x000023cf,0x00001262, -0x00000001,0x00050080,0x00000006,0x000023d1, -0x000023cf,0x000023cb,0x00050050,0x00000007, -0x000023d2,0x000023cc,0x000023d1,0x0004007c, -0x00000014,0x000023c2,0x000023d2,0x00060041, -0x0000015f,0x000023b9,0x000023c2,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000023ba, -0x000023b9,0x00000002,0x00000004,0x00050080, -0x00000006,0x00001265,0x000023ba,0x00000135, -0x00050084,0x00000006,0x00001266,0x00001265, -0x0000018b,0x00050041,0x0000022d,0x00001268, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x00001269,0x00001268,0x00050051,0x00000006, -0x000023e8,0x00001269,0x00000000,0x00050095, -0x00000130,0x000023ea,0x000023e8,0x0000012b, -0x00050051,0x00000006,0x000023eb,0x000023ea, -0x00000001,0x00050051,0x00000006,0x000023ec, -0x000023ea,0x00000000,0x00050051,0x00000006, -0x000023ef,0x00001269,0x00000001,0x00050080, -0x00000006,0x000023f1,0x000023ef,0x000023eb, -0x00050050,0x00000007,0x000023f2,0x000023ec, -0x000023f1,0x0004007c,0x00000014,0x000023e2, -0x000023f2,0x00060041,0x0000015f,0x000023da, -0x000023e2,0x0000015e,0x0000015e,0x0005003e, -0x000023da,0x00001266,0x00000002,0x00000004, -0x00050095,0x00000130,0x0000240a,0x000023e8, -0x000000df,0x00050051,0x00000006,0x0000240b, -0x0000240a,0x00000001,0x00050051,0x00000006, -0x0000240c,0x0000240a,0x00000000,0x00050080, -0x00000006,0x00002411,0x000023ef,0x0000240b, -0x00050050,0x00000007,0x00002412,0x0000240c, -0x00002411,0x0004007c,0x00000014,0x00002402, -0x00002412,0x00060041,0x0000015f,0x000023fa, -0x00002402,0x0000015e,0x0000015e,0x0005003e, -0x000023fa,0x0000012b,0x00000002,0x00000004, -0x000200f9,0x0000125f,0x000200f8,0x0000125f, -0x000200f9,0x000012fe,0x000200f8,0x0000125b, -0x000500aa,0x0000002f,0x00001276,0x000011e0, -0x0000019b,0x000300f7,0x00001278,0x00000000, -0x000400fa,0x00001276,0x00001277,0x00001278, -0x000200f8,0x00001277,0x00050084,0x00000006, -0x0000127a,0x000000df,0x000011de,0x00050041, -0x0000022d,0x0000127c,0x00000180,0x000002dc, -0x0004003d,0x00000007,0x0000127d,0x0000127c, -0x00050051,0x00000006,0x00002429,0x0000127d, -0x00000000,0x00050095,0x00000130,0x0000242b, -0x00002429,0x000000df,0x00050051,0x00000006, -0x0000242c,0x0000242b,0x00000001,0x00050051, -0x00000006,0x0000242d,0x0000242b,0x00000000, -0x00050051,0x00000006,0x00002430,0x0000127d, -0x00000001,0x00050080,0x00000006,0x00002432, -0x00002430,0x0000242c,0x00050050,0x00000007, -0x00002433,0x0000242d,0x00002432,0x0004007c, -0x00000014,0x00002423,0x00002433,0x00060041, -0x0000015f,0x0000241a,0x00002423,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x0000241b, -0x0000241a,0x00000002,0x00000004,0x00050080, -0x00000006,0x00001280,0x0000241b,0x00000135, -0x00050084,0x00000006,0x00001281,0x00001280, -0x0000018b,0x000500b0,0x0000002f,0x00001282, -0x0000127a,0x00001281,0x000300f7,0x00001284, -0x00000000,0x000400fa,0x00001282,0x00001283, -0x00001284,0x000200f8,0x00001283,0x00050095, -0x00000130,0x0000244c,0x00002429,0x0000127a, -0x00050051,0x00000006,0x0000244d,0x0000244c, -0x00000001,0x00050051,0x00000006,0x0000244e, -0x0000244c,0x00000000,0x00050080,0x00000006, -0x00002453,0x00002430,0x0000244d,0x00050050, -0x00000007,0x00002454,0x0000244e,0x00002453, -0x0004007c,0x00000014,0x00002444,0x00002454, -0x00060041,0x0000015f,0x0000243b,0x00002444, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x0000243c,0x0000243b,0x00000002,0x00000004, -0x00050041,0x0000022d,0x0000128f,0x00000180, -0x0000015e,0x0004003d,0x00000007,0x00001290, -0x0000128f,0x00050051,0x00000006,0x0000246a, -0x00001290,0x00000000,0x00050095,0x00000130, -0x0000246c,0x0000246a,0x0000127a,0x00050051, -0x00000006,0x0000246d,0x0000246c,0x00000001, -0x00050051,0x00000006,0x0000246e,0x0000246c, -0x00000000,0x00050051,0x00000006,0x00002471, -0x00001290,0x00000001,0x00050080,0x00000006, -0x00002473,0x00002471,0x0000246d,0x00050050, -0x00000007,0x00002474,0x0000246e,0x00002473, -0x0004007c,0x00000014,0x00002464,0x00002474, -0x00060041,0x0000015f,0x0000245c,0x00002464, -0x0000015e,0x0000015e,0x0005003e,0x0000245c, -0x0000243c,0x00000002,0x00000004,0x000200f9, -0x00001284,0x000200f8,0x00001284,0x000200f9, -0x000012fe,0x000200f8,0x00001278,0x000500aa, -0x0000002f,0x00001297,0x000011e0,0x0000012b, -0x000300f7,0x00001299,0x00000000,0x000400fa, -0x00001297,0x00001298,0x000012ba,0x000200f8, -0x000012ba,0x000500aa,0x0000002f,0x000012bd, -0x000011e0,0x00000135,0x000300f7,0x000012bf, -0x00000000,0x000400fa,0x000012bd,0x000012be, -0x000012c3,0x000200f8,0x000012c3,0x000500aa, -0x0000002f,0x000012c6,0x000011e0,0x00000247, -0x000300f7,0x000012c8,0x00000000,0x000400fa, -0x000012c6,0x000012c7,0x000012cc,0x000200f8, -0x000012cc,0x000500aa,0x0000002f,0x000012cf, -0x000011e0,0x00000437,0x000300f7,0x000012d1, -0x00000000,0x000400fa,0x000012cf,0x000012d0, -0x000012d5,0x000200f8,0x000012d5,0x000500aa, -0x0000002f,0x000012d8,0x000011e0,0x000000df, -0x000300f7,0x000012da,0x00000000,0x000400fa, -0x000012d8,0x000012d9,0x000012df,0x000200f8, -0x000012df,0x000500aa,0x0000002f,0x000012e2, -0x000011e0,0x0000032b,0x000300f7,0x000012e4, -0x00000000,0x000400fa,0x000012e2,0x000012e3, -0x000012e8,0x000200f8,0x000012e8,0x000500aa, -0x0000002f,0x000012ec,0x000011e0,0x000012eb, -0x000300f7,0x000012ee,0x00000000,0x000400fa, -0x000012ec,0x000012ed,0x000012f2,0x000200f8, -0x000012f2,0x000500aa,0x0000002f,0x000012f6, -0x000011e0,0x000012f5,0x000300f7,0x000012f8, -0x00000000,0x000400fa,0x000012f6,0x000012f7, -0x000012f8,0x000200f8,0x000012f7,0x00050041, -0x00000182,0x000056be,0x00000180,0x00000181, -0x0004003d,0x00000006,0x000056bf,0x000056be, -0x00050084,0x00000006,0x000056c0,0x000001a2, -0x000056bf,0x00050080,0x00000006,0x000056c1, -0x0000018b,0x000056c0,0x00050080,0x00000006, -0x000056c7,0x000056bf,0x00005cc3,0x00050086, -0x00000006,0x000056c8,0x000056c7,0x00000185, -0x00050084,0x00000006,0x000056ba,0x0000018b, -0x000056c8,0x00050080,0x00000006,0x000056bb, -0x000056c1,0x000056ba,0x00050080,0x00000006, -0x000056b5,0x000056bb,0x000056ba,0x00050041, -0x00000182,0x000056ac,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x000056ad,0x000056ac, -0x00050084,0x00000006,0x000056ae,0x000001b6, -0x000056ad,0x00050080,0x00000006,0x000056af, -0x000056b5,0x000056ae,0x00050084,0x00000006, -0x000056a4,0x000001cc,0x000011de,0x00050080, -0x00000006,0x000056a5,0x000056af,0x000056a4, -0x00050041,0x0000022d,0x000056a6,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x000056a7, -0x000056a6,0x00050051,0x00000006,0x000056dd, -0x000056a7,0x00000000,0x00050095,0x00000130, -0x000056df,0x000056dd,0x000056a5,0x00050051, -0x00000006,0x000056e0,0x000056df,0x00000001, -0x00050051,0x00000006,0x000056e1,0x000056df, -0x00000000,0x00050051,0x00000006,0x000056e4, -0x000056a7,0x00000001,0x00050080,0x00000006, -0x000056e6,0x000056e4,0x000056e0,0x00050050, -0x00000007,0x000056e7,0x000056e1,0x000056e6, -0x0004007c,0x00000014,0x000056d7,0x000056e7, -0x00060041,0x0000015f,0x00005691,0x000056d7, -0x0000015e,0x0000015e,0x0005003e,0x00005691, -0x0000012b,0x00000002,0x00000004,0x00060041, -0x0000015f,0x00005693,0x000056d7,0x0000015e, -0x0000022b,0x0005003e,0x00005693,0x00000500, -0x00000002,0x00000004,0x00060041,0x0000015f, -0x00005695,0x000056d7,0x0000015e,0x000002dc, -0x0005003e,0x00005695,0x00000500,0x00000002, -0x00000004,0x00060041,0x0000015f,0x00005697, -0x000056d7,0x0000015e,0x000002e4,0x0005003e, -0x00005697,0x00000500,0x00000002,0x00000004, -0x00060041,0x0000015f,0x00005699,0x000056d7, -0x0000015e,0x000002ec,0x0005003e,0x00005699, -0x0000012b,0x00000002,0x00000004,0x00060041, -0x0000015f,0x0000569b,0x000056d7,0x0000015e, -0x000002f4,0x0005003e,0x0000569b,0x0000012b, -0x00000002,0x00000004,0x00060041,0x0000015f, -0x0000569d,0x000056d7,0x0000015e,0x00000318, -0x0005003e,0x0000569d,0x0000012b,0x00000002, -0x00000004,0x000200f9,0x000012f8,0x000200f8, -0x000012f8,0x000200f9,0x000012ee,0x000200f8, -0x000012ed,0x000300f7,0x00004e17,0x00000000, -0x000300fb,0x0000012b,0x00004d82,0x000200f8, -0x00004d82,0x00050041,0x00000182,0x00004d83, -0x00000180,0x000003fb,0x0004003d,0x00000006, -0x00004d84,0x00004d83,0x000500aa,0x0000002f, -0x00004d85,0x00004d84,0x00000135,0x000300f7, -0x00004d91,0x00000000,0x000400fa,0x00004d85, -0x00004d86,0x00004d89,0x000200f8,0x00004d89, -0x00050041,0x00000182,0x00004e7b,0x00000180, -0x00000181,0x0004003d,0x00000006,0x00004e7c, -0x00004e7b,0x00050084,0x00000006,0x00004e7d, -0x000001a2,0x00004e7c,0x00050080,0x00000006, -0x00004e7e,0x0000018b,0x00004e7d,0x00050080, -0x00000006,0x00004e84,0x00004e7c,0x00005cc3, -0x00050086,0x00000006,0x00004e85,0x00004e84, -0x00000185,0x00050084,0x00000006,0x00004e77, -0x0000018b,0x00004e85,0x00050080,0x00000006, -0x00004e78,0x00004e7e,0x00004e77,0x00050080, -0x00000006,0x00004e72,0x00004e78,0x00004e77, -0x00050041,0x00000182,0x00004e69,0x00000180, -0x000001b7,0x0004003d,0x00000006,0x00004e6a, -0x00004e69,0x00050084,0x00000006,0x00004e6b, -0x000001b6,0x00004e6a,0x00050080,0x00000006, -0x00004e6c,0x00004e72,0x00004e6b,0x00050041, -0x00000182,0x00004e62,0x00000180,0x000001cd, -0x0004003d,0x00000006,0x00004e63,0x00004e62, -0x00050084,0x00000006,0x00004e64,0x000001cc, -0x00004e63,0x00050080,0x00000006,0x00004e65, -0x00004e6c,0x00004e64,0x000500ac,0x0000002f, -0x00004e92,0x00004e6a,0x00000135,0x000300f7, -0x00004e98,0x00000000,0x000400fa,0x00004e92, -0x00004e93,0x00004e97,0x000200f8,0x00004e97, -0x000200f9,0x00004e98,0x000200f8,0x00004e93, -0x00050082,0x00000006,0x00004e96,0x00004e6a, -0x00000135,0x000200f9,0x00004e98,0x000200f8, -0x00004e98,0x000700f5,0x00000006,0x0000591b, -0x00004e96,0x00004e93,0x0000012b,0x00004e97, -0x00050084,0x00000006,0x00004e5d,0x000000df, -0x0000591b,0x00050080,0x00000006,0x00004e5e, -0x00004e65,0x00004e5d,0x000300f7,0x00004ea5, -0x00000000,0x000400fa,0x00004e92,0x00004ea0, -0x00004ea4,0x000200f8,0x00004ea4,0x000200f9, -0x00004ea5,0x000200f8,0x00004ea0,0x00050082, -0x00000006,0x00004ea3,0x00004e6a,0x00000135, -0x000200f9,0x00004ea5,0x000200f8,0x00004ea5, -0x000700f5,0x00000006,0x0000591c,0x00004ea3, -0x00004ea0,0x0000012b,0x00004ea4,0x00050084, -0x00000006,0x00004e57,0x000000df,0x0000591c, -0x00050080,0x00000006,0x00004e58,0x00004e5e, -0x00004e57,0x000300f7,0x00004eb2,0x00000000, -0x000400fa,0x00004e92,0x00004ead,0x00004eb1, -0x000200f8,0x00004eb1,0x000200f9,0x00004eb2, -0x000200f8,0x00004ead,0x00050082,0x00000006, -0x00004eb0,0x00004e6a,0x00000135,0x000200f9, -0x00004eb2,0x000200f8,0x00004eb2,0x000700f5, -0x00000006,0x0000591d,0x00004eb0,0x00004ead, -0x0000012b,0x00004eb1,0x00050084,0x00000006, -0x00004e51,0x000000df,0x0000591d,0x00050080, -0x00000006,0x00004e52,0x00004e58,0x00004e51, -0x000300f7,0x00004ebf,0x00000000,0x000400fa, -0x00004e92,0x00004eba,0x00004ebe,0x000200f8, -0x00004ebe,0x000200f9,0x00004ebf,0x000200f8, -0x00004eba,0x00050082,0x00000006,0x00004ebd, -0x00004e6a,0x00000135,0x000200f9,0x00004ebf, -0x000200f8,0x00004ebf,0x000700f5,0x00000006, -0x0000591e,0x00004ebd,0x00004eba,0x0000012b, -0x00004ebe,0x00050084,0x00000006,0x00004e4b, -0x000000df,0x0000591e,0x00050080,0x00000006, -0x00004e4c,0x00004e52,0x00004e4b,0x000300f7, -0x00004ecc,0x00000000,0x000400fa,0x00004e92, -0x00004ec7,0x00004ecb,0x000200f8,0x00004ecb, -0x000200f9,0x00004ecc,0x000200f8,0x00004ec7, -0x00050082,0x00000006,0x00004eca,0x00004e6a, -0x00000135,0x000200f9,0x00004ecc,0x000200f8, -0x00004ecc,0x000700f5,0x00000006,0x0000591f, -0x00004eca,0x00004ec7,0x0000012b,0x00004ecb, -0x00050084,0x00000006,0x00004e45,0x000000df, -0x0000591f,0x00050080,0x00000006,0x00004e46, -0x00004e4c,0x00004e45,0x000300f7,0x00004edf, -0x00000000,0x000400fa,0x00004e92,0x00004eda, -0x00004ede,0x000200f8,0x00004ede,0x000200f9, -0x00004edf,0x000200f8,0x00004eda,0x00050082, -0x00000006,0x00004edd,0x00004e6a,0x00000135, -0x000200f9,0x00004edf,0x000200f8,0x00004edf, -0x000700f5,0x00000006,0x00005920,0x00004edd, -0x00004eda,0x0000012b,0x00004ede,0x00050080, -0x00000006,0x00004ed2,0x00005920,0x00005cc3, -0x00050086,0x00000006,0x00004ed3,0x00004ed2, -0x00000185,0x00050084,0x00000006,0x00004e3f, -0x000000df,0x00004ed3,0x00050080,0x00000006, -0x00004e40,0x00004e46,0x00004e3f,0x000300f7, -0x00004ef2,0x00000000,0x000400fa,0x00004e92, -0x00004eed,0x00004ef1,0x000200f8,0x00004ef1, -0x000200f9,0x00004ef2,0x000200f8,0x00004eed, -0x00050082,0x00000006,0x00004ef0,0x00004e6a, -0x00000135,0x000200f9,0x00004ef2,0x000200f8, -0x00004ef2,0x000700f5,0x00000006,0x00005921, -0x00004ef0,0x00004eed,0x0000012b,0x00004ef1, -0x00050080,0x00000006,0x00004ee5,0x00005921, -0x00005cc3,0x00050086,0x00000006,0x00004ee6, -0x00004ee5,0x00000185,0x00050084,0x00000006, -0x00004e39,0x000000df,0x00004ee6,0x00050080, -0x00000006,0x00004e3a,0x00004e40,0x00004e39, -0x00050084,0x00000006,0x00004d8c,0x000000df, -0x000011de,0x00050080,0x00000006,0x00004d8d, -0x00004e3a,0x00004d8c,0x00050041,0x0000022d, -0x00004d8e,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00004d8f,0x00004d8e,0x00050051, -0x00000006,0x00004f0a,0x00004d8f,0x00000000, -0x00050095,0x00000130,0x00004f0c,0x00004f0a, -0x00004d8d,0x00050051,0x00000006,0x00004f0d, -0x00004f0c,0x00000001,0x00050051,0x00000006, -0x00004f0e,0x00004f0c,0x00000000,0x00050051, -0x00000006,0x00004f11,0x00004d8f,0x00000001, -0x00050080,0x00000006,0x00004f13,0x00004f11, -0x00004f0d,0x00050050,0x00000007,0x00004f14, -0x00004f0e,0x00004f13,0x0004007c,0x00000014, -0x00004f04,0x00004f14,0x00060041,0x0000015f, -0x00004efb,0x00004f04,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004efc,0x00004efb, -0x00000002,0x00000004,0x000200f9,0x00004d91, -0x000200f8,0x00004d86,0x00050041,0x00000182, -0x00004e1a,0x00000180,0x00000311,0x0004003d, -0x00000006,0x00004e1b,0x00004e1a,0x00050041, -0x00000182,0x00004e2b,0x00000180,0x000002fb, -0x0004003d,0x00000006,0x00004e2c,0x00004e2b, -0x000500c7,0x00000006,0x00004e2d,0x00004e2c, -0x00000135,0x000500ab,0x0000002f,0x00004e2e, -0x00004e2d,0x0000012b,0x000600a9,0x00000006, -0x00004e28,0x00004e2e,0x00000309,0x0000018b, -0x00050084,0x00000006,0x00004e1e,0x000011de, -0x00004e28,0x00050080,0x00000006,0x00004e1f, -0x00004e1b,0x00004e1e,0x000500c2,0x00000006, -0x00004e20,0x00004e1f,0x00000318,0x000500c4, -0x00000006,0x00004e21,0x00004e20,0x000002e4, -0x000600a9,0x00000006,0x00004e23,0x00004e2e, -0x0000031c,0x0000012b,0x000500c5,0x00000006, -0x00004e24,0x00004e21,0x00004e23,0x000200f9, -0x00004d91,0x000200f8,0x00004d91,0x000700f5, -0x00000006,0x00005922,0x00004e24,0x00004d86, -0x00004efc,0x00004ef2,0x00050041,0x00000182, -0x00004f5a,0x00000180,0x00000181,0x0004003d, -0x00000006,0x00004f5b,0x00004f5a,0x00050084, -0x00000006,0x00004f5c,0x000001a2,0x00004f5b, -0x00050080,0x00000006,0x00004f5d,0x0000018b, -0x00004f5c,0x00050080,0x00000006,0x00004f63, -0x00004f5b,0x00005cc3,0x00050086,0x00000006, -0x00004f64,0x00004f63,0x00000185,0x00050084, -0x00000006,0x00004f56,0x0000018b,0x00004f64, -0x00050080,0x00000006,0x00004f57,0x00004f5d, -0x00004f56,0x00050080,0x00000006,0x00004f51, -0x00004f57,0x00004f56,0x00050084,0x00000006, -0x00004f25,0x000001b6,0x000011de,0x00050080, -0x00000006,0x00004f26,0x00004f51,0x00004f25, -0x00050041,0x0000022d,0x00004f27,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x00004f28, -0x00004f27,0x00050051,0x00000006,0x00004f82, -0x00004f28,0x00000000,0x00050095,0x00000130, -0x00004f84,0x00004f82,0x00004f26,0x00050051, -0x00000006,0x00004f85,0x00004f84,0x00000001, -0x00050051,0x00000006,0x00004f86,0x00004f84, -0x00000000,0x00050051,0x00000006,0x00004f89, -0x00004f28,0x00000001,0x00050080,0x00000006, -0x00004f8b,0x00004f89,0x00004f85,0x00050050, -0x00000007,0x00004f8c,0x00004f86,0x00004f8b, -0x0004007c,0x00000014,0x00004f7c,0x00004f8c, -0x00060041,0x0000015f,0x00004f73,0x00004f7c, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00004f74,0x00004f73,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00004f2b,0x00004f74, -0x00050080,0x00000006,0x00004f2d,0x00004f26, -0x000000df,0x00050095,0x00000130,0x00004fa5, -0x00004f82,0x00004f2d,0x00050051,0x00000006, -0x00004fa6,0x00004fa5,0x00000001,0x00050051, -0x00000006,0x00004fa7,0x00004fa5,0x00000000, -0x00050080,0x00000006,0x00004fac,0x00004f89, -0x00004fa6,0x00050050,0x00000007,0x00004fad, -0x00004fa7,0x00004fac,0x0004007c,0x00000014, -0x00004f9d,0x00004fad,0x00060041,0x0000015f, -0x00004f94,0x00004f9d,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004f95,0x00004f94, -0x00000002,0x00000004,0x0004007c,0x00000027, -0x00004f31,0x00004f95,0x00050080,0x00000006, -0x00004f33,0x00004f26,0x00000194,0x00050095, -0x00000130,0x00004fc6,0x00004f82,0x00004f33, -0x00050051,0x00000006,0x00004fc7,0x00004fc6, -0x00000001,0x00050051,0x00000006,0x00004fc8, -0x00004fc6,0x00000000,0x00050080,0x00000006, -0x00004fcd,0x00004f89,0x00004fc7,0x00050050, -0x00000007,0x00004fce,0x00004fc8,0x00004fcd, -0x0004007c,0x00000014,0x00004fbe,0x00004fce, -0x00060041,0x0000015f,0x00004fb5,0x00004fbe, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00004fb6,0x00004fb5,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00004f37,0x00004fb6, -0x00060050,0x00000063,0x00004f38,0x00004f2b, -0x00004f31,0x00004f37,0x00050080,0x00000006, -0x00004f3a,0x00004f26,0x0000019b,0x00050095, -0x00000130,0x00004fe7,0x00004f82,0x00004f3a, -0x00050051,0x00000006,0x00004fe8,0x00004fe7, -0x00000001,0x00050051,0x00000006,0x00004fe9, -0x00004fe7,0x00000000,0x00050080,0x00000006, -0x00004fee,0x00004f89,0x00004fe8,0x00050050, -0x00000007,0x00004fef,0x00004fe9,0x00004fee, -0x0004007c,0x00000014,0x00004fdf,0x00004fef, -0x00060041,0x0000015f,0x00004fd6,0x00004fdf, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00004fd7,0x00004fd6,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00004f3e,0x00004fd7, -0x00050080,0x00000006,0x00004f40,0x00004f26, -0x000001a2,0x00050095,0x00000130,0x00005008, -0x00004f82,0x00004f40,0x00050051,0x00000006, -0x00005009,0x00005008,0x00000001,0x00050051, -0x00000006,0x0000500a,0x00005008,0x00000000, -0x00050080,0x00000006,0x0000500f,0x00004f89, -0x00005009,0x00050050,0x00000007,0x00005010, -0x0000500a,0x0000500f,0x0004007c,0x00000014, -0x00005000,0x00005010,0x00060041,0x0000015f, -0x00004ff7,0x00005000,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004ff8,0x00004ff7, -0x00000002,0x00000004,0x0004007c,0x00000027, -0x00004f44,0x00004ff8,0x00050080,0x00000006, -0x00004f46,0x00004f26,0x00000260,0x00050095, -0x00000130,0x00005029,0x00004f82,0x00004f46, -0x00050051,0x00000006,0x0000502a,0x00005029, -0x00000001,0x00050051,0x00000006,0x0000502b, -0x00005029,0x00000000,0x00050080,0x00000006, -0x00005030,0x00004f89,0x0000502a,0x00050050, -0x00000007,0x00005031,0x0000502b,0x00005030, -0x0004007c,0x00000014,0x00005021,0x00005031, -0x00060041,0x0000015f,0x00005018,0x00005021, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00005019,0x00005018,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00004f4a,0x00005019, -0x00060050,0x00000063,0x00004f4b,0x00004f3e, -0x00004f44,0x00004f4a,0x00050041,0x00000182, -0x00005037,0x00000180,0x00000fbf,0x0004003d, -0x00000006,0x00005038,0x00005037,0x000500c2, -0x00000006,0x00005047,0x00005922,0x000002e4, -0x00050041,0x00000182,0x0000503b,0x00000180, -0x00000311,0x0004003d,0x00000006,0x0000503c, -0x0000503b,0x00050086,0x00000006,0x0000503d, -0x0000503c,0x0000018b,0x00050082,0x00000006, -0x0000503e,0x00005047,0x0000503d,0x00050084, -0x00000006,0x0000503f,0x000000df,0x0000503e, -0x00050080,0x00000006,0x00005040,0x00005038, -0x0000503f,0x00050041,0x0000022d,0x00005041, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x00005042,0x00005041,0x00050051,0x00000006, -0x0000505e,0x00005042,0x00000000,0x00050095, -0x00000130,0x00005060,0x0000505e,0x00005040, -0x00050051,0x00000006,0x00005061,0x00005060, -0x00000001,0x00050051,0x00000006,0x00005062, -0x00005060,0x00000000,0x00050051,0x00000006, -0x00005065,0x00005042,0x00000001,0x00050080, -0x00000006,0x00005067,0x00005065,0x00005061, -0x00050050,0x00000007,0x00005068,0x00005062, -0x00005067,0x0004007c,0x00000014,0x00005058, -0x00005068,0x00060041,0x0000015f,0x0000504f, -0x00005058,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00005050,0x0000504f,0x00000002, -0x00000004,0x00050041,0x00000182,0x0000506b, -0x00000180,0x000002fb,0x0004003d,0x00000006, -0x0000506c,0x0000506b,0x000500c7,0x00000006, -0x0000506d,0x0000506c,0x00000135,0x000500ab, -0x0000002f,0x0000506e,0x0000506d,0x0000012b, -0x000300f7,0x00004da5,0x00000000,0x000400fa, -0x0000506e,0x00004d9a,0x00004da5,0x000200f8, -0x00004d9a,0x00050084,0x00000006,0x00004d9e, -0x00000309,0x000011de,0x00050080,0x00000006, -0x00004d9f,0x0000503c,0x00004d9e,0x00050080, -0x00000006,0x00004da0,0x00004d9f,0x0000074b, -0x00050095,0x00000130,0x00005086,0x0000505e, -0x00004da0,0x00050051,0x00000006,0x00005087, -0x00005086,0x00000001,0x00050051,0x00000006, -0x00005088,0x00005086,0x00000000,0x00050080, -0x00000006,0x0000508d,0x00005065,0x00005087, -0x00050050,0x00000007,0x0000508e,0x00005088, -0x0000508d,0x0004007c,0x00000014,0x0000507e, -0x0000508e,0x00060041,0x0000015f,0x00005076, -0x0000507e,0x0000015e,0x0000015e,0x0005003e, -0x00005076,0x00005050,0x00000002,0x00000004, -0x000200f9,0x00004da5,0x000200f8,0x00004da5, -0x000200f9,0x00004da6,0x000200f8,0x00004da6, -0x000700f5,0x00000063,0x0000592c,0x00004f4b, -0x00004da5,0x00005954,0x00004e11,0x000700f5, -0x00000063,0x00005929,0x00004f38,0x00004da5, -0x00005950,0x00004e11,0x000700f5,0x00000006, -0x00005925,0x0000012b,0x00004da5,0x00004e13, -0x00004e11,0x000700f5,0x00000006,0x00005923, -0x00005050,0x00004da5,0x00005672,0x00004e11, -0x000700f5,0x00000006,0x00005996,0x00005922, -0x00004da5,0x00005923,0x00004e11,0x000500ab, -0x0000002f,0x00004da9,0x00005923,0x00000500, -0x000500b0,0x0000002f,0x00004dab,0x00005925, -0x00000309,0x000500a7,0x0000002f,0x00004dac, -0x00004da9,0x00004dab,0x000400f6,0x00004e14, -0x00004e11,0x00000000,0x000400fa,0x00004dac, -0x00004dad,0x00004e14,0x000200f8,0x00004dad, -0x000500c2,0x00000006,0x00005092,0x00005923, -0x000002e4,0x00050084,0x00000006,0x00004db0, -0x00005092,0x0000018b,0x000200f9,0x00004db1, -0x000200f8,0x00004db1,0x000700f5,0x00000006, -0x00005942,0x0000012b,0x00004dad,0x00005bf6, -0x00004dcf,0x000700f5,0x00000006,0x00005926, -0x0000012b,0x00004dad,0x00004dd1,0x00004dcf, -0x000500b0,0x0000002f,0x00004db4,0x00005926, -0x000000df,0x000400f6,0x00004dd2,0x00004dcf, -0x00000000,0x000400fa,0x00004db4,0x00004db5, -0x00004dd2,0x000200f8,0x00004db5,0x00050084, -0x00000006,0x00004db8,0x000000df,0x00005926, -0x00050080,0x00000006,0x00004db9,0x00004db0, -0x00004db8,0x00050095,0x00000130,0x000050ab, -0x0000505e,0x00004db9,0x00050051,0x00000006, -0x000050ac,0x000050ab,0x00000001,0x00050051, -0x00000006,0x000050ad,0x000050ab,0x00000000, -0x00050080,0x00000006,0x000050b2,0x00005065, -0x000050ac,0x00050050,0x00000007,0x000050b3, -0x000050ad,0x000050b2,0x0004007c,0x00000014, -0x000050a3,0x000050b3,0x00060041,0x0000015f, -0x0000509a,0x000050a3,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x0000509b,0x0000509a, -0x00000002,0x00000004,0x000500aa,0x0000002f, -0x00004dbe,0x0000509b,0x00000500,0x000300f7, -0x00004dc0,0x00000000,0x000400fa,0x00004dbe, -0x00004dbf,0x00004dc0,0x000200f8,0x00004dbf, -0x000200f9,0x00004dcf,0x000200f8,0x00004dc0, -0x00050080,0x00000006,0x00004dc2,0x00005942, -0x0000022b,0x000500aa,0x0000002f,0x00004dc5, -0x0000509b,0x00005996,0x000300f7,0x00004dce, -0x00000000,0x000400fa,0x00004dc5,0x00004dc6, -0x00004dce,0x000200f8,0x00004dc6,0x000500c7, -0x00000006,0x000050b7,0x00005923,0x00000c2c, -0x000500aa,0x0000002f,0x000050b8,0x000050b7, -0x000000df,0x000300f7,0x0000510b,0x00000000, -0x000300fb,0x0000012b,0x000050d1,0x000200f8, -0x000050d1,0x000300f7,0x000050dc,0x00000000, -0x000400fa,0x000050b8,0x000050d3,0x000050dc, -0x000200f8,0x000050d3,0x00050080,0x00000006, -0x000050d5,0x00004db0,0x000001a2,0x00050084, -0x00000006,0x000050d7,0x0000019b,0x00005926, -0x00050080,0x00000006,0x000050d8,0x000050d5, -0x000050d7,0x00050051,0x00000027,0x00005123, -0x00005929,0x00000000,0x000300f7,0x0000519a, -0x00000000,0x000300fb,0x0000012b,0x00005154, -0x000200f8,0x00005154,0x0004007c,0x00000006, -0x00005156,0x00005123,0x000500c2,0x00000006, -0x00005158,0x00005156,0x00000321,0x000500c7, -0x00000006,0x00005159,0x00005158,0x0000033a, -0x000500c7,0x00000006,0x0000515b,0x00005156, -0x0000021d,0x000500ab,0x0000002f,0x0000515e, -0x00005159,0x0000012b,0x000500ac,0x0000002f, -0x00005161,0x0000515b,0x00000345,0x000300f7, -0x00005165,0x00000000,0x000400fa,0x00005161, -0x00005162,0x00005165,0x000200f8,0x00005162, -0x000500c5,0x00000006,0x00005164,0x00005159, -0x0000034a,0x000200f9,0x0000519a,0x000200f8, -0x00005165,0x000500aa,0x0000002f,0x00005167, -0x0000515b,0x0000012b,0x000300f7,0x0000516a, -0x00000000,0x000400fa,0x00005167,0x00005168, -0x0000516a,0x000200f8,0x00005168,0x000200f9, -0x0000519a,0x000200f8,0x0000516a,0x000500c2, -0x00000006,0x0000516c,0x0000515b,0x00000355, -0x0004007c,0x000000e7,0x0000516d,0x0000516c, -0x00050082,0x000000e7,0x0000516e,0x0000516d, -0x00000358,0x000500af,0x0000002f,0x00005170, -0x0000516e,0x00000321,0x000300f7,0x00005176, -0x00000000,0x000400fa,0x00005170,0x00005171, -0x00005176,0x000200f8,0x00005171,0x000600a9, -0x00000006,0x00005174,0x0000515e,0x00000360, -0x00000361,0x000500c5,0x00000006,0x00005175, -0x00005159,0x00005174,0x000200f9,0x0000519a, -0x000200f8,0x00005176,0x000500b1,0x0000002f, -0x00005178,0x0000516e,0x00000366,0x000300f7, -0x00005182,0x00000000,0x000400fa,0x00005178, -0x00005179,0x00005182,0x000200f8,0x00005179, -0x000300f7,0x00005180,0x00000000,0x000400fa, -0x0000515e,0x0000517b,0x0000517e,0x000200f8, -0x0000517e,0x000200f9,0x00005180,0x000200f8, -0x0000517b,0x000500c5,0x00000006,0x0000517d, -0x00005159,0x0000036f,0x000200f9,0x00005180, -0x000200f8,0x00005180,0x000700f5,0x00000006, -0x0000599a,0x0000517d,0x0000517b,0x00005159, -0x0000517e,0x000200f9,0x0000519a,0x000200f8, -0x00005182,0x000500c7,0x00000006,0x00005184, -0x00005156,0x00000377,0x00050080,0x000000e7, -0x00005186,0x0000516d,0x00005cc4,0x0004007c, -0x00000006,0x00005187,0x00005186,0x000500c4, -0x00000006,0x00005188,0x00005187,0x0000037d, -0x000500c2,0x00000006,0x0000518a,0x00005184, -0x000001b7,0x000500c5,0x00000006,0x0000518b, -0x00005188,0x0000518a,0x000300f7,0x00005191, -0x00000000,0x000400fa,0x0000515e,0x0000518d, -0x00005191,0x000200f8,0x0000518d,0x000500c7, -0x00000006,0x0000518f,0x00005156,0x00000386, -0x000500ab,0x0000002f,0x00005190,0x0000518f, -0x0000012b,0x000200f9,0x00005191,0x000200f8, -0x00005191,0x000700f5,0x0000002f,0x00005192, -0x0000515e,0x00005182,0x00005190,0x0000518d, -0x000300f7,0x00005196,0x00000000,0x000400fa, -0x00005192,0x00005193,0x00005196,0x000200f8, -0x00005193,0x00050080,0x00000006,0x00005195, -0x0000518b,0x00000135,0x000200f9,0x00005196, -0x000200f8,0x00005196,0x000700f5,0x00000006, -0x00005999,0x0000518b,0x00005191,0x00005195, -0x00005193,0x000500c5,0x00000006,0x00005199, -0x00005159,0x00005999,0x000200f9,0x0000519a, -0x000200f8,0x0000519a,0x000d00f5,0x00000006, -0x0000599b,0x00005164,0x00005162,0x00005159, -0x00005168,0x00005175,0x00005171,0x0000599a, -0x00005180,0x00005199,0x00005196,0x00050051, -0x00000027,0x00005126,0x00005929,0x00000001, -0x000300f7,0x000051ee,0x00000000,0x000300fb, -0x0000012b,0x000051a8,0x000200f8,0x000051a8, -0x0004007c,0x00000006,0x000051aa,0x00005126, -0x000500c2,0x00000006,0x000051ac,0x000051aa, -0x00000321,0x000500c7,0x00000006,0x000051ad, -0x000051ac,0x0000033a,0x000500c7,0x00000006, -0x000051af,0x000051aa,0x0000021d,0x000500ab, -0x0000002f,0x000051b2,0x000051ad,0x0000012b, -0x000500ac,0x0000002f,0x000051b5,0x000051af, -0x00000345,0x000300f7,0x000051b9,0x00000000, -0x000400fa,0x000051b5,0x000051b6,0x000051b9, -0x000200f8,0x000051b6,0x000500c5,0x00000006, -0x000051b8,0x000051ad,0x0000034a,0x000200f9, -0x000051ee,0x000200f8,0x000051b9,0x000500aa, -0x0000002f,0x000051bb,0x000051af,0x0000012b, -0x000300f7,0x000051be,0x00000000,0x000400fa, -0x000051bb,0x000051bc,0x000051be,0x000200f8, -0x000051bc,0x000200f9,0x000051ee,0x000200f8, -0x000051be,0x000500c2,0x00000006,0x000051c0, -0x000051af,0x00000355,0x0004007c,0x000000e7, -0x000051c1,0x000051c0,0x00050082,0x000000e7, -0x000051c2,0x000051c1,0x00000358,0x000500af, -0x0000002f,0x000051c4,0x000051c2,0x00000321, -0x000300f7,0x000051ca,0x00000000,0x000400fa, -0x000051c4,0x000051c5,0x000051ca,0x000200f8, -0x000051c5,0x000600a9,0x00000006,0x000051c8, -0x000051b2,0x00000360,0x00000361,0x000500c5, -0x00000006,0x000051c9,0x000051ad,0x000051c8, -0x000200f9,0x000051ee,0x000200f8,0x000051ca, -0x000500b1,0x0000002f,0x000051cc,0x000051c2, -0x00000366,0x000300f7,0x000051d6,0x00000000, -0x000400fa,0x000051cc,0x000051cd,0x000051d6, -0x000200f8,0x000051cd,0x000300f7,0x000051d4, -0x00000000,0x000400fa,0x000051b2,0x000051cf, -0x000051d2,0x000200f8,0x000051d2,0x000200f9, -0x000051d4,0x000200f8,0x000051cf,0x000500c5, -0x00000006,0x000051d1,0x000051ad,0x0000036f, -0x000200f9,0x000051d4,0x000200f8,0x000051d4, -0x000700f5,0x00000006,0x0000599e,0x000051d1, -0x000051cf,0x000051ad,0x000051d2,0x000200f9, -0x000051ee,0x000200f8,0x000051d6,0x000500c7, -0x00000006,0x000051d8,0x000051aa,0x00000377, -0x00050080,0x000000e7,0x000051da,0x000051c1, -0x00005cc4,0x0004007c,0x00000006,0x000051db, -0x000051da,0x000500c4,0x00000006,0x000051dc, -0x000051db,0x0000037d,0x000500c2,0x00000006, -0x000051de,0x000051d8,0x000001b7,0x000500c5, -0x00000006,0x000051df,0x000051dc,0x000051de, -0x000300f7,0x000051e5,0x00000000,0x000400fa, -0x000051b2,0x000051e1,0x000051e5,0x000200f8, -0x000051e1,0x000500c7,0x00000006,0x000051e3, -0x000051aa,0x00000386,0x000500ab,0x0000002f, -0x000051e4,0x000051e3,0x0000012b,0x000200f9, -0x000051e5,0x000200f8,0x000051e5,0x000700f5, -0x0000002f,0x000051e6,0x000051b2,0x000051d6, -0x000051e4,0x000051e1,0x000300f7,0x000051ea, -0x00000000,0x000400fa,0x000051e6,0x000051e7, -0x000051ea,0x000200f8,0x000051e7,0x00050080, -0x00000006,0x000051e9,0x000051df,0x00000135, -0x000200f9,0x000051ea,0x000200f8,0x000051ea, -0x000700f5,0x00000006,0x0000599d,0x000051df, -0x000051e5,0x000051e9,0x000051e7,0x000500c5, -0x00000006,0x000051ed,0x000051ad,0x0000599d, -0x000200f9,0x000051ee,0x000200f8,0x000051ee, -0x000d00f5,0x00000006,0x0000599f,0x000051b8, -0x000051b6,0x000051ad,0x000051bc,0x000051c9, -0x000051c5,0x0000599e,0x000051d4,0x000051ed, -0x000051ea,0x000500c4,0x00000006,0x00005128, -0x0000599f,0x00000321,0x000500c5,0x00000006, -0x00005129,0x0000599b,0x00005128,0x00050095, -0x00000130,0x00005207,0x0000505e,0x000050d8, -0x00050051,0x00000006,0x00005208,0x00005207, -0x00000001,0x00050051,0x00000006,0x00005209, -0x00005207,0x00000000,0x00050080,0x00000006, -0x0000520e,0x00005065,0x00005208,0x00050050, -0x00000007,0x0000520f,0x00005209,0x0000520e, -0x0004007c,0x00000014,0x000051ff,0x0000520f, -0x00060041,0x0000015f,0x000051f7,0x000051ff, -0x0000015e,0x0000015e,0x0005003e,0x000051f7, -0x00005129,0x00000002,0x00000004,0x00050080, -0x00000006,0x0000512f,0x000050d8,0x000000df, -0x00050051,0x00000027,0x00005131,0x00005929, -0x00000002,0x000300f7,0x00005262,0x00000000, -0x000300fb,0x0000012b,0x0000521c,0x000200f8, -0x0000521c,0x0004007c,0x00000006,0x0000521e, -0x00005131,0x000500c2,0x00000006,0x00005220, -0x0000521e,0x00000321,0x000500c7,0x00000006, -0x00005221,0x00005220,0x0000033a,0x000500c7, -0x00000006,0x00005223,0x0000521e,0x0000021d, -0x000500ab,0x0000002f,0x00005226,0x00005221, -0x0000012b,0x000500ac,0x0000002f,0x00005229, -0x00005223,0x00000345,0x000300f7,0x0000522d, -0x00000000,0x000400fa,0x00005229,0x0000522a, -0x0000522d,0x000200f8,0x0000522a,0x000500c5, -0x00000006,0x0000522c,0x00005221,0x0000034a, -0x000200f9,0x00005262,0x000200f8,0x0000522d, -0x000500aa,0x0000002f,0x0000522f,0x00005223, -0x0000012b,0x000300f7,0x00005232,0x00000000, -0x000400fa,0x0000522f,0x00005230,0x00005232, -0x000200f8,0x00005230,0x000200f9,0x00005262, -0x000200f8,0x00005232,0x000500c2,0x00000006, -0x00005234,0x00005223,0x00000355,0x0004007c, -0x000000e7,0x00005235,0x00005234,0x00050082, -0x000000e7,0x00005236,0x00005235,0x00000358, -0x000500af,0x0000002f,0x00005238,0x00005236, -0x00000321,0x000300f7,0x0000523e,0x00000000, -0x000400fa,0x00005238,0x00005239,0x0000523e, -0x000200f8,0x00005239,0x000600a9,0x00000006, -0x0000523c,0x00005226,0x00000360,0x00000361, -0x000500c5,0x00000006,0x0000523d,0x00005221, -0x0000523c,0x000200f9,0x00005262,0x000200f8, -0x0000523e,0x000500b1,0x0000002f,0x00005240, -0x00005236,0x00000366,0x000300f7,0x0000524a, -0x00000000,0x000400fa,0x00005240,0x00005241, -0x0000524a,0x000200f8,0x00005241,0x000300f7, -0x00005248,0x00000000,0x000400fa,0x00005226, -0x00005243,0x00005246,0x000200f8,0x00005246, -0x000200f9,0x00005248,0x000200f8,0x00005243, -0x000500c5,0x00000006,0x00005245,0x00005221, -0x0000036f,0x000200f9,0x00005248,0x000200f8, -0x00005248,0x000700f5,0x00000006,0x000059a2, -0x00005245,0x00005243,0x00005221,0x00005246, -0x000200f9,0x00005262,0x000200f8,0x0000524a, -0x000500c7,0x00000006,0x0000524c,0x0000521e, -0x00000377,0x00050080,0x000000e7,0x0000524e, -0x00005235,0x00005cc4,0x0004007c,0x00000006, -0x0000524f,0x0000524e,0x000500c4,0x00000006, -0x00005250,0x0000524f,0x0000037d,0x000500c2, -0x00000006,0x00005252,0x0000524c,0x000001b7, -0x000500c5,0x00000006,0x00005253,0x00005250, -0x00005252,0x000300f7,0x00005259,0x00000000, -0x000400fa,0x00005226,0x00005255,0x00005259, -0x000200f8,0x00005255,0x000500c7,0x00000006, -0x00005257,0x0000521e,0x00000386,0x000500ab, -0x0000002f,0x00005258,0x00005257,0x0000012b, -0x000200f9,0x00005259,0x000200f8,0x00005259, -0x000700f5,0x0000002f,0x0000525a,0x00005226, -0x0000524a,0x00005258,0x00005255,0x000300f7, -0x0000525e,0x00000000,0x000400fa,0x0000525a, -0x0000525b,0x0000525e,0x000200f8,0x0000525b, -0x00050080,0x00000006,0x0000525d,0x00005253, -0x00000135,0x000200f9,0x0000525e,0x000200f8, -0x0000525e,0x000700f5,0x00000006,0x000059a1, -0x00005253,0x00005259,0x0000525d,0x0000525b, -0x000500c5,0x00000006,0x00005261,0x00005221, -0x000059a1,0x000200f9,0x00005262,0x000200f8, -0x00005262,0x000d00f5,0x00000006,0x000059a3, -0x0000522c,0x0000522a,0x00005221,0x00005230, -0x0000523d,0x00005239,0x000059a2,0x00005248, -0x00005261,0x0000525e,0x00050051,0x00000027, -0x00005134,0x0000592c,0x00000000,0x000300f7, -0x000052b6,0x00000000,0x000300fb,0x0000012b, -0x00005270,0x000200f8,0x00005270,0x0004007c, -0x00000006,0x00005272,0x00005134,0x000500c2, -0x00000006,0x00005274,0x00005272,0x00000321, -0x000500c7,0x00000006,0x00005275,0x00005274, -0x0000033a,0x000500c7,0x00000006,0x00005277, -0x00005272,0x0000021d,0x000500aa,0x0000002f, -0x0000527b,0x00005275,0x0000012b,0x000500ac, -0x0000002f,0x0000527d,0x00005277,0x00000345, -0x000300f7,0x00005281,0x00000000,0x000400fa, -0x0000527d,0x0000527e,0x00005281,0x000200f8, -0x0000527e,0x000500c5,0x00000006,0x00005280, -0x00005275,0x0000034a,0x000200f9,0x000052b6, -0x000200f8,0x00005281,0x000500aa,0x0000002f, -0x00005283,0x00005277,0x0000012b,0x000300f7, -0x00005286,0x00000000,0x000400fa,0x00005283, -0x00005284,0x00005286,0x000200f8,0x00005284, -0x000200f9,0x000052b6,0x000200f8,0x00005286, -0x000500c2,0x00000006,0x00005288,0x00005277, -0x00000355,0x0004007c,0x000000e7,0x00005289, -0x00005288,0x00050082,0x000000e7,0x0000528a, -0x00005289,0x00000358,0x000500af,0x0000002f, -0x0000528c,0x0000528a,0x00000321,0x000300f7, -0x00005292,0x00000000,0x000400fa,0x0000528c, -0x0000528d,0x00005292,0x000200f8,0x0000528d, -0x000600a9,0x00000006,0x00005290,0x0000527b, -0x00000360,0x00000361,0x000500c5,0x00000006, -0x00005291,0x00005275,0x00005290,0x000200f9, -0x000052b6,0x000200f8,0x00005292,0x000500b1, -0x0000002f,0x00005294,0x0000528a,0x00000366, -0x000300f7,0x0000529e,0x00000000,0x000400fa, -0x00005294,0x00005295,0x0000529e,0x000200f8, -0x00005295,0x000300f7,0x0000529c,0x00000000, -0x000400fa,0x0000527b,0x00005297,0x0000529a, -0x000200f8,0x0000529a,0x000200f9,0x0000529c, -0x000200f8,0x00005297,0x000500c5,0x00000006, -0x00005299,0x00005275,0x0000036f,0x000200f9, -0x0000529c,0x000200f8,0x0000529c,0x000700f5, -0x00000006,0x000059a6,0x00005299,0x00005297, -0x00005275,0x0000529a,0x000200f9,0x000052b6, -0x000200f8,0x0000529e,0x000500c7,0x00000006, -0x000052a0,0x00005272,0x00000377,0x00050080, -0x000000e7,0x000052a2,0x00005289,0x00005cc4, -0x0004007c,0x00000006,0x000052a3,0x000052a2, -0x000500c4,0x00000006,0x000052a4,0x000052a3, -0x0000037d,0x000500c2,0x00000006,0x000052a6, -0x000052a0,0x000001b7,0x000500c5,0x00000006, -0x000052a7,0x000052a4,0x000052a6,0x000300f7, -0x000052ad,0x00000000,0x000400fa,0x0000527b, -0x000052a9,0x000052ad,0x000200f8,0x000052a9, -0x000500c7,0x00000006,0x000052ab,0x00005272, -0x00000386,0x000500ab,0x0000002f,0x000052ac, -0x000052ab,0x0000012b,0x000200f9,0x000052ad, -0x000200f8,0x000052ad,0x000700f5,0x0000002f, -0x000052ae,0x0000527b,0x0000529e,0x000052ac, -0x000052a9,0x000300f7,0x000052b2,0x00000000, -0x000400fa,0x000052ae,0x000052af,0x000052b2, -0x000200f8,0x000052af,0x00050080,0x00000006, -0x000052b1,0x000052a7,0x00000135,0x000200f9, -0x000052b2,0x000200f8,0x000052b2,0x000700f5, -0x00000006,0x000059a5,0x000052a7,0x000052ad, -0x000052b1,0x000052af,0x000500c5,0x00000006, -0x000052b5,0x00005275,0x000059a5,0x000200f9, -0x000052b6,0x000200f8,0x000052b6,0x000d00f5, -0x00000006,0x000059a7,0x00005280,0x0000527e, -0x00005275,0x00005284,0x00005291,0x0000528d, -0x000059a6,0x0000529c,0x000052b5,0x000052b2, -0x000500c4,0x00000006,0x00005136,0x000059a7, -0x00000321,0x000500c5,0x00000006,0x00005137, -0x000059a3,0x00005136,0x00050095,0x00000130, -0x000052cf,0x0000505e,0x0000512f,0x00050051, -0x00000006,0x000052d0,0x000052cf,0x00000001, -0x00050051,0x00000006,0x000052d1,0x000052cf, -0x00000000,0x00050080,0x00000006,0x000052d6, -0x00005065,0x000052d0,0x00050050,0x00000007, -0x000052d7,0x000052d1,0x000052d6,0x0004007c, -0x00000014,0x000052c7,0x000052d7,0x00060041, -0x0000015f,0x000052bf,0x000052c7,0x0000015e, -0x0000015e,0x0005003e,0x000052bf,0x00005137, -0x00000002,0x00000004,0x00050080,0x00000006, -0x0000513c,0x000050d8,0x00000194,0x00050051, -0x00000027,0x0000513e,0x0000592c,0x00000001, -0x000300f7,0x0000532a,0x00000000,0x000300fb, -0x0000012b,0x000052e4,0x000200f8,0x000052e4, -0x0004007c,0x00000006,0x000052e6,0x0000513e, -0x000500c2,0x00000006,0x000052e8,0x000052e6, -0x00000321,0x000500c7,0x00000006,0x000052e9, -0x000052e8,0x0000033a,0x000500c7,0x00000006, -0x000052eb,0x000052e6,0x0000021d,0x000500aa, -0x0000002f,0x000052ef,0x000052e9,0x0000012b, -0x000500ac,0x0000002f,0x000052f1,0x000052eb, -0x00000345,0x000300f7,0x000052f5,0x00000000, -0x000400fa,0x000052f1,0x000052f2,0x000052f5, -0x000200f8,0x000052f2,0x000500c5,0x00000006, -0x000052f4,0x000052e9,0x0000034a,0x000200f9, -0x0000532a,0x000200f8,0x000052f5,0x000500aa, -0x0000002f,0x000052f7,0x000052eb,0x0000012b, -0x000300f7,0x000052fa,0x00000000,0x000400fa, -0x000052f7,0x000052f8,0x000052fa,0x000200f8, -0x000052f8,0x000200f9,0x0000532a,0x000200f8, -0x000052fa,0x000500c2,0x00000006,0x000052fc, -0x000052eb,0x00000355,0x0004007c,0x000000e7, -0x000052fd,0x000052fc,0x00050082,0x000000e7, -0x000052fe,0x000052fd,0x00000358,0x000500af, -0x0000002f,0x00005300,0x000052fe,0x00000321, -0x000300f7,0x00005306,0x00000000,0x000400fa, -0x00005300,0x00005301,0x00005306,0x000200f8, -0x00005301,0x000600a9,0x00000006,0x00005304, -0x000052ef,0x00000360,0x00000361,0x000500c5, -0x00000006,0x00005305,0x000052e9,0x00005304, -0x000200f9,0x0000532a,0x000200f8,0x00005306, -0x000500b1,0x0000002f,0x00005308,0x000052fe, -0x00000366,0x000300f7,0x00005312,0x00000000, -0x000400fa,0x00005308,0x00005309,0x00005312, -0x000200f8,0x00005309,0x000300f7,0x00005310, -0x00000000,0x000400fa,0x000052ef,0x0000530b, -0x0000530e,0x000200f8,0x0000530e,0x000200f9, -0x00005310,0x000200f8,0x0000530b,0x000500c5, -0x00000006,0x0000530d,0x000052e9,0x0000036f, -0x000200f9,0x00005310,0x000200f8,0x00005310, -0x000700f5,0x00000006,0x000059aa,0x0000530d, -0x0000530b,0x000052e9,0x0000530e,0x000200f9, -0x0000532a,0x000200f8,0x00005312,0x000500c7, -0x00000006,0x00005314,0x000052e6,0x00000377, -0x00050080,0x000000e7,0x00005316,0x000052fd, -0x00005cc4,0x0004007c,0x00000006,0x00005317, -0x00005316,0x000500c4,0x00000006,0x00005318, -0x00005317,0x0000037d,0x000500c2,0x00000006, -0x0000531a,0x00005314,0x000001b7,0x000500c5, -0x00000006,0x0000531b,0x00005318,0x0000531a, -0x000300f7,0x00005321,0x00000000,0x000400fa, -0x000052ef,0x0000531d,0x00005321,0x000200f8, -0x0000531d,0x000500c7,0x00000006,0x0000531f, -0x000052e6,0x00000386,0x000500ab,0x0000002f, -0x00005320,0x0000531f,0x0000012b,0x000200f9, -0x00005321,0x000200f8,0x00005321,0x000700f5, -0x0000002f,0x00005322,0x000052ef,0x00005312, -0x00005320,0x0000531d,0x000300f7,0x00005326, -0x00000000,0x000400fa,0x00005322,0x00005323, -0x00005326,0x000200f8,0x00005323,0x00050080, -0x00000006,0x00005325,0x0000531b,0x00000135, -0x000200f9,0x00005326,0x000200f8,0x00005326, -0x000700f5,0x00000006,0x000059a9,0x0000531b, -0x00005321,0x00005325,0x00005323,0x000500c5, -0x00000006,0x00005329,0x000052e9,0x000059a9, -0x000200f9,0x0000532a,0x000200f8,0x0000532a, -0x000d00f5,0x00000006,0x000059ab,0x000052f4, -0x000052f2,0x000052e9,0x000052f8,0x00005305, -0x00005301,0x000059aa,0x00005310,0x00005329, -0x00005326,0x00050051,0x00000027,0x00005141, -0x0000592c,0x00000002,0x000300f7,0x0000537e, -0x00000000,0x000300fb,0x0000012b,0x00005338, -0x000200f8,0x00005338,0x0004007c,0x00000006, -0x0000533a,0x00005141,0x000500c2,0x00000006, -0x0000533c,0x0000533a,0x00000321,0x000500c7, -0x00000006,0x0000533d,0x0000533c,0x0000033a, -0x000500c7,0x00000006,0x0000533f,0x0000533a, -0x0000021d,0x000500aa,0x0000002f,0x00005343, -0x0000533d,0x0000012b,0x000500ac,0x0000002f, -0x00005345,0x0000533f,0x00000345,0x000300f7, -0x00005349,0x00000000,0x000400fa,0x00005345, -0x00005346,0x00005349,0x000200f8,0x00005346, -0x000500c5,0x00000006,0x00005348,0x0000533d, -0x0000034a,0x000200f9,0x0000537e,0x000200f8, -0x00005349,0x000500aa,0x0000002f,0x0000534b, -0x0000533f,0x0000012b,0x000300f7,0x0000534e, -0x00000000,0x000400fa,0x0000534b,0x0000534c, -0x0000534e,0x000200f8,0x0000534c,0x000200f9, -0x0000537e,0x000200f8,0x0000534e,0x000500c2, -0x00000006,0x00005350,0x0000533f,0x00000355, -0x0004007c,0x000000e7,0x00005351,0x00005350, -0x00050082,0x000000e7,0x00005352,0x00005351, -0x00000358,0x000500af,0x0000002f,0x00005354, -0x00005352,0x00000321,0x000300f7,0x0000535a, -0x00000000,0x000400fa,0x00005354,0x00005355, -0x0000535a,0x000200f8,0x00005355,0x000600a9, -0x00000006,0x00005358,0x00005343,0x00000360, -0x00000361,0x000500c5,0x00000006,0x00005359, -0x0000533d,0x00005358,0x000200f9,0x0000537e, -0x000200f8,0x0000535a,0x000500b1,0x0000002f, -0x0000535c,0x00005352,0x00000366,0x000300f7, -0x00005366,0x00000000,0x000400fa,0x0000535c, -0x0000535d,0x00005366,0x000200f8,0x0000535d, -0x000300f7,0x00005364,0x00000000,0x000400fa, -0x00005343,0x0000535f,0x00005362,0x000200f8, -0x00005362,0x000200f9,0x00005364,0x000200f8, -0x0000535f,0x000500c5,0x00000006,0x00005361, -0x0000533d,0x0000036f,0x000200f9,0x00005364, -0x000200f8,0x00005364,0x000700f5,0x00000006, -0x000059ae,0x00005361,0x0000535f,0x0000533d, -0x00005362,0x000200f9,0x0000537e,0x000200f8, -0x00005366,0x000500c7,0x00000006,0x00005368, -0x0000533a,0x00000377,0x00050080,0x000000e7, -0x0000536a,0x00005351,0x00005cc4,0x0004007c, -0x00000006,0x0000536b,0x0000536a,0x000500c4, -0x00000006,0x0000536c,0x0000536b,0x0000037d, -0x000500c2,0x00000006,0x0000536e,0x00005368, -0x000001b7,0x000500c5,0x00000006,0x0000536f, -0x0000536c,0x0000536e,0x000300f7,0x00005375, -0x00000000,0x000400fa,0x00005343,0x00005371, -0x00005375,0x000200f8,0x00005371,0x000500c7, -0x00000006,0x00005373,0x0000533a,0x00000386, -0x000500ab,0x0000002f,0x00005374,0x00005373, -0x0000012b,0x000200f9,0x00005375,0x000200f8, -0x00005375,0x000700f5,0x0000002f,0x00005376, -0x00005343,0x00005366,0x00005374,0x00005371, -0x000300f7,0x0000537a,0x00000000,0x000400fa, -0x00005376,0x00005377,0x0000537a,0x000200f8, -0x00005377,0x00050080,0x00000006,0x00005379, -0x0000536f,0x00000135,0x000200f9,0x0000537a, -0x000200f8,0x0000537a,0x000700f5,0x00000006, -0x000059ad,0x0000536f,0x00005375,0x00005379, -0x00005377,0x000500c5,0x00000006,0x0000537d, -0x0000533d,0x000059ad,0x000200f9,0x0000537e, -0x000200f8,0x0000537e,0x000d00f5,0x00000006, -0x000059af,0x00005348,0x00005346,0x0000533d, -0x0000534c,0x00005359,0x00005355,0x000059ae, -0x00005364,0x0000537d,0x0000537a,0x000500c4, -0x00000006,0x00005143,0x000059af,0x00000321, -0x000500c5,0x00000006,0x00005144,0x000059ab, -0x00005143,0x00050095,0x00000130,0x00005397, -0x0000505e,0x0000513c,0x00050051,0x00000006, -0x00005398,0x00005397,0x00000001,0x00050051, -0x00000006,0x00005399,0x00005397,0x00000000, -0x00050080,0x00000006,0x0000539e,0x00005065, -0x00005398,0x00050050,0x00000007,0x0000539f, -0x00005399,0x0000539e,0x0004007c,0x00000014, -0x0000538f,0x0000539f,0x00060041,0x0000015f, -0x00005387,0x0000538f,0x0000015e,0x0000015e, -0x0005003e,0x00005387,0x00005144,0x00000002, -0x00000004,0x000200f9,0x0000510b,0x000200f8, -0x000050dc,0x00050080,0x00000006,0x000050de, -0x00004db0,0x000001a2,0x00050084,0x00000006, -0x000050e0,0x000001b6,0x00005926,0x00050080, -0x00000006,0x000050e1,0x000050de,0x000050e0, -0x00050051,0x00000027,0x000050e6,0x00005929, -0x00000000,0x0004007c,0x00000006,0x000053a5, -0x000050e6,0x00050095,0x00000130,0x000053c0, -0x0000505e,0x000050e1,0x00050051,0x00000006, -0x000053c1,0x000053c0,0x00000001,0x00050051, -0x00000006,0x000053c2,0x000053c0,0x00000000, -0x00050080,0x00000006,0x000053c7,0x00005065, -0x000053c1,0x00050050,0x00000007,0x000053c8, -0x000053c2,0x000053c7,0x0004007c,0x00000014, -0x000053b8,0x000053c8,0x00060041,0x0000015f, -0x000053b0,0x000053b8,0x0000015e,0x0000015e, -0x0005003e,0x000053b0,0x000053a5,0x00000002, -0x00000004,0x00050080,0x00000006,0x000050e9, -0x000050e1,0x000000df,0x00050051,0x00000027, -0x000050ed,0x00005929,0x00000001,0x0004007c, -0x00000006,0x000053ce,0x000050ed,0x00050095, -0x00000130,0x000053e9,0x0000505e,0x000050e9, -0x00050051,0x00000006,0x000053ea,0x000053e9, -0x00000001,0x00050051,0x00000006,0x000053eb, -0x000053e9,0x00000000,0x00050080,0x00000006, -0x000053f0,0x00005065,0x000053ea,0x00050050, -0x00000007,0x000053f1,0x000053eb,0x000053f0, -0x0004007c,0x00000014,0x000053e1,0x000053f1, -0x00060041,0x0000015f,0x000053d9,0x000053e1, -0x0000015e,0x0000015e,0x0005003e,0x000053d9, -0x000053ce,0x00000002,0x00000004,0x00050080, -0x00000006,0x000050f0,0x000050e1,0x00000194, -0x00050051,0x00000027,0x000050f4,0x00005929, -0x00000002,0x0004007c,0x00000006,0x000053f7, -0x000050f4,0x00050095,0x00000130,0x00005412, -0x0000505e,0x000050f0,0x00050051,0x00000006, +0x000020c9,0x00005f40,0x00000000,0x0004007c, +0x00000006,0x0000228c,0x000020c9,0x00050095, +0x0000013d,0x000022a7,0x0000222a,0x000006d9, +0x00050051,0x00000006,0x000022a8,0x000022a7, +0x00000001,0x00050051,0x00000006,0x000022a9, +0x000022a7,0x00000000,0x00050080,0x00000006, +0x000022ae,0x00002231,0x000022a8,0x00050050, +0x00000007,0x000022af,0x000022a9,0x000022ae, +0x0004007c,0x00000014,0x0000229f,0x000022af, +0x00060041,0x0000016c,0x00002297,0x0000229f, +0x0000016b,0x0000016b,0x0005003e,0x00002297, +0x0000228c,0x00000002,0x00000004,0x00050051, +0x00000027,0x000020ce,0x00005f40,0x00000001, +0x0004007c,0x00000006,0x000022b5,0x000020ce, +0x00050095,0x0000013d,0x000022d0,0x0000222a, +0x00000205,0x00050051,0x00000006,0x000022d1, +0x000022d0,0x00000001,0x00050051,0x00000006, +0x000022d2,0x000022d0,0x00000000,0x00050080, +0x00000006,0x000022d7,0x00002231,0x000022d1, +0x00050050,0x00000007,0x000022d8,0x000022d2, +0x000022d7,0x0004007c,0x00000014,0x000022c8, +0x000022d8,0x00060041,0x0000016c,0x000022c0, +0x000022c8,0x0000016b,0x0000016b,0x0005003e, +0x000022c0,0x000022b5,0x00000002,0x00000004, +0x00050051,0x00000027,0x000020d3,0x00005f40, +0x00000002,0x0004007c,0x00000006,0x000022de, +0x000020d3,0x00050095,0x0000013d,0x000022f9, +0x0000222a,0x00000500,0x00050051,0x00000006, +0x000022fa,0x000022f9,0x00000001,0x00050051, +0x00000006,0x000022fb,0x000022f9,0x00000000, +0x00050080,0x00000006,0x00002300,0x00002231, +0x000022fa,0x00050050,0x00000007,0x00002301, +0x000022fb,0x00002300,0x0004007c,0x00000014, +0x000022f1,0x00002301,0x00060041,0x0000016c, +0x000022e9,0x000022f1,0x0000016b,0x0000016b, +0x0005003e,0x000022e9,0x000022de,0x00000002, +0x00000004,0x00050041,0x000001bb,0x000020d5, +0x000001b9,0x00000434,0x0004003d,0x00000006, +0x000020d6,0x000020d5,0x000500aa,0x0000002f, +0x000020d7,0x000020d6,0x00000142,0x000300f7, +0x000020d9,0x00000000,0x000400fa,0x000020d7, +0x000020d8,0x000020d9,0x000200f8,0x000020d8, +0x000200f9,0x0000212c,0x000200f8,0x000020d9, +0x000500b2,0x0000002f,0x000020dc,0x00002177, +0x00000142,0x000300f7,0x000020e2,0x00000000, +0x000400fa,0x000020dc,0x000020dd,0x000020de, +0x000200f8,0x000020de,0x00050095,0x0000013d, +0x0000231a,0x000021a7,0x000001ef,0x00050051, +0x00000006,0x0000231b,0x0000231a,0x00000001, +0x00050051,0x00000006,0x0000231c,0x0000231a, +0x00000000,0x00050080,0x00000006,0x00002321, +0x000021ae,0x0000231b,0x00050050,0x00000007, +0x00002322,0x0000231c,0x00002321,0x0004007c, +0x00000014,0x00002312,0x00002322,0x00060041, +0x0000016c,0x00002309,0x00002312,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000230a, +0x00002309,0x00000002,0x00000004,0x000200f9, +0x000020e2,0x000200f8,0x000020dd,0x000200f9, +0x000020e2,0x000200f8,0x000020e2,0x000700f5, +0x00000006,0x00005f41,0x00000142,0x000020dd, +0x0000230a,0x000020de,0x00050041,0x000001bb, +0x000020e4,0x000001b9,0x0000035a,0x0004003d, +0x00000006,0x000020e5,0x000020e4,0x00050041, +0x000001bb,0x00002329,0x000001b9,0x00000334, +0x0004003d,0x00000006,0x0000232a,0x00002329, +0x000500c7,0x00000006,0x0000232b,0x0000232a, +0x00000280,0x000500ab,0x0000002f,0x0000232c, +0x0000232b,0x00000138,0x000600a9,0x00000006, +0x00002326,0x0000232c,0x000001c4,0x00000342, +0x00050084,0x00000006,0x000020e8,0x00002326, +0x00005f41,0x00050080,0x00000006,0x000020e9, +0x000020e5,0x000020e8,0x000300f7,0x000020fe, +0x00000000,0x000400fa,0x0000232c,0x000020eb, +0x000020fe,0x000200f8,0x000020eb,0x000200f9, +0x000020ec,0x000200f8,0x000020ec,0x000700f5, +0x00000006,0x00005f42,0x00000138,0x000020eb, +0x000020fa,0x000020f0,0x000500b0,0x0000002f, +0x000020ef,0x00005f42,0x000001db,0x000400f6, +0x000020fb,0x000020f0,0x00000000,0x000400fa, +0x000020ef,0x000020f0,0x000020fb,0x000200f8, +0x000020f0,0x00050084,0x00000006,0x000020f3, +0x000000ec,0x00005f42,0x00050080,0x00000006, +0x000020f4,0x000020e9,0x000020f3,0x00050095, +0x0000013d,0x0000234a,0x0000222a,0x000020f4, +0x00050051,0x00000006,0x0000234b,0x0000234a, +0x00000001,0x00050051,0x00000006,0x0000234c, +0x0000234a,0x00000000,0x00050080,0x00000006, +0x00002351,0x00002231,0x0000234b,0x00050050, +0x00000007,0x00002352,0x0000234c,0x00002351, +0x0004007c,0x00000014,0x00002342,0x00002352, +0x00060041,0x0000016c,0x0000233a,0x00002342, +0x0000016b,0x0000016b,0x0005003e,0x0000233a, +0x00000138,0x00000002,0x00000004,0x00050080, +0x00000006,0x000020fa,0x00005f42,0x00000264, +0x000200f9,0x000020ec,0x000200f8,0x000020fb, +0x00050080,0x00000006,0x000020fd,0x000020e9, +0x000001c4,0x000200f9,0x000020fe,0x000200f8, +0x000020fe,0x000700f5,0x00000006,0x00005f44, +0x000020e9,0x000020e2,0x000020fd,0x000020fb, +0x000500c7,0x00000006,0x00002357,0x0000232a, +0x00000142,0x000500ab,0x0000002f,0x00002358, +0x00002357,0x00000138,0x000600a9,0x00000006, +0x00002101,0x00002358,0x00000355,0x0000610e, +0x00050095,0x0000013d,0x00002370,0x0000222a, +0x00000138,0x00050051,0x00000006,0x00002371, +0x00002370,0x00000001,0x00050051,0x00000006, +0x00002372,0x00002370,0x00000000,0x00050080, +0x00000006,0x00002377,0x00002231,0x00002371, +0x00050050,0x00000007,0x00002378,0x00002372, +0x00002377,0x0004007c,0x00000014,0x00002368, +0x00002378,0x00060041,0x0000016c,0x00002360, +0x00002368,0x0000016b,0x0000016b,0x0005003e, +0x00002360,0x00002101,0x00000002,0x00000004, +0x00050086,0x00000006,0x00002106,0x00005f44, +0x000001c4,0x00050082,0x00000006,0x00002107, +0x00002106,0x00000142,0x00050095,0x0000013d, +0x00002390,0x0000222a,0x000000ec,0x00050051, +0x00000006,0x00002391,0x00002390,0x00000001, +0x00050051,0x00000006,0x00002392,0x00002390, +0x00000000,0x00050080,0x00000006,0x00002397, +0x00002231,0x00002391,0x00050050,0x00000007, +0x00002398,0x00002392,0x00002397,0x0004007c, +0x00000014,0x00002388,0x00002398,0x00060041, +0x0000016c,0x00002380,0x00002388,0x0000016b, +0x0000016b,0x0005003e,0x00002380,0x00002107, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x000023b0,0x0000222a,0x000001cd,0x00050051, +0x00000006,0x000023b1,0x000023b0,0x00000001, +0x00050051,0x00000006,0x000023b2,0x000023b0, +0x00000000,0x00050080,0x00000006,0x000023b7, +0x00002231,0x000023b1,0x00050050,0x00000007, +0x000023b8,0x000023b2,0x000023b7,0x0004007c, +0x00000014,0x000023a8,0x000023b8,0x00060041, +0x0000016c,0x000023a0,0x000023a8,0x0000016b, +0x0000016b,0x0005003e,0x000023a0,0x00000138, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x000023d0,0x0000222a,0x000001d4,0x00050051, +0x00000006,0x000023d1,0x000023d0,0x00000001, +0x00050051,0x00000006,0x000023d2,0x000023d0, +0x00000000,0x00050080,0x00000006,0x000023d7, +0x00002231,0x000023d1,0x00050050,0x00000007, +0x000023d8,0x000023d2,0x000023d7,0x0004007c, +0x00000014,0x000023c8,0x000023d8,0x00060041, +0x0000016c,0x000023c0,0x000023c8,0x0000016b, +0x0000016b,0x0005003e,0x000023c0,0x00002177, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x000023f0,0x0000222a,0x0000050b,0x00050051, +0x00000006,0x000023f1,0x000023f0,0x00000001, +0x00050051,0x00000006,0x000023f2,0x000023f0, +0x00000000,0x00050080,0x00000006,0x000023f7, +0x00002231,0x000023f1,0x00050050,0x00000007, +0x000023f8,0x000023f2,0x000023f7,0x0004007c, +0x00000014,0x000023e8,0x000023f8,0x00060041, +0x0000016c,0x000023e0,0x000023e8,0x0000016b, +0x0000016b,0x0005003e,0x000023e0,0x000020e5, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x00002410,0x0000222a,0x00000516,0x00050051, +0x00000006,0x00002411,0x00002410,0x00000001, +0x00050051,0x00000006,0x00002412,0x00002410, +0x00000000,0x00050080,0x00000006,0x00002417, +0x00002231,0x00002411,0x00050050,0x00000007, +0x00002418,0x00002412,0x00002417,0x0004007c, +0x00000014,0x00002408,0x00002418,0x00060041, +0x0000016c,0x00002400,0x00002408,0x0000016b, +0x0000016b,0x0005003e,0x00002400,0x00000138, +0x00000002,0x00000004,0x000500c2,0x00000006, +0x00002421,0x000020e5,0x00000351,0x000500c4, +0x00000006,0x00002422,0x00002421,0x0000031d, +0x000600a9,0x00000006,0x00002424,0x0000232c, +0x000000ec,0x00000364,0x000500c5,0x00000006, +0x00002425,0x00002422,0x00002424,0x00050095, +0x0000013d,0x0000244d,0x0000222a,0x00000521, +0x00050051,0x00000006,0x0000244e,0x0000244d, +0x00000001,0x00050051,0x00000006,0x0000244f, +0x0000244d,0x00000000,0x00050080,0x00000006, +0x00002454,0x00002231,0x0000244e,0x00050050, +0x00000007,0x00002455,0x0000244f,0x00002454, +0x0004007c,0x00000014,0x00002445,0x00002455, +0x00060041,0x0000016c,0x0000243d,0x00002445, +0x0000016b,0x0000016b,0x0005003e,0x0000243d, +0x00002425,0x00000002,0x00000004,0x00050041, +0x000001bb,0x00002121,0x000001b9,0x0000034a, +0x0004003d,0x00000006,0x00002122,0x00002121, +0x00050095,0x0000013d,0x0000246d,0x0000222a, +0x0000052d,0x00050051,0x00000006,0x0000246e, +0x0000246d,0x00000001,0x00050051,0x00000006, +0x0000246f,0x0000246d,0x00000000,0x00050080, +0x00000006,0x00002474,0x00002231,0x0000246e, +0x00050050,0x00000007,0x00002475,0x0000246f, +0x00002474,0x0004007c,0x00000014,0x00002465, +0x00002475,0x00060041,0x0000016c,0x0000245d, +0x00002465,0x0000016b,0x0000016b,0x0005003e, +0x0000245d,0x00002122,0x00000002,0x00000004, +0x00050041,0x000001bb,0x00002126,0x000001b9, +0x000010be,0x0004003d,0x00000006,0x00002127, +0x00002126,0x00050095,0x0000013d,0x0000248d, +0x0000222a,0x00000537,0x00050051,0x00000006, +0x0000248e,0x0000248d,0x00000001,0x00050051, +0x00000006,0x0000248f,0x0000248d,0x00000000, +0x00050080,0x00000006,0x00002494,0x00002231, +0x0000248e,0x00050050,0x00000007,0x00002495, +0x0000248f,0x00002494,0x0004007c,0x00000014, +0x00002485,0x00002495,0x00060041,0x0000016c, +0x0000247d,0x00002485,0x0000016b,0x0000016b, +0x0005003e,0x0000247d,0x00002127,0x00000002, +0x00000004,0x00050095,0x0000013d,0x000024ad, +0x0000222a,0x00000541,0x00050051,0x00000006, +0x000024ae,0x000024ad,0x00000001,0x00050051, +0x00000006,0x000024af,0x000024ad,0x00000000, +0x00050080,0x00000006,0x000024b4,0x00002231, +0x000024ae,0x00050050,0x00000007,0x000024b5, +0x000024af,0x000024b4,0x0004007c,0x00000014, +0x000024a5,0x000024b5,0x00060041,0x0000016c, +0x0000249d,0x000024a5,0x0000016b,0x0000016b, +0x0005003e,0x0000249d,0x00000138,0x00000002, +0x00000004,0x000200f9,0x0000212c,0x000200f8, +0x0000212c,0x000200f9,0x0000134b,0x000200f8, +0x0000134b,0x000200f9,0x000013fd,0x000200f8, +0x00001347,0x00050041,0x000001bb,0x0000134f, +0x000001b9,0x0000074d,0x0004003d,0x00000006, +0x00001350,0x0000134f,0x000500ae,0x0000002f, +0x00001351,0x000012dd,0x00001350,0x000300f7, +0x00001353,0x00000000,0x000400fa,0x00001351, +0x00001352,0x00001353,0x000200f8,0x00001352, +0x000200f9,0x000013fd,0x000200f8,0x00001353, +0x000500aa,0x0000002f,0x00001358,0x000012df, +0x00001357,0x000300f7,0x0000135a,0x00000000, +0x000400fa,0x00001358,0x00001359,0x0000135a, +0x000200f8,0x00001359,0x000500aa,0x0000002f, +0x0000135c,0x000012dd,0x00000138,0x000300f7, +0x0000135e,0x00000000,0x000400fa,0x0000135c, +0x0000135d,0x0000135e,0x000200f8,0x0000135d, +0x00050041,0x00000266,0x00001360,0x000001b9, +0x00000315,0x0004003d,0x00000007,0x00001361, +0x00001360,0x00050051,0x00000006,0x000024cc, +0x00001361,0x00000000,0x00050095,0x0000013d, +0x000024ce,0x000024cc,0x000000ec,0x00050051, +0x00000006,0x000024cf,0x000024ce,0x00000001, +0x00050051,0x00000006,0x000024d0,0x000024ce, +0x00000000,0x00050051,0x00000006,0x000024d3, +0x00001361,0x00000001,0x00050080,0x00000006, +0x000024d5,0x000024d3,0x000024cf,0x00050050, +0x00000007,0x000024d6,0x000024d0,0x000024d5, +0x0004007c,0x00000014,0x000024c6,0x000024d6, +0x00060041,0x0000016c,0x000024bd,0x000024c6, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000024be,0x000024bd,0x00000002,0x00000004, +0x00050080,0x00000006,0x00001364,0x000024be, +0x00000142,0x00050084,0x00000006,0x00001365, +0x00001364,0x000001c4,0x00050041,0x00000266, +0x00001367,0x000001b9,0x0000016b,0x0004003d, +0x00000007,0x00001368,0x00001367,0x00050051, +0x00000006,0x000024ec,0x00001368,0x00000000, +0x00050095,0x0000013d,0x000024ee,0x000024ec, +0x00000138,0x00050051,0x00000006,0x000024ef, +0x000024ee,0x00000001,0x00050051,0x00000006, +0x000024f0,0x000024ee,0x00000000,0x00050051, +0x00000006,0x000024f3,0x00001368,0x00000001, +0x00050080,0x00000006,0x000024f5,0x000024f3, +0x000024ef,0x00050050,0x00000007,0x000024f6, +0x000024f0,0x000024f5,0x0004007c,0x00000014, +0x000024e6,0x000024f6,0x00060041,0x0000016c, +0x000024de,0x000024e6,0x0000016b,0x0000016b, +0x0005003e,0x000024de,0x00001365,0x00000002, +0x00000004,0x00050095,0x0000013d,0x0000250e, +0x000024ec,0x000000ec,0x00050051,0x00000006, +0x0000250f,0x0000250e,0x00000001,0x00050051, +0x00000006,0x00002510,0x0000250e,0x00000000, +0x00050080,0x00000006,0x00002515,0x000024f3, +0x0000250f,0x00050050,0x00000007,0x00002516, +0x00002510,0x00002515,0x0004007c,0x00000014, +0x00002506,0x00002516,0x00060041,0x0000016c, +0x000024fe,0x00002506,0x0000016b,0x0000016b, +0x0005003e,0x000024fe,0x00000138,0x00000002, +0x00000004,0x000200f9,0x0000135e,0x000200f8, +0x0000135e,0x000200f9,0x000013fd,0x000200f8, +0x0000135a,0x000500aa,0x0000002f,0x00001375, +0x000012df,0x000001d4,0x000300f7,0x00001377, +0x00000000,0x000400fa,0x00001375,0x00001376, +0x00001377,0x000200f8,0x00001376,0x00050084, +0x00000006,0x00001379,0x000000ec,0x000012dd, +0x00050041,0x00000266,0x0000137b,0x000001b9, +0x00000315,0x0004003d,0x00000007,0x0000137c, +0x0000137b,0x00050051,0x00000006,0x0000252d, +0x0000137c,0x00000000,0x00050095,0x0000013d, +0x0000252f,0x0000252d,0x000000ec,0x00050051, +0x00000006,0x00002530,0x0000252f,0x00000001, +0x00050051,0x00000006,0x00002531,0x0000252f, +0x00000000,0x00050051,0x00000006,0x00002534, +0x0000137c,0x00000001,0x00050080,0x00000006, +0x00002536,0x00002534,0x00002530,0x00050050, +0x00000007,0x00002537,0x00002531,0x00002536, +0x0004007c,0x00000014,0x00002527,0x00002537, +0x00060041,0x0000016c,0x0000251e,0x00002527, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x0000251f,0x0000251e,0x00000002,0x00000004, +0x00050080,0x00000006,0x0000137f,0x0000251f, +0x00000142,0x00050084,0x00000006,0x00001380, +0x0000137f,0x000001c4,0x000500b0,0x0000002f, +0x00001381,0x00001379,0x00001380,0x000300f7, +0x00001383,0x00000000,0x000400fa,0x00001381, +0x00001382,0x00001383,0x000200f8,0x00001382, +0x00050095,0x0000013d,0x00002550,0x0000252d, +0x00001379,0x00050051,0x00000006,0x00002551, +0x00002550,0x00000001,0x00050051,0x00000006, +0x00002552,0x00002550,0x00000000,0x00050080, +0x00000006,0x00002557,0x00002534,0x00002551, +0x00050050,0x00000007,0x00002558,0x00002552, +0x00002557,0x0004007c,0x00000014,0x00002548, +0x00002558,0x00060041,0x0000016c,0x0000253f, +0x00002548,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002540,0x0000253f,0x00000002, +0x00000004,0x00050041,0x00000266,0x0000138e, +0x000001b9,0x0000016b,0x0004003d,0x00000007, +0x0000138f,0x0000138e,0x00050051,0x00000006, +0x0000256e,0x0000138f,0x00000000,0x00050095, +0x0000013d,0x00002570,0x0000256e,0x00001379, +0x00050051,0x00000006,0x00002571,0x00002570, +0x00000001,0x00050051,0x00000006,0x00002572, +0x00002570,0x00000000,0x00050051,0x00000006, +0x00002575,0x0000138f,0x00000001,0x00050080, +0x00000006,0x00002577,0x00002575,0x00002571, +0x00050050,0x00000007,0x00002578,0x00002572, +0x00002577,0x0004007c,0x00000014,0x00002568, +0x00002578,0x00060041,0x0000016c,0x00002560, +0x00002568,0x0000016b,0x0000016b,0x0005003e, +0x00002560,0x00002540,0x00000002,0x00000004, +0x000200f9,0x00001383,0x000200f8,0x00001383, +0x000200f9,0x000013fd,0x000200f8,0x00001377, +0x000500aa,0x0000002f,0x00001396,0x000012df, +0x00000138,0x000300f7,0x00001398,0x00000000, +0x000400fa,0x00001396,0x00001397,0x000013b9, +0x000200f8,0x000013b9,0x000500aa,0x0000002f, +0x000013bc,0x000012df,0x00000142,0x000300f7, +0x000013be,0x00000000,0x000400fa,0x000013bc, +0x000013bd,0x000013c2,0x000200f8,0x000013c2, +0x000500aa,0x0000002f,0x000013c5,0x000012df, +0x00000280,0x000300f7,0x000013c7,0x00000000, +0x000400fa,0x000013c5,0x000013c6,0x000013cb, +0x000200f8,0x000013cb,0x000500aa,0x0000002f, +0x000013ce,0x000012df,0x00000470,0x000300f7, +0x000013d0,0x00000000,0x000400fa,0x000013ce, +0x000013cf,0x000013d4,0x000200f8,0x000013d4, +0x000500aa,0x0000002f,0x000013d7,0x000012df, +0x000000ec,0x000300f7,0x000013d9,0x00000000, +0x000400fa,0x000013d7,0x000013d8,0x000013de, +0x000200f8,0x000013de,0x000500aa,0x0000002f, +0x000013e1,0x000012df,0x00000364,0x000300f7, +0x000013e3,0x00000000,0x000400fa,0x000013e1, +0x000013e2,0x000013e7,0x000200f8,0x000013e7, +0x000500aa,0x0000002f,0x000013eb,0x000012df, +0x000013ea,0x000300f7,0x000013ed,0x00000000, +0x000400fa,0x000013eb,0x000013ec,0x000013f1, +0x000200f8,0x000013f1,0x000500aa,0x0000002f, +0x000013f5,0x000012df,0x000013f4,0x000300f7, +0x000013f7,0x00000000,0x000400fa,0x000013f5, +0x000013f6,0x000013f7,0x000200f8,0x000013f6, +0x00050041,0x000001bb,0x00005a4a,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00005a4b, +0x00005a4a,0x00050084,0x00000006,0x00005a4c, +0x000001db,0x00005a4b,0x00050080,0x00000006, +0x00005a4d,0x000001c4,0x00005a4c,0x00050080, +0x00000006,0x00005a53,0x00005a4b,0x0000062f, +0x00050086,0x00000006,0x00005a54,0x00005a53, +0x000001be,0x00050084,0x00000006,0x00005a46, +0x000001c4,0x00005a54,0x00050080,0x00000006, +0x00005a47,0x00005a4d,0x00005a46,0x00050080, +0x00000006,0x00005a41,0x00005a47,0x00005a46, +0x00050041,0x000001bb,0x00005a38,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00005a39, +0x00005a38,0x00050084,0x00000006,0x00005a3a, +0x000001ef,0x00005a39,0x00050080,0x00000006, +0x00005a3b,0x00005a41,0x00005a3a,0x00050084, +0x00000006,0x00005a30,0x00000205,0x000012dd, +0x00050080,0x00000006,0x00005a31,0x00005a3b, +0x00005a30,0x00050041,0x00000266,0x00005a32, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x00005a33,0x00005a32,0x00050051,0x00000006, +0x00005a69,0x00005a33,0x00000000,0x00050095, +0x0000013d,0x00005a6b,0x00005a69,0x00005a31, +0x00050051,0x00000006,0x00005a6c,0x00005a6b, +0x00000001,0x00050051,0x00000006,0x00005a6d, +0x00005a6b,0x00000000,0x00050051,0x00000006, +0x00005a70,0x00005a33,0x00000001,0x00050080, +0x00000006,0x00005a72,0x00005a70,0x00005a6c, +0x00050050,0x00000007,0x00005a73,0x00005a6d, +0x00005a72,0x0004007c,0x00000014,0x00005a63, +0x00005a73,0x00060041,0x0000016c,0x00005a1d, +0x00005a63,0x0000016b,0x0000016b,0x0005003e, +0x00005a1d,0x00000138,0x00000002,0x00000004, +0x00060041,0x0000016c,0x00005a1f,0x00005a63, +0x0000016b,0x00000264,0x0005003e,0x00005a1f, +0x00000539,0x00000002,0x00000004,0x00060041, +0x0000016c,0x00005a21,0x00005a63,0x0000016b, +0x00000315,0x0005003e,0x00005a21,0x00000539, +0x00000002,0x00000004,0x00060041,0x0000016c, +0x00005a23,0x00005a63,0x0000016b,0x0000031d, +0x0005003e,0x00005a23,0x00000539,0x00000002, +0x00000004,0x00060041,0x0000016c,0x00005a25, +0x00005a63,0x0000016b,0x00000325,0x0005003e, +0x00005a25,0x00000138,0x00000002,0x00000004, +0x00060041,0x0000016c,0x00005a27,0x00005a63, +0x0000016b,0x0000032d,0x0005003e,0x00005a27, +0x00000138,0x00000002,0x00000004,0x00060041, +0x0000016c,0x00005a29,0x00005a63,0x0000016b, +0x00000351,0x0005003e,0x00005a29,0x00000138, +0x00000002,0x00000004,0x000200f9,0x000013f7, +0x000200f8,0x000013f7,0x000200f9,0x000013ed, +0x000200f8,0x000013ec,0x000300f7,0x000051a3, +0x00000000,0x000300fb,0x00000138,0x0000510e, +0x000200f8,0x0000510e,0x00050041,0x000001bb, +0x0000510f,0x000001b9,0x00000434,0x0004003d, +0x00000006,0x00005110,0x0000510f,0x000500aa, +0x0000002f,0x00005111,0x00005110,0x00000142, +0x000300f7,0x0000511d,0x00000000,0x000400fa, +0x00005111,0x00005112,0x00005115,0x000200f8, +0x00005115,0x00050041,0x000001bb,0x00005207, +0x000001b9,0x000001ba,0x0004003d,0x00000006, +0x00005208,0x00005207,0x00050084,0x00000006, +0x00005209,0x000001db,0x00005208,0x00050080, +0x00000006,0x0000520a,0x000001c4,0x00005209, +0x00050080,0x00000006,0x00005210,0x00005208, +0x0000062f,0x00050086,0x00000006,0x00005211, +0x00005210,0x000001be,0x00050084,0x00000006, +0x00005203,0x000001c4,0x00005211,0x00050080, +0x00000006,0x00005204,0x0000520a,0x00005203, +0x00050080,0x00000006,0x000051fe,0x00005204, +0x00005203,0x00050041,0x000001bb,0x000051f5, +0x000001b9,0x000001f0,0x0004003d,0x00000006, +0x000051f6,0x000051f5,0x00050084,0x00000006, +0x000051f7,0x000001ef,0x000051f6,0x00050080, +0x00000006,0x000051f8,0x000051fe,0x000051f7, +0x00050041,0x000001bb,0x000051ee,0x000001b9, +0x00000206,0x0004003d,0x00000006,0x000051ef, +0x000051ee,0x00050084,0x00000006,0x000051f0, +0x00000205,0x000051ef,0x00050080,0x00000006, +0x000051f1,0x000051f8,0x000051f0,0x000500ac, +0x0000002f,0x0000521e,0x000051f6,0x00000142, +0x000300f7,0x00005224,0x00000000,0x000400fa, +0x0000521e,0x0000521f,0x00005223,0x000200f8, +0x00005223,0x000200f9,0x00005224,0x000200f8, +0x0000521f,0x00050082,0x00000006,0x00005222, +0x000051f6,0x00000142,0x000200f9,0x00005224, +0x000200f8,0x00005224,0x000700f5,0x00000006, +0x00005ce3,0x00005222,0x0000521f,0x00000138, +0x00005223,0x00050084,0x00000006,0x000051e9, +0x000000ec,0x00005ce3,0x00050080,0x00000006, +0x000051ea,0x000051f1,0x000051e9,0x000300f7, +0x00005231,0x00000000,0x000400fa,0x0000521e, +0x0000522c,0x00005230,0x000200f8,0x00005230, +0x000200f9,0x00005231,0x000200f8,0x0000522c, +0x00050082,0x00000006,0x0000522f,0x000051f6, +0x00000142,0x000200f9,0x00005231,0x000200f8, +0x00005231,0x000700f5,0x00000006,0x00005ce4, +0x0000522f,0x0000522c,0x00000138,0x00005230, +0x00050084,0x00000006,0x000051e3,0x000000ec, +0x00005ce4,0x00050080,0x00000006,0x000051e4, +0x000051ea,0x000051e3,0x000300f7,0x0000523e, +0x00000000,0x000400fa,0x0000521e,0x00005239, +0x0000523d,0x000200f8,0x0000523d,0x000200f9, +0x0000523e,0x000200f8,0x00005239,0x00050082, +0x00000006,0x0000523c,0x000051f6,0x00000142, +0x000200f9,0x0000523e,0x000200f8,0x0000523e, +0x000700f5,0x00000006,0x00005ce5,0x0000523c, +0x00005239,0x00000138,0x0000523d,0x00050084, +0x00000006,0x000051dd,0x000000ec,0x00005ce5, +0x00050080,0x00000006,0x000051de,0x000051e4, +0x000051dd,0x000300f7,0x0000524b,0x00000000, +0x000400fa,0x0000521e,0x00005246,0x0000524a, +0x000200f8,0x0000524a,0x000200f9,0x0000524b, +0x000200f8,0x00005246,0x00050082,0x00000006, +0x00005249,0x000051f6,0x00000142,0x000200f9, +0x0000524b,0x000200f8,0x0000524b,0x000700f5, +0x00000006,0x00005ce6,0x00005249,0x00005246, +0x00000138,0x0000524a,0x00050084,0x00000006, +0x000051d7,0x000000ec,0x00005ce6,0x00050080, +0x00000006,0x000051d8,0x000051de,0x000051d7, +0x000300f7,0x00005258,0x00000000,0x000400fa, +0x0000521e,0x00005253,0x00005257,0x000200f8, +0x00005257,0x000200f9,0x00005258,0x000200f8, +0x00005253,0x00050082,0x00000006,0x00005256, +0x000051f6,0x00000142,0x000200f9,0x00005258, +0x000200f8,0x00005258,0x000700f5,0x00000006, +0x00005ce7,0x00005256,0x00005253,0x00000138, +0x00005257,0x00050084,0x00000006,0x000051d1, +0x000000ec,0x00005ce7,0x00050080,0x00000006, +0x000051d2,0x000051d8,0x000051d1,0x000300f7, +0x0000526b,0x00000000,0x000400fa,0x0000521e, +0x00005266,0x0000526a,0x000200f8,0x0000526a, +0x000200f9,0x0000526b,0x000200f8,0x00005266, +0x00050082,0x00000006,0x00005269,0x000051f6, +0x00000142,0x000200f9,0x0000526b,0x000200f8, +0x0000526b,0x000700f5,0x00000006,0x00005ce8, +0x00005269,0x00005266,0x00000138,0x0000526a, +0x00050080,0x00000006,0x0000525e,0x00005ce8, +0x0000062f,0x00050086,0x00000006,0x0000525f, +0x0000525e,0x000001be,0x00050084,0x00000006, +0x000051cb,0x000000ec,0x0000525f,0x00050080, +0x00000006,0x000051cc,0x000051d2,0x000051cb, +0x000300f7,0x0000527e,0x00000000,0x000400fa, +0x0000521e,0x00005279,0x0000527d,0x000200f8, +0x0000527d,0x000200f9,0x0000527e,0x000200f8, +0x00005279,0x00050082,0x00000006,0x0000527c, +0x000051f6,0x00000142,0x000200f9,0x0000527e, +0x000200f8,0x0000527e,0x000700f5,0x00000006, +0x00005ce9,0x0000527c,0x00005279,0x00000138, +0x0000527d,0x00050080,0x00000006,0x00005271, +0x00005ce9,0x0000062f,0x00050086,0x00000006, +0x00005272,0x00005271,0x000001be,0x00050084, +0x00000006,0x000051c5,0x000000ec,0x00005272, +0x00050080,0x00000006,0x000051c6,0x000051cc, +0x000051c5,0x00050084,0x00000006,0x00005118, +0x000000ec,0x000012dd,0x00050080,0x00000006, +0x00005119,0x000051c6,0x00005118,0x00050041, +0x00000266,0x0000511a,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x0000511b,0x0000511a, +0x00050051,0x00000006,0x00005296,0x0000511b, +0x00000000,0x00050095,0x0000013d,0x00005298, +0x00005296,0x00005119,0x00050051,0x00000006, +0x00005299,0x00005298,0x00000001,0x00050051, +0x00000006,0x0000529a,0x00005298,0x00000000, +0x00050051,0x00000006,0x0000529d,0x0000511b, +0x00000001,0x00050080,0x00000006,0x0000529f, +0x0000529d,0x00005299,0x00050050,0x00000007, +0x000052a0,0x0000529a,0x0000529f,0x0004007c, +0x00000014,0x00005290,0x000052a0,0x00060041, +0x0000016c,0x00005287,0x00005290,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00005288, +0x00005287,0x00000002,0x00000004,0x000200f9, +0x0000511d,0x000200f8,0x00005112,0x00050041, +0x000001bb,0x000051a6,0x000001b9,0x0000034a, +0x0004003d,0x00000006,0x000051a7,0x000051a6, +0x00050041,0x000001bb,0x000051b7,0x000001b9, +0x00000334,0x0004003d,0x00000006,0x000051b8, +0x000051b7,0x000500c7,0x00000006,0x000051b9, +0x000051b8,0x00000142,0x000500ab,0x0000002f, +0x000051ba,0x000051b9,0x00000138,0x000600a9, +0x00000006,0x000051b4,0x000051ba,0x00000342, +0x000001c4,0x00050084,0x00000006,0x000051aa, +0x000012dd,0x000051b4,0x00050080,0x00000006, +0x000051ab,0x000051a7,0x000051aa,0x000500c2, +0x00000006,0x000051ac,0x000051ab,0x00000351, +0x000500c4,0x00000006,0x000051ad,0x000051ac, +0x0000031d,0x000600a9,0x00000006,0x000051af, +0x000051ba,0x00000355,0x00000138,0x000500c5, +0x00000006,0x000051b0,0x000051ad,0x000051af, +0x000200f9,0x0000511d,0x000200f8,0x0000511d, +0x000700f5,0x00000006,0x00005cea,0x000051b0, +0x00005112,0x00005288,0x0000527e,0x00050041, +0x000001bb,0x000052e6,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x000052e7,0x000052e6, +0x00050084,0x00000006,0x000052e8,0x000001db, +0x000052e7,0x00050080,0x00000006,0x000052e9, +0x000001c4,0x000052e8,0x00050080,0x00000006, +0x000052ef,0x000052e7,0x0000062f,0x00050086, +0x00000006,0x000052f0,0x000052ef,0x000001be, +0x00050084,0x00000006,0x000052e2,0x000001c4, +0x000052f0,0x00050080,0x00000006,0x000052e3, +0x000052e9,0x000052e2,0x00050080,0x00000006, +0x000052dd,0x000052e3,0x000052e2,0x00050084, +0x00000006,0x000052b1,0x000001ef,0x000012dd, +0x00050080,0x00000006,0x000052b2,0x000052dd, +0x000052b1,0x00050041,0x00000266,0x000052b3, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x000052b4,0x000052b3,0x00050051,0x00000006, +0x0000530e,0x000052b4,0x00000000,0x00050095, +0x0000013d,0x00005310,0x0000530e,0x000052b2, +0x00050051,0x00000006,0x00005311,0x00005310, +0x00000001,0x00050051,0x00000006,0x00005312, +0x00005310,0x00000000,0x00050051,0x00000006, +0x00005315,0x000052b4,0x00000001,0x00050080, +0x00000006,0x00005317,0x00005315,0x00005311, +0x00050050,0x00000007,0x00005318,0x00005312, +0x00005317,0x0004007c,0x00000014,0x00005308, +0x00005318,0x00060041,0x0000016c,0x000052ff, +0x00005308,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00005300,0x000052ff,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000052b7, +0x00005300,0x00050080,0x00000006,0x000052b9, +0x000052b2,0x000000ec,0x00050095,0x0000013d, +0x00005331,0x0000530e,0x000052b9,0x00050051, +0x00000006,0x00005332,0x00005331,0x00000001, +0x00050051,0x00000006,0x00005333,0x00005331, +0x00000000,0x00050080,0x00000006,0x00005338, +0x00005315,0x00005332,0x00050050,0x00000007, +0x00005339,0x00005333,0x00005338,0x0004007c, +0x00000014,0x00005329,0x00005339,0x00060041, +0x0000016c,0x00005320,0x00005329,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00005321, +0x00005320,0x00000002,0x00000004,0x0004007c, +0x00000027,0x000052bd,0x00005321,0x00050080, +0x00000006,0x000052bf,0x000052b2,0x000001cd, +0x00050095,0x0000013d,0x00005352,0x0000530e, +0x000052bf,0x00050051,0x00000006,0x00005353, +0x00005352,0x00000001,0x00050051,0x00000006, +0x00005354,0x00005352,0x00000000,0x00050080, +0x00000006,0x00005359,0x00005315,0x00005353, +0x00050050,0x00000007,0x0000535a,0x00005354, +0x00005359,0x0004007c,0x00000014,0x0000534a, +0x0000535a,0x00060041,0x0000016c,0x00005341, +0x0000534a,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00005342,0x00005341,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000052c3, +0x00005342,0x00060050,0x0000006c,0x000052c4, +0x000052b7,0x000052bd,0x000052c3,0x00050080, +0x00000006,0x000052c6,0x000052b2,0x000001d4, +0x00050095,0x0000013d,0x00005373,0x0000530e, +0x000052c6,0x00050051,0x00000006,0x00005374, +0x00005373,0x00000001,0x00050051,0x00000006, +0x00005375,0x00005373,0x00000000,0x00050080, +0x00000006,0x0000537a,0x00005315,0x00005374, +0x00050050,0x00000007,0x0000537b,0x00005375, +0x0000537a,0x0004007c,0x00000014,0x0000536b, +0x0000537b,0x00060041,0x0000016c,0x00005362, +0x0000536b,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00005363,0x00005362,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000052ca, +0x00005363,0x00050080,0x00000006,0x000052cc, +0x000052b2,0x000001db,0x00050095,0x0000013d, +0x00005394,0x0000530e,0x000052cc,0x00050051, +0x00000006,0x00005395,0x00005394,0x00000001, +0x00050051,0x00000006,0x00005396,0x00005394, +0x00000000,0x00050080,0x00000006,0x0000539b, +0x00005315,0x00005395,0x00050050,0x00000007, +0x0000539c,0x00005396,0x0000539b,0x0004007c, +0x00000014,0x0000538c,0x0000539c,0x00060041, +0x0000016c,0x00005383,0x0000538c,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00005384, +0x00005383,0x00000002,0x00000004,0x0004007c, +0x00000027,0x000052d0,0x00005384,0x00050080, +0x00000006,0x000052d2,0x000052b2,0x00000299, +0x00050095,0x0000013d,0x000053b5,0x0000530e, +0x000052d2,0x00050051,0x00000006,0x000053b6, +0x000053b5,0x00000001,0x00050051,0x00000006, +0x000053b7,0x000053b5,0x00000000,0x00050080, +0x00000006,0x000053bc,0x00005315,0x000053b6, +0x00050050,0x00000007,0x000053bd,0x000053b7, +0x000053bc,0x0004007c,0x00000014,0x000053ad, +0x000053bd,0x00060041,0x0000016c,0x000053a4, +0x000053ad,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000053a5,0x000053a4,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000052d6, +0x000053a5,0x00060050,0x0000006c,0x000052d7, +0x000052ca,0x000052d0,0x000052d6,0x00050041, +0x000001bb,0x000053c3,0x000001b9,0x000010be, +0x0004003d,0x00000006,0x000053c4,0x000053c3, +0x000500c2,0x00000006,0x000053d3,0x00005cea, +0x0000031d,0x00050041,0x000001bb,0x000053c7, +0x000001b9,0x0000034a,0x0004003d,0x00000006, +0x000053c8,0x000053c7,0x00050086,0x00000006, +0x000053c9,0x000053c8,0x000001c4,0x00050082, +0x00000006,0x000053ca,0x000053d3,0x000053c9, +0x00050084,0x00000006,0x000053cb,0x000000ec, +0x000053ca,0x00050080,0x00000006,0x000053cc, +0x000053c4,0x000053cb,0x00050041,0x00000266, +0x000053cd,0x000001b9,0x0000016b,0x0004003d, +0x00000007,0x000053ce,0x000053cd,0x00050051, +0x00000006,0x000053ea,0x000053ce,0x00000000, +0x00050095,0x0000013d,0x000053ec,0x000053ea, +0x000053cc,0x00050051,0x00000006,0x000053ed, +0x000053ec,0x00000001,0x00050051,0x00000006, +0x000053ee,0x000053ec,0x00000000,0x00050051, +0x00000006,0x000053f1,0x000053ce,0x00000001, +0x00050080,0x00000006,0x000053f3,0x000053f1, +0x000053ed,0x00050050,0x00000007,0x000053f4, +0x000053ee,0x000053f3,0x0004007c,0x00000014, +0x000053e4,0x000053f4,0x00060041,0x0000016c, +0x000053db,0x000053e4,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x000053dc,0x000053db, +0x00000002,0x00000004,0x00050041,0x000001bb, +0x000053f7,0x000001b9,0x00000334,0x0004003d, +0x00000006,0x000053f8,0x000053f7,0x000500c7, +0x00000006,0x000053f9,0x000053f8,0x00000142, +0x000500ab,0x0000002f,0x000053fa,0x000053f9, +0x00000138,0x000300f7,0x00005131,0x00000000, +0x000400fa,0x000053fa,0x00005126,0x00005131, +0x000200f8,0x00005126,0x00050084,0x00000006, +0x0000512a,0x00000342,0x000012dd,0x00050080, +0x00000006,0x0000512b,0x000053c8,0x0000512a, +0x00050080,0x00000006,0x0000512c,0x0000512b, +0x0000084a,0x00050095,0x0000013d,0x00005412, +0x000053ea,0x0000512c,0x00050051,0x00000006, 0x00005413,0x00005412,0x00000001,0x00050051, 0x00000006,0x00005414,0x00005412,0x00000000, -0x00050080,0x00000006,0x00005419,0x00005065, +0x00050080,0x00000006,0x00005419,0x000053f1, 0x00005413,0x00050050,0x00000007,0x0000541a, 0x00005414,0x00005419,0x0004007c,0x00000014, -0x0000540a,0x0000541a,0x00060041,0x0000015f, -0x00005402,0x0000540a,0x0000015e,0x0000015e, -0x0005003e,0x00005402,0x000053f7,0x00000002, -0x00000004,0x00050080,0x00000006,0x000050f7, -0x000050e1,0x0000019b,0x00050051,0x00000027, -0x000050fb,0x0000592c,0x00000000,0x0004007c, -0x00000006,0x00005420,0x000050fb,0x00050095, -0x00000130,0x0000543b,0x0000505e,0x000050f7, -0x00050051,0x00000006,0x0000543c,0x0000543b, -0x00000001,0x00050051,0x00000006,0x0000543d, -0x0000543b,0x00000000,0x00050080,0x00000006, -0x00005442,0x00005065,0x0000543c,0x00050050, -0x00000007,0x00005443,0x0000543d,0x00005442, -0x0004007c,0x00000014,0x00005433,0x00005443, -0x00060041,0x0000015f,0x0000542b,0x00005433, -0x0000015e,0x0000015e,0x0005003e,0x0000542b, -0x00005420,0x00000002,0x00000004,0x00050080, -0x00000006,0x000050fe,0x000050e1,0x000001a2, -0x00050051,0x00000027,0x00005102,0x0000592c, -0x00000001,0x0004007c,0x00000006,0x00005449, -0x00005102,0x00050095,0x00000130,0x00005464, -0x0000505e,0x000050fe,0x00050051,0x00000006, -0x00005465,0x00005464,0x00000001,0x00050051, -0x00000006,0x00005466,0x00005464,0x00000000, -0x00050080,0x00000006,0x0000546b,0x00005065, -0x00005465,0x00050050,0x00000007,0x0000546c, -0x00005466,0x0000546b,0x0004007c,0x00000014, -0x0000545c,0x0000546c,0x00060041,0x0000015f, -0x00005454,0x0000545c,0x0000015e,0x0000015e, -0x0005003e,0x00005454,0x00005449,0x00000002, -0x00000004,0x00050080,0x00000006,0x00005105, -0x000050e1,0x00000260,0x00050051,0x00000027, -0x00005109,0x0000592c,0x00000002,0x0004007c, -0x00000006,0x00005472,0x00005109,0x00050095, -0x00000130,0x0000548d,0x0000505e,0x00005105, -0x00050051,0x00000006,0x0000548e,0x0000548d, -0x00000001,0x00050051,0x00000006,0x0000548f, -0x0000548d,0x00000000,0x00050080,0x00000006, -0x00005494,0x00005065,0x0000548e,0x00050050, -0x00000007,0x00005495,0x0000548f,0x00005494, -0x0004007c,0x00000014,0x00005485,0x00005495, -0x00060041,0x0000015f,0x0000547d,0x00005485, -0x0000015e,0x0000015e,0x0005003e,0x0000547d, -0x00005472,0x00000002,0x00000004,0x000200f9, -0x0000510b,0x000200f8,0x0000510b,0x000200f9, -0x00004dce,0x000200f8,0x00004dce,0x000200f9, -0x00004dcf,0x000200f8,0x00004dcf,0x000700f5, -0x00000006,0x00005bf6,0x00005942,0x00004dbf, -0x00004dc2,0x00004dce,0x00050080,0x00000006, -0x00004dd1,0x00005926,0x0000022b,0x000200f9, -0x00004db1,0x000200f8,0x00004dd2,0x00050041, -0x00000182,0x0000549d,0x00000180,0x00000321, -0x0004003d,0x00000006,0x0000549e,0x0000549d, -0x00050082,0x00000006,0x0000549f,0x00004db0, -0x0000549e,0x000500c7,0x00000006,0x000054ab, -0x00005923,0x00000c2c,0x000500aa,0x0000002f, -0x000054ac,0x000054ab,0x000000df,0x000600a9, -0x00000006,0x000054a2,0x000054ac,0x0000018b, -0x00000309,0x00050086,0x00000006,0x000054a3, -0x0000549f,0x000054a2,0x00050041,0x00000182, -0x000054bb,0x00000180,0x000001b7,0x0004003d, -0x00000006,0x000054bc,0x000054bb,0x00050084, -0x00000006,0x000054bd,0x000001b6,0x000054bc, -0x00050080,0x00000006,0x000054be,0x00004f51, -0x000054bd,0x00050084,0x00000006,0x000054b3, -0x000001cc,0x000054a3,0x00050080,0x00000006, -0x000054b4,0x000054be,0x000054b3,0x00050095, -0x00000130,0x000054ee,0x00004f82,0x000054b4, -0x00050051,0x00000006,0x000054ef,0x000054ee, -0x00000001,0x00050051,0x00000006,0x000054f0, -0x000054ee,0x00000000,0x00050080,0x00000006, -0x000054f5,0x00004f89,0x000054ef,0x00050050, -0x00000007,0x000054f6,0x000054f0,0x000054f5, -0x0004007c,0x00000014,0x000054e6,0x000054f6, -0x00050051,0x00000027,0x000054fa,0x00005929, -0x00000000,0x00050051,0x00000027,0x000054fc, -0x0000592c,0x00000000,0x000500bc,0x0000002f, -0x000054fd,0x000054fa,0x000054fc,0x000300f7, -0x00005504,0x00000000,0x000400fa,0x000054fd, -0x000054fe,0x00005504,0x000200f8,0x000054fe, -0x00050051,0x00000027,0x00005500,0x00005929, -0x00000001,0x00050051,0x00000027,0x00005502, -0x0000592c,0x00000001,0x000500bc,0x0000002f, -0x00005503,0x00005500,0x00005502,0x000200f9, -0x00005504,0x000200f8,0x00005504,0x000700f5, -0x0000002f,0x00005505,0x000054fd,0x00004dd2, -0x00005503,0x000054fe,0x000300f7,0x0000550c, -0x00000000,0x000400fa,0x00005505,0x00005506, -0x0000550c,0x000200f8,0x00005506,0x00050051, -0x00000027,0x00005508,0x00005929,0x00000002, -0x00050051,0x00000027,0x0000550a,0x0000592c, -0x00000002,0x000500bc,0x0000002f,0x0000550b, -0x00005508,0x0000550a,0x000200f9,0x0000550c, -0x000200f8,0x0000550c,0x000700f5,0x0000002f, -0x0000550d,0x00005505,0x00005504,0x0000550b, -0x00005506,0x000300f7,0x00004e00,0x00000000, -0x000400fa,0x0000550d,0x00004ddb,0x00004e00, -0x000200f8,0x00004ddb,0x00060041,0x0000015f, -0x00004ddd,0x000054e6,0x0000015e,0x0000022b, -0x0004007c,0x00000006,0x00005514,0x000054fa, -0x000500c7,0x00000006,0x00005516,0x00005514, -0x00000208,0x000500ab,0x0000002f,0x00005517, -0x00005516,0x0000012b,0x000300f7,0x0000551e, -0x00000000,0x000400fa,0x00005517,0x00005518, -0x0000551b,0x000200f8,0x0000551b,0x000500c5, -0x00000006,0x0000551d,0x00005514,0x00000208, -0x000200f9,0x0000551e,0x000200f8,0x00005518, -0x000400c8,0x00000006,0x0000551a,0x00005514, -0x000200f9,0x0000551e,0x000200f8,0x0000551e, -0x000700f5,0x00000006,0x00005930,0x0000551a, -0x00005518,0x0000551d,0x0000551b,0x000700ed, -0x00000006,0x00004de1,0x00004ddd,0x00000135, -0x0000012b,0x00005930,0x00060041,0x0000015f, -0x00004de3,0x000054e6,0x0000015e,0x000002dc, -0x00050051,0x00000027,0x00004de5,0x00005929, -0x00000001,0x0004007c,0x00000006,0x00005525, -0x00004de5,0x000500c7,0x00000006,0x00005527, -0x00005525,0x00000208,0x000500ab,0x0000002f, -0x00005528,0x00005527,0x0000012b,0x000300f7, -0x0000552f,0x00000000,0x000400fa,0x00005528, -0x00005529,0x0000552c,0x000200f8,0x0000552c, -0x000500c5,0x00000006,0x0000552e,0x00005525, -0x00000208,0x000200f9,0x0000552f,0x000200f8, -0x00005529,0x000400c8,0x00000006,0x0000552b, -0x00005525,0x000200f9,0x0000552f,0x000200f8, -0x0000552f,0x000700f5,0x00000006,0x00005932, -0x0000552b,0x00005529,0x0000552e,0x0000552c, -0x000700ed,0x00000006,0x00004de7,0x00004de3, -0x00000135,0x0000012b,0x00005932,0x00060041, -0x0000015f,0x00004de9,0x000054e6,0x0000015e, -0x000002e4,0x00050051,0x00000027,0x00004deb, -0x00005929,0x00000002,0x0004007c,0x00000006, -0x00005536,0x00004deb,0x000500c7,0x00000006, -0x00005538,0x00005536,0x00000208,0x000500ab, -0x0000002f,0x00005539,0x00005538,0x0000012b, -0x000300f7,0x00005540,0x00000000,0x000400fa, -0x00005539,0x0000553a,0x0000553d,0x000200f8, -0x0000553d,0x000500c5,0x00000006,0x0000553f, -0x00005536,0x00000208,0x000200f9,0x00005540, -0x000200f8,0x0000553a,0x000400c8,0x00000006, -0x0000553c,0x00005536,0x000200f9,0x00005540, -0x000200f8,0x00005540,0x000700f5,0x00000006, -0x00005934,0x0000553c,0x0000553a,0x0000553f, -0x0000553d,0x000700ed,0x00000006,0x00004ded, -0x00004de9,0x00000135,0x0000012b,0x00005934, -0x00060041,0x0000015f,0x00004def,0x000054e6, -0x0000015e,0x000002ec,0x0004007c,0x00000006, -0x00005547,0x000054fc,0x000500c7,0x00000006, -0x00005549,0x00005547,0x00000208,0x000500ab, -0x0000002f,0x0000554a,0x00005549,0x0000012b, -0x000300f7,0x00005551,0x00000000,0x000400fa, -0x0000554a,0x0000554b,0x0000554e,0x000200f8, -0x0000554e,0x000500c5,0x00000006,0x00005550, -0x00005547,0x00000208,0x000200f9,0x00005551, -0x000200f8,0x0000554b,0x000400c8,0x00000006, -0x0000554d,0x00005547,0x000200f9,0x00005551, -0x000200f8,0x00005551,0x000700f5,0x00000006, -0x0000593a,0x0000554d,0x0000554b,0x00005550, -0x0000554e,0x000700ef,0x00000006,0x00004df3, -0x00004def,0x00000135,0x0000012b,0x0000593a, -0x00060041,0x0000015f,0x00004df5,0x000054e6, -0x0000015e,0x000002f4,0x00050051,0x00000027, -0x00004df7,0x0000592c,0x00000001,0x0004007c, -0x00000006,0x00005558,0x00004df7,0x000500c7, -0x00000006,0x0000555a,0x00005558,0x00000208, -0x000500ab,0x0000002f,0x0000555b,0x0000555a, -0x0000012b,0x000300f7,0x00005562,0x00000000, -0x000400fa,0x0000555b,0x0000555c,0x0000555f, -0x000200f8,0x0000555f,0x000500c5,0x00000006, -0x00005561,0x00005558,0x00000208,0x000200f9, -0x00005562,0x000200f8,0x0000555c,0x000400c8, -0x00000006,0x0000555e,0x00005558,0x000200f9, -0x00005562,0x000200f8,0x00005562,0x000700f5, -0x00000006,0x0000593c,0x0000555e,0x0000555c, -0x00005561,0x0000555f,0x000700ef,0x00000006, -0x00004df9,0x00004df5,0x00000135,0x0000012b, -0x0000593c,0x00060041,0x0000015f,0x00004dfb, -0x000054e6,0x0000015e,0x00000318,0x00050051, -0x00000027,0x00004dfd,0x0000592c,0x00000002, -0x0004007c,0x00000006,0x00005569,0x00004dfd, -0x000500c7,0x00000006,0x0000556b,0x00005569, -0x00000208,0x000500ab,0x0000002f,0x0000556c, -0x0000556b,0x0000012b,0x000300f7,0x00005573, -0x00000000,0x000400fa,0x0000556c,0x0000556d, -0x00005570,0x000200f8,0x00005570,0x000500c5, -0x00000006,0x00005572,0x00005569,0x00000208, -0x000200f9,0x00005573,0x000200f8,0x0000556d, -0x000400c8,0x00000006,0x0000556f,0x00005569, -0x000200f9,0x00005573,0x000200f8,0x00005573, -0x000700f5,0x00000006,0x0000593e,0x0000556f, -0x0000556d,0x00005572,0x00005570,0x000700ef, -0x00000006,0x00004dff,0x00004dfb,0x00000135, -0x0000012b,0x0000593e,0x000200f9,0x00004e00, -0x000200f8,0x00004e00,0x00060041,0x0000015f, -0x00004e02,0x000054e6,0x0000015e,0x0000015e, -0x000700ea,0x00000006,0x00004e03,0x00004e02, -0x0000022b,0x00000721,0x00000135,0x00050080, -0x00000006,0x00004e05,0x00004e03,0x00000135, -0x000500ab,0x0000002f,0x00004e07,0x00004e05, -0x00005942,0x000300f7,0x00004e09,0x00000000, -0x000400fa,0x00004e07,0x00004e08,0x00004e09, -0x000200f8,0x00004e08,0x000200f9,0x00004e14, -0x000200f8,0x00004e09,0x000300f7,0x000055af, -0x00000000,0x000300fb,0x0000012b,0x00005581, -0x000200f8,0x00005581,0x000200f9,0x00005584, -0x000200f8,0x00005584,0x000700f5,0x00000006, -0x00005949,0x0000012b,0x00005581,0x00005592, -0x00005588,0x000500b0,0x0000002f,0x00005587, -0x00005949,0x0000031c,0x000400f6,0x00005593, -0x00005588,0x00000000,0x000400fa,0x00005587, -0x00005588,0x00005593,0x000200f8,0x00005588, -0x00050080,0x00000006,0x0000558c,0x00000135, -0x00005949,0x00060041,0x0000015f,0x0000558d, -0x000054e6,0x0000015e,0x0000558c,0x000700f1, -0x00000006,0x0000558e,0x0000558d,0x00000135, -0x0000012b,0x0000012b,0x00050041,0x00000009, -0x0000558f,0x00005579,0x00005949,0x0003003e, -0x0000558f,0x0000558e,0x00050080,0x00000006, -0x00005592,0x00005949,0x0000022b,0x000200f9, -0x00005584,0x000200f8,0x00005593,0x00050041, -0x00000009,0x00005594,0x00005579,0x0000015e, -0x0004003d,0x00000006,0x00005595,0x00005594, -0x000500aa,0x0000002f,0x00005596,0x00005595, -0x00000500,0x000300f7,0x0000559a,0x00000000, -0x000400fa,0x00005596,0x00005597,0x0000559a, -0x000200f8,0x00005597,0x000200f9,0x000055af, -0x000200f8,0x0000559a,0x0004003d,0x00000006, -0x0000559c,0x00005594,0x000500c7,0x00000006, -0x000055fe,0x0000559c,0x00000208,0x000500ab, -0x0000002f,0x000055ff,0x000055fe,0x0000012b, -0x000300f7,0x00005606,0x00000000,0x000400fa, -0x000055ff,0x00005600,0x00005603,0x000200f8, -0x00005603,0x000400c8,0x00000006,0x00005605, -0x0000559c,0x000200f9,0x00005606,0x000200f8, -0x00005600,0x000500c7,0x00000006,0x00005602, -0x0000559c,0x0000021d,0x000200f9,0x00005606, -0x000200f8,0x00005606,0x000700f5,0x00000006, -0x0000594a,0x00005602,0x00005600,0x00005605, -0x00005603,0x0004007c,0x00000027,0x00005608, -0x0000594a,0x00050041,0x00000009,0x0000559e, -0x00005579,0x0000022b,0x0004003d,0x00000006, -0x0000559f,0x0000559e,0x000500c7,0x00000006, -0x0000560d,0x0000559f,0x00000208,0x000500ab, -0x0000002f,0x0000560e,0x0000560d,0x0000012b, -0x000300f7,0x00005615,0x00000000,0x000400fa, -0x0000560e,0x0000560f,0x00005612,0x000200f8, -0x00005612,0x000400c8,0x00000006,0x00005614, -0x0000559f,0x000200f9,0x00005615,0x000200f8, -0x0000560f,0x000500c7,0x00000006,0x00005611, -0x0000559f,0x0000021d,0x000200f9,0x00005615, -0x000200f8,0x00005615,0x000700f5,0x00000006, -0x0000594b,0x00005611,0x0000560f,0x00005614, -0x00005612,0x0004007c,0x00000027,0x00005617, -0x0000594b,0x00050041,0x00000009,0x000055a1, -0x00005579,0x000002dc,0x0004003d,0x00000006, -0x000055a2,0x000055a1,0x000500c7,0x00000006, -0x0000561c,0x000055a2,0x00000208,0x000500ab, -0x0000002f,0x0000561d,0x0000561c,0x0000012b, -0x000300f7,0x00005624,0x00000000,0x000400fa, -0x0000561d,0x0000561e,0x00005621,0x000200f8, -0x00005621,0x000400c8,0x00000006,0x00005623, -0x000055a2,0x000200f9,0x00005624,0x000200f8, -0x0000561e,0x000500c7,0x00000006,0x00005620, -0x000055a2,0x0000021d,0x000200f9,0x00005624, -0x000200f8,0x00005624,0x000700f5,0x00000006, -0x0000594c,0x00005620,0x0000561e,0x00005623, -0x00005621,0x0004007c,0x00000027,0x00005626, -0x0000594c,0x00060050,0x00000063,0x000055a4, -0x00005608,0x00005617,0x00005626,0x00050041, -0x00000009,0x000055a5,0x00005579,0x000002e4, -0x0004003d,0x00000006,0x000055a6,0x000055a5, -0x000500c7,0x00000006,0x0000562b,0x000055a6, -0x00000208,0x000500ab,0x0000002f,0x0000562c, -0x0000562b,0x0000012b,0x000300f7,0x00005633, -0x00000000,0x000400fa,0x0000562c,0x0000562d, -0x00005630,0x000200f8,0x00005630,0x000400c8, -0x00000006,0x00005632,0x000055a6,0x000200f9, -0x00005633,0x000200f8,0x0000562d,0x000500c7, -0x00000006,0x0000562f,0x000055a6,0x0000021d, -0x000200f9,0x00005633,0x000200f8,0x00005633, -0x000700f5,0x00000006,0x0000594d,0x0000562f, -0x0000562d,0x00005632,0x00005630,0x0004007c, -0x00000027,0x00005635,0x0000594d,0x00050041, -0x00000009,0x000055a8,0x00005579,0x000002ec, -0x0004003d,0x00000006,0x000055a9,0x000055a8, -0x000500c7,0x00000006,0x0000563a,0x000055a9, -0x00000208,0x000500ab,0x0000002f,0x0000563b, -0x0000563a,0x0000012b,0x000300f7,0x00005642, -0x00000000,0x000400fa,0x0000563b,0x0000563c, -0x0000563f,0x000200f8,0x0000563f,0x000400c8, -0x00000006,0x00005641,0x000055a9,0x000200f9, -0x00005642,0x000200f8,0x0000563c,0x000500c7, -0x00000006,0x0000563e,0x000055a9,0x0000021d, +0x0000540a,0x0000541a,0x00060041,0x0000016c, +0x00005402,0x0000540a,0x0000016b,0x0000016b, +0x0005003e,0x00005402,0x000053dc,0x00000002, +0x00000004,0x000200f9,0x00005131,0x000200f8, +0x00005131,0x000200f9,0x00005132,0x000200f8, +0x00005132,0x000700f5,0x0000006c,0x00005cf4, +0x000052d7,0x00005131,0x00005d1c,0x0000519d, +0x000700f5,0x0000006c,0x00005cf1,0x000052c4, +0x00005131,0x00005d18,0x0000519d,0x000700f5, +0x00000006,0x00005ced,0x00000138,0x00005131, +0x0000519f,0x0000519d,0x000700f5,0x00000006, +0x00005ceb,0x000053dc,0x00005131,0x000059fe, +0x0000519d,0x000700f5,0x00000006,0x00005d5e, +0x00005cea,0x00005131,0x00005ceb,0x0000519d, +0x000500ab,0x0000002f,0x00005135,0x00005ceb, +0x00000539,0x000500b0,0x0000002f,0x00005137, +0x00005ced,0x00000342,0x000500a7,0x0000002f, +0x00005138,0x00005135,0x00005137,0x000400f6, +0x000051a0,0x0000519d,0x00000000,0x000400fa, +0x00005138,0x00005139,0x000051a0,0x000200f8, +0x00005139,0x000500c2,0x00000006,0x0000541e, +0x00005ceb,0x0000031d,0x00050084,0x00000006, +0x0000513c,0x0000541e,0x000001c4,0x000200f9, +0x0000513d,0x000200f8,0x0000513d,0x000700f5, +0x00000006,0x00005d0a,0x00000138,0x00005139, +0x00006026,0x0000515b,0x000700f5,0x00000006, +0x00005cee,0x00000138,0x00005139,0x0000515d, +0x0000515b,0x000500b0,0x0000002f,0x00005140, +0x00005cee,0x000000ec,0x000400f6,0x0000515e, +0x0000515b,0x00000000,0x000400fa,0x00005140, +0x00005141,0x0000515e,0x000200f8,0x00005141, +0x00050084,0x00000006,0x00005144,0x000000ec, +0x00005cee,0x00050080,0x00000006,0x00005145, +0x0000513c,0x00005144,0x00050095,0x0000013d, +0x00005437,0x000053ea,0x00005145,0x00050051, +0x00000006,0x00005438,0x00005437,0x00000001, +0x00050051,0x00000006,0x00005439,0x00005437, +0x00000000,0x00050080,0x00000006,0x0000543e, +0x000053f1,0x00005438,0x00050050,0x00000007, +0x0000543f,0x00005439,0x0000543e,0x0004007c, +0x00000014,0x0000542f,0x0000543f,0x00060041, +0x0000016c,0x00005426,0x0000542f,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00005427, +0x00005426,0x00000002,0x00000004,0x000500aa, +0x0000002f,0x0000514a,0x00005427,0x00000539, +0x000300f7,0x0000514c,0x00000000,0x000400fa, +0x0000514a,0x0000514b,0x0000514c,0x000200f8, +0x0000514b,0x000200f9,0x0000515b,0x000200f8, +0x0000514c,0x00050080,0x00000006,0x0000514e, +0x00005d0a,0x00000264,0x000500aa,0x0000002f, +0x00005151,0x00005427,0x00005d5e,0x000300f7, +0x0000515a,0x00000000,0x000400fa,0x00005151, +0x00005152,0x0000515a,0x000200f8,0x00005152, +0x000500c7,0x00000006,0x00005443,0x00005ceb, +0x00000d2b,0x000500aa,0x0000002f,0x00005444, +0x00005443,0x000000ec,0x000300f7,0x00005497, +0x00000000,0x000300fb,0x00000138,0x0000545d, +0x000200f8,0x0000545d,0x000300f7,0x00005468, +0x00000000,0x000400fa,0x00005444,0x0000545f, +0x00005468,0x000200f8,0x0000545f,0x00050080, +0x00000006,0x00005461,0x0000513c,0x000001db, +0x00050084,0x00000006,0x00005463,0x000001d4, +0x00005cee,0x00050080,0x00000006,0x00005464, +0x00005461,0x00005463,0x00050051,0x00000027, +0x000054af,0x00005cf1,0x00000000,0x000300f7, +0x00005526,0x00000000,0x000300fb,0x00000138, +0x000054e0,0x000200f8,0x000054e0,0x0004007c, +0x00000006,0x000054e2,0x000054af,0x000500c2, +0x00000006,0x000054e4,0x000054e2,0x0000035a, +0x000500c7,0x00000006,0x000054e5,0x000054e4, +0x00000373,0x000500c7,0x00000006,0x000054e7, +0x000054e2,0x00000256,0x000500ab,0x0000002f, +0x000054ea,0x000054e5,0x00000138,0x000500ac, +0x0000002f,0x000054ed,0x000054e7,0x0000037e, +0x000300f7,0x000054f1,0x00000000,0x000400fa, +0x000054ed,0x000054ee,0x000054f1,0x000200f8, +0x000054ee,0x000500c5,0x00000006,0x000054f0, +0x000054e5,0x00000383,0x000200f9,0x00005526, +0x000200f8,0x000054f1,0x000500aa,0x0000002f, +0x000054f3,0x000054e7,0x00000138,0x000300f7, +0x000054f6,0x00000000,0x000400fa,0x000054f3, +0x000054f4,0x000054f6,0x000200f8,0x000054f4, +0x000200f9,0x00005526,0x000200f8,0x000054f6, +0x000500c2,0x00000006,0x000054f8,0x000054e7, +0x0000038e,0x0004007c,0x000000f4,0x000054f9, +0x000054f8,0x00050082,0x000000f4,0x000054fa, +0x000054f9,0x00000391,0x000500af,0x0000002f, +0x000054fc,0x000054fa,0x0000035a,0x000300f7, +0x00005502,0x00000000,0x000400fa,0x000054fc, +0x000054fd,0x00005502,0x000200f8,0x000054fd, +0x000600a9,0x00000006,0x00005500,0x000054ea, +0x00000399,0x0000039a,0x000500c5,0x00000006, +0x00005501,0x000054e5,0x00005500,0x000200f9, +0x00005526,0x000200f8,0x00005502,0x000500b1, +0x0000002f,0x00005504,0x000054fa,0x0000039f, +0x000300f7,0x0000550e,0x00000000,0x000400fa, +0x00005504,0x00005505,0x0000550e,0x000200f8, +0x00005505,0x000300f7,0x0000550c,0x00000000, +0x000400fa,0x000054ea,0x00005507,0x0000550a, +0x000200f8,0x0000550a,0x000200f9,0x0000550c, +0x000200f8,0x00005507,0x000500c5,0x00000006, +0x00005509,0x000054e5,0x000003a8,0x000200f9, +0x0000550c,0x000200f8,0x0000550c,0x000700f5, +0x00000006,0x00005d62,0x00005509,0x00005507, +0x000054e5,0x0000550a,0x000200f9,0x00005526, +0x000200f8,0x0000550e,0x000500c7,0x00000006, +0x00005510,0x000054e2,0x000003b0,0x00050080, +0x000000f4,0x00005512,0x000054f9,0x000060ff, +0x0004007c,0x00000006,0x00005513,0x00005512, +0x000500c4,0x00000006,0x00005514,0x00005513, +0x000003b6,0x000500c2,0x00000006,0x00005516, +0x00005510,0x000001f0,0x000500c5,0x00000006, +0x00005517,0x00005514,0x00005516,0x000300f7, +0x0000551d,0x00000000,0x000400fa,0x000054ea, +0x00005519,0x0000551d,0x000200f8,0x00005519, +0x000500c7,0x00000006,0x0000551b,0x000054e2, +0x000003bf,0x000500ab,0x0000002f,0x0000551c, +0x0000551b,0x00000138,0x000200f9,0x0000551d, +0x000200f8,0x0000551d,0x000700f5,0x0000002f, +0x0000551e,0x000054ea,0x0000550e,0x0000551c, +0x00005519,0x000300f7,0x00005522,0x00000000, +0x000400fa,0x0000551e,0x0000551f,0x00005522, +0x000200f8,0x0000551f,0x00050080,0x00000006, +0x00005521,0x00005517,0x00000142,0x000200f9, +0x00005522,0x000200f8,0x00005522,0x000700f5, +0x00000006,0x00005d61,0x00005517,0x0000551d, +0x00005521,0x0000551f,0x000500c5,0x00000006, +0x00005525,0x000054e5,0x00005d61,0x000200f9, +0x00005526,0x000200f8,0x00005526,0x000d00f5, +0x00000006,0x00005d63,0x000054f0,0x000054ee, +0x000054e5,0x000054f4,0x00005501,0x000054fd, +0x00005d62,0x0000550c,0x00005525,0x00005522, +0x00050051,0x00000027,0x000054b2,0x00005cf1, +0x00000001,0x000300f7,0x0000557a,0x00000000, +0x000300fb,0x00000138,0x00005534,0x000200f8, +0x00005534,0x0004007c,0x00000006,0x00005536, +0x000054b2,0x000500c2,0x00000006,0x00005538, +0x00005536,0x0000035a,0x000500c7,0x00000006, +0x00005539,0x00005538,0x00000373,0x000500c7, +0x00000006,0x0000553b,0x00005536,0x00000256, +0x000500ab,0x0000002f,0x0000553e,0x00005539, +0x00000138,0x000500ac,0x0000002f,0x00005541, +0x0000553b,0x0000037e,0x000300f7,0x00005545, +0x00000000,0x000400fa,0x00005541,0x00005542, +0x00005545,0x000200f8,0x00005542,0x000500c5, +0x00000006,0x00005544,0x00005539,0x00000383, +0x000200f9,0x0000557a,0x000200f8,0x00005545, +0x000500aa,0x0000002f,0x00005547,0x0000553b, +0x00000138,0x000300f7,0x0000554a,0x00000000, +0x000400fa,0x00005547,0x00005548,0x0000554a, +0x000200f8,0x00005548,0x000200f9,0x0000557a, +0x000200f8,0x0000554a,0x000500c2,0x00000006, +0x0000554c,0x0000553b,0x0000038e,0x0004007c, +0x000000f4,0x0000554d,0x0000554c,0x00050082, +0x000000f4,0x0000554e,0x0000554d,0x00000391, +0x000500af,0x0000002f,0x00005550,0x0000554e, +0x0000035a,0x000300f7,0x00005556,0x00000000, +0x000400fa,0x00005550,0x00005551,0x00005556, +0x000200f8,0x00005551,0x000600a9,0x00000006, +0x00005554,0x0000553e,0x00000399,0x0000039a, +0x000500c5,0x00000006,0x00005555,0x00005539, +0x00005554,0x000200f9,0x0000557a,0x000200f8, +0x00005556,0x000500b1,0x0000002f,0x00005558, +0x0000554e,0x0000039f,0x000300f7,0x00005562, +0x00000000,0x000400fa,0x00005558,0x00005559, +0x00005562,0x000200f8,0x00005559,0x000300f7, +0x00005560,0x00000000,0x000400fa,0x0000553e, +0x0000555b,0x0000555e,0x000200f8,0x0000555e, +0x000200f9,0x00005560,0x000200f8,0x0000555b, +0x000500c5,0x00000006,0x0000555d,0x00005539, +0x000003a8,0x000200f9,0x00005560,0x000200f8, +0x00005560,0x000700f5,0x00000006,0x00005d66, +0x0000555d,0x0000555b,0x00005539,0x0000555e, +0x000200f9,0x0000557a,0x000200f8,0x00005562, +0x000500c7,0x00000006,0x00005564,0x00005536, +0x000003b0,0x00050080,0x000000f4,0x00005566, +0x0000554d,0x000060ff,0x0004007c,0x00000006, +0x00005567,0x00005566,0x000500c4,0x00000006, +0x00005568,0x00005567,0x000003b6,0x000500c2, +0x00000006,0x0000556a,0x00005564,0x000001f0, +0x000500c5,0x00000006,0x0000556b,0x00005568, +0x0000556a,0x000300f7,0x00005571,0x00000000, +0x000400fa,0x0000553e,0x0000556d,0x00005571, +0x000200f8,0x0000556d,0x000500c7,0x00000006, +0x0000556f,0x00005536,0x000003bf,0x000500ab, +0x0000002f,0x00005570,0x0000556f,0x00000138, +0x000200f9,0x00005571,0x000200f8,0x00005571, +0x000700f5,0x0000002f,0x00005572,0x0000553e, +0x00005562,0x00005570,0x0000556d,0x000300f7, +0x00005576,0x00000000,0x000400fa,0x00005572, +0x00005573,0x00005576,0x000200f8,0x00005573, +0x00050080,0x00000006,0x00005575,0x0000556b, +0x00000142,0x000200f9,0x00005576,0x000200f8, +0x00005576,0x000700f5,0x00000006,0x00005d65, +0x0000556b,0x00005571,0x00005575,0x00005573, +0x000500c5,0x00000006,0x00005579,0x00005539, +0x00005d65,0x000200f9,0x0000557a,0x000200f8, +0x0000557a,0x000d00f5,0x00000006,0x00005d67, +0x00005544,0x00005542,0x00005539,0x00005548, +0x00005555,0x00005551,0x00005d66,0x00005560, +0x00005579,0x00005576,0x000500c4,0x00000006, +0x000054b4,0x00005d67,0x0000035a,0x000500c5, +0x00000006,0x000054b5,0x00005d63,0x000054b4, +0x00050095,0x0000013d,0x00005593,0x000053ea, +0x00005464,0x00050051,0x00000006,0x00005594, +0x00005593,0x00000001,0x00050051,0x00000006, +0x00005595,0x00005593,0x00000000,0x00050080, +0x00000006,0x0000559a,0x000053f1,0x00005594, +0x00050050,0x00000007,0x0000559b,0x00005595, +0x0000559a,0x0004007c,0x00000014,0x0000558b, +0x0000559b,0x00060041,0x0000016c,0x00005583, +0x0000558b,0x0000016b,0x0000016b,0x0005003e, +0x00005583,0x000054b5,0x00000002,0x00000004, +0x00050080,0x00000006,0x000054bb,0x00005464, +0x000000ec,0x00050051,0x00000027,0x000054bd, +0x00005cf1,0x00000002,0x000300f7,0x000055ee, +0x00000000,0x000300fb,0x00000138,0x000055a8, +0x000200f8,0x000055a8,0x0004007c,0x00000006, +0x000055aa,0x000054bd,0x000500c2,0x00000006, +0x000055ac,0x000055aa,0x0000035a,0x000500c7, +0x00000006,0x000055ad,0x000055ac,0x00000373, +0x000500c7,0x00000006,0x000055af,0x000055aa, +0x00000256,0x000500ab,0x0000002f,0x000055b2, +0x000055ad,0x00000138,0x000500ac,0x0000002f, +0x000055b5,0x000055af,0x0000037e,0x000300f7, +0x000055b9,0x00000000,0x000400fa,0x000055b5, +0x000055b6,0x000055b9,0x000200f8,0x000055b6, +0x000500c5,0x00000006,0x000055b8,0x000055ad, +0x00000383,0x000200f9,0x000055ee,0x000200f8, +0x000055b9,0x000500aa,0x0000002f,0x000055bb, +0x000055af,0x00000138,0x000300f7,0x000055be, +0x00000000,0x000400fa,0x000055bb,0x000055bc, +0x000055be,0x000200f8,0x000055bc,0x000200f9, +0x000055ee,0x000200f8,0x000055be,0x000500c2, +0x00000006,0x000055c0,0x000055af,0x0000038e, +0x0004007c,0x000000f4,0x000055c1,0x000055c0, +0x00050082,0x000000f4,0x000055c2,0x000055c1, +0x00000391,0x000500af,0x0000002f,0x000055c4, +0x000055c2,0x0000035a,0x000300f7,0x000055ca, +0x00000000,0x000400fa,0x000055c4,0x000055c5, +0x000055ca,0x000200f8,0x000055c5,0x000600a9, +0x00000006,0x000055c8,0x000055b2,0x00000399, +0x0000039a,0x000500c5,0x00000006,0x000055c9, +0x000055ad,0x000055c8,0x000200f9,0x000055ee, +0x000200f8,0x000055ca,0x000500b1,0x0000002f, +0x000055cc,0x000055c2,0x0000039f,0x000300f7, +0x000055d6,0x00000000,0x000400fa,0x000055cc, +0x000055cd,0x000055d6,0x000200f8,0x000055cd, +0x000300f7,0x000055d4,0x00000000,0x000400fa, +0x000055b2,0x000055cf,0x000055d2,0x000200f8, +0x000055d2,0x000200f9,0x000055d4,0x000200f8, +0x000055cf,0x000500c5,0x00000006,0x000055d1, +0x000055ad,0x000003a8,0x000200f9,0x000055d4, +0x000200f8,0x000055d4,0x000700f5,0x00000006, +0x00005d6a,0x000055d1,0x000055cf,0x000055ad, +0x000055d2,0x000200f9,0x000055ee,0x000200f8, +0x000055d6,0x000500c7,0x00000006,0x000055d8, +0x000055aa,0x000003b0,0x00050080,0x000000f4, +0x000055da,0x000055c1,0x000060ff,0x0004007c, +0x00000006,0x000055db,0x000055da,0x000500c4, +0x00000006,0x000055dc,0x000055db,0x000003b6, +0x000500c2,0x00000006,0x000055de,0x000055d8, +0x000001f0,0x000500c5,0x00000006,0x000055df, +0x000055dc,0x000055de,0x000300f7,0x000055e5, +0x00000000,0x000400fa,0x000055b2,0x000055e1, +0x000055e5,0x000200f8,0x000055e1,0x000500c7, +0x00000006,0x000055e3,0x000055aa,0x000003bf, +0x000500ab,0x0000002f,0x000055e4,0x000055e3, +0x00000138,0x000200f9,0x000055e5,0x000200f8, +0x000055e5,0x000700f5,0x0000002f,0x000055e6, +0x000055b2,0x000055d6,0x000055e4,0x000055e1, +0x000300f7,0x000055ea,0x00000000,0x000400fa, +0x000055e6,0x000055e7,0x000055ea,0x000200f8, +0x000055e7,0x00050080,0x00000006,0x000055e9, +0x000055df,0x00000142,0x000200f9,0x000055ea, +0x000200f8,0x000055ea,0x000700f5,0x00000006, +0x00005d69,0x000055df,0x000055e5,0x000055e9, +0x000055e7,0x000500c5,0x00000006,0x000055ed, +0x000055ad,0x00005d69,0x000200f9,0x000055ee, +0x000200f8,0x000055ee,0x000d00f5,0x00000006, +0x00005d6b,0x000055b8,0x000055b6,0x000055ad, +0x000055bc,0x000055c9,0x000055c5,0x00005d6a, +0x000055d4,0x000055ed,0x000055ea,0x00050051, +0x00000027,0x000054c0,0x00005cf4,0x00000000, +0x000300f7,0x00005642,0x00000000,0x000300fb, +0x00000138,0x000055fc,0x000200f8,0x000055fc, +0x0004007c,0x00000006,0x000055fe,0x000054c0, +0x000500c2,0x00000006,0x00005600,0x000055fe, +0x0000035a,0x000500c7,0x00000006,0x00005601, +0x00005600,0x00000373,0x000500c7,0x00000006, +0x00005603,0x000055fe,0x00000256,0x000500aa, +0x0000002f,0x00005607,0x00005601,0x00000138, +0x000500ac,0x0000002f,0x00005609,0x00005603, +0x0000037e,0x000300f7,0x0000560d,0x00000000, +0x000400fa,0x00005609,0x0000560a,0x0000560d, +0x000200f8,0x0000560a,0x000500c5,0x00000006, +0x0000560c,0x00005601,0x00000383,0x000200f9, +0x00005642,0x000200f8,0x0000560d,0x000500aa, +0x0000002f,0x0000560f,0x00005603,0x00000138, +0x000300f7,0x00005612,0x00000000,0x000400fa, +0x0000560f,0x00005610,0x00005612,0x000200f8, +0x00005610,0x000200f9,0x00005642,0x000200f8, +0x00005612,0x000500c2,0x00000006,0x00005614, +0x00005603,0x0000038e,0x0004007c,0x000000f4, +0x00005615,0x00005614,0x00050082,0x000000f4, +0x00005616,0x00005615,0x00000391,0x000500af, +0x0000002f,0x00005618,0x00005616,0x0000035a, +0x000300f7,0x0000561e,0x00000000,0x000400fa, +0x00005618,0x00005619,0x0000561e,0x000200f8, +0x00005619,0x000600a9,0x00000006,0x0000561c, +0x00005607,0x00000399,0x0000039a,0x000500c5, +0x00000006,0x0000561d,0x00005601,0x0000561c, +0x000200f9,0x00005642,0x000200f8,0x0000561e, +0x000500b1,0x0000002f,0x00005620,0x00005616, +0x0000039f,0x000300f7,0x0000562a,0x00000000, +0x000400fa,0x00005620,0x00005621,0x0000562a, +0x000200f8,0x00005621,0x000300f7,0x00005628, +0x00000000,0x000400fa,0x00005607,0x00005623, +0x00005626,0x000200f8,0x00005626,0x000200f9, +0x00005628,0x000200f8,0x00005623,0x000500c5, +0x00000006,0x00005625,0x00005601,0x000003a8, +0x000200f9,0x00005628,0x000200f8,0x00005628, +0x000700f5,0x00000006,0x00005d6e,0x00005625, +0x00005623,0x00005601,0x00005626,0x000200f9, +0x00005642,0x000200f8,0x0000562a,0x000500c7, +0x00000006,0x0000562c,0x000055fe,0x000003b0, +0x00050080,0x000000f4,0x0000562e,0x00005615, +0x000060ff,0x0004007c,0x00000006,0x0000562f, +0x0000562e,0x000500c4,0x00000006,0x00005630, +0x0000562f,0x000003b6,0x000500c2,0x00000006, +0x00005632,0x0000562c,0x000001f0,0x000500c5, +0x00000006,0x00005633,0x00005630,0x00005632, +0x000300f7,0x00005639,0x00000000,0x000400fa, +0x00005607,0x00005635,0x00005639,0x000200f8, +0x00005635,0x000500c7,0x00000006,0x00005637, +0x000055fe,0x000003bf,0x000500ab,0x0000002f, +0x00005638,0x00005637,0x00000138,0x000200f9, +0x00005639,0x000200f8,0x00005639,0x000700f5, +0x0000002f,0x0000563a,0x00005607,0x0000562a, +0x00005638,0x00005635,0x000300f7,0x0000563e, +0x00000000,0x000400fa,0x0000563a,0x0000563b, +0x0000563e,0x000200f8,0x0000563b,0x00050080, +0x00000006,0x0000563d,0x00005633,0x00000142, +0x000200f9,0x0000563e,0x000200f8,0x0000563e, +0x000700f5,0x00000006,0x00005d6d,0x00005633, +0x00005639,0x0000563d,0x0000563b,0x000500c5, +0x00000006,0x00005641,0x00005601,0x00005d6d, 0x000200f9,0x00005642,0x000200f8,0x00005642, -0x000700f5,0x00000006,0x0000594e,0x0000563e, -0x0000563c,0x00005641,0x0000563f,0x0004007c, -0x00000027,0x00005644,0x0000594e,0x00050041, -0x00000009,0x000055ab,0x00005579,0x000002f4, -0x0004003d,0x00000006,0x000055ac,0x000055ab, -0x000500c7,0x00000006,0x00005649,0x000055ac, -0x00000208,0x000500ab,0x0000002f,0x0000564a, -0x00005649,0x0000012b,0x000300f7,0x00005651, -0x00000000,0x000400fa,0x0000564a,0x0000564b, -0x0000564e,0x000200f8,0x0000564e,0x000400c8, -0x00000006,0x00005650,0x000055ac,0x000200f9, -0x00005651,0x000200f8,0x0000564b,0x000500c7, -0x00000006,0x0000564d,0x000055ac,0x0000021d, -0x000200f9,0x00005651,0x000200f8,0x00005651, -0x000700f5,0x00000006,0x0000594f,0x0000564d, -0x0000564b,0x00005650,0x0000564e,0x0004007c, -0x00000027,0x00005653,0x0000594f,0x00060050, -0x00000063,0x000055ae,0x00005635,0x00005644, -0x00005653,0x000200f9,0x000055af,0x000200f8, -0x000055af,0x000700f5,0x00000063,0x00005954, -0x00005cc2,0x00005597,0x000055ae,0x00005651, -0x000700f5,0x00000063,0x00005950,0x0000053d, -0x00005597,0x000055a4,0x00005651,0x00050082, -0x00000006,0x00005660,0x00005092,0x0000503d, -0x00050084,0x00000006,0x00005661,0x000000df, -0x00005660,0x00050080,0x00000006,0x00005662, -0x00005038,0x00005661,0x00050095,0x00000130, -0x00005682,0x0000505e,0x00005662,0x00050051, -0x00000006,0x00005683,0x00005682,0x00000001, -0x00050051,0x00000006,0x00005684,0x00005682, -0x00000000,0x00050080,0x00000006,0x00005689, -0x00005065,0x00005683,0x00050050,0x00000007, -0x0000568a,0x00005684,0x00005689,0x0004007c, -0x00000014,0x0000567a,0x0000568a,0x00060041, -0x0000015f,0x00005671,0x0000567a,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00005672, -0x00005671,0x00000002,0x00000004,0x000200f9, -0x00004e11,0x000200f8,0x00004e11,0x00050080, -0x00000006,0x00004e13,0x00005925,0x0000022b, -0x000200f9,0x00004da6,0x000200f8,0x00004e14, -0x000700f5,0x0000002f,0x00005978,0x00000393, -0x00004da6,0x000003ae,0x00004e08,0x000300f7, -0x00004e16,0x00000000,0x000400fa,0x00005978, -0x00004e17,0x00004e16,0x000200f8,0x00004e16, -0x000200f9,0x00004e17,0x000200f8,0x00004e17, -0x000200f9,0x000012ee,0x000200f8,0x000012ee, -0x000200f9,0x000012e4,0x000200f8,0x000012e3, -0x000300f7,0x00003d8d,0x00000000,0x000300fb, -0x0000012b,0x00003c9f,0x000200f8,0x00003c9f, -0x0003003e,0x00003c67,0x00000ed6,0x0003003e, -0x00003c68,0x00000ed6,0x00050041,0x00000182, -0x00003ca0,0x00000180,0x000001b7,0x0004003d, -0x00000006,0x00003ca1,0x00003ca0,0x000500b2, -0x0000002f,0x00003ca2,0x00003ca1,0x00000135, -0x000300f7,0x00003d22,0x00000000,0x000400fa, -0x00003ca2,0x00003ca3,0x00003cb2,0x000200f8, -0x00003cb2,0x00050041,0x00000182,0x00003e00, -0x00000180,0x00000181,0x0004003d,0x00000006, -0x00003e01,0x00003e00,0x00050084,0x00000006, -0x00003e02,0x000001a2,0x00003e01,0x00050080, -0x00000006,0x00003e03,0x0000018b,0x00003e02, -0x00050080,0x00000006,0x00003e09,0x00003e01, -0x00005cc3,0x00050086,0x00000006,0x00003e0a, -0x00003e09,0x00000185,0x00050084,0x00000006, -0x00003dfc,0x0000018b,0x00003e0a,0x00050080, -0x00000006,0x00003dfd,0x00003e03,0x00003dfc, -0x00050080,0x00000006,0x00003df7,0x00003dfd, -0x00003dfc,0x00050084,0x00000006,0x00003df0, -0x000001b6,0x00003ca1,0x00050080,0x00000006, -0x00003df1,0x00003df7,0x00003df0,0x00050041, -0x00000182,0x00003de7,0x00000180,0x000001cd, -0x0004003d,0x00000006,0x00003de8,0x00003de7, -0x00050084,0x00000006,0x00003de9,0x000001cc, -0x00003de8,0x00050080,0x00000006,0x00003dea, -0x00003df1,0x00003de9,0x000500ac,0x0000002f, -0x00003e17,0x00003ca1,0x00000135,0x000300f7, -0x00003e1d,0x00000000,0x000400fa,0x00003e17, -0x00003e18,0x00003e1c,0x000200f8,0x00003e1c, -0x000200f9,0x00003e1d,0x000200f8,0x00003e18, -0x00050082,0x00000006,0x00003e1b,0x00003ca1, -0x00000135,0x000200f9,0x00003e1d,0x000200f8, -0x00003e1d,0x000700f5,0x00000006,0x000059cb, -0x00003e1b,0x00003e18,0x0000012b,0x00003e1c, -0x00050084,0x00000006,0x00003de2,0x000000df, -0x000059cb,0x00050080,0x00000006,0x00003de3, -0x00003dea,0x00003de2,0x000300f7,0x00003e2a, -0x00000000,0x000400fa,0x00003e17,0x00003e25, -0x00003e29,0x000200f8,0x00003e29,0x000200f9, -0x00003e2a,0x000200f8,0x00003e25,0x00050082, -0x00000006,0x00003e28,0x00003ca1,0x00000135, -0x000200f9,0x00003e2a,0x000200f8,0x00003e2a, -0x000700f5,0x00000006,0x000059cc,0x00003e28, -0x00003e25,0x0000012b,0x00003e29,0x00050084, -0x00000006,0x00003ddc,0x000000df,0x000059cc, -0x00050080,0x00000006,0x00003ddd,0x00003de3, -0x00003ddc,0x000300f7,0x00003e37,0x00000000, -0x000400fa,0x00003e17,0x00003e32,0x00003e36, -0x000200f8,0x00003e36,0x000200f9,0x00003e37, -0x000200f8,0x00003e32,0x00050082,0x00000006, -0x00003e35,0x00003ca1,0x00000135,0x000200f9, -0x00003e37,0x000200f8,0x00003e37,0x000700f5, -0x00000006,0x000059cd,0x00003e35,0x00003e32, -0x0000012b,0x00003e36,0x00050084,0x00000006, -0x00003dd6,0x000000df,0x000059cd,0x00050080, -0x00000006,0x00003dd7,0x00003ddd,0x00003dd6, -0x00050084,0x00000006,0x00003cb5,0x000000df, -0x000011de,0x00050080,0x00000006,0x00003cb6, -0x00003dd7,0x00003cb5,0x00050041,0x0000022d, -0x00003cb7,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00003cb8,0x00003cb7,0x00050051, -0x00000006,0x00003e4f,0x00003cb8,0x00000000, -0x00050095,0x00000130,0x00003e51,0x00003e4f, -0x00003cb6,0x00050051,0x00000006,0x00003e52, -0x00003e51,0x00000001,0x00050051,0x00000006, -0x00003e53,0x00003e51,0x00000000,0x00050051, -0x00000006,0x00003e56,0x00003cb8,0x00000001, -0x00050080,0x00000006,0x00003e58,0x00003e56, -0x00003e52,0x00050050,0x00000007,0x00003e59, -0x00003e53,0x00003e58,0x0004007c,0x00000014, -0x00003e49,0x00003e59,0x00060041,0x0000015f, -0x00003e40,0x00003e49,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00003e41,0x00003e40, -0x00000002,0x00000004,0x000500aa,0x0000002f, -0x00003cba,0x00003e41,0x0000012b,0x000300f7, -0x00003cbc,0x00000000,0x000400fa,0x00003cba, -0x00003cbb,0x00003cbc,0x000200f8,0x00003cbb, -0x000200f9,0x00003d8d,0x000200f8,0x00003cbc, -0x000300f7,0x00003eab,0x00000000,0x000400fa, -0x00003e17,0x00003ea6,0x00003eaa,0x000200f8, -0x00003eaa,0x000200f9,0x00003eab,0x000200f8, -0x00003ea6,0x00050082,0x00000006,0x00003ea9, -0x00003ca1,0x00000135,0x000200f9,0x00003eab, -0x000200f8,0x00003eab,0x000700f5,0x00000006, -0x000059ce,0x00003ea9,0x00003ea6,0x0000012b, -0x00003eaa,0x00050084,0x00000006,0x00003e70, -0x000000df,0x000059ce,0x00050080,0x00000006, -0x00003e71,0x00003dea,0x00003e70,0x000300f7, -0x00003eb8,0x00000000,0x000400fa,0x00003e17, -0x00003eb3,0x00003eb7,0x000200f8,0x00003eb7, -0x000200f9,0x00003eb8,0x000200f8,0x00003eb3, -0x00050082,0x00000006,0x00003eb6,0x00003ca1, -0x00000135,0x000200f9,0x00003eb8,0x000200f8, -0x00003eb8,0x000700f5,0x00000006,0x000059cf, -0x00003eb6,0x00003eb3,0x0000012b,0x00003eb7, -0x00050084,0x00000006,0x00003e6a,0x000000df, -0x000059cf,0x00050080,0x00000006,0x00003e6b, -0x00003e71,0x00003e6a,0x000300f7,0x00003ec5, -0x00000000,0x000400fa,0x00003e17,0x00003ec0, -0x00003ec4,0x000200f8,0x00003ec4,0x000200f9, -0x00003ec5,0x000200f8,0x00003ec0,0x00050082, -0x00000006,0x00003ec3,0x00003ca1,0x00000135, -0x000200f9,0x00003ec5,0x000200f8,0x00003ec5, -0x000700f5,0x00000006,0x000059d0,0x00003ec3, -0x00003ec0,0x0000012b,0x00003ec4,0x00050084, -0x00000006,0x00003e64,0x000000df,0x000059d0, -0x00050080,0x00000006,0x00003e65,0x00003e6b, -0x00003e64,0x000300f7,0x00003ed2,0x00000000, -0x000400fa,0x00003e17,0x00003ecd,0x00003ed1, -0x000200f8,0x00003ed1,0x000200f9,0x00003ed2, -0x000200f8,0x00003ecd,0x00050082,0x00000006, -0x00003ed0,0x00003ca1,0x00000135,0x000200f9, -0x00003ed2,0x000200f8,0x00003ed2,0x000700f5, -0x00000006,0x000059d1,0x00003ed0,0x00003ecd, -0x0000012b,0x00003ed1,0x00050084,0x00000006, -0x00003e5e,0x000000df,0x000059d1,0x00050080, -0x00000006,0x00003e5f,0x00003e65,0x00003e5e, -0x00050080,0x00000006,0x00003cc0,0x00003e5f, -0x00003cb5,0x00050095,0x00000130,0x00003eec, -0x00003e4f,0x00003cc0,0x00050051,0x00000006, -0x00003eed,0x00003eec,0x00000001,0x00050051, -0x00000006,0x00003eee,0x00003eec,0x00000000, -0x00050080,0x00000006,0x00003ef3,0x00003e56, -0x00003eed,0x00050050,0x00000007,0x00003ef4, -0x00003eee,0x00003ef3,0x0004007c,0x00000014, -0x00003ee4,0x00003ef4,0x00060041,0x0000015f, -0x00003edb,0x00003ee4,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00003edc,0x00003edb, -0x00000002,0x00000004,0x000500ae,0x0000002f, -0x00003cc7,0x00003edc,0x00003de8,0x000300f7, -0x00003cc9,0x00000000,0x000400fa,0x00003cc7, -0x00003cc8,0x00003cc9,0x000200f8,0x00003cc8, -0x000200f9,0x00003d8d,0x000200f8,0x00003cc9, -0x00050080,0x00000006,0x00003ccd,0x00003dea, -0x00003cb5,0x00050095,0x00000130,0x00003f3b, -0x00003e4f,0x00003ccd,0x00050051,0x00000006, -0x00003f3c,0x00003f3b,0x00000001,0x00050051, -0x00000006,0x00003f3d,0x00003f3b,0x00000000, -0x00050080,0x00000006,0x00003f42,0x00003e56, -0x00003f3c,0x00050050,0x00000007,0x00003f43, -0x00003f3d,0x00003f42,0x0004007c,0x00000014, -0x00003f33,0x00003f43,0x00060041,0x0000015f, -0x00003f2a,0x00003f33,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00003f2b,0x00003f2a, -0x00000002,0x00000004,0x000300f7,0x00003f83, -0x00000000,0x000400fa,0x00003e17,0x00003f7e, -0x00003f82,0x000200f8,0x00003f82,0x000200f9, -0x00003f83,0x000200f8,0x00003f7e,0x00050082, -0x00000006,0x00003f81,0x00003ca1,0x00000135, -0x000200f9,0x00003f83,0x000200f8,0x00003f83, -0x000700f5,0x00000006,0x000059d2,0x00003f81, -0x00003f7e,0x0000012b,0x00003f82,0x00050084, -0x00000006,0x00003f48,0x000000df,0x000059d2, -0x00050080,0x00000006,0x00003f49,0x00003dea, -0x00003f48,0x00050080,0x00000006,0x00003cd4, -0x00003f49,0x00003cb5,0x00050095,0x00000130, -0x00003f9d,0x00003e4f,0x00003cd4,0x00050051, -0x00000006,0x00003f9e,0x00003f9d,0x00000001, -0x00050051,0x00000006,0x00003f9f,0x00003f9d, -0x00000000,0x00050080,0x00000006,0x00003fa4, -0x00003e56,0x00003f9e,0x00050050,0x00000007, -0x00003fa5,0x00003f9f,0x00003fa4,0x0004007c, -0x00000014,0x00003f95,0x00003fa5,0x00060041, -0x0000015f,0x00003f8c,0x00003f95,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003f8d, -0x00003f8c,0x00000002,0x00000004,0x00050050, -0x00000f0e,0x00003cd8,0x00003f2b,0x00003f8d, -0x0003003e,0x00003c72,0x00003cd8,0x000200f9, -0x00003cd9,0x000200f8,0x00003cd9,0x000700f5, -0x00000006,0x000059d3,0x0000012b,0x00003f83, -0x00003d11,0x00003d0f,0x000700f5,0x00000006, -0x000059fc,0x0000012b,0x00003f83,0x000059fa, -0x00003d0f,0x000500b0,0x0000002f,0x00003cdc, -0x000059d3,0x00000247,0x000400f6,0x00003d12, -0x00003d0f,0x00000000,0x000400fa,0x00003cdc, -0x00003cdd,0x00003d12,0x000200f8,0x00003cdd, -0x00050041,0x00000009,0x00003cdf,0x00003c72, -0x000059d3,0x0004003d,0x00000006,0x00003ce0, -0x00003cdf,0x00050050,0x00000f0e,0x00003ce2, -0x00003ce0,0x00003ce0,0x0003003e,0x00003c79, -0x00003ce2,0x000500c7,0x00000006,0x00003ce4, -0x00003ce0,0x00000208,0x000500aa,0x0000002f, -0x00003ce5,0x00003ce4,0x0000012b,0x000300f7, -0x00003cf7,0x00000000,0x000400fa,0x00003ce5, -0x00003ce6,0x00003cf7,0x000200f8,0x00003ce6, -0x00050084,0x00000006,0x00003ce9,0x000000df, -0x00003ce0,0x00050080,0x00000006,0x00003cea, -0x00003dea,0x00003ce9,0x00050095,0x00000130, -0x00003fec,0x00003e4f,0x00003cea,0x00050051, -0x00000006,0x00003fed,0x00003fec,0x00000001, -0x00050051,0x00000006,0x00003fee,0x00003fec, -0x00000000,0x00050080,0x00000006,0x00003ff3, -0x00003e56,0x00003fed,0x00050050,0x00000007, -0x00003ff4,0x00003fee,0x00003ff3,0x0004007c, -0x00000014,0x00003fe4,0x00003ff4,0x00060041, -0x0000015f,0x00003fdb,0x00003fe4,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003fdc, -0x00003fdb,0x00000002,0x00000004,0x00050041, -0x00000009,0x00003cee,0x00003c79,0x0000015e, -0x0003003e,0x00003cee,0x00003fdc,0x000300f7, -0x00004034,0x00000000,0x000400fa,0x00003e17, -0x0000402f,0x00004033,0x000200f8,0x00004033, -0x000200f9,0x00004034,0x000200f8,0x0000402f, -0x00050082,0x00000006,0x00004032,0x00003ca1, -0x00000135,0x000200f9,0x00004034,0x000200f8, -0x00004034,0x000700f5,0x00000006,0x000059f3, -0x00004032,0x0000402f,0x0000012b,0x00004033, -0x00050084,0x00000006,0x00003ff9,0x000000df, -0x000059f3,0x00050080,0x00000006,0x00003ffa, -0x00003dea,0x00003ff9,0x00050080,0x00000006, -0x00003cf2,0x00003ffa,0x00003ce9,0x00050095, -0x00000130,0x0000404e,0x00003e4f,0x00003cf2, -0x00050051,0x00000006,0x0000404f,0x0000404e, -0x00000001,0x00050051,0x00000006,0x00004050, -0x0000404e,0x00000000,0x00050080,0x00000006, -0x00004055,0x00003e56,0x0000404f,0x00050050, -0x00000007,0x00004056,0x00004050,0x00004055, -0x0004007c,0x00000014,0x00004046,0x00004056, -0x00060041,0x0000015f,0x0000403d,0x00004046, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x0000403e,0x0000403d,0x00000002,0x00000004, -0x00050041,0x00000009,0x00003cf6,0x00003c79, -0x0000022b,0x0003003e,0x00003cf6,0x0000403e, -0x000200f9,0x00003cf7,0x000200f8,0x00003cf7, -0x000600a9,0x00000006,0x00005cdb,0x00003ce5, -0x00000247,0x00000135,0x000200f9,0x00003cf8, -0x000200f8,0x00003cf8,0x000700f5,0x00000006, -0x000059fa,0x000059fc,0x00003cf7,0x00003d05, -0x00003d0b,0x000700f5,0x00000006,0x000059f4, -0x0000012b,0x00003cf7,0x00003d0d,0x00003d0b, -0x000500b0,0x0000002f,0x00003cfc,0x000059f4, -0x00005cdb,0x000400f6,0x00003d0e,0x00003d0b, -0x00000000,0x000400fa,0x00003cfc,0x00003cfd, -0x00003d0e,0x000200f8,0x00003cfd,0x00050041, -0x00000009,0x00003d00,0x00003c79,0x000059f4, -0x0004003d,0x00000006,0x00003d01,0x00003d00, -0x000500c7,0x00000006,0x0000405d,0x00003d01, -0x00000208,0x000500ab,0x0000002f,0x0000405e, -0x0000405d,0x0000012b,0x000300f7,0x00004069, -0x00000000,0x000400fa,0x0000405e,0x0000405f, -0x00004068,0x000200f8,0x00004068,0x000200f9, -0x00004069,0x000200f8,0x0000405f,0x00050084, -0x00000006,0x0000406f,0x000000df,0x00003e01, -0x00050080,0x00000006,0x00004070,0x0000018b, -0x0000406f,0x000500c7,0x00000006,0x00004062, -0x00003d01,0x0000021d,0x00050084,0x00000006, -0x00004063,0x000000df,0x00004062,0x00050080, -0x00000006,0x00004064,0x00004070,0x00004063, -0x00050095,0x00000130,0x00004089,0x00003e4f, -0x00004064,0x00050051,0x00000006,0x0000408a, -0x00004089,0x00000001,0x00050051,0x00000006, -0x0000408b,0x00004089,0x00000000,0x00050080, -0x00000006,0x00004090,0x00003e56,0x0000408a, -0x00050050,0x00000007,0x00004091,0x0000408b, -0x00004090,0x0004007c,0x00000014,0x00004081, -0x00004091,0x00060041,0x0000015f,0x00004078, -0x00004081,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00004079,0x00004078,0x00000002, -0x00000004,0x000200f9,0x00004069,0x000200f8, -0x00004069,0x000700f5,0x00000006,0x000059ff, -0x00004079,0x0000405f,0x00000500,0x00004068, -0x00050041,0x00000009,0x00003d03,0x00003c68, -0x000059fa,0x0003003e,0x00003d03,0x000059ff, -0x00050080,0x00000006,0x00003d05,0x000059fa, -0x0000022b,0x0004003d,0x00000006,0x00003d08, -0x00003d00,0x000300f7,0x000040ac,0x00000000, -0x000300fb,0x0000012b,0x0000409b,0x000200f8, -0x0000409b,0x000500c7,0x00000006,0x0000409d, -0x00003d08,0x00000208,0x000500ab,0x0000002f, -0x0000409e,0x0000409d,0x0000012b,0x000300f7, -0x000040a3,0x00000000,0x000400fa,0x0000409e, -0x0000409f,0x000040a3,0x000200f8,0x0000409f, -0x000300f7,0x000040c0,0x00000000,0x000400fa, -0x0000409e,0x000040b6,0x000040bf,0x000200f8, -0x000040bf,0x000200f9,0x000040c0,0x000200f8, -0x000040b6,0x00050084,0x00000006,0x000040c6, -0x000000df,0x00003e01,0x00050080,0x00000006, -0x000040c7,0x0000018b,0x000040c6,0x000500c7, -0x00000006,0x000040b9,0x00003d08,0x0000021d, -0x00050084,0x00000006,0x000040ba,0x000000df, -0x000040b9,0x00050080,0x00000006,0x000040bb, -0x000040c7,0x000040ba,0x00050095,0x00000130, -0x000040e0,0x00003e4f,0x000040bb,0x00050051, -0x00000006,0x000040e1,0x000040e0,0x00000001, -0x00050051,0x00000006,0x000040e2,0x000040e0, -0x00000000,0x00050080,0x00000006,0x000040e7, -0x00003e56,0x000040e1,0x00050050,0x00000007, -0x000040e8,0x000040e2,0x000040e7,0x0004007c, -0x00000014,0x000040d8,0x000040e8,0x00060041, -0x0000015f,0x000040cf,0x000040d8,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000040d0, -0x000040cf,0x00000002,0x00000004,0x000200f9, -0x000040c0,0x000200f8,0x000040c0,0x000700f5, -0x00000006,0x00005a06,0x000040d0,0x000040b6, -0x00000500,0x000040bf,0x00050041,0x00000182, -0x000040eb,0x00000180,0x00000311,0x0004003d, -0x00000006,0x000040ec,0x000040eb,0x00050041, -0x00000182,0x000040fc,0x00000180,0x000002fb, -0x0004003d,0x00000006,0x000040fd,0x000040fc, -0x000500c7,0x00000006,0x000040fe,0x000040fd, -0x00000135,0x000500ab,0x0000002f,0x000040ff, -0x000040fe,0x0000012b,0x000600a9,0x00000006, -0x000040f9,0x000040ff,0x00000309,0x0000018b, -0x00050084,0x00000006,0x000040ef,0x00005a06, -0x000040f9,0x00050080,0x00000006,0x000040f0, -0x000040ec,0x000040ef,0x000500c2,0x00000006, -0x000040f1,0x000040f0,0x00000318,0x000500c4, -0x00000006,0x000040f2,0x000040f1,0x000002e4, -0x000600a9,0x00000006,0x000040f4,0x000040ff, -0x0000031c,0x0000012b,0x000500c5,0x00000006, -0x000040f5,0x000040f2,0x000040f4,0x000200f9, -0x000040ac,0x000200f8,0x000040a3,0x000300f7, -0x00004157,0x00000000,0x000400fa,0x00003e17, -0x00004152,0x00004156,0x000200f8,0x00004156, -0x000200f9,0x00004157,0x000200f8,0x00004152, -0x00050082,0x00000006,0x00004155,0x00003ca1, -0x00000135,0x000200f9,0x00004157,0x000200f8, -0x00004157,0x000700f5,0x00000006,0x00005a02, -0x00004155,0x00004152,0x0000012b,0x00004156, -0x00050084,0x00000006,0x0000411c,0x000000df, -0x00005a02,0x00050080,0x00000006,0x0000411d, -0x00003dea,0x0000411c,0x000300f7,0x00004164, -0x00000000,0x000400fa,0x00003e17,0x0000415f, -0x00004163,0x000200f8,0x00004163,0x000200f9, -0x00004164,0x000200f8,0x0000415f,0x00050082, -0x00000006,0x00004162,0x00003ca1,0x00000135, -0x000200f9,0x00004164,0x000200f8,0x00004164, -0x000700f5,0x00000006,0x00005a03,0x00004162, -0x0000415f,0x0000012b,0x00004163,0x00050084, -0x00000006,0x00004116,0x000000df,0x00005a03, -0x00050080,0x00000006,0x00004117,0x0000411d, -0x00004116,0x000300f7,0x00004171,0x00000000, -0x000400fa,0x00003e17,0x0000416c,0x00004170, -0x000200f8,0x00004170,0x000200f9,0x00004171, -0x000200f8,0x0000416c,0x00050082,0x00000006, -0x0000416f,0x00003ca1,0x00000135,0x000200f9, -0x00004171,0x000200f8,0x00004171,0x000700f5, -0x00000006,0x00005a04,0x0000416f,0x0000416c, -0x0000012b,0x00004170,0x00050084,0x00000006, -0x00004110,0x000000df,0x00005a04,0x00050080, -0x00000006,0x00004111,0x00004117,0x00004110, -0x000300f7,0x0000417e,0x00000000,0x000400fa, -0x00003e17,0x00004179,0x0000417d,0x000200f8, -0x0000417d,0x000200f9,0x0000417e,0x000200f8, -0x00004179,0x00050082,0x00000006,0x0000417c, -0x00003ca1,0x00000135,0x000200f9,0x0000417e, -0x000200f8,0x0000417e,0x000700f5,0x00000006, -0x00005a05,0x0000417c,0x00004179,0x0000012b, -0x0000417d,0x00050084,0x00000006,0x0000410a, -0x000000df,0x00005a05,0x00050080,0x00000006, -0x0000410b,0x00004111,0x0000410a,0x00050084, -0x00000006,0x000040a6,0x000000df,0x00003d08, -0x00050080,0x00000006,0x000040a7,0x0000410b, -0x000040a6,0x00050095,0x00000130,0x00004198, -0x00003e4f,0x000040a7,0x00050051,0x00000006, -0x00004199,0x00004198,0x00000001,0x00050051, -0x00000006,0x0000419a,0x00004198,0x00000000, -0x00050080,0x00000006,0x0000419f,0x00003e56, -0x00004199,0x00050050,0x00000007,0x000041a0, -0x0000419a,0x0000419f,0x0004007c,0x00000014, -0x00004190,0x000041a0,0x00060041,0x0000015f, -0x00004187,0x00004190,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004188,0x00004187, -0x00000002,0x00000004,0x00050041,0x00000182, -0x000041a3,0x00000180,0x00000321,0x0004003d, -0x00000006,0x000041a4,0x000041a3,0x00050041, -0x00000182,0x000041b4,0x00000180,0x000002fb, -0x0004003d,0x00000006,0x000041b5,0x000041b4, -0x000500c7,0x00000006,0x000041b6,0x000041b5, -0x00000247,0x000500ab,0x0000002f,0x000041b7, -0x000041b6,0x0000012b,0x000600a9,0x00000006, -0x000041b1,0x000041b7,0x0000018b,0x00000309, -0x00050084,0x00000006,0x000041a7,0x00004188, -0x000041b1,0x00050080,0x00000006,0x000041a8, -0x000041a4,0x000041a7,0x000500c2,0x00000006, -0x000041a9,0x000041a8,0x00000318,0x000500c4, -0x00000006,0x000041aa,0x000041a9,0x000002e4, -0x000600a9,0x00000006,0x000041ac,0x000041b7, -0x000000df,0x0000032b,0x000500c5,0x00000006, -0x000041ad,0x000041aa,0x000041ac,0x000200f9, -0x000040ac,0x000200f8,0x000040ac,0x000700f5, -0x00000006,0x00005a07,0x000040f5,0x000040c0, -0x000041ad,0x0000417e,0x00050041,0x00000009, -0x00003d0a,0x00003c67,0x000059fa,0x0003003e, -0x00003d0a,0x00005a07,0x000200f9,0x00003d0b, -0x000200f8,0x00003d0b,0x00050080,0x00000006, -0x00003d0d,0x000059f4,0x0000022b,0x000200f9, -0x00003cf8,0x000200f8,0x00003d0e,0x000200f9, -0x00003d0f,0x000200f8,0x00003d0f,0x00050080, -0x00000006,0x00003d11,0x000059d3,0x0000022b, -0x000200f9,0x00003cd9,0x000200f8,0x00003d12, -0x00050041,0x00000182,0x000041c0,0x00000180, -0x000002fb,0x0004003d,0x00000006,0x000041c1, -0x000041c0,0x000500c7,0x00000006,0x000041c2, -0x000041c1,0x00000135,0x000500aa,0x0000002f, -0x00003d14,0x000041c2,0x0000012b,0x000300f7, -0x00003d1a,0x00000000,0x000400fa,0x00003d14, -0x00003d15,0x00003d1a,0x000200f8,0x00003d15, -0x000500c7,0x00000006,0x00003d18,0x000041c1, -0x000000df,0x000500ab,0x0000002f,0x00003d19, -0x00003d18,0x0000012b,0x000200f9,0x00003d1a, -0x000200f8,0x00003d1a,0x000700f5,0x0000002f, -0x00003d1b,0x00003d14,0x00003d12,0x00003d19, -0x00003d15,0x000300f7,0x00003d21,0x00000000, -0x000400fa,0x00003d1b,0x00003d1c,0x00003d21, -0x000200f8,0x00003d1c,0x0004003d,0x000000e0, -0x00003d1d,0x00003c68,0x0003003e,0x00003c82, -0x00003d1d,0x0004003d,0x000000e0,0x00003d1e, -0x00003c67,0x0003003e,0x00003c83,0x00003d1e, -0x000200f9,0x000041f9,0x000200f8,0x000041f9, -0x000700f5,0x00000006,0x000059d4,0x0000012b, -0x00003d1c,0x0000423f,0x0000423d,0x000500b0, -0x0000002f,0x000041fc,0x000059d4,0x000000df, -0x000400f6,0x00004240,0x0000423d,0x00000000, -0x000400fa,0x000041fc,0x000041fd,0x00004240, -0x000200f8,0x000041fd,0x00050041,0x0000008d, -0x000041ff,0x000041c5,0x000059d4,0x0003003e, -0x000041ff,0x00000393,0x00050041,0x0000008d, -0x00004201,0x000041c6,0x000059d4,0x0003003e, -0x00004201,0x00000393,0x00050041,0x00000009, -0x00004203,0x000041c7,0x000059d4,0x0003003e, -0x00004203,0x0000012b,0x000200f9,0x00004204, -0x000200f8,0x00004204,0x000700f5,0x00000006, -0x000059ec,0x0000012b,0x000041fd,0x0000420e, -0x00004208,0x000500b0,0x0000002f,0x00004207, -0x000059ec,0x00000437,0x000400f6,0x0000420f, -0x00004208,0x00000000,0x000400fa,0x00004207, -0x00004208,0x0000420f,0x000200f8,0x00004208, -0x00060041,0x000000d8,0x0000420b,0x000041c9, -0x000059d4,0x000059ec,0x0003003e,0x0000420b, -0x00000b0f,0x00050080,0x00000006,0x0000420e, -0x000059ec,0x0000022b,0x000200f9,0x00004204, -0x000200f8,0x0000420f,0x00050041,0x00000009, -0x00004211,0x00003c82,0x000059d4,0x0004003d, -0x00000006,0x00004212,0x00004211,0x000500aa, -0x0000002f,0x00004213,0x00004212,0x00000500, -0x000300f7,0x00004215,0x00000000,0x000400fa, -0x00004213,0x00004214,0x00004215,0x000200f8, -0x00004214,0x000200f9,0x0000423d,0x000200f8, -0x00004215,0x0004003d,0x00000006,0x00004219, -0x00004211,0x00050041,0x00000182,0x00004319, -0x00000180,0x00000311,0x0004003d,0x00000006, -0x0000431a,0x00004319,0x00050084,0x00000006, -0x0000431c,0x0000018b,0x00004219,0x00050080, -0x00000006,0x0000431d,0x0000431a,0x0000431c, -0x00050080,0x00000006,0x0000421b,0x0000431d, -0x000004e8,0x00050041,0x0000022d,0x0000421c, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x0000421d,0x0000421c,0x00050051,0x00000006, -0x00004334,0x0000421d,0x00000000,0x00050095, -0x00000130,0x00004336,0x00004334,0x0000421b, -0x00050051,0x00000006,0x00004337,0x00004336, -0x00000001,0x00050051,0x00000006,0x00004338, -0x00004336,0x00000000,0x00050051,0x00000006, -0x0000433b,0x0000421d,0x00000001,0x00050080, -0x00000006,0x0000433d,0x0000433b,0x00004337, -0x00050050,0x00000007,0x0000433e,0x00004338, -0x0000433d,0x0004007c,0x00000014,0x0000432e, -0x0000433e,0x00060041,0x0000015f,0x00004325, -0x0000432e,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00004326,0x00004325,0x00000002, -0x00000004,0x0003003e,0x00004203,0x00004326, -0x000200f9,0x00004220,0x000200f8,0x00004220, -0x000700f5,0x00000006,0x000059ee,0x0000012b, -0x00004215,0x0000422f,0x00004224,0x000500b0, -0x0000002f,0x00004223,0x000059ee,0x00000437, -0x000400f6,0x00004230,0x00004224,0x00000000, -0x000400fa,0x00004223,0x00004224,0x00004230, -0x000200f8,0x00004224,0x0004003d,0x00000006, -0x00004229,0x00004211,0x00050084,0x00000006, -0x00004362,0x0000018b,0x00004229,0x00050080, -0x00000006,0x00004363,0x0000431a,0x00004362, -0x00050084,0x00000006,0x0000434c,0x0000019b, -0x000059ee,0x00050080,0x00000006,0x0000434d, -0x00004363,0x0000434c,0x00050095,0x00000130, -0x0000437c,0x00004334,0x0000434d,0x00050051, -0x00000006,0x0000437d,0x0000437c,0x00000001, -0x00050051,0x00000006,0x0000437e,0x0000437c, -0x00000000,0x00050080,0x00000006,0x00004383, -0x0000433b,0x0000437d,0x00050050,0x00000007, -0x00004384,0x0000437e,0x00004383,0x0004007c, -0x00000014,0x00004374,0x00004384,0x00060041, -0x0000015f,0x0000436b,0x00004374,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x0000436c, -0x0000436b,0x00000002,0x00000004,0x00050080, -0x00000006,0x00004353,0x0000434d,0x000000df, -0x00050095,0x00000130,0x0000439d,0x00004334, -0x00004353,0x00050051,0x00000006,0x0000439e, -0x0000439d,0x00000001,0x00050051,0x00000006, -0x0000439f,0x0000439d,0x00000000,0x00050080, -0x00000006,0x000043a4,0x0000433b,0x0000439e, -0x00050050,0x00000007,0x000043a5,0x0000439f, -0x000043a4,0x0004007c,0x00000014,0x00004395, -0x000043a5,0x00060041,0x0000015f,0x0000438c, -0x00004395,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x0000438d,0x0000438c,0x00000002, -0x00000004,0x00050080,0x00000006,0x00004358, -0x0000434d,0x00000194,0x00050095,0x00000130, -0x000043be,0x00004334,0x00004358,0x00050051, -0x00000006,0x000043bf,0x000043be,0x00000001, -0x00050051,0x00000006,0x000043c0,0x000043be, -0x00000000,0x00050080,0x00000006,0x000043c5, -0x0000433b,0x000043bf,0x00050050,0x00000007, -0x000043c6,0x000043c0,0x000043c5,0x0004007c, -0x00000014,0x000043b6,0x000043c6,0x00060041, -0x0000015f,0x000043ad,0x000043b6,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000043ae, -0x000043ad,0x00000002,0x00000004,0x00060050, -0x000000d2,0x0000435c,0x0000436c,0x0000438d, -0x000043ae,0x00060041,0x000000d8,0x0000422c, -0x000041c9,0x000059d4,0x000059ee,0x0003003e, -0x0000422c,0x0000435c,0x00050080,0x00000006, -0x0000422f,0x000059ee,0x0000022b,0x000200f9, -0x00004220,0x000200f8,0x00004230,0x0004003d, -0x00000006,0x00004233,0x00004211,0x00050084, -0x00000006,0x000043d7,0x000001b6,0x00004233, -0x00050080,0x00000006,0x000043d8,0x00003df7, -0x000043d7,0x00050095,0x00000130,0x00004436, -0x00003e4f,0x000043d8,0x00050051,0x00000006, -0x00004437,0x00004436,0x00000001,0x00050051, -0x00000006,0x00004438,0x00004436,0x00000000, -0x00050080,0x00000006,0x0000443d,0x00003e56, -0x00004437,0x00050050,0x00000007,0x0000443e, -0x00004438,0x0000443d,0x0004007c,0x00000014, -0x0000442e,0x0000443e,0x00060041,0x0000015f, -0x00004425,0x0000442e,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004426,0x00004425, -0x00000002,0x00000004,0x0004007c,0x00000027, -0x000043dd,0x00004426,0x00050080,0x00000006, -0x000043df,0x000043d8,0x000000df,0x00050095, -0x00000130,0x00004457,0x00003e4f,0x000043df, -0x00050051,0x00000006,0x00004458,0x00004457, -0x00000001,0x00050051,0x00000006,0x00004459, -0x00004457,0x00000000,0x00050080,0x00000006, -0x0000445e,0x00003e56,0x00004458,0x00050050, -0x00000007,0x0000445f,0x00004459,0x0000445e, -0x0004007c,0x00000014,0x0000444f,0x0000445f, -0x00060041,0x0000015f,0x00004446,0x0000444f, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00004447,0x00004446,0x00000002,0x00000004, -0x0004007c,0x00000027,0x000043e3,0x00004447, -0x00050080,0x00000006,0x000043e5,0x000043d8, -0x00000194,0x00050095,0x00000130,0x00004478, -0x00003e4f,0x000043e5,0x00050051,0x00000006, -0x00004479,0x00004478,0x00000001,0x00050051, -0x00000006,0x0000447a,0x00004478,0x00000000, -0x00050080,0x00000006,0x0000447f,0x00003e56, -0x00004479,0x00050050,0x00000007,0x00004480, -0x0000447a,0x0000447f,0x0004007c,0x00000014, -0x00004470,0x00004480,0x00060041,0x0000015f, -0x00004467,0x00004470,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00004468,0x00004467, -0x00000002,0x00000004,0x0004007c,0x00000027, -0x000043e9,0x00004468,0x00050080,0x00000006, -0x000043ec,0x000043d8,0x0000019b,0x00050095, -0x00000130,0x00004499,0x00003e4f,0x000043ec, -0x00050051,0x00000006,0x0000449a,0x00004499, -0x00000001,0x00050051,0x00000006,0x0000449b, -0x00004499,0x00000000,0x00050080,0x00000006, -0x000044a0,0x00003e56,0x0000449a,0x00050050, -0x00000007,0x000044a1,0x0000449b,0x000044a0, -0x0004007c,0x00000014,0x00004491,0x000044a1, -0x00060041,0x0000015f,0x00004488,0x00004491, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00004489,0x00004488,0x00000002,0x00000004, -0x0004007c,0x00000027,0x000043f0,0x00004489, -0x00050080,0x00000006,0x000043f2,0x000043d8, -0x000001a2,0x00050095,0x00000130,0x000044ba, -0x00003e4f,0x000043f2,0x00050051,0x00000006, -0x000044bb,0x000044ba,0x00000001,0x00050051, -0x00000006,0x000044bc,0x000044ba,0x00000000, -0x00050080,0x00000006,0x000044c1,0x00003e56, -0x000044bb,0x00050050,0x00000007,0x000044c2, -0x000044bc,0x000044c1,0x0004007c,0x00000014, -0x000044b2,0x000044c2,0x00060041,0x0000015f, -0x000044a9,0x000044b2,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x000044aa,0x000044a9, -0x00000002,0x00000004,0x0004007c,0x00000027, -0x000043f6,0x000044aa,0x00050080,0x00000006, -0x000043f8,0x000043d8,0x00000260,0x00050095, -0x00000130,0x000044db,0x00003e4f,0x000043f8, -0x00050051,0x00000006,0x000044dc,0x000044db, -0x00000001,0x00050051,0x00000006,0x000044dd, -0x000044db,0x00000000,0x00050080,0x00000006, -0x000044e2,0x00003e56,0x000044dc,0x00050050, -0x00000007,0x000044e3,0x000044dd,0x000044e2, -0x0004007c,0x00000014,0x000044d3,0x000044e3, -0x00060041,0x0000015f,0x000044ca,0x000044d3, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x000044cb,0x000044ca,0x00000002,0x00000004, -0x0004007c,0x00000027,0x000043fc,0x000044cb, -0x000500bc,0x0000002f,0x000044ea,0x000043dd, -0x000043f0,0x000300f7,0x000044f1,0x00000000, -0x000400fa,0x000044ea,0x000044eb,0x000044f1, -0x000200f8,0x000044eb,0x000500bc,0x0000002f, -0x000044f0,0x000043e3,0x000043f6,0x000200f9, -0x000044f1,0x000200f8,0x000044f1,0x000700f5, -0x0000002f,0x000044f2,0x000044ea,0x00004230, -0x000044f0,0x000044eb,0x000300f7,0x000044f9, -0x00000000,0x000400fa,0x000044f2,0x000044f3, -0x000044f9,0x000200f8,0x000044f3,0x000500bc, -0x0000002f,0x000044f8,0x000043e9,0x000043fc, -0x000200f9,0x000044f9,0x000200f8,0x000044f9, -0x000700f5,0x0000002f,0x000044fa,0x000044f2, -0x000044f1,0x000044f8,0x000044f3,0x0003003e, -0x000041ff,0x000044fa,0x000200f9,0x0000423d, -0x000200f8,0x0000423d,0x00050080,0x00000006, -0x0000423f,0x000059d4,0x0000022b,0x000200f9, -0x000041f9,0x000200f8,0x00004240,0x000200f9, -0x00004241,0x000200f8,0x00004241,0x000700f5, -0x00000006,0x000059d5,0x0000012b,0x00004240, -0x00004315,0x00004313,0x000500b0,0x0000002f, -0x00004244,0x000059d5,0x000000df,0x000400f6, -0x00004316,0x00004313,0x00000000,0x000400fa, -0x00004244,0x00004245,0x00004316,0x000200f8, -0x00004245,0x00050041,0x0000008d,0x00004247, -0x000041c6,0x000059d5,0x0004003d,0x0000002f, -0x00004248,0x00004247,0x000400a8,0x0000002f, -0x00004249,0x00004248,0x000300f7,0x0000424f, -0x00000000,0x000400fa,0x00004249,0x0000424a, -0x0000424f,0x000200f8,0x0000424a,0x00050041, -0x0000008d,0x0000424c,0x000041c5,0x000059d5, -0x0004003d,0x0000002f,0x0000424d,0x0000424c, -0x000400a8,0x0000002f,0x0000424e,0x0000424d, -0x000200f9,0x0000424f,0x000200f8,0x0000424f, -0x000700f5,0x0000002f,0x00004250,0x00004248, -0x00004245,0x0000424e,0x0000424a,0x000300f7, -0x00004252,0x00000000,0x000400fa,0x00004250, -0x00004251,0x00004252,0x000200f8,0x00004251, -0x000200f9,0x00004313,0x000200f8,0x00004252, -0x0003003e,0x00004247,0x000003ae,0x00050080, -0x00000006,0x00004256,0x000059d5,0x00000135, -0x000200f9,0x00004257,0x000200f8,0x00004257, -0x000700f5,0x00000006,0x000059d7,0x00004256, -0x00004252,0x00004311,0x0000430f,0x000500b0, -0x0000002f,0x0000425a,0x000059d7,0x000000df, -0x000400f6,0x00004312,0x0000430f,0x00000000, -0x000400fa,0x0000425a,0x0000425b,0x00004312, -0x000200f8,0x0000425b,0x00050041,0x0000008d, -0x0000425d,0x000041c6,0x000059d7,0x0004003d, -0x0000002f,0x0000425e,0x0000425d,0x000400a8, -0x0000002f,0x0000425f,0x0000425e,0x000300f7, -0x00004265,0x00000000,0x000400fa,0x0000425f, -0x00004260,0x00004265,0x000200f8,0x00004260, -0x00050041,0x0000008d,0x00004262,0x000041c5, -0x000059d7,0x0004003d,0x0000002f,0x00004263, -0x00004262,0x000400a8,0x0000002f,0x00004264, -0x00004263,0x000200f9,0x00004265,0x000200f8, -0x00004265,0x000700f5,0x0000002f,0x00004266, -0x0000425e,0x0000425b,0x00004264,0x00004260, -0x000400a8,0x0000002f,0x00004267,0x00004266, -0x000300f7,0x00004270,0x00000000,0x000400fa, -0x00004267,0x00004268,0x00004270,0x000200f8, -0x00004268,0x00050041,0x00000009,0x0000426a, -0x000041c7,0x000059d7,0x0004003d,0x00000006, -0x0000426b,0x0000426a,0x00050041,0x00000009, -0x0000426d,0x000041c7,0x000059d5,0x0004003d, -0x00000006,0x0000426e,0x0000426d,0x000500ab, -0x0000002f,0x0000426f,0x0000426b,0x0000426e, -0x000200f9,0x00004270,0x000200f8,0x00004270, -0x000700f5,0x0000002f,0x00004271,0x00004266, -0x00004265,0x0000426f,0x00004268,0x000300f7, -0x00004273,0x00000000,0x000400fa,0x00004271, -0x00004272,0x00004273,0x000200f8,0x00004272, -0x000200f9,0x0000430f,0x000200f8,0x00004273, -0x000200f9,0x00004274,0x000200f8,0x00004274, -0x000700f5,0x00000006,0x000059e1,0x00000437, -0x00004273,0x00005c6e,0x000042ac,0x000700f5, -0x00000006,0x000059dc,0x00000437,0x00004273, -0x00005c63,0x000042ac,0x000700f5,0x00000006, -0x000059db,0x0000012b,0x00004273,0x000042ae, -0x000042ac,0x000500b0,0x0000002f,0x00004277, -0x000059db,0x00000437,0x000500aa,0x0000002f, -0x00004279,0x000059dc,0x00000437,0x000500a7, -0x0000002f,0x0000427a,0x00004277,0x00004279, -0x000400f6,0x000042af,0x000042ac,0x00000000, -0x000400fa,0x0000427a,0x0000427b,0x000042af, -0x000200f8,0x0000427b,0x00060041,0x000000d8, -0x0000427e,0x000041c9,0x000059d5,0x000059db, -0x0004003d,0x000000d2,0x0000427f,0x0000427e, -0x00050080,0x00000006,0x00004282,0x000059db, -0x00000135,0x00050089,0x00000006,0x00004283, -0x00004282,0x00000437,0x00060041,0x000000d8, -0x00004284,0x000041c9,0x000059d5,0x00004283, -0x0004003d,0x000000d2,0x00004285,0x00004284, -0x000500aa,0x00000514,0x00004288,0x0000427f, -0x00004285,0x0004009b,0x0000002f,0x00004289, -0x00004288,0x000300f7,0x0000428b,0x00000000, -0x000400fa,0x00004289,0x0000428a,0x0000428b, -0x000200f8,0x0000428a,0x000200f9,0x000042ac, -0x000200f8,0x0000428b,0x000200f9,0x0000428c, -0x000200f8,0x0000428c,0x000700f5,0x00000006, -0x000059e2,0x0000012b,0x0000428b,0x000042aa, -0x000042a8,0x000500b0,0x0000002f,0x0000428f, -0x000059e2,0x00000437,0x000400f6,0x000042ab, -0x000042a8,0x00000000,0x000400fa,0x0000428f, -0x00004290,0x000042ab,0x000200f8,0x00004290, -0x00060041,0x000000d8,0x00004293,0x000041c9, -0x000059d7,0x000059e2,0x0004003d,0x000000d2, -0x00004294,0x00004293,0x000500aa,0x00000514, -0x00004296,0x00004294,0x00004285,0x0004009b, -0x0000002f,0x00004297,0x00004296,0x000300f7, -0x000042a2,0x00000000,0x000400fa,0x00004297, -0x00004298,0x000042a2,0x000200f8,0x00004298, -0x00050080,0x00000006,0x0000429b,0x000059e2, -0x00000135,0x00050089,0x00000006,0x0000429c, -0x0000429b,0x00000437,0x00060041,0x000000d8, -0x0000429d,0x000041c9,0x000059d7,0x0000429c, -0x0004003d,0x000000d2,0x0000429e,0x0000429d, -0x000500aa,0x00000514,0x000042a0,0x0000429e, -0x0000427f,0x0004009b,0x0000002f,0x000042a1, -0x000042a0,0x000200f9,0x000042a2,0x000200f8, -0x000042a2,0x000700f5,0x0000002f,0x000042a3, -0x00004297,0x00004290,0x000042a1,0x00004298, -0x000300f7,0x000042a7,0x00000000,0x000400fa, -0x000042a3,0x000042a4,0x000042a7,0x000200f8, -0x000042a4,0x000200f9,0x000042ab,0x000200f8, -0x000042a7,0x000200f9,0x000042a8,0x000200f8, -0x000042a8,0x00050080,0x00000006,0x000042aa, -0x000059e2,0x0000022b,0x000200f9,0x0000428c, -0x000200f8,0x000042ab,0x000700f5,0x00000006, -0x00005c6f,0x000059e1,0x0000428c,0x000059e2, -0x000042a4,0x000700f5,0x00000006,0x00005c64, -0x000059dc,0x0000428c,0x000059db,0x000042a4, -0x000200f9,0x000042ac,0x000200f8,0x000042ac, -0x000700f5,0x00000006,0x00005c6e,0x000059e1, -0x0000428a,0x00005c6f,0x000042ab,0x000700f5, -0x00000006,0x00005c63,0x000059dc,0x0000428a, -0x00005c64,0x000042ab,0x00050080,0x00000006, -0x000042ae,0x000059db,0x0000022b,0x000200f9, -0x00004274,0x000200f8,0x000042af,0x000300f7, -0x000042b3,0x00000000,0x000400fa,0x00004279, -0x000042b2,0x000042b3,0x000200f8,0x000042b2, -0x000200f9,0x0000430f,0x000200f8,0x000042b3, -0x0003003e,0x0000425d,0x000003ae,0x00050080, -0x00000006,0x000042b9,0x000059dc,0x00000247, -0x00050089,0x00000006,0x000042ba,0x000042b9, -0x00000437,0x00050041,0x00000009,0x000042bb, -0x00003c82,0x000059d5,0x0004003d,0x00000006, -0x000042bc,0x000042bb,0x00060041,0x000000d8, -0x000042bd,0x000041c9,0x000059d5,0x000042ba, -0x0004003d,0x000000d2,0x000042be,0x000042bd, -0x00050041,0x00000182,0x00004523,0x00000180, -0x00000311,0x0004003d,0x00000006,0x00004524, -0x00004523,0x00050084,0x00000006,0x00004526, -0x0000018b,0x000042bc,0x00050080,0x00000006, -0x00004527,0x00004524,0x00004526,0x00050041, -0x0000022d,0x0000450d,0x00000180,0x0000015e, -0x0004003d,0x00000007,0x0000450e,0x0000450d, -0x00050051,0x00000006,0x00004511,0x000042be, -0x00000000,0x00050051,0x00000006,0x0000453d, -0x0000450e,0x00000000,0x00050095,0x00000130, -0x0000453f,0x0000453d,0x00004527,0x00050051, -0x00000006,0x00004540,0x0000453f,0x00000001, -0x00050051,0x00000006,0x00004541,0x0000453f, -0x00000000,0x00050051,0x00000006,0x00004544, -0x0000450e,0x00000001,0x00050080,0x00000006, -0x00004546,0x00004544,0x00004540,0x00050050, -0x00000007,0x00004547,0x00004541,0x00004546, -0x0004007c,0x00000014,0x00004537,0x00004547, -0x00060041,0x0000015f,0x0000452f,0x00004537, -0x0000015e,0x0000015e,0x0005003e,0x0000452f, -0x00004511,0x00000002,0x00000004,0x00050080, -0x00000006,0x00004514,0x00004527,0x000000df, -0x00050051,0x00000006,0x00004518,0x000042be, -0x00000001,0x00050095,0x00000130,0x0000455f, -0x0000453d,0x00004514,0x00050051,0x00000006, -0x00004560,0x0000455f,0x00000001,0x00050051, -0x00000006,0x00004561,0x0000455f,0x00000000, -0x00050080,0x00000006,0x00004566,0x00004544, -0x00004560,0x00050050,0x00000007,0x00004567, -0x00004561,0x00004566,0x0004007c,0x00000014, -0x00004557,0x00004567,0x00060041,0x0000015f, -0x0000454f,0x00004557,0x0000015e,0x0000015e, -0x0005003e,0x0000454f,0x00004518,0x00000002, -0x00000004,0x00050080,0x00000006,0x0000451b, -0x00004527,0x00000194,0x00050051,0x00000006, -0x0000451f,0x000042be,0x00000002,0x00050095, -0x00000130,0x0000457f,0x0000453d,0x0000451b, -0x00050051,0x00000006,0x00004580,0x0000457f, -0x00000001,0x00050051,0x00000006,0x00004581, -0x0000457f,0x00000000,0x00050080,0x00000006, -0x00004586,0x00004544,0x00004580,0x00050050, -0x00000007,0x00004587,0x00004581,0x00004586, -0x0004007c,0x00000014,0x00004577,0x00004587, -0x00060041,0x0000015f,0x0000456f,0x00004577, -0x0000015e,0x0000015e,0x0005003e,0x0000456f, -0x0000451f,0x00000002,0x00000004,0x0004003d, -0x00000006,0x000042c4,0x000042bb,0x00060041, -0x000000d8,0x000042c5,0x000041c9,0x000059d5, -0x000059dc,0x0004003d,0x000000d2,0x000042c6, -0x000042c5,0x00050084,0x00000006,0x000045b2, -0x0000018b,0x000042c4,0x00050080,0x00000006, -0x000045b3,0x00004524,0x000045b2,0x00050080, -0x00000006,0x00004598,0x000045b3,0x0000019b, -0x00050051,0x00000006,0x0000459d,0x000042c6, -0x00000000,0x00050095,0x00000130,0x000045cb, -0x0000453d,0x00004598,0x00050051,0x00000006, -0x000045cc,0x000045cb,0x00000001,0x00050051, -0x00000006,0x000045cd,0x000045cb,0x00000000, -0x00050080,0x00000006,0x000045d2,0x00004544, -0x000045cc,0x00050050,0x00000007,0x000045d3, -0x000045cd,0x000045d2,0x0004007c,0x00000014, -0x000045c3,0x000045d3,0x00060041,0x0000015f, -0x000045bb,0x000045c3,0x0000015e,0x0000015e, -0x0005003e,0x000045bb,0x0000459d,0x00000002, -0x00000004,0x00050080,0x00000006,0x000045a0, -0x000045b3,0x000001a2,0x00050051,0x00000006, -0x000045a4,0x000042c6,0x00000001,0x00050095, -0x00000130,0x000045eb,0x0000453d,0x000045a0, -0x00050051,0x00000006,0x000045ec,0x000045eb, -0x00000001,0x00050051,0x00000006,0x000045ed, -0x000045eb,0x00000000,0x00050080,0x00000006, -0x000045f2,0x00004544,0x000045ec,0x00050050, -0x00000007,0x000045f3,0x000045ed,0x000045f2, -0x0004007c,0x00000014,0x000045e3,0x000045f3, -0x00060041,0x0000015f,0x000045db,0x000045e3, -0x0000015e,0x0000015e,0x0005003e,0x000045db, -0x000045a4,0x00000002,0x00000004,0x00050080, -0x00000006,0x000045a7,0x000045b3,0x00000260, -0x00050051,0x00000006,0x000045ab,0x000042c6, -0x00000002,0x00050095,0x00000130,0x0000460b, -0x0000453d,0x000045a7,0x00050051,0x00000006, -0x0000460c,0x0000460b,0x00000001,0x00050051, -0x00000006,0x0000460d,0x0000460b,0x00000000, -0x00050080,0x00000006,0x00004612,0x00004544, -0x0000460c,0x00050050,0x00000007,0x00004613, -0x0000460d,0x00004612,0x0004007c,0x00000014, -0x00004603,0x00004613,0x00060041,0x0000015f, -0x000045fb,0x00004603,0x0000015e,0x0000015e, -0x0005003e,0x000045fb,0x000045ab,0x00000002, -0x00000004,0x00050080,0x00000006,0x000042cb, -0x000059dc,0x00000135,0x00050089,0x00000006, -0x000042cc,0x000042cb,0x00000437,0x0004003d, -0x00000006,0x000042ce,0x000042bb,0x00060041, -0x000000d8,0x000042cf,0x000041c9,0x000059d5, -0x000042cc,0x0004003d,0x000000d2,0x000042d0, -0x000042cf,0x00050084,0x00000006,0x0000463e, -0x0000018b,0x000042ce,0x00050080,0x00000006, -0x0000463f,0x00004524,0x0000463e,0x00050080, -0x00000006,0x00004624,0x0000463f,0x000001b6, -0x00050051,0x00000006,0x00004629,0x000042d0, -0x00000000,0x00050095,0x00000130,0x00004657, -0x0000453d,0x00004624,0x00050051,0x00000006, -0x00004658,0x00004657,0x00000001,0x00050051, -0x00000006,0x00004659,0x00004657,0x00000000, -0x00050080,0x00000006,0x0000465e,0x00004544, -0x00004658,0x00050050,0x00000007,0x0000465f, -0x00004659,0x0000465e,0x0004007c,0x00000014, -0x0000464f,0x0000465f,0x00060041,0x0000015f, -0x00004647,0x0000464f,0x0000015e,0x0000015e, -0x0005003e,0x00004647,0x00004629,0x00000002, -0x00000004,0x00050080,0x00000006,0x0000462c, -0x0000463f,0x000005df,0x00050051,0x00000006, -0x00004630,0x000042d0,0x00000001,0x00050095, -0x00000130,0x00004677,0x0000453d,0x0000462c, -0x00050051,0x00000006,0x00004678,0x00004677, -0x00000001,0x00050051,0x00000006,0x00004679, -0x00004677,0x00000000,0x00050080,0x00000006, -0x0000467e,0x00004544,0x00004678,0x00050050, -0x00000007,0x0000467f,0x00004679,0x0000467e, -0x0004007c,0x00000014,0x0000466f,0x0000467f, -0x00060041,0x0000015f,0x00004667,0x0000466f, -0x0000015e,0x0000015e,0x0005003e,0x00004667, -0x00004630,0x00000002,0x00000004,0x00050080, -0x00000006,0x00004633,0x0000463f,0x000001cc, -0x00050051,0x00000006,0x00004637,0x000042d0, -0x00000002,0x00050095,0x00000130,0x00004697, -0x0000453d,0x00004633,0x00050051,0x00000006, -0x00004698,0x00004697,0x00000001,0x00050051, -0x00000006,0x00004699,0x00004697,0x00000000, -0x00050080,0x00000006,0x0000469e,0x00004544, -0x00004698,0x00050050,0x00000007,0x0000469f, -0x00004699,0x0000469e,0x0004007c,0x00000014, -0x0000468f,0x0000469f,0x00060041,0x0000015f, -0x00004687,0x0000468f,0x0000015e,0x0000015e, -0x0005003e,0x00004687,0x00004637,0x00000002, -0x00000004,0x00050080,0x00000006,0x000042d5, -0x000059e1,0x00000247,0x00050089,0x00000006, -0x000042d6,0x000042d5,0x00000437,0x0004003d, -0x00000006,0x000042d8,0x000042bb,0x00060041, -0x000000d8,0x000042d9,0x000041c9,0x000059d7, -0x000042d6,0x0004003d,0x000000d2,0x000042da, -0x000042d9,0x00050084,0x00000006,0x000046ca, -0x0000018b,0x000042d8,0x00050080,0x00000006, -0x000046cb,0x00004524,0x000046ca,0x00050080, -0x00000006,0x000046b0,0x000046cb,0x000004c7, -0x00050051,0x00000006,0x000046b5,0x000042da, -0x00000000,0x00050095,0x00000130,0x000046e3, -0x0000453d,0x000046b0,0x00050051,0x00000006, -0x000046e4,0x000046e3,0x00000001,0x00050051, -0x00000006,0x000046e5,0x000046e3,0x00000000, -0x00050080,0x00000006,0x000046ea,0x00004544, -0x000046e4,0x00050050,0x00000007,0x000046eb, -0x000046e5,0x000046ea,0x0004007c,0x00000014, -0x000046db,0x000046eb,0x00060041,0x0000015f, -0x000046d3,0x000046db,0x0000015e,0x0000015e, -0x0005003e,0x000046d3,0x000046b5,0x00000002, -0x00000004,0x00050080,0x00000006,0x000046b8, -0x000046cb,0x000004d2,0x00050051,0x00000006, -0x000046bc,0x000042da,0x00000001,0x00050095, -0x00000130,0x00004703,0x0000453d,0x000046b8, -0x00050051,0x00000006,0x00004704,0x00004703, -0x00000001,0x00050051,0x00000006,0x00004705, -0x00004703,0x00000000,0x00050080,0x00000006, -0x0000470a,0x00004544,0x00004704,0x00050050, -0x00000007,0x0000470b,0x00004705,0x0000470a, -0x0004007c,0x00000014,0x000046fb,0x0000470b, -0x00060041,0x0000015f,0x000046f3,0x000046fb, -0x0000015e,0x0000015e,0x0005003e,0x000046f3, -0x000046bc,0x00000002,0x00000004,0x00050080, -0x00000006,0x000046bf,0x000046cb,0x000004dd, -0x00050051,0x00000006,0x000046c3,0x000042da, -0x00000002,0x00050095,0x00000130,0x00004723, -0x0000453d,0x000046bf,0x00050051,0x00000006, -0x00004724,0x00004723,0x00000001,0x00050051, -0x00000006,0x00004725,0x00004723,0x00000000, -0x00050080,0x00000006,0x0000472a,0x00004544, -0x00004724,0x00050050,0x00000007,0x0000472b, -0x00004725,0x0000472a,0x0004007c,0x00000014, -0x0000471b,0x0000472b,0x00060041,0x0000015f, -0x00004713,0x0000471b,0x0000015e,0x0000015e, -0x0005003e,0x00004713,0x000046c3,0x00000002, -0x00000004,0x0004003d,0x00000006,0x000042de, -0x000042bb,0x00050084,0x00000006,0x00004731, -0x0000018b,0x000042de,0x00050080,0x00000006, -0x00004732,0x00004524,0x00004731,0x00050080, -0x00000006,0x000042e0,0x00004732,0x000004fe, -0x00050041,0x00000009,0x000042e2,0x00003c82, -0x000059d7,0x0004003d,0x00000006,0x000042e3, -0x000042e2,0x00050084,0x00000006,0x00004738, -0x0000018b,0x000042e3,0x00050080,0x00000006, -0x00004739,0x00004524,0x00004738,0x00050080, -0x00000006,0x000042e5,0x00004739,0x000004f4, -0x00050095,0x00000130,0x00004752,0x0000453d, -0x000042e5,0x00050051,0x00000006,0x00004753, -0x00004752,0x00000001,0x00050051,0x00000006, -0x00004754,0x00004752,0x00000000,0x00050080, -0x00000006,0x00004759,0x00004544,0x00004753, -0x00050050,0x00000007,0x0000475a,0x00004754, -0x00004759,0x0004007c,0x00000014,0x0000474a, -0x0000475a,0x00060041,0x0000015f,0x00004741, -0x0000474a,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00004742,0x00004741,0x00000002, -0x00000004,0x00050095,0x00000130,0x00004772, -0x0000453d,0x000042e0,0x00050051,0x00000006, -0x00004773,0x00004772,0x00000001,0x00050051, -0x00000006,0x00004774,0x00004772,0x00000000, -0x00050080,0x00000006,0x00004779,0x00004544, -0x00004773,0x00050050,0x00000007,0x0000477a, -0x00004774,0x00004779,0x0004007c,0x00000014, -0x0000476a,0x0000477a,0x00060041,0x0000015f, -0x00004762,0x0000476a,0x0000015e,0x0000015e, -0x0005003e,0x00004762,0x00004742,0x00000002, -0x00000004,0x00050082,0x00000006,0x000042ed, -0x0000032b,0x000059dc,0x00050089,0x00000006, -0x000042ee,0x000042ed,0x00000437,0x00050082, -0x00000006,0x000042f0,0x0000031c,0x000059dc, -0x00050089,0x00000006,0x000042f1,0x000042f0, -0x00000437,0x000500c4,0x00000006,0x000042f2, -0x000042f1,0x000002dc,0x000500c5,0x00000006, -0x000042f3,0x000042ee,0x000042f2,0x00050082, -0x00000006,0x000042f5,0x0000031c,0x000059e1, -0x00050089,0x00000006,0x000042f6,0x000042f5, -0x00000437,0x00050082,0x00000006,0x000042f8, -0x00000c2c,0x000059e1,0x00050089,0x00000006, -0x000042f9,0x000042f8,0x00000437,0x000500c4, -0x00000006,0x000042fa,0x000042f9,0x000002dc, -0x000500c5,0x00000006,0x000042fb,0x000042f6, -0x000042fa,0x0004003d,0x00000006,0x000042fe, -0x000042bb,0x00050084,0x00000006,0x00004780, -0x0000018b,0x000042fe,0x00050080,0x00000006, -0x00004781,0x00004524,0x00004780,0x00050080, -0x00000006,0x00004300,0x00004781,0x00000508, -0x000500c4,0x00000006,0x00004303,0x000042fb, -0x00000488,0x000500c5,0x00000006,0x00004304, -0x000042f3,0x00004303,0x00050095,0x00000130, -0x00004799,0x0000453d,0x00004300,0x00050051, -0x00000006,0x0000479a,0x00004799,0x00000001, -0x00050051,0x00000006,0x0000479b,0x00004799, -0x00000000,0x00050080,0x00000006,0x000047a0, -0x00004544,0x0000479a,0x00050050,0x00000007, -0x000047a1,0x0000479b,0x000047a0,0x0004007c, -0x00000014,0x00004791,0x000047a1,0x00060041, -0x0000015f,0x00004789,0x00004791,0x0000015e, -0x0000015e,0x0005003e,0x00004789,0x00004304, -0x00000002,0x00000004,0x00050041,0x00000009, -0x0000430a,0x00003c83,0x000059d5,0x0004003d, -0x00000006,0x0000430b,0x0000430a,0x000500c7, -0x00000006,0x0000430c,0x0000430b,0x00000c46, -0x000500c5,0x00000006,0x0000430d,0x0000430c, -0x00000135,0x00050041,0x00000009,0x0000430e, -0x00003c83,0x000059d7,0x0003003e,0x0000430e, -0x0000430d,0x000200f9,0x00004312,0x000200f8, -0x0000430f,0x00050080,0x00000006,0x00004311, -0x000059d7,0x0000022b,0x000200f9,0x00004257, -0x000200f8,0x00004312,0x000200f9,0x00004313, -0x000200f8,0x00004313,0x00050080,0x00000006, -0x00004315,0x000059d5,0x0000022b,0x000200f9, -0x00004241,0x000200f8,0x00004316,0x0004003d, -0x000000e0,0x00003d20,0x00003c83,0x0003003e, -0x00003c67,0x00003d20,0x000200f9,0x00003d21, -0x000200f8,0x00003d21,0x000200f9,0x00003d22, -0x000200f8,0x00003ca3,0x000500aa,0x0000002f, -0x00003ca6,0x00003ca1,0x00000135,0x000300f7, -0x00003cb1,0x00000000,0x000400fa,0x00003ca6, -0x00003ca7,0x00003cb1,0x000200f8,0x00003ca7, -0x00050041,0x00000182,0x00003d90,0x00000180, -0x00000181,0x0004003d,0x00000006,0x00003d91, -0x00003d90,0x00050084,0x00000006,0x00003d92, -0x000000df,0x00003d91,0x00050080,0x00000006, -0x00003d93,0x0000018b,0x00003d92,0x00050041, -0x0000022d,0x00003ca9,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00003caa,0x00003ca9, -0x00050051,0x00000006,0x00003daa,0x00003caa, -0x00000000,0x00050095,0x00000130,0x00003dac, -0x00003daa,0x00003d93,0x00050051,0x00000006, -0x00003dad,0x00003dac,0x00000001,0x00050051, -0x00000006,0x00003dae,0x00003dac,0x00000000, -0x00050051,0x00000006,0x00003db1,0x00003caa, -0x00000001,0x00050080,0x00000006,0x00003db3, -0x00003db1,0x00003dad,0x00050050,0x00000007, -0x00003db4,0x00003dae,0x00003db3,0x0004007c, -0x00000014,0x00003da4,0x00003db4,0x00060041, -0x0000015f,0x00003d9b,0x00003da4,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003d9c, -0x00003d9b,0x00000002,0x00000004,0x00050041, -0x00000009,0x00003cac,0x00003c68,0x0000015e, -0x0003003e,0x00003cac,0x00003d9c,0x0004003d, -0x00000006,0x00003cae,0x00003cac,0x00050041, -0x00000182,0x00003db7,0x00000180,0x00000311, -0x0004003d,0x00000006,0x00003db8,0x00003db7, -0x00050041,0x00000182,0x00003dc8,0x00000180, -0x000002fb,0x0004003d,0x00000006,0x00003dc9, -0x00003dc8,0x000500c7,0x00000006,0x00003dca, -0x00003dc9,0x00000135,0x000500ab,0x0000002f, -0x00003dcb,0x00003dca,0x0000012b,0x000600a9, -0x00000006,0x00003dc5,0x00003dcb,0x00000309, -0x0000018b,0x00050084,0x00000006,0x00003dbb, -0x00003cae,0x00003dc5,0x00050080,0x00000006, -0x00003dbc,0x00003db8,0x00003dbb,0x000500c2, -0x00000006,0x00003dbd,0x00003dbc,0x00000318, -0x000500c4,0x00000006,0x00003dbe,0x00003dbd, -0x000002e4,0x000600a9,0x00000006,0x00003dc0, -0x00003dcb,0x0000031c,0x0000012b,0x000500c5, -0x00000006,0x00003dc1,0x00003dbe,0x00003dc0, -0x00050041,0x00000009,0x00003cb0,0x00003c67, -0x0000015e,0x0003003e,0x00003cb0,0x00003dc1, -0x000200f9,0x00003cb1,0x000200f8,0x00003cb1, -0x000200f9,0x00003d22,0x000200f8,0x00003d22, -0x000700f5,0x00000006,0x00005a10,0x0000012b, -0x00003cb1,0x00003edc,0x00003d21,0x000200f9, -0x00003d23,0x000200f8,0x00003d23,0x000700f5, -0x00000006,0x00005a0e,0x0000012b,0x00003d22, -0x00003d3c,0x00003d3a,0x000500b0,0x0000002f, -0x00003d26,0x00005a0e,0x000000df,0x000400f6, -0x00003d3d,0x00003d3a,0x00000000,0x000400fa, -0x00003d26,0x00003d27,0x00003d3d,0x000200f8, -0x00003d27,0x00050041,0x00000009,0x00003d29, -0x00003c68,0x00005a0e,0x0004003d,0x00000006, -0x00003d2a,0x00003d29,0x000500ab,0x0000002f, -0x00003d2b,0x00003d2a,0x00000500,0x000300f7, -0x00003d39,0x00000000,0x000400fa,0x00003d2b, -0x00003d2c,0x00003d39,0x000200f8,0x00003d2c, -0x00050041,0x00000182,0x000047e8,0x00000180, -0x00000181,0x0004003d,0x00000006,0x000047e9, -0x000047e8,0x00050084,0x00000006,0x000047ea, -0x000001a2,0x000047e9,0x00050080,0x00000006, -0x000047eb,0x0000018b,0x000047ea,0x00050080, -0x00000006,0x000047f1,0x000047e9,0x00005cc3, -0x00050086,0x00000006,0x000047f2,0x000047f1, -0x00000185,0x00050084,0x00000006,0x000047e4, -0x0000018b,0x000047f2,0x00050080,0x00000006, -0x000047e5,0x000047eb,0x000047e4,0x00050080, -0x00000006,0x000047df,0x000047e5,0x000047e4, -0x00050084,0x00000006,0x000047d8,0x000001b6, -0x00003ca1,0x00050080,0x00000006,0x000047d9, -0x000047df,0x000047d8,0x00050041,0x00000182, -0x000047cf,0x00000180,0x000001cd,0x0004003d, -0x00000006,0x000047d0,0x000047cf,0x00050084, -0x00000006,0x000047d1,0x000001cc,0x000047d0, -0x00050080,0x00000006,0x000047d2,0x000047d9, -0x000047d1,0x000500ac,0x0000002f,0x000047ff, -0x00003ca1,0x00000135,0x000300f7,0x00004805, -0x00000000,0x000400fa,0x000047ff,0x00004800, -0x00004804,0x000200f8,0x00004804,0x000200f9, -0x00004805,0x000200f8,0x00004800,0x00050082, -0x00000006,0x00004803,0x00003ca1,0x00000135, -0x000200f9,0x00004805,0x000200f8,0x00004805, -0x000700f5,0x00000006,0x00005a6a,0x00004803, -0x00004800,0x0000012b,0x00004804,0x00050084, -0x00000006,0x000047ca,0x000000df,0x00005a6a, -0x00050080,0x00000006,0x000047cb,0x000047d2, -0x000047ca,0x000300f7,0x00004812,0x00000000, -0x000400fa,0x000047ff,0x0000480d,0x00004811, -0x000200f8,0x00004811,0x000200f9,0x00004812, -0x000200f8,0x0000480d,0x00050082,0x00000006, -0x00004810,0x00003ca1,0x00000135,0x000200f9, -0x00004812,0x000200f8,0x00004812,0x000700f5, -0x00000006,0x00005a6b,0x00004810,0x0000480d, -0x0000012b,0x00004811,0x00050084,0x00000006, -0x000047c4,0x000000df,0x00005a6b,0x00050080, -0x00000006,0x000047c5,0x000047cb,0x000047c4, -0x000300f7,0x0000481f,0x00000000,0x000400fa, -0x000047ff,0x0000481a,0x0000481e,0x000200f8, -0x0000481e,0x000200f9,0x0000481f,0x000200f8, -0x0000481a,0x00050082,0x00000006,0x0000481d, -0x00003ca1,0x00000135,0x000200f9,0x0000481f, -0x000200f8,0x0000481f,0x000700f5,0x00000006, -0x00005a6c,0x0000481d,0x0000481a,0x0000012b, -0x0000481e,0x00050084,0x00000006,0x000047be, -0x000000df,0x00005a6c,0x00050080,0x00000006, -0x000047bf,0x000047c5,0x000047be,0x000300f7, -0x0000482c,0x00000000,0x000400fa,0x000047ff, -0x00004827,0x0000482b,0x000200f8,0x0000482b, -0x000200f9,0x0000482c,0x000200f8,0x00004827, -0x00050082,0x00000006,0x0000482a,0x00003ca1, -0x00000135,0x000200f9,0x0000482c,0x000200f8, -0x0000482c,0x000700f5,0x00000006,0x00005a6d, -0x0000482a,0x00004827,0x0000012b,0x0000482b, -0x00050084,0x00000006,0x000047b8,0x000000df, -0x00005a6d,0x00050080,0x00000006,0x000047b9, -0x000047bf,0x000047b8,0x000300f7,0x00004839, -0x00000000,0x000400fa,0x000047ff,0x00004834, -0x00004838,0x000200f8,0x00004838,0x000200f9, -0x00004839,0x000200f8,0x00004834,0x00050082, -0x00000006,0x00004837,0x00003ca1,0x00000135, -0x000200f9,0x00004839,0x000200f8,0x00004839, -0x000700f5,0x00000006,0x00005a6e,0x00004837, -0x00004834,0x0000012b,0x00004838,0x00050084, -0x00000006,0x000047b2,0x000000df,0x00005a6e, -0x00050080,0x00000006,0x000047b3,0x000047b9, -0x000047b2,0x000300f7,0x0000484c,0x00000000, -0x000400fa,0x000047ff,0x00004847,0x0000484b, -0x000200f8,0x0000484b,0x000200f9,0x0000484c, -0x000200f8,0x00004847,0x00050082,0x00000006, -0x0000484a,0x00003ca1,0x00000135,0x000200f9, -0x0000484c,0x000200f8,0x0000484c,0x000700f5, -0x00000006,0x00005a6f,0x0000484a,0x00004847, -0x0000012b,0x0000484b,0x00050080,0x00000006, -0x0000483f,0x00005a6f,0x00005cc3,0x00050086, -0x00000006,0x00004840,0x0000483f,0x00000185, -0x00050084,0x00000006,0x000047ac,0x000000df, -0x00004840,0x00050080,0x00000006,0x000047ad, -0x000047b3,0x000047ac,0x000300f7,0x0000485f, -0x00000000,0x000400fa,0x000047ff,0x0000485a, -0x0000485e,0x000200f8,0x0000485e,0x000200f9, -0x0000485f,0x000200f8,0x0000485a,0x00050082, -0x00000006,0x0000485d,0x00003ca1,0x00000135, -0x000200f9,0x0000485f,0x000200f8,0x0000485f, -0x000700f5,0x00000006,0x00005a70,0x0000485d, -0x0000485a,0x0000012b,0x0000485e,0x00050080, -0x00000006,0x00004852,0x00005a70,0x00005cc3, -0x00050086,0x00000006,0x00004853,0x00004852, -0x00000185,0x00050084,0x00000006,0x000047a6, -0x000000df,0x00004853,0x00050080,0x00000006, -0x000047a7,0x000047ad,0x000047a6,0x0004003d, -0x00000006,0x00003d30,0x00003d29,0x00050084, -0x00000006,0x00003d31,0x000000df,0x00003d30, -0x00050080,0x00000006,0x00003d32,0x000047a7, -0x00003d31,0x00050041,0x0000022d,0x00003d34, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x00003d35,0x00003d34,0x00050041,0x00000009, -0x00003d36,0x00003c67,0x00005a0e,0x0004003d, -0x00000006,0x00003d37,0x00003d36,0x00050051, -0x00000006,0x00004876,0x00003d35,0x00000000, -0x00050095,0x00000130,0x00004878,0x00004876, -0x00003d32,0x00050051,0x00000006,0x00004879, -0x00004878,0x00000001,0x00050051,0x00000006, -0x0000487a,0x00004878,0x00000000,0x00050051, -0x00000006,0x0000487d,0x00003d35,0x00000001, -0x00050080,0x00000006,0x0000487f,0x0000487d, -0x00004879,0x00050050,0x00000007,0x00004880, -0x0000487a,0x0000487f,0x0004007c,0x00000014, -0x00004870,0x00004880,0x00060041,0x0000015f, -0x00004868,0x00004870,0x0000015e,0x0000015e, -0x0005003e,0x00004868,0x00003d37,0x00000002, -0x00000004,0x000200f9,0x00003d39,0x000200f8, -0x00003d39,0x000200f9,0x00003d3a,0x000200f8, -0x00003d3a,0x00050080,0x00000006,0x00003d3c, -0x00005a0e,0x0000022b,0x000200f9,0x00003d23, -0x000200f8,0x00003d3d,0x00050041,0x00000182, -0x00004883,0x00000180,0x00000321,0x0004003d, -0x00000006,0x00004884,0x00004883,0x00050041, -0x00000182,0x00004894,0x00000180,0x000002fb, -0x0004003d,0x00000006,0x00004895,0x00004894, -0x000500c7,0x00000006,0x00004896,0x00004895, -0x00000247,0x000500ab,0x0000002f,0x00004897, -0x00004896,0x0000012b,0x000600a9,0x00000006, -0x00004891,0x00004897,0x0000018b,0x00000309, -0x00050084,0x00000006,0x00004887,0x00005a10, -0x00004891,0x00050080,0x00000006,0x00004888, -0x00004884,0x00004887,0x000500c2,0x00000006, -0x00004889,0x00004888,0x00000318,0x000500c4, -0x00000006,0x0000488a,0x00004889,0x000002e4, -0x000600a9,0x00000006,0x0000488c,0x00004897, -0x000000df,0x0000032b,0x000500c5,0x00000006, -0x0000488d,0x0000488a,0x0000488c,0x000200f9, -0x00003d46,0x000200f8,0x00003d46,0x000700f5, -0x00000006,0x00005a33,0x0000012b,0x00003d3d, -0x00003d74,0x00003d72,0x000500b0,0x0000002f, -0x00003d49,0x00005a33,0x000000df,0x000400f6, -0x00003d75,0x00003d72,0x00000000,0x000400fa, -0x00003d49,0x00003d4a,0x00003d75,0x000200f8, -0x00003d4a,0x00050084,0x00000006,0x00003d4d, -0x000000df,0x00005a33,0x00050080,0x00000006, -0x00003d4e,0x00004888,0x00003d4d,0x00050041, -0x0000022d,0x00003d50,0x00000180,0x0000015e, -0x0004003d,0x00000007,0x00003d51,0x00003d50, -0x00050041,0x00000009,0x00003d52,0x00003c67, -0x00005a33,0x0004003d,0x00000006,0x00003d53, -0x00003d52,0x00050051,0x00000006,0x000048bd, -0x00003d51,0x00000000,0x00050095,0x00000130, -0x000048bf,0x000048bd,0x00003d4e,0x00050051, -0x00000006,0x000048c0,0x000048bf,0x00000001, -0x00050051,0x00000006,0x000048c1,0x000048bf, -0x00000000,0x00050051,0x00000006,0x000048c4, -0x00003d51,0x00000001,0x00050080,0x00000006, -0x000048c6,0x000048c4,0x000048c0,0x00050050, -0x00000007,0x000048c7,0x000048c1,0x000048c6, -0x0004007c,0x00000014,0x000048b7,0x000048c7, -0x00060041,0x0000015f,0x000048af,0x000048b7, -0x0000015e,0x0000015e,0x0005003e,0x000048af, -0x00003d53,0x00000002,0x00000004,0x0004003d, -0x00000006,0x00003d57,0x00003d52,0x000500ab, -0x0000002f,0x00003d58,0x00003d57,0x00000500, -0x000300f7,0x00003d6a,0x00000000,0x000400fa, -0x00003d58,0x00003d59,0x00003d6a,0x000200f8, -0x00003d59,0x00050041,0x00000182,0x00003d5a, -0x00000180,0x00000fbf,0x0004003d,0x00000006, -0x00003d5b,0x00003d5a,0x0004003d,0x00000006, -0x00003d5e,0x00003d52,0x000500c2,0x00000006, -0x000048cb,0x00003d5e,0x000002e4,0x00050041, -0x00000182,0x00003d60,0x00000180,0x00000311, -0x0004003d,0x00000006,0x00003d61,0x00003d60, -0x00050086,0x00000006,0x00003d62,0x00003d61, -0x0000018b,0x00050082,0x00000006,0x00003d63, -0x000048cb,0x00003d62,0x00050084,0x00000006, -0x00003d64,0x000000df,0x00003d63,0x00050080, -0x00000006,0x00003d65,0x00003d5b,0x00003d64, -0x00050095,0x00000130,0x000048e3,0x000048bd, -0x00003d65,0x00050051,0x00000006,0x000048e4, -0x000048e3,0x00000001,0x00050051,0x00000006, -0x000048e5,0x000048e3,0x00000000,0x00050080, -0x00000006,0x000048ea,0x000048c4,0x000048e4, -0x00050050,0x00000007,0x000048eb,0x000048e5, -0x000048ea,0x0004007c,0x00000014,0x000048db, -0x000048eb,0x00060041,0x0000015f,0x000048d3, -0x000048db,0x0000015e,0x0000015e,0x0005003e, -0x000048d3,0x0000488d,0x00000002,0x00000004, -0x000200f9,0x00003d72,0x000200f8,0x00003d6a, -0x000300f7,0x00004944,0x00000000,0x000300fb, -0x0000012b,0x0000490a,0x000200f8,0x0000490a, -0x000300f7,0x00004915,0x00000000,0x000400fa, -0x00004897,0x0000490c,0x00004915,0x000200f8, -0x0000490c,0x00050080,0x00000006,0x0000490e, -0x00004888,0x000001a2,0x00050084,0x00000006, -0x00004910,0x0000019b,0x00005a33,0x00050080, -0x00000006,0x00004911,0x0000490e,0x00004910, -0x00050095,0x00000130,0x00004a40,0x000048bd, -0x00004911,0x00050051,0x00000006,0x00004a41, -0x00004a40,0x00000001,0x00050051,0x00000006, -0x00004a42,0x00004a40,0x00000000,0x00050080, -0x00000006,0x00004a47,0x000048c4,0x00004a41, -0x00050050,0x00000007,0x00004a48,0x00004a42, -0x00004a47,0x0004007c,0x00000014,0x00004a38, -0x00004a48,0x00060041,0x0000015f,0x00004a30, -0x00004a38,0x0000015e,0x0000015e,0x0005003e, -0x00004a30,0x00005cd7,0x00000002,0x00000004, -0x00050080,0x00000006,0x00004968,0x00004911, -0x000000df,0x00050095,0x00000130,0x00004b08, -0x000048bd,0x00004968,0x00050051,0x00000006, -0x00004b09,0x00004b08,0x00000001,0x00050051, -0x00000006,0x00004b0a,0x00004b08,0x00000000, -0x00050080,0x00000006,0x00004b0f,0x000048c4, -0x00004b09,0x00050050,0x00000007,0x00004b10, -0x00004b0a,0x00004b0f,0x0004007c,0x00000014, -0x00004b00,0x00004b10,0x00060041,0x0000015f, -0x00004af8,0x00004b00,0x0000015e,0x0000015e, -0x0005003e,0x00004af8,0x00005cd9,0x00000002, -0x00000004,0x00050080,0x00000006,0x00004975, -0x00004911,0x00000194,0x00050095,0x00000130, -0x00004bd0,0x000048bd,0x00004975,0x00050051, -0x00000006,0x00004bd1,0x00004bd0,0x00000001, -0x00050051,0x00000006,0x00004bd2,0x00004bd0, -0x00000000,0x00050080,0x00000006,0x00004bd7, -0x000048c4,0x00004bd1,0x00050050,0x00000007, -0x00004bd8,0x00004bd2,0x00004bd7,0x0004007c, -0x00000014,0x00004bc8,0x00004bd8,0x00060041, -0x0000015f,0x00004bc0,0x00004bc8,0x0000015e, -0x0000015e,0x0005003e,0x00004bc0,0x00005cda, -0x00000002,0x00000004,0x000200f9,0x00004944, -0x000200f8,0x00004915,0x00050080,0x00000006, -0x00004917,0x00004888,0x000001a2,0x00050084, -0x00000006,0x00004919,0x000001b6,0x00005a33, -0x00050080,0x00000006,0x0000491a,0x00004917, -0x00004919,0x00050095,0x00000130,0x00004bf9, -0x000048bd,0x0000491a,0x00050051,0x00000006, -0x00004bfa,0x00004bf9,0x00000001,0x00050051, -0x00000006,0x00004bfb,0x00004bf9,0x00000000, -0x00050080,0x00000006,0x00004c00,0x000048c4, -0x00004bfa,0x00050050,0x00000007,0x00004c01, -0x00004bfb,0x00004c00,0x0004007c,0x00000014, -0x00004bf1,0x00004c01,0x00060041,0x0000015f, -0x00004be9,0x00004bf1,0x0000015e,0x0000015e, -0x0005003e,0x00004be9,0x00000345,0x00000002, -0x00000004,0x00050080,0x00000006,0x00004922, -0x0000491a,0x000000df,0x00050095,0x00000130, -0x00004c22,0x000048bd,0x00004922,0x00050051, -0x00000006,0x00004c23,0x00004c22,0x00000001, -0x00050051,0x00000006,0x00004c24,0x00004c22, -0x00000000,0x00050080,0x00000006,0x00004c29, -0x000048c4,0x00004c23,0x00050050,0x00000007, -0x00004c2a,0x00004c24,0x00004c29,0x0004007c, -0x00000014,0x00004c1a,0x00004c2a,0x00060041, -0x0000015f,0x00004c12,0x00004c1a,0x0000015e, -0x0000015e,0x0005003e,0x00004c12,0x00000345, +0x000d00f5,0x00000006,0x00005d6f,0x0000560c, +0x0000560a,0x00005601,0x00005610,0x0000561d, +0x00005619,0x00005d6e,0x00005628,0x00005641, +0x0000563e,0x000500c4,0x00000006,0x000054c2, +0x00005d6f,0x0000035a,0x000500c5,0x00000006, +0x000054c3,0x00005d6b,0x000054c2,0x00050095, +0x0000013d,0x0000565b,0x000053ea,0x000054bb, +0x00050051,0x00000006,0x0000565c,0x0000565b, +0x00000001,0x00050051,0x00000006,0x0000565d, +0x0000565b,0x00000000,0x00050080,0x00000006, +0x00005662,0x000053f1,0x0000565c,0x00050050, +0x00000007,0x00005663,0x0000565d,0x00005662, +0x0004007c,0x00000014,0x00005653,0x00005663, +0x00060041,0x0000016c,0x0000564b,0x00005653, +0x0000016b,0x0000016b,0x0005003e,0x0000564b, +0x000054c3,0x00000002,0x00000004,0x00050080, +0x00000006,0x000054c8,0x00005464,0x000001cd, +0x00050051,0x00000027,0x000054ca,0x00005cf4, +0x00000001,0x000300f7,0x000056b6,0x00000000, +0x000300fb,0x00000138,0x00005670,0x000200f8, +0x00005670,0x0004007c,0x00000006,0x00005672, +0x000054ca,0x000500c2,0x00000006,0x00005674, +0x00005672,0x0000035a,0x000500c7,0x00000006, +0x00005675,0x00005674,0x00000373,0x000500c7, +0x00000006,0x00005677,0x00005672,0x00000256, +0x000500aa,0x0000002f,0x0000567b,0x00005675, +0x00000138,0x000500ac,0x0000002f,0x0000567d, +0x00005677,0x0000037e,0x000300f7,0x00005681, +0x00000000,0x000400fa,0x0000567d,0x0000567e, +0x00005681,0x000200f8,0x0000567e,0x000500c5, +0x00000006,0x00005680,0x00005675,0x00000383, +0x000200f9,0x000056b6,0x000200f8,0x00005681, +0x000500aa,0x0000002f,0x00005683,0x00005677, +0x00000138,0x000300f7,0x00005686,0x00000000, +0x000400fa,0x00005683,0x00005684,0x00005686, +0x000200f8,0x00005684,0x000200f9,0x000056b6, +0x000200f8,0x00005686,0x000500c2,0x00000006, +0x00005688,0x00005677,0x0000038e,0x0004007c, +0x000000f4,0x00005689,0x00005688,0x00050082, +0x000000f4,0x0000568a,0x00005689,0x00000391, +0x000500af,0x0000002f,0x0000568c,0x0000568a, +0x0000035a,0x000300f7,0x00005692,0x00000000, +0x000400fa,0x0000568c,0x0000568d,0x00005692, +0x000200f8,0x0000568d,0x000600a9,0x00000006, +0x00005690,0x0000567b,0x00000399,0x0000039a, +0x000500c5,0x00000006,0x00005691,0x00005675, +0x00005690,0x000200f9,0x000056b6,0x000200f8, +0x00005692,0x000500b1,0x0000002f,0x00005694, +0x0000568a,0x0000039f,0x000300f7,0x0000569e, +0x00000000,0x000400fa,0x00005694,0x00005695, +0x0000569e,0x000200f8,0x00005695,0x000300f7, +0x0000569c,0x00000000,0x000400fa,0x0000567b, +0x00005697,0x0000569a,0x000200f8,0x0000569a, +0x000200f9,0x0000569c,0x000200f8,0x00005697, +0x000500c5,0x00000006,0x00005699,0x00005675, +0x000003a8,0x000200f9,0x0000569c,0x000200f8, +0x0000569c,0x000700f5,0x00000006,0x00005d72, +0x00005699,0x00005697,0x00005675,0x0000569a, +0x000200f9,0x000056b6,0x000200f8,0x0000569e, +0x000500c7,0x00000006,0x000056a0,0x00005672, +0x000003b0,0x00050080,0x000000f4,0x000056a2, +0x00005689,0x000060ff,0x0004007c,0x00000006, +0x000056a3,0x000056a2,0x000500c4,0x00000006, +0x000056a4,0x000056a3,0x000003b6,0x000500c2, +0x00000006,0x000056a6,0x000056a0,0x000001f0, +0x000500c5,0x00000006,0x000056a7,0x000056a4, +0x000056a6,0x000300f7,0x000056ad,0x00000000, +0x000400fa,0x0000567b,0x000056a9,0x000056ad, +0x000200f8,0x000056a9,0x000500c7,0x00000006, +0x000056ab,0x00005672,0x000003bf,0x000500ab, +0x0000002f,0x000056ac,0x000056ab,0x00000138, +0x000200f9,0x000056ad,0x000200f8,0x000056ad, +0x000700f5,0x0000002f,0x000056ae,0x0000567b, +0x0000569e,0x000056ac,0x000056a9,0x000300f7, +0x000056b2,0x00000000,0x000400fa,0x000056ae, +0x000056af,0x000056b2,0x000200f8,0x000056af, +0x00050080,0x00000006,0x000056b1,0x000056a7, +0x00000142,0x000200f9,0x000056b2,0x000200f8, +0x000056b2,0x000700f5,0x00000006,0x00005d71, +0x000056a7,0x000056ad,0x000056b1,0x000056af, +0x000500c5,0x00000006,0x000056b5,0x00005675, +0x00005d71,0x000200f9,0x000056b6,0x000200f8, +0x000056b6,0x000d00f5,0x00000006,0x00005d73, +0x00005680,0x0000567e,0x00005675,0x00005684, +0x00005691,0x0000568d,0x00005d72,0x0000569c, +0x000056b5,0x000056b2,0x00050051,0x00000027, +0x000054cd,0x00005cf4,0x00000002,0x000300f7, +0x0000570a,0x00000000,0x000300fb,0x00000138, +0x000056c4,0x000200f8,0x000056c4,0x0004007c, +0x00000006,0x000056c6,0x000054cd,0x000500c2, +0x00000006,0x000056c8,0x000056c6,0x0000035a, +0x000500c7,0x00000006,0x000056c9,0x000056c8, +0x00000373,0x000500c7,0x00000006,0x000056cb, +0x000056c6,0x00000256,0x000500aa,0x0000002f, +0x000056cf,0x000056c9,0x00000138,0x000500ac, +0x0000002f,0x000056d1,0x000056cb,0x0000037e, +0x000300f7,0x000056d5,0x00000000,0x000400fa, +0x000056d1,0x000056d2,0x000056d5,0x000200f8, +0x000056d2,0x000500c5,0x00000006,0x000056d4, +0x000056c9,0x00000383,0x000200f9,0x0000570a, +0x000200f8,0x000056d5,0x000500aa,0x0000002f, +0x000056d7,0x000056cb,0x00000138,0x000300f7, +0x000056da,0x00000000,0x000400fa,0x000056d7, +0x000056d8,0x000056da,0x000200f8,0x000056d8, +0x000200f9,0x0000570a,0x000200f8,0x000056da, +0x000500c2,0x00000006,0x000056dc,0x000056cb, +0x0000038e,0x0004007c,0x000000f4,0x000056dd, +0x000056dc,0x00050082,0x000000f4,0x000056de, +0x000056dd,0x00000391,0x000500af,0x0000002f, +0x000056e0,0x000056de,0x0000035a,0x000300f7, +0x000056e6,0x00000000,0x000400fa,0x000056e0, +0x000056e1,0x000056e6,0x000200f8,0x000056e1, +0x000600a9,0x00000006,0x000056e4,0x000056cf, +0x00000399,0x0000039a,0x000500c5,0x00000006, +0x000056e5,0x000056c9,0x000056e4,0x000200f9, +0x0000570a,0x000200f8,0x000056e6,0x000500b1, +0x0000002f,0x000056e8,0x000056de,0x0000039f, +0x000300f7,0x000056f2,0x00000000,0x000400fa, +0x000056e8,0x000056e9,0x000056f2,0x000200f8, +0x000056e9,0x000300f7,0x000056f0,0x00000000, +0x000400fa,0x000056cf,0x000056eb,0x000056ee, +0x000200f8,0x000056ee,0x000200f9,0x000056f0, +0x000200f8,0x000056eb,0x000500c5,0x00000006, +0x000056ed,0x000056c9,0x000003a8,0x000200f9, +0x000056f0,0x000200f8,0x000056f0,0x000700f5, +0x00000006,0x00005d76,0x000056ed,0x000056eb, +0x000056c9,0x000056ee,0x000200f9,0x0000570a, +0x000200f8,0x000056f2,0x000500c7,0x00000006, +0x000056f4,0x000056c6,0x000003b0,0x00050080, +0x000000f4,0x000056f6,0x000056dd,0x000060ff, +0x0004007c,0x00000006,0x000056f7,0x000056f6, +0x000500c4,0x00000006,0x000056f8,0x000056f7, +0x000003b6,0x000500c2,0x00000006,0x000056fa, +0x000056f4,0x000001f0,0x000500c5,0x00000006, +0x000056fb,0x000056f8,0x000056fa,0x000300f7, +0x00005701,0x00000000,0x000400fa,0x000056cf, +0x000056fd,0x00005701,0x000200f8,0x000056fd, +0x000500c7,0x00000006,0x000056ff,0x000056c6, +0x000003bf,0x000500ab,0x0000002f,0x00005700, +0x000056ff,0x00000138,0x000200f9,0x00005701, +0x000200f8,0x00005701,0x000700f5,0x0000002f, +0x00005702,0x000056cf,0x000056f2,0x00005700, +0x000056fd,0x000300f7,0x00005706,0x00000000, +0x000400fa,0x00005702,0x00005703,0x00005706, +0x000200f8,0x00005703,0x00050080,0x00000006, +0x00005705,0x000056fb,0x00000142,0x000200f9, +0x00005706,0x000200f8,0x00005706,0x000700f5, +0x00000006,0x00005d75,0x000056fb,0x00005701, +0x00005705,0x00005703,0x000500c5,0x00000006, +0x00005709,0x000056c9,0x00005d75,0x000200f9, +0x0000570a,0x000200f8,0x0000570a,0x000d00f5, +0x00000006,0x00005d77,0x000056d4,0x000056d2, +0x000056c9,0x000056d8,0x000056e5,0x000056e1, +0x00005d76,0x000056f0,0x00005709,0x00005706, +0x000500c4,0x00000006,0x000054cf,0x00005d77, +0x0000035a,0x000500c5,0x00000006,0x000054d0, +0x00005d73,0x000054cf,0x00050095,0x0000013d, +0x00005723,0x000053ea,0x000054c8,0x00050051, +0x00000006,0x00005724,0x00005723,0x00000001, +0x00050051,0x00000006,0x00005725,0x00005723, +0x00000000,0x00050080,0x00000006,0x0000572a, +0x000053f1,0x00005724,0x00050050,0x00000007, +0x0000572b,0x00005725,0x0000572a,0x0004007c, +0x00000014,0x0000571b,0x0000572b,0x00060041, +0x0000016c,0x00005713,0x0000571b,0x0000016b, +0x0000016b,0x0005003e,0x00005713,0x000054d0, +0x00000002,0x00000004,0x000200f9,0x00005497, +0x000200f8,0x00005468,0x00050080,0x00000006, +0x0000546a,0x0000513c,0x000001db,0x00050084, +0x00000006,0x0000546c,0x000001ef,0x00005cee, +0x00050080,0x00000006,0x0000546d,0x0000546a, +0x0000546c,0x00050051,0x00000027,0x00005472, +0x00005cf1,0x00000000,0x0004007c,0x00000006, +0x00005731,0x00005472,0x00050095,0x0000013d, +0x0000574c,0x000053ea,0x0000546d,0x00050051, +0x00000006,0x0000574d,0x0000574c,0x00000001, +0x00050051,0x00000006,0x0000574e,0x0000574c, +0x00000000,0x00050080,0x00000006,0x00005753, +0x000053f1,0x0000574d,0x00050050,0x00000007, +0x00005754,0x0000574e,0x00005753,0x0004007c, +0x00000014,0x00005744,0x00005754,0x00060041, +0x0000016c,0x0000573c,0x00005744,0x0000016b, +0x0000016b,0x0005003e,0x0000573c,0x00005731, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00005475,0x0000546d,0x000000ec,0x00050051, +0x00000027,0x00005479,0x00005cf1,0x00000001, +0x0004007c,0x00000006,0x0000575a,0x00005479, +0x00050095,0x0000013d,0x00005775,0x000053ea, +0x00005475,0x00050051,0x00000006,0x00005776, +0x00005775,0x00000001,0x00050051,0x00000006, +0x00005777,0x00005775,0x00000000,0x00050080, +0x00000006,0x0000577c,0x000053f1,0x00005776, +0x00050050,0x00000007,0x0000577d,0x00005777, +0x0000577c,0x0004007c,0x00000014,0x0000576d, +0x0000577d,0x00060041,0x0000016c,0x00005765, +0x0000576d,0x0000016b,0x0000016b,0x0005003e, +0x00005765,0x0000575a,0x00000002,0x00000004, +0x00050080,0x00000006,0x0000547c,0x0000546d, +0x000001cd,0x00050051,0x00000027,0x00005480, +0x00005cf1,0x00000002,0x0004007c,0x00000006, +0x00005783,0x00005480,0x00050095,0x0000013d, +0x0000579e,0x000053ea,0x0000547c,0x00050051, +0x00000006,0x0000579f,0x0000579e,0x00000001, +0x00050051,0x00000006,0x000057a0,0x0000579e, +0x00000000,0x00050080,0x00000006,0x000057a5, +0x000053f1,0x0000579f,0x00050050,0x00000007, +0x000057a6,0x000057a0,0x000057a5,0x0004007c, +0x00000014,0x00005796,0x000057a6,0x00060041, +0x0000016c,0x0000578e,0x00005796,0x0000016b, +0x0000016b,0x0005003e,0x0000578e,0x00005783, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00005483,0x0000546d,0x000001d4,0x00050051, +0x00000027,0x00005487,0x00005cf4,0x00000000, +0x0004007c,0x00000006,0x000057ac,0x00005487, +0x00050095,0x0000013d,0x000057c7,0x000053ea, +0x00005483,0x00050051,0x00000006,0x000057c8, +0x000057c7,0x00000001,0x00050051,0x00000006, +0x000057c9,0x000057c7,0x00000000,0x00050080, +0x00000006,0x000057ce,0x000053f1,0x000057c8, +0x00050050,0x00000007,0x000057cf,0x000057c9, +0x000057ce,0x0004007c,0x00000014,0x000057bf, +0x000057cf,0x00060041,0x0000016c,0x000057b7, +0x000057bf,0x0000016b,0x0000016b,0x0005003e, +0x000057b7,0x000057ac,0x00000002,0x00000004, +0x00050080,0x00000006,0x0000548a,0x0000546d, +0x000001db,0x00050051,0x00000027,0x0000548e, +0x00005cf4,0x00000001,0x0004007c,0x00000006, +0x000057d5,0x0000548e,0x00050095,0x0000013d, +0x000057f0,0x000053ea,0x0000548a,0x00050051, +0x00000006,0x000057f1,0x000057f0,0x00000001, +0x00050051,0x00000006,0x000057f2,0x000057f0, +0x00000000,0x00050080,0x00000006,0x000057f7, +0x000053f1,0x000057f1,0x00050050,0x00000007, +0x000057f8,0x000057f2,0x000057f7,0x0004007c, +0x00000014,0x000057e8,0x000057f8,0x00060041, +0x0000016c,0x000057e0,0x000057e8,0x0000016b, +0x0000016b,0x0005003e,0x000057e0,0x000057d5, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00005491,0x0000546d,0x00000299,0x00050051, +0x00000027,0x00005495,0x00005cf4,0x00000002, +0x0004007c,0x00000006,0x000057fe,0x00005495, +0x00050095,0x0000013d,0x00005819,0x000053ea, +0x00005491,0x00050051,0x00000006,0x0000581a, +0x00005819,0x00000001,0x00050051,0x00000006, +0x0000581b,0x00005819,0x00000000,0x00050080, +0x00000006,0x00005820,0x000053f1,0x0000581a, +0x00050050,0x00000007,0x00005821,0x0000581b, +0x00005820,0x0004007c,0x00000014,0x00005811, +0x00005821,0x00060041,0x0000016c,0x00005809, +0x00005811,0x0000016b,0x0000016b,0x0005003e, +0x00005809,0x000057fe,0x00000002,0x00000004, +0x000200f9,0x00005497,0x000200f8,0x00005497, +0x000200f9,0x0000515a,0x000200f8,0x0000515a, +0x000200f9,0x0000515b,0x000200f8,0x0000515b, +0x000700f5,0x00000006,0x00006026,0x00005d0a, +0x0000514b,0x0000514e,0x0000515a,0x00050080, +0x00000006,0x0000515d,0x00005cee,0x00000264, +0x000200f9,0x0000513d,0x000200f8,0x0000515e, +0x00050041,0x000001bb,0x00005829,0x000001b9, +0x0000035a,0x0004003d,0x00000006,0x0000582a, +0x00005829,0x00050082,0x00000006,0x0000582b, +0x0000513c,0x0000582a,0x000500c7,0x00000006, +0x00005837,0x00005ceb,0x00000d2b,0x000500aa, +0x0000002f,0x00005838,0x00005837,0x000000ec, +0x000600a9,0x00000006,0x0000582e,0x00005838, +0x000001c4,0x00000342,0x00050086,0x00000006, +0x0000582f,0x0000582b,0x0000582e,0x00050041, +0x000001bb,0x00005847,0x000001b9,0x000001f0, +0x0004003d,0x00000006,0x00005848,0x00005847, +0x00050084,0x00000006,0x00005849,0x000001ef, +0x00005848,0x00050080,0x00000006,0x0000584a, +0x000052dd,0x00005849,0x00050084,0x00000006, +0x0000583f,0x00000205,0x0000582f,0x00050080, +0x00000006,0x00005840,0x0000584a,0x0000583f, +0x00050095,0x0000013d,0x0000587a,0x0000530e, +0x00005840,0x00050051,0x00000006,0x0000587b, +0x0000587a,0x00000001,0x00050051,0x00000006, +0x0000587c,0x0000587a,0x00000000,0x00050080, +0x00000006,0x00005881,0x00005315,0x0000587b, +0x00050050,0x00000007,0x00005882,0x0000587c, +0x00005881,0x0004007c,0x00000014,0x00005872, +0x00005882,0x00050051,0x00000027,0x00005886, +0x00005cf1,0x00000000,0x00050051,0x00000027, +0x00005888,0x00005cf4,0x00000000,0x000500bc, +0x0000002f,0x00005889,0x00005886,0x00005888, +0x000300f7,0x00005890,0x00000000,0x000400fa, +0x00005889,0x0000588a,0x00005890,0x000200f8, +0x0000588a,0x00050051,0x00000027,0x0000588c, +0x00005cf1,0x00000001,0x00050051,0x00000027, +0x0000588e,0x00005cf4,0x00000001,0x000500bc, +0x0000002f,0x0000588f,0x0000588c,0x0000588e, +0x000200f9,0x00005890,0x000200f8,0x00005890, +0x000700f5,0x0000002f,0x00005891,0x00005889, +0x0000515e,0x0000588f,0x0000588a,0x000300f7, +0x00005898,0x00000000,0x000400fa,0x00005891, +0x00005892,0x00005898,0x000200f8,0x00005892, +0x00050051,0x00000027,0x00005894,0x00005cf1, +0x00000002,0x00050051,0x00000027,0x00005896, +0x00005cf4,0x00000002,0x000500bc,0x0000002f, +0x00005897,0x00005894,0x00005896,0x000200f9, +0x00005898,0x000200f8,0x00005898,0x000700f5, +0x0000002f,0x00005899,0x00005891,0x00005890, +0x00005897,0x00005892,0x000300f7,0x0000518c, +0x00000000,0x000400fa,0x00005899,0x00005167, +0x0000518c,0x000200f8,0x00005167,0x00060041, +0x0000016c,0x00005169,0x00005872,0x0000016b, +0x00000264,0x0004007c,0x00000006,0x000058a0, +0x00005886,0x000500c7,0x00000006,0x000058a2, +0x000058a0,0x00000241,0x000500ab,0x0000002f, +0x000058a3,0x000058a2,0x00000138,0x000300f7, +0x000058aa,0x00000000,0x000400fa,0x000058a3, +0x000058a4,0x000058a7,0x000200f8,0x000058a7, +0x000500c5,0x00000006,0x000058a9,0x000058a0, +0x00000241,0x000200f9,0x000058aa,0x000200f8, +0x000058a4,0x000400c8,0x00000006,0x000058a6, +0x000058a0,0x000200f9,0x000058aa,0x000200f8, +0x000058aa,0x000700f5,0x00000006,0x00005cf8, +0x000058a6,0x000058a4,0x000058a9,0x000058a7, +0x000700ed,0x00000006,0x0000516d,0x00005169, +0x00000142,0x00000138,0x00005cf8,0x00060041, +0x0000016c,0x0000516f,0x00005872,0x0000016b, +0x00000315,0x00050051,0x00000027,0x00005171, +0x00005cf1,0x00000001,0x0004007c,0x00000006, +0x000058b1,0x00005171,0x000500c7,0x00000006, +0x000058b3,0x000058b1,0x00000241,0x000500ab, +0x0000002f,0x000058b4,0x000058b3,0x00000138, +0x000300f7,0x000058bb,0x00000000,0x000400fa, +0x000058b4,0x000058b5,0x000058b8,0x000200f8, +0x000058b8,0x000500c5,0x00000006,0x000058ba, +0x000058b1,0x00000241,0x000200f9,0x000058bb, +0x000200f8,0x000058b5,0x000400c8,0x00000006, +0x000058b7,0x000058b1,0x000200f9,0x000058bb, +0x000200f8,0x000058bb,0x000700f5,0x00000006, +0x00005cfa,0x000058b7,0x000058b5,0x000058ba, +0x000058b8,0x000700ed,0x00000006,0x00005173, +0x0000516f,0x00000142,0x00000138,0x00005cfa, +0x00060041,0x0000016c,0x00005175,0x00005872, +0x0000016b,0x0000031d,0x00050051,0x00000027, +0x00005177,0x00005cf1,0x00000002,0x0004007c, +0x00000006,0x000058c2,0x00005177,0x000500c7, +0x00000006,0x000058c4,0x000058c2,0x00000241, +0x000500ab,0x0000002f,0x000058c5,0x000058c4, +0x00000138,0x000300f7,0x000058cc,0x00000000, +0x000400fa,0x000058c5,0x000058c6,0x000058c9, +0x000200f8,0x000058c9,0x000500c5,0x00000006, +0x000058cb,0x000058c2,0x00000241,0x000200f9, +0x000058cc,0x000200f8,0x000058c6,0x000400c8, +0x00000006,0x000058c8,0x000058c2,0x000200f9, +0x000058cc,0x000200f8,0x000058cc,0x000700f5, +0x00000006,0x00005cfc,0x000058c8,0x000058c6, +0x000058cb,0x000058c9,0x000700ed,0x00000006, +0x00005179,0x00005175,0x00000142,0x00000138, +0x00005cfc,0x00060041,0x0000016c,0x0000517b, +0x00005872,0x0000016b,0x00000325,0x0004007c, +0x00000006,0x000058d3,0x00005888,0x000500c7, +0x00000006,0x000058d5,0x000058d3,0x00000241, +0x000500ab,0x0000002f,0x000058d6,0x000058d5, +0x00000138,0x000300f7,0x000058dd,0x00000000, +0x000400fa,0x000058d6,0x000058d7,0x000058da, +0x000200f8,0x000058da,0x000500c5,0x00000006, +0x000058dc,0x000058d3,0x00000241,0x000200f9, +0x000058dd,0x000200f8,0x000058d7,0x000400c8, +0x00000006,0x000058d9,0x000058d3,0x000200f9, +0x000058dd,0x000200f8,0x000058dd,0x000700f5, +0x00000006,0x00005d02,0x000058d9,0x000058d7, +0x000058dc,0x000058da,0x000700ef,0x00000006, +0x0000517f,0x0000517b,0x00000142,0x00000138, +0x00005d02,0x00060041,0x0000016c,0x00005181, +0x00005872,0x0000016b,0x0000032d,0x00050051, +0x00000027,0x00005183,0x00005cf4,0x00000001, +0x0004007c,0x00000006,0x000058e4,0x00005183, +0x000500c7,0x00000006,0x000058e6,0x000058e4, +0x00000241,0x000500ab,0x0000002f,0x000058e7, +0x000058e6,0x00000138,0x000300f7,0x000058ee, +0x00000000,0x000400fa,0x000058e7,0x000058e8, +0x000058eb,0x000200f8,0x000058eb,0x000500c5, +0x00000006,0x000058ed,0x000058e4,0x00000241, +0x000200f9,0x000058ee,0x000200f8,0x000058e8, +0x000400c8,0x00000006,0x000058ea,0x000058e4, +0x000200f9,0x000058ee,0x000200f8,0x000058ee, +0x000700f5,0x00000006,0x00005d04,0x000058ea, +0x000058e8,0x000058ed,0x000058eb,0x000700ef, +0x00000006,0x00005185,0x00005181,0x00000142, +0x00000138,0x00005d04,0x00060041,0x0000016c, +0x00005187,0x00005872,0x0000016b,0x00000351, +0x00050051,0x00000027,0x00005189,0x00005cf4, +0x00000002,0x0004007c,0x00000006,0x000058f5, +0x00005189,0x000500c7,0x00000006,0x000058f7, +0x000058f5,0x00000241,0x000500ab,0x0000002f, +0x000058f8,0x000058f7,0x00000138,0x000300f7, +0x000058ff,0x00000000,0x000400fa,0x000058f8, +0x000058f9,0x000058fc,0x000200f8,0x000058fc, +0x000500c5,0x00000006,0x000058fe,0x000058f5, +0x00000241,0x000200f9,0x000058ff,0x000200f8, +0x000058f9,0x000400c8,0x00000006,0x000058fb, +0x000058f5,0x000200f9,0x000058ff,0x000200f8, +0x000058ff,0x000700f5,0x00000006,0x00005d06, +0x000058fb,0x000058f9,0x000058fe,0x000058fc, +0x000700ef,0x00000006,0x0000518b,0x00005187, +0x00000142,0x00000138,0x00005d06,0x000200f9, +0x0000518c,0x000200f8,0x0000518c,0x00060041, +0x0000016c,0x0000518e,0x00005872,0x0000016b, +0x0000016b,0x000700ea,0x00000006,0x0000518f, +0x0000518e,0x00000264,0x00000820,0x00000142, +0x00050080,0x00000006,0x00005191,0x0000518f, +0x00000142,0x000500ab,0x0000002f,0x00005193, +0x00005191,0x00005d0a,0x000300f7,0x00005195, +0x00000000,0x000400fa,0x00005193,0x00005194, +0x00005195,0x000200f8,0x00005194,0x000200f9, +0x000051a0,0x000200f8,0x00005195,0x000300f7, +0x0000593b,0x00000000,0x000300fb,0x00000138, +0x0000590d,0x000200f8,0x0000590d,0x000200f9, +0x00005910,0x000200f8,0x00005910,0x000700f5, +0x00000006,0x00005d11,0x00000138,0x0000590d, +0x0000591e,0x00005914,0x000500b0,0x0000002f, +0x00005913,0x00005d11,0x00000355,0x000400f6, +0x0000591f,0x00005914,0x00000000,0x000400fa, +0x00005913,0x00005914,0x0000591f,0x000200f8, +0x00005914,0x00050080,0x00000006,0x00005918, +0x00000142,0x00005d11,0x00060041,0x0000016c, +0x00005919,0x00005872,0x0000016b,0x00005918, +0x000700f1,0x00000006,0x0000591a,0x00005919, +0x00000142,0x00000138,0x00000138,0x00050041, +0x00000009,0x0000591b,0x00005905,0x00005d11, +0x0003003e,0x0000591b,0x0000591a,0x00050080, +0x00000006,0x0000591e,0x00005d11,0x00000264, +0x000200f9,0x00005910,0x000200f8,0x0000591f, +0x00050041,0x00000009,0x00005920,0x00005905, +0x0000016b,0x0004003d,0x00000006,0x00005921, +0x00005920,0x000500aa,0x0000002f,0x00005922, +0x00005921,0x00000539,0x000300f7,0x00005926, +0x00000000,0x000400fa,0x00005922,0x00005923, +0x00005926,0x000200f8,0x00005923,0x000200f9, +0x0000593b,0x000200f8,0x00005926,0x0004003d, +0x00000006,0x00005928,0x00005920,0x000500c7, +0x00000006,0x0000598a,0x00005928,0x00000241, +0x000500ab,0x0000002f,0x0000598b,0x0000598a, +0x00000138,0x000300f7,0x00005992,0x00000000, +0x000400fa,0x0000598b,0x0000598c,0x0000598f, +0x000200f8,0x0000598f,0x000400c8,0x00000006, +0x00005991,0x00005928,0x000200f9,0x00005992, +0x000200f8,0x0000598c,0x000500c7,0x00000006, +0x0000598e,0x00005928,0x00000256,0x000200f9, +0x00005992,0x000200f8,0x00005992,0x000700f5, +0x00000006,0x00005d12,0x0000598e,0x0000598c, +0x00005991,0x0000598f,0x0004007c,0x00000027, +0x00005994,0x00005d12,0x00050041,0x00000009, +0x0000592a,0x00005905,0x00000264,0x0004003d, +0x00000006,0x0000592b,0x0000592a,0x000500c7, +0x00000006,0x00005999,0x0000592b,0x00000241, +0x000500ab,0x0000002f,0x0000599a,0x00005999, +0x00000138,0x000300f7,0x000059a1,0x00000000, +0x000400fa,0x0000599a,0x0000599b,0x0000599e, +0x000200f8,0x0000599e,0x000400c8,0x00000006, +0x000059a0,0x0000592b,0x000200f9,0x000059a1, +0x000200f8,0x0000599b,0x000500c7,0x00000006, +0x0000599d,0x0000592b,0x00000256,0x000200f9, +0x000059a1,0x000200f8,0x000059a1,0x000700f5, +0x00000006,0x00005d13,0x0000599d,0x0000599b, +0x000059a0,0x0000599e,0x0004007c,0x00000027, +0x000059a3,0x00005d13,0x00050041,0x00000009, +0x0000592d,0x00005905,0x00000315,0x0004003d, +0x00000006,0x0000592e,0x0000592d,0x000500c7, +0x00000006,0x000059a8,0x0000592e,0x00000241, +0x000500ab,0x0000002f,0x000059a9,0x000059a8, +0x00000138,0x000300f7,0x000059b0,0x00000000, +0x000400fa,0x000059a9,0x000059aa,0x000059ad, +0x000200f8,0x000059ad,0x000400c8,0x00000006, +0x000059af,0x0000592e,0x000200f9,0x000059b0, +0x000200f8,0x000059aa,0x000500c7,0x00000006, +0x000059ac,0x0000592e,0x00000256,0x000200f9, +0x000059b0,0x000200f8,0x000059b0,0x000700f5, +0x00000006,0x00005d14,0x000059ac,0x000059aa, +0x000059af,0x000059ad,0x0004007c,0x00000027, +0x000059b2,0x00005d14,0x00060050,0x0000006c, +0x00005930,0x00005994,0x000059a3,0x000059b2, +0x00050041,0x00000009,0x00005931,0x00005905, +0x0000031d,0x0004003d,0x00000006,0x00005932, +0x00005931,0x000500c7,0x00000006,0x000059b7, +0x00005932,0x00000241,0x000500ab,0x0000002f, +0x000059b8,0x000059b7,0x00000138,0x000300f7, +0x000059bf,0x00000000,0x000400fa,0x000059b8, +0x000059b9,0x000059bc,0x000200f8,0x000059bc, +0x000400c8,0x00000006,0x000059be,0x00005932, +0x000200f9,0x000059bf,0x000200f8,0x000059b9, +0x000500c7,0x00000006,0x000059bb,0x00005932, +0x00000256,0x000200f9,0x000059bf,0x000200f8, +0x000059bf,0x000700f5,0x00000006,0x00005d15, +0x000059bb,0x000059b9,0x000059be,0x000059bc, +0x0004007c,0x00000027,0x000059c1,0x00005d15, +0x00050041,0x00000009,0x00005934,0x00005905, +0x00000325,0x0004003d,0x00000006,0x00005935, +0x00005934,0x000500c7,0x00000006,0x000059c6, +0x00005935,0x00000241,0x000500ab,0x0000002f, +0x000059c7,0x000059c6,0x00000138,0x000300f7, +0x000059ce,0x00000000,0x000400fa,0x000059c7, +0x000059c8,0x000059cb,0x000200f8,0x000059cb, +0x000400c8,0x00000006,0x000059cd,0x00005935, +0x000200f9,0x000059ce,0x000200f8,0x000059c8, +0x000500c7,0x00000006,0x000059ca,0x00005935, +0x00000256,0x000200f9,0x000059ce,0x000200f8, +0x000059ce,0x000700f5,0x00000006,0x00005d16, +0x000059ca,0x000059c8,0x000059cd,0x000059cb, +0x0004007c,0x00000027,0x000059d0,0x00005d16, +0x00050041,0x00000009,0x00005937,0x00005905, +0x0000032d,0x0004003d,0x00000006,0x00005938, +0x00005937,0x000500c7,0x00000006,0x000059d5, +0x00005938,0x00000241,0x000500ab,0x0000002f, +0x000059d6,0x000059d5,0x00000138,0x000300f7, +0x000059dd,0x00000000,0x000400fa,0x000059d6, +0x000059d7,0x000059da,0x000200f8,0x000059da, +0x000400c8,0x00000006,0x000059dc,0x00005938, +0x000200f9,0x000059dd,0x000200f8,0x000059d7, +0x000500c7,0x00000006,0x000059d9,0x00005938, +0x00000256,0x000200f9,0x000059dd,0x000200f8, +0x000059dd,0x000700f5,0x00000006,0x00005d17, +0x000059d9,0x000059d7,0x000059dc,0x000059da, +0x0004007c,0x00000027,0x000059df,0x00005d17, +0x00060050,0x0000006c,0x0000593a,0x000059c1, +0x000059d0,0x000059df,0x000200f9,0x0000593b, +0x000200f8,0x0000593b,0x000700f5,0x0000006c, +0x00005d1c,0x000060fe,0x00005923,0x0000593a, +0x000059dd,0x000700f5,0x0000006c,0x00005d18, +0x00000576,0x00005923,0x00005930,0x000059dd, +0x00050082,0x00000006,0x000059ec,0x0000541e, +0x000053c9,0x00050084,0x00000006,0x000059ed, +0x000000ec,0x000059ec,0x00050080,0x00000006, +0x000059ee,0x000053c4,0x000059ed,0x00050095, +0x0000013d,0x00005a0e,0x000053ea,0x000059ee, +0x00050051,0x00000006,0x00005a0f,0x00005a0e, +0x00000001,0x00050051,0x00000006,0x00005a10, +0x00005a0e,0x00000000,0x00050080,0x00000006, +0x00005a15,0x000053f1,0x00005a0f,0x00050050, +0x00000007,0x00005a16,0x00005a10,0x00005a15, +0x0004007c,0x00000014,0x00005a06,0x00005a16, +0x00060041,0x0000016c,0x000059fd,0x00005a06, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000059fe,0x000059fd,0x00000002,0x00000004, +0x000200f9,0x0000519d,0x000200f8,0x0000519d, +0x00050080,0x00000006,0x0000519f,0x00005ced, +0x00000264,0x000200f9,0x00005132,0x000200f8, +0x000051a0,0x000700f5,0x0000002f,0x00005d40, +0x000003cc,0x00005132,0x000003e7,0x00005194, +0x000300f7,0x000051a2,0x00000000,0x000400fa, +0x00005d40,0x000051a3,0x000051a2,0x000200f8, +0x000051a2,0x000200f9,0x000051a3,0x000200f8, +0x000051a3,0x000200f9,0x000013ed,0x000200f8, +0x000013ed,0x000200f9,0x000013e3,0x000200f8, +0x000013e2,0x000300f7,0x00004119,0x00000000, +0x000300fb,0x00000138,0x0000402b,0x000200f8, +0x0000402b,0x0003003e,0x00003ff3,0x00000fd5, +0x0003003e,0x00003ff4,0x00000fd5,0x00050041, +0x000001bb,0x0000402c,0x000001b9,0x000001f0, +0x0004003d,0x00000006,0x0000402d,0x0000402c, +0x000500b2,0x0000002f,0x0000402e,0x0000402d, +0x00000142,0x000300f7,0x000040ae,0x00000000, +0x000400fa,0x0000402e,0x0000402f,0x0000403e, +0x000200f8,0x0000403e,0x00050041,0x000001bb, +0x0000418c,0x000001b9,0x000001ba,0x0004003d, +0x00000006,0x0000418d,0x0000418c,0x00050084, +0x00000006,0x0000418e,0x000001db,0x0000418d, +0x00050080,0x00000006,0x0000418f,0x000001c4, +0x0000418e,0x00050080,0x00000006,0x00004195, +0x0000418d,0x0000062f,0x00050086,0x00000006, +0x00004196,0x00004195,0x000001be,0x00050084, +0x00000006,0x00004188,0x000001c4,0x00004196, +0x00050080,0x00000006,0x00004189,0x0000418f, +0x00004188,0x00050080,0x00000006,0x00004183, +0x00004189,0x00004188,0x00050084,0x00000006, +0x0000417c,0x000001ef,0x0000402d,0x00050080, +0x00000006,0x0000417d,0x00004183,0x0000417c, +0x00050041,0x000001bb,0x00004173,0x000001b9, +0x00000206,0x0004003d,0x00000006,0x00004174, +0x00004173,0x00050084,0x00000006,0x00004175, +0x00000205,0x00004174,0x00050080,0x00000006, +0x00004176,0x0000417d,0x00004175,0x000500ac, +0x0000002f,0x000041a3,0x0000402d,0x00000142, +0x000300f7,0x000041a9,0x00000000,0x000400fa, +0x000041a3,0x000041a4,0x000041a8,0x000200f8, +0x000041a8,0x000200f9,0x000041a9,0x000200f8, +0x000041a4,0x00050082,0x00000006,0x000041a7, +0x0000402d,0x00000142,0x000200f9,0x000041a9, +0x000200f8,0x000041a9,0x000700f5,0x00000006, +0x00005d93,0x000041a7,0x000041a4,0x00000138, +0x000041a8,0x00050084,0x00000006,0x0000416e, +0x000000ec,0x00005d93,0x00050080,0x00000006, +0x0000416f,0x00004176,0x0000416e,0x000300f7, +0x000041b6,0x00000000,0x000400fa,0x000041a3, +0x000041b1,0x000041b5,0x000200f8,0x000041b5, +0x000200f9,0x000041b6,0x000200f8,0x000041b1, +0x00050082,0x00000006,0x000041b4,0x0000402d, +0x00000142,0x000200f9,0x000041b6,0x000200f8, +0x000041b6,0x000700f5,0x00000006,0x00005d94, +0x000041b4,0x000041b1,0x00000138,0x000041b5, +0x00050084,0x00000006,0x00004168,0x000000ec, +0x00005d94,0x00050080,0x00000006,0x00004169, +0x0000416f,0x00004168,0x000300f7,0x000041c3, +0x00000000,0x000400fa,0x000041a3,0x000041be, +0x000041c2,0x000200f8,0x000041c2,0x000200f9, +0x000041c3,0x000200f8,0x000041be,0x00050082, +0x00000006,0x000041c1,0x0000402d,0x00000142, +0x000200f9,0x000041c3,0x000200f8,0x000041c3, +0x000700f5,0x00000006,0x00005d95,0x000041c1, +0x000041be,0x00000138,0x000041c2,0x00050084, +0x00000006,0x00004162,0x000000ec,0x00005d95, +0x00050080,0x00000006,0x00004163,0x00004169, +0x00004162,0x00050084,0x00000006,0x00004041, +0x000000ec,0x000012dd,0x00050080,0x00000006, +0x00004042,0x00004163,0x00004041,0x00050041, +0x00000266,0x00004043,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00004044,0x00004043, +0x00050051,0x00000006,0x000041db,0x00004044, +0x00000000,0x00050095,0x0000013d,0x000041dd, +0x000041db,0x00004042,0x00050051,0x00000006, +0x000041de,0x000041dd,0x00000001,0x00050051, +0x00000006,0x000041df,0x000041dd,0x00000000, +0x00050051,0x00000006,0x000041e2,0x00004044, +0x00000001,0x00050080,0x00000006,0x000041e4, +0x000041e2,0x000041de,0x00050050,0x00000007, +0x000041e5,0x000041df,0x000041e4,0x0004007c, +0x00000014,0x000041d5,0x000041e5,0x00060041, +0x0000016c,0x000041cc,0x000041d5,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000041cd, +0x000041cc,0x00000002,0x00000004,0x000500aa, +0x0000002f,0x00004046,0x000041cd,0x00000138, +0x000300f7,0x00004048,0x00000000,0x000400fa, +0x00004046,0x00004047,0x00004048,0x000200f8, +0x00004047,0x000200f9,0x00004119,0x000200f8, +0x00004048,0x000300f7,0x00004237,0x00000000, +0x000400fa,0x000041a3,0x00004232,0x00004236, +0x000200f8,0x00004236,0x000200f9,0x00004237, +0x000200f8,0x00004232,0x00050082,0x00000006, +0x00004235,0x0000402d,0x00000142,0x000200f9, +0x00004237,0x000200f8,0x00004237,0x000700f5, +0x00000006,0x00005d96,0x00004235,0x00004232, +0x00000138,0x00004236,0x00050084,0x00000006, +0x000041fc,0x000000ec,0x00005d96,0x00050080, +0x00000006,0x000041fd,0x00004176,0x000041fc, +0x000300f7,0x00004244,0x00000000,0x000400fa, +0x000041a3,0x0000423f,0x00004243,0x000200f8, +0x00004243,0x000200f9,0x00004244,0x000200f8, +0x0000423f,0x00050082,0x00000006,0x00004242, +0x0000402d,0x00000142,0x000200f9,0x00004244, +0x000200f8,0x00004244,0x000700f5,0x00000006, +0x00005d97,0x00004242,0x0000423f,0x00000138, +0x00004243,0x00050084,0x00000006,0x000041f6, +0x000000ec,0x00005d97,0x00050080,0x00000006, +0x000041f7,0x000041fd,0x000041f6,0x000300f7, +0x00004251,0x00000000,0x000400fa,0x000041a3, +0x0000424c,0x00004250,0x000200f8,0x00004250, +0x000200f9,0x00004251,0x000200f8,0x0000424c, +0x00050082,0x00000006,0x0000424f,0x0000402d, +0x00000142,0x000200f9,0x00004251,0x000200f8, +0x00004251,0x000700f5,0x00000006,0x00005d98, +0x0000424f,0x0000424c,0x00000138,0x00004250, +0x00050084,0x00000006,0x000041f0,0x000000ec, +0x00005d98,0x00050080,0x00000006,0x000041f1, +0x000041f7,0x000041f0,0x000300f7,0x0000425e, +0x00000000,0x000400fa,0x000041a3,0x00004259, +0x0000425d,0x000200f8,0x0000425d,0x000200f9, +0x0000425e,0x000200f8,0x00004259,0x00050082, +0x00000006,0x0000425c,0x0000402d,0x00000142, +0x000200f9,0x0000425e,0x000200f8,0x0000425e, +0x000700f5,0x00000006,0x00005d99,0x0000425c, +0x00004259,0x00000138,0x0000425d,0x00050084, +0x00000006,0x000041ea,0x000000ec,0x00005d99, +0x00050080,0x00000006,0x000041eb,0x000041f1, +0x000041ea,0x00050080,0x00000006,0x0000404c, +0x000041eb,0x00004041,0x00050095,0x0000013d, +0x00004278,0x000041db,0x0000404c,0x00050051, +0x00000006,0x00004279,0x00004278,0x00000001, +0x00050051,0x00000006,0x0000427a,0x00004278, +0x00000000,0x00050080,0x00000006,0x0000427f, +0x000041e2,0x00004279,0x00050050,0x00000007, +0x00004280,0x0000427a,0x0000427f,0x0004007c, +0x00000014,0x00004270,0x00004280,0x00060041, +0x0000016c,0x00004267,0x00004270,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00004268, +0x00004267,0x00000002,0x00000004,0x000500ae, +0x0000002f,0x00004053,0x00004268,0x00004174, +0x000300f7,0x00004055,0x00000000,0x000400fa, +0x00004053,0x00004054,0x00004055,0x000200f8, +0x00004054,0x000200f9,0x00004119,0x000200f8, +0x00004055,0x00050080,0x00000006,0x00004059, +0x00004176,0x00004041,0x00050095,0x0000013d, +0x000042c7,0x000041db,0x00004059,0x00050051, +0x00000006,0x000042c8,0x000042c7,0x00000001, +0x00050051,0x00000006,0x000042c9,0x000042c7, +0x00000000,0x00050080,0x00000006,0x000042ce, +0x000041e2,0x000042c8,0x00050050,0x00000007, +0x000042cf,0x000042c9,0x000042ce,0x0004007c, +0x00000014,0x000042bf,0x000042cf,0x00060041, +0x0000016c,0x000042b6,0x000042bf,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000042b7, +0x000042b6,0x00000002,0x00000004,0x000300f7, +0x0000430f,0x00000000,0x000400fa,0x000041a3, +0x0000430a,0x0000430e,0x000200f8,0x0000430e, +0x000200f9,0x0000430f,0x000200f8,0x0000430a, +0x00050082,0x00000006,0x0000430d,0x0000402d, +0x00000142,0x000200f9,0x0000430f,0x000200f8, +0x0000430f,0x000700f5,0x00000006,0x00005d9a, +0x0000430d,0x0000430a,0x00000138,0x0000430e, +0x00050084,0x00000006,0x000042d4,0x000000ec, +0x00005d9a,0x00050080,0x00000006,0x000042d5, +0x00004176,0x000042d4,0x00050080,0x00000006, +0x00004060,0x000042d5,0x00004041,0x00050095, +0x0000013d,0x00004329,0x000041db,0x00004060, +0x00050051,0x00000006,0x0000432a,0x00004329, +0x00000001,0x00050051,0x00000006,0x0000432b, +0x00004329,0x00000000,0x00050080,0x00000006, +0x00004330,0x000041e2,0x0000432a,0x00050050, +0x00000007,0x00004331,0x0000432b,0x00004330, +0x0004007c,0x00000014,0x00004321,0x00004331, +0x00060041,0x0000016c,0x00004318,0x00004321, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00004319,0x00004318,0x00000002,0x00000004, +0x00050050,0x0000100d,0x00004064,0x000042b7, +0x00004319,0x0003003e,0x00003ffe,0x00004064, +0x000200f9,0x00004065,0x000200f8,0x00004065, +0x000700f5,0x00000006,0x00005d9b,0x00000138, +0x0000430f,0x0000409d,0x0000409b,0x000700f5, +0x00000006,0x00005dc4,0x00000138,0x0000430f, +0x00005dc2,0x0000409b,0x000500b0,0x0000002f, +0x00004068,0x00005d9b,0x00000280,0x000400f6, +0x0000409e,0x0000409b,0x00000000,0x000400fa, +0x00004068,0x00004069,0x0000409e,0x000200f8, +0x00004069,0x00050041,0x00000009,0x0000406b, +0x00003ffe,0x00005d9b,0x0004003d,0x00000006, +0x0000406c,0x0000406b,0x00050050,0x0000100d, +0x0000406e,0x0000406c,0x0000406c,0x0003003e, +0x00004005,0x0000406e,0x000500c7,0x00000006, +0x00004070,0x0000406c,0x00000241,0x000500aa, +0x0000002f,0x00004071,0x00004070,0x00000138, +0x000300f7,0x00004083,0x00000000,0x000400fa, +0x00004071,0x00004072,0x00004083,0x000200f8, +0x00004072,0x00050084,0x00000006,0x00004075, +0x000000ec,0x0000406c,0x00050080,0x00000006, +0x00004076,0x00004176,0x00004075,0x00050095, +0x0000013d,0x00004378,0x000041db,0x00004076, +0x00050051,0x00000006,0x00004379,0x00004378, +0x00000001,0x00050051,0x00000006,0x0000437a, +0x00004378,0x00000000,0x00050080,0x00000006, +0x0000437f,0x000041e2,0x00004379,0x00050050, +0x00000007,0x00004380,0x0000437a,0x0000437f, +0x0004007c,0x00000014,0x00004370,0x00004380, +0x00060041,0x0000016c,0x00004367,0x00004370, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00004368,0x00004367,0x00000002,0x00000004, +0x00050041,0x00000009,0x0000407a,0x00004005, +0x0000016b,0x0003003e,0x0000407a,0x00004368, +0x000300f7,0x000043c0,0x00000000,0x000400fa, +0x000041a3,0x000043bb,0x000043bf,0x000200f8, +0x000043bf,0x000200f9,0x000043c0,0x000200f8, +0x000043bb,0x00050082,0x00000006,0x000043be, +0x0000402d,0x00000142,0x000200f9,0x000043c0, +0x000200f8,0x000043c0,0x000700f5,0x00000006, +0x00005dbb,0x000043be,0x000043bb,0x00000138, +0x000043bf,0x00050084,0x00000006,0x00004385, +0x000000ec,0x00005dbb,0x00050080,0x00000006, +0x00004386,0x00004176,0x00004385,0x00050080, +0x00000006,0x0000407e,0x00004386,0x00004075, +0x00050095,0x0000013d,0x000043da,0x000041db, +0x0000407e,0x00050051,0x00000006,0x000043db, +0x000043da,0x00000001,0x00050051,0x00000006, +0x000043dc,0x000043da,0x00000000,0x00050080, +0x00000006,0x000043e1,0x000041e2,0x000043db, +0x00050050,0x00000007,0x000043e2,0x000043dc, +0x000043e1,0x0004007c,0x00000014,0x000043d2, +0x000043e2,0x00060041,0x0000016c,0x000043c9, +0x000043d2,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000043ca,0x000043c9,0x00000002, +0x00000004,0x00050041,0x00000009,0x00004082, +0x00004005,0x00000264,0x0003003e,0x00004082, +0x000043ca,0x000200f9,0x00004083,0x000200f8, +0x00004083,0x000600a9,0x00000006,0x00006116, +0x00004071,0x00000280,0x00000142,0x000200f9, +0x00004084,0x000200f8,0x00004084,0x000700f5, +0x00000006,0x00005dc2,0x00005dc4,0x00004083, +0x00004091,0x00004097,0x000700f5,0x00000006, +0x00005dbc,0x00000138,0x00004083,0x00004099, +0x00004097,0x000500b0,0x0000002f,0x00004088, +0x00005dbc,0x00006116,0x000400f6,0x0000409a, +0x00004097,0x00000000,0x000400fa,0x00004088, +0x00004089,0x0000409a,0x000200f8,0x00004089, +0x00050041,0x00000009,0x0000408c,0x00004005, +0x00005dbc,0x0004003d,0x00000006,0x0000408d, +0x0000408c,0x000500c7,0x00000006,0x000043e9, +0x0000408d,0x00000241,0x000500ab,0x0000002f, +0x000043ea,0x000043e9,0x00000138,0x000300f7, +0x000043f5,0x00000000,0x000400fa,0x000043ea, +0x000043eb,0x000043f4,0x000200f8,0x000043f4, +0x000200f9,0x000043f5,0x000200f8,0x000043eb, +0x00050084,0x00000006,0x000043fb,0x000000ec, +0x0000418d,0x00050080,0x00000006,0x000043fc, +0x000001c4,0x000043fb,0x000500c7,0x00000006, +0x000043ee,0x0000408d,0x00000256,0x00050084, +0x00000006,0x000043ef,0x000000ec,0x000043ee, +0x00050080,0x00000006,0x000043f0,0x000043fc, +0x000043ef,0x00050095,0x0000013d,0x00004415, +0x000041db,0x000043f0,0x00050051,0x00000006, +0x00004416,0x00004415,0x00000001,0x00050051, +0x00000006,0x00004417,0x00004415,0x00000000, +0x00050080,0x00000006,0x0000441c,0x000041e2, +0x00004416,0x00050050,0x00000007,0x0000441d, +0x00004417,0x0000441c,0x0004007c,0x00000014, +0x0000440d,0x0000441d,0x00060041,0x0000016c, +0x00004404,0x0000440d,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00004405,0x00004404, +0x00000002,0x00000004,0x000200f9,0x000043f5, +0x000200f8,0x000043f5,0x000700f5,0x00000006, +0x00005dc7,0x00004405,0x000043eb,0x00000539, +0x000043f4,0x00050041,0x00000009,0x0000408f, +0x00003ff4,0x00005dc2,0x0003003e,0x0000408f, +0x00005dc7,0x00050080,0x00000006,0x00004091, +0x00005dc2,0x00000264,0x0004003d,0x00000006, +0x00004094,0x0000408c,0x000300f7,0x00004438, +0x00000000,0x000300fb,0x00000138,0x00004427, +0x000200f8,0x00004427,0x000500c7,0x00000006, +0x00004429,0x00004094,0x00000241,0x000500ab, +0x0000002f,0x0000442a,0x00004429,0x00000138, +0x000300f7,0x0000442f,0x00000000,0x000400fa, +0x0000442a,0x0000442b,0x0000442f,0x000200f8, +0x0000442b,0x000300f7,0x0000444c,0x00000000, +0x000400fa,0x0000442a,0x00004442,0x0000444b, +0x000200f8,0x0000444b,0x000200f9,0x0000444c, +0x000200f8,0x00004442,0x00050084,0x00000006, +0x00004452,0x000000ec,0x0000418d,0x00050080, +0x00000006,0x00004453,0x000001c4,0x00004452, +0x000500c7,0x00000006,0x00004445,0x00004094, +0x00000256,0x00050084,0x00000006,0x00004446, +0x000000ec,0x00004445,0x00050080,0x00000006, +0x00004447,0x00004453,0x00004446,0x00050095, +0x0000013d,0x0000446c,0x000041db,0x00004447, +0x00050051,0x00000006,0x0000446d,0x0000446c, +0x00000001,0x00050051,0x00000006,0x0000446e, +0x0000446c,0x00000000,0x00050080,0x00000006, +0x00004473,0x000041e2,0x0000446d,0x00050050, +0x00000007,0x00004474,0x0000446e,0x00004473, +0x0004007c,0x00000014,0x00004464,0x00004474, +0x00060041,0x0000016c,0x0000445b,0x00004464, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x0000445c,0x0000445b,0x00000002,0x00000004, +0x000200f9,0x0000444c,0x000200f8,0x0000444c, +0x000700f5,0x00000006,0x00005dce,0x0000445c, +0x00004442,0x00000539,0x0000444b,0x00050041, +0x000001bb,0x00004477,0x000001b9,0x0000034a, +0x0004003d,0x00000006,0x00004478,0x00004477, +0x00050041,0x000001bb,0x00004488,0x000001b9, +0x00000334,0x0004003d,0x00000006,0x00004489, +0x00004488,0x000500c7,0x00000006,0x0000448a, +0x00004489,0x00000142,0x000500ab,0x0000002f, +0x0000448b,0x0000448a,0x00000138,0x000600a9, +0x00000006,0x00004485,0x0000448b,0x00000342, +0x000001c4,0x00050084,0x00000006,0x0000447b, +0x00005dce,0x00004485,0x00050080,0x00000006, +0x0000447c,0x00004478,0x0000447b,0x000500c2, +0x00000006,0x0000447d,0x0000447c,0x00000351, +0x000500c4,0x00000006,0x0000447e,0x0000447d, +0x0000031d,0x000600a9,0x00000006,0x00004480, +0x0000448b,0x00000355,0x00000138,0x000500c5, +0x00000006,0x00004481,0x0000447e,0x00004480, +0x000200f9,0x00004438,0x000200f8,0x0000442f, +0x000300f7,0x000044e3,0x00000000,0x000400fa, +0x000041a3,0x000044de,0x000044e2,0x000200f8, +0x000044e2,0x000200f9,0x000044e3,0x000200f8, +0x000044de,0x00050082,0x00000006,0x000044e1, +0x0000402d,0x00000142,0x000200f9,0x000044e3, +0x000200f8,0x000044e3,0x000700f5,0x00000006, +0x00005dca,0x000044e1,0x000044de,0x00000138, +0x000044e2,0x00050084,0x00000006,0x000044a8, +0x000000ec,0x00005dca,0x00050080,0x00000006, +0x000044a9,0x00004176,0x000044a8,0x000300f7, +0x000044f0,0x00000000,0x000400fa,0x000041a3, +0x000044eb,0x000044ef,0x000200f8,0x000044ef, +0x000200f9,0x000044f0,0x000200f8,0x000044eb, +0x00050082,0x00000006,0x000044ee,0x0000402d, +0x00000142,0x000200f9,0x000044f0,0x000200f8, +0x000044f0,0x000700f5,0x00000006,0x00005dcb, +0x000044ee,0x000044eb,0x00000138,0x000044ef, +0x00050084,0x00000006,0x000044a2,0x000000ec, +0x00005dcb,0x00050080,0x00000006,0x000044a3, +0x000044a9,0x000044a2,0x000300f7,0x000044fd, +0x00000000,0x000400fa,0x000041a3,0x000044f8, +0x000044fc,0x000200f8,0x000044fc,0x000200f9, +0x000044fd,0x000200f8,0x000044f8,0x00050082, +0x00000006,0x000044fb,0x0000402d,0x00000142, +0x000200f9,0x000044fd,0x000200f8,0x000044fd, +0x000700f5,0x00000006,0x00005dcc,0x000044fb, +0x000044f8,0x00000138,0x000044fc,0x00050084, +0x00000006,0x0000449c,0x000000ec,0x00005dcc, +0x00050080,0x00000006,0x0000449d,0x000044a3, +0x0000449c,0x000300f7,0x0000450a,0x00000000, +0x000400fa,0x000041a3,0x00004505,0x00004509, +0x000200f8,0x00004509,0x000200f9,0x0000450a, +0x000200f8,0x00004505,0x00050082,0x00000006, +0x00004508,0x0000402d,0x00000142,0x000200f9, +0x0000450a,0x000200f8,0x0000450a,0x000700f5, +0x00000006,0x00005dcd,0x00004508,0x00004505, +0x00000138,0x00004509,0x00050084,0x00000006, +0x00004496,0x000000ec,0x00005dcd,0x00050080, +0x00000006,0x00004497,0x0000449d,0x00004496, +0x00050084,0x00000006,0x00004432,0x000000ec, +0x00004094,0x00050080,0x00000006,0x00004433, +0x00004497,0x00004432,0x00050095,0x0000013d, +0x00004524,0x000041db,0x00004433,0x00050051, +0x00000006,0x00004525,0x00004524,0x00000001, +0x00050051,0x00000006,0x00004526,0x00004524, +0x00000000,0x00050080,0x00000006,0x0000452b, +0x000041e2,0x00004525,0x00050050,0x00000007, +0x0000452c,0x00004526,0x0000452b,0x0004007c, +0x00000014,0x0000451c,0x0000452c,0x00060041, +0x0000016c,0x00004513,0x0000451c,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00004514, +0x00004513,0x00000002,0x00000004,0x00050041, +0x000001bb,0x0000452f,0x000001b9,0x0000035a, +0x0004003d,0x00000006,0x00004530,0x0000452f, +0x00050041,0x000001bb,0x00004540,0x000001b9, +0x00000334,0x0004003d,0x00000006,0x00004541, +0x00004540,0x000500c7,0x00000006,0x00004542, +0x00004541,0x00000280,0x000500ab,0x0000002f, +0x00004543,0x00004542,0x00000138,0x000600a9, +0x00000006,0x0000453d,0x00004543,0x000001c4, +0x00000342,0x00050084,0x00000006,0x00004533, +0x00004514,0x0000453d,0x00050080,0x00000006, +0x00004534,0x00004530,0x00004533,0x000500c2, +0x00000006,0x00004535,0x00004534,0x00000351, +0x000500c4,0x00000006,0x00004536,0x00004535, +0x0000031d,0x000600a9,0x00000006,0x00004538, +0x00004543,0x000000ec,0x00000364,0x000500c5, +0x00000006,0x00004539,0x00004536,0x00004538, +0x000200f9,0x00004438,0x000200f8,0x00004438, +0x000700f5,0x00000006,0x00005dcf,0x00004481, +0x0000444c,0x00004539,0x0000450a,0x00050041, +0x00000009,0x00004096,0x00003ff3,0x00005dc2, +0x0003003e,0x00004096,0x00005dcf,0x000200f9, +0x00004097,0x000200f8,0x00004097,0x00050080, +0x00000006,0x00004099,0x00005dbc,0x00000264, +0x000200f9,0x00004084,0x000200f8,0x0000409a, +0x000200f9,0x0000409b,0x000200f8,0x0000409b, +0x00050080,0x00000006,0x0000409d,0x00005d9b, +0x00000264,0x000200f9,0x00004065,0x000200f8, +0x0000409e,0x00050041,0x000001bb,0x0000454c, +0x000001b9,0x00000334,0x0004003d,0x00000006, +0x0000454d,0x0000454c,0x000500c7,0x00000006, +0x0000454e,0x0000454d,0x00000142,0x000500aa, +0x0000002f,0x000040a0,0x0000454e,0x00000138, +0x000300f7,0x000040a6,0x00000000,0x000400fa, +0x000040a0,0x000040a1,0x000040a6,0x000200f8, +0x000040a1,0x000500c7,0x00000006,0x000040a4, +0x0000454d,0x000000ec,0x000500ab,0x0000002f, +0x000040a5,0x000040a4,0x00000138,0x000200f9, +0x000040a6,0x000200f8,0x000040a6,0x000700f5, +0x0000002f,0x000040a7,0x000040a0,0x0000409e, +0x000040a5,0x000040a1,0x000300f7,0x000040ad, +0x00000000,0x000400fa,0x000040a7,0x000040a8, +0x000040ad,0x000200f8,0x000040a8,0x0004003d, +0x000000ed,0x000040a9,0x00003ff4,0x0003003e, +0x0000400e,0x000040a9,0x0004003d,0x000000ed, +0x000040aa,0x00003ff3,0x0003003e,0x0000400f, +0x000040aa,0x000200f9,0x00004585,0x000200f8, +0x00004585,0x000700f5,0x00000006,0x00005d9c, +0x00000138,0x000040a8,0x000045cb,0x000045c9, +0x000500b0,0x0000002f,0x00004588,0x00005d9c, +0x000000ec,0x000400f6,0x000045cc,0x000045c9, +0x00000000,0x000400fa,0x00004588,0x00004589, +0x000045cc,0x000200f8,0x00004589,0x00050041, +0x00000096,0x0000458b,0x00004551,0x00005d9c, +0x0003003e,0x0000458b,0x000003cc,0x00050041, +0x00000096,0x0000458d,0x00004552,0x00005d9c, +0x0003003e,0x0000458d,0x000003cc,0x00050041, +0x00000009,0x0000458f,0x00004553,0x00005d9c, +0x0003003e,0x0000458f,0x00000138,0x000200f9, +0x00004590,0x000200f8,0x00004590,0x000700f5, +0x00000006,0x00005db4,0x00000138,0x00004589, +0x0000459a,0x00004594,0x000500b0,0x0000002f, +0x00004593,0x00005db4,0x00000470,0x000400f6, +0x0000459b,0x00004594,0x00000000,0x000400fa, +0x00004593,0x00004594,0x0000459b,0x000200f8, +0x00004594,0x00060041,0x000000e5,0x00004597, +0x00004555,0x00005d9c,0x00005db4,0x0003003e, +0x00004597,0x00000c0e,0x00050080,0x00000006, +0x0000459a,0x00005db4,0x00000264,0x000200f9, +0x00004590,0x000200f8,0x0000459b,0x00050041, +0x00000009,0x0000459d,0x0000400e,0x00005d9c, +0x0004003d,0x00000006,0x0000459e,0x0000459d, +0x000500aa,0x0000002f,0x0000459f,0x0000459e, +0x00000539,0x000300f7,0x000045a1,0x00000000, +0x000400fa,0x0000459f,0x000045a0,0x000045a1, +0x000200f8,0x000045a0,0x000200f9,0x000045c9, +0x000200f8,0x000045a1,0x0004003d,0x00000006, +0x000045a5,0x0000459d,0x00050041,0x000001bb, +0x000046a5,0x000001b9,0x0000034a,0x0004003d, +0x00000006,0x000046a6,0x000046a5,0x00050084, +0x00000006,0x000046a8,0x000001c4,0x000045a5, +0x00050080,0x00000006,0x000046a9,0x000046a6, +0x000046a8,0x00050080,0x00000006,0x000045a7, +0x000046a9,0x00000521,0x00050041,0x00000266, +0x000045a8,0x000001b9,0x0000016b,0x0004003d, +0x00000007,0x000045a9,0x000045a8,0x00050051, +0x00000006,0x000046c0,0x000045a9,0x00000000, +0x00050095,0x0000013d,0x000046c2,0x000046c0, +0x000045a7,0x00050051,0x00000006,0x000046c3, +0x000046c2,0x00000001,0x00050051,0x00000006, +0x000046c4,0x000046c2,0x00000000,0x00050051, +0x00000006,0x000046c7,0x000045a9,0x00000001, +0x00050080,0x00000006,0x000046c9,0x000046c7, +0x000046c3,0x00050050,0x00000007,0x000046ca, +0x000046c4,0x000046c9,0x0004007c,0x00000014, +0x000046ba,0x000046ca,0x00060041,0x0000016c, +0x000046b1,0x000046ba,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x000046b2,0x000046b1, +0x00000002,0x00000004,0x0003003e,0x0000458f, +0x000046b2,0x000200f9,0x000045ac,0x000200f8, +0x000045ac,0x000700f5,0x00000006,0x00005db6, +0x00000138,0x000045a1,0x000045bb,0x000045b0, +0x000500b0,0x0000002f,0x000045af,0x00005db6, +0x00000470,0x000400f6,0x000045bc,0x000045b0, +0x00000000,0x000400fa,0x000045af,0x000045b0, +0x000045bc,0x000200f8,0x000045b0,0x0004003d, +0x00000006,0x000045b5,0x0000459d,0x00050084, +0x00000006,0x000046ee,0x000001c4,0x000045b5, +0x00050080,0x00000006,0x000046ef,0x000046a6, +0x000046ee,0x00050084,0x00000006,0x000046d8, +0x000001d4,0x00005db6,0x00050080,0x00000006, +0x000046d9,0x000046ef,0x000046d8,0x00050095, +0x0000013d,0x00004708,0x000046c0,0x000046d9, +0x00050051,0x00000006,0x00004709,0x00004708, +0x00000001,0x00050051,0x00000006,0x0000470a, +0x00004708,0x00000000,0x00050080,0x00000006, +0x0000470f,0x000046c7,0x00004709,0x00050050, +0x00000007,0x00004710,0x0000470a,0x0000470f, +0x0004007c,0x00000014,0x00004700,0x00004710, +0x00060041,0x0000016c,0x000046f7,0x00004700, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000046f8,0x000046f7,0x00000002,0x00000004, +0x00050080,0x00000006,0x000046df,0x000046d9, +0x000000ec,0x00050095,0x0000013d,0x00004729, +0x000046c0,0x000046df,0x00050051,0x00000006, +0x0000472a,0x00004729,0x00000001,0x00050051, +0x00000006,0x0000472b,0x00004729,0x00000000, +0x00050080,0x00000006,0x00004730,0x000046c7, +0x0000472a,0x00050050,0x00000007,0x00004731, +0x0000472b,0x00004730,0x0004007c,0x00000014, +0x00004721,0x00004731,0x00060041,0x0000016c, +0x00004718,0x00004721,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00004719,0x00004718, +0x00000002,0x00000004,0x00050080,0x00000006, +0x000046e4,0x000046d9,0x000001cd,0x00050095, +0x0000013d,0x0000474a,0x000046c0,0x000046e4, +0x00050051,0x00000006,0x0000474b,0x0000474a, +0x00000001,0x00050051,0x00000006,0x0000474c, +0x0000474a,0x00000000,0x00050080,0x00000006, +0x00004751,0x000046c7,0x0000474b,0x00050050, +0x00000007,0x00004752,0x0000474c,0x00004751, +0x0004007c,0x00000014,0x00004742,0x00004752, +0x00060041,0x0000016c,0x00004739,0x00004742, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x0000473a,0x00004739,0x00000002,0x00000004, +0x00060050,0x000000df,0x000046e8,0x000046f8, +0x00004719,0x0000473a,0x00060041,0x000000e5, +0x000045b8,0x00004555,0x00005d9c,0x00005db6, +0x0003003e,0x000045b8,0x000046e8,0x00050080, +0x00000006,0x000045bb,0x00005db6,0x00000264, +0x000200f9,0x000045ac,0x000200f8,0x000045bc, +0x0004003d,0x00000006,0x000045bf,0x0000459d, +0x00050084,0x00000006,0x00004763,0x000001ef, +0x000045bf,0x00050080,0x00000006,0x00004764, +0x00004183,0x00004763,0x00050095,0x0000013d, +0x000047c2,0x000041db,0x00004764,0x00050051, +0x00000006,0x000047c3,0x000047c2,0x00000001, +0x00050051,0x00000006,0x000047c4,0x000047c2, +0x00000000,0x00050080,0x00000006,0x000047c9, +0x000041e2,0x000047c3,0x00050050,0x00000007, +0x000047ca,0x000047c4,0x000047c9,0x0004007c, +0x00000014,0x000047ba,0x000047ca,0x00060041, +0x0000016c,0x000047b1,0x000047ba,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000047b2, +0x000047b1,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00004769,0x000047b2,0x00050080, +0x00000006,0x0000476b,0x00004764,0x000000ec, +0x00050095,0x0000013d,0x000047e3,0x000041db, +0x0000476b,0x00050051,0x00000006,0x000047e4, +0x000047e3,0x00000001,0x00050051,0x00000006, +0x000047e5,0x000047e3,0x00000000,0x00050080, +0x00000006,0x000047ea,0x000041e2,0x000047e4, +0x00050050,0x00000007,0x000047eb,0x000047e5, +0x000047ea,0x0004007c,0x00000014,0x000047db, +0x000047eb,0x00060041,0x0000016c,0x000047d2, +0x000047db,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000047d3,0x000047d2,0x00000002, +0x00000004,0x0004007c,0x00000027,0x0000476f, +0x000047d3,0x00050080,0x00000006,0x00004771, +0x00004764,0x000001cd,0x00050095,0x0000013d, +0x00004804,0x000041db,0x00004771,0x00050051, +0x00000006,0x00004805,0x00004804,0x00000001, +0x00050051,0x00000006,0x00004806,0x00004804, +0x00000000,0x00050080,0x00000006,0x0000480b, +0x000041e2,0x00004805,0x00050050,0x00000007, +0x0000480c,0x00004806,0x0000480b,0x0004007c, +0x00000014,0x000047fc,0x0000480c,0x00060041, +0x0000016c,0x000047f3,0x000047fc,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000047f4, +0x000047f3,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00004775,0x000047f4,0x00050080, +0x00000006,0x00004778,0x00004764,0x000001d4, +0x00050095,0x0000013d,0x00004825,0x000041db, +0x00004778,0x00050051,0x00000006,0x00004826, +0x00004825,0x00000001,0x00050051,0x00000006, +0x00004827,0x00004825,0x00000000,0x00050080, +0x00000006,0x0000482c,0x000041e2,0x00004826, +0x00050050,0x00000007,0x0000482d,0x00004827, +0x0000482c,0x0004007c,0x00000014,0x0000481d, +0x0000482d,0x00060041,0x0000016c,0x00004814, +0x0000481d,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00004815,0x00004814,0x00000002, +0x00000004,0x0004007c,0x00000027,0x0000477c, +0x00004815,0x00050080,0x00000006,0x0000477e, +0x00004764,0x000001db,0x00050095,0x0000013d, +0x00004846,0x000041db,0x0000477e,0x00050051, +0x00000006,0x00004847,0x00004846,0x00000001, +0x00050051,0x00000006,0x00004848,0x00004846, +0x00000000,0x00050080,0x00000006,0x0000484d, +0x000041e2,0x00004847,0x00050050,0x00000007, +0x0000484e,0x00004848,0x0000484d,0x0004007c, +0x00000014,0x0000483e,0x0000484e,0x00060041, +0x0000016c,0x00004835,0x0000483e,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00004836, +0x00004835,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00004782,0x00004836,0x00050080, +0x00000006,0x00004784,0x00004764,0x00000299, +0x00050095,0x0000013d,0x00004867,0x000041db, +0x00004784,0x00050051,0x00000006,0x00004868, +0x00004867,0x00000001,0x00050051,0x00000006, +0x00004869,0x00004867,0x00000000,0x00050080, +0x00000006,0x0000486e,0x000041e2,0x00004868, +0x00050050,0x00000007,0x0000486f,0x00004869, +0x0000486e,0x0004007c,0x00000014,0x0000485f, +0x0000486f,0x00060041,0x0000016c,0x00004856, +0x0000485f,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00004857,0x00004856,0x00000002, +0x00000004,0x0004007c,0x00000027,0x00004788, +0x00004857,0x000500bc,0x0000002f,0x00004876, +0x00004769,0x0000477c,0x000300f7,0x0000487d, +0x00000000,0x000400fa,0x00004876,0x00004877, +0x0000487d,0x000200f8,0x00004877,0x000500bc, +0x0000002f,0x0000487c,0x0000476f,0x00004782, +0x000200f9,0x0000487d,0x000200f8,0x0000487d, +0x000700f5,0x0000002f,0x0000487e,0x00004876, +0x000045bc,0x0000487c,0x00004877,0x000300f7, +0x00004885,0x00000000,0x000400fa,0x0000487e, +0x0000487f,0x00004885,0x000200f8,0x0000487f, +0x000500bc,0x0000002f,0x00004884,0x00004775, +0x00004788,0x000200f9,0x00004885,0x000200f8, +0x00004885,0x000700f5,0x0000002f,0x00004886, +0x0000487e,0x0000487d,0x00004884,0x0000487f, +0x0003003e,0x0000458b,0x00004886,0x000200f9, +0x000045c9,0x000200f8,0x000045c9,0x00050080, +0x00000006,0x000045cb,0x00005d9c,0x00000264, +0x000200f9,0x00004585,0x000200f8,0x000045cc, +0x000200f9,0x000045cd,0x000200f8,0x000045cd, +0x000700f5,0x00000006,0x00005d9d,0x00000138, +0x000045cc,0x000046a1,0x0000469f,0x000500b0, +0x0000002f,0x000045d0,0x00005d9d,0x000000ec, +0x000400f6,0x000046a2,0x0000469f,0x00000000, +0x000400fa,0x000045d0,0x000045d1,0x000046a2, +0x000200f8,0x000045d1,0x00050041,0x00000096, +0x000045d3,0x00004552,0x00005d9d,0x0004003d, +0x0000002f,0x000045d4,0x000045d3,0x000400a8, +0x0000002f,0x000045d5,0x000045d4,0x000300f7, +0x000045db,0x00000000,0x000400fa,0x000045d5, +0x000045d6,0x000045db,0x000200f8,0x000045d6, +0x00050041,0x00000096,0x000045d8,0x00004551, +0x00005d9d,0x0004003d,0x0000002f,0x000045d9, +0x000045d8,0x000400a8,0x0000002f,0x000045da, +0x000045d9,0x000200f9,0x000045db,0x000200f8, +0x000045db,0x000700f5,0x0000002f,0x000045dc, +0x000045d4,0x000045d1,0x000045da,0x000045d6, +0x000300f7,0x000045de,0x00000000,0x000400fa, +0x000045dc,0x000045dd,0x000045de,0x000200f8, +0x000045dd,0x000200f9,0x0000469f,0x000200f8, +0x000045de,0x0003003e,0x000045d3,0x000003e7, +0x00050080,0x00000006,0x000045e2,0x00005d9d, +0x00000142,0x000200f9,0x000045e3,0x000200f8, +0x000045e3,0x000700f5,0x00000006,0x00005d9f, +0x000045e2,0x000045de,0x0000469d,0x0000469b, +0x000500b0,0x0000002f,0x000045e6,0x00005d9f, +0x000000ec,0x000400f6,0x0000469e,0x0000469b, +0x00000000,0x000400fa,0x000045e6,0x000045e7, +0x0000469e,0x000200f8,0x000045e7,0x00050041, +0x00000096,0x000045e9,0x00004552,0x00005d9f, +0x0004003d,0x0000002f,0x000045ea,0x000045e9, +0x000400a8,0x0000002f,0x000045eb,0x000045ea, +0x000300f7,0x000045f1,0x00000000,0x000400fa, +0x000045eb,0x000045ec,0x000045f1,0x000200f8, +0x000045ec,0x00050041,0x00000096,0x000045ee, +0x00004551,0x00005d9f,0x0004003d,0x0000002f, +0x000045ef,0x000045ee,0x000400a8,0x0000002f, +0x000045f0,0x000045ef,0x000200f9,0x000045f1, +0x000200f8,0x000045f1,0x000700f5,0x0000002f, +0x000045f2,0x000045ea,0x000045e7,0x000045f0, +0x000045ec,0x000400a8,0x0000002f,0x000045f3, +0x000045f2,0x000300f7,0x000045fc,0x00000000, +0x000400fa,0x000045f3,0x000045f4,0x000045fc, +0x000200f8,0x000045f4,0x00050041,0x00000009, +0x000045f6,0x00004553,0x00005d9f,0x0004003d, +0x00000006,0x000045f7,0x000045f6,0x00050041, +0x00000009,0x000045f9,0x00004553,0x00005d9d, +0x0004003d,0x00000006,0x000045fa,0x000045f9, +0x000500ab,0x0000002f,0x000045fb,0x000045f7, +0x000045fa,0x000200f9,0x000045fc,0x000200f8, +0x000045fc,0x000700f5,0x0000002f,0x000045fd, +0x000045f2,0x000045f1,0x000045fb,0x000045f4, +0x000300f7,0x000045ff,0x00000000,0x000400fa, +0x000045fd,0x000045fe,0x000045ff,0x000200f8, +0x000045fe,0x000200f9,0x0000469b,0x000200f8, +0x000045ff,0x000200f9,0x00004600,0x000200f8, +0x00004600,0x000700f5,0x00000006,0x00005da9, +0x00000470,0x000045ff,0x0000609e,0x00004638, +0x000700f5,0x00000006,0x00005da4,0x00000470, +0x000045ff,0x00006093,0x00004638,0x000700f5, +0x00000006,0x00005da3,0x00000138,0x000045ff, +0x0000463a,0x00004638,0x000500b0,0x0000002f, +0x00004603,0x00005da3,0x00000470,0x000500aa, +0x0000002f,0x00004605,0x00005da4,0x00000470, +0x000500a7,0x0000002f,0x00004606,0x00004603, +0x00004605,0x000400f6,0x0000463b,0x00004638, +0x00000000,0x000400fa,0x00004606,0x00004607, +0x0000463b,0x000200f8,0x00004607,0x00060041, +0x000000e5,0x0000460a,0x00004555,0x00005d9d, +0x00005da3,0x0004003d,0x000000df,0x0000460b, +0x0000460a,0x00050080,0x00000006,0x0000460e, +0x00005da3,0x00000142,0x00050089,0x00000006, +0x0000460f,0x0000460e,0x00000470,0x00060041, +0x000000e5,0x00004610,0x00004555,0x00005d9d, +0x0000460f,0x0004003d,0x000000df,0x00004611, +0x00004610,0x000500aa,0x0000054d,0x00004614, +0x0000460b,0x00004611,0x0004009b,0x0000002f, +0x00004615,0x00004614,0x000300f7,0x00004617, +0x00000000,0x000400fa,0x00004615,0x00004616, +0x00004617,0x000200f8,0x00004616,0x000200f9, +0x00004638,0x000200f8,0x00004617,0x000200f9, +0x00004618,0x000200f8,0x00004618,0x000700f5, +0x00000006,0x00005daa,0x00000138,0x00004617, +0x00004636,0x00004634,0x000500b0,0x0000002f, +0x0000461b,0x00005daa,0x00000470,0x000400f6, +0x00004637,0x00004634,0x00000000,0x000400fa, +0x0000461b,0x0000461c,0x00004637,0x000200f8, +0x0000461c,0x00060041,0x000000e5,0x0000461f, +0x00004555,0x00005d9f,0x00005daa,0x0004003d, +0x000000df,0x00004620,0x0000461f,0x000500aa, +0x0000054d,0x00004622,0x00004620,0x00004611, +0x0004009b,0x0000002f,0x00004623,0x00004622, +0x000300f7,0x0000462e,0x00000000,0x000400fa, +0x00004623,0x00004624,0x0000462e,0x000200f8, +0x00004624,0x00050080,0x00000006,0x00004627, +0x00005daa,0x00000142,0x00050089,0x00000006, +0x00004628,0x00004627,0x00000470,0x00060041, +0x000000e5,0x00004629,0x00004555,0x00005d9f, +0x00004628,0x0004003d,0x000000df,0x0000462a, +0x00004629,0x000500aa,0x0000054d,0x0000462c, +0x0000462a,0x0000460b,0x0004009b,0x0000002f, +0x0000462d,0x0000462c,0x000200f9,0x0000462e, +0x000200f8,0x0000462e,0x000700f5,0x0000002f, +0x0000462f,0x00004623,0x0000461c,0x0000462d, +0x00004624,0x000300f7,0x00004633,0x00000000, +0x000400fa,0x0000462f,0x00004630,0x00004633, +0x000200f8,0x00004630,0x000200f9,0x00004637, +0x000200f8,0x00004633,0x000200f9,0x00004634, +0x000200f8,0x00004634,0x00050080,0x00000006, +0x00004636,0x00005daa,0x00000264,0x000200f9, +0x00004618,0x000200f8,0x00004637,0x000700f5, +0x00000006,0x0000609f,0x00005da9,0x00004618, +0x00005daa,0x00004630,0x000700f5,0x00000006, +0x00006094,0x00005da4,0x00004618,0x00005da3, +0x00004630,0x000200f9,0x00004638,0x000200f8, +0x00004638,0x000700f5,0x00000006,0x0000609e, +0x00005da9,0x00004616,0x0000609f,0x00004637, +0x000700f5,0x00000006,0x00006093,0x00005da4, +0x00004616,0x00006094,0x00004637,0x00050080, +0x00000006,0x0000463a,0x00005da3,0x00000264, +0x000200f9,0x00004600,0x000200f8,0x0000463b, +0x000300f7,0x0000463f,0x00000000,0x000400fa, +0x00004605,0x0000463e,0x0000463f,0x000200f8, +0x0000463e,0x000200f9,0x0000469b,0x000200f8, +0x0000463f,0x0003003e,0x000045e9,0x000003e7, +0x00050080,0x00000006,0x00004645,0x00005da4, +0x00000280,0x00050089,0x00000006,0x00004646, +0x00004645,0x00000470,0x00050041,0x00000009, +0x00004647,0x0000400e,0x00005d9d,0x0004003d, +0x00000006,0x00004648,0x00004647,0x00060041, +0x000000e5,0x00004649,0x00004555,0x00005d9d, +0x00004646,0x0004003d,0x000000df,0x0000464a, +0x00004649,0x00050041,0x000001bb,0x000048af, +0x000001b9,0x0000034a,0x0004003d,0x00000006, +0x000048b0,0x000048af,0x00050084,0x00000006, +0x000048b2,0x000001c4,0x00004648,0x00050080, +0x00000006,0x000048b3,0x000048b0,0x000048b2, +0x00050041,0x00000266,0x00004899,0x000001b9, +0x0000016b,0x0004003d,0x00000007,0x0000489a, +0x00004899,0x00050051,0x00000006,0x0000489d, +0x0000464a,0x00000000,0x00050051,0x00000006, +0x000048c9,0x0000489a,0x00000000,0x00050095, +0x0000013d,0x000048cb,0x000048c9,0x000048b3, +0x00050051,0x00000006,0x000048cc,0x000048cb, +0x00000001,0x00050051,0x00000006,0x000048cd, +0x000048cb,0x00000000,0x00050051,0x00000006, +0x000048d0,0x0000489a,0x00000001,0x00050080, +0x00000006,0x000048d2,0x000048d0,0x000048cc, +0x00050050,0x00000007,0x000048d3,0x000048cd, +0x000048d2,0x0004007c,0x00000014,0x000048c3, +0x000048d3,0x00060041,0x0000016c,0x000048bb, +0x000048c3,0x0000016b,0x0000016b,0x0005003e, +0x000048bb,0x0000489d,0x00000002,0x00000004, +0x00050080,0x00000006,0x000048a0,0x000048b3, +0x000000ec,0x00050051,0x00000006,0x000048a4, +0x0000464a,0x00000001,0x00050095,0x0000013d, +0x000048eb,0x000048c9,0x000048a0,0x00050051, +0x00000006,0x000048ec,0x000048eb,0x00000001, +0x00050051,0x00000006,0x000048ed,0x000048eb, +0x00000000,0x00050080,0x00000006,0x000048f2, +0x000048d0,0x000048ec,0x00050050,0x00000007, +0x000048f3,0x000048ed,0x000048f2,0x0004007c, +0x00000014,0x000048e3,0x000048f3,0x00060041, +0x0000016c,0x000048db,0x000048e3,0x0000016b, +0x0000016b,0x0005003e,0x000048db,0x000048a4, +0x00000002,0x00000004,0x00050080,0x00000006, +0x000048a7,0x000048b3,0x000001cd,0x00050051, +0x00000006,0x000048ab,0x0000464a,0x00000002, +0x00050095,0x0000013d,0x0000490b,0x000048c9, +0x000048a7,0x00050051,0x00000006,0x0000490c, +0x0000490b,0x00000001,0x00050051,0x00000006, +0x0000490d,0x0000490b,0x00000000,0x00050080, +0x00000006,0x00004912,0x000048d0,0x0000490c, +0x00050050,0x00000007,0x00004913,0x0000490d, +0x00004912,0x0004007c,0x00000014,0x00004903, +0x00004913,0x00060041,0x0000016c,0x000048fb, +0x00004903,0x0000016b,0x0000016b,0x0005003e, +0x000048fb,0x000048ab,0x00000002,0x00000004, +0x0004003d,0x00000006,0x00004650,0x00004647, +0x00060041,0x000000e5,0x00004651,0x00004555, +0x00005d9d,0x00005da4,0x0004003d,0x000000df, +0x00004652,0x00004651,0x00050084,0x00000006, +0x0000493e,0x000001c4,0x00004650,0x00050080, +0x00000006,0x0000493f,0x000048b0,0x0000493e, +0x00050080,0x00000006,0x00004924,0x0000493f, +0x000001d4,0x00050051,0x00000006,0x00004929, +0x00004652,0x00000000,0x00050095,0x0000013d, +0x00004957,0x000048c9,0x00004924,0x00050051, +0x00000006,0x00004958,0x00004957,0x00000001, +0x00050051,0x00000006,0x00004959,0x00004957, +0x00000000,0x00050080,0x00000006,0x0000495e, +0x000048d0,0x00004958,0x00050050,0x00000007, +0x0000495f,0x00004959,0x0000495e,0x0004007c, +0x00000014,0x0000494f,0x0000495f,0x00060041, +0x0000016c,0x00004947,0x0000494f,0x0000016b, +0x0000016b,0x0005003e,0x00004947,0x00004929, +0x00000002,0x00000004,0x00050080,0x00000006, +0x0000492c,0x0000493f,0x000001db,0x00050051, +0x00000006,0x00004930,0x00004652,0x00000001, +0x00050095,0x0000013d,0x00004977,0x000048c9, +0x0000492c,0x00050051,0x00000006,0x00004978, +0x00004977,0x00000001,0x00050051,0x00000006, +0x00004979,0x00004977,0x00000000,0x00050080, +0x00000006,0x0000497e,0x000048d0,0x00004978, +0x00050050,0x00000007,0x0000497f,0x00004979, +0x0000497e,0x0004007c,0x00000014,0x0000496f, +0x0000497f,0x00060041,0x0000016c,0x00004967, +0x0000496f,0x0000016b,0x0000016b,0x0005003e, +0x00004967,0x00004930,0x00000002,0x00000004, +0x00050080,0x00000006,0x00004933,0x0000493f, +0x00000299,0x00050051,0x00000006,0x00004937, +0x00004652,0x00000002,0x00050095,0x0000013d, +0x00004997,0x000048c9,0x00004933,0x00050051, +0x00000006,0x00004998,0x00004997,0x00000001, +0x00050051,0x00000006,0x00004999,0x00004997, +0x00000000,0x00050080,0x00000006,0x0000499e, +0x000048d0,0x00004998,0x00050050,0x00000007, +0x0000499f,0x00004999,0x0000499e,0x0004007c, +0x00000014,0x0000498f,0x0000499f,0x00060041, +0x0000016c,0x00004987,0x0000498f,0x0000016b, +0x0000016b,0x0005003e,0x00004987,0x00004937, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004657,0x00005da4,0x00000142,0x00050089, +0x00000006,0x00004658,0x00004657,0x00000470, +0x0004003d,0x00000006,0x0000465a,0x00004647, +0x00060041,0x000000e5,0x0000465b,0x00004555, +0x00005d9d,0x00004658,0x0004003d,0x000000df, +0x0000465c,0x0000465b,0x00050084,0x00000006, +0x000049ca,0x000001c4,0x0000465a,0x00050080, +0x00000006,0x000049cb,0x000048b0,0x000049ca, +0x00050080,0x00000006,0x000049b0,0x000049cb, +0x000001ef,0x00050051,0x00000006,0x000049b5, +0x0000465c,0x00000000,0x00050095,0x0000013d, +0x000049e3,0x000048c9,0x000049b0,0x00050051, +0x00000006,0x000049e4,0x000049e3,0x00000001, +0x00050051,0x00000006,0x000049e5,0x000049e3, +0x00000000,0x00050080,0x00000006,0x000049ea, +0x000048d0,0x000049e4,0x00050050,0x00000007, +0x000049eb,0x000049e5,0x000049ea,0x0004007c, +0x00000014,0x000049db,0x000049eb,0x00060041, +0x0000016c,0x000049d3,0x000049db,0x0000016b, +0x0000016b,0x0005003e,0x000049d3,0x000049b5, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00004929,0x0000491a,0x00000194,0x00050095, -0x00000130,0x00004c4b,0x000048bd,0x00004929, +0x000049b8,0x000049cb,0x000006d9,0x00050051, +0x00000006,0x000049bc,0x0000465c,0x00000001, +0x00050095,0x0000013d,0x00004a03,0x000048c9, +0x000049b8,0x00050051,0x00000006,0x00004a04, +0x00004a03,0x00000001,0x00050051,0x00000006, +0x00004a05,0x00004a03,0x00000000,0x00050080, +0x00000006,0x00004a0a,0x000048d0,0x00004a04, +0x00050050,0x00000007,0x00004a0b,0x00004a05, +0x00004a0a,0x0004007c,0x00000014,0x000049fb, +0x00004a0b,0x00060041,0x0000016c,0x000049f3, +0x000049fb,0x0000016b,0x0000016b,0x0005003e, +0x000049f3,0x000049bc,0x00000002,0x00000004, +0x00050080,0x00000006,0x000049bf,0x000049cb, +0x00000205,0x00050051,0x00000006,0x000049c3, +0x0000465c,0x00000002,0x00050095,0x0000013d, +0x00004a23,0x000048c9,0x000049bf,0x00050051, +0x00000006,0x00004a24,0x00004a23,0x00000001, +0x00050051,0x00000006,0x00004a25,0x00004a23, +0x00000000,0x00050080,0x00000006,0x00004a2a, +0x000048d0,0x00004a24,0x00050050,0x00000007, +0x00004a2b,0x00004a25,0x00004a2a,0x0004007c, +0x00000014,0x00004a1b,0x00004a2b,0x00060041, +0x0000016c,0x00004a13,0x00004a1b,0x0000016b, +0x0000016b,0x0005003e,0x00004a13,0x000049c3, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004661,0x00005da9,0x00000280,0x00050089, +0x00000006,0x00004662,0x00004661,0x00000470, +0x0004003d,0x00000006,0x00004664,0x00004647, +0x00060041,0x000000e5,0x00004665,0x00004555, +0x00005d9f,0x00004662,0x0004003d,0x000000df, +0x00004666,0x00004665,0x00050084,0x00000006, +0x00004a56,0x000001c4,0x00004664,0x00050080, +0x00000006,0x00004a57,0x000048b0,0x00004a56, +0x00050080,0x00000006,0x00004a3c,0x00004a57, +0x00000500,0x00050051,0x00000006,0x00004a41, +0x00004666,0x00000000,0x00050095,0x0000013d, +0x00004a6f,0x000048c9,0x00004a3c,0x00050051, +0x00000006,0x00004a70,0x00004a6f,0x00000001, +0x00050051,0x00000006,0x00004a71,0x00004a6f, +0x00000000,0x00050080,0x00000006,0x00004a76, +0x000048d0,0x00004a70,0x00050050,0x00000007, +0x00004a77,0x00004a71,0x00004a76,0x0004007c, +0x00000014,0x00004a67,0x00004a77,0x00060041, +0x0000016c,0x00004a5f,0x00004a67,0x0000016b, +0x0000016b,0x0005003e,0x00004a5f,0x00004a41, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004a44,0x00004a57,0x0000050b,0x00050051, +0x00000006,0x00004a48,0x00004666,0x00000001, +0x00050095,0x0000013d,0x00004a8f,0x000048c9, +0x00004a44,0x00050051,0x00000006,0x00004a90, +0x00004a8f,0x00000001,0x00050051,0x00000006, +0x00004a91,0x00004a8f,0x00000000,0x00050080, +0x00000006,0x00004a96,0x000048d0,0x00004a90, +0x00050050,0x00000007,0x00004a97,0x00004a91, +0x00004a96,0x0004007c,0x00000014,0x00004a87, +0x00004a97,0x00060041,0x0000016c,0x00004a7f, +0x00004a87,0x0000016b,0x0000016b,0x0005003e, +0x00004a7f,0x00004a48,0x00000002,0x00000004, +0x00050080,0x00000006,0x00004a4b,0x00004a57, +0x00000516,0x00050051,0x00000006,0x00004a4f, +0x00004666,0x00000002,0x00050095,0x0000013d, +0x00004aaf,0x000048c9,0x00004a4b,0x00050051, +0x00000006,0x00004ab0,0x00004aaf,0x00000001, +0x00050051,0x00000006,0x00004ab1,0x00004aaf, +0x00000000,0x00050080,0x00000006,0x00004ab6, +0x000048d0,0x00004ab0,0x00050050,0x00000007, +0x00004ab7,0x00004ab1,0x00004ab6,0x0004007c, +0x00000014,0x00004aa7,0x00004ab7,0x00060041, +0x0000016c,0x00004a9f,0x00004aa7,0x0000016b, +0x0000016b,0x0005003e,0x00004a9f,0x00004a4f, +0x00000002,0x00000004,0x0004003d,0x00000006, +0x0000466a,0x00004647,0x00050084,0x00000006, +0x00004abd,0x000001c4,0x0000466a,0x00050080, +0x00000006,0x00004abe,0x000048b0,0x00004abd, +0x00050080,0x00000006,0x0000466c,0x00004abe, +0x00000537,0x00050041,0x00000009,0x0000466e, +0x0000400e,0x00005d9f,0x0004003d,0x00000006, +0x0000466f,0x0000466e,0x00050084,0x00000006, +0x00004ac4,0x000001c4,0x0000466f,0x00050080, +0x00000006,0x00004ac5,0x000048b0,0x00004ac4, +0x00050080,0x00000006,0x00004671,0x00004ac5, +0x0000052d,0x00050095,0x0000013d,0x00004ade, +0x000048c9,0x00004671,0x00050051,0x00000006, +0x00004adf,0x00004ade,0x00000001,0x00050051, +0x00000006,0x00004ae0,0x00004ade,0x00000000, +0x00050080,0x00000006,0x00004ae5,0x000048d0, +0x00004adf,0x00050050,0x00000007,0x00004ae6, +0x00004ae0,0x00004ae5,0x0004007c,0x00000014, +0x00004ad6,0x00004ae6,0x00060041,0x0000016c, +0x00004acd,0x00004ad6,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00004ace,0x00004acd, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x00004afe,0x000048c9,0x0000466c,0x00050051, +0x00000006,0x00004aff,0x00004afe,0x00000001, +0x00050051,0x00000006,0x00004b00,0x00004afe, +0x00000000,0x00050080,0x00000006,0x00004b05, +0x000048d0,0x00004aff,0x00050050,0x00000007, +0x00004b06,0x00004b00,0x00004b05,0x0004007c, +0x00000014,0x00004af6,0x00004b06,0x00060041, +0x0000016c,0x00004aee,0x00004af6,0x0000016b, +0x0000016b,0x0005003e,0x00004aee,0x00004ace, +0x00000002,0x00000004,0x00050082,0x00000006, +0x00004679,0x00000364,0x00005da4,0x00050089, +0x00000006,0x0000467a,0x00004679,0x00000470, +0x00050082,0x00000006,0x0000467c,0x00000355, +0x00005da4,0x00050089,0x00000006,0x0000467d, +0x0000467c,0x00000470,0x000500c4,0x00000006, +0x0000467e,0x0000467d,0x00000315,0x000500c5, +0x00000006,0x0000467f,0x0000467a,0x0000467e, +0x00050082,0x00000006,0x00004681,0x00000355, +0x00005da9,0x00050089,0x00000006,0x00004682, +0x00004681,0x00000470,0x00050082,0x00000006, +0x00004684,0x00000d2b,0x00005da9,0x00050089, +0x00000006,0x00004685,0x00004684,0x00000470, +0x000500c4,0x00000006,0x00004686,0x00004685, +0x00000315,0x000500c5,0x00000006,0x00004687, +0x00004682,0x00004686,0x0004003d,0x00000006, +0x0000468a,0x00004647,0x00050084,0x00000006, +0x00004b0c,0x000001c4,0x0000468a,0x00050080, +0x00000006,0x00004b0d,0x000048b0,0x00004b0c, +0x00050080,0x00000006,0x0000468c,0x00004b0d, +0x00000541,0x000500c4,0x00000006,0x0000468f, +0x00004687,0x000004c1,0x000500c5,0x00000006, +0x00004690,0x0000467f,0x0000468f,0x00050095, +0x0000013d,0x00004b25,0x000048c9,0x0000468c, +0x00050051,0x00000006,0x00004b26,0x00004b25, +0x00000001,0x00050051,0x00000006,0x00004b27, +0x00004b25,0x00000000,0x00050080,0x00000006, +0x00004b2c,0x000048d0,0x00004b26,0x00050050, +0x00000007,0x00004b2d,0x00004b27,0x00004b2c, +0x0004007c,0x00000014,0x00004b1d,0x00004b2d, +0x00060041,0x0000016c,0x00004b15,0x00004b1d, +0x0000016b,0x0000016b,0x0005003e,0x00004b15, +0x00004690,0x00000002,0x00000004,0x00050041, +0x00000009,0x00004696,0x0000400f,0x00005d9d, +0x0004003d,0x00000006,0x00004697,0x00004696, +0x000500c7,0x00000006,0x00004698,0x00004697, +0x00000d45,0x000500c5,0x00000006,0x00004699, +0x00004698,0x00000142,0x00050041,0x00000009, +0x0000469a,0x0000400f,0x00005d9f,0x0003003e, +0x0000469a,0x00004699,0x000200f9,0x0000469e, +0x000200f8,0x0000469b,0x00050080,0x00000006, +0x0000469d,0x00005d9f,0x00000264,0x000200f9, +0x000045e3,0x000200f8,0x0000469e,0x000200f9, +0x0000469f,0x000200f8,0x0000469f,0x00050080, +0x00000006,0x000046a1,0x00005d9d,0x00000264, +0x000200f9,0x000045cd,0x000200f8,0x000046a2, +0x0004003d,0x000000ed,0x000040ac,0x0000400f, +0x0003003e,0x00003ff3,0x000040ac,0x000200f9, +0x000040ad,0x000200f8,0x000040ad,0x000200f9, +0x000040ae,0x000200f8,0x0000402f,0x000500aa, +0x0000002f,0x00004032,0x0000402d,0x00000142, +0x000300f7,0x0000403d,0x00000000,0x000400fa, +0x00004032,0x00004033,0x0000403d,0x000200f8, +0x00004033,0x00050041,0x000001bb,0x0000411c, +0x000001b9,0x000001ba,0x0004003d,0x00000006, +0x0000411d,0x0000411c,0x00050084,0x00000006, +0x0000411e,0x000000ec,0x0000411d,0x00050080, +0x00000006,0x0000411f,0x000001c4,0x0000411e, +0x00050041,0x00000266,0x00004035,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00004036, +0x00004035,0x00050051,0x00000006,0x00004136, +0x00004036,0x00000000,0x00050095,0x0000013d, +0x00004138,0x00004136,0x0000411f,0x00050051, +0x00000006,0x00004139,0x00004138,0x00000001, +0x00050051,0x00000006,0x0000413a,0x00004138, +0x00000000,0x00050051,0x00000006,0x0000413d, +0x00004036,0x00000001,0x00050080,0x00000006, +0x0000413f,0x0000413d,0x00004139,0x00050050, +0x00000007,0x00004140,0x0000413a,0x0000413f, +0x0004007c,0x00000014,0x00004130,0x00004140, +0x00060041,0x0000016c,0x00004127,0x00004130, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00004128,0x00004127,0x00000002,0x00000004, +0x00050041,0x00000009,0x00004038,0x00003ff4, +0x0000016b,0x0003003e,0x00004038,0x00004128, +0x0004003d,0x00000006,0x0000403a,0x00004038, +0x00050041,0x000001bb,0x00004143,0x000001b9, +0x0000034a,0x0004003d,0x00000006,0x00004144, +0x00004143,0x00050041,0x000001bb,0x00004154, +0x000001b9,0x00000334,0x0004003d,0x00000006, +0x00004155,0x00004154,0x000500c7,0x00000006, +0x00004156,0x00004155,0x00000142,0x000500ab, +0x0000002f,0x00004157,0x00004156,0x00000138, +0x000600a9,0x00000006,0x00004151,0x00004157, +0x00000342,0x000001c4,0x00050084,0x00000006, +0x00004147,0x0000403a,0x00004151,0x00050080, +0x00000006,0x00004148,0x00004144,0x00004147, +0x000500c2,0x00000006,0x00004149,0x00004148, +0x00000351,0x000500c4,0x00000006,0x0000414a, +0x00004149,0x0000031d,0x000600a9,0x00000006, +0x0000414c,0x00004157,0x00000355,0x00000138, +0x000500c5,0x00000006,0x0000414d,0x0000414a, +0x0000414c,0x00050041,0x00000009,0x0000403c, +0x00003ff3,0x0000016b,0x0003003e,0x0000403c, +0x0000414d,0x000200f9,0x0000403d,0x000200f8, +0x0000403d,0x000200f9,0x000040ae,0x000200f8, +0x000040ae,0x000700f5,0x00000006,0x00005dd8, +0x00000138,0x0000403d,0x00004268,0x000040ad, +0x000200f9,0x000040af,0x000200f8,0x000040af, +0x000700f5,0x00000006,0x00005dd6,0x00000138, +0x000040ae,0x000040c8,0x000040c6,0x000500b0, +0x0000002f,0x000040b2,0x00005dd6,0x000000ec, +0x000400f6,0x000040c9,0x000040c6,0x00000000, +0x000400fa,0x000040b2,0x000040b3,0x000040c9, +0x000200f8,0x000040b3,0x00050041,0x00000009, +0x000040b5,0x00003ff4,0x00005dd6,0x0004003d, +0x00000006,0x000040b6,0x000040b5,0x000500ab, +0x0000002f,0x000040b7,0x000040b6,0x00000539, +0x000300f7,0x000040c5,0x00000000,0x000400fa, +0x000040b7,0x000040b8,0x000040c5,0x000200f8, +0x000040b8,0x00050041,0x000001bb,0x00004b74, +0x000001b9,0x000001ba,0x0004003d,0x00000006, +0x00004b75,0x00004b74,0x00050084,0x00000006, +0x00004b76,0x000001db,0x00004b75,0x00050080, +0x00000006,0x00004b77,0x000001c4,0x00004b76, +0x00050080,0x00000006,0x00004b7d,0x00004b75, +0x0000062f,0x00050086,0x00000006,0x00004b7e, +0x00004b7d,0x000001be,0x00050084,0x00000006, +0x00004b70,0x000001c4,0x00004b7e,0x00050080, +0x00000006,0x00004b71,0x00004b77,0x00004b70, +0x00050080,0x00000006,0x00004b6b,0x00004b71, +0x00004b70,0x00050084,0x00000006,0x00004b64, +0x000001ef,0x0000402d,0x00050080,0x00000006, +0x00004b65,0x00004b6b,0x00004b64,0x00050041, +0x000001bb,0x00004b5b,0x000001b9,0x00000206, +0x0004003d,0x00000006,0x00004b5c,0x00004b5b, +0x00050084,0x00000006,0x00004b5d,0x00000205, +0x00004b5c,0x00050080,0x00000006,0x00004b5e, +0x00004b65,0x00004b5d,0x000500ac,0x0000002f, +0x00004b8b,0x0000402d,0x00000142,0x000300f7, +0x00004b91,0x00000000,0x000400fa,0x00004b8b, +0x00004b8c,0x00004b90,0x000200f8,0x00004b90, +0x000200f9,0x00004b91,0x000200f8,0x00004b8c, +0x00050082,0x00000006,0x00004b8f,0x0000402d, +0x00000142,0x000200f9,0x00004b91,0x000200f8, +0x00004b91,0x000700f5,0x00000006,0x00005e32, +0x00004b8f,0x00004b8c,0x00000138,0x00004b90, +0x00050084,0x00000006,0x00004b56,0x000000ec, +0x00005e32,0x00050080,0x00000006,0x00004b57, +0x00004b5e,0x00004b56,0x000300f7,0x00004b9e, +0x00000000,0x000400fa,0x00004b8b,0x00004b99, +0x00004b9d,0x000200f8,0x00004b9d,0x000200f9, +0x00004b9e,0x000200f8,0x00004b99,0x00050082, +0x00000006,0x00004b9c,0x0000402d,0x00000142, +0x000200f9,0x00004b9e,0x000200f8,0x00004b9e, +0x000700f5,0x00000006,0x00005e33,0x00004b9c, +0x00004b99,0x00000138,0x00004b9d,0x00050084, +0x00000006,0x00004b50,0x000000ec,0x00005e33, +0x00050080,0x00000006,0x00004b51,0x00004b57, +0x00004b50,0x000300f7,0x00004bab,0x00000000, +0x000400fa,0x00004b8b,0x00004ba6,0x00004baa, +0x000200f8,0x00004baa,0x000200f9,0x00004bab, +0x000200f8,0x00004ba6,0x00050082,0x00000006, +0x00004ba9,0x0000402d,0x00000142,0x000200f9, +0x00004bab,0x000200f8,0x00004bab,0x000700f5, +0x00000006,0x00005e34,0x00004ba9,0x00004ba6, +0x00000138,0x00004baa,0x00050084,0x00000006, +0x00004b4a,0x000000ec,0x00005e34,0x00050080, +0x00000006,0x00004b4b,0x00004b51,0x00004b4a, +0x000300f7,0x00004bb8,0x00000000,0x000400fa, +0x00004b8b,0x00004bb3,0x00004bb7,0x000200f8, +0x00004bb7,0x000200f9,0x00004bb8,0x000200f8, +0x00004bb3,0x00050082,0x00000006,0x00004bb6, +0x0000402d,0x00000142,0x000200f9,0x00004bb8, +0x000200f8,0x00004bb8,0x000700f5,0x00000006, +0x00005e35,0x00004bb6,0x00004bb3,0x00000138, +0x00004bb7,0x00050084,0x00000006,0x00004b44, +0x000000ec,0x00005e35,0x00050080,0x00000006, +0x00004b45,0x00004b4b,0x00004b44,0x000300f7, +0x00004bc5,0x00000000,0x000400fa,0x00004b8b, +0x00004bc0,0x00004bc4,0x000200f8,0x00004bc4, +0x000200f9,0x00004bc5,0x000200f8,0x00004bc0, +0x00050082,0x00000006,0x00004bc3,0x0000402d, +0x00000142,0x000200f9,0x00004bc5,0x000200f8, +0x00004bc5,0x000700f5,0x00000006,0x00005e36, +0x00004bc3,0x00004bc0,0x00000138,0x00004bc4, +0x00050084,0x00000006,0x00004b3e,0x000000ec, +0x00005e36,0x00050080,0x00000006,0x00004b3f, +0x00004b45,0x00004b3e,0x000300f7,0x00004bd8, +0x00000000,0x000400fa,0x00004b8b,0x00004bd3, +0x00004bd7,0x000200f8,0x00004bd7,0x000200f9, +0x00004bd8,0x000200f8,0x00004bd3,0x00050082, +0x00000006,0x00004bd6,0x0000402d,0x00000142, +0x000200f9,0x00004bd8,0x000200f8,0x00004bd8, +0x000700f5,0x00000006,0x00005e37,0x00004bd6, +0x00004bd3,0x00000138,0x00004bd7,0x00050080, +0x00000006,0x00004bcb,0x00005e37,0x0000062f, +0x00050086,0x00000006,0x00004bcc,0x00004bcb, +0x000001be,0x00050084,0x00000006,0x00004b38, +0x000000ec,0x00004bcc,0x00050080,0x00000006, +0x00004b39,0x00004b3f,0x00004b38,0x000300f7, +0x00004beb,0x00000000,0x000400fa,0x00004b8b, +0x00004be6,0x00004bea,0x000200f8,0x00004bea, +0x000200f9,0x00004beb,0x000200f8,0x00004be6, +0x00050082,0x00000006,0x00004be9,0x0000402d, +0x00000142,0x000200f9,0x00004beb,0x000200f8, +0x00004beb,0x000700f5,0x00000006,0x00005e38, +0x00004be9,0x00004be6,0x00000138,0x00004bea, +0x00050080,0x00000006,0x00004bde,0x00005e38, +0x0000062f,0x00050086,0x00000006,0x00004bdf, +0x00004bde,0x000001be,0x00050084,0x00000006, +0x00004b32,0x000000ec,0x00004bdf,0x00050080, +0x00000006,0x00004b33,0x00004b39,0x00004b32, +0x0004003d,0x00000006,0x000040bc,0x000040b5, +0x00050084,0x00000006,0x000040bd,0x000000ec, +0x000040bc,0x00050080,0x00000006,0x000040be, +0x00004b33,0x000040bd,0x00050041,0x00000266, +0x000040c0,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x000040c1,0x000040c0,0x00050041, +0x00000009,0x000040c2,0x00003ff3,0x00005dd6, +0x0004003d,0x00000006,0x000040c3,0x000040c2, +0x00050051,0x00000006,0x00004c02,0x000040c1, +0x00000000,0x00050095,0x0000013d,0x00004c04, +0x00004c02,0x000040be,0x00050051,0x00000006, +0x00004c05,0x00004c04,0x00000001,0x00050051, +0x00000006,0x00004c06,0x00004c04,0x00000000, +0x00050051,0x00000006,0x00004c09,0x000040c1, +0x00000001,0x00050080,0x00000006,0x00004c0b, +0x00004c09,0x00004c05,0x00050050,0x00000007, +0x00004c0c,0x00004c06,0x00004c0b,0x0004007c, +0x00000014,0x00004bfc,0x00004c0c,0x00060041, +0x0000016c,0x00004bf4,0x00004bfc,0x0000016b, +0x0000016b,0x0005003e,0x00004bf4,0x000040c3, +0x00000002,0x00000004,0x000200f9,0x000040c5, +0x000200f8,0x000040c5,0x000200f9,0x000040c6, +0x000200f8,0x000040c6,0x00050080,0x00000006, +0x000040c8,0x00005dd6,0x00000264,0x000200f9, +0x000040af,0x000200f8,0x000040c9,0x00050041, +0x000001bb,0x00004c0f,0x000001b9,0x0000035a, +0x0004003d,0x00000006,0x00004c10,0x00004c0f, +0x00050041,0x000001bb,0x00004c20,0x000001b9, +0x00000334,0x0004003d,0x00000006,0x00004c21, +0x00004c20,0x000500c7,0x00000006,0x00004c22, +0x00004c21,0x00000280,0x000500ab,0x0000002f, +0x00004c23,0x00004c22,0x00000138,0x000600a9, +0x00000006,0x00004c1d,0x00004c23,0x000001c4, +0x00000342,0x00050084,0x00000006,0x00004c13, +0x00005dd8,0x00004c1d,0x00050080,0x00000006, +0x00004c14,0x00004c10,0x00004c13,0x000500c2, +0x00000006,0x00004c15,0x00004c14,0x00000351, +0x000500c4,0x00000006,0x00004c16,0x00004c15, +0x0000031d,0x000600a9,0x00000006,0x00004c18, +0x00004c23,0x000000ec,0x00000364,0x000500c5, +0x00000006,0x00004c19,0x00004c16,0x00004c18, +0x000200f9,0x000040d2,0x000200f8,0x000040d2, +0x000700f5,0x00000006,0x00005dfb,0x00000138, +0x000040c9,0x00004100,0x000040fe,0x000500b0, +0x0000002f,0x000040d5,0x00005dfb,0x000000ec, +0x000400f6,0x00004101,0x000040fe,0x00000000, +0x000400fa,0x000040d5,0x000040d6,0x00004101, +0x000200f8,0x000040d6,0x00050084,0x00000006, +0x000040d9,0x000000ec,0x00005dfb,0x00050080, +0x00000006,0x000040da,0x00004c14,0x000040d9, +0x00050041,0x00000266,0x000040dc,0x000001b9, +0x0000016b,0x0004003d,0x00000007,0x000040dd, +0x000040dc,0x00050041,0x00000009,0x000040de, +0x00003ff3,0x00005dfb,0x0004003d,0x00000006, +0x000040df,0x000040de,0x00050051,0x00000006, +0x00004c49,0x000040dd,0x00000000,0x00050095, +0x0000013d,0x00004c4b,0x00004c49,0x000040da, 0x00050051,0x00000006,0x00004c4c,0x00004c4b, 0x00000001,0x00050051,0x00000006,0x00004c4d, -0x00004c4b,0x00000000,0x00050080,0x00000006, -0x00004c52,0x000048c4,0x00004c4c,0x00050050, -0x00000007,0x00004c53,0x00004c4d,0x00004c52, -0x0004007c,0x00000014,0x00004c43,0x00004c53, -0x00060041,0x0000015f,0x00004c3b,0x00004c43, -0x0000015e,0x0000015e,0x0005003e,0x00004c3b, -0x00000345,0x00000002,0x00000004,0x00050080, -0x00000006,0x00004930,0x0000491a,0x0000019b, -0x00050095,0x00000130,0x00004c74,0x000048bd, -0x00004930,0x00050051,0x00000006,0x00004c75, -0x00004c74,0x00000001,0x00050051,0x00000006, -0x00004c76,0x00004c74,0x00000000,0x00050080, -0x00000006,0x00004c7b,0x000048c4,0x00004c75, -0x00050050,0x00000007,0x00004c7c,0x00004c76, -0x00004c7b,0x0004007c,0x00000014,0x00004c6c, -0x00004c7c,0x00060041,0x0000015f,0x00004c64, -0x00004c6c,0x0000015e,0x0000015e,0x0005003e, -0x00004c64,0x00005cc5,0x00000002,0x00000004, -0x00050080,0x00000006,0x00004937,0x0000491a, -0x000001a2,0x00050095,0x00000130,0x00004c9d, -0x000048bd,0x00004937,0x00050051,0x00000006, -0x00004c9e,0x00004c9d,0x00000001,0x00050051, -0x00000006,0x00004c9f,0x00004c9d,0x00000000, -0x00050080,0x00000006,0x00004ca4,0x000048c4, -0x00004c9e,0x00050050,0x00000007,0x00004ca5, -0x00004c9f,0x00004ca4,0x0004007c,0x00000014, -0x00004c95,0x00004ca5,0x00060041,0x0000015f, -0x00004c8d,0x00004c95,0x0000015e,0x0000015e, -0x0005003e,0x00004c8d,0x00005cc5,0x00000002, -0x00000004,0x00050080,0x00000006,0x0000493e, -0x0000491a,0x00000260,0x00050095,0x00000130, -0x00004cc6,0x000048bd,0x0000493e,0x00050051, -0x00000006,0x00004cc7,0x00004cc6,0x00000001, -0x00050051,0x00000006,0x00004cc8,0x00004cc6, -0x00000000,0x00050080,0x00000006,0x00004ccd, -0x000048c4,0x00004cc7,0x00050050,0x00000007, -0x00004cce,0x00004cc8,0x00004ccd,0x0004007c, -0x00000014,0x00004cbe,0x00004cce,0x00060041, -0x0000015f,0x00004cb6,0x00004cbe,0x0000015e, -0x0000015e,0x0005003e,0x00004cb6,0x00005cc5, -0x00000002,0x00000004,0x000200f9,0x00004944, -0x000200f8,0x00004944,0x000200f9,0x00003d72, -0x000200f8,0x00003d72,0x00050080,0x00000006, -0x00003d74,0x00005a33,0x0000022b,0x000200f9, -0x00003d46,0x000200f8,0x00003d75,0x000400a8, -0x0000002f,0x00003d77,0x00004897,0x000300f7, -0x00003d8a,0x00000000,0x000400fa,0x00003d77, -0x00003d78,0x00003d8a,0x000200f8,0x00003d78, -0x000200f9,0x00003d79,0x000200f8,0x00003d79, -0x000700f5,0x00000006,0x00005a34,0x0000012b, -0x00003d78,0x00003d88,0x00003d7d,0x000500b0, -0x0000002f,0x00003d7c,0x00005a34,0x000000df, -0x000400f6,0x00003d89,0x00003d7d,0x00000000, -0x000400fa,0x00003d7c,0x00003d7d,0x00003d89, -0x000200f8,0x00003d7d,0x00050080,0x00000006, -0x00003d7f,0x00004888,0x00000741,0x00050084, -0x00000006,0x00003d81,0x000000df,0x00005a34, -0x00050080,0x00000006,0x00003d82,0x00003d7f, -0x00003d81,0x00050041,0x0000022d,0x00003d83, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x00003d84,0x00003d83,0x00050051,0x00000006, -0x00004cea,0x00003d84,0x00000000,0x00050095, -0x00000130,0x00004cec,0x00004cea,0x00003d82, -0x00050051,0x00000006,0x00004ced,0x00004cec, -0x00000001,0x00050051,0x00000006,0x00004cee, -0x00004cec,0x00000000,0x00050051,0x00000006, -0x00004cf1,0x00003d84,0x00000001,0x00050080, -0x00000006,0x00004cf3,0x00004cf1,0x00004ced, -0x00050050,0x00000007,0x00004cf4,0x00004cee, -0x00004cf3,0x0004007c,0x00000014,0x00004ce4, -0x00004cf4,0x00060041,0x0000015f,0x00004cdc, -0x00004ce4,0x0000015e,0x0000015e,0x0005003e, -0x00004cdc,0x0000012b,0x00000002,0x00000004, -0x00050080,0x00000006,0x00003d88,0x00005a34, -0x0000022b,0x000200f9,0x00003d79,0x000200f8, -0x00003d89,0x000200f9,0x00003d8a,0x000200f8, -0x00003d8a,0x00050041,0x00000182,0x00004d28, -0x00000180,0x00000181,0x0004003d,0x00000006, -0x00004d29,0x00004d28,0x00050084,0x00000006, -0x00004d2a,0x000001a2,0x00004d29,0x00050080, -0x00000006,0x00004d2b,0x0000018b,0x00004d2a, -0x00050080,0x00000006,0x00004d31,0x00004d29, -0x00005cc3,0x00050086,0x00000006,0x00004d32, -0x00004d31,0x00000185,0x00050084,0x00000006, -0x00004d24,0x0000018b,0x00004d32,0x00050080, -0x00000006,0x00004d25,0x00004d2b,0x00004d24, -0x00050080,0x00000006,0x00004d1f,0x00004d25, -0x00004d24,0x00050084,0x00000006,0x00004d18, -0x000001b6,0x00003ca1,0x00050080,0x00000006, -0x00004d19,0x00004d1f,0x00004d18,0x00050084, -0x00000006,0x00004d0e,0x000001cc,0x00005a10, -0x00050080,0x00000006,0x00004d0f,0x00004d19, -0x00004d0e,0x00050041,0x0000022d,0x00004d10, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x00004d11,0x00004d10,0x00050051,0x00000006, -0x00004d47,0x00004d11,0x00000000,0x00050095, -0x00000130,0x00004d49,0x00004d47,0x00004d0f, -0x00050051,0x00000006,0x00004d4a,0x00004d49, -0x00000001,0x00050051,0x00000006,0x00004d4b, -0x00004d49,0x00000000,0x00050051,0x00000006, -0x00004d4e,0x00004d11,0x00000001,0x00050080, -0x00000006,0x00004d50,0x00004d4e,0x00004d4a, -0x00050050,0x00000007,0x00004d51,0x00004d4b, -0x00004d50,0x0004007c,0x00000014,0x00004d41, -0x00004d51,0x00060041,0x0000015f,0x00004cfb, -0x00004d41,0x0000015e,0x0000015e,0x0005003e, -0x00004cfb,0x0000012b,0x00000002,0x00000004, -0x00060041,0x0000015f,0x00004cfd,0x00004d41, -0x0000015e,0x0000022b,0x0005003e,0x00004cfd, -0x00000500,0x00000002,0x00000004,0x00060041, -0x0000015f,0x00004cff,0x00004d41,0x0000015e, -0x000002dc,0x0005003e,0x00004cff,0x00000500, -0x00000002,0x00000004,0x00060041,0x0000015f, -0x00004d01,0x00004d41,0x0000015e,0x000002e4, -0x0005003e,0x00004d01,0x00000500,0x00000002, -0x00000004,0x00060041,0x0000015f,0x00004d03, -0x00004d41,0x0000015e,0x000002ec,0x0005003e, -0x00004d03,0x0000012b,0x00000002,0x00000004, -0x00060041,0x0000015f,0x00004d05,0x00004d41, -0x0000015e,0x000002f4,0x0005003e,0x00004d05, -0x0000012b,0x00000002,0x00000004,0x00060041, -0x0000015f,0x00004d07,0x00004d41,0x0000015e, -0x00000318,0x0005003e,0x00004d07,0x0000012b, -0x00000002,0x00000004,0x000200f9,0x00003d8d, -0x000200f8,0x00003d8d,0x000200f9,0x000012e4, -0x000200f8,0x000012e4,0x000200f9,0x000012da, -0x000200f8,0x000012d9,0x0004007c,0x000000e7, -0x000012dc,0x000011de,0x00050080,0x000000e7, -0x000035dc,0x000012dc,0x0000022b,0x000300f7, -0x000036bf,0x00000000,0x000300fb,0x0000012b, -0x0000369d,0x000200f8,0x0000369d,0x000500b1, -0x0000002f,0x0000369f,0x000035dc,0x0000015e, -0x000400a8,0x0000002f,0x000036a0,0x0000369f, -0x000300f7,0x000036a7,0x00000000,0x000400fa, -0x000036a0,0x000036a1,0x000036a7,0x000200f8, -0x000036a1,0x00050041,0x00000182,0x000036a3, -0x00000180,0x000001b7,0x0004003d,0x00000006, -0x000036a4,0x000036a3,0x0004007c,0x000000e7, -0x000036a5,0x000036a4,0x000500af,0x0000002f, -0x000036a6,0x000035dc,0x000036a5,0x000200f9, -0x000036a7,0x000200f8,0x000036a7,0x000700f5, -0x0000002f,0x000036a8,0x0000369f,0x0000369d, -0x000036a6,0x000036a1,0x000300f7,0x000036aa, -0x00000000,0x000400fa,0x000036a8,0x000036a9, -0x000036aa,0x000200f8,0x000036a9,0x000200f9, -0x000036bf,0x000200f8,0x000036aa,0x00050084, -0x00000006,0x000036c8,0x000000df,0x000011de, -0x00050080,0x00000006,0x000036c9,0x0000018b, -0x000036c8,0x00050041,0x0000022d,0x000036ca, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x000036cb,0x000036ca,0x00050051,0x00000006, -0x000036e5,0x000036cb,0x00000000,0x00050095, -0x00000130,0x000036e7,0x000036e5,0x000036c9, -0x00050051,0x00000006,0x000036e8,0x000036e7, -0x00000001,0x00050051,0x00000006,0x000036e9, -0x000036e7,0x00000000,0x00050051,0x00000006, -0x000036ec,0x000036cb,0x00000001,0x00050080, -0x00000006,0x000036ee,0x000036ec,0x000036e8, -0x00050050,0x00000007,0x000036ef,0x000036e9, -0x000036ee,0x0004007c,0x00000014,0x000036df, -0x000036ef,0x00060041,0x0000015f,0x000036d6, -0x000036df,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x000036d7,0x000036d6,0x00000002, -0x00000004,0x0004007c,0x00000006,0x000036f6, -0x000035dc,0x00050084,0x00000006,0x000036f7, -0x000000df,0x000036f6,0x00050080,0x00000006, -0x000036f8,0x0000018b,0x000036f7,0x00050095, -0x00000130,0x00003716,0x000036e5,0x000036f8, -0x00050051,0x00000006,0x00003717,0x00003716, -0x00000001,0x00050051,0x00000006,0x00003718, -0x00003716,0x00000000,0x00050080,0x00000006, -0x0000371d,0x000036ec,0x00003717,0x00050050, -0x00000007,0x0000371e,0x00003718,0x0000371d, -0x0004007c,0x00000014,0x0000370e,0x0000371e, -0x00060041,0x0000015f,0x00003705,0x0000370e, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00003706,0x00003705,0x00000002,0x00000004, -0x000500aa,0x0000002f,0x000036b1,0x000036d7, -0x00003706,0x000300f7,0x000036b9,0x00000000, -0x000400fa,0x000036b1,0x000036b2,0x000036b9, -0x000200f8,0x000036b2,0x000500c6,0x000000e7, -0x000036b5,0x000012dc,0x000035dc,0x0004007c, -0x00000006,0x000036b6,0x000036b5,0x0006000c, -0x000000e7,0x000036b7,0x00000001,0x0000004b, -0x000036b6,0x00050082,0x000000e7,0x000036b8, -0x00000c77,0x000036b7,0x000200f9,0x000036bf, -0x000200f8,0x000036b9,0x000500c6,0x00000006, -0x000036bc,0x000036d7,0x00003706,0x0006000c, -0x000000e7,0x000036bd,0x00000001,0x0000004b, -0x000036bc,0x00050082,0x000000e7,0x000036be, -0x00000c7f,0x000036bd,0x000200f9,0x000036bf, -0x000200f8,0x000036bf,0x000900f5,0x000000e7, -0x00005a79,0x00000c68,0x000036a9,0x000036b8, -0x000036b2,0x000036be,0x000036b9,0x00050082, -0x000000e7,0x000035e0,0x000012dc,0x0000022b, -0x000300f7,0x00003749,0x00000000,0x000300fb, -0x0000012b,0x00003727,0x000200f8,0x00003727, -0x000500b1,0x0000002f,0x00003729,0x000035e0, -0x0000015e,0x000400a8,0x0000002f,0x0000372a, -0x00003729,0x000300f7,0x00003731,0x00000000, -0x000400fa,0x0000372a,0x0000372b,0x00003731, -0x000200f8,0x0000372b,0x00050041,0x00000182, -0x0000372d,0x00000180,0x000001b7,0x0004003d, -0x00000006,0x0000372e,0x0000372d,0x0004007c, -0x000000e7,0x0000372f,0x0000372e,0x000500af, -0x0000002f,0x00003730,0x000035e0,0x0000372f, -0x000200f9,0x00003731,0x000200f8,0x00003731, -0x000700f5,0x0000002f,0x00003732,0x00003729, -0x00003727,0x00003730,0x0000372b,0x000300f7, -0x00003734,0x00000000,0x000400fa,0x00003732, -0x00003733,0x00003734,0x000200f8,0x00003733, -0x000200f9,0x00003749,0x000200f8,0x00003734, -0x00050084,0x00000006,0x00003752,0x000000df, -0x000011de,0x00050080,0x00000006,0x00003753, -0x0000018b,0x00003752,0x00050041,0x0000022d, -0x00003754,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00003755,0x00003754,0x00050051, -0x00000006,0x0000376f,0x00003755,0x00000000, -0x00050095,0x00000130,0x00003771,0x0000376f, -0x00003753,0x00050051,0x00000006,0x00003772, -0x00003771,0x00000001,0x00050051,0x00000006, -0x00003773,0x00003771,0x00000000,0x00050051, -0x00000006,0x00003776,0x00003755,0x00000001, -0x00050080,0x00000006,0x00003778,0x00003776, -0x00003772,0x00050050,0x00000007,0x00003779, -0x00003773,0x00003778,0x0004007c,0x00000014, -0x00003769,0x00003779,0x00060041,0x0000015f, -0x00003760,0x00003769,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00003761,0x00003760, +0x00004c4b,0x00000000,0x00050051,0x00000006, +0x00004c50,0x000040dd,0x00000001,0x00050080, +0x00000006,0x00004c52,0x00004c50,0x00004c4c, +0x00050050,0x00000007,0x00004c53,0x00004c4d, +0x00004c52,0x0004007c,0x00000014,0x00004c43, +0x00004c53,0x00060041,0x0000016c,0x00004c3b, +0x00004c43,0x0000016b,0x0000016b,0x0005003e, +0x00004c3b,0x000040df,0x00000002,0x00000004, +0x0004003d,0x00000006,0x000040e3,0x000040de, +0x000500ab,0x0000002f,0x000040e4,0x000040e3, +0x00000539,0x000300f7,0x000040f6,0x00000000, +0x000400fa,0x000040e4,0x000040e5,0x000040f6, +0x000200f8,0x000040e5,0x00050041,0x000001bb, +0x000040e6,0x000001b9,0x000010be,0x0004003d, +0x00000006,0x000040e7,0x000040e6,0x0004003d, +0x00000006,0x000040ea,0x000040de,0x000500c2, +0x00000006,0x00004c57,0x000040ea,0x0000031d, +0x00050041,0x000001bb,0x000040ec,0x000001b9, +0x0000034a,0x0004003d,0x00000006,0x000040ed, +0x000040ec,0x00050086,0x00000006,0x000040ee, +0x000040ed,0x000001c4,0x00050082,0x00000006, +0x000040ef,0x00004c57,0x000040ee,0x00050084, +0x00000006,0x000040f0,0x000000ec,0x000040ef, +0x00050080,0x00000006,0x000040f1,0x000040e7, +0x000040f0,0x00050095,0x0000013d,0x00004c6f, +0x00004c49,0x000040f1,0x00050051,0x00000006, +0x00004c70,0x00004c6f,0x00000001,0x00050051, +0x00000006,0x00004c71,0x00004c6f,0x00000000, +0x00050080,0x00000006,0x00004c76,0x00004c50, +0x00004c70,0x00050050,0x00000007,0x00004c77, +0x00004c71,0x00004c76,0x0004007c,0x00000014, +0x00004c67,0x00004c77,0x00060041,0x0000016c, +0x00004c5f,0x00004c67,0x0000016b,0x0000016b, +0x0005003e,0x00004c5f,0x00004c19,0x00000002, +0x00000004,0x000200f9,0x000040fe,0x000200f8, +0x000040f6,0x000300f7,0x00004cd0,0x00000000, +0x000300fb,0x00000138,0x00004c96,0x000200f8, +0x00004c96,0x000300f7,0x00004ca1,0x00000000, +0x000400fa,0x00004c23,0x00004c98,0x00004ca1, +0x000200f8,0x00004c98,0x00050080,0x00000006, +0x00004c9a,0x00004c14,0x000001db,0x00050084, +0x00000006,0x00004c9c,0x000001d4,0x00005dfb, +0x00050080,0x00000006,0x00004c9d,0x00004c9a, +0x00004c9c,0x00050095,0x0000013d,0x00004dcc, +0x00004c49,0x00004c9d,0x00050051,0x00000006, +0x00004dcd,0x00004dcc,0x00000001,0x00050051, +0x00000006,0x00004dce,0x00004dcc,0x00000000, +0x00050080,0x00000006,0x00004dd3,0x00004c50, +0x00004dcd,0x00050050,0x00000007,0x00004dd4, +0x00004dce,0x00004dd3,0x0004007c,0x00000014, +0x00004dc4,0x00004dd4,0x00060041,0x0000016c, +0x00004dbc,0x00004dc4,0x0000016b,0x0000016b, +0x0005003e,0x00004dbc,0x00006112,0x00000002, +0x00000004,0x00050080,0x00000006,0x00004cf4, +0x00004c9d,0x000000ec,0x00050095,0x0000013d, +0x00004e94,0x00004c49,0x00004cf4,0x00050051, +0x00000006,0x00004e95,0x00004e94,0x00000001, +0x00050051,0x00000006,0x00004e96,0x00004e94, +0x00000000,0x00050080,0x00000006,0x00004e9b, +0x00004c50,0x00004e95,0x00050050,0x00000007, +0x00004e9c,0x00004e96,0x00004e9b,0x0004007c, +0x00000014,0x00004e8c,0x00004e9c,0x00060041, +0x0000016c,0x00004e84,0x00004e8c,0x0000016b, +0x0000016b,0x0005003e,0x00004e84,0x00006114, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004d01,0x00004c9d,0x000001cd,0x00050095, +0x0000013d,0x00004f5c,0x00004c49,0x00004d01, +0x00050051,0x00000006,0x00004f5d,0x00004f5c, +0x00000001,0x00050051,0x00000006,0x00004f5e, +0x00004f5c,0x00000000,0x00050080,0x00000006, +0x00004f63,0x00004c50,0x00004f5d,0x00050050, +0x00000007,0x00004f64,0x00004f5e,0x00004f63, +0x0004007c,0x00000014,0x00004f54,0x00004f64, +0x00060041,0x0000016c,0x00004f4c,0x00004f54, +0x0000016b,0x0000016b,0x0005003e,0x00004f4c, +0x00006115,0x00000002,0x00000004,0x000200f9, +0x00004cd0,0x000200f8,0x00004ca1,0x00050080, +0x00000006,0x00004ca3,0x00004c14,0x000001db, +0x00050084,0x00000006,0x00004ca5,0x000001ef, +0x00005dfb,0x00050080,0x00000006,0x00004ca6, +0x00004ca3,0x00004ca5,0x00050095,0x0000013d, +0x00004f85,0x00004c49,0x00004ca6,0x00050051, +0x00000006,0x00004f86,0x00004f85,0x00000001, +0x00050051,0x00000006,0x00004f87,0x00004f85, +0x00000000,0x00050080,0x00000006,0x00004f8c, +0x00004c50,0x00004f86,0x00050050,0x00000007, +0x00004f8d,0x00004f87,0x00004f8c,0x0004007c, +0x00000014,0x00004f7d,0x00004f8d,0x00060041, +0x0000016c,0x00004f75,0x00004f7d,0x0000016b, +0x0000016b,0x0005003e,0x00004f75,0x0000037e, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004cae,0x00004ca6,0x000000ec,0x00050095, +0x0000013d,0x00004fae,0x00004c49,0x00004cae, +0x00050051,0x00000006,0x00004faf,0x00004fae, +0x00000001,0x00050051,0x00000006,0x00004fb0, +0x00004fae,0x00000000,0x00050080,0x00000006, +0x00004fb5,0x00004c50,0x00004faf,0x00050050, +0x00000007,0x00004fb6,0x00004fb0,0x00004fb5, +0x0004007c,0x00000014,0x00004fa6,0x00004fb6, +0x00060041,0x0000016c,0x00004f9e,0x00004fa6, +0x0000016b,0x0000016b,0x0005003e,0x00004f9e, +0x0000037e,0x00000002,0x00000004,0x00050080, +0x00000006,0x00004cb5,0x00004ca6,0x000001cd, +0x00050095,0x0000013d,0x00004fd7,0x00004c49, +0x00004cb5,0x00050051,0x00000006,0x00004fd8, +0x00004fd7,0x00000001,0x00050051,0x00000006, +0x00004fd9,0x00004fd7,0x00000000,0x00050080, +0x00000006,0x00004fde,0x00004c50,0x00004fd8, +0x00050050,0x00000007,0x00004fdf,0x00004fd9, +0x00004fde,0x0004007c,0x00000014,0x00004fcf, +0x00004fdf,0x00060041,0x0000016c,0x00004fc7, +0x00004fcf,0x0000016b,0x0000016b,0x0005003e, +0x00004fc7,0x0000037e,0x00000002,0x00000004, +0x00050080,0x00000006,0x00004cbc,0x00004ca6, +0x000001d4,0x00050095,0x0000013d,0x00005000, +0x00004c49,0x00004cbc,0x00050051,0x00000006, +0x00005001,0x00005000,0x00000001,0x00050051, +0x00000006,0x00005002,0x00005000,0x00000000, +0x00050080,0x00000006,0x00005007,0x00004c50, +0x00005001,0x00050050,0x00000007,0x00005008, +0x00005002,0x00005007,0x0004007c,0x00000014, +0x00004ff8,0x00005008,0x00060041,0x0000016c, +0x00004ff0,0x00004ff8,0x0000016b,0x0000016b, +0x0005003e,0x00004ff0,0x00006100,0x00000002, +0x00000004,0x00050080,0x00000006,0x00004cc3, +0x00004ca6,0x000001db,0x00050095,0x0000013d, +0x00005029,0x00004c49,0x00004cc3,0x00050051, +0x00000006,0x0000502a,0x00005029,0x00000001, +0x00050051,0x00000006,0x0000502b,0x00005029, +0x00000000,0x00050080,0x00000006,0x00005030, +0x00004c50,0x0000502a,0x00050050,0x00000007, +0x00005031,0x0000502b,0x00005030,0x0004007c, +0x00000014,0x00005021,0x00005031,0x00060041, +0x0000016c,0x00005019,0x00005021,0x0000016b, +0x0000016b,0x0005003e,0x00005019,0x00006100, +0x00000002,0x00000004,0x00050080,0x00000006, +0x00004cca,0x00004ca6,0x00000299,0x00050095, +0x0000013d,0x00005052,0x00004c49,0x00004cca, +0x00050051,0x00000006,0x00005053,0x00005052, +0x00000001,0x00050051,0x00000006,0x00005054, +0x00005052,0x00000000,0x00050080,0x00000006, +0x00005059,0x00004c50,0x00005053,0x00050050, +0x00000007,0x0000505a,0x00005054,0x00005059, +0x0004007c,0x00000014,0x0000504a,0x0000505a, +0x00060041,0x0000016c,0x00005042,0x0000504a, +0x0000016b,0x0000016b,0x0005003e,0x00005042, +0x00006100,0x00000002,0x00000004,0x000200f9, +0x00004cd0,0x000200f8,0x00004cd0,0x000200f9, +0x000040fe,0x000200f8,0x000040fe,0x00050080, +0x00000006,0x00004100,0x00005dfb,0x00000264, +0x000200f9,0x000040d2,0x000200f8,0x00004101, +0x000400a8,0x0000002f,0x00004103,0x00004c23, +0x000300f7,0x00004116,0x00000000,0x000400fa, +0x00004103,0x00004104,0x00004116,0x000200f8, +0x00004104,0x000200f9,0x00004105,0x000200f8, +0x00004105,0x000700f5,0x00000006,0x00005dfc, +0x00000138,0x00004104,0x00004114,0x00004109, +0x000500b0,0x0000002f,0x00004108,0x00005dfc, +0x000000ec,0x000400f6,0x00004115,0x00004109, +0x00000000,0x000400fa,0x00004108,0x00004109, +0x00004115,0x000200f8,0x00004109,0x00050080, +0x00000006,0x0000410b,0x00004c14,0x00000840, +0x00050084,0x00000006,0x0000410d,0x000000ec, +0x00005dfc,0x00050080,0x00000006,0x0000410e, +0x0000410b,0x0000410d,0x00050041,0x00000266, +0x0000410f,0x000001b9,0x0000016b,0x0004003d, +0x00000007,0x00004110,0x0000410f,0x00050051, +0x00000006,0x00005076,0x00004110,0x00000000, +0x00050095,0x0000013d,0x00005078,0x00005076, +0x0000410e,0x00050051,0x00000006,0x00005079, +0x00005078,0x00000001,0x00050051,0x00000006, +0x0000507a,0x00005078,0x00000000,0x00050051, +0x00000006,0x0000507d,0x00004110,0x00000001, +0x00050080,0x00000006,0x0000507f,0x0000507d, +0x00005079,0x00050050,0x00000007,0x00005080, +0x0000507a,0x0000507f,0x0004007c,0x00000014, +0x00005070,0x00005080,0x00060041,0x0000016c, +0x00005068,0x00005070,0x0000016b,0x0000016b, +0x0005003e,0x00005068,0x00000138,0x00000002, +0x00000004,0x00050080,0x00000006,0x00004114, +0x00005dfc,0x00000264,0x000200f9,0x00004105, +0x000200f8,0x00004115,0x000200f9,0x00004116, +0x000200f8,0x00004116,0x00050041,0x000001bb, +0x000050b4,0x000001b9,0x000001ba,0x0004003d, +0x00000006,0x000050b5,0x000050b4,0x00050084, +0x00000006,0x000050b6,0x000001db,0x000050b5, +0x00050080,0x00000006,0x000050b7,0x000001c4, +0x000050b6,0x00050080,0x00000006,0x000050bd, +0x000050b5,0x0000062f,0x00050086,0x00000006, +0x000050be,0x000050bd,0x000001be,0x00050084, +0x00000006,0x000050b0,0x000001c4,0x000050be, +0x00050080,0x00000006,0x000050b1,0x000050b7, +0x000050b0,0x00050080,0x00000006,0x000050ab, +0x000050b1,0x000050b0,0x00050084,0x00000006, +0x000050a4,0x000001ef,0x0000402d,0x00050080, +0x00000006,0x000050a5,0x000050ab,0x000050a4, +0x00050084,0x00000006,0x0000509a,0x00000205, +0x00005dd8,0x00050080,0x00000006,0x0000509b, +0x000050a5,0x0000509a,0x00050041,0x00000266, +0x0000509c,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x0000509d,0x0000509c,0x00050051, +0x00000006,0x000050d3,0x0000509d,0x00000000, +0x00050095,0x0000013d,0x000050d5,0x000050d3, +0x0000509b,0x00050051,0x00000006,0x000050d6, +0x000050d5,0x00000001,0x00050051,0x00000006, +0x000050d7,0x000050d5,0x00000000,0x00050051, +0x00000006,0x000050da,0x0000509d,0x00000001, +0x00050080,0x00000006,0x000050dc,0x000050da, +0x000050d6,0x00050050,0x00000007,0x000050dd, +0x000050d7,0x000050dc,0x0004007c,0x00000014, +0x000050cd,0x000050dd,0x00060041,0x0000016c, +0x00005087,0x000050cd,0x0000016b,0x0000016b, +0x0005003e,0x00005087,0x00000138,0x00000002, +0x00000004,0x00060041,0x0000016c,0x00005089, +0x000050cd,0x0000016b,0x00000264,0x0005003e, +0x00005089,0x00000539,0x00000002,0x00000004, +0x00060041,0x0000016c,0x0000508b,0x000050cd, +0x0000016b,0x00000315,0x0005003e,0x0000508b, +0x00000539,0x00000002,0x00000004,0x00060041, +0x0000016c,0x0000508d,0x000050cd,0x0000016b, +0x0000031d,0x0005003e,0x0000508d,0x00000539, +0x00000002,0x00000004,0x00060041,0x0000016c, +0x0000508f,0x000050cd,0x0000016b,0x00000325, +0x0005003e,0x0000508f,0x00000138,0x00000002, +0x00000004,0x00060041,0x0000016c,0x00005091, +0x000050cd,0x0000016b,0x0000032d,0x0005003e, +0x00005091,0x00000138,0x00000002,0x00000004, +0x00060041,0x0000016c,0x00005093,0x000050cd, +0x0000016b,0x00000351,0x0005003e,0x00005093, +0x00000138,0x00000002,0x00000004,0x000200f9, +0x00004119,0x000200f8,0x00004119,0x000200f9, +0x000013e3,0x000200f8,0x000013e3,0x000200f9, +0x000013d9,0x000200f8,0x000013d8,0x0004007c, +0x000000f4,0x000013db,0x000012dd,0x00050080, +0x000000f4,0x00003968,0x000013db,0x00000264, +0x000300f7,0x00003a4b,0x00000000,0x000300fb, +0x00000138,0x00003a29,0x000200f8,0x00003a29, +0x000500b1,0x0000002f,0x00003a2b,0x00003968, +0x0000016b,0x000400a8,0x0000002f,0x00003a2c, +0x00003a2b,0x000300f7,0x00003a33,0x00000000, +0x000400fa,0x00003a2c,0x00003a2d,0x00003a33, +0x000200f8,0x00003a2d,0x00050041,0x000001bb, +0x00003a2f,0x000001b9,0x000001f0,0x0004003d, +0x00000006,0x00003a30,0x00003a2f,0x0004007c, +0x000000f4,0x00003a31,0x00003a30,0x000500af, +0x0000002f,0x00003a32,0x00003968,0x00003a31, +0x000200f9,0x00003a33,0x000200f8,0x00003a33, +0x000700f5,0x0000002f,0x00003a34,0x00003a2b, +0x00003a29,0x00003a32,0x00003a2d,0x000300f7, +0x00003a36,0x00000000,0x000400fa,0x00003a34, +0x00003a35,0x00003a36,0x000200f8,0x00003a35, +0x000200f9,0x00003a4b,0x000200f8,0x00003a36, +0x00050084,0x00000006,0x00003a54,0x000000ec, +0x000012dd,0x00050080,0x00000006,0x00003a55, +0x000001c4,0x00003a54,0x00050041,0x00000266, +0x00003a56,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x00003a57,0x00003a56,0x00050051, +0x00000006,0x00003a71,0x00003a57,0x00000000, +0x00050095,0x0000013d,0x00003a73,0x00003a71, +0x00003a55,0x00050051,0x00000006,0x00003a74, +0x00003a73,0x00000001,0x00050051,0x00000006, +0x00003a75,0x00003a73,0x00000000,0x00050051, +0x00000006,0x00003a78,0x00003a57,0x00000001, +0x00050080,0x00000006,0x00003a7a,0x00003a78, +0x00003a74,0x00050050,0x00000007,0x00003a7b, +0x00003a75,0x00003a7a,0x0004007c,0x00000014, +0x00003a6b,0x00003a7b,0x00060041,0x0000016c, +0x00003a62,0x00003a6b,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003a63,0x00003a62, 0x00000002,0x00000004,0x0004007c,0x00000006, -0x00003780,0x000035e0,0x00050084,0x00000006, -0x00003781,0x000000df,0x00003780,0x00050080, -0x00000006,0x00003782,0x0000018b,0x00003781, -0x00050095,0x00000130,0x000037a0,0x0000376f, -0x00003782,0x00050051,0x00000006,0x000037a1, -0x000037a0,0x00000001,0x00050051,0x00000006, -0x000037a2,0x000037a0,0x00000000,0x00050080, -0x00000006,0x000037a7,0x00003776,0x000037a1, -0x00050050,0x00000007,0x000037a8,0x000037a2, -0x000037a7,0x0004007c,0x00000014,0x00003798, -0x000037a8,0x00060041,0x0000015f,0x0000378f, -0x00003798,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00003790,0x0000378f,0x00000002, -0x00000004,0x000500aa,0x0000002f,0x0000373b, -0x00003761,0x00003790,0x000300f7,0x00003743, -0x00000000,0x000400fa,0x0000373b,0x0000373c, -0x00003743,0x000200f8,0x0000373c,0x000500c6, -0x000000e7,0x0000373f,0x000012dc,0x000035e0, -0x0004007c,0x00000006,0x00003740,0x0000373f, -0x0006000c,0x000000e7,0x00003741,0x00000001, -0x0000004b,0x00003740,0x00050082,0x000000e7, -0x00003742,0x00000c77,0x00003741,0x000200f9, -0x00003749,0x000200f8,0x00003743,0x000500c6, -0x00000006,0x00003746,0x00003761,0x00003790, -0x0006000c,0x000000e7,0x00003747,0x00000001, -0x0000004b,0x00003746,0x00050082,0x000000e7, -0x00003748,0x00000c7f,0x00003747,0x000200f9, -0x00003749,0x000200f8,0x00003749,0x000900f5, -0x000000e7,0x00005a7a,0x00000c68,0x00003733, -0x00003742,0x0000373c,0x00003748,0x00003743, -0x00050082,0x000000e7,0x000035e3,0x00005a79, -0x00005a7a,0x000500ad,0x0000002f,0x000035e4, -0x000035e3,0x0000015e,0x000600a9,0x000000e7, -0x000035e5,0x000035e4,0x0000022b,0x00000c68, -0x00050082,0x000000e7,0x000035e8,0x000012dc, -0x000035e5,0x000300f7,0x000037d3,0x00000000, -0x000300fb,0x0000012b,0x000037b1,0x000200f8, -0x000037b1,0x000500b1,0x0000002f,0x000037b3, -0x000035e8,0x0000015e,0x000400a8,0x0000002f, -0x000037b4,0x000037b3,0x000300f7,0x000037bb, -0x00000000,0x000400fa,0x000037b4,0x000037b5, -0x000037bb,0x000200f8,0x000037b5,0x00050041, -0x00000182,0x000037b7,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x000037b8,0x000037b7, -0x0004007c,0x000000e7,0x000037b9,0x000037b8, -0x000500af,0x0000002f,0x000037ba,0x000035e8, -0x000037b9,0x000200f9,0x000037bb,0x000200f8, -0x000037bb,0x000700f5,0x0000002f,0x000037bc, -0x000037b3,0x000037b1,0x000037ba,0x000037b5, -0x000300f7,0x000037be,0x00000000,0x000400fa, -0x000037bc,0x000037bd,0x000037be,0x000200f8, -0x000037bd,0x000200f9,0x000037d3,0x000200f8, -0x000037be,0x00050084,0x00000006,0x000037dc, -0x000000df,0x000011de,0x00050080,0x00000006, -0x000037dd,0x0000018b,0x000037dc,0x00050041, -0x0000022d,0x000037de,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x000037df,0x000037de, -0x00050051,0x00000006,0x000037f9,0x000037df, -0x00000000,0x00050095,0x00000130,0x000037fb, -0x000037f9,0x000037dd,0x00050051,0x00000006, -0x000037fc,0x000037fb,0x00000001,0x00050051, -0x00000006,0x000037fd,0x000037fb,0x00000000, -0x00050051,0x00000006,0x00003800,0x000037df, -0x00000001,0x00050080,0x00000006,0x00003802, -0x00003800,0x000037fc,0x00050050,0x00000007, -0x00003803,0x000037fd,0x00003802,0x0004007c, -0x00000014,0x000037f3,0x00003803,0x00060041, -0x0000015f,0x000037ea,0x000037f3,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000037eb, -0x000037ea,0x00000002,0x00000004,0x0004007c, -0x00000006,0x0000380a,0x000035e8,0x00050084, -0x00000006,0x0000380b,0x000000df,0x0000380a, -0x00050080,0x00000006,0x0000380c,0x0000018b, -0x0000380b,0x00050095,0x00000130,0x0000382a, -0x000037f9,0x0000380c,0x00050051,0x00000006, -0x0000382b,0x0000382a,0x00000001,0x00050051, -0x00000006,0x0000382c,0x0000382a,0x00000000, -0x00050080,0x00000006,0x00003831,0x00003800, -0x0000382b,0x00050050,0x00000007,0x00003832, -0x0000382c,0x00003831,0x0004007c,0x00000014, -0x00003822,0x00003832,0x00060041,0x0000015f, -0x00003819,0x00003822,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x0000381a,0x00003819, -0x00000002,0x00000004,0x000500aa,0x0000002f, -0x000037c5,0x000037eb,0x0000381a,0x000300f7, -0x000037cd,0x00000000,0x000400fa,0x000037c5, -0x000037c6,0x000037cd,0x000200f8,0x000037c6, -0x000500c6,0x000000e7,0x000037c9,0x000012dc, -0x000035e8,0x0004007c,0x00000006,0x000037ca, -0x000037c9,0x0006000c,0x000000e7,0x000037cb, -0x00000001,0x0000004b,0x000037ca,0x00050082, -0x000000e7,0x000037cc,0x00000c77,0x000037cb, -0x000200f9,0x000037d3,0x000200f8,0x000037cd, -0x000500c6,0x00000006,0x000037d0,0x000037eb, -0x0000381a,0x0006000c,0x000000e7,0x000037d1, -0x00000001,0x0000004b,0x000037d0,0x00050082, -0x000000e7,0x000037d2,0x00000c7f,0x000037d1, -0x000200f9,0x000037d3,0x000200f8,0x000037d3, -0x000900f5,0x000000e7,0x00005a7b,0x00000c68, -0x000037bd,0x000037cc,0x000037c6,0x000037d2, -0x000037cd,0x000200f9,0x000035eb,0x000200f8, -0x000035eb,0x000700f5,0x000000e7,0x00005a7c, -0x000002dc,0x000037d3,0x000035f8,0x000035f6, -0x000400f6,0x000035fa,0x000035f6,0x00000000, -0x000200f9,0x000035ec,0x000200f8,0x000035ec, -0x00050084,0x000000e7,0x000035f0,0x00005a7c, -0x000035e5,0x00050080,0x000000e7,0x000035f1, -0x000012dc,0x000035f0,0x000300f7,0x0000385d, -0x00000000,0x000300fb,0x0000012b,0x0000383b, -0x000200f8,0x0000383b,0x000500b1,0x0000002f, -0x0000383d,0x000035f1,0x0000015e,0x000400a8, -0x0000002f,0x0000383e,0x0000383d,0x000300f7, -0x00003845,0x00000000,0x000400fa,0x0000383e, -0x0000383f,0x00003845,0x000200f8,0x0000383f, -0x00050041,0x00000182,0x00003841,0x00000180, -0x000001b7,0x0004003d,0x00000006,0x00003842, -0x00003841,0x0004007c,0x000000e7,0x00003843, -0x00003842,0x000500af,0x0000002f,0x00003844, -0x000035f1,0x00003843,0x000200f9,0x00003845, -0x000200f8,0x00003845,0x000700f5,0x0000002f, -0x00003846,0x0000383d,0x0000383b,0x00003844, -0x0000383f,0x000300f7,0x00003848,0x00000000, -0x000400fa,0x00003846,0x00003847,0x00003848, -0x000200f8,0x00003847,0x000200f9,0x0000385d, -0x000200f8,0x00003848,0x00050084,0x00000006, -0x00003866,0x000000df,0x000011de,0x00050080, -0x00000006,0x00003867,0x0000018b,0x00003866, -0x00050041,0x0000022d,0x00003868,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x00003869, -0x00003868,0x00050051,0x00000006,0x00003883, -0x00003869,0x00000000,0x00050095,0x00000130, -0x00003885,0x00003883,0x00003867,0x00050051, -0x00000006,0x00003886,0x00003885,0x00000001, -0x00050051,0x00000006,0x00003887,0x00003885, -0x00000000,0x00050051,0x00000006,0x0000388a, -0x00003869,0x00000001,0x00050080,0x00000006, -0x0000388c,0x0000388a,0x00003886,0x00050050, -0x00000007,0x0000388d,0x00003887,0x0000388c, -0x0004007c,0x00000014,0x0000387d,0x0000388d, -0x00060041,0x0000015f,0x00003874,0x0000387d, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00003875,0x00003874,0x00000002,0x00000004, -0x0004007c,0x00000006,0x00003894,0x000035f1, -0x00050084,0x00000006,0x00003895,0x000000df, -0x00003894,0x00050080,0x00000006,0x00003896, -0x0000018b,0x00003895,0x00050095,0x00000130, -0x000038b4,0x00003883,0x00003896,0x00050051, -0x00000006,0x000038b5,0x000038b4,0x00000001, -0x00050051,0x00000006,0x000038b6,0x000038b4, -0x00000000,0x00050080,0x00000006,0x000038bb, -0x0000388a,0x000038b5,0x00050050,0x00000007, -0x000038bc,0x000038b6,0x000038bb,0x0004007c, -0x00000014,0x000038ac,0x000038bc,0x00060041, -0x0000015f,0x000038a3,0x000038ac,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000038a4, -0x000038a3,0x00000002,0x00000004,0x000500aa, -0x0000002f,0x0000384f,0x00003875,0x000038a4, -0x000300f7,0x00003857,0x00000000,0x000400fa, -0x0000384f,0x00003850,0x00003857,0x000200f8, -0x00003850,0x000500c6,0x000000e7,0x00003853, -0x000012dc,0x000035f1,0x0004007c,0x00000006, -0x00003854,0x00003853,0x0006000c,0x000000e7, -0x00003855,0x00000001,0x0000004b,0x00003854, -0x00050082,0x000000e7,0x00003856,0x00000c77, -0x00003855,0x000200f9,0x0000385d,0x000200f8, -0x00003857,0x000500c6,0x00000006,0x0000385a, -0x00003875,0x000038a4,0x0006000c,0x000000e7, -0x0000385b,0x00000001,0x0000004b,0x0000385a, -0x00050082,0x000000e7,0x0000385c,0x00000c7f, -0x0000385b,0x000200f9,0x0000385d,0x000200f8, -0x0000385d,0x000900f5,0x000000e7,0x00005a7d, -0x00000c68,0x00003847,0x00003856,0x00003850, -0x0000385c,0x00003857,0x000500ad,0x0000002f, -0x000035f5,0x00005a7d,0x00005a7b,0x000400fa, -0x000035f5,0x000035f6,0x000035fa,0x000200f8, -0x000035f6,0x000500c4,0x000000e7,0x000035f8, -0x00005a7c,0x0000022b,0x000200f9,0x000035eb, -0x000200f8,0x000035fa,0x000500c3,0x000000e7, -0x000035fc,0x00005a7c,0x0000022b,0x000200f9, -0x000035fd,0x000200f8,0x000035fd,0x000700f5, -0x000000e7,0x00005a81,0x0000015e,0x000035fa, -0x00005cdc,0x00003612,0x000700f5,0x000000e7, -0x00005a80,0x000035fc,0x000035fa,0x00003614, -0x00003612,0x000500af,0x0000002f,0x00003600, -0x00005a80,0x0000022b,0x000400f6,0x00003615, -0x00003612,0x00000000,0x000400fa,0x00003600, -0x00003601,0x00003615,0x000200f8,0x00003601, -0x00050080,0x000000e7,0x00003605,0x00005a81, -0x00005a80,0x00050084,0x000000e7,0x00003607, -0x00003605,0x000035e5,0x00050080,0x000000e7, -0x00003608,0x000012dc,0x00003607,0x000300f7, -0x000038e7,0x00000000,0x000300fb,0x0000012b, -0x000038c5,0x000200f8,0x000038c5,0x000500b1, -0x0000002f,0x000038c7,0x00003608,0x0000015e, -0x000400a8,0x0000002f,0x000038c8,0x000038c7, -0x000300f7,0x000038cf,0x00000000,0x000400fa, -0x000038c8,0x000038c9,0x000038cf,0x000200f8, -0x000038c9,0x00050041,0x00000182,0x000038cb, -0x00000180,0x000001b7,0x0004003d,0x00000006, -0x000038cc,0x000038cb,0x0004007c,0x000000e7, -0x000038cd,0x000038cc,0x000500af,0x0000002f, -0x000038ce,0x00003608,0x000038cd,0x000200f9, -0x000038cf,0x000200f8,0x000038cf,0x000700f5, -0x0000002f,0x000038d0,0x000038c7,0x000038c5, -0x000038ce,0x000038c9,0x000300f7,0x000038d2, -0x00000000,0x000400fa,0x000038d0,0x000038d1, -0x000038d2,0x000200f8,0x000038d1,0x000200f9, -0x000038e7,0x000200f8,0x000038d2,0x00050084, -0x00000006,0x000038f0,0x000000df,0x000011de, -0x00050080,0x00000006,0x000038f1,0x0000018b, -0x000038f0,0x00050041,0x0000022d,0x000038f2, -0x00000180,0x0000022b,0x0004003d,0x00000007, -0x000038f3,0x000038f2,0x00050051,0x00000006, -0x0000390d,0x000038f3,0x00000000,0x00050095, -0x00000130,0x0000390f,0x0000390d,0x000038f1, -0x00050051,0x00000006,0x00003910,0x0000390f, -0x00000001,0x00050051,0x00000006,0x00003911, -0x0000390f,0x00000000,0x00050051,0x00000006, -0x00003914,0x000038f3,0x00000001,0x00050080, -0x00000006,0x00003916,0x00003914,0x00003910, -0x00050050,0x00000007,0x00003917,0x00003911, -0x00003916,0x0004007c,0x00000014,0x00003907, -0x00003917,0x00060041,0x0000015f,0x000038fe, -0x00003907,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x000038ff,0x000038fe,0x00000002, -0x00000004,0x0004007c,0x00000006,0x0000391e, -0x00003608,0x00050084,0x00000006,0x0000391f, -0x000000df,0x0000391e,0x00050080,0x00000006, -0x00003920,0x0000018b,0x0000391f,0x00050095, -0x00000130,0x0000393e,0x0000390d,0x00003920, -0x00050051,0x00000006,0x0000393f,0x0000393e, -0x00000001,0x00050051,0x00000006,0x00003940, -0x0000393e,0x00000000,0x00050080,0x00000006, -0x00003945,0x00003914,0x0000393f,0x00050050, -0x00000007,0x00003946,0x00003940,0x00003945, -0x0004007c,0x00000014,0x00003936,0x00003946, -0x00060041,0x0000015f,0x0000392d,0x00003936, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x0000392e,0x0000392d,0x00000002,0x00000004, -0x000500aa,0x0000002f,0x000038d9,0x000038ff, -0x0000392e,0x000300f7,0x000038e1,0x00000000, -0x000400fa,0x000038d9,0x000038da,0x000038e1, -0x000200f8,0x000038da,0x000500c6,0x000000e7, -0x000038dd,0x000012dc,0x00003608,0x0004007c, -0x00000006,0x000038de,0x000038dd,0x0006000c, -0x000000e7,0x000038df,0x00000001,0x0000004b, -0x000038de,0x00050082,0x000000e7,0x000038e0, -0x00000c77,0x000038df,0x000200f9,0x000038e7, -0x000200f8,0x000038e1,0x000500c6,0x00000006, -0x000038e4,0x000038ff,0x0000392e,0x0006000c, -0x000000e7,0x000038e5,0x00000001,0x0000004b, -0x000038e4,0x00050082,0x000000e7,0x000038e6, -0x00000c7f,0x000038e5,0x000200f9,0x000038e7, -0x000200f8,0x000038e7,0x000900f5,0x000000e7, -0x00005a97,0x00000c68,0x000038d1,0x000038e0, -0x000038da,0x000038e6,0x000038e1,0x000500ad, -0x0000002f,0x0000360c,0x00005a97,0x00005a7b, -0x000600a9,0x000000e7,0x00005cdc,0x0000360c, -0x00003605,0x00005a81,0x000200f9,0x00003612, -0x000200f8,0x00003612,0x000500c3,0x000000e7, -0x00003614,0x00005a80,0x0000022b,0x000200f9, -0x000035fd,0x000200f8,0x00003615,0x00050084, -0x000000e7,0x00003619,0x00005a81,0x000035e5, -0x00050080,0x000000e7,0x0000361a,0x000012dc, -0x00003619,0x000300f7,0x00003971,0x00000000, -0x000300fb,0x0000012b,0x0000394f,0x000200f8, -0x0000394f,0x000500b1,0x0000002f,0x00003951, -0x0000361a,0x0000015e,0x000400a8,0x0000002f, -0x00003952,0x00003951,0x000300f7,0x00003959, -0x00000000,0x000400fa,0x00003952,0x00003953, -0x00003959,0x000200f8,0x00003953,0x00050041, -0x00000182,0x00003955,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x00003956,0x00003955, -0x0004007c,0x000000e7,0x00003957,0x00003956, -0x000500af,0x0000002f,0x00003958,0x0000361a, -0x00003957,0x000200f9,0x00003959,0x000200f8, -0x00003959,0x000700f5,0x0000002f,0x0000395a, -0x00003951,0x0000394f,0x00003958,0x00003953, -0x000300f7,0x0000395c,0x00000000,0x000400fa, -0x0000395a,0x0000395b,0x0000395c,0x000200f8, -0x0000395b,0x000200f9,0x00003971,0x000200f8, -0x0000395c,0x00050084,0x00000006,0x0000397a, -0x000000df,0x000011de,0x00050080,0x00000006, -0x0000397b,0x0000018b,0x0000397a,0x00050041, -0x0000022d,0x0000397c,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x0000397d,0x0000397c, -0x00050051,0x00000006,0x00003997,0x0000397d, -0x00000000,0x00050095,0x00000130,0x00003999, -0x00003997,0x0000397b,0x00050051,0x00000006, -0x0000399a,0x00003999,0x00000001,0x00050051, -0x00000006,0x0000399b,0x00003999,0x00000000, -0x00050051,0x00000006,0x0000399e,0x0000397d, -0x00000001,0x00050080,0x00000006,0x000039a0, -0x0000399e,0x0000399a,0x00050050,0x00000007, -0x000039a1,0x0000399b,0x000039a0,0x0004007c, -0x00000014,0x00003991,0x000039a1,0x00060041, -0x0000015f,0x00003988,0x00003991,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003989, -0x00003988,0x00000002,0x00000004,0x0004007c, -0x00000006,0x000039a8,0x0000361a,0x00050084, -0x00000006,0x000039a9,0x000000df,0x000039a8, -0x00050080,0x00000006,0x000039aa,0x0000018b, -0x000039a9,0x00050095,0x00000130,0x000039c8, -0x00003997,0x000039aa,0x00050051,0x00000006, -0x000039c9,0x000039c8,0x00000001,0x00050051, -0x00000006,0x000039ca,0x000039c8,0x00000000, -0x00050080,0x00000006,0x000039cf,0x0000399e, -0x000039c9,0x00050050,0x00000007,0x000039d0, -0x000039ca,0x000039cf,0x0004007c,0x00000014, -0x000039c0,0x000039d0,0x00060041,0x0000015f, -0x000039b7,0x000039c0,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x000039b8,0x000039b7, +0x00003a82,0x00003968,0x00050084,0x00000006, +0x00003a83,0x000000ec,0x00003a82,0x00050080, +0x00000006,0x00003a84,0x000001c4,0x00003a83, +0x00050095,0x0000013d,0x00003aa2,0x00003a71, +0x00003a84,0x00050051,0x00000006,0x00003aa3, +0x00003aa2,0x00000001,0x00050051,0x00000006, +0x00003aa4,0x00003aa2,0x00000000,0x00050080, +0x00000006,0x00003aa9,0x00003a78,0x00003aa3, +0x00050050,0x00000007,0x00003aaa,0x00003aa4, +0x00003aa9,0x0004007c,0x00000014,0x00003a9a, +0x00003aaa,0x00060041,0x0000016c,0x00003a91, +0x00003a9a,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003a92,0x00003a91,0x00000002, +0x00000004,0x000500aa,0x0000002f,0x00003a3d, +0x00003a63,0x00003a92,0x000300f7,0x00003a45, +0x00000000,0x000400fa,0x00003a3d,0x00003a3e, +0x00003a45,0x000200f8,0x00003a3e,0x000500c6, +0x000000f4,0x00003a41,0x000013db,0x00003968, +0x0004007c,0x00000006,0x00003a42,0x00003a41, +0x0006000c,0x000000f4,0x00003a43,0x00000001, +0x0000004b,0x00003a42,0x00050082,0x000000f4, +0x00003a44,0x00000d76,0x00003a43,0x000200f9, +0x00003a4b,0x000200f8,0x00003a45,0x000500c6, +0x00000006,0x00003a48,0x00003a63,0x00003a92, +0x0006000c,0x000000f4,0x00003a49,0x00000001, +0x0000004b,0x00003a48,0x00050082,0x000000f4, +0x00003a4a,0x00000d7e,0x00003a49,0x000200f9, +0x00003a4b,0x000200f8,0x00003a4b,0x000900f5, +0x000000f4,0x00005e41,0x00000d67,0x00003a35, +0x00003a44,0x00003a3e,0x00003a4a,0x00003a45, +0x00050082,0x000000f4,0x0000396c,0x000013db, +0x00000264,0x000300f7,0x00003ad5,0x00000000, +0x000300fb,0x00000138,0x00003ab3,0x000200f8, +0x00003ab3,0x000500b1,0x0000002f,0x00003ab5, +0x0000396c,0x0000016b,0x000400a8,0x0000002f, +0x00003ab6,0x00003ab5,0x000300f7,0x00003abd, +0x00000000,0x000400fa,0x00003ab6,0x00003ab7, +0x00003abd,0x000200f8,0x00003ab7,0x00050041, +0x000001bb,0x00003ab9,0x000001b9,0x000001f0, +0x0004003d,0x00000006,0x00003aba,0x00003ab9, +0x0004007c,0x000000f4,0x00003abb,0x00003aba, +0x000500af,0x0000002f,0x00003abc,0x0000396c, +0x00003abb,0x000200f9,0x00003abd,0x000200f8, +0x00003abd,0x000700f5,0x0000002f,0x00003abe, +0x00003ab5,0x00003ab3,0x00003abc,0x00003ab7, +0x000300f7,0x00003ac0,0x00000000,0x000400fa, +0x00003abe,0x00003abf,0x00003ac0,0x000200f8, +0x00003abf,0x000200f9,0x00003ad5,0x000200f8, +0x00003ac0,0x00050084,0x00000006,0x00003ade, +0x000000ec,0x000012dd,0x00050080,0x00000006, +0x00003adf,0x000001c4,0x00003ade,0x00050041, +0x00000266,0x00003ae0,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00003ae1,0x00003ae0, +0x00050051,0x00000006,0x00003afb,0x00003ae1, +0x00000000,0x00050095,0x0000013d,0x00003afd, +0x00003afb,0x00003adf,0x00050051,0x00000006, +0x00003afe,0x00003afd,0x00000001,0x00050051, +0x00000006,0x00003aff,0x00003afd,0x00000000, +0x00050051,0x00000006,0x00003b02,0x00003ae1, +0x00000001,0x00050080,0x00000006,0x00003b04, +0x00003b02,0x00003afe,0x00050050,0x00000007, +0x00003b05,0x00003aff,0x00003b04,0x0004007c, +0x00000014,0x00003af5,0x00003b05,0x00060041, +0x0000016c,0x00003aec,0x00003af5,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003aed, +0x00003aec,0x00000002,0x00000004,0x0004007c, +0x00000006,0x00003b0c,0x0000396c,0x00050084, +0x00000006,0x00003b0d,0x000000ec,0x00003b0c, +0x00050080,0x00000006,0x00003b0e,0x000001c4, +0x00003b0d,0x00050095,0x0000013d,0x00003b2c, +0x00003afb,0x00003b0e,0x00050051,0x00000006, +0x00003b2d,0x00003b2c,0x00000001,0x00050051, +0x00000006,0x00003b2e,0x00003b2c,0x00000000, +0x00050080,0x00000006,0x00003b33,0x00003b02, +0x00003b2d,0x00050050,0x00000007,0x00003b34, +0x00003b2e,0x00003b33,0x0004007c,0x00000014, +0x00003b24,0x00003b34,0x00060041,0x0000016c, +0x00003b1b,0x00003b24,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003b1c,0x00003b1b, 0x00000002,0x00000004,0x000500aa,0x0000002f, -0x00003963,0x00003989,0x000039b8,0x000300f7, -0x0000396b,0x00000000,0x000400fa,0x00003963, -0x00003964,0x0000396b,0x000200f8,0x00003964, -0x000500c6,0x000000e7,0x00003967,0x000012dc, -0x0000361a,0x0004007c,0x00000006,0x00003968, -0x00003967,0x0006000c,0x000000e7,0x00003969, -0x00000001,0x0000004b,0x00003968,0x00050082, -0x000000e7,0x0000396a,0x00000c77,0x00003969, -0x000200f9,0x00003971,0x000200f8,0x0000396b, -0x000500c6,0x00000006,0x0000396e,0x00003989, -0x000039b8,0x0006000c,0x000000e7,0x0000396f, -0x00000001,0x0000004b,0x0000396e,0x00050082, -0x000000e7,0x00003970,0x00000c7f,0x0000396f, -0x000200f9,0x00003971,0x000200f8,0x00003971, -0x000900f5,0x000000e7,0x00005a82,0x00000c68, -0x0000395b,0x0000396a,0x00003964,0x00003970, -0x0000396b,0x000200f9,0x0000361f,0x000200f8, -0x0000361f,0x000700f5,0x000000e7,0x00005a86, -0x0000015e,0x00003971,0x00005cdd,0x00003634, -0x000700f5,0x000000e7,0x00005a85,0x00005a81, -0x00003971,0x00003623,0x00003634,0x000400f6, -0x00003637,0x00003634,0x00000000,0x000200f9, -0x00003620,0x000200f8,0x00003620,0x00050080, -0x000000e7,0x00003622,0x00005a85,0x0000022b, -0x000500c3,0x000000e7,0x00003623,0x00003622, -0x0000022b,0x00050080,0x000000e7,0x00003627, -0x00005a86,0x00003623,0x00050084,0x000000e7, -0x00003629,0x00003627,0x000035e5,0x00050080, -0x000000e7,0x0000362a,0x000012dc,0x00003629, -0x000300f7,0x000039fb,0x00000000,0x000300fb, -0x0000012b,0x000039d9,0x000200f8,0x000039d9, -0x000500b1,0x0000002f,0x000039db,0x0000362a, -0x0000015e,0x000400a8,0x0000002f,0x000039dc, -0x000039db,0x000300f7,0x000039e3,0x00000000, -0x000400fa,0x000039dc,0x000039dd,0x000039e3, -0x000200f8,0x000039dd,0x00050041,0x00000182, -0x000039df,0x00000180,0x000001b7,0x0004003d, -0x00000006,0x000039e0,0x000039df,0x0004007c, -0x000000e7,0x000039e1,0x000039e0,0x000500af, -0x0000002f,0x000039e2,0x0000362a,0x000039e1, -0x000200f9,0x000039e3,0x000200f8,0x000039e3, -0x000700f5,0x0000002f,0x000039e4,0x000039db, -0x000039d9,0x000039e2,0x000039dd,0x000300f7, -0x000039e6,0x00000000,0x000400fa,0x000039e4, -0x000039e5,0x000039e6,0x000200f8,0x000039e5, -0x000200f9,0x000039fb,0x000200f8,0x000039e6, -0x00050084,0x00000006,0x00003a04,0x000000df, -0x000011de,0x00050080,0x00000006,0x00003a05, -0x0000018b,0x00003a04,0x00050041,0x0000022d, -0x00003a06,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x00003a07,0x00003a06,0x00050051, -0x00000006,0x00003a21,0x00003a07,0x00000000, -0x00050095,0x00000130,0x00003a23,0x00003a21, -0x00003a05,0x00050051,0x00000006,0x00003a24, -0x00003a23,0x00000001,0x00050051,0x00000006, -0x00003a25,0x00003a23,0x00000000,0x00050051, -0x00000006,0x00003a28,0x00003a07,0x00000001, -0x00050080,0x00000006,0x00003a2a,0x00003a28, -0x00003a24,0x00050050,0x00000007,0x00003a2b, -0x00003a25,0x00003a2a,0x0004007c,0x00000014, -0x00003a1b,0x00003a2b,0x00060041,0x0000015f, -0x00003a12,0x00003a1b,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00003a13,0x00003a12, +0x00003ac7,0x00003aed,0x00003b1c,0x000300f7, +0x00003acf,0x00000000,0x000400fa,0x00003ac7, +0x00003ac8,0x00003acf,0x000200f8,0x00003ac8, +0x000500c6,0x000000f4,0x00003acb,0x000013db, +0x0000396c,0x0004007c,0x00000006,0x00003acc, +0x00003acb,0x0006000c,0x000000f4,0x00003acd, +0x00000001,0x0000004b,0x00003acc,0x00050082, +0x000000f4,0x00003ace,0x00000d76,0x00003acd, +0x000200f9,0x00003ad5,0x000200f8,0x00003acf, +0x000500c6,0x00000006,0x00003ad2,0x00003aed, +0x00003b1c,0x0006000c,0x000000f4,0x00003ad3, +0x00000001,0x0000004b,0x00003ad2,0x00050082, +0x000000f4,0x00003ad4,0x00000d7e,0x00003ad3, +0x000200f9,0x00003ad5,0x000200f8,0x00003ad5, +0x000900f5,0x000000f4,0x00005e42,0x00000d67, +0x00003abf,0x00003ace,0x00003ac8,0x00003ad4, +0x00003acf,0x00050082,0x000000f4,0x0000396f, +0x00005e41,0x00005e42,0x000500ad,0x0000002f, +0x00003970,0x0000396f,0x0000016b,0x000600a9, +0x000000f4,0x00003971,0x00003970,0x00000264, +0x00000d67,0x00050082,0x000000f4,0x00003974, +0x000013db,0x00003971,0x000300f7,0x00003b5f, +0x00000000,0x000300fb,0x00000138,0x00003b3d, +0x000200f8,0x00003b3d,0x000500b1,0x0000002f, +0x00003b3f,0x00003974,0x0000016b,0x000400a8, +0x0000002f,0x00003b40,0x00003b3f,0x000300f7, +0x00003b47,0x00000000,0x000400fa,0x00003b40, +0x00003b41,0x00003b47,0x000200f8,0x00003b41, +0x00050041,0x000001bb,0x00003b43,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00003b44, +0x00003b43,0x0004007c,0x000000f4,0x00003b45, +0x00003b44,0x000500af,0x0000002f,0x00003b46, +0x00003974,0x00003b45,0x000200f9,0x00003b47, +0x000200f8,0x00003b47,0x000700f5,0x0000002f, +0x00003b48,0x00003b3f,0x00003b3d,0x00003b46, +0x00003b41,0x000300f7,0x00003b4a,0x00000000, +0x000400fa,0x00003b48,0x00003b49,0x00003b4a, +0x000200f8,0x00003b49,0x000200f9,0x00003b5f, +0x000200f8,0x00003b4a,0x00050084,0x00000006, +0x00003b68,0x000000ec,0x000012dd,0x00050080, +0x00000006,0x00003b69,0x000001c4,0x00003b68, +0x00050041,0x00000266,0x00003b6a,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00003b6b, +0x00003b6a,0x00050051,0x00000006,0x00003b85, +0x00003b6b,0x00000000,0x00050095,0x0000013d, +0x00003b87,0x00003b85,0x00003b69,0x00050051, +0x00000006,0x00003b88,0x00003b87,0x00000001, +0x00050051,0x00000006,0x00003b89,0x00003b87, +0x00000000,0x00050051,0x00000006,0x00003b8c, +0x00003b6b,0x00000001,0x00050080,0x00000006, +0x00003b8e,0x00003b8c,0x00003b88,0x00050050, +0x00000007,0x00003b8f,0x00003b89,0x00003b8e, +0x0004007c,0x00000014,0x00003b7f,0x00003b8f, +0x00060041,0x0000016c,0x00003b76,0x00003b7f, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003b77,0x00003b76,0x00000002,0x00000004, +0x0004007c,0x00000006,0x00003b96,0x00003974, +0x00050084,0x00000006,0x00003b97,0x000000ec, +0x00003b96,0x00050080,0x00000006,0x00003b98, +0x000001c4,0x00003b97,0x00050095,0x0000013d, +0x00003bb6,0x00003b85,0x00003b98,0x00050051, +0x00000006,0x00003bb7,0x00003bb6,0x00000001, +0x00050051,0x00000006,0x00003bb8,0x00003bb6, +0x00000000,0x00050080,0x00000006,0x00003bbd, +0x00003b8c,0x00003bb7,0x00050050,0x00000007, +0x00003bbe,0x00003bb8,0x00003bbd,0x0004007c, +0x00000014,0x00003bae,0x00003bbe,0x00060041, +0x0000016c,0x00003ba5,0x00003bae,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003ba6, +0x00003ba5,0x00000002,0x00000004,0x000500aa, +0x0000002f,0x00003b51,0x00003b77,0x00003ba6, +0x000300f7,0x00003b59,0x00000000,0x000400fa, +0x00003b51,0x00003b52,0x00003b59,0x000200f8, +0x00003b52,0x000500c6,0x000000f4,0x00003b55, +0x000013db,0x00003974,0x0004007c,0x00000006, +0x00003b56,0x00003b55,0x0006000c,0x000000f4, +0x00003b57,0x00000001,0x0000004b,0x00003b56, +0x00050082,0x000000f4,0x00003b58,0x00000d76, +0x00003b57,0x000200f9,0x00003b5f,0x000200f8, +0x00003b59,0x000500c6,0x00000006,0x00003b5c, +0x00003b77,0x00003ba6,0x0006000c,0x000000f4, +0x00003b5d,0x00000001,0x0000004b,0x00003b5c, +0x00050082,0x000000f4,0x00003b5e,0x00000d7e, +0x00003b5d,0x000200f9,0x00003b5f,0x000200f8, +0x00003b5f,0x000900f5,0x000000f4,0x00005e43, +0x00000d67,0x00003b49,0x00003b58,0x00003b52, +0x00003b5e,0x00003b59,0x000200f9,0x00003977, +0x000200f8,0x00003977,0x000700f5,0x000000f4, +0x00005e44,0x00000315,0x00003b5f,0x00003984, +0x00003982,0x000400f6,0x00003986,0x00003982, +0x00000000,0x000200f9,0x00003978,0x000200f8, +0x00003978,0x00050084,0x000000f4,0x0000397c, +0x00005e44,0x00003971,0x00050080,0x000000f4, +0x0000397d,0x000013db,0x0000397c,0x000300f7, +0x00003be9,0x00000000,0x000300fb,0x00000138, +0x00003bc7,0x000200f8,0x00003bc7,0x000500b1, +0x0000002f,0x00003bc9,0x0000397d,0x0000016b, +0x000400a8,0x0000002f,0x00003bca,0x00003bc9, +0x000300f7,0x00003bd1,0x00000000,0x000400fa, +0x00003bca,0x00003bcb,0x00003bd1,0x000200f8, +0x00003bcb,0x00050041,0x000001bb,0x00003bcd, +0x000001b9,0x000001f0,0x0004003d,0x00000006, +0x00003bce,0x00003bcd,0x0004007c,0x000000f4, +0x00003bcf,0x00003bce,0x000500af,0x0000002f, +0x00003bd0,0x0000397d,0x00003bcf,0x000200f9, +0x00003bd1,0x000200f8,0x00003bd1,0x000700f5, +0x0000002f,0x00003bd2,0x00003bc9,0x00003bc7, +0x00003bd0,0x00003bcb,0x000300f7,0x00003bd4, +0x00000000,0x000400fa,0x00003bd2,0x00003bd3, +0x00003bd4,0x000200f8,0x00003bd3,0x000200f9, +0x00003be9,0x000200f8,0x00003bd4,0x00050084, +0x00000006,0x00003bf2,0x000000ec,0x000012dd, +0x00050080,0x00000006,0x00003bf3,0x000001c4, +0x00003bf2,0x00050041,0x00000266,0x00003bf4, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x00003bf5,0x00003bf4,0x00050051,0x00000006, +0x00003c0f,0x00003bf5,0x00000000,0x00050095, +0x0000013d,0x00003c11,0x00003c0f,0x00003bf3, +0x00050051,0x00000006,0x00003c12,0x00003c11, +0x00000001,0x00050051,0x00000006,0x00003c13, +0x00003c11,0x00000000,0x00050051,0x00000006, +0x00003c16,0x00003bf5,0x00000001,0x00050080, +0x00000006,0x00003c18,0x00003c16,0x00003c12, +0x00050050,0x00000007,0x00003c19,0x00003c13, +0x00003c18,0x0004007c,0x00000014,0x00003c09, +0x00003c19,0x00060041,0x0000016c,0x00003c00, +0x00003c09,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003c01,0x00003c00,0x00000002, +0x00000004,0x0004007c,0x00000006,0x00003c20, +0x0000397d,0x00050084,0x00000006,0x00003c21, +0x000000ec,0x00003c20,0x00050080,0x00000006, +0x00003c22,0x000001c4,0x00003c21,0x00050095, +0x0000013d,0x00003c40,0x00003c0f,0x00003c22, +0x00050051,0x00000006,0x00003c41,0x00003c40, +0x00000001,0x00050051,0x00000006,0x00003c42, +0x00003c40,0x00000000,0x00050080,0x00000006, +0x00003c47,0x00003c16,0x00003c41,0x00050050, +0x00000007,0x00003c48,0x00003c42,0x00003c47, +0x0004007c,0x00000014,0x00003c38,0x00003c48, +0x00060041,0x0000016c,0x00003c2f,0x00003c38, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003c30,0x00003c2f,0x00000002,0x00000004, +0x000500aa,0x0000002f,0x00003bdb,0x00003c01, +0x00003c30,0x000300f7,0x00003be3,0x00000000, +0x000400fa,0x00003bdb,0x00003bdc,0x00003be3, +0x000200f8,0x00003bdc,0x000500c6,0x000000f4, +0x00003bdf,0x000013db,0x0000397d,0x0004007c, +0x00000006,0x00003be0,0x00003bdf,0x0006000c, +0x000000f4,0x00003be1,0x00000001,0x0000004b, +0x00003be0,0x00050082,0x000000f4,0x00003be2, +0x00000d76,0x00003be1,0x000200f9,0x00003be9, +0x000200f8,0x00003be3,0x000500c6,0x00000006, +0x00003be6,0x00003c01,0x00003c30,0x0006000c, +0x000000f4,0x00003be7,0x00000001,0x0000004b, +0x00003be6,0x00050082,0x000000f4,0x00003be8, +0x00000d7e,0x00003be7,0x000200f9,0x00003be9, +0x000200f8,0x00003be9,0x000900f5,0x000000f4, +0x00005e45,0x00000d67,0x00003bd3,0x00003be2, +0x00003bdc,0x00003be8,0x00003be3,0x000500ad, +0x0000002f,0x00003981,0x00005e45,0x00005e43, +0x000400fa,0x00003981,0x00003982,0x00003986, +0x000200f8,0x00003982,0x000500c4,0x000000f4, +0x00003984,0x00005e44,0x00000264,0x000200f9, +0x00003977,0x000200f8,0x00003986,0x000500c3, +0x000000f4,0x00003988,0x00005e44,0x00000264, +0x000200f9,0x00003989,0x000200f8,0x00003989, +0x000700f5,0x000000f4,0x00005e49,0x0000016b, +0x00003986,0x00006117,0x0000399e,0x000700f5, +0x000000f4,0x00005e48,0x00003988,0x00003986, +0x000039a0,0x0000399e,0x000500af,0x0000002f, +0x0000398c,0x00005e48,0x00000264,0x000400f6, +0x000039a1,0x0000399e,0x00000000,0x000400fa, +0x0000398c,0x0000398d,0x000039a1,0x000200f8, +0x0000398d,0x00050080,0x000000f4,0x00003991, +0x00005e49,0x00005e48,0x00050084,0x000000f4, +0x00003993,0x00003991,0x00003971,0x00050080, +0x000000f4,0x00003994,0x000013db,0x00003993, +0x000300f7,0x00003c73,0x00000000,0x000300fb, +0x00000138,0x00003c51,0x000200f8,0x00003c51, +0x000500b1,0x0000002f,0x00003c53,0x00003994, +0x0000016b,0x000400a8,0x0000002f,0x00003c54, +0x00003c53,0x000300f7,0x00003c5b,0x00000000, +0x000400fa,0x00003c54,0x00003c55,0x00003c5b, +0x000200f8,0x00003c55,0x00050041,0x000001bb, +0x00003c57,0x000001b9,0x000001f0,0x0004003d, +0x00000006,0x00003c58,0x00003c57,0x0004007c, +0x000000f4,0x00003c59,0x00003c58,0x000500af, +0x0000002f,0x00003c5a,0x00003994,0x00003c59, +0x000200f9,0x00003c5b,0x000200f8,0x00003c5b, +0x000700f5,0x0000002f,0x00003c5c,0x00003c53, +0x00003c51,0x00003c5a,0x00003c55,0x000300f7, +0x00003c5e,0x00000000,0x000400fa,0x00003c5c, +0x00003c5d,0x00003c5e,0x000200f8,0x00003c5d, +0x000200f9,0x00003c73,0x000200f8,0x00003c5e, +0x00050084,0x00000006,0x00003c7c,0x000000ec, +0x000012dd,0x00050080,0x00000006,0x00003c7d, +0x000001c4,0x00003c7c,0x00050041,0x00000266, +0x00003c7e,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x00003c7f,0x00003c7e,0x00050051, +0x00000006,0x00003c99,0x00003c7f,0x00000000, +0x00050095,0x0000013d,0x00003c9b,0x00003c99, +0x00003c7d,0x00050051,0x00000006,0x00003c9c, +0x00003c9b,0x00000001,0x00050051,0x00000006, +0x00003c9d,0x00003c9b,0x00000000,0x00050051, +0x00000006,0x00003ca0,0x00003c7f,0x00000001, +0x00050080,0x00000006,0x00003ca2,0x00003ca0, +0x00003c9c,0x00050050,0x00000007,0x00003ca3, +0x00003c9d,0x00003ca2,0x0004007c,0x00000014, +0x00003c93,0x00003ca3,0x00060041,0x0000016c, +0x00003c8a,0x00003c93,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003c8b,0x00003c8a, 0x00000002,0x00000004,0x0004007c,0x00000006, -0x00003a32,0x0000362a,0x00050084,0x00000006, -0x00003a33,0x000000df,0x00003a32,0x00050080, -0x00000006,0x00003a34,0x0000018b,0x00003a33, -0x00050095,0x00000130,0x00003a52,0x00003a21, -0x00003a34,0x00050051,0x00000006,0x00003a53, -0x00003a52,0x00000001,0x00050051,0x00000006, -0x00003a54,0x00003a52,0x00000000,0x00050080, -0x00000006,0x00003a59,0x00003a28,0x00003a53, -0x00050050,0x00000007,0x00003a5a,0x00003a54, -0x00003a59,0x0004007c,0x00000014,0x00003a4a, -0x00003a5a,0x00060041,0x0000015f,0x00003a41, -0x00003a4a,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00003a42,0x00003a41,0x00000002, -0x00000004,0x000500aa,0x0000002f,0x000039ed, -0x00003a13,0x00003a42,0x000300f7,0x000039f5, -0x00000000,0x000400fa,0x000039ed,0x000039ee, -0x000039f5,0x000200f8,0x000039ee,0x000500c6, -0x000000e7,0x000039f1,0x000012dc,0x0000362a, -0x0004007c,0x00000006,0x000039f2,0x000039f1, -0x0006000c,0x000000e7,0x000039f3,0x00000001, -0x0000004b,0x000039f2,0x00050082,0x000000e7, -0x000039f4,0x00000c77,0x000039f3,0x000200f9, -0x000039fb,0x000200f8,0x000039f5,0x000500c6, -0x00000006,0x000039f8,0x00003a13,0x00003a42, -0x0006000c,0x000000e7,0x000039f9,0x00000001, -0x0000004b,0x000039f8,0x00050082,0x000000e7, -0x000039fa,0x00000c7f,0x000039f9,0x000200f9, -0x000039fb,0x000200f8,0x000039fb,0x000900f5, -0x000000e7,0x00005a87,0x00000c68,0x000039e5, -0x000039f4,0x000039ee,0x000039fa,0x000039f5, -0x000500ad,0x0000002f,0x0000362e,0x00005a87, -0x00005a82,0x000600a9,0x000000e7,0x00005cdd, -0x0000362e,0x00003627,0x00005a86,0x000200f9, -0x00003634,0x000200f8,0x00003634,0x000500ad, -0x0000002f,0x00003636,0x00003623,0x0000022b, -0x000400fa,0x00003636,0x0000361f,0x00003637, -0x000200f8,0x00003637,0x00050084,0x000000e7, -0x0000363b,0x00005cdd,0x000035e5,0x00050080, -0x000000e7,0x0000363c,0x000012dc,0x0000363b, -0x0007000c,0x000000e7,0x0000363e,0x00000001, -0x00000027,0x000035e5,0x0000015e,0x00050080, -0x000000e7,0x0000363f,0x0000363c,0x0000363e, -0x0007000c,0x000000e7,0x00003642,0x00000001, -0x00000027,0x000012dc,0x0000361a,0x000500aa, -0x0000002f,0x00003644,0x00003642,0x0000363f, -0x000300f7,0x0000364c,0x00000000,0x000400fa, -0x00003644,0x00003645,0x00003649,0x000200f8, -0x00003649,0x0004007c,0x00000006,0x0000364b, -0x0000363f,0x000200f9,0x0000364c,0x000200f8, -0x00003645,0x0004007c,0x00000006,0x00003647, -0x0000363f,0x000500c5,0x00000006,0x00003648, -0x00000208,0x00003647,0x000200f9,0x0000364c, -0x000200f8,0x0000364c,0x000700f5,0x00000006, -0x00005a8e,0x00003648,0x00003645,0x0000364b, -0x00003649,0x0007000c,0x000000e7,0x00003650, -0x00000001,0x0000002a,0x000012dc,0x0000361a, -0x00050080,0x000000e7,0x00003652,0x0000363f, -0x0000022b,0x000500aa,0x0000002f,0x00003653, -0x00003650,0x00003652,0x000300f7,0x0000365d, -0x00000000,0x000400fa,0x00003653,0x00003654, -0x00003659,0x000200f8,0x00003659,0x0004007c, -0x00000006,0x0000365c,0x00003652,0x000200f9, -0x0000365d,0x000200f8,0x00003654,0x0004007c, -0x00000006,0x00003657,0x00003652,0x000500c5, -0x00000006,0x00003658,0x00000208,0x00003657, -0x000200f9,0x0000365d,0x000200f8,0x0000365d, -0x000700f5,0x00000006,0x00005a8f,0x00003658, -0x00003654,0x0000365c,0x00003659,0x00050041, -0x00000182,0x00003a77,0x00000180,0x00000181, -0x0004003d,0x00000006,0x00003a78,0x00003a77, -0x00050084,0x00000006,0x00003a79,0x000001a2, -0x00003a78,0x00050080,0x00000006,0x00003a7a, -0x0000018b,0x00003a79,0x00050080,0x00000006, -0x00003a80,0x00003a78,0x00005cc3,0x00050086, -0x00000006,0x00003a81,0x00003a80,0x00000185, -0x00050084,0x00000006,0x00003a73,0x0000018b, -0x00003a81,0x00050080,0x00000006,0x00003a74, -0x00003a7a,0x00003a73,0x00050080,0x00000006, -0x00003a6e,0x00003a74,0x00003a73,0x00050041, -0x00000182,0x00003a65,0x00000180,0x000001b7, -0x0004003d,0x00000006,0x00003a66,0x00003a65, -0x00050084,0x00000006,0x00003a67,0x000001b6, -0x00003a66,0x00050080,0x00000006,0x00003a68, -0x00003a6e,0x00003a67,0x00050041,0x00000182, -0x00003a5e,0x00000180,0x000001cd,0x0004003d, -0x00000006,0x00003a5f,0x00003a5e,0x00050084, -0x00000006,0x00003a60,0x000001cc,0x00003a5f, -0x00050080,0x00000006,0x00003a61,0x00003a68, -0x00003a60,0x00050084,0x00000006,0x00003662, -0x000000df,0x000011de,0x00050080,0x00000006, -0x00003663,0x00003a61,0x00003662,0x00050041, -0x0000022d,0x00003664,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00003665,0x00003664, -0x00050051,0x00000006,0x00003a9e,0x00003665, -0x00000000,0x00050095,0x00000130,0x00003aa0, -0x00003a9e,0x00003663,0x00050051,0x00000006, -0x00003aa1,0x00003aa0,0x00000001,0x00050051, -0x00000006,0x00003aa2,0x00003aa0,0x00000000, -0x00050051,0x00000006,0x00003aa5,0x00003665, -0x00000001,0x00050080,0x00000006,0x00003aa7, -0x00003aa5,0x00003aa1,0x00050050,0x00000007, -0x00003aa8,0x00003aa2,0x00003aa7,0x0004007c, -0x00000014,0x00003a98,0x00003aa8,0x00060041, -0x0000015f,0x00003a90,0x00003a98,0x0000015e, -0x0000015e,0x0005003e,0x00003a90,0x00005a8e, -0x00000002,0x00000004,0x000500ac,0x0000002f, -0x00003ae2,0x00003a66,0x00000135,0x000300f7, -0x00003ae8,0x00000000,0x000400fa,0x00003ae2, -0x00003ae3,0x00003ae7,0x000200f8,0x00003ae7, -0x000200f9,0x00003ae8,0x000200f8,0x00003ae3, -0x00050082,0x00000006,0x00003ae6,0x00003a66, -0x00000135,0x000200f9,0x00003ae8,0x000200f8, -0x00003ae8,0x000700f5,0x00000006,0x00005a90, -0x00003ae6,0x00003ae3,0x0000012b,0x00003ae7, -0x00050084,0x00000006,0x00003aad,0x000000df, -0x00005a90,0x00050080,0x00000006,0x00003aae, -0x00003a61,0x00003aad,0x00050080,0x00000006, -0x0000366c,0x00003aae,0x00003662,0x00050095, -0x00000130,0x00003b01,0x00003a9e,0x0000366c, -0x00050051,0x00000006,0x00003b02,0x00003b01, -0x00000001,0x00050051,0x00000006,0x00003b03, -0x00003b01,0x00000000,0x00050080,0x00000006, -0x00003b08,0x00003aa5,0x00003b02,0x00050050, -0x00000007,0x00003b09,0x00003b03,0x00003b08, -0x0004007c,0x00000014,0x00003af9,0x00003b09, -0x00060041,0x0000015f,0x00003af1,0x00003af9, -0x0000015e,0x0000015e,0x0005003e,0x00003af1, -0x00005a8f,0x00000002,0x00000004,0x000500c7, -0x00000006,0x00003672,0x00005a8e,0x00000208, -0x000500aa,0x0000002f,0x00003673,0x00003672, -0x0000012b,0x000300f7,0x0000367e,0x00000000, -0x000400fa,0x00003673,0x00003674,0x0000367e, -0x000200f8,0x00003674,0x000300f7,0x00003b4f, -0x00000000,0x000400fa,0x00003ae2,0x00003b4a, -0x00003b4e,0x000200f8,0x00003b4e,0x000200f9, -0x00003b4f,0x000200f8,0x00003b4a,0x00050082, -0x00000006,0x00003b4d,0x00003a66,0x00000135, -0x000200f9,0x00003b4f,0x000200f8,0x00003b4f, -0x000700f5,0x00000006,0x00005a91,0x00003b4d, -0x00003b4a,0x0000012b,0x00003b4e,0x00050084, -0x00000006,0x00003b14,0x000000df,0x00005a91, -0x00050080,0x00000006,0x00003b15,0x00003a61, -0x00003b14,0x000300f7,0x00003b5c,0x00000000, -0x000400fa,0x00003ae2,0x00003b57,0x00003b5b, -0x000200f8,0x00003b5b,0x000200f9,0x00003b5c, -0x000200f8,0x00003b57,0x00050082,0x00000006, -0x00003b5a,0x00003a66,0x00000135,0x000200f9, -0x00003b5c,0x000200f8,0x00003b5c,0x000700f5, -0x00000006,0x00005a92,0x00003b5a,0x00003b57, -0x0000012b,0x00003b5b,0x00050084,0x00000006, -0x00003b0e,0x000000df,0x00005a92,0x00050080, -0x00000006,0x00003b0f,0x00003b15,0x00003b0e, -0x00050084,0x00000006,0x00003677,0x000000df, -0x00005a8e,0x00050080,0x00000006,0x00003678, -0x00003b0f,0x00003677,0x00050095,0x00000130, -0x00003b75,0x00003a9e,0x00003678,0x00050051, -0x00000006,0x00003b76,0x00003b75,0x00000001, -0x00050051,0x00000006,0x00003b77,0x00003b75, -0x00000000,0x00050080,0x00000006,0x00003b7c, -0x00003aa5,0x00003b76,0x00050050,0x00000007, -0x00003b7d,0x00003b77,0x00003b7c,0x0004007c, -0x00000014,0x00003b6d,0x00003b7d,0x00060041, -0x0000015f,0x00003b65,0x00003b6d,0x0000015e, -0x0000015e,0x0005003e,0x00003b65,0x000011de, -0x00000002,0x00000004,0x000200f9,0x0000367e, -0x000200f8,0x0000367e,0x000500c7,0x00000006, -0x00003680,0x00005a8f,0x00000208,0x000500aa, -0x0000002f,0x00003681,0x00003680,0x0000012b, -0x000300f7,0x0000368c,0x00000000,0x000400fa, -0x00003681,0x00003682,0x0000368c,0x000200f8, -0x00003682,0x000300f7,0x00003bc3,0x00000000, -0x000400fa,0x00003ae2,0x00003bbe,0x00003bc2, -0x000200f8,0x00003bc2,0x000200f9,0x00003bc3, -0x000200f8,0x00003bbe,0x00050082,0x00000006, -0x00003bc1,0x00003a66,0x00000135,0x000200f9, -0x00003bc3,0x000200f8,0x00003bc3,0x000700f5, -0x00000006,0x00005a93,0x00003bc1,0x00003bbe, -0x0000012b,0x00003bc2,0x00050084,0x00000006, -0x00003b88,0x000000df,0x00005a93,0x00050080, -0x00000006,0x00003b89,0x00003a61,0x00003b88, -0x000300f7,0x00003bd0,0x00000000,0x000400fa, -0x00003ae2,0x00003bcb,0x00003bcf,0x000200f8, -0x00003bcf,0x000200f9,0x00003bd0,0x000200f8, -0x00003bcb,0x00050082,0x00000006,0x00003bce, -0x00003a66,0x00000135,0x000200f9,0x00003bd0, -0x000200f8,0x00003bd0,0x000700f5,0x00000006, -0x00005a94,0x00003bce,0x00003bcb,0x0000012b, -0x00003bcf,0x00050084,0x00000006,0x00003b82, -0x000000df,0x00005a94,0x00050080,0x00000006, -0x00003b83,0x00003b89,0x00003b82,0x00050084, -0x00000006,0x00003685,0x000000df,0x00005a8f, -0x00050080,0x00000006,0x00003686,0x00003b83, -0x00003685,0x00050095,0x00000130,0x00003be9, -0x00003a9e,0x00003686,0x00050051,0x00000006, -0x00003bea,0x00003be9,0x00000001,0x00050051, -0x00000006,0x00003beb,0x00003be9,0x00000000, -0x00050080,0x00000006,0x00003bf0,0x00003aa5, -0x00003bea,0x00050050,0x00000007,0x00003bf1, -0x00003beb,0x00003bf0,0x0004007c,0x00000014, -0x00003be1,0x00003bf1,0x00060041,0x0000015f, -0x00003bd9,0x00003be1,0x0000015e,0x0000015e, -0x0005003e,0x00003bd9,0x000011de,0x00000002, -0x00000004,0x000200f9,0x0000368c,0x000200f8, -0x0000368c,0x000500aa,0x0000002f,0x0000368e, -0x000012dc,0x0000015e,0x000300f7,0x00003694, -0x00000000,0x000400fa,0x0000368e,0x0000368f, -0x00003694,0x000200f8,0x0000368f,0x000300f7, -0x00003c37,0x00000000,0x000400fa,0x00003ae2, -0x00003c32,0x00003c36,0x000200f8,0x00003c36, -0x000200f9,0x00003c37,0x000200f8,0x00003c32, -0x00050082,0x00000006,0x00003c35,0x00003a66, -0x00000135,0x000200f9,0x00003c37,0x000200f8, -0x00003c37,0x000700f5,0x00000006,0x00005a95, -0x00003c35,0x00003c32,0x0000012b,0x00003c36, -0x00050084,0x00000006,0x00003bfc,0x000000df, -0x00005a95,0x00050080,0x00000006,0x00003bfd, -0x00003a61,0x00003bfc,0x000300f7,0x00003c44, -0x00000000,0x000400fa,0x00003ae2,0x00003c3f, -0x00003c43,0x000200f8,0x00003c43,0x000200f9, -0x00003c44,0x000200f8,0x00003c3f,0x00050082, -0x00000006,0x00003c42,0x00003a66,0x00000135, -0x000200f9,0x00003c44,0x000200f8,0x00003c44, -0x000700f5,0x00000006,0x00005a96,0x00003c42, -0x00003c3f,0x0000012b,0x00003c43,0x00050084, -0x00000006,0x00003bf6,0x000000df,0x00005a96, -0x00050080,0x00000006,0x00003bf7,0x00003bfd, -0x00003bf6,0x00050095,0x00000130,0x00003c5d, -0x00003a9e,0x00003bf7,0x00050051,0x00000006, -0x00003c5e,0x00003c5d,0x00000001,0x00050051, -0x00000006,0x00003c5f,0x00003c5d,0x00000000, -0x00050080,0x00000006,0x00003c64,0x00003aa5, -0x00003c5e,0x00050050,0x00000007,0x00003c65, -0x00003c5f,0x00003c64,0x0004007c,0x00000014, -0x00003c55,0x00003c65,0x00060041,0x0000015f, -0x00003c4d,0x00003c55,0x0000015e,0x0000015e, -0x0005003e,0x00003c4d,0x00000500,0x00000002, -0x00000004,0x000200f9,0x00003694,0x000200f8, -0x00003694,0x000200f9,0x000012da,0x000200f8, -0x000012da,0x000200f9,0x000012d1,0x000200f8, -0x000012d0,0x00050041,0x00000182,0x000033ba, -0x00000180,0x00000181,0x0004003d,0x00000006, -0x000033bb,0x000033ba,0x00050084,0x00000006, -0x000033bc,0x000001a2,0x000033bb,0x00050080, -0x00000006,0x000033bd,0x0000018b,0x000033bc, -0x00050080,0x00000006,0x000033c3,0x000033bb, -0x00005cc3,0x00050086,0x00000006,0x000033c4, -0x000033c3,0x00000185,0x00050084,0x00000006, -0x000033b6,0x0000018b,0x000033c4,0x00050080, -0x00000006,0x000033b7,0x000033bd,0x000033b6, -0x00050080,0x00000006,0x000033b1,0x000033b7, -0x000033b6,0x00050084,0x00000006,0x00003385, -0x000001b6,0x000011de,0x00050080,0x00000006, -0x00003386,0x000033b1,0x00003385,0x00050041, -0x0000022d,0x00003387,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x00003388,0x00003387, -0x00050051,0x00000006,0x000033e2,0x00003388, -0x00000000,0x00050095,0x00000130,0x000033e4, -0x000033e2,0x00003386,0x00050051,0x00000006, -0x000033e5,0x000033e4,0x00000001,0x00050051, -0x00000006,0x000033e6,0x000033e4,0x00000000, -0x00050051,0x00000006,0x000033e9,0x00003388, -0x00000001,0x00050080,0x00000006,0x000033eb, -0x000033e9,0x000033e5,0x00050050,0x00000007, -0x000033ec,0x000033e6,0x000033eb,0x0004007c, -0x00000014,0x000033dc,0x000033ec,0x00060041, -0x0000015f,0x000033d3,0x000033dc,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000033d4, -0x000033d3,0x00000002,0x00000004,0x0004007c, -0x00000027,0x0000338b,0x000033d4,0x00050080, -0x00000006,0x0000338d,0x00003386,0x000000df, -0x00050095,0x00000130,0x00003405,0x000033e2, -0x0000338d,0x00050051,0x00000006,0x00003406, -0x00003405,0x00000001,0x00050051,0x00000006, -0x00003407,0x00003405,0x00000000,0x00050080, -0x00000006,0x0000340c,0x000033e9,0x00003406, -0x00050050,0x00000007,0x0000340d,0x00003407, -0x0000340c,0x0004007c,0x00000014,0x000033fd, -0x0000340d,0x00060041,0x0000015f,0x000033f4, -0x000033fd,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x000033f5,0x000033f4,0x00000002, -0x00000004,0x0004007c,0x00000027,0x00003391, -0x000033f5,0x00050080,0x00000006,0x00003393, -0x00003386,0x00000194,0x00050095,0x00000130, -0x00003426,0x000033e2,0x00003393,0x00050051, -0x00000006,0x00003427,0x00003426,0x00000001, -0x00050051,0x00000006,0x00003428,0x00003426, -0x00000000,0x00050080,0x00000006,0x0000342d, -0x000033e9,0x00003427,0x00050050,0x00000007, -0x0000342e,0x00003428,0x0000342d,0x0004007c, -0x00000014,0x0000341e,0x0000342e,0x00060041, -0x0000015f,0x00003415,0x0000341e,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003416, -0x00003415,0x00000002,0x00000004,0x0004007c, -0x00000027,0x00003397,0x00003416,0x00060050, -0x00000063,0x00003398,0x0000338b,0x00003391, -0x00003397,0x00050080,0x00000006,0x0000339a, -0x00003386,0x0000019b,0x00050095,0x00000130, -0x00003447,0x000033e2,0x0000339a,0x00050051, -0x00000006,0x00003448,0x00003447,0x00000001, -0x00050051,0x00000006,0x00003449,0x00003447, -0x00000000,0x00050080,0x00000006,0x0000344e, -0x000033e9,0x00003448,0x00050050,0x00000007, -0x0000344f,0x00003449,0x0000344e,0x0004007c, -0x00000014,0x0000343f,0x0000344f,0x00060041, -0x0000015f,0x00003436,0x0000343f,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003437, -0x00003436,0x00000002,0x00000004,0x0004007c, -0x00000027,0x0000339e,0x00003437,0x00050080, -0x00000006,0x000033a0,0x00003386,0x000001a2, -0x00050095,0x00000130,0x00003468,0x000033e2, -0x000033a0,0x00050051,0x00000006,0x00003469, -0x00003468,0x00000001,0x00050051,0x00000006, -0x0000346a,0x00003468,0x00000000,0x00050080, -0x00000006,0x0000346f,0x000033e9,0x00003469, -0x00050050,0x00000007,0x00003470,0x0000346a, -0x0000346f,0x0004007c,0x00000014,0x00003460, -0x00003470,0x00060041,0x0000015f,0x00003457, -0x00003460,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00003458,0x00003457,0x00000002, -0x00000004,0x0004007c,0x00000027,0x000033a4, -0x00003458,0x00050080,0x00000006,0x000033a6, -0x00003386,0x00000260,0x00050095,0x00000130, -0x00003489,0x000033e2,0x000033a6,0x00050051, -0x00000006,0x0000348a,0x00003489,0x00000001, -0x00050051,0x00000006,0x0000348b,0x00003489, -0x00000000,0x00050080,0x00000006,0x00003490, -0x000033e9,0x0000348a,0x00050050,0x00000007, -0x00003491,0x0000348b,0x00003490,0x0004007c, -0x00000014,0x00003481,0x00003491,0x00060041, -0x0000015f,0x00003478,0x00003481,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00003479, -0x00003478,0x00000002,0x00000004,0x0004007c, -0x00000027,0x000033aa,0x00003479,0x00060050, -0x00000063,0x000033ab,0x0000339e,0x000033a4, -0x000033aa,0x000500bc,0x0000002f,0x00003498, -0x0000338b,0x0000339e,0x000300f7,0x0000349f, -0x00000000,0x000400fa,0x00003498,0x00003499, -0x0000349f,0x000200f8,0x00003499,0x000500bc, -0x0000002f,0x0000349e,0x00003391,0x000033a4, -0x000200f9,0x0000349f,0x000200f8,0x0000349f, -0x000700f5,0x0000002f,0x000034a0,0x00003498, -0x000012d0,0x0000349e,0x00003499,0x000300f7, -0x000034a7,0x00000000,0x000400fa,0x000034a0, -0x000034a1,0x000034a7,0x000200f8,0x000034a1, -0x000500bc,0x0000002f,0x000034a6,0x00003397, -0x000033aa,0x000200f9,0x000034a7,0x000200f8, -0x000034a7,0x000700f5,0x0000002f,0x000034a8, -0x000034a0,0x0000349f,0x000034a6,0x000034a1, -0x000300f7,0x00003364,0x00000000,0x000400fa, -0x000034a8,0x00003328,0x00003364,0x000200f8, -0x00003328,0x00050095,0x00000130,0x000034b9, -0x000033e2,0x0000012b,0x00050051,0x00000006, -0x000034ba,0x000034b9,0x00000001,0x00050051, -0x00000006,0x000034bb,0x000034b9,0x00000000, -0x00050080,0x00000006,0x000034c0,0x000033e9, -0x000034ba,0x00050050,0x00000007,0x000034c1, -0x000034bb,0x000034c0,0x0004007c,0x00000014, -0x000034b1,0x000034c1,0x00060041,0x0000015f, -0x0000332d,0x000034b1,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x0000332e,0x0000332d, -0x00000002,0x00000004,0x000500c7,0x00000006, -0x000034c6,0x0000332e,0x00000208,0x000500ab, -0x0000002f,0x000034c7,0x000034c6,0x0000012b, -0x000300f7,0x000034ce,0x00000000,0x000400fa, -0x000034c7,0x000034c8,0x000034cb,0x000200f8, -0x000034cb,0x000400c8,0x00000006,0x000034cd, -0x0000332e,0x000200f9,0x000034ce,0x000200f8, -0x000034c8,0x000500c7,0x00000006,0x000034ca, -0x0000332e,0x0000021d,0x000200f9,0x000034ce, -0x000200f8,0x000034ce,0x000700f5,0x00000006, -0x00005a9d,0x000034ca,0x000034c8,0x000034cd, -0x000034cb,0x0004007c,0x00000027,0x000034d0, -0x00005a9d,0x00060041,0x0000015f,0x00003331, -0x000034b1,0x0000015e,0x0000022b,0x0006003d, -0x00000006,0x00003332,0x00003331,0x00000002, -0x00000004,0x000500c7,0x00000006,0x000034d5, -0x00003332,0x00000208,0x000500ab,0x0000002f, -0x000034d6,0x000034d5,0x0000012b,0x000300f7, -0x000034dd,0x00000000,0x000400fa,0x000034d6, -0x000034d7,0x000034da,0x000200f8,0x000034da, -0x000400c8,0x00000006,0x000034dc,0x00003332, -0x000200f9,0x000034dd,0x000200f8,0x000034d7, -0x000500c7,0x00000006,0x000034d9,0x00003332, -0x0000021d,0x000200f9,0x000034dd,0x000200f8, -0x000034dd,0x000700f5,0x00000006,0x00005a9e, -0x000034d9,0x000034d7,0x000034dc,0x000034da, -0x0004007c,0x00000027,0x000034df,0x00005a9e, -0x00060041,0x0000015f,0x00003335,0x000034b1, -0x0000015e,0x000002dc,0x0006003d,0x00000006, -0x00003336,0x00003335,0x00000002,0x00000004, -0x000500c7,0x00000006,0x000034e4,0x00003336, -0x00000208,0x000500ab,0x0000002f,0x000034e5, -0x000034e4,0x0000012b,0x000300f7,0x000034ec, -0x00000000,0x000400fa,0x000034e5,0x000034e6, -0x000034e9,0x000200f8,0x000034e9,0x000400c8, -0x00000006,0x000034eb,0x00003336,0x000200f9, -0x000034ec,0x000200f8,0x000034e6,0x000500c7, -0x00000006,0x000034e8,0x00003336,0x0000021d, -0x000200f9,0x000034ec,0x000200f8,0x000034ec, -0x000700f5,0x00000006,0x00005a9f,0x000034e8, -0x000034e6,0x000034eb,0x000034e9,0x0004007c, -0x00000027,0x000034ee,0x00005a9f,0x00060050, -0x00000063,0x00003338,0x000034d0,0x000034df, -0x000034ee,0x00060041,0x0000015f,0x0000333a, -0x000034b1,0x0000015e,0x000002e4,0x0006003d, -0x00000006,0x0000333b,0x0000333a,0x00000002, -0x00000004,0x000500c7,0x00000006,0x000034f3, -0x0000333b,0x00000208,0x000500ab,0x0000002f, -0x000034f4,0x000034f3,0x0000012b,0x000300f7, -0x000034fb,0x00000000,0x000400fa,0x000034f4, -0x000034f5,0x000034f8,0x000200f8,0x000034f8, -0x000400c8,0x00000006,0x000034fa,0x0000333b, -0x000200f9,0x000034fb,0x000200f8,0x000034f5, -0x000500c7,0x00000006,0x000034f7,0x0000333b, -0x0000021d,0x000200f9,0x000034fb,0x000200f8, -0x000034fb,0x000700f5,0x00000006,0x00005aa0, -0x000034f7,0x000034f5,0x000034fa,0x000034f8, -0x0004007c,0x00000027,0x000034fd,0x00005aa0, -0x00060041,0x0000015f,0x0000333e,0x000034b1, -0x0000015e,0x000002ec,0x0006003d,0x00000006, -0x0000333f,0x0000333e,0x00000002,0x00000004, -0x000500c7,0x00000006,0x00003502,0x0000333f, -0x00000208,0x000500ab,0x0000002f,0x00003503, -0x00003502,0x0000012b,0x000300f7,0x0000350a, -0x00000000,0x000400fa,0x00003503,0x00003504, -0x00003507,0x000200f8,0x00003507,0x000400c8, -0x00000006,0x00003509,0x0000333f,0x000200f9, -0x0000350a,0x000200f8,0x00003504,0x000500c7, -0x00000006,0x00003506,0x0000333f,0x0000021d, -0x000200f9,0x0000350a,0x000200f8,0x0000350a, -0x000700f5,0x00000006,0x00005aa1,0x00003506, -0x00003504,0x00003509,0x00003507,0x0004007c, -0x00000027,0x0000350c,0x00005aa1,0x00060041, -0x0000015f,0x00003342,0x000034b1,0x0000015e, -0x000002f4,0x0006003d,0x00000006,0x00003343, -0x00003342,0x00000002,0x00000004,0x000500c7, -0x00000006,0x00003511,0x00003343,0x00000208, -0x000500ab,0x0000002f,0x00003512,0x00003511, -0x0000012b,0x000300f7,0x00003519,0x00000000, -0x000400fa,0x00003512,0x00003513,0x00003516, -0x000200f8,0x00003516,0x000400c8,0x00000006, -0x00003518,0x00003343,0x000200f9,0x00003519, -0x000200f8,0x00003513,0x000500c7,0x00000006, -0x00003515,0x00003343,0x0000021d,0x000200f9, -0x00003519,0x000200f8,0x00003519,0x000700f5, -0x00000006,0x00005aa2,0x00003515,0x00003513, -0x00003518,0x00003516,0x0004007c,0x00000027, -0x0000351b,0x00005aa2,0x00060050,0x00000063, -0x00003345,0x000034fd,0x0000350c,0x0000351b, -0x00050083,0x00000063,0x00003348,0x00003345, -0x00003338,0x0007000c,0x00000063,0x00003349, -0x00000001,0x00000028,0x00003348,0x000007d4, -0x00050081,0x00000063,0x0000334c,0x00003398, -0x000033ab,0x0005008e,0x00000063,0x0000334d, -0x0000334c,0x000002c4,0x00050083,0x00000063, -0x0000334f,0x0000334d,0x00003338,0x00050088, -0x00000063,0x00003351,0x0000334f,0x00003349, -0x0008000c,0x00000063,0x00003354,0x00000001, -0x0000002b,0x00003351,0x000006eb,0x00005cc0, -0x0005008e,0x00000063,0x00003355,0x00003354, -0x000007e2,0x0004006d,0x000000d2,0x00003356, -0x00003355,0x00050051,0x00000006,0x00003358, -0x00003356,0x00000000,0x000500c7,0x00000006, -0x0000351f,0x00003358,0x00000777,0x000500c4, -0x00000006,0x00003522,0x0000351f,0x00000321, -0x000500c5,0x00000006,0x00003523,0x0000351f, -0x00003522,0x000500c7,0x00000006,0x00003524, -0x00003523,0x0000077e,0x000500c4,0x00000006, -0x00003527,0x00003524,0x00000488,0x000500c5, -0x00000006,0x00003528,0x00003524,0x00003527, -0x000500c7,0x00000006,0x00003529,0x00003528, -0x00000784,0x000500c4,0x00000006,0x0000352c, -0x00003529,0x000002ec,0x000500c5,0x00000006, -0x0000352d,0x00003529,0x0000352c,0x000500c7, -0x00000006,0x0000352e,0x0000352d,0x0000078a, -0x000500c4,0x00000006,0x00003531,0x0000352e, -0x000002dc,0x000500c5,0x00000006,0x00003532, -0x0000352e,0x00003531,0x000500c7,0x00000006, -0x00003533,0x00003532,0x00000790,0x000500c4, -0x00000006,0x0000335a,0x00003533,0x000002dc, -0x00050051,0x00000006,0x0000335c,0x00003356, -0x00000001,0x000500c7,0x00000006,0x00003538, -0x0000335c,0x00000777,0x000500c4,0x00000006, -0x0000353b,0x00003538,0x00000321,0x000500c5, -0x00000006,0x0000353c,0x00003538,0x0000353b, -0x000500c7,0x00000006,0x0000353d,0x0000353c, -0x0000077e,0x000500c4,0x00000006,0x00003540, -0x0000353d,0x00000488,0x000500c5,0x00000006, -0x00003541,0x0000353d,0x00003540,0x000500c7, -0x00000006,0x00003542,0x00003541,0x00000784, -0x000500c4,0x00000006,0x00003545,0x00003542, -0x000002ec,0x000500c5,0x00000006,0x00003546, -0x00003542,0x00003545,0x000500c7,0x00000006, -0x00003547,0x00003546,0x0000078a,0x000500c4, -0x00000006,0x0000354a,0x00003547,0x000002dc, -0x000500c5,0x00000006,0x0000354b,0x00003547, -0x0000354a,0x000500c7,0x00000006,0x0000354c, -0x0000354b,0x00000790,0x000500c4,0x00000006, -0x0000335e,0x0000354c,0x0000022b,0x000500c5, -0x00000006,0x0000335f,0x0000335a,0x0000335e, -0x00050051,0x00000006,0x00003361,0x00003356, -0x00000002,0x000500c7,0x00000006,0x00003551, -0x00003361,0x00000777,0x000500c4,0x00000006, -0x00003554,0x00003551,0x00000321,0x000500c5, -0x00000006,0x00003555,0x00003551,0x00003554, -0x000500c7,0x00000006,0x00003556,0x00003555, -0x0000077e,0x000500c4,0x00000006,0x00003559, -0x00003556,0x00000488,0x000500c5,0x00000006, -0x0000355a,0x00003556,0x00003559,0x000500c7, -0x00000006,0x0000355b,0x0000355a,0x00000784, -0x000500c4,0x00000006,0x0000355e,0x0000355b, -0x000002ec,0x000500c5,0x00000006,0x0000355f, -0x0000355b,0x0000355e,0x000500c7,0x00000006, -0x00003560,0x0000355f,0x0000078a,0x000500c4, -0x00000006,0x00003563,0x00003560,0x000002dc, -0x000500c5,0x00000006,0x00003564,0x00003560, -0x00003563,0x000500c7,0x00000006,0x00003565, -0x00003564,0x00000790,0x000500c5,0x00000006, -0x00003363,0x0000335f,0x00003565,0x000200f9, -0x00003364,0x000200f8,0x00003364,0x000700f5, -0x00000006,0x00005aa3,0x000006ac,0x000034a7, -0x00003363,0x00003519,0x00050084,0x00000006, -0x00003367,0x000000df,0x000011de,0x00050080, -0x00000006,0x00003368,0x0000018b,0x00003367, -0x00050095,0x00000130,0x00003580,0x000033e2, -0x00003368,0x00050051,0x00000006,0x00003581, -0x00003580,0x00000001,0x00050051,0x00000006, -0x00003582,0x00003580,0x00000000,0x00050080, -0x00000006,0x00003587,0x000033e9,0x00003581, -0x00050050,0x00000007,0x00003588,0x00003582, -0x00003587,0x0004007c,0x00000014,0x00003578, -0x00003588,0x00060041,0x0000015f,0x00003570, -0x00003578,0x0000015e,0x0000015e,0x0005003e, -0x00003570,0x00005aa3,0x00000002,0x00000004, -0x00050084,0x00000006,0x0000358d,0x000000df, -0x000033bb,0x00050080,0x00000006,0x0000358e, -0x0000018b,0x0000358d,0x00050080,0x00000006, -0x00003370,0x0000358e,0x00003367,0x00050095, -0x00000130,0x000035a6,0x000033e2,0x00003370, -0x00050051,0x00000006,0x000035a7,0x000035a6, -0x00000001,0x00050051,0x00000006,0x000035a8, -0x000035a6,0x00000000,0x00050080,0x00000006, -0x000035ad,0x000033e9,0x000035a7,0x00050050, -0x00000007,0x000035ae,0x000035a8,0x000035ad, -0x0004007c,0x00000014,0x0000359e,0x000035ae, -0x00060041,0x0000015f,0x00003596,0x0000359e, -0x0000015e,0x0000015e,0x0005003e,0x00003596, -0x000011de,0x00000002,0x00000004,0x000200f9, -0x000012d1,0x000200f8,0x000012d1,0x000200f9, -0x000012c8,0x000200f8,0x000012c7,0x00050084, -0x00000006,0x00002b91,0x0000018b,0x000011de, -0x000200f9,0x00002b92,0x000200f8,0x00002b92, -0x000700f5,0x00000006,0x00005aa6,0x0000012b, -0x000012c7,0x00002ba3,0x00002b96,0x000500b0, -0x0000002f,0x00002b95,0x00005aa6,0x0000019b, -0x000400f6,0x00002ba4,0x00002b96,0x00000000, -0x000400fa,0x00002b95,0x00002b96,0x00002ba4, -0x000200f8,0x00002b96,0x00050084,0x00000006, -0x00002b9a,0x000000df,0x00005aa6,0x00050080, -0x00000006,0x00002b9b,0x00002b91,0x00002b9a, -0x00050041,0x0000022d,0x00002b9c,0x00000180, -0x000002dc,0x0004003d,0x00000007,0x00002b9d, -0x00002b9c,0x00050051,0x00000006,0x00002d5a, -0x00002b9d,0x00000000,0x00050095,0x00000130, -0x00002d5c,0x00002d5a,0x00002b9b,0x00050051, -0x00000006,0x00002d5d,0x00002d5c,0x00000001, -0x00050051,0x00000006,0x00002d5e,0x00002d5c, -0x00000000,0x00050051,0x00000006,0x00002d61, -0x00002b9d,0x00000001,0x00050080,0x00000006, -0x00002d63,0x00002d61,0x00002d5d,0x00050050, -0x00000007,0x00002d64,0x00002d5e,0x00002d63, -0x0004007c,0x00000014,0x00002d54,0x00002d64, -0x00060041,0x0000015f,0x00002d4b,0x00002d54, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00002d4c,0x00002d4b,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00002b9f,0x00002d4c, -0x00050041,0x00000028,0x00002ba0,0x00002b2c, -0x00005aa6,0x0003003e,0x00002ba0,0x00002b9f, -0x00050080,0x00000006,0x00002ba3,0x00005aa6, -0x0000022b,0x000200f9,0x00002b92,0x000200f8, -0x00002ba4,0x00050080,0x00000006,0x00002ba6, -0x00002b91,0x000004e8,0x00050041,0x0000022d, -0x00002ba7,0x00000180,0x000002dc,0x0004003d, -0x00000007,0x00002ba8,0x00002ba7,0x00050051, -0x00000006,0x00002d7b,0x00002ba8,0x00000000, -0x00050095,0x00000130,0x00002d7d,0x00002d7b, -0x00002ba6,0x00050051,0x00000006,0x00002d7e, -0x00002d7d,0x00000001,0x00050051,0x00000006, -0x00002d7f,0x00002d7d,0x00000000,0x00050051, -0x00000006,0x00002d82,0x00002ba8,0x00000001, -0x00050080,0x00000006,0x00002d84,0x00002d82, -0x00002d7e,0x00050050,0x00000007,0x00002d85, -0x00002d7f,0x00002d84,0x0004007c,0x00000014, -0x00002d75,0x00002d85,0x00060041,0x0000015f, -0x00002d6c,0x00002d75,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00002d6d,0x00002d6c, -0x00000002,0x00000004,0x00050080,0x00000006, -0x00002bab,0x00002b91,0x000004f4,0x00050095, -0x00000130,0x00002d9e,0x00002d7b,0x00002bab, -0x00050051,0x00000006,0x00002d9f,0x00002d9e, -0x00000001,0x00050051,0x00000006,0x00002da0, -0x00002d9e,0x00000000,0x00050080,0x00000006, -0x00002da5,0x00002d82,0x00002d9f,0x00050050, -0x00000007,0x00002da6,0x00002da0,0x00002da5, -0x0004007c,0x00000014,0x00002d96,0x00002da6, -0x00060041,0x0000015f,0x00002d8d,0x00002d96, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00002d8e,0x00002d8d,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002bb0,0x00002b91, -0x000004fe,0x00050095,0x00000130,0x00002dbf, -0x00002d7b,0x00002bb0,0x00050051,0x00000006, -0x00002dc0,0x00002dbf,0x00000001,0x00050051, -0x00000006,0x00002dc1,0x00002dbf,0x00000000, -0x00050080,0x00000006,0x00002dc6,0x00002d82, -0x00002dc0,0x00050050,0x00000007,0x00002dc7, -0x00002dc1,0x00002dc6,0x0004007c,0x00000014, -0x00002db7,0x00002dc7,0x00060041,0x0000015f, -0x00002dae,0x00002db7,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00002daf,0x00002dae, -0x00000002,0x00000004,0x00050080,0x00000006, -0x00002bb5,0x00002b91,0x00000508,0x00050095, -0x00000130,0x00002de0,0x00002d7b,0x00002bb5, -0x00050051,0x00000006,0x00002de1,0x00002de0, -0x00000001,0x00050051,0x00000006,0x00002de2, -0x00002de0,0x00000000,0x00050080,0x00000006, -0x00002de7,0x00002d82,0x00002de1,0x00050050, -0x00000007,0x00002de8,0x00002de2,0x00002de7, -0x0004007c,0x00000014,0x00002dd8,0x00002de8, -0x00060041,0x0000015f,0x00002dcf,0x00002dd8, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00002dd0,0x00002dcf,0x00000002,0x00000004, -0x00050041,0x00000182,0x00002bba,0x00000180, -0x00000311,0x0004003d,0x00000006,0x00002bbb, -0x00002bba,0x00050084,0x00000006,0x00002bbd, -0x00000309,0x000011de,0x00050080,0x00000006, -0x00002bbe,0x00002bbb,0x00002bbd,0x000200f9, -0x00002bbf,0x000200f8,0x00002bbf,0x000700f5, -0x00000006,0x00005aa7,0x0000012b,0x00002ba4, -0x00002bd0,0x00002bc3,0x000500b0,0x0000002f, -0x00002bc2,0x00005aa7,0x0000019b,0x000400f6, -0x00002bd1,0x00002bc3,0x00000000,0x000400fa, -0x00002bc2,0x00002bc3,0x00002bd1,0x000200f8, -0x00002bc3,0x00050084,0x00000006,0x00002bc6, -0x000000df,0x00005aa7,0x00050080,0x00000006, -0x00002bc7,0x00002bbe,0x00002bc6,0x00050041, -0x0000022d,0x00002bc9,0x00000180,0x0000015e, -0x0004003d,0x00000007,0x00002bca,0x00002bc9, -0x00050041,0x00000028,0x00002bcb,0x00002b2c, -0x00005aa7,0x0004003d,0x00000027,0x00002bcc, -0x00002bcb,0x0004007c,0x00000006,0x00002dee, -0x00002bcc,0x00050051,0x00000006,0x00002e07, -0x00002bca,0x00000000,0x00050095,0x00000130, -0x00002e09,0x00002e07,0x00002bc7,0x00050051, -0x00000006,0x00002e0a,0x00002e09,0x00000001, -0x00050051,0x00000006,0x00002e0b,0x00002e09, -0x00000000,0x00050051,0x00000006,0x00002e0e, -0x00002bca,0x00000001,0x00050080,0x00000006, -0x00002e10,0x00002e0e,0x00002e0a,0x00050050, -0x00000007,0x00002e11,0x00002e0b,0x00002e10, -0x0004007c,0x00000014,0x00002e01,0x00002e11, -0x00060041,0x0000015f,0x00002df9,0x00002e01, -0x0000015e,0x0000015e,0x0005003e,0x00002df9, -0x00002dee,0x00000002,0x00000004,0x00050080, -0x00000006,0x00002bd0,0x00005aa7,0x0000022b, -0x000200f9,0x00002bbf,0x000200f8,0x00002bd1, -0x00050080,0x00000006,0x00002bd3,0x00002bbe, -0x000004e8,0x00050041,0x0000022d,0x00002bd4, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x00002bd5,0x00002bd4,0x00050051,0x00000006, -0x00002e27,0x00002bd5,0x00000000,0x00050095, -0x00000130,0x00002e29,0x00002e27,0x00002bd3, -0x00050051,0x00000006,0x00002e2a,0x00002e29, -0x00000001,0x00050051,0x00000006,0x00002e2b, -0x00002e29,0x00000000,0x00050051,0x00000006, -0x00002e2e,0x00002bd5,0x00000001,0x00050080, -0x00000006,0x00002e30,0x00002e2e,0x00002e2a, -0x00050050,0x00000007,0x00002e31,0x00002e2b, -0x00002e30,0x0004007c,0x00000014,0x00002e21, -0x00002e31,0x00060041,0x0000015f,0x00002e19, -0x00002e21,0x0000015e,0x0000015e,0x0005003e, -0x00002e19,0x00002d6d,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002bd9,0x00002bbe, -0x000004f4,0x00050095,0x00000130,0x00002e49, -0x00002e27,0x00002bd9,0x00050051,0x00000006, -0x00002e4a,0x00002e49,0x00000001,0x00050051, -0x00000006,0x00002e4b,0x00002e49,0x00000000, -0x00050080,0x00000006,0x00002e50,0x00002e2e, -0x00002e4a,0x00050050,0x00000007,0x00002e51, -0x00002e4b,0x00002e50,0x0004007c,0x00000014, -0x00002e41,0x00002e51,0x00060041,0x0000015f, -0x00002e39,0x00002e41,0x0000015e,0x0000015e, -0x0005003e,0x00002e39,0x00002d8e,0x00000002, -0x00000004,0x000500aa,0x0000002f,0x00002e56, -0x00002daf,0x0000012b,0x000300f7,0x00002e5b, -0x00000000,0x000400fa,0x00002e56,0x00002e57, -0x00002e5b,0x000200f8,0x00002e57,0x000500aa, -0x0000002f,0x00002e5a,0x00002dd0,0x0000012b, -0x000200f9,0x00002e5b,0x000200f8,0x00002e5b, -0x000700f5,0x0000002f,0x00002e5c,0x00002e56, -0x00002bd1,0x00002e5a,0x00002e57,0x000400a8, -0x0000002f,0x00002be2,0x00002e5c,0x000300f7, -0x00002c78,0x00000000,0x000400fa,0x00002be2, -0x00002be3,0x00002c78,0x000200f8,0x00002be3, -0x00050041,0x0000022d,0x00002be5,0x00000180, -0x000002f4,0x0004003d,0x00000007,0x00002be6, -0x00002be5,0x00050051,0x00000006,0x00002e64, -0x00002be6,0x00000000,0x00050095,0x00000130, -0x00002e65,0x00002daf,0x00002e64,0x00050051, -0x00000006,0x00002e66,0x00002e65,0x00000001, -0x00050051,0x00000006,0x00002e67,0x00002e65, -0x00000000,0x00050051,0x00000006,0x00002e6c, -0x00002be6,0x00000001,0x00050080,0x00000006, -0x00002e6d,0x00002dd0,0x00002e6c,0x00050080, -0x00000006,0x00002e6f,0x00002e6d,0x00002e66, -0x00050095,0x00000130,0x00002e89,0x00002e67, -0x000004e8,0x00050051,0x00000006,0x00002e8a, -0x00002e89,0x00000001,0x00050051,0x00000006, -0x00002e8b,0x00002e89,0x00000000,0x00050080, -0x00000006,0x00002e90,0x00002e6f,0x00002e8a, -0x00050050,0x00000007,0x00002e91,0x00002e8b, -0x00002e90,0x0004007c,0x00000014,0x00002e81, -0x00002e91,0x00060041,0x0000015f,0x00002e78, -0x00002e81,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00002e79,0x00002e78,0x00000002, -0x00000004,0x00050095,0x00000130,0x00002eaa, -0x00002e67,0x000001a2,0x00050051,0x00000006, -0x00002eab,0x00002eaa,0x00000001,0x00050051, -0x00000006,0x00002eac,0x00002eaa,0x00000000, -0x00050080,0x00000006,0x00002eb1,0x00002e6f, -0x00002eab,0x00050050,0x00000007,0x00002eb2, -0x00002eac,0x00002eb1,0x0004007c,0x00000014, -0x00002ea2,0x00002eb2,0x00060041,0x0000015f, -0x00002e99,0x00002ea2,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00002e9a,0x00002e99, +0x00003caa,0x00003994,0x00050084,0x00000006, +0x00003cab,0x000000ec,0x00003caa,0x00050080, +0x00000006,0x00003cac,0x000001c4,0x00003cab, +0x00050095,0x0000013d,0x00003cca,0x00003c99, +0x00003cac,0x00050051,0x00000006,0x00003ccb, +0x00003cca,0x00000001,0x00050051,0x00000006, +0x00003ccc,0x00003cca,0x00000000,0x00050080, +0x00000006,0x00003cd1,0x00003ca0,0x00003ccb, +0x00050050,0x00000007,0x00003cd2,0x00003ccc, +0x00003cd1,0x0004007c,0x00000014,0x00003cc2, +0x00003cd2,0x00060041,0x0000016c,0x00003cb9, +0x00003cc2,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003cba,0x00003cb9,0x00000002, +0x00000004,0x000500aa,0x0000002f,0x00003c65, +0x00003c8b,0x00003cba,0x000300f7,0x00003c6d, +0x00000000,0x000400fa,0x00003c65,0x00003c66, +0x00003c6d,0x000200f8,0x00003c66,0x000500c6, +0x000000f4,0x00003c69,0x000013db,0x00003994, +0x0004007c,0x00000006,0x00003c6a,0x00003c69, +0x0006000c,0x000000f4,0x00003c6b,0x00000001, +0x0000004b,0x00003c6a,0x00050082,0x000000f4, +0x00003c6c,0x00000d76,0x00003c6b,0x000200f9, +0x00003c73,0x000200f8,0x00003c6d,0x000500c6, +0x00000006,0x00003c70,0x00003c8b,0x00003cba, +0x0006000c,0x000000f4,0x00003c71,0x00000001, +0x0000004b,0x00003c70,0x00050082,0x000000f4, +0x00003c72,0x00000d7e,0x00003c71,0x000200f9, +0x00003c73,0x000200f8,0x00003c73,0x000900f5, +0x000000f4,0x00005e5f,0x00000d67,0x00003c5d, +0x00003c6c,0x00003c66,0x00003c72,0x00003c6d, +0x000500ad,0x0000002f,0x00003998,0x00005e5f, +0x00005e43,0x000600a9,0x000000f4,0x00006117, +0x00003998,0x00003991,0x00005e49,0x000200f9, +0x0000399e,0x000200f8,0x0000399e,0x000500c3, +0x000000f4,0x000039a0,0x00005e48,0x00000264, +0x000200f9,0x00003989,0x000200f8,0x000039a1, +0x00050084,0x000000f4,0x000039a5,0x00005e49, +0x00003971,0x00050080,0x000000f4,0x000039a6, +0x000013db,0x000039a5,0x000300f7,0x00003cfd, +0x00000000,0x000300fb,0x00000138,0x00003cdb, +0x000200f8,0x00003cdb,0x000500b1,0x0000002f, +0x00003cdd,0x000039a6,0x0000016b,0x000400a8, +0x0000002f,0x00003cde,0x00003cdd,0x000300f7, +0x00003ce5,0x00000000,0x000400fa,0x00003cde, +0x00003cdf,0x00003ce5,0x000200f8,0x00003cdf, +0x00050041,0x000001bb,0x00003ce1,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00003ce2, +0x00003ce1,0x0004007c,0x000000f4,0x00003ce3, +0x00003ce2,0x000500af,0x0000002f,0x00003ce4, +0x000039a6,0x00003ce3,0x000200f9,0x00003ce5, +0x000200f8,0x00003ce5,0x000700f5,0x0000002f, +0x00003ce6,0x00003cdd,0x00003cdb,0x00003ce4, +0x00003cdf,0x000300f7,0x00003ce8,0x00000000, +0x000400fa,0x00003ce6,0x00003ce7,0x00003ce8, +0x000200f8,0x00003ce7,0x000200f9,0x00003cfd, +0x000200f8,0x00003ce8,0x00050084,0x00000006, +0x00003d06,0x000000ec,0x000012dd,0x00050080, +0x00000006,0x00003d07,0x000001c4,0x00003d06, +0x00050041,0x00000266,0x00003d08,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00003d09, +0x00003d08,0x00050051,0x00000006,0x00003d23, +0x00003d09,0x00000000,0x00050095,0x0000013d, +0x00003d25,0x00003d23,0x00003d07,0x00050051, +0x00000006,0x00003d26,0x00003d25,0x00000001, +0x00050051,0x00000006,0x00003d27,0x00003d25, +0x00000000,0x00050051,0x00000006,0x00003d2a, +0x00003d09,0x00000001,0x00050080,0x00000006, +0x00003d2c,0x00003d2a,0x00003d26,0x00050050, +0x00000007,0x00003d2d,0x00003d27,0x00003d2c, +0x0004007c,0x00000014,0x00003d1d,0x00003d2d, +0x00060041,0x0000016c,0x00003d14,0x00003d1d, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003d15,0x00003d14,0x00000002,0x00000004, +0x0004007c,0x00000006,0x00003d34,0x000039a6, +0x00050084,0x00000006,0x00003d35,0x000000ec, +0x00003d34,0x00050080,0x00000006,0x00003d36, +0x000001c4,0x00003d35,0x00050095,0x0000013d, +0x00003d54,0x00003d23,0x00003d36,0x00050051, +0x00000006,0x00003d55,0x00003d54,0x00000001, +0x00050051,0x00000006,0x00003d56,0x00003d54, +0x00000000,0x00050080,0x00000006,0x00003d5b, +0x00003d2a,0x00003d55,0x00050050,0x00000007, +0x00003d5c,0x00003d56,0x00003d5b,0x0004007c, +0x00000014,0x00003d4c,0x00003d5c,0x00060041, +0x0000016c,0x00003d43,0x00003d4c,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003d44, +0x00003d43,0x00000002,0x00000004,0x000500aa, +0x0000002f,0x00003cef,0x00003d15,0x00003d44, +0x000300f7,0x00003cf7,0x00000000,0x000400fa, +0x00003cef,0x00003cf0,0x00003cf7,0x000200f8, +0x00003cf0,0x000500c6,0x000000f4,0x00003cf3, +0x000013db,0x000039a6,0x0004007c,0x00000006, +0x00003cf4,0x00003cf3,0x0006000c,0x000000f4, +0x00003cf5,0x00000001,0x0000004b,0x00003cf4, +0x00050082,0x000000f4,0x00003cf6,0x00000d76, +0x00003cf5,0x000200f9,0x00003cfd,0x000200f8, +0x00003cf7,0x000500c6,0x00000006,0x00003cfa, +0x00003d15,0x00003d44,0x0006000c,0x000000f4, +0x00003cfb,0x00000001,0x0000004b,0x00003cfa, +0x00050082,0x000000f4,0x00003cfc,0x00000d7e, +0x00003cfb,0x000200f9,0x00003cfd,0x000200f8, +0x00003cfd,0x000900f5,0x000000f4,0x00005e4a, +0x00000d67,0x00003ce7,0x00003cf6,0x00003cf0, +0x00003cfc,0x00003cf7,0x000200f9,0x000039ab, +0x000200f8,0x000039ab,0x000700f5,0x000000f4, +0x00005e4e,0x0000016b,0x00003cfd,0x00006118, +0x000039c0,0x000700f5,0x000000f4,0x00005e4d, +0x00005e49,0x00003cfd,0x000039af,0x000039c0, +0x000400f6,0x000039c3,0x000039c0,0x00000000, +0x000200f9,0x000039ac,0x000200f8,0x000039ac, +0x00050080,0x000000f4,0x000039ae,0x00005e4d, +0x00000264,0x000500c3,0x000000f4,0x000039af, +0x000039ae,0x00000264,0x00050080,0x000000f4, +0x000039b3,0x00005e4e,0x000039af,0x00050084, +0x000000f4,0x000039b5,0x000039b3,0x00003971, +0x00050080,0x000000f4,0x000039b6,0x000013db, +0x000039b5,0x000300f7,0x00003d87,0x00000000, +0x000300fb,0x00000138,0x00003d65,0x000200f8, +0x00003d65,0x000500b1,0x0000002f,0x00003d67, +0x000039b6,0x0000016b,0x000400a8,0x0000002f, +0x00003d68,0x00003d67,0x000300f7,0x00003d6f, +0x00000000,0x000400fa,0x00003d68,0x00003d69, +0x00003d6f,0x000200f8,0x00003d69,0x00050041, +0x000001bb,0x00003d6b,0x000001b9,0x000001f0, +0x0004003d,0x00000006,0x00003d6c,0x00003d6b, +0x0004007c,0x000000f4,0x00003d6d,0x00003d6c, +0x000500af,0x0000002f,0x00003d6e,0x000039b6, +0x00003d6d,0x000200f9,0x00003d6f,0x000200f8, +0x00003d6f,0x000700f5,0x0000002f,0x00003d70, +0x00003d67,0x00003d65,0x00003d6e,0x00003d69, +0x000300f7,0x00003d72,0x00000000,0x000400fa, +0x00003d70,0x00003d71,0x00003d72,0x000200f8, +0x00003d71,0x000200f9,0x00003d87,0x000200f8, +0x00003d72,0x00050084,0x00000006,0x00003d90, +0x000000ec,0x000012dd,0x00050080,0x00000006, +0x00003d91,0x000001c4,0x00003d90,0x00050041, +0x00000266,0x00003d92,0x000001b9,0x00000264, +0x0004003d,0x00000007,0x00003d93,0x00003d92, +0x00050051,0x00000006,0x00003dad,0x00003d93, +0x00000000,0x00050095,0x0000013d,0x00003daf, +0x00003dad,0x00003d91,0x00050051,0x00000006, +0x00003db0,0x00003daf,0x00000001,0x00050051, +0x00000006,0x00003db1,0x00003daf,0x00000000, +0x00050051,0x00000006,0x00003db4,0x00003d93, +0x00000001,0x00050080,0x00000006,0x00003db6, +0x00003db4,0x00003db0,0x00050050,0x00000007, +0x00003db7,0x00003db1,0x00003db6,0x0004007c, +0x00000014,0x00003da7,0x00003db7,0x00060041, +0x0000016c,0x00003d9e,0x00003da7,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003d9f, +0x00003d9e,0x00000002,0x00000004,0x0004007c, +0x00000006,0x00003dbe,0x000039b6,0x00050084, +0x00000006,0x00003dbf,0x000000ec,0x00003dbe, +0x00050080,0x00000006,0x00003dc0,0x000001c4, +0x00003dbf,0x00050095,0x0000013d,0x00003dde, +0x00003dad,0x00003dc0,0x00050051,0x00000006, +0x00003ddf,0x00003dde,0x00000001,0x00050051, +0x00000006,0x00003de0,0x00003dde,0x00000000, +0x00050080,0x00000006,0x00003de5,0x00003db4, +0x00003ddf,0x00050050,0x00000007,0x00003de6, +0x00003de0,0x00003de5,0x0004007c,0x00000014, +0x00003dd6,0x00003de6,0x00060041,0x0000016c, +0x00003dcd,0x00003dd6,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003dce,0x00003dcd, +0x00000002,0x00000004,0x000500aa,0x0000002f, +0x00003d79,0x00003d9f,0x00003dce,0x000300f7, +0x00003d81,0x00000000,0x000400fa,0x00003d79, +0x00003d7a,0x00003d81,0x000200f8,0x00003d7a, +0x000500c6,0x000000f4,0x00003d7d,0x000013db, +0x000039b6,0x0004007c,0x00000006,0x00003d7e, +0x00003d7d,0x0006000c,0x000000f4,0x00003d7f, +0x00000001,0x0000004b,0x00003d7e,0x00050082, +0x000000f4,0x00003d80,0x00000d76,0x00003d7f, +0x000200f9,0x00003d87,0x000200f8,0x00003d81, +0x000500c6,0x00000006,0x00003d84,0x00003d9f, +0x00003dce,0x0006000c,0x000000f4,0x00003d85, +0x00000001,0x0000004b,0x00003d84,0x00050082, +0x000000f4,0x00003d86,0x00000d7e,0x00003d85, +0x000200f9,0x00003d87,0x000200f8,0x00003d87, +0x000900f5,0x000000f4,0x00005e4f,0x00000d67, +0x00003d71,0x00003d80,0x00003d7a,0x00003d86, +0x00003d81,0x000500ad,0x0000002f,0x000039ba, +0x00005e4f,0x00005e4a,0x000600a9,0x000000f4, +0x00006118,0x000039ba,0x000039b3,0x00005e4e, +0x000200f9,0x000039c0,0x000200f8,0x000039c0, +0x000500ad,0x0000002f,0x000039c2,0x000039af, +0x00000264,0x000400fa,0x000039c2,0x000039ab, +0x000039c3,0x000200f8,0x000039c3,0x00050084, +0x000000f4,0x000039c7,0x00006118,0x00003971, +0x00050080,0x000000f4,0x000039c8,0x000013db, +0x000039c7,0x0007000c,0x000000f4,0x000039ca, +0x00000001,0x00000027,0x00003971,0x0000016b, +0x00050080,0x000000f4,0x000039cb,0x000039c8, +0x000039ca,0x0007000c,0x000000f4,0x000039ce, +0x00000001,0x00000027,0x000013db,0x000039a6, +0x000500aa,0x0000002f,0x000039d0,0x000039ce, +0x000039cb,0x000300f7,0x000039d8,0x00000000, +0x000400fa,0x000039d0,0x000039d1,0x000039d5, +0x000200f8,0x000039d5,0x0004007c,0x00000006, +0x000039d7,0x000039cb,0x000200f9,0x000039d8, +0x000200f8,0x000039d1,0x0004007c,0x00000006, +0x000039d3,0x000039cb,0x000500c5,0x00000006, +0x000039d4,0x00000241,0x000039d3,0x000200f9, +0x000039d8,0x000200f8,0x000039d8,0x000700f5, +0x00000006,0x00005e56,0x000039d4,0x000039d1, +0x000039d7,0x000039d5,0x0007000c,0x000000f4, +0x000039dc,0x00000001,0x0000002a,0x000013db, +0x000039a6,0x00050080,0x000000f4,0x000039de, +0x000039cb,0x00000264,0x000500aa,0x0000002f, +0x000039df,0x000039dc,0x000039de,0x000300f7, +0x000039e9,0x00000000,0x000400fa,0x000039df, +0x000039e0,0x000039e5,0x000200f8,0x000039e5, +0x0004007c,0x00000006,0x000039e8,0x000039de, +0x000200f9,0x000039e9,0x000200f8,0x000039e0, +0x0004007c,0x00000006,0x000039e3,0x000039de, +0x000500c5,0x00000006,0x000039e4,0x00000241, +0x000039e3,0x000200f9,0x000039e9,0x000200f8, +0x000039e9,0x000700f5,0x00000006,0x00005e57, +0x000039e4,0x000039e0,0x000039e8,0x000039e5, +0x00050041,0x000001bb,0x00003e03,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00003e04, +0x00003e03,0x00050084,0x00000006,0x00003e05, +0x000001db,0x00003e04,0x00050080,0x00000006, +0x00003e06,0x000001c4,0x00003e05,0x00050080, +0x00000006,0x00003e0c,0x00003e04,0x0000062f, +0x00050086,0x00000006,0x00003e0d,0x00003e0c, +0x000001be,0x00050084,0x00000006,0x00003dff, +0x000001c4,0x00003e0d,0x00050080,0x00000006, +0x00003e00,0x00003e06,0x00003dff,0x00050080, +0x00000006,0x00003dfa,0x00003e00,0x00003dff, +0x00050041,0x000001bb,0x00003df1,0x000001b9, +0x000001f0,0x0004003d,0x00000006,0x00003df2, +0x00003df1,0x00050084,0x00000006,0x00003df3, +0x000001ef,0x00003df2,0x00050080,0x00000006, +0x00003df4,0x00003dfa,0x00003df3,0x00050041, +0x000001bb,0x00003dea,0x000001b9,0x00000206, +0x0004003d,0x00000006,0x00003deb,0x00003dea, +0x00050084,0x00000006,0x00003dec,0x00000205, +0x00003deb,0x00050080,0x00000006,0x00003ded, +0x00003df4,0x00003dec,0x00050084,0x00000006, +0x000039ee,0x000000ec,0x000012dd,0x00050080, +0x00000006,0x000039ef,0x00003ded,0x000039ee, +0x00050041,0x00000266,0x000039f0,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x000039f1, +0x000039f0,0x00050051,0x00000006,0x00003e2a, +0x000039f1,0x00000000,0x00050095,0x0000013d, +0x00003e2c,0x00003e2a,0x000039ef,0x00050051, +0x00000006,0x00003e2d,0x00003e2c,0x00000001, +0x00050051,0x00000006,0x00003e2e,0x00003e2c, +0x00000000,0x00050051,0x00000006,0x00003e31, +0x000039f1,0x00000001,0x00050080,0x00000006, +0x00003e33,0x00003e31,0x00003e2d,0x00050050, +0x00000007,0x00003e34,0x00003e2e,0x00003e33, +0x0004007c,0x00000014,0x00003e24,0x00003e34, +0x00060041,0x0000016c,0x00003e1c,0x00003e24, +0x0000016b,0x0000016b,0x0005003e,0x00003e1c, +0x00005e56,0x00000002,0x00000004,0x000500ac, +0x0000002f,0x00003e6e,0x00003df2,0x00000142, +0x000300f7,0x00003e74,0x00000000,0x000400fa, +0x00003e6e,0x00003e6f,0x00003e73,0x000200f8, +0x00003e73,0x000200f9,0x00003e74,0x000200f8, +0x00003e6f,0x00050082,0x00000006,0x00003e72, +0x00003df2,0x00000142,0x000200f9,0x00003e74, +0x000200f8,0x00003e74,0x000700f5,0x00000006, +0x00005e58,0x00003e72,0x00003e6f,0x00000138, +0x00003e73,0x00050084,0x00000006,0x00003e39, +0x000000ec,0x00005e58,0x00050080,0x00000006, +0x00003e3a,0x00003ded,0x00003e39,0x00050080, +0x00000006,0x000039f8,0x00003e3a,0x000039ee, +0x00050095,0x0000013d,0x00003e8d,0x00003e2a, +0x000039f8,0x00050051,0x00000006,0x00003e8e, +0x00003e8d,0x00000001,0x00050051,0x00000006, +0x00003e8f,0x00003e8d,0x00000000,0x00050080, +0x00000006,0x00003e94,0x00003e31,0x00003e8e, +0x00050050,0x00000007,0x00003e95,0x00003e8f, +0x00003e94,0x0004007c,0x00000014,0x00003e85, +0x00003e95,0x00060041,0x0000016c,0x00003e7d, +0x00003e85,0x0000016b,0x0000016b,0x0005003e, +0x00003e7d,0x00005e57,0x00000002,0x00000004, +0x000500c7,0x00000006,0x000039fe,0x00005e56, +0x00000241,0x000500aa,0x0000002f,0x000039ff, +0x000039fe,0x00000138,0x000300f7,0x00003a0a, +0x00000000,0x000400fa,0x000039ff,0x00003a00, +0x00003a0a,0x000200f8,0x00003a00,0x000300f7, +0x00003edb,0x00000000,0x000400fa,0x00003e6e, +0x00003ed6,0x00003eda,0x000200f8,0x00003eda, +0x000200f9,0x00003edb,0x000200f8,0x00003ed6, +0x00050082,0x00000006,0x00003ed9,0x00003df2, +0x00000142,0x000200f9,0x00003edb,0x000200f8, +0x00003edb,0x000700f5,0x00000006,0x00005e59, +0x00003ed9,0x00003ed6,0x00000138,0x00003eda, +0x00050084,0x00000006,0x00003ea0,0x000000ec, +0x00005e59,0x00050080,0x00000006,0x00003ea1, +0x00003ded,0x00003ea0,0x000300f7,0x00003ee8, +0x00000000,0x000400fa,0x00003e6e,0x00003ee3, +0x00003ee7,0x000200f8,0x00003ee7,0x000200f9, +0x00003ee8,0x000200f8,0x00003ee3,0x00050082, +0x00000006,0x00003ee6,0x00003df2,0x00000142, +0x000200f9,0x00003ee8,0x000200f8,0x00003ee8, +0x000700f5,0x00000006,0x00005e5a,0x00003ee6, +0x00003ee3,0x00000138,0x00003ee7,0x00050084, +0x00000006,0x00003e9a,0x000000ec,0x00005e5a, +0x00050080,0x00000006,0x00003e9b,0x00003ea1, +0x00003e9a,0x00050084,0x00000006,0x00003a03, +0x000000ec,0x00005e56,0x00050080,0x00000006, +0x00003a04,0x00003e9b,0x00003a03,0x00050095, +0x0000013d,0x00003f01,0x00003e2a,0x00003a04, +0x00050051,0x00000006,0x00003f02,0x00003f01, +0x00000001,0x00050051,0x00000006,0x00003f03, +0x00003f01,0x00000000,0x00050080,0x00000006, +0x00003f08,0x00003e31,0x00003f02,0x00050050, +0x00000007,0x00003f09,0x00003f03,0x00003f08, +0x0004007c,0x00000014,0x00003ef9,0x00003f09, +0x00060041,0x0000016c,0x00003ef1,0x00003ef9, +0x0000016b,0x0000016b,0x0005003e,0x00003ef1, +0x000012dd,0x00000002,0x00000004,0x000200f9, +0x00003a0a,0x000200f8,0x00003a0a,0x000500c7, +0x00000006,0x00003a0c,0x00005e57,0x00000241, +0x000500aa,0x0000002f,0x00003a0d,0x00003a0c, +0x00000138,0x000300f7,0x00003a18,0x00000000, +0x000400fa,0x00003a0d,0x00003a0e,0x00003a18, +0x000200f8,0x00003a0e,0x000300f7,0x00003f4f, +0x00000000,0x000400fa,0x00003e6e,0x00003f4a, +0x00003f4e,0x000200f8,0x00003f4e,0x000200f9, +0x00003f4f,0x000200f8,0x00003f4a,0x00050082, +0x00000006,0x00003f4d,0x00003df2,0x00000142, +0x000200f9,0x00003f4f,0x000200f8,0x00003f4f, +0x000700f5,0x00000006,0x00005e5b,0x00003f4d, +0x00003f4a,0x00000138,0x00003f4e,0x00050084, +0x00000006,0x00003f14,0x000000ec,0x00005e5b, +0x00050080,0x00000006,0x00003f15,0x00003ded, +0x00003f14,0x000300f7,0x00003f5c,0x00000000, +0x000400fa,0x00003e6e,0x00003f57,0x00003f5b, +0x000200f8,0x00003f5b,0x000200f9,0x00003f5c, +0x000200f8,0x00003f57,0x00050082,0x00000006, +0x00003f5a,0x00003df2,0x00000142,0x000200f9, +0x00003f5c,0x000200f8,0x00003f5c,0x000700f5, +0x00000006,0x00005e5c,0x00003f5a,0x00003f57, +0x00000138,0x00003f5b,0x00050084,0x00000006, +0x00003f0e,0x000000ec,0x00005e5c,0x00050080, +0x00000006,0x00003f0f,0x00003f15,0x00003f0e, +0x00050084,0x00000006,0x00003a11,0x000000ec, +0x00005e57,0x00050080,0x00000006,0x00003a12, +0x00003f0f,0x00003a11,0x00050095,0x0000013d, +0x00003f75,0x00003e2a,0x00003a12,0x00050051, +0x00000006,0x00003f76,0x00003f75,0x00000001, +0x00050051,0x00000006,0x00003f77,0x00003f75, +0x00000000,0x00050080,0x00000006,0x00003f7c, +0x00003e31,0x00003f76,0x00050050,0x00000007, +0x00003f7d,0x00003f77,0x00003f7c,0x0004007c, +0x00000014,0x00003f6d,0x00003f7d,0x00060041, +0x0000016c,0x00003f65,0x00003f6d,0x0000016b, +0x0000016b,0x0005003e,0x00003f65,0x000012dd, +0x00000002,0x00000004,0x000200f9,0x00003a18, +0x000200f8,0x00003a18,0x000500aa,0x0000002f, +0x00003a1a,0x000013db,0x0000016b,0x000300f7, +0x00003a20,0x00000000,0x000400fa,0x00003a1a, +0x00003a1b,0x00003a20,0x000200f8,0x00003a1b, +0x000300f7,0x00003fc3,0x00000000,0x000400fa, +0x00003e6e,0x00003fbe,0x00003fc2,0x000200f8, +0x00003fc2,0x000200f9,0x00003fc3,0x000200f8, +0x00003fbe,0x00050082,0x00000006,0x00003fc1, +0x00003df2,0x00000142,0x000200f9,0x00003fc3, +0x000200f8,0x00003fc3,0x000700f5,0x00000006, +0x00005e5d,0x00003fc1,0x00003fbe,0x00000138, +0x00003fc2,0x00050084,0x00000006,0x00003f88, +0x000000ec,0x00005e5d,0x00050080,0x00000006, +0x00003f89,0x00003ded,0x00003f88,0x000300f7, +0x00003fd0,0x00000000,0x000400fa,0x00003e6e, +0x00003fcb,0x00003fcf,0x000200f8,0x00003fcf, +0x000200f9,0x00003fd0,0x000200f8,0x00003fcb, +0x00050082,0x00000006,0x00003fce,0x00003df2, +0x00000142,0x000200f9,0x00003fd0,0x000200f8, +0x00003fd0,0x000700f5,0x00000006,0x00005e5e, +0x00003fce,0x00003fcb,0x00000138,0x00003fcf, +0x00050084,0x00000006,0x00003f82,0x000000ec, +0x00005e5e,0x00050080,0x00000006,0x00003f83, +0x00003f89,0x00003f82,0x00050095,0x0000013d, +0x00003fe9,0x00003e2a,0x00003f83,0x00050051, +0x00000006,0x00003fea,0x00003fe9,0x00000001, +0x00050051,0x00000006,0x00003feb,0x00003fe9, +0x00000000,0x00050080,0x00000006,0x00003ff0, +0x00003e31,0x00003fea,0x00050050,0x00000007, +0x00003ff1,0x00003feb,0x00003ff0,0x0004007c, +0x00000014,0x00003fe1,0x00003ff1,0x00060041, +0x0000016c,0x00003fd9,0x00003fe1,0x0000016b, +0x0000016b,0x0005003e,0x00003fd9,0x00000539, +0x00000002,0x00000004,0x000200f9,0x00003a20, +0x000200f8,0x00003a20,0x000200f9,0x000013d9, +0x000200f8,0x000013d9,0x000200f9,0x000013d0, +0x000200f8,0x000013cf,0x00050041,0x000001bb, +0x00003746,0x000001b9,0x000001ba,0x0004003d, +0x00000006,0x00003747,0x00003746,0x00050084, +0x00000006,0x00003748,0x000001db,0x00003747, +0x00050080,0x00000006,0x00003749,0x000001c4, +0x00003748,0x00050080,0x00000006,0x0000374f, +0x00003747,0x0000062f,0x00050086,0x00000006, +0x00003750,0x0000374f,0x000001be,0x00050084, +0x00000006,0x00003742,0x000001c4,0x00003750, +0x00050080,0x00000006,0x00003743,0x00003749, +0x00003742,0x00050080,0x00000006,0x0000373d, +0x00003743,0x00003742,0x00050084,0x00000006, +0x00003711,0x000001ef,0x000012dd,0x00050080, +0x00000006,0x00003712,0x0000373d,0x00003711, +0x00050041,0x00000266,0x00003713,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x00003714, +0x00003713,0x00050051,0x00000006,0x0000376e, +0x00003714,0x00000000,0x00050095,0x0000013d, +0x00003770,0x0000376e,0x00003712,0x00050051, +0x00000006,0x00003771,0x00003770,0x00000001, +0x00050051,0x00000006,0x00003772,0x00003770, +0x00000000,0x00050051,0x00000006,0x00003775, +0x00003714,0x00000001,0x00050080,0x00000006, +0x00003777,0x00003775,0x00003771,0x00050050, +0x00000007,0x00003778,0x00003772,0x00003777, +0x0004007c,0x00000014,0x00003768,0x00003778, +0x00060041,0x0000016c,0x0000375f,0x00003768, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003760,0x0000375f,0x00000002,0x00000004, +0x0004007c,0x00000027,0x00003717,0x00003760, +0x00050080,0x00000006,0x00003719,0x00003712, +0x000000ec,0x00050095,0x0000013d,0x00003791, +0x0000376e,0x00003719,0x00050051,0x00000006, +0x00003792,0x00003791,0x00000001,0x00050051, +0x00000006,0x00003793,0x00003791,0x00000000, +0x00050080,0x00000006,0x00003798,0x00003775, +0x00003792,0x00050050,0x00000007,0x00003799, +0x00003793,0x00003798,0x0004007c,0x00000014, +0x00003789,0x00003799,0x00060041,0x0000016c, +0x00003780,0x00003789,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003781,0x00003780, 0x00000002,0x00000004,0x0004007c,0x00000027, -0x00002bec,0x00002e9a,0x00050095,0x00000130, -0x00002ecb,0x00002e67,0x00000260,0x00050051, -0x00000006,0x00002ecc,0x00002ecb,0x00000001, -0x00050051,0x00000006,0x00002ecd,0x00002ecb, -0x00000000,0x00050080,0x00000006,0x00002ed2, -0x00002e6f,0x00002ecc,0x00050050,0x00000007, -0x00002ed3,0x00002ecd,0x00002ed2,0x0004007c, -0x00000014,0x00002ec3,0x00002ed3,0x00060041, -0x0000015f,0x00002eba,0x00002ec3,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00002ebb, -0x00002eba,0x00000002,0x00000004,0x0004007c, -0x00000027,0x00002bef,0x00002ebb,0x00050095, -0x00000130,0x00002eec,0x00002e67,0x000001b6, -0x00050051,0x00000006,0x00002eed,0x00002eec, -0x00000001,0x00050051,0x00000006,0x00002eee, -0x00002eec,0x00000000,0x00050080,0x00000006, -0x00002ef3,0x00002e6f,0x00002eed,0x00050050, -0x00000007,0x00002ef4,0x00002eee,0x00002ef3, -0x0004007c,0x00000014,0x00002ee4,0x00002ef4, -0x00060041,0x0000015f,0x00002edb,0x00002ee4, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00002edc,0x00002edb,0x00000002,0x00000004, -0x0004007c,0x00000027,0x00002bf2,0x00002edc, -0x00050095,0x00000130,0x00002f0d,0x00002e67, -0x000005df,0x00050051,0x00000006,0x00002f0e, -0x00002f0d,0x00000001,0x00050051,0x00000006, -0x00002f0f,0x00002f0d,0x00000000,0x00050080, -0x00000006,0x00002f14,0x00002e6f,0x00002f0e, -0x00050050,0x00000007,0x00002f15,0x00002f0f, -0x00002f14,0x0004007c,0x00000014,0x00002f05, -0x00002f15,0x00060041,0x0000015f,0x00002efc, -0x00002f05,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00002efd,0x00002efc,0x00000002, -0x00000004,0x0004007c,0x00000027,0x00002bf6, -0x00002efd,0x00050095,0x00000130,0x00002f2e, -0x00002e67,0x000001cc,0x00050051,0x00000006, -0x00002f2f,0x00002f2e,0x00000001,0x00050051, -0x00000006,0x00002f30,0x00002f2e,0x00000000, -0x00050080,0x00000006,0x00002f35,0x00002e6f, -0x00002f2f,0x00050050,0x00000007,0x00002f36, -0x00002f30,0x00002f35,0x0004007c,0x00000014, -0x00002f26,0x00002f36,0x00060041,0x0000015f, -0x00002f1d,0x00002f26,0x0000015e,0x0000015e, -0x0006003d,0x00000006,0x00002f1e,0x00002f1d, +0x0000371d,0x00003781,0x00050080,0x00000006, +0x0000371f,0x00003712,0x000001cd,0x00050095, +0x0000013d,0x000037b2,0x0000376e,0x0000371f, +0x00050051,0x00000006,0x000037b3,0x000037b2, +0x00000001,0x00050051,0x00000006,0x000037b4, +0x000037b2,0x00000000,0x00050080,0x00000006, +0x000037b9,0x00003775,0x000037b3,0x00050050, +0x00000007,0x000037ba,0x000037b4,0x000037b9, +0x0004007c,0x00000014,0x000037aa,0x000037ba, +0x00060041,0x0000016c,0x000037a1,0x000037aa, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000037a2,0x000037a1,0x00000002,0x00000004, +0x0004007c,0x00000027,0x00003723,0x000037a2, +0x00060050,0x0000006c,0x00003724,0x00003717, +0x0000371d,0x00003723,0x00050080,0x00000006, +0x00003726,0x00003712,0x000001d4,0x00050095, +0x0000013d,0x000037d3,0x0000376e,0x00003726, +0x00050051,0x00000006,0x000037d4,0x000037d3, +0x00000001,0x00050051,0x00000006,0x000037d5, +0x000037d3,0x00000000,0x00050080,0x00000006, +0x000037da,0x00003775,0x000037d4,0x00050050, +0x00000007,0x000037db,0x000037d5,0x000037da, +0x0004007c,0x00000014,0x000037cb,0x000037db, +0x00060041,0x0000016c,0x000037c2,0x000037cb, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000037c3,0x000037c2,0x00000002,0x00000004, +0x0004007c,0x00000027,0x0000372a,0x000037c3, +0x00050080,0x00000006,0x0000372c,0x00003712, +0x000001db,0x00050095,0x0000013d,0x000037f4, +0x0000376e,0x0000372c,0x00050051,0x00000006, +0x000037f5,0x000037f4,0x00000001,0x00050051, +0x00000006,0x000037f6,0x000037f4,0x00000000, +0x00050080,0x00000006,0x000037fb,0x00003775, +0x000037f5,0x00050050,0x00000007,0x000037fc, +0x000037f6,0x000037fb,0x0004007c,0x00000014, +0x000037ec,0x000037fc,0x00060041,0x0000016c, +0x000037e3,0x000037ec,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x000037e4,0x000037e3, 0x00000002,0x00000004,0x0004007c,0x00000027, -0x00002bf9,0x00002f1e,0x00050095,0x00000130, -0x00002f4f,0x00002e67,0x000004c7,0x00050051, -0x00000006,0x00002f50,0x00002f4f,0x00000001, -0x00050051,0x00000006,0x00002f51,0x00002f4f, -0x00000000,0x00050080,0x00000006,0x00002f56, -0x00002e6f,0x00002f50,0x00050050,0x00000007, -0x00002f57,0x00002f51,0x00002f56,0x0004007c, -0x00000014,0x00002f47,0x00002f57,0x00060041, -0x0000015f,0x00002f3e,0x00002f47,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x00002f3f, -0x00002f3e,0x00000002,0x00000004,0x0004007c, -0x00000027,0x00002bfc,0x00002f3f,0x000500bc, -0x0000002f,0x00002f5e,0x00002bec,0x00002bf6, -0x000300f7,0x00002f65,0x00000000,0x000400fa, -0x00002f5e,0x00002f5f,0x00002f65,0x000200f8, -0x00002f5f,0x000500bc,0x0000002f,0x00002f64, -0x00002bef,0x00002bf9,0x000200f9,0x00002f65, -0x000200f8,0x00002f65,0x000700f5,0x0000002f, -0x00002f66,0x00002f5e,0x00002be3,0x00002f64, -0x00002f5f,0x000300f7,0x00002f6d,0x00000000, -0x000400fa,0x00002f66,0x00002f67,0x00002f6d, -0x000200f8,0x00002f67,0x000500bc,0x0000002f, -0x00002f6c,0x00002bf2,0x00002bfc,0x000200f9, -0x00002f6d,0x000200f8,0x00002f6d,0x000700f5, -0x0000002f,0x00002f6e,0x00002f66,0x00002f65, -0x00002f6c,0x00002f67,0x000300f7,0x00002c06, -0x00000000,0x000400fa,0x00002f6e,0x00002c02, -0x00002c06,0x000200f8,0x00002c02,0x000500c2, -0x00000006,0x00002c04,0x00002d6d,0x000005f9, -0x000500ab,0x0000002f,0x00002c05,0x00002c04, -0x0000012b,0x000200f9,0x00002c06,0x000200f8, -0x00002c06,0x000700f5,0x0000002f,0x00002c07, -0x00002f6e,0x00002f6d,0x00002c05,0x00002c02, -0x000300f7,0x00002c77,0x00000000,0x000400fa, -0x00002c07,0x00002c08,0x00002c77,0x000200f8, -0x00002c08,0x000200f9,0x00002c09,0x000200f8, -0x00002c09,0x000700f5,0x00000063,0x00005add, -0x00005cc2,0x00002c08,0x00002c72,0x00002c0d, -0x000700f5,0x00000063,0x00005acb,0x0000053d, -0x00002c08,0x00002c6f,0x00002c0d,0x000700f5, -0x00000006,0x00005aa8,0x0000012b,0x00002c08, -0x00002c75,0x00002c0d,0x000500b0,0x0000002f, -0x00002c0c,0x00005aa8,0x00000194,0x000400f6, -0x00002c76,0x00002c0d,0x00000000,0x000400fa, -0x00002c0c,0x00002c0d,0x00002c76,0x000200f8, -0x00002c0d,0x000500c7,0x00000006,0x00002c0f, -0x00005aa8,0x00000135,0x000500ab,0x0000002f, -0x00002c10,0x00002c0f,0x0000012b,0x000600a9, -0x00000027,0x00005cde,0x00002c10,0x00002bf6, -0x00002bec,0x000500c7,0x00000006,0x00002c1a, -0x00005aa8,0x00000247,0x000500ab,0x0000002f, -0x00002c1b,0x00002c1a,0x0000012b,0x000600a9, -0x00000027,0x00005cdf,0x00002c1b,0x00002bf9, -0x00002bef,0x000500c7,0x00000006,0x00002c25, -0x00005aa8,0x000000df,0x000500ab,0x0000002f, -0x00002c26,0x00002c25,0x0000012b,0x000600a9, -0x00000027,0x00005ce0,0x00002c26,0x00002bfc, -0x00002bf2,0x00050041,0x00000028,0x00002c30, -0x00002b2c,0x0000015e,0x0004003d,0x00000027, -0x00002c31,0x00002c30,0x00050085,0x00000027, -0x00002c34,0x00002c31,0x00005cde,0x00050041, -0x00000028,0x00002c35,0x00002b2c,0x0000022b, -0x0004003d,0x00000027,0x00002c36,0x00002c35, -0x00050085,0x00000027,0x00002c39,0x00002c36, -0x00005cdf,0x00050081,0x00000027,0x00002c3a, -0x00002c34,0x00002c39,0x00050041,0x00000028, -0x00002c3b,0x00002b2c,0x000002dc,0x0004003d, -0x00000027,0x00002c3c,0x00002c3b,0x00050085, -0x00000027,0x00002c3f,0x00002c3c,0x00005ce0, -0x00050081,0x00000027,0x00002c40,0x00002c3a, -0x00002c3f,0x00050041,0x00000028,0x00002c41, -0x00002b2c,0x000002e4,0x0004003d,0x00000027, -0x00002c42,0x00002c41,0x00050081,0x00000027, -0x00002c43,0x00002c40,0x00002c42,0x00050041, -0x00000028,0x00002c44,0x00002b2c,0x000002ec, -0x0004003d,0x00000027,0x00002c45,0x00002c44, -0x00050085,0x00000027,0x00002c48,0x00002c45, -0x00005cde,0x00050041,0x00000028,0x00002c49, -0x00002b2c,0x000002f4,0x0004003d,0x00000027, -0x00002c4a,0x00002c49,0x00050085,0x00000027, -0x00002c4d,0x00002c4a,0x00005cdf,0x00050081, -0x00000027,0x00002c4e,0x00002c48,0x00002c4d, -0x00050041,0x00000028,0x00002c4f,0x00002b2c, -0x00000318,0x0004003d,0x00000027,0x00002c50, -0x00002c4f,0x00050085,0x00000027,0x00002c53, -0x00002c50,0x00005ce0,0x00050081,0x00000027, -0x00002c54,0x00002c4e,0x00002c53,0x00050041, -0x00000028,0x00002c55,0x00002b2c,0x00000653, -0x0004003d,0x00000027,0x00002c56,0x00002c55, -0x00050081,0x00000027,0x00002c57,0x00002c54, -0x00002c56,0x00050041,0x00000028,0x00002c58, -0x00002b2c,0x00000488,0x0004003d,0x00000027, -0x00002c59,0x00002c58,0x00050085,0x00000027, -0x00002c5c,0x00002c59,0x00005cde,0x00050041, -0x00000028,0x00002c5d,0x00002b2c,0x000001cd, -0x0004003d,0x00000027,0x00002c5e,0x00002c5d, -0x00050085,0x00000027,0x00002c61,0x00002c5e, -0x00005cdf,0x00050081,0x00000027,0x00002c62, -0x00002c5c,0x00002c61,0x00050041,0x00000028, -0x00002c63,0x00002b2c,0x0000037d,0x0004003d, -0x00000027,0x00002c64,0x00002c63,0x00050085, -0x00000027,0x00002c67,0x00002c64,0x00005ce0, -0x00050081,0x00000027,0x00002c68,0x00002c62, -0x00002c67,0x00050041,0x00000028,0x00002c69, -0x00002b2c,0x000003fb,0x0004003d,0x00000027, -0x00002c6a,0x00002c69,0x00050081,0x00000027, -0x00002c6b,0x00002c68,0x00002c6a,0x00060050, -0x00000063,0x00002c6c,0x00002c43,0x00002c57, -0x00002c6b,0x0007000c,0x00000063,0x00002c6f, -0x00000001,0x00000025,0x00005acb,0x00002c6c, -0x0007000c,0x00000063,0x00002c72,0x00000001, -0x00000028,0x00005add,0x00002c6c,0x00050080, -0x00000006,0x00002c75,0x00005aa8,0x0000022b, -0x000200f9,0x00002c09,0x000200f8,0x00002c76, -0x000200f9,0x00002c77,0x000200f8,0x00002c77, -0x000700f5,0x00000063,0x00005ad9,0x00005cc2, -0x00002c06,0x00005add,0x00002c76,0x000700f5, -0x00000063,0x00005ac7,0x0000053d,0x00002c06, -0x00005acb,0x00002c76,0x000200f9,0x00002c78, -0x000200f8,0x00002c78,0x000700f5,0x00000063, -0x00005ad7,0x00005cc2,0x00002e5b,0x00005ad9, -0x00002c77,0x000700f5,0x00000063,0x00005ac5, -0x0000053d,0x00002e5b,0x00005ac7,0x00002c77, -0x000700f5,0x00000006,0x00005ab1,0x00000500, -0x00002e5b,0x00002e79,0x00002c77,0x00050041, -0x00000028,0x00002c79,0x00002b2c,0x0000015e, -0x0004003d,0x00000027,0x00002c7a,0x00002c79, -0x000500b4,0x0000002f,0x00002c7b,0x00002c7a, -0x00000677,0x000300f7,0x00002c80,0x00000000, -0x000400fa,0x00002c7b,0x00002c7c,0x00002c80, -0x000200f8,0x00002c7c,0x00050041,0x00000028, -0x00002c7d,0x00002b2c,0x0000022b,0x0004003d, -0x00000027,0x00002c7e,0x00002c7d,0x000500b4, -0x0000002f,0x00002c7f,0x00002c7e,0x000003ed, -0x000200f9,0x00002c80,0x000200f8,0x00002c80, -0x000700f5,0x0000002f,0x00002c81,0x00002c7b, -0x00002c78,0x00002c7f,0x00002c7c,0x000300f7, -0x00002c86,0x00000000,0x000400fa,0x00002c81, -0x00002c82,0x00002c86,0x000200f8,0x00002c82, -0x00050041,0x00000028,0x00002c83,0x00002b2c, -0x000002dc,0x0004003d,0x00000027,0x00002c84, -0x00002c83,0x000500b4,0x0000002f,0x00002c85, -0x00002c84,0x000003ed,0x000200f9,0x00002c86, -0x000200f8,0x00002c86,0x000700f5,0x0000002f, -0x00002c87,0x00002c81,0x00002c80,0x00002c85, -0x00002c82,0x000300f7,0x00002c8c,0x00000000, -0x000400fa,0x00002c87,0x00002c88,0x00002c8c, -0x000200f8,0x00002c88,0x00050041,0x00000028, -0x00002c89,0x00002b2c,0x000002ec,0x0004003d, -0x00000027,0x00002c8a,0x00002c89,0x000500b4, -0x0000002f,0x00002c8b,0x00002c8a,0x000003ed, -0x000200f9,0x00002c8c,0x000200f8,0x00002c8c, -0x000700f5,0x0000002f,0x00002c8d,0x00002c87, -0x00002c86,0x00002c8b,0x00002c88,0x000300f7, -0x00002c92,0x00000000,0x000400fa,0x00002c8d, -0x00002c8e,0x00002c92,0x000200f8,0x00002c8e, -0x00050041,0x00000028,0x00002c8f,0x00002b2c, -0x000002f4,0x0004003d,0x00000027,0x00002c90, -0x00002c8f,0x000500b4,0x0000002f,0x00002c91, -0x00002c90,0x00000677,0x000200f9,0x00002c92, -0x000200f8,0x00002c92,0x000700f5,0x0000002f, -0x00002c93,0x00002c8d,0x00002c8c,0x00002c91, -0x00002c8e,0x000300f7,0x00002c98,0x00000000, -0x000400fa,0x00002c93,0x00002c94,0x00002c98, -0x000200f8,0x00002c94,0x00050041,0x00000028, -0x00002c95,0x00002b2c,0x00000318,0x0004003d, -0x00000027,0x00002c96,0x00002c95,0x000500b4, -0x0000002f,0x00002c97,0x00002c96,0x000003ed, -0x000200f9,0x00002c98,0x000200f8,0x00002c98, -0x000700f5,0x0000002f,0x00002c99,0x00002c93, -0x00002c92,0x00002c97,0x00002c94,0x000300f7, -0x00002c9e,0x00000000,0x000400fa,0x00002c99, -0x00002c9a,0x00002c9e,0x000200f8,0x00002c9a, -0x00050041,0x00000028,0x00002c9b,0x00002b2c, -0x00000488,0x0004003d,0x00000027,0x00002c9c, -0x00002c9b,0x000500b4,0x0000002f,0x00002c9d, -0x00002c9c,0x000003ed,0x000200f9,0x00002c9e, -0x000200f8,0x00002c9e,0x000700f5,0x0000002f, -0x00002c9f,0x00002c99,0x00002c98,0x00002c9d, -0x00002c9a,0x000300f7,0x00002ca4,0x00000000, -0x000400fa,0x00002c9f,0x00002ca0,0x00002ca4, -0x000200f8,0x00002ca0,0x00050041,0x00000028, -0x00002ca1,0x00002b2c,0x000001cd,0x0004003d, -0x00000027,0x00002ca2,0x00002ca1,0x000500b4, -0x0000002f,0x00002ca3,0x00002ca2,0x000003ed, -0x000200f9,0x00002ca4,0x000200f8,0x00002ca4, -0x000700f5,0x0000002f,0x00002ca5,0x00002c9f, -0x00002c9e,0x00002ca3,0x00002ca0,0x000300f7, -0x00002caa,0x00000000,0x000400fa,0x00002ca5, -0x00002ca6,0x00002caa,0x000200f8,0x00002ca6, -0x00050041,0x00000028,0x00002ca7,0x00002b2c, -0x0000037d,0x0004003d,0x00000027,0x00002ca8, -0x00002ca7,0x000500b4,0x0000002f,0x00002ca9, -0x00002ca8,0x00000677,0x000200f9,0x00002caa, -0x000200f8,0x00002caa,0x000700f5,0x0000002f, -0x00002cab,0x00002ca5,0x00002ca4,0x00002ca9, -0x00002ca6,0x00050080,0x00000006,0x00002cad, -0x00002bbe,0x000004fe,0x000500c7,0x00000006, -0x00002caf,0x00005ab1,0x000006ac,0x000600a9, -0x00000006,0x00002cb1,0x00002cab,0x00000208, -0x0000012b,0x000500c5,0x00000006,0x00002cb2, -0x00002caf,0x00002cb1,0x00050095,0x00000130, -0x00002f87,0x00002e27,0x00002cad,0x00050051, -0x00000006,0x00002f88,0x00002f87,0x00000001, -0x00050051,0x00000006,0x00002f89,0x00002f87, -0x00000000,0x00050080,0x00000006,0x00002f8e, -0x00002e2e,0x00002f88,0x00050050,0x00000007, -0x00002f8f,0x00002f89,0x00002f8e,0x0004007c, -0x00000014,0x00002f7f,0x00002f8f,0x00060041, -0x0000015f,0x00002f77,0x00002f7f,0x0000015e, -0x0000015e,0x0005003e,0x00002f77,0x00002cb2, -0x00000002,0x00000004,0x00050080,0x00000006, -0x00002cb7,0x00002bbe,0x00000508,0x000500c2, -0x00000006,0x00002cba,0x00002daf,0x00000488, -0x000500c4,0x00000006,0x00002cbd,0x00002dd0, -0x000005f9,0x000500c5,0x00000006,0x00002cbe, -0x00002cba,0x00002cbd,0x00050095,0x00000130, -0x00002fa7,0x00002e27,0x00002cb7,0x00050051, -0x00000006,0x00002fa8,0x00002fa7,0x00000001, -0x00050051,0x00000006,0x00002fa9,0x00002fa7, -0x00000000,0x00050080,0x00000006,0x00002fae, -0x00002e2e,0x00002fa8,0x00050050,0x00000007, -0x00002faf,0x00002fa9,0x00002fae,0x0004007c, -0x00000014,0x00002f9f,0x00002faf,0x00060041, -0x0000015f,0x00002f97,0x00002f9f,0x0000015e, -0x0000015e,0x0005003e,0x00002f97,0x00002cbe, -0x00000002,0x00000004,0x0004003d,0x00000027, -0x00002cc3,0x00002c79,0x00050041,0x00000028, -0x00002cc4,0x00002b2c,0x000002ec,0x0004003d, -0x00000027,0x00002cc5,0x00002cc4,0x00050041, -0x00000028,0x00002cc6,0x00002b2c,0x00000488, -0x0004003d,0x00000027,0x00002cc7,0x00002cc6, -0x00050041,0x00000028,0x00002cc8,0x00002b2c, -0x0000022b,0x0004003d,0x00000027,0x00002cc9, -0x00002cc8,0x00050041,0x00000028,0x00002cca, -0x00002b2c,0x000002f4,0x0004003d,0x00000027, -0x00002ccb,0x00002cca,0x00050041,0x00000028, -0x00002ccc,0x00002b2c,0x000001cd,0x0004003d, -0x00000027,0x00002ccd,0x00002ccc,0x00050041, -0x00000028,0x00002cce,0x00002b2c,0x000002dc, -0x0004003d,0x00000027,0x00002ccf,0x00002cce, -0x00050041,0x00000028,0x00002cd0,0x00002b2c, -0x00000318,0x0004003d,0x00000027,0x00002cd1, -0x00002cd0,0x00050041,0x00000028,0x00002cd2, -0x00002b2c,0x0000037d,0x0004003d,0x00000027, -0x00002cd3,0x00002cd2,0x00060050,0x00000063, -0x00002cd4,0x00002cc3,0x00002cc5,0x00002cc7, -0x00060050,0x00000063,0x00002cd5,0x00002cc9, -0x00002ccb,0x00002ccd,0x00060050,0x00000063, -0x00002cd6,0x00002ccf,0x00002cd1,0x00002cd3, -0x00060050,0x000006c6,0x00002cd7,0x00002cd4, -0x00002cd5,0x00002cd6,0x0006000c,0x00000027, -0x00002cd9,0x00000001,0x00000021,0x00002cd7, -0x000500b7,0x0000002f,0x00002cdb,0x00002cd9, -0x000003ed,0x000300f7,0x00002ce0,0x00000000, -0x000400fa,0x00002cdb,0x00002cdc,0x00002cdf, -0x000200f8,0x00002cdf,0x000200f9,0x00002ce0, -0x000200f8,0x00002cdc,0x0006000c,0x000006c6, -0x00002cde,0x00000001,0x00000022,0x00002cd7, -0x000200f9,0x00002ce0,0x000200f8,0x00002ce0, -0x000700f5,0x000006c6,0x00005ab8,0x00002cde, -0x00002cdc,0x000006ec,0x00002cdf,0x0003003e, -0x00002b6d,0x00005ab8,0x00050041,0x00000028, -0x00002ce2,0x00002b2c,0x000002e4,0x0004003d, -0x00000027,0x00002ce3,0x00002ce2,0x00050041, -0x00000028,0x00002ce4,0x00002b2c,0x00000653, -0x0004003d,0x00000027,0x00002ce5,0x00002ce4, -0x00050041,0x00000028,0x00002ce6,0x00002b2c, -0x000003fb,0x0004003d,0x00000027,0x00002ce7, -0x00002ce6,0x00060050,0x00000063,0x00002ce8, -0x00002ce3,0x00002ce5,0x00002ce7,0x00050091, -0x00000063,0x00002ceb,0x00005ab8,0x00002ce8, -0x0004007f,0x00000063,0x00002cec,0x00002ceb, -0x0003003e,0x00002b70,0x00002cec,0x000200f9, -0x00002ced,0x000200f8,0x00002ced,0x000700f5, -0x00000006,0x00005ab9,0x0000012b,0x00002ce0, -0x00002d20,0x00002cf1,0x000500b0,0x0000002f, -0x00002cf0,0x00005ab9,0x00000437,0x000400f6, -0x00002d21,0x00002cf1,0x00000000,0x000400fa, -0x00002cf0,0x00002cf1,0x00002d21,0x000200f8, -0x00002cf1,0x00050080,0x00000006,0x00002cf3, -0x00002bbe,0x0000018b,0x00050084,0x00000006, -0x00002cf5,0x000001a2,0x00005ab9,0x00050080, -0x00000006,0x00002cf6,0x00002cf3,0x00002cf5, -0x00060041,0x00000028,0x00002cfa,0x00002b6d, -0x0000015e,0x00005ab9,0x0004003d,0x00000027, -0x00002cfb,0x00002cfa,0x0004007c,0x00000006, -0x00002fb5,0x00002cfb,0x00050095,0x00000130, -0x00002fd0,0x00002e27,0x00002cf6,0x00050051, -0x00000006,0x00002fd1,0x00002fd0,0x00000001, -0x00050051,0x00000006,0x00002fd2,0x00002fd0, -0x00000000,0x00050080,0x00000006,0x00002fd7, -0x00002e2e,0x00002fd1,0x00050050,0x00000007, -0x00002fd8,0x00002fd2,0x00002fd7,0x0004007c, -0x00000014,0x00002fc8,0x00002fd8,0x00060041, -0x0000015f,0x00002fc0,0x00002fc8,0x0000015e, -0x0000015e,0x0005003e,0x00002fc0,0x00002fb5, -0x00000002,0x00000004,0x00050080,0x00000006, -0x00002cfe,0x00002bbe,0x00000712,0x00050080, -0x00000006,0x00002d01,0x00002cfe,0x00002cf5, -0x00060041,0x00000028,0x00002d05,0x00002b6d, -0x0000022b,0x00005ab9,0x0004003d,0x00000027, -0x00002d06,0x00002d05,0x0004007c,0x00000006, -0x00002fde,0x00002d06,0x00050095,0x00000130, -0x00002ff9,0x00002e27,0x00002d01,0x00050051, -0x00000006,0x00002ffa,0x00002ff9,0x00000001, -0x00050051,0x00000006,0x00002ffb,0x00002ff9, -0x00000000,0x00050080,0x00000006,0x00003000, -0x00002e2e,0x00002ffa,0x00050050,0x00000007, -0x00003001,0x00002ffb,0x00003000,0x0004007c, -0x00000014,0x00002ff1,0x00003001,0x00060041, -0x0000015f,0x00002fe9,0x00002ff1,0x0000015e, -0x0000015e,0x0005003e,0x00002fe9,0x00002fde, +0x00003730,0x000037e4,0x00050080,0x00000006, +0x00003732,0x00003712,0x00000299,0x00050095, +0x0000013d,0x00003815,0x0000376e,0x00003732, +0x00050051,0x00000006,0x00003816,0x00003815, +0x00000001,0x00050051,0x00000006,0x00003817, +0x00003815,0x00000000,0x00050080,0x00000006, +0x0000381c,0x00003775,0x00003816,0x00050050, +0x00000007,0x0000381d,0x00003817,0x0000381c, +0x0004007c,0x00000014,0x0000380d,0x0000381d, +0x00060041,0x0000016c,0x00003804,0x0000380d, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003805,0x00003804,0x00000002,0x00000004, +0x0004007c,0x00000027,0x00003736,0x00003805, +0x00060050,0x0000006c,0x00003737,0x0000372a, +0x00003730,0x00003736,0x000500bc,0x0000002f, +0x00003824,0x00003717,0x0000372a,0x000300f7, +0x0000382b,0x00000000,0x000400fa,0x00003824, +0x00003825,0x0000382b,0x000200f8,0x00003825, +0x000500bc,0x0000002f,0x0000382a,0x0000371d, +0x00003730,0x000200f9,0x0000382b,0x000200f8, +0x0000382b,0x000700f5,0x0000002f,0x0000382c, +0x00003824,0x000013cf,0x0000382a,0x00003825, +0x000300f7,0x00003833,0x00000000,0x000400fa, +0x0000382c,0x0000382d,0x00003833,0x000200f8, +0x0000382d,0x000500bc,0x0000002f,0x00003832, +0x00003723,0x00003736,0x000200f9,0x00003833, +0x000200f8,0x00003833,0x000700f5,0x0000002f, +0x00003834,0x0000382c,0x0000382b,0x00003832, +0x0000382d,0x000300f7,0x000036f0,0x00000000, +0x000400fa,0x00003834,0x000036b4,0x000036f0, +0x000200f8,0x000036b4,0x00050095,0x0000013d, +0x00003845,0x0000376e,0x00000138,0x00050051, +0x00000006,0x00003846,0x00003845,0x00000001, +0x00050051,0x00000006,0x00003847,0x00003845, +0x00000000,0x00050080,0x00000006,0x0000384c, +0x00003775,0x00003846,0x00050050,0x00000007, +0x0000384d,0x00003847,0x0000384c,0x0004007c, +0x00000014,0x0000383d,0x0000384d,0x00060041, +0x0000016c,0x000036b9,0x0000383d,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000036ba, +0x000036b9,0x00000002,0x00000004,0x000500c7, +0x00000006,0x00003852,0x000036ba,0x00000241, +0x000500ab,0x0000002f,0x00003853,0x00003852, +0x00000138,0x000300f7,0x0000385a,0x00000000, +0x000400fa,0x00003853,0x00003854,0x00003857, +0x000200f8,0x00003857,0x000400c8,0x00000006, +0x00003859,0x000036ba,0x000200f9,0x0000385a, +0x000200f8,0x00003854,0x000500c7,0x00000006, +0x00003856,0x000036ba,0x00000256,0x000200f9, +0x0000385a,0x000200f8,0x0000385a,0x000700f5, +0x00000006,0x00005e65,0x00003856,0x00003854, +0x00003859,0x00003857,0x0004007c,0x00000027, +0x0000385c,0x00005e65,0x00060041,0x0000016c, +0x000036bd,0x0000383d,0x0000016b,0x00000264, +0x0006003d,0x00000006,0x000036be,0x000036bd, +0x00000002,0x00000004,0x000500c7,0x00000006, +0x00003861,0x000036be,0x00000241,0x000500ab, +0x0000002f,0x00003862,0x00003861,0x00000138, +0x000300f7,0x00003869,0x00000000,0x000400fa, +0x00003862,0x00003863,0x00003866,0x000200f8, +0x00003866,0x000400c8,0x00000006,0x00003868, +0x000036be,0x000200f9,0x00003869,0x000200f8, +0x00003863,0x000500c7,0x00000006,0x00003865, +0x000036be,0x00000256,0x000200f9,0x00003869, +0x000200f8,0x00003869,0x000700f5,0x00000006, +0x00005e66,0x00003865,0x00003863,0x00003868, +0x00003866,0x0004007c,0x00000027,0x0000386b, +0x00005e66,0x00060041,0x0000016c,0x000036c1, +0x0000383d,0x0000016b,0x00000315,0x0006003d, +0x00000006,0x000036c2,0x000036c1,0x00000002, +0x00000004,0x000500c7,0x00000006,0x00003870, +0x000036c2,0x00000241,0x000500ab,0x0000002f, +0x00003871,0x00003870,0x00000138,0x000300f7, +0x00003878,0x00000000,0x000400fa,0x00003871, +0x00003872,0x00003875,0x000200f8,0x00003875, +0x000400c8,0x00000006,0x00003877,0x000036c2, +0x000200f9,0x00003878,0x000200f8,0x00003872, +0x000500c7,0x00000006,0x00003874,0x000036c2, +0x00000256,0x000200f9,0x00003878,0x000200f8, +0x00003878,0x000700f5,0x00000006,0x00005e67, +0x00003874,0x00003872,0x00003877,0x00003875, +0x0004007c,0x00000027,0x0000387a,0x00005e67, +0x00060050,0x0000006c,0x000036c4,0x0000385c, +0x0000386b,0x0000387a,0x00060041,0x0000016c, +0x000036c6,0x0000383d,0x0000016b,0x0000031d, +0x0006003d,0x00000006,0x000036c7,0x000036c6, +0x00000002,0x00000004,0x000500c7,0x00000006, +0x0000387f,0x000036c7,0x00000241,0x000500ab, +0x0000002f,0x00003880,0x0000387f,0x00000138, +0x000300f7,0x00003887,0x00000000,0x000400fa, +0x00003880,0x00003881,0x00003884,0x000200f8, +0x00003884,0x000400c8,0x00000006,0x00003886, +0x000036c7,0x000200f9,0x00003887,0x000200f8, +0x00003881,0x000500c7,0x00000006,0x00003883, +0x000036c7,0x00000256,0x000200f9,0x00003887, +0x000200f8,0x00003887,0x000700f5,0x00000006, +0x00005e68,0x00003883,0x00003881,0x00003886, +0x00003884,0x0004007c,0x00000027,0x00003889, +0x00005e68,0x00060041,0x0000016c,0x000036ca, +0x0000383d,0x0000016b,0x00000325,0x0006003d, +0x00000006,0x000036cb,0x000036ca,0x00000002, +0x00000004,0x000500c7,0x00000006,0x0000388e, +0x000036cb,0x00000241,0x000500ab,0x0000002f, +0x0000388f,0x0000388e,0x00000138,0x000300f7, +0x00003896,0x00000000,0x000400fa,0x0000388f, +0x00003890,0x00003893,0x000200f8,0x00003893, +0x000400c8,0x00000006,0x00003895,0x000036cb, +0x000200f9,0x00003896,0x000200f8,0x00003890, +0x000500c7,0x00000006,0x00003892,0x000036cb, +0x00000256,0x000200f9,0x00003896,0x000200f8, +0x00003896,0x000700f5,0x00000006,0x00005e69, +0x00003892,0x00003890,0x00003895,0x00003893, +0x0004007c,0x00000027,0x00003898,0x00005e69, +0x00060041,0x0000016c,0x000036ce,0x0000383d, +0x0000016b,0x0000032d,0x0006003d,0x00000006, +0x000036cf,0x000036ce,0x00000002,0x00000004, +0x000500c7,0x00000006,0x0000389d,0x000036cf, +0x00000241,0x000500ab,0x0000002f,0x0000389e, +0x0000389d,0x00000138,0x000300f7,0x000038a5, +0x00000000,0x000400fa,0x0000389e,0x0000389f, +0x000038a2,0x000200f8,0x000038a2,0x000400c8, +0x00000006,0x000038a4,0x000036cf,0x000200f9, +0x000038a5,0x000200f8,0x0000389f,0x000500c7, +0x00000006,0x000038a1,0x000036cf,0x00000256, +0x000200f9,0x000038a5,0x000200f8,0x000038a5, +0x000700f5,0x00000006,0x00005e6a,0x000038a1, +0x0000389f,0x000038a4,0x000038a2,0x0004007c, +0x00000027,0x000038a7,0x00005e6a,0x00060050, +0x0000006c,0x000036d1,0x00003889,0x00003898, +0x000038a7,0x00050083,0x0000006c,0x000036d4, +0x000036d1,0x000036c4,0x0007000c,0x0000006c, +0x000036d5,0x00000001,0x00000028,0x000036d4, +0x000008d3,0x00050081,0x0000006c,0x000036d8, +0x00003724,0x00003737,0x0005008e,0x0000006c, +0x000036d9,0x000036d8,0x000002fd,0x00050083, +0x0000006c,0x000036db,0x000036d9,0x000036c4, +0x00050088,0x0000006c,0x000036dd,0x000036db, +0x000036d5,0x0008000c,0x0000006c,0x000036e0, +0x00000001,0x0000002b,0x000036dd,0x000007ea, +0x000060fc,0x0005008e,0x0000006c,0x000036e1, +0x000036e0,0x000008e1,0x0004006d,0x000000df, +0x000036e2,0x000036e1,0x00050051,0x00000006, +0x000036e4,0x000036e2,0x00000000,0x000500c7, +0x00000006,0x000038ab,0x000036e4,0x00000876, +0x000500c4,0x00000006,0x000038ae,0x000038ab, +0x0000035a,0x000500c5,0x00000006,0x000038af, +0x000038ab,0x000038ae,0x000500c7,0x00000006, +0x000038b0,0x000038af,0x0000087d,0x000500c4, +0x00000006,0x000038b3,0x000038b0,0x000004c1, +0x000500c5,0x00000006,0x000038b4,0x000038b0, +0x000038b3,0x000500c7,0x00000006,0x000038b5, +0x000038b4,0x00000883,0x000500c4,0x00000006, +0x000038b8,0x000038b5,0x00000325,0x000500c5, +0x00000006,0x000038b9,0x000038b5,0x000038b8, +0x000500c7,0x00000006,0x000038ba,0x000038b9, +0x00000889,0x000500c4,0x00000006,0x000038bd, +0x000038ba,0x00000315,0x000500c5,0x00000006, +0x000038be,0x000038ba,0x000038bd,0x000500c7, +0x00000006,0x000038bf,0x000038be,0x0000088f, +0x000500c4,0x00000006,0x000036e6,0x000038bf, +0x00000315,0x00050051,0x00000006,0x000036e8, +0x000036e2,0x00000001,0x000500c7,0x00000006, +0x000038c4,0x000036e8,0x00000876,0x000500c4, +0x00000006,0x000038c7,0x000038c4,0x0000035a, +0x000500c5,0x00000006,0x000038c8,0x000038c4, +0x000038c7,0x000500c7,0x00000006,0x000038c9, +0x000038c8,0x0000087d,0x000500c4,0x00000006, +0x000038cc,0x000038c9,0x000004c1,0x000500c5, +0x00000006,0x000038cd,0x000038c9,0x000038cc, +0x000500c7,0x00000006,0x000038ce,0x000038cd, +0x00000883,0x000500c4,0x00000006,0x000038d1, +0x000038ce,0x00000325,0x000500c5,0x00000006, +0x000038d2,0x000038ce,0x000038d1,0x000500c7, +0x00000006,0x000038d3,0x000038d2,0x00000889, +0x000500c4,0x00000006,0x000038d6,0x000038d3, +0x00000315,0x000500c5,0x00000006,0x000038d7, +0x000038d3,0x000038d6,0x000500c7,0x00000006, +0x000038d8,0x000038d7,0x0000088f,0x000500c4, +0x00000006,0x000036ea,0x000038d8,0x00000264, +0x000500c5,0x00000006,0x000036eb,0x000036e6, +0x000036ea,0x00050051,0x00000006,0x000036ed, +0x000036e2,0x00000002,0x000500c7,0x00000006, +0x000038dd,0x000036ed,0x00000876,0x000500c4, +0x00000006,0x000038e0,0x000038dd,0x0000035a, +0x000500c5,0x00000006,0x000038e1,0x000038dd, +0x000038e0,0x000500c7,0x00000006,0x000038e2, +0x000038e1,0x0000087d,0x000500c4,0x00000006, +0x000038e5,0x000038e2,0x000004c1,0x000500c5, +0x00000006,0x000038e6,0x000038e2,0x000038e5, +0x000500c7,0x00000006,0x000038e7,0x000038e6, +0x00000883,0x000500c4,0x00000006,0x000038ea, +0x000038e7,0x00000325,0x000500c5,0x00000006, +0x000038eb,0x000038e7,0x000038ea,0x000500c7, +0x00000006,0x000038ec,0x000038eb,0x00000889, +0x000500c4,0x00000006,0x000038ef,0x000038ec, +0x00000315,0x000500c5,0x00000006,0x000038f0, +0x000038ec,0x000038ef,0x000500c7,0x00000006, +0x000038f1,0x000038f0,0x0000088f,0x000500c5, +0x00000006,0x000036ef,0x000036eb,0x000038f1, +0x000200f9,0x000036f0,0x000200f8,0x000036f0, +0x000700f5,0x00000006,0x00005e6b,0x000007a6, +0x00003833,0x000036ef,0x000038a5,0x00050084, +0x00000006,0x000036f3,0x000000ec,0x000012dd, +0x00050080,0x00000006,0x000036f4,0x000001c4, +0x000036f3,0x00050095,0x0000013d,0x0000390c, +0x0000376e,0x000036f4,0x00050051,0x00000006, +0x0000390d,0x0000390c,0x00000001,0x00050051, +0x00000006,0x0000390e,0x0000390c,0x00000000, +0x00050080,0x00000006,0x00003913,0x00003775, +0x0000390d,0x00050050,0x00000007,0x00003914, +0x0000390e,0x00003913,0x0004007c,0x00000014, +0x00003904,0x00003914,0x00060041,0x0000016c, +0x000038fc,0x00003904,0x0000016b,0x0000016b, +0x0005003e,0x000038fc,0x00005e6b,0x00000002, +0x00000004,0x00050084,0x00000006,0x00003919, +0x000000ec,0x00003747,0x00050080,0x00000006, +0x0000391a,0x000001c4,0x00003919,0x00050080, +0x00000006,0x000036fc,0x0000391a,0x000036f3, +0x00050095,0x0000013d,0x00003932,0x0000376e, +0x000036fc,0x00050051,0x00000006,0x00003933, +0x00003932,0x00000001,0x00050051,0x00000006, +0x00003934,0x00003932,0x00000000,0x00050080, +0x00000006,0x00003939,0x00003775,0x00003933, +0x00050050,0x00000007,0x0000393a,0x00003934, +0x00003939,0x0004007c,0x00000014,0x0000392a, +0x0000393a,0x00060041,0x0000016c,0x00003922, +0x0000392a,0x0000016b,0x0000016b,0x0005003e, +0x00003922,0x000012dd,0x00000002,0x00000004, +0x000200f9,0x000013d0,0x000200f8,0x000013d0, +0x000200f9,0x000013c7,0x000200f8,0x000013c6, +0x00050084,0x00000006,0x00002c99,0x000001c4, +0x000012dd,0x000200f9,0x00002c9a,0x000200f8, +0x00002c9a,0x000700f5,0x00000006,0x00005e6e, +0x00000138,0x000013c6,0x00002cab,0x00002c9e, +0x000500b0,0x0000002f,0x00002c9d,0x00005e6e, +0x000001d4,0x000400f6,0x00002cac,0x00002c9e, +0x00000000,0x000400fa,0x00002c9d,0x00002c9e, +0x00002cac,0x000200f8,0x00002c9e,0x00050084, +0x00000006,0x00002ca2,0x000000ec,0x00005e6e, +0x00050080,0x00000006,0x00002ca3,0x00002c99, +0x00002ca2,0x00050041,0x00000266,0x00002ca4, +0x000001b9,0x00000315,0x0004003d,0x00000007, +0x00002ca5,0x00002ca4,0x00050051,0x00000006, +0x00002e6e,0x00002ca5,0x00000000,0x00050095, +0x0000013d,0x00002e70,0x00002e6e,0x00002ca3, +0x00050051,0x00000006,0x00002e71,0x00002e70, +0x00000001,0x00050051,0x00000006,0x00002e72, +0x00002e70,0x00000000,0x00050051,0x00000006, +0x00002e75,0x00002ca5,0x00000001,0x00050080, +0x00000006,0x00002e77,0x00002e75,0x00002e71, +0x00050050,0x00000007,0x00002e78,0x00002e72, +0x00002e77,0x0004007c,0x00000014,0x00002e68, +0x00002e78,0x00060041,0x0000016c,0x00002e5f, +0x00002e68,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002e60,0x00002e5f,0x00000002, +0x00000004,0x0004007c,0x00000027,0x00002ca7, +0x00002e60,0x00050041,0x00000028,0x00002ca8, +0x00002c30,0x00005e6e,0x0003003e,0x00002ca8, +0x00002ca7,0x00050080,0x00000006,0x00002cab, +0x00005e6e,0x00000264,0x000200f9,0x00002c9a, +0x000200f8,0x00002cac,0x00050080,0x00000006, +0x00002cae,0x00002c99,0x00000521,0x00050041, +0x00000266,0x00002caf,0x000001b9,0x00000315, +0x0004003d,0x00000007,0x00002cb0,0x00002caf, +0x00050051,0x00000006,0x00002e8f,0x00002cb0, +0x00000000,0x00050095,0x0000013d,0x00002e91, +0x00002e8f,0x00002cae,0x00050051,0x00000006, +0x00002e92,0x00002e91,0x00000001,0x00050051, +0x00000006,0x00002e93,0x00002e91,0x00000000, +0x00050051,0x00000006,0x00002e96,0x00002cb0, +0x00000001,0x00050080,0x00000006,0x00002e98, +0x00002e96,0x00002e92,0x00050050,0x00000007, +0x00002e99,0x00002e93,0x00002e98,0x0004007c, +0x00000014,0x00002e89,0x00002e99,0x00060041, +0x0000016c,0x00002e80,0x00002e89,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00002e81, +0x00002e80,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002cb3,0x00002c99,0x0000052d, +0x00050095,0x0000013d,0x00002eb2,0x00002e8f, +0x00002cb3,0x00050051,0x00000006,0x00002eb3, +0x00002eb2,0x00000001,0x00050051,0x00000006, +0x00002eb4,0x00002eb2,0x00000000,0x00050080, +0x00000006,0x00002eb9,0x00002e96,0x00002eb3, +0x00050050,0x00000007,0x00002eba,0x00002eb4, +0x00002eb9,0x0004007c,0x00000014,0x00002eaa, +0x00002eba,0x00060041,0x0000016c,0x00002ea1, +0x00002eaa,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002ea2,0x00002ea1,0x00000002, +0x00000004,0x00050080,0x00000006,0x00002cb8, +0x00002c99,0x00000537,0x00050095,0x0000013d, +0x00002ed3,0x00002e8f,0x00002cb8,0x00050051, +0x00000006,0x00002ed4,0x00002ed3,0x00000001, +0x00050051,0x00000006,0x00002ed5,0x00002ed3, +0x00000000,0x00050080,0x00000006,0x00002eda, +0x00002e96,0x00002ed4,0x00050050,0x00000007, +0x00002edb,0x00002ed5,0x00002eda,0x0004007c, +0x00000014,0x00002ecb,0x00002edb,0x00060041, +0x0000016c,0x00002ec2,0x00002ecb,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00002ec3, +0x00002ec2,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002cbd,0x00002c99,0x00000541, +0x00050095,0x0000013d,0x00002ef4,0x00002e8f, +0x00002cbd,0x00050051,0x00000006,0x00002ef5, +0x00002ef4,0x00000001,0x00050051,0x00000006, +0x00002ef6,0x00002ef4,0x00000000,0x00050080, +0x00000006,0x00002efb,0x00002e96,0x00002ef5, +0x00050050,0x00000007,0x00002efc,0x00002ef6, +0x00002efb,0x0004007c,0x00000014,0x00002eec, +0x00002efc,0x00060041,0x0000016c,0x00002ee3, +0x00002eec,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002ee4,0x00002ee3,0x00000002, +0x00000004,0x00050050,0x00000007,0x00002cc1, +0x00002ec3,0x00002ee4,0x00050041,0x000001bb, +0x00002cc2,0x000001b9,0x0000034a,0x0004003d, +0x00000006,0x00002cc3,0x00002cc2,0x00050084, +0x00000006,0x00002cc5,0x00000342,0x000012dd, +0x00050080,0x00000006,0x00002cc6,0x00002cc3, +0x00002cc5,0x000200f9,0x00002cc7,0x000200f8, +0x00002cc7,0x000700f5,0x00000006,0x00005e6f, +0x00000138,0x00002cac,0x00002cd8,0x00002ccb, +0x000500b0,0x0000002f,0x00002cca,0x00005e6f, +0x000001d4,0x000400f6,0x00002cd9,0x00002ccb, +0x00000000,0x000400fa,0x00002cca,0x00002ccb, +0x00002cd9,0x000200f8,0x00002ccb,0x00050084, +0x00000006,0x00002cce,0x000000ec,0x00005e6f, +0x00050080,0x00000006,0x00002ccf,0x00002cc6, +0x00002cce,0x00050041,0x00000266,0x00002cd1, +0x000001b9,0x0000016b,0x0004003d,0x00000007, +0x00002cd2,0x00002cd1,0x00050041,0x00000028, +0x00002cd3,0x00002c30,0x00005e6f,0x0004003d, +0x00000027,0x00002cd4,0x00002cd3,0x0004007c, +0x00000006,0x00002f02,0x00002cd4,0x00050051, +0x00000006,0x00002f1b,0x00002cd2,0x00000000, +0x00050095,0x0000013d,0x00002f1d,0x00002f1b, +0x00002ccf,0x00050051,0x00000006,0x00002f1e, +0x00002f1d,0x00000001,0x00050051,0x00000006, +0x00002f1f,0x00002f1d,0x00000000,0x00050051, +0x00000006,0x00002f22,0x00002cd2,0x00000001, +0x00050080,0x00000006,0x00002f24,0x00002f22, +0x00002f1e,0x00050050,0x00000007,0x00002f25, +0x00002f1f,0x00002f24,0x0004007c,0x00000014, +0x00002f15,0x00002f25,0x00060041,0x0000016c, +0x00002f0d,0x00002f15,0x0000016b,0x0000016b, +0x0005003e,0x00002f0d,0x00002f02,0x00000002, +0x00000004,0x00050080,0x00000006,0x00002cd8, +0x00005e6f,0x00000264,0x000200f9,0x00002cc7, +0x000200f8,0x00002cd9,0x00050080,0x00000006, +0x00002cdb,0x00002cc6,0x00000521,0x00050041, +0x00000266,0x00002cdc,0x000001b9,0x0000016b, +0x0004003d,0x00000007,0x00002cdd,0x00002cdc, +0x00050051,0x00000006,0x00002f3b,0x00002cdd, +0x00000000,0x00050095,0x0000013d,0x00002f3d, +0x00002f3b,0x00002cdb,0x00050051,0x00000006, +0x00002f3e,0x00002f3d,0x00000001,0x00050051, +0x00000006,0x00002f3f,0x00002f3d,0x00000000, +0x00050051,0x00000006,0x00002f42,0x00002cdd, +0x00000001,0x00050080,0x00000006,0x00002f44, +0x00002f42,0x00002f3e,0x00050050,0x00000007, +0x00002f45,0x00002f3f,0x00002f44,0x0004007c, +0x00000014,0x00002f35,0x00002f45,0x00060041, +0x0000016c,0x00002f2d,0x00002f35,0x0000016b, +0x0000016b,0x0005003e,0x00002f2d,0x00002e81, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00002d09,0x00002bbe,0x00000721,0x00050080, -0x00000006,0x00002d0c,0x00002d09,0x00002cf5, -0x00060041,0x00000028,0x00002d10,0x00002b6d, -0x000002dc,0x00005ab9,0x0004003d,0x00000027, -0x00002d11,0x00002d10,0x0004007c,0x00000006, -0x00003007,0x00002d11,0x00050095,0x00000130, -0x00003022,0x00002e27,0x00002d0c,0x00050051, -0x00000006,0x00003023,0x00003022,0x00000001, -0x00050051,0x00000006,0x00003024,0x00003022, -0x00000000,0x00050080,0x00000006,0x00003029, -0x00002e2e,0x00003023,0x00050050,0x00000007, -0x0000302a,0x00003024,0x00003029,0x0004007c, -0x00000014,0x0000301a,0x0000302a,0x00060041, -0x0000015f,0x00003012,0x0000301a,0x0000015e, -0x0000015e,0x0005003e,0x00003012,0x00003007, +0x00002ce1,0x00002cc6,0x0000052d,0x00050095, +0x0000013d,0x00002f5d,0x00002f3b,0x00002ce1, +0x00050051,0x00000006,0x00002f5e,0x00002f5d, +0x00000001,0x00050051,0x00000006,0x00002f5f, +0x00002f5d,0x00000000,0x00050080,0x00000006, +0x00002f64,0x00002f42,0x00002f5e,0x00050050, +0x00000007,0x00002f65,0x00002f5f,0x00002f64, +0x0004007c,0x00000014,0x00002f55,0x00002f65, +0x00060041,0x0000016c,0x00002f4d,0x00002f55, +0x0000016b,0x0000016b,0x0005003e,0x00002f4d, +0x00002ea2,0x00000002,0x00000004,0x000500aa, +0x0000002f,0x00002f6a,0x00002ec3,0x00000138, +0x000300f7,0x00002f6f,0x00000000,0x000400fa, +0x00002f6a,0x00002f6b,0x00002f6f,0x000200f8, +0x00002f6b,0x000500aa,0x0000002f,0x00002f6e, +0x00002ee4,0x00000138,0x000200f9,0x00002f6f, +0x000200f8,0x00002f6f,0x000700f5,0x0000002f, +0x00002f70,0x00002f6a,0x00002cd9,0x00002f6e, +0x00002f6b,0x000400a8,0x0000002f,0x00002ceb, +0x00002f70,0x000300f7,0x00002cf0,0x00000000, +0x000400fa,0x00002ceb,0x00002cec,0x00002cf0, +0x000200f8,0x00002cec,0x000300f7,0x00003024, +0x00000000,0x000300fb,0x00000138,0x00002fa0, +0x000200f8,0x00002fa0,0x00050041,0x000001bb, +0x00002fa2,0x000001b9,0x00000334,0x0004003d, +0x00000006,0x00002fa3,0x00002fa2,0x000500c7, +0x00000006,0x00002fa4,0x00002fa3,0x000001cd, +0x000500aa,0x0000002f,0x00002fa5,0x00002fa4, +0x00000138,0x000300f7,0x00002fa7,0x00000000, +0x000400fa,0x00002fa5,0x00002fa6,0x00002fa7, +0x000200f8,0x00002fa6,0x000200f9,0x00003024, +0x000200f8,0x00002fa7,0x00050041,0x000001bb, +0x00002fa8,0x000001b9,0x000003b6,0x0004003d, +0x00000006,0x00002fa9,0x00002fa8,0x000200f9, +0x00002faa,0x000200f8,0x00002faa,0x000700f5, +0x00000006,0x00005e71,0x00002fa9,0x00002fa7, +0x00006119,0x00002fc9,0x000700f5,0x00000006, +0x00005e70,0x00000138,0x00002fa7,0x000060d9, +0x00002fc9,0x000500b0,0x0000002f,0x00002fae, +0x00005e70,0x00005e71,0x000400f6,0x00002fca, +0x00002fc9,0x00000000,0x000400fa,0x00002fae, +0x00002faf,0x00002fca,0x000200f8,0x00002faf, +0x00050080,0x00000006,0x00002fb2,0x00005e70, +0x00005e71,0x000500c2,0x00000006,0x00002fb3, +0x00002fb2,0x00000142,0x00050084,0x00000006, +0x00002fb5,0x000001ef,0x00002fb3,0x00050041, +0x00000266,0x00002fb6,0x000001b9,0x0000031d, +0x0004003d,0x00000007,0x00002fb7,0x00002fb6, +0x00050051,0x00000006,0x0000303c,0x00002fb7, +0x00000000,0x00050095,0x0000013d,0x0000303e, +0x0000303c,0x00002fb5,0x00050051,0x00000006, +0x0000303f,0x0000303e,0x00000001,0x00050051, +0x00000006,0x00003040,0x0000303e,0x00000000, +0x00050051,0x00000006,0x00003043,0x00002fb7, +0x00000001,0x00050080,0x00000006,0x00003045, +0x00003043,0x0000303f,0x00050050,0x00000007, +0x00003046,0x00003040,0x00003045,0x0004007c, +0x00000014,0x00003036,0x00003046,0x00060041, +0x0000016c,0x0000302d,0x00003036,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000302e, +0x0000302d,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002fbb,0x00002fb5,0x000000ec, +0x00050095,0x0000013d,0x0000305f,0x0000303c, +0x00002fbb,0x00050051,0x00000006,0x00003060, +0x0000305f,0x00000001,0x00050051,0x00000006, +0x00003061,0x0000305f,0x00000000,0x00050080, +0x00000006,0x00003066,0x00003043,0x00003060, +0x00050050,0x00000007,0x00003067,0x00003061, +0x00003066,0x0004007c,0x00000014,0x00003057, +0x00003067,0x00060041,0x0000016c,0x0000304e, +0x00003057,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x0000304f,0x0000304e,0x00000002, +0x00000004,0x000500b0,0x0000002f,0x0000306e, +0x00002ee4,0x0000304f,0x000400a8,0x0000002f, +0x0000306f,0x0000306e,0x000300f7,0x0000307e, +0x00000000,0x000400fa,0x0000306f,0x00003070, +0x0000307e,0x000200f8,0x00003070,0x000500aa, +0x0000002f,0x00003075,0x00002ee4,0x0000304f, +0x000300f7,0x0000307c,0x00000000,0x000400fa, +0x00003075,0x00003076,0x0000307c,0x000200f8, +0x00003076,0x000500b0,0x0000002f,0x0000307b, +0x00002ec3,0x0000302e,0x000200f9,0x0000307c, +0x000200f8,0x0000307c,0x000700f5,0x0000002f, +0x0000307d,0x00003075,0x00003070,0x0000307b, +0x00003076,0x000200f9,0x0000307e,0x000200f8, +0x0000307e,0x000700f5,0x0000002f,0x0000307f, +0x0000306e,0x00002faf,0x0000307d,0x0000307c, +0x000300f7,0x00002fc8,0x00000000,0x000400fa, +0x0000307f,0x00002fc3,0x00002fc5,0x000200f8, +0x00002fc5,0x00050080,0x00000006,0x00002fc7, +0x00002fb3,0x00000142,0x000200f9,0x00002fc8, +0x000200f8,0x00002fc3,0x000200f9,0x00002fc8, +0x000200f8,0x00002fc8,0x000700f5,0x00000006, +0x000060d9,0x00005e70,0x00002fc3,0x00002fc7, +0x00002fc5,0x000600a9,0x00000006,0x00006119, +0x0000307f,0x00002fb3,0x00005e71,0x000200f9, +0x00002fc9,0x000200f8,0x00002fc9,0x000200f9, +0x00002faa,0x000200f8,0x00002fca,0x00050095, +0x0000013d,0x00003087,0x00002ec3,0x000001c4, +0x00050051,0x00000006,0x00003088,0x00003087, +0x00000001,0x00050051,0x00000006,0x00003089, +0x00003087,0x00000000,0x00050080,0x00000006, +0x0000308e,0x00002ee4,0x00003088,0x000500b0, +0x0000002f,0x00003096,0x0000308e,0x00002ee4, +0x000400a8,0x0000002f,0x00003097,0x00003096, +0x000300f7,0x000030a6,0x00000000,0x000400fa, +0x00003097,0x00003098,0x000030a6,0x000200f8, +0x00003098,0x000500aa,0x0000002f,0x0000309d, +0x0000308e,0x00002ee4,0x000300f7,0x000030a4, +0x00000000,0x000400fa,0x0000309d,0x0000309e, +0x000030a4,0x000200f8,0x0000309e,0x000500b0, +0x0000002f,0x000030a3,0x00003089,0x00002ec3, +0x000200f9,0x000030a4,0x000200f8,0x000030a4, +0x000700f5,0x0000002f,0x000030a5,0x0000309d, +0x00003098,0x000030a3,0x0000309e,0x000200f9, +0x000030a6,0x000200f8,0x000030a6,0x000700f5, +0x0000002f,0x000030a7,0x00003096,0x00002fca, +0x000030a5,0x000030a4,0x000300f7,0x00002fd1, +0x00000000,0x000400fa,0x000030a7,0x00002fd0, +0x00002fd1,0x000200f8,0x00002fd0,0x000200f9, +0x00003024,0x000200f8,0x00002fd1,0x000500ac, +0x0000002f,0x00002fd3,0x00005e70,0x00000138, +0x000300f7,0x00003007,0x00000000,0x000400fa, +0x00002fd3,0x00002fd4,0x00003007,0x000200f8, +0x00002fd4,0x00050082,0x00000006,0x00002fd6, +0x00005e70,0x00000142,0x00050084,0x00000006, +0x00002fd7,0x000001ef,0x00002fd6,0x00050080, +0x00000006,0x00002fd9,0x00002fd7,0x000001cd, +0x00050041,0x00000266,0x00002fda,0x000001b9, +0x0000031d,0x0004003d,0x00000007,0x00002fdb, +0x00002fda,0x00050051,0x00000006,0x000030be, +0x00002fdb,0x00000000,0x00050095,0x0000013d, +0x000030c0,0x000030be,0x00002fd9,0x00050051, +0x00000006,0x000030c1,0x000030c0,0x00000001, +0x00050051,0x00000006,0x000030c2,0x000030c0, +0x00000000,0x00050051,0x00000006,0x000030c5, +0x00002fdb,0x00000001,0x00050080,0x00000006, +0x000030c7,0x000030c5,0x000030c1,0x00050050, +0x00000007,0x000030c8,0x000030c2,0x000030c7, +0x0004007c,0x00000014,0x000030b8,0x000030c8, +0x00060041,0x0000016c,0x000030af,0x000030b8, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000030b0,0x000030af,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002fde,0x00002fd7, +0x000001d4,0x00050095,0x0000013d,0x000030e1, +0x000030be,0x00002fde,0x00050051,0x00000006, +0x000030e2,0x000030e1,0x00000001,0x00050051, +0x00000006,0x000030e3,0x000030e1,0x00000000, +0x00050080,0x00000006,0x000030e8,0x000030c5, +0x000030e2,0x00050050,0x00000007,0x000030e9, +0x000030e3,0x000030e8,0x0004007c,0x00000014, +0x000030d9,0x000030e9,0x00060041,0x0000016c, +0x000030d0,0x000030d9,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x000030d1,0x000030d0, +0x00000002,0x00000004,0x000500b0,0x0000002f, +0x000030f0,0x00002ee4,0x000030d1,0x000400a8, +0x0000002f,0x000030f1,0x000030f0,0x000300f7, +0x00003100,0x00000000,0x000400fa,0x000030f1, +0x000030f2,0x00003100,0x000200f8,0x000030f2, +0x000500aa,0x0000002f,0x000030f7,0x00002ee4, +0x000030d1,0x000300f7,0x000030fe,0x00000000, +0x000400fa,0x000030f7,0x000030f8,0x000030fe, +0x000200f8,0x000030f8,0x000500b0,0x0000002f, +0x000030fd,0x00002ec3,0x000030b0,0x000200f9, +0x000030fe,0x000200f8,0x000030fe,0x000700f5, +0x0000002f,0x000030ff,0x000030f7,0x000030f2, +0x000030fd,0x000030f8,0x000200f9,0x00003100, +0x000200f8,0x00003100,0x000700f5,0x0000002f, +0x00003101,0x000030f0,0x00002fd4,0x000030ff, +0x000030fe,0x000300f7,0x00003006,0x00000000, +0x000400fa,0x00003101,0x00002fe6,0x00003006, +0x000200f8,0x00002fe6,0x000500b0,0x0000002f, +0x00003108,0x000030d1,0x0000308e,0x000400a8, +0x0000002f,0x00003109,0x00003108,0x000300f7, +0x00003118,0x00000000,0x000400fa,0x00003109, +0x0000310a,0x00003118,0x000200f8,0x0000310a, +0x000500aa,0x0000002f,0x0000310f,0x000030d1, +0x0000308e,0x000300f7,0x00003116,0x00000000, +0x000400fa,0x0000310f,0x00003110,0x00003116, +0x000200f8,0x00003110,0x000500b0,0x0000002f, +0x00003115,0x000030b0,0x00003089,0x000200f9, +0x00003116,0x000200f8,0x00003116,0x000700f5, +0x0000002f,0x00003117,0x0000310f,0x0000310a, +0x00003115,0x00003110,0x000200f9,0x00003118, +0x000200f8,0x00003118,0x000700f5,0x0000002f, +0x00003119,0x00003108,0x00002fe6,0x00003117, +0x00003116,0x000300f7,0x00002feb,0x00000000, +0x000400fa,0x00003119,0x00002fea,0x00002feb, +0x000200f8,0x00002fea,0x000200f9,0x00003024, +0x000200f8,0x00002feb,0x00050095,0x0000013d, +0x00003132,0x000030be,0x00002fd7,0x00050051, +0x00000006,0x00003133,0x00003132,0x00000001, +0x00050051,0x00000006,0x00003134,0x00003132, +0x00000000,0x00050080,0x00000006,0x00003139, +0x000030c5,0x00003133,0x00050050,0x00000007, +0x0000313a,0x00003134,0x00003139,0x0004007c, +0x00000014,0x0000312a,0x0000313a,0x00060041, +0x0000016c,0x00003121,0x0000312a,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003122, +0x00003121,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002ff1,0x00002fd7,0x000000ec, +0x00050095,0x0000013d,0x00003153,0x000030be, +0x00002ff1,0x00050051,0x00000006,0x00003154, +0x00003153,0x00000001,0x00050051,0x00000006, +0x00003155,0x00003153,0x00000000,0x00050080, +0x00000006,0x0000315a,0x000030c5,0x00003154, +0x00050050,0x00000007,0x0000315b,0x00003155, +0x0000315a,0x0004007c,0x00000014,0x0000314b, +0x0000315b,0x00060041,0x0000016c,0x00003142, +0x0000314b,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003143,0x00003142,0x00000002, +0x00000004,0x00050080,0x00000006,0x00002ff7, +0x00002fd7,0x000001db,0x00050095,0x0000013d, +0x00003174,0x000030be,0x00002ff7,0x00050051, +0x00000006,0x00003175,0x00003174,0x00000001, +0x00050051,0x00000006,0x00003176,0x00003174, +0x00000000,0x00050080,0x00000006,0x0000317b, +0x000030c5,0x00003175,0x00050050,0x00000007, +0x0000317c,0x00003176,0x0000317b,0x0004007c, +0x00000014,0x0000316c,0x0000317c,0x00060041, +0x0000016c,0x00003163,0x0000316c,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003164, +0x00003163,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002ffc,0x00002fd7,0x00000299, +0x00050095,0x0000013d,0x00003195,0x000030be, +0x00002ffc,0x00050051,0x00000006,0x00003196, +0x00003195,0x00000001,0x00050051,0x00000006, +0x00003197,0x00003195,0x00000000,0x00050080, +0x00000006,0x0000319c,0x000030c5,0x00003196, +0x00050050,0x00000007,0x0000319d,0x00003197, +0x0000319c,0x0004007c,0x00000014,0x0000318d, +0x0000319d,0x00060041,0x0000016c,0x00003184, +0x0000318d,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003185,0x00003184,0x00000002, +0x00000004,0x00050096,0x0000013d,0x000031a6, +0x00002ec3,0x00003122,0x00050051,0x00000006, +0x000031a7,0x000031a6,0x00000001,0x00050051, +0x00000006,0x000031a8,0x000031a6,0x00000000, +0x00050082,0x00000006,0x000031ae,0x00002ee4, +0x00003143,0x00050082,0x00000006,0x000031b0, +0x000031ae,0x000031a7,0x00050095,0x0000013d, +0x000031ba,0x00003164,0x000031a8,0x00050051, +0x00000006,0x000031bb,0x000031ba,0x00000001, +0x00050051,0x00000006,0x000031bc,0x000031ba, +0x00000000,0x00050080,0x00000006,0x000031c2, +0x00003185,0x000031b0,0x00050080,0x00000006, +0x000031c4,0x000031c2,0x000031bb,0x00050050, +0x00000007,0x000031c5,0x000031bc,0x000031c4, +0x000200f9,0x00003006,0x000200f8,0x00003006, +0x000700f5,0x00000007,0x00005e7e,0x00002cc1, +0x00003100,0x000031c5,0x00002feb,0x000200f9, +0x00003007,0x000200f8,0x00003007,0x000700f5, +0x00000007,0x00005e7a,0x00002cc1,0x00002fd1, +0x00005e7e,0x00003006,0x000700f5,0x0000002f, +0x00005e74,0x000003cc,0x00002fd1,0x00003101, +0x00003006,0x000400a8,0x0000002f,0x00003009, +0x00005e74,0x000300f7,0x0000300f,0x00000000, +0x000400fa,0x00003009,0x0000300a,0x0000300f, +0x000200f8,0x0000300a,0x00050041,0x00000266, +0x0000300b,0x000001b9,0x00000325,0x0004003d, +0x00000007,0x0000300c,0x0000300b,0x00050051, +0x00000006,0x000031c9,0x0000300c,0x00000000, +0x000500aa,0x0000002f,0x000031ca,0x000031c9, +0x00000138,0x000300f7,0x000031cf,0x00000000, +0x000400fa,0x000031ca,0x000031cb,0x000031cf, +0x000200f8,0x000031cb,0x00050051,0x00000006, +0x000031cd,0x0000300c,0x00000001,0x000500aa, +0x0000002f,0x000031ce,0x000031cd,0x00000138, +0x000200f9,0x000031cf,0x000200f8,0x000031cf, +0x000700f5,0x0000002f,0x000031d0,0x000031ca, +0x0000300a,0x000031ce,0x000031cb,0x000400a8, +0x0000002f,0x0000300e,0x000031d0,0x000200f9, +0x0000300f,0x000200f8,0x0000300f,0x000700f5, +0x0000002f,0x00003010,0x00003009,0x00003007, +0x0000300e,0x000031cf,0x000300f7,0x00003016, +0x00000000,0x000400fa,0x00003010,0x00003011, +0x00003016,0x000200f8,0x00003011,0x00050041, +0x00000266,0x00003012,0x000001b9,0x00000325, +0x0004003d,0x00000007,0x00003013,0x00003012, +0x00050051,0x00000006,0x000031d4,0x00003013, +0x00000001,0x000500b0,0x0000002f,0x000031d7, +0x000031d4,0x0000308e,0x000400a8,0x0000002f, +0x000031d8,0x000031d7,0x000300f7,0x000031e7, +0x00000000,0x000400fa,0x000031d8,0x000031d9, +0x000031e7,0x000200f8,0x000031d9,0x000500aa, +0x0000002f,0x000031de,0x000031d4,0x0000308e, +0x000300f7,0x000031e5,0x00000000,0x000400fa, +0x000031de,0x000031df,0x000031e5,0x000200f8, +0x000031df,0x00050051,0x00000006,0x000031e1, +0x00003013,0x00000000,0x000500b0,0x0000002f, +0x000031e4,0x000031e1,0x00003089,0x000200f9, +0x000031e5,0x000200f8,0x000031e5,0x000700f5, +0x0000002f,0x000031e6,0x000031de,0x000031d9, +0x000031e4,0x000031df,0x000200f9,0x000031e7, +0x000200f8,0x000031e7,0x000700f5,0x0000002f, +0x000031e8,0x000031d7,0x00003011,0x000031e6, +0x000031e5,0x000200f9,0x00003016,0x000200f8, +0x00003016,0x000700f5,0x0000002f,0x00003017, +0x00003010,0x0000300f,0x000031e8,0x000031e7, +0x000300f7,0x00003019,0x00000000,0x000400fa, +0x00003017,0x00003018,0x00003019,0x000200f8, +0x00003018,0x000200f9,0x00003024,0x000200f8, +0x00003019,0x00050051,0x00000006,0x0000301b, +0x00005e7a,0x00000000,0x000500c7,0x00000006, +0x0000301c,0x0000301b,0x0000062f,0x000500aa, +0x0000002f,0x0000301d,0x0000301c,0x00000138, +0x000300f7,0x00003022,0x00000000,0x000400fa, +0x0000301d,0x0000301e,0x00003022,0x000200f8, +0x0000301e,0x00050051,0x00000006,0x00003020, +0x00005e7a,0x00000001,0x000500b0,0x0000002f, +0x00003021,0x00003020,0x000001be,0x000200f9, +0x00003022,0x000200f8,0x00003022,0x000700f5, +0x0000002f,0x00003023,0x0000301d,0x00003019, +0x00003021,0x0000301e,0x000200f9,0x00003024, +0x000200f8,0x00003024,0x000d00f5,0x00000007, +0x00005e85,0x00002cc1,0x00002fa6,0x00002cc1, +0x00002fd0,0x00002cc1,0x00002fea,0x00005e7a, +0x00003018,0x00005e7a,0x00003022,0x000d00f5, +0x0000002f,0x00005e84,0x000003e7,0x00002fa6, +0x000003cc,0x00002fd0,0x000003cc,0x00002fea, +0x000003cc,0x00003018,0x00003023,0x00003022, +0x000200f9,0x00002cf0,0x000200f8,0x00002cf0, +0x000700f5,0x00000007,0x00005e89,0x00002cc1, +0x00002f6f,0x00005e85,0x00003024,0x000700f5, +0x0000002f,0x00002cf1,0x00002ceb,0x00002f6f, +0x00005e84,0x00003024,0x000300f7,0x00002d88, +0x00000000,0x000400fa,0x00002cf1,0x00002cf3, +0x00002d88,0x000200f8,0x00002cf3,0x00050041, +0x00000266,0x00002cf5,0x000001b9,0x0000032d, +0x0004003d,0x00000007,0x00002cf6,0x00002cf5, +0x00050051,0x00000006,0x000031ee,0x00005e89, +0x00000000,0x00050051,0x00000006,0x000031f0, +0x00002cf6,0x00000000,0x00050095,0x0000013d, +0x000031f1,0x000031ee,0x000031f0,0x00050051, +0x00000006,0x000031f2,0x000031f1,0x00000001, +0x00050051,0x00000006,0x000031f3,0x000031f1, +0x00000000,0x00050051,0x00000006,0x000031f6, +0x00005e89,0x00000001,0x00050051,0x00000006, +0x000031f8,0x00002cf6,0x00000001,0x00050080, +0x00000006,0x000031f9,0x000031f6,0x000031f8, +0x00050080,0x00000006,0x000031fb,0x000031f9, +0x000031f2,0x00050095,0x0000013d,0x00003215, +0x000031f3,0x00000521,0x00050051,0x00000006, +0x00003216,0x00003215,0x00000001,0x00050051, +0x00000006,0x00003217,0x00003215,0x00000000, +0x00050080,0x00000006,0x0000321c,0x000031fb, +0x00003216,0x00050050,0x00000007,0x0000321d, +0x00003217,0x0000321c,0x0004007c,0x00000014, +0x0000320d,0x0000321d,0x00060041,0x0000016c, +0x00003204,0x0000320d,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003205,0x00003204, +0x00000002,0x00000004,0x00050095,0x0000013d, +0x00003236,0x000031f3,0x000001db,0x00050051, +0x00000006,0x00003237,0x00003236,0x00000001, +0x00050051,0x00000006,0x00003238,0x00003236, +0x00000000,0x00050080,0x00000006,0x0000323d, +0x000031fb,0x00003237,0x00050050,0x00000007, +0x0000323e,0x00003238,0x0000323d,0x0004007c, +0x00000014,0x0000322e,0x0000323e,0x00060041, +0x0000016c,0x00003225,0x0000322e,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00003226, +0x00003225,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00002cfc,0x00003226,0x00050095, +0x0000013d,0x00003257,0x000031f3,0x00000299, +0x00050051,0x00000006,0x00003258,0x00003257, +0x00000001,0x00050051,0x00000006,0x00003259, +0x00003257,0x00000000,0x00050080,0x00000006, +0x0000325e,0x000031fb,0x00003258,0x00050050, +0x00000007,0x0000325f,0x00003259,0x0000325e, +0x0004007c,0x00000014,0x0000324f,0x0000325f, +0x00060041,0x0000016c,0x00003246,0x0000324f, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x00003247,0x00003246,0x00000002,0x00000004, +0x0004007c,0x00000027,0x00002cff,0x00003247, +0x00050095,0x0000013d,0x00003278,0x000031f3, +0x000001ef,0x00050051,0x00000006,0x00003279, +0x00003278,0x00000001,0x00050051,0x00000006, +0x0000327a,0x00003278,0x00000000,0x00050080, +0x00000006,0x0000327f,0x000031fb,0x00003279, +0x00050050,0x00000007,0x00003280,0x0000327a, +0x0000327f,0x0004007c,0x00000014,0x00003270, +0x00003280,0x00060041,0x0000016c,0x00003267, +0x00003270,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00003268,0x00003267,0x00000002, +0x00000004,0x0004007c,0x00000027,0x00002d02, +0x00003268,0x00050095,0x0000013d,0x00003299, +0x000031f3,0x000006d9,0x00050051,0x00000006, +0x0000329a,0x00003299,0x00000001,0x00050051, +0x00000006,0x0000329b,0x00003299,0x00000000, +0x00050080,0x00000006,0x000032a0,0x000031fb, +0x0000329a,0x00050050,0x00000007,0x000032a1, +0x0000329b,0x000032a0,0x0004007c,0x00000014, +0x00003291,0x000032a1,0x00060041,0x0000016c, +0x00003288,0x00003291,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x00003289,0x00003288, +0x00000002,0x00000004,0x0004007c,0x00000027, +0x00002d06,0x00003289,0x00050095,0x0000013d, +0x000032ba,0x000031f3,0x00000205,0x00050051, +0x00000006,0x000032bb,0x000032ba,0x00000001, +0x00050051,0x00000006,0x000032bc,0x000032ba, +0x00000000,0x00050080,0x00000006,0x000032c1, +0x000031fb,0x000032bb,0x00050050,0x00000007, +0x000032c2,0x000032bc,0x000032c1,0x0004007c, +0x00000014,0x000032b2,0x000032c2,0x00060041, +0x0000016c,0x000032a9,0x000032b2,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000032aa, +0x000032a9,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00002d09,0x000032aa,0x00050095, +0x0000013d,0x000032db,0x000031f3,0x00000500, +0x00050051,0x00000006,0x000032dc,0x000032db, +0x00000001,0x00050051,0x00000006,0x000032dd, +0x000032db,0x00000000,0x00050080,0x00000006, +0x000032e2,0x000031fb,0x000032dc,0x00050050, +0x00000007,0x000032e3,0x000032dd,0x000032e2, +0x0004007c,0x00000014,0x000032d3,0x000032e3, +0x00060041,0x0000016c,0x000032ca,0x000032d3, +0x0000016b,0x0000016b,0x0006003d,0x00000006, +0x000032cb,0x000032ca,0x00000002,0x00000004, +0x0004007c,0x00000027,0x00002d0c,0x000032cb, +0x000500bc,0x0000002f,0x000032ea,0x00002cfc, +0x00002d06,0x000300f7,0x000032f1,0x00000000, +0x000400fa,0x000032ea,0x000032eb,0x000032f1, +0x000200f8,0x000032eb,0x000500bc,0x0000002f, +0x000032f0,0x00002cff,0x00002d09,0x000200f9, +0x000032f1,0x000200f8,0x000032f1,0x000700f5, +0x0000002f,0x000032f2,0x000032ea,0x00002cf3, +0x000032f0,0x000032eb,0x000300f7,0x000032f9, +0x00000000,0x000400fa,0x000032f2,0x000032f3, +0x000032f9,0x000200f8,0x000032f3,0x000500bc, +0x0000002f,0x000032f8,0x00002d02,0x00002d0c, +0x000200f9,0x000032f9,0x000200f8,0x000032f9, +0x000700f5,0x0000002f,0x000032fa,0x000032f2, +0x000032f1,0x000032f8,0x000032f3,0x000300f7, +0x00002d16,0x00000000,0x000400fa,0x000032fa, +0x00002d12,0x00002d16,0x000200f8,0x00002d12, +0x000500c2,0x00000006,0x00002d14,0x00002e81, +0x000006f3,0x000500ab,0x0000002f,0x00002d15, +0x00002d14,0x00000138,0x000200f9,0x00002d16, +0x000200f8,0x00002d16,0x000700f5,0x0000002f, +0x00002d17,0x000032fa,0x000032f9,0x00002d15, +0x00002d12,0x000300f7,0x00002d87,0x00000000, +0x000400fa,0x00002d17,0x00002d18,0x00002d87, +0x000200f8,0x00002d18,0x000200f9,0x00002d19, +0x000200f8,0x00002d19,0x000700f5,0x0000006c, +0x00005f0d,0x000060fe,0x00002d18,0x00002d82, +0x00002d1d,0x000700f5,0x0000006c,0x00005ee6, +0x00000576,0x00002d18,0x00002d7f,0x00002d1d, +0x000700f5,0x00000006,0x00005e8b,0x00000138, +0x00002d18,0x00002d85,0x00002d1d,0x000500b0, +0x0000002f,0x00002d1c,0x00005e8b,0x000001cd, +0x000400f6,0x00002d86,0x00002d1d,0x00000000, +0x000400fa,0x00002d1c,0x00002d1d,0x00002d86, +0x000200f8,0x00002d1d,0x000500c7,0x00000006, +0x00002d1f,0x00005e8b,0x00000142,0x000500ab, +0x0000002f,0x00002d20,0x00002d1f,0x00000138, +0x000600a9,0x00000027,0x0000611b,0x00002d20, +0x00002d06,0x00002cfc,0x000500c7,0x00000006, +0x00002d2a,0x00005e8b,0x00000280,0x000500ab, +0x0000002f,0x00002d2b,0x00002d2a,0x00000138, +0x000600a9,0x00000027,0x0000611c,0x00002d2b, +0x00002d09,0x00002cff,0x000500c7,0x00000006, +0x00002d35,0x00005e8b,0x000000ec,0x000500ab, +0x0000002f,0x00002d36,0x00002d35,0x00000138, +0x000600a9,0x00000027,0x0000611d,0x00002d36, +0x00002d0c,0x00002d02,0x00050041,0x00000028, +0x00002d40,0x00002c30,0x0000016b,0x0004003d, +0x00000027,0x00002d41,0x00002d40,0x00050085, +0x00000027,0x00002d44,0x00002d41,0x0000611b, +0x00050041,0x00000028,0x00002d45,0x00002c30, +0x00000264,0x0004003d,0x00000027,0x00002d46, +0x00002d45,0x00050085,0x00000027,0x00002d49, +0x00002d46,0x0000611c,0x00050081,0x00000027, +0x00002d4a,0x00002d44,0x00002d49,0x00050041, +0x00000028,0x00002d4b,0x00002c30,0x00000315, +0x0004003d,0x00000027,0x00002d4c,0x00002d4b, +0x00050085,0x00000027,0x00002d4f,0x00002d4c, +0x0000611d,0x00050081,0x00000027,0x00002d50, +0x00002d4a,0x00002d4f,0x00050041,0x00000028, +0x00002d51,0x00002c30,0x0000031d,0x0004003d, +0x00000027,0x00002d52,0x00002d51,0x00050081, +0x00000027,0x00002d53,0x00002d50,0x00002d52, +0x00050041,0x00000028,0x00002d54,0x00002c30, +0x00000325,0x0004003d,0x00000027,0x00002d55, +0x00002d54,0x00050085,0x00000027,0x00002d58, +0x00002d55,0x0000611b,0x00050041,0x00000028, +0x00002d59,0x00002c30,0x0000032d,0x0004003d, +0x00000027,0x00002d5a,0x00002d59,0x00050085, +0x00000027,0x00002d5d,0x00002d5a,0x0000611c, +0x00050081,0x00000027,0x00002d5e,0x00002d58, +0x00002d5d,0x00050041,0x00000028,0x00002d5f, +0x00002c30,0x00000351,0x0004003d,0x00000027, +0x00002d60,0x00002d5f,0x00050085,0x00000027, +0x00002d63,0x00002d60,0x0000611d,0x00050081, +0x00000027,0x00002d64,0x00002d5e,0x00002d63, +0x00050041,0x00000028,0x00002d65,0x00002c30, +0x0000074d,0x0004003d,0x00000027,0x00002d66, +0x00002d65,0x00050081,0x00000027,0x00002d67, +0x00002d64,0x00002d66,0x00050041,0x00000028, +0x00002d68,0x00002c30,0x000004c1,0x0004003d, +0x00000027,0x00002d69,0x00002d68,0x00050085, +0x00000027,0x00002d6c,0x00002d69,0x0000611b, +0x00050041,0x00000028,0x00002d6d,0x00002c30, +0x00000206,0x0004003d,0x00000027,0x00002d6e, +0x00002d6d,0x00050085,0x00000027,0x00002d71, +0x00002d6e,0x0000611c,0x00050081,0x00000027, +0x00002d72,0x00002d6c,0x00002d71,0x00050041, +0x00000028,0x00002d73,0x00002c30,0x000003b6, +0x0004003d,0x00000027,0x00002d74,0x00002d73, +0x00050085,0x00000027,0x00002d77,0x00002d74, +0x0000611d,0x00050081,0x00000027,0x00002d78, +0x00002d72,0x00002d77,0x00050041,0x00000028, +0x00002d79,0x00002c30,0x00000434,0x0004003d, +0x00000027,0x00002d7a,0x00002d79,0x00050081, +0x00000027,0x00002d7b,0x00002d78,0x00002d7a, +0x00060050,0x0000006c,0x00002d7c,0x00002d53, +0x00002d67,0x00002d7b,0x0007000c,0x0000006c, +0x00002d7f,0x00000001,0x00000025,0x00005ee6, +0x00002d7c,0x0007000c,0x0000006c,0x00002d82, +0x00000001,0x00000028,0x00005f0d,0x00002d7c, +0x00050080,0x00000006,0x00002d85,0x00005e8b, +0x00000264,0x000200f9,0x00002d19,0x000200f8, +0x00002d86,0x000200f9,0x00002d87,0x000200f8, +0x00002d87,0x000700f5,0x0000006c,0x00005f09, +0x000060fe,0x00002d16,0x00005f0d,0x00002d86, +0x000700f5,0x0000006c,0x00005ee2,0x00000576, +0x00002d16,0x00005ee6,0x00002d86,0x000200f9, +0x00002d88,0x000200f8,0x00002d88,0x000700f5, +0x0000006c,0x00005ef3,0x000060fe,0x00002cf0, +0x00005f09,0x00002d87,0x000700f5,0x0000006c, +0x00005ecc,0x00000576,0x00002cf0,0x00005ee2, +0x00002d87,0x000700f5,0x00000006,0x00005e94, +0x00000539,0x00002cf0,0x00003205,0x00002d87, +0x00050041,0x00000028,0x00002d89,0x00002c30, +0x0000016b,0x0004003d,0x00000027,0x00002d8a, +0x00002d89,0x000500b4,0x0000002f,0x00002d8b, +0x00002d8a,0x00000771,0x000300f7,0x00002d90, +0x00000000,0x000400fa,0x00002d8b,0x00002d8c, +0x00002d90,0x000200f8,0x00002d8c,0x00050041, +0x00000028,0x00002d8d,0x00002c30,0x00000264, +0x0004003d,0x00000027,0x00002d8e,0x00002d8d, +0x000500b4,0x0000002f,0x00002d8f,0x00002d8e, +0x00000426,0x000200f9,0x00002d90,0x000200f8, +0x00002d90,0x000700f5,0x0000002f,0x00002d91, +0x00002d8b,0x00002d88,0x00002d8f,0x00002d8c, +0x000300f7,0x00002d96,0x00000000,0x000400fa, +0x00002d91,0x00002d92,0x00002d96,0x000200f8, +0x00002d92,0x00050041,0x00000028,0x00002d93, +0x00002c30,0x00000315,0x0004003d,0x00000027, +0x00002d94,0x00002d93,0x000500b4,0x0000002f, +0x00002d95,0x00002d94,0x00000426,0x000200f9, +0x00002d96,0x000200f8,0x00002d96,0x000700f5, +0x0000002f,0x00002d97,0x00002d91,0x00002d90, +0x00002d95,0x00002d92,0x000300f7,0x00002d9c, +0x00000000,0x000400fa,0x00002d97,0x00002d98, +0x00002d9c,0x000200f8,0x00002d98,0x00050041, +0x00000028,0x00002d99,0x00002c30,0x00000325, +0x0004003d,0x00000027,0x00002d9a,0x00002d99, +0x000500b4,0x0000002f,0x00002d9b,0x00002d9a, +0x00000426,0x000200f9,0x00002d9c,0x000200f8, +0x00002d9c,0x000700f5,0x0000002f,0x00002d9d, +0x00002d97,0x00002d96,0x00002d9b,0x00002d98, +0x000300f7,0x00002da2,0x00000000,0x000400fa, +0x00002d9d,0x00002d9e,0x00002da2,0x000200f8, +0x00002d9e,0x00050041,0x00000028,0x00002d9f, +0x00002c30,0x0000032d,0x0004003d,0x00000027, +0x00002da0,0x00002d9f,0x000500b4,0x0000002f, +0x00002da1,0x00002da0,0x00000771,0x000200f9, +0x00002da2,0x000200f8,0x00002da2,0x000700f5, +0x0000002f,0x00002da3,0x00002d9d,0x00002d9c, +0x00002da1,0x00002d9e,0x000300f7,0x00002da8, +0x00000000,0x000400fa,0x00002da3,0x00002da4, +0x00002da8,0x000200f8,0x00002da4,0x00050041, +0x00000028,0x00002da5,0x00002c30,0x00000351, +0x0004003d,0x00000027,0x00002da6,0x00002da5, +0x000500b4,0x0000002f,0x00002da7,0x00002da6, +0x00000426,0x000200f9,0x00002da8,0x000200f8, +0x00002da8,0x000700f5,0x0000002f,0x00002da9, +0x00002da3,0x00002da2,0x00002da7,0x00002da4, +0x000300f7,0x00002dae,0x00000000,0x000400fa, +0x00002da9,0x00002daa,0x00002dae,0x000200f8, +0x00002daa,0x00050041,0x00000028,0x00002dab, +0x00002c30,0x000004c1,0x0004003d,0x00000027, +0x00002dac,0x00002dab,0x000500b4,0x0000002f, +0x00002dad,0x00002dac,0x00000426,0x000200f9, +0x00002dae,0x000200f8,0x00002dae,0x000700f5, +0x0000002f,0x00002daf,0x00002da9,0x00002da8, +0x00002dad,0x00002daa,0x000300f7,0x00002db4, +0x00000000,0x000400fa,0x00002daf,0x00002db0, +0x00002db4,0x000200f8,0x00002db0,0x00050041, +0x00000028,0x00002db1,0x00002c30,0x00000206, +0x0004003d,0x00000027,0x00002db2,0x00002db1, +0x000500b4,0x0000002f,0x00002db3,0x00002db2, +0x00000426,0x000200f9,0x00002db4,0x000200f8, +0x00002db4,0x000700f5,0x0000002f,0x00002db5, +0x00002daf,0x00002dae,0x00002db3,0x00002db0, +0x000300f7,0x00002dba,0x00000000,0x000400fa, +0x00002db5,0x00002db6,0x00002dba,0x000200f8, +0x00002db6,0x00050041,0x00000028,0x00002db7, +0x00002c30,0x000003b6,0x0004003d,0x00000027, +0x00002db8,0x00002db7,0x000500b4,0x0000002f, +0x00002db9,0x00002db8,0x00000771,0x000200f9, +0x00002dba,0x000200f8,0x00002dba,0x000700f5, +0x0000002f,0x00002dbb,0x00002db5,0x00002db4, +0x00002db9,0x00002db6,0x00050080,0x00000006, +0x00002dbd,0x00002cc6,0x00000537,0x000500c7, +0x00000006,0x00002dbf,0x00005e94,0x000007a6, +0x000600a9,0x00000006,0x00002dc1,0x00002dbb, +0x00000241,0x00000138,0x000500c5,0x00000006, +0x00002dc2,0x00002dbf,0x00002dc1,0x00050095, +0x0000013d,0x00003313,0x00002f3b,0x00002dbd, +0x00050051,0x00000006,0x00003314,0x00003313, +0x00000001,0x00050051,0x00000006,0x00003315, +0x00003313,0x00000000,0x00050080,0x00000006, +0x0000331a,0x00002f42,0x00003314,0x00050050, +0x00000007,0x0000331b,0x00003315,0x0000331a, +0x0004007c,0x00000014,0x0000330b,0x0000331b, +0x00060041,0x0000016c,0x00003303,0x0000330b, +0x0000016b,0x0000016b,0x0005003e,0x00003303, +0x00002dc2,0x00000002,0x00000004,0x000400a8, +0x0000002f,0x00002dc7,0x00002cf1,0x00050050, +0x0000611e,0x0000611f,0x00002dc7,0x00002dc7, +0x000600a9,0x00000007,0x00006120,0x0000611f, +0x000007b5,0x00005e89,0x00050080,0x00000006, +0x00002dcb,0x00002cc6,0x00000541,0x00050051, +0x00000006,0x00002dcd,0x00006120,0x00000000, +0x000500c2,0x00000006,0x00002dce,0x00002dcd, +0x000004c1,0x00050051,0x00000006,0x00002dd0, +0x00006120,0x00000001,0x000500c4,0x00000006, +0x00002dd1,0x00002dd0,0x000006f3,0x000500c5, +0x00000006,0x00002dd2,0x00002dce,0x00002dd1, +0x00050095,0x0000013d,0x00003333,0x00002f3b, +0x00002dcb,0x00050051,0x00000006,0x00003334, +0x00003333,0x00000001,0x00050051,0x00000006, +0x00003335,0x00003333,0x00000000,0x00050080, +0x00000006,0x0000333a,0x00002f42,0x00003334, +0x00050050,0x00000007,0x0000333b,0x00003335, +0x0000333a,0x0004007c,0x00000014,0x0000332b, +0x0000333b,0x00060041,0x0000016c,0x00003323, +0x0000332b,0x0000016b,0x0000016b,0x0005003e, +0x00003323,0x00002dd2,0x00000002,0x00000004, +0x0004003d,0x00000027,0x00002dd7,0x00002d89, +0x00050041,0x00000028,0x00002dd8,0x00002c30, +0x00000325,0x0004003d,0x00000027,0x00002dd9, +0x00002dd8,0x00050041,0x00000028,0x00002dda, +0x00002c30,0x000004c1,0x0004003d,0x00000027, +0x00002ddb,0x00002dda,0x00050041,0x00000028, +0x00002ddc,0x00002c30,0x00000264,0x0004003d, +0x00000027,0x00002ddd,0x00002ddc,0x00050041, +0x00000028,0x00002dde,0x00002c30,0x0000032d, +0x0004003d,0x00000027,0x00002ddf,0x00002dde, +0x00050041,0x00000028,0x00002de0,0x00002c30, +0x00000206,0x0004003d,0x00000027,0x00002de1, +0x00002de0,0x00050041,0x00000028,0x00002de2, +0x00002c30,0x00000315,0x0004003d,0x00000027, +0x00002de3,0x00002de2,0x00050041,0x00000028, +0x00002de4,0x00002c30,0x00000351,0x0004003d, +0x00000027,0x00002de5,0x00002de4,0x00050041, +0x00000028,0x00002de6,0x00002c30,0x000003b6, +0x0004003d,0x00000027,0x00002de7,0x00002de6, +0x00060050,0x0000006c,0x00002de8,0x00002dd7, +0x00002dd9,0x00002ddb,0x00060050,0x0000006c, +0x00002de9,0x00002ddd,0x00002ddf,0x00002de1, +0x00060050,0x0000006c,0x00002dea,0x00002de3, +0x00002de5,0x00002de7,0x00060050,0x000007c5, +0x00002deb,0x00002de8,0x00002de9,0x00002dea, +0x0006000c,0x00000027,0x00002ded,0x00000001, +0x00000021,0x00002deb,0x000500b7,0x0000002f, +0x00002def,0x00002ded,0x00000426,0x000300f7, +0x00002df4,0x00000000,0x000400fa,0x00002def, +0x00002df0,0x00002df3,0x000200f8,0x00002df3, +0x000200f9,0x00002df4,0x000200f8,0x00002df0, +0x0006000c,0x000007c5,0x00002df2,0x00000001, +0x00000022,0x00002deb,0x000200f9,0x00002df4, +0x000200f8,0x00002df4,0x000700f5,0x000007c5, +0x00005ebe,0x00002df2,0x00002df0,0x000007eb, +0x00002df3,0x0003003e,0x00002c75,0x00005ebe, +0x00050041,0x00000028,0x00002df6,0x00002c30, +0x0000031d,0x0004003d,0x00000027,0x00002df7, +0x00002df6,0x00050041,0x00000028,0x00002df8, +0x00002c30,0x0000074d,0x0004003d,0x00000027, +0x00002df9,0x00002df8,0x00050041,0x00000028, +0x00002dfa,0x00002c30,0x00000434,0x0004003d, +0x00000027,0x00002dfb,0x00002dfa,0x00060050, +0x0000006c,0x00002dfc,0x00002df7,0x00002df9, +0x00002dfb,0x00050091,0x0000006c,0x00002dff, +0x00005ebe,0x00002dfc,0x0004007f,0x0000006c, +0x00002e00,0x00002dff,0x0003003e,0x00002c78, +0x00002e00,0x000200f9,0x00002e01,0x000200f8, +0x00002e01,0x000700f5,0x00000006,0x00005ebf, +0x00000138,0x00002df4,0x00002e34,0x00002e05, +0x000500b0,0x0000002f,0x00002e04,0x00005ebf, +0x00000470,0x000400f6,0x00002e35,0x00002e05, +0x00000000,0x000400fa,0x00002e04,0x00002e05, +0x00002e35,0x000200f8,0x00002e05,0x00050080, +0x00000006,0x00002e07,0x00002cc6,0x000001c4, +0x00050084,0x00000006,0x00002e09,0x000001db, +0x00005ebf,0x00050080,0x00000006,0x00002e0a, +0x00002e07,0x00002e09,0x00060041,0x00000028, +0x00002e0e,0x00002c75,0x0000016b,0x00005ebf, +0x0004003d,0x00000027,0x00002e0f,0x00002e0e, +0x0004007c,0x00000006,0x00003341,0x00002e0f, +0x00050095,0x0000013d,0x0000335c,0x00002f3b, +0x00002e0a,0x00050051,0x00000006,0x0000335d, +0x0000335c,0x00000001,0x00050051,0x00000006, +0x0000335e,0x0000335c,0x00000000,0x00050080, +0x00000006,0x00003363,0x00002f42,0x0000335d, +0x00050050,0x00000007,0x00003364,0x0000335e, +0x00003363,0x0004007c,0x00000014,0x00003354, +0x00003364,0x00060041,0x0000016c,0x0000334c, +0x00003354,0x0000016b,0x0000016b,0x0005003e, +0x0000334c,0x00003341,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002e12,0x00002cc6, +0x00000811,0x00050080,0x00000006,0x00002e15, +0x00002e12,0x00002e09,0x00060041,0x00000028, +0x00002e19,0x00002c75,0x00000264,0x00005ebf, +0x0004003d,0x00000027,0x00002e1a,0x00002e19, +0x0004007c,0x00000006,0x0000336a,0x00002e1a, +0x00050095,0x0000013d,0x00003385,0x00002f3b, +0x00002e15,0x00050051,0x00000006,0x00003386, +0x00003385,0x00000001,0x00050051,0x00000006, +0x00003387,0x00003385,0x00000000,0x00050080, +0x00000006,0x0000338c,0x00002f42,0x00003386, +0x00050050,0x00000007,0x0000338d,0x00003387, +0x0000338c,0x0004007c,0x00000014,0x0000337d, +0x0000338d,0x00060041,0x0000016c,0x00003375, +0x0000337d,0x0000016b,0x0000016b,0x0005003e, +0x00003375,0x0000336a,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002e1d,0x00002cc6, +0x00000820,0x00050080,0x00000006,0x00002e20, +0x00002e1d,0x00002e09,0x00060041,0x00000028, +0x00002e24,0x00002c75,0x00000315,0x00005ebf, +0x0004003d,0x00000027,0x00002e25,0x00002e24, +0x0004007c,0x00000006,0x00003393,0x00002e25, +0x00050095,0x0000013d,0x000033ae,0x00002f3b, +0x00002e20,0x00050051,0x00000006,0x000033af, +0x000033ae,0x00000001,0x00050051,0x00000006, +0x000033b0,0x000033ae,0x00000000,0x00050080, +0x00000006,0x000033b5,0x00002f42,0x000033af, +0x00050050,0x00000007,0x000033b6,0x000033b0, +0x000033b5,0x0004007c,0x00000014,0x000033a6, +0x000033b6,0x00060041,0x0000016c,0x0000339e, +0x000033a6,0x0000016b,0x0000016b,0x0005003e, +0x0000339e,0x00003393,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002e28,0x00002cc6, +0x0000082f,0x00050080,0x00000006,0x00002e2b, +0x00002e28,0x00002e09,0x00050041,0x00000028, +0x00002e2f,0x00002c78,0x00005ebf,0x0004003d, +0x00000027,0x00002e30,0x00002e2f,0x0004007c, +0x00000006,0x000033bc,0x00002e30,0x00050095, +0x0000013d,0x000033d7,0x00002f3b,0x00002e2b, +0x00050051,0x00000006,0x000033d8,0x000033d7, +0x00000001,0x00050051,0x00000006,0x000033d9, +0x000033d7,0x00000000,0x00050080,0x00000006, +0x000033de,0x00002f42,0x000033d8,0x00050050, +0x00000007,0x000033df,0x000033d9,0x000033de, +0x0004007c,0x00000014,0x000033cf,0x000033df, +0x00060041,0x0000016c,0x000033c7,0x000033cf, +0x0000016b,0x0000016b,0x0005003e,0x000033c7, +0x000033bc,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002e34,0x00005ebf,0x00000264, +0x000200f9,0x00002e01,0x000200f8,0x00002e35, +0x00050080,0x00000006,0x00002e37,0x00002cc6, +0x00000840,0x00050095,0x0000013d,0x000033f7, +0x00002f3b,0x00002e37,0x00050051,0x00000006, +0x000033f8,0x000033f7,0x00000001,0x00050051, +0x00000006,0x000033f9,0x000033f7,0x00000000, +0x00050080,0x00000006,0x000033fe,0x00002f42, +0x000033f8,0x00050050,0x00000007,0x000033ff, +0x000033f9,0x000033fe,0x0004007c,0x00000014, +0x000033ef,0x000033ff,0x00060041,0x0000016c, +0x000033e7,0x000033ef,0x0000016b,0x0000016b, +0x0005003e,0x000033e7,0x000012dd,0x00000002, +0x00000004,0x00050080,0x00000006,0x00002e3d, +0x00002cc6,0x0000084a,0x00050095,0x0000013d, +0x00003417,0x00002f3b,0x00002e3d,0x00050051, +0x00000006,0x00003418,0x00003417,0x00000001, +0x00050051,0x00000006,0x00003419,0x00003417, +0x00000000,0x00050080,0x00000006,0x0000341e, +0x00002f42,0x00003418,0x00050050,0x00000007, +0x0000341f,0x00003419,0x0000341e,0x0004007c, +0x00000014,0x0000340f,0x0000341f,0x00060041, +0x0000016c,0x00003407,0x0000340f,0x0000016b, +0x0000016b,0x0005003e,0x00003407,0x00000539, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00002d14,0x00002bbe,0x00000730,0x00050080, -0x00000006,0x00002d17,0x00002d14,0x00002cf5, -0x00050041,0x00000028,0x00002d1b,0x00002b70, -0x00005ab9,0x0004003d,0x00000027,0x00002d1c, -0x00002d1b,0x0004007c,0x00000006,0x00003030, -0x00002d1c,0x00050095,0x00000130,0x0000304b, -0x00002e27,0x00002d17,0x00050051,0x00000006, -0x0000304c,0x0000304b,0x00000001,0x00050051, -0x00000006,0x0000304d,0x0000304b,0x00000000, -0x00050080,0x00000006,0x00003052,0x00002e2e, -0x0000304c,0x00050050,0x00000007,0x00003053, -0x0000304d,0x00003052,0x0004007c,0x00000014, -0x00003043,0x00003053,0x00060041,0x0000015f, -0x0000303b,0x00003043,0x0000015e,0x0000015e, -0x0005003e,0x0000303b,0x00003030,0x00000002, -0x00000004,0x00050080,0x00000006,0x00002d20, -0x00005ab9,0x0000022b,0x000200f9,0x00002ced, -0x000200f8,0x00002d21,0x00050080,0x00000006, -0x00002d23,0x00002bbe,0x00000741,0x00050095, -0x00000130,0x0000306b,0x00002e27,0x00002d23, -0x00050051,0x00000006,0x0000306c,0x0000306b, -0x00000001,0x00050051,0x00000006,0x0000306d, -0x0000306b,0x00000000,0x00050080,0x00000006, -0x00003072,0x00002e2e,0x0000306c,0x00050050, -0x00000007,0x00003073,0x0000306d,0x00003072, -0x0004007c,0x00000014,0x00003063,0x00003073, -0x00060041,0x0000015f,0x0000305b,0x00003063, -0x0000015e,0x0000015e,0x0005003e,0x0000305b, -0x000011de,0x00000002,0x00000004,0x00050080, -0x00000006,0x00002d29,0x00002bbe,0x0000074b, -0x00050095,0x00000130,0x0000308b,0x00002e27, -0x00002d29,0x00050051,0x00000006,0x0000308c, -0x0000308b,0x00000001,0x00050051,0x00000006, -0x0000308d,0x0000308b,0x00000000,0x00050080, -0x00000006,0x00003092,0x00002e2e,0x0000308c, -0x00050050,0x00000007,0x00003093,0x0000308d, -0x00003092,0x0004007c,0x00000014,0x00003083, -0x00003093,0x00060041,0x0000015f,0x0000307b, -0x00003083,0x0000015e,0x0000015e,0x0005003e, -0x0000307b,0x00000500,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002d2e,0x00002bbe, -0x00000754,0x00050095,0x00000130,0x000030ab, -0x00002e27,0x00002d2e,0x00050051,0x00000006, -0x000030ac,0x000030ab,0x00000001,0x00050051, -0x00000006,0x000030ad,0x000030ab,0x00000000, -0x00050080,0x00000006,0x000030b2,0x00002e2e, -0x000030ac,0x00050050,0x00000007,0x000030b3, -0x000030ad,0x000030b2,0x0004007c,0x00000014, -0x000030a3,0x000030b3,0x00060041,0x0000015f, -0x0000309b,0x000030a3,0x0000015e,0x0000015e, -0x0005003e,0x0000309b,0x0000012b,0x00000002, -0x00000004,0x00050080,0x00000006,0x00002d33, -0x00002bbe,0x0000075d,0x00050095,0x00000130, -0x000030cb,0x00002e27,0x00002d33,0x00050051, -0x00000006,0x000030cc,0x000030cb,0x00000001, -0x00050051,0x00000006,0x000030cd,0x000030cb, -0x00000000,0x00050080,0x00000006,0x000030d2, -0x00002e2e,0x000030cc,0x00050050,0x00000007, -0x000030d3,0x000030cd,0x000030d2,0x0004007c, -0x00000014,0x000030c3,0x000030d3,0x00060041, -0x0000015f,0x000030bb,0x000030c3,0x0000015e, -0x0000015e,0x0005003e,0x000030bb,0x0000012b, -0x00000002,0x00000004,0x000500b4,0x0000002f, -0x00002d38,0x00002cd9,0x000003ed,0x00060050, -0x00000514,0x00005ce1,0x00002d38,0x00002d38, -0x00002d38,0x000600a9,0x00000063,0x00005ce2, -0x00005ce1,0x00005cc2,0x00005ad7,0x000600a9, -0x00000063,0x00005ce4,0x00005ce1,0x0000053d, -0x00005ac5,0x00050041,0x00000182,0x00003123, -0x00000180,0x00000181,0x0004003d,0x00000006, -0x00003124,0x00003123,0x00050084,0x00000006, -0x00003125,0x000001a2,0x00003124,0x00050080, -0x00000006,0x00003126,0x0000018b,0x00003125, -0x00050080,0x00000006,0x0000312c,0x00003124, -0x00005cc3,0x00050086,0x00000006,0x0000312d, -0x0000312c,0x00000185,0x00050084,0x00000006, -0x0000311f,0x0000018b,0x0000312d,0x00050080, -0x00000006,0x00003120,0x00003126,0x0000311f, -0x00050080,0x00000006,0x0000311a,0x00003120, -0x0000311f,0x00050084,0x00000006,0x000030ea, -0x000001b6,0x000011de,0x00050080,0x00000006, -0x000030eb,0x0000311a,0x000030ea,0x00050041, -0x0000022d,0x000030ec,0x00000180,0x0000022b, -0x0004003d,0x00000007,0x000030ed,0x000030ec, -0x00050051,0x00000027,0x000030f0,0x00005ce4, -0x00000000,0x0004007c,0x00000006,0x0000313a, -0x000030f0,0x00050051,0x00000006,0x00003153, -0x000030ed,0x00000000,0x00050095,0x00000130, -0x00003155,0x00003153,0x000030eb,0x00050051, -0x00000006,0x00003156,0x00003155,0x00000001, -0x00050051,0x00000006,0x00003157,0x00003155, -0x00000000,0x00050051,0x00000006,0x0000315a, -0x000030ed,0x00000001,0x00050080,0x00000006, -0x0000315c,0x0000315a,0x00003156,0x00050050, -0x00000007,0x0000315d,0x00003157,0x0000315c, -0x0004007c,0x00000014,0x0000314d,0x0000315d, -0x00060041,0x0000015f,0x00003145,0x0000314d, -0x0000015e,0x0000015e,0x0005003e,0x00003145, -0x0000313a,0x00000002,0x00000004,0x00050080, -0x00000006,0x000030f3,0x000030eb,0x000000df, -0x00050051,0x00000027,0x000030f7,0x00005ce4, -0x00000001,0x0004007c,0x00000006,0x00003163, -0x000030f7,0x00050095,0x00000130,0x0000317e, -0x00003153,0x000030f3,0x00050051,0x00000006, -0x0000317f,0x0000317e,0x00000001,0x00050051, -0x00000006,0x00003180,0x0000317e,0x00000000, -0x00050080,0x00000006,0x00003185,0x0000315a, -0x0000317f,0x00050050,0x00000007,0x00003186, -0x00003180,0x00003185,0x0004007c,0x00000014, -0x00003176,0x00003186,0x00060041,0x0000015f, -0x0000316e,0x00003176,0x0000015e,0x0000015e, -0x0005003e,0x0000316e,0x00003163,0x00000002, -0x00000004,0x00050080,0x00000006,0x000030fa, -0x000030eb,0x00000194,0x00050051,0x00000027, -0x000030fe,0x00005ce4,0x00000002,0x0004007c, -0x00000006,0x0000318c,0x000030fe,0x00050095, -0x00000130,0x000031a7,0x00003153,0x000030fa, -0x00050051,0x00000006,0x000031a8,0x000031a7, -0x00000001,0x00050051,0x00000006,0x000031a9, -0x000031a7,0x00000000,0x00050080,0x00000006, -0x000031ae,0x0000315a,0x000031a8,0x00050050, -0x00000007,0x000031af,0x000031a9,0x000031ae, -0x0004007c,0x00000014,0x0000319f,0x000031af, -0x00060041,0x0000015f,0x00003197,0x0000319f, -0x0000015e,0x0000015e,0x0005003e,0x00003197, -0x0000318c,0x00000002,0x00000004,0x00050080, -0x00000006,0x00003101,0x000030eb,0x0000019b, -0x00050051,0x00000027,0x00003105,0x00005ce2, -0x00000000,0x0004007c,0x00000006,0x000031b5, -0x00003105,0x00050095,0x00000130,0x000031d0, -0x00003153,0x00003101,0x00050051,0x00000006, -0x000031d1,0x000031d0,0x00000001,0x00050051, -0x00000006,0x000031d2,0x000031d0,0x00000000, -0x00050080,0x00000006,0x000031d7,0x0000315a, -0x000031d1,0x00050050,0x00000007,0x000031d8, -0x000031d2,0x000031d7,0x0004007c,0x00000014, -0x000031c8,0x000031d8,0x00060041,0x0000015f, -0x000031c0,0x000031c8,0x0000015e,0x0000015e, -0x0005003e,0x000031c0,0x000031b5,0x00000002, -0x00000004,0x00050080,0x00000006,0x00003108, -0x000030eb,0x000001a2,0x00050051,0x00000027, -0x0000310c,0x00005ce2,0x00000001,0x0004007c, -0x00000006,0x000031de,0x0000310c,0x00050095, -0x00000130,0x000031f9,0x00003153,0x00003108, -0x00050051,0x00000006,0x000031fa,0x000031f9, -0x00000001,0x00050051,0x00000006,0x000031fb, -0x000031f9,0x00000000,0x00050080,0x00000006, -0x00003200,0x0000315a,0x000031fa,0x00050050, -0x00000007,0x00003201,0x000031fb,0x00003200, -0x0004007c,0x00000014,0x000031f1,0x00003201, -0x00060041,0x0000015f,0x000031e9,0x000031f1, -0x0000015e,0x0000015e,0x0005003e,0x000031e9, -0x000031de,0x00000002,0x00000004,0x00050080, -0x00000006,0x0000310f,0x000030eb,0x00000260, -0x00050051,0x00000027,0x00003113,0x00005ce2, -0x00000002,0x0004007c,0x00000006,0x00003207, -0x00003113,0x00050095,0x00000130,0x00003222, -0x00003153,0x0000310f,0x00050051,0x00000006, -0x00003223,0x00003222,0x00000001,0x00050051, -0x00000006,0x00003224,0x00003222,0x00000000, -0x00050080,0x00000006,0x00003229,0x0000315a, -0x00003223,0x00050050,0x00000007,0x0000322a, -0x00003224,0x00003229,0x0004007c,0x00000014, -0x0000321a,0x0000322a,0x00060041,0x0000015f, -0x00003212,0x0000321a,0x0000015e,0x0000015e, -0x0005003e,0x00003212,0x00003207,0x00000002, -0x00000004,0x000300f7,0x0000326a,0x00000000, -0x000300fb,0x0000012b,0x00003239,0x000200f8, -0x00003239,0x000500bc,0x0000002f,0x00003271, -0x000030f0,0x00003105,0x000300f7,0x00003278, -0x00000000,0x000400fa,0x00003271,0x00003272, -0x00003278,0x000200f8,0x00003272,0x000500bc, -0x0000002f,0x00003277,0x000030f7,0x0000310c, -0x000200f9,0x00003278,0x000200f8,0x00003278, -0x000700f5,0x0000002f,0x00003279,0x00003271, -0x00003239,0x00003277,0x00003272,0x000300f7, -0x00003280,0x00000000,0x000400fa,0x00003279, -0x0000327a,0x00003280,0x000200f8,0x0000327a, -0x000500bc,0x0000002f,0x0000327f,0x000030fe, -0x00003113,0x000200f9,0x00003280,0x000200f8, -0x00003280,0x000700f5,0x0000002f,0x00003281, -0x00003279,0x00003278,0x0000327f,0x0000327a, -0x000400a8,0x0000002f,0x00003282,0x00003281, -0x000300f7,0x0000323e,0x00000000,0x000400fa, -0x00003282,0x0000323d,0x0000323e,0x000200f8, -0x0000323d,0x000200f9,0x0000326a,0x000200f8, -0x0000323e,0x00050081,0x00000063,0x00003241, -0x00005ce4,0x00005ce2,0x0005008e,0x00000063, -0x00003242,0x00003241,0x000002c4,0x00050095, -0x00000130,0x00003292,0x00003153,0x0000012b, -0x00050051,0x00000006,0x00003293,0x00003292, -0x00000001,0x00050051,0x00000006,0x00003294, -0x00003292,0x00000000,0x00050080,0x00000006, -0x00003299,0x0000315a,0x00003293,0x00050050, -0x00000007,0x0000329a,0x00003294,0x00003299, -0x0004007c,0x00000014,0x0000328a,0x0000329a, -0x00060041,0x0000015f,0x00003247,0x0000328a, -0x0000015e,0x0000015e,0x00050051,0x00000027, -0x00003249,0x00003242,0x00000000,0x0004007c, -0x00000006,0x000032a0,0x00003249,0x000500c7, -0x00000006,0x000032a2,0x000032a0,0x00000208, -0x000500ab,0x0000002f,0x000032a3,0x000032a2, -0x0000012b,0x000300f7,0x000032aa,0x00000000, -0x000400fa,0x000032a3,0x000032a4,0x000032a7, -0x000200f8,0x000032a7,0x000500c5,0x00000006, -0x000032a9,0x000032a0,0x00000208,0x000200f9, -0x000032aa,0x000200f8,0x000032a4,0x000400c8, -0x00000006,0x000032a6,0x000032a0,0x000200f9, -0x000032aa,0x000200f8,0x000032aa,0x000700f5, -0x00000006,0x00005ade,0x000032a6,0x000032a4, -0x000032a9,0x000032a7,0x000700ed,0x00000006, -0x0000324b,0x00003247,0x00000135,0x0000012b, -0x00005ade,0x00060041,0x0000015f,0x0000324d, -0x0000328a,0x0000015e,0x0000022b,0x00050051, -0x00000027,0x0000324f,0x00003242,0x00000001, -0x0004007c,0x00000006,0x000032b1,0x0000324f, -0x000500c7,0x00000006,0x000032b3,0x000032b1, -0x00000208,0x000500ab,0x0000002f,0x000032b4, -0x000032b3,0x0000012b,0x000300f7,0x000032bb, -0x00000000,0x000400fa,0x000032b4,0x000032b5, -0x000032b8,0x000200f8,0x000032b8,0x000500c5, -0x00000006,0x000032ba,0x000032b1,0x00000208, -0x000200f9,0x000032bb,0x000200f8,0x000032b5, -0x000400c8,0x00000006,0x000032b7,0x000032b1, -0x000200f9,0x000032bb,0x000200f8,0x000032bb, -0x000700f5,0x00000006,0x00005adf,0x000032b7, -0x000032b5,0x000032ba,0x000032b8,0x000700ed, -0x00000006,0x00003251,0x0000324d,0x00000135, -0x0000012b,0x00005adf,0x00060041,0x0000015f, -0x00003253,0x0000328a,0x0000015e,0x000002dc, -0x00050051,0x00000027,0x00003255,0x00003242, -0x00000002,0x0004007c,0x00000006,0x000032c2, -0x00003255,0x000500c7,0x00000006,0x000032c4, -0x000032c2,0x00000208,0x000500ab,0x0000002f, -0x000032c5,0x000032c4,0x0000012b,0x000300f7, -0x000032cc,0x00000000,0x000400fa,0x000032c5, -0x000032c6,0x000032c9,0x000200f8,0x000032c9, -0x000500c5,0x00000006,0x000032cb,0x000032c2, -0x00000208,0x000200f9,0x000032cc,0x000200f8, -0x000032c6,0x000400c8,0x00000006,0x000032c8, -0x000032c2,0x000200f9,0x000032cc,0x000200f8, -0x000032cc,0x000700f5,0x00000006,0x00005ae0, -0x000032c8,0x000032c6,0x000032cb,0x000032c9, -0x000700ed,0x00000006,0x00003257,0x00003253, -0x00000135,0x0000012b,0x00005ae0,0x00060041, -0x0000015f,0x00003259,0x0000328a,0x0000015e, -0x000002e4,0x000300f7,0x000032dd,0x00000000, -0x000400fa,0x000032a3,0x000032d7,0x000032da, -0x000200f8,0x000032da,0x000500c5,0x00000006, -0x000032dc,0x000032a0,0x00000208,0x000200f9, -0x000032dd,0x000200f8,0x000032d7,0x000400c8, -0x00000006,0x000032d9,0x000032a0,0x000200f9, -0x000032dd,0x000200f8,0x000032dd,0x000700f5, -0x00000006,0x00005ae1,0x000032d9,0x000032d7, -0x000032dc,0x000032da,0x000700ef,0x00000006, -0x0000325d,0x00003259,0x00000135,0x0000012b, -0x00005ae1,0x00060041,0x0000015f,0x0000325f, -0x0000328a,0x0000015e,0x000002ec,0x000300f7, -0x000032ee,0x00000000,0x000400fa,0x000032b4, -0x000032e8,0x000032eb,0x000200f8,0x000032eb, -0x000500c5,0x00000006,0x000032ed,0x000032b1, -0x00000208,0x000200f9,0x000032ee,0x000200f8, -0x000032e8,0x000400c8,0x00000006,0x000032ea, -0x000032b1,0x000200f9,0x000032ee,0x000200f8, -0x000032ee,0x000700f5,0x00000006,0x00005ae2, -0x000032ea,0x000032e8,0x000032ed,0x000032eb, -0x000700ef,0x00000006,0x00003263,0x0000325f, -0x00000135,0x0000012b,0x00005ae2,0x00060041, -0x0000015f,0x00003265,0x0000328a,0x0000015e, -0x000002f4,0x000300f7,0x000032ff,0x00000000, -0x000400fa,0x000032c5,0x000032f9,0x000032fc, -0x000200f8,0x000032fc,0x000500c5,0x00000006, -0x000032fe,0x000032c2,0x00000208,0x000200f9, -0x000032ff,0x000200f8,0x000032f9,0x000400c8, -0x00000006,0x000032fb,0x000032c2,0x000200f9, -0x000032ff,0x000200f8,0x000032ff,0x000700f5, -0x00000006,0x00005ae3,0x000032fb,0x000032f9, -0x000032fe,0x000032fc,0x000700ef,0x00000006, -0x00003269,0x00003265,0x00000135,0x0000012b, -0x00005ae3,0x000200f9,0x0000326a,0x000200f8, -0x0000326a,0x000200f9,0x000012c8,0x000200f8, -0x000012c8,0x000200f9,0x000012bf,0x000200f8, -0x000012be,0x000200f9,0x00002504,0x000200f8, -0x00002504,0x000700f5,0x00000006,0x00005af0, -0x0000012b,0x000012be,0x00002514,0x00002512, -0x000500b0,0x0000002f,0x00002507,0x00005af0, -0x00000437,0x000400f6,0x00002515,0x00002512, -0x00000000,0x000400fa,0x00002507,0x00002508, -0x00002515,0x000200f8,0x00002508,0x00050084, -0x00000006,0x0000250b,0x00000437,0x000011de, -0x00050080,0x00000006,0x0000250d,0x0000250b, -0x00005af0,0x000300f7,0x000025d0,0x00000000, -0x000300fb,0x0000012b,0x000025ae,0x000200f8, -0x000025ae,0x00050041,0x00000182,0x000025af, -0x00000180,0x000003fb,0x0004003d,0x00000006, -0x000025b0,0x000025af,0x000500aa,0x0000002f, -0x000025b1,0x000025b0,0x0000012b,0x000300f7, -0x000025b4,0x00000000,0x000400fa,0x000025b1, -0x000025b2,0x000025b4,0x000200f8,0x000025b2, -0x000200f9,0x000025d0,0x000200f8,0x000025b4, -0x000500aa,0x0000002f,0x000025b7,0x000025b0, -0x00000247,0x000300f7,0x000025be,0x00000000, -0x000400fa,0x000025b7,0x000025b8,0x000025be, -0x000200f8,0x000025b8,0x00050084,0x00000006, -0x000025ba,0x000000df,0x0000250d,0x00050041, -0x0000022d,0x000025bb,0x00000180,0x000002e4, -0x0004003d,0x00000007,0x000025bc,0x000025bb, -0x00050051,0x00000006,0x000025e8,0x000025bc, -0x00000000,0x00050095,0x00000130,0x000025ea, -0x000025e8,0x000025ba,0x00050051,0x00000006, -0x000025eb,0x000025ea,0x00000001,0x00050051, -0x00000006,0x000025ec,0x000025ea,0x00000000, -0x00050051,0x00000006,0x000025ef,0x000025bc, -0x00000001,0x00050080,0x00000006,0x000025f1, -0x000025ef,0x000025eb,0x00050050,0x00000007, -0x000025f2,0x000025ec,0x000025f1,0x0004007c, -0x00000014,0x000025e2,0x000025f2,0x00060041, -0x0000015f,0x000025d9,0x000025e2,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x000025da, -0x000025d9,0x00000002,0x00000004,0x000200f9, -0x000025d0,0x000200f8,0x000025be,0x000500c2, -0x00000006,0x000025c0,0x0000250d,0x0000022b, -0x00050084,0x00000006,0x000025c1,0x000000df, -0x000025c0,0x00050041,0x0000022d,0x000025c2, -0x00000180,0x000002e4,0x0004003d,0x00000007, -0x000025c3,0x000025c2,0x00050051,0x00000006, -0x00002609,0x000025c3,0x00000000,0x00050095, -0x00000130,0x0000260b,0x00002609,0x000025c1, -0x00050051,0x00000006,0x0000260c,0x0000260b, -0x00000001,0x00050051,0x00000006,0x0000260d, -0x0000260b,0x00000000,0x00050051,0x00000006, -0x00002610,0x000025c3,0x00000001,0x00050080, -0x00000006,0x00002612,0x00002610,0x0000260c, -0x00050050,0x00000007,0x00002613,0x0000260d, -0x00002612,0x0004007c,0x00000014,0x00002603, -0x00002613,0x00060041,0x0000015f,0x000025fa, -0x00002603,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x000025fb,0x000025fa,0x00000002, -0x00000004,0x000500c7,0x00000006,0x000025c6, -0x0000250d,0x00000135,0x000500ab,0x0000002f, -0x000025c7,0x000025c6,0x0000012b,0x000300f7, -0x000025ce,0x00000000,0x000400fa,0x000025c7, -0x000025c8,0x000025cb,0x000200f8,0x000025cb, -0x000500c7,0x00000006,0x000025cd,0x000025fb, -0x00000423,0x000200f9,0x000025ce,0x000200f8, -0x000025c8,0x000500c2,0x00000006,0x000025ca, -0x000025fb,0x00000321,0x000200f9,0x000025ce, -0x000200f8,0x000025ce,0x000700f5,0x00000006, -0x00005afa,0x000025ca,0x000025c8,0x000025cd, -0x000025cb,0x000200f9,0x000025d0,0x000200f8, -0x000025d0,0x000900f5,0x00000006,0x00005afb, -0x0000250d,0x000025b2,0x000025da,0x000025b8, -0x00005afa,0x000025ce,0x00050041,0x00000182, -0x00002624,0x00000180,0x000001cd,0x0004003d, -0x00000006,0x00002625,0x00002624,0x00050084, -0x00000006,0x00002626,0x00005afb,0x00002625, -0x00050041,0x0000022d,0x00002627,0x00000180, -0x000002dc,0x0004003d,0x00000007,0x00002628, -0x00002627,0x00050051,0x00000006,0x00002643, -0x00002628,0x00000000,0x00050095,0x00000130, -0x00002645,0x00002643,0x00002626,0x00050051, -0x00000006,0x00002646,0x00002645,0x00000001, -0x00050051,0x00000006,0x00002647,0x00002645, -0x00000000,0x00050051,0x00000006,0x0000264a, -0x00002628,0x00000001,0x00050080,0x00000006, -0x0000264c,0x0000264a,0x00002646,0x00050095, -0x00000130,0x00002666,0x00002647,0x0000012b, -0x00050051,0x00000006,0x00002667,0x00002666, -0x00000001,0x00050051,0x00000006,0x00002668, -0x00002666,0x00000000,0x00050080,0x00000006, -0x0000266d,0x0000264c,0x00002667,0x00050050, -0x00000007,0x0000266e,0x00002668,0x0000266d, -0x0004007c,0x00000014,0x0000265e,0x0000266e, -0x00060041,0x0000015f,0x00002655,0x0000265e, -0x0000015e,0x0000015e,0x0006003d,0x00000006, -0x00002656,0x00002655,0x00000002,0x00000004, -0x0004007c,0x00000027,0x0000262c,0x00002656, -0x00050095,0x00000130,0x00002687,0x00002647, -0x000000df,0x00050051,0x00000006,0x00002688, -0x00002687,0x00000001,0x00050051,0x00000006, -0x00002689,0x00002687,0x00000000,0x00050080, -0x00000006,0x0000268e,0x0000264c,0x00002688, -0x00050050,0x00000007,0x0000268f,0x00002689, -0x0000268e,0x0004007c,0x00000014,0x0000267f, -0x0000268f,0x00060041,0x0000015f,0x00002676, -0x0000267f,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00002677,0x00002676,0x00000002, -0x00000004,0x0004007c,0x00000027,0x0000262f, -0x00002677,0x00050041,0x00000182,0x00002630, -0x00000180,0x0000037d,0x0004003d,0x00000006, -0x00002631,0x00002630,0x000500aa,0x0000002f, -0x00002632,0x00002631,0x00000135,0x000300f7, -0x00002638,0x00000000,0x000400fa,0x00002632, -0x00002633,0x00002634,0x000200f8,0x00002634, -0x00050095,0x00000130,0x000026a8,0x00002647, -0x00000194,0x00050051,0x00000006,0x000026a9, -0x000026a8,0x00000001,0x00050051,0x00000006, -0x000026aa,0x000026a8,0x00000000,0x00050080, -0x00000006,0x000026af,0x0000264c,0x000026a9, -0x00050050,0x00000007,0x000026b0,0x000026aa, -0x000026af,0x0004007c,0x00000014,0x000026a0, -0x000026b0,0x00060041,0x0000015f,0x00002697, -0x000026a0,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x00002698,0x00002697,0x00000002, -0x00000004,0x0004007c,0x00000027,0x00002637, -0x00002698,0x000200f9,0x00002638,0x000200f8, -0x00002633,0x000200f9,0x00002638,0x000200f8, -0x00002638,0x000700f5,0x00000027,0x00005afc, -0x000003ed,0x00002633,0x00002637,0x00002634, -0x00060050,0x00000063,0x0000263d,0x0000262c, -0x0000262f,0x00005afc,0x000300f7,0x000026f6, -0x00000000,0x000300fb,0x0000012b,0x000026c2, -0x000200f8,0x000026c2,0x00050041,0x0000022d, -0x000026c3,0x00000180,0x000002ec,0x0004003d, -0x00000007,0x000026c4,0x000026c3,0x00050051, -0x00000006,0x000026fb,0x000026c4,0x00000000, -0x000500aa,0x0000002f,0x000026fc,0x000026fb, -0x0000012b,0x000300f7,0x00002701,0x00000000, -0x000400fa,0x000026fc,0x000026fd,0x00002701, -0x000200f8,0x000026fd,0x00050051,0x00000006, -0x000026ff,0x000026c4,0x00000001,0x000500aa, -0x0000002f,0x00002700,0x000026ff,0x0000012b, -0x000200f9,0x00002701,0x000200f8,0x00002701, -0x000700f5,0x0000002f,0x00002702,0x000026fc, -0x000026c2,0x00002700,0x000026fd,0x000300f7, -0x000026c8,0x00000000,0x000400fa,0x00002702, -0x000026c6,0x000026c8,0x000200f8,0x000026c6, -0x000200f9,0x000026f6,0x000200f8,0x000026c8, -0x000200f9,0x000026c9,0x000200f8,0x000026c9, -0x000700f5,0x00000006,0x00005afd,0x0000012b, -0x000026c8,0x000026f3,0x000026cd,0x000500b0, -0x0000002f,0x000026cc,0x00005afd,0x00000437, -0x000400f6,0x000026f4,0x000026cd,0x00000000, -0x000400fa,0x000026cc,0x000026cd,0x000026f4, -0x000200f8,0x000026cd,0x00050084,0x00000006, -0x000026cf,0x000001a2,0x00005afd,0x00050095, -0x00000130,0x0000271b,0x000026fb,0x000026cf, -0x00050051,0x00000006,0x0000271c,0x0000271b, -0x00000001,0x00050051,0x00000006,0x0000271d, -0x0000271b,0x00000000,0x00050051,0x00000006, -0x00002720,0x000026c4,0x00000001,0x00050080, -0x00000006,0x00002722,0x00002720,0x0000271c, -0x00050050,0x00000007,0x00002723,0x0000271d, -0x00002722,0x0004007c,0x00000014,0x00002713, -0x00002723,0x00060041,0x0000015f,0x0000270a, -0x00002713,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x0000270b,0x0000270a,0x00000002, -0x00000004,0x0004007c,0x00000027,0x000026d4, -0x0000270b,0x00050080,0x00000006,0x000026d6, -0x000026cf,0x000000df,0x00050095,0x00000130, -0x0000273c,0x000026fb,0x000026d6,0x00050051, -0x00000006,0x0000273d,0x0000273c,0x00000001, -0x00050051,0x00000006,0x0000273e,0x0000273c, -0x00000000,0x00050080,0x00000006,0x00002743, -0x00002720,0x0000273d,0x00050050,0x00000007, -0x00002744,0x0000273e,0x00002743,0x0004007c, -0x00000014,0x00002734,0x00002744,0x00060041, -0x0000015f,0x0000272b,0x00002734,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x0000272c, -0x0000272b,0x00000002,0x00000004,0x0004007c, -0x00000027,0x000026da,0x0000272c,0x00050080, -0x00000006,0x000026dc,0x000026cf,0x00000194, -0x00050095,0x00000130,0x0000275d,0x000026fb, -0x000026dc,0x00050051,0x00000006,0x0000275e, -0x0000275d,0x00000001,0x00050051,0x00000006, -0x0000275f,0x0000275d,0x00000000,0x00050080, -0x00000006,0x00002764,0x00002720,0x0000275e, -0x00050050,0x00000007,0x00002765,0x0000275f, -0x00002764,0x0004007c,0x00000014,0x00002755, -0x00002765,0x00060041,0x0000015f,0x0000274c, -0x00002755,0x0000015e,0x0000015e,0x0006003d, -0x00000006,0x0000274d,0x0000274c,0x00000002, -0x00000004,0x0004007c,0x00000027,0x000026e0, -0x0000274d,0x00050080,0x00000006,0x000026e2, -0x000026cf,0x0000019b,0x00050095,0x00000130, -0x0000277e,0x000026fb,0x000026e2,0x00050051, -0x00000006,0x0000277f,0x0000277e,0x00000001, -0x00050051,0x00000006,0x00002780,0x0000277e, -0x00000000,0x00050080,0x00000006,0x00002785, -0x00002720,0x0000277f,0x00050050,0x00000007, -0x00002786,0x00002780,0x00002785,0x0004007c, -0x00000014,0x00002776,0x00002786,0x00060041, -0x0000015f,0x0000276d,0x00002776,0x0000015e, -0x0000015e,0x0006003d,0x00000006,0x0000276e, -0x0000276d,0x00000002,0x00000004,0x0004007c, -0x00000027,0x000026e6,0x0000276e,0x00070050, -0x0000043c,0x000026e7,0x000026d4,0x000026da, -0x000026e0,0x000026e6,0x0008004f,0x00000063, -0x000026ea,0x000026e7,0x000026e7,0x00000000, -0x00000001,0x00000002,0x00050094,0x00000027, -0x000026ec,0x000026ea,0x0000263d,0x00050081, -0x00000027,0x000026ef,0x000026ec,0x000026e6, -0x00050041,0x00000028,0x000026f0,0x000026bf, -0x00005afd,0x0003003e,0x000026f0,0x000026ef, -0x00050080,0x00000006,0x000026f3,0x00005afd, -0x0000022b,0x000200f9,0x000026c9,0x000200f8, -0x000026f4,0x0004003d,0x00000063,0x000026f5, -0x000026bf,0x000200f9,0x000026f6,0x000200f8, -0x000026f6,0x000700f5,0x00000063,0x00005afe, -0x0000263d,0x000026c6,0x000026f5,0x000026f4, -0x00050041,0x00000064,0x00002511,0x000024d6, -0x00005af0,0x0003003e,0x00002511,0x00005afe, -0x000200f9,0x00002512,0x000200f8,0x00002512, -0x00050080,0x00000006,0x00002514,0x00005af0, -0x0000022b,0x000200f9,0x00002504,0x000200f8, -0x00002515,0x00050041,0x00000182,0x00002516, -0x00000180,0x00000488,0x0004003d,0x00000006, -0x00002517,0x00002516,0x00050080,0x00000006, -0x00002519,0x00002517,0x000011de,0x00050041, -0x00000182,0x0000251a,0x00000180,0x00000311, -0x0004003d,0x00000006,0x0000251b,0x0000251a, -0x00050084,0x00000006,0x0000251d,0x0000018b, -0x00002519,0x00050080,0x00000006,0x0000251e, -0x0000251b,0x0000251d,0x000200f9,0x0000251f, -0x000200f8,0x0000251f,0x000700f5,0x00000006, -0x00005af1,0x0000012b,0x00002515,0x00002546, -0x00002523,0x000500b0,0x0000002f,0x00002522, -0x00005af1,0x00000437,0x000400f6,0x00002547, -0x00002523,0x00000000,0x000400fa,0x00002522, -0x00002523,0x00002547,0x000200f8,0x00002523, -0x00050084,0x00000006,0x00002526,0x0000019b, -0x00005af1,0x00050080,0x00000006,0x00002527, -0x0000251e,0x00002526,0x00050041,0x0000022d, -0x00002529,0x00000180,0x0000015e,0x0004003d, -0x00000007,0x0000252a,0x00002529,0x00060041, -0x00000028,0x0000252b,0x000024d6,0x00005af1, -0x0000012b,0x0004003d,0x00000027,0x0000252c, -0x0000252b,0x0004007c,0x00000006,0x0000278c, -0x0000252c,0x00050051,0x00000006,0x000027a5, -0x0000252a,0x00000000,0x00050095,0x00000130, -0x000027a7,0x000027a5,0x00002527,0x00050051, -0x00000006,0x000027a8,0x000027a7,0x00000001, -0x00050051,0x00000006,0x000027a9,0x000027a7, -0x00000000,0x00050051,0x00000006,0x000027ac, -0x0000252a,0x00000001,0x00050080,0x00000006, -0x000027ae,0x000027ac,0x000027a8,0x00050050, -0x00000007,0x000027af,0x000027a9,0x000027ae, -0x0004007c,0x00000014,0x0000279f,0x000027af, -0x00060041,0x0000015f,0x00002797,0x0000279f, -0x0000015e,0x0000015e,0x0005003e,0x00002797, -0x0000278c,0x00000002,0x00000004,0x00050080, -0x00000006,0x00002532,0x00002527,0x000000df, -0x00060041,0x00000028,0x00002536,0x000024d6, -0x00005af1,0x00000135,0x0004003d,0x00000027, -0x00002537,0x00002536,0x0004007c,0x00000006, -0x000027b5,0x00002537,0x00050095,0x00000130, -0x000027d0,0x000027a5,0x00002532,0x00050051, -0x00000006,0x000027d1,0x000027d0,0x00000001, -0x00050051,0x00000006,0x000027d2,0x000027d0, -0x00000000,0x00050080,0x00000006,0x000027d7, -0x000027ac,0x000027d1,0x00050050,0x00000007, -0x000027d8,0x000027d2,0x000027d7,0x0004007c, -0x00000014,0x000027c8,0x000027d8,0x00060041, -0x0000015f,0x000027c0,0x000027c8,0x0000015e, -0x0000015e,0x0005003e,0x000027c0,0x000027b5, +0x00002e42,0x00002cc6,0x00000853,0x00050095, +0x0000013d,0x00003437,0x00002f3b,0x00002e42, +0x00050051,0x00000006,0x00003438,0x00003437, +0x00000001,0x00050051,0x00000006,0x00003439, +0x00003437,0x00000000,0x00050080,0x00000006, +0x0000343e,0x00002f42,0x00003438,0x00050050, +0x00000007,0x0000343f,0x00003439,0x0000343e, +0x0004007c,0x00000014,0x0000342f,0x0000343f, +0x00060041,0x0000016c,0x00003427,0x0000342f, +0x0000016b,0x0000016b,0x0005003e,0x00003427, +0x00000138,0x00000002,0x00000004,0x00050080, +0x00000006,0x00002e47,0x00002cc6,0x0000085c, +0x00050095,0x0000013d,0x00003457,0x00002f3b, +0x00002e47,0x00050051,0x00000006,0x00003458, +0x00003457,0x00000001,0x00050051,0x00000006, +0x00003459,0x00003457,0x00000000,0x00050080, +0x00000006,0x0000345e,0x00002f42,0x00003458, +0x00050050,0x00000007,0x0000345f,0x00003459, +0x0000345e,0x0004007c,0x00000014,0x0000344f, +0x0000345f,0x00060041,0x0000016c,0x00003447, +0x0000344f,0x0000016b,0x0000016b,0x0005003e, +0x00003447,0x00000138,0x00000002,0x00000004, +0x000500b4,0x0000002f,0x00002e4c,0x00002ded, +0x00000426,0x00060050,0x0000054d,0x00006121, +0x00002e4c,0x00002e4c,0x00002e4c,0x000600a9, +0x0000006c,0x00006122,0x00006121,0x000060fe, +0x00005ef3,0x000600a9,0x0000006c,0x00006124, +0x00006121,0x00000576,0x00005ecc,0x00050041, +0x000001bb,0x000034af,0x000001b9,0x000001ba, +0x0004003d,0x00000006,0x000034b0,0x000034af, +0x00050084,0x00000006,0x000034b1,0x000001db, +0x000034b0,0x00050080,0x00000006,0x000034b2, +0x000001c4,0x000034b1,0x00050080,0x00000006, +0x000034b8,0x000034b0,0x0000062f,0x00050086, +0x00000006,0x000034b9,0x000034b8,0x000001be, +0x00050084,0x00000006,0x000034ab,0x000001c4, +0x000034b9,0x00050080,0x00000006,0x000034ac, +0x000034b2,0x000034ab,0x00050080,0x00000006, +0x000034a6,0x000034ac,0x000034ab,0x00050084, +0x00000006,0x00003476,0x000001ef,0x000012dd, +0x00050080,0x00000006,0x00003477,0x000034a6, +0x00003476,0x00050041,0x00000266,0x00003478, +0x000001b9,0x00000264,0x0004003d,0x00000007, +0x00003479,0x00003478,0x00050051,0x00000027, +0x0000347c,0x00006124,0x00000000,0x0004007c, +0x00000006,0x000034c6,0x0000347c,0x00050051, +0x00000006,0x000034df,0x00003479,0x00000000, +0x00050095,0x0000013d,0x000034e1,0x000034df, +0x00003477,0x00050051,0x00000006,0x000034e2, +0x000034e1,0x00000001,0x00050051,0x00000006, +0x000034e3,0x000034e1,0x00000000,0x00050051, +0x00000006,0x000034e6,0x00003479,0x00000001, +0x00050080,0x00000006,0x000034e8,0x000034e6, +0x000034e2,0x00050050,0x00000007,0x000034e9, +0x000034e3,0x000034e8,0x0004007c,0x00000014, +0x000034d9,0x000034e9,0x00060041,0x0000016c, +0x000034d1,0x000034d9,0x0000016b,0x0000016b, +0x0005003e,0x000034d1,0x000034c6,0x00000002, +0x00000004,0x00050080,0x00000006,0x0000347f, +0x00003477,0x000000ec,0x00050051,0x00000027, +0x00003483,0x00006124,0x00000001,0x0004007c, +0x00000006,0x000034ef,0x00003483,0x00050095, +0x0000013d,0x0000350a,0x000034df,0x0000347f, +0x00050051,0x00000006,0x0000350b,0x0000350a, +0x00000001,0x00050051,0x00000006,0x0000350c, +0x0000350a,0x00000000,0x00050080,0x00000006, +0x00003511,0x000034e6,0x0000350b,0x00050050, +0x00000007,0x00003512,0x0000350c,0x00003511, +0x0004007c,0x00000014,0x00003502,0x00003512, +0x00060041,0x0000016c,0x000034fa,0x00003502, +0x0000016b,0x0000016b,0x0005003e,0x000034fa, +0x000034ef,0x00000002,0x00000004,0x00050080, +0x00000006,0x00003486,0x00003477,0x000001cd, +0x00050051,0x00000027,0x0000348a,0x00006124, +0x00000002,0x0004007c,0x00000006,0x00003518, +0x0000348a,0x00050095,0x0000013d,0x00003533, +0x000034df,0x00003486,0x00050051,0x00000006, +0x00003534,0x00003533,0x00000001,0x00050051, +0x00000006,0x00003535,0x00003533,0x00000000, +0x00050080,0x00000006,0x0000353a,0x000034e6, +0x00003534,0x00050050,0x00000007,0x0000353b, +0x00003535,0x0000353a,0x0004007c,0x00000014, +0x0000352b,0x0000353b,0x00060041,0x0000016c, +0x00003523,0x0000352b,0x0000016b,0x0000016b, +0x0005003e,0x00003523,0x00003518,0x00000002, +0x00000004,0x00050080,0x00000006,0x0000348d, +0x00003477,0x000001d4,0x00050051,0x00000027, +0x00003491,0x00006122,0x00000000,0x0004007c, +0x00000006,0x00003541,0x00003491,0x00050095, +0x0000013d,0x0000355c,0x000034df,0x0000348d, +0x00050051,0x00000006,0x0000355d,0x0000355c, +0x00000001,0x00050051,0x00000006,0x0000355e, +0x0000355c,0x00000000,0x00050080,0x00000006, +0x00003563,0x000034e6,0x0000355d,0x00050050, +0x00000007,0x00003564,0x0000355e,0x00003563, +0x0004007c,0x00000014,0x00003554,0x00003564, +0x00060041,0x0000016c,0x0000354c,0x00003554, +0x0000016b,0x0000016b,0x0005003e,0x0000354c, +0x00003541,0x00000002,0x00000004,0x00050080, +0x00000006,0x00003494,0x00003477,0x000001db, +0x00050051,0x00000027,0x00003498,0x00006122, +0x00000001,0x0004007c,0x00000006,0x0000356a, +0x00003498,0x00050095,0x0000013d,0x00003585, +0x000034df,0x00003494,0x00050051,0x00000006, +0x00003586,0x00003585,0x00000001,0x00050051, +0x00000006,0x00003587,0x00003585,0x00000000, +0x00050080,0x00000006,0x0000358c,0x000034e6, +0x00003586,0x00050050,0x00000007,0x0000358d, +0x00003587,0x0000358c,0x0004007c,0x00000014, +0x0000357d,0x0000358d,0x00060041,0x0000016c, +0x00003575,0x0000357d,0x0000016b,0x0000016b, +0x0005003e,0x00003575,0x0000356a,0x00000002, +0x00000004,0x00050080,0x00000006,0x0000349b, +0x00003477,0x00000299,0x00050051,0x00000027, +0x0000349f,0x00006122,0x00000002,0x0004007c, +0x00000006,0x00003593,0x0000349f,0x00050095, +0x0000013d,0x000035ae,0x000034df,0x0000349b, +0x00050051,0x00000006,0x000035af,0x000035ae, +0x00000001,0x00050051,0x00000006,0x000035b0, +0x000035ae,0x00000000,0x00050080,0x00000006, +0x000035b5,0x000034e6,0x000035af,0x00050050, +0x00000007,0x000035b6,0x000035b0,0x000035b5, +0x0004007c,0x00000014,0x000035a6,0x000035b6, +0x00060041,0x0000016c,0x0000359e,0x000035a6, +0x0000016b,0x0000016b,0x0005003e,0x0000359e, +0x00003593,0x00000002,0x00000004,0x000300f7, +0x000035f6,0x00000000,0x000300fb,0x00000138, +0x000035c5,0x000200f8,0x000035c5,0x000500bc, +0x0000002f,0x000035fd,0x0000347c,0x00003491, +0x000300f7,0x00003604,0x00000000,0x000400fa, +0x000035fd,0x000035fe,0x00003604,0x000200f8, +0x000035fe,0x000500bc,0x0000002f,0x00003603, +0x00003483,0x00003498,0x000200f9,0x00003604, +0x000200f8,0x00003604,0x000700f5,0x0000002f, +0x00003605,0x000035fd,0x000035c5,0x00003603, +0x000035fe,0x000300f7,0x0000360c,0x00000000, +0x000400fa,0x00003605,0x00003606,0x0000360c, +0x000200f8,0x00003606,0x000500bc,0x0000002f, +0x0000360b,0x0000348a,0x0000349f,0x000200f9, +0x0000360c,0x000200f8,0x0000360c,0x000700f5, +0x0000002f,0x0000360d,0x00003605,0x00003604, +0x0000360b,0x00003606,0x000400a8,0x0000002f, +0x0000360e,0x0000360d,0x000300f7,0x000035ca, +0x00000000,0x000400fa,0x0000360e,0x000035c9, +0x000035ca,0x000200f8,0x000035c9,0x000200f9, +0x000035f6,0x000200f8,0x000035ca,0x00050081, +0x0000006c,0x000035cd,0x00006124,0x00006122, +0x0005008e,0x0000006c,0x000035ce,0x000035cd, +0x000002fd,0x00050095,0x0000013d,0x0000361e, +0x000034df,0x00000138,0x00050051,0x00000006, +0x0000361f,0x0000361e,0x00000001,0x00050051, +0x00000006,0x00003620,0x0000361e,0x00000000, +0x00050080,0x00000006,0x00003625,0x000034e6, +0x0000361f,0x00050050,0x00000007,0x00003626, +0x00003620,0x00003625,0x0004007c,0x00000014, +0x00003616,0x00003626,0x00060041,0x0000016c, +0x000035d3,0x00003616,0x0000016b,0x0000016b, +0x00050051,0x00000027,0x000035d5,0x000035ce, +0x00000000,0x0004007c,0x00000006,0x0000362c, +0x000035d5,0x000500c7,0x00000006,0x0000362e, +0x0000362c,0x00000241,0x000500ab,0x0000002f, +0x0000362f,0x0000362e,0x00000138,0x000300f7, +0x00003636,0x00000000,0x000400fa,0x0000362f, +0x00003630,0x00003633,0x000200f8,0x00003633, +0x000500c5,0x00000006,0x00003635,0x0000362c, +0x00000241,0x000200f9,0x00003636,0x000200f8, +0x00003630,0x000400c8,0x00000006,0x00003632, +0x0000362c,0x000200f9,0x00003636,0x000200f8, +0x00003636,0x000700f5,0x00000006,0x00005f0e, +0x00003632,0x00003630,0x00003635,0x00003633, +0x000700ed,0x00000006,0x000035d7,0x000035d3, +0x00000142,0x00000138,0x00005f0e,0x00060041, +0x0000016c,0x000035d9,0x00003616,0x0000016b, +0x00000264,0x00050051,0x00000027,0x000035db, +0x000035ce,0x00000001,0x0004007c,0x00000006, +0x0000363d,0x000035db,0x000500c7,0x00000006, +0x0000363f,0x0000363d,0x00000241,0x000500ab, +0x0000002f,0x00003640,0x0000363f,0x00000138, +0x000300f7,0x00003647,0x00000000,0x000400fa, +0x00003640,0x00003641,0x00003644,0x000200f8, +0x00003644,0x000500c5,0x00000006,0x00003646, +0x0000363d,0x00000241,0x000200f9,0x00003647, +0x000200f8,0x00003641,0x000400c8,0x00000006, +0x00003643,0x0000363d,0x000200f9,0x00003647, +0x000200f8,0x00003647,0x000700f5,0x00000006, +0x00005f0f,0x00003643,0x00003641,0x00003646, +0x00003644,0x000700ed,0x00000006,0x000035dd, +0x000035d9,0x00000142,0x00000138,0x00005f0f, +0x00060041,0x0000016c,0x000035df,0x00003616, +0x0000016b,0x00000315,0x00050051,0x00000027, +0x000035e1,0x000035ce,0x00000002,0x0004007c, +0x00000006,0x0000364e,0x000035e1,0x000500c7, +0x00000006,0x00003650,0x0000364e,0x00000241, +0x000500ab,0x0000002f,0x00003651,0x00003650, +0x00000138,0x000300f7,0x00003658,0x00000000, +0x000400fa,0x00003651,0x00003652,0x00003655, +0x000200f8,0x00003655,0x000500c5,0x00000006, +0x00003657,0x0000364e,0x00000241,0x000200f9, +0x00003658,0x000200f8,0x00003652,0x000400c8, +0x00000006,0x00003654,0x0000364e,0x000200f9, +0x00003658,0x000200f8,0x00003658,0x000700f5, +0x00000006,0x00005f10,0x00003654,0x00003652, +0x00003657,0x00003655,0x000700ed,0x00000006, +0x000035e3,0x000035df,0x00000142,0x00000138, +0x00005f10,0x00060041,0x0000016c,0x000035e5, +0x00003616,0x0000016b,0x0000031d,0x000300f7, +0x00003669,0x00000000,0x000400fa,0x0000362f, +0x00003663,0x00003666,0x000200f8,0x00003666, +0x000500c5,0x00000006,0x00003668,0x0000362c, +0x00000241,0x000200f9,0x00003669,0x000200f8, +0x00003663,0x000400c8,0x00000006,0x00003665, +0x0000362c,0x000200f9,0x00003669,0x000200f8, +0x00003669,0x000700f5,0x00000006,0x00005f11, +0x00003665,0x00003663,0x00003668,0x00003666, +0x000700ef,0x00000006,0x000035e9,0x000035e5, +0x00000142,0x00000138,0x00005f11,0x00060041, +0x0000016c,0x000035eb,0x00003616,0x0000016b, +0x00000325,0x000300f7,0x0000367a,0x00000000, +0x000400fa,0x00003640,0x00003674,0x00003677, +0x000200f8,0x00003677,0x000500c5,0x00000006, +0x00003679,0x0000363d,0x00000241,0x000200f9, +0x0000367a,0x000200f8,0x00003674,0x000400c8, +0x00000006,0x00003676,0x0000363d,0x000200f9, +0x0000367a,0x000200f8,0x0000367a,0x000700f5, +0x00000006,0x00005f12,0x00003676,0x00003674, +0x00003679,0x00003677,0x000700ef,0x00000006, +0x000035ef,0x000035eb,0x00000142,0x00000138, +0x00005f12,0x00060041,0x0000016c,0x000035f1, +0x00003616,0x0000016b,0x0000032d,0x000300f7, +0x0000368b,0x00000000,0x000400fa,0x00003651, +0x00003685,0x00003688,0x000200f8,0x00003688, +0x000500c5,0x00000006,0x0000368a,0x0000364e, +0x00000241,0x000200f9,0x0000368b,0x000200f8, +0x00003685,0x000400c8,0x00000006,0x00003687, +0x0000364e,0x000200f9,0x0000368b,0x000200f8, +0x0000368b,0x000700f5,0x00000006,0x00005f13, +0x00003687,0x00003685,0x0000368a,0x00003688, +0x000700ef,0x00000006,0x000035f5,0x000035f1, +0x00000142,0x00000138,0x00005f13,0x000200f9, +0x000035f6,0x000200f8,0x000035f6,0x000200f9, +0x000013c7,0x000200f8,0x000013c7,0x000200f9, +0x000013be,0x000200f8,0x000013bd,0x000200f9, +0x00002608,0x000200f8,0x00002608,0x000700f5, +0x00000006,0x00005f20,0x00000138,0x000013bd, +0x00002618,0x00002616,0x000500b0,0x0000002f, +0x0000260b,0x00005f20,0x00000470,0x000400f6, +0x00002619,0x00002616,0x00000000,0x000400fa, +0x0000260b,0x0000260c,0x00002619,0x000200f8, +0x0000260c,0x00050084,0x00000006,0x0000260f, +0x00000470,0x000012dd,0x00050080,0x00000006, +0x00002611,0x0000260f,0x00005f20,0x000300f7, +0x000026d4,0x00000000,0x000300fb,0x00000138, +0x000026b2,0x000200f8,0x000026b2,0x00050041, +0x000001bb,0x000026b3,0x000001b9,0x00000434, +0x0004003d,0x00000006,0x000026b4,0x000026b3, +0x000500aa,0x0000002f,0x000026b5,0x000026b4, +0x00000138,0x000300f7,0x000026b8,0x00000000, +0x000400fa,0x000026b5,0x000026b6,0x000026b8, +0x000200f8,0x000026b6,0x000200f9,0x000026d4, +0x000200f8,0x000026b8,0x000500aa,0x0000002f, +0x000026bb,0x000026b4,0x00000280,0x000300f7, +0x000026c2,0x00000000,0x000400fa,0x000026bb, +0x000026bc,0x000026c2,0x000200f8,0x000026bc, +0x00050084,0x00000006,0x000026be,0x000000ec, +0x00002611,0x00050041,0x00000266,0x000026bf, +0x000001b9,0x0000031d,0x0004003d,0x00000007, +0x000026c0,0x000026bf,0x00050051,0x00000006, +0x000026ec,0x000026c0,0x00000000,0x00050095, +0x0000013d,0x000026ee,0x000026ec,0x000026be, +0x00050051,0x00000006,0x000026ef,0x000026ee, +0x00000001,0x00050051,0x00000006,0x000026f0, +0x000026ee,0x00000000,0x00050051,0x00000006, +0x000026f3,0x000026c0,0x00000001,0x00050080, +0x00000006,0x000026f5,0x000026f3,0x000026ef, +0x00050050,0x00000007,0x000026f6,0x000026f0, +0x000026f5,0x0004007c,0x00000014,0x000026e6, +0x000026f6,0x00060041,0x0000016c,0x000026dd, +0x000026e6,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x000026de,0x000026dd,0x00000002, +0x00000004,0x000200f9,0x000026d4,0x000200f8, +0x000026c2,0x000500c2,0x00000006,0x000026c4, +0x00002611,0x00000264,0x00050084,0x00000006, +0x000026c5,0x000000ec,0x000026c4,0x00050041, +0x00000266,0x000026c6,0x000001b9,0x0000031d, +0x0004003d,0x00000007,0x000026c7,0x000026c6, +0x00050051,0x00000006,0x0000270d,0x000026c7, +0x00000000,0x00050095,0x0000013d,0x0000270f, +0x0000270d,0x000026c5,0x00050051,0x00000006, +0x00002710,0x0000270f,0x00000001,0x00050051, +0x00000006,0x00002711,0x0000270f,0x00000000, +0x00050051,0x00000006,0x00002714,0x000026c7, +0x00000001,0x00050080,0x00000006,0x00002716, +0x00002714,0x00002710,0x00050050,0x00000007, +0x00002717,0x00002711,0x00002716,0x0004007c, +0x00000014,0x00002707,0x00002717,0x00060041, +0x0000016c,0x000026fe,0x00002707,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x000026ff, +0x000026fe,0x00000002,0x00000004,0x000500c7, +0x00000006,0x000026ca,0x00002611,0x00000142, +0x000500ab,0x0000002f,0x000026cb,0x000026ca, +0x00000138,0x000300f7,0x000026d2,0x00000000, +0x000400fa,0x000026cb,0x000026cc,0x000026cf, +0x000200f8,0x000026cf,0x000500c7,0x00000006, +0x000026d1,0x000026ff,0x0000045c,0x000200f9, +0x000026d2,0x000200f8,0x000026cc,0x000500c2, +0x00000006,0x000026ce,0x000026ff,0x0000035a, +0x000200f9,0x000026d2,0x000200f8,0x000026d2, +0x000700f5,0x00000006,0x00005f2a,0x000026ce, +0x000026cc,0x000026d1,0x000026cf,0x000200f9, +0x000026d4,0x000200f8,0x000026d4,0x000900f5, +0x00000006,0x00005f2b,0x00002611,0x000026b6, +0x000026de,0x000026bc,0x00005f2a,0x000026d2, +0x00050041,0x000001bb,0x00002728,0x000001b9, +0x00000206,0x0004003d,0x00000006,0x00002729, +0x00002728,0x00050084,0x00000006,0x0000272a, +0x00005f2b,0x00002729,0x00050041,0x00000266, +0x0000272b,0x000001b9,0x00000315,0x0004003d, +0x00000007,0x0000272c,0x0000272b,0x00050051, +0x00000006,0x00002747,0x0000272c,0x00000000, +0x00050095,0x0000013d,0x00002749,0x00002747, +0x0000272a,0x00050051,0x00000006,0x0000274a, +0x00002749,0x00000001,0x00050051,0x00000006, +0x0000274b,0x00002749,0x00000000,0x00050051, +0x00000006,0x0000274e,0x0000272c,0x00000001, +0x00050080,0x00000006,0x00002750,0x0000274e, +0x0000274a,0x00050095,0x0000013d,0x0000276a, +0x0000274b,0x00000138,0x00050051,0x00000006, +0x0000276b,0x0000276a,0x00000001,0x00050051, +0x00000006,0x0000276c,0x0000276a,0x00000000, +0x00050080,0x00000006,0x00002771,0x00002750, +0x0000276b,0x00050050,0x00000007,0x00002772, +0x0000276c,0x00002771,0x0004007c,0x00000014, +0x00002762,0x00002772,0x00060041,0x0000016c, +0x00002759,0x00002762,0x0000016b,0x0000016b, +0x0006003d,0x00000006,0x0000275a,0x00002759, +0x00000002,0x00000004,0x0004007c,0x00000027, +0x00002730,0x0000275a,0x00050095,0x0000013d, +0x0000278b,0x0000274b,0x000000ec,0x00050051, +0x00000006,0x0000278c,0x0000278b,0x00000001, +0x00050051,0x00000006,0x0000278d,0x0000278b, +0x00000000,0x00050080,0x00000006,0x00002792, +0x00002750,0x0000278c,0x00050050,0x00000007, +0x00002793,0x0000278d,0x00002792,0x0004007c, +0x00000014,0x00002783,0x00002793,0x00060041, +0x0000016c,0x0000277a,0x00002783,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000277b, +0x0000277a,0x00000002,0x00000004,0x0004007c, +0x00000027,0x00002733,0x0000277b,0x00050041, +0x000001bb,0x00002734,0x000001b9,0x000003b6, +0x0004003d,0x00000006,0x00002735,0x00002734, +0x000500aa,0x0000002f,0x00002736,0x00002735, +0x00000142,0x000300f7,0x0000273c,0x00000000, +0x000400fa,0x00002736,0x00002737,0x00002738, +0x000200f8,0x00002738,0x00050095,0x0000013d, +0x000027ac,0x0000274b,0x000001cd,0x00050051, +0x00000006,0x000027ad,0x000027ac,0x00000001, +0x00050051,0x00000006,0x000027ae,0x000027ac, +0x00000000,0x00050080,0x00000006,0x000027b3, +0x00002750,0x000027ad,0x00050050,0x00000007, +0x000027b4,0x000027ae,0x000027b3,0x0004007c, +0x00000014,0x000027a4,0x000027b4,0x00060041, +0x0000016c,0x0000279b,0x000027a4,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000279c, +0x0000279b,0x00000002,0x00000004,0x0004007c, +0x00000027,0x0000273b,0x0000279c,0x000200f9, +0x0000273c,0x000200f8,0x00002737,0x000200f9, +0x0000273c,0x000200f8,0x0000273c,0x000700f5, +0x00000027,0x00005f2c,0x00000426,0x00002737, +0x0000273b,0x00002738,0x00060050,0x0000006c, +0x00002741,0x00002730,0x00002733,0x00005f2c, +0x000300f7,0x000027fa,0x00000000,0x000300fb, +0x00000138,0x000027c6,0x000200f8,0x000027c6, +0x00050041,0x00000266,0x000027c7,0x000001b9, +0x00000325,0x0004003d,0x00000007,0x000027c8, +0x000027c7,0x00050051,0x00000006,0x000027ff, +0x000027c8,0x00000000,0x000500aa,0x0000002f, +0x00002800,0x000027ff,0x00000138,0x000300f7, +0x00002805,0x00000000,0x000400fa,0x00002800, +0x00002801,0x00002805,0x000200f8,0x00002801, +0x00050051,0x00000006,0x00002803,0x000027c8, +0x00000001,0x000500aa,0x0000002f,0x00002804, +0x00002803,0x00000138,0x000200f9,0x00002805, +0x000200f8,0x00002805,0x000700f5,0x0000002f, +0x00002806,0x00002800,0x000027c6,0x00002804, +0x00002801,0x000300f7,0x000027cc,0x00000000, +0x000400fa,0x00002806,0x000027ca,0x000027cc, +0x000200f8,0x000027ca,0x000200f9,0x000027fa, +0x000200f8,0x000027cc,0x000200f9,0x000027cd, +0x000200f8,0x000027cd,0x000700f5,0x00000006, +0x00005f2d,0x00000138,0x000027cc,0x000027f7, +0x000027d1,0x000500b0,0x0000002f,0x000027d0, +0x00005f2d,0x00000470,0x000400f6,0x000027f8, +0x000027d1,0x00000000,0x000400fa,0x000027d0, +0x000027d1,0x000027f8,0x000200f8,0x000027d1, +0x00050084,0x00000006,0x000027d3,0x000001db, +0x00005f2d,0x00050095,0x0000013d,0x0000281f, +0x000027ff,0x000027d3,0x00050051,0x00000006, +0x00002820,0x0000281f,0x00000001,0x00050051, +0x00000006,0x00002821,0x0000281f,0x00000000, +0x00050051,0x00000006,0x00002824,0x000027c8, +0x00000001,0x00050080,0x00000006,0x00002826, +0x00002824,0x00002820,0x00050050,0x00000007, +0x00002827,0x00002821,0x00002826,0x0004007c, +0x00000014,0x00002817,0x00002827,0x00060041, +0x0000016c,0x0000280e,0x00002817,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x0000280f, +0x0000280e,0x00000002,0x00000004,0x0004007c, +0x00000027,0x000027d8,0x0000280f,0x00050080, +0x00000006,0x000027da,0x000027d3,0x000000ec, +0x00050095,0x0000013d,0x00002840,0x000027ff, +0x000027da,0x00050051,0x00000006,0x00002841, +0x00002840,0x00000001,0x00050051,0x00000006, +0x00002842,0x00002840,0x00000000,0x00050080, +0x00000006,0x00002847,0x00002824,0x00002841, +0x00050050,0x00000007,0x00002848,0x00002842, +0x00002847,0x0004007c,0x00000014,0x00002838, +0x00002848,0x00060041,0x0000016c,0x0000282f, +0x00002838,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002830,0x0000282f,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000027de, +0x00002830,0x00050080,0x00000006,0x000027e0, +0x000027d3,0x000001cd,0x00050095,0x0000013d, +0x00002861,0x000027ff,0x000027e0,0x00050051, +0x00000006,0x00002862,0x00002861,0x00000001, +0x00050051,0x00000006,0x00002863,0x00002861, +0x00000000,0x00050080,0x00000006,0x00002868, +0x00002824,0x00002862,0x00050050,0x00000007, +0x00002869,0x00002863,0x00002868,0x0004007c, +0x00000014,0x00002859,0x00002869,0x00060041, +0x0000016c,0x00002850,0x00002859,0x0000016b, +0x0000016b,0x0006003d,0x00000006,0x00002851, +0x00002850,0x00000002,0x00000004,0x0004007c, +0x00000027,0x000027e4,0x00002851,0x00050080, +0x00000006,0x000027e6,0x000027d3,0x000001d4, +0x00050095,0x0000013d,0x00002882,0x000027ff, +0x000027e6,0x00050051,0x00000006,0x00002883, +0x00002882,0x00000001,0x00050051,0x00000006, +0x00002884,0x00002882,0x00000000,0x00050080, +0x00000006,0x00002889,0x00002824,0x00002883, +0x00050050,0x00000007,0x0000288a,0x00002884, +0x00002889,0x0004007c,0x00000014,0x0000287a, +0x0000288a,0x00060041,0x0000016c,0x00002871, +0x0000287a,0x0000016b,0x0000016b,0x0006003d, +0x00000006,0x00002872,0x00002871,0x00000002, +0x00000004,0x0004007c,0x00000027,0x000027ea, +0x00002872,0x00070050,0x00000475,0x000027eb, +0x000027d8,0x000027de,0x000027e4,0x000027ea, +0x0008004f,0x0000006c,0x000027ee,0x000027eb, +0x000027eb,0x00000000,0x00000001,0x00000002, +0x00050094,0x00000027,0x000027f0,0x000027ee, +0x00002741,0x00050081,0x00000027,0x000027f3, +0x000027f0,0x000027ea,0x00050041,0x00000028, +0x000027f4,0x000027c3,0x00005f2d,0x0003003e, +0x000027f4,0x000027f3,0x00050080,0x00000006, +0x000027f7,0x00005f2d,0x00000264,0x000200f9, +0x000027cd,0x000200f8,0x000027f8,0x0004003d, +0x0000006c,0x000027f9,0x000027c3,0x000200f9, +0x000027fa,0x000200f8,0x000027fa,0x000700f5, +0x0000006c,0x00005f2e,0x00002741,0x000027ca, +0x000027f9,0x000027f8,0x00050041,0x0000006d, +0x00002615,0x000025da,0x00005f20,0x0003003e, +0x00002615,0x00005f2e,0x000200f9,0x00002616, +0x000200f8,0x00002616,0x00050080,0x00000006, +0x00002618,0x00005f20,0x00000264,0x000200f9, +0x00002608,0x000200f8,0x00002619,0x00050041, +0x000001bb,0x0000261a,0x000001b9,0x000004c1, +0x0004003d,0x00000006,0x0000261b,0x0000261a, +0x00050080,0x00000006,0x0000261d,0x0000261b, +0x000012dd,0x00050041,0x000001bb,0x0000261e, +0x000001b9,0x0000034a,0x0004003d,0x00000006, +0x0000261f,0x0000261e,0x00050084,0x00000006, +0x00002621,0x000001c4,0x0000261d,0x00050080, +0x00000006,0x00002622,0x0000261f,0x00002621, +0x000200f9,0x00002623,0x000200f8,0x00002623, +0x000700f5,0x00000006,0x00005f21,0x00000138, +0x00002619,0x0000264a,0x00002627,0x000500b0, +0x0000002f,0x00002626,0x00005f21,0x00000470, +0x000400f6,0x0000264b,0x00002627,0x00000000, +0x000400fa,0x00002626,0x00002627,0x0000264b, +0x000200f8,0x00002627,0x00050084,0x00000006, +0x0000262a,0x000001d4,0x00005f21,0x00050080, +0x00000006,0x0000262b,0x00002622,0x0000262a, +0x00050041,0x00000266,0x0000262d,0x000001b9, +0x0000016b,0x0004003d,0x00000007,0x0000262e, +0x0000262d,0x00060041,0x00000028,0x0000262f, +0x000025da,0x00005f21,0x00000138,0x0004003d, +0x00000027,0x00002630,0x0000262f,0x0004007c, +0x00000006,0x00002890,0x00002630,0x00050051, +0x00000006,0x000028a9,0x0000262e,0x00000000, +0x00050095,0x0000013d,0x000028ab,0x000028a9, +0x0000262b,0x00050051,0x00000006,0x000028ac, +0x000028ab,0x00000001,0x00050051,0x00000006, +0x000028ad,0x000028ab,0x00000000,0x00050051, +0x00000006,0x000028b0,0x0000262e,0x00000001, +0x00050080,0x00000006,0x000028b2,0x000028b0, +0x000028ac,0x00050050,0x00000007,0x000028b3, +0x000028ad,0x000028b2,0x0004007c,0x00000014, +0x000028a3,0x000028b3,0x00060041,0x0000016c, +0x0000289b,0x000028a3,0x0000016b,0x0000016b, +0x0005003e,0x0000289b,0x00002890,0x00000002, +0x00000004,0x00050080,0x00000006,0x00002636, +0x0000262b,0x000000ec,0x00060041,0x00000028, +0x0000263a,0x000025da,0x00005f21,0x00000142, +0x0004003d,0x00000027,0x0000263b,0x0000263a, +0x0004007c,0x00000006,0x000028b9,0x0000263b, +0x00050095,0x0000013d,0x000028d4,0x000028a9, +0x00002636,0x00050051,0x00000006,0x000028d5, +0x000028d4,0x00000001,0x00050051,0x00000006, +0x000028d6,0x000028d4,0x00000000,0x00050080, +0x00000006,0x000028db,0x000028b0,0x000028d5, +0x00050050,0x00000007,0x000028dc,0x000028d6, +0x000028db,0x0004007c,0x00000014,0x000028cc, +0x000028dc,0x00060041,0x0000016c,0x000028c4, +0x000028cc,0x0000016b,0x0000016b,0x0005003e, +0x000028c4,0x000028b9,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002641,0x0000262b, +0x000001cd,0x00060041,0x00000028,0x00002645, +0x000025da,0x00005f21,0x00000280,0x0004003d, +0x00000027,0x00002646,0x00002645,0x0004007c, +0x00000006,0x000028e2,0x00002646,0x00050095, +0x0000013d,0x000028fd,0x000028a9,0x00002641, +0x00050051,0x00000006,0x000028fe,0x000028fd, +0x00000001,0x00050051,0x00000006,0x000028ff, +0x000028fd,0x00000000,0x00050080,0x00000006, +0x00002904,0x000028b0,0x000028fe,0x00050050, +0x00000007,0x00002905,0x000028ff,0x00002904, +0x0004007c,0x00000014,0x000028f5,0x00002905, +0x00060041,0x0000016c,0x000028ed,0x000028f5, +0x0000016b,0x0000016b,0x0005003e,0x000028ed, +0x000028e2,0x00000002,0x00000004,0x00050080, +0x00000006,0x0000264a,0x00005f21,0x00000264, +0x000200f9,0x00002623,0x000200f8,0x0000264b, +0x00050080,0x00000006,0x0000264d,0x00002622, +0x00000500,0x00050041,0x00000266,0x0000264e, +0x000001b9,0x0000016b,0x0004003d,0x00000007, +0x0000264f,0x0000264e,0x00060041,0x00000028, +0x00002650,0x000025da,0x00000315,0x00000138, +0x0004003d,0x00000027,0x00002651,0x00002650, +0x0004007c,0x00000006,0x0000290b,0x00002651, +0x00050051,0x00000006,0x00002924,0x0000264f, +0x00000000,0x00050095,0x0000013d,0x00002926, +0x00002924,0x0000264d,0x00050051,0x00000006, +0x00002927,0x00002926,0x00000001,0x00050051, +0x00000006,0x00002928,0x00002926,0x00000000, +0x00050051,0x00000006,0x0000292b,0x0000264f, +0x00000001,0x00050080,0x00000006,0x0000292d, +0x0000292b,0x00002927,0x00050050,0x00000007, +0x0000292e,0x00002928,0x0000292d,0x0004007c, +0x00000014,0x0000291e,0x0000292e,0x00060041, +0x0000016c,0x00002916,0x0000291e,0x0000016b, +0x0000016b,0x0005003e,0x00002916,0x0000290b, 0x00000002,0x00000004,0x00050080,0x00000006, -0x0000253d,0x00002527,0x00000194,0x00060041, -0x00000028,0x00002541,0x000024d6,0x00005af1, -0x00000247,0x0004003d,0x00000027,0x00002542, -0x00002541,0x0004007c,0x00000006,0x000027de, -0x00002542,0x00050095,0x00000130,0x000027f9, -0x000027a5,0x0000253d,0x00050051,0x00000006, -0x000027fa,0x000027f9,0x00000001,0x00050051, -0x00000006,0x000027fb,0x000027f9,0x00000000, -0x00050080,0x00000006,0x00002800,0x000027ac, -0x000027fa,0x00050050,0x00000007,0x00002801, -0x000027fb,0x00002800,0x0004007c,0x00000014, -0x000027f1,0x00002801,0x00060041,0x0000015f, -0x000027e9,0x000027f1,0x0000015e,0x0000015e, -0x0005003e,0x000027e9,0x000027de,0x00000002, -0x00000004,0x00050080,0x00000006,0x00002546, -0x00005af1,0x0000022b,0x000200f9,0x0000251f, -0x000200f8,0x00002547,0x00050080,0x00000006, -0x00002549,0x0000251e,0x000004c7,0x00050041, -0x0000022d,0x0000254a,0x00000180,0x0000015e, -0x0004003d,0x00000007,0x0000254b,0x0000254a, -0x00060041,0x00000028,0x0000254c,0x000024d6, -0x000002dc,0x0000012b,0x0004003d,0x00000027, -0x0000254d,0x0000254c,0x0004007c,0x00000006, -0x00002807,0x0000254d,0x00050051,0x00000006, -0x00002820,0x0000254b,0x00000000,0x00050095, -0x00000130,0x00002822,0x00002820,0x00002549, -0x00050051,0x00000006,0x00002823,0x00002822, -0x00000001,0x00050051,0x00000006,0x00002824, -0x00002822,0x00000000,0x00050051,0x00000006, -0x00002827,0x0000254b,0x00000001,0x00050080, -0x00000006,0x00002829,0x00002827,0x00002823, -0x00050050,0x00000007,0x0000282a,0x00002824, -0x00002829,0x0004007c,0x00000014,0x0000281a, -0x0000282a,0x00060041,0x0000015f,0x00002812, -0x0000281a,0x0000015e,0x0000015e,0x0005003e, -0x00002812,0x00002807,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002550,0x0000251e, -0x000004d2,0x00060041,0x00000028,0x00002553, -0x000024d6,0x000002dc,0x00000135,0x0004003d, -0x00000027,0x00002554,0x00002553,0x0004007c, -0x00000006,0x00002830,0x00002554,0x00050095, -0x00000130,0x0000284b,0x00002820,0x00002550, -0x00050051,0x00000006,0x0000284c,0x0000284b, -0x00000001,0x00050051,0x00000006,0x0000284d, -0x0000284b,0x00000000,0x00050080,0x00000006, -0x00002852,0x00002827,0x0000284c,0x00050050, -0x00000007,0x00002853,0x0000284d,0x00002852, -0x0004007c,0x00000014,0x00002843,0x00002853, -0x00060041,0x0000015f,0x0000283b,0x00002843, -0x0000015e,0x0000015e,0x0005003e,0x0000283b, -0x00002830,0x00000002,0x00000004,0x00050080, -0x00000006,0x00002557,0x0000251e,0x000004dd, -0x00060041,0x00000028,0x0000255a,0x000024d6, -0x000002dc,0x00000247,0x0004003d,0x00000027, -0x0000255b,0x0000255a,0x0004007c,0x00000006, -0x00002859,0x0000255b,0x00050095,0x00000130, -0x00002874,0x00002820,0x00002557,0x00050051, -0x00000006,0x00002875,0x00002874,0x00000001, -0x00050051,0x00000006,0x00002876,0x00002874, -0x00000000,0x00050080,0x00000006,0x0000287b, -0x00002827,0x00002875,0x00050050,0x00000007, -0x0000287c,0x00002876,0x0000287b,0x0004007c, -0x00000014,0x0000286c,0x0000287c,0x00060041, -0x0000015f,0x00002864,0x0000286c,0x0000015e, -0x0000015e,0x0005003e,0x00002864,0x00002859, +0x00002654,0x00002622,0x0000050b,0x00060041, +0x00000028,0x00002657,0x000025da,0x00000315, +0x00000142,0x0004003d,0x00000027,0x00002658, +0x00002657,0x0004007c,0x00000006,0x00002934, +0x00002658,0x00050095,0x0000013d,0x0000294f, +0x00002924,0x00002654,0x00050051,0x00000006, +0x00002950,0x0000294f,0x00000001,0x00050051, +0x00000006,0x00002951,0x0000294f,0x00000000, +0x00050080,0x00000006,0x00002956,0x0000292b, +0x00002950,0x00050050,0x00000007,0x00002957, +0x00002951,0x00002956,0x0004007c,0x00000014, +0x00002947,0x00002957,0x00060041,0x0000016c, +0x0000293f,0x00002947,0x0000016b,0x0000016b, +0x0005003e,0x0000293f,0x00002934,0x00000002, +0x00000004,0x00050080,0x00000006,0x0000265b, +0x00002622,0x00000516,0x00060041,0x00000028, +0x0000265e,0x000025da,0x00000315,0x00000280, +0x0004003d,0x00000027,0x0000265f,0x0000265e, +0x0004007c,0x00000006,0x0000295d,0x0000265f, +0x00050095,0x0000013d,0x00002978,0x00002924, +0x0000265b,0x00050051,0x00000006,0x00002979, +0x00002978,0x00000001,0x00050051,0x00000006, +0x0000297a,0x00002978,0x00000000,0x00050080, +0x00000006,0x0000297f,0x0000292b,0x00002979, +0x00050050,0x00000007,0x00002980,0x0000297a, +0x0000297f,0x0004007c,0x00000014,0x00002970, +0x00002980,0x00060041,0x0000016c,0x00002968, +0x00002970,0x0000016b,0x0000016b,0x0005003e, +0x00002968,0x0000295d,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002662,0x00002622, +0x00000521,0x00050041,0x000001bb,0x00002665, +0x000001b9,0x00000523,0x0004003d,0x00000006, +0x00002666,0x00002665,0x00050095,0x0000013d, +0x00002998,0x00002924,0x00002662,0x00050051, +0x00000006,0x00002999,0x00002998,0x00000001, +0x00050051,0x00000006,0x0000299a,0x00002998, +0x00000000,0x00050080,0x00000006,0x0000299f, +0x0000292b,0x00002999,0x00050050,0x00000007, +0x000029a0,0x0000299a,0x0000299f,0x0004007c, +0x00000014,0x00002990,0x000029a0,0x00060041, +0x0000016c,0x00002988,0x00002990,0x0000016b, +0x0000016b,0x0005003e,0x00002988,0x00002666, 0x00000002,0x00000004,0x00050080,0x00000006, -0x0000255e,0x0000251e,0x000004e8,0x00050041, -0x00000182,0x00002561,0x00000180,0x000004ea, -0x0004003d,0x00000006,0x00002562,0x00002561, -0x00050095,0x00000130,0x00002894,0x00002820, -0x0000255e,0x00050051,0x00000006,0x00002895, -0x00002894,0x00000001,0x00050051,0x00000006, -0x00002896,0x00002894,0x00000000,0x00050080, -0x00000006,0x0000289b,0x00002827,0x00002895, -0x00050050,0x00000007,0x0000289c,0x00002896, -0x0000289b,0x0004007c,0x00000014,0x0000288c, -0x0000289c,0x00060041,0x0000015f,0x00002884, -0x0000288c,0x0000015e,0x0000015e,0x0005003e, -0x00002884,0x00002562,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002565,0x0000251e, -0x000004f4,0x00050095,0x00000130,0x000028b4, -0x00002820,0x00002565,0x00050051,0x00000006, -0x000028b5,0x000028b4,0x00000001,0x00050051, -0x00000006,0x000028b6,0x000028b4,0x00000000, -0x00050080,0x00000006,0x000028bb,0x00002827, -0x000028b5,0x00050050,0x00000007,0x000028bc, -0x000028b6,0x000028bb,0x0004007c,0x00000014, -0x000028ac,0x000028bc,0x00060041,0x0000015f, -0x000028a4,0x000028ac,0x0000015e,0x0000015e, -0x0005003e,0x000028a4,0x000011de,0x00000002, -0x00000004,0x00050080,0x00000006,0x0000256b, -0x0000251e,0x000004fe,0x00050095,0x00000130, -0x000028d4,0x00002820,0x0000256b,0x00050051, -0x00000006,0x000028d5,0x000028d4,0x00000001, -0x00050051,0x00000006,0x000028d6,0x000028d4, -0x00000000,0x00050080,0x00000006,0x000028db, -0x00002827,0x000028d5,0x00050050,0x00000007, -0x000028dc,0x000028d6,0x000028db,0x0004007c, -0x00000014,0x000028cc,0x000028dc,0x00060041, -0x0000015f,0x000028c4,0x000028cc,0x0000015e, -0x0000015e,0x0005003e,0x000028c4,0x00000500, +0x00002669,0x00002622,0x0000052d,0x00050095, +0x0000013d,0x000029b8,0x00002924,0x00002669, +0x00050051,0x00000006,0x000029b9,0x000029b8, +0x00000001,0x00050051,0x00000006,0x000029ba, +0x000029b8,0x00000000,0x00050080,0x00000006, +0x000029bf,0x0000292b,0x000029b9,0x00050050, +0x00000007,0x000029c0,0x000029ba,0x000029bf, +0x0004007c,0x00000014,0x000029b0,0x000029c0, +0x00060041,0x0000016c,0x000029a8,0x000029b0, +0x0000016b,0x0000016b,0x0005003e,0x000029a8, +0x000012dd,0x00000002,0x00000004,0x00050080, +0x00000006,0x0000266f,0x00002622,0x00000537, +0x00050095,0x0000013d,0x000029d8,0x00002924, +0x0000266f,0x00050051,0x00000006,0x000029d9, +0x000029d8,0x00000001,0x00050051,0x00000006, +0x000029da,0x000029d8,0x00000000,0x00050080, +0x00000006,0x000029df,0x0000292b,0x000029d9, +0x00050050,0x00000007,0x000029e0,0x000029da, +0x000029df,0x0004007c,0x00000014,0x000029d0, +0x000029e0,0x00060041,0x0000016c,0x000029c8, +0x000029d0,0x0000016b,0x0000016b,0x0005003e, +0x000029c8,0x00000539,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002674,0x00002622, +0x00000541,0x00050095,0x0000013d,0x000029f8, +0x00002924,0x00002674,0x00050051,0x00000006, +0x000029f9,0x000029f8,0x00000001,0x00050051, +0x00000006,0x000029fa,0x000029f8,0x00000000, +0x00050080,0x00000006,0x000029ff,0x0000292b, +0x000029f9,0x00050050,0x00000007,0x00002a00, +0x000029fa,0x000029ff,0x0004007c,0x00000014, +0x000029f0,0x00002a00,0x00060041,0x0000016c, +0x000029e8,0x000029f0,0x0000016b,0x0000016b, +0x0005003e,0x000029e8,0x00000543,0x00000002, +0x00000004,0x00050041,0x0000006d,0x00002678, +0x000025da,0x0000016b,0x0004003d,0x0000006c, +0x00002679,0x00002678,0x0004009c,0x0000054d, +0x0000267a,0x00002679,0x0004009a,0x0000002f, +0x0000267b,0x0000267a,0x000400a8,0x0000002f, +0x0000267c,0x0000267b,0x000300f7,0x00002682, +0x00000000,0x000400fa,0x0000267c,0x0000267d, +0x00002682,0x000200f8,0x0000267d,0x00050041, +0x0000006d,0x0000267e,0x000025da,0x00000264, +0x0004003d,0x0000006c,0x0000267f,0x0000267e, +0x0004009c,0x0000054d,0x00002680,0x0000267f, +0x0004009a,0x0000002f,0x00002681,0x00002680, +0x000200f9,0x00002682,0x000200f8,0x00002682, +0x000700f5,0x0000002f,0x00002683,0x0000267b, +0x0000264b,0x00002681,0x0000267d,0x000400a8, +0x0000002f,0x00002684,0x00002683,0x000300f7, +0x0000268a,0x00000000,0x000400fa,0x00002684, +0x00002685,0x0000268a,0x000200f8,0x00002685, +0x00050041,0x0000006d,0x00002686,0x000025da, +0x00000315,0x0004003d,0x0000006c,0x00002687, +0x00002686,0x0004009c,0x0000054d,0x00002688, +0x00002687,0x0004009a,0x0000002f,0x00002689, +0x00002688,0x000200f9,0x0000268a,0x000200f8, +0x0000268a,0x000700f5,0x0000002f,0x0000268b, +0x00002683,0x00002682,0x00002689,0x00002685, +0x0004003d,0x0000006c,0x0000268d,0x00002678, +0x00050041,0x0000006d,0x0000268e,0x000025da, +0x00000264,0x0004003d,0x0000006c,0x0000268f, +0x0000268e,0x0007000c,0x0000006c,0x00002690, +0x00000001,0x00000025,0x0000268d,0x0000268f, +0x00050041,0x0000006d,0x00002691,0x000025da, +0x00000315,0x0004003d,0x0000006c,0x00002692, +0x00002691,0x0007000c,0x0000006c,0x00002693, +0x00000001,0x00000025,0x00002690,0x00002692, +0x0004003d,0x0000006c,0x00002695,0x00002678, +0x0004003d,0x0000006c,0x00002697,0x0000268e, +0x0007000c,0x0000006c,0x00002698,0x00000001, +0x00000028,0x00002695,0x00002697,0x0004003d, +0x0000006c,0x0000269a,0x00002691,0x0007000c, +0x0000006c,0x0000269b,0x00000001,0x00000028, +0x00002698,0x0000269a,0x00060050,0x0000054d, +0x00006125,0x0000268b,0x0000268b,0x0000268b, +0x000600a9,0x0000006c,0x00006126,0x00006125, +0x000060fe,0x0000269b,0x000600a9,0x0000006c, +0x00006128,0x00006125,0x00000576,0x00002693, +0x00050041,0x000001bb,0x00002a50,0x000001b9, +0x000001ba,0x0004003d,0x00000006,0x00002a51, +0x00002a50,0x00050084,0x00000006,0x00002a52, +0x000001db,0x00002a51,0x00050080,0x00000006, +0x00002a53,0x000001c4,0x00002a52,0x00050080, +0x00000006,0x00002a59,0x00002a51,0x0000062f, +0x00050086,0x00000006,0x00002a5a,0x00002a59, +0x000001be,0x00050084,0x00000006,0x00002a4c, +0x000001c4,0x00002a5a,0x00050080,0x00000006, +0x00002a4d,0x00002a53,0x00002a4c,0x00050080, +0x00000006,0x00002a47,0x00002a4d,0x00002a4c, +0x00050084,0x00000006,0x00002a17,0x000001ef, +0x0000261d,0x00050080,0x00000006,0x00002a18, +0x00002a47,0x00002a17,0x00050041,0x00000266, +0x00002a19,0x000001b9,0x00000264,0x0004003d, +0x00000007,0x00002a1a,0x00002a19,0x00050051, +0x00000027,0x00002a1d,0x00006128,0x00000000, +0x0004007c,0x00000006,0x00002a67,0x00002a1d, +0x00050051,0x00000006,0x00002a80,0x00002a1a, +0x00000000,0x00050095,0x0000013d,0x00002a82, +0x00002a80,0x00002a18,0x00050051,0x00000006, +0x00002a83,0x00002a82,0x00000001,0x00050051, +0x00000006,0x00002a84,0x00002a82,0x00000000, +0x00050051,0x00000006,0x00002a87,0x00002a1a, +0x00000001,0x00050080,0x00000006,0x00002a89, +0x00002a87,0x00002a83,0x00050050,0x00000007, +0x00002a8a,0x00002a84,0x00002a89,0x0004007c, +0x00000014,0x00002a7a,0x00002a8a,0x00060041, +0x0000016c,0x00002a72,0x00002a7a,0x0000016b, +0x0000016b,0x0005003e,0x00002a72,0x00002a67, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00002570,0x0000251e,0x00000508,0x00050095, -0x00000130,0x000028f4,0x00002820,0x00002570, -0x00050051,0x00000006,0x000028f5,0x000028f4, -0x00000001,0x00050051,0x00000006,0x000028f6, -0x000028f4,0x00000000,0x00050080,0x00000006, -0x000028fb,0x00002827,0x000028f5,0x00050050, -0x00000007,0x000028fc,0x000028f6,0x000028fb, -0x0004007c,0x00000014,0x000028ec,0x000028fc, -0x00060041,0x0000015f,0x000028e4,0x000028ec, -0x0000015e,0x0000015e,0x0005003e,0x000028e4, -0x0000050a,0x00000002,0x00000004,0x00050041, -0x00000064,0x00002574,0x000024d6,0x0000015e, -0x0004003d,0x00000063,0x00002575,0x00002574, -0x0004009c,0x00000514,0x00002576,0x00002575, -0x0004009a,0x0000002f,0x00002577,0x00002576, -0x000400a8,0x0000002f,0x00002578,0x00002577, -0x000300f7,0x0000257e,0x00000000,0x000400fa, -0x00002578,0x00002579,0x0000257e,0x000200f8, -0x00002579,0x00050041,0x00000064,0x0000257a, -0x000024d6,0x0000022b,0x0004003d,0x00000063, -0x0000257b,0x0000257a,0x0004009c,0x00000514, -0x0000257c,0x0000257b,0x0004009a,0x0000002f, -0x0000257d,0x0000257c,0x000200f9,0x0000257e, -0x000200f8,0x0000257e,0x000700f5,0x0000002f, -0x0000257f,0x00002577,0x00002547,0x0000257d, -0x00002579,0x000400a8,0x0000002f,0x00002580, -0x0000257f,0x000300f7,0x00002586,0x00000000, -0x000400fa,0x00002580,0x00002581,0x00002586, -0x000200f8,0x00002581,0x00050041,0x00000064, -0x00002582,0x000024d6,0x000002dc,0x0004003d, -0x00000063,0x00002583,0x00002582,0x0004009c, -0x00000514,0x00002584,0x00002583,0x0004009a, -0x0000002f,0x00002585,0x00002584,0x000200f9, -0x00002586,0x000200f8,0x00002586,0x000700f5, -0x0000002f,0x00002587,0x0000257f,0x0000257e, -0x00002585,0x00002581,0x0004003d,0x00000063, -0x00002589,0x00002574,0x00050041,0x00000064, -0x0000258a,0x000024d6,0x0000022b,0x0004003d, -0x00000063,0x0000258b,0x0000258a,0x0007000c, -0x00000063,0x0000258c,0x00000001,0x00000025, -0x00002589,0x0000258b,0x00050041,0x00000064, -0x0000258d,0x000024d6,0x000002dc,0x0004003d, -0x00000063,0x0000258e,0x0000258d,0x0007000c, -0x00000063,0x0000258f,0x00000001,0x00000025, -0x0000258c,0x0000258e,0x0004003d,0x00000063, -0x00002591,0x00002574,0x0004003d,0x00000063, -0x00002593,0x0000258a,0x0007000c,0x00000063, -0x00002594,0x00000001,0x00000028,0x00002591, -0x00002593,0x0004003d,0x00000063,0x00002596, -0x0000258d,0x0007000c,0x00000063,0x00002597, -0x00000001,0x00000028,0x00002594,0x00002596, -0x00060050,0x00000514,0x00005ce5,0x00002587, -0x00002587,0x00002587,0x000600a9,0x00000063, -0x00005ce6,0x00005ce5,0x00005cc2,0x00002597, -0x000600a9,0x00000063,0x00005ce8,0x00005ce5, -0x0000053d,0x0000258f,0x00050041,0x00000182, -0x0000294c,0x00000180,0x00000181,0x0004003d, -0x00000006,0x0000294d,0x0000294c,0x00050084, -0x00000006,0x0000294e,0x000001a2,0x0000294d, -0x00050080,0x00000006,0x0000294f,0x0000018b, -0x0000294e,0x00050080,0x00000006,0x00002955, -0x0000294d,0x00005cc3,0x00050086,0x00000006, -0x00002956,0x00002955,0x00000185,0x00050084, -0x00000006,0x00002948,0x0000018b,0x00002956, -0x00050080,0x00000006,0x00002949,0x0000294f, -0x00002948,0x00050080,0x00000006,0x00002943, -0x00002949,0x00002948,0x00050084,0x00000006, -0x00002913,0x000001b6,0x00002519,0x00050080, -0x00000006,0x00002914,0x00002943,0x00002913, -0x00050041,0x0000022d,0x00002915,0x00000180, -0x0000022b,0x0004003d,0x00000007,0x00002916, -0x00002915,0x00050051,0x00000027,0x00002919, -0x00005ce8,0x00000000,0x0004007c,0x00000006, -0x00002963,0x00002919,0x00050051,0x00000006, -0x0000297c,0x00002916,0x00000000,0x00050095, -0x00000130,0x0000297e,0x0000297c,0x00002914, -0x00050051,0x00000006,0x0000297f,0x0000297e, -0x00000001,0x00050051,0x00000006,0x00002980, -0x0000297e,0x00000000,0x00050051,0x00000006, -0x00002983,0x00002916,0x00000001,0x00050080, -0x00000006,0x00002985,0x00002983,0x0000297f, -0x00050050,0x00000007,0x00002986,0x00002980, -0x00002985,0x0004007c,0x00000014,0x00002976, -0x00002986,0x00060041,0x0000015f,0x0000296e, -0x00002976,0x0000015e,0x0000015e,0x0005003e, -0x0000296e,0x00002963,0x00000002,0x00000004, -0x00050080,0x00000006,0x0000291c,0x00002914, -0x000000df,0x00050051,0x00000027,0x00002920, -0x00005ce8,0x00000001,0x0004007c,0x00000006, -0x0000298c,0x00002920,0x00050095,0x00000130, -0x000029a7,0x0000297c,0x0000291c,0x00050051, -0x00000006,0x000029a8,0x000029a7,0x00000001, -0x00050051,0x00000006,0x000029a9,0x000029a7, -0x00000000,0x00050080,0x00000006,0x000029ae, -0x00002983,0x000029a8,0x00050050,0x00000007, -0x000029af,0x000029a9,0x000029ae,0x0004007c, -0x00000014,0x0000299f,0x000029af,0x00060041, -0x0000015f,0x00002997,0x0000299f,0x0000015e, -0x0000015e,0x0005003e,0x00002997,0x0000298c, +0x00002a20,0x00002a18,0x000000ec,0x00050051, +0x00000027,0x00002a24,0x00006128,0x00000001, +0x0004007c,0x00000006,0x00002a90,0x00002a24, +0x00050095,0x0000013d,0x00002aab,0x00002a80, +0x00002a20,0x00050051,0x00000006,0x00002aac, +0x00002aab,0x00000001,0x00050051,0x00000006, +0x00002aad,0x00002aab,0x00000000,0x00050080, +0x00000006,0x00002ab2,0x00002a87,0x00002aac, +0x00050050,0x00000007,0x00002ab3,0x00002aad, +0x00002ab2,0x0004007c,0x00000014,0x00002aa3, +0x00002ab3,0x00060041,0x0000016c,0x00002a9b, +0x00002aa3,0x0000016b,0x0000016b,0x0005003e, +0x00002a9b,0x00002a90,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002a27,0x00002a18, +0x000001cd,0x00050051,0x00000027,0x00002a2b, +0x00006128,0x00000002,0x0004007c,0x00000006, +0x00002ab9,0x00002a2b,0x00050095,0x0000013d, +0x00002ad4,0x00002a80,0x00002a27,0x00050051, +0x00000006,0x00002ad5,0x00002ad4,0x00000001, +0x00050051,0x00000006,0x00002ad6,0x00002ad4, +0x00000000,0x00050080,0x00000006,0x00002adb, +0x00002a87,0x00002ad5,0x00050050,0x00000007, +0x00002adc,0x00002ad6,0x00002adb,0x0004007c, +0x00000014,0x00002acc,0x00002adc,0x00060041, +0x0000016c,0x00002ac4,0x00002acc,0x0000016b, +0x0000016b,0x0005003e,0x00002ac4,0x00002ab9, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00002923,0x00002914,0x00000194,0x00050051, -0x00000027,0x00002927,0x00005ce8,0x00000002, -0x0004007c,0x00000006,0x000029b5,0x00002927, -0x00050095,0x00000130,0x000029d0,0x0000297c, -0x00002923,0x00050051,0x00000006,0x000029d1, -0x000029d0,0x00000001,0x00050051,0x00000006, -0x000029d2,0x000029d0,0x00000000,0x00050080, -0x00000006,0x000029d7,0x00002983,0x000029d1, -0x00050050,0x00000007,0x000029d8,0x000029d2, -0x000029d7,0x0004007c,0x00000014,0x000029c8, -0x000029d8,0x00060041,0x0000015f,0x000029c0, -0x000029c8,0x0000015e,0x0000015e,0x0005003e, -0x000029c0,0x000029b5,0x00000002,0x00000004, -0x00050080,0x00000006,0x0000292a,0x00002914, -0x0000019b,0x00050051,0x00000027,0x0000292e, -0x00005ce6,0x00000000,0x0004007c,0x00000006, -0x000029de,0x0000292e,0x00050095,0x00000130, -0x000029f9,0x0000297c,0x0000292a,0x00050051, -0x00000006,0x000029fa,0x000029f9,0x00000001, -0x00050051,0x00000006,0x000029fb,0x000029f9, -0x00000000,0x00050080,0x00000006,0x00002a00, -0x00002983,0x000029fa,0x00050050,0x00000007, -0x00002a01,0x000029fb,0x00002a00,0x0004007c, -0x00000014,0x000029f1,0x00002a01,0x00060041, -0x0000015f,0x000029e9,0x000029f1,0x0000015e, -0x0000015e,0x0005003e,0x000029e9,0x000029de, +0x00002a2e,0x00002a18,0x000001d4,0x00050051, +0x00000027,0x00002a32,0x00006126,0x00000000, +0x0004007c,0x00000006,0x00002ae2,0x00002a32, +0x00050095,0x0000013d,0x00002afd,0x00002a80, +0x00002a2e,0x00050051,0x00000006,0x00002afe, +0x00002afd,0x00000001,0x00050051,0x00000006, +0x00002aff,0x00002afd,0x00000000,0x00050080, +0x00000006,0x00002b04,0x00002a87,0x00002afe, +0x00050050,0x00000007,0x00002b05,0x00002aff, +0x00002b04,0x0004007c,0x00000014,0x00002af5, +0x00002b05,0x00060041,0x0000016c,0x00002aed, +0x00002af5,0x0000016b,0x0000016b,0x0005003e, +0x00002aed,0x00002ae2,0x00000002,0x00000004, +0x00050080,0x00000006,0x00002a35,0x00002a18, +0x000001db,0x00050051,0x00000027,0x00002a39, +0x00006126,0x00000001,0x0004007c,0x00000006, +0x00002b0b,0x00002a39,0x00050095,0x0000013d, +0x00002b26,0x00002a80,0x00002a35,0x00050051, +0x00000006,0x00002b27,0x00002b26,0x00000001, +0x00050051,0x00000006,0x00002b28,0x00002b26, +0x00000000,0x00050080,0x00000006,0x00002b2d, +0x00002a87,0x00002b27,0x00050050,0x00000007, +0x00002b2e,0x00002b28,0x00002b2d,0x0004007c, +0x00000014,0x00002b1e,0x00002b2e,0x00060041, +0x0000016c,0x00002b16,0x00002b1e,0x0000016b, +0x0000016b,0x0005003e,0x00002b16,0x00002b0b, 0x00000002,0x00000004,0x00050080,0x00000006, -0x00002931,0x00002914,0x000001a2,0x00050051, -0x00000027,0x00002935,0x00005ce6,0x00000001, -0x0004007c,0x00000006,0x00002a07,0x00002935, -0x00050095,0x00000130,0x00002a22,0x0000297c, -0x00002931,0x00050051,0x00000006,0x00002a23, -0x00002a22,0x00000001,0x00050051,0x00000006, -0x00002a24,0x00002a22,0x00000000,0x00050080, -0x00000006,0x00002a29,0x00002983,0x00002a23, -0x00050050,0x00000007,0x00002a2a,0x00002a24, -0x00002a29,0x0004007c,0x00000014,0x00002a1a, -0x00002a2a,0x00060041,0x0000015f,0x00002a12, -0x00002a1a,0x0000015e,0x0000015e,0x0005003e, -0x00002a12,0x00002a07,0x00000002,0x00000004, -0x00050080,0x00000006,0x00002938,0x00002914, -0x00000260,0x00050051,0x00000027,0x0000293c, -0x00005ce6,0x00000002,0x0004007c,0x00000006, -0x00002a30,0x0000293c,0x00050095,0x00000130, -0x00002a4b,0x0000297c,0x00002938,0x00050051, -0x00000006,0x00002a4c,0x00002a4b,0x00000001, -0x00050051,0x00000006,0x00002a4d,0x00002a4b, -0x00000000,0x00050080,0x00000006,0x00002a52, -0x00002983,0x00002a4c,0x00050050,0x00000007, -0x00002a53,0x00002a4d,0x00002a52,0x0004007c, -0x00000014,0x00002a43,0x00002a53,0x00060041, -0x0000015f,0x00002a3b,0x00002a43,0x0000015e, -0x0000015e,0x0005003e,0x00002a3b,0x00002a30, -0x00000002,0x00000004,0x000300f7,0x00002a93, -0x00000000,0x000300fb,0x0000012b,0x00002a62, -0x000200f8,0x00002a62,0x000500bc,0x0000002f, -0x00002a9a,0x00002919,0x0000292e,0x000300f7, -0x00002aa1,0x00000000,0x000400fa,0x00002a9a, -0x00002a9b,0x00002aa1,0x000200f8,0x00002a9b, -0x000500bc,0x0000002f,0x00002aa0,0x00002920, -0x00002935,0x000200f9,0x00002aa1,0x000200f8, -0x00002aa1,0x000700f5,0x0000002f,0x00002aa2, -0x00002a9a,0x00002a62,0x00002aa0,0x00002a9b, -0x000300f7,0x00002aa9,0x00000000,0x000400fa, -0x00002aa2,0x00002aa3,0x00002aa9,0x000200f8, -0x00002aa3,0x000500bc,0x0000002f,0x00002aa8, -0x00002927,0x0000293c,0x000200f9,0x00002aa9, -0x000200f8,0x00002aa9,0x000700f5,0x0000002f, -0x00002aaa,0x00002aa2,0x00002aa1,0x00002aa8, -0x00002aa3,0x000400a8,0x0000002f,0x00002aab, -0x00002aaa,0x000300f7,0x00002a67,0x00000000, -0x000400fa,0x00002aab,0x00002a66,0x00002a67, -0x000200f8,0x00002a66,0x000200f9,0x00002a93, -0x000200f8,0x00002a67,0x00050081,0x00000063, -0x00002a6a,0x00005ce8,0x00005ce6,0x0005008e, -0x00000063,0x00002a6b,0x00002a6a,0x000002c4, -0x00050095,0x00000130,0x00002abb,0x0000297c, -0x0000012b,0x00050051,0x00000006,0x00002abc, -0x00002abb,0x00000001,0x00050051,0x00000006, -0x00002abd,0x00002abb,0x00000000,0x00050080, -0x00000006,0x00002ac2,0x00002983,0x00002abc, -0x00050050,0x00000007,0x00002ac3,0x00002abd, -0x00002ac2,0x0004007c,0x00000014,0x00002ab3, -0x00002ac3,0x00060041,0x0000015f,0x00002a70, -0x00002ab3,0x0000015e,0x0000015e,0x00050051, -0x00000027,0x00002a72,0x00002a6b,0x00000000, -0x0004007c,0x00000006,0x00002ac9,0x00002a72, -0x000500c7,0x00000006,0x00002acb,0x00002ac9, -0x00000208,0x000500ab,0x0000002f,0x00002acc, -0x00002acb,0x0000012b,0x000300f7,0x00002ad3, -0x00000000,0x000400fa,0x00002acc,0x00002acd, -0x00002ad0,0x000200f8,0x00002ad0,0x000500c5, -0x00000006,0x00002ad2,0x00002ac9,0x00000208, -0x000200f9,0x00002ad3,0x000200f8,0x00002acd, -0x000400c8,0x00000006,0x00002acf,0x00002ac9, -0x000200f9,0x00002ad3,0x000200f8,0x00002ad3, -0x000700f5,0x00000006,0x00005af4,0x00002acf, -0x00002acd,0x00002ad2,0x00002ad0,0x000700ed, -0x00000006,0x00002a74,0x00002a70,0x00000135, -0x0000012b,0x00005af4,0x00060041,0x0000015f, -0x00002a76,0x00002ab3,0x0000015e,0x0000022b, -0x00050051,0x00000027,0x00002a78,0x00002a6b, -0x00000001,0x0004007c,0x00000006,0x00002ada, -0x00002a78,0x000500c7,0x00000006,0x00002adc, -0x00002ada,0x00000208,0x000500ab,0x0000002f, -0x00002add,0x00002adc,0x0000012b,0x000300f7, -0x00002ae4,0x00000000,0x000400fa,0x00002add, -0x00002ade,0x00002ae1,0x000200f8,0x00002ae1, -0x000500c5,0x00000006,0x00002ae3,0x00002ada, -0x00000208,0x000200f9,0x00002ae4,0x000200f8, -0x00002ade,0x000400c8,0x00000006,0x00002ae0, -0x00002ada,0x000200f9,0x00002ae4,0x000200f8, -0x00002ae4,0x000700f5,0x00000006,0x00005af5, -0x00002ae0,0x00002ade,0x00002ae3,0x00002ae1, -0x000700ed,0x00000006,0x00002a7a,0x00002a76, -0x00000135,0x0000012b,0x00005af5,0x00060041, -0x0000015f,0x00002a7c,0x00002ab3,0x0000015e, -0x000002dc,0x00050051,0x00000027,0x00002a7e, -0x00002a6b,0x00000002,0x0004007c,0x00000006, -0x00002aeb,0x00002a7e,0x000500c7,0x00000006, -0x00002aed,0x00002aeb,0x00000208,0x000500ab, -0x0000002f,0x00002aee,0x00002aed,0x0000012b, -0x000300f7,0x00002af5,0x00000000,0x000400fa, -0x00002aee,0x00002aef,0x00002af2,0x000200f8, -0x00002af2,0x000500c5,0x00000006,0x00002af4, -0x00002aeb,0x00000208,0x000200f9,0x00002af5, -0x000200f8,0x00002aef,0x000400c8,0x00000006, -0x00002af1,0x00002aeb,0x000200f9,0x00002af5, -0x000200f8,0x00002af5,0x000700f5,0x00000006, -0x00005af6,0x00002af1,0x00002aef,0x00002af4, -0x00002af2,0x000700ed,0x00000006,0x00002a80, -0x00002a7c,0x00000135,0x0000012b,0x00005af6, -0x00060041,0x0000015f,0x00002a82,0x00002ab3, -0x0000015e,0x000002e4,0x000300f7,0x00002b06, -0x00000000,0x000400fa,0x00002acc,0x00002b00, -0x00002b03,0x000200f8,0x00002b03,0x000500c5, -0x00000006,0x00002b05,0x00002ac9,0x00000208, -0x000200f9,0x00002b06,0x000200f8,0x00002b00, -0x000400c8,0x00000006,0x00002b02,0x00002ac9, -0x000200f9,0x00002b06,0x000200f8,0x00002b06, -0x000700f5,0x00000006,0x00005af7,0x00002b02, -0x00002b00,0x00002b05,0x00002b03,0x000700ef, -0x00000006,0x00002a86,0x00002a82,0x00000135, -0x0000012b,0x00005af7,0x00060041,0x0000015f, -0x00002a88,0x00002ab3,0x0000015e,0x000002ec, -0x000300f7,0x00002b17,0x00000000,0x000400fa, -0x00002add,0x00002b11,0x00002b14,0x000200f8, -0x00002b14,0x000500c5,0x00000006,0x00002b16, -0x00002ada,0x00000208,0x000200f9,0x00002b17, -0x000200f8,0x00002b11,0x000400c8,0x00000006, -0x00002b13,0x00002ada,0x000200f9,0x00002b17, -0x000200f8,0x00002b17,0x000700f5,0x00000006, -0x00005af8,0x00002b13,0x00002b11,0x00002b16, -0x00002b14,0x000700ef,0x00000006,0x00002a8c, -0x00002a88,0x00000135,0x0000012b,0x00005af8, -0x00060041,0x0000015f,0x00002a8e,0x00002ab3, -0x0000015e,0x000002f4,0x000300f7,0x00002b28, -0x00000000,0x000400fa,0x00002aee,0x00002b22, -0x00002b25,0x000200f8,0x00002b25,0x000500c5, -0x00000006,0x00002b27,0x00002aeb,0x00000208, -0x000200f9,0x00002b28,0x000200f8,0x00002b22, -0x000400c8,0x00000006,0x00002b24,0x00002aeb, -0x000200f9,0x00002b28,0x000200f8,0x00002b28, -0x000700f5,0x00000006,0x00005af9,0x00002b24, -0x00002b22,0x00002b27,0x00002b25,0x000700ef, -0x00000006,0x00002a92,0x00002a8e,0x00000135, -0x0000012b,0x00005af9,0x000200f9,0x00002a93, -0x000200f8,0x00002a93,0x000200f9,0x000012bf, -0x000200f8,0x000012bf,0x000200f9,0x00001299, -0x000200f8,0x00001298,0x00050041,0x00000182, -0x0000129a,0x00000180,0x00000fbf,0x0004003d, -0x00000006,0x0000129b,0x0000129a,0x00050084, -0x00000006,0x0000129d,0x000000df,0x000011de, -0x00050080,0x00000006,0x0000129e,0x0000129b, -0x0000129d,0x00050041,0x0000022d,0x000012a0, -0x00000180,0x0000015e,0x0004003d,0x00000007, -0x000012a1,0x000012a0,0x00050051,0x00000006, -0x0000248a,0x000012a1,0x00000000,0x00050095, -0x00000130,0x0000248c,0x0000248a,0x0000129e, -0x00050051,0x00000006,0x0000248d,0x0000248c, -0x00000001,0x00050051,0x00000006,0x0000248e, -0x0000248c,0x00000000,0x00050051,0x00000006, -0x00002491,0x000012a1,0x00000001,0x00050080, -0x00000006,0x00002493,0x00002491,0x0000248d, -0x00050050,0x00000007,0x00002494,0x0000248e, -0x00002493,0x0004007c,0x00000014,0x00002484, -0x00002494,0x00060041,0x0000015f,0x0000247c, -0x00002484,0x0000015e,0x0000015e,0x0005003e, -0x0000247c,0x00000500,0x00000002,0x00000004, -0x000500b0,0x0000002f,0x000012a6,0x000011de, -0x00000437,0x000300f7,0x000012a8,0x00000000, -0x000400fa,0x000012a6,0x000012a7,0x000012a8, -0x000200f8,0x000012a7,0x00050041,0x0000022d, -0x000012ac,0x00000180,0x0000022b,0x0004003d, -0x00000007,0x000012ad,0x000012ac,0x00050051, -0x00000006,0x000024aa,0x000012ad,0x00000000, -0x00050095,0x00000130,0x000024ac,0x000024aa, -0x0000129d,0x00050051,0x00000006,0x000024ad, -0x000024ac,0x00000001,0x00050051,0x00000006, -0x000024ae,0x000024ac,0x00000000,0x00050051, -0x00000006,0x000024b1,0x000012ad,0x00000001, -0x00050080,0x00000006,0x000024b3,0x000024b1, -0x000024ad,0x00050050,0x00000007,0x000024b4, -0x000024ae,0x000024b3,0x0004007c,0x00000014, -0x000024a4,0x000024b4,0x00060041,0x0000015f, -0x0000249c,0x000024a4,0x0000015e,0x0000015e, -0x0005003e,0x0000249c,0x00000500,0x00000002, -0x00000004,0x00050080,0x00000006,0x000012b3, -0x0000019b,0x0000129d,0x00050095,0x00000130, -0x000024cc,0x000024aa,0x000012b3,0x00050051, -0x00000006,0x000024cd,0x000024cc,0x00000001, -0x00050051,0x00000006,0x000024ce,0x000024cc, -0x00000000,0x00050080,0x00000006,0x000024d3, -0x000024b1,0x000024cd,0x00050050,0x00000007, -0x000024d4,0x000024ce,0x000024d3,0x0004007c, -0x00000014,0x000024c4,0x000024d4,0x00060041, -0x0000015f,0x000024bc,0x000024c4,0x0000015e, -0x0000015e,0x0005003e,0x000024bc,0x0000012b, -0x00000002,0x00000004,0x000200f9,0x000012a8, -0x000200f8,0x000012a8,0x000200f9,0x00001299, -0x000200f8,0x00001299,0x000200f9,0x000012fe, -0x000200f8,0x000012fe,0x000100fd,0x00010038} +0x00002a3c,0x00002a18,0x00000299,0x00050051, +0x00000027,0x00002a40,0x00006126,0x00000002, +0x0004007c,0x00000006,0x00002b34,0x00002a40, +0x00050095,0x0000013d,0x00002b4f,0x00002a80, +0x00002a3c,0x00050051,0x00000006,0x00002b50, +0x00002b4f,0x00000001,0x00050051,0x00000006, +0x00002b51,0x00002b4f,0x00000000,0x00050080, +0x00000006,0x00002b56,0x00002a87,0x00002b50, +0x00050050,0x00000007,0x00002b57,0x00002b51, +0x00002b56,0x0004007c,0x00000014,0x00002b47, +0x00002b57,0x00060041,0x0000016c,0x00002b3f, +0x00002b47,0x0000016b,0x0000016b,0x0005003e, +0x00002b3f,0x00002b34,0x00000002,0x00000004, +0x000300f7,0x00002b97,0x00000000,0x000300fb, +0x00000138,0x00002b66,0x000200f8,0x00002b66, +0x000500bc,0x0000002f,0x00002b9e,0x00002a1d, +0x00002a32,0x000300f7,0x00002ba5,0x00000000, +0x000400fa,0x00002b9e,0x00002b9f,0x00002ba5, +0x000200f8,0x00002b9f,0x000500bc,0x0000002f, +0x00002ba4,0x00002a24,0x00002a39,0x000200f9, +0x00002ba5,0x000200f8,0x00002ba5,0x000700f5, +0x0000002f,0x00002ba6,0x00002b9e,0x00002b66, +0x00002ba4,0x00002b9f,0x000300f7,0x00002bad, +0x00000000,0x000400fa,0x00002ba6,0x00002ba7, +0x00002bad,0x000200f8,0x00002ba7,0x000500bc, +0x0000002f,0x00002bac,0x00002a2b,0x00002a40, +0x000200f9,0x00002bad,0x000200f8,0x00002bad, +0x000700f5,0x0000002f,0x00002bae,0x00002ba6, +0x00002ba5,0x00002bac,0x00002ba7,0x000400a8, +0x0000002f,0x00002baf,0x00002bae,0x000300f7, +0x00002b6b,0x00000000,0x000400fa,0x00002baf, +0x00002b6a,0x00002b6b,0x000200f8,0x00002b6a, +0x000200f9,0x00002b97,0x000200f8,0x00002b6b, +0x00050081,0x0000006c,0x00002b6e,0x00006128, +0x00006126,0x0005008e,0x0000006c,0x00002b6f, +0x00002b6e,0x000002fd,0x00050095,0x0000013d, +0x00002bbf,0x00002a80,0x00000138,0x00050051, +0x00000006,0x00002bc0,0x00002bbf,0x00000001, +0x00050051,0x00000006,0x00002bc1,0x00002bbf, +0x00000000,0x00050080,0x00000006,0x00002bc6, +0x00002a87,0x00002bc0,0x00050050,0x00000007, +0x00002bc7,0x00002bc1,0x00002bc6,0x0004007c, +0x00000014,0x00002bb7,0x00002bc7,0x00060041, +0x0000016c,0x00002b74,0x00002bb7,0x0000016b, +0x0000016b,0x00050051,0x00000027,0x00002b76, +0x00002b6f,0x00000000,0x0004007c,0x00000006, +0x00002bcd,0x00002b76,0x000500c7,0x00000006, +0x00002bcf,0x00002bcd,0x00000241,0x000500ab, +0x0000002f,0x00002bd0,0x00002bcf,0x00000138, +0x000300f7,0x00002bd7,0x00000000,0x000400fa, +0x00002bd0,0x00002bd1,0x00002bd4,0x000200f8, +0x00002bd4,0x000500c5,0x00000006,0x00002bd6, +0x00002bcd,0x00000241,0x000200f9,0x00002bd7, +0x000200f8,0x00002bd1,0x000400c8,0x00000006, +0x00002bd3,0x00002bcd,0x000200f9,0x00002bd7, +0x000200f8,0x00002bd7,0x000700f5,0x00000006, +0x00005f24,0x00002bd3,0x00002bd1,0x00002bd6, +0x00002bd4,0x000700ed,0x00000006,0x00002b78, +0x00002b74,0x00000142,0x00000138,0x00005f24, +0x00060041,0x0000016c,0x00002b7a,0x00002bb7, +0x0000016b,0x00000264,0x00050051,0x00000027, +0x00002b7c,0x00002b6f,0x00000001,0x0004007c, +0x00000006,0x00002bde,0x00002b7c,0x000500c7, +0x00000006,0x00002be0,0x00002bde,0x00000241, +0x000500ab,0x0000002f,0x00002be1,0x00002be0, +0x00000138,0x000300f7,0x00002be8,0x00000000, +0x000400fa,0x00002be1,0x00002be2,0x00002be5, +0x000200f8,0x00002be5,0x000500c5,0x00000006, +0x00002be7,0x00002bde,0x00000241,0x000200f9, +0x00002be8,0x000200f8,0x00002be2,0x000400c8, +0x00000006,0x00002be4,0x00002bde,0x000200f9, +0x00002be8,0x000200f8,0x00002be8,0x000700f5, +0x00000006,0x00005f25,0x00002be4,0x00002be2, +0x00002be7,0x00002be5,0x000700ed,0x00000006, +0x00002b7e,0x00002b7a,0x00000142,0x00000138, +0x00005f25,0x00060041,0x0000016c,0x00002b80, +0x00002bb7,0x0000016b,0x00000315,0x00050051, +0x00000027,0x00002b82,0x00002b6f,0x00000002, +0x0004007c,0x00000006,0x00002bef,0x00002b82, +0x000500c7,0x00000006,0x00002bf1,0x00002bef, +0x00000241,0x000500ab,0x0000002f,0x00002bf2, +0x00002bf1,0x00000138,0x000300f7,0x00002bf9, +0x00000000,0x000400fa,0x00002bf2,0x00002bf3, +0x00002bf6,0x000200f8,0x00002bf6,0x000500c5, +0x00000006,0x00002bf8,0x00002bef,0x00000241, +0x000200f9,0x00002bf9,0x000200f8,0x00002bf3, +0x000400c8,0x00000006,0x00002bf5,0x00002bef, +0x000200f9,0x00002bf9,0x000200f8,0x00002bf9, +0x000700f5,0x00000006,0x00005f26,0x00002bf5, +0x00002bf3,0x00002bf8,0x00002bf6,0x000700ed, +0x00000006,0x00002b84,0x00002b80,0x00000142, +0x00000138,0x00005f26,0x00060041,0x0000016c, +0x00002b86,0x00002bb7,0x0000016b,0x0000031d, +0x000300f7,0x00002c0a,0x00000000,0x000400fa, +0x00002bd0,0x00002c04,0x00002c07,0x000200f8, +0x00002c07,0x000500c5,0x00000006,0x00002c09, +0x00002bcd,0x00000241,0x000200f9,0x00002c0a, +0x000200f8,0x00002c04,0x000400c8,0x00000006, +0x00002c06,0x00002bcd,0x000200f9,0x00002c0a, +0x000200f8,0x00002c0a,0x000700f5,0x00000006, +0x00005f27,0x00002c06,0x00002c04,0x00002c09, +0x00002c07,0x000700ef,0x00000006,0x00002b8a, +0x00002b86,0x00000142,0x00000138,0x00005f27, +0x00060041,0x0000016c,0x00002b8c,0x00002bb7, +0x0000016b,0x00000325,0x000300f7,0x00002c1b, +0x00000000,0x000400fa,0x00002be1,0x00002c15, +0x00002c18,0x000200f8,0x00002c18,0x000500c5, +0x00000006,0x00002c1a,0x00002bde,0x00000241, +0x000200f9,0x00002c1b,0x000200f8,0x00002c15, +0x000400c8,0x00000006,0x00002c17,0x00002bde, +0x000200f9,0x00002c1b,0x000200f8,0x00002c1b, +0x000700f5,0x00000006,0x00005f28,0x00002c17, +0x00002c15,0x00002c1a,0x00002c18,0x000700ef, +0x00000006,0x00002b90,0x00002b8c,0x00000142, +0x00000138,0x00005f28,0x00060041,0x0000016c, +0x00002b92,0x00002bb7,0x0000016b,0x0000032d, +0x000300f7,0x00002c2c,0x00000000,0x000400fa, +0x00002bf2,0x00002c26,0x00002c29,0x000200f8, +0x00002c29,0x000500c5,0x00000006,0x00002c2b, +0x00002bef,0x00000241,0x000200f9,0x00002c2c, +0x000200f8,0x00002c26,0x000400c8,0x00000006, +0x00002c28,0x00002bef,0x000200f9,0x00002c2c, +0x000200f8,0x00002c2c,0x000700f5,0x00000006, +0x00005f29,0x00002c28,0x00002c26,0x00002c2b, +0x00002c29,0x000700ef,0x00000006,0x00002b96, +0x00002b92,0x00000142,0x00000138,0x00005f29, +0x000200f9,0x00002b97,0x000200f8,0x00002b97, +0x000200f9,0x000013be,0x000200f8,0x000013be, +0x000200f9,0x00001398,0x000200f8,0x00001397, +0x00050041,0x000001bb,0x00001399,0x000001b9, +0x000010be,0x0004003d,0x00000006,0x0000139a, +0x00001399,0x00050084,0x00000006,0x0000139c, +0x000000ec,0x000012dd,0x00050080,0x00000006, +0x0000139d,0x0000139a,0x0000139c,0x00050041, +0x00000266,0x0000139f,0x000001b9,0x0000016b, +0x0004003d,0x00000007,0x000013a0,0x0000139f, +0x00050051,0x00000006,0x0000258e,0x000013a0, +0x00000000,0x00050095,0x0000013d,0x00002590, +0x0000258e,0x0000139d,0x00050051,0x00000006, +0x00002591,0x00002590,0x00000001,0x00050051, +0x00000006,0x00002592,0x00002590,0x00000000, +0x00050051,0x00000006,0x00002595,0x000013a0, +0x00000001,0x00050080,0x00000006,0x00002597, +0x00002595,0x00002591,0x00050050,0x00000007, +0x00002598,0x00002592,0x00002597,0x0004007c, +0x00000014,0x00002588,0x00002598,0x00060041, +0x0000016c,0x00002580,0x00002588,0x0000016b, +0x0000016b,0x0005003e,0x00002580,0x00000539, +0x00000002,0x00000004,0x000500b0,0x0000002f, +0x000013a5,0x000012dd,0x00000470,0x000300f7, +0x000013a7,0x00000000,0x000400fa,0x000013a5, +0x000013a6,0x000013a7,0x000200f8,0x000013a6, +0x00050041,0x00000266,0x000013ab,0x000001b9, +0x00000264,0x0004003d,0x00000007,0x000013ac, +0x000013ab,0x00050051,0x00000006,0x000025ae, +0x000013ac,0x00000000,0x00050095,0x0000013d, +0x000025b0,0x000025ae,0x0000139c,0x00050051, +0x00000006,0x000025b1,0x000025b0,0x00000001, +0x00050051,0x00000006,0x000025b2,0x000025b0, +0x00000000,0x00050051,0x00000006,0x000025b5, +0x000013ac,0x00000001,0x00050080,0x00000006, +0x000025b7,0x000025b5,0x000025b1,0x00050050, +0x00000007,0x000025b8,0x000025b2,0x000025b7, +0x0004007c,0x00000014,0x000025a8,0x000025b8, +0x00060041,0x0000016c,0x000025a0,0x000025a8, +0x0000016b,0x0000016b,0x0005003e,0x000025a0, +0x00000539,0x00000002,0x00000004,0x00050080, +0x00000006,0x000013b2,0x000001d4,0x0000139c, +0x00050095,0x0000013d,0x000025d0,0x000025ae, +0x000013b2,0x00050051,0x00000006,0x000025d1, +0x000025d0,0x00000001,0x00050051,0x00000006, +0x000025d2,0x000025d0,0x00000000,0x00050080, +0x00000006,0x000025d7,0x000025b5,0x000025d1, +0x00050050,0x00000007,0x000025d8,0x000025d2, +0x000025d7,0x0004007c,0x00000014,0x000025c8, +0x000025d8,0x00060041,0x0000016c,0x000025c0, +0x000025c8,0x0000016b,0x0000016b,0x0005003e, +0x000025c0,0x00000138,0x00000002,0x00000004, +0x000200f9,0x000013a7,0x000200f8,0x000013a7, +0x000200f9,0x00001398,0x000200f8,0x00001398, +0x000200f9,0x000013fd,0x000200f8,0x000013fd, +0x000100fd,0x00010038} diff --git a/runtime/test/arena_blocks_test.cpp b/runtime/test/arena_blocks_test.cpp new file mode 100644 index 0000000000..d1da077f1f --- /dev/null +++ b/runtime/test/arena_blocks_test.cpp @@ -0,0 +1,273 @@ +// leonida::ArenaBlocks (src/arena_blocks.h): the GPU address arena's free-block map, its first fit at an alignment, +// its coalescing, and a walk that survives the map being cut under it. No GPU, no device. +// +// The crash this covers is an access violation in arena_allocate: a walk over the map stepped into a node that had +// been freed under it (the nil flag of a null child at 0x19). A map freed or rebalanced by a write outside the +// arena's lock does that to a walk on another thread; the walk here also re-reads the map every step instead of +// keeping an iterator, so a cut made under it (a nested release or allocation, as a test can do) is survived too. +#include "../src/arena_blocks.h" + +#include +#include +#include +#include +#include +#include + +#define EXPECT(condition) do { \ + if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \ +} while (0) + +namespace { + +constexpr std::uint64_t kReserved = 0x10000; // the zero page and the quad index list +constexpr std::uint64_t kSize = 1 << 20; +constexpr std::uint64_t kAlign = 0x1000; + +using Blocks = leonida::ArenaBlocks; + +// The device's keep-out: no title range in these tests, so nothing is excluded. +std::uint64_t no_keep_out(std::uint64_t, std::uint64_t) { return 0; } + +bool one_block_of(const Blocks& blocks, std::uint64_t offset, std::uint64_t size) { + const auto all = blocks.blocks(); + return all.size() == 1 && all.front().offset == offset && all.front().size == size; +} + +// First fit, alignment, coalescing and exact placement. +int basics() { + Blocks b; + b.reset(kReserved, kSize); + EXPECT(b.count() == 1 && b.free_bytes() == kSize - kReserved); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0)); + std::uint64_t scratch = 0; + EXPECT(!b.allocate(0, kAlign, no_keep_out, scratch)); + EXPECT(!b.allocate(kSize, kAlign, no_keep_out, scratch)); // larger than the arena + std::uint64_t a = 0, c = 0, d = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, a) && a == kReserved); + EXPECT(b.free_bytes() == kSize - kReserved - 0x1000 && b.consistent(0x1000)); + EXPECT(b.allocate(0x3000, kAlign, no_keep_out, c) && c == kReserved + 0x1000); + // An unaligned free start is rounded up: the request lands on the next boundary. + EXPECT(b.release(a, 0x1000) == Blocks::Fault::none); + EXPECT(b.allocate(0x800, kAlign, no_keep_out, d) && d == kReserved); + // Placement at a console VA only where a free block holds the range exactly. + EXPECT(!b.allocate_at(c, 0x800)); // a live range + EXPECT(!b.allocate_at(kReserved, 0x2000)); + EXPECT(b.release(c, 0x3000) == Blocks::Fault::none); + EXPECT(b.allocate_at(kReserved + 0x1000, 0x1000)); + EXPECT(b.check() == Blocks::Fault::none); + EXPECT(b.consistent(0x800 + 0x1000)); + // Giving everything back merges the arena into the one block it started as. + EXPECT(b.release(kReserved, 0x800) == Blocks::Fault::none); + EXPECT(b.release(kReserved + 0x1000, 0x1000) == Blocks::Fault::none); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0)); + EXPECT(one_block_of(b, kReserved, kSize - kReserved)); + return 0; +} + +// A keep-out the device passes for the title's own memory: a request that starts inside a title range is moved past +// it, and a free block the range covers entirely is skipped for the next one (first fit moves on). +int keep_out() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t a = 0, c = 0, d = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, a)); // kReserved + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, c)); // kReserved + 0x1000 + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, d)); // kReserved + 0x2000 + EXPECT(b.release(a, 0x1000) == Blocks::Fault::none); + EXPECT(b.release(c, 0x1000) == Blocks::Fault::none); // one free block [kReserved, kReserved + 0x2000) + // A title range over the block's first 0x800 bytes pushes the start to the next 0x1000 boundary, where the + // request still fits the same block. + const std::uint64_t title_lo = kReserved, title_hi = kReserved + 0x800; + const auto keep_out_first = [&](std::uint64_t lo, std::uint64_t hi) -> std::uint64_t { + return lo < title_hi && hi > title_lo ? title_hi : 0; + }; + std::uint64_t out = 0; + EXPECT(b.allocate(0x1000, kAlign, keep_out_first, out) && out == kReserved + 0x1000); + // A title range over the whole free block leaves it unusable: first fit moves on to the tail block. + EXPECT(b.release(out, 0x1000) == Blocks::Fault::none); + const auto keep_out_all = [&](std::uint64_t lo, std::uint64_t hi) -> std::uint64_t { + return lo < kReserved + 0x2000 && hi > kReserved ? kReserved + 0x2000 : 0; + }; + EXPECT(b.allocate(0x1000, kAlign, keep_out_all, out) && out >= kReserved + 0x3000); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0x2000)); + return 0; +} + +// The crash's shape: the walk stands on a free block, and a call it makes releases live memory that borders that +// block, so the block is merged away -- the very node the walk stands on is erased and freed. The walk re-reads the +// map every step, so it carries on from the new map instead of stepping into the freed node. +int cut_under_the_walk() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t a = 0, c = 0, d = 0, e = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, a)); + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, c)); + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, d)); + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, e)); + EXPECT(b.release(a, 0x1000) == Blocks::Fault::none); + EXPECT(b.release(c, 0x1000) == Blocks::Fault::none); + EXPECT(b.release(d, 0x1000) == Blocks::Fault::none); + EXPECT(b.count() == 2); // the coalesced gap run and the tail: the walk visits both + int visits = 0; + bool released_under_the_walk = false; + const auto keep_out = [&](std::uint64_t, std::uint64_t) -> std::uint64_t { + ++visits; + if (visits > 8 || released_under_the_walk) return 0; // once, to bound the nesting + // `e` sits between the free run the walk is in and the tail: giving it back merges both blocks and erases + // the node being walked. + released_under_the_walk = b.release(e, 0x1000) == Blocks::Fault::none; + return 0; + }; + std::uint64_t out = 0; + const bool found = b.allocate(0x1000, kAlign, keep_out, out); + EXPECT(visits > 0 && released_under_the_walk); + EXPECT(b.check() == Blocks::Fault::none); + // Found or refused, the map is a partition of the arena and the result is a range of it. + if (found) { + EXPECT(out >= kReserved && out + 0x1000 <= kSize); + for (const auto& block : b.blocks()) EXPECT(out + 0x1000 <= block.offset || block.offset + block.size <= out); + } + EXPECT(b.consistent(found ? 0x1000 : 0)); + return 0; +} + +// A nested allocation takes the very block the walk stands on: the walk re-reads the map and carries on instead of +// cutting a node it has already left behind. +int taken_under_the_walk() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t a = 0, c = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, a)); + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, c)); + EXPECT(b.release(a, 0x1000) == Blocks::Fault::none); + bool nested = false; + std::uint64_t taken = 0; + const auto keep_out = [&](std::uint64_t, std::uint64_t) -> std::uint64_t { + if (!nested) { + nested = true; + (void)b.allocate(0x1000, kAlign, no_keep_out, taken); // the first free block, where the walk is + } + return 0; + }; + std::uint64_t out = 0; + EXPECT(b.allocate(0x1000, kAlign, keep_out, out)); + EXPECT(nested && out >= kReserved && out + 0x1000 <= kSize); + EXPECT(taken != 0 && (out != taken || out + 0x1000 <= taken || taken + 0x1000 <= out)); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0x3000)); + return 0; +} + +// A search the map is cut under on every step gives up at its limit and says so, rather than looking like a full +// arena. +int walk_interrupted() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t live = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, live)); + int cuts = 0; + const auto keep_out = [&](std::uint64_t, std::uint64_t) -> std::uint64_t { + ++cuts; + // Give the live block back and take it again: the map is cut under every search of the walk. + (void)b.release(live, 0x1000); + (void)b.allocate(0x1000, kAlign, no_keep_out, live); + return 0; + }; + std::uint64_t out = 0; + EXPECT(!b.allocate(0x1000, kAlign, keep_out, out)); + EXPECT(b.interrupted() && cuts >= Blocks::kAttempts); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0x1000)); + // A search with nothing cutting it clears the report. + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, out) && !b.interrupted()); + return 0; +} + +// Releases that are wrong are reported and cannot make two live ranges overlap. +int bad_releases() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t a = 0; + EXPECT(b.allocate(0x2000, kAlign, no_keep_out, a)); + EXPECT(b.release(a, 0x1000) == Blocks::Fault::none); + EXPECT(b.count() == 2 && b.blocks().front().offset == a && b.blocks().front().size == 0x1000); + // The same bytes again: the union is inserted once, so they are free once. + const std::uint64_t free_before = b.free_bytes(); + EXPECT(b.release(a, 0x1000) == Blocks::Fault::double_free); + EXPECT(b.free_bytes() == free_before); + EXPECT(b.count() == 2 && b.check() == Blocks::Fault::none); + // A range the arena never had: refused, and the map is untouched. + EXPECT(b.release(kSize, 0x1000) == Blocks::Fault::outside_arena); + EXPECT(b.release(kReserved / 2, 0x1000) == Blocks::Fault::outside_arena); + EXPECT(b.count() == 2); + // The rest, then everything, merges into one block. + EXPECT(b.release(a + 0x1000, 0x1000) == Blocks::Fault::none); + EXPECT(b.count() == 1 && b.free_bytes() == kSize - kReserved); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0)); + return 0; +} + +// The diagnostic reader in d3d12_compute_input_probe.h: is an address inside a free block, and where does the next +// one start. +int reader() { + Blocks b; + b.reset(kReserved, kSize); + std::uint64_t a = 0, c = 0, offset = 0, size = 0, next = 0; + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, a)); + EXPECT(b.allocate(0x1000, kAlign, no_keep_out, c)); + EXPECT(!b.free_at(a, offset, size, next) && next == c + 0x1000); + EXPECT(b.free_at(c + 0x1000, offset, size, next) && offset == c + 0x1000 && next == kSize); + return 0; +} + +// Many threads, one lock -- the device's shape: every call to the block map under one mutex, no call re-entering it. +int threads() { + Blocks b; + b.reset(kReserved, kSize); + std::mutex mutex; // the device's arena mutex + std::atomic failed{false}; + std::vector workers; + constexpr int kThreads = 4, kRounds = 2000; + for (int t = 0; t < kThreads; ++t) { + workers.emplace_back([&b, &mutex, &failed, t] { + std::uint64_t live[8] = {}; + for (int round = 0; round < kRounds && !failed.load(); ++round) { + const int slot = (t * 3 + round) % 8; + std::lock_guard lock(mutex); + if (live[slot]) { + b.release(live[slot], 0x400); + live[slot] = 0; + } else { + std::uint64_t out = 0; + if (b.allocate(0x400, 64, no_keep_out, out)) live[slot] = out; + } + if (b.check() != Blocks::Fault::none) failed.store(true); + } + std::lock_guard lock(mutex); + for (std::uint64_t& block : live) { + if (!block) continue; + b.release(block, 0x400); + block = 0; + } + }); + } + for (auto& worker : workers) worker.join(); + EXPECT(!failed.load()); + EXPECT(b.check() == Blocks::Fault::none && b.consistent(0)); + EXPECT(one_block_of(b, kReserved, kSize - kReserved)); + return 0; +} + +} // namespace + +int main() { + if (int r = basics()) return r; + if (int r = keep_out()) return r; + if (int r = cut_under_the_walk()) return r; + if (int r = taken_under_the_walk()) return r; + if (int r = walk_interrupted()) return r; + if (int r = bad_releases()) return r; + if (int r = reader()) return r; + if (int r = threads()) return r; + std::fprintf(stderr, "arena_blocks: ok\n"); + return 0; +} diff --git a/runtime/test/d3d12_bundle_test.cpp b/runtime/test/d3d12_bundle_test.cpp index b7db739257..6e6be231c9 100644 --- a/runtime/test/d3d12_bundle_test.cpp +++ b/runtime/test/d3d12_bundle_test.cpp @@ -14,6 +14,7 @@ // No game data. #include "test_temp_dir.h" #include "vk_test_device.h" +#include "shader_fixture_path.h" #include "d3d12_test_shaders.h" #include "host_wine.h" #include "../shims/d3d12_com.h" @@ -822,15 +823,119 @@ bool root_layout_case(Rig& rig, UINT table_count, UINT constants, bool expect_gr return true; } +// One immutable bundle, executed twice with different parent VB/root state. A normal +// direct draw supplies the pixel oracle for each legal fixed-count indirect operation. +bool check_bundle_indirect(ID3D12Device* device, const std::vector& vs, + const std::vector& ps, bool inspect_layer_ir, bool opt_out = false) { + for (const bool indexed : {false, true}) { + Rig r; + CHECK(r.init(device, vs, ps)); + D3D12_INDIRECT_ARGUMENT_DESC action{}; + action.Type = indexed ? D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED : D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + D3D12_COMMAND_SIGNATURE_DESC desc{}; + desc.NumArgumentDescs = 1; desc.pArgumentDescs = &action; + desc.ByteStride = indexed ? sizeof(D3D12_DRAW_INDEXED_ARGUMENTS) : sizeof(D3D12_DRAW_ARGUMENTS); + Ref sig; + CHECK(SUCCEEDED(device->CreateCommandSignature(&desc, nullptr, IID_PPV_ARGS(&sig.p)))); + constexpr UINT64 offset = 1024; + const D3D12_DRAW_ARGUMENTS draw{3, 1, 0, 0}; + const D3D12_DRAW_INDEXED_ARGUMENTS draw_indexed{6, 1, 0, 0, 0}; + std::uint8_t* upload = nullptr; + CHECK(SUCCEEDED(r.upload->Map(0, nullptr, reinterpret_cast(&upload)))); + if (indexed) std::memcpy(upload + offset, &draw_indexed, sizeof(draw_indexed)); + else std::memcpy(upload + offset, &draw, sizeof(draw)); + r.upload->Unmap(0, nullptr); + auto* bundle = r.bundle(r.pso_a.p, [&](ID3D12GraphicsCommandList* l) { + l->IASetPrimitiveTopology(tlist); + l->SetMarker(1, "before", 7); + l->ExecuteIndirect(sig.p, 1, r.upload.p, offset, nullptr, 0); + l->SetMarker(1, "after", 6); + }); + CHECK(bundle); + bool ordered = !inspect_layer_ir; + const auto record = [&](ID3D12GraphicsCommandList* l, bool indirect) { + r.targets(l); + l->SetGraphicsRootSignature(r.root1.p); + l->SetPipelineState(r.pso_a.p); + l->IASetPrimitiveTopology(tlist); + r.indices(l, ib_quad); + r.offset(l, 0, 0); + for (UINT i = 0; i != 2; ++i) { + r.vertices(l, i ? vb_other : vb_quad); + r.tint(l, i ? tint_green : tint_red); + if (indirect) { + if (opt_out) l->ExecuteIndirect(sig.p, 1, r.upload.p, offset, nullptr, 0); // direct list too + l->ExecuteBundle(bundle); + } else if (indexed) l->DrawIndexedInstanced(6, 1, 0, 0, 0); + else l->DrawInstanced(3, 1, 0, 0); + } + if (indirect && inspect_layer_ir) { + std::vector commands; + if (!rt::d3d12::recorded_commands(l, commands)) return; + std::string order; + unsigned seen = 0; + for (const auto& cmd : commands) { + if (const auto* m = std::get_if(&cmd)) order += m->label + ","; + if (const auto d = leonida::draw_command(cmd); d.state) { + if (!d.arguments || d.state->indexed != indexed || d.arguments->max_count != 1 || + d.arguments->count_buffer || d.arguments->argument_offset != offset || + d.arguments->argument_buffer != rt::d3d12::resource_id(r.upload.p) || !d.state->views || + d.state->views->vertex_buffers[0].va != r.upload_va + (seen ? vb_other : vb_quad)) return; + order += "draw,"; + ++seen; + } + } + ordered = opt_out ? seen == 0 && order == "before,after,before,after," + : seen == 2 && order == "before,draw,after,before,draw,after,"; + } + }; + std::string direct, indirect; + HRESULT close = E_FAIL; + CHECK(r.render([&](Rig&, auto* l) { record(l, false); }, direct, close) && close == S_OK); + CHECK(direct.find('R') != std::string::npos && direct.find('G') != std::string::npos); + CHECK(r.render([&](Rig&, auto* l) { record(l, true); }, indirect, close) && close == S_OK); + if (!(ordered && indirect == (opt_out ? BLANK4 " " BLANK4 : direct))) { + std::fprintf(stderr, "bundle indirect mismatch: indexed=%d opt_out=%d ordered=%d direct=[%s] indirect=[%s]\n", + indexed, opt_out, ordered, direct.c_str(), indirect.c_str()); + return false; + } + } + return true; +} + int main(int argc, char** argv) { std::setvbuf(stdout, nullptr, _IONBF, 0); + const bool warp_indirect = argc == 2 && !std::strcmp(argv[1], "--indirect-bundle-warp"); + const bool opt_out = argc == 2 && !std::strcmp(argv[1], "--indirect-bundle-off"); + const bool layer_indirect = opt_out || (argc == 2 && !std::strcmp(argv[1], "--indirect-bundle-layer")); + const bool root_layout = argc == 2 && (!std::strcmp(argv[1], "--compact") || !std::strcmp(argv[1], "--legacy")); + if (opt_out) REQUIRE(SetEnvironmentVariableA("LEONIDA_INDIRECT_DRAWS", "off")); + if (argc != 1 && !warp_indirect && !layer_indirect && !root_layout) return 2; + if (warp_indirect) { + if (hostwine::host_is_wine()) return 77; + Ref factory; Ref warp; Ref device; + std::vector vs, ps; + if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p))) || + FAILED(factory->EnumWarpAdapter(IID_PPV_ARGS(&warp.p))) || + FAILED(D3D12CreateDevice(warp.p, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device.p)))) return 77; + REQUIRE(compile_hlsl(hlsl, "vs", "vs_5_0", vs) && compile_hlsl(hlsl, "ps", "ps_5_0", ps)); + REQUIRE(check_bundle_indirect(device.p, vs, ps, false)); + std::puts("WARP: both indirect bundle draws matched direct across two inherited parent states"); + return 0; + } vktest::Device vk; + vk.request_draw_indirect_first_instance = layer_indirect; + vk.request_robust_index_view = layer_indirect; const auto device_status = vk.initialize(); if (device_status == vktest::DeviceStatus::unavailable) { std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n"); return 77; } REQUIRE(device_status == vktest::DeviceStatus::ready); + if (layer_indirect && (!vk.enabled.drawIndirectFirstInstance || !vk.robust_index_view)) { + std::fprintf(stderr, "SKIP: bundle draw pair requires drawIndirectFirstInstance and a bounded robust index view\n"); + return 77; + } const auto list = scenarios(); // Layer shaders: FSSM-shaped containers found by hash in a translator-style index. @@ -839,8 +944,8 @@ int main(int argc, char** argv) { const auto vs_container = shader_container(vs_program), ps_container = shader_container(ps_program); const testfiles::ScratchDir scratch("leonida_bundle_test"); // removed on every way out of main const auto& library = scratch.path(); - REQUIRE(testfiles::copy_file(LEONIDA_TEST_VS_SPV, library / "vs_draw.spv")); - REQUIRE(testfiles::copy_file(LEONIDA_TEST_PS_SPV, library / "ps_draw.spv")); + REQUIRE(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_VS_SPV), library / "vs_draw.spv")); + REQUIRE(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_PS_SPV), library / "ps_draw.spv")); { std::ofstream index(library / "index.json", std::ios::binary); index << "{\"vs_draw\": {\"stage\": \"vs\", \"fssm_sha256\": \"" << leonida::sha256_hex(vs_program) @@ -864,12 +969,14 @@ int main(int argc, char** argv) { info.queue = vk.queue; info.queue_family = vk.family; info.buffer_device_address = true; + info.draw_indirect_first_instance = vk.enabled.drawIndirectFirstInstance == VK_TRUE; + info.robust_index_view = vk.robust_index_view; + info.max_draw_indirect_count = vk.max_draw_indirect_count; info.shader_dir = library.string(); Ref ours; REQUIRE(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&ours.p)))); - if (argc == 2) { + if (root_layout) { const bool stage = std::strcmp(argv[1], "--compact") == 0; - REQUIRE(stage || std::strcmp(argv[1], "--legacy") == 0); Rig rig; rig.device = ours.p; rig.vs_code = vs_container; @@ -883,6 +990,12 @@ int main(int argc, char** argv) { REQUIRE(vk.validation_errors() == errors_before); return 0; } + if (layer_indirect) { + REQUIRE(check_bundle_indirect(ours.p, vs_container, ps_container, true, opt_out)); + REQUIRE(vk.validation_errors() == errors_before); + std::puts(opt_out ? "layer: both indirect draws omitted on direct lists and in bundles; direct pixels and marker order checked" + : "layer: both indirect bundle draws matched direct; snapshots and marker order checked"); + } REQUIRE(run_all(ours.p, false, nullptr, vs_container, ps_container, list, layer_grids, layer_closes)); REQUIRE(layer_checks(ours.p, vs_container, ps_container, library)); } diff --git a/runtime/test/d3d12_com_test.cpp b/runtime/test/d3d12_com_test.cpp index 7f07e8bdf1..8691e5a740 100644 --- a/runtime/test/d3d12_com_test.cpp +++ b/runtime/test/d3d12_com_test.cpp @@ -4,6 +4,7 @@ // Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation; any validation error fails the test. #include "vk_test_device.h" #include "../shims/d3d12_com.h" +#include "../shims/d3d12_indirect_draw_policy.h" #include "../shims/d3d12_trace.h" #include "../src/gfx10_descriptors.h" @@ -37,6 +38,16 @@ static_assert(sizeof(leonida::DrawViews::vertex_buffers) == sizeof(leonida::Vert static_assert(sizeof(leonida::Draw) < sizeof(leonida::DrawViews)); int main(int argc, char** argv) { + if (argc == 3 && std::strcmp(argv[1], "--indirect-policy") == 0) { + // Each CTest is a fresh process. This branch creates no graphics device. + const bool unset = !std::strcmp(argv[2], "unset"), off = !std::strcmp(argv[2], "off"); + if (unset) SetEnvironmentVariableA("LEONIDA_INDIRECT_DRAWS", nullptr); + else EXPECT(SetEnvironmentVariableA("LEONIDA_INDIRECT_DRAWS", !std::strcmp(argv[2], "uppercase") ? "OFF" : argv[2])); + EXPECT(rt::d3d12::indirect_draws_disabled() == off); + EXPECT(SetEnvironmentVariableA("LEONIDA_INDIRECT_DRAWS", off ? "on" : "off")); + EXPECT(rt::d3d12::indirect_draws_disabled() == off); // process-cached, not re-read per draw + return 0; + } if (argc == 2 && std::strcmp(argv[1], "--trace-d3d12") == 0) rt::d3d12_trace::set_enabled(true); else if (argc != 1) return 2; using namespace leonida; diff --git a/runtime/test/d3d12_compile_teardown_test.cpp b/runtime/test/d3d12_compile_teardown_test.cpp new file mode 100644 index 0000000000..653de046a9 --- /dev/null +++ b/runtime/test/d3d12_compile_teardown_test.cpp @@ -0,0 +1,662 @@ +// Device teardown with background pipeline builds queued or running (PipelineCompiler, shims/d3d12_pipeline_compile.h). +// Every compute PSO queues a warm-up build at creation (lazy compute, LEONIDA_COMPUTE_WARMUP). The test's VkDevice +// outlives each D3D12 device made over it, as a title's would not: a build left running after the last Release +// would reach a device the test goes on to destroy, which is how d3d12_subgroup_test crashed with warm-up on. +// A job probe (PipelineCompiler::set_job_probe) parks a PSO's real warm-up build on the worker, after it counts as +// running and before it calls the driver, so "in flight" is a state the test holds, not a race. Cases: +// cache a build in the background, then release: the device writes the session cache, the worker joins. +// queued the worker held by a gate while PSOs are created and released: every queued build is dropped. +// prompt a PSO released while its build is in flight returns at once; the build then runs on the released +// PSO and the worker deletes it. +// last device the PSO holding the device's last reference released while its build is in flight: the device's +// teardown waits for the build, then the worker is joined. +// on worker the PSO released on the worker from inside its own build, once with the device still held and once +// holding its last reference (the device is then torn down on the worker, which lets itself go). +// two devices one torn down while the other's builds are queued behind it: the other's still run. +// racing many PSOs released at once with builds queued and one usually running, repeated. +// restart a device made after the worker stopped gets a new one, and its builds run. +// exit stop_pipeline_compiles with a device alive: the queue goes, later builds are refused, a warm-up +// is skipped and a dispatch (LEONIDA_ASYNC_PIPELINES on) builds its pipeline in place and runs. +// After each case the compiler's thread is gone and the process's thread count is back where it was. +// No game data: the shader is test/glsl/cs_user_data.comp, the programs are made-up FSSM bytes. +#include "shader_fixture_path.h" +#include "test_temp_dir.h" +#include "vk_test_device.h" +#include "../shims/d3d12_com.h" +#include "../shims/d3d12_compile_exit.h" +#include "../shims/d3d12_pipeline_compile.h" +#include "../shims/d3d12_xs_device.h" +#include "../src/shader_library.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef LEONIDA_TEST_CS_SPV +#error "LEONIDA_TEST_CS_SPV must name the compiled test shader" +#endif + +#define EXPECT(condition) do { \ + if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \ +} while (0) + +namespace { + +using XboxComputePipelineFn = HRESULT(WINAPI*)(void* device, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, std::uint64_t, + std::uint64_t, const IID*, void**); +using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void* heap); // heap slots 9/10: handle in RAX +using SerializeFn = HRESULT(WINAPI*)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC*, ID3DBlob**, ID3DBlob**); +using Clock = std::chrono::steady_clock; + +constexpr unsigned kPrograms = 48; // PSOs per device: enough that the worker is still busy at the release +constexpr unsigned kRacingRounds = 12; + +void* slot(void* object, unsigned index) { return (*reinterpret_cast(object))[index]; } + +void put32(std::vector& out, std::uint32_t v) { + for (int i = 0; i < 4; ++i) out.push_back(std::uint8_t(v >> (8 * i))); +} + +std::vector zlib_stored(const std::vector& data) { + std::vector out = {0x78, 0x01, 0x01}; + const auto length = std::uint16_t(data.size()); + out.insert(out.end(), {std::uint8_t(length), std::uint8_t(length >> 8), std::uint8_t(~length), + std::uint8_t(~length >> 8)}); + out.insert(out.end(), data.begin(), data.end()); + std::uint32_t a = 1, b = 0; + for (const std::uint8_t x : data) { + a = (a + x) % 65521; + b = (b + a) % 65521; + } + const std::uint32_t adler = (b << 16) | a; + out.insert(out.end(), {std::uint8_t(adler >> 24), std::uint8_t(adler >> 16), std::uint8_t(adler >> 8), + std::uint8_t(adler)}); + return out; +} + +// DXBC { DXIL { stub, XDAT { 0x0D: XBCH + zlib(fssm) } } }, as in d3d12_compute_test. +std::vector shader_container(const std::vector& fssm) { + const auto stream = zlib_stored(fssm); + std::vector xbch = {'X', 'B', 'C', 'H'}; + for (const std::uint32_t v : {1u, std::uint32_t(stream.size()), 0u, std::uint32_t(fssm.size()), 0u}) put32(xbch, v); + xbch.insert(xbch.end(), stream.begin(), stream.end()); + std::vector dxil(16, 0); + dxil.insert(dxil.end(), {'X', 'D', 'A', 'T'}); + put32(dxil, 1); + put32(dxil, 12); + put32(dxil, 0x0d); + put32(dxil, 16 + 12 + 12); + put32(dxil, std::uint32_t(xbch.size())); + dxil.insert(dxil.end(), xbch.begin(), xbch.end()); + std::vector out = {'D', 'X', 'B', 'C'}; + out.resize(28, 0); + put32(out, 1); + put32(out, 36); + out.insert(out.end(), {'D', 'X', 'I', 'L'}); + put32(out, std::uint32_t(dxil.size())); + out.insert(out.end(), dxil.begin(), dxil.end()); + return out; +} + +// Program i: a made-up FSSM blob whose code word (dword 1, which the shader reads through its code base) differs, +// so each has its own hash and its own index entry. +std::uint32_t code_word(unsigned i) { return 7000 + i; } +std::vector program(unsigned i) { + std::vector fssm = {'F', 'S', 'S', 'M'}; + put32(fssm, code_word(i)); + for (std::uint32_t w = 0; w < 14; ++w) put32(fssm, 0xbf810000u + w); + return fssm; +} + +std::vector serialize(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC& desc) { + const HMODULE d3d12 = LoadLibraryExA("d3d12.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + const auto fn = d3d12 ? reinterpret_cast( + reinterpret_cast(GetProcAddress(d3d12, "D3D12SerializeVersionedRootSignature"))) + : nullptr; + std::vector out; + ID3DBlob* blob = nullptr; + if (fn && SUCCEEDED(fn(&desc, &blob, nullptr)) && blob) { + const auto* p = static_cast(blob->GetBufferPointer()); + out.assign(p, p + blob->GetBufferSize()); + blob->Release(); + } + return out; +} + +D3D12_RESOURCE_DESC buffer_desc(UINT64 bytes, D3D12_RESOURCE_FLAGS flags) { + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Width = bytes; + desc.Height = 1; + desc.DepthOrArraySize = 1; + desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = flags; + return desc; +} + +unsigned thread_count() { + const HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); + if (snapshot == INVALID_HANDLE_VALUE) return 0; + unsigned count = 0; + THREADENTRY32 entry{sizeof(entry)}; + for (BOOL more = Thread32First(snapshot, &entry); more; more = Thread32Next(snapshot, &entry)) + if (entry.th32OwnerProcessID == GetCurrentProcessId()) ++count; + CloseHandle(snapshot); + return count; +} + +// Waits up to `ms` for `done`; true when it held. +template bool eventually(Done done, unsigned ms = 10000) { + const auto until = Clock::now() + std::chrono::milliseconds(ms); + while (!done()) { + if (Clock::now() > until) return false; + Sleep(5); + } + return true; +} + +struct Event { + HANDLE handle = CreateEventW(nullptr, TRUE, FALSE, nullptr); + Event() = default; + Event(const Event&) = delete; + Event& operator=(const Event&) = delete; + ~Event() { CloseHandle(handle); } + void set() const { SetEvent(handle); } + bool wait(DWORD ms = 30000) const { return WaitForSingleObject(handle, ms) == WAIT_OBJECT_0; } +}; + +bool built(ID3D12PipelineState* pso) { + const auto* requests = rt::d3d12::pipeline_subgroup_requests(pso); + return requests && !requests->empty(); // recorded when the Vulkan pipeline is made (build_compute) +} + +// One D3D12 device over the test's VkDevice, the compute test's root signature (two constants, a root UAV, a CBV +// table) and PSOs. The title's references, released in any order with release(). +struct Session { + ID3D12Device* device = nullptr; + ID3D12RootSignature* root = nullptr; + std::vector psos; + + int open(vktest::Device& d, const std::filesystem::path& library, unsigned count) { + rt::d3d12::VulkanDeviceInfo info{}; + info.get_instance_proc = d.instance_proc; + info.instance = d.instance; + info.physical = d.physical; + info.device = d.device; + info.queue = d.queue; + info.queue_family = d.family; + info.buffer_device_address = true; + info.subgroup = d.subgroup; + info.shader_dir = library.string(); + ID3D12Device* inner = nullptr; + EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner)))); + const HRESULT proxied = rt::d3d12_xs::create_device_proxy(inner, __uuidof(ID3D12Device), + reinterpret_cast(&device), false); + if (FAILED(proxied)) inner->Release(); + EXPECT(SUCCEEDED(proxied)); + rt::d3d12::set_device_outer(inner, device); + + D3D12_DESCRIPTOR_RANGE range{D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 1, 0, 0}; + D3D12_ROOT_PARAMETER params[3] = {}; + params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; + params[0].Constants = {0, 0, 2}; + params[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; + params[1].Descriptor = {0, 0}; + params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + params[2].DescriptorTable = {1, &range}; + D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{}; + root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; + root_desc.Desc_1_0 = {3, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE}; + const auto blob = serialize(root_desc); + EXPECT(!blob.empty()); + EXPECT(SUCCEEDED(device->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root)))); + for (unsigned i = 0; i < count; ++i) EXPECT(add(i) == 0); + return 0; + } + + int add(unsigned program_index) { + const auto container = shader_container(program(program_index)); + D3D12_COMPUTE_PIPELINE_STATE_DESC desc{}; + desc.pRootSignature = root; + desc.CS = {container.data(), container.size()}; + const IID iid = __uuidof(ID3D12PipelineState); + ID3D12PipelineState* pso = nullptr; + EXPECT(SUCCEEDED(reinterpret_cast(slot(device, 62))( + device, &desc, 0, 0, &iid, reinterpret_cast(&pso)))); + psos.push_back(pso); + return 0; + } + + // One dispatch of `pso` (program `program_index`): out[i] = 7 + 3 i + table[i % 4] + code word, read back. + int dispatch(ID3D12PipelineState* pso, unsigned program_index) { + constexpr UINT elements = 64, bytes = elements * 4; + const std::uint32_t table_values[4] = {1000, 2000, 3000, 4000}; + const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}; + const D3D12_HEAP_PROPERTIES upload_heap{D3D12_HEAP_TYPE_UPLOAD}; + const D3D12_HEAP_PROPERTIES readback_heap{D3D12_HEAP_TYPE_READBACK}; + const auto uav = buffer_desc(bytes, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); + const auto constants_desc = buffer_desc(256, D3D12_RESOURCE_FLAG_NONE); + const auto readback_desc = buffer_desc(bytes, D3D12_RESOURCE_FLAG_NONE); + ID3D12Resource *out = nullptr, *constants = nullptr, *readback = nullptr; + ID3D12DescriptorHeap* heap = nullptr; + ID3D12CommandQueue* queue = nullptr; + ID3D12CommandAllocator* allocator = nullptr; + ID3D12GraphicsCommandList* list = nullptr; + ID3D12Fence* fence = nullptr; + struct Releaser { + std::vector all; + ~Releaser() { + for (IUnknown** p : all) + if (*p) (*p)->Release(); + } + } releaser{{reinterpret_cast(&out), reinterpret_cast(&constants), + reinterpret_cast(&readback), reinterpret_cast(&heap), + reinterpret_cast(&queue), reinterpret_cast(&allocator), + reinterpret_cast(&list), reinterpret_cast(&fence)}}; + EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &uav, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, + IID_PPV_ARGS(&out)))); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE, &constants_desc, + D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, + IID_PPV_ARGS(&constants)))); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &readback_desc, + D3D12_RESOURCE_STATE_COPY_DEST, nullptr, + IID_PPV_ARGS(&readback)))); + void* mapped = nullptr; + EXPECT(SUCCEEDED(constants->Map(0, nullptr, &mapped))); + std::memcpy(mapped, table_values, sizeof(table_values)); + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 8, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; + EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap)))); + const std::uint64_t cpu = reinterpret_cast(slot(heap, 9))(heap); + const std::uint64_t gpu = reinterpret_cast(slot(heap, 10))(heap); + EXPECT(cpu && gpu >= 0x10000 && gpu < (1ull << 32)); + const std::uint64_t target = constants->GetGPUVirtualAddress(); + std::memcpy(reinterpret_cast(cpu), &target, sizeof(target)); + + D3D12_COMMAND_QUEUE_DESC queue_desc{}; + EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue)))); + EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator)))); + EXPECT(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator, pso, + IID_PPV_ARGS(&list)))); + EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence)))); + list->SetDescriptorHeaps(1, &heap); + list->SetComputeRootSignature(root); + list->SetComputeRoot32BitConstant(0, 7, 0); + list->SetComputeRoot32BitConstant(0, 3, 1); + list->SetComputeRootUnorderedAccessView(1, out->GetGPUVirtualAddress()); + list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu}); + list->Dispatch(1, 1, 1); + D3D12_RESOURCE_BARRIER barrier{}; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Transition = {out, D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, + D3D12_RESOURCE_STATE_COPY_SOURCE}; + list->ResourceBarrier(1, &barrier); + list->CopyBufferRegion(readback, 0, out, 0, bytes); + EXPECT(list->Close() == S_OK); + ID3D12CommandList* lists[] = {list}; + queue->ExecuteCommandLists(1, lists); + EXPECT(rt::d3d12::last_execute_result(queue) == leonida::ReplayResult::success); + EXPECT(SUCCEEDED(queue->Signal(fence, 1))); + EXPECT(SUCCEEDED(fence->SetEventOnCompletion(1, nullptr))); + void* results = nullptr; + EXPECT(SUCCEEDED(readback->Map(0, nullptr, &results))); + std::vector words(elements); + std::memcpy(words.data(), results, bytes); + for (std::uint32_t i = 0; i < elements; ++i) + EXPECT(words[i] == 7 + 3 * i + table_values[i % 4] + code_word(program_index)); + return 0; + } + + // The device first, as a title that lets its PSOs go last: the last PSO's Release destroys the device. In + // creation order a PSO's build is usually the one running (the worker takes equal sizes in submission order); + // newest first, the ones still queued are dropped. + void release(bool newest_first = false) { + if (device) device->Release(); + device = nullptr; + if (root) root->Release(); + root = nullptr; + if (newest_first) + for (auto it = psos.rbegin(); it != psos.rend(); ++it) (*it)->Release(); + else + for (ID3D12PipelineState* pso : psos) pso->Release(); + psos.clear(); + } + ~Session() { release(); } +}; + +using rt::d3d12::PipelineCompiler; + +// Waits until the worker has run everything queued so far: a last-priority marker job. +bool drain(PipelineCompiler& compiler) { + Event done; + static const int marker = 0; + if (!compiler.submit(&marker, nullptr, SIZE_MAX, [&done] { done.set(); })) return false; + return done.wait(120000); +} + +// Holds the worker in a job of no device until open() (or the end of the scope). +struct Gate { + Event entered, opened, left; + explicit Gate(PipelineCompiler& compiler) { + static const int gate = 0; + compiler.submit(&gate, nullptr, 0, [this] { + entered.set(); + opened.wait(INFINITE); + left.set(); + }); + entered.wait(); + } + void open() { opened.set(); } + ~Gate() { + opened.set(); + left.wait(); // the job is out of this object before its events close + } +}; + +// Parks the build of one PSO on the worker once it counts as running, before its work (the real build) starts. +struct Park { + PipelineCompiler& compiler; + std::atomic target{nullptr}; + Event parked, proceed; + explicit Park(PipelineCompiler& c) : compiler(c) { + compiler.set_job_probe([this](const void* owner) { + if (owner != target.load()) return; + parked.set(); + proceed.wait(INFINITE); + }); + } + ~Park() { + proceed.set(); + compiler.set_job_probe(nullptr); + } +}; + +} // namespace + +int main() { + // Lazy compute with the warm-up thread on (the defaults, set so a caller's environment cannot turn them off), and + // asynchronous first-use builds, so the exit case's dispatch goes through queue_build. + _putenv_s("LEONIDA_LAZY_COMPUTE", "1"); + _putenv_s("LEONIDA_COMPUTE_WARMUP", "1"); + _putenv_s("LEONIDA_ASYNC_PIPELINES", "1"); + _putenv_s("LEONIDA_STRICT_REPLAY", "0"); + const testfiles::ScratchDir scratch("leonida_compile_teardown_test"); + const auto library = scratch.path() / "spirv"; + const auto cache_dir = scratch.path() / "cache"; + std::filesystem::create_directories(library); + _putenv_s("LEONIDA_PIPELINE_CACHE_DIR", cache_dir.string().c_str()); + _putenv_s("LEONIDA_PIPELINE_CACHE_BYTES", "67108864"); + + vktest::Device d; + const auto device_status = d.initialize(); + if (device_status == vktest::DeviceStatus::unavailable) { + std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n"); + return 77; + } + EXPECT(device_status == vktest::DeviceStatus::ready); + + { + std::ofstream index(library / "index.json", std::ios::binary); + index << "{"; + for (unsigned i = 0; i < kPrograms; ++i) { + const std::string name = "cs_teardown_" + std::to_string(i); + EXPECT(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_CS_SPV), library / (name + ".spv"))); + index << (i ? ",\n" : "") << "\"" << name << "\": {\"stage\": \"cs\", \"fssm_sha256\": \"" + << leonida::sha256_hex(program(i)) << "\", \"bindings\": [], \"push_constant_bytes\": 144, " + << "\"local_size\": [64, 1, 1], \"uses_code_base\": true, \"wave64\": false}"; + } + index << "}"; + } + + auto& compiler = PipelineCompiler::instance(); + EXPECT(!compiler.worker_running()); + + // --- cache: one PSO built by the warm-up thread; the device writes the session cache at teardown ------------- + { + Session s; + if (s.open(d, library, 1)) return 1; + EXPECT(compiler.worker_running()); + EXPECT(drain(compiler)); // the PSO's warm-up build has run: the device has a pipeline cache + EXPECT(built(s.psos[0])); + s.release(); + EXPECT(!compiler.worker_running()); + EXPECT(std::filesystem::exists(cache_dir / "pipeline_cache.session.bin")); + std::printf("cache: built in the background, session cache written at teardown, worker joined\n"); + } + // The driver may start threads of its own at the first pipeline build; count from here. + const unsigned baseline = thread_count(); + EXPECT(baseline > 0); + constexpr unsigned slack = 2; // driver threads that come and go + const auto threads_back = [&] { return eventually([&] { return thread_count() <= baseline + slack; }); }; + + // --- queued: every warm-up build still queued behind a gate when the PSOs are released ---------------------- + { + Gate gate(compiler); + const auto before = compiler.stats(); + Session s; + if (s.open(d, library, kPrograms)) return 1; + EXPECT(compiler.stats().submitted - before.submitted == kPrograms); + // Everything but the last PSO: each drops its own queued build. + ID3D12PipelineState* last = s.psos.back(); + s.psos.pop_back(); + s.release(); + const auto dropped = compiler.stats().dropped - before.dropped; + std::printf("queued: %llu of %u warm-up builds dropped at release, none run\n", + static_cast(dropped), kPrograms - 1); + EXPECT(dropped == kPrograms - 1); + // The device goes with the last PSO. The gate is a job of no device, so it is let go first: the last + // device's release joins the worker, which must not be parked in it. + gate.open(); + last->Release(); + EXPECT(!compiler.worker_running()); + EXPECT(threads_back()); + } + + // --- prompt: a PSO released while its real build is in flight; the device is still held --------------------- + { + Park park(compiler); + Session s; + { + Gate gate(compiler); // so the PSO's build cannot start before the probe knows it + if (s.open(d, library, 1)) return 1; + park.target = s.psos[0]; + } + EXPECT(park.parked.wait()); + const auto before = compiler.stats(); + const long live = rt::d3d12::live_pipeline_states(); + ID3D12PipelineState* pso = s.psos[0]; + s.psos.clear(); + const auto start = Clock::now(); + pso->Release(); // the title's last reference + const auto took = std::chrono::duration_cast(Clock::now() - start).count(); + const auto after = compiler.stats(); + Sleep(50); + const long live_while_parked = rt::d3d12::live_pipeline_states(); // the build has not run: not deleted + park.proceed.set(); // the build now runs on the released PSO, which the worker deletes after it + EXPECT(drain(compiler)); + const long live_after_build = rt::d3d12::live_pipeline_states(); + std::printf("prompt: a PSO released with its build in flight returned in %lld ms; PSOs alive %ld before, %ld " + "while its build was parked, %ld after the build\n", + static_cast(took), live, live_while_parked, live_after_build); + EXPECT(took < 250); + EXPECT(after.deferred == before.deferred + 1 && after.waited == before.waited); + EXPECT(live == 1 && live_while_parked == live && live_after_build == live - 1); + s.release(); + EXPECT(!compiler.worker_running()); + EXPECT(threads_back()); + } + + // --- last device: the release that tears the device down waits for the PSO's build --------------------------- + { + Park park(compiler); + Session s; + { + Gate gate(compiler); + if (s.open(d, library, 1)) return 1; + park.target = s.psos[0]; + } + EXPECT(park.parked.wait()); + const auto before = compiler.stats(); + s.device->Release(); + s.device = nullptr; + s.root->Release(); + s.root = nullptr; + ID3D12PipelineState* pso = s.psos[0]; + s.psos.clear(); + std::atomic returned{false}; + std::thread title([&] { + pso->Release(); // the PSO held the device's last reference + returned = true; + }); + Sleep(300); + const bool early = returned.load(); + park.proceed.set(); + title.join(); + std::printf("last device: the device's teardown %s for the PSO's build in flight\n", + early ? "did NOT wait" : "waited"); + EXPECT(!early); + EXPECT(compiler.stats().waited == before.waited + 1); + EXPECT(!compiler.worker_running()); + EXPECT(rt::d3d12::live_pipeline_states() == 0); // deleted after its build, before the device went + EXPECT(threads_back()); + } + + // --- on worker: the PSO's last Release comes from inside its own build -------------------------------------- + for (const bool device_held : {true, false}) { + Session s; + Event released; + std::atomic target{nullptr}; + compiler.set_job_probe([&](const void* owner) { + if (owner != target.load()) return; + static_cast(const_cast(owner))->Release(); + released.set(); + }); + const auto before = compiler.stats(); + { + Gate gate(compiler); + if (s.open(d, library, 1)) return 1; + target = s.psos[0]; + s.psos.clear(); // the probe releases it + if (!device_held) { + s.device->Release(); // the PSO now holds the device's last reference + s.device = nullptr; + s.root->Release(); + s.root = nullptr; + } + } + EXPECT(released.wait()); + if (device_held) { + EXPECT(drain(compiler)); // the build ran on, then the PSO was deleted + s.release(); + } + // Without the device held, it is torn down on the worker after the build, and the worker lets itself go. + EXPECT(eventually([&] { return !compiler.worker_running(); })); + compiler.set_job_probe(nullptr); + EXPECT(compiler.stats().deferred == before.deferred + 1); + EXPECT(rt::d3d12::live_pipeline_states() == 0); + EXPECT(threads_back()); + std::printf("on worker (%s): released inside its own build, deleted after it\n", + device_held ? "device held" : "device's last reference"); + } + + // --- two devices: one torn down while the other's builds are queued ----------------------------------------- + { + Session a, b; + const auto before = compiler.stats(); + { + Gate gate(compiler); + if (a.open(d, library, kPrograms / 2)) return 1; + if (b.open(d, library, kPrograms / 2)) return 1; + a.release(); + EXPECT(compiler.stats().dropped - before.dropped == kPrograms / 2); + EXPECT(compiler.worker_running()); // b still holds it + for (unsigned i = kPrograms / 2; i < kPrograms; ++i) EXPECT(b.add(i) == 0); + } + EXPECT(drain(compiler)); + for (ID3D12PipelineState* pso : b.psos) EXPECT(built(pso)); + b.release(); + EXPECT(!compiler.worker_running()); + EXPECT(threads_back()); + std::printf("two devices: %u builds of the released one dropped, all %zu of the other built\n", + kPrograms / 2, size_t(kPrograms / 2 + kPrograms / 2)); + } + + // --- racing: release at once, builds queued and usually one running --------------------------------------- + { + const auto before = compiler.stats(); + unsigned peak = 0; + for (unsigned round = 0; round < kRacingRounds; ++round) { + Session s; + if (s.open(d, library, kPrograms)) return 1; + if (round % 3 == 1) Sleep(round); // let some rounds get a build or more under way first + s.release(round & 1); + EXPECT(!compiler.worker_running()); + EXPECT(rt::d3d12::live_pipeline_states() == 0); // every PSO deleted, deferred ones included + const unsigned now = thread_count(); + if (now > peak) peak = now; + EXPECT(threads_back()); + } + const auto after = compiler.stats(); + std::printf("racing: %u rounds of %u PSOs; %llu builds queued, %llu dropped, %llu PSO releases left a running " + "build behind, %llu device teardowns waited for one; threads %u at the start, at most %u\n", + kRacingRounds, kPrograms, static_cast(after.submitted - before.submitted), + static_cast(after.dropped - before.dropped), + static_cast(after.deferred - before.deferred), + static_cast(after.waited - before.waited), baseline, peak); + // How many builds were dropped or left running depends on timing (tiny programs, a warm cache): reported, + // not asserted. The queued, prompt and last device cases hold those states deterministically. + EXPECT(after.submitted - before.submitted == kRacingRounds * kPrograms); + } + + // --- restart: a device made after the worker stopped gets a new worker, and its builds run ------------------ + { + EXPECT(!compiler.worker_running()); + Session s; + if (s.open(d, library, kPrograms)) return 1; + EXPECT(compiler.worker_running()); + EXPECT(drain(compiler)); + for (ID3D12PipelineState* pso : s.psos) EXPECT(built(pso)); + s.release(); + EXPECT(!compiler.worker_running()); + std::printf("restart: a new device after a stop got a new worker; all %u builds ran\n", kPrograms); + } + + // --- exit: stop_pipeline_compiles with a device alive -------------------------------------------------------- + { + Session s; + if (s.open(d, library, kPrograms)) return 1; + EXPECT(rt::d3d12::stop_pipeline_compiles(60000)); + EXPECT(!compiler.worker_running()); + const auto before = compiler.stats(); + static const int late = 0; + EXPECT(!compiler.submit(&late, nullptr, 0, [] {})); + EXPECT(compiler.stats().refused == before.refused + 1); + // A PSO made now queues no warm-up, and its first dispatch builds the pipeline in place and runs. + const unsigned fresh = 0; + EXPECT(s.add(fresh) == 0); + ID3D12PipelineState* pso = s.psos.back(); + EXPECT(compiler.stats().submitted == before.submitted && !built(pso)); + if (s.dispatch(pso, fresh)) return 1; + EXPECT(built(pso)); + EXPECT(compiler.stats().submitted == before.submitted); + s.release(); // the device's teardown after the exit stop: nothing left to cancel or join + EXPECT(!compiler.worker_running()); + EXPECT(rt::d3d12::live_pipeline_states() == 0); // no PSO of any case leaked + std::printf("exit: queue dropped, later builds refused, a dispatch built its pipeline in place and ran\n"); + } + std::printf("ok\n"); + return 0; +} diff --git a/runtime/test/d3d12_draw_test.cpp b/runtime/test/d3d12_draw_test.cpp index d107161584..ffbfbf718d 100644 --- a/runtime/test/d3d12_draw_test.cpp +++ b/runtime/test/d3d12_draw_test.cpp @@ -77,17 +77,51 @@ static_assert(offsetof(Vertex, wrong_color) == 16); } // namespace +// Positive-only offscreen variant, sharing the translated-shader fixture, root signature and PSO description. +int check_stateful_indirect_pixels(ID3D12Device* device, ID3D12RootSignature* root, D3D12_GRAPHICS_PIPELINE_STATE_DESC desc, + bool multi, bool counted, bool nonindexed_only); + int main(int argc, char** argv) { + const bool nonindexed_only = argc == 3 && std::strcmp(argv[2], "--nonindexed-only") == 0; + const bool indirect_mode = argc == 2 || nonindexed_only; + const bool multi_pixels = indirect_mode && std::strcmp(argv[1], "--stateful-indirect-multi-pixels") == 0; + const bool count_pixels = indirect_mode && std::strcmp(argv[1], "--stateful-indirect-counted-pixels") == 0; + const bool indirect_pixels = multi_pixels || count_pixels || + (indirect_mode && std::strcmp(argv[1], "--stateful-indirect-pixels") == 0); + if (argc > 2 && !(nonindexed_only && indirect_pixels)) return 1; const bool title_index = argc == 2 && std::strcmp(argv[1], "--title-index-window") == 0; const bool title_vertex = argc == 2 && std::strcmp(argv[1], "--title-vertex-window") == 0; const bool title_window = title_index || title_vertex; vktest::Device d; + d.request_draw_indirect_first_instance = indirect_pixels; + d.request_robust_index_view = indirect_pixels && !nonindexed_only; + // Only the uncounted multi-record commands require multiDrawIndirect. Keep it disabled in the counted fixture. + d.request_multi_draw_indirect = multi_pixels; + d.request_draw_indirect_count = count_pixels; const auto device_status = d.initialize(); if (device_status == vktest::DeviceStatus::unavailable) { std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n"); return 77; } EXPECT(device_status == vktest::DeviceStatus::ready); + if (indirect_pixels && !d.enabled.drawIndirectFirstInstance) { + std::fprintf(stderr, "SKIP: drawIndirectFirstInstance is unavailable\n"); + return 77; + } + + if (nonindexed_only) EXPECT(!d.robust_index_view); + if (d.request_robust_index_view && !d.robust_index_view) { + std::fprintf(stderr, "SKIP: indexed indirect pixels require maintenance5 and compatible robustBufferAccess2\n"); + return 77; + } + if (multi_pixels && (!d.enabled.multiDrawIndirect || d.max_draw_indirect_count < 2)) { + std::fprintf(stderr, "SKIP: multiDrawIndirect unavailable or maxDrawIndirectCount < 2\n"); + return 77; + } + if (count_pixels && (!d.draw_indirect_count_enabled || d.max_draw_indirect_count != UINT32_MAX)) { + std::fprintf(stderr, "SKIP: counted replay requires drawIndirectCount and maxDrawIndirectCount == UINT32_MAX\n"); + return 77; + } // Shader programs and the index that maps their hashes to the compiled test modules. const auto vs_program = fssm_program({0x56530001, 0xbf810000}); @@ -163,6 +197,11 @@ int main(int argc, char** argv) { info.shader_dir = library.string(); // Of the PSO features only logicOp is passed on, so the other feature refusals below still apply. info.features.logicOp = d.enabled.logicOp; + info.draw_indirect_first_instance = d.enabled.drawIndirectFirstInstance == VK_TRUE; + info.multi_draw_indirect = d.enabled.multiDrawIndirect == VK_TRUE; + info.draw_indirect_count_enabled = d.draw_indirect_count_enabled; + info.robust_index_view = d.robust_index_view; + info.max_draw_indirect_count = d.max_draw_indirect_count; info.vertex_attribute_divisor = d.vertex_attribute_divisor; ID3D12Device* inner = nullptr; EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner)))); @@ -204,6 +243,12 @@ int main(int argc, char** argv) { pso_desc.NumRenderTargets = 1; pso_desc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; pso_desc.SampleDesc.Count = 1; + if (indirect_pixels) { + const int result = check_stateful_indirect_pixels(device.p, root.p, pso_desc, multi_pixels || count_pixels, + count_pixels, nonindexed_only); + EXPECT(d.validation_errors() == 0); + return result; + } Ref pso, unfed, mrt, instanced, refused, xor_pso, fullscreen; EXPECT(SUCCEEDED(device->CreateGraphicsPipelineState(&pso_desc, IID_PPV_ARGS(&pso.p)))); pso_desc.InputLayout = {elements, 1}; // COLOR missing: D3D12 rejects a layout that leaves an input unfed diff --git a/runtime/test/d3d12_graphics_direct_heaps_test.cpp b/runtime/test/d3d12_graphics_direct_heaps_test.cpp index b09cbc3b63..3445438dd5 100644 --- a/runtime/test/d3d12_graphics_direct_heaps_test.cpp +++ b/runtime/test/d3d12_graphics_direct_heaps_test.cpp @@ -1,23 +1,30 @@ // Directly indexed descriptor heaps for graphics draws, through the Xbox-ABI proxy over the Vulkan device. // // A root signature with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED and/or SAMPLER_HEAP_DIRECTLY_INDEXED gives the console's -// vertex and pixel shaders the bound heaps' 32-bit shader VAs in the user-data dwords right after the explicit root -// arguments (from s8, one dword per table): resource heap first, then sampler heap. The vertex and pixel shaders here -// (test/glsl/vs_user_data_window.vert, ps_user_data_window.frag) both read s10..s13 and write what they saw to two -// UINT render targets, one pixel per draw: +// vertex, pixel and mesh shaders the bound heaps' 32-bit shader VAs in the user-data dwords right after the explicit +// root arguments (from s8, one dword per table): resource heap first, then sampler heap. The vertex and pixel shaders +// here (test/glsl/vs_user_data_window.vert, ps_user_data_window.frag) both read s10..s13 and write what they saw to +// two UINT render targets, one pixel per draw: // 0. three constants (s8..s10), both flags: s10 = constant, s11 = resource heap, s12 = sampler heap; // 1. the same signature without the flags: s11..s13 stay 0; // 2. a table (s8) and three constants (s9..s11): s12 = resource heap, s13 = sampler heap; // 3. three constants, the sampler flag alone: s11 = sampler heap; // 4. as 0 after SetDescriptorHeaps with the resource heap alone: the sampler heap's dword is 0 for that draw only -// (each draw snapshots the heaps, as a dispatch does). +// (each draw snapshots the heaps, as a dispatch does); +// 5. a mesh pipeline (test/glsl/ms_user_data_window.mesh and ps_mesh_user_data_window.frag) after both heaps are +// bound again: the mesh shader uses the graphics root window (push dword i -> s(i+8)), while the pixel shader +// uses the same shared block. Target 0 gets the mesh stage's words and target 1 the pixel stage's, so one draw +// shows both stages of the pipeline got the heaps. Skipped on a device without VK_EXT_mesh_shader. // The recorded Draw commands are checked too. With --off (ctest d3d12_graphics_direct_heaps_off sets // LEONIDA_GRAPHICS_DIRECT_HEAPS=0) no draw gets a heap dword. No game data. +// --indirect-resources changes the pixel shader to read slot 1 of the directly indexed resource heap. Five draws +// on one list (direct A, indirect B, indirect A, direct B, indirect B without a sampler) check actual payloads. // Set LEONIDA_VK_VALIDATION=1 to run under VK_LAYER_KHRONOS_validation. #include "shader_fixture_path.h" #include "test_temp_dir.h" #include "vk_test_device.h" #include "d3d12_test_shaders.h" +#include "d3d12_pipeline_stream.h" #include "../shims/d3d12_com.h" #include "../shims/d3d12_xs_device.h" #include "../src/shader_library.h" @@ -29,8 +36,9 @@ #include #include -#if !defined(LEONIDA_TEST_VS_SPV) || !defined(LEONIDA_TEST_PS_SPV) -#error "LEONIDA_TEST_VS_SPV and LEONIDA_TEST_PS_SPV must name the compiled test shaders" +#if !defined(LEONIDA_TEST_VS_SPV) || !defined(LEONIDA_TEST_PS_SPV) || !defined(LEONIDA_TEST_MS_SPV) || \ + !defined(LEONIDA_TEST_PS_MESH_SPV) +#error "LEONIDA_TEST_VS_SPV, LEONIDA_TEST_PS_SPV, LEONIDA_TEST_MS_SPV and LEONIDA_TEST_PS_MESH_SPV must name the compiled test shaders" #endif #define EXPECT(condition) do { \ @@ -42,36 +50,72 @@ using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void* heap); // heap slots 9/10 int main(int argc, char** argv) { const bool off = argc == 2 && std::strcmp(argv[1], "--off") == 0; + const bool indirect_resources = argc == 2 && std::strcmp(argv[1], "--indirect-resources") == 0; if (off) { const char* v = std::getenv("LEONIDA_GRAPHICS_DIRECT_HEAPS"); EXPECT(v && std::strcmp(v, "0") == 0); } vktest::Device d; + d.request_mesh_shader = !indirect_resources; // the mesh draw of this test skips when the GPU has no VK_EXT_mesh_shader + d.request_draw_indirect_first_instance = indirect_resources; const auto device_status = d.initialize(); if (device_status == vktest::DeviceStatus::unavailable) { std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n"); return 77; } EXPECT(device_status == vktest::DeviceStatus::ready); + if (indirect_resources && !d.enabled.drawIndirectFirstInstance) { + std::fprintf(stderr, "SKIP: no enabled indirect first-instance capability\n"); + return 77; + } const auto vs_program = fssm_program({0x56530011, 0xbf810000}); const auto ps_program = fssm_program({0x50530011, 0xbf810000}); + const auto ms_program = fssm_program({0x4d530011, 0xbf810000}); + const auto ps_mesh_program = fssm_program({0x50530012, 0xbf810000}); const auto vs_container = shader_container(vs_program), ps_container = shader_container(ps_program); + auto ms_container = shader_container(ms_program); + ms_container[36 + 8 + 2] = 13; // the DXIL mesh shader kind, as the game's mesh containers carry + const auto ps_mesh_container = shader_container(ps_mesh_program); const testfiles::ScratchDir scratch("leonida_graphics_direct_heaps_test"); const auto& library = scratch.path(); EXPECT(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_VS_SPV), library / "vs_user_data_window.spv")); - EXPECT(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_PS_SPV), library / "ps_user_data_window.spv")); + EXPECT(testfiles::copy_file(vktest::shader_fixture_path(indirect_resources ? LEONIDA_TEST_PS_INDIRECT_HEAP + : LEONIDA_TEST_PS_SPV), + library / "ps_user_data_window.spv")); + EXPECT(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_MS_SPV), library / "ms_user_data_window.spv")); + EXPECT(testfiles::copy_file(vktest::shader_fixture_path(LEONIDA_TEST_PS_MESH_SPV), + library / "ps_mesh_user_data_window.spv")); { std::ofstream index(library / "index.json", std::ios::binary); index << "{\"vs_user_data_window\": {\"stage\": \"vs\", \"fssm_sha256\": \"" << leonida::sha256_hex(vs_program) << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"input_signature\": []},\n" " \"ps_user_data_window\": {\"stage\": \"ps\", \"fssm_sha256\": \"" << leonida::sha256_hex(ps_program) + << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"outputs\": [0, 1]},\n" + " \"ms_user_data_window\": {\"stage\": \"ms\", \"fssm_sha256\": \"" << leonida::sha256_hex(ms_program) + << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"local_size\": [32, 1, 1], " + "\"root_window\": {\"sgpr\": 16, \"dword\": 8}, " + "\"max_vertices\": 3, \"max_primitives\": 1},\n" + " \"ps_mesh_user_data_window\": {\"stage\": \"ps\", \"fssm_sha256\": \"" + << leonida::sha256_hex(ps_mesh_program) << "\", \"bindings\": [], \"push_constant_bytes\": 144, \"outputs\": [0, 1]}}"; } - constexpr UINT draws = 5; - constexpr UINT pixel_bytes = 16; // R32G32B32A32_UINT - std::array, draws> vs_seen{}, ps_seen{}, want{}; + constexpr UINT draws = 6; // five vertex draws, then one mesh draw + const UINT used = d.mesh_shader && !indirect_resources ? draws : draws - 1; // without VK_EXT_mesh_shader the mesh draw is skipped + constexpr UINT mesh_draw = draws - 1; + constexpr std::uint32_t mesh_marker = 0x4d53u; // 'MS': what the mesh shader puts beside the heaps it read + constexpr UINT pixel_bytes = 16; // R32G32B32A32_UINT + constexpr UINT user_dwords = 32; // the user-data block: s0..s31 + std::array, draws> vs_seen{}, ps_seen{}, want_vs{}, want_ps{}; + std::array, draws> want_user{}; + // The user-data dwords a recorded draw carries, from `first` on (the rest stay 0). + const auto set_user = [](std::array& data, UINT first, + std::initializer_list values) { + UINT dword = first; + for (const std::uint32_t value : values) data[dword++] = value; + }; + constexpr bool use_indirect[]{false, true, true, false, true}; { rt::d3d12::VulkanDeviceInfo info{}; info.get_instance_proc = d.instance_proc; @@ -81,8 +125,11 @@ int main(int argc, char** argv) { info.queue = d.queue; info.queue_family = d.family; info.buffer_device_address = true; + info.draw_indirect_first_instance = d.enabled.drawIndirectFirstInstance == VK_TRUE; + info.max_draw_indirect_count = d.max_draw_indirect_count; info.subgroup = d.subgroup; info.shader_dir = library.string(); + info.mesh_shader = d.mesh_shader; // the mesh draw's PSO needs VK_EXT_mesh_shader ID3D12Device* inner = nullptr; EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&inner)))); Ref device; @@ -152,7 +199,26 @@ int main(int argc, char** argv) { EXPECT(make_pso(table_both.p, pso_table_both)); EXPECT(make_pso(three_sampler.p, pso_three_sampler)); - // Two 5x1 UINT targets (what the VS saw, what the PS saw) and their RTVs. + // The mesh PSO of draw 5: a mesh shader has no D3D12_GRAPHICS_PIPELINE_STATE_DESC field, so it comes from a + // pipeline state stream. Back-face culling is off so the triangle's winding does not matter here. + Ref pso_mesh; + if (d.mesh_shader) { + D3D12_RASTERIZER_DESC raster{}; + raster.FillMode = D3D12_FILL_MODE_SOLID; + raster.CullMode = D3D12_CULL_MODE_NONE; + raster.DepthClipEnable = TRUE; + Stream stream; + stream.add(RootSubobject{.inner = three_both.p}) + .add(MsSubobject{.inner = {ms_container.data(), ms_container.size()}}) + .add(PsSubobject{.inner = {ps_mesh_container.data(), ps_mesh_container.size()}}) + .add(RasterizerSubobject{.inner = raster}) + .add(TargetsSubobject{.inner = rt_formats(2, DXGI_FORMAT_R32G32B32A32_UINT)}); + const HRESULT hr = create(device.p, stream, pso_mesh); + if (FAILED(hr)) std::fprintf(stderr, "mesh PSO: 0x%08lx\n", static_cast(hr)); + EXPECT(SUCCEEDED(hr)); + } + + // Two 6x1 UINT targets (what the VS or mesh stage saw, what the PS saw) and their RTVs. const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}; const D3D12_HEAP_PROPERTIES readback_heap{D3D12_HEAP_TYPE_READBACK}; D3D12_RESOURCE_DESC rt_desc{}; @@ -187,11 +253,13 @@ int main(int argc, char** argv) { Ref queue; Ref allocator; Ref list; + Ref list6; // DispatchMesh Ref fence; EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p)))); EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); EXPECT(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, pso_three_both.p, IID_PPV_ARGS(&list.p)))); + if (d.mesh_shader) EXPECT(SUCCEEDED(list->QueryInterface(IID_PPV_ARGS(&list6.p)))); EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p)))); const FLOAT seven[4] = {7, 7, 7, 7}; // a pixel no draw reached reads 7s @@ -217,17 +285,109 @@ int main(int argc, char** argv) { } list->DrawInstanced(3, 1, 0, 0); }; - draw_at(0, pso_three_both.p, three_both.p, false); - want[0] = {0xA2, r, s, 0}; - draw_at(1, pso_three_none.p, three_none.p, false); - want[1] = {0xA2, 0, 0, 0}; - draw_at(2, pso_table_both.p, table_both.p, true); - want[2] = {0xB1, 0xB2, r, s}; - draw_at(3, pso_three_sampler.p, three_sampler.p, false); - want[3] = {0xA2, s, 0, 0}; - list->SetDescriptorHeaps(1, &resources.p); // the sampler heap is unbound for the next draw - draw_at(4, pso_three_both.p, three_both.p, false); - want[4] = {0xA2, r, 0, 0}; + Ref args, inputs[2]; + Ref signature; + Ref alternate; + if (indirect_resources) { + EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&resource_desc, IID_PPV_ARGS(&alternate.p)))); + ID3D12DescriptorHeap* heaps[]{resources.p, alternate.p}; + const D3D12_HEAP_PROPERTIES upload{D3D12_HEAP_TYPE_UPLOAD}; + const auto desc = buffer_desc(256); + constexpr std::array, 2> values{{{11, 13, 17, 19}, {101, 103, 107, 109}}}; + const auto write_buffer = [&](Ref& dst, const void* src, std::size_t bytes) { + if (FAILED(device->CreateCommittedResource(&upload, {}, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, IID_PPV_ARGS(&dst.p)))) return false; + void* data{}; + if (FAILED(dst->Map(0, nullptr, &data))) return false; + std::memcpy(data, src, bytes); + dst->Unmap(0, nullptr); + return true; + }; + D3D12_SHADER_RESOURCE_VIEW_DESC srv{}; + srv.Format = DXGI_FORMAT_R32_TYPELESS; + srv.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srv.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srv.Buffer.NumElements = 4; + srv.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; + for (UINT i = 0; i < 2; ++i) { + EXPECT(write_buffer(inputs[i], values[i].data(), sizeof(values[i]))); + const auto cpu = reinterpret_cast(slot(heaps[i], 9))(heaps[i]); + device->CreateShaderResourceView(inputs[i].p, &srv, {SIZE_T(cpu + 32)}); // slot 1 + } + const D3D12_DRAW_ARGUMENTS record{3, 1, 0, 0}; + EXPECT(write_buffer(args, &record, sizeof(record))); + D3D12_INDIRECT_ARGUMENT_DESC action{}; + action.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + const D3D12_COMMAND_SIGNATURE_DESC description{sizeof(record), 1, &action, 0}; + EXPECT(SUCCEEDED(inner->CreateCommandSignature(&description, nullptr, IID_PPV_ARGS(&signature.p)))); + constexpr UINT which[]{0, 1, 0, 1, 1}; // both sources have a direct control on this list + for (UINT i = 0; i < used; ++i) { + const auto h = which[i]; + auto* heap = heaps[h]; + const auto gpu = reinterpret_cast(slot(heap, 10))(heap); + EXPECT(gpu >= 0x10000 && gpu <= 0xffffffffu - 64u); + if (h) EXPECT(gpu != res); + const auto va = inputs[h]->GetGPUVirtualAddress(); + EXPECT(va); + const UINT allowed[]{UINT(gpu), UINT(va), UINT(va >> 32)}; + ID3D12DescriptorHeap* bound[]{heap, samplers.p}; + list->SetDescriptorHeaps(i + 1 == used ? 1 : 2, bound); + list->SetGraphicsRootSignature(three_both.p); + list->SetPipelineState(pso_three_both.p); + list->SetGraphicsRoot32BitConstants(0, 3, allowed, 0); + const D3D12_VIEWPORT vp{float(i), 0, 1, 1, 0, 1}; + list->RSSetViewports(1, &vp); + if (use_indirect[i]) list->ExecuteIndirect(signature.p, 1, args.p, 0, nullptr, 0); + else list->DrawInstanced(3, 1, 0, 0); + want_vs[i] = {allowed[2], UINT(gpu), i + 1 == used ? 0u : s, 0}; + want_ps[i] = values[h]; + set_user(want_user[i], 8, {allowed[0], allowed[1], allowed[2]}); + set_user(want_user[i], 11, {UINT(gpu), i + 1 == used ? 0u : s}); + } + } else { + // The heap dwords a draw of this signature carries after the explicit arguments (`pixel_slot`). The same + // shared graphics block is used by vertex, pixel and mesh stages; root_window maps mesh push dword i to s(i+8). + const auto set_heap_windows = [&](std::array& data, UINT pixel_slot, bool resource, + bool sampler) { + UINT slot = pixel_slot; + if (resource) data[slot++] = r; + if (sampler) data[slot] = s; + }; + draw_at(0, pso_three_both.p, three_both.p, false); + want_vs[0] = want_ps[0] = {0xA2, r, s, 0}; + set_user(want_user[0], 8, {0xA0, 0xA1, 0xA2}); + set_heap_windows(want_user[0], 11, true, true); + draw_at(1, pso_three_none.p, three_none.p, false); + want_vs[1] = want_ps[1] = {0xA2, 0, 0, 0}; + set_user(want_user[1], 8, {0xA0, 0xA1, 0xA2}); // no flags: no heap dword in either window + draw_at(2, pso_table_both.p, table_both.p, true); + want_vs[2] = want_ps[2] = {0xB1, 0xB2, r, s}; + set_user(want_user[2], 9, {0xB0, 0xB1, 0xB2}); // s8 is the table's handle, not a constant + set_heap_windows(want_user[2], 12, true, true); // a table (s8) and three constants (s9..s11) + draw_at(3, pso_three_sampler.p, three_sampler.p, false); + want_vs[3] = want_ps[3] = {0xA2, s, 0, 0}; + set_user(want_user[3], 8, {0xA0, 0xA1, 0xA2}); + set_heap_windows(want_user[3], 11, false, true); + list->SetDescriptorHeaps(1, &resources.p); // the sampler heap is unbound for the next draw + draw_at(4, pso_three_both.p, three_both.p, false); + want_vs[4] = want_ps[4] = {0xA2, r, 0, 0}; + set_user(want_user[4], 8, {0xA0, 0xA1, 0xA2}); + set_heap_windows(want_user[4], 11, true, false); // 0 for the unbound sampler heap, this draw only + if (d.mesh_shader) { + // Both heaps bound again: both stages consume the same graphics user-data block. + list->SetDescriptorHeaps(2, both_heaps); + const D3D12_VIEWPORT viewport{float(mesh_draw), 0, 1, 1, 0, 1}; + list->RSSetViewports(1, &viewport); + list->SetPipelineState(pso_mesh.p); + list->SetGraphicsRootSignature(three_both.p); + list->SetGraphicsRoot32BitConstants(0, 3, a, 0); + list6->DispatchMesh(1, 1, 1); + want_vs[mesh_draw] = {r, s, mesh_marker, 0}; // the mesh stage's own words + want_ps[mesh_draw] = {r, s, 0, 0}; + set_user(want_user[mesh_draw], 8, {0xA0, 0xA1, 0xA2}); + set_heap_windows(want_user[mesh_draw], 11, true, true); + } + } for (std::size_t t = 0; t < targets.size(); ++t) { const auto to_copy = transition(targets[t].p, D3D12_RESOURCE_STATE_RENDER_TARGET, @@ -244,19 +404,30 @@ int main(int argc, char** argv) { } EXPECT(list->Close() == S_OK); - // The recorded draws carry the same words, snapshotted per draw. + // The recorded draws carry the same words, snapshotted per draw: explicit arguments and shared heap dwords. std::vector commands; EXPECT(rt::d3d12::recorded_commands(list.p, commands)); - UINT recorded = 0; + UINT recorded = 0, recorded_mismatches = 0; for (const auto& command : commands) { const auto* draw = std::get_if(&command); + const auto* raster = std::get_if(&command); + if (raster) { + EXPECT(indirect_resources && *raster && recorded < used && use_indirect[recorded]); + draw = &(*raster)->state; + } else if (draw && indirect_resources) EXPECT(recorded < used && !use_indirect[recorded]); if (!draw) continue; - EXPECT(recorded < draws); - const auto& w = want[recorded++]; - for (UINT k = 0; k < 4; ++k) EXPECT(draw->user_data[10 + k] == w[k]); - for (UINT k = 14; k < draw->user_data.size(); ++k) EXPECT(draw->user_data[k] == 0); + EXPECT(recorded < used); + const UINT index = recorded++; + const auto& want_dwords = want_user[index]; + for (UINT k = 9; k < user_dwords && k < draw->user_data.size(); ++k) { + if (draw->user_data[k] == want_dwords[k]) continue; + ++recorded_mismatches; + std::fprintf(stderr, "recorded draw %u s%u: got %08x want %08x\n", index, k, draw->user_data[k], + want_dwords[k]); + } } - EXPECT(recorded == draws); + EXPECT(recorded == used); + EXPECT(recorded_mismatches == 0); ID3D12CommandList* lists[] = {list.p}; queue->ExecuteCommandLists(1, lists); @@ -266,19 +437,25 @@ int main(int argc, char** argv) { void* mapped = nullptr; EXPECT(SUCCEEDED(readback->Map(0, nullptr, &mapped))); const auto* bytes = static_cast(mapped); - for (UINT pixel = 0; pixel < draws; ++pixel) { + for (UINT pixel = 0; pixel < used; ++pixel) { std::memcpy(vs_seen[pixel].data(), bytes + pixel * pixel_bytes, pixel_bytes); std::memcpy(ps_seen[pixel].data(), bytes + 512 + pixel * pixel_bytes, pixel_bytes); } readback->Unmap(0, nullptr); + pso_mesh.reset(); for (auto* p : {&pso_three_both, &pso_three_none, &pso_table_both, &pso_three_sampler}) p->reset(); for (auto* p : {&three_both, &three_none, &table_both, &three_sampler}) p->reset(); for (auto& t : targets) t.reset(); for (auto& h : rtv_heaps) h.reset(); + args.reset(); + signature.reset(); + for (auto& input : inputs) input.reset(); + alternate.reset(); readback.reset(); resources.reset(); samplers.reset(); + list6.reset(); list.reset(); allocator.reset(); queue.reset(); @@ -287,14 +464,15 @@ int main(int argc, char** argv) { } unsigned mismatches = 0; - for (UINT pixel = 0; pixel < draws; ++pixel) { - for (const auto* seen : {&vs_seen, &ps_seen}) { - const auto& got = (*seen)[pixel]; - if (got == want[pixel]) continue; + for (UINT pixel = 0; pixel < used; ++pixel) { + for (int which = 0; which < 2; ++which) { + const auto& got = which == 0 ? vs_seen[pixel] : ps_seen[pixel]; + const auto& want_words = which == 0 ? want_vs[pixel] : want_ps[pixel]; + if (got == want_words) continue; ++mismatches; - std::fprintf(stderr, "draw %u %s s10..s13: got %08x %08x %08x %08x want %08x %08x %08x %08x\n", pixel, - seen == &vs_seen ? "VS" : "PS", got[0], got[1], got[2], got[3], want[pixel][0], - want[pixel][1], want[pixel][2], want[pixel][3]); + std::fprintf(stderr, "draw %u %s: got %08x %08x %08x %08x want %08x %08x %08x %08x\n", pixel, + which == 0 ? "VS/MS words" : "PS words", got[0], got[1], got[2], got[3], want_words[0], + want_words[1], want_words[2], want_words[3]); } } EXPECT(!mismatches); @@ -302,9 +480,15 @@ int main(int argc, char** argv) { std::fprintf(stderr, "%u validation errors\n", d.validation_errors()); return 1; } - std::printf("graphics direct heaps%s: %u draws, the VS and PS read s10..s13 as recorded (heap dwords after the " - "explicit arguments at s11/s12 or s12/s13, sampler alone at s11, none without the flags, per-draw " - "snapshot)\n", - off ? " (LEONIDA_GRAPHICS_DIRECT_HEAPS=0: none supplied)" : "", draws); + if (indirect_resources) { + std::puts("3 indirect draws and 2 direct controls: exact VS heap state and PS resource payloads across heap changes"); + return 0; + } + std::printf("graphics direct heaps%s: %u draws, the VS, PS and%s read the heap dwords as recorded (after the " + "explicit arguments at s11/s12 or s12/s13, the sampler alone at s11, none without the flags, per-draw " + "snapshot%s)\n", + off ? " (LEONIDA_GRAPHICS_DIRECT_HEAPS=0: none supplied)" : "", used, + d.mesh_shader ? " mesh stage" : "", d.mesh_shader ? ", the mesh stage at s19/s20" : ""); + if (!d.mesh_shader) std::fprintf(stderr, "no VK_EXT_mesh_shader on this device: the mesh draw was skipped\n"); return 0; } diff --git a/runtime/test/d3d12_indirect_dispatch_count_test.cpp b/runtime/test/d3d12_indirect_dispatch_count_test.cpp index 9a97032e8f..f53502b5d7 100644 --- a/runtime/test/d3d12_indirect_dispatch_count_test.cpp +++ b/runtime/test/d3d12_indirect_dispatch_count_test.cpp @@ -36,7 +36,7 @@ void main(uint3 group : SV_GroupID) { )"; bool run(ID3D12Device* dev, const std::vector& shader, UINT count, bool gpu_update, - std::array& result, bool shim) { + std::array& result, bool shim, bool fixed = false, bool clamp_fixture = false) { Ref root; D3D12_ROOT_PARAMETER param{}; param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; @@ -80,6 +80,11 @@ bool run(ID3D12Device* dev, const std::vector& shader, UINT count, const UINT base = (kArgsOffset + i * kStride) / 4; input[base] = i + 1; // number of groups in the record, 1 then 2 then 3 input[base + 1] = input[base + 2] = 1; + if (clamp_fixture) { + // Budget 2: (1,4,4)->(1,2,1), (2,0,1)->empty, (3,1,1)->(2,1,1). + if (i == 0) input[base + 1] = input[base + 2] = 4; + if (i == 1) input[base + 1] = 0; + } input[base + 3] = 0xa5a5a5a5; // padding: must be ignored input[base + 4] = 0x5a5a5a5a; } @@ -112,7 +117,7 @@ bool run(ID3D12Device* dev, const std::vector& shader, UINT count, list->SetComputeRootSignature(root.p); list->SetPipelineState(pso.p); list->SetComputeRootUnorderedAccessView(0, output->GetGPUVirtualAddress()); - list->ExecuteIndirect(signature.p, kMaximum, args.p, kArgsOffset, counts.p, kCountOffset); + list->ExecuteIndirect(signature.p, kMaximum, args.p, kArgsOffset, fixed ? nullptr : counts.p, fixed ? 0 : kCountOffset); if (gpu_update) { auto to_copy = transition(counts.p, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, D3D12_RESOURCE_STATE_COPY_DEST); @@ -122,7 +127,7 @@ bool run(ID3D12Device* dev, const std::vector& shader, UINT count, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); list->ResourceBarrier(1, &to_indirect); // Repeat with a count produced by a GPU copy after the previous indirect dispatch. - list->ExecuteIndirect(signature.p, kMaximum, args.p, kArgsOffset, counts.p, kCountOffset); + list->ExecuteIndirect(signature.p, kMaximum, args.p, kArgsOffset, fixed ? nullptr : counts.p, fixed ? 0 : kCountOffset); } const auto to_copy = transition(output.p, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); @@ -178,37 +183,38 @@ std::string module_version(const wchar_t* name) { } } // namespace -int main() { - // Wine has no WARP (its host is vkd3d on the GPU), and its D3DCompile has no RWByteAddressBuffer::InterlockedAdd - // (E5005 on wine-staging 11.21), so the reference shader did not build and the test ended before the layer ran. - // The host runs are skipped there; the layer is still checked against expected(). - const bool compare_host = !hostwine::host_is_wine(); - std::vector native_code; +int make_host(Ref& host, std::vector& native_code) { + using Compile = decltype(&D3DCompile); + const HMODULE compiler = LoadLibraryExW(L"d3dcompiler_47.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (!compiler) return 77; + const auto compile = reinterpret_cast(GetProcAddress(compiler, "D3DCompile")); + if (!compile) return 77; + Ref native, errors; + if (FAILED(compile(native_shader, std::strlen(native_shader), nullptr, nullptr, nullptr, + "main", "cs_5_0", 0, 0, &native.p, &errors.p)) || !native.p) + return 1; + const auto* native_bytes = static_cast(native->GetBufferPointer()); + native_code.assign(native_bytes, native_bytes + native->GetBufferSize()); Ref factory; Ref warp; + + if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p))) || + FAILED(factory->EnumWarpAdapter(IID_PPV_ARGS(&warp.p))) || + FAILED(D3D12CreateDevice(warp.p, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&host.p)))) + return 77; + + return 0; +} + +int main(int argc, char** argv) { + const bool clamp = argc == 2 && !std::strcmp(argv[1], "--clamp"); + // Wine has no WARP (its host is vkd3d on the GPU); the layer is still checked against expected(). + const bool compare_host = !hostwine::host_is_wine(); Ref host; - if (compare_host) { - using Compile = decltype(&D3DCompile); - const HMODULE compiler = LoadLibraryExW(L"d3dcompiler_47.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); - if (!compiler) return 77; - const auto compile = reinterpret_cast(GetProcAddress(compiler, "D3DCompile")); - if (!compile) return 77; - Ref native, errors; - if (FAILED(compile(native_shader, std::strlen(native_shader), nullptr, nullptr, nullptr, - "main", "cs_5_0", 0, 0, &native.p, &errors.p)) || !native.p) { - std::fprintf(stderr, "D3DCompile of the reference shader failed%s%.*s\n", errors.p ? ": " : "", - errors.p ? int(errors->GetBufferSize()) : 0, - errors.p ? static_cast(errors->GetBufferPointer()) : ""); - return 1; - } - const auto* native_bytes = static_cast(native->GetBufferPointer()); - native_code.assign(native_bytes, native_bytes + native->GetBufferSize()); - if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory.p))) || - FAILED(factory->EnumWarpAdapter(IID_PPV_ARGS(&warp.p))) || - FAILED(D3D12CreateDevice(warp.p, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&host.p)))) - return 77; + std::vector native_code; + if (!clamp && compare_host) { + if (const int status = make_host(host, native_code)) return status; } - vktest::Device vk; vk.request_buffer_device_address = true; const auto status = vk.initialize(); @@ -241,6 +247,22 @@ int main() { Ref layer; if (FAILED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&layer.p)))) return 1; + if (clamp) { + for (bool fixed : {false, true}) { + for (UINT count : {0u, 1u, 7u}) { + const auto want = fixed || count >= 3 ? std::array{4, 5} : + count ? std::array{2, 2} : std::array{}; + std::array result{}; + if (!run(layer.p, container, count, false, result, true, fixed, true) || result != want) { + std::fprintf(stderr, "group budget: fixed=%d count=%u got %u/%u expected %u/%u\n", + int(fixed), count, result[0], result[1], want[0], want[1]); + return 1; + } + } + } + std::puts("6 indirect group budget cases passed"); + return vk.validation_errors() ? 1 : 0; + } // The layer is checked against expected(), the D3D12 rule that the count is read when the GPU executes the // command. WARP must match it too, with one measured exception: in-box WARP 10.0.22621.5415 (Windows 11 23H2) // reuses the first count for the second ExecuteIndirect after the GPU copy overwrites it (0 -> 3 gives 0/0, diff --git a/runtime/test/d3d12_indirect_rt_test.cpp b/runtime/test/d3d12_indirect_rt_test.cpp index f7ecfa2f50..3a58e48c0a 100644 --- a/runtime/test/d3d12_indirect_rt_test.cpp +++ b/runtime/test/d3d12_indirect_rt_test.cpp @@ -1,6 +1,6 @@ // Real GPU test for: -// 1) ExecuteIndirect with CountBuffer (ID3D12Device::CreateCommandSignature + -// ID3D12GraphicsCommandList::ExecuteIndirect -> vkCmdDrawIndirectCount, Vulkan 1.2 core). +// 1) D3D12 draw-signature creation and a native Vulkan counted-draw pixel reference. +// The pixel reference tests suballocated argument/count offsets, not D3D12 command replay. // 2) Hardware Ray Tracing / BVH (ID3D12Device5::GetRaytracingAccelerationStructurePrebuildInfo + // ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure BLAS + TLAS + RayQueryKHR // hit vs. miss; clean SKIP on GPUs without VK_KHR_acceleration_structure / VK_KHR_ray_query). @@ -341,7 +341,7 @@ int main() { cl->Close(); // ------------------------------------------------------------------------- - // Part 1: ExecuteIndirect with CountBuffer (vkCmdDrawIndirectCount) + // Part 1: draw-signature creation smoke + native vkCmdDrawIndirectCount reference // ------------------------------------------------------------------------- { D3D12_INDIRECT_ARGUMENT_DESC arg_desc{D3D12_INDIRECT_ARGUMENT_TYPE_DRAW}; @@ -350,7 +350,7 @@ int main() { if (FAILED(dev->CreateCommandSignature(&sig_desc, nullptr, IID_PPV_ARGS(&cmd_sig))) || !cmd_sig) return fail("CreateCommandSignature"); - // Verify COM command-list recording of ExecuteIndirect with CountBuffer. + // The Vulkan reference below uses two independently prefixed upload slices. D3D12_HEAP_PROPERTIES up_hp{D3D12_HEAP_TYPE_UPLOAD}; constexpr VkDeviceSize buffer_size = 256, argument_base = 64, count_base = 128; auto b256 = make_buf_desc(buffer_size); @@ -380,13 +380,12 @@ int main() { counts[1] = 1u; // draw 1 fullscreen triangle count_buf->Unmap(0, nullptr); - alloc->Reset(); - cl->Reset(alloc, nullptr); - cl->ExecuteIndirect(cmd_sig, 2, arg_buf, argument_base, count_buf, count_base + sizeof(std::uint32_t)); - if (FAILED(cl->Close())) return fail("ExecuteIndirect COM record Close"); - #if defined(LEONIDA_TEST_VS_TRI_SPV) && defined(LEONIDA_TEST_FS_SOLID_SPV) - if (chosen12.drawIndirectCount) { + if (chosen12.drawIndirectCount) { // enabled at device creation + constexpr std::uint32_t max_draws = 1; // this oracle tests counts 0 and 1, not multiDrawIndirect + static_assert(sizeof(D3D12_DRAW_ARGUMENTS) == sizeof(VkDrawIndirectCommand)); + if (!vkCmdDrawIndirectCount || chosen.limits.maxDrawIndirectCount < max_draws) + return fail("native counted-draw feature/limit mismatch"); std::vector vs_words, fs_words; if (!read_spv(LEONIDA_TEST_VS_TRI_SPV, vs_words) || !read_spv(LEONIDA_TEST_FS_SOLID_SPV, fs_words)) return fail("read vs_tri/fs_solid spv"); @@ -501,19 +500,11 @@ int main() { cbai.commandBufferCount = 1; vkAllocateCommandBuffers(vk_dev, &cbai, &cb); - leonida::ReplayFunctions rf{}; - rf.draw_indirect_count = vkCmdDrawIndirectCount; - auto run_indirect_count = [&](std::uint64_t count_offset, std::uint8_t exp_r, std::uint8_t exp_g, - std::uint8_t exp_b) -> int { - leonida::CommandList ir; - ir.execute_indirect({leonida::IndirectKind::draw, sizeof(D3D12_DRAW_ARGUMENTS), 2u, - rt::d3d12::resource_id(arg_buf), 0, rt::d3d12::resource_id(count_buf), - count_offset}); - ir.close(); - + auto run_native_count = [&](VkDeviceSize count_offset, std::uint8_t exp_r, std::uint8_t exp_g, + std::uint8_t exp_b) -> int { VkCommandBufferBeginInfo bi{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; bi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - vkBeginCommandBuffer(cb, &bi); + if (vkBeginCommandBuffer(cb, &bi) != VK_SUCCESS) return fail("begin native counted draw"); VkImageMemoryBarrier b_to_rt{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; b_to_rt.srcAccessMask = 0; @@ -544,22 +535,10 @@ int main() { vkCmdSetScissor(cb, 0, 1, &sc); vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, pso); - const auto resolver = [&](leonida::ResourceId id) -> const leonida::ResourceBinding* { - // Treat the two upload buffers as backing stores for slices that start after a prefix. - static leonida::ResourceBinding arg_b{}, cnt_b{}; - arg_b.buffer = rt::d3d12::vulkan_buffer(arg_buf); - arg_b.buffer_offset = argument_base; - arg_b.size = buffer_size - argument_base; - cnt_b.buffer = rt::d3d12::vulkan_buffer(count_buf); - cnt_b.buffer_offset = count_base; - cnt_b.size = buffer_size - count_base; - if (id == rt::d3d12::resource_id(arg_buf)) return &arg_b; - if (id == rt::d3d12::resource_id(count_buf)) return &cnt_b; - return nullptr; - }; - if (leonida::replay(ir, cb, resolver, rf) != leonida::ReplayResult::success) - return fail("leonida::replay(ExecuteIndirect CountBuffer)"); - + // Native reference, not a stateful D3D12 replay. Both bindings start after poison prefixes. + vkCmdDrawIndirectCount(cb, rt::d3d12::vulkan_buffer(arg_buf), argument_base, + rt::d3d12::vulkan_buffer(count_buf), count_base + count_offset, + max_draws, sizeof(VkDrawIndirectCommand)); vkCmdEndRendering(cb); VkImageMemoryBarrier b_to_src{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; @@ -583,26 +562,26 @@ int main() { host_b.dstAccessMask = VK_ACCESS_HOST_READ_BIT; vkCmdPipelineBarrier(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &host_b, 0, nullptr, 0, nullptr); - vkEndCommandBuffer(cb); + if (vkEndCommandBuffer(cb) != VK_SUCCESS) return fail("end native counted draw"); VkSubmitInfo si{VK_STRUCTURE_TYPE_SUBMIT_INFO}; si.commandBufferCount = 1; si.pCommandBuffers = &cb; - vkQueueSubmit(vk_queue, 1, &si, VK_NULL_HANDLE); - vkQueueWaitIdle(vk_queue); + if (vkQueueSubmit(vk_queue, 1, &si, VK_NULL_HANDLE) != VK_SUCCESS || + vkQueueWaitIdle(vk_queue) != VK_SUCCESS) return fail("submit/wait native counted draw"); void* mp = nullptr; - rb->Map(0, nullptr, &mp); + if (FAILED(rb->Map(0, nullptr, &mp)) || !mp) return fail("map native counted-draw readback"); const auto* px = static_cast(mp); const bool ok = std::abs(int(px[0]) - int(exp_r)) <= 1 && std::abs(int(px[1]) - int(exp_g)) <= 1 && std::abs(int(px[2]) - int(exp_b)) <= 1 && px[3] == 255; rb->Unmap(0, nullptr); - if (!ok) return fail("ExecuteIndirect CountBuffer pixel mismatch"); + if (!ok) return fail("native counted-draw pixel mismatch"); return 0; }; - if (run_indirect_count(0, 0, 0, 0) != 0) return 1; // count = 0 -> black - if (run_indirect_count(4, 32, 160, 240) != 0) return 1; // count = 1 -> triangle + if (run_native_count(0, 0, 0, 0) != 0) return 1; // count = 0 -> black + if (run_native_count(4, 32, 160, 240) != 0) return 1; // count = 1 -> triangle vkDestroyCommandPool(vk_dev, pool, nullptr); vkDestroyImageView(vk_dev, rt_view, nullptr); @@ -610,8 +589,10 @@ int main() { vkDestroyPipelineLayout(vk_dev, pl, nullptr); rb->Release(); rt->Release(); - std::printf(" [PASS] ExecuteIndirect with suballocated argument and count buffers " - "(count=0 skipped, count=1 rendered)\n"); + std::printf(" [PASS] native Vulkan counted-draw reference with suballocated argument/count offsets " + "(count=0 black, count=1 solid triangle)\n"); + } else { + std::printf(" [SKIP] native counted-draw reference: drawIndirectCount unsupported\n"); } #endif count_buf->Release(); diff --git a/runtime/test/d3d12_m4_compute_test.cpp b/runtime/test/d3d12_m4_compute_test.cpp index bad8ed98ef..97a4e8600f 100644 --- a/runtime/test/d3d12_m4_compute_test.cpp +++ b/runtime/test/d3d12_m4_compute_test.cpp @@ -11,8 +11,10 @@ // arguments of the next dispatch into the raw buffer. Barriers (a transition of the argument buffer to // INDIRECT_ARGUMENT and UAV barriers on the buffer and the image) and ExecuteIndirect with a dispatch // command signature runs a second PSO whose group count is that buffer's first word: it reads the -// structured buffer and the image back and writes the raw output. Everything then goes to COMMON and -// the queue does Signal(compute fence, 1). +// structured buffer and the image back and writes the raw output. A second ExecuteIndirect runs a +// garbage argument record (billions of groups in every dimension) that the argument clamp pass empties +// on the GPU (runtime/src/vulkan_indirect_clamp.h), so it completes instead of resetting the driver. +// Everything then goes to COMMON and the queue does Signal(compute fence, 1). // COPY queue Wait(compute fence, 1), a COPY list that copies the five results (four buffers and the image through // CopyTextureRegion) to a READBACK buffer, Signal(copy fence, 2). The CPU waits for that with // SetEventOnCompletion and an event. @@ -28,6 +30,7 @@ #include "../shims/d3d12_com.h" #include "../shims/d3d12_xs_device.h" #include "../src/shader_library.h" +#include "../src/vulkan_indirect_clamp.h" #include #include @@ -179,7 +182,7 @@ int main() { constexpr auto uav_flag = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; constexpr auto uav_state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; constexpr auto common = D3D12_RESOURCE_STATE_COMMON; - Ref upload, input, data, args, out2, image, readback; + Ref upload, input, data, args, out2, image, readback, garbage; const auto create_buffer = [&](Ref& out, const D3D12_HEAP_PROPERTIES& heap, UINT64 bytes, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES state) { const auto desc = buffer_desc(bytes, flags); @@ -191,6 +194,9 @@ int main() { EXPECT(create_buffer(data, default_heap, data_bytes, uav_flag, uav_state)); EXPECT(create_buffer(args, default_heap, 256, uav_flag, uav_state)); EXPECT(create_buffer(out2, default_heap, out2_bytes, uav_flag, uav_state)); + // The garbage arguments: what an argument buffer holds when the compute that writes it was skipped. This one + // asks for billions of groups in every dimension, and the clamp pass must run it empty (vulkan_indirect_clamp.h). + EXPECT(create_buffer(garbage, upload_heap, 256, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ)); EXPECT(create_buffer(readback, readback_heap, readback_bytes, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST)); D3D12_RESOURCE_DESC image_desc{}; @@ -209,6 +215,14 @@ int main() { for (UINT g = 0; g < records; ++g) mapped[g] = input_word(g); upload->Unmap(0, nullptr); } + { + D3D12_DISPATCH_ARGUMENTS* mapped = nullptr; + EXPECT(SUCCEEDED(garbage->Map(0, nullptr, reinterpret_cast(&mapped)))); + mapped->ThreadGroupCountX = 0xFFFFFFF0u; + mapped->ThreadGroupCountY = 0xFFFFFFFFu; + mapped->ThreadGroupCountZ = 1u; + garbage->Unmap(0, nullptr); + } // The table: slot 0 structured buffer (stride 16), 1 raw argument buffer, 2 image, 3 raw input, 4 raw output. const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 5, @@ -301,6 +315,12 @@ int main() { compute_list->ResourceBarrier(3, between); compute_list->SetPipelineState(pso_indirect.p); // the root arguments stay compute_list->ExecuteIndirect(signature.p, 1, args.p, 0, nullptr, 0); + // The clamp pass (vulkan_indirect_clamp.h) runs this one empty: its record asks for billions of groups, which + // would otherwise run until the host resets the display driver. out2's expected words below show it wrote + // nothing, which is also what a skipped compute pass leaves for a legitimate record to ask for. With + // LEONIDA_INDIRECT_CLAMP=0 the raw argument buffer is read again, so such a record is not recorded at all. + if (leonida::indirect_clamp_enabled()) + compute_list->ExecuteIndirect(signature.p, 1, garbage.p, 0, nullptr, 0); D3D12_RESOURCE_BARRIER release[5] = {transition(data.p, uav_state, common), transition(args.p, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, common), transition(out2.p, uav_state, common), @@ -361,7 +381,7 @@ int main() { got.assign(static_cast(mapped), static_cast(mapped) + readback_bytes); readback->Unmap(0, nullptr); - for (auto* r : {&upload, &input, &data, &args, &out2, &image, &readback}) r->reset(); + for (auto* r : {&upload, &input, &data, &args, &out2, &image, &readback, &garbage}) r->reset(); stream_list.reset(); compute_list.reset(); readback_list.reset(); stream_alloc.reset(); compute_alloc.reset(); readback_alloc.reset(); copy_fence.reset(); compute_fence.reset(); diff --git a/runtime/test/d3d12_pipeline_stream.h b/runtime/test/d3d12_pipeline_stream.h new file mode 100644 index 0000000000..d20982d1b0 --- /dev/null +++ b/runtime/test/d3d12_pipeline_stream.h @@ -0,0 +1,70 @@ +// Build a pipeline state stream the way d3dx12.h lays one out (CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT: a subobject +// type followed by its description, pointer-aligned), and create the PSO from it. A mesh-shader PSO has no +// D3D12_GRAPHICS_PIPELINE_STATE_DESC form, so the tests that build one use this. +#pragma once + +#include +#include + +#include +#include + +#include "d3d12_test_shaders.h" // Ref + +namespace d3d12test { + +// One stream subobject as d3dx12.h declares it (CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT). +template +struct alignas(void*) Subobject { + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE type = Type; + Inner inner; +}; +using RootSubobject = Subobject; +using VsSubobject = Subobject; +using PsSubobject = Subobject; +using CsSubobject = Subobject; +using AsSubobject = Subobject; +using MsSubobject = Subobject; +using TopologySubobject = Subobject; +using TargetsSubobject = Subobject; +using DepthStencil1Subobject = Subobject; +using DepthStencilSubobject = Subobject; +using RasterizerSubobject = Subobject; +using Rasterizer2Subobject = Subobject; +using MaskSubobject = Subobject; + +// Subobjects appended one after another: each is pointer-aligned and a multiple of the pointer size, so the bytes +// are what a struct of the same members would hold. +struct Stream { + std::vector bytes; + template + Stream& add(const S& subobject) { + static_assert(sizeof(S) % sizeof(void*) == 0); + const std::size_t at = bytes.size(); + bytes.resize(at + sizeof(S)); + std::memcpy(bytes.data() + at, &subobject, sizeof(S)); + return *this; + } + D3D12_PIPELINE_STATE_STREAM_DESC desc(std::size_t trim = 0) { return {bytes.size() - trim, bytes.data()}; } +}; + +// `count` render targets of one format. +inline D3D12_RT_FORMAT_ARRAY rt_formats(UINT count, DXGI_FORMAT format) { + D3D12_RT_FORMAT_ARRAY formats{}; + for (UINT i = 0; i < count && i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) formats.RTFormats[i] = format; + formats.NumRenderTargets = count; + return formats; +} + +inline D3D12_RT_FORMAT_ARRAY one_target() { return rt_formats(1, DXGI_FORMAT_R8G8B8A8_UNORM); } + +inline HRESULT create(ID3D12Device* device, Stream& stream, Ref& out, std::size_t trim = 0) { + Ref device2; + if (FAILED(device->QueryInterface(IID_PPV_ARGS(&device2.p)))) return E_NOINTERFACE; + const D3D12_PIPELINE_STATE_STREAM_DESC desc = stream.desc(trim); + out.reset(); + return device2->CreatePipelineState(&desc, IID_PPV_ARGS(&out.p)); +} + +} // namespace d3d12test diff --git a/runtime/test/d3d12_state_map_test.cpp b/runtime/test/d3d12_state_map_test.cpp index 2fec30ba43..c39c063c42 100644 --- a/runtime/test/d3d12_state_map_test.cpp +++ b/runtime/test/d3d12_state_map_test.cpp @@ -4,8 +4,20 @@ #define VK_NO_PROTOTYPES #endif #include "../src/vulkan_replay.h" +#include "../src/vulkan_index_view.h" +#include #include "../src/vulkan_memory.h" // resizable_bar, memory_type_order +// Argument-buffer bounds only, no Vulkan calls. A 64-byte compound record has padding to an +// 80-byte stride between records, but needs none after the last. A terminal DRAW_INDEXED alone is only 20 bytes. +static_assert(leonida::indirect_records_fit(2048, 1904, 2, 80, 64)); +static_assert(!leonida::indirect_records_fit(2048, 1908, 2, 80, 64)); +static_assert(leonida::indirect_records_fit(2048, 1908, 2, 80, 20)); +static_assert(leonida::indirect_records_fit(0, UINT64_MAX - 3, 0, 80, 64)); +static_assert(!leonida::indirect_records_fit(UINT64_MAX, UINT64_MAX - 3, 1, 80, 64)); +static_assert(leonida::indirect_records_fit(UINT64_MAX, 0, UINT32_MAX, UINT32_MAX - 3, UINT32_MAX - 3)); +static_assert(!leonida::indirect_records_fit(UINT32_MAX, 0, UINT32_MAX, UINT32_MAX - 3, UINT32_MAX - 3)); + #ifdef _WIN32 #include #include @@ -159,7 +171,7 @@ static_assert(leonida::query_result_size(leonida::d3d12_query::pipeline_statisti } \ } while (0) -int main() { +static int state_map_tests() { using namespace leonida; namespace s = d3d12_state; const auto layout = [](std::uint32_t states, bool presentable = false) { @@ -608,7 +620,8 @@ int main() { CHECK(list.execute_indirect({IndirectKind::dispatch, 20, 2, 1, 20, 0, 0})); CHECK(list.close()); CHECK(replay(list, VK_NULL_HANDLE, resolve, vk) == ReplayResult::success); - const std::vector expected{260, 264, 268, 516, 272, 520, 276, 296}; + // Only the two dispatch records emit: legacy graphics IR carries no captured draw state. + const std::vector expected{276, 296}; CHECK(offsets == expected); // Reject invalid spans before invoking Vulkan, including after adding the backing-buffer base. @@ -628,6 +641,184 @@ int main() { CHECK(offsets == expected); } + return 0; +} + +static int indirect_tests(bool bounded_only) { + using namespace leonida; + // Pure CPU recorder: both indirect actions use the current draw's scope, pipeline, + // pushed data and (when indexed) IA binding. The opaque argument buffer is never mapped. + { + static std::string events; + static VkDeviceSize argument_offset, count_offset; + static VkBuffer argument_handle, count_handle, index_handle; + static VkDeviceSize index_offset, index_size; + static VkIndexType index_type; + static std::uint32_t argument_count, argument_stride; + GraphicsPipeline pipeline{}; + pipeline.pipeline = reinterpret_cast(std::uintptr_t{1}); + ResourceBinding args{}; + args.buffer = reinterpret_cast(std::uintptr_t{2}); + args.size = 36; args.buffer_offset = 256; args.indirect_arguments = true; + ResourceBinding counts{}; + counts.buffer = args.buffer; counts.size = 8; counts.buffer_offset = 512; counts.indirect_arguments = true; + ReplayFunctions vk{}; + vk.draw_indirect_first_instance = true; + vk.graphics_pipeline = [&](std::uintptr_t) { return &pipeline; }; + vk.buffer_at = [](std::uint64_t, std::uint64_t&, VkBuffer& buffer, VkDeviceSize& offset) { + buffer = reinterpret_cast(std::uintptr_t{3}); offset = 16; return true; + }; + vk.image_view = [](const ResourceBinding&, const VkImageSubresourceRange&) { return VkImageView{}; }; + const auto ignore = [](auto...) {}; + vk.bind_vertex_buffers2 = ignore; vk.set_viewport = ignore; vk.set_scissor = ignore; + vk.set_primitive_topology = ignore; vk.set_primitive_restart_enable = ignore; + vk.set_stencil_reference = ignore; vk.set_blend_constants = ignore; + vk.begin_rendering = [](auto...) { events += '['; }; + vk.end_rendering = [](auto...) { events += ']'; }; + vk.bind_pipeline = [](auto...) { events += 'P'; }; + vk.push_constants = [](auto...) { events += 'C'; }; + vk.bind_index_buffer = [](auto...) { events += 'L'; }; // direct, legacy bind + const auto bounded = [](VkCommandBuffer, VkBuffer b, VkDeviceSize off, VkDeviceSize size, VkIndexType t) { + index_handle = b; index_offset = off; index_size = size; index_type = t; events += 'I'; + }; + vk.draw = [](auto...) { events += 'D'; }; + vk.draw_indexed = [](auto...) { events += 'X'; }; + vk.draw_indirect = [](VkCommandBuffer, VkBuffer, VkDeviceSize offset, std::uint32_t count, std::uint32_t stride) { + argument_offset = offset; argument_count = count; argument_stride = stride; events += 'd'; + }; + vk.draw_indexed_indirect = [](VkCommandBuffer, VkBuffer, VkDeviceSize offset, std::uint32_t count, std::uint32_t stride) { + argument_offset = offset; argument_count = count; argument_stride = stride; events += 'x'; + }; + vk.draw_indirect_count = [](VkCommandBuffer, VkBuffer arg, VkDeviceSize offset, VkBuffer cnt, VkDeviceSize coff, + std::uint32_t max_count, std::uint32_t stride) { + argument_handle = arg; count_handle = cnt; argument_offset = offset; count_offset = coff; + argument_count = max_count; argument_stride = stride; events += 'n'; + }; + vk.draw_indexed_indirect_count = [](VkCommandBuffer, VkBuffer arg, VkDeviceSize offset, VkBuffer cnt, + VkDeviceSize coff, std::uint32_t max_count, std::uint32_t stride) { + argument_handle = arg; count_handle = cnt; argument_offset = offset; count_offset = coff; + argument_count = max_count; argument_stride = stride; events += 'y'; + }; + Draw d{}; d.pipeline = 1; d.topology = 4; d.viewport = {0,0,8,8,0,1}; d.scissor = {0,0,8,8}; + IndirectDrawArgs arg{9,16,24}; // one record, legal padding must not be read + { + // Copying the rare command shares a stable snapshot and reuses the original views block. + auto views = std::make_shared(); + Draw source = d; source.views = views; + auto mutable_args = arg; + CommandList list; + CHECK(list.draw_indirect(std::move(source), mutable_args) && list.commands().size() == 1); + mutable_args.argument_buffer = 123; + const Command command_copy = list.commands().front(); + const auto captured = draw_command(command_copy); + CHECK(captured.state && captured.arguments && captured.state == draw_command(list.commands().front()).state); + CHECK(captured.state->views == views && captured.arguments->argument_buffer == arg.argument_buffer); + CHECK(!draw_command(Command{Draw{}}).arguments && !draw_command(Command{UavBarrier{}}).state); + } + const auto run = [&] { + CommandList list; + events.clear(); + if (!list.draw_indirect(Draw{d}, arg) || !list.close()) return ReplayResult::invalid_draw; + return replay(list, VK_NULL_HANDLE, [&](ResourceId id) { + return id == 9 ? &args : id == 10 ? &counts : nullptr; + }, vk); + }; + CHECK(run() == ReplayResult::success && events == "[PCd]"); + CHECK(argument_offset == 272 && argument_count == 1 && argument_stride == 24); + d.indexed = true; d.index = {0x1000, 8, 57}; + CHECK(run() == ReplayResult::success && events.empty()); // supported draw, no safe index binding + vk.bind_robust_index_view = bounded; + // Resolver returns the rest of a larger allocation. Only complete elements inside the IBV are bindable. + vk.buffer_at = [](std::uint64_t, std::uint64_t& size, VkBuffer& b, VkDeviceSize& off) { + b = reinterpret_cast(std::uintptr_t{3}); off = 16; size = 64; return true; + }; + const auto ib = reinterpret_cast(std::uintptr_t{3}); + CHECK(run() == ReplayResult::success && events == "[PCIx]" && index_handle == ib && + index_offset == 16 && index_size == 8 && index_type == VK_INDEX_TYPE_UINT16); + d.index = {0x1000, 15, 42}; + CHECK(run() == ReplayResult::success && events == "[PCIx]" && index_size == 12 && + index_type == VK_INDEX_TYPE_UINT32); + vk.draw_indirect_count_enabled = true; vk.max_draw_indirect_count = UINT32_MAX; + arg.count_buffer = 10; arg.count_offset = 4; d.index.size = 20; + CHECK(run() == ReplayResult::success && events == "[PCIy]" && index_size == 20 && + index_offset == 16 && index_type == VK_INDEX_TYPE_UINT32); + // The ordinary direct draw still uses its original unsized binding. + CommandList direct; + Draw direct_state = d; + direct_state.count = 3; direct_state.instances = 1; + CHECK(direct.draw(direct_state) && direct.close()); events.clear(); + CHECK(replay(direct, VK_NULL_HANDLE, [](ResourceId) -> const ResourceBinding* { return nullptr; }, vk) + == ReplayResult::success && events == "[PCLX]"); + CHECK(!can_enable_robust_index_view({}, nullptr, false, true, false)); + CHECK(!can_enable_robust_index_view({}, nullptr, true, false, false)); + CHECK(!can_enable_robust_index_view({}, nullptr, true, true, true)); + CHECK(can_enable_robust_index_view({}, nullptr, true, true, false)); + const auto compatible = [](VkPhysicalDevice, VkPhysicalDeviceProperties2* p) { + static_cast(p->pNext)->robustBufferAccessUpdateAfterBind = VK_TRUE; + }; + CHECK(can_enable_robust_index_view({}, compatible, true, true, true)); + const auto incompatible = [](VkPhysicalDevice, VkPhysicalDeviceProperties2*) {}; // remains VK_FALSE + CHECK(!can_enable_robust_index_view({}, incompatible, true, true, true)); + if (bounded_only) return 0; + d.index = {0x1000, 8, 57}; + vk.draw_indirect_count_enabled = false; vk.max_draw_indirect_count = 1; + arg.count_buffer = 0; arg.count_offset = 0; + CHECK(run() == ReplayResult::success && events == "[PCIx]"); + CHECK(argument_offset == 272 && argument_count == 1 && argument_stride == 24); + d.index.va = 0; CHECK(run() == ReplayResult::success && events.empty()); d.index.va = 0x1000; + // An unresolvable indexed argument buffer never turns into a direct indexed draw. + arg.argument_buffer = 999; + const auto missing = run(); + CHECK((missing == ReplayResult::success || missing == ReplayResult::unresolved_resource) && events.empty()); + arg.argument_buffer = 9; + arg.argument_offset = 20; CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); + arg.argument_offset = 16; args.buffer_offset = UINT64_MAX - 3; + CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); args.buffer_offset = 256; + args.indirect_arguments = false; CHECK(run() == ReplayResult::success && events.empty()); args.indirect_arguments = true; + pipeline.nonunit_vertex_divisor = true; CHECK(run() == ReplayResult::success && events.empty()); + pipeline.nonunit_vertex_divisor = false; vk.draw_indirect_first_instance = false; + CHECK(run() == ReplayResult::success && events.empty()); + vk.draw_indirect_first_instance = true; d.topology = topology_quad_list; + CHECK(run() == ReplayResult::success && events.empty()); + + // Multi-record fixed count, then counted, both forms. Ranges end exactly + // at the final payload and uint32 count, after nonzero backing-buffer bases. + d.topology = 4; d.indexed = false; arg.max_count = 2; + vk.max_draw_indirect_count = 2; vk.multi_draw_indirect = true; + args.size = 56; CHECK(run() == ReplayResult::success && events == "[PCd]"); + CHECK(argument_count == 2 && argument_stride == 24 && argument_offset == 272); + d.indexed = true; CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); + args.size = 60; CHECK(run() == ReplayResult::success && events == "[PCIx]"); + CHECK(argument_count == 2 && argument_stride == 24); + vk.max_draw_indirect_count = 1; CHECK(run() == ReplayResult::success && events.empty()); + vk.max_draw_indirect_count = UINT32_MAX; vk.multi_draw_indirect = false; + CHECK(run() == ReplayResult::success && events.empty()); + // Counted commands have their own drawIndirectCount feature; leave multiDrawIndirect disabled. + arg.count_offset = 4; CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); + arg.count_buffer = 10; CHECK(run() == ReplayResult::success && events.empty()); + vk.draw_indirect_count_enabled = true; d.indexed = false; + CHECK(run() == ReplayResult::success && events == "[PCn]"); + CHECK(argument_offset == 272 && count_offset == 516 && argument_handle == args.buffer && + count_handle == counts.buffer && argument_count == 2 && argument_stride == 24); + d.indexed = true; CHECK(run() == ReplayResult::success && events == "[PCIy]"); + CHECK(argument_offset == 272 && count_offset == 516 && argument_count == 2 && argument_stride == 24); + vk.max_draw_indirect_count = 128; CHECK(run() == ReplayResult::success && events.empty()); // unknown raw count + vk.max_draw_indirect_count = UINT32_MAX; counts.indirect_arguments = false; + CHECK(run() == ReplayResult::success && events.empty()); counts.indirect_arguments = true; + counts.size = 7; CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); counts.size = 8; + counts.buffer_offset = UINT64_MAX - 3; CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); + counts.buffer_offset = 512; arg.count_offset = 1; + CHECK(run() == ReplayResult::invalid_indirect_arguments && events.empty()); + arg.count_offset = 4; vk.draw_indexed_indirect_count = nullptr; + CHECK(run() == ReplayResult::success && events.empty()); + arg.max_count = 0; CHECK(run() == ReplayResult::success && events.empty()); + } + + return 0; +} + +static int memory_tests() { + using namespace leonida; // Resizable BAR detection (D3D-96) on the heap layouts real cards report. { constexpr VkDeviceSize mib = VkDeviceSize(1) << 20; @@ -787,3 +978,9 @@ int main() { "BAR detection and memory types OK\n"); return 0; } + +int main(int argc, char** argv) { + if (argc == 2 && !std::strcmp(argv[1], "--bounded-index-view")) return indirect_tests(true); + if (argc != 1) return 1; + return state_map_tests() || indirect_tests(false) || memory_tests(); +} diff --git a/runtime/test/d3d12_stateful_indirect_pixels.cpp b/runtime/test/d3d12_stateful_indirect_pixels.cpp new file mode 100644 index 0000000000..7672c13a46 --- /dev/null +++ b/runtime/test/d3d12_stateful_indirect_pixels.cpp @@ -0,0 +1,322 @@ +// Positive graphics replay only: the direct and indirect submissions each draw into a fresh offscreen target. +// The quadrant depends on the indexed vertices; red requires firstInstance=1. No title, presentation or display. +#include "d3d12_test_shaders.h" +#include "../shims/d3d12_com.h" + +#include +#include +#include + +using namespace d3d12test; + +#define CHECK(x) \ + do { \ + if (!(x)) { \ + std::fprintf(stderr, "indirect pixels line %d: %s\n", __LINE__, #x); \ + return 1; \ + } \ + } while (0) + +int check_stateful_indirect_pixels(ID3D12Device* device, ID3D12RootSignature* root, + D3D12_GRAPHICS_PIPELINE_STATE_DESC desc, bool multi, bool counted, bool nonindexed_only) { + constexpr UINT side = 64, pitch = side * 4; + using Image = std::array; + constexpr float xy[][2] = { + {0, 0}, {-1, 1}, {0, 1}, {-1, 0}, {-1, 0}, {0, 1}, {0, 0}, // DRAW: left quad, StartVertexLocation=1 + {0, 1}, {1, 1}, {0, 0}, {0, 0}, {1, 1}, {1, 0} // second DRAW: right quad + }; + constexpr std::uint16_t indices[] = {0, 0, 6, 7, 8, 8, 7, 11, 0, 1, 2, 2, 1, 5}; // right, then left (base vertex=1) + constexpr std::uint8_t colors[][4] = {{0, 255, 0, 255}, {255, 0, 0, 255}, {255, 0, 255, 255}}; + constexpr float red_tint[3] = {1, 0, 1}, other_tint[3] = {0, 1, 0}; + // The third record is always valid but beyond maxCount=2. If it executed, magenta would overwrite the first red + // quad. + constexpr D3D12_DRAW_ARGUMENTS draw[] = {{6, 1, 1, 1}, {6, 1, 7, 2}, {6, 1, 1, 2}}; + constexpr D3D12_DRAW_INDEXED_ARGUMENTS indexed_draw[] = {{6, 1, 2, 1, 1}, {6, 1, 8, 1, 2}, {6, 1, 2, 1, 2}}; + constexpr UINT args_at = 1280, indexed_at = 1536, padded_stride = 32; + constexpr UINT count_at[] = {24, 44, 92, 108}; + // Valid decoy at offset zero lives in a separate argument resource. It draws nothing if offset handling is lost. + const std::array layout{ + {{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 0, D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1}}}; + desc.InputLayout = {layout.data(), UINT(layout.size())}; + Ref pso; + CHECK(SUCCEEDED(device->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso.p)))); + + const D3D12_HEAP_PROPERTIES upload_heap{D3D12_HEAP_TYPE_UPLOAD}, read_heap{D3D12_HEAP_TYPE_READBACK}, + def_heap{D3D12_HEAP_TYPE_DEFAULT}; + const auto upload_desc = buffer_desc(2048), rb_desc = buffer_desc(sizeof(Image)); + Ref input, args, counts; + CHECK(SUCCEEDED(device->CreateCommittedResource(&upload_heap, {}, &upload_desc, D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, IID_PPV_ARGS(&input.p)))); + CHECK(SUCCEEDED(device->CreateCommittedResource(&upload_heap, {}, &upload_desc, D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, IID_PPV_ARGS(&args.p)))); + std::uint8_t* data{}; + CHECK(SUCCEEDED(input->Map(0, nullptr, reinterpret_cast(&data)))); + std::memcpy(data, xy, sizeof(xy)); + std::memcpy(data + 256, indices, sizeof(indices)); + std::memcpy(data + 512, red_tint, sizeof(red_tint)); + std::memcpy(data + 768, other_tint, sizeof(other_tint)); + std::memcpy(data + 1024, colors, sizeof(colors)); + input->Unmap(0, nullptr); + const auto va = input->GetGPUVirtualAddress(); + const D3D12_VERTEX_BUFFER_VIEW vbs[] = {{va, sizeof(xy), sizeof(xy[0])}, + {va + 1024, sizeof(colors), sizeof(colors[0])}}; + const D3D12_INDEX_BUFFER_VIEW ib{va + 256, sizeof(indices), DXGI_FORMAT_R16_UINT}; + constexpr UINT compound_stride = 80, compound_size = 64, compound_at = 2048 - compound_stride - compound_size; + CHECK(SUCCEEDED(args->Map(0, nullptr, reinterpret_cast(&data)))); + std::memset(data, 0, 2048); + for (UINT i = 0; i < 3; ++i) { + std::memcpy(data + args_at + padded_stride * i, &draw[i], sizeof(draw[i])); + std::memcpy(data + indexed_at + padded_stride * i, &indexed_draw[i], sizeof(indexed_draw[i])); + } + const D3D12_GPU_VIRTUAL_ADDRESS cb = va + 512; + for (UINT i = 0; i < 2; ++i) { + auto* rec = data + compound_at + i * compound_stride; // first DWORD is the already-zero root constant + std::memcpy(rec + 4, &cb, sizeof(cb)); + std::memcpy(rec + 12, &vbs[0], sizeof(vbs[0])); + std::memcpy(rec + 28, &ib, sizeof(ib)); + std::memcpy(rec + 44, &indexed_draw[i], sizeof(indexed_draw[i])); + } + args->Unmap(0, nullptr); + if (counted) { + const auto count_desc = buffer_desc(128); + CHECK(SUCCEEDED(device->CreateCommittedResource( + &upload_heap, {}, &count_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&counts.p)))); + CHECK(SUCCEEDED(counts->Map(0, nullptr, reinterpret_cast(&data)))); + std::memset(data, 0, 128); + const UINT wrong_offset = 2; + std::memcpy(data, &wrong_offset, sizeof(wrong_offset)); + for (UINT n = 0; n <= 3; ++n) + std::memcpy(data + count_at[n], &n, sizeof(n)); + counts->Unmap(0, nullptr); + } + const D3D12_VIEWPORT viewport{0, 0, float(side), float(side), 0, 1}; + const D3D12_RECT clip{8, 4, 56, 40}, later_clip{0, 0, 1, 1}; + const float blue[]{0, 0, 1, 1}, offset[]{0, -0.5f}, later_offset[]{0, 2}; + D3D12_RESOURCE_DESC tex{}; + tex.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + tex.Width = tex.Height = side; + tex.DepthOrArraySize = tex.MipLevels = 1; + tex.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + tex.SampleDesc.Count = 1; + tex.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1}; + const D3D12_COMMAND_QUEUE_DESC queue_desc{}; + Ref queue; + CHECK(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p)))); + // Identical padded byte stride and terminal kind do not make a compound signature a simple draw. + // Create and inspect both signatures; the compound is deliberately never recorded or executed. + { + D3D12_INDIRECT_ARGUMENT_DESC members[2]{}; + members[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW; + members[0].VertexBuffer.Slot = 0; + members[1].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + for (const bool compound : {false, true}) { + const D3D12_COMMAND_SIGNATURE_DESC sd{48, compound ? 2u : 1u, compound ? members : members + 1, 0}; + Ref sig; + CHECK(SUCCEEDED(device->CreateCommandSignature(&sd, nullptr, IID_PPV_ARGS(&sig.p)))); + auto kind = leonida::IndirectKind::dispatch; + UINT stride = 0; + bool terminal_only = compound; + CHECK(rt::d3d12::command_signature_info(sig.p, kind, stride, terminal_only)); + CHECK(kind == leonida::IndirectKind::draw && stride == 48 && terminal_only == !compound); + } + } + // Record-only: an unsupported compound draw still resets its written bindings. Nothing from + // this list is submitted. The ordinary draws either side expose the two immutable state snapshots. + for (UINT scenario = 0; !multi && !counted && scenario < 3; ++scenario) { + Ref allocator; + Ref list; + CHECK(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); + CHECK(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, pso.p, + IID_PPV_ARGS(&list.p)))); + Ref compound; + { + D3D12_INDIRECT_ARGUMENT_DESC members[5]{}; + members[0].Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT; + members[0].Constant = {0, 1, 1}; + members[1].Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW; + members[1].ConstantBufferView.RootParameterIndex = 1; + members[2].Type = D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW; + members[2].VertexBuffer.Slot = 5; + members[3].Type = D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW; + members[4].Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED; + const D3D12_COMMAND_SIGNATURE_DESC sd{compound_stride, 5, members, 0}; + CHECK(SUCCEEDED(device->CreateCommandSignature(&sd, root, IID_PPV_ARGS(&compound.p)))); + } + const UINT words[] = {37, 73}; + list->SetGraphicsRootSignature(root); + list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + list->IASetVertexBuffers(0, 2, vbs); + list->IASetVertexBuffers(5, 1, vbs); + list->IASetIndexBuffer(&ib); + list->RSSetViewports(1, &viewport); + list->SetGraphicsRoot32BitConstants(0, 2, words, 0); + list->SetGraphicsRootConstantBufferView(1, va + 512); + list->DrawInstanced(3, 1, 0, 0); + // The two packed records fit exactly, without trailing padding. Fixed zero and GPU count zero + // have the same postcondition. The count DWORD at offset zero is separate from the records. + list->ExecuteIndirect(compound.p, scenario == 1 ? 0 : 2, args.p, compound_at, + scenario == 2 ? args.p : nullptr, 0); + list->DrawInstanced(3, 1, 0, 0); + CHECK(list->Close() == S_OK); + std::vector recorded; + CHECK(rt::d3d12::recorded_commands(list.p, recorded) && recorded.size() == 2); + const auto* before = std::get_if(&recorded[0]); + const auto* after = std::get_if(&recorded[1]); + CHECK(before && after && before->views && after->views && before->views != after->views); + CHECK(before->views->vertex_buffers[5].va == va && after->views->vertex_buffers[5].va == 0); + CHECK(after->views->vertex_buffers[0].va == va && after->views->vertex_buffers[1].va == va + 1024); + CHECK(before->index.va == ib.BufferLocation && after->index.va == 0 && after->index.size == 0); + // These are packed shader words, not D3D root-parameter indices. The graphics packer can reserve a prefix. + const auto* packed = rt::d3d12::root_signature_layout(root); + CHECK(packed && packed->parameters.size() == 2); + const auto c0 = packed->parameters[0].user_offset, view = packed->parameters[1].user_offset; + CHECK(c0 < before->user_data.size() - 1 && view < before->user_data.size() - 1); + CHECK(before->user_data[c0] == 37 && before->user_data[c0 + 1] == 73); + CHECK(before->user_data[view] || before->user_data[view + 1]); + auto expected_words = before->user_data; + expected_words[c0 + 1] = expected_words[view] = expected_words[view + 1] = 0; + CHECK(after->user_data == expected_words); + if (scenario == 0) { + // Recording check only, never submitted: omit the last DWORD of the compound record. + CHECK(SUCCEEDED(list->Reset(allocator.p, pso.p))); + list->SetGraphicsRootSignature(root); + list->ExecuteIndirect(compound.p, 2, args.p, compound_at + 4, nullptr, 0); + CHECK(list->Close() == E_INVALIDARG); + } + } + for (const bool indexed : {false, true}) { + D3D12_INDIRECT_ARGUMENT_DESC argument{}; + if (nonindexed_only && indexed) continue; + argument.Type = indexed ? D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED : D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + const UINT stride = multi ? padded_stride : indexed ? UINT(sizeof(indexed_draw[0])) : UINT(sizeof(draw[0])); + const D3D12_COMMAND_SIGNATURE_DESC sd{stride, 1, &argument, 0}; + Ref sig; + CHECK(SUCCEEDED(device->CreateCommandSignature(&sd, nullptr, IID_PPV_ARGS(&sig.p)))); + // Uncounted covers maxCount=1 or 2; counted clamps each execution to the GPU count at its own byte offset. + const UINT max_records = multi ? 2u : 1u; + for (UINT raw_count = counted ? 0u : max_records; raw_count <= (counted ? 3u : max_records); ++raw_count) { + const UINT records = raw_count < max_records ? raw_count : max_records; + Image reference{}; + for (const bool indirect : {false, true}) { + Ref target, readback, copied_args, copied_counts; + Ref heap; + Ref allocator; + Ref list; + Ref fence; + CHECK(SUCCEEDED(device->CreateCommittedResource(&def_heap, {}, &tex, D3D12_RESOURCE_STATE_COMMON, + nullptr, IID_PPV_ARGS(&target.p)))); + CHECK(SUCCEEDED(device->CreateCommittedResource( + &read_heap, {}, &rb_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&readback.p)))); + CHECK(SUCCEEDED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap.p)))); + using XboxHeapHandleFn = std::uint64_t(WINAPI*)(void*); + const D3D12_CPU_DESCRIPTOR_HANDLE rtv{ + SIZE_T(reinterpret_cast(slot(heap.p, 9))(heap.p))}; + device->CreateRenderTargetView(target.p, nullptr, rtv); + CHECK(SUCCEEDED( + device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); + CHECK(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, pso.p, + IID_PPV_ARGS(&list.p)))); + CHECK(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p)))); + if (indirect && counted) { + // ExecuteIndirect sees only fresh, never-CPU-mapped DEFAULT resources. Their argument and count + // bytes become available when these copies execute, *after* CPU command recording. + const auto count_desc = counts->GetDesc(); + CHECK(SUCCEEDED(device->CreateCommittedResource(&def_heap, {}, &upload_desc, + D3D12_RESOURCE_STATE_COPY_DEST, nullptr, + IID_PPV_ARGS(&copied_args.p)))); + CHECK(SUCCEEDED(device->CreateCommittedResource(&def_heap, {}, &count_desc, + D3D12_RESOURCE_STATE_COPY_DEST, nullptr, + IID_PPV_ARGS(&copied_counts.p)))); + list->CopyBufferRegion(copied_args.p, 0, args.p, 0, upload_desc.Width); + list->CopyBufferRegion(copied_counts.p, 0, counts.p, 0, count_desc.Width); + const D3D12_RESOURCE_BARRIER ready[] = {transition(copied_args.p, D3D12_RESOURCE_STATE_COPY_DEST, + D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT), + transition(copied_counts.p, D3D12_RESOURCE_STATE_COPY_DEST, + D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT)}; + list->ResourceBarrier(2, ready); + } + auto b = transition(target.p, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_RENDER_TARGET); + list->ResourceBarrier(1, &b); + list->ClearRenderTargetView(rtv, blue, 0, nullptr); + list->SetGraphicsRootSignature(root); + list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + list->IASetVertexBuffers(0, 2, vbs); + if (indexed) list->IASetIndexBuffer(&ib); + list->RSSetViewports(1, &viewport); + list->RSSetScissorRects(1, &clip); + list->OMSetRenderTargets(1, &rtv, FALSE, nullptr); + list->SetGraphicsRoot32BitConstants(0, 2, offset, 0); + list->SetGraphicsRootConstantBufferView(1, va + 512); + if (indirect) { + list->ExecuteIndirect(sig.p, max_records, counted ? copied_args.p : args.p, + indexed ? indexed_at : args_at, counted ? copied_counts.p : nullptr, + counted ? count_at[raw_count] : 0); + } else { + for (UINT i = 0; i < records; ++i) { + if (indexed) { + const auto& cmd = indexed_draw[i]; + list->DrawIndexedInstanced(cmd.IndexCountPerInstance, cmd.InstanceCount, + cmd.StartIndexLocation, cmd.BaseVertexLocation, + cmd.StartInstanceLocation); + } else { + const auto& cmd = draw[i]; + list->DrawInstanced(cmd.VertexCountPerInstance, cmd.InstanceCount, cmd.StartVertexLocation, + cmd.StartInstanceLocation); + } + } + } + // Legal state changes, not another draw. Taking a late reference to list state instead of a snapshot + // would miss the nonempty region or change its tint. + list->RSSetScissorRects(1, &later_clip); + list->SetGraphicsRoot32BitConstants(0, 2, later_offset, 0); + list->SetGraphicsRootConstantBufferView(1, va + 768); + + b = transition(target.p, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + list->ResourceBarrier(1, &b); + D3D12_TEXTURE_COPY_LOCATION dst{}, src{}; + dst.pResource = readback.p; + dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + dst.PlacedFootprint = {0, {tex.Format, side, side, 1, pitch}}; + src.pResource = target.p; + src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + list->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr); + CHECK(list->Close() == S_OK); + ID3D12CommandList* lists[]{list.p}; + queue->ExecuteCommandLists(1, lists); + CHECK(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); + CHECK(SUCCEEDED(queue->Signal(fence.p, 1))); + CHECK(SUCCEEDED(fence->SetEventOnCompletion(1, nullptr))); + void* mapped{}; + CHECK(SUCCEEDED(readback->Map(0, nullptr, &mapped))); + Image image{}; + std::memcpy(image.data(), mapped, image.size()); + readback->Unmap(0, nullptr); + unsigned wrong = 0, red = 0, magenta = 0; + for (UINT y = 0; y < side; ++y) { + for (UINT x = 0; x < side; ++x) { + const bool left = y >= 16 && y < 40 && x >= 8 && x < 32; + const bool right = y >= 16 && y < 40 && x >= 32 && x < 56; + const bool first = records >= 1 && (indexed ? right : left); + const bool second = records == 2 && (indexed ? left : right); + const std::array expected{std::uint8_t(first || second ? 255 : 0), 0, + std::uint8_t(first ? 0 : 255), 255}; + const bool equal = !std::memcmp(expected.data(), image.data() + y * pitch + 4 * x, 4); + wrong += !equal; + red += equal && first; + magenta += equal && second; + } + } + const bool same = !indirect || image == reference; + std::printf("%s %s %s (input=%u, max=%u): %u red / %u magenta, %u/4096 RGBA mismatches%s\n", + indexed ? "DRAW_INDEXED" : "DRAW", indirect ? "indirect" : "direct", + counted ? "count-buffer" : "uncounted", raw_count, max_records, red, magenta, wrong, + indirect ? (same ? ", direct image identical" : ", direct image differs") : ""); + CHECK(!wrong && same); + if (!indirect) reference = image; + } + } + } + return 0; +} diff --git a/runtime/test/d3d12_subgroup_test.cpp b/runtime/test/d3d12_subgroup_test.cpp index 2da834f2a2..7bd99d436d 100644 --- a/runtime/test/d3d12_subgroup_test.cpp +++ b/runtime/test/d3d12_subgroup_test.cpp @@ -534,11 +534,9 @@ const Pixel readlane_expected = {0x40000079u, 0x40000010u, 0x40000064u, 0x400000 int main() { // The PSO's subgroup requests are recorded when its Vulkan pipeline is made, and the layer builds compute // pipelines lazily by default: at the first dispatch (or on the warm-up thread), not at - // CreateComputePipelineState. `run` reads them straight after creation, so build at creation on this thread; and - // keep the warm-up thread off so a pipeline it is still compiling cannot outlive the device the test releases - // (it crashed the process after a failed check). + // CreateComputePipelineState. `run` reads them straight after creation, so build at creation on this thread. + // (A device released with warm-up builds queued no longer outlives its release: d3d12_compile_teardown_test.) _putenv_s("LEONIDA_LAZY_COMPUTE", "0"); - _putenv_s("LEONIDA_COMPUTE_WARMUP", "0"); vktest::Device d; const auto device_status = d.initialize(); if (device_status == vktest::DeviceStatus::unavailable) return 77; // no Vulkan GPU: ctest skips diff --git a/runtime/test/d3d12_title_va_test.cpp b/runtime/test/d3d12_title_va_test.cpp index 2aac6c680f..622e8252ec 100644 --- a/runtime/test/d3d12_title_va_test.cpp +++ b/runtime/test/d3d12_title_va_test.cpp @@ -433,6 +433,14 @@ static std::uintptr_t source_tile, peer_tile; void aliases_of_test_tile(std::uintptr_t va, std::vector& peers) { if (va == source_tile) peers.push_back(peer_tile); } +// These fixtures register their own pairs without XMem. Retire each before Wine can reuse either VA. +void remove_test_pair(std::uintptr_t gpu, std::uintptr_t cpu) { + auto& state = leonida::title_gpu_views::state(); + std::unique_lock lock(state.mutex); + std::erase_if(state.views, [&](const auto& pair) { return pair.gpu == gpu && pair.cpu == cpu; }); + state.count.store(state.views.size(), std::memory_order_release); +} + int check_title_memory(Context& c, int& checks, bool geometry) { constexpr UINT64 ring_bytes = 256 * 1024; auto* ring = static_cast(VirtualAlloc(nullptr, ring_bytes, MEM_TOP_DOWN | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); @@ -447,12 +455,12 @@ int check_title_memory(Context& c, int& checks, bool geometry) { const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}, readback_heap{D3D12_HEAP_TYPE_READBACK}; const auto uav = buffer_desc(kBytes, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); - Ref out[3], readback; + Ref out[4], readback; for (auto& o : out) EXPECT(SUCCEEDED(c.device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &uav, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(&o.p)))); - const auto readback_desc = buffer_desc(3 * kBytes); + const auto readback_desc = buffer_desc(4 * kBytes); EXPECT(SUCCEEDED(c.device->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &readback_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&readback.p)))); @@ -462,7 +470,8 @@ int check_title_memory(Context& c, int& checks, bool geometry) { D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; UINT64 address{}, size{}; } h; - if (geometry) { + const bool console = geometry || std::getenv("LEONIDA_TEST_CONSOLE_SHADOW"); + if (console) { h.size = 65536; h.desc.NumDescriptors = UINT(h.size / 32); h.address = reinterpret_cast(VirtualAlloc(nullptr, h.size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); @@ -473,7 +482,7 @@ int check_title_memory(Context& c, int& checks, bool geometry) { const std::uint64_t cpu = reinterpret_cast(slot(heap.p, 9))(heap.p); const std::uint64_t gpu = reinterpret_cast(slot(heap.p, 10))(heap.p); const UINT inc = c.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - EXPECT(!geometry || cpu == h.address); + EXPECT(!console || cpu == h.address); const auto raw_vsharp = [](std::uint64_t address) { leonida::gfx10::Buffer b{}; b.address = address; @@ -482,6 +491,17 @@ int check_title_memory(Context& c, int& checks, bool geometry) { b.oob_select = leonida::gfx10::OobSelect::raw; return leonida::gfx10::encode(b); }; + if (!console) { + // Unknown high address and a view extending past a real buffer. + const auto missing = raw_vsharp((1ull << 46) + 4096); + const auto partial = raw_vsharp(out[0]->GetGPUVirtualAddress() + kBytes - 4); + auto* words = reinterpret_cast(cpu + 6 * inc); + std::memcpy(words, missing.data(), sizeof(missing)); + std::memcpy(words + 4, partial.data(), sizeof(partial)); + aliases.scan_table(gpu + 6 * inc, 1); + EXPECT(words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == missing[3]); + EXPECT(words[4] == 0 && words[5] == 0 && words[6] == 0 && words[7] == partial[3]); + } // Slot 0: a V# the CPU writes itself, its base in the ring. Slot 1: CreateConstantBufferView of the ring. // Slot 2: a raw 64-bit VA (out[2]) for the root-view mode. Slots 3 and 4: the negative controls. std::uint64_t guest = ring_va; @@ -531,7 +551,8 @@ int check_title_memory(Context& c, int& checks, bool geometry) { std::uint8_t before3[32], before4[32]; std::memcpy(before3, reinterpret_cast(cpu + 3 * inc), 32); std::memcpy(before4, reinterpret_cast(cpu + 4 * inc), 32); - + const auto missing = raw_vsharp((1ull << 46) + 4096); + std::memcpy(reinterpret_cast(cpu + 5 * inc), missing.data(), sizeof(missing)); // The ring's data, written before the submission (after the descriptors, as a title fills its ring per frame). for (UINT i = 0; i < ring_bytes / 4; ++i) ring[i] = 0xC0000000u + i * 7u; if (geometry) { @@ -565,13 +586,17 @@ int check_title_memory(Context& c, int& checks, bool geometry) { list->SetComputeRootUnorderedAccessView(1, ring_va + 0x3000); list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 2 * inc}); list->Dispatch(1, 1, 1); + list->SetComputeRoot32BitConstant(0, 0xFFFFFFFBu, 1); + list->SetComputeRootUnorderedAccessView(1, out[3]->GetGPUVirtualAddress()); + list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 5 * inc}); + list->Dispatch(1, 1, 1); // The negative-control slots are bound too, so the scan reads them. list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 3 * inc}); list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 4 * inc}); D3D12_RESOURCE_BARRIER barrier{}; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; list->ResourceBarrier(1, &barrier); - for (UINT k = 0; k < 3; ++k) { + for (UINT k = 0; k < 4; ++k) { D3D12_RESOURCE_BARRIER to_copy{}; to_copy.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; to_copy.Transition.pResource = out[k].p; @@ -597,9 +622,12 @@ int check_title_memory(Context& c, int& checks, bool geometry) { if (got[kElements + i] == ring[0x2000 / 4 + (geometry ? i % 4 : i)]) ++cbv_ok; if (got[2 * kElements + i] == ring[0x3000 / 4 + 64 + i] + kRootAdd) ++root_ok; } + const auto* descriptor = got + 3 * kElements; + EXPECT(!descriptor[0] && !descriptor[1] && !descriptor[2] && descriptor[3] == missing[3]); + if (console) EXPECT(!std::memcmp(reinterpret_cast(cpu + 5 * inc), missing.data(), sizeof(missing))); readback->Unmap(0, nullptr); - const bool rewritten = geometry - ? vsharp_base(cpu + 9 * inc) == guest + data_offset // shader followed the copy; original bytes intact + const bool rewritten = console + ? vsharp_base(cpu + (geometry ? 9 * inc : 0)) == guest + data_offset // shader followed the copy; original bytes intact : vsharp_base(cpu) != ring_va + data_offset && vsharp_base(cpu) == aliases.shader_va(ring_va + data_offset); const bool arena_kept = !std::memcmp(before3, reinterpret_cast(cpu + 3 * inc), 32); const bool image_kept = !std::memcmp(before4, reinterpret_cast(cpu + 4 * inc), 32); @@ -614,8 +642,7 @@ int check_title_memory(Context& c, int& checks, bool geometry) { static_cast(aliases.translated(leonida::TitleVaAliases::root_view) - root_before)); EXPECT(raw_ok == kElements && cbv_ok == kElements && root_ok == kElements); EXPECT(rewritten && arena_kept && image_kept); - // Left alone and counted: committed memory that is not the title's (the runtime's own, say), and a title range - // with no committed page. + // Neither unrelated host memory nor a reserved-only title page has a GPU copy. const std::uint64_t untranslated_before = aliases.untranslated(leonida::TitleVaAliases::created_view); void* host = VirtualAlloc(nullptr, 65536, MEM_TOP_DOWN | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); void* gone = VirtualAlloc(nullptr, 65536, MEM_TOP_DOWN | MEM_RESERVE, PAGE_READWRITE); @@ -624,19 +651,22 @@ int check_title_memory(Context& c, int& checks, bool geometry) { const D3D12_CONSTANT_BUFFER_VIEW_DESC not_title{host_va, 256}, reserved_only{gone_va, 256}; c.device->CreateConstantBufferView(¬_title, D3D12_CPU_DESCRIPTOR_HANDLE{cpu + 5 * inc}); c.device->CreateConstantBufferView(&reserved_only, D3D12_CPU_DESCRIPTOR_HANDLE{cpu + 6 * inc}); - EXPECT(vsharp_base(cpu + 5 * inc) == (host_va & 0xFFFFFFFFFFFFull)); - EXPECT(vsharp_base(cpu + 6 * inc) == (gone_va & 0xFFFFFFFFFFFFull)); - EXPECT(aliases.untranslated(leonida::TitleVaAliases::created_view) - untranslated_before == 2); + EXPECT(vsharp_base(cpu + 5 * inc) == 0); + // A title range with no committed page gets no copy: the view is written with no base and no records (loads + // return 0, stores are dropped), never with the raw title address a shader would add heap_base to. + EXPECT(vsharp_base(cpu + 6 * inc) == 0); + EXPECT(aliases.untranslated(leonida::TitleVaAliases::created_view) == untranslated_before); + if (console) heap.reset(); if (geometry) { - heap.reset(); leonida::geometry_writes::aliases.store(nullptr); + remove_test_pair(guest, source_tile); UnmapViewOfFile(peer); UnmapViewOfFile(primary); CloseHandle(section); - VirtualFree(reinterpret_cast(h.address), 0, MEM_RELEASE); aliases.remove_title_memory(guest); VirtualFree(reinterpret_cast(guest), 0, MEM_RELEASE); } + if (console) VirtualFree(reinterpret_cast(h.address), 0, MEM_RELEASE); aliases.remove_title_memory(gone_va); aliases.remove_title_memory(ring_va); VirtualFree(host, 0, MEM_RELEASE); @@ -645,6 +675,62 @@ int check_title_memory(Context& c, int& checks, bool geometry) { return 0; } +// For a stream pool, the title reserves its CPU view and a GPU-only alias of the +// same size; both name the same frames. One mapping serves the pool's readable run, and a view naming either address +// resolves to it, so streamed vertex buffers stop asking for a 128 KiB title window each and no address is left raw. +int check_stream_pool(Context& c, int& checks) { + constexpr UINT64 pool_bytes = 256 * 1024; + void* cpu_pages = VirtualAlloc(nullptr, pool_bytes, MEM_TOP_DOWN | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + void* gpu_alias = VirtualAlloc(nullptr, pool_bytes, MEM_TOP_DOWN | MEM_RESERVE, PAGE_NOACCESS); + EXPECT(cpu_pages && gpu_alias); + const auto cpu_va = reinterpret_cast(cpu_pages); + const auto gpu_va = reinterpret_cast(gpu_alias); + EXPECT(cpu_va >= c.arena && gpu_va >= c.arena); + // The reservations the xmem shims record, CPU view first (title_gpu_views pairs a GPU-only one with the + // CPU-mappable one of the same size made just before it). + EXPECT(!leonida::title_gpu_views::note_reservation(cpu_va, pool_bytes, false)); // the CPU twin + EXPECT(leonida::title_gpu_views::note_reservation(gpu_va, pool_bytes, true)); // pairs with it + auto& aliases = leonida::title_va_aliases(); + aliases.add_title_memory(cpu_va, pool_bytes); + aliases.add_title_memory(gpu_va, pool_bytes); + EXPECT(leonida::title_gpu_views::to_host_view(gpu_va + 0x2000, 0x100) == cpu_va + 0x2000); + + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; + Ref heap; + EXPECT(SUCCEEDED(c.device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap.p)))); + const std::uint64_t handle = reinterpret_cast(slot(heap.p, 9))(heap.p); + const UINT inc = c.device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + const std::size_t ranges_before = aliases.size(); + // A view naming the GPU-only alias, then one naming the CPU view of the same bytes. + const D3D12_CONSTANT_BUFFER_VIEW_DESC alias_view{gpu_va + 0x2000, 256}; + const D3D12_CONSTANT_BUFFER_VIEW_DESC cpu_view{cpu_va + 0x2000, 256}; + c.device->CreateConstantBufferView(&alias_view, D3D12_CPU_DESCRIPTOR_HANDLE{handle}); + c.device->CreateConstantBufferView(&cpu_view, D3D12_CPU_DESCRIPTOR_HANDLE{handle + inc}); + const std::uint64_t alias_base = vsharp_base(handle); + const std::uint64_t twin_base = vsharp_base(handle + inc); + // One mapping, entered for both addresses: the same backing, and no raw address. + EXPECT(alias_base != 0 && alias_base != ((gpu_va + 0x2000) & 0xFFFFFFFFFFFFull)); + EXPECT(alias_base == twin_base); + EXPECT(alias_base == (aliases.shader_va(gpu_va + 0x2000) & 0xFFFFFFFFFFFFull)); + EXPECT(aliases.shader_va(gpu_va + 0x2000) == aliases.shader_va(cpu_va + 0x2000)); + // Two ranges (the two views' addresses), each a page-aligned run of the pool: one mapping, not one per view. + EXPECT(aliases.size() == ranges_before + 2); + std::printf("stream pool: GPU-only alias 0x%llx and CPU view 0x%llx share one %llu KiB mapping (V# base " + "0x%llx); a second view naming the twin made no mapping\n", + static_cast(gpu_va), static_cast(cpu_va), + static_cast(pool_bytes >> 10), static_cast(alias_base)); + + heap.reset(); + aliases.remove_title_memory(gpu_va); + aliases.remove_title_memory(cpu_va); + remove_test_pair(gpu_va, cpu_va); + VirtualFree(gpu_alias, 0, MEM_RELEASE); + VirtualFree(cpu_pages, 0, MEM_RELEASE); + checks += 3; + return 0; +} + // Four 4 MiB slabs fill the 16 MiB fixture budget. A final 1 MiB view still fits // immediately after the 3 MiB view in the second slab. int check_geometry_slab_tails(Context& c) { @@ -922,6 +1008,7 @@ int main(int argc, char** argv) { if (check_kind(c, "read-write", PAGE_READWRITE, checks)) return 1; if (check_kind(c, "write-combined", PAGE_READWRITE | PAGE_WRITECOMBINE, checks)) return 1; if (check_title_memory(c, checks, geometry)) return 1; + if (check_stream_pool(c, checks)) return 1; if (geometry && std::atoi(setting) == 16 && check_geometry_slab_tails(c)) return 1; } if (d.validation_errors()) { diff --git a/runtime/test/d3d12_unmapped_vsharp_test.cpp b/runtime/test/d3d12_unmapped_vsharp_test.cpp new file mode 100644 index 0000000000..83fe2c0901 --- /dev/null +++ b/runtime/test/d3d12_unmapped_vsharp_test.cpp @@ -0,0 +1,368 @@ +// Buffer descriptors that name memory nothing backs become zero-size (docs/d3d12_vulkan.md section 3.3, "Title-chosen +// addresses"): a shader adds heap_base to a V#'s base, and heap_base + an address no allocation holds is a GPU MMU +// fault. Each path the layer sees a buffer address on writes such an address as a V# with no base and no records +// (loads return 0, stores are dropped) instead of passing it through: +// - created views: CreateConstantBufferView and a slot-70 placed buffer view of an unmapped address; +// - inline V#s: a V# the CPU writes into a bound table of a shader-visible heap itself, rewritten before the +// submission; +// - a console descriptor heap (Xbox slot 14) the title writes itself: its GPU copy's slot is null, the title's +// bytes are left as written; +// - and the null slots after a resource heap's GPU copy: an index past the heap reads a null descriptor, not the +// arena's next bytes. +// A data slot (neither a V# nor a T#) of a console heap is null in its GPU copy too. +// Positive controls: an arena buffer's V#, an upload buffer's V# (outside the arena, a registered buffer) and an +// image-shaped slot keep their bytes. Nothing here dispatches through a descriptor, so a regression shows as a +// failed check, never as a GPU fault. No game data. +#include "vk_test_device.h" +#include "../shims/d3d12_com.h" +#include "../src/gfx10_descriptors.h" +#include "../src/title_va_alias.h" + +#include +#include +#include +#include + +#define EXPECT(condition) do { \ + if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \ +} while (0) + +namespace { + +using SerializeFn = HRESULT(WINAPI*)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC*, ID3DBlob**, ID3DBlob**); + +template +struct Ref { + T* p = nullptr; + ~Ref() { reset(); } + void reset() { + if (p) p->Release(); + p = nullptr; + } + T* operator->() const { return p; } +}; + +constexpr UINT kDescriptor = 32; +constexpr UINT kViewBytes = 256; + +D3D12_RESOURCE_DESC buffer_desc(UINT64 bytes) { + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Width = bytes; + desc.Height = 1; + desc.DepthOrArraySize = 1; + desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + return desc; +} + +leonida::gfx10::BufferWords raw_vsharp(std::uint64_t address) { + leonida::gfx10::Buffer b{}; + b.address = address; + b.num_records = kViewBytes; + b.format = leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT); + b.oob_select = leonida::gfx10::OobSelect::raw; + return leonida::gfx10::encode(b); +} + +std::uint64_t base_of(const std::uint32_t* w) { return std::uint64_t(w[0]) | (std::uint64_t(w[1] & 0xFFFFu) << 32); } +bool zero_size(const std::uint32_t* w) { return base_of(w) == 0 && w[2] == 0; } + +// An address no allocation holds and that is not the title's memory: reserved, then released. Top-down, so it lies +// far past the arena (which is below 4 GiB). +std::uint64_t unmapped_address() { + void* p = VirtualAlloc(nullptr, 1 << 20, MEM_TOP_DOWN | MEM_RESERVE, PAGE_NOACCESS); + if (!p) return 0; + VirtualFree(p, 0, MEM_RELEASE); + return reinterpret_cast(p) + 0x1000; +} + +std::vector serialize(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC& desc) { + const HMODULE d3d12 = LoadLibraryExA("d3d12.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + const auto fn = d3d12 ? reinterpret_cast( + reinterpret_cast(GetProcAddress(d3d12, "D3D12SerializeVersionedRootSignature"))) + : nullptr; + std::vector out; + ID3DBlob* blob = nullptr; + if (fn && SUCCEEDED(fn(&desc, &blob, nullptr)) && blob) { + const auto* p = static_cast(blob->GetBufferPointer()); + out.assign(p, p + blob->GetBufferSize()); + blob->Release(); + } + return out; +} + +struct Buffers { + Ref arena, upload; + std::uint64_t arena_va = 0, upload_va = 0; +}; + +int make_buffers(ID3D12Device* device, std::uint64_t arena_size, Buffers& b) { + const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}, upload_heap{D3D12_HEAP_TYPE_UPLOAD}; + const auto desc = buffer_desc(64 * 1024); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &desc, + D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&b.arena.p)))); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE, &desc, + D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, + IID_PPV_ARGS(&b.upload.p)))); + b.arena_va = b.arena->GetGPUVirtualAddress(); + b.upload_va = b.upload->GetGPUVirtualAddress(); + EXPECT(b.arena_va && b.arena_va < arena_size); + EXPECT(b.upload_va); + return 0; +} + +// Created views: a CBV and a slot-70 buffer SRV of an unmapped address get no base and no records; a CBV of an +// arena buffer and of an upload buffer keep their addresses. +int check_created_views(ID3D12Device* device, const Buffers& b, std::uint64_t unmapped) { + alignas(32) std::uint32_t slots[4][8] = {}; + const auto handle = [&](int i) { return D3D12_CPU_DESCRIPTOR_HANDLE{reinterpret_cast(slots[i])}; }; + const D3D12_CONSTANT_BUFFER_VIEW_DESC nowhere{unmapped, kViewBytes}, arena{b.arena_va, kViewBytes}, + upload{b.upload_va, kViewBytes}; + device->CreateConstantBufferView(&nowhere, handle(0)); + device->CreateConstantBufferView(&arena, handle(1)); + device->CreateConstantBufferView(&upload, handle(2)); + D3D12_SHADER_RESOURCE_VIEW_DESC srv{}; + srv.Format = DXGI_FORMAT_R32_TYPELESS; + srv.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srv.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srv.Buffer.NumElements = kViewBytes / 4; + srv.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; + EXPECT(rt::d3d12::write_placed_buffer_view(device, false, &srv, unmapped, kViewBytes, handle(3))); + EXPECT(zero_size(slots[0])); + EXPECT(base_of(slots[1]) == b.arena_va && slots[1][2] != 0); + EXPECT(base_of(slots[2]) == (b.upload_va & 0xFFFFFFFFFFFFull) && slots[2][2] != 0); + EXPECT(zero_size(slots[3])); + std::printf("created views: a CBV and a placed SRV of unmapped 0x%llx are zero-size; arena and upload CBVs kept\n", + static_cast(unmapped)); + return 0; +} + +// Inline V#s in a bound table of one of the layer's heaps, written by the CPU itself as the title does: before the +// submission an unmapped base becomes zero-size in place; arena, upload and image-shaped slots keep their bytes. +int check_inline_table(ID3D12Device* device, ID3D12CommandQueue* queue, ID3D12Fence* fence, UINT64& fence_value, + const Buffers& b, std::uint64_t unmapped) { + const D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 8, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; + Ref heap; + EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&heap.p)))); + auto* cpu = reinterpret_cast(heap->GetCPUDescriptorHandleForHeapStart().ptr); + const auto put = [&](int slot, const leonida::gfx10::BufferWords& w) { + std::memcpy(cpu + slot * kDescriptor, w.data(), sizeof(w)); + }; + put(0, raw_vsharp(unmapped)); + for (int i = 4; i < 131; ++i) put(i, raw_vsharp(unmapped)); + put(1, raw_vsharp(b.arena_va)); + put(2, raw_vsharp(b.upload_va & 0xFFFFFFFFFFFFull)); + auto image_like = raw_vsharp(unmapped); + image_like[3] |= 0x8u << 28; // TYPE: an image + put(3, image_like); + std::uint8_t kept[3][kDescriptor]; + for (int i = 0; i < 3; ++i) std::memcpy(kept[i], cpu + (i + 1) * kDescriptor, kDescriptor); + + D3D12_DESCRIPTOR_RANGE range{D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 8, 0, 0, 0}; + D3D12_ROOT_PARAMETER param{}; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + param.DescriptorTable = {1, &range}; + D3D12_VERSIONED_ROOT_SIGNATURE_DESC root_desc{}; + root_desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; + root_desc.Desc_1_0 = {1, ¶m, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE}; + const auto blob = serialize(root_desc); + EXPECT(!blob.empty()); + Ref root; + EXPECT(SUCCEEDED(device->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root.p)))); + Ref allocator; + Ref list; + EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); + EXPECT(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr, + IID_PPV_ARGS(&list.p)))); + ID3D12DescriptorHeap* heaps[] = {heap.p}; + list->SetDescriptorHeaps(1, heaps); + list->SetComputeRootSignature(root.p); + list->SetComputeRootDescriptorTable(0, heap->GetGPUDescriptorHandleForHeapStart()); + EXPECT(list->Close() == S_OK); + ID3D12CommandList* lists[] = {list.p}; + queue->ExecuteCommandLists(1, lists); + EXPECT(SUCCEEDED(queue->Signal(fence, ++fence_value))); + EXPECT(SUCCEEDED(fence->SetEventOnCompletion(fence_value, nullptr))); + + const auto* slot0 = reinterpret_cast(cpu); + EXPECT(zero_size(slot0)); + for (int i = 0; i < 3; ++i) EXPECT(!std::memcmp(kept[i], cpu + (i + 1) * kDescriptor, kDescriptor)); + std::printf("inline table V#s: unmapped base written zero-size before the submission; arena, upload and " + "image-shaped slots kept\n"); + return 0; +} + +// A console descriptor heap the title fills itself: its GPU copy nulls the V# that names unmapped memory and keeps the +// others; the title's own bytes are left as written. After the copy come null slots, which no other allocation takes. +int check_console_heap(ID3D12Device* device, ID3D12CommandQueue* queue, ID3D12Fence* fence, + UINT64& fence_value, const Buffers& b, std::uint64_t unmapped) { + constexpr UINT slots = 2048; + constexpr std::uint64_t bytes = std::uint64_t(slots) * kDescriptor; + auto* title = static_cast(VirtualAlloc(nullptr, bytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); + EXPECT(title); + // Written before the heap exists: the first refresh copies and fixes every slot (no write tracking needed). + const auto put = [&](int slot, const leonida::gfx10::BufferWords& w) { + std::memcpy(title + slot * kDescriptor, w.data(), sizeof(w)); + }; + put(0, raw_vsharp(unmapped)); + for (int i = 4; i < 131; ++i) put(i, raw_vsharp(unmapped)); + put(1, raw_vsharp(b.arena_va)); + put(2, raw_vsharp(b.upload_va & 0xFFFFFFFFFFFFull)); + // Slot 3: data the title keeps in a slot, neither a V# (TYPE 4) nor a T#; read as a V# its words name nothing. + const std::uint32_t data[8] = {0x12345000u, 0x00007777u, 0x00000400u, 0x40000000u, 1, 2, 3, 4}; + std::memcpy(title + 3 * kDescriptor, data, sizeof(data)); + std::uint8_t before[4][kDescriptor]; + for (int i = 0; i < 4; ++i) std::memcpy(before[i], title + i * kDescriptor, kDescriptor); + + const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, slots, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; + Ref heap; + EXPECT(SUCCEEDED(rt::d3d12::create_console_descriptor_heap(device, &desc, reinterpret_cast(title), + bytes, IID_PPV_ARGS(&heap.p)))); + D3D12_DESCRIPTOR_HEAP_DESC got{}; + D3D12_GPU_VIRTUAL_ADDRESS shader_va = 0; + EXPECT(rt::d3d12::descriptor_heap_info(heap.p, got, shader_va)); + std::uint32_t copy[4][kDescriptor / 4]; + EXPECT(rt::d3d12::read_arena(device, shader_va, copy, sizeof(copy))); + EXPECT(zero_size(copy[0])); + EXPECT(!std::memcmp(copy[1], before[1], kDescriptor)); + EXPECT(!std::memcmp(copy[2], before[2], kDescriptor)); + EXPECT(!(copy[3][0] | copy[3][1] | copy[3][2] | copy[3][3])); // the data slot's descriptor half is null + for (int i = 0; i < 4; ++i) EXPECT(!std::memcmp(title + i * kDescriptor, before[i], kDescriptor)); + + // 128 cold descriptors share one absent range. Publishing its alias leaves the title bytes + // unchanged. Only the bounded round-robin probes should discover it in the first 64 submits. + Ref allocator; + Ref list; + EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); + EXPECT(SUCCEEDED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr, + IID_PPV_ARGS(&list.p)))); + EXPECT(SUCCEEDED(list->Close())); + ID3D12CommandList* lists[] = {list.p}; + for (unsigned pass = 0; pass < 64; ++pass) { + if (pass == 1) leonida::title_va_aliases().add(unmapped, kViewBytes, b.arena_va); + queue->ExecuteCommandLists(1, lists); + EXPECT(SUCCEEDED(queue->Signal(fence, ++fence_value))); + EXPECT(SUCCEEDED(fence->SetEventOnCompletion(fence_value, nullptr))); + } + unsigned restored = 0; + for (unsigned slot = 0; slot < 131; ++slot) { + if (slot > 0 && slot < 4) continue; + std::uint32_t words[8]; + EXPECT(rt::d3d12::read_arena(device, shader_va + slot * kDescriptor, words, sizeof(words))); + if (base_of(words) == b.arena_va && words[2]) ++restored; + else EXPECT(zero_size(words)); + } + EXPECT(restored == 16); + std::printf("128 settled zero descriptors, %u restored in 64 submissions\n", restored); + leonida::title_va_aliases().remove(unmapped, b.arena_va); + + // The null guard: past the heap's last slot, up to kHeapIndexReach from its start, every byte reads 0. + constexpr std::uint64_t reach = 64ull << 20; + std::vector tail(1 << 20); + for (std::uint64_t at = bytes; at < reach; at += tail.size()) { + const std::size_t n = std::size_t(std::min(tail.size(), reach - at)); + EXPECT(rt::d3d12::read_arena(device, shader_va + at, tail.data(), n)); + for (std::size_t i = 0; i < n; ++i) + if (tail[i]) { + std::fprintf(stderr, "guard byte +0x%llx is 0x%02x\n", static_cast(at + i), tail[i]); + return 1; + } + } + // Reserved with the heap: a buffer made now lies outside the copy and its guard. + Ref later; + const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}; + const auto later_desc = buffer_desc(64 * 1024); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &later_desc, + D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&later.p)))); + const std::uint64_t later_va = later->GetGPUVirtualAddress(); + EXPECT(later_va + 64 * 1024 <= shader_va || later_va >= shader_va + reach); + std::printf("console heap: GPU copy at 0x%llx nulls the unmapped V# and a data slot, keeps arena and upload V#s, title bytes " + "intact; %llu MiB of null slots after it\n", + static_cast(shader_va), static_cast(reach >> 20)); + heap.reset(); + VirtualFree(title, 0, MEM_RELEASE); + return 0; +} + +// A bindless-sized heap of the layer's own (64Ki slots): an index past it reads null slots up to the reach. +int check_layer_heap_guard(ID3D12Device* device) { + constexpr UINT slots = 65536; + constexpr std::uint64_t bytes = std::uint64_t(slots) * kDescriptor, reach = 64ull << 20; + const D3D12_DESCRIPTOR_HEAP_DESC desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, slots, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; + Ref heap; + EXPECT(SUCCEEDED(device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&heap.p)))); + const std::uint64_t base = heap->GetGPUDescriptorHandleForHeapStart().ptr; + std::vector tail(1 << 20); + for (std::uint64_t at = bytes; at < bytes + reach; at += tail.size()) { + EXPECT(rt::d3d12::read_arena(device, base + at, tail.data(), tail.size())); + for (const std::uint8_t v : tail) EXPECT(v == 0); + } + Ref later; + const D3D12_HEAP_PROPERTIES default_heap{D3D12_HEAP_TYPE_DEFAULT}; + const auto later_desc = buffer_desc(64 * 1024); + EXPECT(SUCCEEDED(device->CreateCommittedResource(&default_heap, D3D12_HEAP_FLAG_NONE, &later_desc, + D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&later.p)))); + const std::uint64_t later_va = later->GetGPUVirtualAddress(); + EXPECT(later_va + 64 * 1024 <= base || later_va >= base + bytes + reach); + std::printf("layer heap: %u slots, then %llu MiB of null slots no other allocation takes\n", slots, + static_cast(reach >> 20)); + return 0; +} + +} // namespace + +int main() { + vktest::Device d; + const auto status = d.initialize(); + if (status == vktest::DeviceStatus::unavailable) { + std::fprintf(stderr, "SKIP: no usable Vulkan 1.3 device\n"); + return 77; + } + EXPECT(status == vktest::DeviceStatus::ready); + { + rt::d3d12::VulkanDeviceInfo info{}; + info.get_instance_proc = d.instance_proc; + info.instance = d.instance; + info.physical = d.physical; + info.device = d.device; + info.queue = d.queue; + info.queue_family = d.family; + info.buffer_device_address = true; + info.subgroup = d.subgroup; + Ref device; + EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device(info, IID_PPV_ARGS(&device.p)))); + const std::uint64_t arena = rt::d3d12::device_arena_size(device.p); + EXPECT(arena > 0); + const std::uint64_t unmapped = unmapped_address(); + EXPECT(unmapped > arena && unmapped < (1ull << 47)); + std::uint64_t lo = 0, hi = 0; + EXPECT(!leonida::title_va_aliases().title_memory(unmapped, lo, hi)); + + const D3D12_COMMAND_QUEUE_DESC queue_desc{}; + Ref queue; + Ref fence; + EXPECT(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p)))); + EXPECT(SUCCEEDED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p)))); + UINT64 fence_value = 0; + Buffers b; + if (make_buffers(device.p, arena, b)) return 1; + auto& aliases = leonida::title_va_aliases(); + EXPECT(aliases.resolve(unmapped, kViewBytes, leonida::TitleVaAliases::root_view) == 0); + EXPECT(aliases.resolve(b.upload_va, kViewBytes, leonida::TitleVaAliases::root_view) == b.upload_va); + if (check_created_views(device.p, b, unmapped)) return 1; + if (check_inline_table(device.p, queue.p, fence.p, fence_value, b, unmapped)) return 1; + if (check_console_heap(device.p, queue.p, fence.p, fence_value, b, unmapped)) return 1; + if (check_layer_heap_guard(device.p)) return 1; + } + if (d.validation_errors()) { + std::fprintf(stderr, "%u validation errors\n", d.validation_errors()); + return 1; + } + std::puts("ok"); + return 0; +} diff --git a/runtime/test/d3d12_xdxr_rt_test.cpp b/runtime/test/d3d12_xdxr_rt_test.cpp index 23c7a4698d..f7e9d90fc6 100644 --- a/runtime/test/d3d12_xdxr_rt_test.cpp +++ b/runtime/test/d3d12_xdxr_rt_test.cpp @@ -10,9 +10,21 @@ // d3d12_blas_box16, then updated in place with the same flags (d3d12_blas_box16_update); and once more without // ALLOW_UPDATE, so that its triangles are paired into TRI0/TRI1 leaves (d3d12_blas_paired; the ALLOW_UPDATE builds // must have no pairs, since a refit rewrites the leaves one triangle each). +// Then the paired BLAS and a TLAS over it again, each into a title-placed buffer (Xbox device slot 133: a buffer on +// the caller's own pages, its GPU VA their CPU address, past the GPU address arena; once on read-write pages, which +// the layer imports, and once on write-combined ones, which get a shadow), with instance descs that name the BLAS by +// that address, a COMPACTED_SIZE postbuild and a CLONE copy of it: the builder must write the buffer's GPU copy, the +// same bytes as the arena builds, and the TLAS record must name the BLAS by the VA shaders reach that copy at; heap_base +// + the title address is no allocation (in retail, an MMU write fault and a lost device). The same again on a list of +// the device behind the Xbox-ABI device proxy, as the title makes its lists (the list's device is then the proxy). +// Last, a destination on pages no buffer covers is left out (the pages keep their bytes), and a TLAS instance naming +// such pages gets no BLAS. // `python -I tools/xdxr_bvh.py check-build ` validates them and traces rays against brute force (ctest: // d3d12_xdxr_rt + d3d12_xdxr_rt_check). Exit 77 without a Vulkan device, or with LEONIDA_RT_AS=khr. No game files. #include "../shims/d3d12_com.h" +#include "../shims/d3d12_xs_device.h" +#include "../src/title_va_alias.h" +#include "../src/xdxr_build.h" #include #include @@ -496,6 +508,286 @@ int main(int argc, char** argv) { "{\"kind\": \"blas\", \"pairs\": true, \"address\": " + std::to_string(static_blas->GetGPUVirtualAddress()) + ", \"triangles\": " + tris + "}\n")) return fail("static BLAS readback"); + // ---- title-placed destinations (slot 133) ---- + std::vector paired; + { + void* p = nullptr; + if (FAILED(static_rb->Map(0, nullptr, &p))) return fail("Map the paired BLAS"); + std::uint32_t units = 0; + std::memcpy(&units, static_cast(p) + 4, 4); + paired.assign(static_cast(p), static_cast(p) + (UINT64(units) + 1) * 64); + static_rb->Unmap(0, nullptr); + } + leonida::XdxrLayout tlas_layout; + tlas_layout.compute(3, true); + auto instance_word = [&](const std::uint8_t* tl, int i, unsigned at) { + std::uint32_t w = 0; + std::memcpy(&w, tl + tlas_layout.elements_off + 128 * i + at, 4); + return w; + }; + auto read_back = [&](ID3D12Resource* rb, UINT64 bytes, std::vector& out) { + void* p = nullptr; + if (FAILED(rb->Map(0, nullptr, &p))) return false; + out.assign(static_cast(p), static_cast(p) + bytes); + rb->Unmap(0, nullptr); + return true; + }; + auto round_up = [](UINT64 x) { return (x + 0xffff) & ~UINT64(0xffff); }; + const UINT64 blas_room = round_up(static_info.ResultDataMaxSizeInBytes); + const UINT64 tlas_room = round_up(tlas_info.ResultDataMaxSizeInBytes); + Ref refs_up; // instance descs: three naming the slot-133 BLAS, three naming the arena one + if (FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_UPLOAD, 6 * 64, D3D12_RESOURCE_STATE_GENERIC_READ, + D3D12_RESOURCE_FLAG_NONE, refs_up.put()))) + return fail("instance upload buffer", hr); + Ref clone, clone_rb, title_tlas_rb; + if (FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_DEFAULT, static_info.ResultDataMaxSizeInBytes, as_state, uav, + clone.put())) || + FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_READBACK, static_info.ResultDataMaxSizeInBytes, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_FLAG_NONE, clone_rb.put())) || + FAILED(hr = buffer(device.p, D3D12_HEAP_TYPE_READBACK, tlas_info.ResultDataMaxSizeInBytes, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_FLAG_NONE, title_tlas_rb.put()))) + return fail("clone buffers", hr); + UINT64 fence_value = 8; + for (const DWORD modifier : {DWORD(0), DWORD(PAGE_WRITECOMBINE)}) { + // Top-down: far above the arena's size, as the title's pages are, so no arena VA can be mistaken for them. + auto* pages = static_cast(VirtualAlloc(nullptr, std::size_t(blas_room + tlas_room), + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE | modifier)); + if (!pages) return fail("title pages"); + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Width = blas_room; + desc.Height = desc.DepthOrArraySize = desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = uav; + Ref title_blas, title_tlas; + if (FAILED(hr = rt::d3d12::create_buffer_at_host_address(device.p, pages, desc, 0xFFFFFFFFu, + IID_PPV_ARGS(title_blas.put())))) + return fail("slot-133 BLAS buffer", hr); + desc.Width = tlas_room; + if (FAILED(hr = rt::d3d12::create_buffer_at_host_address(device.p, pages + blas_room, desc, 0xFFFFFFFFu, + IID_PPV_ARGS(title_tlas.put())))) + return fail("slot-133 TLAS buffer", hr); + const UINT64 title_blas_va = reinterpret_cast(pages); + if (title_blas->GetGPUVirtualAddress() != title_blas_va || + title_tlas->GetGPUVirtualAddress() != title_blas_va + blas_room) + return fail("a slot-133 buffer's GPU VA is not its address"); + const bool shadow = rt::d3d12::title_shadow_buffer(title_blas.p); + const UINT64 shader_va = leonida::title_va_aliases().shader_va(title_blas_va); + if (shader_va == title_blas_va) return fail("the slot-133 BLAS buffer has no GPU copy"); + D3D12_RAYTRACING_INSTANCE_DESC refs[6]{}; + for (int i = 0; i < 6; ++i) { + std::memcpy(refs[i].Transform, xforms[i % 3], sizeof xforms[i % 3]); + refs[i].InstanceID = 20 + i % 3; + refs[i].InstanceMask = masks[i % 3]; + refs[i].AccelerationStructure = i < 3 ? title_blas_va : static_blas->GetGPUVirtualAddress(); + } + void* up = nullptr; + if (FAILED(refs_up->Map(0, nullptr, &up))) return fail("Map instance descs"); + std::memcpy(up, refs, sizeof refs); + refs_up->Unmap(0, nullptr); + + if (FAILED(allocator->Reset()) || FAILED(list->Reset(allocator.p, nullptr))) return fail("Reset (slot 133)"); + build = {}; + build.Inputs = static_inputs; + build.DestAccelerationStructureData = title_blas_va; + build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + list->BuildRaytracingAccelerationStructure(&build, 1, &compacted_desc); // COMPACTED_SIZE at info + 0 + list->ResourceBarrier(1, &barrier); + build = {}; + build.Inputs = tlas_inputs; + build.Inputs.InstanceDescs = refs_up->GetGPUVirtualAddress(); + build.DestAccelerationStructureData = title_tlas->GetGPUVirtualAddress(); + build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + list->BuildRaytracingAccelerationStructure(&build, 0, nullptr); + list->ResourceBarrier(1, &barrier); + build.Inputs.InstanceDescs = refs_up->GetGPUVirtualAddress() + 3 * 64; // the same over the arena BLAS + build.DestAccelerationStructureData = tlas->GetGPUVirtualAddress(); + list->BuildRaytracingAccelerationStructure(&build, 0, nullptr); + list->CopyRaytracingAccelerationStructure(clone->GetGPUVirtualAddress(), title_blas_va, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_CLONE); + list->ResourceBarrier(1, &barrier); + list->CopyBufferRegion(blas_rb.p, 0, title_blas.p, 0, static_info.ResultDataMaxSizeInBytes); + list->CopyBufferRegion(title_tlas_rb.p, 0, title_tlas.p, 0, tlas_info.ResultDataMaxSizeInBytes); + list->CopyBufferRegion(tlas_rb.p, 0, tlas.p, 0, tlas_info.ResultDataMaxSizeInBytes); + list->CopyBufferRegion(clone_rb.p, 0, clone.p, 0, static_info.ResultDataMaxSizeInBytes); + list->CopyBufferRegion(info_rb.p, 0, info.p, 0, 8); + if (!submit(fence_value++)) return fail("slot-133 builds did not complete"); + if (FAILED(device->GetDeviceRemovedReason())) + return fail("device removed by slot-133 builds", device->GetDeviceRemovedReason()); + std::vector got, title_tl, arena_tl, cloned; + UINT64 size = 0; + if (!read_back(blas_rb.p, paired.size(), got) || !read_back(title_tlas_rb.p, tlas_info.ResultDataMaxSizeInBytes, title_tl) || + !read_back(tlas_rb.p, tlas_info.ResultDataMaxSizeInBytes, arena_tl) || + !read_back(clone_rb.p, paired.size(), cloned)) + return fail("Map slot-133 readbacks"); + { + void* p = nullptr; + if (FAILED(info_rb->Map(0, nullptr, &p))) return fail("Map postbuild (slot 133)"); + std::memcpy(&size, p, 8); + info_rb->Unmap(0, nullptr); + } + const char* kind = shadow ? "write-combined pages (shadow)" : "read-write pages (import)"; + if (got != paired) { + std::fprintf(stderr, "slot-133 BLAS on %s differs from the arena build\n", kind); + return fail("slot-133 BLAS bytes"); + } + // An import is the title's pages: the CPU reads what the GPU wrote there. + if (!shadow && std::memcmp(pages, paired.data(), paired.size()) != 0) return fail("the imported pages"); + if (size != paired.size()) return fail("slot-133 BLAS COMPACTED_SIZE"); + if (cloned != paired) return fail("CLONE of the slot-133 BLAS"); + // The two TLASes agree but for the BLAS address of their records: the shader VA of the slot-133 BLAS's copy, + // and the arena BLAS's VA, in 256-byte units. + std::uint32_t units = 0; + std::memcpy(&units, arena_tl.data() + 4, 4); + const std::size_t used = std::size_t(units + 1) * 64; + if (used > title_tl.size()) return fail("TLAS size"); + for (int i = 0; i < 3; ++i) { + const std::uint32_t want_title = std::uint32_t(shader_va >> 8); + const std::uint32_t want_arena = std::uint32_t(static_blas->GetGPUVirtualAddress() >> 8); + if (instance_word(title_tl.data(), i, 60) != want_title || instance_word(arena_tl.data(), i, 60) != want_arena) { + std::fprintf(stderr, "instance %d: BLAS 0x%08x (want 0x%08x), arena 0x%08x (want 0x%08x)\n", i, + instance_word(title_tl.data(), i, 60), want_title, instance_word(arena_tl.data(), i, 60), + want_arena); + return fail("the TLAS record's BLAS address"); + } + std::memset(title_tl.data() + tlas_layout.elements_off + 128 * i + 60, 0, 4); + std::memset(arena_tl.data() + tlas_layout.elements_off + 128 * i + 60, 0, 4); + } + if (std::memcmp(title_tl.data(), arena_tl.data(), used) != 0) return fail("slot-133 TLAS bytes"); + std::printf("d3d12_xdxr_rt: BLAS and TLAS built into slot-133 buffers on %s, at shader VA 0x%llx for title " + "address 0x%llx\n", + kind, static_cast(shader_va), static_cast(title_blas_va)); + // The buffers go before their pages (a shadow watches them). + for (Ref* r : {&title_blas, &title_tlas}) { + r->p->Release(); + r->p = nullptr; + } + VirtualFree(pages, 0, MEM_RELEASE); + } + + // ---- the same on a list whose device is the Xbox-ABI proxy (Device::identity), as the title's lists are ---- + { + void* proxy = nullptr; + if (FAILED(hr = rt::d3d12_xs::create_device_proxy(device.p, __uuidof(ID3D12Device), &proxy)) || !proxy) + return fail("device proxy", hr); + rt::d3d12::set_device_outer(device.p, static_cast(proxy)); + // Made after the outer is set, so they belong to the proxied device (a queue checks its lists' and fences'). + Ref proxy_queue; + Ref proxy_fence; + Ref proxy_allocator; + Ref proxy_list; + Ref proxy_rb; + if (FAILED(device->CreateCommandQueue(&qd, IID_PPV_ARGS(proxy_queue.put()))) || + FAILED(device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(proxy_fence.put()))) || + FAILED(buffer(device.p, D3D12_HEAP_TYPE_READBACK, static_info.ResultDataMaxSizeInBytes, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_FLAG_NONE, proxy_rb.put())) || + FAILED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(proxy_allocator.put()))) || + FAILED(device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, proxy_allocator.p, nullptr, + IID_PPV_ARGS(proxy_list.put())))) + return fail("list of the proxied device"); + auto* pages = static_cast(VirtualAlloc(nullptr, std::size_t(blas_room), + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE)); + if (!pages) return fail("title pages (proxy)"); + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Width = blas_room; + desc.Height = desc.DepthOrArraySize = desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + desc.Flags = uav; + Ref title_blas; + if (FAILED(hr = rt::d3d12::create_buffer_at_host_address(device.p, pages, desc, 0xFFFFFFFFu, + IID_PPV_ARGS(title_blas.put())))) + return fail("slot-133 BLAS buffer (proxy)", hr); + build = {}; + build.Inputs = static_inputs; + build.DestAccelerationStructureData = reinterpret_cast(pages); + build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + proxy_list->BuildRaytracingAccelerationStructure(&build, 0, nullptr); + proxy_list->ResourceBarrier(1, &barrier); + proxy_list->CopyBufferRegion(proxy_rb.p, 0, title_blas.p, 0, static_info.ResultDataMaxSizeInBytes); + if (FAILED(hr = proxy_list->Close())) return fail("Close (proxy)", hr); + ID3D12CommandList* proxy_lists[] = {proxy_list.p}; + proxy_queue->ExecuteCommandLists(1, proxy_lists); + if (rt::d3d12::last_execute_result(proxy_queue.p) != leonida::ReplayResult::success) + return fail("the proxied list was refused"); + if (FAILED(proxy_queue->Signal(proxy_fence.p, 1))) return fail("Signal (proxy)"); + HANDLE e = CreateEventW(nullptr, FALSE, FALSE, nullptr); + const bool ran = e && SUCCEEDED(proxy_fence->SetEventOnCompletion(1, e)) && + WaitForSingleObject(e, 10000) == WAIT_OBJECT_0; + if (e) CloseHandle(e); + if (!ran) return fail("the proxied list did not complete"); + if (FAILED(device->GetDeviceRemovedReason())) + return fail("device removed by a proxied list's build", device->GetDeviceRemovedReason()); + std::vector got; + if (!read_back(proxy_rb.p, paired.size(), got)) return fail("Map (proxy)"); + if (got != paired) return fail("slot-133 BLAS built on a proxied list"); + rt::d3d12::set_device_outer(device.p, nullptr); + title_blas.p->Release(); + title_blas.p = nullptr; + proxy_list.p->Release(); + proxy_list.p = nullptr; + proxy_allocator.p->Release(); + proxy_allocator.p = nullptr; + proxy_queue.p->Release(); + proxy_queue.p = nullptr; + proxy_fence.p->Release(); + proxy_fence.p = nullptr; + // The proxy is kept: the queue releases the lists it pinned on its own thread after the fence, and they hold + // the proxy as their device. + VirtualFree(pages, 0, MEM_RELEASE); + std::printf("d3d12_xdxr_rt: a list of the proxied device builds into a slot-133 buffer\n"); + } + + // ---- no GPU copy: pages no buffer covers. The build is left out (the list still closes, the pages keep their + // bytes, the device stays), and a TLAS instance naming them gets no BLAS (record 0, root INVALID) ---- + { + auto* raw = static_cast(VirtualAlloc(nullptr, std::size_t(blas_room), + MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE)); + if (!raw) return fail("raw pages"); + std::memset(raw, 0xCD, std::size_t(blas_room)); + D3D12_RAYTRACING_INSTANCE_DESC refs[3]{}; + for (int i = 0; i < 3; ++i) { + std::memcpy(refs[i].Transform, xforms[0], sizeof xforms[0]); + refs[i].InstanceMask = 0xff; + refs[i].AccelerationStructure = i == 0 ? reinterpret_cast(raw) : static_blas->GetGPUVirtualAddress(); + } + void* up = nullptr; + if (FAILED(refs_up->Map(0, nullptr, &up))) return fail("Map instance descs (raw)"); + std::memcpy(up, refs, sizeof refs); + refs_up->Unmap(0, nullptr); + if (FAILED(allocator->Reset()) || FAILED(list->Reset(allocator.p, nullptr))) return fail("Reset (raw)"); + build = {}; + build.Inputs = static_inputs; + build.DestAccelerationStructureData = reinterpret_cast(raw); + build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + list->BuildRaytracingAccelerationStructure(&build, 1, &compacted_desc); + list->ResourceBarrier(1, &barrier); + build = {}; + build.Inputs = tlas_inputs; + build.Inputs.InstanceDescs = refs_up->GetGPUVirtualAddress(); + build.DestAccelerationStructureData = tlas->GetGPUVirtualAddress(); + build.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + list->BuildRaytracingAccelerationStructure(&build, 0, nullptr); + list->ResourceBarrier(1, &barrier); + list->CopyBufferRegion(tlas_rb.p, 0, tlas.p, 0, tlas_info.ResultDataMaxSizeInBytes); + if (!submit(fence_value++)) return fail("the list with an unresolved destination did not run"); + if (FAILED(device->GetDeviceRemovedReason())) + return fail("device removed by an unresolved destination", device->GetDeviceRemovedReason()); + for (UINT64 i = 0; i < blas_room; ++i) + if (raw[i] != 0xCD) return fail("a build wrote pages no buffer covers"); + std::vector tl; + if (!read_back(tlas_rb.p, tlas_info.ResultDataMaxSizeInBytes, tl)) return fail("Map TLAS (raw)"); + if (instance_word(tl.data(), 0, 60) != 0 || (instance_word(tl.data(), 0, 56) & 0x3fffffffu) != 0x3fffffffu || + instance_word(tl.data(), 1, 60) != std::uint32_t(static_blas->GetGPUVirtualAddress() >> 8)) + return fail("a TLAS instance naming unbacked pages"); + VirtualFree(raw, 0, MEM_RELEASE); + std::printf("d3d12_xdxr_rt: a build into pages no buffer covers was left out, and an instance naming them " + "has no BLAS\n"); + } + std::printf("d3d12_xdxr_rt: BLAS %llu bytes (prebuild %llu), TLAS (prebuild %llu), written to %s\n", static_cast(blas_info.ResultDataMaxSizeInBytes), static_cast(blas_info.ResultDataMaxSizeInBytes), diff --git a/runtime/test/d3d12_xmem_placed_test.cpp b/runtime/test/d3d12_xmem_placed_test.cpp index 253fee2e73..fb20305578 100644 --- a/runtime/test/d3d12_xmem_placed_test.cpp +++ b/runtime/test/d3d12_xmem_placed_test.cpp @@ -6,6 +6,7 @@ // pages hook (rt::d3d12_xs::set_placed_at_va_pages_hook, as gta6rt does), the pages are committed first: the buffer's // GPU VA is the window itself and a GPU copy reads what the CPU writes there afterwards. // Needs VK_EXT_external_memory_host (skipped otherwise). No shaders or game data. +#include "xmem_section_state.h" #include "vk_test_device.h" #include "d3d12_test_shaders.h" #include "../shims/d3d12_com.h" @@ -13,7 +14,13 @@ #include "../shims/shims.h" #include "../shims/xmem.h" +#include "../src/title_page_watch.h" +#include +#include #include +#include +#include +#include #define EXPECT(condition) do { \ if (!(condition)) { std::fprintf(stderr, "%s line %d: %s\n", who, __LINE__, #condition); return 1; } \ @@ -88,6 +95,263 @@ int gpu_reads_cpu_writes(ID3D12Device* real, ID3D12Resource* buffer, const void* return 0; } +int queue_remap(ID3D12Device* real, ID3D12Device* proxy) { + using rt::xmem::PageRange; + using rt::xmem::PageBatch; + auto reserve = reinterpret_cast(rt::shims::find("xmem.dll", "XMemVirtualAlloc")); + auto allocate = reinterpret_cast(rt::shims::find("xmem.dll", "XMemAllocatePhysicalPages")); + auto map = reinterpret_cast(rt::shims::find("xmem.dll", "XMemMapPhysicalPages")); + auto free_pages = reinterpret_cast(rt::shims::find("xmem.dll", "XMemFreePhysicalPages")); + constexpr unsigned n = 6; + auto window = [&](DWORD protect) { + return static_cast(reserve(nullptr, n * kPage64k, MEM_RESERVE | kXmem64kPages, 0, protect)); + }; + auto* pool = window(PAGE_READWRITE); + auto* cpu = window(PAGE_READWRITE); + auto* dst = window(0x801); + EXPECT(pool && cpu && dst && leonida::title_gpu_views::other_view(uintptr_t(dst)) == uintptr_t(cpu)); + EXPECT(leonida::title_gpu_views::to_cpu(uintptr_t(dst)) == uintptr_t(dst)); + std::uint64_t pages[n]{}, count = n; + EXPECT(allocate(0x280, &count, pages) && count == n); + EXPECT(map(pool, n, pages) && map(cpu, n, pages) && map(dst, n, pages)); + for (unsigned i = 0; i < n; ++i) pool[i * kPage64k] = static_cast(10 + i); + + D3D12_COMMAND_QUEUE_DESC desc{D3D12_COMMAND_LIST_TYPE_COPY}; + Ref queue; + Ref gate; + EXPECT(SUCCEEDED(proxy->CreateCommandQueue(&desc, IID_PPV_ARGS(&queue.p)))); + EXPECT(SUCCEEDED(real->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&gate.p)))); + auto* real_queue = rt::d3d12_xs::queue_proxy_real_queue(queue.p); + EXPECT(real_queue && SUCCEEDED(real_queue->Wait(gate.p, 1))); + rt::d3d12_xs::set_copy_page_mappings_hook(&rt::xmem::copy_page_mappings); + using Copy = HRESULT(WINAPI*)(void*, UINT, const PageBatch*, std::uintptr_t, UINT, UINT); + auto call = reinterpret_cast((*reinterpret_cast(queue.p))[31]); + const PageRange first[] = {{0, 1, 2}, {1, 4, 2}}; + const PageRange second[] = {{2, UINT32_MAX, 1}, {3, UINT32_MAX, 1}}; + const PageBatch batches[] = {{uintptr_t(dst), 2, first}, {uintptr_t(dst + 4 * kPage64k), 2, second}}; + std::promise started; + auto done = std::async(std::launch::async, [&] { + started.set_value(); + return call(queue.p, 2, batches, uintptr_t(pool), n, 0); + }); + started.get_future().wait(); + const bool waited = done.wait_for(std::chrono::milliseconds(100)) == std::future_status::timeout; + const auto before = dst[0]; + EXPECT(SUCCEEDED(gate->Signal(1))); + EXPECT(SUCCEEDED(done.get()) && before == 10); + // With list values the call can return after queuing the remap. Its gate must still order later queue work. + const char* list_values = std::getenv("LEONIDA_LIST_VALUES"); + if (list_values && !std::strcmp(list_values, "0")) EXPECT(waited); + EXPECT(SUCCEEDED(real_queue->Signal(gate.p, 2))); + HANDLE remapped = CreateEventW(nullptr, FALSE, FALSE, nullptr); + EXPECT(remapped && SUCCEEDED(gate->SetEventOnCompletion(2, remapped))); + const auto completion = WaitForSingleObject(remapped, 10000); + CloseHandle(remapped); + EXPECT(completion == WAIT_OBJECT_0); + EXPECT(dst[0] == 11 && dst[kPage64k] == 12 && dst[2 * kPage64k] == 14 && dst[3 * kPage64k] == 14); + EXPECT(state_is(dst + 4 * kPage64k, MEM_RESERVE) && dst[5 * kPage64k] == 15); + dst[2 * kPage64k] = 93; + EXPECT(pool[4 * kPage64k] == 93 && dst[3 * kPage64k] == 93 && cpu[0] == 10 && cpu[4 * kPage64k] == 93); + + // Snapshot overlapping source/destination before changing either. Reject a late invalid range atomically. + const PageRange overlap[] = {{0, 0, 1}, {0, 1, 1}}; + const PageBatch same_pool{uintptr_t(dst + kPage64k), 2, overlap}; + EXPECT(SUCCEEDED(call(queue.p, 1, &same_pool, uintptr_t(dst), n, 0))); + EXPECT(dst[kPage64k] == 11 && dst[2 * kPage64k] == 12); + const PageRange invalid[] = {{2, 0, 1}, {0, n, 1}}; + const PageBatch bad{uintptr_t(dst), 2, invalid}; + EXPECT(FAILED(call(queue.p, 1, &bad, uintptr_t(pool), n, 0)) && dst[0] == 11); + bool overflow = false; + auto writes = leonida::title_texel_writes::take(overflow); + EXPECT(!overflow && !writes.empty()); + EXPECT(map(dst, n, nullptr) && map(cpu, n, nullptr) && map(pool, n, nullptr)); + EXPECT(free_pages(n, pages)); + rt::d3d12_xs::set_copy_page_mappings_hook(nullptr); + std::puts("queue slot 31: ordered two batches, four range kinds, shared physical data, independent CPU view, overlap and invalid input passed"); + return 0; +} + +// What a GPU copy of `buffer` reads now (a submission: the shadows are refreshed first). +int read_back(ID3D12Device* real, ID3D12Resource* buffer, UINT64 size, std::vector& out) { + D3D12_RESOURCE_DESC desc = buffer->GetDesc(); + D3D12_HEAP_PROPERTIES readback_heap{D3D12_HEAP_TYPE_READBACK}; + Ref readback; + EXPECT(SUCCEEDED(real->CreateCommittedResource(&readback_heap, D3D12_HEAP_FLAG_NONE, &desc, + D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&readback.p)))); + D3D12_COMMAND_QUEUE_DESC queue_desc{D3D12_COMMAND_LIST_TYPE_DIRECT}; + Ref queue; + Ref allocator; + Ref list; + Ref fence; + EXPECT(SUCCEEDED(real->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue.p)))); + EXPECT(SUCCEEDED(real->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator.p)))); + EXPECT(SUCCEEDED(real->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.p, nullptr, + IID_PPV_ARGS(&list.p)))); + list->CopyBufferRegion(readback.p, 0, buffer, 0, size); + EXPECT(SUCCEEDED(list->Close())); + ID3D12CommandList* lists[] = {list.p}; + queue->ExecuteCommandLists(1, lists); + EXPECT(SUCCEEDED(real->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence.p)))); + EXPECT(SUCCEEDED(queue->Signal(fence.p, 1))); + HANDLE done = CreateEventW(nullptr, FALSE, FALSE, nullptr); + EXPECT(SUCCEEDED(fence->SetEventOnCompletion(1, done))); + EXPECT(WaitForSingleObject(done, 10000) == WAIT_OBJECT_0); + CloseHandle(done); + void* mapped = nullptr; + EXPECT(SUCCEEDED(readback->Map(0, nullptr, &mapped))); + out.assign(static_cast(mapped), static_cast(mapped) + size); + readback->Unmap(0, nullptr); + return 0; +} + +DWORD protection_of(const void* address) { + MEMORY_BASIC_INFORMATION info{}; + return VirtualQuery(address, &info, sizeof(info)) && info.State == MEM_COMMIT ? info.Protect : 0; +} + +// A write from a thread of its own (the title's, or a DirectStorage queue's), waited for. +template +bool on_thread(F f) { + std::thread t(f); + t.join(); + return true; +} + +// The guards over a stream pool's physical pages, mapped at the CPU view and at its GPU-only twin (protect 0x801, a +// window slot 31 maps by itself), with a slot-133 buffer (a shadow: the twin's pages are mapped independently) over +// the twin. Checked by what a GPU copy reads after each step: +// 1. after a submission the twin's pages are read-only (guarded); +// 2. a pin taken with an OVERLAPPED that does not say pending yet (ReadFile stores STATUS_PENDING once it starts) +// survives a submission: the pinned page stays writable, as the kernel's write into it needs; +// 3. a host thread's copy into a guarded page (kernel_writes::write, as a DirectStorage queue publishes) lands, and +// so does a DirectStorage page-list write through the section (rt::xmem::transfer_physical) into another; +// 4. the pages are mapped at the CPU view too: a title thread's write through the CPU view (no fault) and one through +// the guarded twin (a fault its shadow answers) both reach the GPU; +// 5. a CPU-view page left read-only with no guard to reopen it: a title thread's write there faults, xmem's +// unguarder makes it writable, and the write lands; a kernel write (kernel_writes::read_file) into another +// such page succeeds too. Both reach the GPU through the twin. +int paired_views(ID3D12Device* real) { + namespace kw = leonida::kernel_writes; + auto reserve = reinterpret_cast(rt::shims::find("xmem.dll", "XMemVirtualAlloc")); + auto allocate = reinterpret_cast(rt::shims::find("xmem.dll", "XMemAllocatePhysicalPages")); + auto map = reinterpret_cast(rt::shims::find("xmem.dll", "XMemMapPhysicalPages")); + auto free_pages = reinterpret_cast(rt::shims::find("xmem.dll", "XMemFreePhysicalPages")); + constexpr unsigned n = 4; + constexpr UINT64 size = n * kPage64k; + auto* cpu = static_cast(reserve(nullptr, size, MEM_RESERVE | kXmem64kPages, 0, PAGE_READWRITE)); + auto* gpu = static_cast(reserve(nullptr, size, MEM_RESERVE | kXmem64kPages, 0, 0x801)); + EXPECT(cpu && gpu && leonida::title_gpu_views::other_view(uintptr_t(gpu)) == uintptr_t(cpu)); + EXPECT(leonida::title_gpu_views::independently_mapped(uintptr_t(gpu), size)); + std::uint64_t pages[n]{}, count = n; + EXPECT(allocate(0x280, &count, pages) && count == n && map(gpu, n, pages) == gpu); + std::vector want(size), got; + for (UINT64 i = 0; i < size; ++i) want[i] = gpu[i] = static_cast(i * 37u + 11u); + kw::set_unguarder(&rt::xmem::reopen_unowned); + int failures = 0; + { + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + desc.Width = size; + desc.Height = desc.DepthOrArraySize = desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + Ref buffer; + EXPECT(SUCCEEDED(rt::d3d12::create_buffer_at_host_address(real, gpu, desc, 0xFFFFFFFFu, + IID_PPV_ARGS(&buffer.p)))); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + // 1. + const DWORD guarded = protection_of(gpu + 0x8000); + EXPECT((guarded & 0xff) == PAGE_READONLY); + + // 2. The pin of a read whose call has started but whose OVERLAPPED is still all zeros. + OVERLAPPED starting{}; + const std::uint64_t pin = kw::begin_write(gpu + 0x10000, 0x1000, &starting); + EXPECT(pin && (protection_of(gpu + 0x10000) & 0xff) == PAGE_READWRITE); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + EXPECT(kw::state().count.load() == 1 && (protection_of(gpu + 0x10000) & 0xff) == PAGE_READWRITE); + kw::end_write(pin, false); + EXPECT(kw::state().count.load() == 0); + + // 3. A host thread's copy into a guarded page. + EXPECT(read_back(real, buffer.p, size, got) == 0 && (protection_of(gpu + 0x20000) & 0xff) == PAGE_READONLY); + std::vector source(0x2800); + for (std::size_t i = 0; i < source.size(); ++i) source[i] = static_cast(i * 5u + 200u); + bool wrote = false; + on_thread([&] { wrote = kw::write(gpu + 0x20400, source.data(), source.size()); }); + EXPECT(wrote); + std::memcpy(want.data() + 0x20400, source.data(), source.size()); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + // And a DirectStorage page-list write (through the section) into a guarded page: pinned, so it is copied. + EXPECT((protection_of(gpu + 0x30000) & 0xff) == PAGE_READONLY); + std::vector listed(0x600, 0x6b); + EXPECT(rt::xmem::transfer_physical(std::span(&pages[3], 1), 0x800, listed, true)); + std::fill(want.begin() + 0x30800, want.begin() + 0x30e00, std::uint8_t(0x6b)); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + + // 4. Paired: the same pages at the CPU view too. + EXPECT(map(cpu, n, pages) == cpu && cpu[0x20400] == source[0]); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + on_thread([&] { for (int i = 0; i < 256; ++i) want[0x30000 + i] = cpu[0x30000 + i] = std::uint8_t(0xa0 + i); }); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + const bool twin_guarded = (protection_of(gpu + 0x8000) & 0xff) == PAGE_READONLY; + EXPECT(twin_guarded); // still the shadow's: its write below faults + on_thread([&] { for (int i = 0; i < 64; ++i) want[0x8010 + i] = gpu[0x8010 + i] = std::uint8_t(0x30 + i); }); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + + // 5. CPU-view pages read-only with no guard to answer for them. + DWORD old = 0; + EXPECT(VirtualProtect(cpu + 0x11000, 0x1000, PAGE_READONLY, &old)); + on_thread([&] { for (int i = 0; i < 64; ++i) want[0x11100 + i] = cpu[0x11100 + i] = std::uint8_t(0x70 + i); }); + EXPECT((protection_of(cpu + 0x11000) & 0xff) == PAGE_READWRITE); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + wchar_t dir[MAX_PATH]{}, path[MAX_PATH]{}; + EXPECT(GetTempPathW(MAX_PATH, dir) && GetTempFileNameW(dir, L"xpv", 0, path)); + HANDLE file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, + FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, nullptr); + DWORD moved = 0; + EXPECT(file != INVALID_HANDLE_VALUE && WriteFile(file, source.data(), 0x1000, &moved, nullptr) && moved == 0x1000); + EXPECT(VirtualProtect(cpu + 0x32000, 0x1000, PAGE_READONLY, &old)); + OVERLAPPED at{}; + bool read = false; + on_thread([&] { read = kw::read_file(file, cpu + 0x32000, 0x1000, &moved, &at) && moved == 0x1000; }); + CloseHandle(file); + EXPECT(read); + std::memcpy(want.data() + 0x32000, source.data(), 0x1000); + EXPECT(read_back(real, buffer.p, size, got) == 0 && got == want); + std::printf("%s: paired views: guarded twin 0x%lx (0x%lx with the CPU view mapped), a pin whose OVERLAPPED " + "said nothing yet kept its page writable across a submission, host and title writes through " + "either view and into unowned read-only pages reached the GPU\n", + who, guarded, twin_guarded ? guarded : protection_of(gpu + 0x8000)); + } + kw::set_unguarder(nullptr); + EXPECT(map(cpu, n, nullptr) && map(gpu, n, nullptr) && free_pages(n, pages)); + return failures; +} + +int exposure_map_ranges(void* device) { + auto* pages = static_cast(VirtualAlloc(nullptr, 2 * kPage64k, MEM_RESERVE, PAGE_READWRITE)); + EXPECT(pages && VirtualAlloc(pages, kPage64k, MEM_COMMIT, PAGE_READWRITE)); + D3D12_RESOURCE_DESC desc{}; + desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + desc.Width = desc.Height = desc.DepthOrArraySize = desc.MipLevels = 1; + desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + desc.SampleDesc.Count = 1; + desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + { + Ref image; + EXPECT(SUCCEEDED(place(device, pages, desc, &image.p))); + for (SIZE_T offset : {SIZE_T(0), kPage64k}) { + const D3D12_RANGE read{offset, offset + 256}, written{}; + void* raw = nullptr; + EXPECT(SUCCEEDED(image->Map(0, &read, &raw)) && raw == pages); + image->Unmap(0, &written); + } + EXPECT(state_is(pages + kPage64k, MEM_RESERVE)); // logging must not fault in the page + } + EXPECT(VirtualFree(pages, 0, MEM_RELEASE)); + return 0; +} + int run(ID3D12Device* real, void* device, bool eager) { const auto virtual_alloc = reinterpret_cast(rt::shims::find("xmem.dll", "XMemVirtualAlloc")); const auto allocate = @@ -105,7 +369,8 @@ int run(ID3D12Device* real, void* device, bool eager) { std::uint64_t count = kPages; EXPECT(allocate(0x280, &count, pages) == TRUE && count == kPages); EXPECT(map(window, kPages, pages) == window); - EXPECT(state_is(window, eager ? MEM_COMMIT : MEM_RESERVE)); // verify the selected physical-page mapper + const DWORD initial_state = expected_xmem_section_state(); + EXPECT(state_is(window, initial_state)); D3D12_RESOURCE_DESC desc{}; desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; @@ -129,7 +394,7 @@ int run(ID3D12Device* real, void* device, bool eager) { if (gpu_reads_cpu_writes(real, fallback.p, window, size)) return 1; } else { EXPECT(fallback->GetGPUVirtualAddress() == window_va); - EXPECT(state_is(window, MEM_RESERVE)); + EXPECT(state_is(window, initial_state)); } } std::printf("%s: physical pages without the hook: %s\n", who, eager ? "already committed and GPU-visible" : "still reserved"); @@ -272,7 +537,12 @@ int main(int argc, char** argv) { } if (argc==2 && (std::strcmp(argv[1],"--linear-map")==0 || std::strcmp(argv[1],"--linear-staging")==0)) failures+=linear_texture_mapping(real.p,device.p,std::strcmp(argv[1],"--linear-staging")==0); - else failures += run(real.p, device.p, eager); + else { + failures += run(real.p, device.p, eager); + failures += exposure_map_ranges(device.p); + failures += queue_remap(real.p, device.p); + failures += paired_views(real.p); + } } if (vk.validation_errors()) { std::fprintf(stderr, "%u validation errors\n", vk.validation_errors()); diff --git a/runtime/test/dstorage_test.cpp b/runtime/test/dstorage_test.cpp index 4c1bb7d2f8..c24bcdb652 100644 --- a/runtime/test/dstorage_test.cpp +++ b/runtime/test/dstorage_test.cpp @@ -18,7 +18,9 @@ #include #include "../src/bcpack.h" #include "../src/bcpack_stream.h" +#include "../src/title_geometry_watch.h" #include "../src/title_page_watch.h" +#include "xmem.h" #include "dstorage_xs_abi.h" #include "dstorage_staging.h" #include "file_system.h" @@ -1356,6 +1358,106 @@ leonida::bcpack::Calibration test_profile() { return history; } +// Requests whose destination the runtime's own guards keep read-only, written from the queue's worker threads (each +// through kernel_writes: src/title_page_watch.h): +// 1. a geometry tile the geometry watch armed (src/title_geometry_watch.h), with the D3D12 layer's opener as far as +// that watch goes: a file read, a memory copy and a decompressed (BCPack) publish into it all succeed, and the +// tile counts as written (its GPU copy is refilled); +// 2. an xmem physical page (the stream pool's CPU view) left read-only with no guard to reopen it, with +// rt::xmem::reopen_unowned as the unguarder (as gta6rt sets it): the same three requests succeed. +void test_guarded_destinations(Env& env) { + namespace gw = leonida::geometry_writes; + namespace kw = leonida::kernel_writes; + auto* file = open(env, L"game:/data/b.bin"); + auto* files = make_queue(env, 0x80, false); + auto* memory = make_queue(env, 0x80, false, DSTORAGE_REQUEST_SOURCE_MEMORY, DSTORAGE_PRIORITY_REALTIME); + auto* status = make_status(env, 3); + const std::vector source = pattern(4096, 21); + const auto& packed = vectors[0]; + // Each request into `at` (file range, memory copy, BCPack), each of the three after `guard` made the pages + // read-only again; the bytes are checked after each. + const auto run = [&](uint8_t* at, const std::function& guard, const char* where) { + guard(); + auto read = file_request(file, 300, at, 4096); + files->EnqueueRequest(&read); + files->EnqueueStatus(status, 0); + files->Submit(); + check(wait_complete(status, 0), where); + check_hr(status->GetHResult(0), S_OK, where); + check(std::memcmp(at, env.b.data() + 300, 4096) == 0, where); + guard(); + DSTORAGE_REQUEST copy{}; + copy.Options.SourceType = DSTORAGE_REQUEST_SOURCE_MEMORY; + copy.Source = source.data(); + copy.Destination = at + 0x1000; + copy.SourceSize = copy.DestinationSize = 4096; + memory->EnqueueRequest(©); + memory->EnqueueStatus(status, 1); + memory->Submit(); + check(wait_complete(status, 1), where); + check_hr(status->GetHResult(1), S_OK, where); + check(std::memcmp(at + 0x1000, source.data(), 4096) == 0, where); + guard(); + DSTORAGE_REQUEST bc{}; + bc.Options.AsUINT64 = options::kSourceMemory | (packed.codec << options::kBcpackShift); + bc.Source = packed.raw.data(); + bc.SourceSize = static_cast(packed.raw.size()); + bc.Destination = at + 0x2000; + bc.DestinationSize = static_cast(packed.plain.size()); + memory->EnqueueRequest(&bc); + memory->EnqueueStatus(status, 2); + memory->Submit(); + check(wait_complete(status, 2), where); + check_hr(status->GetHResult(2), S_OK, where); + check(std::equal(packed.plain.begin(), packed.plain.end(), at + 0x2000), where); + }; + + // 1. A geometry tile. + auto* tile = static_cast(VirtualAlloc(nullptr, gw::tile_size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); + check(tile != nullptr && packed.plain.size() <= gw::tile_size - 0x2000, "a geometry tile for the destinations"); + if (tile) { + const auto va = reinterpret_cast(tile); + gw::Cell* cell = gw::acquire(va); + kw::set_opener([](uintptr_t from, uintptr_t to) { gw::notify(from, to, gw::Event::open); }); + const auto version = cell->version.load(); + run(tile, [&] { gw::arm(va, *cell); }, "a request into an armed geometry tile"); + check(cell->version.load() != version, "the geometry tile counts as written"); + kw::set_opener(nullptr); + gw::release(va); + VirtualFree(tile, 0, MEM_RELEASE); + } + + // 2. An xmem physical page read-only with no guard to answer for it. + using Reserve = void*(WINAPI*)(void*, SIZE_T, DWORD, ULONGLONG, DWORD); + using Allocate = BOOL(WINAPI*)(uint64_t, uint64_t*, uint64_t*); + using Free = BOOL(WINAPI*)(uint64_t, const uint64_t*); + using Map = void*(WINAPI*)(void*, uint64_t, const uint64_t*); + const auto reserve = reinterpret_cast(rt::shims::find("xmem.dll", "XMemVirtualAlloc")); + const auto allocate = reinterpret_cast(rt::shims::find("xmem.dll", "XMemAllocatePhysicalPages")); + const auto free_pages = reinterpret_cast(rt::shims::find("xmem.dll", "XMemFreePhysicalPages")); + const auto map = reinterpret_cast(rt::shims::find("xmem.dll", "XMemMapPhysicalPages")); + auto* window = reserve ? static_cast(reserve(nullptr, 0x10000, MEM_RESERVE | 0x20400000, 0x23, + PAGE_READWRITE)) : nullptr; + uint64_t page = 0, count = 1; + check(window && allocate && allocate(0x280, &count, &page) && map && map(window, 1, &page) == window, + "an xmem physical page for the destinations"); + if (window && count == 1) { + for (size_t i = 0; i < 0x10000; i += 0x1000) window[i] = 0; // committed + kw::set_unguarder(&rt::xmem::reopen_unowned); + run(window, [&] { + DWORD old = 0; + VirtualProtect(window, 0x10000, PAGE_READONLY, &old); + }, "a request into an xmem page left read-only"); + kw::set_unguarder(nullptr); + map(window, 1, nullptr); + free_pages(1, &page); + } + status->Release(); + memory->Release(); + files->Release(); + file->Release(); +} + void test_extended(Env& env) { auto* q = make_queue(env, 0x80, false, DSTORAGE_REQUEST_SOURCE_MEMORY, DSTORAGE_PRIORITY_REALTIME); auto* status = make_status(env, 1); @@ -1566,6 +1668,7 @@ int main() { test_stats_timing(env); test_stats(env); test_extended(env); + test_guarded_destinations(env); test_zlib(env); // after test_stats, whose request totals it would change fs::remove_all(env.root, ec); diff --git a/runtime/test/geometry_views_test.cpp b/runtime/test/geometry_views_test.cpp new file mode 100644 index 0000000000..920283f41c --- /dev/null +++ b/runtime/test/geometry_views_test.cpp @@ -0,0 +1,166 @@ +// rt::d3d12::GeometryViews (runtime/shims/d3d12_geometry_views.h): device-local copies of the title's geometry, kept +// up to date from 64 KiB tiles of the title's pages that are watched for writes. A fake Vulkan device gives the copies +// host memory. No game data, no GPU. +// 1. a new view is copied whole; +// 2. a write into one tile of a 1 MiB view (16 tiles) copies that tile's 64 KiB again, not the view; +// 3. a write into a tile two views share is read once and copied into both; +// 4. two written tiles of one view are two tile copies (LEONIDA_GEOMETRY_WHOLE_VIEWS=1, whole views, fails 2-4). +#include + +#include +#include +#include +#include +#include + +#include "../shims/d3d12_geometry_views.h" + +namespace { + +int g_checks = 0; +int g_failures = 0; + +void check(bool condition, const char* what) { + ++g_checks; + std::printf("%s %s\n", condition ? "PASS" : "FAIL", what); + if (!condition) ++g_failures; +} + +// The Vulkan calls TitleBufferWindows::allocate makes, over host memory. +struct FakeBuffer { + VkDeviceSize size = 0; + void* memory = nullptr; +}; +VKAPI_ATTR VkResult VKAPI_CALL create_buffer(VkDevice, const VkBufferCreateInfo* info, const VkAllocationCallbacks*, + VkBuffer* out) { + auto* b = new FakeBuffer{info->size}; + *out = reinterpret_cast(b); + return VK_SUCCESS; +} +VKAPI_ATTR void VKAPI_CALL requirements(VkDevice, VkBuffer buffer, VkMemoryRequirements* out) { + *out = {}; + out->size = reinterpret_cast(buffer)->size; + out->alignment = 65536; + out->memoryTypeBits = 1; +} +VKAPI_ATTR VkResult VKAPI_CALL bind(VkDevice, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize) { + reinterpret_cast(buffer)->memory = memory; + return VK_SUCCESS; +} +VKAPI_ATTR VkResult VKAPI_CALL map(VkDevice, VkDeviceMemory memory, VkDeviceSize, VkDeviceSize, VkMemoryMapFlags, + void** out) { + *out = memory; + return VK_SUCCESS; +} +VKAPI_ATTR void VKAPI_CALL unmap(VkDevice, VkDeviceMemory) {} +VKAPI_ATTR VkDeviceAddress VKAPI_CALL address(VkDevice, const VkBufferDeviceAddressInfo* info) { + return VkDeviceAddress(reinterpret_cast(reinterpret_cast(info->buffer)->memory)); +} +VKAPI_ATTR void VKAPI_CALL destroy_buffer(VkDevice, VkBuffer buffer, const VkAllocationCallbacks*) { + delete reinterpret_cast(buffer); +} +VKAPI_ATTR void VKAPI_CALL free_memory(VkDevice, VkDeviceMemory memory, const VkAllocationCallbacks*) { + VirtualFree(memory, 0, MEM_RELEASE); +} + +struct FakeDevice { + struct { + PFN_vkCreateBuffer vkCreateBuffer = create_buffer; + PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements = requirements; + PFN_vkBindBufferMemory vkBindBufferMemory = bind; + PFN_vkMapMemory vkMapMemory = map; + PFN_vkUnmapMemory vkUnmapMemory = unmap; + PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress = address; + PFN_vkDestroyBuffer vkDestroyBuffer = destroy_buffer; + PFN_vkFreeMemory vkFreeMemory = free_memory; + } vk_; + struct { + decltype(vk_)& vk; + } context_{vk_}; + decltype(context_)* context = &context_; + struct { + VkDevice device = VK_NULL_HANDLE; + } info; + struct { + VkDeviceAddress address = 0; + } arena; + void share(VkBufferCreateInfo&) {} + VkDeviceMemory allocate(const VkMemoryRequirements& r, VkMemoryPropertyFlags required, + VkMemoryPropertyFlags preferred, VkMemoryPropertyFlags* chosen, bool) { + if (chosen) *chosen = required | preferred; + return reinterpret_cast(VirtualAlloc(nullptr, r.size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)); + } +}; + +// What the views copy, through the same readability check the device makes. +std::vector g_copies; +rt::d3d12::GeometryCopy copy(std::uint8_t* to, const std::uint8_t* from, std::size_t size) { + g_copies.push_back(size); + std::memcpy(to, from, size); + return rt::d3d12::GeometryCopy::copied; +} + +// The title writes into a watched tile: reopened (as the write-fault handler does), then written. +void title_write(std::uintptr_t at, std::uint8_t value) { + namespace watch = leonida::geometry_writes; + watch::notify(at, at + 1, watch::Event::fault); + *reinterpret_cast(at) = value; +} + +} // namespace + +int main() { + _putenv_s("LEONIDA_GEOMETRY_MB", "64"); + constexpr std::size_t kTile = 65536, kView = 16 * kTile; + auto* title = static_cast(VirtualAlloc(nullptr, 2 * kView, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)); + if (!title) return 1; + for (std::size_t i = 0; i < 2 * kView; ++i) title[i] = std::uint8_t(i * 7); + const auto base = reinterpret_cast(title); + + FakeDevice device; + rt::d3d12::GeometryViews views; + g_copies.clear(); + const std::uint64_t va = views.resolve(device, base, kView, copy); + check(va != 0 && g_copies.size() == 1 && g_copies[0] == kView, "a new 1 MiB view is copied whole"); + std::uint64_t host = 0, bytes = 0; + bool populated = false; + check(views.lookup(device.arena.address + va, host, bytes, nullptr, &populated) && populated && bytes == kView, + "the copy is found by its device address"); + auto* copy_bytes = reinterpret_cast(host); + check(!std::memcmp(copy_bytes, title, kView), "the copy holds the title's bytes"); + + // 2. One write in tile 5. + g_copies.clear(); + views.refresh(copy); + check(g_copies.empty(), "a refresh with nothing written copies nothing"); + title_write(base + 5 * kTile + 123, 0xab); + views.refresh(copy); + check(g_copies.size() == 1 && g_copies[0] == kTile, "one write copies its 64 KiB tile again, not the 1 MiB view"); + check(copy_bytes[5 * kTile + 123] == 0xab && !std::memcmp(copy_bytes, title, kView), + "the copy has the new byte and the rest unchanged"); + + // 3. A second view over tiles 8..23 shares tiles 8..15 with the first: a write in tile 10 reaches both. + const std::uint64_t va2 = views.resolve(device, base + 8 * kTile, kView, copy); + check(va2 != 0, "a second view over half of the first one's tiles"); + std::uint64_t host2 = 0; + views.lookup(device.arena.address + va2, host2, bytes); + g_copies.clear(); + title_write(base + 10 * kTile + 9, 0xcd); + views.refresh(copy); + check(g_copies.size() == 1 && g_copies[0] == kTile, + "a write in a shared tile reads that tile from the title's pages once for both views"); + check(copy_bytes[10 * kTile + 9] == 0xcd && reinterpret_cast(host2)[2 * kTile + 9] == 0xcd, + "both copies see it"); + + // 4. Writes in two tiles of one view: two tile copies. + g_copies.clear(); + title_write(base + 1 * kTile, 1); + title_write(base + 3 * kTile + kTile - 1, 2); + views.refresh(copy); + check(g_copies.size() == 2 && g_copies[0] == kTile && g_copies[1] == kTile, "two written tiles, two tile copies"); + check(!std::memcmp(copy_bytes, title, kView), "the copy matches the title's pages"); + + views.release(device); + std::printf("%d checks, %d failures\n", g_checks, g_failures); + return g_failures ? 1 : 0; +} diff --git a/runtime/test/glsl/aftermath_fault.comp b/runtime/test/glsl/aftermath_fault.comp new file mode 100644 index 0000000000..5b6f2feb7d --- /dev/null +++ b/runtime/test/glsl/aftermath_fault.comp @@ -0,0 +1,20 @@ +#version 460 +// vk_aftermath_test: every invocation writes through the buffer device address in the push constants. The test passes +// an address no buffer is bound to, so the store page-faults and the device is lost (no hang, no TDR). +#extension GL_EXT_buffer_reference : require +#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require + +layout(local_size_x = 64) in; + +layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { + uint v[]; +}; + +layout(push_constant) uniform Push { + uint64_t address; +} pc; + +void main() { + Words words = Words(pc.address); + words.v[gl_GlobalInvocationID.x * 1024u] = gl_GlobalInvocationID.x + 1u; +} diff --git a/runtime/test/glsl/cs_null_descriptors.comp b/runtime/test/glsl/cs_null_descriptors.comp new file mode 100644 index 0000000000..6e64e93af2 --- /dev/null +++ b/runtime/test/glsl/cs_null_descriptors.comp @@ -0,0 +1,110 @@ +#version 460 +// Null descriptors of every kind through the bindless set 0 (src/vulkan_bindless.h), for vk_null_descriptor_test. +// The shader finds its images the way translated shaders do (tools/rdna2spirv.py desc_probe; docs/design.md, +// "Images"): FNV-1a over the eight key dwords, eight probes of the table at binding 2, a miss is index 0, and it uses +// that index in the binding of the instruction's own dimension. The keys come from the test (set 1 binding 1): +// key 0: all zeros (a null T#), key 1: a 3D T# no image answers, key 2: a cube T# (read through the 2D-array +// binding, as the translator reads cubes), key 3: a 1D T#, key 4: the T# of a real 2D image, key 5: a zero S#. +// pc.mode 0 stores and adds through the storage fallbacks (a null UAV); mode 1 reads everything back. Result words +// (set 1 binding 0), each vec4 as four uints: +// 0..5 the index each key finds; 8, 9: what the 2D and 3D r32ui atomics of mode 0 returned; +// 16.. sampled fetches: 2D, 2D array, 3D, 1D, then the real 2D image; 36.. sampled with the found sampler: +// 2D, cube (layer 3, clamped), 3D, 1D; 64.. storage loads (2D, 2D array, 3D, 1D) x (float, uint, sint); +// 112, 113: the 2D and 3D atomics of mode 1. +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require + +layout(local_size_x = 1) in; + +layout(push_constant) uniform Mode { uint mode; } pc; + +layout(set = 0, binding = 0) uniform texture2D images[]; +layout(set = 0, binding = 1) uniform sampler samplers[]; +layout(set = 0, binding = 2, std430) readonly buffer DescriptorMap { uint map[]; }; +layout(set = 0, binding = 3) uniform texture2DArray layers[]; +layout(set = 0, binding = 5) uniform texture1D lines[]; +layout(set = 0, binding = 6) uniform texture3D volumes[]; +layout(set = 0, binding = 4, r32ui) uniform uimage2D atomics_2d[]; +layout(set = 0, binding = 7, r32ui) uniform uimage3D atomics_3d[]; +layout(set = 0, binding = 8, rgba8) uniform image2D store_2d_f[]; +layout(set = 0, binding = 9, r32ui) uniform uimage2D store_2d_u[]; +layout(set = 0, binding = 10, r32i) uniform iimage2D store_2d_i[]; +layout(set = 0, binding = 11, rgba8) uniform image2DArray store_arr_f[]; +layout(set = 0, binding = 12, r32ui) uniform uimage2DArray store_arr_u[]; +layout(set = 0, binding = 13, r32i) uniform iimage2DArray store_arr_i[]; +layout(set = 0, binding = 14, rgba8) uniform image3D store_3d_f[]; +layout(set = 0, binding = 15, r32ui) uniform uimage3D store_3d_u[]; +layout(set = 0, binding = 16, r32i) uniform iimage3D store_3d_i[]; +layout(set = 0, binding = 17, rgba8) uniform image1D store_1d_f[]; +layout(set = 0, binding = 18, r32ui) uniform uimage1D store_1d_u[]; +layout(set = 0, binding = 19, r32i) uniform iimage1D store_1d_i[]; + +layout(set = 1, binding = 0, std430) buffer Result { uint result[]; }; +layout(set = 1, binding = 1, std430) readonly buffer Keys { uint keys[]; }; // 6 keys of 8 words + +uint lookup(uint which) { + uint h = 2166136261u; + for (uint i = 0; i < 8; ++i) h = (h ^ keys[which * 8 + i]) * 16777619u; + const uint mask = map[0]; + for (uint k = 0; k < 8; ++k) { + const uint slot = 1 + ((h + k) & mask) * 10; + bool same = true; + for (uint i = 0; i < 8; ++i) same = same && map[slot + i] == keys[which * 8 + i]; + if (same) return map[slot + 8]; + } + return 0; +} + +void put(uint at, vec4 v) { + for (int c = 0; c < 4; ++c) result[at + c] = floatBitsToUint(v[c]); +} +void put(uint at, uvec4 v) { + for (int c = 0; c < 4; ++c) result[at + c] = v[c]; +} + +void main() { + const uint zero = lookup(0), volume = lookup(1), cube = lookup(2), line = lookup(3), real = lookup(4); + const uint smp = lookup(5); + if (pc.mode == 0) { + for (uint k = 0; k < 6; ++k) result[k] = lookup(k); + // A null UAV of each dimension and class: on the console these stores are dropped. + imageStore(store_2d_f[zero], ivec2(0), vec4(1.0, 0.5, 0.25, 1.0)); + imageStore(store_2d_u[zero], ivec2(0), uvec4(0xA1u)); + imageStore(store_2d_i[zero], ivec2(0), ivec4(-0xA2)); + imageStore(store_arr_f[cube], ivec3(0), vec4(1.0)); + imageStore(store_arr_u[cube], ivec3(0), uvec4(0xB1u)); + imageStore(store_arr_i[cube], ivec3(0), ivec4(-0xB2)); + imageStore(store_3d_f[volume], ivec3(0), vec4(1.0)); + imageStore(store_3d_u[volume], ivec3(0), uvec4(0xC1u)); + imageStore(store_3d_i[volume], ivec3(0), ivec4(-0xC2)); + imageStore(store_1d_f[line], 0, vec4(1.0)); + imageStore(store_1d_u[line], 0, uvec4(0xD1u)); + imageStore(store_1d_i[line], 0, ivec4(-0xD2)); + result[8] = imageAtomicAdd(atomics_2d[zero], ivec2(0), 5u); + result[9] = imageAtomicAdd(atomics_3d[volume], ivec3(0), 7u); + return; + } + put(16, texelFetch(images[zero], ivec2(0), 0)); + put(20, texelFetch(layers[cube], ivec3(0), 0)); + put(24, texelFetch(volumes[volume], ivec3(0), 0)); + put(28, texelFetch(lines[line], 0, 0)); + put(32, texelFetch(images[real], ivec2(0), 0)); + put(36, textureLod(sampler2D(images[zero], samplers[smp]), vec2(0.75, 0.25), 0.0)); + put(40, textureLod(sampler2DArray(layers[cube], samplers[smp]), vec3(0.5, 0.5, 3.0), 0.0)); + put(44, textureLod(sampler3D(volumes[volume], samplers[smp]), vec3(0.5), 0.0)); + put(48, textureLod(sampler1D(lines[line], samplers[smp]), 0.5, 0.0)); + put(64, imageLoad(store_2d_f[zero], ivec2(0))); + put(68, imageLoad(store_2d_u[zero], ivec2(0))); + put(72, uvec4(imageLoad(store_2d_i[zero], ivec2(0)))); + put(76, imageLoad(store_arr_f[cube], ivec3(0))); + put(80, imageLoad(store_arr_u[cube], ivec3(0))); + put(84, uvec4(imageLoad(store_arr_i[cube], ivec3(0)))); + put(88, imageLoad(store_3d_f[volume], ivec3(0))); + put(92, imageLoad(store_3d_u[volume], ivec3(0))); + put(96, uvec4(imageLoad(store_3d_i[volume], ivec3(0)))); + put(100, imageLoad(store_1d_f[line], 0)); + put(104, imageLoad(store_1d_u[line], 0)); + put(108, uvec4(imageLoad(store_1d_i[line], 0))); + result[112] = imageAtomicAdd(atomics_2d[zero], ivec2(0), 5u); + result[113] = imageAtomicAdd(atomics_3d[volume], ivec3(0), 7u); +} diff --git a/runtime/test/glsl/cs_user_data.comp b/runtime/test/glsl/cs_user_data.comp index a04b23c9f5..6029eddfb6 100644 --- a/runtime/test/glsl/cs_user_data.comp +++ b/runtime/test/glsl/cs_user_data.comp @@ -38,6 +38,12 @@ Words at(uvec2 va) { void main() { const uint i = gl_GlobalInvocationID.x; Words result = at(uvec2(pc.s[6], pc.s[7])); + if (pc.s[5] == 0xFFFFFFFBu) { + // Inspect descriptor words without dereferencing a possibly invalid address. + Words view = at(uvec2(pc.s[8], 0u)); + result.w[i] = view.w[i % 4u]; + return; + } if (pc.s[5] == 0xFFFFFFFCu) { // Direct resource indexing. The explicit table is unrelated; the heap follows it at s9. uint value = 0u; diff --git a/runtime/test/glsl/ms_user_data_window.mesh b/runtime/test/glsl/ms_user_data_window.mesh new file mode 100644 index 0000000000..04e1112445 --- /dev/null +++ b/runtime/test/glsl/ms_user_data_window.mesh @@ -0,0 +1,29 @@ +#version 460 +// The mesh-stage fixture shares the graphics user-data block with the vertex and pixel stages. A translated mesh +// shader maps root-window dword i to s(i+8); the layer supplies the heap dwords once after the explicit arguments. +// With three root constants at s8..s10, the shared fixture reads the resource and sampler dwords at s11 and s12. +// It hands them to its pixel shader, which writes them to the first render target. One triangle covers the draw's 1x1 viewport. +#extension GL_EXT_mesh_shader : require + +layout(local_size_x = 32) in; +layout(triangles, max_vertices = 3, max_primitives = 1) out; + +layout(location = 0) out uvec4 out_words[]; + +layout(push_constant) uniform UserData { + uint s[32]; + uvec2 heap_base; + uvec2 code_base; +} pc; + +void main() { + SetMeshOutputsEXT(3, 1); + const uint i = gl_LocalInvocationIndex; + if (i < 3) { + const vec2 corner = vec2(float(i & 1u), float(i >> 1)); // (0,0), (1,0), (0,1): a full-screen triangle + gl_MeshVerticesEXT[i].gl_Position = vec4(corner * 4.0 - 1.0, 0.0, 1.0); + // The heaps the mesh stage read, then 'MS' as a marker that these words came from it. + out_words[i] = uvec4(pc.s[11], pc.s[12], 0x4d53u, 0u); + } + if (i == 0) gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0, 1, 2); +} diff --git a/runtime/test/glsl/ps_indirect_heap_resource.frag b/runtime/test/glsl/ps_indirect_heap_resource.frag new file mode 100644 index 0000000000..8eeae8615b --- /dev/null +++ b/runtime/test/glsl/ps_indirect_heap_resource.frag @@ -0,0 +1,26 @@ +#version 460 +#extension GL_EXT_buffer_reference : require +#extension GL_EXT_buffer_reference_uvec2 : require +// Positive authored fixture. The heap word comes from the directly-indexed signature, not a root table. +// Require the fixture's expected heap and resource addresses before following either reference. +layout(location=0) flat in uvec4 vs_words; +layout(location=0) out uvec4 vs_target; +layout(location=1) out uvec4 ps_target; +layout(push_constant) uniform UserData { uint s[32]; uvec2 heap_base; uvec2 code_base; } pc; +layout(buffer_reference, std430, buffer_reference_align=4) readonly buffer Words { uint w[]; }; +uvec2 add64(uvec2 a, uvec2 b) { + uint carry; + uint lo=uaddCarry(a.x,b.x,carry); + return uvec2(lo,a.y+b.y+carry); +} +void main() { + vs_target=vs_words; + ps_target=uvec4(0xddddddddu); + uint heap=pc.s[11]; + if (heap==0u || heap!=pc.s[8]) return; + Words srv=Words(add64(pc.heap_base,uvec2(heap+32u,0u))); // descriptor slot 1, not slot 0 + uvec2 va=uvec2(srv.w[0],uint(int(srv.w[1]<<16u)>>16)); + if (srv.w[2]<16u || va!=uvec2(pc.s[9],pc.s[10])) return; + Words input_words=Words(add64(pc.heap_base,va)); + ps_target=uvec4(input_words.w[0],input_words.w[1],input_words.w[2],input_words.w[3]); +} diff --git a/runtime/test/glsl/ps_mesh_user_data_window.frag b/runtime/test/glsl/ps_mesh_user_data_window.frag new file mode 100644 index 0000000000..a399849e69 --- /dev/null +++ b/runtime/test/glsl/ps_mesh_user_data_window.frag @@ -0,0 +1,19 @@ +#version 460 +// The pixel shader of the mesh draw in d3d12_graphics_direct_heaps_test: render target 0 gets the heap dwords the +// mesh stage read (its own window at s19/s20, 8 dwords above the vertex and pixel base), render target 1 the pixel +// stage's (s11/s12), so one draw shows both stages of the same mesh pipeline received their heaps. + +layout(location = 0) flat in uvec4 mesh_words; +layout(location = 0) out uvec4 mesh_target; +layout(location = 1) out uvec4 ps_target; + +layout(push_constant) uniform UserData { + uint s[32]; + uvec2 heap_base; + uvec2 code_base; +} pc; + +void main() { + mesh_target = mesh_words; + ps_target = uvec4(pc.s[11], pc.s[12], 0u, 0u); +} diff --git a/runtime/test/guarded_copy_test.cpp b/runtime/test/guarded_copy_test.cpp new file mode 100644 index 0000000000..69326d41de --- /dev/null +++ b/runtime/test/guarded_copy_test.cpp @@ -0,0 +1,99 @@ +// src/guarded_copy.h: a copy made in a __try frame turns an access violation into an error, under Wine too. +// +// Each helper reads from a reserved, never committed page inside a __try and must land in the __except. Then +// leonida::guarded::move is checked against memmove for every overlap direction and a range of sizes and offsets, +// and copy and read_word for plain values. +// +// guarded_copy_test --crt makes the same read with the CRT's memcpy instead. Under Wine the fault raised inside +// ucrtbase does not reach the __except and the process ends (exit 5 under Proton Experimental, Wine 11.0); on Windows +// it is caught. Not registered with CTest: it shows why the helpers exist. +#include "../src/guarded_copy.h" + +#include + +#include +#include +#include + +namespace { + +unsigned checks = 0, failures = 0; +void expect(bool ok, const char* what) { + ++checks; + if (!ok) { + ++failures; + std::fprintf(stderr, "FAIL: %s\n", what); + } +} + +enum class How { copy, move, word, crt }; + +bool read_guarded(unsigned char* to, const unsigned char* from, std::size_t bytes, How how) { + __try { + switch (how) { + case How::copy: leonida::guarded::copy(to, from, bytes); break; + case How::move: leonida::guarded::move(to, from, bytes); break; + case How::word: to[0] = static_cast(leonida::guarded::read_word(from)); break; + case How::crt: std::memcpy(to, from, bytes); break; + } + return true; + } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return false; + } +} + +} // namespace + +int main(int argc, char** argv) { + // 64 KiB reserved and never committed: every read of it faults. + auto* reserved = static_cast(VirtualAlloc(nullptr, 1 << 16, MEM_RESERVE, PAGE_READWRITE)); + if (!reserved) return std::fprintf(stderr, "VirtualAlloc failed\n"), 1; + static unsigned char out[8192]; + + if (argc > 1 && !std::strcmp(argv[1], "--crt")) { + const bool ok = read_guarded(out, reserved, sizeof out, How::crt); + std::printf("guarded_copy_test --crt: the CRT's memcpy from a reserved page %s\n", + ok ? "returned (no fault?)" : "was caught by __except"); + return 0; + } + + expect(!read_guarded(out, reserved, sizeof out, How::copy), "a fault in guarded::copy reaches the __except"); + expect(!read_guarded(out, reserved, sizeof out, How::move), "a fault in guarded::move reaches the __except"); + expect(!read_guarded(out, reserved, 8, How::word), "a fault in guarded::read_word reaches the __except"); + // A fault part-way: the first page readable, the next one not. + auto* half = static_cast(VirtualAlloc(nullptr, 2 * 4096, MEM_RESERVE, PAGE_READWRITE)); + expect(half && VirtualAlloc(half, 4096, MEM_COMMIT, PAGE_READWRITE), "commit one page of two"); + if (half) { + std::memset(half, 0x5a, 4096); + expect(!read_guarded(out, half + 2048, 4096, How::copy), "a copy that runs into an uncommitted page faults"); + expect(out[0] == 0x5a && out[2047] == 0x5a, "the bytes before the fault were copied"); + VirtualFree(half, 0, MEM_RELEASE); + } + + // memmove semantics, both overlap directions, every small size and a few offsets. + std::vector a(1024), b(1024); + for (std::size_t size : {0u, 1u, 7u, 8u, 15u, 64u, 255u, 600u}) { + for (std::ptrdiff_t shift : {-33, -8, -1, 1, 8, 33, 0}) { + for (std::size_t i = 0; i < a.size(); ++i) a[i] = b[i] = static_cast(i * 31 + size); + const std::size_t from = 200; + const std::size_t to = static_cast(static_cast(from) + shift); + std::memmove(b.data() + to, b.data() + from, size); + expect(read_guarded(a.data() + to, a.data() + from, size, How::move), "move of readable bytes succeeds"); + expect(a == b, "guarded::move matches memmove"); + } + } + unsigned char src[300], dst[300] = {}; + for (int i = 0; i < 300; ++i) src[i] = static_cast(i ^ 0xa5); + expect(read_guarded(dst, src, sizeof src, How::copy) && !std::memcmp(dst, src, sizeof src), "guarded::copy copies"); + const std::uintptr_t word = 0x1122334455667788ull; + expect(leonida::guarded::read_word(&word) == word, "guarded::read_word reads the word"); + + VirtualFree(reserved, 0, MEM_RELEASE); + if (failures) { + std::fprintf(stderr, "guarded_copy_test: %u of %u checks failed\n", failures, checks); + return 1; + } + std::printf("guarded_copy_test: %u checks passed\n", checks); + return 0; +} diff --git a/runtime/test/indirect_clamp_test.cpp b/runtime/test/indirect_clamp_test.cpp new file mode 100644 index 0000000000..3f34d4c43a --- /dev/null +++ b/runtime/test/indirect_clamp_test.cpp @@ -0,0 +1,385 @@ +// GPU test for runtime/src/vulkan_indirect_clamp.h: the D3D12 ExecuteIndirect argument clamp. +// +// - in-range records of every kind (draw, draw indexed, dispatch, mesh dispatch) come back bit-identical, and the +// pass counts nothing as clamped; +// - a garbage record is bounded (2^24 vertices, 2^26 vertex instances, 65 535 groups per dimension, 2^20 groups per +// dispatch) instead of asking for billions of groups; +// - a counted batch clamps the count to max_command_count and empties the records past it; +// - a batch whose records fit but whose total work passes the 2^27 budget runs all but the records that no longer +// fit, so thousands of garbage records cannot run for seconds. +// +// A record that asks for billions of groups or vertices would run until the host resets the driver, so this test is +// about the values the pass writes, never about running such a dispatch here: every case ends in a copy of the +// clamped scratch back to the host. No game data. Run with LEONIDA_VK_VALIDATION=1 to count VUIDs. +#ifndef VK_NO_PROTOTYPES +#define VK_NO_PROTOTYPES +#endif +#include "vk_test_device.h" + +#include "../src/vulkan_indirect_clamp.h" + +#include +#include +#include +#include +#include + +namespace { + +int failures = 0; + +#define CHECK(cond) \ + do { \ + if (!(cond)) { \ + std::fprintf(stderr, "line %d: CHECK failed: %s\n", __LINE__, #cond); \ + ++failures; \ + } \ + } while (0) + +// The clamped records and the pass's counters of one ExecuteIndirect call. +struct Clamped { + std::vector records; // records_out, `records` * words + std::uint32_t count = 0; // the clamped count word + leonida::IndirectArgumentClamp::Counters counters{}; // what this call added +}; + +struct Env { + vktest::Device& device; + leonida::IndirectArgumentClamp& clamp; + // Host-visible argument, count and readback buffers, one set reused by every case. + VkBuffer arguments = VK_NULL_HANDLE; + void* arguments_map = nullptr; + VkBuffer counts = VK_NULL_HANDLE; + void* counts_map = nullptr; + VkBuffer readback = VK_NULL_HANDLE; + void* readback_map = nullptr; + VkDeviceSize argument_bytes = 4096, readback_bytes = 4096; + + // Runs one clamp call as a submission of its own: `records` argument records of `kind` at `stride` bytes, with + // `count_value` bounding them when given. Reads the clamped scratch back once the queue is idle, and the + // counters once that call's batch has been released, exactly as a completed submission does. + bool run(std::uint32_t kind, std::uint32_t stride, std::uint32_t records, std::uint32_t words, + const std::uint32_t* values, const std::uint32_t* count_value, Clamped& out) { + std::memset(arguments_map, 0, size_t(argument_bytes)); + for (std::uint32_t r = 0; r < records; ++r) + std::memcpy(static_cast(arguments_map) + r * stride, values + r * words, words * 4); + if (count_value) std::memcpy(counts_map, count_value, 4); + std::memset(readback_map, 0xcd, size_t(readback_bytes)); + const auto before = clamp.counters(); + { + auto batch = clamp.batch(); + leonida::ClampedIndirect job{}; + if (!batch->prepare(arguments, 0, count_value ? counts : VK_NULL_HANDLE, 0, kind, stride, records, job)) + return false; + const bool ok = device.run([&](VkCommandBuffer cb) { + clamp.emit(cb, job); + // The clamp's last barrier orders its writes before anything that follows, this copy included. The + // records start the slice; a counted call has its clamped count word after them. + const VkDeviceSize end = count_value ? job.count_offset + sizeof(std::uint32_t) + : job.offset + VkDeviceSize(records) * job.stride; + VkBufferCopy copy{job.offset, 0, end - job.offset}; + device.fn("vkCmdCopyBuffer")(cb, job.buffer, readback, 1, ©); + VkMemoryBarrier host{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + host.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + host.dstAccessMask = VK_ACCESS_HOST_READ_BIT; + device.fn("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &host, 0, + nullptr, 0, nullptr); + return true; + }); + if (!ok) return false; + const auto* words_out = static_cast(readback_map); + out.count = count_value ? words_out[(job.count_offset - job.offset) / 4] : 0; + out.records.assign(words_out, words_out + records * job.stride / 4); + } + const auto after = clamp.counters(); + out.counters.calls = after.calls - before.calls; + out.counters.records = after.records - before.records; + out.counters.records_clamped = after.records_clamped - before.records_clamped; + out.counters.counts_clamped = after.counts_clamped - before.counts_clamped; + out.counters.over_budget = after.over_budget - before.over_budget; + // The scratch is idle once the queue is; hand it back for the next case like a completed submission does. + clamp.retire(VK_NULL_HANDLE, 0); + clamp.collect(); + return true; + } +}; + +// The words of one record in the clamped output, as the replay would hand them to Vulkan. +std::vector record(const Clamped& c, std::uint32_t index, std::uint32_t words) { + return {c.records.begin() + index * words, c.records.begin() + (index + 1) * words}; +} + +bool all_zero(const std::vector& words) { + return std::all_of(words.begin(), words.end(), [](std::uint32_t w) { return w == 0; }); +} + +} // namespace + +int main() { + vktest::Device device; + device.request_buffer_device_address = true; + if (!device.create()) { + std::printf("indirect_clamp_test: SKIP (no Vulkan device)\n"); + return 77; + } + VkPhysicalDeviceProperties properties{}; + device.instance_fn("vkGetPhysicalDeviceProperties")(device.physical, + &properties); + VkPhysicalDeviceMemoryProperties memory{}; + device.instance_fn("vkGetPhysicalDeviceMemoryProperties")( + device.physical, &memory); + // Device-local memory with a device address, as gta6rt allocates the clamp's record scratch. + const auto allocate = [&](const VkMemoryRequirements& requirements) -> VkDeviceMemory { + VkMemoryAllocateFlagsInfo flags{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO}; + flags.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT; + VkMemoryAllocateInfo info{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, &flags}; + info.allocationSize = requirements.size; + for (const std::uint32_t type : leonida::memory_type_order( + memory, requirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0, requirements.size)) { + info.memoryTypeIndex = type; + VkDeviceMemory out = VK_NULL_HANDLE; + if (device.fn("vkAllocateMemory")(device.device, &info, nullptr, &out) == VK_SUCCESS) + return out; + } + return VK_NULL_HANDLE; + }; + leonida::IndirectArgumentClamp clamp(device.device_proc, device.device, memory, properties.limits, allocate); + if (!clamp.loaded()) { + std::printf("indirect_clamp_test: SKIP (no bufferDeviceAddress or no compute)\n"); + return 77; + } + + Env env{device, clamp}; + const VkBufferUsageFlags usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; + env.arguments = device.buffer(env.argument_bytes, usage, &env.arguments_map); + env.counts = device.buffer(env.argument_bytes, usage, &env.counts_map); + env.readback = device.buffer(env.readback_bytes, VK_BUFFER_USAGE_TRANSFER_DST_BIT, &env.readback_map); + CHECK(env.arguments && env.arguments_map && env.counts && env.counts_map && env.readback && env.readback_map); + if (failures) return 1; + + // 1. A draw of 5 vertices in 2 instances: every word comes back untouched. + { + const std::uint32_t values[4] = {5, 2, 7, 3}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw, 16, 1, 4, values, nullptr, out)); + CHECK(record(out, 0, 4) == std::vector(values, values + 4)); + CHECK(out.counters.records_clamped == 0 && out.counters.counts_clamped == 0); + } + + // 2. A draw that asks for four billion vertices in four billion instances is cut to 2^24 vertices, and the + // instances to what keeps count * instances within 2^26. + { + const std::uint32_t values[4] = {0xFFFFFFF0u, 0xFFFFFFFFu, 4, 6}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw, 16, 1, 4, values, nullptr, out)); + const auto words = record(out, 0, 4); + CHECK(words[0] == leonida::indirect_clamp_max_vertices); + CHECK(words[1] == leonida::indirect_clamp_max_vertex_instances / leonida::indirect_clamp_max_vertices); + CHECK(words[2] == 4 && words[3] == 6); + CHECK(out.counters.records_clamped == 1); + } + + // 3. A counted draw: the count is clamped to max_command_count, and the records past min(count, max) are empty. + { + std::uint32_t values[4 * 4] = {}; + for (std::uint32_t r = 0; r < 4; ++r) { + values[r * 4 + 0] = 3 * (r + 1); + values[r * 4 + 1] = 1; + values[r * 4 + 2] = r; + values[r * 4 + 3] = 0; + } + const std::uint32_t count = 2; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw, 16, 4, 4, values, &count, out)); + CHECK(out.count == 2); + CHECK(record(out, 0, 4)[0] == 3 && record(out, 1, 4)[0] == 6); + CHECK(all_zero(record(out, 2, 4)) && all_zero(record(out, 3, 4))); + CHECK(out.counters.counts_clamped == 0); // 2 is a count within max_command_count: nothing to clamp + CHECK(out.counters.records_clamped == 0); // the emptied tail is not a clamped value + } + + // 3b. A count larger than max_command_count is clamped to it: a *Count draw never reads a count past its records + // (VUID-vkCmdDrawIndirectCount-countBuffer-02717). + { + const std::uint32_t values[4] = {3, 1, 0, 0}; + const std::uint32_t count = 0x7FFFFFFFu; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw, 16, 1, 4, values, &count, out)); + CHECK(out.count == 1); + CHECK(out.counters.counts_clamped == 1); + } + + // 4. An indexed draw keeps its two locations and its first instance, and bounds its index count. + { + const std::uint32_t values[5] = {0xFFFFFFFFu, 0xFFFFFFFFu, 10, 20, 30}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw_indexed, 20, 1, 5, values, nullptr, out)); + const auto words = record(out, 0, 5); + CHECK(words[0] == leonida::indirect_clamp_max_vertices); + CHECK(words[1] == leonida::indirect_clamp_max_vertex_instances / leonida::indirect_clamp_max_vertices); + CHECK(words[2] == 10 && words[3] == 20 && words[4] == 30); + CHECK(out.counters.records_clamped == 1); + } + + // 5. An in-range dispatch is copied untouched; a record with no groups costs nothing and is not clamped. + { + const std::uint32_t values[3 * 2] = {4, 2, 1, 0, 0, 0}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_dispatch, 12, 2, 3, values, nullptr, out)); + CHECK(record(out, 0, 3) == std::vector(values, values + 3)); + CHECK(all_zero(record(out, 1, 3))); + CHECK(out.counters.records_clamped == 0); + } + + // 6. A dispatch asking for billions of groups in every dimension runs empty: x * y overflows the group limit. + { + const std::uint32_t values[3] = {0xFFFFFFF0u, 0xFFFFFFFFu, 1}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_dispatch, 12, 1, 3, values, nullptr, out)); + CHECK(all_zero(record(out, 0, 3))); + CHECK(out.counters.records_clamped == 1); + } + + // 6b. A dispatch over the per-dimension limit is cut there, and one over 2^20 groups in all runs empty. + { + const std::uint32_t values[3 * 2] = {0x10000000u, 1, 1, 65535, 65535, 1}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_dispatch, 12, 2, 3, values, nullptr, out)); + const auto per_dimension = record(out, 0, 3); + CHECK(per_dimension[0] == leonida::indirect_clamp_max_group_dimension && per_dimension[1] == 1 && + per_dimension[2] == 1); + CHECK(all_zero(record(out, 1, 3))); + CHECK(out.counters.records_clamped == 2); + } + + // 7. A console mesh dispatch uses only x. + { + const std::uint32_t values[3] = {0x12345678u, 3, 1}; + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_mesh, 12, 1, 3, values, nullptr, out)); + const auto words = record(out, 0, 3); + CHECK(words[0] == leonida::indirect_clamp_max_group_dimension && words[1] == 1 && words[2] == 1); + CHECK(out.counters.records_clamped == 1); + } + + // Unfilled slots leave the list budget available to a later valid record. + { + std::vector values(65 * 4, UINT32_MAX); + const std::uint32_t valid[] = {30, 2, 3, 4}; + std::copy_n(valid, 4, values.end() - 4); + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_draw, 16, 65, 4, values.data(), nullptr, out)); + CHECK(out.counters.records_clamped == 64 && out.counters.over_budget == 0); + CHECK(all_zero(record(out, 0, 4))); + CHECK(record(out, 64, 4) == std::vector(valid, valid + 4)); + } + + // 8. The batch budget: 33 records of 65 535 groups are 33 * 65 535 * 64 units, one record past 2^27, so exactly + // one record is emptied - which one is the GPU's to decide, as the atomic charge is a race. + { + constexpr std::uint32_t kRecords = 33; + std::vector values(kRecords * 3); + for (std::uint32_t r = 0; r < kRecords; ++r) { + values[r * 3 + 0] = 65535; + values[r * 3 + 1] = 1; + values[r * 3 + 2] = 1; + } + Clamped out{}; + CHECK(env.run(leonida::indirect_clamp_dispatch, 12, kRecords, 3, values.data(), nullptr, out)); + std::uint32_t ran = 0, empty = 0, other = 0; + for (std::uint32_t r = 0; r < kRecords; ++r) { + const auto words = record(out, r, 3); + if (all_zero(words)) ++empty; + else if (words[0] == 65535 && words[1] == 1 && words[2] == 1) ++ran; + else ++other; + } + CHECK(ran == 32 && empty == 1 && other == 0); + CHECK(out.counters.over_budget == 1); + } + + // Three calls on one list consume two full draw allowances. A fresh list starts at zero. + { + const std::uint32_t args[] = {1u << 24, 4, 0, 0}; + std::memcpy(env.arguments_map, args, sizeof(args)); + auto batch = clamp.batch(); + leonida::ClampedIndirect jobs[4]{}; + VkDeviceAddress shared = 0; + for (unsigned i = 0; i < 4; ++i) { + CHECK(batch->prepare(env.arguments, 0, VK_NULL_HANDLE, 0, leonida::indirect_clamp_draw, 16, 1, jobs[i])); + if (i < 3) jobs[i].share_list_budget(shared); + } + CHECK(device.run([&](VkCommandBuffer cb) { + for (unsigned i = 0; i < 4; ++i) { + clamp.emit(cb, jobs[i]); + VkBufferCopy copy{jobs[i].offset, i * sizeof(args), sizeof(args)}; + device.fn("vkCmdCopyBuffer")(cb, jobs[i].buffer, env.readback, 1, ©); + } + VkMemoryBarrier host{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + host.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + host.dstAccessMask = VK_ACCESS_HOST_READ_BIT; + device.fn("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &host, 0, nullptr, 0, nullptr); + return true; + })); + const auto* result = static_cast(env.readback_map); + CHECK(result[0] == args[0] && result[4] == args[0] && result[8] == 0 && result[12] == args[0]); + CHECK(std::memcmp(env.arguments_map, args, sizeof(args)) == 0); + } + + // 9. More ExecuteIndirect calls in one submission than there are counter slots (4,096): every call is still + // clamped, none falls back to the application's buffer; the calls past the slots only lose their counters. + { + std::memset(env.arguments_map, 0, size_t(env.argument_bytes)); + const std::uint32_t huge[4] = {0xFFFFFFF0u, 0xFFFFFFFFu, 4, 6}; + std::memcpy(env.arguments_map, huge, sizeof huge); + std::memset(env.readback_map, 0xcd, size_t(env.readback_bytes)); + const auto before = clamp.counters(); + { + auto batch = clamp.batch(); + std::vector jobs(4096 + 2); + bool all = true; + for (auto& job : jobs) + all = batch->prepare(env.arguments, 0, VK_NULL_HANDLE, 0, leonida::indirect_clamp_draw, 16, 1, job) && + all; + const auto during = clamp.counters(); + CHECK(all); + CHECK(during.unclamped_calls == before.unclamped_calls); + CHECK(during.uncounted_calls - before.uncounted_calls >= 2); + const leonida::ClampedIndirect& last = jobs.back(); + CHECK(last.stats_buffer == VK_NULL_HANDLE && jobs.front().stats_buffer != VK_NULL_HANDLE); + const bool ok = device.run([&](VkCommandBuffer cb) { + clamp.emit(cb, last); + VkBufferCopy copy{last.offset, 0, last.stride}; + device.fn("vkCmdCopyBuffer")(cb, last.buffer, env.readback, 1, ©); + VkMemoryBarrier host{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + host.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + host.dstAccessMask = VK_ACCESS_HOST_READ_BIT; + device.fn("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &host, 0, + nullptr, 0, nullptr); + return true; + }); + CHECK(ok); + const auto* words = static_cast(env.readback_map); + CHECK(words[0] == leonida::indirect_clamp_max_vertices && words[2] == 4 && words[3] == 6); + } + clamp.retire(VK_NULL_HANDLE, 0); + clamp.collect(); + } + + // Every case above ran under validation when LEONIDA_VK_VALIDATION=1. + CHECK(device.validation_errors() == device.known_validation_errors()); + + if (failures) { + std::fprintf(stderr, "indirect_clamp_test: %d failure(s)\n", failures); + return 1; + } + const auto counters = clamp.counters(); + std::printf("indirect_clamp_test: every kind clamped, in-range records bit-identical, the budget saturating; " + "%llu record(s) clamped in %llu call(s), %llu count(s), validation errors %u\n", + static_cast(counters.records_clamped), + static_cast(counters.calls), + static_cast(counters.counts_clamped), device.validation_errors()); + return 0; +} diff --git a/runtime/test/indirect_dispatch_count_alloc_test.cpp b/runtime/test/indirect_dispatch_count_alloc_test.cpp index 6365cbdf92..9e32377926 100644 --- a/runtime/test/indirect_dispatch_count_alloc_test.cpp +++ b/runtime/test/indirect_dispatch_count_alloc_test.cpp @@ -115,7 +115,7 @@ VKAPI_ATTR void VKAPI_CALL mock_cmd_bind_pipeline(VkCommandBuffer, VkPipelineBin VKAPI_ATTR void VKAPI_CALL mock_cmd_push_constants(VkCommandBuffer, VkPipelineLayout, VkShaderStageFlags, std::uint32_t, std::uint32_t size, const void* values) { - if (size == 40) { + if (size == 48) { std::uint32_t records = 0; std::memcpy(&records, static_cast(values) + 32, sizeof(records)); g_mock->push_records.push_back(records); diff --git a/runtime/test/kernel_writes_test.cpp b/runtime/test/kernel_writes_test.cpp index 070ae3488c..005e9a9348 100644 --- a/runtime/test/kernel_writes_test.cpp +++ b/runtime/test/kernel_writes_test.cpp @@ -3,13 +3,20 @@ // write does not fault such a page in, so the read fails with ERROR_NOACCESS unless the committer runs first. Then // kernel_writes::hold, the pin a host import keeps over its pages: recorded with no opener set (no tracker yet), seen // by for_each_pin until release(), untouched by a file read's pin ending over the same pages. No game data. +// the pins and the guards of the geometry watch (src/title_geometry_watch.h): a pin made with an OVERLAPPED that does +// not say pending yet lasts until its call returns; a host thread's write (kernel_writes::write) into a geometry tile +// the watch made read-only lands and counts as a write; and a tile armed while another guard changes one of its pages +// gives every page it protected back. No game data. #include +#include #include #include #include +#include #include +#include "../src/title_geometry_watch.h" #include "../src/title_page_watch.h" namespace { @@ -86,9 +93,119 @@ bool commit_view(const void* address, std::size_t bytes) { return VirtualAlloc(const_cast(begin), bytes, MEM_COMMIT, PAGE_READWRITE) != nullptr; } +DWORD protection_of(const void* address) { + MEMORY_BASIC_INFORMATION info{}; + return VirtualQuery(address, &info, sizeof(info)) && info.State == MEM_COMMIT ? info.Protect : 0; +} + +// The D3D12 layer's opener as far as the geometry watch goes (open_shadow_pages): its guards over the range lift. +int g_opened = 0; +void open_geometry(std::uintptr_t from, std::uintptr_t to) { + ++g_opened; + leonida::geometry_writes::notify(from, to, leonida::geometry_writes::Event::open); +} + +// A pin made with an OVERLAPPED whose Internal is not STATUS_PENDING yet (ReadFile stores that when it starts) is kept +// until the call returns; once it returned pending, it lasts until the OVERLAPPED says it completed. +void check_overlapped_pin() { + namespace kw = leonida::kernel_writes; + std::vector bytes(0x1000); + const auto begin = reinterpret_cast(bytes.data()); + const auto pinned = [&] { + int n = 0; + kw::for_each_pin(begin, begin + bytes.size(), [&](std::uintptr_t, std::uintptr_t) { ++n; }); + return n; + }; + kw::set_opener([](std::uintptr_t, std::uintptr_t) {}); + OVERLAPPED at{}; // Internal 0: reads as completed + const std::uint64_t pin = kw::begin_write(bytes.data(), bytes.size(), &at); + check(pin != 0 && pinned() == 1, "an overlapped pin is kept while its call has not returned (Internal still 0)"); + at.Internal = static_cast(STATUS_PENDING); + kw::end_write(pin, true); + check(pinned() == 1, "returned pending: kept while the OVERLAPPED says pending"); + at.Internal = 0; + check(pinned() == 0 && kw::state().count.load() == 0, "and dropped once it says completed"); + const std::uint64_t sync = kw::begin_write(bytes.data(), bytes.size(), &at); + kw::end_write(sync, false); + check(kw::state().count.load() == 0, "an overlapped pin whose call completed ends with the call"); + kw::set_opener(nullptr); +} + +// A geometry tile over 64 KiB of the title's memory, armed: read-only. A host thread copies into it through +// kernel_writes::write (as a DirectStorage queue publishes a request): the opener lifts the watch, the copy lands, and +// the tile's version moved (the geometry copy is refilled at the next submission). The tile is not armed again while +// a write into it is pinned. +void check_geometry_write() { + namespace gw = leonida::geometry_writes; + constexpr std::size_t tile = gw::tile_size; + auto* pages = static_cast(VirtualAlloc(nullptr, tile, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); + check(pages != nullptr, "a tile of memory"); + if (!pages) return; + const auto va = reinterpret_cast(pages); + gw::Cell* cell = gw::acquire(va); + check(gw::arm(va, *cell) && (protection_of(pages + 0x5000) & 0xff) == PAGE_READONLY, "the armed tile is read-only"); + leonida::kernel_writes::set_opener(&open_geometry); + const auto version = cell->version.load(); + std::vector source(0x3000); + for (std::size_t i = 0; i < source.size(); ++i) source[i] = static_cast(i * 13 + 5); + bool ok = false; + std::thread host([&] { ok = leonida::kernel_writes::write(pages + 0x4800, source.data(), source.size()); }); + host.join(); + check(ok && std::memcmp(pages + 0x4800, source.data(), source.size()) == 0, + "a host thread's write into the armed tile lands"); + check(g_opened == 1 && cell->version.load() != version, "the watch was opened first and the tile counts as written"); + check(gw::arm(va, *cell) && (protection_of(pages) & 0xff) == PAGE_READONLY, "armed again after the write"); + const std::uint64_t pin = leonida::kernel_writes::begin_write(pages + 0x100, 0x100, nullptr); + check(!gw::arm(va, *cell), "not armed while a write into the tile is pinned"); + leonida::kernel_writes::end_write(pin, false); + leonida::kernel_writes::set_opener(nullptr); + gw::release(va); + check((protection_of(pages) & 0xff) == PAGE_READWRITE && (protection_of(pages + tile - 1) & 0xff) == PAGE_READWRITE, + "released: the tile is writable again"); + VirtualFree(pages, 0, MEM_RELEASE); +} + +// The geometry watch arms a tile while another guard (a slot-133 shadow, under a lock of its own) makes the tile's +// first page read-only and writable again. VirtualProtect over the tile returns the first page's protection only: +// taken as every page's, a read-only answer left the others read-only for good once the watch reopened the tile. Every +// page but the first must be writable after each reopen. +void check_arm_race() { + namespace gw = leonida::geometry_writes; + constexpr std::size_t tile = gw::tile_size; + auto* pages = static_cast(VirtualAlloc(nullptr, tile, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); + if (!pages) return; + const auto va = reinterpret_cast(pages); + gw::Cell* cell = gw::acquire(va); + std::atomic stop{false}; + std::thread other([&] { + DWORD old = 0; + while (!stop.load(std::memory_order_relaxed)) { + VirtualProtect(pages, 0x1000, PAGE_READONLY, &old); + VirtualProtect(pages, 0x1000, PAGE_READWRITE, &old); + } + }); + int stuck = 0, armed = 0; + const auto until = GetTickCount64() + 1500; + while (GetTickCount64() < until && !stuck) { + armed += gw::arm(va, *cell) ? 1 : 0; + gw::notify(va, va + tile, gw::Event::open); + for (std::size_t at = 0x1000; at < tile; at += 0x1000) + if ((protection_of(pages + at) & 0xff) != PAGE_READWRITE) ++stuck; + } + stop = true; + other.join(); + std::printf(" %d arms while another guard toggled the first page, %d pages left read-only\n", armed, stuck); + check(armed > 0 && stuck == 0, "reopening an armed tile gives back every page it protected"); + gw::release(va); + VirtualFree(pages, 0, MEM_RELEASE); +} + } // namespace int main() { + check_overlapped_pin(); + check_geometry_write(); + check_arm_race(); wchar_t dir[MAX_PATH], path[MAX_PATH]; GetTempPathW(MAX_PATH, dir); GetTempFileNameW(dir, L"kwt", 0, path); diff --git a/runtime/test/title_memory_map_test.cpp b/runtime/test/title_memory_map_test.cpp new file mode 100644 index 0000000000..ba5a518a1d --- /dev/null +++ b/runtime/test/title_memory_map_test.cpp @@ -0,0 +1,147 @@ +// leonida::title_memory_map (runtime/src/title_page_watch.h): the journal of changes to the title's address space, by +// range, and what the D3D12 layer's readers build on it: the title-texture pass probes again only the textures a +// change overlaps (TextureReadability, src/title_texture_memory.h), and a slot-133 shadow queries again only its +// pages a change overlaps. No game data, no GPU. +// 1. a reader is told the changes since its generation that overlap its range, clipped and in whole pages; +// 2. a change elsewhere moves the generation but tells the reader nothing; +// 3. a reader further behind than the journal holds is told so (it then looks at everything); +// 4. a change with no range overlaps every reader; +// 5. TextureReadability keeps a positive answer, when asked to, until a retry; +// 6. a pass over 20,000 waiting textures probes only those under the one mapped block. +#include + +#include +#include +#include +#include + +#include "../src/title_page_watch.h" +#include "../src/title_texture_memory.h" +#include "../src/title_texture_refresh.h" + +namespace { + +namespace map = leonida::title_memory_map; + +int g_checks = 0; +int g_failures = 0; + +void check(bool condition, const char* what) { + ++g_checks; + std::printf("%s %s\n", condition ? "PASS" : "FAIL", what); + if (!condition) ++g_failures; +} + +using Ranges = std::vector>; + +bool since(std::uint64_t from, std::uint64_t& now, std::uintptr_t lo, std::uintptr_t hi, Ranges& out) { + out.clear(); + return map::changes_since(from, now, lo, hi, [&](std::uintptr_t a, std::uintptr_t b) { out.emplace_back(a, b); }); +} + +} // namespace + +int main() { + constexpr std::uintptr_t kBase = 0x7000000000; // no memory is touched: the journal only records addresses + Ranges got; + std::uint64_t now = 0; + + // 1. Overlapping changes only, clipped to the reader's range, rounded out to whole 4 KiB pages. + const std::uint64_t start = map::generation(); + map::changed(kBase + 0x10010, kBase + 0x10020); // inside, not page-aligned + map::changed(kBase + 0x90000, kBase + 0xa0000); // outside + map::changed(kBase + 0x1f000, kBase + 0x31000); // straddles the reader's end + check(since(start, now, kBase + 0x10000, kBase + 0x20000, got), "the journal holds the reader's changes"); + check(now == start + 3, "the reader is brought to the latest generation"); + check(got.size() == 2 && got[0] == std::make_pair(kBase + 0x10000, kBase + 0x11000) && + got[1] == std::make_pair(kBase + 0x1f000, kBase + 0x20000), + "two overlapping changes, in whole pages, clipped to the reader's range"); + + // 2. Caught up: a change elsewhere tells nothing, but the generation moves. + const std::uint64_t caught_up = now; + map::changed(reinterpret_cast(kBase + 0x400000), 0x10000); + check(since(caught_up, now, kBase + 0x10000, kBase + 0x20000, got) && got.empty() && now == caught_up + 1, + "a change outside the range tells the reader nothing"); + + // 3. A reader more than kJournal changes behind is told it missed some. + const std::uint64_t behind = map::generation(); + for (std::size_t i = 0; i <= map::kJournal; ++i) map::changed(kBase + 0x800000, kBase + 0x801000); + check(!since(behind, now, kBase, kBase + 0x1000, got) && got.empty(), + "a reader further behind than the journal is told to look at everything"); + const std::uint64_t latest = map::generation(); + check(since(latest - 10, now, kBase + 0x800000, kBase + 0x801000, got) && got.size() == 10, + "a reader within the journal is told each of its changes"); + + // 4. No range: everyone's. + const std::uint64_t before_all = map::generation(); + map::changed(); + check(since(before_all, now, kBase + 0x123000, kBase + 0x124000, got) && got.size() == 1 && + got[0] == std::make_pair(kBase + 0x123000, kBase + 0x124000), + "a change with no range overlaps every reader"); + + // 5. TextureReadability: positive answers kept until a retry when asked to, else probed every time as before. + { + leonida::TextureReadability r; + unsigned probes = 0; + const auto readable = [&] { ++probes; return true; }; + for (int i = 0; i < 100; ++i) r.check(0, true, readable, true); + check(probes == 1 && !r.pending(), "a readable texture is probed once in 100 checks with cache_success"); + r.retry(); + check(r.check(0, true, readable, true) && probes == 2, "a retry probes it again"); + for (int i = 0; i < 10; ++i) r.check(0, true, readable); + check(probes == 12, "without cache_success every check probes (unchanged behaviour)"); + r.defer(); // a page went between the probe and the read + const auto unreadable = [&] { ++probes; return false; }; + check(!r.check(0, true, unreadable, true) && probes == 12, "a deferred texture waits for a retry"); + r.retry(); + check(!r.check(0, true, unreadable, true) && probes == 13 && r.pending(), "the retry finds it unreadable"); + } + + // 6. The pass: 20,000 waiting textures of 16 KiB each; one 64 KiB block is mapped and reported. Only the four + // textures in it are probed again; the next pass, with no change, probes none. + { + struct Texture { + std::uintptr_t cpu; + std::uint64_t size; + leonida::TextureReadability memory; + }; + std::vector textures(20000); + unsigned probes = 0; + std::uintptr_t mapped_from = 0, mapped_to = 0; + const auto probe = [&](const Texture& t) { + ++probes; + return t.cpu >= mapped_from && t.cpu + t.size <= mapped_to; + }; + for (std::size_t i = 0; i < textures.size(); ++i) { + textures[i].cpu = kBase + 0x10000000 + i * 0x4000; + textures[i].size = 0x4000; + textures[i].memory.check(0, true, [&] { return probe(textures[i]); }, true); + } + std::uint64_t pass_generation = map::generation(); + const auto pass = [&] { + leonida::TitleWriteRanges changes; + std::uint64_t upto = 0; + const bool all = !map::changes_since(pass_generation, upto, 0, UINTPTR_MAX, + [&](std::uintptr_t a, std::uintptr_t b) { changes.emplace_back(a, b); }); + pass_generation = upto; + leonida::merge_title_writes(changes); + unsigned readable = 0; + for (Texture& t : textures) { + if (all || leonida::title_write_overlaps(changes, t.cpu, t.cpu + t.size)) t.memory.retry(); + readable += t.memory.check(0, true, [&] { return probe(t); }, true); + } + return readable; + }; + probes = 0; + mapped_from = kBase + 0x10000000 + 0x10000 * 100; + mapped_to = mapped_from + 0x10000; + map::changed(mapped_from, mapped_to); + const unsigned readable = pass(); + check(probes == 4 && readable == 4, "a mapped block probes and finds only the four textures in it"); + probes = 0; + check(pass() == 4 && probes == 0, "a pass with no change probes nothing"); + } + + std::printf("%d checks, %d failures\n", g_checks, g_failures); + return g_failures ? 1 : 0; +} diff --git a/runtime/test/title_va_alias_test.cpp b/runtime/test/title_va_alias_test.cpp index b658ed3cce..fe378a3bf2 100644 --- a/runtime/test/title_va_alias_test.cpp +++ b/runtime/test/title_va_alias_test.cpp @@ -67,6 +67,24 @@ int main() { EXPECT(a.shader_va(title + 0x8000) == title + 0x8000); a.remove(title + 0x100000, below); EXPECT(a.size() == 0 && a.shader_va(title + 0x100010) == title + 0x100010); + // range_of: what a BVH build checks its bytes against (the whole range must lie in one copy), and mappings, the + // table a TLAS build translates its instances' BLAS addresses with. + std::uint64_t to = 0, room = 0; + std::vector table; + a.mappings(table); + EXPECT(table.empty() && !a.range_of(title, to, room)); + EXPECT(a.add(title + 0x40000, size, 0x7000000) && a.add(title, size, arena)); + EXPECT(a.range_of(title + 0x100, to, room) && to == arena + 0x100 && room == size - 0x100); + EXPECT(a.range_of(title + size - 1, to, room) && to == arena + size - 1 && room == 1); + EXPECT(!a.range_of(title + size, to, room) && !a.range_of(title - 1, to, room)); + EXPECT(a.resolve(title + 0x40010, 64, leonida::TitleVaAliases::bvh_address) == 0x7000010); + EXPECT(a.translated(leonida::TitleVaAliases::bvh_address) == 1); + a.mappings(table); + EXPECT(table.size() == 2 && table[0].title_va == title && table[0].end == title + size && + table[0].shader_va == arena && table[1].title_va == title + 0x40000 && table[1].shader_va == 0x7000000); + a.remove(title, arena); + a.remove(title + 0x40000, 0x7000000); + EXPECT(a.size() == 0); std::printf("title_va_alias: translation inside a title-placed range, identity outside it and after release\n"); return 0; } diff --git a/runtime/test/title_window_plan_test.cpp b/runtime/test/title_window_plan_test.cpp new file mode 100644 index 0000000000..987ee6e35f --- /dev/null +++ b/runtime/test/title_window_plan_test.cpp @@ -0,0 +1,154 @@ +// The mapping a title address gets, without a GPU: src/title_window_plan.h (a window's range and what fits the +// LEONIDA_TITLE_WINDOWS_MB budget; one mapping per readable run of a stream pool) and src/title_va_alias.h with a +// resolver that runs out of budget (no raw address may come back) and with a pool's two addresses (src/title_page_watch.h, +// title_gpu_views) sharing one mapping. The title's stream pool is a 16-24 GiB reservation whose GPU-only alias and CPU view name the same +// frames, and a title address that gets no copy must not reach a shader as itself (heap_base + it is no allocation). +#include "../src/title_page_watch.h" +#include "../src/title_va_alias.h" +#include "../src/title_window_plan.h" + +#include +#include +#include + +#define EXPECT(condition) do { \ + if (!(condition)) { std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); return 1; } \ +} while (0) + +namespace { + +constexpr std::uint64_t kAlign = 65536, kMiB = 1ull << 20, kArenaCap = 1ull << 32; + +// A resolver that makes a window when the budget has room and answers "no backing" when it does not, as the device's +// resolve_title_memory does (d3d12_vulkan_device.cpp). +struct Budget { + std::uint64_t cap = 64 * kMiB; + std::uint64_t used = 0; + std::uint64_t next = 0x10000; // synthetic arena offsets + std::uint64_t windows = 0, refusals = 0; + leonida::TitleVaAliases* table = nullptr; +}; + +bool budget_resolver(void* context, std::uint64_t va, std::uint64_t bytes, std::uint64_t& out) { + auto& budget = *static_cast(context); + leonida::TitleWindowRange range{}; + if (!leonida::title_window_range(va, bytes, 0, UINT64_MAX, kAlign, 16 * kMiB, budget.cap, budget.used, range)) { + ++budget.refusals; + out = 0; // title memory, no backing: the view is written with a zero-size range + return true; + } + budget.used += range.size; + ++budget.windows; + const std::uint64_t shader = budget.next; + budget.next += range.size; + budget.table->add(range.start, range.size, shader); + out = shader + (va - range.start); + return true; +} + +int check_window_budget() { + Budget budget; + leonida::TitleVaAliases table; + budget.table = &table; + table.set_hooks(&budget, &budget_resolver, nullptr); + constexpr std::uint64_t title = 0x5800e0000ull; // a stream-pool alias on the console, past the arena + std::uint64_t backed = 0, zeroed = 0; + for (unsigned i = 0; i < 800; ++i) { + const std::uint64_t va = title + std::uint64_t(i) * 0x20000; + const std::uint64_t to = table.resolve(va, 0x20000, leonida::TitleVaAliases::vertex_view); + // Never the raw title address: a window (an offset below the arena's range), or 0 for a zero-size view. + EXPECT(to == 0 || to < kArenaCap); + EXPECT(to != va); + if (to) ++backed; + else ++zeroed; + } + EXPECT(backed != 0 && zeroed != 0); + EXPECT(budget.windows == budget.cap / 0x20000); // 512 aligned 128 KiB windows fill 64 MiB exactly + EXPECT(budget.used == budget.cap); + EXPECT(budget.refusals >= zeroed); + // A window that does not fit is refused outright: no range and no charge. + leonida::TitleWindowRange range{}; + EXPECT(!leonida::title_window_range(title, 0x20000, 0, UINT64_MAX, kAlign, 16 * kMiB, budget.cap, budget.cap, + range)); + EXPECT(leonida::title_window_range(title, 0x10000, 0, UINT64_MAX, kAlign, 16 * kMiB, budget.cap, + budget.cap - 0x10000, range)); + EXPECT(range.size == 0x10000); + // A span that ends before the request backs nothing. + EXPECT(!leonida::title_window_range(title, 0x20000, 0, title, kAlign, 16 * kMiB, budget.cap, 0, range)); + table.clear_hooks(&budget); + std::printf("title window budget: %llu windows backed 800 requests, %llu zero-size views, %llu KiB of a %llu MiB " + "budget, no raw address\n", + static_cast(budget.windows), static_cast(zeroed), + static_cast(budget.used >> 10), static_cast(budget.cap >> 20)); + return 0; +} + +// One stream pool's pages: an RW CPU view (the pages the title commits and the host reads) and a GPU-only alias of +// the same size, both uncommitted at the alias, as the title's xmem reservations are (protect 0x801). +int check_stream_pool() { + constexpr std::uint64_t pool = 1 * kMiB; + void* cpu_pages = VirtualAlloc(nullptr, pool, MEM_TOP_DOWN | MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + void* gpu_alias = VirtualAlloc(nullptr, pool, MEM_TOP_DOWN | MEM_RESERVE, PAGE_NOACCESS); + EXPECT(cpu_pages && gpu_alias); + const auto cpu = reinterpret_cast(cpu_pages); + const auto gpu = reinterpret_cast(gpu_alias); + EXPECT(!leonida::title_gpu_views::note_reservation(cpu, pool, false)); // remembered as the CPU twin + EXPECT(leonida::title_gpu_views::note_reservation(gpu, pool, true)); // paired: true + + // The pair is found from either address, and rule B sends the GPU-only pages to the CPU view the host reads. + leonida::title_gpu_views::Range view{}; + EXPECT(leonida::title_gpu_views::view_at(gpu + 0x20000, 0x20000, view) && view.gpu == gpu && view.cpu == cpu); + EXPECT(leonida::title_gpu_views::view_at(cpu + 0x20000, 0x20000, view) && view.gpu == gpu && view.cpu == cpu); + EXPECT(leonida::title_gpu_views::to_host_view(gpu + 0x20000, 0x20000) == cpu + 0x20000); + EXPECT(leonida::title_gpu_views::to_host_view(cpu + 0x20000, 0x20000) == cpu + 0x20000); + EXPECT(leonida::title_gpu_views::other_view(gpu + 0x20000) == cpu + 0x20000); + + // One mapping for the readable run: two vertex-buffer requests inside it compute the same extent, so they cost + // one window, not one 128 KiB window each. + const std::uint64_t readable_end = cpu + pool; + leonida::TitleWindowRange first{}, second{}; + EXPECT(leonida::title_pool_extent(cpu, cpu + pool, cpu + 0x20000, readable_end, kAlign, 1 * kMiB, first)); + EXPECT(leonida::title_pool_extent(cpu, cpu + pool, cpu + 0x28000, readable_end, kAlign, 1 * kMiB, second)); + EXPECT(first.start == cpu + 0x20000 && first.size == 0xE0000); + EXPECT(second.start == first.start && second.size == first.size); // one mapping for both requests + // The extent stops at the first page the title has not committed. + leonida::TitleWindowRange partial{}; + EXPECT(leonida::title_pool_extent(cpu, cpu + pool, cpu + 0x20000, cpu + 0x30000, kAlign, 1 * kMiB, partial)); + EXPECT(partial.start == cpu + 0x20000 && partial.size == 0x10000); + EXPECT(!leonida::title_pool_extent(cpu, cpu + pool, cpu + 0x20000, cpu + 0x20000, kAlign, 1 * kMiB, partial)); + + // The mapping the device makes: one shader VA for the extent, entered for both addresses of the pair. + leonida::TitleVaAliases table; + constexpr std::uint64_t shader = 0x3000000; + const auto twin_start = static_cast(leonida::title_gpu_views::other_view(first.start)); + EXPECT(table.add_twin(first.start, twin_start, first.size, shader)); + for (std::uint64_t off = 0; off < pool; off += 0x40000) { + EXPECT(table.shader_va(first.start + off) == shader + off); // the CPU view + EXPECT(table.shader_va(twin_start + off) == shader + off); // the GPU-only alias: the same backing + EXPECT(table.resolve(first.start + off, 0x20000, leonida::TitleVaAliases::vertex_view) == shader + off); + EXPECT(table.resolve(twin_start + off, 0x20000, leonida::TitleVaAliases::vertex_view) == shader + off); + } + // One mapping, two ranges: 8 lookups on both sides called no resolver and made no second mapping. + EXPECT(table.translated(leonida::TitleVaAliases::vertex_view) == 8); + EXPECT(table.size() == 2); + + leonida::title_gpu_views::state().views.clear(); + leonida::title_gpu_views::state().count.store(0); + VirtualFree(gpu_alias, 0, MEM_RELEASE); + VirtualFree(cpu_pages, 0, MEM_RELEASE); + std::printf("stream pool: alias 0x%llx and CPU view 0x%llx share one %llu KiB mapping; 8 lookups, no second " + "mapping\n", + static_cast(gpu), static_cast(cpu), + static_cast(first.size >> 10)); + return 0; +} + +} // namespace + +int main() { + if (check_window_budget()) return 1; + if (check_stream_pool()) return 1; + std::printf("title_window_plan: a refused window gives no raw base, and a stream pool's two views share one " + "mapping\n"); + return 0; +} diff --git a/runtime/test/vk_aftermath_test.cpp b/runtime/test/vk_aftermath_test.cpp new file mode 100644 index 0000000000..e59137aa38 --- /dev/null +++ b/runtime/test/vk_aftermath_test.cpp @@ -0,0 +1,243 @@ +// Nsight Aftermath GPU crash dumps (src/vulkan_aftermath.h) on a real device: a compute shader writes through a +// bogus buffer device address, the device is lost, and the dump must appear and its decoded summary must name the +// faulting shader (its faulted warp's pc) by the name it was created under. Built only with -DLEONIDA_AFTERMATH_SDK. +// +// It loses the device on purpose, so it runs only with LEONIDA_AFTERMATH_FAULT_TEST=1; otherwise, without the +// Aftermath DLL, or without an NVIDIA GPU it prints SKIP and exits 77. A page fault only: no hang, no TDR. +// LEONIDA_AFTERMATH_DIR picks the dump folder (default %TEMP%\leonida_aftermath_test). +#include "vulkan_loader.h" + +#include "vulkan_aftermath.h" +#include "vulkan_device_fault.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +constexpr int skip = 77; +constexpr const char* shader_name = "aftermath_fault_cs"; +// Far from anything the driver maps for this small process, inside the GPU's virtual address range. +constexpr std::uint64_t bogus_address = 0x0000123400000000ull; + +#define FAIL(...) \ + do { \ + std::fprintf(stderr, "FAIL: " __VA_ARGS__); \ + std::fputc('\n', stderr); \ + return 1; \ + } while (0) + +std::vector read_spirv(const char* path) { + std::ifstream file(path, std::ios::binary | std::ios::ate); + if (!file) return {}; + const auto size = std::size_t(file.tellg()); + std::vector words(size / 4); + file.seekg(0); + file.read(reinterpret_cast(words.data()), std::streamsize(words.size() * 4)); + return file ? words : std::vector{}; +} + +} // namespace + +int main() { + const char* armed = std::getenv("LEONIDA_AFTERMATH_FAULT_TEST"); + if (!armed || std::strcmp(armed, "1") != 0) { + std::puts("SKIP: set LEONIDA_AFTERMATH_FAULT_TEST=1 to run (it loses the GPU device on purpose)"); + return skip; + } + if (!leonida::aftermath::available()) { + std::puts("SKIP: built without LEONIDA_AFTERMATH_SDK"); + return skip; + } + SetEnvironmentVariableA("LEONIDA_AFTERMATH", "1"); + SetEnvironmentVariableA("LEONIDA_AFTERMATH_KEEP_SPIRV", "1"); // the decoder maps the pc into our module + if (!std::getenv("LEONIDA_AFTERMATH_DIR")) { + const auto dir = std::filesystem::temp_directory_path() / "leonida_aftermath_test"; + SetEnvironmentVariableW(L"LEONIDA_AFTERMATH_DIR", dir.c_str()); + } + if (!leonida::aftermath::enable()) { + std::puts("SKIP: the Aftermath library did not load or enable"); + return skip; + } + + const auto gipa = load_vulkan(); + if (!gipa) { + std::puts("SKIP: no Vulkan loader"); + return skip; + } +#define INSTANCE_FN(name) const auto name = reinterpret_cast(gipa(instance, #name)) + VkInstance instance = VK_NULL_HANDLE; + const auto vkCreateInstance = reinterpret_cast(gipa(nullptr, "vkCreateInstance")); + VkApplicationInfo app{VK_STRUCTURE_TYPE_APPLICATION_INFO}; + app.pApplicationName = "vk_aftermath_test"; + app.apiVersion = VK_API_VERSION_1_3; + VkInstanceCreateInfo instance_info{VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO}; + instance_info.pApplicationInfo = &app; + if (!vkCreateInstance || vkCreateInstance(&instance_info, nullptr, &instance) != VK_SUCCESS) { + std::puts("SKIP: no Vulkan 1.3 instance"); + return skip; + } + INSTANCE_FN(vkEnumeratePhysicalDevices); + INSTANCE_FN(vkGetPhysicalDeviceProperties); + INSTANCE_FN(vkGetPhysicalDeviceFeatures2); + INSTANCE_FN(vkGetPhysicalDeviceQueueFamilyProperties); + INSTANCE_FN(vkEnumerateDeviceExtensionProperties); + INSTANCE_FN(vkCreateDevice); + INSTANCE_FN(vkGetDeviceProcAddr); + std::uint32_t count = 0; + vkEnumeratePhysicalDevices(instance, &count, nullptr); + std::vector physicals(count); + vkEnumeratePhysicalDevices(instance, &count, physicals.data()); + VkPhysicalDevice physical = VK_NULL_HANDLE; + VkPhysicalDeviceProperties props{}; + for (VkPhysicalDevice candidate : physicals) { + vkGetPhysicalDeviceProperties(candidate, &props); + if (props.vendorID == 0x10de && props.apiVersion >= VK_API_VERSION_1_3) { + physical = candidate; + break; + } + } + if (!physical) { + std::puts("SKIP: no NVIDIA Vulkan 1.3 device"); + return skip; + } + std::printf("device: %s\n", props.deviceName); + + vkGetPhysicalDeviceQueueFamilyProperties(physical, &count, nullptr); + std::vector families(count); + vkGetPhysicalDeviceQueueFamilyProperties(physical, &count, families.data()); + std::uint32_t family = UINT32_MAX; + for (std::uint32_t i = 0; i < count && family == UINT32_MAX; ++i) + if (families[i].queueFlags & VK_QUEUE_COMPUTE_BIT) family = i; + if (family == UINT32_MAX) FAIL("no compute queue family"); + + vkEnumerateDeviceExtensionProperties(physical, nullptr, &count, nullptr); + std::vector advertised(count); + vkEnumerateDeviceExtensionProperties(physical, nullptr, &count, advertised.data()); + + const float priority = 1.0f; + VkDeviceQueueCreateInfo queue_info{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO}; + queue_info.queueFamilyIndex = family; + queue_info.queueCount = 1; + queue_info.pQueuePriorities = &priority; + VkPhysicalDeviceVulkan12Features vk12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES}; + vk12.bufferDeviceAddress = VK_TRUE; + VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &vk12}; + features.features.shaderInt64 = VK_TRUE; + VkDeviceCreateInfo device_info{VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, &features}; + device_info.queueCreateInfoCount = 1; + device_info.pQueueCreateInfos = &queue_info; + // The runtime's path for LEONIDA_AFTERMATH=1 without LEONIDA_DEVICE_FAULT: the NVIDIA diagnostics config only. + leonida::DeviceFaultFeatures fault_features; + std::vector extensions; + const auto diagnostics = fault_features.enable(physical, vkGetPhysicalDeviceFeatures2, advertised, extensions, + device_info, {false, true, leonida::aftermath::extra_config_flags()}); + std::printf("VK_NV_device_diagnostics_config: %s\n", diagnostics.diagnostics_config ? "on" : "unavailable"); + device_info.enabledExtensionCount = std::uint32_t(extensions.size()); + device_info.ppEnabledExtensionNames = extensions.empty() ? nullptr : extensions.data(); + VkDevice device = VK_NULL_HANDLE; + if (vkCreateDevice(physical, &device_info, nullptr, &device) != VK_SUCCESS) FAIL("vkCreateDevice"); + +#define DEVICE_FN(name) const auto name = reinterpret_cast(vkGetDeviceProcAddr(device, #name)) + DEVICE_FN(vkGetDeviceQueue); + DEVICE_FN(vkCreateShaderModule); + DEVICE_FN(vkCreatePipelineLayout); + DEVICE_FN(vkCreateComputePipelines); + DEVICE_FN(vkCreateCommandPool); + DEVICE_FN(vkAllocateCommandBuffers); + DEVICE_FN(vkBeginCommandBuffer); + DEVICE_FN(vkCmdBindPipeline); + DEVICE_FN(vkCmdPushConstants); + DEVICE_FN(vkCmdDispatch); + DEVICE_FN(vkEndCommandBuffer); + DEVICE_FN(vkCreateFence); + DEVICE_FN(vkQueueSubmit); + DEVICE_FN(vkWaitForFences); + DEVICE_FN(vkDeviceWaitIdle); + + const std::vector words = read_spirv(LEONIDA_AFTERMATH_FAULT_SPV); + if (words.empty()) FAIL("cannot read %s", LEONIDA_AFTERMATH_FAULT_SPV); + // Through the wrapper the runtime installs in its function table, under the name the summary must report. + const PFN_vkCreateShaderModule create_module = leonida::aftermath::wrap_create_shader_module(vkCreateShaderModule); + if (create_module == vkCreateShaderModule) FAIL("wrap_create_shader_module did not wrap"); + VkShaderModuleCreateInfo module_info{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; + module_info.codeSize = words.size() * 4; + module_info.pCode = words.data(); + VkShaderModule module = VK_NULL_HANDLE; + { + const leonida::aftermath::ShaderName named(shader_name); + if (create_module(device, &module_info, nullptr, &module) != VK_SUCCESS) FAIL("vkCreateShaderModule"); + } + + VkPushConstantRange range{VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(std::uint64_t)}; + VkPipelineLayoutCreateInfo layout_info{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; + layout_info.pushConstantRangeCount = 1; + layout_info.pPushConstantRanges = ⦥ + VkPipelineLayout layout = VK_NULL_HANDLE; + if (vkCreatePipelineLayout(device, &layout_info, nullptr, &layout) != VK_SUCCESS) FAIL("vkCreatePipelineLayout"); + VkComputePipelineCreateInfo pipeline_info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; + pipeline_info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO}; + pipeline_info.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT; + pipeline_info.stage.module = module; + pipeline_info.stage.pName = "main"; + pipeline_info.layout = layout; + VkPipeline pipeline = VK_NULL_HANDLE; + if (vkCreateComputePipelines(device, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &pipeline) != VK_SUCCESS) + FAIL("vkCreateComputePipelines"); + + VkCommandPoolCreateInfo pool_info{VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO}; + pool_info.queueFamilyIndex = family; + VkCommandPool pool = VK_NULL_HANDLE; + if (vkCreateCommandPool(device, &pool_info, nullptr, &pool) != VK_SUCCESS) FAIL("vkCreateCommandPool"); + VkCommandBufferAllocateInfo allocate{VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO}; + allocate.commandPool = pool; + allocate.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; + allocate.commandBufferCount = 1; + VkCommandBuffer commands = VK_NULL_HANDLE; + if (vkAllocateCommandBuffers(device, &allocate, &commands) != VK_SUCCESS) FAIL("vkAllocateCommandBuffers"); + VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; + vkBeginCommandBuffer(commands, &begin); + vkCmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline); + vkCmdPushConstants(commands, layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof bogus_address, &bogus_address); + vkCmdDispatch(commands, 4, 1, 1); + if (vkEndCommandBuffer(commands) != VK_SUCCESS) FAIL("vkEndCommandBuffer"); + + VkQueue queue = VK_NULL_HANDLE; + vkGetDeviceQueue(device, family, 0, &queue); + VkFenceCreateInfo fence_info{VK_STRUCTURE_TYPE_FENCE_CREATE_INFO}; + VkFence fence = VK_NULL_HANDLE; + if (vkCreateFence(device, &fence_info, nullptr, &fence) != VK_SUCCESS) FAIL("vkCreateFence"); + VkSubmitInfo submit{VK_STRUCTURE_TYPE_SUBMIT_INFO}; + submit.commandBufferCount = 1; + submit.pCommandBuffers = &commands; + std::printf("dispatching a store to 0x%016llx\n", static_cast(bogus_address)); + VkResult result = vkQueueSubmit(queue, 1, &submit, fence); + if (result == VK_SUCCESS) result = vkWaitForFences(device, 1, &fence, VK_TRUE, 10'000'000'000ull); + if (result == VK_SUCCESS) result = vkDeviceWaitIdle(device); + std::printf("result: %d\n", int(result)); + if (result != VK_ERROR_DEVICE_LOST) FAIL("the bogus store did not lose the device (VkResult %d)", int(result)); + + // The runtime's device-loss path: observe() runs the hook vulkan_aftermath installed, which waits for the dump. + leonida::DeviceFaultDiagnostics::observe(nullptr, result, "vk_aftermath_test"); + + const std::string dump = leonida::aftermath::last_dump_path(); + if (dump.empty()) FAIL("no GPU crash dump arrived"); + std::error_code ec; + const auto size = std::filesystem::file_size(std::filesystem::path(std::u8string(dump.begin(), dump.end())), ec); + if (ec || !size) FAIL("dump %s is missing or empty", dump.c_str()); + const std::string summary = leonida::aftermath::last_summary(); + if (summary.empty()) FAIL("the dump was not decoded"); + // The faulted warp's pc, mapped through the dump's shader table to the name the module was created under. + if (summary.find(std::string("faulting shader ") + shader_name + " ") == std::string::npos) + FAIL("the summary does not name %s as the faulting shader", shader_name); + std::printf("PASS: %s (%llu bytes), summary names %s\n", dump.c_str(), static_cast(size), + shader_name); + // The lost device is left to process exit: its objects need no destruction for the test. + return 0; +} diff --git a/runtime/test/vk_null_descriptor_test.cpp b/runtime/test/vk_null_descriptor_test.cpp new file mode 100644 index 0000000000..f34891368b --- /dev/null +++ b/runtime/test/vk_null_descriptor_test.cpp @@ -0,0 +1,292 @@ +// Null descriptors of every kind through the bindless set 0 (src/vulkan_bindless.h), at the Vulkan level. +// +// On the console a null descriptor (a zero T#, or a T# whose image the layer refused or never saw) reads zeros and +// drops stores and atomics. Translated shaders find their image by hashing the T# (a miss is index 0) and read it +// from the binding of the instruction's own dimension, so index 0 of each binding must be a fallback of that +// binding's kind, and nothing written through a null UAV may show in a later read through a null SRV. +// test/glsl/cs_null_descriptors.comp looks up a zero T#, T#s of a 3D, a cube and a 1D image that no image answers, +// a zero S#, and the T# of one real 2D image, then: +// pass 0: stores through the storage fallback of every dimension and component class, and adds to both r32ui +// fallbacks (2D and 3D); +// pass 1: reads every sampled fallback (fetched and sampled, the cube through the 2D-array binding at layer 3) and +// every storage fallback, and adds to the r32ui fallbacks again. +// Every key but the real one must find index 0, every sampled read must be zero after the stores, and the real image +// must read its clear colour (so the reads are not vacuous). Twice: with BindlessFeatures::null_descriptor (where the +// device has VK_EXT_robustness2 nullDescriptor), where the stores and atomics are dropped (storage reads and atomic +// results zero too); and without it, where the storage fallbacks are images of their own that keep the stores, +// apart from the sampled ones. +// Exit 77 without a Vulkan device with the bindless features, or without the shader (no glslangValidator). +// LEONIDA_VK_VALIDATION=1 runs under VK_LAYER_KHRONOS_validation; a validation error fails the test. +#ifndef VK_NO_PROTOTYPES +#define VK_NO_PROTOTYPES +#endif +#include "vk_test_device.h" +#include "shader_fixture_path.h" +#include "../src/vulkan_bindless.h" + +#include +#include +#include +#include +#include +#include + +#define EXPECT(condition) \ + do { \ + if (!(condition)) { \ + std::fprintf(stderr, "line %d: %s\n", __LINE__, #condition); \ + return 1; \ + } \ + } while (0) + +namespace { + +using namespace leonida; + +constexpr std::uint32_t result_words = 128; + +// T# word 3 bits [31:28] hold the image TYPE (gfx10_descriptors.h): 8 1D, 9 2D, 10 3D, 11 cube. +DescriptorKey tsharp_of_type(std::uint32_t type, std::uint32_t salt) { + return {0x00001000u + salt, 0x00000000u, 0x00000000u, (type << 28) | 0x00000fac, 0, 0, 0, 0}; +} + +std::vector load_spirv(const char* path) { + std::ifstream file(vktest::shader_fixture_path(path), std::ios::binary); + const std::vector bytes{std::istreambuf_iterator(file), {}}; + std::vector words(bytes.size() / 4); + if (!words.empty()) std::memcpy(words.data(), bytes.data(), words.size() * 4); + return words; +} + +// One run of the scenario on a new set with `null_descriptor`; the result words in `out`. +int run(vktest::Device& d, const VkPhysicalDeviceMemoryProperties& memory, bool null_descriptor, + std::array& out) { + const VkDevice dev = d.device; + BindlessFeatures features; + features.update_after_bind = true; + features.partially_bound = d.partially_bound; + features.null_descriptor = null_descriptor; + BindlessSet set(d.device_proc, dev, memory, features); + EXPECT(set.ok()); + + // The real 2D image: 1x1 RGBA8, cleared to a colour in the command buffer below. + const VkImage image = d.image(VK_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, VK_IMAGE_USAGE_SAMPLED_BIT); + EXPECT(image); + VkImageViewCreateInfo view_info{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; + view_info.image = image; + view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; + view_info.format = VK_FORMAT_R8G8B8A8_UNORM; + view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + VkImageView view = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreateImageView")(dev, &view_info, nullptr, &view) == VK_SUCCESS); + const DescriptorKey real_key = tsharp_of_type(9, 0x40); + const std::uint32_t real_index = set.add_image(ImageDimension::dim_2d, view, VK_IMAGE_LAYOUT_GENERAL); + EXPECT(real_index != 0); + set.insert_key(real_key, real_index); + + const std::array keys{DescriptorKey{}, tsharp_of_type(10, 0x10), tsharp_of_type(11, 0x20), + tsharp_of_type(8, 0x30), real_key, make_ssharp_key(std::array{}.data())}; + void* result_map = nullptr; + void* key_map = nullptr; + const VkBuffer result = d.buffer(result_words * 4, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &result_map); + const VkBuffer key_buffer = d.buffer(sizeof(keys), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &key_map); + EXPECT(result && key_buffer); + std::memset(result_map, 0xcd, result_words * 4); + std::memcpy(key_map, keys.data(), sizeof(keys)); + + const std::vector code = load_spirv(LEONIDA_TEST_NULL_DESCRIPTORS_SPV); + EXPECT(!code.empty()); + VkShaderModuleCreateInfo module_info{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO}; + module_info.codeSize = code.size() * 4; + module_info.pCode = code.data(); + VkShaderModule module = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreateShaderModule")(dev, &module_info, nullptr, &module) == VK_SUCCESS); + + const std::array bindings{{ + {0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr}, + {1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr}, + }}; + VkDescriptorSetLayoutCreateInfo set1_info{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO}; + set1_info.bindingCount = std::uint32_t(bindings.size()); + set1_info.pBindings = bindings.data(); + VkDescriptorSetLayout set1_layout = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreateDescriptorSetLayout")(dev, &set1_info, nullptr, + &set1_layout) == VK_SUCCESS); + const VkDescriptorPoolSize pool_size{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2}; + VkDescriptorPoolCreateInfo pool_info{VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO}; + pool_info.maxSets = 1; + pool_info.poolSizeCount = 1; + pool_info.pPoolSizes = &pool_size; + VkDescriptorPool pool = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreateDescriptorPool")(dev, &pool_info, nullptr, &pool) == VK_SUCCESS); + VkDescriptorSetAllocateInfo allocate{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO}; + allocate.descriptorPool = pool; + allocate.descriptorSetCount = 1; + allocate.pSetLayouts = &set1_layout; + VkDescriptorSet set1 = VK_NULL_HANDLE; + EXPECT(d.fn("vkAllocateDescriptorSets")(dev, &allocate, &set1) == VK_SUCCESS); + const VkDescriptorBufferInfo buffer_infos[2] = {{result, 0, VK_WHOLE_SIZE}, {key_buffer, 0, VK_WHOLE_SIZE}}; + VkWriteDescriptorSet writes[2]{}; + for (std::uint32_t b = 0; b < 2; ++b) { + writes[b] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + writes[b].dstSet = set1; + writes[b].dstBinding = b; + writes[b].descriptorCount = 1; + writes[b].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; + writes[b].pBufferInfo = &buffer_infos[b]; + } + d.fn("vkUpdateDescriptorSets")(dev, 2, writes, 0, nullptr); + + const VkDescriptorSetLayout layouts[2] = {set.layout(), set1_layout}; + const VkPushConstantRange push{VK_SHADER_STAGE_COMPUTE_BIT, 0, 4}; + VkPipelineLayoutCreateInfo layout_info{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO}; + layout_info.setLayoutCount = 2; + layout_info.pSetLayouts = layouts; + layout_info.pushConstantRangeCount = 1; + layout_info.pPushConstantRanges = &push; + VkPipelineLayout layout = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreatePipelineLayout")(dev, &layout_info, nullptr, &layout) == + VK_SUCCESS); + VkComputePipelineCreateInfo pipeline_info{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO}; + pipeline_info.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO}; + pipeline_info.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT; + pipeline_info.stage.module = module; + pipeline_info.stage.pName = "main"; + pipeline_info.layout = layout; + VkPipeline pipeline = VK_NULL_HANDLE; + EXPECT(d.fn("vkCreateComputePipelines")(dev, VK_NULL_HANDLE, 1, &pipeline_info, + nullptr, &pipeline) == VK_SUCCESS); + + bool flushed = false; + const bool ran = d.run([&](VkCommandBuffer cb) { + set.record_fallback_init(cb); + flushed = set.flush(cb, 0, [] { return std::uint64_t(0); }); + VkImageMemoryBarrier to_general{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER}; + to_general.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + to_general.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; + to_general.newLayout = VK_IMAGE_LAYOUT_GENERAL; + to_general.srcQueueFamilyIndex = to_general.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + to_general.image = image; + to_general.subresourceRange = view_info.subresourceRange; + d.fn("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, + nullptr, 1, &to_general); + const VkClearColorValue colour{{0.5f, 0.25f, 0.75f, 1.0f}}; + d.fn("vkCmdClearColorImage")(cb, image, VK_IMAGE_LAYOUT_GENERAL, &colour, 1, + &view_info.subresourceRange); + VkMemoryBarrier cleared{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + cleared.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + cleared.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; + d.fn("vkCmdPipelineBarrier")(cb, VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 1, &cleared, 0, + nullptr, 0, nullptr); + d.fn("vkCmdBindPipeline")(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline); + const VkDescriptorSet sets[2] = {set.set(), set1}; + d.fn("vkCmdBindDescriptorSets")(cb, VK_PIPELINE_BIND_POINT_COMPUTE, layout, 0, 2, + sets, 0, nullptr); + for (std::uint32_t mode = 0; mode < 2; ++mode) { + d.fn("vkCmdPushConstants")(cb, layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, 4, &mode); + d.fn("vkCmdDispatch")(cb, 1, 1, 1); + VkMemoryBarrier between{VK_STRUCTURE_TYPE_MEMORY_BARRIER}; + between.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + between.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_HOST_READ_BIT; + d.fn("vkCmdPipelineBarrier")( + cb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_HOST_BIT, 0, 1, &between, 0, nullptr, 0, + nullptr); + } + return true; + }); + set.table_upload_result(ran); + EXPECT(ran && flushed); + std::memcpy(out.data(), result_map, sizeof(out)); + + d.fn("vkDestroyPipeline")(dev, pipeline, nullptr); + d.fn("vkDestroyPipelineLayout")(dev, layout, nullptr); + d.fn("vkDestroyDescriptorPool")(dev, pool, nullptr); + d.fn("vkDestroyDescriptorSetLayout")(dev, set1_layout, nullptr); + d.fn("vkDestroyShaderModule")(dev, module, nullptr); + set.release_retired(); + d.fn("vkDestroyImageView")(dev, view, nullptr); + return 0; +} + +void print(const char* what, const std::array& r, std::uint32_t first, + std::uint32_t count) { + std::printf(" %-28s", what); + for (std::uint32_t i = 0; i < count; ++i) std::printf(" %08x", r[first + i]); + std::printf("\n"); +} + +// The checks every mode shares: the keys' indices, the sampled fallbacks and the real image. +int check_common(const std::array& r) { + print("indices (0 3D cube 1D real S#)", r, 0, 6); + print("fetch 2D / 2D array", r, 16, 8); + print("fetch 3D / 1D", r, 24, 8); + print("fetch real 2D", r, 32, 4); + print("sample 2D / cube", r, 36, 8); + print("sample 3D / 1D", r, 44, 8); + print("storage 2D f u i", r, 64, 12); + print("storage 2D array f u i", r, 76, 12); + print("storage 3D f u i", r, 88, 12); + print("storage 1D f u i", r, 100, 12); + print("atomics pass 0 / pass 1", r, 8, 2); + print("", r, 112, 2); + // Every null key finds index 0, the fallback of the binding the instruction picks; the real one its image. + EXPECT(r[0] == 0 && r[1] == 0 && r[2] == 0 && r[3] == 0 && r[5] == 0); + EXPECT(r[4] != 0); + // Every sampled fallback reads zeros, though pass 0 stored and added through every storage fallback. + for (std::uint32_t i = 16; i < 32; ++i) EXPECT(r[i] == 0); + for (std::uint32_t i = 36; i < 52; ++i) EXPECT(r[i] == 0); + // The real image reads its clear colour (0.5, 0.25, 0.75, 1) as RGBA8: the shader does reach images. + EXPECT(r[32] != 0 && r[35] == 0x3f800000u); + return 0; +} + +} // namespace + +int main() { +#ifndef LEONIDA_TEST_NULL_DESCRIPTORS_SPV + std::printf("unsupported: the test shader was not built (no glslangValidator)\n"); + return 77; +#else + vktest::Device d; + d.request_null_descriptor = true; + if (const auto status = d.initialize(); status != vktest::DeviceStatus::ready) + return status == vktest::DeviceStatus::unavailable ? 77 : 1; + if (!d.bindless) { + std::printf("unsupported: the device lacks the bindless set's descriptor-indexing features\n"); + return 77; + } + VkPhysicalDeviceMemoryProperties memory{}; + d.instance_fn("vkGetPhysicalDeviceMemoryProperties")(d.physical, &memory); + + std::array r{}; + if (d.null_descriptor) { + std::printf("null descriptors (VK_EXT_robustness2 nullDescriptor):\n"); + EXPECT(run(d, memory, true, r) == 0); + EXPECT(check_common(r) == 0); + // The stores were dropped: every storage fallback reads zero, and the atomics returned zero both times. + for (std::uint32_t i = 64; i < 112; ++i) EXPECT(r[i] == 0); + EXPECT(r[8] == 0 && r[9] == 0 && r[112] == 0 && r[113] == 0); + } else { + std::printf("the device has no VK_EXT_robustness2 nullDescriptor: only the image fallbacks are tested\n"); + } + + std::printf("storage fallback images:\n"); + EXPECT(run(d, memory, false, r) == 0); + EXPECT(check_common(r) == 0); + // The storage fallbacks are images of their own: they took the stores (which the sampled reads above did not + // see), and the atomics of pass 1 found what pass 0 left. (The uint class's storage fallback is also the + // r32ui one, so the exact values depend on the order of pass 0's store and add, which is not checked.) + EXPECT(r[64] != 0 && r[88] != 0 && r[100] != 0); + EXPECT(r[112] != 0 && r[113] != 0); + + if (d.validation_errors()) { + std::printf("%u validation errors\n", d.validation_errors()); + return 1; + } + std::printf("vk_null_descriptor: ok\n"); + return 0; +#endif +} diff --git a/runtime/test/vk_test_device.h b/runtime/test/vk_test_device.h index 079707aa90..66db0df3c1 100644 --- a/runtime/test/vk_test_device.h +++ b/runtime/test/vk_test_device.h @@ -8,6 +8,7 @@ #include "../src/queue_families.h" #include "../src/vulkan_device_filter.h" #include "../src/vulkan13_features.h" +#include "../src/vulkan_index_view.h" #include "vk_device_pick.h" #include "../src/subgroup_size.h" @@ -123,6 +124,11 @@ class Device { bool prepare_on_bind=false; bool cold_graphics_compile = false; bool pipeline_statistics_query = false; // pipelineStatisticsQuery enabled + bool request_multi_draw_indirect = false, request_draw_indirect_count = false; + bool draw_indirect_count_enabled = false; + bool request_robust_index_view = false, robust_index_view = false; + std::uint32_t max_draw_indirect_count = 0; + bool request_draw_indirect_first_instance = false; // enable the core feature only for positive indirect draws bool request_debug_utils = false; // set before create(): enable VK_EXT_debug_utils when the loader has it bool request_buffer_device_address = false; // set before create(): enable bufferDeviceAddress where supported bool buffer_device_address = false; // enabled: buffer() memory and buffers can be addressed (device_address()) @@ -136,6 +142,8 @@ class Device { bool custom_border_color = false; // VK_EXT_custom_border_color and customBorderColors enabled bool custom_border_color_without_format = false; bool shader_output_viewport_index = false; // Vulkan 1.2 shaderOutputViewportIndex enabled + bool request_null_descriptor = false; // set before initialize(): enable VK_EXT_robustness2 nullDescriptor + bool null_descriptor = false; // VK_EXT_robustness2 and nullDescriptor are enabled // VK_EXT_external_memory_host is enabled when non-zero: its minImportedHostPointerAlignment. VkDeviceSize host_pointer_alignment = 0; @@ -411,6 +419,9 @@ class Device { } enable11.shaderDrawParameters = features11.shaderDrawParameters; VkPhysicalDeviceVulkan12Features enable12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, &enable11}; + max_draw_indirect_count = chosen.limits.maxDrawIndirectCount; + draw_indirect_count_enabled = request_draw_indirect_count && features12.drawIndirectCount == VK_TRUE; + enable12.drawIndirectCount = draw_indirect_count_enabled; enable12.timelineSemaphore = VK_TRUE; enable12.separateDepthStencilLayouts = VK_TRUE; buffer_device_address = request_buffer_device_address && features12.bufferDeviceAddress == VK_TRUE; @@ -466,6 +477,8 @@ class Device { VkPhysicalDeviceFeatures enable{}; storage_image_extended_formats = features.features.shaderStorageImageExtendedFormats == VK_TRUE; enable.shaderStorageImageExtendedFormats = storage_image_extended_formats; + if (request_multi_draw_indirect) enable.multiDrawIndirect = features.features.multiDrawIndirect; + if (request_draw_indirect_first_instance) enable.drawIndirectFirstInstance = features.features.drawIndirectFirstInstance; enable.textureCompressionBC = features.features.textureCompressionBC; // BC uploads, where available enable.shaderInt64 = features.features.shaderInt64; // translated shaders declare Int64 (index features) bc = features.features.textureCompressionBC == VK_TRUE; @@ -570,10 +583,6 @@ class Device { a8_render_target = maintenance5.maintenance5 == VK_TRUE && (a8.optimalTilingFeatures & needed) == needed; } - if (a8_render_target) { - maintenance5.pNext = *v13_.next(); - *v13_.next() = &maintenance5; - } #endif const char* sliced_name = VK_EXT_IMAGE_SLICED_VIEW_OF_3D_EXTENSION_NAME; @@ -645,6 +654,47 @@ class Device { *v13_.next() = &custom_border; } + // Query just the requested robustness features (null descriptors and bounded indexed draws). + VkPhysicalDeviceRobustness2FeaturesEXT robustness2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; + for (const auto& extension : extensions) { + if ((!request_null_descriptor && !request_robust_index_view) || + std::strcmp(extension.extensionName, VK_EXT_ROBUSTNESS_2_EXTENSION_NAME) != 0) + continue; + VkPhysicalDeviceFeatures2 query{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &robustness2}; + instance_fn("vkGetPhysicalDeviceFeatures2")(physical, &query); + null_descriptor = request_null_descriptor && robustness2.nullDescriptor; +#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME + robust_index_view = leonida::can_enable_robust_index_view( + physical, instance_fn("vkGetPhysicalDeviceProperties2"), + request_robust_index_view && enable.drawIndirectFirstInstance && maintenance5.maintenance5, + features.features.robustBufferAccess && robustness2.robustBufferAccess2, bindless); +#endif + } +#ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME + if (a8_render_target || robust_index_view) { + maintenance5.pNext = *v13_.next(); + *v13_.next() = &maintenance5; + } +#endif + if (null_descriptor || robust_index_view) { + robustness2 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT}; + robustness2.nullDescriptor = null_descriptor; + robustness2.robustBufferAccess2 = robust_index_view; + enable.robustBufferAccess = robust_index_view; + robustness2.pNext = *v13_.next(); + *v13_.next() = &robustness2; + } + + // VK_EXT_external_memory_host where the device has it (OpenExistingHeapFromAddress). + for (const auto& extension : extensions) { + if (std::strcmp(extension.extensionName, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) != 0) continue; + VkPhysicalDeviceExternalMemoryHostPropertiesEXT host_memory{ + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT}; + VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &host_memory}; + instance_fn("vkGetPhysicalDeviceProperties2")(physical, &properties); + host_pointer_alignment = host_memory.minImportedHostPointerAlignment; + } + VkDeviceCreateInfo device_info{VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, &enable12}; device_info.queueCreateInfoCount = std::uint32_t(queue_infos.size()); device_info.pQueueCreateInfos = queue_infos.data(); @@ -666,7 +716,7 @@ class Device { if (conditional_rendering) device_extensions.push_back(conditional_extension); if (host_image_copy) device_extensions.push_back(host_image_copy_name); #ifdef VK_KHR_MAINTENANCE_5_EXTENSION_NAME - if (a8_render_target) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); + if (a8_render_target || robust_index_view) device_extensions.push_back(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); #endif if (host_pointer_alignment) device_extensions.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME); if (sliced_3d_uav) device_extensions.push_back(sliced_name); @@ -714,6 +764,7 @@ class Device { if (shader_fma) device_extensions.push_back(VK_KHR_SHADER_FMA_EXTENSION_NAME); #endif if (custom_border_color) device_extensions.push_back(custom_border_color_name); + if (null_descriptor || robust_index_view) device_extensions.push_back(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME); if (mesh_shader) device_extensions.push_back(VK_EXT_MESH_SHADER_EXTENSION_NAME); device_info.enabledExtensionCount = std::uint32_t(device_extensions.size()); device_info.ppEnabledExtensionNames = device_extensions.data(); diff --git a/runtime/test/xg_xs_test.cpp b/runtime/test/xg_xs_test.cpp index 65a31bd7f2..18356cb416 100644 --- a/runtime/test/xg_xs_test.cpp +++ b/runtime/test/xg_xs_test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -396,21 +397,42 @@ int main() { std::uint64_t cursor = 0; std::vector polled; const auto visit = [&](Entry& t) { polled.push_back(t.id); }; - leonida::poll_title_textures(entries, cursor, visit, [&] { return !polled.empty(); }); + const auto poll = [&](auto exhausted) { + const auto snapshot = leonida::title_texture_snapshot(entries); + leonida::poll_title_textures(snapshot, cursor, visit, exhausted); + }; + poll([&] { return !polled.empty(); }); check(polled == std::vector{1}, "budget stops after a background texture"); entries.erase(10); entries[50] = &added; - leonida::poll_title_textures(entries, cursor, visit, [&] { return polled.size() == 2; }); + poll([&] { return polled.size() == 2; }); check(polled == std::vector{1, 4}, "poll resumes after deletion and skips priority textures"); polled.clear(); - leonida::poll_title_textures(entries, cursor, visit, [] { return false; }); + poll([] { return false; }); check(polled == std::vector{5, 4}, "unlimited poll wraps once and includes new textures"); cursor = 20; polled.clear(); - for (unsigned pass = 0; pass < 3; ++pass) - leonida::poll_title_textures(entries, cursor, visit, [] { return true; }); + for (unsigned pass = 0; pass < 3; ++pass) poll([] { return true; }); check(polled == std::vector{4}, "an expired wall budget advances past priority entries to the next texture"); + // A fill made during a pass submits, and that submission destroys a retired image whose destructor erases its + // registry entry; the registry mutex is recursive for its owner on Windows, so the erase lands inside the pass. + // A walk over a snapshot keeps every entry of the pass alive and in order, which a walk over the registry + // itself cannot do: its iterator steps into a freed node. + std::map> registry; + for (std::uint64_t address = 1; address <= 32; ++address) + registry[address * 16] = std::make_shared(Entry{false, false, int(address)}); + std::vector walked; + const auto pass = leonida::title_texture_snapshot(registry); + for (const auto& entry : pass) { + walked.push_back(entry.second->id); + registry.erase(entry.first); // a retired image whose entry leaves mid-pass + registry[entry.first + 1] = entry.second; // and an image re-registered at the next address + } + std::vector every(32); + for (int i = 0; i < 32; ++i) every[i] = i + 1; + check(walked == every, "a pass walks every entry once even when a visit erases and re-registers"); + check(registry.size() == 32, "the registry kept the re-registrations made during the pass"); } { @@ -492,6 +514,42 @@ int main() { test_layout_model(); test_bijection_and_round_trip(); test_models_agree(); + ResourceDesc exposure{3, 0, 1, 1, 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, 0x100, 0x100001}; + void* target = nullptr; + if (!make(create, exposure, target, "create exposure readback render target")) return 1; + ResourceLayout exposure_layout{}; + check(slot(target, 2)(target, &exposure_layout) == S_OK, "exposure slot 2 returns layout"); + const auto& plane = exposure_layout.plane[0]; + const auto& mip = plane.mips[0]; + check(exposure_layout.planes == 1 && exposure_layout.mips == 1 && plane.offset == 0 && mip.offset == 0, + "first plane and mip start at the returned Map pointer"); + check(exposure_layout.size == 256 && mip.pitch_bytes == 256 && mip.slice_bytes == 256 && mip.size == 256, + "one RGBA32F texel occupies one aligned linear row"); + slot(target, 1)(target); + for (uint32_t flags : {kRenderTarget, kRenderTarget | 0x300000u}) { + auto variant = exposure; + variant.flags = flags; + if (!make(create, variant, target, "linear render target with console flag variants")) return 1; + ResourceLayout layout{}; + check(slot(target, 2)(target, &layout) == S_OK && + !std::memcmp(&layout, &exposure_layout, sizeof(layout)), "console flag variants have identical footprints"); + slot(target, 1)(target); + } + for (unsigned i = 0; i < 5; ++i) { + auto other = exposure; + switch (i) { + case 0: other.width = 2; break; + case 1: other.layout = 0x11b; break; + case 2: other.flags |= kDepthStencil; break; + case 3: other.samples = 4; break; + case 4: other.format = DXGI_FORMAT_R8_UNORM; break; + } + Texture primary{}; + check(!build_texture(other, primary), "the linear readback shortcut excludes other target layouts"); + target = nullptr; + check(create(&other, &target) == S_OK && target, "the other render targets still use the general layout model"); + if (target) slot(target, 1)(target); + } ResourceDesc d{3, 0, 256, 128, 1, 1, DXGI_FORMAT_R8_UNORM, 1, 0, 0, 0}; check(suggest(&d, 0, &d.layout) == S_OK && d.layout == 0x105, "2D SRV selects SW_4KB_S with aliased output"); diff --git a/runtime/test/xgameruntime_offline_test.cpp b/runtime/test/xgameruntime_offline_test.cpp index 56457d4726..b441868ba5 100644 --- a/runtime/test/xgameruntime_offline_test.cpp +++ b/runtime/test/xgameruntime_offline_test.cpp @@ -381,6 +381,10 @@ int main() { "XDisplayAcquireTimeoutDeferral rejects null out pointer"); check(at(launcher, 4)(launcher, &deferral) == S_OK && deferral != nullptr, "XDisplayAcquireTimeoutDeferral acquires a display power request handle"); + void* second = nullptr; + check(at(launcher, 4)(launcher, &second) == S_OK && second && second != deferral, + "concurrent display deferrals have distinct handles"); + at(launcher, 5)(launcher, second); at(launcher, 5)(launcher, deferral); at(launcher, 5)(launcher, nullptr); check(true, "XDisplayCloseTimeoutDeferralHandle closes handle and ignores null"); diff --git a/runtime/test/xmem_geometry_aliases_stub.cpp b/runtime/test/xmem_geometry_aliases_stub.cpp new file mode 100644 index 0000000000..c88ced9387 --- /dev/null +++ b/runtime/test/xmem_geometry_aliases_stub.cpp @@ -0,0 +1,9 @@ +// The D3D12 tests link gta6rt_d3d12_com without the xmem shim, but the device's compute input probe (LOCAL +// DIAGNOSTIC, shims/d3d12_compute_input_probe.h) asks xmem for the other addresses of a page. A test process has +// no xmem mappings, so the answer is none. +#include +#include + +namespace rt::xmem { +void geometry_aliases(std::uintptr_t, std::vector&) {} +} // namespace rt::xmem diff --git a/runtime/test/xmem_section_state.h b/runtime/test/xmem_section_state.h new file mode 100644 index 0000000000..8e4e9b66b9 --- /dev/null +++ b/runtime/test/xmem_section_state.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +inline DWORD expected_xmem_section_state() { + char value[4]{}; + const DWORD length = GetEnvironmentVariableA("LEONIDA_XMEM_SEC_COMMIT", value, sizeof(value)); + const bool wine = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr; + return wine && !(length == 1 && value[0] == '0') ? MEM_COMMIT : MEM_RESERVE; +} diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp index 03944b1e16..991388c7f5 100644 --- a/runtime/test/xmem_test.cpp +++ b/runtime/test/xmem_test.cpp @@ -8,6 +8,7 @@ // nothing committed, and one trace event per distinct (type, size). XMemVirtualAlloc accepts attribute words and console // graphics protection bits and commits 2 MiB guest pages; the placeholder flags pass through; physical pages keep their // contents across unmap and remap, alias when mapped twice, and scatter-map per address. +#include "xmem_section_state.h" #include #include #include @@ -405,16 +406,19 @@ bool in_view(const void* address) { return VirtualQuery(address, &info, sizeof(info)) && info.Type == MEM_MAPPED; } -// Physical pages are views of a reserved section and are committed on first touch. Windows then reports the page as -// MEM_COMMIT with its protection. Wine's VirtualQuery keeps reporting MEM_RESERVE and no protection for a view page -// that has been written and reads back, so a check of the reported state and protection has nothing to look at -// there. True for exactly that answer on that host; the caller says what it skips. -bool touched_view_reported_reserved(const MEMORY_BASIC_INFORMATION& info) { +bool wine_host() { static const bool wine = [] { const HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); return ntdll && GetProcAddress(ntdll, "wine_get_version") != nullptr; }(); - return wine && info.Type == MEM_MAPPED && info.State == MEM_RESERVE && info.Protect == 0; + return wine; +} + +// On Windows, physical pages are views of a reserved section and are committed on first touch; Windows then reports the +// page as MEM_COMMIT with its protection. Proton/Wine reports a written mapped view as MEM_RESERVE with no protection; +// this helper recognizes that measured result, and callers validate the data instead of assuming the state. +bool touched_view_reported_reserved(const MEMORY_BASIC_INFORMATION& info) { + return wine_host() && info.Type == MEM_MAPPED && info.State == MEM_RESERVE && info.Protect == 0; } struct PhysicalApi { @@ -504,10 +508,27 @@ void test_physical_pages(const PhysicalApi& api) { check(api.map(window, 1, &pages[0]) == window, "a page already mapped elsewhere maps again"); static_cast(static_cast(window))[1] = 0xfeedf00d; check(read_u32(second + 3 * kPage64k, 4) == 0xfeedf00d, "both mappings of a page see the same memory"); + { + // The D3D12 layer's geometry copies ask for a page's other addresses without xmem's physical-page lock. + std::vector at_window, at_second; + rt::xmem::geometry_aliases(reinterpret_cast(window), at_window); + rt::xmem::geometry_aliases(reinterpret_cast(second + 3 * kPage64k), at_second); + check(at_window.size() == 1 && at_window[0] == reinterpret_cast(second + 3 * kPage64k) && + at_second.size() == 1 && at_second[0] == reinterpret_cast(window), + "geometry_aliases names each address of a page mapped twice from the other"); + std::vector alone; + rt::xmem::geometry_aliases(reinterpret_cast(second), alone); + check(alone.empty(), "geometry_aliases names nothing for a page mapped once"); + } // Mapping over a mapped page replaces it; a 0 entry unmaps one page. const uint64_t replace[2] = {pages[1], 0}; check(api.map(window, 2, replace) == window, "mapping over mapped pages replaces them"); + { + std::vector after; + rt::xmem::geometry_aliases(reinterpret_cast(second + 3 * kPage64k), after); + check(after.empty(), "a page's other address leaves geometry_aliases once that mapping is replaced"); + } check(page_holds(window, 0x2000u) && reserved_only(window + kPage64k), "the first page now shows page 1 and a 0 entry left the second unmapped"); @@ -559,6 +580,58 @@ void test_physical_pages(const PhysicalApi& api) { // rt::xmem::copy_page_mappings_fn, behind console queue slot 31 (CopyPageMappingsBatchX): a destination page maps the // physical page that is mapped at the source page, so both addresses are one memory, as two XMemMapPhysicalPages calls // with the same page would make them. +void test_stream_cpu_twin(const PhysicalApi& api) { + constexpr uint32_t n = 3; + const auto window = [&] { + return static_cast(api.virtual_alloc(nullptr, n * kPage64k, MEM_RESERVE | kXmem64kPages, + 0x23, PAGE_READWRITE)); + }; + auto* cpu = window(); + auto* gpu = window(); + auto* source = window(); + uint64_t count = n, frames[n]{}; + check(cpu && gpu && source && api.allocate(0x280, &count, frames) && count == n, "stream twin setup"); + if (!cpu || !gpu || !source || !frames[2]) return; + check(api.map(source, n, frames) == source, "stream source frames registered"); + for (uint32_t i = 0; i < n; ++i) fill_page(source + i * kPage64k, 0x4100 + i); + char previous[16]{}; + GetEnvironmentVariableA("LEONIDA_SLOT31_CPU_TWIN", previous, sizeof(previous)); + const auto pair = [&](bool enabled) { + SetEnvironmentVariableA("LEONIDA_SLOT31_CPU_TWIN", enabled ? "1" : "0"); + rt::xmem::note_stream_reservation(uintptr_t(cpu), n * kPage64k, 0x1e1d00f); + rt::xmem::note_stream_reservation(uintptr_t(gpu), n * kPage64k, 0x1e1d03e); + }; + const auto batch = [&](uint32_t kind) { + const rt::xmem::PageRange range{kind, 0, n}; + const rt::xmem::PageBatch b{uintptr_t(gpu), 1, &range}; + return rt::xmem::copy_page_mappings(1, &b, uintptr_t(source), n, 0); + }; + pair(false); + check(batch(0) && reserved_only(cpu), "switch off leaves the CPU twin empty"); + pair(true); + check(batch(0) && page_holds(cpu, 0x4100) && page_holds(cpu + 2 * kPage64k, 0x4102), + "unchanged GPU frames gain matching CPU views"); + fill_page(cpu, 0x5110); + check(page_holds(gpu, 0x5110), "CPU mirror writes reach the GPU alias"); + void* middle = cpu + kPage64k; + check(api.scatter(&middle, 1, frames + 1), "scatter takes ownership even of the same frame"); + check(batch(1) && page_holds(cpu + kPage64k, 0x4101) && page_holds(cpu + 2 * kPage64k, 0x5110), + "repeat remaps only mirror-owned CPU pages"); + check(batch(2) && reserved_only(cpu) && reserved_only(cpu + 2 * kPage64k) && page_holds(cpu + kPage64k, 0x4101), + "GPU unmap removes mirrors and preserves the scatter mapping"); + check(batch(0) && api.map(source, 1, nullptr) == source && batch(0) && reserved_only(cpu), + "a source hole removes its CPU mirror"); + auto* other_cpu = window(); + auto* other_gpu = api.virtual_alloc(nullptr, n * kPage64k, MEM_RESERVE | kXmem64kPages, 0x3, 0x801); + const rt::xmem::PageRange other_range{0, 1, 1}; + const rt::xmem::PageBatch other_batch{uintptr_t(other_gpu), 1, &other_range}; + check(other_gpu && other_cpu && rt::xmem::copy_page_mappings(1, &other_batch, uintptr_t(source), n, 0) + && reserved_only(other_cpu), "slot 31 outside the stream pool leaves other CPU reservations empty"); + rt::xmem::note_stream_reservation(0, 0, 0x1e1d00f); + SetEnvironmentVariableA("LEONIDA_SLOT31_CPU_TWIN", *previous ? previous : nullptr); +} + +// Ported from CLHelper's RT-QUEUE31 tests, Leonida Continued f2268abea. void test_copy_page_mappings(const PhysicalApi& api) { const auto copy = rt::xmem::copy_page_mappings_fn; check(copy != nullptr, "xmem.cpp sets the copy_page_mappings hook"); @@ -693,11 +766,678 @@ bool access_faults(volatile uint32_t* address, bool write) { return false; } +struct SectionWriteControl { + bool valid = false; + bool initial_reserved = false; + bool write_faulted = false; + bool reserved_after = false; + uint32_t readback = 0; +}; + +SectionWriteControl g_section_write_control; + +// Measure a plain SEC_RESERVE view before XMemAllocatePhysicalPages installs xmem's VEH. Wine and native Windows do +// not expose the same write/query behavior here, so foreign-section tests must compare the shim's views with this +// direct host control rather than use a host-name skip. +SectionWriteControl measure_section_write_control() { + SectionWriteControl control; + const HANDLE section = + CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, 0, kPage64k, nullptr); + void* const view = section ? MapViewOfFile(section, FILE_MAP_WRITE, 0, 0, kPage64k) : nullptr; + MEMORY_BASIC_INFORMATION before{}; + control.initial_reserved = view && VirtualQuery(view, &before, sizeof(before)) && before.Type == MEM_MAPPED && + before.State == MEM_RESERVE; + if (control.initial_reserved) { + control.write_faulted = access_faults(static_cast(view), true); + control.reserved_after = reserved_only(view); + if (!control.write_faulted) control.readback = read_u32(view, 0); + control.valid = true; + std::printf("CONTROL SEC_RESERVE view: write %s, state %s, readback 0x%08x\n", + control.write_faulted ? "faulted" : "completed", + control.reserved_after ? "reserved" : "committed", control.readback); + } else + std::printf("CONTROL SEC_RESERVE view unavailable; foreign writes keep the original fault assertion\n"); + if (view) UnmapViewOfFile(view); + if (section) CloseHandle(section); + return control; +} + +void check_section_write_against_control(void* view, const char* label) { + const bool initially_reserved = reserved_only(view); + const bool faulted = access_faults(static_cast(view), true); + const bool reserved = reserved_only(view); + const uint32_t readback = faulted ? 0 : read_u32(view, 0); + if (!g_section_write_control.valid) { + check(initially_reserved && faulted && reserved, label); + return; + } + // Native Windows must retain the measured contract: an uncommitted SEC_RESERVE write faults. On other hosts, use + // the direct control's result and require the same state and, when writable, the same actual data. + const bool expected_fault = !wine_host() ? true : g_section_write_control.write_faulted; + bool ok = initially_reserved == g_section_write_control.initial_reserved && faulted == expected_fault && + reserved == g_section_write_control.reserved_after; + if (!faulted) ok = ok && readback == g_section_write_control.readback && readback == 1; + check(ok, label); +} + int64_t commit_growth(const PERFORMANCE_INFORMATION& from, const PERFORMANCE_INFORMATION& to) { return (static_cast(to.CommitTotal) - static_cast(from.CommitTotal)) * static_cast(to.PageSize); } +// A title writes a window page it never mapped. Measured at the story load: a 288 KiB clear into a page of a window +// reserved for physical pages, a page the title never passed to XMemMapPhysicalPages (runs/hrp13, gw2, tw512b, int1). +// The console's window memory is zeroed and writable; on the host the placeholder there is PAGE_NOACCESS, so the write +// fault must be answered with a zeroed page rather than left to the title. +// MapViewOfFile3 / UnmapViewOfFile2 are kernelbase-only: the runtime resolves them at run time, and so does the test. +using MapViewOfFile3Fn = void*(WINAPI*)(HANDLE, HANDLE, void*, ULONG64, SIZE_T, ULONG, ULONG, void*, ULONG); +using UnmapViewOfFile2Fn = BOOL(WINAPI*)(HANDLE, const void*, ULONG); + +void* map_view_of_file3(HANDLE section, void* at, SIZE_T size) { + static MapViewOfFile3Fn fn = [] { + const HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); + return kernelbase ? reinterpret_cast(GetProcAddress(kernelbase, "MapViewOfFile3")) : nullptr; + }(); + return fn ? fn(section, GetCurrentProcess(), at, 0, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE, nullptr, 0) + : nullptr; +} + +bool unmap_view_of_file2(void* view) { + static UnmapViewOfFile2Fn fn = [] { + const HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); + return kernelbase ? reinterpret_cast(GetProcAddress(kernelbase, "UnmapViewOfFile2")) + : nullptr; + }(); + return fn && fn(GetCurrentProcess(), view, MEM_PRESERVE_PLACEHOLDER); +} + +bool clear_faults(void* at, size_t bytes) { + __try { + std::memset(at, 0, bytes); + } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return true; + } + return false; +} + +// A title clears a grid straight into a physical-page window, across pages it never mapped: the measured story-load +// memset (0x48000 bytes, VCRUNTIME140) whose write into a placeholder killed the boot. A page the title never mapped +// is zeroed and writable (the console's window memory), a mapping over such a page replaces it, and the zero pages are +// reused rather than committed per plant. +void test_unmapped_window_page(const PhysicalApi& api) { + constexpr uint64_t kPages = 6; + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPages * kPage64k, MEM_RESERVE | kXmem64kPages, 0x25, PAGE_READWRITE)); + check(window != nullptr, "XMemVirtualAlloc reserves a window with pages left unmapped"); + if (!window) return; + uint64_t pages[kPages]{}; + uint64_t count = kPages; + if (api.allocate(0x281, &count, pages) != TRUE || count != kPages) { + check(false, "six physical pages for the window"); + return; + } + check(api.map(window, 1, pages) == window && api.map(window + 5 * kPage64k, 1, pages + 5) == window + 5 * kPage64k, + "the window's first and last pages map"); + check(reserved_only(window + kPage64k) && reserved_only(window + 2 * kPage64k), + "the pages between them stay placeholders"); + + // A plant reads as zero everywhere the title did not write. + auto* const middle = reinterpret_cast(window + kPage64k); + check(!clear_faults(window + kPage64k + 4, 4), "clearing a word of the unmapped page is answered"); + check(middle[0] == 0, "the rest of the planted page reads as zero"); + check(middle[1] == 0, "and reads back the clear"); + + // The measured clear: 0x48000 bytes from page 0, over the mapped page 0 and the unmapped pages 1 to 4. + check(!clear_faults(window, 0x48000), "a 288 KiB clear across mapped and unmapped pages takes no fault"); + bool committed = true; + for (uint64_t i = 0; i <= 4; ++i) { + MEMORY_BASIC_INFORMATION info{}; + committed &= VirtualQuery(window + i * kPage64k, &info, sizeof(info)) && info.State == MEM_COMMIT; + } + check(committed, "every page the clear reached is committed"); + + // A mapping over a planted page replaces it: the physical page's contents win, and the mapping succeeds. + static_cast(static_cast(window + 2 * kPage64k))[0] = 0x7e570001; + check(api.map(window + 2 * kPage64k, 1, pages + 2) == window + 2 * kPage64k, + "a mapping over a planted page succeeds"); + check(read_u32(window + 2 * kPage64k, 0) == 0, "the mapped page shows the physical page, not the plant"); + + // Plant and replace in a loop: a replaced plant returns its section page, so no new one is handed out. + { + constexpr uint64_t kCycles = 32; + const uint64_t taken_before = rt::xmem::zero_pages_taken(); + bool cycled = true; + for (uint64_t i = 0; i < kCycles; ++i) { + static_cast(static_cast(window + 3 * kPage64k))[0] = 0x5151u + i; + cycled &= api.map(window + 3 * kPage64k, 1, pages + 3) == window + 3 * kPage64k; + void* const at = window + 3 * kPage64k; + cycled &= api.scatter(&at, 1, nullptr) == TRUE; + } + check(cycled, "32 plant-and-replace cycles map and unmap"); + check(rt::xmem::zero_pages_taken() == taken_before, + "32 plant-and-replace cycles reuse the zero pages (no new section page)"); + } + + // A mapped section page the view table does not name (a section the title took over): the fault commits it. + auto* const lone = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x25, PAGE_READWRITE)); + HANDLE section = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, 0, kPage64k, nullptr); + void* const view = lone && section ? map_view_of_file3(section, lone, kPage64k) : nullptr; + check(lone && section && view == lone, "a section view of the title's own maps into a window page"); + if (lone && section && view == lone) { + check(reserved_only(lone), "the section page is reserved, as xmem's own views are before a commit"); + check(!access_faults(reinterpret_cast(static_cast(lone)), true), + "a write into a mapped but uncommitted window page is answered"); + MEMORY_BASIC_INFORMATION info{}; + if (VirtualQuery(lone, &info, sizeof(info)) && touched_view_reported_reserved(info)) { + check(read_u32(lone, 0) == 1, "the mapped section page reads back the write despite its reported state"); + std::printf("SKIP the mapped section page's reported state: the host reports a written view as reserved\n"); + } + else + check(info.State == MEM_COMMIT, "and the page is committed"); + unmap_view_of_file2(view); + } + // The same page outside every window, in a placeholder the title reserved itself (XMemVirtualAlloc with + // MEM_RESERVE_PLACEHOLDER): still the title's memory, so the fault still commits it. (A section page outside the + // title's reservations is not: test_foreign_section_writes.) + auto* const plain = static_cast(api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, + 0x25, PAGE_READWRITE)); + HANDLE plain_section = + CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, 0, kPage64k, nullptr); + void* const plain_view = plain && plain_section ? map_view_of_file3(plain_section, plain, kPage64k) : nullptr; + check(plain && plain_section && plain_view == plain, "a section view maps into a placeholder that is not a window"); + if (plain && plain_section && plain_view == plain) { + check(!access_faults(reinterpret_cast(static_cast(plain)), true), + "a write into a mapped, uncommitted page outside every window is answered"); + MEMORY_BASIC_INFORMATION info{}; + if (VirtualQuery(plain, &info, sizeof(info)) && touched_view_reported_reserved(info)) { + check(read_u32(plain, 0) == 1, "the placeholder section page reads back the write despite its reported state"); + std::printf("SKIP the placeholder section page's reported state: the host reports a written view as reserved\n"); + } + else + check(info.State == MEM_COMMIT, "and that page is committed"); + unmap_view_of_file2(plain_view); + } + if (plain_section) CloseHandle(plain_section); + if (section) CloseHandle(section); + + check(api.map(window, kPages, nullptr) == window, "the window unmaps"); + check(api.free_pages(kPages, pages) == TRUE, "the physical pages are freed"); +} + +// A write racing a remap of its page is answered, not lost: a thread writes into the page while another maps and +// unmaps it. No access violation may escape to the next handler, and the last write must land in the final mapping. +// `reps` remaps per run (xmem_test --remap-reps runs it many times): the writes that went through, the faults the +// handler answered while they did (the races the run made), and the writes that escaped. +struct RemapRace { + uint64_t writes = 0, faults = 0, escaped = 0; +}; + +uint64_t answered_faults() { + using rt::xmem::FaultExit; + return rt::xmem::fault_exits(FaultExit::answered) + rt::xmem::fault_exits(FaultExit::planted) + + rt::xmem::fault_exits(FaultExit::committed); +} + +RemapRace test_write_during_remap(const PhysicalApi& api, int reps = 200) { + constexpr uint64_t kPages = 2; + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + uint64_t pages[kPages]{}; + uint64_t count = kPages; + check(window && api.allocate(0x282, &count, pages) == TRUE && count == kPages, "a window and two pages to remap"); + if (!window || count != kPages) return {}; + check(api.map(window, 1, pages) == window, "the page starts mapped"); + const uint64_t left_before = rt::xmem::fault_exits(rt::xmem::FaultExit::left_to_title); + const uint64_t answered_before = answered_faults(); + std::atomic stop{false}; + std::atomic escaped{0}, writes{0}; + std::thread writer([&] { + for (uint32_t v = 1; !stop.load(std::memory_order_relaxed); ++v) { + auto* const word = reinterpret_cast(static_cast(window)); + if (access_faults(word, true)) { + escaped.fetch_add(1, std::memory_order_relaxed); + continue; + } + *word = v; + writes.fetch_add(1, std::memory_order_relaxed); + } + }); + // The writer is writing before the first remap: 300 remaps take about 10 ms, less than a new thread can take to + // start, and a race the writer joins late (or not at all) tests nothing. + const ULONGLONG started = GetTickCount64(); + while (writes.load(std::memory_order_relaxed) == 0 && GetTickCount64() - started < 10000) SwitchToThread(); + bool remapped = true; + for (int i = 0; i < reps; ++i) { + remapped &= api.map(window, 1, pages + 1) == window; + remapped &= api.map(window, 1, nullptr) == window; + SwitchToThread(); + } + stop = true; + writer.join(); + const ULONGLONG elapsed = GetTickCount64() - started; + check(remapped, "the page maps and unmaps under a writer"); + const uint64_t left = rt::xmem::fault_exits(rt::xmem::FaultExit::left_to_title) - left_before; + const uint64_t faults = answered_faults() - answered_before; + check(escaped.load() == 0 && writes.load() > 0, "every write into the remapped page is answered, none escapes"); + // An escape the handler did not count as left to the title (and note) went out by an exit nothing records. + check(left == escaped.load(), "every write that escaped was left to the title by the handler, and noted"); + if (escaped.load() || left) + std::printf(" %llu of %llu writes escaped; the handler left %llu to the title\n", + static_cast(escaped.load()), static_cast(writes.load()), + static_cast(left)); + check(elapsed < 30000 + static_cast(reps) * 100, "the remap race finishes without hanging"); + check(api.map(window, 1, pages) == window, "the page is mapped again"); + *reinterpret_cast(static_cast(window)) = 0x600dcafe; + check(read_u32(window, 0) == 0x600dcafe, "a write after the race lands in the mapping"); + api.map(window, 1, nullptr); + check(api.free_pages(kPages, pages) == TRUE, "the remap race pages are freed"); + return {writes.load(), faults, escaped.load()}; +} + +// The fault race seam (rt::xmem::set_fault_race_hook): the thread g_race_thread names is held at stage g_race_stage of +// its fault, once, until the test has mapped or planted the page it faulted on from another thread. +std::atomic g_race_thread{0}; +std::atomic g_race_stage{-1}; +HANDLE g_race_reached = nullptr; +HANDLE g_race_resume = nullptr; + +void race_hook(int stage) { + if (stage != g_race_stage.load() || GetCurrentThreadId() != g_race_thread.load()) return; + g_race_thread = 0; // once + SetEvent(g_race_reached); + WaitForSingleObject(g_race_resume, 10000); +} + +enum class Racer { map, map_and_touch, plant }; + +// One race, made to happen: a writer faults on an unmapped window page and is held after the handler's first look +// (stage 0) or just before its exclusive lock (stage 1); meanwhile the page is mapped (and maybe committed by a write of +// this thread's), or another thread's write plants it. The held write must then be answered, not left to the title. +void run_first_touch_race(const PhysicalApi& api, int stage, Racer racer) { + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + uint64_t page = 0, count = 1; + if (!window || api.allocate(0x280, &count, &page) != TRUE || count != 1) { + check(false, "a window and a page for a first-touch race"); + return; + } + ResetEvent(g_race_reached); + ResetEvent(g_race_resume); + g_race_stage = stage; + std::atomic escaped{false}; + std::thread writer([&] { + g_race_thread = GetCurrentThreadId(); + escaped = access_faults(reinterpret_cast(static_cast(window + 0x10)), true); + }); + const bool reached = WaitForSingleObject(g_race_reached, 10000) == WAIT_OBJECT_0; + bool raced = reached; + if (reached) { + if (racer == Racer::plant) { + std::thread other([&] { + raced &= !access_faults(reinterpret_cast(static_cast(window + 0x20)), true); + }); + other.join(); + } else { + raced &= api.map(window, 1, &page) == window; + if (racer == Racer::map_and_touch) + raced &= !access_faults(reinterpret_cast(static_cast(window + 0x20)), true); + } + } + SetEvent(g_race_resume); + writer.join(); + g_race_stage = -1; + g_race_thread = 0; + char what[160]; + static const char* const names[] = {"a map", "a map and a write", "another thread's plant"}; + std::snprintf(what, sizeof what, "first-touch race at stage %d against %s: the held write is answered", stage, + names[static_cast(racer)]); + const uint32_t racer_wrote = racer == Racer::map ? 0u : 1u; + check(reached && raced && !escaped.load() && read_u32(window, 0x10) == 1u && read_u32(window, 0x20) == racer_wrote, + what); + api.map(window, 1, nullptr); + api.free_pages(1, &page); +} + +void test_first_touch_races(const PhysicalApi& api) { + g_race_reached = CreateEventW(nullptr, TRUE, FALSE, nullptr); + g_race_resume = CreateEventW(nullptr, TRUE, FALSE, nullptr); + rt::xmem::set_fault_race_hook(&race_hook); + for (int stage = 0; stage <= 1; ++stage) + for (const Racer racer : {Racer::map, Racer::map_and_touch, Racer::plant}) run_first_touch_race(api, stage, racer); + rt::xmem::set_fault_race_hook(nullptr); + CloseHandle(g_race_reached); + CloseHandle(g_race_resume); + + // The same races left to the scheduler: two threads first-touch one unmapped page behind a barrier, then a write + // races a map of the page. None may escape. + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + uint64_t page = 0, count = 1; + if (!window || api.allocate(0x280, &count, &page) != TRUE || count != 1) { + check(false, "a window and a page for the barrier races"); + return; + } + constexpr uint32_t kRounds = 400; + for (int variant = 0; variant < 2; ++variant) { + std::atomic go{0}, done{0}; + std::atomic escaped{0}; + std::atomic mapped_ok{true}; + std::vector threads; + for (int t = 0; t < 2; ++t) + threads.emplace_back([&, t] { + for (uint32_t round = 1; round <= kRounds; ++round) { + while (go.load(std::memory_order_acquire) < round) YieldProcessor(); + if (variant == 1 && t == 1) { + if (api.map(window, 1, &page) != window) mapped_ok = false; + } else { + auto* const word = + reinterpret_cast(static_cast(window + 0x100 + 4 * t)); + if (access_faults(word, true)) escaped.fetch_add(1); + } + done.fetch_add(1, std::memory_order_acq_rel); + } + }); + bool unmapped = true; + for (uint32_t round = 1; round <= kRounds; ++round) { + go.store(round, std::memory_order_release); + while (done.load(std::memory_order_acquire) < 2 * round) YieldProcessor(); + unmapped &= api.map(window, 1, nullptr) == window; // a placeholder again for the next round + } + for (auto& thread : threads) thread.join(); + check(unmapped && mapped_ok.load(), variant == 0 ? "the page unmaps after every round of two first touches" + : "the page maps and unmaps in every round of a write racing a map"); + check(escaped.load() == 0, variant == 0 ? "two threads first-touching one unmapped page: no write escapes" + : "a write racing a map of its page: no write escapes"); + } + api.free_pages(1, &page); +} + +// Two threads held at once (the decision races below): each hold stops the thread it names at its stage, once, until +// the test resumes it. +struct Hold { + std::atomic thread{0}; + std::atomic stage{-1}; + HANDLE reached = nullptr, resume = nullptr; +}; +Hold g_holds[2]; + +void holds_hook(int stage) { + const DWORD self = GetCurrentThreadId(); + for (Hold& hold : g_holds) { + if (hold.stage.load() != stage || hold.thread.load() != self) continue; + hold.thread = 0; // once + SetEvent(hold.reached); + WaitForSingleObject(hold.resume, 10000); + } +} + +void arm_hold(Hold& hold, int stage) { + ResetEvent(hold.reached); + ResetEvent(hold.resume); + hold.thread = 0; + hold.stage = stage; +} + +bool hold_reached(const Hold& hold) { return WaitForSingleObject(hold.reached, 10000) == WAIT_OBJECT_0; } + +using VirtualAlloc2Fn = void*(WINAPI*)(HANDLE, void*, SIZE_T, ULONG, ULONG, void*, ULONG); + +// A window page that is a placeholder of its own, made free and then reserved again: what the host shows a reader part +// way through MapViewOfFile3 or UnmapViewOfFile2 (MEM_FREE, seen on Windows 11), made to last as long as the test needs +// it. Only while xmem holds its fault lock exclusively for a remap of the page. +bool free_placeholder(void* page) { return VirtualFree(page, 0, MEM_RELEASE) != FALSE; } + +bool reserve_placeholder_again(void* page, SIZE_T size) { + static VirtualAlloc2Fn fn = [] { + const HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); + return kernelbase ? reinterpret_cast(GetProcAddress(kernelbase, "VirtualAlloc2")) : nullptr; + }(); + return fn && fn(GetCurrentProcess(), page, size, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS, nullptr, 0) == + page; +} + +// The handler decides on what it read under its lock. Each race is made to happen with the race seam's stages: +// 0. a write held inside its shared look, after the query it decides on: a map of its page cannot complete until the +// write lets the lock go (with the query outside the lock it could, and the write would act on a page that +// changed under it); +// 1. a write held after its look while the page is mapped, written through, and unmapped again: it is planted; +// 2. a write held after its look while a remap of its page is part way, the page free on the host (as it reads inside +// MapViewOfFile3): it waits for the remap and lands in the mapping, rather than being passed on. +// None of them may escape, and the handler may leave none to the title. +void test_decision_races(const PhysicalApi& api) { + for (Hold& hold : g_holds) { + hold.reached = CreateEventW(nullptr, TRUE, FALSE, nullptr); + hold.resume = CreateEventW(nullptr, TRUE, FALSE, nullptr); + } + rt::xmem::set_fault_race_hook(&holds_hook); + const uint64_t left_before = rt::xmem::fault_exits(rt::xmem::FaultExit::left_to_title); + const auto word_at = [](uint8_t* window, size_t offset) { + return reinterpret_cast(static_cast(window + offset)); + }; + for (int scenario = 0; scenario < 3; ++scenario) { + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + uint64_t page = 0, count = 1; + if (!window || api.allocate(0x280, &count, &page) != TRUE || count != 1) { + check(false, "a window and a page for a decision race"); + break; + } + Hold& writer_hold = g_holds[0]; + Hold& mapper_hold = g_holds[1]; + arm_hold(writer_hold, scenario == 0 ? rt::xmem::kFaultDecided : rt::xmem::kFaultAfterLook); + arm_hold(mapper_hold, scenario == 2 ? rt::xmem::kRemapBetween : -1); + std::atomic escaped{false}, written{false}; + std::thread writer([&] { + writer_hold.thread = GetCurrentThreadId(); + escaped = access_faults(word_at(window, 0x10), true); + written = true; + }); + const bool writer_held = hold_reached(writer_hold); + bool ok = writer_held; + if (scenario == 0 && writer_held) { + // The writer holds the lock shared: the map waits for it. + std::atomic mapped{false}, map_ok{false}; + std::thread mapper([&] { + map_ok = api.map(window, 1, &page) == window; + mapped = true; + }); + Sleep(200); + const bool waited = !mapped.load(); + SetEvent(writer_hold.resume); + mapper.join(); + writer.join(); + check(waited, "decision race: a map of the page waits while a write decides under the shared lock"); + ok &= waited && map_ok.load(); + } else if (scenario == 1 && writer_held) { + // The look saw a placeholder. The page is mapped, written through, and unmapped before the write goes on. + ok &= api.map(window, 1, &page) == window; + ok &= !access_faults(word_at(window, 0x20), true); + ok &= api.map(window, 1, nullptr) == window && reserved_only(window); + SetEvent(writer_hold.resume); + writer.join(); + ok &= read_u32(window, 0x10) == 1u && read_u32(window, 0x20) == 0u; // a fresh plant holds the write + check(ok, "decision race: a write whose page is mapped and unmapped after its look is planted"); + } else if (scenario == 2 && writer_held) { + // A remap held between its unmap and its map, the exclusive lock held, the page free on the host. + std::atomic map_ok{false}; + std::thread mapper([&] { + mapper_hold.thread = GetCurrentThreadId(); + map_ok = api.map(window, 1, &page) == window; + }); + const bool mapper_held = hold_reached(mapper_hold); + const bool freed = mapper_held && free_placeholder(window); + SetEvent(writer_hold.resume); // the write goes on, to the exclusive lock the remap holds + Sleep(200); + const bool waited = !written.load() && !escaped.load(); + const bool reserved = freed && reserve_placeholder_again(window, kPage64k); + SetEvent(mapper_hold.resume); + mapper.join(); + writer.join(); + check(mapper_held && freed && reserved, "decision race: a remap is held part way, its page free on the host"); + check(waited, "decision race: a write after its look waits for a remap in flight"); + ok &= mapper_held && reserved && waited && map_ok.load() && read_u32(window, 0x10) == 1u; + check(ok, "decision race: the write lands in the mapping the remap made"); + } else { + SetEvent(writer_hold.resume); + writer.join(); + } + char what[128]; + std::snprintf(what, sizeof what, "decision race %d: the held write is answered, none escapes", scenario); + check(ok && written.load() && !escaped.load(), what); + for (Hold& hold : g_holds) hold.stage = -1; + api.map(window, 1, nullptr); + api.free_pages(1, &page); + } + rt::xmem::set_fault_race_hook(nullptr); + check(rt::xmem::fault_exits(rt::xmem::FaultExit::left_to_title) == left_before, + "decision races: the handler left no write to the title"); + for (Hold& hold : g_holds) { + CloseHandle(hold.reached); + CloseHandle(hold.resume); + hold.reached = hold.resume = nullptr; + } +} + +bool fill_faults(void* page, uint32_t tag) { + __try { + fill_page(page, tag); + } __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return true; + } + return false; +} + +// The zero pool moves on to a new section after 1,024 live plants. A plant of the older section that is released +// afterwards must not hand its page's offset to the newer section, where another live plant has it: 2,100 plants span +// at least two sections whatever the pool held before, the first 1,100 (all of the full section among them) are +// released and planted again, and every page must still be its own. +void test_zero_pool_rollover(const PhysicalApi& api) { + constexpr uint64_t kPages = 2100, kReleased = 1100; + auto* const window = static_cast( + api.virtual_alloc(nullptr, kPages * kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + check(window != nullptr, "a 2,100-page window nothing is mapped into"); + if (!window) return; + const auto tag = [](uint64_t i, uint32_t round) { return static_cast((i + 1) << 12) + round * 0x10000000u; }; + bool answered = true; + for (uint64_t i = 0; i < kPages; ++i) answered &= !fill_faults(window + i * kPage64k, tag(i, 1)); + check(answered, "2,100 writes into unmapped window pages are all answered"); + check(api.map(window, kReleased, nullptr) == window, "the first 1,100 plants are released"); + answered = true; + bool fresh = true; + for (uint64_t i = 0; i < kReleased; ++i) { + answered &= !fill_faults(window + i * kPage64k, tag(i, 2)); + fresh &= read_u32(window + i * kPage64k, 4) == 0; + } + check(answered && fresh, "they are planted again, zeroed"); + bool kept = true, own = true; + for (uint64_t i = kReleased; i < kPages; ++i) kept &= page_holds(window + i * kPage64k, tag(i, 1)); + for (uint64_t i = 0; i < kReleased; ++i) own &= page_holds(window + i * kPage64k, tag(i, 2)); + check(kept, "the plants that stayed keep their contents after older plants are released and planted again"); + check(own, "every plant made again holds its own contents (no two plants share a page)"); + check(api.map(window, kPages, nullptr) == window, "the rollover window unmaps"); +} + +// Section pages outside the title's reserved memory are not the title's, however a wild write reaches them: a write +// into a physical page's scratch view (xmem's own mirror of its section), into a section view another component mapped, +// or into a view mapped where the title released a placeholder of its own, faults and leaves the page uncommitted. +void test_foreign_section_writes(const PhysicalApi& api) { + uint64_t page = 0, count = 1; + check(api.allocate(0x280, &count, &page) == TRUE && count == 1, "a physical page for the scratch-view write"); + if (count == 1) { + auto* const scratch = reinterpret_cast(rt::xmem::physical_page_scratch(page)); + MEMORY_BASIC_INFORMATION info{}; + check(scratch && VirtualQuery(scratch, &info, sizeof(info)) && info.State == expected_xmem_section_state(), + "the scratch view has the initial state of its physical section"); + if (scratch) { + if (expected_xmem_section_state() == MEM_RESERVE) + check_section_write_against_control( + scratch, "a write into a reserved section's scratch view matches the host control"); + else { + const bool faulted = access_faults(reinterpret_cast(static_cast(scratch)), true); + const bool reserved = reserved_only(scratch); + const uint32_t readback = faulted ? 0 : read_u32(scratch, 0); + check(!faulted && !reserved && readback == 1, + "a write into a committed section's scratch view completes and reads back"); + } + } + api.free_pages(1, &page); + } + + const HANDLE section = + CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, 0, kPage64k, nullptr); + void* const view = section ? MapViewOfFile(section, FILE_MAP_WRITE, 0, 0, kPage64k) : nullptr; + check(view != nullptr && reserved_only(view), "a SEC_RESERVE view the host places"); + if (view) { + check_section_write_against_control( + view, "a write into a SEC_RESERVE view outside the title's reservations matches the host control"); + UnmapViewOfFile(view); + } + + const auto title_free = reinterpret_cast(rt::shims::find("kernel32.dll", "VirtualFree")); + auto* const placeholder = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, 0x25, PAGE_READWRITE)); + check(placeholder && title_free && title_free(placeholder, 0, MEM_RELEASE), + "the title reserves a placeholder and releases it"); + void* const reused = section && placeholder + ? MapViewOfFileEx(section, FILE_MAP_WRITE, 0, 0, kPage64k, placeholder) + : nullptr; + if (reused == placeholder) { + check_section_write_against_control( + reused, "a section view mapped where the title released its placeholder matches the host control"); + UnmapViewOfFile(reused); + } else { + std::printf("SKIP the released-placeholder write: the host gave its address to something else\n"); + if (reused) UnmapViewOfFile(reused); + } + if (section) CloseHandle(section); + + void* const reserve = VirtualAlloc(nullptr, kPage64k, MEM_RESERVE, PAGE_READWRITE); + check(reserve && access_faults(static_cast(reserve), true) && reserved_only(reserve), + "a write into an ordinary reservation is left to the title"); + if (reserve) VirtualFree(reserve, 0, MEM_RELEASE); +} + +bool mapped_view(const void* address) { + MEMORY_BASIC_INFORMATION info{}; + return VirtualQuery(address, &info, sizeof(info)) && info.Type == MEM_MAPPED; +} + +// A map that fails at a page that is not live leaves the pages before it mapped, and recorded as mapped: their +// aliases, copy_page_mappings' sources and transfer_physical's pins see them. And a map far larger than any window is +// refused before its page list is read. +void test_failed_map_records(const PhysicalApi& api) { + auto* const a = static_cast( + api.virtual_alloc(nullptr, 3 * kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + auto* const b = static_cast( + api.virtual_alloc(nullptr, kPage64k, MEM_RESERVE | kXmem64kPages, 0x21, PAGE_READWRITE)); + uint64_t pages[2]{}; + uint64_t count = 2; + if (!a || !b || api.allocate(0x280, &count, pages) != TRUE || count != 2) { + check(false, "two windows and two pages for the failed map"); + return; + } + constexpr uint64_t kNotLive = ((uint64_t{1} << 21) - 1) * 16; + const uint64_t list[3] = {pages[0], pages[1], kNotLive}; + check(api.map(a, 3, list) == nullptr && GetLastError() == ERROR_INVALID_PARAMETER, + "a map with a page that is not live fails"); + check(mapped_view(a) && mapped_view(a + kPage64k) && !mapped_view(a + 2 * kPage64k), + "the pages before it are mapped, the rest of the range is not"); + check(api.map(b, 1, pages) == b, "the first page maps at a second address too"); + std::vector peers; + rt::xmem::geometry_aliases(reinterpret_cast(b), peers); + check(peers.size() == 1 && peers[0] == reinterpret_cast(a), + "the failed call's mapping is recorded: the first page is aliased at both addresses"); + SetLastError(ERROR_SUCCESS); + check(api.map(a, uint64_t{1} << 30, list) == nullptr && GetLastError() == ERROR_INVALID_ADDRESS, + "a map of 2^30 pages is refused for its window before the page list is read"); + api.map(a, 3, nullptr); + api.map(b, 1, nullptr); + check(api.free_pages(2, pages) == TRUE, "the failed map's pages are freed"); +} + void test_physical_pages_commit_on_touch(const PhysicalApi& api) { PERFORMANCE_INFORMATION before{}; if (!GetPerformanceInfo(&before, sizeof(before))) { @@ -828,8 +1568,10 @@ void test_commit_physical_pages(const PhysicalApi& api) { bool queried = true; for (uint64_t i = 0; i < kPages; ++i) queried &= VirtualQuery(window + i * kPage64k, &info[i], sizeof(info[i])) == sizeof(info[i]); - check(queried && info[0].State == MEM_COMMIT && info[1].State == MEM_COMMIT && info[2].State == MEM_RESERVE, - "the two committed by number are committed in the window and the third is not yet"); + const bool wine = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr; + check(queried && info[0].State == MEM_COMMIT && info[1].State == MEM_COMMIT && + info[2].State == (wine ? MEM_COMMIT : MEM_RESERVE), + "the two committed by number are committed in the window and the third retains its initial state"); check(read_u32(window, 0) == 0 && read_u32(window + kPage64k, 0) == 0, "pages committed by number read as zero"); api.map(window, kPages, nullptr); @@ -1030,6 +1772,101 @@ void test_placeholders(const PhysicalApi& api) { check(reserved_only(base), "the rest of the placeholder is still reserved"); } +// A window carved out of a bigger window (a reserve-only MEM_REPLACE_PLACEHOLDER inside it) leaves the rest of the bigger +// window a window: pages still map below and above the carve, and into the carve itself. +void test_window_carve_keeps_rest(const PhysicalApi& api) { + constexpr uint64_t kPages = 8; + auto* const window = static_cast(api.virtual_alloc( + nullptr, kPages * kPage64k, MEM_RESERVE | kXmem64kPages, 0x23, PAGE_READWRITE | PAGE_GRAPHICS_READWRITE)); + check(window != nullptr, "a 64 KiB-page window to carve"); + if (!window) return; + void* const carved = api.virtual_alloc(window + 3 * kPage64k, 2 * kPage64k, + MEM_RESERVE | MEM_REPLACE_PLACEHOLDER | kXmem64kPages, 0x23, + PAGE_READWRITE | PAGE_GRAPHICS_READWRITE); + check(carved == window + 3 * kPage64k, "a reserve-only replacement carves two pages out of the window"); + uint64_t pages[3]{}; + uint64_t count = 3; + check(api.allocate(0x380, &count, pages) == TRUE && count == 3, "allocate three pages"); + if (count != 3) return; + check(api.map(window + kPage64k, 1, &pages[0]) == window + kPage64k, "a page maps below the carve"); + check(api.map(window + 6 * kPage64k, 1, &pages[1]) == window + 6 * kPage64k, "a page maps above the carve"); + check(api.map(window + 3 * kPage64k, 1, &pages[2]) == window + 3 * kPage64k, "a page maps into the carve"); + fill_page(window + 6 * kPage64k, 0x6000000u); + check(page_holds(window + 6 * kPage64k, 0x6000000u), "the page above the carve holds data"); + check(api.map(window + kPage64k, 1, nullptr) == window + kPage64k, "unmap below"); + check(api.map(window + 6 * kPage64k, 1, nullptr) == window + 6 * kPage64k, "unmap above"); + check(api.map(window + 3 * kPage64k, 1, nullptr) == window + 3 * kPage64k, "unmap the carve"); + check(api.free_pages(3, pages) == TRUE, "free the three pages"); +} + +// A reserve-only replacement splits an existing physical window without releasing either neighbour. +void test_nested_window(const PhysicalApi& api) { + auto* base = static_cast(api.virtual_alloc(nullptr, 3 * kPage64k, MEM_RESERVE | kXmem64kPages, + 0x21, PAGE_READWRITE)); + check(base != nullptr, "reserve a parent physical window"); + if (!base) return; + void* child = api.virtual_alloc(base + kPage64k, kPage64k, MEM_RESERVE | MEM_REPLACE_PLACEHOLDER | kXmem64kPages, + 0x23, PAGE_READONLY); + check(child == base + kPage64k, "carve a read-only registration window inside the parent"); + if (!child) return; + void* addresses[] = {base, child, base + 2 * kPage64k}; + check(!access_faults(reinterpret_cast(base), true) && + !access_faults(reinterpret_cast(base + 2 * kPage64k), true), + "faults can still plant writable pages on both sides of the child"); + uint64_t count = 3, pages[3]{}; + const bool allocated = api.allocate(0x281, &count, pages) && count == 3; + check(allocated, "allocate physical pages for nested-window scatter"); + if (!allocated) return; + const bool mapped = api.scatter(addresses, 3, pages) == TRUE; + check(mapped, "scatter reaches both parent fragments and the child"); + if (mapped) { + for (unsigned i = 0; i < 3; ++i) { + auto* word = static_cast(addresses[i]); + check(!access_faults(word, false) && *word == 0 && access_faults(word, true) == (i == 1), + "scattered pages retain the protection of their own window"); + } + } + if (mapped) { + const auto start = reinterpret_cast(base); + const rt::xmem::PageRange repeat{1, 0, 3}; + const rt::xmem::PageBatch batch{start, 1, &repeat}; + const bool copied = rt::xmem::copy_page_mappings(1, &batch, start, 3, 0); + check(copied, "one slot-31 repeat range crosses the child and both parent fragments"); + if (copied) { + auto* first = reinterpret_cast(base); + *first = 42; + std::vector peers; + rt::xmem::geometry_aliases(start + kPage64k, peers); + check(peers == std::vector{start, start + 2 * kPage64k} && + *static_cast(child) == 42 && + access_faults(static_cast(child), true), + "slot-31 publishes both aliases and preserves the child protection"); + } + auto* source = static_cast(api.virtual_alloc(nullptr, 3 * kPage64k, MEM_RESERVE | kXmem64kPages, + 0x21, PAGE_READWRITE)); + const bool source_mapped = source && api.map(source, 3, pages) == source; + check(source_mapped, "map three consecutive source frames for the queue run"); + if (source_mapped) { + const rt::xmem::PageRange sequential{0, 0, 3}; + const rt::xmem::PageBatch run{start, 1, &sequential}; + check(rt::xmem::copy_page_mappings(1, &run, reinterpret_cast(source), 3, 0), + "a sequential queue run crosses both child boundaries"); + for (unsigned i = 0; i < 3; ++i) { + std::vector peers; + rt::xmem::geometry_aliases(reinterpret_cast(source + i * kPage64k), peers); + check(peers == std::vector{start + i * kPage64k}, + "each fragment publishes its corresponding source frame"); + } + api.map(source, 3, nullptr); + } + } + check(api.scatter(addresses, 3, nullptr) == TRUE, "unmap nested-window scatter"); + std::vector peers; + rt::xmem::geometry_aliases(reinterpret_cast(child), peers); + check(peers.empty(), "scatter unmap removes the slot-31 aliases"); + api.free_pages(3, pages); +} + // Three of the retail executable's five physical-page windows carry 0x400 next to PAGE_READWRITE. That is // PAGE_WRITECOMBINE on the PC, outside the PAGE_GRAPHICS_* range, and MapViewOfFile3 refuses a view with it, so the // mapped pages take the window's protection without the cache modifier. @@ -1570,6 +2407,100 @@ void test_write_watch_rereserve(XMemVirtualAllocFn virtual_alloc, XMemGetWriteWa } } +// Guards over physical pages (src/title_page_watch.h, kernel_writes). One page mapped at two windows, A and B: +// 1. a page of A made read-only behind every guard's back (as the geometry watch's race left them) is writable again +// after rt::xmem::reopen_unowned, and a page the title protected itself (its VirtualProtect) is left read-only; +// 2. with reopen_unowned as kernel_writes' unguarder, a host thread's write (kernel_writes::write) and a kernel write +// (kernel_writes::read_file) into such a page both land; +// 3. a DirectStorage page-list write (rt::xmem::transfer_physical) pins and opens every address the page is mapped at +// before it writes the page through its section, and ends the pins after. +std::vector> g_opened; +void record_open(uintptr_t from, uintptr_t to) { g_opened.emplace_back(from, to); } + +void test_unowned_guards(const PhysicalApi& api) { + if (const HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); ntdll && GetProcAddress(ntdll, "wine_get_version")) { + // Under Wine (Proton) these checks fail at their setup: Wine's placeholder views differ (PAGE_WRITECOMBINE and + // PAGE_NOCACHE are dropped, MapViewOfFile3 refuses them), so this safety net is inert there. Harmless today; + // the Wine side is an open item. + std::printf("SKIP unowned guards under Wine: its placeholder views differ, the safety net is Windows-only\n"); + return; + } + namespace kw = leonida::kernel_writes; + auto* const a = static_cast( + api.virtual_alloc(nullptr, 2 * kPage64k, MEM_RESERVE | kXmem64kPages, 0x23, PAGE_READWRITE)); + auto* const b = static_cast( + api.virtual_alloc(nullptr, 2 * kPage64k, MEM_RESERVE | kXmem64kPages, 0x23, PAGE_READWRITE)); + uint64_t pages[2]{}; + uint64_t count = 2; + check(a && b && api.allocate(0x280, &count, pages) == TRUE && count == 2 && api.map(a, 2, pages) == a && + api.map(b, 2, pages) == b, "two windows map the same two physical pages"); + if (!a || !b || count != 2) return; + for (size_t i = 0; i < 2 * kPage64k; i += 0x1000) a[i] = 1; // committed through A + const auto protection = [](const void* at) { + MEMORY_BASIC_INFORMATION info{}; + return VirtualQuery(at, &info, sizeof(info)) ? info.Protect : 0; + }; + const auto va = [](const void* at) { return reinterpret_cast(at); }; + + // 1. An unowned read-only page, and one the title protected. + DWORD old = 0; + check(VirtualProtect(a + 0x1000, 0x1000, PAGE_READONLY, &old), "a page of A made read-only by nobody's guard"); + check(rt::xmem::reopen_unowned(va(a + 0x1000), va(a + 0x1001)) && protection(a + 0x1000) == PAGE_READWRITE && + protection(a + 0x2000) == PAGE_READWRITE, "reopen_unowned makes it writable again, as its window is"); + const auto title_protect = reinterpret_cast( + rt::shims::find("kernel32.dll", "VirtualProtect")); + check(title_protect && title_protect(b + kPage64k, 0x1000, PAGE_READONLY, &old), "the title protects a page of B"); + check(!rt::xmem::reopen_unowned(va(b + kPage64k), va(b + kPage64k + 1)) && + protection(b + kPage64k) == PAGE_READONLY, "reopen_unowned leaves a page the title protected"); + if (title_protect) title_protect(b + kPage64k, 0x1000, PAGE_READWRITE, &old); + + // 2. Writes into an unowned read-only page through kernel_writes. + kw::set_unguarder(&rt::xmem::reopen_unowned); + std::vector source(0x1800); + for (size_t i = 0; i < source.size(); ++i) source[i] = static_cast(i * 7 + 3); + VirtualProtect(a + 0x3000, 0x2000, PAGE_READONLY, &old); + bool wrote = false; + std::thread host([&] { wrote = kw::write(a + 0x3400, source.data(), source.size()); }); + host.join(); + check(wrote && std::memcmp(b + 0x3400, source.data(), source.size()) == 0, + "a host thread's write into it lands (and B shows it: one memory)"); + wchar_t dir[MAX_PATH]{}, path[MAX_PATH]{}; + GetTempPathW(MAX_PATH, dir); + GetTempFileNameW(dir, L"xug", 0, path); + HANDLE file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, + FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, nullptr); + DWORD done = 0; + check(file != INVALID_HANDLE_VALUE && WriteFile(file, source.data(), 0x1000, &done, nullptr) && done == 0x1000, + "a file to read"); + // (Into A: the title's VirtualProtect above marked all of B's view, which reopen_unowned now leaves alone.) + VirtualProtect(a + 0x6000, 0x1000, PAGE_READONLY, &old); + OVERLAPPED at{}; + done = 0; + check(kw::read_file(file, a + 0x6000, 0x1000, &done, &at) && done == 0x1000 && + std::memcmp(b + 0x6000, source.data(), 0x1000) == 0, "a kernel write into it lands, retried once"); + CloseHandle(file); + kw::set_unguarder(nullptr); + + // 3. A page-list write pins every address of the page. + kw::set_opener(&record_open); + std::vector staging(0x200, 0x5a); + const uint64_t page = pages[1]; + check(rt::xmem::transfer_physical(std::span(&page, 1), 0x100, staging, true), + "transfer_physical writes a physical page"); + const bool both = g_opened.size() == 2 && + ((g_opened[0].first == va(a + kPage64k + 0x100) && g_opened[1].first == va(b + kPage64k + 0x100)) || + (g_opened[1].first == va(a + kPage64k + 0x100) && g_opened[0].first == va(b + kPage64k + 0x100))); + check(both && g_opened[0].second - g_opened[0].first == 0x200, "both of its addresses were pinned and opened first"); + check(kw::state().count.load() == 0 && a[kPage64k + 0x100] == 0x5a && b[kPage64k + 0x2ff] == 0x5a, + "the pins ended, and both addresses show the bytes"); + kw::set_opener(nullptr); + g_opened.clear(); + + api.map(a, 2, nullptr); + api.map(b, 2, nullptr); + check(api.free_pages(2, pages) == TRUE, "the pages are freed"); +} + void print_result() { if (g_failures == 0) { std::printf("xmem_test: OK (%d checks)\n", g_checks); @@ -1626,6 +2557,76 @@ int main(int argc, char** argv) { check(physical.map != nullptr, "registry exposes xmem.dll!XMemMapPhysicalPages"); check(physical.scatter != nullptr, "registry exposes xmem.dll!XMemMapPhysicalPagesScatter"); + if (argc == 2 && std::strcmp(argv[1], "--pool-zero-read") == 0) { + // This test executable occupies the title's usual PE base, so its own read exercises the PC filter. + SetEnvironmentVariableA("LEONIDA_POOL_ZERO_PAGES", "1"); + SetEnvironmentVariableA("LEONIDA_SLOT31_CPU_TWIN", "0"); + uint64_t count = 1, page = 0; + const bool allocated = physical.allocate && physical.allocate(0x281, &count, &page) && count == 1; + check(allocated, "allocate a physical page to install the fault handler"); + auto* window = static_cast( + virtual_alloc(nullptr, 2 * kPage64k, MEM_RESERVE | kXmem64kPages, 0x25, PAGE_READWRITE)); + check(window != nullptr, "reserve an unmapped physical window"); + auto* gpu = static_cast(virtual_alloc(nullptr, 2 * kPage64k, MEM_RESERVE | kXmem64kPages, 3, 0x801)); + if (allocated && window && gpu) { + rt::xmem::note_stream_reservation(uintptr_t(window), 2 * kPage64k, 0x1e1d00f); + rt::xmem::note_stream_reservation(uintptr_t(gpu), 2 * kPage64k, 0x1e1d03e); + void* first = gpu; + check(physical.scatter(&first, 1, &page), "fault diagnostic has a scatter-backed GPU twin"); + const rt::xmem::PageRange range{0, 0, 1}; + const rt::xmem::PageBatch batch{uintptr_t(gpu + kPage64k), 1, &range}; + check(rt::xmem::copy_page_mappings(1, &batch, uintptr_t(gpu), 1, 0), + "fault diagnostic has a slot-31-backed GPU twin"); + check(!access_faults(window + kPage64k / sizeof(*window), false), "slot-31 CPU hole reads zero with mirror off"); + } + if (allocated && window) { + const bool readable = !access_faults(window, false); + check(readable && window[0] == 0 && window[kPage64k / sizeof(*window) - 1] == 0, + "a title read of an unmapped pool page returns zeros"); + MEMORY_BASIC_INFORMATION info{}; + check(VirtualQuery(const_cast(window), &info, sizeof(info)) && info.Protect == PAGE_READONLY, + "the read first plants a read-only zero page"); + check(!access_faults(window, true) && window[0] == 1 && window[1] == 0, + "the first write replaces the read plant with writable zero backing"); + } + if (allocated) { + check(physical.map(const_cast(window), 1, &page) == window, + "a physical mapping replaces the read-planted page"); + physical.free_pages(1, &page); + } + print_result(); + return g_failures ? 1 : 0; + } + + // xmem_test --remap-reps N [RUNS]: only the remap race, N remaps per run, RUNS runs (default 1), then the decision + // races once: the race a review reproduced, looped. + if (argc >= 3 && std::strcmp(argv[1], "--remap-reps") == 0) { + const int reps = std::atoi(argv[2]); + const int runs = argc >= 4 ? std::atoi(argv[3]) : 1; + if (!virtual_alloc || !physical.allocate || !physical.free_pages || !physical.map || !physical.scatter || + reps <= 0 || runs <= 0) { + print_result(); + return 1; + } + RemapRace total; + int failed_runs = 0; + for (int run = 0; run < runs; ++run) { + const int failures_before = g_failures; + const RemapRace race = test_write_during_remap(physical, reps); + total.writes += race.writes; + total.faults += race.faults; + total.escaped += race.escaped; + if (g_failures != failures_before) ++failed_runs; + } + test_decision_races(physical); + std::printf("remap race: %d runs of %d remaps, %d failed, %llu writes, %llu faults answered, %llu writes " + "escaped\n", + runs, reps, failed_runs, static_cast(total.writes), + static_cast(total.faults), static_cast(total.escaped)); + print_result(); + return g_failures ? 1 : 0; + } + if (!alloc || !free_mem || !query || !get_stats) { print_result(); return 1; @@ -1651,6 +2652,8 @@ int main(int argc, char** argv) { if (alloc_default && free_default) test_default_alloc(alloc, free_mem, alloc_default, free_default); if (tools_mem) check(tools_mem() == FALSE, "XMemIsToolsMemAvailable returns FALSE (no devkit tools memory)"); if (virtual_alloc && physical.allocate && physical.free_pages && physical.map && physical.scatter) { + // Keep the direct SEC_RESERVE control ahead of the first physical allocation, which installs xmem's VEH. + g_section_write_control = measure_section_write_control(); test_physical_pages(physical); if (argc == 2 && std::strcmp(argv[1], "--file-pools") == 0) { test_placeholders(physical); @@ -1659,12 +2662,23 @@ int main(int argc, char** argv) { } test_copy_page_mappings(physical); test_copy_page_mappings_cpu_view(physical); + test_stream_cpu_twin(physical); + test_unowned_guards(physical); test_physical_pages_commit_on_touch(physical); + test_unmapped_window_page(physical); + test_write_during_remap(physical); + test_first_touch_races(physical); + test_decision_races(physical); + test_zero_pool_rollover(physical); + test_foreign_section_writes(physical); + test_failed_map_records(physical); test_commit_physical_pages(physical); test_first_touch_during_remap(physical); test_long_run(physical); test_split_under_reader(physical); test_placeholders(physical); + test_window_carve_keeps_rest(physical); + test_nested_window(physical); test_write_combine_window(physical); test_heap_lock_faults(physical); } diff --git a/runtime/test/xmem_wine_commit_test.cpp b/runtime/test/xmem_wine_commit_test.cpp new file mode 100644 index 0000000000..17dcf7a07b --- /dev/null +++ b/runtime/test/xmem_wine_commit_test.cpp @@ -0,0 +1,123 @@ +// Physical pages alias and start zeroed on both hosts. Under Wine their first touch and explicit commits +// must leave the memory-map generation alone. Time the same 1,000 queries in each section mode. +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "shims.h" +#include "xmem.h" +#include "../src/title_page_watch.h" + +namespace { +constexpr size_t page = 64 * 1024; +constexpr size_t pool = size_t{1} << 30; +constexpr size_t stride = 16 * page; +int checks = 0; +int failures = 0; + +bool check(bool ok, const char* name) { + ++checks; + if (!ok) { + ++failures; + std::printf("FAIL %s\n", name); + } + return ok; +} + +double query_median(uint8_t* base) { + using Clock = std::chrono::steady_clock; + std::mt19937 random(12345); + std::array times{}; + for (double& time : times) { + const auto address = base + random() % pool; + MEMORY_BASIC_INFORMATION info{}; + const auto start = Clock::now(); + const auto bytes = VirtualQuery(address, &info, sizeof(info)); + const auto end = Clock::now(); + if (bytes != sizeof(info) || info.Type != MEM_MAPPED) return -1; + time = std::chrono::duration(end - start).count(); + } + std::sort(times.begin(), times.end()); + return (times[499] + times[500]) / 2; +} + +void measure_reserved() { + HANDLE section = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE | SEC_RESERVE, 0, pool, nullptr); + if (!section) return; + auto* base = static_cast(MapViewOfFile(section, FILE_MAP_WRITE, 0, 0, pool)); + if (base) { + bool ready = true; + for (size_t at = 0; at < pool; at += stride) { + if (!VirtualAlloc(base + at, page, MEM_COMMIT, PAGE_READWRITE)) { + ready = false; + break; + } + base[at] = 1; + } + const double median = ready ? query_median(base) : -1; + if (median >= 0) std::printf("SEC_RESERVE (one raw view) VirtualQuery median %.3f us\n", median); + UnmapViewOfFile(base); + } + CloseHandle(section); +} + +void run() { + const bool wine = GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr; + const size_t bytes = wine ? pool : 2 * page; + using Reserve = void*(WINAPI*)(void*, SIZE_T, DWORD, ULONGLONG, DWORD); + using Allocate = BOOL(WINAPI*)(uint64_t, uint64_t*, uint64_t*); + using Map = void*(WINAPI*)(void*, uint64_t, const uint64_t*); + using Free = BOOL(WINAPI*)(uint64_t, const uint64_t*); + const auto reserve = reinterpret_cast(rt::shims::find("xmem.dll", "XMemVirtualAlloc")); + const auto allocate = reinterpret_cast(rt::shims::find("xmem.dll", "XMemAllocatePhysicalPages")); + const auto map = reinterpret_cast(rt::shims::find("xmem.dll", "XMemMapPhysicalPages")); + const auto free_pages = reinterpret_cast(rt::shims::find("xmem.dll", "XMemFreePhysicalPages")); + if (!check(reserve && allocate && map && free_pages, "registered physical-page API")) return; + + constexpr DWORD window = MEM_RESERVE | 0x20400000; // XMemVirtualAlloc 64 KiB pages + auto* base = static_cast(reserve(nullptr, bytes, window, 0x23, PAGE_READWRITE)); + auto* alias = static_cast(reserve(nullptr, 2 * page, window, 0x23, PAGE_READWRITE)); + std::vector pages(bytes / page); + uint64_t count = pages.size(); + if (!check(base && alias && base != alias, "reserve distinct windows") || + !check(allocate(0x280, &count, pages.data()) && count == pages.size(), "allocate physical pages") || + !check(map(base, count, pages.data()) == base && map(alias, 2, pages.data()) == alias, "map both windows")) return; + + namespace memory = leonida::title_memory_map; + if (wine) { + MEMORY_BASIC_INFORMATION info{}; + check(VirtualQuery(base, &info, sizeof(info)) == sizeof(info) && + info.Type == MEM_MAPPED && info.State == MEM_COMMIT, "untouched view starts committed"); + } + const auto before = memory::generation(); + volatile uint8_t* a = base; + volatile uint8_t* b = alias; + check(a[0] == 0, "untouched page reads zero"); + a[page] = 0x5a; + check(b[page] == 0x5a, "alias sees first write"); + if (wine) { + check(memory::generation() == before, "first read and write preserve generation"); + check(rt::xmem::commit_physical_range(base, bytes) && rt::xmem::commit_physical_pages(pages.data(), count) + && memory::generation() == before, "explicit commits preserve generation"); + for (size_t at = 0; at < bytes; at += stride) a[at] = 1; + const double median = query_median(base); + std::printf("SEC_COMMIT (xmem pool) VirtualQuery median %.3f us\n", median); + check(median >= 0 && median < 20, "1,000 successful mapped queries with median below 20 us"); + } + check(map(alias, 2, nullptr) == alias && map(base, count, nullptr) == base, "unmap both windows"); + check(free_pages(count, pages.data()), "free physical pages"); + if (wine) measure_reserved(); +} +} // namespace + +int main() { + run(); + std::printf("xmem_wine_commit_test: %d checks, %d failures\n", checks, failures); + return failures ? 1 : 0; +} diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index d1dd93461c..7ce6ea4663 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -16,6 +16,7 @@ // Every device, queue, fence and resource here is a mock that records the calls it gets. No game data, no Xbox DLLs. #include "../shims/d3d12_xs_device.h" #include "../shims/xmem.h" +#include "../src/title_page_watch.h" #include "../src/d3d12_xs_frame_events.h" #include "../src/native_pso.h" @@ -28,6 +29,7 @@ #include #include +#include #include #include #include @@ -102,6 +104,7 @@ struct Mock { bool allocator_tag; // allocator: answers kLeonidaCommandAllocatorTag; device: the allocators it makes do bool full_chain_lists; // device: CreateCommandList makes a full-chain list mock (Kind::list), else command_list bool create_null; // device: creation returns create_result with no object + bool zero_fences; // device: the fences it makes start at 0, not kCompletedValue HRESULT create_result; // device: what creation returns (S_OK makes the object) bool list_refuse; // device: CreateCommandList refuses every riid with E_NOINTERFACE IID create_riid; // device: copy of the riid its last CreateCommandList got (the caller's may be a local) @@ -111,6 +114,9 @@ struct Mock { std::uint64_t completed; // fence: what GetCompletedValue (slot 8) returns std::uint64_t armed_value; // fence: the value SetEventOnCompletion (slot 9) waits for HANDLE armed_event; // fence: the event it sets then, or null + Mock* completes_with; // fence: once its completed value reaches completes_at, a GetCompletedValue first + std::uint64_t completes_at, completes_value; // signals that fence to completes_value (GPU order across queues) + bool signals_complete; // queue: a Signal (slot 14) completes the fence at once, as an idle GPU would unsigned calls[kMockSlots]; std::uint64_t args[kMockSlots][6]; std::uint64_t array[kMockSlots][4]; // device: the first entries of the array argument, as received @@ -133,7 +139,7 @@ struct Mock { D3D_FEATURE_LEVEL max_level; // device: the highest level FEATURE_LEVELS reports (0: the query is refused) }; -Mock g_pool[256]; +Mock g_pool[512]; unsigned g_pool_used = 0; void** mock_vtable(); @@ -217,7 +223,8 @@ bool mock_has(const Mock* m, REFIID iid) { case Kind::fence: return IsEqualIID(iid, __uuidof(ID3D12Fence)) || (m->fence1 && IsEqualIID(iid, __uuidof(ID3D12Fence1))); case Kind::resource: return IsEqualIID(iid, __uuidof(ID3D12Resource)); - case Kind::heap: return IsEqualIID(iid, __uuidof(ID3D12DescriptorHeap)); + case Kind::heap: // a descriptor heap, or a query heap (device slot 39) + return IsEqualIID(iid, __uuidof(ID3D12DescriptorHeap)) || IsEqualIID(iid, __uuidof(ID3D12QueryHeap)); case Kind::command_list: if (IsEqualIID(iid, __uuidof(ID3D12CommandList)) || IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList))) return true; @@ -271,6 +278,7 @@ HRESULT mock_create(Mock* device, Kind kind, std::uint64_t riid, std::uint64_t o Mock* child = new_mock(kind); child->fence1 = device->fence1; child->allocator_tag = device->allocator_tag; + if (kind == Kind::fence && device->zero_fences) child->completed = 0; device->last_child = child; return mock_query(child, reinterpret_cast(riid), out); } @@ -280,6 +288,35 @@ void copy_array(Mock* m, unsigned slot, std::uint64_t objects, std::uint64_t cou for (std::uint32_t i = 0; in && i < static_cast(count) && i < 4; ++i) m->array[slot][i] = in[i]; } +// The mock GPU clock pairs kMockGpu0 with a fixed QPC origin. Its timestamp frequency is 1 MHz. A resource's Map (slot 8) hands out +// g_mock_mapped: the timestamp readback of list values, which the test fills as the GPU would. +constexpr std::uint64_t kMockGpu0 = 1000000; +// All mock queues use the same fixed clock pair, even when the pump recalibrates one queue. +std::uint64_t mock_cpu_origin() { + static const auto origin = [] { + LARGE_INTEGER now{}; + QueryPerformanceCounter(&now); + return static_cast(now.QuadPart); + }(); + return origin; +} +alignas(8) std::uint64_t g_mock_readback[4096]; +void* g_mock_mapped = g_mock_readback; + +// The queue calls that order work (ExecuteCommandLists 10, Signal 14, Wait 15), in the order the mock queues got +// them: for an ExecuteCommandLists, a1 is the count and a2 the first list; else the fence and the value. +struct QueueCall { + const Mock* queue; + unsigned slot; + std::uint64_t a1, a2; +}; +QueueCall g_queue_calls[64]; +unsigned g_queue_call_count = 0; + +void log_queue_call(const Mock* queue, unsigned slot, std::uint64_t a1, std::uint64_t a2) { + if (g_queue_call_count < std::size(g_queue_calls)) g_queue_calls[g_queue_call_count++] = {queue, slot, a1, a2}; +} + // GetResourceAllocationInfo as a PC driver without console tile padding answers it. A buffer is its width, a texture // width x height x slices x element bytes (2 for B5G5R5A1, 4 for RGBA8, 8 for RGBA16F, 16 for RGBA32F; mips are not // counted, and one resource is at most 4 GiB, the way a driver caps an allocation), each rounded up to the @@ -358,6 +395,7 @@ std::uint64_t mock_call(Mock* m, unsigned slot, const std::uint64_t* words) { break; case 75: return static_cast(mock_create(m, Kind::queue, a3, a4)); // CreateCommandQueue1 case 36: return static_cast(mock_create(m, Kind::fence, a3, a4)); // CreateFence + case 39: return static_cast(mock_create(m, Kind::heap, a2, a3)); // CreateQueryHeap case 32: // OpenSharedHandle if (a1 == kFenceHandle) return static_cast(mock_create(m, Kind::fence, a2, a3)); if (a1 == kResourceHandle) return static_cast(mock_create(m, Kind::resource, a2, a3)); @@ -426,13 +464,24 @@ std::uint64_t mock_call(Mock* m, unsigned slot, const std::uint64_t* words) { } if (m->kind == Kind::fence) { switch (slot) { - case 8: return fence_completed(m); // GetCompletedValue + case 8: // GetCompletedValue + if (m->completes_with && fence_completed(m) >= m->completes_at) { + fence_signal(m->completes_with, m->completes_value); + m->completes_with = nullptr; + } + return fence_completed(m); case 9: return static_cast(fence_set_event(m, a1, reinterpret_cast(a2))); case 10: fence_signal(m, a1); return S_OK; // Signal default: break; } } - if (m->kind == Kind::queue && slot == 10) copy_array(m, 10, a2, a1); // ExecuteCommandLists(count, lists) + if (m->kind == Kind::queue && slot == 10) { // ExecuteCommandLists(count, lists) + copy_array(m, 10, a2, a1); + log_queue_call(m, 10, static_cast(a1), a2 ? *reinterpret_cast(a2) : 0); + } + if (m->kind == Kind::queue && (slot == 14 || slot == 15)) log_queue_call(m, slot, a1, a2); // Signal, Wait + if (m->kind == Kind::queue && slot == 14 && m->signals_complete && a1) + fence_signal(reinterpret_cast(a1), a2); if ((m->kind == Kind::command_list || m->kind == Kind::list) && slot == 28) copy_array(m, slot, a2, a1); // SetDescriptorHeaps(count, heaps) if (m->kind == Kind::queue && slot == 16 && a1) { @@ -443,6 +492,13 @@ std::uint64_t mock_call(Mock* m, unsigned slot, const std::uint64_t* words) { const bool is_mock = at >= base && at < base + sizeof(g_pool) && (at - base) % sizeof(Mock) == 0; if (!is_mock) *reinterpret_cast(a1) = 1000000; } + if (m->kind == Kind::queue && slot == 17 && a1 && a2) { + *reinterpret_cast(a1) = kMockGpu0; + *reinterpret_cast(a2) = mock_cpu_origin(); + } + if (m->kind == Kind::resource && slot == 8 && a3) { // Map(subresource, range, data): the test's readback + *reinterpret_cast(a3) = g_mock_mapped; + } if (m->kind == Kind::heap && slot == 9) { if (a1) reinterpret_cast(a1)->ptr = kMockHeapCpuStart; return kMockHeapCpuStart; @@ -3710,6 +3766,682 @@ int check_committed_resource3_x() { } // namespace +// ---- 14. List memory writes and waits (list slots 71-74 on the newer layout, d3d12_xs_list_values.h) ---------- +// Synthetic title memory, the mock queues' ordered calls and the mock fences stand in for the GPU: a write lands +// only once the queue's write fence is reached, a wait holds its part behind a gate fence the pump signals, a write +// in flight is relayed as a queue Wait on its fence, and a list is cut at a wait recorded after work. + +alignas(64) std::uint64_t g_cells[8]; + +std::uint64_t cell(int i) { return *reinterpret_cast(&g_cells[i]); } + +bool queue_call_is(unsigned i, const Mock* queue, unsigned slot, std::uint64_t a1, std::uint64_t a2) { + return i < g_queue_call_count && g_queue_calls[i].queue == queue && g_queue_calls[i].slot == slot && + g_queue_calls[i].a1 == a1 && g_queue_calls[i].a2 == a2; +} + +void* make_console_list(void* device, void* allocator, Mock* device_mock, Mock** real) { + const IID gcl_iid = __uuidof(ID3D12GraphicsCommandList); + void* list = nullptr; + if (FAILED(hr_of(raw(device, 12, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, word(allocator), 0, word(&gcl_iid), + word(&list))))) + return nullptr; + *real = device_mock->last_child; + return list; +} + +std::uint64_t submit(void* queue, void* list) { + void* lists[1] = {list}; + return raw(queue, 35, 1, word(lists)); +} + +int check_list_values() { + // The slot decode: newer layout (and an undetected one) 71-74, older 69-72. + static_assert(xs::console_value_op(71, 0) == xs::ConsoleValueOp::write32); + static_assert(xs::console_value_op(72, xs::kConsoleLayoutNewer) == xs::ConsoleValueOp::write64); + static_assert(xs::console_value_op(73, 0) == xs::ConsoleValueOp::wait32); + static_assert(xs::console_value_op(74, 0) == xs::ConsoleValueOp::wait64); + static_assert(xs::console_value_op(70, 0) == xs::ConsoleValueOp::none); // depth bounds on the newer layout + static_assert(xs::console_value_op(75, 0) == xs::ConsoleValueOp::none); + static_assert(xs::console_value_op(69, xs::kConsoleLayoutOlder) == xs::ConsoleValueOp::write32); + static_assert(xs::console_value_op(72, xs::kConsoleLayoutOlder) == xs::ConsoleValueOp::wait64); + static_assert(xs::console_value_op(73, xs::kConsoleLayoutOlder) == xs::ConsoleValueOp::none); + // Comparison codes: memory OP reference, D3D12_COMPARISON_FUNC order. + EXPECT(xs::console_value_met(2, 4, 5, true) && !xs::console_value_met(2, 5, 5, true)); + EXPECT(xs::console_value_met(3, 5, 5, true) && !xs::console_value_met(3, 6, 5, true)); + EXPECT(xs::console_value_met(4, 5, 5, true) && !xs::console_value_met(4, 6, 5, true)); + EXPECT(xs::console_value_met(5, 6, 5, true) && !xs::console_value_met(5, 5, 5, true)); + EXPECT(xs::console_value_met(6, 6, 5, true) && !xs::console_value_met(6, 5, 5, true)); + EXPECT(xs::console_value_met(7, 5, 5, true) && !xs::console_value_met(7, 4, 5, true)); + // A 32-bit wait compares the low halves only; always, never and unknown codes count as met. + EXPECT(xs::console_value_met(3, 0xffffffff00000005ull, 5, false) && + !xs::console_value_met(3, 0xffffffff00000005ull, 5, true)); + EXPECT(xs::console_value_met(7, 0x100000000ull, 1, true) && !xs::console_value_met(7, 0x100000000ull, 1, false)); + EXPECT(xs::console_value_met(1, 0, 1, true) && xs::console_value_met(8, 0, 1, true) && + xs::console_value_met(0, 0, 1, true) && xs::console_value_met(9, 0, 1, true)); + + Mock* mock = nullptr; + void* device = make_device(mock, 9, true, true, true); // full-chain list mocks + EXPECT(device); + mock->zero_fences = true; // the gate and write fences start at 0: nothing is reached before the test says so + xs::reset_list_value_stats(); + xs::set_list_value_wait_timeout_ms(5000); + void* qa = make_queue(device); + void* qb = make_queue(device); + EXPECT(qa && qb); + Mock* const qa_mock = reinterpret_cast(xs::queue_proxy_real_queue(qa)); + Mock* const qb_mock = reinterpret_cast(xs::queue_proxy_real_queue(qb)); + const IID allocator_iid = __uuidof(ID3D12CommandAllocator); + void* allocator = nullptr; + EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), word(&allocator))) == S_OK); + Mock* const real_allocator = mock->last_child; + Mock* lw_real = nullptr; + Mock* lv_real = nullptr; + void* lw = make_console_list(device, allocator, mock, &lw_real); // writes, on queue A + EXPECT(lw && xs::list_proxy_part_count(lw) == 1); + EXPECT(hr_of(raw(lw, 9)) == S_OK); // closed, so the waiter's list can record into the same allocator + void* lv = make_console_list(device, allocator, mock, &lv_real); // waits, on queue B + EXPECT(lv); + EXPECT(hr_of(raw(lv, 9)) == S_OK); + std::memset(g_cells, 0, sizeof(g_cells)); + + // 1. Writes land after the work before them: not at submission, once the queue's write fence is reached. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 14, 1, 1, 1); // Dispatch + raw(lw, 72, word(&g_cells[0]), 0x1374, 0, 0); // write64(address, value, flush, flags) + raw(lw, 71, word(&g_cells[1]), 0x10000abcdull, 0, 0); // write32: the low 32 bits + raw(lw, 72, word(&g_cells[2]), 0, 0, 1); // write64 flag 1: a GPU timestamp + EXPECT(hr_of(raw(lw, 9)) == S_OK && xs::list_proxy_part_count(lw) == 1); + g_queue_call_count = 0; + EXPECT(submit(qa, lw) == 0); + Mock* const a_written = mock->last_child; // QueueValues::create made the gate, then the write fence + Mock* const a_gate = a_written - 1; + EXPECT(a_written->kind == Kind::fence && a_gate->kind == Kind::fence); + EXPECT(g_queue_call_count == 2 && queue_call_is(0, qa_mock, 10, 1, word(lw_real)) && + queue_call_is(1, qa_mock, 14, word(a_written), 1)); + EXPECT(!xs::list_values_idle(30) && cell(0) == 0 && cell(1) == 0 && cell(2) == 0); + fence_signal(a_written, 1); + EXPECT(xs::list_values_idle(2000)); + EXPECT(cell(0) == 0x1374 && cell(1) == 0xabcd && cell(2) != 0); + xs::ListValueStats stats = xs::list_value_stats(); + EXPECT(stats.writes_recorded == 3 && stats.writes_landed == 3 && stats.writes_failed == 0); + + // 2. A wait holds its part until another queue's write lands: the waiter's queue waits on its gate before the + // part, and the pump signals the gate only after the writer's fence is reached and the value is in memory. + EXPECT(hr_of(raw(lv, 139, word(allocator), 0)) == S_OK); + raw(lv, 74, word(&g_cells[3]), 7, 5, 1); // wait64(address, >=, 5, ?), before any work: the part's gate + raw(lv, 14, 1, 1, 1); + EXPECT(hr_of(raw(lv, 9)) == S_OK && xs::list_proxy_part_count(lv) == 1); + g_queue_call_count = 0; + EXPECT(submit(qb, lv) == 0); + Mock* const b_written = mock->last_child; + Mock* const b_gate = b_written - 1; + EXPECT(b_written->kind == Kind::fence && b_gate->kind == Kind::fence && b_gate != a_gate); + EXPECT(g_queue_call_count == 2 && queue_call_is(0, qb_mock, 15, word(b_gate), 1) && + queue_call_is(1, qb_mock, 10, 1, word(lv_real))); + EXPECT(!xs::list_values_idle(30) && fence_completed(b_gate) == 0); + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 14, 1, 1, 1); + raw(lw, 72, word(&g_cells[3]), 5, 0, 0); + EXPECT(hr_of(raw(lw, 9)) == S_OK); + EXPECT(submit(qa, lw) == 0); + EXPECT(!xs::list_values_idle(30) && fence_completed(b_gate) == 0 && cell(3) == 0); // the writer has not run + fence_signal(a_written, 2); + EXPECT(xs::list_values_idle(2000) && cell(3) == 5 && fence_completed(b_gate) == 1); + stats = xs::list_value_stats(); + EXPECT(stats.waits_recorded == 1 && stats.gates_held == 1 && stats.gates_met == 1 && stats.gates_timed_out == 0); + + // 3. A wait a write in flight will meet is relayed: the waiter's queue waits on the writer's fence value. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 14, 1, 1, 1); + raw(lw, 72, word(&g_cells[4]), 9, 0, 0); + EXPECT(hr_of(raw(lw, 9)) == S_OK); + EXPECT(submit(qa, lw) == 0); // a_written 3, not reached + EXPECT(hr_of(raw(lv, 139, word(allocator), 0)) == S_OK); + raw(lv, 74, word(&g_cells[4]), 7, 9, 1); + raw(lv, 14, 1, 1, 1); + EXPECT(hr_of(raw(lv, 9)) == S_OK); + g_queue_call_count = 0; + EXPECT(submit(qb, lv) == 0); + EXPECT(g_queue_call_count == 2 && queue_call_is(0, qb_mock, 15, word(a_written), 3) && + queue_call_is(1, qb_mock, 10, 1, word(lv_real))); + stats = xs::list_value_stats(); + EXPECT(stats.waits_relayed == 1 && stats.gates_held == 1); + fence_signal(a_written, 3); + EXPECT(xs::list_values_idle(2000) && cell(4) == 9); + + // 4. A met wait costs nothing (a 32-bit one ignores the high half of memory); an unmet one that nothing meets + // is bounded: the gate opens after the timeout. + g_cells[5] = 0xffffffff00000077ull; + xs::set_list_value_wait_timeout_ms(30); + EXPECT(hr_of(raw(lv, 139, word(allocator), 0)) == S_OK); + raw(lv, 73, word(&g_cells[5]), 3, 0x77, 1); // wait32(address, ==, 0x77): met now + raw(lv, 73, word(&g_cells[6]), 3, 0x77, 1); // never written + raw(lv, 14, 1, 1, 1); + EXPECT(hr_of(raw(lv, 9)) == S_OK); + g_queue_call_count = 0; + const ULONGLONG started = GetTickCount64(); + EXPECT(submit(qb, lv) == 0); + EXPECT(g_queue_call_count == 2 && queue_call_is(0, qb_mock, 15, word(b_gate), 2)); + EXPECT(xs::list_values_idle(3000) && fence_completed(b_gate) == 2 && GetTickCount64() - started >= 20); + stats = xs::list_value_stats(); + EXPECT(stats.gates_timed_out == 1 && stats.waits_met_at_submit >= 1); + xs::set_list_value_wait_timeout_ms(5000); + + // 5. Memory the title's CPU writes opens a gate too (the pump looks at it while a gate is held). + EXPECT(hr_of(raw(lv, 139, word(allocator), 0)) == S_OK); + raw(lv, 74, word(&g_cells[7]), 5, 0, 1); // wait64(address, >, 0) + raw(lv, 14, 1, 1, 1); + EXPECT(hr_of(raw(lv, 9)) == S_OK); + EXPECT(submit(qb, lv) == 0); + EXPECT(!xs::list_values_idle(30) && fence_completed(b_gate) == 2); + InterlockedExchange64(reinterpret_cast(&g_cells[7]), 1); + EXPECT(xs::list_values_idle(2000) && fence_completed(b_gate) == 3); + + // 6. A wait after work cuts the list: the part so far closes, recording goes on in a spare list that starts + // with the state the title set, and the queue runs the first part, stands at the wait, then runs the second. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + const unsigned primary_closes = lw_real->calls[9], primary_dispatches = lw_real->calls[14]; + raw(lw, 25, 0x1234); // SetPipelineState -> PC 25 + raw(lw, 33, 0x5678); // SetComputeRootSignature -> PC 29 + raw(lw, 35, 2, 0x9000); // SetComputeRootDescriptorTable(2, handle) -> PC 31 + raw(lw, 37, 1, 0x42, 3); // SetComputeRoot32BitConstant(1, value, offset 3) -> PC 33 + const D3D12_VIEWPORT viewport{0, 0, 640, 480, 0, 1}; + raw(lw, 21, 1, word(&viewport)); // RSSetViewports -> PC 21 + raw(lw, 14, 1, 1, 1); + const unsigned creates = mock->calls[12]; + g_cells[6] = 0; + raw(lw, 74, word(&g_cells[6]), 7, 1, 1); // after work: a cut + EXPECT(xs::list_proxy_part_count(lw) == 2 && xs::list_value_stats().cuts == 1 && mock->calls[12] == creates + 1); + Mock* const spare = mock->last_child; + EXPECT(spare->kind == Kind::list && mock->args[12][2] == word(real_allocator)); + EXPECT(lw_real->calls[9] == primary_closes + 1); // the first part was closed at the cut + EXPECT(spare->calls[25] == 1 && spare->args[25][0] == 0x1234); + EXPECT(spare->calls[29] == 1 && spare->args[29][0] == 0x5678); + EXPECT(spare->calls[31] == 1 && spare->args[31][0] == 2 && spare->args[31][1] == 0x9000); + EXPECT(spare->calls[33] == 1 && spare->args[33][0] == 1 && spare->args[33][1] == 0x42 && spare->args[33][2] == 3); + EXPECT(spare->calls[21] == 1 && spare->args[21][0] == 1); + raw(lw, 14, 2, 2, 2); // after the wait: the spare records it + EXPECT(spare->calls[14] == 1 && lw_real->calls[14] == primary_dispatches + 1); + EXPECT(hr_of(raw(lw, 9)) == S_OK && spare->calls[9] == 1); + g_queue_call_count = 0; + EXPECT(submit(qa, lw) == 0); + EXPECT(g_queue_call_count == 3 && queue_call_is(0, qa_mock, 10, 1, word(lw_real)) && + queue_call_is(1, qa_mock, 15, word(a_gate), 1) && queue_call_is(2, qa_mock, 10, 1, word(spare))); + EXPECT(!xs::list_values_idle(30) && fence_completed(a_gate) == 0); + InterlockedExchange64(reinterpret_cast(&g_cells[6]), 1); + EXPECT(xs::list_values_idle(2000) && fence_completed(a_gate) == 1); + // The next recording starts on the primary list again; a later cut reuses the spare (Reset, no new list), and a + // met wait between the parts puts both in one submission. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK && xs::list_proxy_part_count(lw) == 1); + raw(lw, 14, 1, 1, 1); + raw(lw, 74, word(&g_cells[6]), 7, 1, 1); + EXPECT(xs::list_proxy_part_count(lw) == 2 && mock->calls[12] == creates + 1 && spare->calls[10] == 1); + raw(lw, 14, 1, 1, 1); + EXPECT(hr_of(raw(lw, 9)) == S_OK); + g_queue_call_count = 0; + EXPECT(submit(qa, lw) == 0); + EXPECT(g_queue_call_count == 1 && queue_call_is(0, qa_mock, 10, 2, word(lw_real)) && + qa_mock->array[10][1] == word(spare)); + + // 7. A query open across a wait defers the cut to its EndQuery: a list must end the queries it begins. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 56, 0x1111, D3D12_QUERY_TYPE_OCCLUSION, 0); // BeginQuery -> PC 52 + raw(lw, 12, 3, 1, 0, 0); // DrawInstanced + raw(lw, 74, word(&g_cells[6]), 7, 1, 1); + EXPECT(xs::list_proxy_part_count(lw) == 1 && xs::list_value_stats().cuts_deferred == 1); + raw(lw, 57, 0x1111, D3D12_QUERY_TYPE_OCCLUSION, 0); // EndQuery -> PC 53: the cut happens here + EXPECT(xs::list_proxy_part_count(lw) == 2); + EXPECT(hr_of(raw(lw, 9)) == S_OK); + EXPECT(xs::list_value_stats().cut_failures == 0); + + // 8. Writes before a part's first wait (no work yet) land before the queue stands at it, without a cut: the + // title's direct lists write job tags as their first calls and then wait for compute results whose lists wait + // for those tags; a gate ahead of the writes would hold both queues until the timeout. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 72, word(&g_cells[3]), 0x55, 0, 0); // write64 first + raw(lw, 74, word(&g_cells[7]), 7, 2, 1); // then a wait (memory holds 1) + raw(lw, 14, 1, 1, 1); + EXPECT(hr_of(raw(lw, 9)) == S_OK && xs::list_proxy_part_count(lw) == 1); + g_queue_call_count = 0; + EXPECT(submit(qa, lw) == 0); + EXPECT(g_queue_call_count == 3 && queue_call_is(0, qa_mock, 14, word(a_written), 4) && + queue_call_is(1, qa_mock, 15, word(a_gate), 2) && queue_call_is(2, qa_mock, 10, 1, word(lw_real))); + fence_signal(a_written, 4); + EXPECT(!xs::list_values_idle(30) && cell(3) == 0x55 && fence_completed(a_gate) == 1); + InterlockedExchange64(reinterpret_cast(&g_cells[7]), 2); + EXPECT(xs::list_values_idle(2000) && fence_completed(a_gate) == 2); + // A write between two waits cuts the list (it must not land before the first wait is passed); with the first + // wait met, the first part's pre-write and write land behind it, before the queue stands at the second wait. + EXPECT(hr_of(raw(lw, 139, word(allocator), 0)) == S_OK); + raw(lw, 72, word(&g_cells[3]), 0x66, 0, 0); + raw(lw, 74, word(&g_cells[7]), 7, 2, 1); // met + raw(lw, 72, word(&g_cells[4]), 0x77, 0, 0); + raw(lw, 74, word(&g_cells[7]), 7, 3, 1); // unmet: a cut + EXPECT(xs::list_proxy_part_count(lw) == 2 && mock->calls[12] == creates + 1); + raw(lw, 14, 1, 1, 1); + EXPECT(hr_of(raw(lw, 9)) == S_OK); + g_queue_call_count = 0; + EXPECT(submit(qa, lw) == 0); + EXPECT(g_queue_call_count == 4 && queue_call_is(0, qa_mock, 10, 1, word(lw_real)) && + queue_call_is(1, qa_mock, 14, word(a_written), 5) && queue_call_is(2, qa_mock, 15, word(a_gate), 3) && + queue_call_is(3, qa_mock, 10, 1, word(spare))); + fence_signal(a_written, 5); + EXPECT(!xs::list_values_idle(30) && cell(3) == 0x66 && cell(4) == 0x77 && fence_completed(a_gate) == 2); + InterlockedExchange64(reinterpret_cast(&g_cells[7]), 3); + EXPECT(xs::list_values_idle(2000) && fence_completed(a_gate) == 3); + + // Every real list, spare and fence goes with its proxy. + EXPECT(xs::list_values_idle(2000)); + EXPECT(release(lw) == 0 && lw_real->refs == 0 && spare->refs == 0); + EXPECT(release(lv) == 0 && lv_real->refs == 0); + EXPECT(release(allocator) == 0 && real_allocator->refs == 0); + EXPECT(release(qa) == 0 && release(qb) == 0 && qa_mock->refs == 0 && qb_mock->refs == 0); + EXPECT(a_gate->refs == 0 && a_written->refs == 0 && b_gate->refs == 0 && b_written->refs == 0); + EXPECT(release(device) == 0 && mock->refs == 0); + std::printf("%s: list memory writes land after their part, waits hold their part behind a gate (relayed onto a " + "write in flight, bounded by a timeout), and a wait after work cuts the list with its state replayed\n", + g_label); + return 0; +} + +// ---- 15. List values, the rest: LEONIDA_LIST_VALUES=0, bundles, ClearState, root constants, landing order across +// queues, the short timeout for every wait, CopyPageMappingsBatchX behind held work, value stores, the exit ---- + +alignas(64) std::uint64_t g_cells2[32]; + +std::uint64_t cell2(int i) { return *reinterpret_cast(&g_cells2[i]); } + +struct Tear { + alignas(8) std::uint64_t cell = 0; + std::atomic stop{false}; + std::atomic torn{0}, reads{0}; +}; +Tear g_tear; + +// A CPU job of the title's: writes the label a GPU wait is waiting for, 100 ms after it was started. +DWORD WINAPI label_job(LPVOID cell) { + Sleep(100); + InterlockedExchange64(static_cast(cell), 1); + return 0; +} + +// The value of the queue's first logged Signal (slot 14) on `fence` since g_queue_call_count was reset, or 0. +std::uint64_t logged_signal(const Mock* queue, const Mock* fence) { + for (unsigned i = 0; i < g_queue_call_count; ++i) + if (g_queue_calls[i].queue == queue && g_queue_calls[i].slot == 14 && g_queue_calls[i].a1 == word(fence)) + return g_queue_calls[i].a2; + return 0; +} + +DWORD WINAPI tear_reader(LPVOID) { + while (!g_tear.stop.load(std::memory_order_relaxed)) { + const std::uint64_t v = *reinterpret_cast(&g_tear.cell); + if (v != 0 && v != ~0ull) g_tear.torn.fetch_add(1, std::memory_order_relaxed); + g_tear.reads.fetch_add(1, std::memory_order_relaxed); + } + return 0; +} + +int check_list_values_more() { + Mock* mock = nullptr; + void* device = make_device(mock, 9, true, true, true); + EXPECT(device); + mock->zero_fences = true; + xs::reset_list_value_stats(); + xs::set_list_value_wait_timeout_ms(5000); + void* qa = make_queue(device); + void* qb = make_queue(device); + void* qc = make_queue(device); + EXPECT(qa && qb && qc); + Mock* const qa_mock = reinterpret_cast(xs::queue_proxy_real_queue(qa)); + Mock* const qb_mock = reinterpret_cast(xs::queue_proxy_real_queue(qb)); + Mock* const qc_mock = reinterpret_cast(xs::queue_proxy_real_queue(qc)); + const IID allocator_iid = __uuidof(ID3D12CommandAllocator); + const IID gcl_iid = __uuidof(ID3D12GraphicsCommandList); + void* allocator = nullptr; + EXPECT(hr_of(raw(device, 9, 0, word(&allocator_iid), word(&allocator))) == S_OK); + std::memset(g_cells2, 0, sizeof(g_cells2)); + + // 1. LEONIDA_LIST_VALUES=0 (for the lists made meanwhile): writes and waits are the no-ops they were, nothing is + // cut, and the submission is the plain one. + xs::set_list_values_enabled(false); + Mock* off_real = nullptr; + void* off = make_console_list(device, allocator, mock, &off_real); + EXPECT(off && hr_of(raw(off, 9)) == S_OK); + xs::set_list_values_enabled(true); + EXPECT(hr_of(raw(off, 139, word(allocator), 0)) == S_OK); + raw(off, 25, 0x1234); + raw(off, 14, 1, 1, 1); + raw(off, 74, word(&g_cells2[0]), 7, 1, 1); // unmet, after work: a modelled list would be cut here + raw(off, 72, word(&g_cells2[1]), 5, 0, 0); + EXPECT(hr_of(raw(off, 9)) == S_OK && xs::list_proxy_part_count(off) == 1); + xs::ListValueStats stats = xs::list_value_stats(); + EXPECT(stats.waits_recorded == 0 && stats.writes_recorded == 0 && stats.cuts == 0); + g_queue_call_count = 0; + EXPECT(submit(qa, off) == 0); + EXPECT(g_queue_call_count == 1 && queue_call_is(0, qa_mock, 10, 1, word(off_real))); + EXPECT(xs::list_values_idle(2000) && cell2(1) == 0); + + // 2. A bundle's writes and waits are no-ops too (a cut bundle would lose its first parts: ExecuteBundle names + // one real list), but what it sets stays set in the list that executes it, and a cut there replays it. + void* bundle = nullptr; + EXPECT(hr_of(raw(device, 12, 0, D3D12_COMMAND_LIST_TYPE_BUNDLE, word(allocator), 0, word(&gcl_iid), + word(&bundle))) == S_OK); + Mock* const bundle_real = mock->last_child; + raw(bundle, 25, 0xB0B); // SetPipelineState + raw(bundle, 33, 0x5678); // SetComputeRootSignature: the executing list's, whose arguments stay + raw(bundle, 37, 1, 0x99, 0); // SetComputeRoot32BitConstant(1, 0x99, offset 0) + raw(bundle, 14, 1, 1, 1); + raw(bundle, 74, word(&g_cells2[0]), 7, 1, 1); + raw(bundle, 72, word(&g_cells2[1]), 5, 0, 0); + EXPECT(hr_of(raw(bundle, 9)) == S_OK && xs::list_proxy_part_count(bundle) == 1); + stats = xs::list_value_stats(); + EXPECT(stats.bundle_ops == 2 && stats.waits_recorded == 0 && stats.writes_recorded == 0 && stats.cuts == 0); + Mock* direct_real = nullptr; + void* direct = make_console_list(device, allocator, mock, &direct_real); + EXPECT(direct && hr_of(raw(direct, 9)) == S_OK); + EXPECT(hr_of(raw(direct, 139, word(allocator), 0)) == S_OK); + raw(direct, 33, 0x5678); + raw(direct, 35, 2, 0x9000); // a table the bundle leaves alone + const std::uint32_t constants[3] = {0xc1, 0xc2, 0xc3}; + raw(direct, 39, 3, 3, word(constants), 1); // SetComputeRoot32BitConstants(3, 3 values, offset 1) -> PC 35 + raw(direct, 37, 3, 0xc4, 4); // one more right after them: one run of four + raw(direct, 31, word(bundle)); // ExecuteBundle -> PC 27, with the bundle's real list + EXPECT(direct_real->calls[27] == 1 && direct_real->args[27][0] == word(bundle_real)); + const unsigned creates = mock->calls[12]; + raw(direct, 74, word(&g_cells2[0]), 7, 1, 1); // after the bundle's work: a cut + EXPECT(xs::list_proxy_part_count(direct) == 2 && mock->calls[12] == creates + 1); + Mock* const spare = mock->last_child; + EXPECT(spare->calls[25] == 1 && spare->args[25][0] == 0xB0B); + EXPECT(spare->calls[29] == 1 && spare->args[29][0] == 0x5678); + EXPECT(spare->calls[31] == 1 && spare->args[31][0] == 2 && spare->args[31][1] == 0x9000); + EXPECT(spare->calls[33] == 1 && spare->args[33][0] == 1 && spare->args[33][1] == 0x99 && spare->args[33][2] == 0); + // (UINT arguments: only the low halves of their registers are defined) + EXPECT(spare->calls[35] == 1 && std::uint32_t(spare->args[35][0]) == 3 && std::uint32_t(spare->args[35][1]) == 4 && + std::uint32_t(spare->args[35][3]) == 1); + const auto* run = reinterpret_cast(spare->args[35][2]); + EXPECT(run && run[0] == 0xc1 && run[1] == 0xc2 && run[2] == 0xc3 && run[3] == 0xc4); + EXPECT(hr_of(raw(direct, 9)) == S_OK); + + // 3. ClearState(pipeline) forgets what was set before it and sets its pipeline state. + EXPECT(hr_of(raw(direct, 139, word(allocator), 0)) == S_OK); + raw(direct, 25, 0x1234); + raw(direct, 33, 0x5678); + raw(direct, 11, 0x999); // ClearState -> PC 11 + raw(direct, 14, 1, 1, 1); + const unsigned spare_resets = spare->calls[10], spare_pipelines = spare->calls[25]; + const unsigned spare_signatures = spare->calls[29], spare_constants = spare->calls[35]; + raw(direct, 74, word(&g_cells2[0]), 7, 1, 1); // a cut into the same spare + EXPECT(xs::list_proxy_part_count(direct) == 2 && spare->calls[10] == spare_resets + 1); + EXPECT(spare->calls[25] == spare_pipelines + 1 && spare->args[25][0] == 0x999); + EXPECT(spare->calls[29] == spare_signatures && spare->calls[35] == spare_constants); + EXPECT(hr_of(raw(direct, 9)) == S_OK); + + // 4. Writes land in submission order across queues. B's list waits for A's tag (relayed onto A's write fence) + // and then writes the next tag to the same cell: the GPU runs B's work after A's, so once B's fence is done A's + // is too. A pump that read A's fence before B's could see B done and A not, and land A's older tag last. + EXPECT(hr_of(raw(direct, 139, word(allocator), 0)) == S_OK); + raw(direct, 14, 1, 1, 1); + raw(direct, 72, word(&g_cells2[2]), 1, 0, 0); // the tag + raw(direct, 72, word(&g_cells2[3]), 0xA, 0, 0); // and a result next to it + EXPECT(hr_of(raw(direct, 9)) == S_OK); + EXPECT(submit(qa, direct) == 0); + Mock* const a_written = mock->last_child; // qa's value fences are made at this submission + EXPECT(a_written->kind == Kind::fence && fence_completed(a_written) == 0); + Mock* lb_real = nullptr; + void* lb = make_console_list(device, allocator, mock, &lb_real); + EXPECT(lb && hr_of(raw(lb, 9)) == S_OK); + EXPECT(hr_of(raw(lb, 139, word(allocator), 0)) == S_OK); + raw(lb, 74, word(&g_cells2[2]), 7, 1, 1); // wait64(tag >= 1) + raw(lb, 14, 1, 1, 1); + raw(lb, 72, word(&g_cells2[2]), 2, 0, 0); // the next tag + EXPECT(hr_of(raw(lb, 9)) == S_OK); + g_queue_call_count = 0; + EXPECT(submit(qb, lb) == 0); + Mock* const b_written = mock->last_child; + Mock* const b_gate = b_written - 1; + EXPECT(b_written->kind == Kind::fence && b_gate->kind == Kind::fence); + EXPECT(queue_call_is(0, qb_mock, 15, word(a_written), 1) && xs::list_value_stats().waits_relayed == 1); + EXPECT(!xs::list_values_idle(30) && cell2(2) == 0); + b_written->completes_with = a_written; // the first look at B's fence once it is done finds A done as well + b_written->completes_at = 1; + b_written->completes_value = 1; + fence_signal(b_written, 1); + EXPECT(xs::list_values_idle(2000) && fence_completed(a_written) == 1); + EXPECT(cell2(2) == 2 && cell2(3) == 0xA); + + // 5. Four gates in a row that time out give the short timeout to every wait whose address was never met (a new + // address each time here, so none times out three times on its own). A wait cut short and met in the rest of the + // full timeout keeps the full timeout for its address only; a gate cut short and met within its short timeout + // gives every wait the full timeout again. + xs::set_list_value_wait_timeout_ms(100); + xs::reset_list_value_stats(); + const auto hold_on = [&](void* queue, int index, std::uint64_t reference) -> bool { + if (FAILED(hr_of(raw(lb, 139, word(allocator), 0)))) return false; + raw(lb, 74, word(&g_cells2[index]), 7, reference, 1); // wait64(cell >= reference) + raw(lb, 14, 1, 1, 1); + return SUCCEEDED(hr_of(raw(lb, 9))) && submit(queue, lb) == 0; + }; + const auto hold = [&](int index) { return hold_on(qb, index, 1); }; // a cell nothing writes + using Clock = std::chrono::steady_clock; + const auto ms_since = [](Clock::time_point since) { + return std::chrono::duration_cast(Clock::now() - since).count(); + }; + const auto set_cell = [](int index, std::uint64_t value) { + InterlockedExchange64(reinterpret_cast(&g_cells2[index]), static_cast(value)); + }; + for (int i = 0; i < 4; ++i) EXPECT(hold(4 + i) && xs::list_values_idle(3000)); + stats = xs::list_value_stats(); + EXPECT(stats.gates_held == 4 && stats.gates_timed_out == 4 && stats.demotions == 1 && stats.gates_short == 0); + Clock::time_point started = Clock::now(); + EXPECT(hold(8) && xs::list_values_idle(3000) && ms_since(started) < 60); // a new address: cut short + stats = xs::list_value_stats(); + EXPECT(stats.gates_short == 1 && stats.gates_timed_out == 5 && stats.late_met == 0); + set_cell(8, 1); // late, within the full timeout + for (int i = 0; i < 2000 && xs::list_value_stats().late_met == 0; ++i) Sleep(1); + EXPECT(xs::list_value_stats().late_met == 1); + started = Clock::now(); + EXPECT(hold(9) && xs::list_values_idle(3000) && ms_since(started) < 60); // still demoted for a new address + stats = xs::list_value_stats(); + EXPECT(stats.gates_short == 2 && stats.gates_timed_out == 6 && stats.demotions == 1); + // Cell 8 was met before: it keeps the full timeout (met here after 30 ms, within it), and the demotion stays. + EXPECT(hold_on(qb, 8, 2) && !xs::list_values_idle(30)); + set_cell(8, 2); + EXPECT(xs::list_values_idle(3000)); + stats = xs::list_value_stats(); + EXPECT(stats.gates_short == 2 && stats.gates_met == 1 && stats.gates_timed_out == 6); + started = Clock::now(); + EXPECT(hold(10) && xs::list_values_idle(3000) && ms_since(started) < 60); + EXPECT(xs::list_value_stats().gates_short == 3); + // A gate cut short and met within its short timeout lifts the demotion (the write follows the submission at + // once; a slow machine may need another try). + bool lifted = false; + for (int i = 0; i < 3 && !lifted; ++i) { + const std::uint64_t met_before = xs::list_value_stats().gates_met; + EXPECT(hold(11 + i)); + set_cell(11 + i, 1); + EXPECT(xs::list_values_idle(3000)); + lifted = xs::list_value_stats().gates_met == met_before + 1; + } + EXPECT(lifted); + const std::uint64_t short_before = xs::list_value_stats().gates_short; + started = Clock::now(); + EXPECT(hold(14) && !xs::list_values_idle(40)); // a new address, the full timeout again + EXPECT(xs::list_values_idle(3000) && ms_since(started) >= 90); + EXPECT(xs::list_value_stats().gates_short == short_before && xs::list_value_stats().demotions == 1); + + // 6. CopyPageMappingsBatchX behind work the queue has not done: the call returns, and the remap (of a copy of + // the batches) runs once the queue gets there, before the gate its later work waits on opens. With the earlier + // work done it remaps at the call. + xs::set_copy_page_mappings_hook(&record_page_mapping); + g_page_mapping = {}; + const rt::xmem::PageRange remap_ranges[] = {{0, 4, 2}, {2, 0, 6}}; + const rt::xmem::PageBatch remap[] = {{0x9000000000, 2, remap_ranges}}; + g_queue_call_count = 0; + started = Clock::now(); + EXPECT(hr_of(raw(qc, 31, 1, word(remap), 0x7000000000, 16, 0)) == S_OK); + const auto deferred_after = ms_since(started); + EXPECT(deferred_after >= 15 && deferred_after < 100); // the 16 ms bound, on a high-resolution timer + Mock* const c_written = mock->last_child; + Mock* const c_gate = c_written - 1; + EXPECT(c_written->kind == Kind::fence && c_gate->kind == Kind::fence && g_page_mapping.count == 0); + EXPECT(g_queue_call_count == 2 && queue_call_is(0, qc_mock, 14, word(c_written), 1) && + queue_call_is(1, qc_mock, 15, word(c_gate), 1)); + EXPECT(!xs::list_values_idle(30) && fence_completed(c_gate) == 0 && g_page_mapping.count == 0); + // A memory wait behind the remap on the same queue: its time starts when the remap's gate opens, not at its + // submission (held 150 ms behind the remap, it does not open at once then). + const std::uint64_t timed_out_before = xs::list_value_stats().gates_timed_out; + EXPECT(hold_on(qc, 15, 1)); + Sleep(150); + EXPECT(fence_completed(c_gate) == 0 && xs::list_value_stats().gates_timed_out == timed_out_before); + fence_signal(c_written, 1); + EXPECT(!xs::list_values_idle(40) && fence_completed(c_gate) == 1); + EXPECT(xs::list_values_idle(3000) && fence_completed(c_gate) == 2); + EXPECT(xs::list_value_stats().gates_timed_out == timed_out_before + 1); + EXPECT(g_page_mapping.count == 1 && g_page_mapping.batches != remap && g_page_mapping.pool == 0x7000000000 && + g_page_mapping.pages == 16 && g_page_mapping.first_destination == 0x9000000000 && + g_page_mapping.first_count == 2 && g_page_mapping.first_ranges[0].start == 4 && + g_page_mapping.first_ranges[1].kind == 2 && g_page_mapping.first_ranges[1].count == 6); + stats = xs::list_value_stats(); + EXPECT(stats.remaps_deferred == 1 && stats.remaps_now == 0 && stats.remaps_failed == 0); + qc_mock->signals_complete = true; // the queue is idle: its Signal is done at once + g_page_mapping = {}; + g_queue_call_count = 0; + EXPECT(hr_of(raw(qc, 31, 1, word(remap), 0x7000000000, 16, 0)) == S_OK); + EXPECT(g_page_mapping.count == 1 && g_page_mapping.batches == remap && g_queue_call_count == 1); + stats = xs::list_value_stats(); + EXPECT(stats.remaps_deferred == 1 && stats.remaps_now == 1); + qc_mock->signals_complete = false; + xs::set_copy_page_mappings_hook(nullptr); + xs::set_list_value_wait_timeout_ms(5000); + + // 7. Value stores: an aligned 4- or 8-byte value in one locked access (a reader polling it never sees half of + // each), an unaligned one byte by byte, memory that cannot be written reported, not raised. + alignas(8) static std::uint8_t bytes[32] = {}; + EXPECT(leonida::kernel_writes::store(bytes, 0x1122334455667788ull, 8)); + EXPECT(*reinterpret_cast(bytes) == 0x1122334455667788ull); + EXPECT(leonida::kernel_writes::store(bytes + 8, 0xaabbccdd11223344ull, 4)); + EXPECT(*reinterpret_cast(bytes + 8) == 0x11223344u && bytes[12] == 0); + EXPECT(leonida::kernel_writes::store(bytes + 17, 0x0102030405060708ull, 8)); + EXPECT(bytes[17] == 0x08 && bytes[24] == 0x01 && bytes[16] == 0 && bytes[25] == 0); + void* read_only = VirtualAlloc(nullptr, 4096, MEM_COMMIT | MEM_RESERVE, PAGE_READONLY); + EXPECT(read_only && !leonida::kernel_writes::store(read_only, 1, 8) && + !leonida::kernel_writes::store(static_cast(read_only) + 1, 1, 8)); + VirtualFree(read_only, 0, MEM_RELEASE); + const HANDLE reader = CreateThread(nullptr, 0, &tear_reader, nullptr, 0, nullptr); + EXPECT(reader); + for (int i = 0; i < 200000; ++i) leonida::kernel_writes::store(&g_tear.cell, (i & 1) ? ~0ull : 0, 8); + g_tear.stop = true; + WaitForSingleObject(reader, INFINITE); + CloseHandle(reader); + EXPECT(g_tear.torn == 0 && g_tear.reads > 0); + + // 9. write64 flags 1 and 2 take the GPU's timestamp at the write's place in its list (EndQuery and a resolve of + // that one slot into the readback), landed once the part's fence passed: flag 1 in the queue's timestamp ticks (a + // begin/end pair is the GPU work's, not one landing time), flag 2 as the QPC value the queue's clock calibration + // gives. A pre-write that lands before its part ran (the gate is held) takes the CPU's clock instead. + xs::reset_list_value_stats(); + xs::set_list_value_wait_timeout_ms(5000); + EXPECT(hr_of(raw(direct, 139, word(allocator), 0)) == S_OK); + const unsigned end_queries = direct_real->calls[53], resolves = direct_real->calls[54]; + raw(direct, 72, word(&g_cells2[20]), 0, 0, 1); // begin + raw(direct, 14, 1, 1, 1); + raw(direct, 72, word(&g_cells2[21]), 0, 0, 1); // end + raw(direct, 72, word(&g_cells2[22]), 0, 0, 2); // the system's timestamp + EXPECT(hr_of(raw(direct, 9)) == S_OK); + EXPECT(direct_real->calls[53] == end_queries + 3 && direct_real->calls[54] == resolves + 3); + const auto last = static_cast(direct_real->args[53][2]); // EndQuery(heap, type, slot) + EXPECT(std::uint32_t(direct_real->args[53][1]) == D3D12_QUERY_TYPE_TIMESTAMP && last >= 2 && last < 4096); + EXPECT(direct_real->args[54][0] == direct_real->args[53][0] && // ResolveQueryData(heap, type, first, count, + std::uint32_t(direct_real->args[54][2]) == last && // readback, offset) + std::uint32_t(direct_real->args[54][3]) == 1 && direct_real->args[54][5] == std::uint64_t{last} * 8); + g_queue_call_count = 0; + EXPECT(submit(qa, direct) == 0); + const std::uint64_t stamped = logged_signal(qa_mock, a_written); + EXPECT(stamped && cell2(20) == 0 && cell2(21) == 0); + g_mock_readback[last - 2] = kMockGpu0 + 1000; // as the GPU resolves them: 1 MHz ticks + g_mock_readback[last - 1] = kMockGpu0 + 4000; // 3 ms of GPU work later + g_mock_readback[last] = kMockGpu0 - 2000; // 2 ms before the calibration point + fence_signal(a_written, stamped); + EXPECT(xs::list_values_idle(2000)); + EXPECT(cell2(20) == kMockGpu0 + 1000 && cell2(21) == kMockGpu0 + 4000); + LARGE_INTEGER qpc_frequency{}, qpc_now{}; + QueryPerformanceFrequency(&qpc_frequency); + QueryPerformanceCounter(&qpc_now); + EXPECT(cell2(22) == mock_cpu_origin() - 2000 * static_cast(qpc_frequency.QuadPart) / 1000000 && + cell2(22) <= static_cast(qpc_now.QuadPart)); + stats = xs::list_value_stats(); + EXPECT(stats.stamps_gpu == 3 && stats.stamps_cpu == 0); + EXPECT(hr_of(raw(direct, 139, word(allocator), 0)) == S_OK); + raw(direct, 72, word(&g_cells2[23]), 0, 0, 1); // a timestamp, then a wait: a pre-write + raw(direct, 74, word(&g_cells2[24]), 7, 1, 1); // unmet: the gate holds the part + raw(direct, 14, 1, 1, 1); + EXPECT(hr_of(raw(direct, 9)) == S_OK); + const auto pre_slot = static_cast(direct_real->args[53][2]); + g_queue_call_count = 0; + EXPECT(submit(qa, direct) == 0); + const std::uint64_t pre = logged_signal(qa_mock, a_written); + // The pre-write's group is signalled, then the queue stands at the gate, then the part. + EXPECT(pre && g_queue_call_count == 3 && queue_call_is(0, qa_mock, 14, word(a_written), pre) && + g_queue_calls[1].slot == 15 && g_queue_calls[1].a1 == word(a_written - 1)); + g_mock_readback[pre_slot] = 77; // what the part writes once it runs: not there when the pre-write lands + fence_signal(a_written, pre); + for (int i = 0; i < 2000 && cell2(23) == 0; ++i) Sleep(1); + EXPECT(cell2(23) != 0 && cell2(23) != 77 && xs::list_value_stats().stamps_cpu == 1); + set_cell(24, 1); + EXPECT(xs::list_values_idle(3000)); + + // 10. A GPU wait for a label a CPU job of the title's writes later never blocks the submitting thread: the + // submission returns at once with the gate held (with a 5 s timeout), a submission behind it on the same queue + // returns at once too, and the CPU job's write (on another thread, 100 ms later) opens the gate. + const std::uint64_t met_before = xs::list_value_stats().gates_met; + started = Clock::now(); + EXPECT(hold(25)); + const HANDLE job = CreateThread(nullptr, 0, &label_job, &g_cells2[25], 0, nullptr); + EXPECT(job); + EXPECT(hold_on(qb, 26, 0) && ms_since(started) < 50); // a met wait: the plain way, behind the held gate + EXPECT(!xs::list_values_idle(40) && xs::list_value_stats().gates_met == met_before); + EXPECT(xs::list_values_idle(3000) && xs::list_value_stats().gates_met == met_before + 1 && + ms_since(started) >= 90); + WaitForSingleObject(job, INFINITE); + CloseHandle(job); + + // 8. stop() ends both threads. Afterwards nothing new is landed or opened (the process is ending: a gate + // signalled from another thread could open one whose remap was skipped, or go below one still to come), and + // CopyPageMappingsBatchX remaps at the call rather than wait for a queue whose gates stay shut. + xs::stop_list_values(2000); + const std::uint64_t gates_before = fence_completed(b_gate); + EXPECT(hold(16)); + Sleep(20); + EXPECT(fence_completed(b_gate) == gates_before); + xs::set_copy_page_mappings_hook(&record_page_mapping); + g_page_mapping = {}; + started = Clock::now(); + EXPECT(hr_of(raw(qc, 31, 1, word(remap), 0x7000000000, 16, 0)) == S_OK); // its point is never reached + EXPECT(g_page_mapping.count == 1 && g_page_mapping.batches == remap && ms_since(started) < 1000); + xs::set_copy_page_mappings_hook(nullptr); + + EXPECT(release(off) == 0 && off_real->refs == 0); + EXPECT(release(bundle) == 0 && bundle_real->refs == 0); + EXPECT(release(direct) == 0 && direct_real->refs == 0 && spare->refs == 0); + EXPECT(release(lb) == 0 && lb_real->refs == 0); + EXPECT(release(allocator) == 0); + EXPECT(release(qa) == 0 && release(qb) == 0 && release(qc) == 0); + EXPECT(qa_mock->refs == 0 && qb_mock->refs == 0 && qc_mock->refs == 0); + EXPECT(a_written->refs == 0 && b_written->refs == 0 && b_gate->refs == 0 && c_written->refs == 0 && + c_gate->refs == 0); + EXPECT(release(device) == 0 && mock->refs == 0); + std::printf("%s: with LEONIDA_LIST_VALUES=0 and on bundles writes and waits are no-ops, a bundle's and " + "ClearState's state carry over a cut, writes land in submission order across queues, timeouts in a " + "row shorten the waits for addresses never met until one cut short is met, a gate's time starts at " + "its queue's head, a page remap behind held work is deferred, value stores do not tear, and nothing " + "is opened after stop(); timestamp writes land the GPU's timestamps, and a wait for a label a CPU job " + "writes later never blocks the submitting thread\n", + g_label); + return 0; +} + // A failure ends the process with a message on stderr, never in a dialog a test run would wait on: abort() (an // exception that escapes, for one), the debug CRT's reports, and Windows' fault and critical-error boxes. static void no_dialogs() { @@ -4102,6 +4834,8 @@ int main(int argc, char** argv) { check_presentation_wiring() || check_queue_copy_page_mappings()) return 1; if (check_placed_resource_x()) return 1; + if (check_list_values()) return 1; // last: it starts the list-values threads + if (check_list_values_more()) return 1; // and this one stops them std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); return 0; } diff --git a/tests/semantic/test_null_vsharp.py b/tests/semantic/test_null_vsharp.py new file mode 100644 index 0000000000..d7a804fbda --- /dev/null +++ b/tests/semantic/test_null_vsharp.py @@ -0,0 +1,103 @@ +"""Semantic regression tests for a null V# (all four words zero): it reads as a zero buffer, not memory at address 0. + +The D3D12 layer leaves a slot all zeros for a null SRV/UAV/CBV, an empty heap slot, or a buffer view it refuses +(runtime/shims/d3d12_vulkan_device.cpp, CreateShaderResourceView / CreateUnorderedAccessView / +CreateConstantBufferView), and a title's own empty slot holds zeros too. A shader that loads that slot as a V# gets +base 0, NUM_RECORDS 0, OOB_SELECT 0 (structured with offset), FORMAT 0 (INVALID) and DST_SEL 0 everywhere. Every +access is then out of range (docs/buffer_bounds.md: mode 0 with N = 0, s_buffer_load with a limit of 0 bytes): loads +and typed loads give 0 without touching memory, and stores and atomics leave memory alone, which is a null +descriptor's behaviour on the console. The translator needs no rule of its own for this; these tests pin it, so a +later change to the bounds checks cannot turn a null V# into a read or write at address 0. +""" +from __future__ import annotations + +import os +import sys +import unittest + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) +TOOLS_DIR = os.environ.get("LEONIDA_TOOLS_DIR") or os.path.join(ROOT, "tools") + +sys.dont_write_bytecode = True +if TOOLS_DIR not in sys.path: + sys.path.insert(0, TOOLS_DIR) +if HERE not in sys.path: + sys.path.insert(0, HERE) + +import support # noqa: E402 +import test_value_semantics as tv # noqa: E402 + +OUT = 0x2000 +OUT_V = 0x31016FAC # RAW output V#, 0x100 bytes at OUT +SENTINEL = 0x5A5A5A5A +SEED = 0x12345678 + +# 8 user SGPRs (s[0:3] the output V#, s[4:7] the null V#), no TGID SGPRs, 64x1x1 threads. +CS_8_USER_FSSM = tv._fssm(8 << 1, (64, 1, 1)) + +PROGRAM = [ + "v_cmpx_eq_u32_e32 0, v0", + "v_mov_b32 v1, 0", + f"v_mov_b32 v2, {SEED:#x}", + f"v_mov_b32 v3, {SEED:#x}", + f"v_mov_b32 v4, {SEED:#x}", + f"v_mov_b32 v5, {SEED:#x}", + f"v_mov_b32 v6, {SEED:#x}", + f"v_mov_b32 v7, {SEED:#x}", + f"v_mov_b32 v8, {SEED:#x}", + f"v_mov_b32 v9, {SEED:#x}", + f"v_mov_b32 v10, {SEED:#x}", + "v_mov_b32 v11, 0xdead", + "v_mov_b32 v12, 3", + # Raw and structured loads, a typed load and a typed tbuffer load, all through the null V#. + "buffer_load_dword v2, v1, s[4:7], 0 offen", + "buffer_load_dwordx2 v[3:4], v1, s[4:7], 0 idxen", + "buffer_load_format_xyzw v[5:8], v1, s[4:7], 0 idxen", + "s_waitcnt vmcnt(0)", + "buffer_store_dword v2, off, s[0:3], 0", + "buffer_store_dwordx2 v[3:4], off, s[0:3], 0 offset:4", + "buffer_store_dwordx4 v[5:8], off, s[0:3], 0 offset:12", + # Stores and an atomic through the null V#: memory at its base 0 must keep the sentinel. + "buffer_store_dword v11, v1, s[4:7], 0 offen", + "buffer_store_dword v11, off, s[4:7], 0 offset:8", + "buffer_atomic_add v12, v1, s[4:7], 0 offen glc", + "s_waitcnt vmcnt(0)", + "buffer_store_dword v12, off, s[0:3], 0 offset:28", + # A scalar constant-buffer load (a null CBV). + "s_buffer_load_dwordx4 s[16:19], s[4:7], 0x0", + "s_waitcnt lgkmcnt(0)", + "v_mov_b32 v13, s16", + "v_mov_b32 v14, s17", + "v_mov_b32 v15, s18", + "v_mov_b32 v16, s19", + "buffer_store_dwordx4 v[13:16], off, s[0:3], 0 offset:32", + "s_endpgm", +] + + +class NullVsharpTests(unittest.TestCase): + def test_null_vsharp_reads_zero_and_drops_stores(self): + spv = support.translate_lines("cs_null_vsharp", PROGRAM, fssm=CS_8_USER_FSSM) + low = {4 * i: SENTINEL for i in range(8)} # what a read or write at the null V#'s base 0 would touch + mem = tv.ReadLog(dict(low)) + support.run_fragment( + spv, + inputs={"%wg_id": (0, 0, 0), "%local_id": (0, 0, 0)}, + push_constants=[OUT, 0, 0x100, OUT_V, 0, 0, 0, 0] + [0] * 24, + memory=mem, + ) + # Nothing was read: not the null V#'s base, nor anything else. + self.assertEqual(mem.reads, []) + # The loads gave zeros: raw, structured, typed (FORMAT 0 and DST_SEL 0 select 0), and the scalar load. + self.assertEqual([dict.get(mem, OUT + 4 * i) for i in range(7)], [0] * 7) + self.assertEqual([dict.get(mem, OUT + 32 + 4 * i) for i in range(4)], [0] * 4) + # The atomic did not happen; what it returns (out of range) is the hardware's 0. + self.assertEqual(dict.get(mem, OUT + 28), 0) + # Memory at address 0 is untouched, and nothing outside the output was written. + self.assertEqual({a: v for a, v in mem.items() if a < OUT}, low) + self.assertTrue(all(OUT <= a < OUT + 0x100 for a in mem if a not in low)) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/stage_timeline.py b/tools/stage_timeline.py new file mode 100644 index 0000000000..9b37373f10 --- /dev/null +++ b/tools/stage_timeline.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +"""Stage timeline of a boot from the runtime's stderr log: the title's own state (LEONIDA_PEEK lines) joined with the +scripted presses (LEONIDA_INPUT_SCRIPT), so a Confirm can be paired with the state change it caused. + +Reads only the runtime's own lines: + [rt] peek t=s: 0x7446510= 0x98f828c= [0x7453ed0=] ... + [rt] gameinput: scripted press of button at s + +State meanings for this build: game state 0x7446510 (2 init, 3 running); session = low dword of 0x98f828c +(1 boot screens, 3 landing, 0xd first-run pages, 0 story load); low byte of 0x7453ed0 goes 2 -> 0 when the loading +screen ends. + +usage: stage_timeline.py LOG [--json] +""" +import argparse +import json +import re +import sys + +PEEK = re.compile(r"\[rt\] peek t=(\d+)s:(.*)") +FIELD = re.compile(r"0x([0-9a-fA-F]+)=([0-9a-fA-F?,]+)") +PRESS = re.compile(r"\[rt\] gameinput: scripted press of button (\d+) at ([0-9.]+) s") + +SESSION = {1: "boot screens", 3: "landing", 0xD: "first-run pages", 0: "story load"} +GAME = {0: "not started", 2: "init", 3: "running"} + + +def first_value(text): + if text is None or text.startswith("?"): + return None + return int(text.split(",")[0], 16) + + +def read(path): + peeks, presses = [], [] + with open(path, encoding="utf-8", errors="replace") as f: + for line in f: + m = PEEK.search(line) + if m: + fields = {k.lower(): v for k, v in FIELD.findall(m.group(2))} + game = first_value(fields.get("7446510")) + raw = first_value(fields.get("98f828c")) + session = None if raw is None else raw & 0xFFFFFFFF + load = first_value(fields.get("7453ed0")) + peeks.append({"t": int(m.group(1)), "game": game, "session": session, "load": load}) + continue + m = PRESS.search(line) + if m: + presses.append({"t": float(m.group(2)), "button": int(m.group(1))}) + return peeks, presses + + +def timeline(peeks, presses): + """Stage changes with the presses between them; each press is paired with the next stage change, if any.""" + events = [] + last = None + seen_load_byte = False + for p in peeks: + load = p["load"] + ended = p["session"] == 0 and load is not None and seen_load_byte and (load & 0xFF) == 0 + if load is not None and (load & 0xFF) == 2: + seen_load_byte = True + name = "story load (loading screen ended)" if ended else ( + SESSION.get(p["session"], f"session {p['session']:#x}") if p["game"] == 3 and p["session"] is not None + else GAME.get(p["game"], "no title state yet" if p["game"] is None else f"game state {p['game']:#x}")) + if name != last: + events.append({"t": p["t"], "stage": name}) + last = name + for pr in presses: + nxt = next((e for e in events if e["t"] >= pr["t"]), None) + pr["next_change"] = None if nxt is None else {"t": nxt["t"], "stage": nxt["stage"]} + return events + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("log") + ap.add_argument("--json", action="store_true", help="print the stages and presses as JSON") + a = ap.parse_args() + peeks, presses = read(a.log) + if not peeks: + print("no peek lines: run with LEONIDA_PEEK=0x7446510,0x98f828c,0x7453ed0", file=sys.stderr) + return 1 + events = timeline(peeks, presses) + if a.json: + print(json.dumps({"stages": events, "presses": presses}, indent=1)) + return 0 + print("stages (first peek showing each):") + for e in events: + print(f" {e['t']:>5} s {e['stage']}") + print("scripted presses -> next stage change:") + for pr in presses: + n = pr["next_change"] + print(f" {pr['t']:>7.1f} s button {pr['button']} -> " + + (f"{n['stage']} at {n['t']} s" if n else "no later change")) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) From df2e4093efc71313026a93216b1741d7b83d7295 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 05:16:01 -0500 Subject: [PATCH 02/12] runtime: define NOMINMAX before windows.h in submit_phases.h and thread_sampler.h Both headers now include , and the test targets that reach them through vulkan_replay.h (replay_uav_clear_offset_test first) do not define NOMINMAX, so windows.h's max/min macros broke the std::max/std::min calls in vulkan_replay.h ("expected unqualified-id") and the runtime's test build failed. Guard the include the way vulkan_gpu_labels.h already does. Co-Authored-By: Claude Opus 5.5 --- runtime/src/submit_phases.h | 3 +++ runtime/src/thread_sampler.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/runtime/src/submit_phases.h b/runtime/src/submit_phases.h index 790c7e0981..84ea77b028 100644 --- a/runtime/src/submit_phases.h +++ b/runtime/src/submit_phases.h @@ -5,6 +5,9 @@ // milliseconds per submission of each phase with the largest single one, and the share of the wall time the // submitting threads spent in them. The time is the process's age (GetProcessTimes), so it lines up with the boot. #ifdef _WIN32 +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #endif #include diff --git a/runtime/src/thread_sampler.h b/runtime/src/thread_sampler.h index 9166fe5523..282eb20dd1 100644 --- a/runtime/src/thread_sampler.h +++ b/runtime/src/thread_sampler.h @@ -6,6 +6,9 @@ // LEONIDA_SAMPLE_REPORT_S seconds (10) one block lists the busiest threads (CPU share) and the most frequent call // chains (up to eight frames, innermost first): title frames as t+RVA of the function, others as module+RVA. Nothing is // allocated or logged while a thread is suspended, so a suspended thread's locks are never waited for. +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #include From 682a557f873acad42a3df33133a02ab3b3ded600 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 05:27:50 -0500 Subject: [PATCH 03/12] runtime test: define the slot-31 recorder check_list_values_more uses The list-values test of #1723 installs `record_page_mapping` as the CopyPageMappingsBatchX hook and checks `g_page_mapping`, but neither was defined, so xs_proxy_mock_test did not compile. The recorder counts the calls and keeps the arguments plus a copy of the first batch's first ranges, so section 6 can tell a deferred remap of the proxy's copy from one made at the call with the caller's array. It is written from `CopyPageMappingsHook` (shims/d3d12_xs_device.h) and the fields the test reads. Co-Authored-By: Claude Opus 5.5 --- runtime/test/xs_proxy_mock_test.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 7ce6ea4663..b29dd0582b 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -4083,6 +4083,35 @@ DWORD WINAPI tear_reader(LPVOID) { return 0; } +// Queue slot 31 (CopyPageMappingsBatchX) as the list-values tests see it: the hook records the last call and the +// first batch, so a test can tell a remap of the proxy's copy (deferred behind queue work) from the caller's array. +struct PageMappingRecord { + int count = 0; + const rt::xmem::PageBatch* batches = nullptr; + std::uintptr_t pool = 0; + std::uint32_t pages = 0, flags = 0; + std::uintptr_t first_destination = 0; + std::uint32_t first_count = 0; + rt::xmem::PageRange first_ranges[4]{}; +}; +static PageMappingRecord g_page_mapping; + +static bool record_page_mapping(std::uint32_t count, const rt::xmem::PageBatch* batches, std::uintptr_t pool, + std::uint32_t pages, std::uint32_t flags) { + ++g_page_mapping.count; + g_page_mapping.batches = batches; + g_page_mapping.pool = pool; + g_page_mapping.pages = pages; + g_page_mapping.flags = flags; + if (count && batches) { + g_page_mapping.first_destination = batches[0].destination; + g_page_mapping.first_count = batches[0].count; + for (std::uint32_t i = 0; i < batches[0].count && i < 4 && batches[0].ranges; ++i) + g_page_mapping.first_ranges[i] = batches[0].ranges[i]; + } + return true; +} + int check_list_values_more() { Mock* mock = nullptr; void* device = make_device(mock, 9, true, true, true); From eedc7c8db98f26a0cf23d3593bb2eb39fe47d491 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 05:31:36 -0500 Subject: [PATCH 04/12] d3d12_xs: queue slot 31 without a mapper keeps the unmodelled answer xs_proxy_mock failed at line 4791: on a queue whose presentation is managed outside (set_presentation_handler), raw(queue, 31, 0) must be E_NOTIMPL and must not reach SuspendX. #1723's CopyPageMappingsBatchX dispatch answered every slot-31 call itself, and with no hook and no xmem (a proxy compiled alone) queue_copy_page_mappings returned S_OK having mapped nothing. The test was right. The file's own comment says that without xmem the slot is refused as before, and check_queue_copy_page_mappings expects the console-only answer every unmodelled queue slot gets in that case. The new dispatch now runs only when something can remap (a hook set with set_copy_page_mappings_hook, or xmem's copy_page_mappings_fn); otherwise the call goes on to the presentation routes and the unmodelled-slot answer as on main. With xmem linked, as in gta6rt, nothing changes. Co-Authored-By: Claude Opus 5.5 --- runtime/shims/d3d12_xs_device.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 55113b8c3d..57f209c194 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -2258,16 +2258,22 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_ std::unique_lock queue_order; if constexpr (K == ChildKind::queue && queue_slot_orders_work(Slot)) queue_order = std::unique_lock(self->queue_order); + // CopyPageMappingsBatchX when something can remap: a hook (set_copy_page_mappings_hook) or xmem. Without + // either (a proxy compiled without xmem) the slot keeps the answer every unmodelled queue slot past the + // public chain gets below: console-only S_OK, or E_NOTIMPL on a queue whose presentation is managed outside. if constexpr (K == ChildKind::queue && Slot == kQueueCopyPageMappingsBatchX) { - const HRESULT hr = queue_copy_page_mappings(self, UINT(a1), reinterpret_cast(a2), - a3, UINT(a4), UINT(a5)); - if (FAILED(hr)) { - static std::atomic failures{0}; - if (failures.fetch_add(1, std::memory_order_relaxed) < 8) - std::fprintf(stderr, "[rt] CopyPageMappingsBatchX failed: hr=0x%08x batches=%u pool=%p pages=%u flags=%u\n", - unsigned(hr), UINT(a1), reinterpret_cast(a3), UINT(a4), UINT(a5)); + if (g_copy_page_mappings.load(std::memory_order_acquire) || rt::xmem::copy_page_mappings_fn) { + const HRESULT hr = queue_copy_page_mappings( + self, UINT(a1), reinterpret_cast(a2), a3, UINT(a4), UINT(a5)); + if (FAILED(hr)) { + static std::atomic failures{0}; + if (failures.fetch_add(1, std::memory_order_relaxed) < 8) + std::fprintf(stderr, "[rt] CopyPageMappingsBatchX failed: hr=0x%08x batches=%u pool=%p " + "pages=%u flags=%u\n", unsigned(hr), UINT(a1), reinterpret_cast(a3), + UINT(a4), UINT(a5)); + } + return hr_to_u64(d3d12_trace::result(child_trace_name(Slot), hr)); } - return hr_to_u64(d3d12_trace::result(child_trace_name(Slot), hr)); } if constexpr (K == ChildKind::queue && Slot == kQueueExecuteCommandListsX) { d3d12_trace::record(child_trace_name(Slot)); From 6f36d1400297d44151e5b078248cdf15c7b98211 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:00:30 -0500 Subject: [PATCH 05/12] d3d12: inline table V#s nothing backs become zero-size, as console heap slots d3d12_title_va failed at line 502 and d3d12_unmapped_vsharp at line 191: a V# the CPU writes into a bound table of a layer heap, naming an address nothing backs (an unknown high address, a view past the end of a real buffer), kept its base after the table scan, so a shader would add heap_base to it and fault. The tests were right. #1723 added fix_vsharp, which rebases a V# into the title's memory and writes one with no GPU backing as zero-size, and gave it an "inline table" path (VsharpPath::table), but only the console heap copy calls it; scan_title_table still called rebase_title_vsharp, which leaves an unbacked base as it is, and only the slot's first V#. scan_title_table now runs fix_vsharp on both V#s of each slot (the second is a UAV's counter), as fix_console_slot does. With line 502 passing, the rest of d3d12_title_va runs again, #1539's check_declined_imports and check_import_over_shadow (run by d3d12_geometry_views) included. The same executable's d3d12_api_descriptor_copy and d3d12_rebound_* registrations stopped at line 502 too. Co-Authored-By: Claude Opus 5.5 --- runtime/shims/d3d12_vulkan_device.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 0b80f053bc..f7739635b5 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -2770,8 +2770,14 @@ struct DeviceState { // Slots the title wrote in its own backing of this heap, if it gave the heap one. aliases.pull_descriptors(arena.mapped + table_va, std::size_t(end - table_va)); if (sampler) return; // S# words describe sampling state. They have no buffer address to translate. - for (VkDeviceSize at = table_va; at + 16 <= end; at += kDescriptorSize) - rebase_title_vsharp(reinterpret_cast(arena.mapped + at), aliases); + // Each slot's V# and the counter V# in its second half, as a console heap's GPU copy (fix_vsharp): a base in + // the title's memory is rebased, one nothing backs becomes zero-size instead of a GPU fault at heap_base plus + // that address. + for (VkDeviceSize at = table_va; at + kDescriptorSize <= end; at += kDescriptorSize) { + auto* const w = reinterpret_cast(arena.mapped + at); + fix_vsharp(w, VsharpPath::table); + fix_vsharp(w + 4, VsharpPath::table); + } } // A buffer V# (its first four dwords at `w`) whose base is in the title's own memory gets the console VA of a GPU From d7ef292e31807bb1f890384a2a9b1337f1032fdf Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:00:45 -0500 Subject: [PATCH 06/12] d3d12: a V# may name a layer buffer below the arena again, sign-extended On the RDNA2 iGPU (RADV) d3d12_compute went from pass (main) to fail at line 676, and #1723's d3d12_unmapped_vsharp failed at line 135 and d3d12_graphics_indirect_heap_resources at line 478. In each, a view of an upload buffer came out zero-size ("buffer SRV: address 0xffffffffffe20000 (16 bytes) has no GPU copy; zero records"). Measured there: RADV puts upload buffers below the arena, so their VA (device address minus heap_base) is negative, 0xffffffffffe30000 in unmapped_vsharp. llvmpipe puts them above it, and all three pass there. main was right. docs/design.md ("Heap-relative buffer device addresses") makes the V# base a signed 48-bit offset: the translator sign-extends it, and main wrote such an offset for the layer's own buffers. d3d12_compute's shader reads it sign-extended, as the contract says. #1723's vsharp_address accepted a negative offset only with LEONIDA_IMPORT_BELOW_ARENA=1, the switch that decides whether title memory may be imported below the arena, and wrote every other view of such a buffer as zero-size. encodable() now accepts a negative offset that fits in 48 signed bits whatever the switch says. backed() still requires a buffer registered in gpu_backings or the geometry copies, so the switch alone still decides whether there is a title import there. An already-written V# whose bit 47 is set is also read as negative when that is what names a backing. Unbacked addresses still become zero-size, as #1723 wants. Co-Authored-By: Claude Opus 5.5 --- runtime/shims/d3d12_vulkan_device.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index f7739635b5..fdef7f25a5 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -2841,11 +2841,15 @@ struct DeviceState { if (!base || !bytes) return 0; auto& aliases = leonida::title_va_aliases(); constexpr uint64_t mask = (1ull << 48) - 1; + // A negative offset (a buffer of the layer's that the driver put below the arena) fits the 48 bits as the + // translated shaders read them, sign-extended (docs/design.md, "Heap-relative buffer device addresses"); only + // a buffer registered in gpu_backings or the geometry copies is ever accepted, so LEONIDA_IMPORT_BELOW_ARENA + // still decides alone whether title memory is imported there. const auto encodable = [&](uint64_t offset) { const uint64_t limit = signed_vsharp_offsets() ? mask / 2 : mask; if (offset <= limit) return bytes - 1 <= limit - offset; - return signed_vsharp_offsets() && offset >= UINT64_MAX - limit && - bytes - 1 <= limit - offset; // unsigned distance across zero + return offset >= UINT64_MAX - mask / 2 && + bytes - 1 <= mask / 2 - offset; // unsigned distance across zero }; const auto backed = [&](uint64_t offset) { if (!encodable(offset)) return false; @@ -2867,6 +2871,8 @@ struct DeviceState { uint64_t offset = base; if (signed_vsharp_offsets() && base <= mask && (base & (1ull << 47))) offset |= ~mask; if (backed(offset)) return offset; + // Read the other way: bit 47 as a sign, for a below-arena buffer's V# the layer wrote itself. + if (offset == base && base <= mask && (base & (1ull << 47)) && backed(base | ~mask)) return base | ~mask; if (try_geometry) { to = geometry_va(base, bytes, false); if (to && encodable(to)) return to; From 92394f1f83e96099cc517aefcbe70adc69c9a520 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:00:45 -0500 Subject: [PATCH 07/12] title_gpu_views: a pair can be marked independent; such a twin is not imported d3d12_xmem_placed failed at line 113 (to_cpu(dst) == dst) and line 244 (independently_mapped(gpu, size)). #1723 added View::independent_pages, the to_cpu branch and independently_mapped for a GPU-only range that queue slot 31 maps by itself, but nothing ever sets the flag: xmem calls note_reservation without it, so every pair it makes is the legacy kind, read at its CPU view. Nothing in the runtime read independently_mapped either, although its comment says a slot-133 buffer there must be a shadow, not an import. Neither side is simply right. The tests express #1723's design, but no rule exists for which of the title's pairs are independent, and none can be inferred: marking every GPU-only pair independent (tried) breaks main's xmem test, whose pair (attributes 0x23/0x3, protect 0x2004 then 0x801, two constant sets docs/xmem_exe_calls.md lists among the title's sites) must read at the CPU view, and would move where DirectStorage, slot-70 views and slot 31's CPU mirror read and write in the game. That rule is left to #1723's author. So: - title_gpu_views::set_independent_pages(gpu) marks a pair. Nothing in the runtime calls it yet, so the game's behaviour does not change. - create_host_buffer declines an import over an independently mapped range before making anything, as independently_mapped's comment asks, and the shadow answers. On llvmpipe the import otherwise succeeded and the twin was never guarded (line 264, seen with every pair marked). - d3d12_xmem_placed marks its two windows. It now also checks that xmem made them the legacy kind and that marking changes to_cpu and independently_mapped. Everything after that (slot 31 remapping only the GPU range, the CPU view untouched, the guarded twin, pins, host and kernel writes) is checked as before. Co-Authored-By: Claude Opus 5.5 --- runtime/shims/d3d12_vulkan_device.cpp | 8 ++++++++ runtime/src/title_page_watch.h | 16 ++++++++++++++++ runtime/test/d3d12_xmem_placed_test.cpp | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index fdef7f25a5..22d5f1f419 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -5741,6 +5741,14 @@ class Resource final int(desc_.Width > INT_MAX ? INT_MAX : desc_.Width)); return E_NOTIMPL; } + // A GPU-only range with pages of its own (title_gpu_views::independently_mapped): queue slot 31 remaps them + // there, and an import would keep the GPU on the old physical pages. The shadow, copied from the pages before + // every submission, follows the remap. Declined before anything is made, so nothing is left behind. + if (leonida::title_gpu_views::independently_mapped(start, desc_.Width)) { + log_once("a title-placed buffer over a GPU-only range slot 31 maps by itself is not imported, size", + int(desc_.Width > INT_MAX ? INT_MAX : desc_.Width)); + return E_NOTIMPL; + } // The whole imported range must be committed, possibly across several allocations (the retail buffer spans // three mapped windows); a page not committed yet (xmem commits on first touch) or a write-combined one (on // an RTX 5090 such an import succeeded but GPU reads returned wrong bytes, found in review) is not imported, diff --git a/runtime/src/title_page_watch.h b/runtime/src/title_page_watch.h index 2592f57cec..ccc085466c 100644 --- a/runtime/src/title_page_watch.h +++ b/runtime/src/title_page_watch.h @@ -258,6 +258,22 @@ inline bool note_reservation(std::uintptr_t base, std::uintptr_t size, bool gpu_ return true; } +// Marks the pair whose GPU-only range starts at `gpu` as one whose GPU-only range has pages of its own (queue slot 31 +// or XMemMapPhysicalPages map them at that address, not through the CPU view): the host reads it there (to_cpu) and +// a slot-133 buffer over it is a shadow, not an import (independently_mapped). False when no pair starts at `gpu`. +// Nothing in the runtime marks a pair yet: which of the title's pairs are independent is not decided (a pair xmem +// makes is the legacy kind, read at its CPU view), so only tests that model an independent window call it. +inline bool set_independent_pages(std::uintptr_t gpu, bool independent = true) { + State& s = state(); + std::unique_lock lock(s.mutex); + for (View& v : s.views) { + if (v.gpu != gpu) continue; + v.independent_pages = independent; + return true; + } + return false; +} + // Where the host reads a GPU address. Slot 31 maps its window directly; legacy pairs use the CPU view. inline std::uintptr_t to_cpu(std::uintptr_t va, std::uintptr_t bytes = 1) { State& s = state(); diff --git a/runtime/test/d3d12_xmem_placed_test.cpp b/runtime/test/d3d12_xmem_placed_test.cpp index fb20305578..7c64a23cf6 100644 --- a/runtime/test/d3d12_xmem_placed_test.cpp +++ b/runtime/test/d3d12_xmem_placed_test.cpp @@ -110,6 +110,9 @@ int queue_remap(ID3D12Device* real, ID3D12Device* proxy) { auto* cpu = window(PAGE_READWRITE); auto* dst = window(0x801); EXPECT(pool && cpu && dst && leonida::title_gpu_views::other_view(uintptr_t(dst)) == uintptr_t(cpu)); + // xmem pairs dst with cpu as the legacy kind (read at the CPU view); this window is the kind slot 31 maps by itself. + EXPECT(leonida::title_gpu_views::to_cpu(uintptr_t(dst)) == uintptr_t(cpu)); + EXPECT(leonida::title_gpu_views::set_independent_pages(uintptr_t(dst))); EXPECT(leonida::title_gpu_views::to_cpu(uintptr_t(dst)) == uintptr_t(dst)); std::uint64_t pages[n]{}, count = n; EXPECT(allocate(0x280, &count, pages) && count == n); @@ -241,6 +244,9 @@ int paired_views(ID3D12Device* real) { auto* cpu = static_cast(reserve(nullptr, size, MEM_RESERVE | kXmem64kPages, 0, PAGE_READWRITE)); auto* gpu = static_cast(reserve(nullptr, size, MEM_RESERVE | kXmem64kPages, 0, 0x801)); EXPECT(cpu && gpu && leonida::title_gpu_views::other_view(uintptr_t(gpu)) == uintptr_t(cpu)); + // The twin is the kind slot 31 maps by itself (xmem pairs it as the legacy kind, read at the CPU view). + EXPECT(!leonida::title_gpu_views::independently_mapped(uintptr_t(gpu), size)); + EXPECT(leonida::title_gpu_views::set_independent_pages(uintptr_t(gpu))); EXPECT(leonida::title_gpu_views::independently_mapped(uintptr_t(gpu), size)); std::uint64_t pages[n]{}, count = n; EXPECT(allocate(0x280, &count, pages) && count == n && map(gpu, n, pages) == gpu); From 29c356b0bcd448181eb74367757dae922cb106ec Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 05:54:13 -0500 Subject: [PATCH 08/12] runtime test: cs_user_data's descriptor-word mode gets its own sentinel d3d12_rebound_tables, d3d12_rebound_second_device and d3d12_api_descriptor_copy went from pass (main) to fail at line 896 of d3d12_title_va_test: 0/64 GPU words matched on both submissions, although the mirrored CBV in the layer heap was right (checked by printing the slot after the submission). They had been hidden behind line 502 in the same executable. main was right. Its rebound-table check selects the test shader's indexed CBV mode with s5 = 0xFFFFFFFB. #1723 added a mode that returns a descriptor's words instead, also on 0xFFFFFFFB, ahead of main's branch, so the rebound tables read the words at s8 (unset, address 0) instead of the CBV's data. #1723's mode now uses 0xFFFFFFFA, which nothing else uses, and its one caller (the out[3] dispatch in check_title_va) passes that. Both checks run as written. Co-Authored-By: Claude Opus 5.5 --- runtime/test/d3d12_title_va_test.cpp | 2 +- runtime/test/glsl/cs_user_data.comp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/test/d3d12_title_va_test.cpp b/runtime/test/d3d12_title_va_test.cpp index 622e8252ec..ce4c7a7235 100644 --- a/runtime/test/d3d12_title_va_test.cpp +++ b/runtime/test/d3d12_title_va_test.cpp @@ -586,7 +586,7 @@ int check_title_memory(Context& c, int& checks, bool geometry) { list->SetComputeRootUnorderedAccessView(1, ring_va + 0x3000); list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 2 * inc}); list->Dispatch(1, 1, 1); - list->SetComputeRoot32BitConstant(0, 0xFFFFFFFBu, 1); + list->SetComputeRoot32BitConstant(0, 0xFFFFFFFAu, 1); // cs_user_data's descriptor-word mode list->SetComputeRootUnorderedAccessView(1, out[3]->GetGPUVirtualAddress()); list->SetComputeRootDescriptorTable(2, D3D12_GPU_DESCRIPTOR_HANDLE{gpu + 5 * inc}); list->Dispatch(1, 1, 1); diff --git a/runtime/test/glsl/cs_user_data.comp b/runtime/test/glsl/cs_user_data.comp index 6029eddfb6..113d1454c0 100644 --- a/runtime/test/glsl/cs_user_data.comp +++ b/runtime/test/glsl/cs_user_data.comp @@ -38,8 +38,9 @@ Words at(uvec2 va) { void main() { const uint i = gl_GlobalInvocationID.x; Words result = at(uvec2(pc.s[6], pc.s[7])); - if (pc.s[5] == 0xFFFFFFFBu) { - // Inspect descriptor words without dereferencing a possibly invalid address. + if (pc.s[5] == 0xFFFFFFFAu) { + // Inspect descriptor words without dereferencing a possibly invalid address. 0xFFFFFFFB is the rebound-table + // test's indexed CBV mode below. Words view = at(uvec2(pc.s[8], 0u)); result.w[i] = view.w[i % 4u]; return; From c7fdc26d2a06df7b25242963b7be18d5c53e33fd Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:00:54 -0500 Subject: [PATCH 09/12] runtime test: compile_teardown expects no session cache from llvmpipe #1723's new d3d12_compile_teardown failed on llvmpipe at line 436: no pipeline_cache.session.bin after teardown. It passes on the iGPU. The runtime was right and the test assumed every driver keeps compiled pipelines in a VkPipelineCache. Measured with a print in save_session_pipeline_cache: after the warm-up build, llvmpipe's vkGetPipelineCacheData returns VK_SUCCESS and 32 bytes, the header alone (the save limit was 64 MiB). The runtime writes no file of a bare header on purpose, as it is no cache. The check now reads the driver ID (VkPhysicalDeviceDriverProperties). On llvmpipe the file must be absent; on every other driver it must be written at teardown, as before. The rest of the case (the background build ran, the worker joined) is unchanged. Co-Authored-By: Claude Opus 5.5 --- runtime/test/d3d12_compile_teardown_test.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/test/d3d12_compile_teardown_test.cpp b/runtime/test/d3d12_compile_teardown_test.cpp index 653de046a9..116c2459d8 100644 --- a/runtime/test/d3d12_compile_teardown_test.cpp +++ b/runtime/test/d3d12_compile_teardown_test.cpp @@ -433,8 +433,16 @@ int main() { EXPECT(built(s.psos[0])); s.release(); EXPECT(!compiler.worker_running()); - EXPECT(std::filesystem::exists(cache_dir / "pipeline_cache.session.bin")); - std::printf("cache: built in the background, session cache written at teardown, worker joined\n"); + // llvmpipe keeps no pipelines in a VkPipelineCache (measured: vkGetPipelineCacheData returns the 32-byte + // header alone after the build), and the runtime writes no file of a bare header (save_session_pipeline_cache). + VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; + VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &driver}; + reinterpret_cast( + d.instance_proc(d.instance, "vkGetPhysicalDeviceProperties2"))(d.physical, &properties); + const bool caches = driver.driverID != VK_DRIVER_ID_MESA_LLVMPIPE; + EXPECT(std::filesystem::exists(cache_dir / "pipeline_cache.session.bin") == caches); + std::printf("cache: built in the background, session cache %s at teardown, worker joined\n", + caches ? "written" : "not written (the driver keeps no pipelines in its cache)"); } // The driver may start threads of its own at the first pipeline build; count from here. const unsigned baseline = thread_count(); From 59c54c1eb000162fe0b07f200ecdf327e5b0d435 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:16:46 -0500 Subject: [PATCH 10/12] d3d12_xs: list slots 71/72 have one writer, the list values, when they track the list Found by the comparison agent, not by a failing test. #1723's console list slot path still handed slots 71 and 72 to main's GPU-label hook (record_gpu_label, LEONIDA_GPU_LABELS) when its own list values track the list (track_values, on by default with LEONIDA_LIST_VALUES). The --first-run-ui profile sets LEONIDA_GPU_LABELS=1 (runtime/src/main.cpp). With both on, two threads stored to one title address, one from a Vulkan command buffer's completion and query, the other from the part's fence and a D3D12 timestamp query. A late label could rewind a rising counter or split a begin/end pair. The suite did not catch it: xbox_gpu_label_completion submits its real list straight to the queue, so only the label path landed there. The list values are the right owner. They land slots 71 to 74 in queue order behind the gates, and they also do the waits the labels cannot do. Now: - The label hook runs only for a list the list values do not track (LEONIDA_LIST_VALUES=0, bundles). Each handoff is counted in ListValueStats::labels_handed. - The --first-run-ui profile no longer sets LEONIDA_GPU_LABELS. runtime/README.md and docs/first_run_ui.md say so. - xbox_gpu_label_completion runs its label section with the list values off, as it always measured the label path alone, and checks that all five writes went there. A new section turns both on and records one write32 and one write64 on a tracked list, submitted through the queue proxy. Each lands exactly once: writes_landed == 2, labels_handed == 0, and the values are in memory. With the old condition this section fails at line 136 (labels_handed was 2), on llvmpipe and the iGPU. Co-Authored-By: Claude Opus 5.5 --- docs/first_run_ui.md | 2 +- runtime/README.md | 2 +- runtime/shims/d3d12_xs_device.cpp | 10 +++++-- runtime/shims/d3d12_xs_device.h | 1 + runtime/shims/d3d12_xs_list_values.h | 2 ++ runtime/src/main.cpp | 2 +- runtime/test/xbox_gpu_label_test.cpp | 42 +++++++++++++++++++++++++++- 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/docs/first_run_ui.md b/docs/first_run_ui.md index d7b2fe5e5c..11db318735 100644 --- a/docs/first_run_ui.md +++ b/docs/first_run_ui.md @@ -30,7 +30,7 @@ Run the title offline. The Winsock shim permits loopback and the WinHTTP shim re & (Join-Path $port 'gta6rt.exe') --first-run-ui (Join-Path $game 'game_scarlett_master.exe') ``` -The profile selects Vulkan, a 2 GiB graphics address arena, on-demand pipelines, console root-argument layout, GPU completion labels, frame pacing and the keyboard gamepad. Explicit environment settings take precedence; a variable that is set but empty does not count. Speech synthesis through the host's own runtime is not part of the profile: `LEONIDA_LOCAL_SPEECH=1` turns it on, and without it the silent voice answers. The switches are listed in [`runtime/README.md`](../runtime/README.md). The package directory is the working directory. Guest output goes under `first-run-ui/overlay` beside the runtime, and sparse physical-memory backing uses `first-run-ui/xmem` on that volume. Use `--overlay DIR` or the absolute directory in `LEONIDA_XMEM_BACKING_DIR` to choose other writable locations. +The profile selects Vulkan, a 2 GiB graphics address arena, on-demand pipelines, console root-argument layout, frame pacing and the keyboard gamepad. GPU completion labels (`LEONIDA_GPU_LABELS`) are not part of it: the list values land the title's list writes, and two writers of one address could rewind a counter. Explicit environment settings take precedence; a variable that is set but empty does not count. Speech synthesis through the host's own runtime is not part of the profile: `LEONIDA_LOCAL_SPEECH=1` turns it on, and without it the silent voice answers. The switches are listed in [`runtime/README.md`](../runtime/README.md). The package directory is the working directory. Guest output goes under `first-run-ui/overlay` beside the runtime, and sparse physical-memory backing uses `first-run-ui/xmem` on that volume. Use `--overlay DIR` or the absolute directory in `LEONIDA_XMEM_BACKING_DIR` to choose other writable locations. ## Contributions diff --git a/runtime/README.md b/runtime/README.md index 9f353f72f0..d446f3afc7 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -352,7 +352,7 @@ ones marked *diagnostic* only add log lines or exist to compare a run with and w | `LEONIDA_PIPELINE_COMPILE` | unset | `on-demand` (the `--first-run-ui` profile sets it) prepares pipeline-state streams and sampled views at bind time: a placed 2D texture then waits for its memory until a command or a view first uses it. `cache-only` makes an eager build (`LEONIDA_LAZY_PIPELINES=0`) ask the driver's cache first and leaves what would have to be compiled to the first draw. `first-use` is accepted and means the default. When a pipeline is compiled is `LEONIDA_LAZY_PIPELINES`. | | `LEONIDA_GRAPHICS_STAGE_LAYOUT` | on | Graphics root arguments are laid out as the console does for the vertex, pixel and geometry stages (from `s8`, a descriptor table in one dword). `0` keeps `rt::rootsig::pack()` (from `s0`, two dwords per address) for every graphics signature. | | `LEONIDA_FRAME_PACING` | unset | `1` (the `--first-run-ui` profile sets it) hands device slots 78 to 81 (`SetFrameIntervalX`, `ScheduleFrameEventX`, `WaitFrameEventX`, `GetFrameStatisticsX`) to the device's own presentation once the first `PresentX` has built it, with the title's interval and origin event replayed to its pacer. Unset, the slots answer from the device's token counter with no wait. | -| `LEONIDA_GPU_LABELS` | unset | `1` (the `--first-run-ui` profile sets it) records the labels of console list slots 71 and 72 and stores each into the title's memory when the GPU has finished the command buffer that carries it (`src/vulkan_gpu_labels.h`). Unset, the two slots do nothing. | +| `LEONIDA_GPU_LABELS` | unset | `1` records the labels of console list slots 71 and 72 and stores each into the title's memory when the GPU has finished the command buffer that carries it (`src/vulkan_gpu_labels.h`), for lists the list values (`LEONIDA_LIST_VALUES`, on by default) do not track: those land their slot 71 to 74 writes themselves, and a second writer could rewind a counter. Unset, the two slots of an untracked list do nothing. | | `LEONIDA_LINEAR_MAP_FIRST` | unset | `Map` of a slot 133 texture leased as linear answers with the placement address and the title texture registry fills the image. `1` gives it the linear mapping instead: pinned pages, with a GPU-written texture read back into them, and a refusal when the pages are gone. | | `LEONIDA_CONSOLE_D16S8` | by GPU | The console's `D16_UNORM_S8_UINT` family (DXGI 118 to 120) is made as the D24S8 family where the GPU has `D24_UNORM_S8_UINT` as a depth-stencil attachment and keeps its own D16/S8 path where it has none (AMD). `native` or `d24` chooses for every GPU. The device logs which it took. | | `LEONIDA_RGBA4_COPY_REFUSE` | unset | `1` refuses a footprint copy to or from a `B4G4R4A4_UNORM` render target stored as RGBA8 (its texels are four bytes there, not two). Unset, the copy is made. | diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 57f209c194..f89067fa39 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -3204,7 +3204,13 @@ std::uint64_t WINAPI list_slot(ListProxy* self, std::uint64_t a1, std::uint64_t if constexpr (pc == kListNotForwarded) { #ifdef LEONIDA_VULKAN_DEVICE if constexpr (Slot == 71 || Slot == 72) { - if (leonida::label::enabled()) { + // One owner per write: a list the list values track lands its slot 71-74 writes itself, at the part's + // fence and with a D3D12 timestamp query for flags 1 and 2. The label path would store to the same + // address again from its own command-buffer completion and a Vulkan query, so a late label could + // rewind a rising counter or split a begin/end pair. It answers only for lists not tracked here + // (LEONIDA_LIST_VALUES=0, bundles). + if (leonida::label::enabled() && !self->track_values) { + list_values::bump(list_values::counters().labels_handed); const unsigned width = Slot == 71 ? 4u : 8u; const unsigned clock = Slot == 72 ? ((a4 & 1) ? 1u : ((a4 & 2) ? 2u : 0u)) : 0u; auto target = leonida::label::memory().capture(a1, width); @@ -6488,7 +6494,7 @@ const char* list_tail_slot_name(unsigned slot, unsigned char console_layout) { X(waits_relayed) X(gates_held) X(gates_met) X(gates_timed_out) X(cuts) X(cuts_deferred) X(cut_failures) \ X(gates_short) X(demotions) X(late_met) X(bundle_ops) X(releases) X(release_us) X(release_us_max) \ X(pass_us_max) X(release_stalls) X(remaps_now) X(remaps_deferred) X(remaps_failed) X(remap_wait_us_max) \ - X(stamps_gpu) X(stamps_cpu) + X(stamps_gpu) X(stamps_cpu) X(labels_handed) ListValueStats list_value_stats() { const list_values::Counters& c = list_values::counters(); diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 7b5a3b35fa..8ad512bc98 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -475,6 +475,7 @@ struct ListValueStats { std::uint64_t release_stalls; // gate Signals still running after a second std::uint64_t remaps_now, remaps_deferred, remaps_failed, remap_wait_us_max; // queue slot 31 std::uint64_t stamps_gpu, stamps_cpu; // write64 flags 1/2 landed with the GPU's timestamp, the CPU's clock + std::uint64_t labels_handed; // slot 71/72 writes given to LEONIDA_GPU_LABELS (lists not tracked here) }; ListValueStats list_value_stats(); void reset_list_value_stats(); diff --git a/runtime/shims/d3d12_xs_list_values.h b/runtime/shims/d3d12_xs_list_values.h index eefca7e23b..d6baab5bd4 100644 --- a/runtime/shims/d3d12_xs_list_values.h +++ b/runtime/shims/d3d12_xs_list_values.h @@ -169,6 +169,8 @@ struct Counters { std::atomic remaps_now{0}, remaps_deferred{0}, remaps_failed{0}, remap_wait_us_max{0}; // Timestamp writes (write64 flags 1 and 2) landed with the GPU's timestamp, and with the CPU clock at landing. std::atomic stamps_gpu{0}, stamps_cpu{0}; + // List slot 71/72 writes handed to the GPU-label path (LEONIDA_GPU_LABELS) of a list these values do not track. + std::atomic labels_handed{0}; }; inline Counters& counters() { diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index aec5114148..f019977759 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -195,7 +195,7 @@ bool configure_first_run_ui(const std::filesystem::path& package, std::filesyste const struct { const wchar_t* name; const wchar_t* value; } settings[] = { {L"LEONIDA_D3D12", L"vulkan"}, {L"LEONIDA_ARENA_MB", L"2048"}, {L"LEONIDA_GRAPHICS_STAGE_LAYOUT", L"1"}, {L"LEONIDA_PIPELINE_COMPILE", L"on-demand"}, - {L"LEONIDA_GPU_LABELS", L"1"}, {L"LEONIDA_FRAME_PACING", L"1"}, + {L"LEONIDA_FRAME_PACING", L"1"}, {L"LEONIDA_KEYBOARD_PAD", L"always"}, }; for (const auto& setting : settings) { diff --git a/runtime/test/xbox_gpu_label_test.cpp b/runtime/test/xbox_gpu_label_test.cpp index 4d1be21610..a7aa64818b 100644 --- a/runtime/test/xbox_gpu_label_test.cpp +++ b/runtime/test/xbox_gpu_label_test.cpp @@ -34,6 +34,10 @@ using Create = HRESULT(WINAPI *)(void *, const void *, ID3D12CommandAllocator *, using Label = void(WINAPI *)(void *, std::uintptr_t, std::uint64_t, std::uint32_t, std::uint32_t); int main() { _putenv_s("LEONIDA_GPU_LABELS", "1"); + // First the label path alone: these lists are not tracked by the list values, which own slots 71 to 74 of the + // lists they track (the last section). The real list is submitted straight to the queue below. + xs::set_list_values_enabled(false); + xs::reset_list_value_stats(); vktest::Device gpu; auto status = gpu.initialize(); if (status == vktest::DeviceStatus::unavailable) return 77; @@ -105,7 +109,43 @@ int main() { CHECK(t0 > 0 && t1 >= t0); CHECK(*retired == 7); } - CHECK(gpu.validation_errors() == 0); + CHECK(xs::list_value_stats().labels_handed == 5 && xs::list_value_stats().writes_recorded == 0); std::puts("GPU completion values, two real timestamp samples, resubmission and stale allocation guard passed"); + + // With LEONIDA_GPU_LABELS=1 and the list values on (their default), a tracked list's slot 71/72 writes have one + // owner: the list values land each exactly once, and nothing goes to the label path, which would store the same + // address again from its own completion and clock. + xs::set_list_values_enabled(true); + xs::reset_list_value_stats(); + { + Ref proxy_queue; + CHECK(SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&proxy_queue.p)))); + Ref tracked; + CHECK(SUCCEEDED(reinterpret_cast(slot(device.p, 73))(device.p, desc, allocator.p, nullptr, + &__uuidof(ID3D12GraphicsCommandList), + reinterpret_cast(&tracked.p)))); + CHECK(xs::is_list_proxy(tracked.p)); + const auto put32 = reinterpret_cast
/:::[::]` specs (`shims/d3d12_compute_input_probe.h`). Each logs `compute-heap-record` lines for the records of `stride` bytes in the buffer at root `s
`, descriptor ``, whose dword `` holds a resource-heap index in its low 24 bits, with `s` holding the heap's 32-bit shader address. `` and `` name the root dwords that hold the dispatch's first record and record count; without them the first records of the buffer are read. | +| `LEONIDA_SLOT31_ASYNC` | unset | Trades correctness for speed. `1` makes queue slot 31 (`CopyPageMappingsBatchX`) signal the queue, hand a copy of its batches to one worker thread and return; the worker waits for that signal and maps them in call order (`shims/d3d12_xs_device.cpp`). A copy of the GPU-only window made before the worker gets there reads the old pages for a moment. Unset, the caller waits for the mapping. | +| `LEONIDA_SLOT31_RUNS` | unset | `1` makes queue slot 31 unmap a run of pages whose mapping changes once and map one view for each stretch of consecutive pages of one section, instead of page by page (`shims/xmem.cpp`). Off by default because it was measured slower. | +| `LEONIDA_SLOT31_CPU_TWIN` | unset | `1` repeats the page mappings queue slot 31 makes in the GPU view of the title's stream pool at the matching addresses of its CPU view (`shims/xmem.cpp`, read when the second of the pool's two reservations is noted). | +| `LEONIDA_QUEUE_PAGE_MAPPINGS` | on | Read by `rt::xmem::queue_page_mappings_enabled()` (`shims/xmem.cpp`), where `0` turns it off. Nothing in the runtime calls that function, so the variable has no effect at present, and what it was meant to switch is not clear from the code. | +| `LEONIDA_POOL_ZERO_PAGES` | unset | `1` answers a read by title code of an unmapped page of an XMem physical-page window by mapping a zeroed read-only page there (a "zero plant", logged), taken under the physical-mapping lock (`shims/xmem.cpp`). Unset, only a write into such a page is backed with a zeroed page. | +| `LEONIDA_TITLE_HEAP` | unset | `1` makes the title's `XMemAlloc` blocks come from a Win32 heap of their own instead of the CRT heap (`shims/xmem.cpp`), so a GPU store through a slot-133 import past a buffer's end, or into a freed block, cannot corrupt the runtime's own objects on the same page. | +| `LEONIDA_XMEM_SEC_COMMIT` | on under Wine | XMem's physical-page sections are committed whole under Wine; `0` reserves them and commits each page at its first touch, as on Windows, where the variable has no effect (`shims/xmem.cpp`). | +| `LEONIDA_HANG_EXIT_S` | `0` | `s` seconds with work pending on the queues and no submission retired counts as a GPU hang the driver may recover from without reporting the device lost: the stall is reported (with checkpoints under `LEONIDA_STALL_CHECKPOINTS=1`) and the process ends with exit code `0x47` (`src/vulkan_backend.h`), so a boot does not sit until its time limit. `0` or unset never ends the process. | +| `LEONIDA_STALL_CHECKPOINTS` | unset | *Diagnostic.* `1` makes a device-stall report also collect the NVIDIA checkpoints of every queue (`src/vulkan_device_fault.h`), which name the programs in flight. The extension only promises them for a lost device, so outside that state the call is outside its contract. | +| `LEONIDA_PASS_TRACE` | unset | *Diagnostic.* `n`, with `LEONIDA_DEVICE_FAULT=1`: in the frame after every `n`-th present, each submission logs its compute programs in order, repeats folded (`src/vulkan_backend.h`), for the frame's pass order. | +| `LEONIDA_GPU_LATENCY` | unset | *Diagnostic.* `1` logs, every 10 s for each queue kind, how long the GPU took from a submission's `vkQueueSubmit` to it being seen done, and the share of the wall time the queue had work (`src/vulkan_backend.h`). | +| `LEONIDA_SUBMIT_PHASES_SECONDS` | `5` | *Diagnostic.* The period, in seconds, of the always-on line that says how many submissions there were and where their CPU time went, phase by phase (`src/submit_phases.h`). `0` turns the line off. | +| `LEONIDA_SAMPLE_MS` | unset | *Diagnostic.* `ms` starts the thread sampler (`src/thread_sampler.h`): every `ms` milliseconds each thread of the process that used CPU since the last look is suspended just long enough to copy its context, its stack is unwound afterwards, and a periodic report lists the busiest threads and their most frequent call chains (eight frames, innermost first). | +| `LEONIDA_SAMPLE_REPORT_S` | `10` | *Diagnostic.* Seconds between two reports of the thread sampler (`LEONIDA_SAMPLE_MS`). | +| `LEONIDA_SAMPLE_WAITS` | unset | *Diagnostic.* `1` makes the thread sampler sample waiting threads too, not only those that used CPU, and list each thread's most frequent chain, so a thread that waits shows where. | +| `LEONIDA_SAMPLE_DETAIL` | unset | *Diagnostic.* Comma-separated thread IDs whose samples the thread sampler also unwinds 16 frames deep, listing each such thread's ten most frequent chains. | +| `LEONIDA_SAMPLE_SHIMS` | unset | *Diagnostic.* `1` makes the thread sampler unwind each sample deep enough to tell whether a title thread is inside the runtime (a frame of `gta6rt` called from title code) and where, and report it. | +| `LEONIDA_AFTERMATH_SHADER_ERRORS` | unset | *Diagnostic.* With `LEONIDA_AFTERMATH=1`, `1` also sets `VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV` (`src/vulkan_aftermath.cpp`): the driver reports more shader errors, so a run can fault where it otherwise does not. | +| `LEONIDA_AFTERMATH_KEEP_SPIRV` | unset | *Diagnostic.* With `LEONIDA_AFTERMATH=1`, `1` keeps a copy of every SPIR-V module created, for the crash-dump decoder. Off by default because the title creates gigabytes of them; the decoder then reads `/.spv` back when its hash matches the module's. The runtime's own modules are always kept. | | `LEONIDA_AUDIO` | unset | `silent` (any case) makes the title's `MMDeviceEnumerator` answer every render question with the runtime's silent output endpoint, even on a host that has an output (`shims/silent_audio.cpp`, read at each `CoCreateInstance`): no host audio device is opened and every sample is thrown away, for muted test runs. Unset, or any other value, the host's endpoint answers when there is one and the silent endpoint only when the host has none. Capture keeps the host's answer either way. See [docs/runtime_imports.md](../docs/runtime_imports.md#audio-output-off-the-console-wasapi). | The two serializer functions and `D3D12XboxCreateDevice` are the only `d3d12_xs` imports used by the From 9177972ae89d32c92a64dfc9ebd8ae8e06cd6942 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Wed, 25 Nov 2026 06:32:52 -0500 Subject: [PATCH 12/12] runtime: register indirect_clamp_test beside its add_executable indirect_clamp_test came with #1723 and was registered through the foreach over ${test}_test with the other self-checking Vulkan tests, which tests/test_ctest_registration.py cannot see, so it reported the executable as built but never run. It is now registered next to its own add_executable, with the same SKIP_RETURN_CODE 77 and BUILD_TESTING guard, and left out of the foreach. Built and run with ctest on Linux: passed. Co-Authored-By: Claude Opus 5.5 --- runtime/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 2d7e410161..a3da490790 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1842,6 +1842,10 @@ if(TARGET Vulkan::Headers) if(MSVC) target_compile_options(indirect_clamp_test PRIVATE /W4 /permissive- /utf-8) endif() + if(BUILD_TESTING) + add_test(NAME indirect_clamp COMMAND indirect_clamp_test) + set_tests_properties(indirect_clamp PROPERTIES SKIP_RETURN_CODE 77) + endif() # OpFmaKHR width gate of vk_shader_fma.h (shaderFmaFloat32 / shaderFmaFloat64): no Vulkan instance, no GPU. add_executable(vk_shader_fma_test test/vk_shader_fma_test.cpp) target_link_libraries(vk_shader_fma_test PRIVATE Vulkan::Headers) @@ -1906,7 +1910,9 @@ if(TARGET Vulkan::Headers) add_test(NAME depth24_convert COMMAND depth24_convert_test) set_tests_properties(depth24_convert PROPERTIES SKIP_RETURN_CODE 77) # Self-checking Vulkan tests with no shaders or game data; each exits 77 without a Vulkan device (TEST-514). - foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue indirect_clamp) + # indirect_clamp is registered next to its own add_executable above, where tests/test_ctest_registration.py + # can see it. + foreach(test vk_command_replay vk_predicated_copy vk_predicate_capture vk_queue) add_test(NAME ${test} COMMAND ${test}_test) set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77) endforeach()