Repository navigation
Export: convert H.264 frames to YUV 4:2:0 on the GPU - #1631
Open
MatejKozlovsky wants to merge 1 commit into
Open
MatejKozlovsky wants to merge 1 commit into
MatejKozlovsky wants to merge 1 commit into
Conversation
Accelerator::comp_frame_yuv420 (default None) renders a top-level comp frame and converts it over the background to the H.264 export's 8-bit BT.709 limited-range 4:2:0, every byte within one level of the CPU conversion (the GPU kernel follows it operation for operation, including NaN and half-away-from-zero ties, but a driver may contract its arithmetic). A 4K frame then reads back 12 MB of planes instead of 133 MB of RGBA f32. The H.264 export asks the accelerator for planes when a frame needs nothing after the render (progressive, project depth, no crop/resize, rendered at the output size) and otherwise renders and converts on the CPU as before. Deferred readbacks (a browser worker) keep the pass-based path. Sizes the kernel can't take (width not a multiple of 8, odd height) are declined before any GPU work. rgba_to_yuv420 moves to effectcraft_raster::yuv so the export and the GPU tests share one reference. The GPU tests are #[ignore]d and fail without an adapter instead of passing untested.
This was referenced Oct 16, 2026
|
Tested on AMD: RX 6900 XT, Windows 11, Adrenalin 32.0.21045.5002, Vulkan, All 6
Odd sizes fall back to the CPU, and unsupported sizes are declined as expected. Whole Generated with Claude Code |
This branch has not been deployed
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.
YUV part of #898, split out.
With the GPU on, H.264 export reads every frame back as RGBA f32 and converts to 4:2:0 on the CPU. At 4K that's ~133 MB per frame back for ~12 MB of planes. This does the conversion in a small compute kernel and reads back only the planes.
Accelerator::comp_frame_yuv420, defaults toNone. The GPU compositor implements it.None, it's the old RGBA path. Deferred readbacks (browser worker) keep their path. Sizes the kernel can't do (width not a multiple of 8, odd height) are rejected before rendering.rgba_to_yuv420moved from export toeffectcraft_raster::yuvso export and the GPU tests share it.GPU output is within one level of the CPU conversion. llvmpipe matches exactly; on an RTX 3090 (Vulkan) ~0.25% of bytes come out one level off, probably FMA contraction / divide precision in the driver. Tests require exact on software adapters and allow ±1 on a small fraction elsewhere.
Tests:
yuv420_matches_cpu(noise, NaN/inf, out-of-range, a few sizes)rounding_ties_match_cpu(every Y tie, plus U/V ties)comp_frame_yuv420_is_the_cpu_conversion_of_comp_frame,odd_sized_comps_fall_back_to_the_cpu,unsupported_sizes_are_not_convertedexport/tests/h264_gpu_yuv.rs(fake accelerator, checks the wiring, fallback and deferred path)GPU tests follow the crate's usual
tests::gpu()pattern and skip without an adapter.Tested on llvmpipe and an RTX 3090 (Vulkan). DX12 on that card fails to create the context on main already (
classic3d: Validation Error), separate issue. fmt/clippy clean; only the two known main failures (tests_fx_pixel2::stylize,tests_fx_stylize::posterize_thresholds_strobe_vignette).Async version is #1632, on top of this.