Tests: compare the D3D12 answers with the host driver on the same machine (no console files needed) #480

Open
opened 2026-11-26 04:22:53 +00:00 by github-bot · 3 comments
Owner

@⁠Luislariosss on GitHub · 2026-11-24 00:54 UTC · original

tests/xg_oracle.rs compares XCL against the console's own xg_xs.dll (XCL_SAMPLE_XG), which is the right oracle for the console layout, but it needs console files, so it skips on a machine that has none. There is no test that compares XCL's answers with the PC driver on the same machine, and for the part of the API that D3D12.X shares with plain D3D12 that driver is also ground truth: if XCL's GetResourceTiling, CreateReservedResource or CheckFeatureSupport answer something the driver would not, the title sees a difference that no console-file test would catch.

Proposal: a small integration test that asks the host device and the XCL path the same question and compares. It needs no game data and no console DLL.

Measured expectations, so the test has something to assert

Plain D3D12 on this machine, no game files, GetResourceTiling on a reserved resource created with D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE:

adapter: AMD Radeon RX 9060 XT, Adrenalin 26.10.1 (Windows driver 32.0.32015.7029), Windows 11 26200
tiled_resources_tier: 4

R8G8B8A8_UNORM   8x8     total_tiles=1  subresources=1  mip0 1x1  shape 128x128
R8G8B8A8_UNORM   256x256 total_tiles=4  subresources=1  mip0 2x2  shape 128x128
BC1_UNORM        256x256 total_tiles=1  subresources=1  mip0 1x1  shape 512x256
D32_FLOAT        8x8     total_tiles=1  subresources=1  mip0 1x1  shape 128x128

Two things worth pinning, both of which a hand-written tile formula would get wrong: the 8x8 case is one tile, not zero, and the tile shape depends on the format - BC1 reports 512x256 texels per tile where RGBA8 and D32 report 128x128.

What the test would do

  1. Create the same reserved resource twice on the same device: once through ID3D12Device::CreateReservedResource directly, once through the path the title's CreateReservedResource takes in hle/d3d12x/vram.rs (which rewrites the layout and then calls dev_create_reserved_resource).
  2. Ask GetResourceTiling of both and assert equal total_tiles, WidthInTiles, HeightInTiles and D3D12_TILE_SHAPE.
  3. The same shape for CheckFeatureSupport over the request types XCL answers itself, comparing with D3D12_FEATURE_DATA_D3D12_OPTIONS* from the host device.

If XCL decides to compute tiling rather than ask the driver (vram.rs:490 asks it today, so this may already hold), the numbers above are the ones to match on RDNA4.

I have not opened a PR: I would rather know whether this is wanted, and which side should be the oracle where the console and the PC driver legitimately differ (a D3D12.X feature the PC has no equivalent for). If it is wanted, I can write it and paste a full cargo test --workspace run from this card (676 passed, 0 failed, 41 ignored on 2997c9aca).

AI-assisted.

