Repository navigation
Model K: output alpha follows the colour input's alpha; motion rounding on the raw-buffer routes - #207
Merged
Conversation
…unding on the raw-buffer routes Fixes #26. Output alpha: the colour input's alpha of the frame (spatial only: the fourth channel of the current-colour 2 x 2 bilinear, FP16 steps as the colour taps, no exposure and no clamp) is the output's fourth channel on every K output path: RGBA16F rows, a new dense RGBA f32 result for the interop's output pass (FrameIo.out_rgba32f), and the runtime's own buffer; the interop's input passes keep the colour texel's alpha for model K (model M: +0 in, alpha 1 out, unchanged); a colour format without alpha gives 1. Motion rounding: on the raw-buffer routes (the interop's input copies and its compact input pass, KIO_M16) and on the FP32 input pass, K takes the raw motion texel and folds the scale into its motion factor and RN(offset / scale) into raw units, as the reference and the buffer forms do, instead of a per-texel scale * raw + offset followed by a factor of 1. 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.
Fixes #26. Stacked on #198 (the diff is against that branch; once it is merged, against main).
Both fixes of #26 for Preset K, on the HIP executor and the interop; the D3D12 ports of the input and output stages follow this behaviour (a later PR) and need it to be byte-identical to HIP.
What changes
Output alpha follows the input's alpha, on every K output path.
FrameIo.out_rgba32f, 16 bytes per pixel) carries it to the interop's output pass for model K; the runtime's own output buffer can hold either.wg_rt_upload_inputs_rgbais the test path with an RGBA colour (wg_rt_upload_inputsgives model K alpha 1).Converter::set_model_k); the output pass, the output pass on a result texture and the fallback store the carried alpha. Model M is unchanged in all of them (colour alpha +0 in, alpha 1 out); the HLSL changes are under a flag only model K sets or in a pass only model K runs.Motion rounding on the raw-buffer routes.
KIO_M16) K used to scale every raw motion texel (ms * r + mo, two roundings) and then apply a factor with scale 1; the reference and the buffer forms fold the scale into the factor and the offset (asRN(mo / ms)) into raw units.k_io.hipnow does the latter on the raw texel at both use sites (inputki_fine, outputk_out_pixel).motion_scaleand the raw-unit offset inWgRtFrame, so K folds them the same way. A zero scale keeps the pass's conversion. Model M: unchanged.Files:
k_io.hip,runtime_k.cpp/.h,interop/convert.cpp/.h,backend.cpp,executor.h,executor_hip.cpp,runtime.cpp,runtime_core.h,wg_runtime.h, the twoFORMATS.md, and tests (test_k_alpha.py,test_k_m16_alpha.py,test_k_route3_motion.py,test_k_direct_motion.py,test_k_runtime_gpu.py).Tested
test_k_alpha,test_k_m16_alpha,test_k_route3_motion,test_k_direct_motion: 27 tests pass, 4 skip (the source checks of the D3D12 input and output ports skip while those ports are not in the tree and run once they are). They check: the alpha rule's CPU form against exact rational arithmetic and against the output-stage reference's fourth channel (gradient, random, negative, above-1 and out-of-FP16-range alphas; HDR and LDR; several sizes and jitters; render-rectangle edges); spatial-only (no change with history, network output, motion, exposure, pre-exposure; chained frames take their own colour's alpha); no clamp; the FP32 arithmetic of the old and new motion routes (the new one equals the buffer form on every value, signed zeros, infinities and NaN included, the old one differs for a share of the values); the interop's run-time HLSL (each alpha-carry text present, model M's texts absent) and that all its passes compile withd3dcompiler_47.test_k_runtime_gpu20 of 20: HDR and LDR, the three exposure sources, the raw input-copy route with the scale and offset folded (frame outputs bit for bitKFrame's), RGBA16F rows whose alpha equals the reference's fourth channel (negative and above-1 alphas in the inputs),k_head=full,reset=2,network=fused16,k_fast_in=1.public_gates.pymust-pass gates pass, LOOK counts equal main's.Not tested
test_k_alpha_gpu.pyneeds the D3D12 K ports; it comes with them).