Start shader constant tables after instructions #408
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!408
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-408"
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?
@safesearch77 on GitHub · 2026-11-28 13:25 UTC · original
safesearch77:fix/shader-code-table-start→main· +61 −5 · 3 files · 1 commits · closed without mergingWhen a shader reads its embedded
CODEconstant table through a computed offset, the resource pass records an address at offset0.Lower::code_dwordpreviously took the minimumCODEoffset across all loads and descriptors, which turned the entire program (instructions plus constants, up to 64 KiB) into an internal DXIL constant array.Under
vkd3d-protonon NVIDIA Vulkan, that internal constant array lowers to per-thread local memory reserved across the GPU, so a large table consumes substantial VRAM. Even on native D3D12, keeping instruction bytes out of the constant array avoids emitting unneeded constant data.code_table_startnow starts the constant table where the program's instructions end (code_end & !3), unless a load at a fixed offset reads belowcode_end, in which case it falls back tolowest. Trade-off (same as upstream#2143): a computed load that actually reads instruction bytes clamps to the last entry (relunderflows andoverclamps).TRANSLATOR_VERSIONis bumped from15to16because the emitted DXIL constant array changes for shaders with computedCODEtable offsets.Ported from
Marvisak/VIctory#2143(e04c0781, bydesp).Verification
cargo +1.98.1 test --locked -p victory-shader --lib(native Linux):230 passed; 0 failed; 2 ignored, includingthe_code_table_starts_after_the_instructions(covers computed offset at0, computed + fixed aftercode_end, computed + fixed inside instructions, and fixed-only pastcode_end).cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-shader --lib -- --skip paired_fp32(Wine, no GPU/D3D12 host): all300CPU-side tests pass includingthe_code_table_starts_after_the_instructions;40GPU/WARP SM 6.6 shader-execution tests fail under sandboxed Wine because no GPU device is exposed.cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib -- shader_cache(Wine):4 passed; 0 failed(pure CPU/disk tests; nohost()guard).cargo +1.98.1 clippy --locked --target x86_64-pc-windows-msvc -p victory-shader --all-targets -- -D warnings: clean (0warnings).cargo +1.98.1 xtask policy:asset policy: 322 files ok.vkd3d-proton(RTX 4070 Laptop 8 GB, CachyOS,GE-Proton11-14-viewtree, Wayland, Series S, DLSS Quality,VICTORY_VRAM_HEADROOM_MB=1024,VICTORY_POOL_STATS=1):25,792shader files pre-translated cleanly underTRANSLATOR_VERSION = 16(2,530active translations /105 MBin-run), zero visual regressions, steady13.7–16.6 fpsat5,390–5,863draws/frame (matching13.4–16.8 fpson the same heavy scene without this change), clean shutdown (DLSS: NGX shut down result="Success").@Aniseto on GitHub · 2026-11-28 13:34 UTC · original
Ran the code-table placement test at
06aaf1bon an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.The test passes on a real 32-lane NVIDIA host, covering a computed
CODEoffset at 0, computed and fixed reads before and after the instruction end, and fixed-only reads past it. It is a translation-level test; no Vulkan/VKD3D VRAM measurement was made here. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.Not tested: a retail title, the VRAM saving under vkd3d-proton, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
@Kal0s-design on GitHub · 2026-11-28 19:14 UTC · original
The description says the 40 GPU shader-execution tests couldn't run under Wine, so I ran the whole
victory-shaderlib suite natively on Windows (NVIDIA card, debug build):main(fe7c6e5)06aaf1b)the_code_table_starts_after_the_instructions)It merges cleanly on current
main.On the trade-off:
code_endcomes fromir::build, andgfx10::decodeonly follows reachable control flow, so it's the end of the last instruction that can actually run, never constant data decoded as code. A computed load can only clamp to the wrong entry if the title puts constants before its last reachable instruction (between two code regions, say). The upstream port has the same assumption, so I'm only noting it here.One practical point: the
TRANSLATOR_VERSION15 → 16 bump makes everyone translate again and rebuild pipelines on their next launch, which is the slow first launch from #422/#423. If other translator changes are close to landing, merging them in the same window would save users one of those launches.AI-assisted: yes
@TaynanGT on GitHub · 2026-11-29 11:35 UTC · original
Thanks for running the native shader execution suite. The 344 vs 343 test result adds useful coverage beyond Wine. #428 carries the same constant-table change; we'll keep one implementation and coordinate the translator version and regression test.
@safesearch77 on GitHub · 2026-11-29 13:18 UTC · original
Thanks. I compared this PR with #428 (
85a3ebf). The code is identical:emit/lower.rs, the regression testthe_code_table_starts_after_the_instructions, and theTRANSLATOR_VERSIONbump. The only difference is one extra doc-comment line on the test in #428 that names #221.Since #428 is already in #439 and #439 has moved
TRANSLATOR_VERSIONon to 19, I'll close this PR in favor of #428 so there's one implementation to keep. If you'd rather keep this one, tell me and I'll rebase it instead.Thanks to @Aniseto and @Kal0s-design for the native Windows runs (RTX 5070 Ti, plus the full
victory-shadersuite: 344 passed against 343 onmain). Those apply to #428's code too.AI-assisted: yes (Claude), reviewed locally before posting.
@zmelumian972 on GitHub · 2026-11-29 17:23 UTC · original · edited 2026-11-29 17:24 UTC
Hey @safesearch77
thanks for 408, I think both of them are identical tbh so it doens't really matter, once I realized the problem I asked claude how come Victory doesn't have it and he told me it was solved there, so I asked him to port it... I think we both did the same thing
can you take a look at #221 ?
on both 428 and 408 I still have those artifacts, I want to make sure it's not something specific to the 5090
@TaynanGT on GitHub · 2026-11-29 19:02 UTC · original
Thanks for checking both branches. Let's keep #428 as the single constant-table implementation and track the remaining rendering artifacts in #221 rather than duplicate the fix. A matched Windows/Proton comparison would help establish whether this is specific to the RTX 5090.
Pull request closed