Repository navigation
Model K (HIP): exposure rule on the GPU, exact input stage by default, no reset on a size change - #198
Merged
Conversation
…ge by default, no history reset on a render-size change Refs #15. k_expo_scalars takes the game's exposure (value, texel, or none) as E_cur and the auto-exposure value as E_aux, keeps the previous frame's E_cur for E_prev, and writes the raw values for the buffers exposure.pair and exposure.measured. The runtime applies the rule, runs auto-exposure beside a game texture, and resets history only on the game's flag and the first frame. The input stage is the exact one (k_io_exact.co, embedded in the runtime library) unless k_fast_in=1, k_in_exact=0 or k_fast=1 is named. KFrame and reference_frame take the same rule and reset behaviour. k_expo_rule=v051 restores the old rule for A/B. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
This was referenced Nov 14, 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.
Refs #15. Stacked on #194 (the diff here is against that branch; once #194 is merged it is against main).
Second piece of bringing Preset K back: the HIP side of the exposure rule, the exact input stage as the default, and no history reset on a render-size change. All of it was already written for the private line; this is the part that the D3D12 ports and the visual fixes build on.
What changes
k_io.hipk_expo_scalars: now(st, src, measured, xs, KExpoArgs). [HDR]E_curis the front end's value, the game's exposure texel, or 1 when the game gives none;E_auxis the measured auto-exposure value when it ran, elseE_cur;E_previs the previous frame'sE_cur(E_curon the first frame and on a reset). [LDR] everything is 1. The raw values go to a 4-float state; the scalars then use the same FP32 operations ask_io.py.KExpoArgsis{value; src_mode, aux, first, hdr, reset; e1, e2, inv_pi}(36 bytes).runtime_k.cpp/.h:k_io_exact.co(tagkx) unlessk_fast_in=1,k_in_exact=0ork_fast=1is named;k_in_exact=1with either fast option is refused;exposure.pair([E_cur, E_prev, E_aux], raw) andexposure.measured;k_expo_rule=v051restores the old rule for A/B only.runner/build.py:k_io_exact.cois built into a K-enabled runtime library.k_frame.py,k_io.py:KFrameandreference_frameapply the rule (game_exposure,measured,exposure_scale) and the new reset behaviour;KExpoArgshas the new fields.test_k_exposure_rule.pygainsreference_frametests with recorder stages (CPU);test_k_frame_emu.py(needs the Linux lane emulator, skipped on Windows) andtest_k_runtime_gpu.py(GPU) follow the new behaviour; the GPU test adds the exposure-source and reset cases and the exact/fast input checks.FORMATS.md,README.mdfor the new kernel signature, options and reset rule.No approximation is added: the exact input stage becomes the default, and the opt-in options that already existed keep their meaning.
Tested
python -m unittest clean.k.tests.test_k_exposure_rule: 7 tests pass.python -m unittest -v clean.k.tests.test_k_runtime_gpu: 20 tests pass (HDR and LDR, value / texel / auto-exposure sources, texel with auto-exposure, pre-exposure, raw inputs,k_head=full,reset=2,k_fast_in=1,network=fused16,k_expo_rule=v051). The runtime's frames equalKFrame's bit for bit.public_gates.py: must-pass gates pass; LOOK counts equal main's.Not tested
test_k_frame_emu.py(skipped without the Linux lane emulator).