Shaders: byte and half format loads at a constant offset load the aligned dword directly (NVIDIA) #2037
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
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
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
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/Marvisak--VIctory!2037
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2037"
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?
@desplmfao on GitHub · 2026-11-25 03:51 UTC · original
desplmfao:fix/nvidia-shader-tests→main· +18 −5 · 1 files · 1 commits · openProblem
On NVIDIA (RTX 5080, vkd3d-proton 3.2.0 under Proton), two buffer-format tests on
mainread 0 where they stored a value:valu_tests::normalized_buffer_formats_load_their_ends_exactly:format 1 of 0xff = 0x00000000, want 1valu_tests::tbuffer_d16_loads_pack_two_channels_per_dword:d16 opcode 8 format 13 of 0x40003c00 = 0x00000000, want 0x00003c00Only formats narrower than a dword fail (8_UNORM, 16_FLOAT single channel); the 32-bit formats in the same tests pass.
Cause
format_loadaligns the offset of a byte or half field withoff & !3, even whenoffis a constant. In the SPIR-V that vkd3d-proton makes of it (VKD3D_SHADER_DUMP_PATH):OpRawAccessChainNV ... %uint_16 %uint_0 %uint_0 RobustnessPerElementNV, the same access as the test'sbuffer_store_dwordbefore it;0 & 0xFFFFFFFC:OpRawAccessChainNV ... %uint_0 %uint_0 %96 RobustnessPerComponentNV.On NVIDIA that second load does not see the dword the same invocation just stored through the first kind of access, and reads 0.
Change
When the offset is a constant,
format_loadcomputes the aligned address and the shift as constants, so the load takes the same access as the store. A computed offset is lowered as before.This doesn't fix a load at a computed offset after a store in the same invocation, if NVIDIA behaves the same way there. These two tests don't cover that case, and I haven't seen it in a test or in the title.
Tested
RTX 5080, Linux, proton-cachyos 11.0 with vkd3d-proton 3.2.0,
victory-shadertests with--test-threads 1:main(940d32f): 241 passed, 6 failedvalu_testspass.cargo clippyreports nothing new;cargo fmt --checkshows no diff in the changed lines.The other four failures on this machine
semantics_tests::rounding_matches_the_hardware(v_fract/v_floor/v_ceilof denormals): #1994 should fix it.stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros:dispatch failed: Invalid parameter.The test harness asks for a heap ofHEAP_VIEWS= 2,097,152 views, and vkd3d-proton refuses heaps over 1,041,451 on NVIDIA (Unsupported descriptor count 2097152 for heap type 0). #1777 and #1779 address the capped heap and should fix it.semantics_tests::hosts_that_do_not_fuse_are_namedandtests::stub_pipeline_is_created: these come from running the tests under Wine. Wine's "WARP" adapter is not Microsoft's WARP, and vkd3d-proton doesn't check the DXIL digest. Neither is a translation problem.Related
#1669 and #1288 change the same branch of
format_load(fields at byte offsets that straddle or sit inside a dword). They don't touch constant offsets, but they may conflict textually with this change.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-25 03:58 UTC · original
Triage verdict — Keep the constant-offset fix (
8c0058b)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@Marvisak on GitHub · 2026-11-25 09:18 UTC · original
Automated triage for the maintainers.
Merge candidate.
In
crates/victory-shader/src/emit/lower.rs(Lower::format_load, the sub-dword branch), a constant offset now produces a constant aligned address (o & !3) and a constant shift ((o & 3) * 8) throughModule::int_value. A computed offset is lowered exactly as before. For constant offsets the result is the same as the currentand/shlsequence, so emulation semantics do not change; the generated DXIL is simply folded. According to the PR's SPIR-V dumps, this makes vkd3d-proton on NVIDIA use the same access for the store and the load, which fixes twovalu_testsfailures there. The benefit is limited to that host (a computed-offset load after a store is still not covered, as the body says), but the change is small and safe. It touches the same branch as open #1669 and #1288, so whichever lands second may need a small rebase. Recommending a look, not approving.CI: passing (
check).Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 09:43 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
8c0058bfontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
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.