Batch Windows DLSS GPU inputs and add deferred kernel diagnostics

This commit is contained in:
xdfnx-dev committed 2026-10-02 12:06:15 +03:00
1 parent 4f3b3a9fe6
commit 973eb5ecd2
15 files changed
+692 -37

No files matched your search

+86 -1
View File
@@ -4,7 +4,7 @@ Hardware: RX 9070 XT / gfx1201, Windows 11, display driver 32.0.31041.1004.
Runtime: TheRock 10.2.0a20260929, HIP 7.17.26386; ZLUDA b0161a4 with
`D4R_ZLUDA_WMMA=1`, FP8 widening, native FP8 disabled, f16 reference rounding.
The optional profiler uses HIP events on the actual launch stream, including
The original serializing profiler uses HIP events on the actual launch stream, including
separate measurements of one-time weight preparation. It synchronizes each
sampled launch and changes scheduling: these numbers are not application FPS.
HIP occupancy predictions are not measured hardware occupancy. The native
@@ -192,6 +192,91 @@ without backend errors; ordinary recording intervals later return to about
16 ms. A stable foreground-scene capture is needed before optimizing from
the ETW metrics. Raw files: `test-results/silent-hill2-k-presentmon-4k`.
The following 30-second capture starts after the user confirms the same
foreground scene is ready. All 1902 presents use Hardware Independent Flip
and SyncInterval 0; input/output resolution remains 2259x1271 -> 3840x2160.
The mean present interval is 15.730 ms (**63.574 FPS**). PresentMon estimates
mean GPU busy/wait at 14.504/1.110 ms, GPU time at 15.614 ms and CPU wait at
0.052 ms. These frame-attributed metrics do not equal a hardware utilization
sensor and do not establish a physical CPU limit. FSR4 has not been captured
in this same scene, so its previously reported 80+ FPS remains a user reading.
Raw files: `test-results/silent-hill2-k-steady-profile-4k`.
The containing ten-minute diagnostic completes 36591 K frames, with zero
backend failures, CPU image copies, previous-frame outputs or recorded game
crashes. It deliberately stops at its time bound. Output scans and serializing
kernel events are off. Whole-run median boundary timestamps measure input
copies 0.063 ms, external span 5.399 ms and output copies 0.212 ms. The external
span includes HIP execution and host/driver scheduling, not only transformer
arithmetic. These medians cover the whole run; the PresentMon numbers above
come from the explicitly selected 30-second scene.
### Deferred kernel events and batched inputs
The new optional `-ProfileKernelsDeferred` samples every seventeenth launch
by default (`-KernelProfileEvery`). Its thread-local pool is bounded to 64
event pairs. It queries ready events before selected launches and after the
application's existing context synchronization, reusing a pair only after
reading its old timestamps. It adds no explicit event/stream/device completion
wait; timestamps, queries and logging still add overhead. Stream capture and
legacy default-stream launches are skipped by default. `-ProfileLegacyStream`
allows the latter explicitly, retaining their legacy cross-stream ordering.
This opt-in is necessary to profile this DLSS K binary, whose measured launches
use the legacy default stream. `completion_ms` now denotes collection lag for
deferred records. The report separates serializing/deferred records and retains
invalid timestamps and skipped samples outside kernel timing statistics.
HIP 7.17.26386 reports some negative elapsed times in the tiny queued PTX
diagnostic, including intervals exceeding one microsecond. These are logged as
`D4R_KERNEL_PROFILE_INVALID`; they are not clamped or used as valid GPU samples.
The cause is not established, and nonnegative samples alone cannot prove a
runtime's timestamp accuracy. The diagnostic verifies all 516 PTX launches
across primary/created contexts and individual/queued submission, checks final
device output and guards, accounts for every collected event and verifies safe
default-stream skipping. Results: `test-results/zluda-deferred-profile-final-ptx`.
The same diagnostic with stable HIP SDK 7.2 also verifies all 516 outputs and
reproduces negative intervals (`test-results/zluda-deferred-profile-stable-ptx`).
A native K dec4 sample is negative too; this is not confined to tiny PTX kernels.
Do not infer hardware/kernel utilization or a speedup from these event samples.
HIP event semantics: [AMD event management](https://rocm.docs.amd.com/projects/HIP/en/latest/reference/hip_runtime_api/modules/event_management.html).
The opt-in `-BatchInputCopies` (`D4R_BATCH_INPUT_COPIES=1`) enqueues native
pixel decoding and device-to-array input copies on the shared HIP/ZLUDA legacy
default stream. One all-stream completion remains before NGX can use any input
on its own streams. The independent D3D12 input-fence check, NGX completion and
same-frame output dependency remain. Output transfers retain their existing
completion. Every image stays in VRAM. The ZLUDA implementation adds
`cuMemcpy2DAsync_v2` using `hipMemcpyParam2DAsync`; format-80 array emulation
is explicitly rejected because its synchronous implementation uses temporary
host storage. The Windows path supplies canonical FP16/FP32 arrays instead.
This experiment is disabled by default until the correctness and game timing
gates below pass; there is no claimed FPS improvement yet.
```powershell
.\scripts\windows\test-deferred-kernel-profile.ps1
.\scripts\windows\test-async-k.ps1 -BatchInputCopies -ProfileGpuBoundary -ZludaRoot "$PWD\dist\zluda-windows-deferred-profile"
```
The rebuilt Windows shim and new ZLUDA pass all seventeen CTest gates,
including the added asynchronous pitched FP16/FP32 array-copy test and
padding checks. Completed boundary timestamps are also read before reuse if
the copy fence advances between the first completion scan and slot selection;
this prevents diagnostic records being overwritten without adding a wait.
The depth/stencil and packed-format burst/recreation gates pass 24 full K/4K
frames. All twelve candidate RGB outputs match fresh unbatched synchronous
controls exactly, with finite RGBA. The former also enables deferred legacy
events; invalid timestamps remain separate. These short correctness fixtures
include initialization and do not establish steady-state FPS or a copy-stage
speedup. Raw results: `test-results/k-batch-deferred-4k` and
`test-results/k-batch-packed-4k`. ZLUDA candidate source is `67127dd`, isolated
in `dist/zluda-windows-deferred-profile`; patches 0016/0017 and all preceding
patches apply to the clean pinned base. The public prerelease is unchanged.
After committing/rebuilding ZLUDA with a clean worktree, the twelve-frame
four-way K/4K gate passes again with exact candidate RGB and finite RGBA
(`test-results/k-batch-committed-source-4k`). This warms the committed runtime's
JIT cache before the game comparison.
Further game coverage (HIP kernel profiling disabled, GPU output checks enabled):
M at 1920x1080 completes 4833 frames, all finite. K at 3840x2160 completes
4685 frames, all finite. Neither has a backend failure, CPU image copy or an
+41 -7
View File
@@ -2,11 +2,13 @@
Branch: `windows-rdna4`. Target: Windows 11 x64, RX 9070 XT, **gfx1201**.
Priority: correct K, correct M, native Windows, same-frame output, then speed.
Upstream integration: [draft PR #11](https://github.com/countervolts/d4r/pull/11)
targets `countervolts/d4r:windows` from `xdfnx-dev/d4r:upstream-windows`.
Upstream integration: [PR #11](https://github.com/countervolts/d4r/pull/11)
is merged into `countervolts/d4r:windows` at `c522101`.
The integration branch retains upstream's README with a Windows status section;
the fork's `main` keeps the dedicated English Windows README. The PR is open,
mergeable and allows maintainer edits. K performance remains a separate open gate.
the fork's `main` keeps the dedicated English Windows README. The maintainer
invitation is accepted; GitHub confirms `xdfnx-dev` has push access and the
Windows branch is unprotected. Further validated Windows changes can go there
directly. K performance remains a separate open gate.
This file records current results followed by the dated development history. Standalone DLSS K/M
works on the real Windows GPU, including the patched OptiScaler frontend.
Silent Hill 2 now renders through the Windows backend; gameplay and output
@@ -15,8 +17,9 @@ explicit limits; the validated package keeps conservative arithmetic.
## Milestone and gates
**Current milestone: K performance remains open.** The user reports 49–51 FPS
and about 53% GPU utilization in 4K Silent Hill 2, compared with roughly 80+
**Current milestone: K performance remains open.** Async submission improves
the user's 4K Silent Hill 2 reading to 62 FPS / 63% GPU utilization. A subsequent
controlled 30-second foreground-scene capture records 63.574 FPS, compared with roughly 80+
FPS / 100% GPU utilization with FSR4 on this system. Functional K/M and the
reproducible archive do not close this gate. Prioritize K queue scheduling and
host synchronization; postpone further M/FP8 optimization. These user readings
@@ -82,7 +85,38 @@ measures median input/output copies at 0.061/0.208 ms and external span at
as HIP. PresentMon 2.6.0 capture/report tooling is added; its first trace
contains changing presentation modes and is not a controlled capture of
the user's 62 FPS scene. See `windows-performance.md` for exact metrics and
the stable foreground-scene gate that remains open.
the initial capture limitations. A subsequent user-confirmed foreground-scene
capture completes 1902 presents at 63.574 FPS, all Independent Flip / SyncInterval
0. PresentMon mean GPU busy/wait is 14.504/1.110 ms; this is not sensor
utilization. The containing ten-minute run completes 36591 K frames without
backend errors; median external span is 5.399 ms. Log bundle:
`test-results/silent-hill2-k-steady-profile-4k`.
The next candidate adds bounded, deferred HIP-event sampling and opt-in batched
GPU input conversion/array copies. It retains one all-stream input completion
before NGX and every D3D12/output dependency. All seventeen CTest gates pass,
including asynchronous pitched FP16/FP32 array copies and guard checks.
The deferred profiler's tiny PTX diagnostic verifies 516 launches and safe
default-stream skipping; negative HIP elapsed times are retained as invalid
samples, with cause unresolved. This DLSS K binary uses the legacy default
stream, which needs explicit opt-in for timestamp sampling. The depth/stencil
and packed-format burst/recreation gates pass 24 full K/4K frames: all twelve
candidate RGB images match their fresh unbatched synchronous controls exactly,
with finite RGBA. Results: `test-results/k-batch-deferred-4k` and
`test-results/k-batch-packed-4k`. The game performance gate is pending. The candidate remains
disabled by default; see `windows-performance.md` for semantics and commands.
Current candidate source is ZLUDA `67127dde599879ada022d6439383d682e09e0b36`
in `dist/zluda-windows-deferred-profile`, containing patches 0016/0017.
All sixteen patches (0002 through 0017) apply to clean pinned base `ee2f25a`.
The committed ZLUDA is rebuilt with a clean worktree and the four-way K/4K
gate is repeated: twelve frames pass, all six candidate RGB outputs match
their controls exactly, and all six async boundary timestamp records survive
slot reuse/release. Results: `test-results/k-batch-committed-source-4k`.
The same negative HIP event-timing issue reproduces with stable SDK 7.2 as
well as TheRock; PTX output/guards remain correct. It also affects a native K
dec4 timing sample, so valid-looking events alone are not a timing-accuracy
gate. No hardware utilization or kernel speedup is inferred from these samples.
The public prerelease `windows-rdna4-dev-20261002-a346d76` is published to
`xdfnx-dev/d4r`, containing source commit `a346d76` and ZLUDA `a1c506f`.