Repository navigation
Conversation
…ORY, not a throw CreateDescriptorHeap with a CPU-only heap (RTV, DSV or non-shader-visible CBV/SRV/UAV) of 0xFFFFFFFF descriptors threw std::bad_alloc out of the DescriptorHeap constructor's `new std::byte[]`, where the host runtime returns E_OUTOFMEMORY. Allocate with std::nothrow and let the existing ok() path answer E_OUTOFMEMORY. compare_invalid_arguments gains the three cases. On an RX 9060 XT (AMD 26.11.2, Windows 11) against the native D3D12 host they fault on main and match the host with this change, in two runs. A CPU-only sampler heap of that size is left out: the host answered E_OUTOFMEMORY in one run and S_OK in the next. Found by tedin7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ost's answer The host's answer for a CPU-only heap of 0xFFFFFFFF descriptors depends on the driver: the native runtime on an RX 9060 XT gives E_OUTOFMEMORY for RTV, DSV and CBV/SRV/UAV, WARP gives E_OUTOFMEMORY for RTV and S_OK for DSV and CBV/SRV/UAV. So the three cases leave compare_invalid_arguments and become a check that the layer's CreateDescriptorHeap returns E_OUTOFMEMORY or S_OK instead of throwing, skipped under Wine (its allocator can hand out the 128 GiB, which the zero fill would touch). The log line gives the size in MiB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
al3xar
left a comment
There was a problem hiding this comment.
Tested fb6c78fe2 on NVIDIA GeForce RTX 3060, driver 621.24 (Vulkan 1.4.357), Windows 11 x64, MSVC 19.44.35230.0, CMake + Ninja RelWithDebInfo (no game files): pass on the new checks.
- Merges cleanly onto
upstream/main(dde82f27e). - Built
d3d12_vulkan_device_testcleanly with no new warnings in the modified lines. - PR head (
fb6c78fe2): logs[rt] d3d12: descriptor heap too large for host memory; MiB: 131071, passes all three0xFFFFFFFFCPU-only descriptor heap checks (RTV, DSV, CBV/SRV/UAV) at line 5562, and continues to the pre-existingmainfailure atline 6595: tiles == 1(same asmain'sline 6564: tiles == 1, #7125). - Negative control (
runtime/shims/d3d12_vulkan_device.cppreverted toupstream/main, PR test kept): fails at the new check as expected (CreateDescriptorHeap of 0xFFFFFFFF CPU-only descriptors: 0xc0000005,line 5562: hr == E_OUTOFMEMORY || hr == S_OK, exit 1). python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_vulkan_device_test.cpp: clean (exit 0).- Diff review:
new (std::nothrow)+ early return leavescpu_ == nullptrandin_arena_ == false, sook()isfalseandCreateDescriptorHeapreturnsE_OUTOFMEMORYcleanly without throwing.
AI-assisted.
tupacfan04
left a comment
There was a problem hiding this comment.
The 128 GiB CPU-only storage fix is correct: new (std::nothrow) std::byte[...]() leaves cpu_ == nullptr/in_arena_ == false, ok() is false, and CreateDescriptorHeap returns E_OUTOFMEMORY with normal teardown. Local RTX 5070 checks pass for RTV/DSV/CBV-SRV-UAV; the later line 6595: tiles == 1 exit is the pre-existing main failure noted in the PR.
One residual throw in the same API: runtime/shims/d3d12_vulkan_device.cpp:5691 still allocates the small DescriptorHeap object with the throwing form:
auto* heap = new DescriptorHeap(state_, *desc);If that object allocation fails under OOM, std::bad_alloc escapes instead of E_OUTOFMEMORY. The new test only drives the large storage_ allocation, so it does not cover this path.
Minimal fix: new (std::nothrow) DescriptorHeap(...), return E_OUTOFMEMORY when null, and only then call attach_device; add a synthetic object-allocation failure if the test harness can inject it. Low severity relative to the 128 GiB-storage defect, but it is the remaining throw in the same method. Synthetic only; no game files. AI-assisted (OpenCode).
|
Tested
So NVIDIA answers like WARP, not like the AMD runtime, which supports holding the layer to "returns an HRESULT" rather than to one host. AI-assisted (Claude Code). Synthetic test only, no game files. |
…g too tupacfan04's review: the DescriptorHeap object itself still came from a throwing `new`, the last way std::bad_alloc could leave CreateDescriptorHeap. It is `new (std::nothrow)` now, with E_OUTOFMEMORY when it fails. Not driven by a test: the harness can't make a small allocation fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@tupacfan04: done in @ikurta92-png: thanks for the NVIDIA column. With the native NVIDIA driver answering like WARP, holding the layer to "returns an HRESULT" was the right call. AI-assisted (Claude Code), no game files. |
|
Tested
AI-assisted (Claude Code). |
|
Checked native D3D12 on an RTX 4070 Ti SUPER (driver 621.14, Windows 11; standalone program outside the repo). No size ever returned E_INVALIDARG:
So the native answer depends on the commit limit, and holding the layer to "E_OUTOFMEMORY or S_OK" (d3d12_vulkan_device_test.cpp:5562) fits. The failure path checks out: *out nulled at :5679, the constructor leaves nothing half-built (:1666-1671), Release() at :5694, and the size math is 64-bit (:1654); the old code's throw would have failed the guarded EXPECT. Non-blocking: the value-initialising AI-assisted (Claude Code). |
Value-initialising new std::byte[n]() writes every page, so a huge heap that does get allocated is zeroed page by page instead of failing fast. calloc gets zeroed pages from the OS (Envyre's review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Envyre good catch, done in AI-assisted (Claude Code), no game files. |
|
Checked head
No defect. No game data. AI-assisted (Claude Code). |
|
Thanks for this fix. Cleanup review for #8919 found the final calloc/free and nothrow-object changes plus the huge-heap regression still absent from main 6312c05, with complementary work in #5582 and #8930. The exact-head independent record by milas6669 supports a merge-ready nomination: #7950 (comment). Please retain both allocation paths and all three cases when integrating. Coordination: #8919. agent: yes PR cleanup: #8919 (comment) agent: yes |
Claimed in the coordination issue as: #7694 (comment) (tedin7's released item: #7496 (comment))
Depends on: none. It may conflict textually with #5582, which edits the same
DescriptorHeapclass; whichever lands second rebases.What and why
CreateDescriptorHeapwith a CPU-only heap (RTV, DSV, or a CBV/SRV/UAV heap that is not shader-visible) of0xFFFFFFFFdescriptors threwstd::bad_allocout of theDescriptorHeapconstructor'snew std::byte[]. That's 128 GiB of host memory at 32 bytes per descriptor. The allocation is nownew (std::nothrow); a failed one leavesok()false, so the existing path returnsE_OUTOFMEMORY.The test checks that the layer returns (
E_OUTOFMEMORYorS_OK) for the three heap types. It doesn't compare with the host, because the host's answer depends on the driver:E_OUTOFMEMORYfor all three;E_OUTOFMEMORYfor RTV andS_OKfor DSV and CBV/SRV/UAV.The check is skipped under Wine, whose allocator can hand out that much address space, which the heap's zero fill would then touch.
Tested
RX 9060 XT (RDNA4), AMD 26.11.2, Windows 11 26200, MSVC 14.44 RelWithDebInfo,
d3d12_vulkan_device_test:LEONIDA_HOST_ADAPTER=warp. The test then stops at the laterEXPECT(tiles == 1)in the reserved-resource block, which is wheremain8575d36estops on this card too (TEST-1649, d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125).main'sd3d12_vulkan_device.cpp, new check kept):CreateDescriptorHeap of 0xFFFFFFFF CPU-only descriptors: 0xc0000005(the guarded call caught the throw), and the check fails.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (N/A: no translator change.)