Shaders: pixel programs the console depth-tests before they run declare early depth (glass prepass over characters) #907
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!907
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-907"
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?
@SpaghettiMaster545 on GitHub · 2026-11-25 12:23 UTC · original
SpaghettiMaster545:pr/early-depth→main· +110 −1 · 4 files · 1 commits · openWhat was wrong
A pixel program's DB_SHADER_CONTROL (in its native record) says whether the console runs the depth and stencil tests before the shader: bit 12, DEPTH_BEFORE_SHADER, which the console compiler sets for HLSL
[earlydepthstencil]. The translation never declared it, so the host tested after the shader, and a program that writes unordered views wrote them for pixels the depth test then rejected.How it shows in game
The glass prepass (
PS_AlphaPrepass, DB_SHADER_CONTROL 0x1450) writes the glass's depth and motion to a view. With late tests it wrote them for every pixel of a window pane, including a character standing in front of it, andPS_AlphaVelocityDepthResolvethen copied those over the character's depth and motion vectors. Inside each pane the character lost her depth and motion (rectangles cut out of the depth and velocity targets) and moved with ghosted, staircase-edged smears.What the change does
Pixel programs with DEPTH_BEFORE_SHADER set get
ShaderFlagsForceEarlyDepthStencil (bit 3), unless they export depth, stencil or coverage. 3,023 of the pack's 12,101 pixel programs have the bit (DB_SHADER_CONTROL 0x1050: 1,718, 0x1450: 705, 0x1010: 380, 0x1410: 220).victory shader-infonow prints a pixel program's DB_SHADER_CONTROL, which is how they were counted.How it was tested
a_pixel_program_tested_before_it_runs_declares_early_depth;cargo test --locked -p victory-shader --libpasses on this branch (216 passed, 3 ignored).cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean. (A workspace-wide clippy fails onmainalready, invictory-gpu:placed_filler_twinsunused,sort_unstable_by_key,is_multiple_of; this change does not touch that crate.)Developed with AI assistance (Claude Code).
@avt0m4t48 on GitHub · 2026-11-25 12:31 UTC · original
Independent synthetic check of
6f358fc6againsta2537066. GitHub's test merge has the same tree as the checked head.0x0to0x8. The disassembled instructions, signatures, PSV0 and SFI0 were identical.SV_Depth,SV_DepthLessEqual,SV_DepthGreaterEqual,SV_StencilRefandSV_Coverage, each with bit 12 unset and set. The stencil output retained its existing ShaderFlags0x800and SFI00x200.cargo check --all-targets -p victory-shader -p victory --features blake3/pure. The cross-check emitted the existingplaced_filler_twinswarning invictory-gpu.The color fixture uses the GFX10 words
7e0002f0 7e020287 f800180f 00000000 bf810000and an OSG1 signature with one float4SV_Target. LLVM 19 read a copy of each DXIL module with the legacy i8 alignment spelling adapted for disassembly. Microsoft DXIL validation, native Windows execution, and depth-tested UAV writes on a D3D12 device remain unverified by this check. No game files were used.@iGoldenNinja on GitHub · 2026-11-25 12:53 UTC · original
Independent native Windows result for PR head
6f358fc6, integrated as74becd8. RTX 5080 16 GB, 617.14, Windows 11 Pro 25H2 build 26200.9974, Ryzen 9 5900X, 32 GB RAM. Basebbc35d0and candidate both emitted, validated and created D3D12 test pipelines for ten alpha prepass shaders bound in the baseline. All ten showDB_SHADER_CONTROL=0x1450. The native early-depth test passed, and all ten matching programs built and bound during the candidate's successful run.Both reached the controllable Series X prison view. At 2542 × 1396 before the same replayed pan, the candidate showed wall detail and a smaller dark shoulder band. Mean encoded luma in the same 250 × 120 wall region was 7.39 and 44.87, respectively. Indirect draw windows were off in both of these captures. The captures are from separate launches with different shader-cache history and idle poses. Direct depth and motion target validation remains open.
One earlier candidate launch failed a 1 MiB host allocation at world entry, with minimum sampled commit headroom around 0.01 GiB. The same executable reached the view on an isolated retry with a fresh profile copy and its warm cache, and ended deliberately with no logged device removal. Revisions and results. Testing and reporting assisted by OpenAI Codex.
@naixue2233 on GitHub · 2026-11-25 15:19 UTC · original
Heads up from a Windows 10 host, in case it saves someone else a power cycle. I am not claiming the change is wrong — I am reporting what happened and offering data.
I merged this (
6f358fc) into a fork on top of#867+#916and ran the title on Windows 10 19045, RTX 3080 (driver 32.0.16.1742),--console series-x, the same scene and flags as the run before it. The machine then went down hard and had to be power-cycled, twice:Kernel-Power 41— "the system has rebooted without cleanly shutting down first" — with noBugCheck 1001and no bugcheck code anywhere in the log. The box hung; it did not bugcheck.unhandled exceptionin the run log (victory_gpu=info); frames were still being presented when the machine stopped responding.6a6d66e, identical environment variables and scene) ran the same prologue corridor for about forty minutes with no hang. Three such unexpected shutdowns happened tonight in total; the two that I can line up with a build carry this change.What makes me suspect an interaction rather than a wrong flag: 3,023 programs switch from testing depth after the shader to testing it before, while the title's prepasses are exactly the ones that also write unordered views in that same pass. Any ordering mistake there is a read/write hazard between a pass and the pass that consumes its targets, and this title's glass prepass (
PS_AlphaPrepass) feeds several resolves.I have reverted the merge in my fork for now (
dcdbccb, everything else kept) so that I can test the rest of the stack. Two questions:nvidia-smiis not usable on this box, so I cannot show a TDR counter — only that there is no bugcheck.DB_SHADER_CONTROL0x1050/0x1450, including the resource-state and barrier lines aroundPS_AlphaPrepassand its resolves.If you want to bisect from your side, a narrowed variant would be cheap for me to test: only
0x1050, or only programs that write no unordered view. Happy to run either.@SpaghettiMaster545 on GitHub · 2026-11-25 15:34 UTC · original
Thanks for the report. To your two questions:
PS_AlphaPrepassand its resolves (resource states and barriers) would help most. Please leave out shader code.On the narrowed variants: the programs that matter here are the ones that write unordered views. Without them the flag only moves the test, so "only programs that write no unordered view" would leave out the fix itself. "Only
0x1050" is a useful split, though, because the glass prepass is0x1450. If it helps you A/B without rebuilding, I can add a switch that turns the flag off.@Exopus-0x65f7ad0 on GitHub · 2026-11-26 14:36 UTC · original
Tested on an RTX 5060 Ti 8 GB (Windows 11, 16 GB RAM, Series S profile). I ported it onto our tree (fork main plus PRs). There were two small conflicts:
flagsinshader.rs, whereRAW_BUFFERSalready exists, and the signature lines inLower::new.a_pixel_program_tested_before_it_runs_declares_early_depthpasses.In game I ran one warm-up run after the translator change, then the same scripted walk: cell window, dormitory windows, corridor, up to the guard room. Results:
AI-assisted (Claude Code). Counts and descriptions only, nothing from the game.
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.