Shaders: lower the pixel ordered section (POPS) as rasterizer-ordered UAVs #215
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!215
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-215"
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?
@arminkhaleghirod on GitHub · 2026-11-24 22:36 UTC · original
shader/hardware-sgpr-input→main· +71 −1 · 3 files · 1 commits · closed without mergingFixes the 10
emit: a hardware SGPR inputfailures.All 10 are one pixel-program shape that uses the console's primitive-ordered pixel shading (POPS). It reads s18, the entry word above the user data, sets the packer register (
s_setregtoHW_REG_POPS_PACKER), spins untilsrc_pops_exiting_wave_idpasses the earlier wave, then does an ordered read-modify-write on UAV images.The host equivalent is a rasterizer-ordered view. So for a pixel program that enters POPS:
s_setregis a no-op.Full-title
translate --validate, RTX 4080:a hardware SGPR input10 → 0. The 10 land in the blanket PSV mismatch, and no other count changes.--pipelinescreated a host pipeline for one of them.Not checked in the game yet (I don't know where these programs draw).
cargo test -p victory-shader --lib: same as main (the two rectangle tests that fail on main still fail). Clippy is clean.@JRamos1993 on GitHub · 2026-11-25 06:11 UTC · original
Offline check on the retail shader pack: merged onto current
main310c6eb, this PR fixes all 10 POPS pixel programs (the "a hardware SGPR input" ones) and loses none. 59 compute programs' DXIL changes, and all of them still validate.Setup: RTX 5090, Windows 11.
victory translate --validate --listover the title's full shader pack (26,084 programs), with a local DXIL hash on each validated line.main310c6ebmain(the collision-wave SGPR of the ordered section)bitcode/opt.rspart. I have not looked into what changes in them, or whether it matters at run time.main, and it still merges cleanly.AI use: Claude Code with Claude Opus 5.5 ran the pack and wrote this. Nothing from the title is in it.
@JRamos1993 on GitHub · 2026-11-25 06:17 UTC · original
Follow-up on the 59 compute programs whose DXIL changes. The module is the same; only its encoding differs. I checked 5 of the 59:
dxc -dumpbingives the same text formain's DXIL and this PR's: IR, metadata and the header comments.So the bytes differ in the bitcode encoding, probably from the
bitcode/opt.rspart, not in the program. Nothing for this title's compute shaders changes in behaviour.AI use: Claude Code with Claude Opus 5.5 compared the dumps and wrote this.
@MKmajster on GitHub · 2026-11-25 11:53 UTC · original
Tested on a combined tree, offline: the pixel programs that stopped with "a hardware SGPR input" all translate with this PR.
Tree.
skornuta/victory-forkmain(this repo's310c6ebplus ZSlayerHQnext), with the LooperSalty/victory lot, #188, #258, #806 and #739 of this repo, then this PR (776ec56).Offline,
victory translate --listover the title's shader pack (26,084 programs; counts are refusals at emission). "Before" is the tree without #806, #739 and this PR; "after" has all three:cargo test -p victory-shader --lib: 238 passed, 0 failed, 3 ignored (235 on the tree before the three PRs).One conflict, easy: on that tree, #258 adds an
Operand::Const(253)arm (src_sccread as an operand) in the samematchwhere this PR addsOperand::Const(POPS_EXITING_WAVE_ID)(239). Both arms stay; the constants differ, so neither shadows the other.Not verified: a game run with this tree, and the ordering itself on the GPU (no rasterizer-ordered output was compared against a reference). The numbers above are the offline pack and the unit tests only.
AI-assisted (Claude Code). No game data attached.
@KainanP on GitHub · 2026-11-25 13:30 UTC · original
Tested
776ec56merged ontomain0b0074e(clean merge) on three adapters. The upstreamvictory-shadertests give the same results asmainon each adapter. A local synthetic POPS program translates, validates and gets a host pipeline on all three with this PR, and is refused onmain. Ordering itself is still untested: no test draws overlapping primitives.ROV support (
D3D12_OPTIONS.ROVsSupported, queried per adapter)10de:28a08086:a78b1414:008cAll three support ROVs, so I could not test an adapter without them. From reading the code (not measured): the PR has no host-side check for ROV support. On such a device the translated shader would carry the ROV feature bit,
CreateGraphicsPipelineStatewould fail, andpipeline/host.rswould log "host pipeline refused" and drop the draw. That fails cleanly: those draws are dropped today anyway. Separately, the guest-facingdevice.rsreports ROVs as supported regardless of the host.Upstream tests,
cargo test -p victory-shader --lib --locked --no-fail-fast(Windows 11, rustc 1.98.1)victory-gpuis not touched by the PR, so I didn't run it.main0b0074emain+ #215VICTORY_WARP=1)emit/host.rs, not committed)The failures already happen on
main, so none are new:ds_min_max_f32_order_floats_and_return_the_old_value,v_permlane16_and_x16_read_the_lanes_their_selectors_pickandwhole_wave_f64_sum_and_cvt_f32_f64(compute pipelineE_INVALIDARG), pluswave64_tests::a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is.valu_tests, plus the 4intersect_tests::the_{32,64}_bit_node_test_*.The PR adds no tests. The two rectangle tests the PR body says fail on
mainpass on currentmainon the RTX.Synthetic POPS program (local test, not committed)
The GFX10 words follow the shape #721 describes:
s_lshr_b32/s_and_b32of s18.s_setreg_b32 hwreg(HW_REG_POPS_PACKER).s_cmp_eq_u32bit-31 gate.s_mov_b32 sN, src_pops_exiting_wave_id/s_cmp_lt_u32/s_cbranch_scc1.buffer_load_dword … glc dlc→ add →buffer_store_dwordon a raw UAV from a descriptor table.s_sendmsg MSG_ORDERED_PS_DONEandexp mrt0.maina hardware SGPR input0x1000(ROVs);dxil.dllvalidates;Host::pipelinecreates the PSO on all 3dxc -dumpbinof the output: "Raster Ordered UAVs" is listed in the required features, the handle is annotated{ i32 12299, … }(ROVByteAddressBuffer), and the wait loop folds away entirely (no spin remains).One pitfall I hit: my first version read barycentrics, and Intel UHD refused that PSO because it has no barycentrics support. It was not an ROV problem. Without barycentrics, Intel takes the ROV pipeline.
What a real ordering test would need (missing)
This only proves the program translates, validates and gets a pipeline. Nothing checks that accesses happen in primitive order. A test that does needs:
RWTexture2D/raw UAV, e.g.v = v*3 + primitive_id.The test host's
Drawonly draws one triangle and binds no UAVs, so this needs harness work first.Review (code reading; hypotheses unless marked)
props0bit 12 is IsUAV and bit 13 is IsROV, shader flag bit 18 is ROVs, and SFI00x1000is ROVs. The flags are re-derived from usage after optimisation, so a ROV handle that gets optimised away also drops its flag. HW_REG id 25 and source 239 areHW_REG_POPS_PACKERandsrc_pops_exiting_wave_idon GFX10. The other SOPP messages, includingMSG_ORDERED_PS_DONE, already lower to no-ops.opt.rs.let ordered = self.m.md_value(self.m.bool(self.rov))is created inside the root-UAV loop for every shader, andModule::md_valuealways pushes a new metadata entry with no dedup. That makes each root UAV one metadata record larger even whenrovis false. This fits "same-dumpbin, container 4–8 bytes larger". Fix: reusenowhen!self.rov, and build thetruevalue once outside the loop.DB_SHADER_CONTROL(native.rs,PS_DB_SHADER_CONTROL). If I have the GFX9/10 layout right, its bit 16 (PRIMITIVE_ORDERED_PIXEL_SHADER) is the authoritative flag, and bits 22:20 (POPS_OVERLAP_NUM_SAMPLES) give the overlap granularity. Cross-checking against it would catch a POPS program whose wait readssrc_pops_exiting_wave_idthrough a VALU (that fails closed today). It would also catch the case where s18 is zeroed for a non-POPS program that happens to set reg 25 (unlikely).Commands:
git fetch origin '+refs/pull/*/head:refs/remotes/pr/*', a worktree atorigin/main+git merge pr/215,CARGO_BUILD_JOBS=6, thecargo testabove once per adapter, anddxc.exe -dumpbin(Windows SDK 10.0.26100). No game data used.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
@KainanP on GitHub · 2026-11-25 13:52 UTC · original
Follow-up: an ordering test for this PR. It fails on the RTX 4060 and on Intel UHD. Both drivers leave a rasterizer-ordered view unordered when the shader opens it from the descriptor heap, and that is how this PR's UAVs reach the shader. On WARP it passes, but there it proves nothing (see the control). I also fixed the extra root-UAV metadata entry: the DXIL is now byte-identical to
mainfor every program the tests translate.Two commits on top of
776ec56, so you can pick either one alone:fe3262emakescargo testfail on NVIDIA and Intel until the ordering works. If you want to keep the suite green for now, take only293d117.What the test checks (
emit/pops_tests.rs)Harness (
emit/host.rs):Drawnow takestriangles(N triangles in oneDrawInstanced) anduav_dwords(a zeroed raw UAV placed after the textures in the heap).draw_with_uavreturns that UAV's contents.passthrough_vsfeeds the pixel shader's inputs from the vertex buffer.drawcallers are unchanged apart from the two new fields set to 0.Program: a synthetic GFX10 pixel program with the same shape as #721:
s_setreg_b32 hwreg(HW_REG_POPS_PACKER).src_pops_exiting_wave_id.v_interp_mov_f32of a flat attribute (k, the triangle's number).buffer_load_dword … offen glc dlc.v = v*31 + k, thenbuffer_store_dword.s_sendmsg MSG_ORDERED_PS_DONE,exp mrt0.The UAV comes from a descriptor table, so the translation opens it with
createHandleFromHeapand annotates itROVByteAddressBuffer(props012299). SFI0 has the ROVs bit, anddxil.dllvalidates it.Draw: 64 full-screen triangles numbered 1..64 in one draw on a 32×32 target, run 4 times. Every pixel must equal the serial result
fold(0, v*31+k)=0x94504420. The update does not commute, so any race or reordering shows up.Results (
main0b0074e+ #215 + these two commits; RTX and WARP give the same at bare776ec56+ the two commits)10de:28a08086:a78b(local adapter hook, not committed)With 2 triangles, RTX ends with 1 or 2 instead of
0x21. Both triangles read 0, so their sections overlap completely. With #215, the program behaves on the hardware exactly like the control without ROV. WARP runs overlapping pixels one after another anyway, so it cannot tell the two apart.Why: heap-indexed ROVs are not ordered on these drivers (checked with dxc, not the translator)
Next I wanted to know whether the problem is the translation or the hardware. I compiled the same RMW from HLSL with
dxc -T ps_6_6(Windows SDK 10.0.26100) and ran it in the same harness (n = 64; wrong pixels out of 1024 in each of 3 draws):RasterizerOrderedByteAddressBuffer b = ResourceDescriptorHeap[0]RWByteAddressBufferfrom the heap (no ROV)RasterizerOrderedByteAddressBuffer b : register(u0, space1)(root UAV)RWByteAddressBuffer : register(u0, space1)if (t.y == 12345.0)(never true)rov_heapis what this PR emits, and dxc emits the same handle (annotateHandle … { i32 12299, i32 0 }). It carries the ROVs feature flag and is still unordered on both drivers. As soon as the shader references any ROV declared indx.resources, the heap ROV accesses are ordered, even if that reference never runs. My reading is that both drivers turn on pixel-shader interlock based on the declared resources, not on the annotate props or the SFI0 flag. I don't know whether the D3D12 spec promises ordering for heap-indexed ROVs. Either way, these two drivers don't provide it.That suggests a fix, which I have not implemented because it touches the host's bindings. When
rovis set, give the program one declared ROV and reference it in a branch that never runs. The root UAV path already writes the "rasterizer ordered" field in its metadata, from this PR.SLOT_FAULTSis a candidate, butvictory-gpubinds it only when the program also readsSLOT_MEMORY(draw.rs,memory), so the binding would have to be guaranteed for these programs. The test above would show whether the fix works.Metadata fix (
293d117)md_valueadds an entry on every call, so the per-root-UAVorderedadded one metadata entry to every program with root UAVs, even withrovfalse. The fix reusesnowhenrovis false and builds thetruevalue once. Evidence:Module::mds.len()after the root-UAV list,intersect_tests::a_descriptor_of_numbers…, 1 root UAV,rovfalse):main27, #215 28, with the fix 27.lower::lowerreturns during the wholevictory-shaderlib suite (117 programs). #215 vsmain: the 2 programs with a root UAV are each +4 bytes, and the other 115 are identical. Fix vsmain: all 117 are byte-identical, container hash included.dxc -dumpbinre-uniques the metadata, so the listing looks the same either way. That matches JRamos1993's finding of the "same module, encoding differs" for the 59 compute programs, which should now be identical tomain. I can't check that without the pack.Full suite and lint
cargo test -p victory-shader --lib --locked --no-fail-fast:main+ #215)main+ #215 + both commitsAt bare
776ec56+ both commits, RTX gives 210 passed and 1 failed (the new test).cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean, with and without--all-featureson the merged tree, and with--all-featuresat bare776ec56. No game data used. The adapter hook, the ROV-off control, the DXIL dumps and the HLSL variants were local only and are not in the commits.AI use: Claude Code (Claude Opus 5.5).
@m335671 on GitHub · 2026-11-25 22:23 UTC · original
Offline check on current
main: this PR brings up the 10 programs that fail witha hardware SGPR input. All 10 arePS_PedTexturedCutOutTint_Zerovariants, the ones #923 is about. No other program changes.Tested
main9c184b3with this PR's head776ec56merged in. The merge was clean, even though the PR is based on2119b0e.VICTORY_HOST_MAX_WAVE=32 victory translate --list --pipelinesover the title's whole shader pack, compared program by program by hash with my earlier listing ofmain3973179. The same 10 still failed on9c184b3(with #941 merged, to name the register). The 10 were also run alone with--validate.a hardware SGPR inputmain3973179main9c184b3+ this PRs18in all 10.f0296ce9fbe481cbaround0x2d3c,s18is split withs_bfe_u32(bits 0–9, 16–25, 28–29 and 31), followed bys_setreg hwreg(HW_REG_POPS_PACKER),src_pops_exiting_wave_idand ans_sleepwait loop: the POPS collision wave ID.dxil.dllvalidation, and the driver creates their pipelines. None of the other 25,608 is lost.Not tested in the title: none of these 10 hashes appears in my logs from the first room or the following café scene, so I haven't seen them draw. #923's black faces may come from a later scene or a cutscene.
AI use: Claude Code (Claude Opus 5.5) built and ran the check on my machine, read the disassembly and wrote this comment.
@UwUCammie on GitHub · 2026-11-26 02:30 UTC · original
On an RX 7900 XT (RADV 26.3.1, Wine and vkd3d-proton) I tested the 280 character-texture pixel programs in my local package. Before the ordered-pixel change, 270 emitted DXIL and ten stopped on a hardware SGPR input. With the change, all 280 emitted. I ran just those ten through
translate --pipelineson the same card and all ten created a host pipeline.None of those ten shader identities appeared in the first-bind logs from the opening diner runs where the server's face drew black. This fixes a reproducible translation failure on AMD. That particular scene still has a separate rendering problem.
Tested branch
Pull request closed