Shaders: derivative sampling is pixel-only at validator version 1.6 #1948
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!1948
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1948/head"
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?
@Luislariosss on GitHub · 2026-11-25 01:38 UTC · original
Luislariosss:shaders/non-pixel-sample→main· +163 −44 · 3 files · 1 commits · closed without mergingWhy
The translator declares validator version 1.6 (
emit/shader.rs). Before 1.8, DXC takesSample,SampleBias,SampleCmp,CalculateLODand the derivative ops as pixel-only.lower.rsalready limitedimage_sample_candimage_get_lodto pixel shaders, butimage_sample,image_sample_oandimage_sample_bwere emitted in any stage.So a compute (or mesh) program using them is invalid DXIL by construction. The validator's text is the generic "Function uses features incompatible with the shader stage (cs)", with no line naming a rule, which is what hid the cause. Running the validator over one title's shader pack, this accounts for the compute class of rejections (735 programs on
42363ab). A minimalTexture2D.Samplein[numthreads(32,1,1)]compiled withdxc -validator-version 1.6or1.7gives the same text, and1.8accepts it.What
image_sample,image_sample_oandimage_sample_bfollow the same rule asimage_sample_c: allowed whenself.s.pixel, refused with the existing "does not translate" path otherwise. No new state. The comment says why, and that a later change could lower them toSampleGradwith gradients taken from quad lanes.This does not make those programs render; it makes them refuse with a reason instead of reaching the driver as invalid DXIL (the runtime-side safety net for the same class is #1936).
Tests
Unsupportednaming the op;image_sample_lzin compute still lowers and validates.dxil.dllis present.image_addresses_of_16_bits_and_clampshad a "biased" program that ranimage_sample_bin compute; it would now be refused, so that program and its cases are removed (comment points at the new test). The a16 bias address layout therefore has no compute coverage left; the pixel path only checks that it translates.cargo test -p victory-shader --locked: 248 passed, 3 ignored (246 + 2 new on this machine'smain).cargo build --release -p victory --locked: clean.No game data, hashes or program names are included (asset policy).
@Marvisak on GitHub · 2026-11-25 08:19 UTC · original
Automated triage for the maintainers.
Needs work.
The PR makes
image_sample,image_sample_oandimage_sample_bpixel-only inLower(crates/victory-shader/src/emit/lower.rs, the MIMG op match). Outside pixel shaders they are now refused, and the change removes the compute case ofimage_addresses_of_16_bits_and_clampsthat used them.On
main, that removed case is the evidence that compute works.image_addresses_of_16_bits_and_clamps(emit/valu_tests.rs) lowers animage_sample_bcompute program without validation, with the comment "The 1.6 validator refuses implicit derivatives in compute (1.8 takes them); the host runs them". It then runs that program on the hardware adapter and on WARP and checks the selected levels for five bias values. The runtime never runs the validator: the container hash is ours, andpipelineaccepts it. The module declares shader model 6.6, which supports derivatives in compute. So the change turns compute programs that work and are tested today (735 by the PR's own count) into refusals, and deletes the test that showed they work.What would change the verdict:
image_addresses_of_16_bits_and_clamps.DerivativesInMeshAndAmplificationShadersSupported), so that case could check the feature.CI:
checkpasses.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 11:12 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
0a4d90bbontomain940d32f(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.740 programs that fail on both change their 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).
@Luislariosss on GitHub · 2026-11-25 20:10 UTC · original
Withdrawing this, and thank you for the careful read — you are right on the point that matters here.
image_addresses_of_16_bits_and_clampsis the proof, and this PR deleted its biased case. I should not have turned working compute programs into refusals on that basis, and sinan-cmyk's measurement (no change in the validated count) shows the PR did not buy anything on the offline side either.What I do have, for the record, is hardware data on one AMD card (RX 9060 XT, RDNA4, 15.2 GB,
amdxc64.dll32.0.32015.7029), because that is the case I was really chasing:0xc0000005insideamdxc64.dll, read 0x8) on some of the ~230 translated compute programs that use implicit-derivative sampling, and the process dies 40–90 s into the world.SampleGradwith quad gradients (valid at 1.6, accepted by the validator) did not help: two runs died at the same address after ~50 s. So the problem on that card is the programs themselves reaching the compiler, not which sample opcode they use.So the AMD case is not something this PR should decide. I will handle it as an opt-in safety net in #1936 (off by default, as you suggested) and keep the translation of these programs untouched. Closing this one.
AI-assisted.
Pull request closed