Skip to content

Runtime: resources answer ID3D12Resource1/2 and heaps ID3D12Heap1, as on the PC runtime - #2590

Open
nightmoon1996 wants to merge 1 commit into
ItsNotRexed:mainfrom
nightmoon1996:feat/resource2-heap1
Open

nightmoon1996 wants to merge 1 commit into
ItsNotRexed:mainfrom
nightmoon1996:feat/resource2-heap1

Conversation

@nightmoon1996

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #2300 (comment) (new D3D item)

What and why

QueryInterface for ID3D12Resource1, ID3D12Resource2 or ID3D12Heap1 returned E_NOINTERFACE on the layer: Resource and Heap only listed ID3D12Resource and ID3D12Heap. The PC runtime hands these out for every resource and heap, and code written against a current SDK asks a resource for ID3D12Resource2 to call GetDesc1. #1846 added CreateHeap1, not the interface.

Measured on the PC runtime first (RTX 4060 Ti and WARP, the same in every case):

Probe PC runtime
QueryInterface for Resource1 and Resource2 (committed, placed, reserved; buffer, 2D, MSAA; the CreateCommittedResource2/3, CreatePlacedResource1, CreateReservedResource2 forms) S_OK, same IUnknown, one reference each
QueryInterface for Heap1 S_OK
GetDesc1 against GetDesc the shared fields are equal, alignment resolved the same way
SamplerFeedbackMipRegion 0/0/0, except a buffer created from a D3D12_RESOURCE_DESC1 that carried one: it is kept and returned
GetProtectedResourceSession, no session DXGI_ERROR_NOT_FOUND, out pointer nulled, for any riid
GetProtectedResourceSession, null out pointer access violation

The change

Tested

Windows 11, NVIDIA GeForce RTX 4060 Ti (driver 32.0.16.2101), clang-cl 23.1.6 with the xwin SDK (10.0.26100), run natively. No game files.

  • d3d12_resource_desc, extended: 15 kinds of resource and 2 heaps, each compared with the PC runtime on the RTX 4060 Ti and on WARP (QueryInterface results, IUnknown identity, reference growth, GetDesc1 field by field with the mip region, the session answers): 17 of 17 on both, 3 runs. The 26 existing GetDesc cases still match on both.
  • An object the layer fails to create now fails the test (placed resources and heaps are tolerated only on a device without buffer device address).
  • Negative control: with main's sources, 0 of 17 match on either adapter (QueryInterface returns 0x80004002).
  • d3d12_vulkan_device, d3d12_com, unimplemented_policy, d3d12_method_variants, device_proxy, xs_proxy_mock*, d3d12_present, xbox_present, dxgi_swapchain pass. Full ctest before the review changes: 118 of 119, the one being d3d12_subgroup, which my toolchain can't build (no AMDGPU target in llvm-mc); after them I re-ran the tests listed here, not the whole suite.
  • Not measured: the PC runtime's answers for swapchain back buffers (they get the same answers as other resources here, and no test queries them), upload or readback heaps, MSVC, Wine, any AMD or Intel GPU.

The test's layer device now asks for buffer device address, so heaps and placed resources can be created; the 26 existing cases therefore run on the arena path.

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not a translator change)

🤖 Generated with Claude Code

@Yourrespawn

Copy link
Copy Markdown
Contributor

Tested 4c3bd1f1 on NVIDIA GeForce RTX 4080 (Ada), driver 617.14, Vulkan API 1.4.351, Windows 11 Pro 10.0.26200, MSVC 14.44, Windows SDK 10.0.26100: pass.

AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine.

@nightmoon1996

Copy link
Copy Markdown
Contributor Author

Rebased onto main (f847748). One conflict in d3d12_vulkan_device.cpp: create_placed now takes the initial state, and this PR wraps the same two calls (CreatePlacedResource1/2) in keep_mip_region. The calls are main's, wrapped as before; no behaviour change.

