Shaders: lower buffer cache invalidations as no-ops #368
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/368"
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?
Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T02:40:33Z.
What
buffer_gl0_invandbuffer_gl1_invwere the only buffer cacheinstructions the translator refused:
resource::trackdemanded a resourcedescriptor even though the instructions carry no data operand, and lowering
had no arm for their names. The host has no console buffer cache to drop,
so this skips descriptor tracking for
_invbuffer instructions and lowersthe pair as no-ops — the same treatment the scalar
s_gl1_invands_dcache_invalready get. A synthetic full-pipeline test covers bothopcodes.
This was one of the refusals listed in PR #163's audit. That PR only prints
a notice when a listed opcode begins to lower, so the two lines become
stale rather than failing.
An AI tool wrote part of this change.
Tested
cargo test --workspacewith PR #112's Linux build fix applied locally (not part of this PR): 165 passed, 0 failed, 3 ignored. One new test runs both opcodes through decoding, resource tracking, structure and lowering.cargo check --target x86_64-pc-windows-gnu --workspace --testspasses. No Windows host here.cargo xtask policypasses (150 files ok). No game files or data from them were added.shaders.rpfwith no reader in the repo, so the test uses synthetic instruction words.Checklist
cargo xtask policypasses. No game files or data from them were added.Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:03:17Z.
Thanks @Quat3rnion for this change. I tested head
d3c40da1c8371648774e11963cd880539e3d8085with:Result: 1 passed, 0 failed (61 filtered out). The synthetic lowering test decodes and lowers both
buffer_gl0_invandbuffer_gl1_invthrough the shader pipeline. This validates translator acceptance and no-op lowering; it does not exercise behavior in a real title or GPU dispatch.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:13:15Z.
Review: COMMENTED
Tested
42c86c3on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (248 passed, 0 failed; older base).victory translate <title exe> --validate --pipelinesgives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines.Skipping descriptor tracking for the
_invforms is right, since they read no data through the descriptor. But I'm not sure a plain no-op is safe:globallycoherentUAVs, or after a device-scope memory barrier (DeviceMemoryBarrier, i.e.dx.op.barrierwithUAV_FENCE_GLOBAL).buffer_gl0_inv/buffer_gl1_invexactly in cross-group producer/consumer patterns: after an atomic flag or before re-reading data another workgroup wrote, often in spin-waits (see #452). As a no-op, such a shader translates but can read stale data or spin forever on NVIDIA and AMD PC drivers. The PC L1 is not coherent either.Suggested change: lower both to a device-scope UAV memory barrier (no group sync) instead of nothing. It is cheap, it gives the visibility guarantee these instructions request, and it still lets the shader translate. Alternatively, mark the UAVs the program touches
globallycoherent. A comment-only review for now.AI-assisted (Claude Code).