GPU: a least amount of indirect light while rays do not run (VICTORY_AMBIENT, off by default) #1093
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1093
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1093"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@m335671 on GitHub · 2026-11-25 19:16 UTC · original
m335671:port/ambient→main· +467 −0 · 4 files · 3 commits · openWhat
The title's indirect diffuse light comes from probes that it fills by tracing rays. Those don't run here yet, so whatever the sun doesn't reach directly comes out black: in the first room, the whole half away from the window. This adds an opt-in stand-in for that light, ported from Belobug/VIctory-Belobug-AMD (GPL-3.0,
ambient.rs):CS_ScreenProbes_TemporalResolve*, found by name in the container), a small compute pass of the layer's own replaces that program's output (R9G9B9E5 as 32-bit integers) with a constant level.bindto set again (host_pipeline,host_roots,host_heapscleared, as after the clamp passes).Off by default.
VICTORY_AMBIENT=<level>turns it on; 0.6 looked balanced here.VICTORY_AMBIENT_TINT=r,g,bsets the colour andVICTORY_AMBIENT_SHADEthe depth shading, both as in the original. It's a stopgap: once the probes are filled by real rays, it should stay off.Changes
crates/victory-gpu/src/ambient.rs(new): the pass, compiled withD3DCompile(theFxcfeature is already enabled), and a unit test that builds it on the host.pipeline.rs:Shader::resolves_light, set when the container names the resolve program.draw.rs: after a compute dispatch,ambient()finds the light UAV and depth SRV in the program's tables and records the pass.lib.rs: the module.Testing
RTX 4070 12 GB (32-lane waves), driver 32.0.16.2124, Ryzen 9 7900, 32 GB, Windows 11 Pro 26300, Series X profile. Diagnostics build, prewarmed cache, from the checkpoint to the first room, then idle.
VICTORY_INDIRECT_WINDOW=1 VICTORY_LEVELS_ON_DEMAND=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_COPY_PLAIN=1 VICTORY_LATE_WAIT=3 VICTORY_CAPTURE_WORLD_EVERY=64. Means once the frame rate had settled.3973179, off3973179,VICTORY_AMBIENT=0.6d510ee4,VICTORY_AMBIENT=0.6d510ee4,VICTORY_AMBIENT=0.6+VICTORY_INDIRECT_GATHER=1 VICTORY_CARD_REHASH_RUNS=1cargo test -p victory-gpu: 193 passed, 0 failed, includingambient::tests::ambient_pass_buildson the 4070.Not tested: other scenes and hours of the day (the original notes that one level doesn't suit every hour), AMD and Intel cards, release builds.
Credit: the pass and its tuning are Belobug's work; this PR only wires it into this tree.
AI use: Claude Code (Claude Opus 5.5) ported the code, ran the tests on my machine and wrote this description.
🤖 Generated with Claude Code
@deadkid14 on GitHub · 2026-11-25 19:36 UTC · original
Tested on Linux/Proton (RTX 5070 Ti, driver 620.73.04, GE-Proton11-14, main
d510ee4plus our Linux patches). It works well, but under Wine the pass needs one change to start at all.Without the change:
WARN victory_gpu::ambient: no ambient light error=Call failed. (0x80004005). Wine's builtinD3DCompileaccepts the source, but the bytecode it returns has no root signature from the[RootSignature(RS)]attribute, soCreateRootSignature(0, code)fails.With the change: compile with DXC first, the same fallback used for the indirect clamp on Wine (#20). The pass then runs (
ambient light level=0.6 width=2560 height=1440):This replaces the
D3DCompileblock inmake(and drops its two imports). It assumes thedxc_compile_forhelper from #20. Without #20, routing throughcrate::host::compilewith a DXC fallback there would do the same.Result with
VICTORY_AMBIENT=0.6, in the first room:AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.
@m335671 on GitHub · 2026-11-25 20:04 UTC · original
Thanks, that's very useful, especially the square blocks on characters going away and the face being lit. I hadn't been able to check either here.
On Wine:
maindoesn't havedxc_compile_foryet (it comes with #20), so I've taken your second option. The pass now compiles throughcrate::host::compile, the helper the indirect clamp uses, instead of its ownD3DCompileblock (41cf630, 32 lines out). If the DXC fallback goes into that helper (with #20 or after it), it covers this pass with no further change; until then, under Wine this pass still fails to start, as you found.ambient::tests::ambient_pass_buildsstill passes on the RTX 4070 (Windows,D3DCompile).AI use: Claude Code (Claude Opus 5.5) made the change, ran the test on my machine and wrote this reply.
@deadkid14 on GitHub · 2026-11-25 20:11 UTC · original
Thanks for taking it. A correction to my "second option": routing through
crate::host::compileis not enough under Wine, even once that helper has the DXC fallback from #20. I tried that first, and it is what failed with0x80004005here.The helper falls back to DXC only when
D3DCompilereturns an error. For this source, Wine'sD3DCompilereturns success. It just leaves out the root signature from[RootSignature(RS)]. So the fallback never runs, and the error only appears later, atCreateRootSignature(0, &code).Two ways that would work:
make: ifCreateRootSignature(or the pipeline) fails onD3DCompile's bytecode, compile again with DXC and retry. Windows behaviour is unchanged.dxc_compile_for).Without either, the pass stays off under Wine.
AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.
@m335671 on GitHub · 2026-11-25 21:14 UTC · original
You're right, thanks for the correction: the fallback only runs on an error, and here there isn't one.
A third way, which needs neither DXC nor #20: the pass no longer takes its root signature from the compiled shader. It builds the same one (8 root constants at
b0, then a table ofu0andt0) withD3D12SerializeRootSignatureand passes it toCreateRootSignatureand the pipeline (790a0a4). The[RootSignature]attribute stays in the source, so the bytecode matches it where the compiler does embed it. vkd3d implementsD3D12SerializeRootSignature, so I expect it to work under Wine, but I can't test that here. Would you mind checking it with plainD3DCompile?On Windows (RTX 4070),
ambient::tests::ambient_pass_buildsstill passes, which means the driver takes the serialized signature together with the pipeline.AI use: Claude Code (Claude Opus 5.5) made the change, ran the test on my machine and wrote this reply.
@deadkid14 on GitHub · 2026-11-26 02:17 UTC · original
Confirmed:
790a0a4works under Wine with plainD3DCompile.The tree is the same as before, with this PR's current
ambient.rs(41cf630+790a0a4) in place of my local DXC patch. WithVICTORY_AMBIENT=0.6the pass starts:ambient light level=0.6 width=2560 height=1440, with no "no ambient light" warning. The log's compiler fallbacks are only the usual two of ours (the card compare and the argument clamp,RWByteAddressBuffermethods Wine refuses), none for this pass, so Wine's own compiler built it and the serialized root signature was accepted. No Xid.So the PR as it stands works on Linux/Proton without #20. I've dropped my local patch in favour of it.
AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.
@deadkid14 on GitHub · 2026-11-26 02:28 UTC · original
One more observation with the pass on (same tree,
VICTORY_AMBIENT=0.6; checked with both Wine's compiler and DXC, same result):So the probe resolve this pass replaces accounts for the blocks in shadow, but something else still writes them where surfaces face the light. Possibly the specular or reflection side of the probes, which the pass leaves alone. I haven't identified the program. Just a data point in case the pass could cover a second output.
AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.
@m335671 on GitHub · 2026-11-26 07:39 UTC · original
On the blocks toward the window: I think they come from a missing shadow program, not from the probes. On the RTX 4070 they follow one compute program,
f133e35efed2a48a(CS_ShadowRenderTiledCascadesAlphaCBPPPC, the tiled cascaded shadows).Without #799, it fails to translate here with
GFX10 code at 0x1eb4: a lane mask exchanged where not every lane runs is not supported, and its draws are dropped. That error isn't about wave width, so I'd expect the same on RADV. The message is still inmain'slower.rsat46bf535.Same view (the player in front of the window, this PR at
VICTORY_AMBIENT=0.6), one run per row:f133e35efed2a48ad510ee4+ this PR (two runs, one with #1096)d510ee4+ this PR + #1096 + #646, builder on, ambient off9c184b3+ this PR + #1096 + #215 + #799 withVICTORY_WAVE_LDS_LOOSE=0(two runs)VICTORY_SKIP_PIPELINES=f133e35efed2a48aSo in our runs, the blocks are where lit surfaces miss their shadow tiles. #799 brings this program up without its loose-LDS fallback (I posted that on #799 yesterday). If your log shows
f133e35efed2a48aunderdoes not translate, it's probably the same here.Caveat: one run per configuration, and others on #799 have seen lighting vary from run to run. Still, the blocks were present every time this program was missing and absent every time it ran.
AI use: the runs were done on my machine. Claude Code (Claude Opus 5.5) ran them, compared the captures and logs and wrote this reply.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.