Skip to content

Port upstream #368: lower buffer_gl0_inv and buffer_gl1_inv as no-ops - #36

Merged
DesertGamer merged 1 commit into
DesertGamer:mainfrom
lcg007xd-c:port/upstream-368-buffer-inv
Nov 25, 2026
Merged

DesertGamer merged 1 commit into
DesertGamer:mainfrom
lcg007xd-c:port/upstream-368-buffer-inv

Conversation

@lcg007xd-c

Copy link
Copy Markdown
Contributor

What this changes

This ports Marvisak/VIctory#368 by quaternion. It is cherry-picked with -x, so the commit keeps their authorship.

buffer_gl0_inv and buffer_gl1_inv (MUBUF 0x71 / 0x72) are cache-invalidation hints. They use the MUBUF encoding, but they name no descriptor that is read. resource::track still treats their srsrc field as a descriptor, so a shader containing one is refused before lowering:

Unsupported { offset: 0, what: "a descriptor neither loaded nor built" }

D3D12 already keeps UAV writes coherent across waves and dispatches, and the surrounding s_waitcnt / s_barrier are lowered. So upstream treats these two instructions like s_gl1_inv / s_dcache_inv: no descriptor tracking, and no DXIL.

VIPort has the upstream merge of #368 in its history, but the change is not in the tree. It was lost in a later merge.

The change:

  • resource.rs skips descriptor tracking for _inv buffer instructions.
  • emit/lower.rs returns early for buffer_gl0_inv / buffer_gl1_inv.
  • Adds the test buffer_cache_invalidations_lower_as_no_ops.

In this tree, the resource.rs half alone makes the test pass. With only the lowering half removed, the test still passes. The early return in buffer() keeps those names away from the load/store path, which would otherwise refuse them by name.

Checked

  • No game data of any kind (files, extracts, screenshots, dumps, saves): see docs/asset-policy.md
  • No binary files or archives
  • No new dependency, build.rs, git hook, .cargo config, CI change or script (or an issue explains why)
  • No download, no started program, no network connection added (or an issue explains why)
  • cargo test --workspace passes (only viport-shader --lib on Linux, see below)
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes (for viport-shader, with CI: clear the clippy errors that keep main red since a3e7f17 #21 merged in locally)
  • The code I wrote is formatted with rustfmt; I did not reformat lines I did not change

What I ran

On Linux, Rust 1.98.1:

  • echo "0x00,0x00,0xc4,0xe1,0x00,0x00,0x00,0x00" | llvm-mc --disassemble -triple=amdgcn -mcpu=gfx1030 prints buffer_gl0_inv, the test's first word.
  • cargo test -p viport-shader --lib --locked: 191 passed, 0 failed, 3 ignored.
  • With resource.rs as on main, emit::lower::tests::buffer_cache_invalidations_lower_as_no_ops fails with the error above.
  • cargo clippy -p viport-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean with CI: clear the clippy errors that keep main red since a3e7f17 #21 merged in.

Not run: on a GPU. No DXIL is emitted for these two instructions, so the translated program is the one it would be without them.

Overlaps

#27 moves the lower.rs unit tests into emit/lower_tests.rs. If it lands first, the one new test moves with them, and I will rebase. No other open PR touches resource.rs.

🤖 Generated with Claude Code

buffer_gl0_inv and buffer_gl1_inv name a buffer but read no descriptor, so resource tracking refused them before lowering. Skip descriptor tracking for _inv buffer instructions and lower the pair to nothing, as the existing scalar cache instructions already are. Add a synthetic full-pipeline test.

(cherry picked from commit f47ebd8)
@DesertGamer
DesertGamer merged commit 9fc0d7e into DesertGamer:main Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants