gpu: answer console allocation sizes for depth-stencil and multisampled textures #1283
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1290"
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 R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T06:58:07Z.
Refs #870, #874.
Problem
The startup device wrapper forwards the desktop answer of
GetResourceAllocationInfo/GetResourceAllocationInfo1. A console executable reserves memory of its own for every placed texture from that answer, and it can take all of that memory from one fixed block. For two families the desktop answer is larger than the console's:On the run described below the block ran out, an allocation returned null and the run stopped on a null object about 18 s in. I believe this is the stop reported on #870 for a GTX 1660 SUPER ("a NULL the title expects to be a live object"): it happens at the same point here and goes away with this change. I have not confirmed that on that machine.
Change
src/startup_stubs/console_plane_size.h: for a single description that is single-mip 2D and either depth with stencil (R32G8X24 family, or the console's 16-bit depth with stencil, formats 118-120) or multisampled in a listed colour format, answer the console size. Every plane is padded to whole 64 KiB tiles; a tile holds 64 KiB of samples (128 x 128 texels at 4 bytes, 256 x 128 at 2, 256 x 256 at 1, 64 x 64 at 4 bytes with four samples).Everything else keeps the desktop answer: other formats, mip chains, 3D textures, sample counts outside 1/2/4/8, and any case where the console size would not be smaller than a valid desktop answer. So an adapter that already answers 5 bytes a texel for R32G8X24 is not affected.
Only the amount of memory the executable sets aside changes. The desktop texture created for the description is the same as before. The first eight uses are logged as
x2w-d3d12 allocation info: console size ....Evidence
Commit under test: the head of this branch, on
mainat93cb6a2a.Device-free check (
tests/startup_plane_size_check.cpp, registered asstartup_plane_size):Negative control, registered as
startup_plane_size_packed_controlwithWILL_FAIL:startup_plane_size_check --mutate packedswaps in the expectations of a rule without tile padding and must fail. It reports 6 failures, on the six descriptions whose planes are not whole tiles, for example:Where the expected sizes come from. The first nine are console allocation sizes for descriptions the executable queries, read from the log of an independent implementation of the same device interface. No code was taken from it. The tile rule in the header reproduces all nine; the other three expected values follow from the rule.
Whole-program run. One console executable under the startup debugger, offline; Linux host, Wine with vkd3d-proton, NVIDIA RTX 4070 Ti SUPER:
Also ran
python -B tests/docs_links_check.py(286 links, pass) andgit diff --check(clean).Not measured
d3d12_xs_device.cppwith clang-cl against the Windows SDK and ran the check under Wine; CI is the first MSVC build and the first Windows run.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T07:01:20Z.
Review: CHANGES_REQUESTED
The helper currently turns any invalid desktop result into a plausible allocation size for a matching numeric format. For example, a D32S8 description with
Width=UINT64_MAXpasses the shape checks, wraps while rounding to a tile and can become a 64 KiB result. Invalid sample quality, layout and explicit alignment can also reach the override. Restrict the rule to validated dimensions and supported description fields, with checked size arithmetic. Preserve the desktop failure for desktop formats unless there is independent evidence that the exact rejected shape is valid on the guest. For a console-only format, validate the full supported shape before replacing the sentinel.Please exercise both device query entries and the corresponding placed texture creation on that allocation layout. The helper test confirms the formula but does not establish that the returned size and alignment describe backing accepted by the resource path.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T07:03:15Z.
Review: COMMENTED
Dual-platform review at commit
b316ad128e909139793593354801ab3d6b76af9c:Linux checks
git diff --check origin/main...HEAD: passedpython -B tests/docs_links_check.py: passed (16 Markdown files, 286 links)python -B tests/bidi_controls_check.py: passed (1081 tracked files)Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)
--preset dev):cmake --build --preset dev --target startup_plane_size_check -- -j 6:3.68sctest --preset dev -R '^startup_plane_size' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (startup_plane_size,startup_plane_size_packed_controlnegative control)/O2(--preset release):cmake --build --preset release --target startup_plane_size_check -- -j 6:1.10sctest --preset release -R '^startup_plane_size' --parallel 4 --no-tests=error --output-on-failure: 2/2 passedNotes & Edge Cases
desc.MipLevels == 0insrc/startup_stubs/console_plane_size.h:desc.MipLevels > 1treatsMipLevels == 0as single-mip. In D3D12,MipLevels == 0requests a full mip chain down to1x1, so a non-MSAAd32s8/d16s8descriptor withMipLevels == 0andWidth > 1 || Height > 1would be under-sized; guardingdesc.MipLevels != 1(ordesc.MipLevels == 0 && (desc.Width > 1 || desc.Height > 1)) would match the single-mip contract.startup_plane_size_checkexercisesconsole_plane_size.hstandalone;src/startup_stubs/d3d12_xs_device.cppwas reviewed by inspection (descs[0]is correctly passed unsanitized so formats118–120match, andinfo1is updated forcount == 1), not compiled in this targeted target run.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T07:16:05Z.
Thanks, both points were right. Addressed in the commit just pushed.
Validation (R0Y00, and the
MipLevels == 0note from tedin7).console_plane_shapenow gates the rule: 2D,MipLevels == 1exactly, width and height withinD3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION, slices withinD3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION, 1/2/4/8 samples at quality 0,D3D12_TEXTURE_LAYOUT_UNKNOWN, alignment 0 or 64 KiB. With those bounds the size arithmetic stays below 2^45, so there is nothing left to wrap. A desktop failure is now kept for desktop formats (the R32G8X24 family and the multisampled colour formats): the helper returns false on an all-ones size. Only formats 118-120, which desktop cannot answer, are answered over the sentinel, and only for the validated shape.The device-free check grew from 9 to 25 left-alone cases:
Width = UINT64_MAX(with a failed and with a valid desktop answer), width 16385, zero height, zero slices,MipLevels == 0for both families, sample quality 1, zero samples, row-major and 64 KiB-swizzle layouts, 4 KiB and 4 MiB alignment, and a desktop failure for D32S8 and for 4-sample RGBA8.Device entries and placed creation. New
tests/startup_plane_size_device_check.cpp, registered asstartup_plane_size_device_warpand_hardware(skip code 77). For each description it takes the adapter's own desktop answer, applies the helper to get the expectation, and then:S_OK, an object and no device removal;Because the expectation is derived from the adapter's own answer, the test holds on an adapter whose desktop size is already the smaller one; it prints which case applied.
Result here, at this branch's head, with the branch's own
d3d12_xs.dllbuilt by clang-cl against the Windows SDK and run under Wine with vkd3d-proton on an NVIDIA RTX 4070 Ti SUPER (so a translation-layer result, not Windows, andhardwareonly; there is no WARP there):Two limits I want to be plain about:
I have not run
_warpor anything on Windows; CI is the first run of both device tests there.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:29:06Z.
Review: COMMENTED
Retested PR #1290 at commit
1a2b32b78462ec7d89054cb559e65b71e1308058(following previous review atb316ad12).Verification
git diff --check origin/main...HEAD: passed.tests/docs_links_check.py: passed (16 Markdown files, 290 links).tests/bidi_controls_check.py: passed (1096 tracked files).--preset dev):startup_plane_size_check,startup_plane_size_device_check,d3d12_xs_shimbuilt cleanly;ctest -R '^(startup_plane_size|startup_plane_size_device_warp|startup_plane_size_packed_control)$'3/3 passed (startup_plane_size0.02s,startup_plane_size_packed_control0.01s,startup_plane_size_device_warp0.12s)./O2(--preset release): built cleanly; 3/3 passed (startup_plane_size0.02s,startup_plane_size_packed_control0.02s,startup_plane_size_device_warp0.13s).Fixes & Findings
All items from the previous review at
b316ad12are addressed:console_plane_shape()insrc/startup_stubs/console_plane_size.hnow restricts toMipLevels == 1(fixingMipLevels == 0),Width/Heightwithin1..D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION(preventingUINT64_MAXwrap),DepthOrArraySizewithin1..D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION,SampleDesc.Countin{1, 2, 4, 8},SampleDesc.Quality == 0,Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN, andAlignmentin{0, 0x10000}.console_plane_size()preserves desktop~0ullfailures for desktop formats and only overrides~0ullfor console-only formats118–120after shape validation.tests/startup_plane_size_device_check.cppnow exercises both device allocation-info slots (25and108), placed texture creation (slot 133) over memory of the answered size/alignment, and out-of-rule/invalid-width controls against the desktop device.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:24:36Z.
Review: APPROVED
Windows Release passed 5/5 on RTX 4060 Laptop and WARP, including the device slots 25/108/133, bounds and packed control, and the retained blend fixture. The result covers size answers and successful committed desktop texture creation; it does not establish console-layout aliasing.