Repository navigation
Model K on D3D12: the exact tiled input stage, byte-identical to HIP - #208
Merged
Merged
Conversation
…dentical to HIP Refs #15. Port of kx/k_in_tiled (KInParams; the exact path: correctly rounded log2, 2^x, divisions and reciprocals, FP16 rounding to nearest even; binary64 fma and division from the D3D12 extended doubles, marked fp64=ext so an adapter without them gets no port). Shared headers k_fp.hlsli and k_frame.hlsli; the FP constants and tables are generated at every build by gen_k_fp_tables.py (nothing stored). The forms with KiHost arguments and the forms reading the game's textures are in the source but not declared yet. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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.
Refs #15. Stacked on #206 (the wide stages) and #207 (the visual fixes, merged into this branch): until those are merged the diff here includes theirs.
Preset K's exact tiled input stage on D3D12, byte-identical to its HIP kernel
k_in_tiledofk_io_exact.co. This stage is what #207's motion and alpha behaviour is defined against.What changes
clean/k/dx12/kernels/k_in.hlsl:kx/k_in_tiled(the tagkxis the exact input code object, as in the runtime). One workgroup of 256 lanes per 8 x 8 base positions,KInParamsby value (s200:p4.b128.p5). Exactly HIP's operations in its order:log2and2^xcorrectly rounded (with the binary64 fallback), every division and reciprocal correctly rounded, FP16 rounding to nearest even (never the driver's round-toward-zero), the cases of a reset frame, the exposure scalars from the device buffer.hlsl/k_fp.hlsli,hlsl/k_frame.hlsli: the scalar FP32 / FP16 / binary64 helpers and the frame-input fetch helpers shared with the output stage. Where the D3D12 compiler could merge two of HIP's roundings (a product by a uniform feeding an add, a regrouped constant chain) the product goes through an opaque XOR barrier (kf_opq).gen_k_fp_tables.py: computes the helpers' constants and tables as bit patterns from their binary64 series;build_dx12.pyruns it at every K build into<out>/dx12/gen(nothing is stored).fp64: ext(Model K on D3D12: --model-k, struct arguments, the port check, k_expo_scalars and k_warm #201) and an adapter withoutDoublePrecisionFloatShaderOpsgets no port.KiHostin the arguments (k_in_tiled_uniform) and the forms that read the game's textures (_direct). They are in the sources for the runtime's use and are declared and checked with the runtime wiring.kernel_sets.json:kx/k_in_tiled.k_port_check.py: theinputfamily.Tested
k_port_check.py --run --family expo,warm,narrow,wide,input --seeds 3, one GPU slot (all families of the stack in one run):input: 48 of 48 cases raw-byte identical to HIP (16 flag sets: HDR, low-resolution motion, inverted depth, reset; base grids 1 x 1, 7 x 9, 8 x 8, 9 x 7, 33 x 17; the exposure scalars from a device buffer, the host values wrong on purpose; 18 cases with infinity, huge values, zero and -0 in the colour, depth, motion and histories, 12 more with NaN as well; none differs, not even in a NaN's sign). Every slack byte kept its sentinel (HIP0xA5, D3D120x5A). Negative control (half grid) caught, 5408 bytes differ.scale_rgb) identical; replay exit 0.pr5-input.json(counts and verdicts only).test_kernel_sets,test_k_plan_bridgepass; line endings clean.public_gates.py: must-pass gates pass, LOOK counts equal main's.Not tested
k_in_tiled_uniformand the_directforms (next PRs).Accepted exceptions (review decision, 2026-11-14)