From 120a5ec5f672dcf30f815d3232ff8bf06c5973cc Mon Sep 17 00:00:00 2001 From: Vicente Abarca <135478656+Scarlet-Noble@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:32:09 -0300 Subject: [PATCH] Document D3DMetal GPU limits and add test_d3dmetal_gpu_limits (#453) Adds docs/research/d3dmetal-gpu-limits.md: the D3DMetal and Apple GPU constraints a shader translator has to handle (wave64 splitting, 64-bit atomics and lock emulation, the 32 KiB mesh output limit, an Apple shader compiler crash on early-merged output stores, and OpenExistingHeapFromAddress). Each item is marked as either measured by the new fixture or reported from local builds of a commercial title. It is linked from the M2 and M3 roadmap rows and from the docs index. Adds tests/conformance/test_d3dmetal_gpu_limits: an original D3D12 compute fixture that talks to the host d3d12.dll directly. It has four original HLSL kernels with committed DXC 1.9.2609 output, and shaders/compile.sh regenerates them. Expected values are computed on the CPU. On an Apple M3 Pro (macOS 27.2.1, CodeWeavers Wine 11.0 built from source, D3DMetal 4.0b3) the WaveSize(64) pipeline and the kernels using SM 6.6 64-bit atomics are created but never run. The bounded lock emulation is exact at a 1024-try cap and drops updates at 64 tries. Signed-off-by: Vicente Abarca <135478656+Scarlet-Noble@users.noreply.github.com> --- CHANGELOG.md | 1 + docs/README.md | 1 + docs/research/d3dmetal-gpu-limits.md | 206 +++++ docs/roadmap.md | 4 +- .../test_d3dmetal_gpu_limits/CMakeLists.txt | 6 + .../test_d3dmetal_gpu_limits/main.cpp | 734 ++++++++++++++++++ .../shaders/atomic64_buffer.h | 387 +++++++++ .../shaders/atomic64_buffer.hlsl | 19 + .../shaders/atomic64_image.h | 391 ++++++++++ .../shaders/atomic64_image.hlsl | 22 + .../shaders/compile.sh | 29 + .../shaders/lock64_image.h | 691 +++++++++++++++++ .../shaders/lock64_image.hlsl | 69 ++ .../shaders/wave64_lanes.h | 396 ++++++++++ .../shaders/wave_lanes.h | 394 ++++++++++ .../shaders/wave_lanes.hlsl | 18 + 16 files changed, 3366 insertions(+), 2 deletions(-) create mode 100644 docs/research/d3dmetal-gpu-limits.md create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/CMakeLists.txt create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/main.cpp create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.h create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.hlsl create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.h create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.hlsl create mode 100755 tests/conformance/test_d3dmetal_gpu_limits/shaders/compile.sh create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/lock64_image.h create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/lock64_image.hlsl create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/wave64_lanes.h create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/wave_lanes.h create mode 100644 tests/conformance/test_d3dmetal_gpu_limits/shaders/wave_lanes.hlsl diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da8f356..638126a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game remains unsupported. ### Added +- Added `docs/research/d3dmetal-gpu-limits.md`, the D3DMetal and Apple GPU constraints a shader translator has to handle (#453): wave64 splitting, 64-bit atomics and their lock emulation, Metal's 32 KiB mesh output limit, an Apple shader compiler crash on early-merged output stores, and `OpenExistingHeapFromAddress`. Each item is marked as measured by the new fixture or reported from local VIctory-macOS-based builds of a commercial title; no code from those builds is used. It is linked from the M2 and M3 roadmap rows. Added `tests/conformance/test_d3dmetal_gpu_limits/`, an original D3D12 compute fixture that loads the host `d3d12.dll` directly, with four original HLSL kernels and committed DXC 1.9.2609 output (`shaders/compile.sh` regenerates them). Required checks: a kernel without `WaveSize` runs with a consistent lane layout, and a per-texel spin lock with a 1024-try cap emulates 64-bit add and max with no dropped update and exact values. Everything else is printed as `OBSERVED:` lines. On one Apple M3 Pro (macOS 27.2.1, CodeWeavers Wine 11.0 built from source, D3DMetal 4.0b3), 3 runs gave identical results, with 4/4 required checks passing each time. The `[WaveSize(64)]` pipeline is created but never runs. Kernels using SM 6.6 64-bit atomics on a typed UAV or a raw buffer are also created but never run, although the device reports support for them; a plain-store marker beside the atomics shows the skip. A 64-try lock cap drops 20–28 of 512 updates. This is a local implementer run, not on CrossOver 26.3 and not independently reproduced. - Added file-mapping-backed 64 KiB and 2 MiB physical pages, contiguous and scatter aliases (including intra-span duplicate-tag aliasing), exact-span unmap validation, physical region queries (`bx_xmem_query_region`), and shared working-set accounting / combined title memory budget enforcement across heap, virtual, and physical allocations in `xmem.dll`. Synthetic `XMemAllocatePhysicalPages` / `XMemFreePhysicalPages` signatures follow Win32 AWE (`memoryapi.h`) pending a public console flag encoding (#412). - Added Win32 bridge conformance coverage for a hidden window, message dispatch, concurrent PSM registrations, and per-event JSONL log verification. Offline PSM registration tokens are tracked without C++ exceptions using disjoint family tags so cross-family unregisters log `foreign_token` and retired or invalid tokens log `unknown_token` (#410). - Implemented synthetic APU heap mappings, per-connection APU and DSP queues, and the GameInput ordinal 1 COM stub. Added an audio/input conformance executable covering all four shim DLLs (#419). diff --git a/docs/README.md b/docs/README.md index 0a203664..ad265d30 100644 --- a/docs/README.md +++ b/docs/README.md @@ -21,6 +21,7 @@ - [CrossOver Licensing & Redistribution Boundaries](research/crossover-licensing.md) — Per-component license review for CrossOver, Wine, DXMT, DXVK, VKD3D-Proton, MoltenVK, D3DMetal, and Rosetta 2. - [Upstream Research Registry](research/upstream-registry.md) & [Component Reuse Matrix](research/component-reuse-matrix.md) — Public upstream evaluation and provenance screening. - [Primary-Source Verification (2026-11-25)](research/primary-source-verification-2026-11-25.md) & [Hybrid Backlog Research Record](research/hybrid-backlog-research-2026-11-25.md) — Vendor documentation verification notes. +- [D3DMetal GPU Limits](research/d3dmetal-gpu-limits.md) — Constraints a shader translator targeting D3DMetal must handle (wave64, 64-bit image atomics, mesh output size, compiler crash, heaps), with the `test_d3dmetal_gpu_limits` fixture (#453). - [Public Technical References](research/sources.md), [Xbox GDK Notes](research/xbox-gdk.md), [RDNA 2 Notes](research/rdna2.md), and [Shader Containers](research/shader-containers.md) — Public specification references for shim and shader work. ## Governance, Security & Legal diff --git a/docs/research/d3dmetal-gpu-limits.md b/docs/research/d3dmetal-gpu-limits.md new file mode 100644 index 00000000..a408a6bd --- /dev/null +++ b/docs/research/d3dmetal-gpu-limits.md @@ -0,0 +1,206 @@ +# D3DMetal and Apple GPU limits for a shader translator + +Constraints that any translator emitting shaders for D3DMetal on Apple Silicon has to +handle, collected for the M2 shader-format gate and the M3 shader pipeline (#453). +Writing the translator is out of scope. + +Each constraint states where its evidence comes from: + +- **Fixture** — `tests/conformance/test_d3dmetal_gpu_limits`, an original synthetic + D3D12 compute fixture that checks results against values computed on the CPU. Results + are under [Fixture results](#fixture-results). A local Apple Silicon run of an original + fixture, by the implementer: class A for the stated host only, not independently + reproduced. +- **Reported** — notes from local VIctory-macOS-based builds (GPL-3.0, listed in + [upstream-registry.md](upstream-registry.md)) running a Scarlett title, posted on #453. + These are observations of a commercial title on one host. They are not BetterXen + measurements, no code or shader from that project is adopted, and they need a + synthetic reproduction before being used as evidence. + +Nothing here is an Xbox hardware result, and nothing generalizes beyond the D3DMetal +versions named. + +## 1. Console shaders arrive as RDNA 2 machine code + +*Reported.* The title tested ships its shaders as native RDNA 2 code, with no DXIL to +fall back on. Running it needed a full ISA translator, which points the M2 gate towards +translation (Branch D2) rather than a DXIL fast path. Inspecting real corpora remains +#445 / M2. + +## 2. `WaveSize(64)` does not run; wave64 programs need splitting + +Apple GPUs run 32-lane SIMD groups. A program written for a 64-lane wave has to be split +into two 32-lane halves that agree wherever the original wave acted as one. + +*Fixture:* `wave.control` (no `WaveSize`) and `wave.wavesize64` (`[WaveSize(64)]`, SM 6.6) +record the wave width each thread ran with. On D3DMetal 4.0b3 the device reports +`WaveLaneCountMin = WaveLaneCountMax = 32`. The control runs at width 32. The wave64 +pipeline is **created without error but never runs**: its output buffer keeps the +sentinel. A translator therefore cannot rely on pipeline creation failing. It has to emit +32-lane code itself. + +*Reported:* operations that need care when the two halves must agree: + +- wave reductions, including 16-bit ones; +- `v_readfirstlane` and `v_readlane`; +- the 64-bit lane mask (`exec`, `vcc`) read as data; +- `v_permlanex16`; +- scalar registers spilled into vector lanes (`v_writelane` / `v_readlane`) and later + joined as data; +- group barriers. A barrier is only safe where both halves provably reach it. + +What made most refused programs translate exactly in those builds: + +- **Uniformity dataflow.** A value differs between halves when it derives from a vector + register input, a narrowed `exec`, a lane-numbered 64-bit constant, + `mbcnt`/permlane/DPP, an LDS atomic or a clock. A barrier is placed only where every + branch before it is on uniform values. +- **Loops on `SCC` only.** A loop whose every conditional branch is on `SCC` runs alike in + both halves, so a barrier inside it is safe. +- **Commuting LDS atomics.** Atomics that commute (for example adds in a loop) need no + ordering among themselves. They need ordering only after plain LDS writes, and reads + after either. +- **Approximate fallback.** Where exact agreement cannot be proven, each half can run as + its own wave. An LDS sync in a block that not every lane reaches must then be a memory + fence without the group wait. A full barrier there hangs the group. + +In those builds, LDS programs refused in halves fell from 21 to 1 and dropped passes from +about 246 to 28 per frame, with visibly restored effects (exposure, mips, reductions, +interior lighting). That supports the suspected link between refused programs and +missing effects. The programs still refused are a lane mask spilled through +`v_writelane`, a lane mask read as data where it was never tracked as a mask, and a wave +reduction across both halves. + +## 3. 64-bit image atomics + +*Fixture:* `atomic64.image` runs SM 6.6 64-bit `InterlockedAdd` (low halves carrying +into the high half) and `InterlockedMax` (decided by the high half) on a +`RWTexture2D` over `DXGI_FORMAT_R32G32_UINT`. `atomic64.buffer` runs the same +operations on a raw buffer as a control, and the fixture prints the device's +`AtomicInt64OnTypedResourceSupported` and `AtomicInt64OnDescriptorHeapResourceSupported`. +This separates "typed 64-bit atomics are wrong" from "64-bit atomics are wrong +everywhere". A plain 64-bit store next to the atomics shows whether each kernel ran at +all. + +On D3DMetal 4.0b3: + +- The device reports both `AtomicInt64On*` features as supported, and both pipelines are + created without error. +- Neither kernel runs. The atomic results and the plain-store marker all read back as their + initial zeros, on the texture and on the raw buffer alike. +- A throwaway variant with the atomics removed but the markers kept wrote 8/8 markers, so + the readback path is sound and the skip comes from the atomics. + +In short, a kernel that uses SM 6.6 64-bit atomics is silently skipped there. This is +wider than #453 assumed: raw-buffer atomics are affected too, not only images. It +probably explains why d3dmetal-native's `d3d12-atomic64-test` read back zeros, as the +[d3dmetal-harness](../../shader-transpiler/crates/d3dmetal-harness/README.md) +evaluation recorded on D3DMetal 3.0. + +### Lock-based emulation + +*Fixture:* `lock64.cap64` and `lock64.cap1024` emulate both operations with a per-texel +lock word (`InterlockedCompareExchange` 0→1, update the two 32-bit halves, +`DeviceMemoryBarrier`, release with `InterlockedExchange`), 32 contending threads per +texel and a bounded number of tries. A thread that runs out of tries counts a drop +instead of spinning on. The 1024-try run is required to drop nothing and to match the +CPU reference exactly. The 64-try run is reported. On D3DMetal 4.0b3: + +- **1024 tries:** nothing dropped and 16/16 values exact in all three runs, with about + 14,000–16,000 tries in all. +- **64 tries:** 20–28 of 512 updates dropped. + +So a low cap trades a hang for silently lost updates: with 32 contending threads, 2^6 is +already too low. Apple's shader converter prints `Warning: Undefined: Shader might rely on +forward progress/persistent thread` for this kernel, although the loop is written so that +it does not. + +The loop shape matters. The critical section sits **inside** the retry loop, so a lane +that wins finishes it in the same iteration and no lane waits for another lane to leave +a loop. In the classic shape (`while (!acquire()) {}` then the critical section), the +winning lane can be parked at the loop's reconvergence point behind the lanes still +spinning, and a GPU without independent forward progress for each thread never finishes. +The fixture does not run that shape, because it could hang the queue. + +*Reported* (pixel shaders, not covered by the fixture): + +- **Helper lanes must not take part in the lock.** Their atomics are dropped, so they never + win and spin to the cap on every turn. That caused a hard queue hang: one submission + never completed, and macOS logged no GPU timeout. Apple's shader converter warns that + such a shader relies on forward progress. Excluding helper lanes fixed it. +- **The retry cap.** At 2^16 tries the GPU watchdog fired and the queue stopped accepting + work, while 2^6 and 2^10 ran without hangs. A cap of 2^22 was not adopted because a stall + that long looks exactly like a hang. Whether the 2^16 hang came from the cap itself or + from helper lanes spinning to it has not been separated. The fixture above shows that 2^6 + can drop updates under contention, so "ran without hangs" does not mean "correct". + +## 4. Mesh output size: 32 KiB + +*Reported.* Metal refuses mesh pipelines whose per-vertex outputs exceed 32,768 bytes +(`Total mesh size (35840) exceeds ... 32768`). Under Wine, submitting a refused pipeline +anyway can hang the queue, so a translator must refuse or shrink it itself. + +- **Layout.** Metal lays a vertex out as clip and cull distances, then position, then the + outputs in register order, each aligned to its own size. What counts is the aligned + layout, not the packed component count. +- **Shrinking it.** Two changes took these errors from 37 to 9: + - ordering the outputs within each register row for the least padding; + - linking a mesh shader to its pixel shader, so only the outputs the pixel shader reads + are kept and the rows are numbered anew on both sides. +- **The remaining 9** suggest that D3DMetal's count depends on more than the outputs. + +## 5. Apple shader compiler crash on early-merged output stores + +*Reported.* `MTLCompilerService` crashed in LLVM register allocation, seen as +`XPC_ERROR_CONNECTION_INTERRUPTED`. The crash reports in +`~/Library/Logs/DiagnosticReports/MTLCompilerService-*.ips` name `AGCModule`. +It hit about half of the mesh pipelines whose pixel shader writes several render targets, +and it reproduced offline outside Wine. + +- **Cause.** The shader converter merged an output row's stores at the first store, so + values computed later in the program were used before their definition. That is invalid + IR: `air-opt`'s verifier reports "does not dominate". +- **Fix.** Emitting each output row's stores only after all of its values are computed + took the crashes from about 220 per run to 0. + +## 6. No zero-copy heaps + +*Reported.* D3DMetal 4.0b3 answers `ID3D12Device3::OpenExistingHeapFromAddress` with +"Not implemented". Guest memory therefore cannot be placed straight into a D3D12 heap, and +resource contents must be copied or aliased by other means. + +## Fixture results + +A local run by the implementer on 2026-11-26. Class A for this host only; not +independently reproduced, not CrossOver 26.3, and not an Xbox hardware result. + +| | | +| --- | --- | +| Host | Apple M3 Pro, macOS 27.2.1 (26B131), Rosetta 2 | +| Wine | CodeWeavers Wine 11.0 built from CodeWeavers' published source; CrossOver itself was not installed | +| D3DMetal | 4.0b3 from Apple's Game Porting Toolkit (x86_64; SHA-256 of the binary starts with `b16aab78127d`), user-supplied | +| Shaders | DXC 1.9.2609 via `shaders/compile.sh`; the same DXC reproduces the d3dmetal-harness `fill_cs66` container byte for byte (SHA-256 `7df11b63…`) | +| Command | `ROSETTA_ADVERTISE_AVX=1 WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=b" wine build-shims/bin/test_d3dmetal_gpu_limits.exe` in a fresh prefix | +| Runs | 3, identical outcomes; exit 0, `SUMMARY: 4 required checks, 0 failed` each time | + +| Check | Outcome | +| --- | --- | +| `device.shader_model` | 6.6 | +| `wave.reported` | `WaveOps=1`, lane count min 32, max 32 | +| `wave.control` | ran at width 32, lane layout consistent (required: pass) | +| `wave.wavesize64` | created but not run (output still sentinel) | +| `atomic64.reported` | typed and descriptor-heap 64-bit atomics reported as supported | +| `atomic64.buffer` | not run: marker 0/8, atomic values 16/16 still zero | +| `atomic64.image` | not run: marker 0/8, atomic values 16/16 still zero | +| `lock64.cap64` | 20, 28 and 20 of 512 updates dropped (values not compared) | +| `lock64.cap1024` | 0 of 512 dropped, 16/16 values exact (required: pass) | + +Still to do for the issue's validation requirement: an independent run on CrossOver 26.3 +(D3DMetal 3.0) by another contributor. + +## Regenerating the shaders + +`tests/conformance/test_d3dmetal_gpu_limits/shaders/compile.sh` regenerates the committed +headers with Microsoft's DXC release v1.9.2609 (`dxc_2026_09_29.zip`, SHA-256 +`ad31b1fc8443175d204f77a611fdb3ef2ec42759bdc2f1167368de24a4a7e7f1`, the same package the +d3dmetal-harness records), running `bin/x64/dxc.exe` under a Wine loader. diff --git a/docs/roadmap.md b/docs/roadmap.md index ae0eb297..d84b9fba 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -38,8 +38,8 @@ Priorities, in order: practical compatibility, correctness, stability, observabi | --- | --- | --- | --- | | **M0 — Repo, ABI & Cross-Build** | Establish 6-track directory layout (`abi/`, `launcher/`, `shims/`, `shader-transpiler/`, `tests/conformance/`), frozen `.def`/header contracts, env-isolated `bx-cli`, strict PE Export Directory verifier, and live CrossOver + Rosetta 2 smoke tests (`test_veh_clwb.exe`, `test_shim_exports.exe`) | ARM64 Rust checks green; 16/16 PE32+ DLLs pass strict export & zero-MinGW-dep verification; both synthetic EXEs pass live under CrossOver + Rosetta 2 | **In validation (PR #406)** | | **M1 — Startup Shims to `D3D12XboxCreateDevice`** | Complete Wave 1 parallel issues across Tracks A–F: full `clwb` + crash register VEH, `xmem` core + physical/scatter page engine + Lockhart cap, `XCRDAPI` async file I/O MVP, `d3d12_xs` auto-logging COM proxy over Wine `d3d12.dll`, `xg_xs` linear-compatible layout MVP, `dxbc-accc` C ABI hook + `d3dmetal-native` evaluation, offline `xgameruntime`, non-blocking `AcpHal`/`xapu`/`chad` stubs, `GameInput` `@1`, and combined synthetic integration boot fixture | All 13 Wave 1 conformance binaries pass under CrossOver + Rosetta 2; combined `integration_boot.exe` initializes every subsystem cleanly | **Next (Wave 1 ready)** | -| **M2 — First Rendered Frame & Shader Format Gate** | Implement `d3d12_xs` swapchain presentation (`PresentX` → `IDXGISwapChain3::Present`), placed resources over `xmem`, and `dxbc-accc` shader inspection to establish whether target runtime shader corpora use **DXIL (Branch D1)** or **console-compiled `ACCC`/`FSPX` RDNA 2 ISA (Branch D2)** | Synthetic D3D12 `PresentX` workload renders and verifies pixel readback through D3DMetal 3.0; M2 Gate ADR selects Branch D1 or Branch D2 | Planned | -| **M3 — Full Shaders, Streaming & Texture Correctness** | DirectStorage decompression, accurate RDNA 2 (`gfx1030`) `xg_xs` tile-addressing & deswizzling, full `d3d12_xs` command-list/barrier/GPUVA fidelity, and Branch D1 DXIL normalization or Branch D2 `ACCC`/`FSPX` → DXIL/MSL transpiler | Synthetic textured/swizzled, compute, multi-queue, and compressed DirectStorage conformance suites pass | Planned | +| **M2 — First Rendered Frame & Shader Format Gate** | Implement `d3d12_xs` swapchain presentation (`PresentX` → `IDXGISwapChain3::Present`), placed resources over `xmem`, and `dxbc-accc` shader inspection to establish whether target runtime shader corpora use **DXIL (Branch D1)** or **console-compiled `ACCC`/`FSPX` RDNA 2 ISA (Branch D2)**. Translator constraints: [D3DMetal GPU limits](research/d3dmetal-gpu-limits.md) | Synthetic D3D12 `PresentX` workload renders and verifies pixel readback through D3DMetal 3.0; M2 Gate ADR selects Branch D1 or Branch D2 | Planned | +| **M3 — Full Shaders, Streaming & Texture Correctness** | DirectStorage decompression, accurate RDNA 2 (`gfx1030`) `xg_xs` tile-addressing & deswizzling, full `d3d12_xs` command-list/barrier/GPUVA fidelity, and Branch D1 DXIL normalization or Branch D2 `ACCC`/`FSPX` → DXIL/MSL transpiler, within the [D3DMetal GPU limits](research/d3dmetal-gpu-limits.md) (wave64 splitting, 64-bit image atomics, mesh output size) | Synthetic textured/swizzled, compute, multi-queue, and compressed DirectStorage conformance suites pass | Planned | | **M4 — 3D Rendering, DXR/BVH4 & Upscaling** | Bridge `XboxBvhBuilder` / `ID3D12StateObject` ray tracing to D3DMetal 3.0 DXR (intercepting incompatible AMD BVH4 rehydration → live rebuild), provide PC FidelityFX / MetalFX upscaling shim, and wire full `GameInput` controller/KB/M input | Synthetic DXR + upscaled 3D scene and scripted `GameInput` conformance tests pass | Planned | | **M5 — Software Audio/DSP, Saves & Stability** | Replace `AcpHal`/`xapu`/`chad` stubs with software audio/DSP decoding + XAudio2_9/CoreAudio output, wire `PersistentLocalStorage`, and resolve concurrency/memory/GPU hang bugs under soak testing | Synthetic audio playback, save round-trip, and multi-hour soak benchmarks pass with bounded memory | Planned | | **M6 — Shader Cache, 16 GB Optimization & Polish** | Persistent disk PSO + translated-shader cache, Lockhart 16 GB unified memory pressure tuning, Metal System Trace optimization, and optional Swift launcher UI | Reproducible frame-pacing and memory-pressure receipts under [docs/testing/hybrid-workloads.md](testing/hybrid-workloads.md) | Planned | diff --git a/tests/conformance/test_d3dmetal_gpu_limits/CMakeLists.txt b/tests/conformance/test_d3dmetal_gpu_limits/CMakeLists.txt new file mode 100644 index 00000000..e3225186 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/CMakeLists.txt @@ -0,0 +1,6 @@ +# #453: D3DMetal GPU limits (WaveSize(64), 64-bit typed UAV atomics, bounded lock emulation). +# Loads the host d3d12.dll at run time; links no BetterXen shim. Shader headers are +# generated by shaders/compile.sh (DXC v1.9.2609) and committed. +add_executable(test_d3dmetal_gpu_limits main.cpp) +target_include_directories(test_d3dmetal_gpu_limits PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(test_d3dmetal_gpu_limits PRIVATE kernel32) diff --git a/tests/conformance/test_d3dmetal_gpu_limits/main.cpp b/tests/conformance/test_d3dmetal_gpu_limits/main.cpp new file mode 100644 index 00000000..464dc7c7 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/main.cpp @@ -0,0 +1,734 @@ +/* + * #453: synthetic D3D12 compute fixtures for three GPU limits seen under D3DMetal. + * + * 1. wave64 A [WaveSize(64)] compute shader (SM 6.6). Observed: is it rejected + * at pipeline creation, created but not run, or run, and at which + * wave width? A shader without WaveSize is the control and must run. + * 2. atomic64 SM 6.6 64-bit atomics (add with carry, max) on a typed UAV + * (RWTexture2D over R32G32_UINT). Observed: correct or + * wrong values. The same operations on a raw buffer are run as a + * control and observed the same way. A plain store beside the + * atomics shows whether each kernel ran at all. + * 3. lock64 The same two operations emulated with a per-texel spin lock over + * 32-bit words and a bounded retry cap (64 and 1024 tries). Required: + * with the 1024 cap no update is dropped and every value is exact. + * + * Talks to the host d3d12.dll directly (no BetterXen shim in the path), so under + * CrossOver/Wine with D3DMetal it measures D3DMetal. Expected values come from the + * public HLSL/D3D12 semantics and are computed here on the CPU, never by the GPU. + * + * Output: one "OBSERVED: " line per observation, "FAIL:" lines for + * required checks, and a final summary. Exit 0 when every required check passed, + * 1 otherwise, 77 when no D3D12 device can be created. + */ +#ifndef WIDL_EXPLICIT_AGGREGATE_RETURNS +#define WIDL_EXPLICIT_AGGREGATE_RETURNS /* call struct-returning COM methods with the real x64 ABI */ +#endif +#include +#include + +#include +#include +#include +#include +#include + +#include "shaders/atomic64_buffer.h" +#include "shaders/atomic64_image.h" +#include "shaders/lock64_image.h" +#include "shaders/wave64_lanes.h" +#include "shaders/wave_lanes.h" + +namespace { + +constexpr uint32_t kSentinel = 0xA5A5A5A5u; +constexpr DWORD kGpuTimeoutMs = 10000; +constexpr UINT kThreads = 256; /* 4 groups of 64 for the atomic kernels */ +constexpr UINT kTexels = 8; + +int g_required = 0; +int g_failures = 0; + +__attribute__((format(gnu_printf, 2, 3))) +bool require(bool ok, const char* fmt, ...) { + g_required++; + if (!ok) { + g_failures++; + char msg[320]; + va_list ap; + va_start(ap, fmt); + std::vsnprintf(msg, sizeof(msg), fmt, ap); + va_end(ap); + std::fprintf(stderr, "FAIL: %s\n", msg); + std::fflush(stderr); + } + return ok; +} + +__attribute__((format(gnu_printf, 1, 2))) +void observed(const char* fmt, ...) { + char msg[320]; + va_list ap; + va_start(ap, fmt); + std::vsnprintf(msg, sizeof(msg), fmt, ap); + va_end(ap); + std::printf("OBSERVED: %s\n", msg); + std::fflush(stdout); +} + +unsigned long ul(HRESULT hr) { return static_cast(hr); } + +template +void release(T*& p) { + if (p) { + p->Release(); + p = nullptr; + } +} + +/* ---- CPU reference values (independent of every shader) ---- */ + +uint64_t add_operand(uint32_t i) { return (uint64_t{0x10000000u} << 32) | uint64_t{0xF0000000u + i}; } +uint64_t max_operand(uint32_t i) { return (uint64_t{i} << 40) | uint64_t{0xFFFFFFFFu - i}; } + +void expected_texels(uint64_t add[kTexels], uint64_t mx[kTexels]) { + for (UINT p = 0; p < kTexels; ++p) { + add[p] = 0; + mx[p] = 0; + } + for (uint32_t i = 0; i < kThreads; ++i) { + add[i & 7u] += add_operand(i); /* uint64_t wraps, as the HLSL add does */ + if (max_operand(i) > mx[i & 7u]) mx[i & 7u] = max_operand(i); + } +} + +/* ---- D3D12 plumbing ---- */ + +using PFN_CreateDevice = HRESULT(WINAPI*)(IUnknown*, D3D_FEATURE_LEVEL, REFIID, void**); +using PFN_Serialize = HRESULT(WINAPI*)(const D3D12_ROOT_SIGNATURE_DESC*, D3D_ROOT_SIGNATURE_VERSION, ID3DBlob**, + ID3DBlob**); + +struct Gpu { + ID3D12Device* dev = nullptr; + ID3D12CommandQueue* queue = nullptr; + ID3D12CommandAllocator* alloc = nullptr; + ID3D12GraphicsCommandList* list = nullptr; + ID3D12Fence* fence = nullptr; + UINT64 fence_value = 0; + HANDLE event = nullptr; + PFN_Serialize serialize = nullptr; + bool lost = false; /* a submission timed out or the device was removed */ +}; + +/* Close, submit, wait (bounded) and reopen the list. False on timeout or device removal. */ +bool submit(Gpu& g, const char* what) { + if (g.lost) return false; + HRESULT hr = g.list->Close(); + if (FAILED(hr)) { + observed("%s command list Close failed hr=0x%08lx", what, ul(hr)); + return false; + } + ID3D12CommandList* lists[] = {g.list}; + g.queue->ExecuteCommandLists(1, lists); + g.queue->Signal(g.fence, ++g.fence_value); + if (g.fence->GetCompletedValue() < g.fence_value) { + g.fence->SetEventOnCompletion(g.fence_value, g.event); + if (WaitForSingleObject(g.event, kGpuTimeoutMs) != WAIT_OBJECT_0) { + observed("%s GPU work did not finish within %lu ms (queue considered hung; later checks skipped)", what, + static_cast(kGpuTimeoutMs)); + g.lost = true; + return false; + } + } + if (g.fence->GetCompletedValue() == UINT64_MAX) { + observed("%s device removed, reason hr=0x%08lx", what, ul(g.dev->GetDeviceRemovedReason())); + g.lost = true; + return false; + } + g.alloc->Reset(); + g.list->Reset(g.alloc, nullptr); + return true; +} + +ID3D12Resource* make_buffer(Gpu& g, D3D12_HEAP_TYPE heap, UINT64 size, D3D12_RESOURCE_STATES state, + D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE) { + D3D12_HEAP_PROPERTIES hp = {}; + hp.Type = heap; + D3D12_RESOURCE_DESC rd = {}; + rd.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + rd.Width = size; + rd.Height = 1; + rd.DepthOrArraySize = 1; + rd.MipLevels = 1; + rd.SampleDesc.Count = 1; + rd.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + rd.Flags = flags; + ID3D12Resource* r = nullptr; + HRESULT hr = g.dev->CreateCommittedResource(&hp, D3D12_HEAP_FLAG_NONE, &rd, state, nullptr, + __uuidof(ID3D12Resource), reinterpret_cast(&r)); + return SUCCEEDED(hr) ? r : nullptr; +} + +ID3D12Resource* make_texture(Gpu& g, UINT width, UINT height, DXGI_FORMAT format) { + D3D12_HEAP_PROPERTIES hp = {}; + hp.Type = D3D12_HEAP_TYPE_DEFAULT; + D3D12_RESOURCE_DESC rd = {}; + rd.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + rd.Width = width; + rd.Height = height; + rd.DepthOrArraySize = 1; + rd.MipLevels = 1; + rd.Format = format; + rd.SampleDesc.Count = 1; + rd.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + ID3D12Resource* r = nullptr; + HRESULT hr = g.dev->CreateCommittedResource(&hp, D3D12_HEAP_FLAG_NONE, &rd, D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, __uuidof(ID3D12Resource), reinterpret_cast(&r)); + return SUCCEEDED(hr) ? r : nullptr; +} + +void transition(Gpu& g, ID3D12Resource* r, D3D12_RESOURCE_STATES before, D3D12_RESOURCE_STATES after) { + D3D12_RESOURCE_BARRIER b = {}; + b.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + b.Transition.pResource = r; + b.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; + b.Transition.StateBefore = before; + b.Transition.StateAfter = after; + g.list->ResourceBarrier(1, &b); +} + +void uav_barrier(Gpu& g) { + D3D12_RESOURCE_BARRIER b = {}; + b.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + g.list->ResourceBarrier(1, &b); +} + +bool map_write(ID3D12Resource* r, const void* src, size_t n) { + void* p = nullptr; + if (FAILED(r->Map(0, nullptr, &p)) || !p) return false; + std::memcpy(p, src, n); + r->Unmap(0, nullptr); + return true; +} + +bool map_read(ID3D12Resource* r, void* dst, size_t n) { + void* p = nullptr; + D3D12_RANGE range = {0, n}; + if (FAILED(r->Map(0, &range, &p)) || !p) return false; + std::memcpy(dst, p, n); + D3D12_RANGE none = {0, 0}; + r->Unmap(0, &none); + return true; +} + +/* Root signature from parameters; logs and returns null on failure. */ +ID3D12RootSignature* make_root(Gpu& g, const char* what, const D3D12_ROOT_PARAMETER* params, UINT count) { + D3D12_ROOT_SIGNATURE_DESC desc = {}; + desc.NumParameters = count; + desc.pParameters = params; + ID3DBlob* blob = nullptr; + ID3DBlob* err = nullptr; + HRESULT hr = g.serialize(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, &err); + release(err); + if (FAILED(hr)) { + observed("%s root signature serialization failed hr=0x%08lx", what, ul(hr)); + return nullptr; + } + ID3D12RootSignature* rs = nullptr; + hr = g.dev->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), __uuidof(ID3D12RootSignature), + reinterpret_cast(&rs)); + release(blob); + if (FAILED(hr)) { + observed("%s CreateRootSignature failed hr=0x%08lx", what, ul(hr)); + return nullptr; + } + return rs; +} + +ID3D12PipelineState* make_pipeline(Gpu& g, ID3D12RootSignature* rs, const unsigned char* code, size_t size, + HRESULT* out_hr) { + D3D12_COMPUTE_PIPELINE_STATE_DESC pd = {}; + pd.pRootSignature = rs; + pd.CS.pShaderBytecode = code; + pd.CS.BytecodeLength = size; + ID3D12PipelineState* pso = nullptr; + *out_hr = g.dev->CreateComputePipelineState(&pd, __uuidof(ID3D12PipelineState), reinterpret_cast(&pso)); + return SUCCEEDED(*out_hr) ? pso : nullptr; +} + +D3D12_ROOT_PARAMETER root_uav(UINT reg) { + D3D12_ROOT_PARAMETER p = {}; + p.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; + p.Descriptor.ShaderRegister = reg; + p.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + return p; +} + +/* ---- buffer kernels: run one dispatch over a root-UAV buffer, return its words ---- */ + +bool run_buffer_kernel(Gpu& g, const char* what, ID3D12PipelineState* pso, ID3D12RootSignature* rs, + const std::vector& init, UINT groups, std::vector& out) { + const UINT64 bytes = init.size() * sizeof(uint32_t); + ID3D12Resource* up = make_buffer(g, D3D12_HEAP_TYPE_UPLOAD, bytes, D3D12_RESOURCE_STATE_GENERIC_READ); + ID3D12Resource* buf = make_buffer(g, D3D12_HEAP_TYPE_DEFAULT, bytes, D3D12_RESOURCE_STATE_COMMON, + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); + ID3D12Resource* rb = make_buffer(g, D3D12_HEAP_TYPE_READBACK, bytes, D3D12_RESOURCE_STATE_COPY_DEST); + bool ok = up && buf && rb && map_write(up, init.data(), bytes); + if (ok) { + g.list->CopyBufferRegion(buf, 0, up, 0, bytes); + transition(g, buf, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + g.list->SetComputeRootSignature(rs); + g.list->SetPipelineState(pso); + g.list->SetComputeRootUnorderedAccessView(0, buf->GetGPUVirtualAddress()); + g.list->Dispatch(groups, 1, 1); + transition(g, buf, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + g.list->CopyBufferRegion(rb, 0, buf, 0, bytes); + ok = submit(g, what); + out.assign(init.size(), 0); + ok = ok && map_read(rb, out.data(), bytes); + } else { + observed("%s buffer creation or upload failed", what); + } + release(up); + release(buf); + release(rb); + return ok; +} + +/* ---- 1. wave64 ---- */ + +void check_wave64(Gpu& g) { + D3D12_FEATURE_DATA_D3D12_OPTIONS1 o1 = {}; + if (SUCCEEDED(g.dev->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &o1, sizeof(o1)))) { + observed("wave.reported WaveOps=%d WaveLaneCountMin=%u WaveLaneCountMax=%u", o1.WaveOps ? 1 : 0, + o1.WaveLaneCountMin, o1.WaveLaneCountMax); + } + D3D12_ROOT_PARAMETER params[] = {root_uav(0)}; + ID3D12RootSignature* rs = make_root(g, "wave", params, 1); + if (!require(rs != nullptr, "wave root signature")) return; + + const std::vector init(64, kSentinel); + struct Case { + const char* name; + const unsigned char* code; + size_t size; + bool control; + } cases[] = { + {"wave.control", g_wave_lanes_cs, sizeof(g_wave_lanes_cs), true}, + {"wave.wavesize64", g_wave64_lanes_cs, sizeof(g_wave64_lanes_cs), false}, + }; + for (const Case& c : cases) { + HRESULT hr = S_OK; + ID3D12PipelineState* pso = make_pipeline(g, rs, c.code, c.size, &hr); + if (!pso) { + observed("%s rejected at CreateComputePipelineState hr=0x%08lx", c.name, ul(hr)); + if (c.control) require(false, "%s: control pipeline must be created", c.name); + continue; + } + std::vector out; + bool ran = run_buffer_kernel(g, c.name, pso, rs, init, 1, out); + release(pso); + if (!ran) { + if (c.control) require(false, "%s: control dispatch must complete", c.name); + continue; + } + bool all_sentinel = true; + for (uint32_t w : out) all_sentinel = all_sentinel && w == kSentinel; + if (all_sentinel) { + observed("%s created but not run (output still sentinel)", c.name); + if (c.control) require(false, "%s: control kernel must write its output", c.name); + continue; + } + /* Wave width as reported by lane 0; every thread must agree and lanes must count 0..W-1. */ + const uint32_t width = out[0] >> 16; + bool layout_ok = width >= 1 && width <= 128; + for (uint32_t i = 0; layout_ok && i < 64; ++i) { + layout_ok = (out[i] >> 16) == width && (out[i] & 0xFFFFu) == i % width; + } + observed("%s ran with wave width %u, lane layout %s", c.name, width, layout_ok ? "consistent" : "INCONSISTENT"); + if (c.control) require(layout_ok, "%s: lane indices must count 0..W-1 within each wave", c.name); + if (!c.control && layout_ok && width != 64) { + observed("%s WaveSize(64) not honoured: ran at width %u instead of being rejected", c.name, width); + } + } + release(rs); +} + +/* ---- 2. 64-bit atomics on a typed UAV, with a raw-buffer control ---- */ + +/* Plain-store marker the atomic kernels write next to their atomics: proves the kernel ran. */ +uint64_t marker(UINT p) { return (uint64_t{0xC0DEu} << 32) | p; } + +void report_marker(const char* name, const uint64_t got[kTexels]) { + int bad = 0; + for (UINT p = 0; p < kTexels; ++p) bad += got[p] != marker(p); + observed("%s plain-store marker %s (%d/8 match)", name, bad == 0 ? "written: kernel ran" : "WRONG or missing", + 8 - bad); +} + +void report_texels(const char* name, const uint64_t got_add[kTexels], const uint64_t got_max[kTexels]) { + uint64_t want_add[kTexels], want_max[kTexels]; + expected_texels(want_add, want_max); + int bad = 0; + for (UINT p = 0; p < kTexels; ++p) { + bad += got_add[p] != want_add[p]; + bad += got_max[p] != want_max[p]; + } + if (bad == 0) { + observed("%s correct (16/16 values)", name); + } else { + observed("%s WRONG values: %d/16 differ; texel 0 add got 0x%016llx want 0x%016llx, max got 0x%016llx want " + "0x%016llx", + name, bad, static_cast(got_add[0]), static_cast(want_add[0]), + static_cast(got_max[0]), static_cast(want_max[0])); + } +} + +void check_atomic64_buffer(Gpu& g) { + D3D12_ROOT_PARAMETER params[] = {root_uav(0)}; + ID3D12RootSignature* rs = make_root(g, "atomic64.buffer", params, 1); + if (!rs) return; + HRESULT hr = S_OK; + ID3D12PipelineState* pso = make_pipeline(g, rs, g_atomic64_buffer_cs, sizeof(g_atomic64_buffer_cs), &hr); + if (!pso) { + observed("atomic64.buffer rejected at CreateComputePipelineState hr=0x%08lx", ul(hr)); + release(rs); + return; + } + std::vector out; + if (run_buffer_kernel(g, "atomic64.buffer", pso, rs, std::vector(48, 0), kThreads / 64, out)) { + uint64_t add[kTexels], mx[kTexels], mark[kTexels]; + for (UINT p = 0; p < kTexels; ++p) { + add[p] = (uint64_t{out[2 * p + 1]} << 32) | out[2 * p]; + mx[p] = (uint64_t{out[16 + 2 * p + 1]} << 32) | out[16 + 2 * p]; + mark[p] = (uint64_t{out[32 + 2 * p + 1]} << 32) | out[32 + 2 * p]; + } + report_marker("atomic64.buffer", mark); + report_texels("atomic64.buffer", add, mx); + } + release(pso); + release(rs); +} + +/* Texture helpers: upload zeros into / read back a tightly described 2D texture. */ +struct TexCopy { + D3D12_PLACED_SUBRESOURCE_FOOTPRINT fp = {}; + UINT64 total = 0; +}; + +TexCopy footprint(Gpu& g, ID3D12Resource* tex) { + TexCopy t; + D3D12_RESOURCE_DESC rd; + tex->GetDesc(&rd); + UINT rows = 0; + UINT64 row_bytes = 0; + g.dev->GetCopyableFootprints(&rd, 0, 1, 0, &t.fp, &rows, &row_bytes, &t.total); + return t; +} + +void copy_to_texture(Gpu& g, ID3D12Resource* tex, ID3D12Resource* up, const TexCopy& t) { + D3D12_TEXTURE_COPY_LOCATION dst = {}; + dst.pResource = tex; + dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + D3D12_TEXTURE_COPY_LOCATION src = {}; + src.pResource = up; + src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + src.PlacedFootprint = t.fp; + g.list->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr); +} + +void copy_from_texture(Gpu& g, ID3D12Resource* tex, ID3D12Resource* rb, const TexCopy& t) { + D3D12_TEXTURE_COPY_LOCATION dst = {}; + dst.pResource = rb; + dst.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + dst.PlacedFootprint = t.fp; + D3D12_TEXTURE_COPY_LOCATION src = {}; + src.pResource = tex; + src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + g.list->CopyTextureRegion(&dst, 0, 0, 0, &src, nullptr); +} + +/* Reads texel (x, y), `words` 32-bit words per texel, out of a readback copy. */ +uint32_t texel_word(const std::vector& data, const TexCopy& t, UINT x, UINT y, UINT words, UINT w) { + uint32_t v = 0; + std::memcpy(&v, data.data() + t.fp.Offset + y * t.fp.Footprint.RowPitch + (x * words + w) * 4, 4); + return v; +} + +struct ImageSet { + ID3D12DescriptorHeap* heap = nullptr; + std::vector tex; + std::vector copy; + std::vector rb; + ~ImageSet() { + release(heap); + for (auto*& r : tex) release(r); + for (auto*& r : rb) release(r); + } +}; + +/* Creates zero-filled UAV textures with descriptors in one shader-visible heap, ready in UAV state. */ +bool make_images(Gpu& g, const char* what, ImageSet& s, const UINT (*dims)[2], const DXGI_FORMAT* formats, UINT count) { + D3D12_DESCRIPTOR_HEAP_DESC hd = {}; + hd.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + hd.NumDescriptors = count; + hd.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + if (FAILED(g.dev->CreateDescriptorHeap(&hd, __uuidof(ID3D12DescriptorHeap), reinterpret_cast(&s.heap)))) { + observed("%s descriptor heap creation failed", what); + return false; + } + D3D12_CPU_DESCRIPTOR_HANDLE cpu; + s.heap->GetCPUDescriptorHandleForHeapStart(&cpu); + const UINT inc = g.dev->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + std::vector uploads; + bool ok = true; + for (UINT i = 0; i < count && ok; ++i) { + ID3D12Resource* t = make_texture(g, dims[i][0], dims[i][1], formats[i]); + if (!t) { + observed("%s texture %u creation failed", what, i); + ok = false; + break; + } + s.tex.push_back(t); + s.copy.push_back(footprint(g, t)); + const TexCopy& c = s.copy.back(); + ID3D12Resource* up = make_buffer(g, D3D12_HEAP_TYPE_UPLOAD, c.total, D3D12_RESOURCE_STATE_GENERIC_READ); + ID3D12Resource* rb = make_buffer(g, D3D12_HEAP_TYPE_READBACK, c.total, D3D12_RESOURCE_STATE_COPY_DEST); + s.rb.push_back(rb); + uploads.push_back(up); + std::vector zeros(static_cast(c.total), 0); + ok = up && rb && map_write(up, zeros.data(), zeros.size()); + if (!ok) break; + copy_to_texture(g, t, up, c); + transition(g, t, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + D3D12_UNORDERED_ACCESS_VIEW_DESC ud = {}; + ud.Format = formats[i]; + ud.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; + D3D12_CPU_DESCRIPTOR_HANDLE h = {cpu.ptr + static_cast(i) * inc}; + g.dev->CreateUnorderedAccessView(t, nullptr, &ud, h); + } + ok = ok && submit(g, what); + for (auto*& u : uploads) release(u); + return ok; +} + +bool read_images(Gpu& g, const char* what, ImageSet& s, std::vector>& data) { + for (size_t i = 0; i < s.tex.size(); ++i) { + transition(g, s.tex[i], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + copy_from_texture(g, s.tex[i], s.rb[i], s.copy[i]); + } + if (!submit(g, what)) return false; + data.resize(s.tex.size()); + for (size_t i = 0; i < s.tex.size(); ++i) { + data[i].resize(static_cast(s.copy[i].total)); + if (!map_read(s.rb[i], data[i].data(), data[i].size())) return false; + } + return true; +} + +void bind_table(Gpu& g, ImageSet& s) { + ID3D12DescriptorHeap* heaps[] = {s.heap}; + g.list->SetDescriptorHeaps(1, heaps); + D3D12_GPU_DESCRIPTOR_HANDLE gpu; + s.heap->GetGPUDescriptorHandleForHeapStart(&gpu); + g.list->SetComputeRootDescriptorTable(0, gpu); +} + +void check_atomic64_image(Gpu& g) { + D3D12_FEATURE_DATA_D3D12_OPTIONS9 o9 = {}; + D3D12_FEATURE_DATA_D3D12_OPTIONS11 o11 = {}; + const bool have9 = SUCCEEDED(g.dev->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS9, &o9, sizeof(o9))); + const bool have11 = SUCCEEDED(g.dev->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &o11, sizeof(o11))); + observed("atomic64.reported AtomicInt64OnTypedResourceSupported=%s AtomicInt64OnDescriptorHeapResourceSupported=%s", + have9 ? (o9.AtomicInt64OnTypedResourceSupported ? "1" : "0") : "query-failed", + have11 ? (o11.AtomicInt64OnDescriptorHeapResourceSupported ? "1" : "0") : "query-failed"); + + D3D12_DESCRIPTOR_RANGE range = {D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, 0}; + D3D12_ROOT_PARAMETER table = {}; + table.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + table.DescriptorTable.NumDescriptorRanges = 1; + table.DescriptorTable.pDescriptorRanges = ⦥ + ID3D12RootSignature* rs = make_root(g, "atomic64.image", &table, 1); + if (!rs) return; + HRESULT hr = S_OK; + ID3D12PipelineState* pso = make_pipeline(g, rs, g_atomic64_image_cs, sizeof(g_atomic64_image_cs), &hr); + if (!pso) { + observed("atomic64.image rejected at CreateComputePipelineState hr=0x%08lx", ul(hr)); + release(rs); + return; + } + { + ImageSet s; + const UINT dims[][2] = {{kTexels, 3}}; + const DXGI_FORMAT fmt[] = {DXGI_FORMAT_R32G32_UINT}; + std::vector> data; + if (make_images(g, "atomic64.image", s, dims, fmt, 1)) { + g.list->SetComputeRootSignature(rs); + g.list->SetPipelineState(pso); + bind_table(g, s); + g.list->Dispatch(kThreads / 64, 1, 1); + if (read_images(g, "atomic64.image", s, data)) { + uint64_t add[kTexels], mx[kTexels], mark[kTexels]; + for (UINT p = 0; p < kTexels; ++p) { + mark[p] = (uint64_t{texel_word(data[0], s.copy[0], p, 2, 2, 1)} << 32) | + texel_word(data[0], s.copy[0], p, 2, 2, 0); + add[p] = (uint64_t{texel_word(data[0], s.copy[0], p, 0, 2, 1)} << 32) | + texel_word(data[0], s.copy[0], p, 0, 2, 0); + mx[p] = (uint64_t{texel_word(data[0], s.copy[0], p, 1, 2, 1)} << 32) | + texel_word(data[0], s.copy[0], p, 1, 2, 0); + } + report_marker("atomic64.image", mark); + report_texels("atomic64.image", add, mx); + } + } + } + release(pso); + release(rs); +} + +/* ---- 3. lock-based emulation with a bounded retry cap ---- */ + +void check_lock64(Gpu& g, UINT cap, bool required) { + char name[48]; + std::snprintf(name, sizeof(name), "lock64.cap%u", cap); + + D3D12_DESCRIPTOR_RANGE range = {D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 2, 0, 0, 0}; + D3D12_ROOT_PARAMETER params[3] = {}; + params[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + params[0].DescriptorTable.NumDescriptorRanges = 1; + params[0].DescriptorTable.pDescriptorRanges = ⦥ + params[1] = root_uav(2); + params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; + params[2].Constants.ShaderRegister = 0; + params[2].Constants.Num32BitValues = 1; + ID3D12RootSignature* rs = make_root(g, name, params, 3); + if (!rs) { + if (required) require(false, "%s: root signature", name); + return; + } + HRESULT hr = S_OK; + ID3D12PipelineState* pso = make_pipeline(g, rs, g_lock64_image_cs, sizeof(g_lock64_image_cs), &hr); + if (!pso) { + observed("%s rejected at CreateComputePipelineState hr=0x%08lx", name, ul(hr)); + if (required) require(false, "%s: lock emulation pipeline must be created", name); + release(rs); + return; + } + { + ImageSet s; + const UINT dims[][2] = {{2 * kTexels, 2}, {kTexels, 2}}; + const DXGI_FORMAT fmt[] = {DXGI_FORMAT_R32_UINT, DXGI_FORMAT_R32_UINT}; + ID3D12Resource* stats = nullptr; + ID3D12Resource* stats_rb = nullptr; + bool ok = make_images(g, name, s, dims, fmt, 2); + if (ok) { + const uint32_t zeros[2] = {0, 0}; + ID3D12Resource* up = make_buffer(g, D3D12_HEAP_TYPE_UPLOAD, 8, D3D12_RESOURCE_STATE_GENERIC_READ); + stats = make_buffer(g, D3D12_HEAP_TYPE_DEFAULT, 256, D3D12_RESOURCE_STATE_COMMON, + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); + stats_rb = make_buffer(g, D3D12_HEAP_TYPE_READBACK, 8, D3D12_RESOURCE_STATE_COPY_DEST); + ok = up && stats && stats_rb && map_write(up, zeros, sizeof(zeros)); + if (ok) { + g.list->CopyBufferRegion(stats, 0, up, 0, 8); + transition(g, stats, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + g.list->SetComputeRootSignature(rs); + g.list->SetPipelineState(pso); + bind_table(g, s); + g.list->SetComputeRootUnorderedAccessView(1, stats->GetGPUVirtualAddress()); + g.list->SetComputeRoot32BitConstant(2, cap, 0); + g.list->Dispatch(kThreads / 64, 1, 1); + uav_barrier(g); + transition(g, stats, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + g.list->CopyBufferRegion(stats_rb, 0, stats, 0, 8); + } + release(up); + } + std::vector> data; + ok = ok && read_images(g, name, s, data); + uint32_t st[2] = {0, 0}; + ok = ok && map_read(stats_rb, st, sizeof(st)); + if (ok) { + uint64_t add[kTexels], mx[kTexels]; + for (UINT p = 0; p < kTexels; ++p) { + add[p] = (uint64_t{texel_word(data[0], s.copy[0], 2 * p + 1, 0, 1, 0)} << 32) | + texel_word(data[0], s.copy[0], 2 * p, 0, 1, 0); + mx[p] = (uint64_t{texel_word(data[0], s.copy[0], 2 * p + 1, 1, 1, 0)} << 32) | + texel_word(data[0], s.copy[0], 2 * p, 1, 1, 0); + } + observed("%s dropped %u of %u updates, %u tries in all", name, st[0], 2 * kThreads, st[1]); + if (st[0] == 0) { + report_texels(name, add, mx); + } else { + observed("%s values not compared (updates were dropped)", name); + } + if (required) { + uint64_t want_add[kTexels], want_max[kTexels]; + expected_texels(want_add, want_max); + bool exact = st[0] == 0; + for (UINT p = 0; exact && p < kTexels; ++p) exact = add[p] == want_add[p] && mx[p] == want_max[p]; + require(exact, "%s: no update dropped and every value exact (dropped %u)", name, st[0]); + } + } else if (required) { + require(false, "%s: dispatch and readback must complete", name); + } + release(stats); + release(stats_rb); + } + release(pso); + release(rs); +} + +} // namespace + +int main() { + std::setvbuf(stdout, nullptr, _IONBF, 0); + HMODULE d3d12 = LoadLibraryA("d3d12.dll"); + auto create = d3d12 ? reinterpret_cast(reinterpret_cast(GetProcAddress(d3d12, "D3D12CreateDevice"))) : nullptr; + Gpu g; + g.serialize = d3d12 ? reinterpret_cast( + reinterpret_cast(GetProcAddress(d3d12, "D3D12SerializeRootSignature"))) : nullptr; + if (!create || !g.serialize) { + std::printf("SKIP: d3d12.dll or its exports are unavailable\n"); + return 77; + } + HRESULT hr = create(nullptr, D3D_FEATURE_LEVEL_12_0, __uuidof(ID3D12Device), reinterpret_cast(&g.dev)); + if (FAILED(hr) || !g.dev) { + std::printf("SKIP: D3D12CreateDevice failed hr=0x%08lx\n", ul(hr)); + return 77; + } + D3D12_FEATURE_DATA_SHADER_MODEL sm = {D3D_SHADER_MODEL_6_6}; + if (SUCCEEDED(g.dev->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &sm, sizeof(sm)))) { + observed("device.shader_model 0x%x", static_cast(sm.HighestShaderModel)); + } + + D3D12_COMMAND_QUEUE_DESC qd = {}; + qd.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + bool setup = SUCCEEDED(g.dev->CreateCommandQueue(&qd, __uuidof(ID3D12CommandQueue), + reinterpret_cast(&g.queue))) && + SUCCEEDED(g.dev->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, + __uuidof(ID3D12CommandAllocator), + reinterpret_cast(&g.alloc))) && + SUCCEEDED(g.dev->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, g.alloc, nullptr, + __uuidof(ID3D12GraphicsCommandList), + reinterpret_cast(&g.list))) && + SUCCEEDED(g.dev->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence), + reinterpret_cast(&g.fence))); + g.event = CreateEventA(nullptr, FALSE, FALSE, nullptr); + if (!require(setup && g.event, "queue, allocator, command list and fence creation")) return 1; + + check_wave64(g); + check_atomic64_buffer(g); + check_atomic64_image(g); + check_lock64(g, 64, false); + check_lock64(g, 1024, true); + if (g.lost) require(false, "GPU work must finish and the device must stay alive"); + + std::printf("SUMMARY: %d required checks, %d failed\n", g_required, g_failures); + release(g.fence); + release(g.list); + release(g.alloc); + release(g.queue); + release(g.dev); + if (g.event) CloseHandle(g.event); + return g_failures == 0 ? 0 : 1; +} diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.h b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.h new file mode 100644 index 00000000..29141035 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.h @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// GENERATED by DXC 1.9.2609 from atomic64_buffer.hlsl by compile.sh; do not edit. + +#if 0 +; +; Note: shader requires additional functionality: +; 64-Bit integer +; +; +; Input signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; +; Output signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; shader hash: 190fd681a6fdc81561132f9a2e60b00c +; +; Pipeline Runtime Information: +; +;PSVRuntimeInfo: +; Compute Shader +; NumThreads=(64,1,1) +; MinimumExpectedWaveLaneCount: 0 +; MaximumExpectedWaveLaneCount: 4294967295 +; UsesViewID: false +; SigInputElements: 0 +; SigOutputElements: 0 +; SigPatchConstOrPrimElements: 0 +; SigInputVectors: 0 +; SigOutputVectors[0]: 0 +; SigOutputVectors[1]: 0 +; SigOutputVectors[2]: 0 +; SigOutputVectors[3]: 0 +; EntryFunctionName: main +; +; +; Buffer Definitions: +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; Buf UAV byte r/w U0 u0 1 +; +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%dx.types.Handle = type { i8* } +%dx.types.ResBind = type { i32, i32, i32, i8 } +%dx.types.ResourceProperties = type { i32, i32 } +%struct.RWByteAddressBuffer = type { i32 } + +define void @main() { + %1 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 1 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %2 = call i32 @dx.op.threadId.i32(i32 93, i32 0) ; ThreadId(component) + %3 = and i32 %2, 7 + %4 = add i32 %2, -268435456 + %5 = zext i32 %4 to i64 + %6 = or i64 %5, 1152921504606846976 + %7 = shl nuw nsw i32 %3, 3 + %8 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer + %9 = call i64 @dx.op.atomicBinOp.i64(i32 78, %dx.types.Handle %8, i32 0, i32 %7, i32 undef, i32 undef, i64 %6) ; AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue) + %10 = zext i32 %2 to i64 + %11 = shl i64 %10, 40 + %12 = xor i32 %2, -1 + %13 = zext i32 %12 to i64 + %14 = or i64 %11, %13 + %15 = or i32 %7, 64 + %16 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer + %17 = call i64 @dx.op.atomicBinOp.i64(i32 78, %dx.types.Handle %16, i32 7, i32 %15, i32 undef, i32 undef, i64 %14) ; AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue) + %18 = or i32 %7, 128 + %19 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer + call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %19, i32 %18, i32 undef, i32 %3, i32 49374, i32 undef, i32 undef, i8 3, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment) + ret void +} + +; Function Attrs: nounwind readnone +declare i32 @dx.op.threadId.i32(i32, i32) #0 + +; Function Attrs: nounwind +declare i64 @dx.op.atomicBinOp.i64(i32, %dx.types.Handle, i32, i32, i32, i32, i64) #1 + +; Function Attrs: nounwind +declare void @dx.op.rawBufferStore.i32(i32, %dx.types.Handle, i32, i32, i32, i32, i32, i32, i8, i32) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @dx.op.annotateHandle(i32, %dx.types.Handle, %dx.types.ResourceProperties) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @dx.op.createHandleFromBinding(i32, %dx.types.ResBind, i32, i1) #0 + +attributes #0 = { nounwind readnone } +attributes #1 = { nounwind } + +!llvm.ident = !{!0} +!dx.version = !{!1} +!dx.valver = !{!2} +!dx.shaderModel = !{!3} +!dx.resources = !{!4} +!dx.entryPoints = !{!8} + +!0 = !{!"dxcoob 1.9.2609.5 (01b62ad47)"} +!1 = !{i32 1, i32 6} +!2 = !{i32 1, i32 9} +!3 = !{!"cs", i32 6, i32 6} +!4 = !{null, !5, null, null} +!5 = !{!6} +!6 = !{i32 0, %struct.RWByteAddressBuffer* undef, !"", i32 0, i32 0, i32 1, i32 11, i1 false, i1 false, i1 false, !7} +!7 = !{i32 3, i32 1} +!8 = !{void ()* @main, !"main", null, !4, !9} +!9 = !{i32 0, i64 1048592, i32 4, !10} +!10 = !{i32 64, i32 1, i32 1} + +#endif + +const unsigned char g_atomic64_buffer_cs[] = { + 0x44, 0x58, 0x42, 0x43, 0x5b, 0x87, 0x05, 0x91, 0x7d, 0xd4, 0x0f, 0xf5, + 0x40, 0xd1, 0x11, 0xa2, 0x1d, 0x9a, 0x7f, 0xbb, 0x01, 0x00, 0x00, 0x00, + 0x50, 0x0c, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0xdc, 0x00, 0x00, 0x00, 0x4c, 0x06, 0x00, 0x00, 0x68, 0x06, 0x00, 0x00, + 0x53, 0x46, 0x49, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x31, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x50, 0x53, 0x56, 0x30, 0x68, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, 0x68, 0x05, 0x00, 0x00, + 0x66, 0x00, 0x05, 0x00, 0x5a, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x06, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x51, 0x01, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x52, 0x88, 0x48, 0x90, 0x14, 0x20, + 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x91, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, + 0x04, 0x29, 0x46, 0x06, 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x40, 0x02, 0xa8, 0x0d, + 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, + 0x20, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, + 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, + 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x60, 0x23, 0x00, 0x25, 0x00, 0x14, 0xe6, + 0x08, 0xc0, 0xa0, 0x0c, 0x63, 0x0c, 0x22, 0x73, 0x04, 0xa0, 0x30, 0x47, + 0x80, 0xd0, 0xb9, 0x67, 0xb8, 0xfc, 0x09, 0x7b, 0x08, 0xc9, 0x0f, 0x81, + 0x66, 0x58, 0x08, 0x14, 0xa0, 0x82, 0x98, 0x91, 0xc6, 0x18, 0xc3, 0x90, + 0x2a, 0x0b, 0x18, 0x69, 0x8c, 0x31, 0xc6, 0x38, 0x83, 0xd8, 0x6d, 0xc3, + 0xe5, 0x4f, 0xd8, 0x43, 0x48, 0xfe, 0x4a, 0x48, 0x0e, 0x15, 0x09, 0x44, + 0x1a, 0x39, 0x0f, 0x11, 0x4d, 0x08, 0x21, 0x21, 0x61, 0x8c, 0x42, 0xa4, + 0x91, 0x1c, 0xbd, 0x83, 0x86, 0xcb, 0x9f, 0xb0, 0x87, 0x90, 0xfc, 0x95, + 0x90, 0x36, 0xa4, 0x19, 0x10, 0x31, 0xc6, 0x38, 0x73, 0x04, 0x41, 0x29, + 0xd2, 0x88, 0x43, 0xd2, 0x1c, 0x08, 0x38, 0x4d, 0x9a, 0x22, 0x4a, 0x98, + 0xfc, 0x15, 0xde, 0xb0, 0x89, 0xd0, 0x86, 0x21, 0x22, 0x24, 0x69, 0xa3, + 0x8a, 0x82, 0x88, 0x50, 0x30, 0xc8, 0x02, 0x00, 0x13, 0x14, 0x72, 0xc0, + 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, 0x68, 0x03, 0x72, 0xc0, + 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, 0x7a, 0x50, 0x0e, 0x6d, + 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x78, + 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, + 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, + 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, + 0xd0, 0x06, 0xe6, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe6, + 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0xe0, 0x0e, 0x78, + 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x76, + 0x40, 0x07, 0x43, 0x9e, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x86, 0x3c, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x14, 0x20, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xf2, 0x30, 0x40, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xe4, 0x79, 0x80, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xc8, 0x33, 0x01, 0x01, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x16, 0x08, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, + 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x1a, 0x25, 0x50, 0x0c, 0x23, + 0x00, 0x65, 0x51, 0x06, 0x85, 0x50, 0x80, 0x01, 0x45, 0x50, 0x2a, 0x64, + 0x0a, 0x14, 0x10, 0x30, 0x80, 0xe4, 0x08, 0x00, 0xdd, 0x19, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, + 0x46, 0x02, 0x13, 0xc4, 0x8e, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x0c, 0x24, + 0xc6, 0x25, 0xc7, 0x45, 0xc6, 0x06, 0x26, 0xc7, 0xa5, 0x06, 0x04, 0x05, + 0x26, 0x46, 0xcc, 0x46, 0x26, 0x8c, 0x8c, 0xe6, 0x26, 0x65, 0x43, 0x10, + 0x4c, 0x10, 0x06, 0x63, 0x82, 0x30, 0x1c, 0x1b, 0x84, 0x81, 0x98, 0x20, + 0x0c, 0xc8, 0x06, 0xc1, 0x30, 0x28, 0x8c, 0xcd, 0x6d, 0x18, 0x10, 0x82, + 0x98, 0x20, 0x5c, 0x11, 0x07, 0xa1, 0x3a, 0xb3, 0x09, 0xc2, 0x90, 0x4c, + 0x10, 0x24, 0x68, 0x82, 0x30, 0x28, 0x1b, 0x04, 0x67, 0xd8, 0xb0, 0x18, + 0xca, 0x62, 0x18, 0x03, 0xd3, 0x34, 0xcd, 0xb3, 0x21, 0x80, 0x36, 0x10, + 0x40, 0x04, 0x00, 0x13, 0x04, 0x01, 0xd8, 0x00, 0x6c, 0x18, 0x0c, 0x8a, + 0xda, 0x10, 0x54, 0x1b, 0x86, 0x61, 0xb2, 0x48, 0xb4, 0x85, 0xa5, 0xb9, + 0x4d, 0x10, 0x8c, 0x67, 0x82, 0x30, 0x2c, 0x13, 0x84, 0x81, 0xd9, 0x30, + 0x6c, 0xc3, 0xb0, 0x81, 0x30, 0x32, 0x8d, 0xdb, 0x50, 0x4c, 0x18, 0x20, + 0x75, 0x34, 0xc2, 0xe8, 0xde, 0xda, 0xd2, 0xc6, 0x26, 0x08, 0x43, 0xc3, + 0x22, 0xcd, 0x6d, 0x8e, 0x6e, 0x6e, 0x82, 0x30, 0x38, 0x24, 0xd2, 0xdc, + 0xe8, 0xe6, 0x98, 0xd0, 0x95, 0xe1, 0x7d, 0xcd, 0xd1, 0xbd, 0xc9, 0x95, + 0xb1, 0xa8, 0x4b, 0x73, 0xa3, 0x9b, 0xdb, 0xa0, 0x7c, 0x60, 0x10, 0x06, + 0x62, 0x30, 0x06, 0x03, 0x19, 0x0c, 0x65, 0xc0, 0x54, 0x61, 0x63, 0xb3, + 0x6b, 0x73, 0x49, 0x23, 0x2b, 0x73, 0xa3, 0x9b, 0x12, 0x04, 0x55, 0xc8, + 0xf0, 0x5c, 0xec, 0xca, 0xe4, 0xe6, 0xd2, 0xde, 0xdc, 0xa6, 0x04, 0x44, + 0x13, 0x32, 0x3c, 0x17, 0xbb, 0x30, 0x36, 0xbb, 0x32, 0xb9, 0x29, 0x81, + 0x51, 0x87, 0x0c, 0xcf, 0x65, 0x0e, 0x2d, 0x8c, 0xac, 0x4c, 0xae, 0xe9, + 0x8d, 0xac, 0x8c, 0x6d, 0x4a, 0x80, 0x94, 0x21, 0xc3, 0x73, 0x91, 0x2b, + 0x9b, 0x7b, 0xab, 0x93, 0x1b, 0x2b, 0x9b, 0x9b, 0x12, 0x44, 0x95, 0xc8, + 0xf0, 0x5c, 0xe8, 0xf2, 0xe0, 0xca, 0x82, 0xdc, 0xdc, 0xde, 0xe8, 0xc2, + 0xe8, 0xd2, 0xde, 0xdc, 0xe6, 0xa6, 0x04, 0x56, 0x1d, 0x32, 0x3c, 0x97, + 0x32, 0x37, 0x3a, 0xb9, 0x3c, 0xa8, 0xb7, 0x34, 0x37, 0xba, 0xb9, 0x29, + 0x41, 0xd7, 0x85, 0x0c, 0xcf, 0x65, 0xec, 0xad, 0xce, 0x8d, 0xae, 0x4c, + 0x6e, 0x6e, 0x4a, 0x50, 0x06, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc4, 0x21, 0x07, 0x7c, 0x70, 0x03, 0x7a, 0x28, 0x87, + 0x76, 0x80, 0x87, 0x19, 0xd1, 0x43, 0x0e, 0xf8, 0xe0, 0x06, 0xe4, 0x20, + 0x0e, 0xe7, 0xe0, 0x06, 0xf6, 0x10, 0x0e, 0xf2, 0xc0, 0x0e, 0xe1, 0x90, + 0x0f, 0xef, 0x50, 0x0f, 0xf4, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x46, 0x40, 0x0d, 0x97, 0xef, 0x3c, 0x3e, 0xd0, + 0x34, 0xce, 0x04, 0x4c, 0x44, 0x08, 0x34, 0xc3, 0x42, 0x98, 0x40, 0x35, + 0x5c, 0xbe, 0xf3, 0xf8, 0xc0, 0xe4, 0x30, 0x88, 0xb0, 0x21, 0x0d, 0xfa, + 0xf8, 0x88, 0x8e, 0x5b, 0x41, 0x37, 0x5c, 0xbe, 0xf3, 0xf8, 0x42, 0x44, + 0x00, 0x13, 0x11, 0x02, 0xcd, 0xb0, 0x10, 0x5f, 0xe4, 0x30, 0x1b, 0xd2, + 0x0c, 0x48, 0x63, 0xd8, 0x00, 0x36, 0x5c, 0xbe, 0xf3, 0xf8, 0x11, 0x60, + 0x6d, 0x54, 0x51, 0x10, 0x11, 0x3b, 0x39, 0x11, 0xe1, 0x23, 0xb7, 0x6d, + 0x01, 0xd2, 0x70, 0xf9, 0xce, 0xe3, 0x4f, 0x47, 0x44, 0x00, 0x83, 0x38, + 0xf8, 0xc8, 0x6d, 0x1b, 0x00, 0xc1, 0x00, 0x48, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x41, 0x53, 0x48, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x0f, 0xd6, 0x81, 0xa6, 0xfd, 0xc8, 0x15, + 0x61, 0x13, 0x2f, 0x9a, 0x2e, 0x60, 0xb0, 0x0c, 0x44, 0x58, 0x49, 0x4c, + 0xe0, 0x05, 0x00, 0x00, 0x66, 0x00, 0x05, 0x00, 0x78, 0x01, 0x00, 0x00, + 0x44, 0x58, 0x49, 0x4c, 0x06, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xc8, 0x05, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, + 0x6f, 0x01, 0x00, 0x00, 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, + 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, + 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, + 0xa4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x52, 0x88, + 0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, + 0xe4, 0x48, 0x0e, 0x90, 0x91, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, + 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x29, 0x46, 0x06, 0x51, 0x18, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, + 0x40, 0x02, 0xa8, 0x0d, 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, + 0x01, 0x00, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x82, 0x60, 0x42, 0x20, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, + 0x93, 0x22, 0xa4, 0x84, 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, + 0x12, 0x4c, 0x8a, 0x8c, 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x60, 0x23, 0x00, + 0x25, 0x00, 0x14, 0xe6, 0x08, 0xc0, 0xa0, 0x0c, 0x63, 0x0c, 0x22, 0x73, + 0x04, 0xa0, 0x30, 0x47, 0x80, 0xd0, 0xb9, 0x67, 0xb8, 0xfc, 0x09, 0x7b, + 0x08, 0xc9, 0x0f, 0x81, 0x66, 0x58, 0x08, 0x14, 0xa0, 0x82, 0x98, 0x91, + 0xc6, 0x18, 0xc3, 0x90, 0x2a, 0x0b, 0x18, 0x69, 0x8c, 0x31, 0xc6, 0x38, + 0x83, 0xd8, 0x6d, 0xc3, 0xe5, 0x4f, 0xd8, 0x43, 0x48, 0xfe, 0x4a, 0x48, + 0x0e, 0x15, 0x09, 0x44, 0x1a, 0x39, 0x0f, 0x11, 0x4d, 0x08, 0x21, 0x21, + 0x61, 0x8c, 0x42, 0xa4, 0x91, 0x1c, 0xbd, 0x83, 0x86, 0xcb, 0x9f, 0xb0, + 0x87, 0x90, 0xfc, 0x95, 0x90, 0x36, 0xa4, 0x19, 0x10, 0x31, 0xc6, 0x38, + 0x73, 0x04, 0x41, 0x29, 0xd2, 0x88, 0x43, 0xd2, 0x1c, 0x08, 0x38, 0x4d, + 0x9a, 0x22, 0x4a, 0x98, 0xfc, 0x15, 0xde, 0xb0, 0x89, 0xd0, 0x86, 0x21, + 0x22, 0x24, 0x69, 0xa3, 0x8a, 0x82, 0x88, 0x50, 0x30, 0xc8, 0x02, 0x00, + 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, + 0x7a, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, 0x07, 0x76, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x04, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x14, 0x20, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xf2, 0x30, + 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xe4, + 0x79, 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0xc8, 0x33, 0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x16, 0x08, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x1a, + 0x25, 0x50, 0x0c, 0x25, 0x31, 0x02, 0x50, 0x16, 0x65, 0x50, 0x08, 0x05, + 0x18, 0x40, 0xa6, 0x40, 0x01, 0x01, 0x03, 0x48, 0x8e, 0x00, 0xd0, 0x9d, + 0x01, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, 0x8e, 0x0c, 0x6f, 0xec, + 0xed, 0x4d, 0x0c, 0x24, 0xc6, 0x25, 0xc7, 0x45, 0xc6, 0x06, 0x26, 0xc7, + 0xa5, 0x06, 0x04, 0x05, 0x26, 0x46, 0xcc, 0x46, 0x26, 0x8c, 0x8c, 0xe6, + 0x26, 0x65, 0x43, 0x10, 0x4c, 0x10, 0x06, 0x63, 0x82, 0x30, 0x1c, 0x1b, + 0x84, 0x81, 0x98, 0x20, 0x0c, 0xc8, 0x06, 0x61, 0x30, 0x28, 0x8c, 0xcd, + 0x6d, 0x18, 0x10, 0x82, 0x98, 0x20, 0x0c, 0xc9, 0x04, 0xe1, 0x82, 0x08, + 0x4c, 0x10, 0x06, 0x65, 0x82, 0x20, 0x3d, 0x13, 0x84, 0x61, 0xd9, 0x20, + 0x3c, 0xc3, 0x86, 0x45, 0x59, 0x18, 0x45, 0x19, 0x1a, 0xc7, 0x71, 0xa0, + 0x0d, 0x41, 0xb4, 0x81, 0x00, 0x24, 0x00, 0x98, 0x20, 0x08, 0x00, 0x89, + 0xb6, 0xb0, 0x34, 0xb7, 0x09, 0x82, 0xe1, 0x4c, 0x10, 0x06, 0x66, 0x82, + 0x30, 0x34, 0x1b, 0x06, 0x6c, 0x18, 0x36, 0x10, 0x8a, 0x75, 0x65, 0x1b, + 0x0a, 0xaa, 0x02, 0x26, 0xad, 0x0a, 0x1b, 0x9b, 0x5d, 0x9b, 0x4b, 0x1a, + 0x59, 0x99, 0x1b, 0xdd, 0x94, 0x20, 0xa8, 0x42, 0x86, 0xe7, 0x62, 0x57, + 0x26, 0x37, 0x97, 0xf6, 0xe6, 0x36, 0x25, 0x20, 0x9a, 0x90, 0xe1, 0xb9, + 0xd8, 0x85, 0xb1, 0xd9, 0x95, 0xc9, 0x4d, 0x09, 0x8c, 0x3a, 0x64, 0x78, + 0x2e, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x65, 0x6c, + 0x53, 0x02, 0xa4, 0x0c, 0x19, 0x9e, 0x8b, 0x5c, 0xd9, 0xdc, 0x5b, 0x9d, + 0xdc, 0x58, 0xd9, 0xdc, 0x94, 0x40, 0xaa, 0x43, 0x86, 0xe7, 0x52, 0xe6, + 0x46, 0x27, 0x97, 0x07, 0xf5, 0x96, 0xe6, 0x46, 0x37, 0x37, 0x25, 0xd0, + 0x00, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, + 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, + 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, + 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, + 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, + 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, + 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, + 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, + 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, + 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, + 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, + 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, + 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, + 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, + 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, + 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, + 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, + 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, + 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, + 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, + 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, + 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc4, + 0x21, 0x07, 0x7c, 0x70, 0x03, 0x7a, 0x28, 0x87, 0x76, 0x80, 0x87, 0x19, + 0xd1, 0x43, 0x0e, 0xf8, 0xe0, 0x06, 0xe4, 0x20, 0x0e, 0xe7, 0xe0, 0x06, + 0xf6, 0x10, 0x0e, 0xf2, 0xc0, 0x0e, 0xe1, 0x90, 0x0f, 0xef, 0x50, 0x0f, + 0xf4, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x46, 0x40, 0x0d, 0x97, 0xef, 0x3c, 0x3e, 0xd0, 0x34, 0xce, 0x04, 0x4c, + 0x44, 0x08, 0x34, 0xc3, 0x42, 0x98, 0x40, 0x35, 0x5c, 0xbe, 0xf3, 0xf8, + 0xc0, 0xe4, 0x30, 0x88, 0xb0, 0x21, 0x0d, 0xfa, 0xf8, 0x88, 0x8e, 0x5b, + 0x41, 0x37, 0x5c, 0xbe, 0xf3, 0xf8, 0x42, 0x44, 0x00, 0x13, 0x11, 0x02, + 0xcd, 0xb0, 0x10, 0x5f, 0xe4, 0x30, 0x1b, 0xd2, 0x0c, 0x48, 0x63, 0xd8, + 0x00, 0x36, 0x5c, 0xbe, 0xf3, 0xf8, 0x11, 0x60, 0x6d, 0x54, 0x51, 0x10, + 0x11, 0x3b, 0x39, 0x11, 0xe1, 0x23, 0xb7, 0x6d, 0x01, 0xd2, 0x70, 0xf9, + 0xce, 0xe3, 0x4f, 0x47, 0x44, 0x00, 0x83, 0x38, 0xf8, 0xc8, 0x6d, 0x1b, + 0x00, 0xc1, 0x00, 0x48, 0x03, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x34, 0x66, 0x00, 0x0a, 0x76, 0xa0, 0x1c, 0x8a, + 0x33, 0xa0, 0x64, 0x07, 0x4a, 0x37, 0xa0, 0x02, 0x01, 0x01, 0x01, 0x05, + 0xca, 0x12, 0xa8, 0x06, 0x0a, 0x50, 0xa0, 0x30, 0x05, 0x8a, 0x77, 0xd0, + 0x80, 0x4c, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x14, + 0x14, 0x9d, 0x12, 0x28, 0x03, 0x72, 0x73, 0x08, 0x58, 0x42, 0x71, 0x0e, + 0x22, 0x49, 0x92, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x23, 0x06, 0x08, 0x00, + 0x82, 0x60, 0x30, 0x79, 0x4e, 0xa0, 0x51, 0x23, 0x06, 0x06, 0x00, 0x82, + 0x60, 0x40, 0x8c, 0x81, 0xb3, 0x55, 0x20, 0x69, 0x09, 0x0f, 0x5c, 0x60, + 0xa2, 0x82, 0x65, 0x8d, 0xf0, 0x6e, 0x30, 0x62, 0x70, 0x00, 0x20, 0x08, + 0x06, 0x8f, 0x19, 0x60, 0x47, 0x32, 0x62, 0xb0, 0x00, 0x20, 0x08, 0x06, + 0x4a, 0x1a, 0x5c, 0x81, 0x18, 0x08, 0x9a, 0x36, 0x1c, 0x62, 0xa2, 0x82, + 0xe7, 0x4a, 0xa9, 0xf8, 0x02, 0x13, 0x35, 0x04, 0x5b, 0x08, 0x19, 0xec, + 0x88, 0xc1, 0x01, 0x80, 0x20, 0x18, 0x3c, 0x6e, 0x00, 0x06, 0x4f, 0x34, + 0x62, 0xb0, 0x00, 0x20, 0x08, 0x06, 0x4a, 0x1c, 0x7c, 0x01, 0x18, 0x08, + 0x62, 0x20, 0x06, 0x43, 0x2d, 0xda, 0x8e, 0x18, 0x1c, 0x00, 0x08, 0x82, + 0xc1, 0x13, 0x07, 0x63, 0x20, 0x51, 0x23, 0x06, 0x0e, 0x00, 0x82, 0x60, + 0xc0, 0xcc, 0xc1, 0x16, 0x08, 0x65, 0x10, 0x69, 0x65, 0x50, 0x06, 0x96, + 0x1a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.hlsl b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.hlsl new file mode 100644 index 00000000..af95fa14 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_buffer.hlsl @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// #453: control for atomic64_image.hlsl. The same operations on a raw buffer +// (RWByteAddressBuffer::InterlockedAdd64 / InterlockedMax64), so a failure of +// the typed form can be told apart from 64-bit atomics failing everywhere. +// Layout: 8 add slots, 8 max slots, then 8 plain-store marker slots, 8 bytes each. + +RWByteAddressBuffer Buf : register(u0); + +[numthreads(64, 1, 1)] +void main(uint3 id : SV_DispatchThreadID) +{ + uint px = id.x & 7u; + uint64_t add = (uint64_t(0x10000000u) << 32) | uint64_t(0xF0000000u + id.x); + Buf.InterlockedAdd64(px * 8u, add); + uint64_t m = (uint64_t(id.x) << 40) | uint64_t(0xFFFFFFFFu - id.x); + Buf.InterlockedMax64(64u + px * 8u, m); + Buf.Store2(128u + px * 8u, uint2(px, 0xC0DEu)); +} diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.h b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.h new file mode 100644 index 00000000..6d325124 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.h @@ -0,0 +1,391 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// GENERATED by DXC 1.9.2609 from atomic64_image.hlsl by compile.sh; do not edit. + +#if 0 +; +; Note: shader requires additional functionality: +; 64-Bit integer +; 64-bit Atomics on Typed Resources +; +; +; Input signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; +; Output signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; shader hash: 659a63357ea7f50fffd00a1792de5b68 +; +; Pipeline Runtime Information: +; +;PSVRuntimeInfo: +; Compute Shader +; NumThreads=(64,1,1) +; MinimumExpectedWaveLaneCount: 0 +; MaximumExpectedWaveLaneCount: 4294967295 +; UsesViewID: false +; SigInputElements: 0 +; SigOutputElements: 0 +; SigPatchConstOrPrimElements: 0 +; SigInputVectors: 0 +; SigOutputVectors[0]: 0 +; SigOutputVectors[1]: 0 +; SigOutputVectors[2]: 0 +; SigOutputVectors[3]: 0 +; EntryFunctionName: main +; +; +; Buffer Definitions: +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; Img UAV u32 2d U0 u0 1 +; +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%dx.types.Handle = type { i8* } +%dx.types.ResBind = type { i32, i32, i32, i8 } +%dx.types.ResourceProperties = type { i32, i32 } +%"class.RWTexture2D" = type { i64 } + +define void @main() { + %1 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 1 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %2 = call i32 @dx.op.threadId.i32(i32 93, i32 0) ; ThreadId(component) + %3 = and i32 %2, 7 + %4 = add i32 %2, -268435456 + %5 = zext i32 %4 to i64 + %6 = or i64 %5, 1152921504606846976 + %7 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4098, i32 261 }) ; AnnotateHandle(res,props) resource: RWTexture2D + %8 = call i64 @dx.op.atomicBinOp.i64(i32 78, %dx.types.Handle %7, i32 0, i32 %3, i32 0, i32 undef, i64 %6) ; AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue) + %9 = zext i32 %2 to i64 + %10 = shl i64 %9, 40 + %11 = xor i32 %2, -1 + %12 = zext i32 %11 to i64 + %13 = or i64 %10, %12 + %14 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4098, i32 261 }) ; AnnotateHandle(res,props) resource: RWTexture2D + %15 = call i64 @dx.op.atomicBinOp.i64(i32 78, %dx.types.Handle %14, i32 7, i32 %3, i32 1, i32 undef, i64 %13) ; AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue) + %16 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4098, i32 261 }) ; AnnotateHandle(res,props) resource: RWTexture2D + call void @dx.op.textureStore.i32(i32 67, %dx.types.Handle %16, i32 %3, i32 2, i32 undef, i32 %3, i32 49374, i32 %3, i32 49374, i8 15) ; TextureStore(srv,coord0,coord1,coord2,value0,value1,value2,value3,mask) + ret void +} + +; Function Attrs: nounwind readnone +declare i32 @dx.op.threadId.i32(i32, i32) #0 + +; Function Attrs: nounwind +declare i64 @dx.op.atomicBinOp.i64(i32, %dx.types.Handle, i32, i32, i32, i32, i64) #1 + +; Function Attrs: nounwind +declare void @dx.op.textureStore.i32(i32, %dx.types.Handle, i32, i32, i32, i32, i32, i32, i32, i8) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @dx.op.annotateHandle(i32, %dx.types.Handle, %dx.types.ResourceProperties) #0 + +; Function Attrs: nounwind readnone +declare %dx.types.Handle @dx.op.createHandleFromBinding(i32, %dx.types.ResBind, i32, i1) #0 + +attributes #0 = { nounwind readnone } +attributes #1 = { nounwind } + +!llvm.ident = !{!0} +!dx.version = !{!1} +!dx.valver = !{!2} +!dx.shaderModel = !{!3} +!dx.resources = !{!4} +!dx.entryPoints = !{!8} + +!0 = !{!"dxcoob 1.9.2609.5 (01b62ad47)"} +!1 = !{i32 1, i32 6} +!2 = !{i32 1, i32 9} +!3 = !{!"cs", i32 6, i32 6} +!4 = !{null, !5, null, null} +!5 = !{!6} +!6 = !{i32 0, %"class.RWTexture2D"* undef, !"", i32 0, i32 0, i32 1, i32 2, i1 false, i1 false, i1 false, !7} +!7 = !{i32 0, i32 5, i32 3, i32 1} +!8 = !{void ()* @main, !"main", null, !4, !9} +!9 = !{i32 0, i64 135266304, i32 4, !10} +!10 = !{i32 64, i32 1, i32 1} + +#endif + +const unsigned char g_atomic64_image_cs[] = { + 0x44, 0x58, 0x42, 0x43, 0xfe, 0x59, 0x2d, 0xd5, 0xc7, 0xff, 0x0b, 0xbd, + 0xc9, 0xaa, 0xb8, 0x78, 0x82, 0xae, 0x4f, 0x26, 0x01, 0x00, 0x00, 0x00, + 0x9c, 0x0c, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0xdc, 0x00, 0x00, 0x00, 0x78, 0x06, 0x00, 0x00, 0x94, 0x06, 0x00, 0x00, + 0x53, 0x46, 0x49, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x31, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x50, 0x53, 0x56, 0x30, 0x68, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, 0x94, 0x05, 0x00, 0x00, + 0x66, 0x00, 0x05, 0x00, 0x65, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x06, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x05, 0x00, 0x00, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x5c, 0x01, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x52, 0x88, 0x48, 0x90, 0x14, 0x20, + 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x91, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, + 0x04, 0x29, 0x46, 0x06, 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x40, 0x02, 0xa8, 0x0d, + 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, + 0x20, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, + 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, + 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x60, 0x23, 0x00, 0x25, 0x00, 0x14, 0xe6, + 0x08, 0xc0, 0xa0, 0x0c, 0x63, 0x0c, 0x22, 0x73, 0x04, 0xa0, 0x30, 0x47, + 0x80, 0xd0, 0xb9, 0x67, 0xb8, 0xfc, 0x09, 0x7b, 0x08, 0xc9, 0x0f, 0x81, + 0x66, 0x58, 0x08, 0x14, 0xa0, 0x82, 0x98, 0x91, 0xc6, 0x18, 0xc3, 0x90, + 0x2a, 0x0b, 0x18, 0x69, 0x8c, 0x31, 0xc6, 0x18, 0x87, 0xd8, 0x6d, 0xc3, + 0xe5, 0x4f, 0xd8, 0x43, 0x48, 0xfe, 0x4a, 0x48, 0x0e, 0x15, 0x09, 0x44, + 0x1a, 0x39, 0x0f, 0x11, 0x4d, 0x08, 0x21, 0x21, 0x61, 0x8c, 0x42, 0xa4, + 0x91, 0x1c, 0xbd, 0x83, 0x86, 0xcb, 0x9f, 0xb0, 0x87, 0x90, 0xfc, 0x95, + 0x90, 0x36, 0xa4, 0x19, 0x10, 0x31, 0xc6, 0x38, 0x73, 0x04, 0x41, 0x29, + 0xd2, 0x88, 0x43, 0xd2, 0x1c, 0x08, 0x98, 0xa9, 0x0c, 0xc6, 0x81, 0x1d, + 0xc2, 0x61, 0x1e, 0xe6, 0xc1, 0x0d, 0x64, 0xe1, 0x16, 0x68, 0xa1, 0x1c, + 0xf0, 0x81, 0x1e, 0xea, 0x41, 0x1e, 0xca, 0x41, 0x0e, 0x48, 0x81, 0x0f, + 0xea, 0xc1, 0x1d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, + 0xc0, 0x80, 0x1d, 0xde, 0xc1, 0x1d, 0xce, 0x01, 0x0c, 0xd8, 0xe1, 0x1d, + 0xdc, 0xe1, 0x1c, 0xfc, 0x00, 0x05, 0x86, 0x2c, 0x00, 0x00, 0x00, 0x00, + 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, + 0x7a, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, 0x07, 0x76, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x04, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x14, 0x20, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xf2, 0x30, + 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xe4, + 0x79, 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0xc8, 0x33, 0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x16, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x1a, + 0x25, 0x50, 0x0c, 0x23, 0x00, 0x45, 0x50, 0x0a, 0x65, 0x50, 0x08, 0x05, + 0x18, 0x50, 0x24, 0x05, 0x41, 0xa6, 0x00, 0x01, 0x01, 0x03, 0x03, 0x48, + 0x8e, 0x00, 0xd0, 0x9d, 0x01, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, + 0x8e, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x0c, 0x24, 0xc6, 0x25, 0xc7, 0x45, + 0xc6, 0x06, 0x26, 0xc7, 0xa5, 0x06, 0x04, 0x05, 0x26, 0x46, 0xcc, 0x46, + 0x26, 0x8c, 0x8c, 0xe6, 0x26, 0x65, 0x43, 0x10, 0x4c, 0x10, 0x06, 0x63, + 0x82, 0x30, 0x1c, 0x1b, 0x84, 0x81, 0x98, 0x20, 0x0c, 0xc8, 0x06, 0xc1, + 0x30, 0x28, 0x8c, 0xcd, 0x6d, 0x18, 0x10, 0x82, 0x98, 0x20, 0x5c, 0x12, + 0x87, 0xa4, 0xb6, 0xb3, 0x09, 0xc2, 0x90, 0x4c, 0x10, 0xa4, 0x68, 0x82, + 0x30, 0x28, 0x13, 0x84, 0x61, 0xd9, 0x40, 0x18, 0xce, 0x33, 0x6c, 0x58, + 0x0c, 0x65, 0x31, 0x8c, 0x81, 0x69, 0x9a, 0x06, 0xda, 0x10, 0x44, 0x1b, + 0x08, 0x40, 0x02, 0x80, 0x09, 0x82, 0x00, 0x6c, 0x00, 0x36, 0x0c, 0x46, + 0x55, 0x6d, 0x08, 0xac, 0x0d, 0xc3, 0x40, 0x5d, 0x24, 0xda, 0xc2, 0xd2, + 0xdc, 0x26, 0x08, 0x06, 0x34, 0x41, 0x18, 0x98, 0x09, 0xc2, 0xd0, 0x6c, + 0x18, 0xb8, 0x61, 0xd8, 0x40, 0x18, 0xda, 0xd6, 0x6d, 0x28, 0xa8, 0x0c, + 0x98, 0x3c, 0x1a, 0x61, 0x74, 0x6f, 0x6d, 0x69, 0x63, 0x2c, 0xd2, 0xdc, + 0xe6, 0xe8, 0xe6, 0x26, 0x08, 0x83, 0x43, 0x22, 0xcd, 0x8d, 0x6e, 0x8e, + 0x09, 0x5d, 0x19, 0xde, 0xd7, 0x1c, 0xdd, 0x9b, 0x5c, 0x19, 0x8b, 0xba, + 0x34, 0x37, 0xba, 0xb9, 0x09, 0xc2, 0xf0, 0x6c, 0x50, 0xc0, 0x80, 0x09, + 0x03, 0x31, 0x18, 0x83, 0x81, 0x0c, 0x86, 0x32, 0x30, 0x83, 0x2a, 0x6c, + 0x6c, 0x76, 0x6d, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x53, 0x82, 0xa0, + 0x0a, 0x19, 0x9e, 0x8b, 0x5d, 0x99, 0xdc, 0x5c, 0xda, 0x9b, 0xdb, 0x94, + 0x80, 0x68, 0x42, 0x86, 0xe7, 0x62, 0x17, 0xc6, 0x66, 0x57, 0x26, 0x37, + 0x25, 0x30, 0xea, 0x90, 0xe1, 0xb9, 0xcc, 0xa1, 0x85, 0x91, 0x95, 0xc9, + 0x35, 0xbd, 0x91, 0x95, 0xb1, 0x4d, 0x09, 0x90, 0x32, 0x64, 0x78, 0x2e, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x53, 0x02, 0xa9, + 0x12, 0x19, 0x9e, 0x0b, 0x5d, 0x1e, 0x5c, 0x59, 0x90, 0x9b, 0xdb, 0x1b, + 0x5d, 0x18, 0x5d, 0xda, 0x9b, 0xdb, 0xdc, 0x94, 0xe0, 0xaa, 0x43, 0x86, + 0xe7, 0x52, 0xe6, 0x46, 0x27, 0x97, 0x07, 0xf5, 0x96, 0xe6, 0x46, 0x37, + 0x37, 0x25, 0xf0, 0xba, 0x90, 0xe1, 0xb9, 0x8c, 0xbd, 0xd5, 0xb9, 0xd1, + 0x95, 0xc9, 0xcd, 0x4d, 0x09, 0xcc, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, 0x1c, 0x66, + 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, + 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, + 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, + 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, 0x83, 0x1b, + 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, + 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, + 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, + 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, 0xe3, 0xf0, + 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, + 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, + 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, + 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x68, 0x87, + 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, + 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, + 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, + 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, 0xec, 0x30, + 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, + 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, + 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, 0x03, 0x3b, + 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, + 0xb0, 0xc3, 0x0c, 0xc4, 0x21, 0x07, 0x7c, 0x70, 0x03, 0x7a, 0x28, 0x87, + 0x76, 0x80, 0x87, 0x19, 0xd1, 0x43, 0x0e, 0xf8, 0xe0, 0x06, 0xe4, 0x20, + 0x0e, 0xe7, 0xe0, 0x06, 0xf6, 0x10, 0x0e, 0xf2, 0xc0, 0x0e, 0xe1, 0x90, + 0x0f, 0xef, 0x50, 0x0f, 0xf4, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x46, 0x40, 0x0d, 0x97, 0xef, 0x3c, 0x3e, 0xd0, + 0x34, 0xce, 0x04, 0x4c, 0x44, 0x08, 0x34, 0xc3, 0x42, 0x98, 0x40, 0x35, + 0x5c, 0xbe, 0xf3, 0xf8, 0xc0, 0xe4, 0x30, 0x88, 0xb0, 0x21, 0x0d, 0xfa, + 0xf8, 0x88, 0x8e, 0x5b, 0x41, 0x37, 0x5c, 0xbe, 0xf3, 0xf8, 0x42, 0x44, + 0x00, 0x13, 0x11, 0x02, 0xcd, 0xb0, 0x10, 0x5f, 0xe4, 0x30, 0x1b, 0xd2, + 0x0c, 0x48, 0x63, 0xd8, 0x80, 0x35, 0x5c, 0xbe, 0xf3, 0xf8, 0x13, 0x71, + 0x4d, 0x54, 0x44, 0xb0, 0x93, 0x13, 0x11, 0x3e, 0x72, 0xdb, 0x16, 0x20, + 0x0d, 0x97, 0xef, 0x3c, 0xfe, 0x74, 0x44, 0x04, 0x30, 0x88, 0x83, 0x8f, + 0xdc, 0xb6, 0x01, 0x10, 0x0c, 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x41, 0x53, 0x48, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x65, 0x9a, 0x63, 0x35, 0x7e, 0xa7, 0xf5, 0x0f, 0xff, 0xd0, 0x0a, 0x17, + 0x92, 0xde, 0x5b, 0x68, 0x44, 0x58, 0x49, 0x4c, 0x00, 0x06, 0x00, 0x00, + 0x66, 0x00, 0x05, 0x00, 0x80, 0x01, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, + 0x06, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xe8, 0x05, 0x00, 0x00, + 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0x77, 0x01, 0x00, 0x00, + 0x0b, 0x82, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, + 0x92, 0x01, 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, + 0x80, 0x14, 0x45, 0x02, 0x42, 0x92, 0x0b, 0x42, 0xa4, 0x10, 0x32, 0x14, + 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x52, 0x88, 0x48, 0x90, 0x14, 0x20, + 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0xe4, 0x48, 0x0e, 0x90, + 0x91, 0x22, 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, + 0x04, 0x29, 0x46, 0x06, 0x51, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1b, 0x8c, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x40, 0x02, 0xa8, 0x0d, + 0x84, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x20, 0x01, 0x00, 0x00, 0x00, + 0x49, 0x18, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x82, 0x60, 0x42, + 0x20, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x32, 0x22, 0x48, 0x09, 0x20, 0x64, 0x85, 0x04, 0x93, 0x22, 0xa4, 0x84, + 0x04, 0x93, 0x22, 0xe3, 0x84, 0xa1, 0x90, 0x14, 0x12, 0x4c, 0x8a, 0x8c, + 0x0b, 0x84, 0xa4, 0x4c, 0x10, 0x60, 0x23, 0x00, 0x25, 0x00, 0x14, 0xe6, + 0x08, 0xc0, 0xa0, 0x0c, 0x63, 0x0c, 0x22, 0x73, 0x04, 0xa0, 0x30, 0x47, + 0x80, 0xd0, 0xb9, 0x67, 0xb8, 0xfc, 0x09, 0x7b, 0x08, 0xc9, 0x0f, 0x81, + 0x66, 0x58, 0x08, 0x14, 0xa0, 0x82, 0x98, 0x91, 0xc6, 0x18, 0xc3, 0x90, + 0x2a, 0x0b, 0x18, 0x69, 0x8c, 0x31, 0xc6, 0x18, 0x87, 0xd8, 0x6d, 0xc3, + 0xe5, 0x4f, 0xd8, 0x43, 0x48, 0xfe, 0x4a, 0x48, 0x0e, 0x15, 0x09, 0x44, + 0x1a, 0x39, 0x0f, 0x11, 0x4d, 0x08, 0x21, 0x21, 0x61, 0x8c, 0x42, 0xa4, + 0x91, 0x1c, 0xbd, 0x83, 0x86, 0xcb, 0x9f, 0xb0, 0x87, 0x90, 0xfc, 0x95, + 0x90, 0x36, 0xa4, 0x19, 0x10, 0x31, 0xc6, 0x38, 0x73, 0x04, 0x41, 0x29, + 0xd2, 0x88, 0x43, 0xd2, 0x1c, 0x08, 0x98, 0xa9, 0x0c, 0xc6, 0x81, 0x1d, + 0xc2, 0x61, 0x1e, 0xe6, 0xc1, 0x0d, 0x64, 0xe1, 0x16, 0x68, 0xa1, 0x1c, + 0xf0, 0x81, 0x1e, 0xea, 0x41, 0x1e, 0xca, 0x41, 0x0e, 0x48, 0x81, 0x0f, + 0xea, 0xc1, 0x1d, 0xe6, 0x21, 0x1d, 0xce, 0xc1, 0x1d, 0xca, 0x81, 0x1c, + 0xc0, 0x80, 0x1d, 0xde, 0xc1, 0x1d, 0xce, 0x01, 0x0c, 0xd8, 0xe1, 0x1d, + 0xdc, 0xe1, 0x1c, 0xfc, 0x00, 0x05, 0x86, 0x2c, 0x00, 0x00, 0x00, 0x00, + 0x13, 0x14, 0x72, 0xc0, 0x87, 0x74, 0x60, 0x87, 0x36, 0x68, 0x87, 0x79, + 0x68, 0x03, 0x72, 0xc0, 0x87, 0x0d, 0xaf, 0x50, 0x0e, 0x6d, 0xd0, 0x0e, + 0x7a, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0xa0, 0x07, 0x73, 0x20, 0x07, + 0x6d, 0x90, 0x0e, 0x78, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, + 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xd0, 0x06, 0xe9, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xd0, 0x06, 0xe6, 0x10, 0x07, 0x76, 0xa0, 0x07, + 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xd0, 0x06, 0xe6, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, + 0x72, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x43, 0x9e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0x04, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x79, 0x14, 0x20, + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xf2, 0x30, + 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xe4, + 0x79, 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, + 0xc8, 0x33, 0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x16, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x32, 0x1e, 0x98, 0x14, + 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x1a, + 0x25, 0x50, 0x0c, 0x25, 0x31, 0x02, 0x50, 0x04, 0xa5, 0x50, 0x06, 0x85, + 0x50, 0x80, 0x01, 0x64, 0x0a, 0x10, 0x10, 0x30, 0x30, 0x80, 0xe4, 0x08, + 0x00, 0xdd, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x18, 0x00, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x1a, 0x03, 0x4c, 0x90, 0x46, 0x02, 0x13, 0xc4, + 0x8e, 0x0c, 0x6f, 0xec, 0xed, 0x4d, 0x0c, 0x24, 0xc6, 0x25, 0xc7, 0x45, + 0xc6, 0x06, 0x26, 0xc7, 0xa5, 0x06, 0x04, 0x05, 0x26, 0x46, 0xcc, 0x46, + 0x26, 0x8c, 0x8c, 0xe6, 0x26, 0x65, 0x43, 0x10, 0x4c, 0x10, 0x06, 0x63, + 0x82, 0x30, 0x1c, 0x1b, 0x84, 0x81, 0x98, 0x20, 0x0c, 0xc8, 0x06, 0x61, + 0x30, 0x28, 0x8c, 0xcd, 0x6d, 0x18, 0x10, 0x82, 0x98, 0x20, 0x0c, 0xc9, + 0x04, 0xe1, 0x8a, 0x08, 0x4c, 0x10, 0x06, 0x65, 0x82, 0x20, 0x41, 0x13, + 0x84, 0x61, 0x99, 0x20, 0x0c, 0xcc, 0x06, 0x42, 0x79, 0xa0, 0x61, 0xc3, + 0xa2, 0x2c, 0x8c, 0xa2, 0x0c, 0x8d, 0xe3, 0x38, 0xd1, 0x86, 0x40, 0xda, + 0x40, 0x00, 0x13, 0x00, 0x4c, 0x10, 0x04, 0x80, 0x44, 0x5b, 0x58, 0x9a, + 0xdb, 0x04, 0xc1, 0x78, 0x26, 0x08, 0x43, 0x33, 0x41, 0x18, 0x9c, 0x0d, + 0x43, 0x36, 0x0c, 0x1b, 0x08, 0xe5, 0xc2, 0xb4, 0x0d, 0x45, 0x65, 0x01, + 0xd4, 0x56, 0x85, 0x8d, 0xcd, 0xae, 0xcd, 0x25, 0x8d, 0xac, 0xcc, 0x8d, + 0x6e, 0x4a, 0x10, 0x54, 0x21, 0xc3, 0x73, 0xb1, 0x2b, 0x93, 0x9b, 0x4b, + 0x7b, 0x73, 0x9b, 0x12, 0x10, 0x4d, 0xc8, 0xf0, 0x5c, 0xec, 0xc2, 0xd8, + 0xec, 0xca, 0xe4, 0xa6, 0x04, 0x46, 0x1d, 0x32, 0x3c, 0x97, 0x39, 0xb4, + 0x30, 0xb2, 0x32, 0xb9, 0xa6, 0x37, 0xb2, 0x32, 0xb6, 0x29, 0x01, 0x52, + 0x86, 0x0c, 0xcf, 0x45, 0xae, 0x6c, 0xee, 0xad, 0x4e, 0x6e, 0xac, 0x6c, + 0x6e, 0x4a, 0x30, 0xd5, 0x21, 0xc3, 0x73, 0x29, 0x73, 0xa3, 0x93, 0xcb, + 0x83, 0x7a, 0x4b, 0x73, 0xa3, 0x9b, 0x9b, 0x12, 0x6c, 0x00, 0x00, 0x00, + 0x79, 0x18, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, + 0xc4, 0xe1, 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, + 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, + 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, 0x42, 0x1e, + 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, + 0x38, 0x84, 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, + 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, + 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, 0x70, 0x20, + 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, + 0x30, 0x0f, 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, + 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, + 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, 0xbc, 0x83, + 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, + 0x07, 0x37, 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, + 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, + 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, 0x72, 0x98, + 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, + 0xc0, 0x0e, 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, + 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, 0xc8, 0x43, + 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, + 0x38, 0x88, 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, + 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, 0x0c, 0xc4, 0x21, 0x07, 0x7c, 0x70, + 0x03, 0x7a, 0x28, 0x87, 0x76, 0x80, 0x87, 0x19, 0xd1, 0x43, 0x0e, 0xf8, + 0xe0, 0x06, 0xe4, 0x20, 0x0e, 0xe7, 0xe0, 0x06, 0xf6, 0x10, 0x0e, 0xf2, + 0xc0, 0x0e, 0xe1, 0x90, 0x0f, 0xef, 0x50, 0x0f, 0xf4, 0x00, 0x00, 0x00, + 0x71, 0x20, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x46, 0x40, 0x0d, 0x97, + 0xef, 0x3c, 0x3e, 0xd0, 0x34, 0xce, 0x04, 0x4c, 0x44, 0x08, 0x34, 0xc3, + 0x42, 0x98, 0x40, 0x35, 0x5c, 0xbe, 0xf3, 0xf8, 0xc0, 0xe4, 0x30, 0x88, + 0xb0, 0x21, 0x0d, 0xfa, 0xf8, 0x88, 0x8e, 0x5b, 0x41, 0x37, 0x5c, 0xbe, + 0xf3, 0xf8, 0x42, 0x44, 0x00, 0x13, 0x11, 0x02, 0xcd, 0xb0, 0x10, 0x5f, + 0xe4, 0x30, 0x1b, 0xd2, 0x0c, 0x48, 0x63, 0xd8, 0x80, 0x35, 0x5c, 0xbe, + 0xf3, 0xf8, 0x13, 0x71, 0x4d, 0x54, 0x44, 0xb0, 0x93, 0x13, 0x11, 0x3e, + 0x72, 0xdb, 0x16, 0x20, 0x0d, 0x97, 0xef, 0x3c, 0xfe, 0x74, 0x44, 0x04, + 0x30, 0x88, 0x83, 0x8f, 0xdc, 0xb6, 0x01, 0x10, 0x0c, 0x80, 0x34, 0x00, + 0x61, 0x20, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x0a, 0x76, 0x60, + 0x06, 0xa0, 0x1c, 0x8a, 0x33, 0xa0, 0x78, 0x07, 0x0d, 0x4a, 0x76, 0xa0, + 0x74, 0x03, 0x2a, 0x10, 0x10, 0x10, 0x50, 0xa0, 0x08, 0x81, 0x4a, 0x91, + 0xa0, 0x06, 0xca, 0x30, 0x80, 0x4c, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x82, 0x14, 0x14, 0x9d, 0x12, 0x28, 0x0f, 0x72, 0x73, 0x08, + 0xda, 0x46, 0x71, 0x0e, 0x22, 0x49, 0x12, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x06, 0x08, 0x00, 0x82, 0x60, 0x30, 0x7d, 0x4d, 0xb0, 0x51, 0x23, + 0x06, 0x06, 0x00, 0x82, 0x60, 0x40, 0x90, 0x41, 0xc3, 0x55, 0x20, 0x69, + 0x09, 0x0e, 0x5c, 0x60, 0xa2, 0x82, 0x65, 0x47, 0x0c, 0x0e, 0x00, 0x04, + 0xc1, 0xe0, 0x31, 0x03, 0xcc, 0x40, 0x46, 0x0c, 0x16, 0x00, 0x04, 0xc1, + 0x40, 0x49, 0x03, 0x2b, 0x10, 0x83, 0x42, 0x0c, 0x30, 0xe1, 0x0e, 0x13, + 0x15, 0x38, 0x57, 0x89, 0xc4, 0x17, 0x98, 0xa8, 0x21, 0xd8, 0x11, 0x83, + 0x03, 0x00, 0x41, 0x30, 0x78, 0xda, 0xe0, 0x6b, 0x9e, 0x11, 0x83, 0x05, + 0x00, 0x41, 0x30, 0x50, 0xe0, 0xa0, 0x0b, 0x3c, 0x86, 0x0d, 0x3e, 0x61, + 0xc4, 0xe0, 0x00, 0x40, 0x10, 0x0c, 0x9e, 0x37, 0x08, 0x83, 0x27, 0x1a, + 0x31, 0x70, 0x00, 0x10, 0x04, 0x03, 0x26, 0x0e, 0xae, 0xc0, 0x51, 0x83, + 0x30, 0x70, 0x3c, 0xc7, 0x9b, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.hlsl b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.hlsl new file mode 100644 index 00000000..e7dcfd54 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/atomic64_image.hlsl @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// #453: original synthetic kernel for SM 6.6 64-bit atomics on a typed UAV +// (RWTexture2D over a DXGI_FORMAT_R32G32_UINT texture, 8 x 3 texels). +// 256 threads, 32 per texel: row 0 takes a 64-bit add whose low halves carry +// into the high half, row 1 a 64-bit max decided by the high half. Row 2 gets a +// plain store (no atomic), so "atomics had no effect" is told apart from "the +// kernel never ran". +// Expected values are computed independently on the CPU by the fixture. + +RWTexture2D Img : register(u0); + +[numthreads(64, 1, 1)] +void main(uint3 id : SV_DispatchThreadID) +{ + uint px = id.x & 7u; + uint64_t add = (uint64_t(0x10000000u) << 32) | uint64_t(0xF0000000u + id.x); + InterlockedAdd(Img[uint2(px, 0)], add); + uint64_t m = (uint64_t(id.x) << 40) | uint64_t(0xFFFFFFFFu - id.x); + InterlockedMax(Img[uint2(px, 1)], m); + Img[uint2(px, 2)] = (uint64_t(0xC0DEu) << 32) | uint64_t(px); +} diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/compile.sh b/tests/conformance/test_d3dmetal_gpu_limits/shaders/compile.sh new file mode 100755 index 00000000..64547b92 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/compile.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Regenerates the committed *.h shader headers for test_d3dmetal_gpu_limits (#453). +# Needs Microsoft's official DXC release v1.9.2609 (dxc_2026_09_29.zip, SHA-256 +# ad31b1fc8443175d204f77a611fdb3ef2ec42759bdc2f1167368de24a4a7e7f1); it has no +# macOS build, so bin/x64/dxc.exe runs under a Wine/CrossOver loader. +# +# WINE=/path/to/wine DXC=/path/to/dxc/bin/x64/dxc.exe ./compile.sh +set -eu +: "${WINE:?set WINE to a Wine or CrossOver wine loader}" +: "${DXC:?set DXC to dxc.exe from the DXC v1.9.2609 release}" +cd "$(dirname "$0")" +dxc() { "$WINE" "$DXC" -nologo "$@"; } +dxc -T cs_6_6 -E main -Vn g_wave_lanes_cs -Fh wave_lanes.h wave_lanes.hlsl +dxc -T cs_6_6 -E main -D BX_WAVE64=1 -Vn g_wave64_lanes_cs -Fh wave64_lanes.h wave_lanes.hlsl +dxc -T cs_6_6 -E main -Vn g_atomic64_image_cs -Fh atomic64_image.h atomic64_image.hlsl +dxc -T cs_6_6 -E main -Vn g_atomic64_buffer_cs -Fh atomic64_buffer.h atomic64_buffer.hlsl +dxc -T cs_6_6 -E main -Vn g_lock64_image_cs -Fh lock64_image.h lock64_image.hlsl +# Strip CRs and prepend the licence and provenance header. +for pair in wave_lanes:wave_lanes wave64_lanes:wave_lanes atomic64_image:atomic64_image \ + atomic64_buffer:atomic64_buffer lock64_image:lock64_image; do + h=${pair%%:*} src=${pair#*:} + { + printf '// SPDX-License-Identifier: GPL-3.0-or-later\n//\n' + printf '// GENERATED by DXC 1.9.2609 from %s.hlsl by compile.sh; do not edit.\n\n' "$src" + tr -d '\r' < "$h.h" + } > "$h.h.tmp" && mv "$h.h.tmp" "$h.h" +done diff --git a/tests/conformance/test_d3dmetal_gpu_limits/shaders/lock64_image.h b/tests/conformance/test_d3dmetal_gpu_limits/shaders/lock64_image.h new file mode 100644 index 00000000..081b9160 --- /dev/null +++ b/tests/conformance/test_d3dmetal_gpu_limits/shaders/lock64_image.h @@ -0,0 +1,691 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// +// GENERATED by DXC 1.9.2609 from lock64_image.hlsl by compile.sh; do not edit. + +#if 0 +; +; Note: shader requires additional functionality: +; 64-Bit integer +; +; +; Input signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; +; Output signature: +; +; Name Index Mask Register SysValue Format Used +; -------------------- ----- ------ -------- -------- ------- ------ +; no parameters +; shader hash: 5887d9d772313a937ddc55f21bcb1a08 +; +; Pipeline Runtime Information: +; +;PSVRuntimeInfo: +; Compute Shader +; NumThreads=(64,1,1) +; MinimumExpectedWaveLaneCount: 0 +; MaximumExpectedWaveLaneCount: 4294967295 +; UsesViewID: false +; SigInputElements: 0 +; SigOutputElements: 0 +; SigPatchConstOrPrimElements: 0 +; SigInputVectors: 0 +; SigOutputVectors[0]: 0 +; SigOutputVectors[1]: 0 +; SigOutputVectors[2]: 0 +; SigOutputVectors[3]: 0 +; EntryFunctionName: main +; +; +; Buffer Definitions: +; +; cbuffer Params +; { +; +; struct Params +; { +; +; uint cap; ; Offset: 0 +; +; } Params; ; Offset: 0 Size: 4 +; +; } +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; Params cbuffer NA NA CB0 cb0 1 +; Data UAV u32 2d U0 u0 1 +; Lock UAV u32 2d U1 u1 1 +; Stats UAV byte r/w U2 u2 1 +; +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%dx.types.Handle = type { i8* } +%dx.types.ResBind = type { i32, i32, i32, i8 } +%dx.types.ResourceProperties = type { i32, i32 } +%dx.types.CBufRet.i32 = type { i32, i32, i32, i32 } +%dx.types.ResRet.i32 = type { i32, i32, i32, i32, i32 } +%"class.RWTexture2D" = type { i32 } +%struct.RWByteAddressBuffer = type { i32 } +%Params = type { i32 } + +define void @main() { + %1 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 2, i32 2, i32 0, i8 1 }, i32 2, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %2 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 1, i32 1, i32 0, i8 1 }, i32 1, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %3 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %2, %dx.types.ResourceProperties { i32 20482, i32 261 }) ; AnnotateHandle(res,props) resource: globallycoherent RWTexture2D + %4 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 1 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %5 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %4, %dx.types.ResourceProperties { i32 20482, i32 261 }) ; AnnotateHandle(res,props) resource: globallycoherent RWTexture2D + %6 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 2 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex) + %7 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %6, %dx.types.ResourceProperties { i32 13, i32 4 }) ; AnnotateHandle(res,props) resource: CBuffer + %8 = call i32 @dx.op.threadId.i32(i32 93, i32 0) ; ThreadId(component) + %9 = and i32 %8, 7 + %10 = add i32 %8, -268435456 + %11 = zext i32 %10 to i64 + %12 = or i64 %11, 1152921504606846976 + %13 = call %dx.types.CBufRet.i32 @dx.op.cbufferLoadLegacy.i32(i32 59, %dx.types.Handle %7, i32 0) ; CBufferLoadLegacy(handle,regIndex) + %14 = extractvalue %dx.types.CBufRet.i32 %13, 0 + %15 = icmp eq i32 %14, 0 + br i1 %15, label %18, label %16 + +;