Shaders: refuse LDS past the host's group limit by name #391
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!391
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-391"
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?
@Kaairim on GitHub · 2026-11-24 02:52 UTC · original
Kaairim:lds-host-limit→main· +95 −0 · 1 files · 1 commits · draftWhat
emitnow refuses, asUnsupported, a compute program that reads or writes more than 32 KiB of LDS and a mesh program that declares more than 28 KiB, with the limit in the message (compute LDS over the host's 32 KiB,mesh LDS over the host's 28 KiB).Why
The console gives a thread group up to 64 KiB of LDS (
rsrc2LDS_SIZE, 512-byte granules); D3D12 gives group shared memory 32 KiB in a compute shader and 28 KiB in a mesh shader. Nothing compared the two: such a program was translated, counted as translated byvictory translate, and then failed in the validator or at pipeline creation with an error that did not say why.A compute program declares its LDS array only when it reads or writes it (
Shader::ldsis lazy; swizzles and permutes do not touch it), so one that asks for more but never uses it is left alone – it works today and keeps working. A mesh program always declares its size in PSV0, so it is checked as is.Tested
Windows 11 (build 26300), Rust 1.98.1 (pinned toolchain), x86_64-pc-windows-msvc:
emit::tests::lds_past_the_host_limit_is_refused_by_name(synthetic words, no game data): a compute program withds_read_b32and 65 granules is refused throughemitwith the message; 64 granules (32 KiB) is not; 65 granules with no LDS access is not; a mesh program at 28 KiB + 4 is refused, at 28 KiB it is not. With thelds_fitscall removed fromemitthe test fails.cargo test --workspace --no-fail-fast: 265 passed, 0 failed, 4 ignored (main: 264 / 0 / 4).cargo clippy --workspace --all-targets: the same two warnings as main.rustfmt --check --edition 2024 crates/victory-shader/src/emit/mod.rs: clean.Not run: the title, so I cannot say how many of its programs ask for more than the host limit;
victory translatewould now name them.Improvements by William "kaairim" Deivid (wdcore). AI-assisted: Claude Code with Claude Opus 5.5 wrote the change, the test and this description; a second Claude Opus 5.5 agent reviewed the diff.
🤖 Generated with Claude Code
@SkippySteve on GitHub · 2026-11-24 03:01 UTC · original
Reviewed and tested on Linux (
x86_64-unknown-linux-gnu, heada3f219e, which sits on currentmain). It looks correct to me. Results below; no title data was used.Tests
cargo test -p victory-shader: 57 passed, includinglds_past_the_host_limit_is_refused_by_name.lds_fits(native, p)?;call commented out, that test fails atmod.rs:515(theexpect("refused")). So the test does exercise the check throughemit.div_ceil(4)dwords, which is 28 KiB + 4, so comparing raw bytes is the right call. A compute program at the largestrsrc2LDS size (0x1FF granules, about 255 KiB) with no DS instructions passes.cargo fmt -p victory-shader --check: clean.cargo clippy -p victory-shader --all-targets -- -D warningsfails on the deadconstant_colortest helper, but it fails the same way onmain, so this PR doesn't cause it.Is the compute predicate in line with lowering? Yes, I believe so. In
lower.rs, theds()function declares the LDS global (Shader::lds) only from thedwordclosure, whichds_read*,ds_write*and theds_*atomics use. Everything else the predicate counts errors out before it reaches that closure:"GDS"ds_permute/ds_bpermute/ds_appendreturn"an LDS operation"So the predicate covers everything that declares LDS and a few things that don't. A shader that translates today is never newly refused. The only change is which reason a few already-refused programs report: GDS plus more than 32 KiB of LDS now says "compute LDS over the host's 32 KiB" instead of "GDS". That seems fine.
It works alongside #333. #333 adds a separate check in
native.rs: a mesh record with more than 64 KiB of LDS isMalformed, because past that thelds_dwords * 4product in PSV0 can overflow. This PR adds the host limit inemit. They touch different files. Merged locally with no conflicts, the two together givecargo test -p victory-shader63 passed.Nits (none blocking)
32 << 10and28 << 10could be named constants next to the doc comment, likeMAX_GROUPinnative.rs, so the message and the number can't drift apart.computeandlds_fitsare rebound halfway through. The secondcomputedrops thewordsparameter, and the closurelds_fitshides the function of the same name. Different names would make it easier to read.@alexdeliu on GitHub · 2026-11-24 17:23 UTC · original
Merged onto
main@ffe310eb, this PR (a3f219ec) no longer compiles its tests.crates/victory-shader/src/emit/mod.rs:579callsresource::trackwith 3 arguments. Since6638098cit takes a 4th,lanes: Option<&Structured>; main's tests passSome(&st)withlet st = structure::structure(&p).unwrap();.Checked with CI's steps (both clippy runs with
-D warnings,cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87@Marvisak on GitHub · 2026-11-25 03:14 UTC · original
Automated triage for the maintainers.
This pull request conflicts with
mainincrates/victory-shader/src/emit/mod.rs. It will be reviewed once it is rebased onto currentmain.Generated by 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.