Repository navigation
Conversation
f3f7742 to
179ea43
Compare
Jasper-Bekkers
left a comment
There was a problem hiding this comment.
Looks like some mistakes with the host/device toggle made their way in, or I'm mis-understanding what the is_host boolean should be doing.
|
|
||
| mem_block.sub_allocator.free(allocation.chunk_id)?; | ||
|
|
||
| let is_host = self.heap_properties.Type != D3D12_HEAP_TYPE_DEFAULT; |
There was a problem hiding this comment.
Not sure if this is true, D3D12_HEAP_TYPE_READBACK might also be non host.
There was a problem hiding this comment.
The revised policy distinguishes CPU accessibility from physical memory placement. Standard READBACK is CPU-readable (WRITE_BACK); GPU_UPLOAD can be GPU-local and still CPU-accessible. The allocator's custom heaps are classified by CPUPageProperty WRITE_BACK/WRITE_COMBINE instead of treating every non-DEFAULT type as host memory. GPU_UPLOAD classification also remains compatible with the oldest permitted Windows bindings. This selects the existing host size range without claiming that READBACK necessarily resides in a separate physical host-memory pool. See the explicit predicate and tests in b620867, plus the independent lifetime fix #327. D3D12 heap contracts.
Agent-assisted response, posted at the contributor's direction.
Hi Jasper, the The intention is to keep allocation and deallocation consistent, rather than introduce or change the host/device classification. If the existing classification needs correcting, I am happy to do that in another PR or would you like me to expand the scope of this PR and do that work here too? (I am up for it.) |
|
Actually, I'll expand this Pr's scope because fixing the allocators will affect whether I can simplify/change this Pr's code. |
…nd pressure recovery
179ea43 to
b620867
Compare
|
The reconciled head is693a9fb44e7d6effa20f988217524c61553f95fe. The earlier wording in this thread overstated the classification defects: CPU accessibility versus physical placement needed clarification; the constructed heap policies were largely already consistent with the existing CPU-visible size settings. The revised explicit predicates and resolved per-type sizing preserve that interpretation rather than claiming READBACK or UMA inherently means a separate physical host-memory pool. The independently confirmed native-contract and ownership fixes are #327 and #328. #323 keeps the shared-threshold change, bounded idle retention and recoverable-pressure behavior together. #330/#331 document distinct pre-existing Metal selection/platform defects; Apple runtime validation remains outstanding. No MSRV increase is required. Six final-source native plan checks match all60 historical normal cells. The last source change strengthened only a regression test; production code matches b620867. Full raw evidence and the publication report: https://github.com/simzy39/winit-wgpu-repro-benchmarks/tree/main/allocator-reconciliation-20261128 Agent-assisted reconciliation at the contributor’s direction. |
Depends on #327 and #328. Fixes #322 and #329; adds the manual empty-cache controls requested in #96. The branch contains both independent correctness prerequisites so it compiles and can be tested today; rebase after they merge.
Resolve each memory type's sizing once using explicit CPU accessibility: Vulkan HOST_VISIBLE, D3D12 standard/custom CPU page properties, and Metal Shared versus Private. This describes access, not physical RAM versus VRAM. Use the resolved maximum for the shared/dedicated threshold and grow to fit the resource, counting occupied shared blocks.
Keep one bounded empty cache per type (at most min(2*minimum, maximum)), with aggregate Vulkan retention bounded by the physical heap. Expose cached_capacity(), trim() and trim_to(bytes) using cached indices without scanning historical slots. Under typed memory pressure, reuse compatible blocks, reclaim empty caches and retry, then reduce shared block sizes toward the aligned resource floor. Fatal and allocation-count failures do not cause size retries. Metal uses a conservative exact-floor attempt and commits pending residency removals.
Validation on final 693a9fb (test-only successor of measured b620867): 54 std and 10 no_std library tests; strict Clippy, rustdoc and formatting; actual Rust 1.71 std / 1.81 no_std consumers; Apple ARM/Intel cross-compilation. Six final-source native harness processes match all 60 prior normal allocation-plan cells. Historical seven-policy and downstream comparisons, raw data and reproducer: https://github.com/simzy39/winit-wgpu-repro-benchmarks/tree/main/allocator-reconciliation-20261128. Historical timings are not new final-source timings.
Limits: no Apple runtime validation; source-confirmed Metal selection/platform defects #330 and #331 remain separate. The historical integrated wgpu run has 2,184 passes and 23 failures/aborts, not a passing full native suite. Twenty-two reproduce on pristine upstream; the remaining DX12 multiview behavior depends on executable basename and remains unresolved (gfx-rs/wgpu#8645). wgpu cross-pool recovery also needs a real release of these APIs (gfx-rs/wgpu#11145); no release number or production override is proposed.
AI disclosure: an OpenAI coding agent performed the additional research, source changes, validation and this description under the contributor's explicit publication direction.