Repository navigation
Conversation
… GPU context GpuContext::new built every compute pipeline up front: the compositor's own kernels and ~208 effect kernels. In Chrome on Windows that kept the GPU process busy past its watchdog, so the device was lost ~60 s after every load (storytold#1590); on DirectX 12 with FXC the window took over a minute to appear (storytold#613). The compositor's kernels are still built up front and required. Effect kernels are built the first time a dispatch asks for one, inside the same error scopes, so one a compiler rejects still renders its effects on the CPU. unavailable_kernels lists the failures so far; build_all_kernels builds the rest. RX 6900 XT, Windows: Vulkan context 0.27 s, all effect kernels 0.9 s, GPU tests 77 s -> 26 s; on storytold#1571's DX12/FXC, context ~66 s -> 1.96 s, tests 1306 s -> 252 s, same results. Co-Authored-By: Claude <noreply@anthropic.com>
Building effect kernels on first use was not enough in Chrome: the page and its frame workers each create a device, every one compiled its required kernels against the single ~460K-character module, and Dawn compiles the module again for each pipeline, so the GPU process still passed its watchdog and the device was lost ~64 s after load (RX 6900 XT, Chrome 155). Each kernel family (FAMILIES) is now common.wgsl + kernels.wgsl + its own file and the files it borrows functions from (at most ~120K characters), built with the family's first kernel; the compositor's kernels, sky and classic3d use small modules of their own. Chrome 155 on Windows / RX 6900 XT, release web build, default flags: main loses the device at ~64 s (60.7 s with ?nogpuworkers); with this, two 100 s runs keep it, and both frame workers get the GPU. Native Vulkan tests unchanged (212 passed, the 3 failures that main has, storytold#1605). Co-Authored-By: Claude <noreply@anthropic.com>
|
Follow-up check in Chrome with real work after load, not just an idle page. Windows 11, RX 6900 XT, Chrome 155.0.8059.80, release
Earlier runs (2026-10-16): So with this PR the page device and both frame workers stay on the GPU while effects render. Generated with Claude Code |
|
Native results on NVIDIA, as a second vendor next to your RX 6900 XT: RTX 4070 Laptop (Ada, driver 596.21), Windows 11, head
Not tested: DX12 (it needs #1571, which touches 🤖 Generated with Claude Code |
|
@ded-achtung thanks for the RTX 4070 run. That gives the first-use build a second vendor (215/215 on Vulkan). A note for whoever merges #1571 and this PR: they conflict in https://github.com/00xJS/effectcraft/tree/gpu/lazy-effect-kernels-on-1571 (one merge commit,
On the RX 6900 XT: the Vulkan suite passes apart from the three #1605 / #1776 failures that If #1571 lands first, I'm happy to rebase this PR onto it so it's a normal fast-forward-able branch. Generated with Claude Code |
Problem
GpuContext::newcompiled one ~460K-character WGSL module and built every compute pipeline from it up front: ~20 compositor kernels and ~208 effect kernels. On the web, the page and its frame workers each create a device and do this. Dawn compiles the module again for each pipeline, so Chrome's GPU process stays busy past its watchdog and the device is lost about 60 s after every load (#1590). On desktop DX12 with FXC, the same up-front build keeps the window from appearing for about a minute (#613).Change (
crates/gpu/src/context.rs)ENTRIES, sky,EXT_ENTRIES) are still built with the context and still required. Effect kernels sit ineffect_pipelines(OnceLock<Result<ComputePipeline, String>>) and are built the first timeEnc::dispatch_extasks for one, inside the sameinit_resourceerror scopes, so a kernel a compiler rejects still renders its effects on the CPU (Enc::take_missing).unavailable_kernels()lists the failures so far, andbuild_all_kernels()builds the rest.FAMILIESentry iscommon.wgsl+kernels.wgsl+ its own file, plus the files it borrows functions from (fx_color→fx_lut, fx_key→fx_distort, fx_extra→fx_generate, fx_pixel2→fx_stylize, fx_particles→fx_stylize+fx_sim). That's at most ~120K characters, built with the family's first kernel. The compositor's kernels, sky and classic3d each get a small module (52–67K).New test
effect_kernels_build_on_first_use: no effect kernel is built with the context, and once asked for, every one builds on the device, so a kernel no test dispatches still can't break without anyone noticing.effects_whose_kernels_failed_render_on_the_cpunow expects a sorted list.Results (Windows 11, AMD Radeon RX 6900 XT, Adrenalin 32.0.21045.5002)
Chrome 155.0.8059.80, release web build (
cargo xtask web), served on 127.0.0.1 with COOP/COEP, fresh profile every run, 100 s each, page pinged every 2 s over the DevTools protocol:main8f02f52main,?nogpuworkers?nogpuworkersframe worker 0/1: GPU (BrowserWebGpu)at ~30 s)So first-use builds alone fix the page's own device, but the frame workers' devices still overran the watchdog until the module was split.
Native (
cargo test -p effectcraft-gpu --lib --release,EFFECTCRAFT_REQUIRE_GPU=1):mainThe 3 Vulkan failures (
posterize,ccgridwipe,cchextile) fail identically onmain(#1605). On currentmain, DX12 can't start without #1571 (FXC rejectsclassic3d), so the DX12 rows are measured on top of #1571. The split module isn't in those rows; it should only make FXC faster, since each pipeline compiles less HLSL.Trade-off
The first frame that uses an effect family pays for compiling its module and kernel: a few ms per kernel on Vulkan with a warm cache, and about 300 ms per kernel on FXC. A host that would rather pay up front can call
build_all_kernels()off the first frame.Notes
GpuContext::new(GPU: effect kernels build and match the CPU on DirectX 12 (#613) #1571 makesclassic3doptional). A resolved variant of the first-use part on top of GPU: effect kernels build and match the CPU on DirectX 12 (#613) #1571 is on branchgpu/lazy-on-1571, whereclassic3dis also built on first use with the extended layout andhas_kernelbuilds on demand.cargo fmt --check,cargo xtask layers,cargo xtask assets,cargo xtask wasm,cargo clippy -p effectcraft-gpu -p effectcraft-ui-egui -p effectcraft-cli --all-targets --release -- -D warnings, andcargo test -p effectcraft-gpu --lib --releaseon Vulkan. I didn't finish the fullcargo test --workspace --releaseon this 6-core machine. Onlycrates/gpu/src/context.rsand its tests change, and the publicunavailable_kernels()now returns aVec(its only callers are the crate's tests).🤖 Generated with Claude Code