Shaders: global byte and half stores keep the rest of their dword #1864
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!1864
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1864"
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?
@TinkerBell-90 on GitHub · 2026-11-24 23:46 UTC · original
TinkerBell-90:shaders-global-byte-short-stores→main· +311 −8 · 2 files · 1 commits · openWhat
global_store_byte,global_store_short,global_store_byte_d16_hiandglobal_store_short_d16_hiare translated, both into title memory (addresses the program computes) and through a root view. Main refused them by name inflat_write, so any program with one did not translate.How
The same method
buffer_store_byteandbuffer_store_shortalready use: two atomics on the dword holding the field, anandthat clears it and anorthat sets it, so lanes storing neighbouring bytes of one dword keep each other's values. The_d16_hiforms take the field from bit 16 of the VGPR. Title memory pages are marked written for the bytes actually stored.Tests
Two GPU tests in
memory_tests.rs: 32 lanes store bytes, halves and both_d16_hiforms into shared dwords of a buffer filled with0xAA, through title memory (pointer in root constants, page table, written-page check) and through a root UAV in a program without title memory.Run here on Linux with Wine 10, vkd3d-proton 3.1 and DXVK 3.1.1's dxgi, on an RTX 3070 (driver 595.99), tests built for
x86_64-pc-windows-gnu. There is no WARP in that setup (DXVK returns the hardware adapter forEnumWarpAdapter), so both loops ran on the RTX 3070; CI's WARP is untested by me.lower.rschange both fail (Unsupported { what: "global_store_byte" }); with a plain dword store instead of the two atomics both fail with the neighbours' bytes lost; with the_d16_hiforms read from bit 0 both fail.victory-shadersuite: 206 passed, 5 failed, 2 ignored. The same 5 fail on main70564aein this setup (204 passed):conversions_match_the_hardware,rounding_matches_the_hardware,hosts_that_do_not_fuse_are_named,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,stub_pipeline_is_created.cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warningsclean,cargo test -p victory-shader --libon Linux 118 passed, rustfmt adds no new differences to the two files,cargo xtask policyok.Limits
AI-assisted.
@kais7654 on GitHub · 2026-11-24 23:53 UTC · original
Read the diff and ran it locally (RTX 5070 Laptop, Windows 11):
buffer_store_byteand kin already emit the two atomics — same operation codes, the_d16_hiforms take the field from bit 16 of the VGPR as expected, and the title-memory lookup marks the pages the stored bytes belong to.title_memory_byte_and_half_stores_keep_their_neighboursandroot_uav_byte_and_half_stores_keep_their_neighbours.cargo clippy -p victory-shader --all-targets -- -D warningsis clean.One question:
flat_atomicstill refuses byte and half atomics by name, right? Fine to leave for later — the stores are what the title hits first — just so the follow-up is on record.@Marvisak on GitHub · 2026-11-25 02:17 UTC · original · edited 2026-11-25 15:59 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/memory_tests.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge candidate) was for an older state ofmain.Generated by Claude Code
@TinkerBell-90 on GitHub · 2026-11-25 10:39 UTC · original
Rebased onto main
940d32f. The conflict inmemory_tests.rswas both sides adding tests at the end of the file; all are kept.One change beyond the conflict: since
cd94d35writes through views mark their pages, so the byte and half path now callsmark_view_writeon the dword it writes. The root UAV test runs withview_markson and checks the two pages its stores touch; the title memory test checks that it adds no view marks. Without the new call, or with it pointed at byte 0, the root UAV test fails.Retested on Linux under Wine + vkd3d-proton (RTX 3070): victory-shader 244 passed and 5 failed, the same 5 that fail on main
940d32fon this host (242 passed). Clippy for windows-msvc with-D warningsis clean.AI-assisted.
583d315ef6to3922d17287@catminou4 on GitHub · 2026-11-24 23:52 UTC · original · approved these changes
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows.Global byte/half stores keep the rest of their dword: partial-store masking fix for global stores.
@TinkerBell-90 on GitHub · 2026-11-26 20:34 UTC · original
Rebased onto main
63bcca4. The code is unchanged (git range-diff); only the place of the two tests inmemory_tests.rsmoved. Of the commits since940d32f, the one that reaches this path ise815cef(#2484): it changed howLower::memorymarks the last byte of a write. The byte and half stores call it with 1 or 2 bytes inside one dword, so they get the new marking with no second lookup, and #2484'sstraddling_writes_across_256mib_and_4gib_boundaries_mark_exact_pagespasses on this branch.mark_view_writehas not changed.Tested on a GPU this time: an RX 9070 XT under Linux (Wine 10, vkd3d-proton 3.1 with DXVK's dxgi, Mesa 26.0.8 RADV). Not Windows, nothing run in game.
emit::memory_tests: 7 passed, the two new tests included.lower.rsfrom main with these tests: both panic at translation withUnsupported { offset: 48, what: "global_store_byte" }.victory-shadersuite: 301 passed, 3 failed, 3 ignored, against 299, 3, 3 for main at the same commit. The 3 failures are the same tests on both (stub_pipeline_is_created,hosts_that_do_not_fuse_are_named,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros) and come from this host, not from the change.cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.AI-assisted.
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.