Shaders: restore early-Z on sampled-mark-only pixel shaders and batch uniform marks #4712
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4712"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T03:10:22Z.
What it changes
Fixes two DXIL lowering costs introduced by
VICTORY_SAMPLED_MARKS=1(SLOT_SAMPLED) without disabling sampled-slot tracking or sacrificing eviction accuracy:Restores
ShaderFlags::EARLY_DEPTH_STENCILon pixel shaders whose only UAV isSLOT_SAMPLED:SLOT_SAMPLEDadds a UAV to otherwise UAV-free pixel shaders, causing D3D12/NVIDIA hardware to disable automatic early-Z and shade occluded pixels in full.Shader::has_heap_uav(crates/victory-shader/src/emit/shader.rs) and real pixel discards viaLower::emitted_real_discard(crates/victory-shader/src/emit/lower.rs, distinct from the loop-capabort_blocksafety exit).flags::EARLY_DEPTH_STENCILonly when all safety preconditions hold: pixel shader, neitherEARLY_DEPTH_STENCILnorROVSalready set,!writes_uavs,!has_heap_uav,!emitted_real_discard,root_uavs == [SLOT_SAMPLED](single root UAV), consoleDB_SHADER_CONTROLselected an early-Z order (Z_ORDER1 | 3orDEPTH_BEFORE_SHADER) with none ofKILL_ENABLE/COVERAGE_TO_MASK_ENABLE/EXEC_ON_HIER_FAIL/EXEC_ON_NOOP/CONSERVATIVE_Z_EXPORT/PRIMITIVE_ORDERED_PIXEL_SHADERset, andearly_depth_of(...) == EarlyDepth::Given(no depth/stencil/coverage exports).Batches wave-uniform sampled-slot marks per basic block under one
waveIsFirstLaneguard:!per_lane) sampled-slot indices inLower::block_marksand flushes them together inside a singlewaveIsFirstLaneguard (flush_block_marks/emit_sampled_mark) before whole-wave sections,s_barrier, pixelExpexports, and block exits, keeping back-to-back texture fetches unsplit while still marking every slot.shader_cache.rsuntouched).How it was tested
--fg-type fsr --framegen 3), ray tracing off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12,VICTORY_AMBIENT=0.8,VICTORY_AMBIENT_SPECULAR=1.SLOT_SAMPLEDas their only UAV lost early-Z (EARLY_DEPTH_STENCILunset), and each wave-uniform texture fetch emitted its ownwaveIsFirstLaneguard splitting texture fetches.crates/victory-shader/src/emit/waterfall_tests.rsverify: (a) two distinct uniform sampled slots in one block share a singlewave_op(waveIsFirstLane) while still marking both slots on GPU/WARP, ands_barrierflushes queued marks before the barrier; (b)EARLY_DEPTH_STENCILis restored on safeSLOT_SAMPLED-only pixel shaders (including ones with loop-capabort_block), and stays off when marks are disabled, when the console asks forLATE_Z/RE_Zor kill/coverage/depth export, or when any real discard or other UAV is present.7d93ee0759rather than isolated A/B): offlinewarm --used --jobs 4stored2,396/2,396pipelines cleanly (189.7 s), and a 12-minute (720.7 sin-world,16,447frames) uncontested soak passed with0crashes,0device losses,0Victory errors,0>100 mshitches in the final8.7minutes, and visually verified start (+31 s), mid (+361 s), and end (+701 s) frames with clean depth ordering and zero alpha-to-coverage/foliage/hair artifacts.wave64: falsein the newwaterfall_tests.rsunit/GPU/WARP tests and RTX 3060 Ti Wave32 live soak). Wave64 was not tested on AMD hardware.cargo testpassed for the crates it touches: yes (one3f4f708, base7d93ee0759)crates/victory-shader/src/emit/waterfall_tests.rs:sampled_marks_batch_uniform_slots_and_mark_every_slot_on_gpuandsampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders(included in thevictory-shadertest run one3f4f708).cargo build --release --locked -j 4 -p victory(0 warnings) andcargo xtask policypassed on7d93ee0759.main(5fabb46e) has 5 pre-existing clippy errors incrates/victory-gpu/src/host/{font,menu,panel}.rsfrom#4634(tracked in#4679/#4707); this PR does not touch those files.Checked for overlap
#4506works aroundVICTORY_SAMPLED_MARKS=1GPU cost by disabling it by default; this PR addresses the DXIL lowering root cause so sampled marks remain cheap without losing eviction tracking.#3501deduplicates repeatedSLOT_SAMPLEDmarks (guard_depth == 0) — complementary; does not batch distinct uniform slots under onewaveIsFirstLaneor restore early-Z.#3641/#4173add page write marks (VICTORY_VIEW_MARKS=1); if a second root UAV is bound for write marks,root_uavs.len() == 1here keeps early-Z safely off.#4037,#4680, and#4683touchlower.rs/shader.rsfor unrelated features with no functional overlap.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-12-01T07:23:59Z.
Ran the
gpu_profiletests at3ef4593don an NVIDIA Blackwell desktop part with 16 GB of VRAM.Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build,
XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.Both counts match the new test of the description and the three tests in that module at this exact head; the named test passes on this adapter.
Not tested: the full workspace suite, the standalone D3D12 reproduction of the driver bug, a title run with
XCL_GPU_PROFILE=1on a compute queue, an A/B against a build without the change, AMD and Intel GPUs, Wine, native wave64 hosts, release profile, game data.AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-12-01T07:24:47Z.
This supersedes my immediately preceding comment in this thread (https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4712#issuecomment-7304008751). That body was the wrong local draft, posted because two publishes shared one temporary file; please disregard it. This is the measured report for
e3f4f708.Ran the two named
waterfall_testscases and the whole module ate3f4f708on an NVIDIA Blackwell desktop part with 16 GB of VRAM.Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, detached worktree at the exact PR head, own
CARGO_TARGET_DIR, no local patches.Both new cases of the description pass here, as does the whole module (10 tests). This adapter is wave32 only; the description's GPU/WARP checks and its 12-minute soak were done on a different stack, so the two synthetic cases here are a second host for the wave32 path, not a repeat of the soak.
Not tested: the full workspace suite, the offline
warm --usedprecompile, the live 12-minute title soak, WARP as a separate device, wave64 and AMD hardware, DLSS/frame generation, a title that suppliesSLOT_SAMPLEDmarks, release profile, game data.AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T09:36:29Z.
Thanks @Aniseto for verifying
e3f4f708on an RTX 5070 Ti (Blackwell Wave32) and confirming both new cases and the fullwaterfall_testsmodule pass (10/10). Having independent Wave32 hardware confirmation alongside our earlier checks is very helpful.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.