Repository navigation
Model K direct route: allocate the legacy input stage's intermediates; never pack a null one - #264
Merged
Merged
Conversation
… (cpre, cpre2); never pack a null one A native direct context skipped cpre (R*16) and cpre2 (R*8), but a frame on the legacy input path (a render size above 0.68 x the output, such as DLAA; a jitter outside [-0.5, 0.5]; input_tiled=0) runs kx/k_in_color_direct, then kx/k_in_reset or kx/k_in_base_direct, which write and read them. The null pointers were packed as arena offset 0 (clean/runtime/struct_args.h), so the frame overwrote the start of the arena and read it back: the output differed from the exact reference on every such frame, and the overwritten allocation was corrupted. - runtime_k.cpp: cpre / cpre2 are allocated for every context (+R*24 bytes of arena for a direct context, as the buffer route already has). Create refuses when a buffer an input-stage kernel can be handed is not allocated. A legacy input kernel is never launched with a null cpre / cpre2 (one line, the frame refused). - test_k_direct_legacy.py (new, GPU): test_interop_d3d12.exe dx12same, executor=hip (exact reference) against the native direct route, 6 frames with resets: DLAA, a jitter outside the guard, input_tiled=0, and the tiled control, every output byte identical. - test_interop_d3d12.cpp: dx12same WG_TEST_JITTER_OUT=1 (a jitter outside [-0.5, 0.5] on every frame; this test program only). check_no_dev_diagnostics.py refuses a runtime library, payload or package file that names it (test_dev_diagnostics_off.py). Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On main, a Model K context on the native direct route did not allocate the legacy input stage's intermediates
cpre(R×16 bytes) andcpre2(R×8), where R is the declared maximum render size in pixels. A frame on the legacy input path still runskx/k_in_color_direct, thenkx/k_in_resetorkx/k_in_base_direct, which write and read them. The legacy path covers a render size above 0.68 × the output (DLAA), a jitter outside [-0.5, 0.5], andinput_tiled=0. The null pointers were packed as arena offset 0 (clean/runtime/struct_args.h), so the frame overwrote the start of the arena and read it back.clean/k/runtime/runtime_k.cppcpre/cpre2are allocated for every context. A direct context needs R×24 more bytes of arena, the same as the buffer route already has (about 199 MB at a 4K DLAA declared maximum).cpre/cpre2: the frame is refused with one line instead.clean/k/tests/test_k_direct_legacy.py(new, GPU):test_interop_d3d12.exe dx12sameruns the same 6 frames (resets at 1 and 5) throughexecutor=hip(the exact reference, buffer route) and the native direct route ("inputs read directly 1"). Every output byte must be identical. Cases: DLAA, a jitter outside the guard,input_tiled=0, and the tiled Quality control.clean/runtime/interop/tests/test_interop_d3d12.cpp:dx12sametakesWG_TEST_JITTER_OUT=1, a jitter of (0.75, -0.8) on every frame. It exists in this test program only.clean/tests/check_no_dev_diagnostics.pyrefuses a runtime library, payload or package file that names it (clean/tests/test_dev_diagnostics_off.py).A refusal of every null struct pointer in
struct_args.his not part of this change. Model K passes null on purpose for buffers a kernel does not read (absent block / skip / merged / head stages, and the direct kernels' dense input pointers), so that needs per-field declarations. It is on the 0.6.6 list.Evidence
Developer builds, synthetic model, 1280×720 output (Quality: 853×480 render), 6 frames, resets at frames 1 and 5. The counts are output bytes that differ from the exact reference, out of 7,372,800 per frame.
Main 25429c5 (
test_k_direct_legacy.pyFAILS):input_tiled=0The null pointer reached the launch: a build with only the launch-time check, without the allocation, refuses the first legacy frame of each of the three cases with
model K: kx/k_in_color_direct would get a null cpre / cpre2 (arena offset 0); the frame is refused. The tiled control is unaffected. This stands in for an arena sentinel, which the interop harness cannot reach.With this change (
test_k_direct_legacy.pypasses): DLAA, jitter outside the guard,input_tiled=0and the control are 0 bytes different on all 6 frames.Other runs on the fixed build:
test_interop_d3d12.exe matrixat 1080p and 2160p: 40 direct-route contexts (every usual ratio, HDR / LDR, both declared maximum sizes), 0 refusals, every frame run.test_k_runtime_d3d12.py: 26 / 26 (each test in its own process).Files
clean/k/runtime/runtime_k.cpp,clean/k/tests/test_k_direct_legacy.py(new),clean/runtime/interop/tests/test_interop_d3d12.cpp(test program),clean/tests/check_no_dev_diagnostics.py,clean/tests/test_dev_diagnostics_off.py. No shader, noclean/dx12/build_dx12.py, nothing underclean/dx12/hlsl,clean/dx12/kernelsorclean/rr_f.