Shaders: texel offsets, comparison and gather forms of image samples #160
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!160
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/160/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?
@r4tedx on GitHub · 2026-11-24 01:01 UTC · original
r4tedx:shader/image-sampling-family→main· +1765 −117 · 7 files · 6 commits · closed without mergingRebased onto
main58fed37(head3ef252e, 2026-11-24). #634 (image_sample_owith constant offsets) merged and conflicted with this branch inemit/lower.rs. This branch already lowers that form: constant offsets in -8..7 become the same immediates #634 emits, and it also takes offsets past that range or per lane at a known level, which #634 refuses. So the rebase keeps this branch's offset code and uses #634'sModule::int_valueto read the constant. Its offset test (texel_offsets_and_levels_sample_the_texels_they_name) passes on the RTX 5070.cargo test -p victory-shaderat3ef252e: 97 passed, 1 ignored. The measurements below were taken at25e917b, before the rebase.The last commit (
3ef252e) is not part of this change: onmainthe test target ofvictory-shaderdoes not compile (issue #719; #117's test calls #612's changed helper with one argument). It passes the missing argument so this branch's tests can run, and goes away whenmainhas the fix.What
fn imageaccepted a fixed list of sample and gather opcodes; every other MIMG form failed the whole shader. Samples and gathers now lower by their form (comparison, derivatives, coarse or 16-bit derivatives, level, level 0, bias, level clamp, texel offset). The address dwords follow LLVM'sImageDimIntrinsics/SITargetLowering::lowerImageand Mesa'sac_build_image_opcode: offset, bias, reference, derivatives, coordinates, level or clamp.Newly lowered:
_o) onimage_sample,_lz,_l,_b,_d,_c,_c_lz: DXIL immediates when the offset word is a constant in -8..7; otherwise the coordinates move by offset / size, only at a level known at translation._cl(the DXIL clamp argument),_cd(as_d, marked as a shortcut),_g16.image_sample_d,_d_cl,_cd,_g16forms): two derivatives per direction, those of the face coordinates, turned into the direction's derivatives forSampleGrad.image_sample_c,_c_cl(and_o) in compute as well as pixel shaders;image_sample_c_l(_o)at a level known to be 0;image_sample_c_b(_cl)(_o)with a bias known to be 0.image_gather4_l(_o)at any level. A level known to be 0 is a real gather; a run-time level is four samples at the footprint's texel centres at that level, so the sampler's own address mode and level range apply.image_gather4_c_lz(_o)andimage_gather4_c_l(_o)at level 0 throughtextureGatherCmp._g16opcodes have 16-bit derivatives); the decoder onmaincounted them packed, fixed here.image_storeof some channels: the data VGPRs are the dmask's channels in order; the others are written as 0.Still refused, each with its own reason: gathers at an implicit level or with a bias; comparison gathers and cube gathers at a level not known to be 0; comparisons with derivatives, or at a level or with a bias not known to be 0 (SampleCmpLevel is SM 6.7, SampleCmpBias/Grad 6.8); offsets past -8..7 or per lane at a level not known here; offsets, texel coordinates and level queries on cubes.
Measured on the title's shaders
By @EduAzevedo (comments below),
victory translate --jobs 8 --listover the retail 1.0.2.1 shaders,maind2a4baeagainst this PR at25e917b:mainimage_sample_d_cl(all on cubes)a cross-lane operation outside compute)image_gather4_l(compute)a biased image sample with 16-bit coordinatesimage_sample_omainand no longer doValidated, by TrashTalker3460 (comment):
victory translate --validate --listover the 1.0.2.1shaders.rpfalone (26,084 programs, so the baselines are 12 lower than above), with DXC 1.9.2609's validator,maind2a4baeagainst25e917b:mainmainand no longer doAll 12
image_gather4_lprograms and the 23image_sample_d_clprograms that emit also validate. Of the 108 programs freed froma biased image sample with 16-bit coordinates, 36 validate, 48 stop next ata scalar memory read as data, 16 ata lane mask read as data, and 8 emit but fail validation withContainer part 'Program Input Signature' does not match expected for module. Those 8 are pixel shaders of one family (three distinct programs). #201 counts 21 input-signature mismatches of that kind onmain, so they may be that existing problem reached for the first time; whether this PR's sampling path plays a part is not established.With host pipelines, by adnanoos (comment):
victory translate --list --pipelinesovershaders.rpfon an RTX 5060 Laptop,mainffe310eagainst5ce85c5. That run counts 16image_gather4_lprograms where the table above has 12: 10 meshlet-culling compute programs, which all translate and get host pipelines, and 6water_micro_geom_rendererones, which translate and whose pipelines the NVIDIA driver refuses withE_INVALIDARG, as it refuses about 320 compute pipelines onmain. Vertex and pixel modules with pipelines: 12,231 to 12,300. One title run each: the world is black with audio on both;mainended in a device removal and this PR did not, with a warm pipeline library, so that difference is not established.In the title, by nullmarsh (details): on an RX 9060 XT,
d2a4bae+ #135 + #365 + #500 with and without this PR at25e917b, 12 traced world frames per run, 2 runs each. Without it, #293's top G-buffer pixel shader7bdefdfde461f6e3is refused forimage_sample_d_cland everyExecuteIndirecton its pipelines is dropped (692 and 1,017 in the two runs). With it the shader translates and all of them run, none dropped; the run-timeimage_sample_d_clrefusals go from 3 programs to 0. There was no visible change (the frames are still black apart from the title card) and no device loss in those four runs.What those draws write, same tester (target dumps, one run per arm): the pipelines of
7bdefdfde461f6e3(mesh792314eae4f7da77) write six 2560x1440 colour targets and the depth target. Without this PR, and with it but that shader skipped, 5 to 6% of depth is non-background. With this PR, depth is 94% covered with only 6 distinct levels and the colour targets 100% with 1 to 4 levels: the draws now run and cover the screen with near-constant values, not a scene. With #587 on top the targets look like the run without this PR. So a build that takes this PR without a fix for what that mesh program emits (#586 / #587 work on that) gets screen-covering output from these draws. Whether the near-constant colour comes from the geometry alone or also from this PR's sampling is not established.These are two rows of #293's ranking (
image_sample_d_cl,image_gather4_l). The cube gradient and run-time-level gather support were added because of the first run: everyimage_sample_d_clin the title is on a cube, and noimage_gather4_lhas a provably zero level. Not measured: whether the translated programs compute the right result in the title, and whether these cubes are cube arrays (the lowering treats the view as a cube; for an array the face operand adds 8 x the slice, ashortcut:already onmain).Checked against the references
lowerImage, "Bias is of type half but occupies full 32-bit". #73, #136, #306 read it as an f32; noted there.gfx10_asm_mimg.shasimage_sample_d ... 2D a16with five address dwords,image_sample_d_cl ... 2D a16six.DMASK: "Writes: defines which components are written with data from VGPRs (missing components get 0). Enabled components come from consecutive VGPRs."Known limits
shortcut:in the code.image_samplein compute onmainalready does; the tests accept that one error for those forms.Overlap
_cl/image_sample_d_cl, #136 and #360image_gather4_l, #138 cube gradients, #332 partial stores. Where they differ from this PR I have left notes on each with the reference that settles it. Whichever lands first, I will rebase.Tested
Windows 11, NVIDIA RTX 5070, hand-assembled programs:
dxil.dll; refusal reasons are checked; the decoder's address counts are checked against LLVM's.cargo test -p victory-shader: 77 passed. clippy: nothing new.cargo xtask policy: ok.The title was not used in my tests; the title measurements above are the named testers'. AI-assisted.
🤖 Generated with Claude Code
Image samples and gathers now lower by their form (comparison, derivatives, coarse or 16-bit derivatives, level, level 0, bias, level clamp, texel offset) instead of a fixed list of opcodes. The address dwords follow LLVM's ImageDimIntrinsics and Mesa's ac_build_image_opcode: offset, bias and reference a dword each, then the derivatives (16-bit ones two per dword, each direction its own), the coordinates and the level or clamp. The decoder counted 32-bit derivatives for the _g16 forms; it now counts them packed. Newly lowered: - every texel-offset form of the samples above; DXIL immediates when the offset word is a constant in -8..7, else (past -8..7, or per lane) the coordinates move by offset / size at a level known at translation; - _cl (the DXIL clamp argument), _cd (as _d), _g16; - image_sample_c, _c_cl and their _o forms in compute as well as pixel shaders; image_sample_c_l(_o) with a level, image_sample_c_b(_cl)(_o) with a bias known to be 0; - image_gather4_l(_o) with a level known to be 0, image_gather4_c_lz(_o), image_gather4_c_l(_o) at level 0 (textureGatherCmp); - a16 biased samples (the bias an f16 in its dword's low half) and a16 comparisons; - image_store of some channels: the data VGPRs are the dmask's channels, the others are written as 0. Still refused, each with its reason: gathers at an implicit level or with a bias, comparisons with derivatives, at a level or with a bias not known to be 0 (SM 6.7/6.8 operations), and offsets past -8..7 or per lane at a level not known at translation. Tests: hand-assembled compute programs on the RTX 5070 against texels worked out on the CPU (offsets known, past -8..7 and per lane; levels, gradients, g16, bias and clamp through compute quads; comparisons and comparison gathers per texel; partial stores, d16 too), every newly accepted form through the validator, and the refusal reasons. On upstream/main all of them fail ("... is not supported"). Co-Authored-By: Claude Opus 5.5 <[email protected]>ffe310e) into shader/image-sampling-family 5ce85c5e70@DaviTostes on GitHub · 2026-11-24 01:18 UTC · original
Tested
be7369aon Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 57 passed, 0 failed (2 test binaries), including the 6 tests this PR adds.victory-gpuE0425.No game data used.
@r4tedx on GitHub · 2026-11-24 01:43 UTC · original
Pushed one more commit (
7265593) after checking the open points in the description against AMD's ISA reference and LLVM. One was a mistake of mine, two are now settled:Fixed: a16 does not make derivatives 16-bit. The decoder (already on
main) and my lowering took a16 to pack the derivatives too. On GFX10.3 the two are independent: derivatives are 16-bit only in the_g16opcodes, a16 packs the coordinates and the level. LLVM'sSITargetLowering::lowerImagedoes it that way wherehasG16, and its MC testgfx10_asm_mimg.shasi.e. four 32-bit derivatives plus the packed coordinates (and clamp). The decoder test now checks 5, 6, 3 and 7 address dwords for
image_sample_d,_d_cl,_d_g16and_d_cl_owith a16, and a GPU case samples with a16 and 32-bit derivatives; with the old sizing that case reads level 3 at texel 0 where it should read level 0.Settled: the a16 bias.
lowerImagehas "Special handling of bias when A16 is on. Bias is of type half but occupies full 32-bit" and builds{bias, poison}as av2f16, so the bias is an f16 in the low half of its own dword, as this PR reads it. #73 and #136 read that dword as an f32; I left a note on both.Settled: partial stores. RDNA 2 ISA, MIMG
DMASK: "Writes: defines which components are written with data from VGPRs (missing components get 0). Enabled components come from consecutive VGPRs." That is what this PR does, alpha included.Still open: whether the texel offset applies before the address mode.
cargo test -p victory-shader: 75 passed on the RTX 5070. No game data used.@r4tedx on GitHub · 2026-11-24 03:15 UTC · original
A limit of this PR, confirmed by a probe while reviewing the other image PRs with the same scrutiny (RTX 5070): the fallback for texel offsets that are not immediates (past -8..7, or per lane) shifts the coordinates by offset / size of the level the instruction asks for. If the sampler's own LOD range moves the sampled level (probe: requested level 0, sampler MinLOD 1, x offset +1), the immediate form reads x = 1 at level 1 and the shifted form reads x = 0. The code comment already says this case differs; it is silent, not refused, so it belongs here too. An exact form would need the level the sampler actually uses, which the shader cannot know; refusing non-immediate offsets unless the sampler is known not to clamp the level is the conservative alternative if anyone sees it matter in the title.
From synthetic probes only; I have no copy of the title.
@EduAzevedo on GitHub · 2026-11-24 03:19 UTC · original
Follow-up on the 25
image_sample_d_clprograms that stop atan image addresswith this PR: everyimage_sample_d_clin those programs is on a cube (dim:SQ_RSRC_IMG_CUBE), NSA with 8 address VGPRs, noa16. That is two gradients per direction + three coordinates + the clamp; the translator expects three gradients per direction on a cube (10 dwords), runs past the operand list and refuses.#138 handles exactly this (a cube's gradients are its two face coordinates'). #318 (
1d7bf9b) gives the same result as this PR here: the same 25 stop atan image address, 12,328 vertex and pixel programs emitted. So those draws need #138's cube rule on top of whichever_d_cllowering is merged.AI-assisted.
@r4tedx on GitHub · 2026-11-24 03:25 UTC · original
@EduAzevedo thank you, that is exactly the information this PR was missing, and it reproduces here: a hand-assembled
image_sample_d_clon a cube with eight address dwords stopped atan image addresson this branch.Fixed in
b540f51(pushed). A cube's derivatives are those of its two face coordinates, two per direction, then s, t, the face and the clamp. They become the direction's derivatives forSampleGrad:cube_directionis linear in s and t on a face (u = 2s - 3, v = 2t - 3), so the derivative is the same per-face table with 2 ds for u, 2 dt for v and 0 for the constant axis.image_sample_d,_d_cl,_cdand the_g16forms now lower on cubes.Test on an RTX 5070: a cube whose every face and level holds its own value, sampled at each face's centre with derivatives of 1, 2 and 4 texels along s or along t, with and without a clamp; the texel read names the face and the level. With the scale wrong (1 instead of 2) it reads one level too fine, so the test does check the mapping, at face centres.
cargo test -p victory-shader: 76 passed.If you can rerun on
b540f51, three things would tell me whether it is right for the title:shortcut:already onmainand would read the wrong slice. Yes/no is enough.image_gather4_lshaders of #293: do they translate here (level known to be 0), or stop ata gather at a level not known to be 0?On #138: its cube rule is the same idea. The difference between the two PRs is the a16 layout (#138 packs derivatives under a16, which LLVM's
gfx10_asm_mimg.sdoes not; noted there). Since your programs have no a16, that part does not matter for these 25.No game data used on my side.
@EduAzevedo on GitHub · 2026-11-24 03:32 UTC · original
Reran on
b540f51, same setup (retail v1.0.2.1 shaders,victory translate --jobs 8 --listagainstmaind2a4bae):Vertex and pixel programs emitted: 12,284 → 12,357 (12,332 on
7265593).image_sample_d_clprograms: of the 27 refused forimage_sample_d_clonmain, 23 translate; the other 4 stop ata cross-lane operation outside compute(2 of them already did on7265593). The two programs that hitan image addressonmainitself translate too: that reason goes 2 → 0.dim:SQ_RSRC_IMG_CUBEin all of them, which GFX10 also uses for cube arrays; the array size is in the descriptor, which only exists at run time. If it matters I can log the bound views' dimensions in a game run.image_gather4_l: all 12 stop ata gather at a level not known to be 0; none have a level the translator can prove is 0.Everything else versus
main:a biased image sample with 16-bit coordinates108 → 0,image_sample_o4 → 0,v_swap_b3211 → 0 andv_xnor_b321 → 0; the programs that get further now stop ata scalar memory read as data(573 → 621),a lane mask read as data(206 → 222),a descriptor read only as data(179 → 183) anda cross-lane operation outside compute(46 → 50). Nothing that translated onmainstopped translating.@r4tedx on GitHub · 2026-11-24 03:36 UTC · original
@EduAzevedo thank you, this is the first measurement of this PR on the title's shaders, and "nothing that translated on
mainstopped translating" is the line I most wanted to see.The 12
image_gather4_lprograms. Since none has a level the translator can prove is 0, I have added the general case in25e917b(pushed): a gather at a run-time level becomes four samples, the footprint's four texels in the gather's order, each sampled at its centre at that level. At a texel's centre every filter returns that texel, and the sampler applies its own address mode and level range, as it does for the console's gather (this is why I did not usetextureLoads, which would ignore a wrap or border sampler). A level known to be 0 stays a real gather. Still refused: comparison gathers and cube gathers at an unknown level.Test on an RTX 5070: a mipmapped texture whose texels name themselves; lanes gather at levels 0, 1 and 2 passed per lane, with and without per-lane offsets, through a clamp and a wrap sampler; each lane's four values are that level's footprint.
cargo test -p victory-shader: 77 passed.One
shortcut:to know about: the footprint is that of the level rounded to the nearest whole one. A sampler whose LOD bias or range moves the sampled level off that one would read another grid.The rest of your numbers, as I read them:
image_sample_d_clprograms left stop ata cross-lane operation outside compute, which is the SGPR-spill work (#54, #309), not this PR;a scalar memory read as data(621). That is the largest reason in your list by far, and from what I can see the part of #136 that readss_bufferdescriptors is what addresses it. I have asked there whether it can be split out.If you rerun on
25e917b: do the 12 gather programs translate, and what do they stop at next?No game data used on my side.
@EduAzevedo on GitHub · 2026-11-24 03:53 UTC · original
Reran on
25e917b, same setup:image_gather4_lprograms (all compute) translate now; none stops at anything next.image_sample_d_clprograms are as before: 23 translate, 4 stop ata cross-lane operation outside compute.mainstops translating.A correction to my two earlier comments: my
mainbinary had been built before I updated tod2a4bae. Rebuilt and rerun,mainitself already hasv_swap_b320,v_xnor_b320 anda descriptor read only as dataat 183, so those three lines are not effects of this PR. The 12,284 formain, and everything else I reported for this PR, hold against the rebuiltmain. Sorry for the noise.Cube vs. cube array: not done yet; it needs a game run with a small local logging change, so I'll only do it if you think it is worth it.
@r4tedx on GitHub · 2026-11-24 03:54 UTC · original
@EduAzevedo thank you for the rerun and for the correction; I have put your numbers, with the correction applied, into the PR description under "Measured on the title's shaders" and credited them to you. Tell me if I have misread anything: 12,284 to 12,357 vertex and pixel programs, the 12 gather programs translating, 23 of 27 cube
image_sample_d_cl, 108 to 0 biased a16 samples, and nothing lost.Cube vs. cube array: not worth a run on its own. If you (or anyone) are logging bound views in a world run for another reason, the dimension of the views these 23 programs sample would settle it; until then the description says it is unmeasured.
The 4 left at
a cross-lane operation outside computebelong to the SGPR-spill PRs (#54 / #309). If you ever run this PR together with one of those, whether those 4 then translate would be a useful line for that PR's thread.@EduAzevedo on GitHub · 2026-11-24 04:00 UTC · original
Yes, that's all correct against the rebuilt main
@marquezinii on GitHub · 2026-11-24 05:17 UTC · original
Reviewed
25e917band ran it on an NVIDIA RTX 5070 (driver 621.24), Windows 11, with the SDK'sdxil.dllvalidating:cargo test -p victory-shader77 passed. I found no defect.On the a16 bias question raised across the competing PRs: LLVM (
SITargetLowering::lowerImage,{bias, poison}) and Mesa ACO ("pack it into its own dword anyway") both keep an a16 bias as an f16 in the low half of its own dword, which is what this PR reads. A GPU probe with0x7BFFin the high half of the bias dword samples the expected level here, so a reading that takes the whole dword as an f32 would not match. The decoder's address dword counts also agree with LLVM'sgfx10_asm_mimg.sfor the a16_d/_d_cl/_c_d_oforms (derivatives stay 32-bit under a16 unless_g16), and the operand order (offset, bias, z-compare, derivatives, coordinates, level/clamp) matches LLVM and ACO.Four extra GPU probes for cases the PR's tests skip, all passing (81 with them):
b(garbage in the high half),b_o,lat a run-time f16 level,d_clwith packed clamp,gather4_lat a run-time level,c_lzwith a 32-bit reference;d,d_g16and a16d_claway from the face centre;lz_oandl_oat level 1 with linear filtering: 0 of 32 lanes differ;Questions, not defects:
Round_ne; D3D's nearest-mip rule rounds half up, so a level of exactly n + 0.5 can differ. What the console does there is unknown, and theshortcut:already covers it.image_sample_cin compute is newly accepted and, like plainimage_sampleonmain, gives DXIL validator 1.6 rejects for implicit derivatives; harmless while the runtime does not validate, but worth knowing.Not covered: the title (no game data here).
@r4tedx on GitHub · 2026-11-24 05:45 UTC · original
@marquezinii thank you for the review and the extra probes, in particular the one with
0x7BFFin the high half of the bias dword: that is direct evidence for the a16 bias layout the competing PRs disagree on.On the three questions:
shortcut:stays until something decides it.image_sample_cin compute. Right, and it is the same class as plain computeimage_sampleonmain(#201). #180 replaces implicit-derivative compute samples withsampleGrad, but SM 6.6 has no comparison sample with gradients, so comparison samples are the part that stays. In the tester tree (integration/testerson my fork) those modules declare validator 1.8, taken from #306, which accepts derivatives in compute; that is a resolution made when merging there, not part of this PR.If you are willing to share the four probes, a PR against
shader/image-sampling-familyon r4tedx/VIctory would let me add them under your authorship.No game data used. AI-assisted.
@ghost on GitHub · 2026-11-24 06:39 UTC · original
Validation for
25e917bon the title's shaders, to go with @EduAzevedo's translation counts in the description. Same comparison, plus the DXIL validator.Setup:
victory translate --validate --listover a local 1.0.2.1shaders.rpfonly (no executable, so 26,084 programs; the baselines are 12 lower than the description's).maind2a4baeagainst this PR at25e917b. The validator is DXC 1.9.2609's (dxv). Itsmaincounts are the same as @Halfect's with the SDK'sdxil.dllon #293 (12,172 / 1,670 / 8,129). Counts and refusal reasons only.main25e917bmainand no longer doBy the rows of the description:
image_gather4_l: all 12 emit and validate.image_sample_d_cl: the 23 that emit all validate; the other 4 stop ata cross-lane operation outside compute, as in the description.a biased image sample with 16-bit coordinates(108): 36 validate, 48 now stop ata scalar memory read as data, 16 ata lane mask read as data, and 8 emit but fail validation withContainer part 'Program Input Signature' does not match expected for module.The 8 are pixel shaders of one family (three distinct programs, each in several containers). #201 counts 21 input-signature mismatches of this kind on
mainalready, so these may be that existing signature issue now reached, rather than something in the sampling path. I haven't checked which. Their container offsets and hashes are available if you want to look.Not measured: host pipelines (no D3D12 here) and results in the title.
AI-assisted (Claude Code); counts were cross-checked against the per-program listings of both runs.
@r4tedx on GitHub · 2026-11-24 06:43 UTC · original
@TrashTalker3460 thank you. Validation was the missing half of the counts in the description, and "0 programs that validated on
mainand no longer do" is the line that matters most for anyone merging this. I have added your table to the description, with the eight failures stated as open.On those eight (
Container part 'Program Input Signature' does not match expected for module): I agree with your reading that it is probably the existing signature problem reached for the first time, but I cannot show it from here. This PR does not write the input signature; it changes how image addresses are read and what the samples lower to. A pixel input that is only used by a newly translated sample could still change which signature rows the emitter lists, so it is not ruled out either.One run would separate the two, if you have the time. The tester tree (
integration/testerson my fork, head46ca402) carries this PR together with the signature fixes #176 (packed fp16 pixel inputs paired with unlisted signature rows), #306 and #286:Nothing was run for this note. AI-assisted.
@r4tedx on GitHub · 2026-11-24 06:47 UTC · original
@catminou4 thank you, a macOS build is one this PR had not had.
On the scope note, so it does not read as an open blocker: the Windows-only GPU tests (
image_tests,valu_tests) have been run at this head on two machines. Mine is in the description under "Tested" (RTX 5070 and WARP), and an independent one is marquezinii's review on another RTX 5070, withdxil.dllvalidating:cargo test -p victory-shader77 passed, plus four extra GPU probes of theirs. Not covered by anyone yet: an AMD adapter for the new image tests.Nothing was run for this note. AI-assisted.
@ghost on GitHub · 2026-11-24 06:54 UTC · original
In-game result for
25e917bon AMD RDNA4 (RX 9060 XT): #293's top G-buffer pixel shader7bdefdfde461f6e3translates with this PR and all of itsExecuteIndirectcalls run (692 and 1,017 in two traced runs; all dropped without it). Details: #318AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@r4tedx on GitHub · 2026-11-24 06:56 UTC · original
@nullmarsh thank you, that is the number I asked for on #318 and the first result for this PR from inside the title:
7bdefdfde461f6e3translates, and everyExecuteIndirecton its pipelines runs (1,017 and 692) where all were dropped before.I have added it to the description, with your two caveats kept: no visible change, and four short runs.
That the picture does not change is consistent with what others are finding on #71 today: on builds that survive in the world, the scene reaches a full-resolution
f62target while depth and the G-buffer stay nearly empty, so this shader running is necessary for the G-buffer, not sufficient. If your per-draw trace can say what this shader's draws now write (which targets, and whether anything non-background lands in them), that would show how far down the frame the next gap is.Nothing was run for this note. AI-assisted.
@ghost on GitHub · 2026-11-24 07:25 UTC · original
@r4tedx Target dumps (
VICTORY_DUMP_TARGETS) on the same stack, one run per arm, the two frames after a 1,000-draw trigger.7bdefdfde461f6e3's pipelines (mesh792314eae4f7da77) write six 2560x1440 colour targets (f27, four f28, f34) and the f19 depth target. Share of non-background pixels, both frames alike:25e917b7bdeskipped1052a90So with #160 alone, this shader's draws cover the screen with near-constant values, consistent with #586's culled-group case. With #587 the targets look like the control: whatever these draws write is not visible here, and I can't tell whether they are culled, off-screen or suppressed by #587. #586's count fix needs its stack, so I didn't test it.
AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@r4tedx on GitHub · 2026-11-24 07:31 UTC · original
@nullmarsh thank you, that is exactly the measurement I asked for, and it is a caveat on this PR that belongs in the description; I have put it there.
How I read your table, with what I cannot tell from here:
792314eae4f7da77emits, not at the sampling this PR adds. That #587 (mesh output bounds, every primitive initialised) takes the targets back to the control fits that.If you run it once more, the arm that would separate the two questions is this PR with #587 and with the mesh program's draws counted: do
792314eae4f7da77's dispatches still run and emit primitives there (then they are culled or off-screen and the pixel shader never executes), or are they dropped?Nothing was run for this note. AI-assisted.
@slint6614-dev on GitHub · 2026-11-24 07:32 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate, against maind2a4bae(emitted / validated):cargo test -p victory-shaderimage_gather4_l(12 refusals, all compute): cleared by #694, #160 and #136; the 12 programs then validate.image_sample_d_cl(27 refusals): cleared by #694, #563 and #160, but only #563 (cube gradients) turns 25 of them into validated pixel programs; with #694 they stop on another reason.Windows 11, dxil.dll from SDK 10.0.26100.
@ghost on GitHub · 2026-11-24 07:44 UTC · original
@r4tedx From the #160 + #587 run's trace: in both matched frames all 332 operations on this shader's pipelines ran (
ExecuteIndirect, none dropped), and mesh792314eae4f7da77translates. Whether its groups emit primitives isn't something the trace can see: it records that the call was issued, not what the GPU produced. That would take a pipeline-statistics query around these calls; I have no counter for that here.AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@r4tedx on GitHub · 2026-11-24 07:47 UTC · original
@slint6614-dev thank you for putting the four PRs side by side on one corpus; the #160 row matches the two earlier counts (12,345 / 12,237 and 1,705 / 1,682).
One correction to the second bullet, from your own table: this PR does turn the
image_sample_d_clprograms into validated pixel programs. Its +65 validated vertex and pixel programs overmainare more than #563's +25 because they include them: 23 of the 27image_sample_d_clprograms emit and all 23 validate (TrashTalker3460's breakdown); the other 4 stop ata cross-lane operation outside compute. The cube gradient rule those need has been in this PR sinceb540f51. It is #694 where they stop on another reason, as you say.The 8 input-signature failures are right and are in the description as open; whether they are the signature problem #201 already counts on
main, reached for the first time, is not settled.Nothing was run for this note. AI-assisted.
@r4tedx on GitHub · 2026-11-24 07:50 UTC · original
@nullmarsh thank you, that closes what a trace can close. With #160 and #587 together the shader translates, mesh
792314eae4f7da77translates, and all 332 calls on their pipelines are issued, none dropped; yet the targets look like the run without #160. So the calls reach the GPU and what they produce is the unknown: primitives culled or emitted off-screen by the mesh program, or pixels that are drawn and rejected.As you say, that needs a count from the GPU, not from the trace: pipeline statistics around those calls (mesh primitives out, pixel shader invocations). Nothing in the tree records that today; I will note it as the missing diagnostic rather than ask you for another run.
For readers deciding about this PR: its part is that the shader translates and its draws run. What those draws put in the targets depends on the mesh program's output, with or without #587, and that is not settled by anything here.
Nothing was run for this note. AI-assisted.
@ghost on GitHub · 2026-11-24 10:35 UTC · original
@r4tedx I tried that counter on
25e917bwithout #587 (d2a4bae+ #135 + #365 + #500 + this PR, local patch, not a PR: aPIPELINE_STATISTICS1query around every draw, mesh dispatch andExecuteIndirectof the listed frames; RX 9060 XT, driver 32.0.32029.2010). On AMD it changes the case it was meant to measure:7bdefdfde461f6e3calls, depth and G-buffer are about 5% covered, as without this PR, and about 100 of ~240 dumped targets are non-empty (93–99 without this PR).So what these draws emit without #587 depends on whether queries wrap the frame's work, which fits undefined mesh output. The counts themselves don't settle it: most
ExecuteIndirectcalls read 0 under the queries, including ones writing the G-buffer, and I can't yet tell whether the counter misses indirect work on this driver.AI-assisted (Claude Code, Claude Opus 5.5); no game data.
@MrCloudy2 on GitHub · 2026-11-24 10:59 UTC · original
Tester result: +11 of 339 previously failing world programs now emit (vertex/pixel 0 → 4 of 25, compute 32 → 39 of 272). That includes all seven meshlet-culling compute programs in this set that stopped on
image_gather4_l is not supported; their level is computed per lane, which this PR's run-time-level path covers. Merged together with #539 and #571 the gains add up exactly: vertex/pixel 11, compute 41.How measured: 339 shader containers from my own 1.0.2.1 copy, the distinct programs that logged
shader does not translatein two world runs, each matched to its container by the BLAKE3 VIctory logs. Each PR was merged on its own onto one base:main8e79c80+ #151 #190 #454 #493 #579 + #177's key fix + the wave64 stack via #439. I then ranvictory translate <folder>(diag build, CPU only) and compared DXIL emitted per stage against the base (vertex/pixel 0 of 25, compute 32 of 272, mesh 0 of 13). Linux, Proton-CachyOS wine, cross-built with xwin, RTX 3060 host (only matters for the wave64 part of the base). Translation counts only, not image correctness. AI-assisted (Claude Code).@DeerSilver on GitHub · 2026-11-24 11:01 UTC · original
Tested head
6ad7e15merged ontomainffe310eon NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only.Merged onto current
main, the test build fails.6638098("per-lane descriptors chosen by control flow", merged with #566 at 09:53) added a fourth argument toresource::track:There's no text conflict, so GitHub still shows the PR as mergeable, but merging it as it is would break
cargo testonmain. The call this PR adds needs the fourth argument.main's own tests passSome(&st);Nonekeeps the old three-argument behaviour.With
, Noneadded locally to that call, everything passes:no SM 6.6 deviceskip:texel_offsets_and_levels_sample_the_texels_they_namegathers_at_a_run_time_level_read_that_levels_footprintcomparisons_and_comparison_gathers_match_per_texel_comparisonscube_gradients_are_the_face_coordinatesstores_of_some_channels_write_zero_to_the_otherssample_and_gather_forms_lower_to_valid_dxilforms_without_an_sm_6_6_equivalent_name_whyimage_address_dwords_by_formcargo test --workspace --locked: 350 passed, 0 failed, 6 ignored, against 342 passed / 6 ignored onmain.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.AI-assisted (Claude Code).
@r4tedx on GitHub · 2026-11-24 11:07 UTC · original
@nullmarsh, thanks for tracing
7bdefdfde461f6e3back to the G-buffer pass. The two RX 9060 XT runs answer the question on #318: this shader reachesExecuteIndirectwith #160, and the baseline drops those calls. That gives this PR an AMD in-game result alongside the Windows synthetic image tests. The trace measures draw execution; the final pixel values are a separate measurement.AI-assisted (Codex).
@r4tedx on GitHub · 2026-11-24 13:48 UTC · original
@DeerSilver you are right, and thank you for testing the merge and not just the head. Reproduced here:
6ad7e15merged withmainffe310efails to build its tests atemit/image_tests.rs:230, with the error you quote. GitHub showed the PR mergeable and its check green because that run was before #566 landed.Fixed in
5ce85c5:mainis merged in, and the helper structures the program first and passes it (Some(&st)), asmain's own tests do, notNone. Nothing else changes.On the result, on an RTX 5070 here: both CI clippy commands are clean, and
cargo test --workspace --lockedgives 350 passed, 0 failed, 6 ignored, the count you got with your local fix. The same run withVICTORY_WARP=1, which is what the CI runner has, also gives 350.The title was not used in these tests. AI-assisted.
@r4tedx on GitHub · 2026-11-24 14:08 UTC · original
A note for anyone stacking this PR with #180 (@permadiego, @h0useadv): the two merge without a text conflict, but the result samples wrong texels for three compute sample forms, and validation does not see it.
What fails. With
5ce85c5and #180 ataa69258merged, this PR'stexel_offsets_and_levels_sample_the_texels_they_namefails on an RTX 5070 for bias with offset (b_o), level clamp (cl) and bias with clamp and offset (b_cl_o), and only those. Each PR alone passes. (Found in a stack built like the one reported on #293; I did not run that stack myself.)Why. #180 emits compute
image_sampleandimage_sample_bassampleGradwith the console quad's differences. Its arm reads the bias at address 0 and passes no level clamp:This PR adds the forms where that no longer holds: with a texel offset the bias comes after the offset word (and is an f16 with
a16), and_clforms carry a clamp. Git keeps #180's arm as it is, so those forms read the offset word as the bias and drop the clamp.The change the combination needs, in that arm, using what this PR already computes:
The tester tree has carried both PRs with exactly this since its #180 merge, and the test above passes there (one run today on an RTX 5070, 487 workspace tests). Neither PR can hold the change alone while the other is open, so it belongs in whichever lands second. If #180 lands first I will put it in this branch's merge with
main; if this one lands first, the two lines above are what #180 needs.The title was not used in these tests. AI-assisted.
@pablogonz12 on GitHub · 2026-11-24 16:20 UTC · original
Measured on Linux (RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master), head
5ce85c5, which already mergesffe310e:--host-lanes 32-64), before -> after: vertex+pixel 13146 -> 13171 (+25), compute 2404 -> 2420 (+16), mesh 8396 unchanged; total 23946 -> 23987 (+41), 0 regressions.cargo test -p victory-shader --lib: 118 pass, only the knownindexed_move_initializes_an_input_before_its_first_usefailure; xwin clippy--workspace --all-targetsclean.Not tested: in-game on this branch; native Windows.
@Yaekai on GitHub · 2026-11-24 16:36 UTC · original
Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
5ce85c5:cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 110 passed, 0 failed.cargo clippy -p victory-shader -- -D warnings: 0 warnings.1.0.2.1,--console series-s, 19-min world run): no regressions. Ready to merge!@adnanoos on GitHub · 2026-11-24 18:01 UTC · original
Tested this PR (
5ce85c5, merged with mainffe310e) on an NVIDIA GeForce RTX 5060 Laptop GPU (driver 32.0.16.2124, Intel Core 7 240H, Windows 11 Pro 26200), title files version 1.0.2.1 (title exe BLAKE3b99f876b…239e93).cargo test --release -p victory-shader: 128 passed, 0 failed, 1 ignored (GPU tests on the RTX 5060).victory translate --list --pipelinesonshaders.rpf(26,084 programs), main vs this PR:image_gather4_la biased image sample with 16-bit coordinatesimage_sample_d_cla scalar memory read as dataa lane mask read as dataa cross-lane operation outside computepipeline: The parameter is incorrect.Nothing else changed. On this build there are 16
image_gather4_lprograms (the description counts 12):meshlet_cullingprograms (CS_BatchCullMeshlets*,CS_BatchCullPreSkinnedMeshlets*,CS_BatchCullBatchCSMeshlets*, incl._Prev/_ParaboloidShadows) now translate and create host pipelines.water_micro_geom_rendererones (CS_GenerateWaterPatches*,CS_GenerateWaterPatchWritingJobs*,CS_CullWaterPatches*) translate, but the NVIDIA driver refuses all 6 pipelines withE_INVALIDARG. These are the +6 in the last row, the same refusal as the ~320 compute pipelines on main (looks like #71's class, not this PR).In the title (one run each, Series X mode,
GpuPreference=2so the dGPU is used):DXGI_ERROR_DEVICE_REMOVED/0x887A0006(device removed after a submission of 11 lists; no breadcrumbs).Caveat: one run each, and the PR run had a warm pipeline library, so the timing and the missing hang are not conclusive. Happy to run more passes or a diag build with
VICTORY_D3D12_DEBUG=1if that helps.@r4tedx on GitHub · 2026-11-24 18:33 UTC · original
@adnanoos thank you. This adds the one thing the earlier counts did not have, host pipelines, and it corrects a number: your run finds 16
image_gather4_lprograms where the description's table had 12. I have put your result in the description next to that table, with the split you give (the 10 meshlet-culling programs translate and get pipelines; the 6 water ones translate and the driver refuses their pipelines withE_INVALIDARG).On those 6: I read them as you do. The translation is accepted by the validator and refused at pipeline creation, like the roughly 320 compute pipelines
mainalready loses on NVIDIA, so they belong with that class and not with this PR's lowering. If your--listoutput names the same refusal text for them as for the 320, that settles it; if theirs differs, I would like to know.On the title runs: agreed that one run each with a warm pipeline library does not establish the missing hang, and you say so yourself. No need for more passes on this PR's account. If you do run again, the comparison worth having is both builds on a cold cache.
@Yaekai thank you as well for the run on the RTX 3070, here and on #265.
The title was not used in my tests. AI-assisted.
@adnanoos on GitHub · 2026-11-24 18:38 UTC · original
Checked the saved
--listoutput. The 6water_micro_geom_rendererprograms (CS_GenerateWaterPatches,CS_GenerateWaterPatches_WithLODStitching,CS_GenerateWaterPatchWritingJobs,CS_GenerateWaterPatchWritingJobs_WithLODStitching,CS_CullWaterPatches,CS_CullWaterPatchesUsingCalmingInfo) report exactlypipeline: The parameter is incorrect., the same text as all 320 on main (allCs). A set diff of the refused programs: this PR adds exactly those 6 and removes none, so 320 becomes 326 with no other change.One limit: the listing records only the HRESULT text, not the driver's reason, so this shows the same error code rather than the same cause. If it would help, I can rerun those 6 with the debug layer on and post the messages next to a few of the 320.
On the title: noted. If I run it again, it will be both builds on a cold cache.
@r4tedx on GitHub · 2026-11-24 18:44 UTC · original
@adnanoos thank you, that settles it as far as a listing can: the same text for the 6 as for the 320, and a set difference of exactly those 6. The description already says they are refused the way
main's are, so nothing to change there.On your offer: the debug-layer messages for those 6 next to a few of the 320 would be useful, but for the issue that tracks those refusals (#71's class) rather than for this PR, which only moves the 6 from "refused by the translator" to "refused by the driver". If you do run it, that is where I would post it.
AI-assisted.
@upipibi on GitHub · 2026-11-24 20:58 UTC · original
In-world evidence for the explicit-level gathers here, from a fork that runs
main+ its own changes into the world: fxceless/victory-gta6 (README, "Gathers at a named mip level read level 0"; the comment at itsimage_gather4_llowering).The fork found that a host gather (DXIL op 73, no level) reading level 0 where the title names one broke the title's meshlet occlusion culling. The culling gathers a 4×4 block of the depth pyramid at a named level: one
image_gather4_land threeimage_gather4_l_owith offsets (2,0), (0,2) and (2,2). Read at level 0, "most of the world was culled against the wrong depths". The fork reads the four texels at the named level instead, with the offset in texels of that level.That is what
gathers_at_a_run_time_level_read_that_levels_footprintchecks here (gather4_l_oat a per-lane level included). It also means #694, which mapsimage_gather4_lto op 73 and so reads level 0, would translate those programs but cull most of the world.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 00:19 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-shader/src/emit/host.rs,crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/mod.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@r4tedx on GitHub · 2026-11-25 05:14 UTC · original
Closing this rather than rebasing it.
mainmoved 319 commits on and got its own lowering of the image forms this title uses from other PRs; what is left of this one is unused by the title. The change is not wrong.By count. Local title data (v1.0.2.1, the main shader archive), offline, CPU only; counts and reasons only.
main940d32f(translate --validate --list, 25,889 programs counted): 23,918 validate; the translator refuses 298, under 10 reasons. None names an image instruction.main's own binary over the archive's 26,503 containers (all 26,084 programs decode): every image sample, gather, load and store instruction the title uses occurs in programs that validate onmain, the 16 containers withimage_gather4_land the 16 withimage_gather4_l_oincluded. The forms this PR adds beyond that do not occur: no offset form other thanimage_sample_o(4 containers),image_gather4_lz_o(6) andimage_gather4_l_o, no comparison form other thanimage_sample_c_lz, no_cd, no_g16, no level clamp without derivatives, and everyimage_storewrites all four channels.By what is read. A count cannot show whether
mainreads the right texels, so this PR's GPU tests were ported ontomain940d32fwithout its lowering and run on WARP (one test thread; no hardware GPU):image_sample_b,_lat per-lane levels,_lz,_d,_d_cl,_c_lz,image_gather4_lzandimage_gather4_lz_o(offset known and per lane), 9 of 9 cases; and gathers at a level in the formmaintakes (immediate border sampler, whole level),gather4_l_oper lane andgather4_lat levels past the last, 2 of 2.main, each with a reason (<mnemonic> is not supported,a gather at a level through a sampler from memory,an image store of some channels). Refused, not mis-read; and per the count the title has none of them.main:image_sample_dwith 16-bit addresses (a16).mainpacks the derivatives two per register along with the coordinates; this PR keeps derivatives as 32-bit floats and packs only coordinates and level, which is what LLVM's assembler tests have for GFX10 (image_sample_d … dim:SQ_RSRC_IMG_2D a16takes five address registers, and the_g16opcodes exist for 16-bit derivatives). Onmainthe test reads level 3's texel (0,0) in 32 of 32 lanes where the footprint's texel is expected, and the decoder counts 3 address dwords for 5. The title does not use it: none of its 2,901 containers withimage_sample_dand none of the 29 withimage_sample_d_clhasa16. So I am not opening a PR for it. The ported tests and a 35-line fix are on the fork, branchcheck/image-tests-on-main(4467705tests onmainas it is,f85e0abthe fix,63c2d06the gather test); with the fix the case passes. If a maintainer wants that as a PR, say so here and I will send it. Not checked against the console's own compiler or hardware.@upipibi thank you for the in-world evidence. The case you describe, the culling's 4×4 block of the depth pyramid read with one
image_gather4_land threeimage_gather4_l_oat a named level, is whatmain's own gather at a level now covers: the 16 containers with those instructions validate onmain, and this PR's footprint test, adapted tomain's form, passes there. So that fix no longer needs this PR. Whatmainstill refuses is a gather at a level through a sampler read from memory, which the title does not have.Limits. The count and the passes cover one archive, not shaders elsewhere in the title. A refused program reports only its first reason, so a refused image form could still sit behind another reason in the programs
mainrefuses at emit; by instruction name there is none. All test results are from WARP.The branch
shader/image-sampling-familystays on the fork at5ce85c5; if a program turns up that needs one of its forms, I will reopen this on currentmain.Thank you to everyone who tested and measured this head.
AI-assisted
Pull request closed