Repository navigation
fix(gpu): guard unmapped root views, sanitize 64-lane indirect draws, and defer GPU retirement - #403
Open
gdemontalivet wants to merge 1 commit into
Conversation
… and defer GPU retirement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS with D3DMetal on Apple Silicon (
AGX), several invalid or transiently unmapped GPU addresses submitted by a title trigger hard GPU page faults or premature backing-memory reclamation instead of silent console-like reads and writes:SetGraphicsRoot*View/SetComputeRoot*View) names0, an address outside the 47-bit user virtual space, or a title range with no backing host copy, leaving the previous draw's GPU virtual address bound or passing an unmapped address faults the GPU MMU.0xffffffff(DispatchMesh>65,535groups) or IEEE-754 float bit patterns above2^23interpreted as vertex/index counts with zero instance/start fields, stalling or resetting the host command queue. With macos: build the 64-thread argument clamp with the DXC that D3DMetal ships #301 building the 64-laneindirect-clamp.hlslshader via D3DMetal's shippedDXC, sanitizing unfilled draw/mesh records inindirect-clamp.hlsltakes effect on default macOS builds right away, while upgrading theWORDS_SOURCEcs_5_1fallback to[numthreads(64, 1, 1)]keeps builds without an externalcs_6_0DXCon the same 64-lane clamping and sanitization behavior.fence == completedGPU resource retirement: Releasing host D3D12 buffers, descriptor heaps, and scratch chunks on the exact fence value just completed can reclaim Metal allocations while late command-buffer completion or cross-queue work still references their GPU virtual addresses.What changed
draw.rs,compute.rs,host.rs,shadow.rs):LOWEST_MAPPED(64 KiB) or pastUSER_SPACE_END(1 << 47) up front inshadow::findandshadow::loosebefore consulting thread-local lookup caches orVirtualQuery.Host::zero_root_read()(64 KiB zeroed buffer) andHost::sink_root_uav()(64 KiB writable sink buffer) fallbacks whenever a direct root CBV, SRV, or UAV slot is null, unset, or outside committed title buffers, while preserving Refresh only the proven read span of raw root SRVs #270's proven read span on valid root SRVs.cs_5_1indirect clamp & unfilled-record sanitization (indirect-clamp.hlsl,indirect.rs,host.rs):cs_5_1WORDS_SOURCEshader to[numthreads(64, 1, 1)](matching macos: build the 64-thread argument clamp with the DXC that D3DMetal ships #301'sDXC-builtindirect-clamp.hlsl64-lane layout when no externalDXCis present at build time, while remaining compatible withVICTORY_HELPER_DXC) and preserve fix(gpu): let indirect dispatches wider than 65,535 groups run whole under D3DMetal #244'swidest(> 65,535group) compute-indirect fallback path.0xffffffffor>= 2^23(MAX_SANE_DRAW_VERTICES) with zeroed companion fields, and zero mesh-shader indirect dispatches with any dimension> 65,535in bothindirect-clamp.hlslandWORDS_SOURCE, while keeping valid large vertex draws intact.host.rs,list.rs,placement.rs,resource.rs,switch.rs):VICTORY_BURY_LAG(default16submissions,=0immediate) so retiredID3D12Resource, descriptor-heap, and scratch-pool allocations stay alive across a short submission window before final release.How it was tested
wave32=true), isolated test bottle:cargo test --workspace(native macOS): all passed (0failed).victory-gpu --libunder Wine + D3DMetal (--test-threads=1): all passed (coversnull_and_unmapped_direct_root_views_bind_safe_fallbacks,null_and_out_of_range_addresses_never_create_loose_copies, 64-lane multi-draw indirect clamping,> 65,535compute indirect dispatches, unfilled mesh/draw sentinel zeroing, andVICTORY_BURY_LAGretirement).cargo xtask policy,git diff --check, andcargo clippy --target x86_64-pc-windows-gnullvm -p victory-gpu --all-targets -- -D warnings(with and without--features diagnostics): clean. All test inputs are synthetic.Live M5 Max Verification (Combined Build on CrossOver Preview + D3DMetal)
CrossOver Preview+ D3DMetal,wave32=true), the runtime reached and sustained the 3D world through+8, +24, +48, +90at1.5–1.8 FPS(549.7–672.1 ms/frameon1,021–1,258 draws/frame,1.275 FPSoverall across+8..+90) with02.48 sallocation stalls,7.2–9.0 ms/frameGUARDSlock hold time (down from4,887 ms/framebefore unlockingGUARDS),149–154 MB/framebuffer copy volume,0DirectStorage decompression or access-violation failures, and38/38over-32 KiB aligned mesh/pixel pairs linked with0host mesh refusals.