Re-run (RTX 4060 Ti, driver 32.0.16.2101, clang-cl 23.1.6 + xwin SDK 10.0.26100): d3d12_resource_desc passes; full ctest 133 of 134, the one not run being d3d12_subgroup, which this toolchain cannot build.

@Yourrespawn thanks for the RTX 4080 run.

AI-assisted (Claude Code); no game files.

… on the PC runtime

QueryInterface for ID3D12Resource1, ID3D12Resource2 or ID3D12Heap1 returned
E_NOINTERFACE, so a GetDesc1 call through ID3D12Resource2 could not be made.
The PC runtime hands these interfaces out for every resource and heap.

Resource, Heap and the swapchain's back buffers now answer them. GetDesc1
returns what GetDesc resolves plus the sampler-feedback mip region, which a
buffer created from a D3D12_RESOURCE_DESC1 keeps, as measured.
GetProtectedResourceSession answers DXGI_ERROR_NOT_FOUND and nulls its out
pointer, as the PC runtime does for an object without a session.

d3d12_resource_desc compares 15 kinds of resource and 2 heaps with the PC
runtime.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@nightmoon1996

Copy link
Copy Markdown
Contributor Author

Rebased onto main (2d3369a). Conflicts: in d3d12_vulkan_device.cpp the creation calls are now create_committed_validated(method, ...) / create_placed(method, ...) with trace recording; they are main's calls, wrapped in keep_mip_region as before (CreateCommittedResource3, CreatePlacedResource1/2). In the test only the header comment conflicted; the new cases use main's hostadapter::reference selection. No behaviour change.

Re-run (RTX 4060 Ti, driver 32.0.16.2101, clang-cl 23.1.6 + xwin SDK 10.0.26100): d3d12_resource_desc 26 of 26 descriptions and 17 of 17 Resource1/Resource2/Heap1 objects match, on the RTX 4060 Ti and on WARP. Full ctest 163 of 171; the 8 not run are the tests whose shaders this toolchain cannot generate (no AMDGPU target in its llvm-mc): d3d12_translated_draw, d3d12_m2_textured, d3d12_m2_formats, d3d12_m3_frame, d3d12_m3_first_pass, d3d12_m4_compute, d3d12_buffer_uav, d3d12_subgroup.

AI-assisted (Claude Code); no game files.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Tested 3e02e1d on an RTX 3070 (610.88, Windows 11 26300, MSVC VS 2022, Vulkan SDK 1.4.363 layers), with the validation layer, on its base 2d3369a4: pass. Full ctest is 172/172. d3d12_resource_desc_test gives resource1/resource2/heap1 ... 17 of 17 objects match against both the RTX 3070 host and WARP (and 26 of 26 descriptions), with 0 validation errors. The two build warnings (C4456 in d3d12_vulkan_device_test.cpp) are in a file this PR doesn't touch.

Controls (one change at a time, rebuilt, then restored):

Change d3d12_resource_desc_test
keep_mip_region doesn't store the buffer's region (set_mip_region call removed) fails (exit 1)
Resource::GetProtectedResourceSession returns S_OK instead of DXGI_ERROR_NOT_FOUND fails (exit 1)
BackBufferResource::QueryInterface no longer answers ID3D12Resource2 still passes; so does dxgi_swapchain_test

So the test pins the mip-region store and the session answer on committed, placed and reserved resources. The swapchain backbuffer half (the dxgi_com.cpp change; docs/d3d12_vulkan.md lists backbuffers among the resources that answer) has no test: nothing queries a backbuffer for ID3D12Resource1/2 or calls its GetDesc1. A short check in dxgi_swapchain_test after GetBuffer would cover it: QI for both, identity, GetDesc1 equal to GetDesc with a zero region, and GetProtectedResourceSession returning DXGI_ERROR_NOT_FOUND.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 3e02e1d merged with main 98fa503 on Windows (MSVC 14.51): pass. runtime built on Windows (MSVC 14.51, RelWithDebInfo); d3d12_resource_desc passes on RTX 4080 SUPER and on UHD 770. Negative control with main's runtime/shims/d3d12_vulkan_device.cpp: d3d12_resource_desc fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants