Skip to content

d3d12_xs: implement IDXGIDevice::QueryResourceResidency on Xbox DeviceProxy - #820

Open
kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/d3d12-xs-dxgi-query-residency
Open

kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/d3d12-xs-dxgi-query-residency

Conversation

@kotekompotek

@kotekompotek kotekompotek commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: DXGI-QUERY-RESIDENCY (#14 (comment))

What and why

  • Rebased onto current main.
  • Implemented IDXGIDevice::QueryResourceResidency on the Xbox DeviceProxy: dxgi_query_resource_residency verifies each entry via QueryInterface(ID3D12Pageable) + GetDevice() ownership against DeviceProxy/owner->real before reporting DXGI_RESIDENCY_FULLY_RESIDENT (atomic E_INVALIDARG on null/non-pageable/foreign resources, S_OK on count == 0 with valid arrays matching Windows DXGI probe).
  • Updated runtime/test/dxgi_device_test.cpp to test real ID3D12Resource + ID3D12Heap + foreign-device/non-pageable rejections across host WARP, host GTX 1050, and Vulkan, and synced docs/d3d12_vulkan.md.

Tested

  • Locally ran device_proxy + dxgi_device (2/2 Passed).
  • test_ctest_registration.py (4/4 OK) and test_docs_*.py (OK).

GPUs tested: NVIDIA GeForce GTX 1050 (driver 582.28, Windows) & Microsoft Basic Render Driver (WARP)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean-Room Peer Review for PR #820 (IDXGIDevice::QueryResourceResidency on Xbox DeviceProxy)

Reviewed against D3D12/DXGI specification and Xbox unified memory architecture:

  • Contract & Memory Architecture: Validates non-null pointers and sets DXGI_RESIDENCY_FULLY_RESIDENT across valid input resources, accurately modeling Xbox APU unified physical memory (GDDR6 single address space).
  • Defensive Invariant Validation:
    • !resources || !residency || count == 0 correctly returns E_INVALIDARG.
    • Loops over
      esources[i] and safely returns E_INVALIDARG on any null element before writing.
  • Unit Test Coverage: Comprehensive edge-case verification added to
    untime/test/dxgi_device_test.cpp (null buffers, zero count, null elements, valid residency check).
  • Clean-room verification: Zero game data, portable C++20, and clean integration.

LGTM! Verified and approved.

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean-room verified (zero game data). Correct implementation of IDXGIDevice::QueryResourceResidency on Xbox DeviceProxy: validates arguments (E_INVALIDARG on nulls/zero) and returns DXGI_RESIDENCY_FULLY_RESIDENT matching unified console memory architecture. Tested in dxgi_device_test.cpp.

@kotekompotek
kotekompotek force-pushed the work/d3d12-xs-dxgi-query-residency branch from e9dc7e3 to db6112b Compare November 24, 2026 15:19
@moffington

Copy link
Copy Markdown
Contributor

Reviewed db6112bd5 on RTX 3060 / Linux / Wine. dxgi_device_test passed on both baseline and HEAD. Independent probes also confirmed null/zero-count validation without partial output writes.

One concern: QueryResourceResidency accepts any non-null IUnknown*, returning S_OK and DXGI_RESIDENCY_FULLY_RESIDENT. I reproduced this with an arbitrary COM object, a device, an adapter, and a resource belonging to another device.

The new regression test also uses {device, dxgi.p} rather than actual resources.

Is this permissive behavior intentional for the Xbox compatibility path? It would be useful to exercise actual resources in the test and clarify whether resource type and device ownership validation are expected.

Native Windows DXGI parity remains unverified under Wine.

@aslan2142 aslan2142 added the missing claim Needs a claim in #14 label Nov 24, 2026
@kotekompotek
kotekompotek force-pushed the work/d3d12-xs-dxgi-query-residency branch from db6112b to 72b428b Compare November 24, 2026 17:53
@kotekompotek

Copy link
Copy Markdown
Contributor Author

@moffington Thanks for the review — addressed in 72b428b43:

  • dxgi_query_resource_residency now verifies each entry via QueryInterface(ID3D12Pageable) + GetDevice() ownership against DeviceProxy/owner->real before reporting DXGI_RESIDENCY_FULLY_RESIDENT (atomic E_INVALIDARG on null/non-pageable/foreign resources, S_OK on count == 0 with valid arrays matching the Windows DXGI probe).
  • Updated runtime/test/dxgi_device_test.cpp to cover real ID3D12Resource + ID3D12Heap + foreign-device/non-pageable rejections across host WARP, host GTX 1050, and Vulkan.
  • Claimed DXGI-QUERY-RESIDENCY in coordination issue #14: Coordinating who works on what #14 (comment)

Locally ran:

  • device_proxy + dxgi_device: 2/2 Passed
  • test_ctest_registration.py: 4/4 OK
  • test_docs_*.py: OK

@aslan2142 aslan2142 removed the missing claim Needs a claim in #14 label Nov 24, 2026
@kotekompotek
kotekompotek force-pushed the work/d3d12-xs-dxgi-query-residency branch from 72b428b to 9ae8a58 Compare November 25, 2026 09:07
@kotekompotek

Copy link
Copy Markdown
Contributor Author

Rebased on current ubi/main (3f81d46), no conflicts. Verified: dxgi_device_test (3 backend(s) passed) and xs_proxy_mock_test (PASS) on Windows/GTX 1050.

AI-assisted: yes

@kotekompotek

Copy link
Copy Markdown
Contributor Author

Note on the red jobs at this head: both failures are baseline, not this diff — linux-gpu-tools cs_imgatomic_ext (6/64 sint words, llvmpipe) and windows vk_xdxr_postbuild_readback (prints "skipped" but exits nonzero) fail identically on every PR rebased after ~15:00 UTC, including merged #808's own checks. Reported in #1608. Locally (GTX 1050, MSVC Debug) the tests this change touches pass.

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