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

Open
github-bot wants to merge 1 commit from github-bot/gh-820 into main AGit
Owner

@⁠kotekompotek on GitHub · 2026-11-24 14:11 UTC · original
kotekompotek:work/d3d12-xs-dxgi-query-residency → main · +108 −10 · 3 files · 1 commits · open

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

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.
**@⁠kotekompotek** on GitHub · 2026-11-24 14:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820) `kotekompotek:work/d3d12-xs-dxgi-query-residency` → `main` · +108 −10 · 3 files · 1 commits · open Claimed in the coordination issue as: DXGI-QUERY-RESIDENCY (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:23:00 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:18 UTC · original · approved these changes

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** on GitHub · 2026-11-24 14:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#pullrequestreview-6040856263) · **approved these changes** ### 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.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:26 UTC · original · approved these changes

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.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#pullrequestreview-6041011035) · **approved these changes** 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.
Author
Owner

@⁠moffington on GitHub · 2026-11-24 15:53 UTC · original

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.

**@⁠moffington** on GitHub · 2026-11-24 15:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#issuecomment-7136780823) 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.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-24 18:08 UTC · original

@⁠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: #14

Locally ran:

  • device_proxy + dxgi_device: 2/2 Passed
  • test_ctest_registration.py: 4/4 OK
  • test_docs_*.py: OK
**@⁠kotekompotek** on GitHub · 2026-11-24 18:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#issuecomment-7140220353) @⁠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`: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Locally ran: - `device_proxy` + `dxgi_device`: `2/2 Passed` - `test_ctest_registration.py`: `4/4 OK` - `test_docs_*.py`: `OK`
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 09:18 UTC · original

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

AI-assisted: yes

**@⁠kotekompotek** on GitHub · 2026-11-25 09:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#issuecomment-7158143668) Rebased on current ubi/main (3f81d46ac), no conflicts. Verified: `dxgi_device_test` (3 backend(s) passed) and `xs_proxy_mock_test` (PASS) on Windows/GTX 1050. AI-assisted: yes
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:00 UTC · original

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/820#issuecomment-7168869799) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/820/head:github-bot/gh-820'
git switch 'github-bot/gh-820'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-820'
git switch 'github-bot/gh-820'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-820'
git switch 'github-bot/gh-820'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-820'
git switch 'main'
git merge --squash 'github-bot/gh-820'
git switch 'main'
git merge --ff-only 'github-bot/gh-820'
git switch 'main'
git merge 'github-bot/gh-820'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.