**@⁠Luislariosss** on GitHub · 2026-11-24 00:54 UTC · [original](https://github.com/xcl-dev/xcl/issues/480) `tests/xg_oracle.rs` compares XCL against the console's own `xg_xs.dll` (`XCL_SAMPLE_XG`), which is the right oracle for the console layout, but it needs console files, so it skips on a machine that has none. There is no test that compares XCL's answers with the **PC driver on the same machine**, and for the part of the API that D3D12.X shares with plain D3D12 that driver is also ground truth: if XCL's `GetResourceTiling`, `CreateReservedResource` or `CheckFeatureSupport` answer something the driver would not, the title sees a difference that no console-file test would catch. Proposal: a small integration test that asks the host device and the XCL path the same question and compares. It needs no game data and no console DLL. ## Measured expectations, so the test has something to assert Plain D3D12 on this machine, no game files, `GetResourceTiling` on a reserved resource created with `D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE`: ``` adapter: AMD Radeon RX 9060 XT, Adrenalin 26.10.1 (Windows driver 32.0.32015.7029), Windows 11 26200 tiled_resources_tier: 4 R8G8B8A8_UNORM 8x8 total_tiles=1 subresources=1 mip0 1x1 shape 128x128 R8G8B8A8_UNORM 256x256 total_tiles=4 subresources=1 mip0 2x2 shape 128x128 BC1_UNORM 256x256 total_tiles=1 subresources=1 mip0 1x1 shape 512x256 D32_FLOAT 8x8 total_tiles=1 subresources=1 mip0 1x1 shape 128x128 ``` Two things worth pinning, both of which a hand-written tile formula would get wrong: the 8x8 case is **one** tile, not zero, and the **tile shape depends on the format** - BC1 reports 512x256 texels per tile where RGBA8 and D32 report 128x128. ## What the test would do 1. Create the same reserved resource twice on the same device: once through `ID3D12Device::CreateReservedResource` directly, once through the path the title's `CreateReservedResource` takes in `hle/d3d12x/vram.rs` (which rewrites the layout and then calls `dev_create_reserved_resource`). 2. Ask `GetResourceTiling` of both and assert equal `total_tiles`, `WidthInTiles`, `HeightInTiles` and `D3D12_TILE_SHAPE`. 3. The same shape for `CheckFeatureSupport` over the request types XCL answers itself, comparing with `D3D12_FEATURE_DATA_D3D12_OPTIONS*` from the host device. If XCL decides to compute tiling rather than ask the driver (`vram.rs:490` asks it today, so this may already hold), the numbers above are the ones to match on RDNA4. I have not opened a PR: I would rather know whether this is wanted, and which side should be the oracle where the console and the PC driver legitimately differ (a D3D12.X feature the PC has no equivalent for). If it is wanted, I can write it and paste a full `cargo test --workspace` run from this card (`676 passed, 0 failed, 41 ignored` on `2997c9aca`). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:22:53 +00:00
Author
Owner

@⁠Luislariosss on GitHub · 2026-11-24 01:11 UTC · original

One thing I checked before answering the design question, because it changes what the test can prove: vram.rs:490 already asks the driver — dev.GetResourceTiling(res, Some(&mut total), ...) — for the resource it creates. So step 2 of your proposal ("ask both and compare") compares XCL with the driver only if both queries are made on the same resource. They are not: the console path rewrites Layout before calling dev_create_reserved_resource, so the two calls describe two different resources and equality is not the invariant.

What I think the test should assert, in this order:

  1. Same resource, driver as oracle. Create the resource through the console path, then query GetResourceTiling twice — once through XCL's slot, once directly on the returned ID3D12Resource — and require identical total_tiles, WidthInTiles, HeightInTiles and TILE_SHAPE. That catches XCL answering from a formula instead of the driver, without redefining what is correct.
  2. Measured numbers as a regression pin, not as the oracle. The table in the issue (8x8 → 1 tile, 256x256 → 4, BC1 → 512x256 texels, D32 → 128x128, tier 4), with a comment naming the card and driver. That is what breaks if someone swaps the layout rewrite or the format mapping.
  3. Where they legitimately differ, the console wins and the test says so. For a D3D12.X field the PC driver has no equivalent (console-only enums, Xbox flags), asserting against the host would bake in the PC's answer; those belong with xg_oracle.rs and its XCL_SAMPLE_XG skip, or in a documented exception in the test.

So: host driver as oracle for anything the PC also executes, console as oracle for what only the console defines, and the measured RDNA4 numbers pinned as constants so a regression fails loudly instead of silently following whatever the driver says that day.

I am not the one who decides it — it is the author's call and yours — but if that split is what you want, I can write the test and paste a full cargo test --workspace from this RX 9060 XT (677 passed, 0 failed, 41 ignored on 2997c9aca).

AI-assisted.

**@⁠Luislariosss** on GitHub · 2026-11-24 01:11 UTC · [original](https://github.com/xcl-dev/xcl/issues/480#issuecomment-7118849337) One thing I checked before answering the design question, because it changes what the test can prove: `vram.rs:490` already asks the driver — `dev.GetResourceTiling(res, Some(&mut total), ...)` — for the resource it creates. So step 2 of your proposal ("ask both and compare") compares XCL with the driver only if both queries are made **on the same resource**. They are not: the console path rewrites `Layout` before calling `dev_create_reserved_resource`, so the two calls describe two different resources and equality is not the invariant. What I think the test should assert, in this order: 1. **Same resource, driver as oracle.** Create the resource through the console path, then query `GetResourceTiling` twice — once through XCL's slot, once directly on the returned `ID3D12Resource` — and require identical `total_tiles`, `WidthInTiles`, `HeightInTiles` and `TILE_SHAPE`. That catches XCL answering from a formula instead of the driver, without redefining what is correct. 2. **Measured numbers as a regression pin, not as the oracle.** The table in the issue (8x8 → 1 tile, 256x256 → 4, BC1 → 512x256 texels, D32 → 128x128, tier 4), with a comment naming the card and driver. That is what breaks if someone swaps the layout rewrite or the format mapping. 3. **Where they legitimately differ, the console wins and the test says so.** For a D3D12.X field the PC driver has no equivalent (console-only enums, Xbox flags), asserting against the host would bake in the PC's answer; those belong with `xg_oracle.rs` and its `XCL_SAMPLE_XG` skip, or in a documented exception in the test. So: host driver as oracle for anything the PC also executes, console as oracle for what only the console defines, and the measured RDNA4 numbers pinned as constants so a regression fails loudly instead of silently following whatever the driver says that day. I am not the one who decides it — it is the author's call and yours — but if that split is what you want, I can write the test and paste a full `cargo test --workspace` from this RX 9060 XT (677 passed, 0 failed, 41 ignored on `2997c9aca`). AI-assisted.
Author
Owner

@⁠razormontana on GitHub · 2026-11-24 18:02 UTC · original

I’m taking the CreateCommandQueue host-driver parity test. I’ll compare XCL’s queue hook with native D3D12 on the same adapter, including console flag translation, using synthetic inputs on my RTX 3070. Codex (GPT-6.2 Sol) is assisting.

**@⁠razormontana** on GitHub · 2026-11-24 18:02 UTC · [original](https://github.com/xcl-dev/xcl/issues/480#issuecomment-7140067935) I’m taking the `CreateCommandQueue` host-driver parity test. I’ll compare XCL’s queue hook with native D3D12 on the same adapter, including console flag translation, using synthetic inputs on my RTX 3070. Codex (GPT-6.2 Sol) is assisting.
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 07:41 UTC · original

Taking the DispatchX indirect-execution parity case for console argument type 105. The planned RTX 4080 check covers the synthetic mapped-title path on current main, native and adopted-PC controls, and GPU readback of the dispatch output.

**@⁠CryingLaughing** on GitHub · 2026-11-26 07:41 UTC · [original](https://github.com/xcl-dev/xcl/issues/480#issuecomment-7185732798) Taking the `DispatchX` indirect-execution parity case for console argument type `105`. The planned RTX 4080 check covers the synthetic mapped-title path on current `main`, native and adopted-PC controls, and GPU readback of the dispatch output.
This discussion has been locked. Commenting is limited to contributors.
No description provided.