shader: load program constant tables from root SRV and fix raw buffer size CFG #173
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!173
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/173/head"
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?
@Androtim on GitHub · 2026-11-30 00:01 UTC · original
Androtim:feat/iter170-shader-root-srv-const-table-and-amd-fix→main· +177 −8 · 17 files · 1 commits · merged 2026-11-30 09:15 UTCSummary
Moves shader program constant tables out of per-shader internal DXIL constant arrays into a deduplicated root SRV (
SLOT_CODE_TABLE,t250) and fixes an AMD DXIL raw buffer size query CFG lowering crash:Root SRV constant table (
SLOT_CODE_TABLE,crates/victory-shader+crates/victory-gpu):SLOT_CODE_TABLE = 250(crates/victory-shader/src/emit/shader.rs) and exposesHostShader::code_table(Vec<u32>).code_dwordincrates/victory-shader/src/emit/hdr.rsnow loads from root SRVt250viarawBufferLoad.f32at the clampeddword * 4byte offset instead of indexing an internal constant array (avoiding large per-threadPrivatescratch allocations underdxil-spirvon Vulkan/Proton drivers; opt-out viaVICTORY_CODE_TABLE_PRIVATE=1for debugging).crates/victory-gpu/src/shader_cache.rsappends non-emptycode_tablewords cleanly at the tail of cache records so older cached entries still decode, with unit test coverage for both legacy and extended records.crates/victory-gpu/src/pipeline/host.rsandcrates/victory-gpu/src/draw.rsdeduplicate each table by content inside pooled 4 MiB upload buffers and bindSLOT_CODE_TABLEacross compute and graphics command lists.AMD DXIL raw buffer size query block split (
crates/victory-shader/src/emit/lower.rs):descriptor_dataaround raw buffer size queries so the emitted DXIL satisfies strict block-terminator validation.Verification
cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy:asset policy: 311 files okcargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: passcargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings: passvictory-shader+victory-gpu):victory-shader(resource::tests::,emit::lower::tests::,emit::valu_tests::,emit::wave64_tests::,emit::size_tests::,emit::waterfall_tests::): passvictory-gpu(shader_cache::,pipeline::,draw::, including legacy/extended cache round-trip): passRTX 4060 Ti 8 GB,--release --features diagnostics,DLSS quality,75sin-world offorigin/main64 MiBtexture blocks, dedicated shader cache):LowVram):0crashes,0untranslated shaders,9.0 fpsmedian (max_draws=11700),used_max=6607 MB / budget_min=6836 MB(over=0 MB,room_false=81.2%vs92.9%onpr170,55x 64 MiB blocks =3520 MB,no_room_reuploads=52000),16/24lit frames (luma=107.62,near_black=0.0%,edge_energy=7.99,magenta=0.0%).1440p,PlayParity,LowVram):0crashes,0untranslated shaders,10.8 fpsmedian (max_draws=14300),used_max=6911 MB / budget_min=6868 MB(over=29 MBon unmerged64 MiBblocks),18/24lit frames (luma=97.71,edge_energy=6.72,magenta=0.0%).dxil-spirv+ Vulkan avoids multi-GBSPIR-V Privatescratch allocations and AMD avoids the raw buffer size DXIL validation failure; combining with PR #171's 16 MiB pool blocks keeps Series X1440pwithin 8 GB budget.)@Androtim on GitHub · 2026-11-30 00:03 UTC · original · edited 2026-11-30 01:05 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
Logic and safety look solid, and CI is passing. This PR touches shader emission, D3D12 root signatures, upload-buffer pooling, and command-list binding, so it warrants a local real-GPU smoke test before merging.
What Was Checked
crates/victory-shader/src/emit/shader.rs,hdr.rs,lower.rs,mod.rs):SLOT_CODE_TABLE = 250andHostShader::code_table: Vec<u32>, withVICTORY_CODE_TABLE_PRIVATE=1preserving the previous in-shader constant array path.Lower::code_dword,indexis unsigned-clamped (IUGT) to0..=len - 1before computing the byte offset (index << 2) forrawBufferLoad.f32, preventing out-of-bounds reads through the root SRV descriptor.SLOT_CODE_TABLEis only registered whenwordsis non-empty, matching the!t.code_table.is_empty()guard inHostPipeline.crates/victory-gpu/src/pipeline/host.rs,draw.rs):code_table_addressdeduplicates constant tables by content into 256-byte-aligned slices of process-lifetime 4 MiB upload buffers (CHUNK = 4 << 20), keepingID3D12Resourceallocations alive in astatic Mutex<Option<Pool>>.SLOT_CODE_TABLEis added to theoursset so it remains a root SRV descriptor (not wrapped in a one-view table underbounded_root_srvs()), matchingSetComputeRootShaderResourceView/SetGraphicsRootShaderResourceViewindraw.rs.code_table_addressassumeswordsis non-empty (currently guaranteed by its sole caller); an earlyif words.is_empty() { return Some(0); }or debug assert would prevent a nullcopy_nonoverlappingif another caller is added later.crates/victory-gpu/src/shader_cache.rs):"VICTORY_CODE_TABLE_PRIVATE"tobuild()so toggling the env var does not collide with cached translations.code_tableonly when non-empty and decodes trailing bytes when present, preserving backwards compatibility with legacy entries (covered by unit tests).crates/victory-shader/src/emit/lower.rs):self.curwith an unconditionalTerm::Br(next)after a raw buffer (props.0 & 0xff == 11) descriptor size query when the size dword is read as a number, keeping the emitted DXIL CFG well-formed.Verdict
needs-gpu-test— Code and CI look good; run a local real-GPU smoke test (ideally covering both default root-SRV mode andVICTORY_CODE_TABLE_PRIVATE=1, plus AMD/Vulkan-Proton if available) to confirm constant-table rendering and shader compilation stability.Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-11-30 09:15 UTC · original
Hardware-verified on RTX 4060 Ti 8 GB (Series X 1440p
-PlayParity, warm shader cache, stacked Wave 7A:#173, #199, #203, #204, #205, #206, #207, #208, #211, #213, #221):5.55 fps(vs5.25 fpsWave 6) | Draws:11475| Crashes/DRED:0final_waiting=14855(-11729vs Wave 626584),uploaded=449217397 / 6862 MB(warm60blocks /6988 MBon first pass),0failed bakesluma=98.64,near_black=0.08%,edge_energy=17.55,magenta=0.0%)Merging onto
main.