d3d12_xs: device slots 127 (CreateCommittedResource3) and 133 (CreatePlacedResourceX with a resource desc 1) for GXDK 2504+ callers #335

Closed
github-bot wants to merge 2 commits from gh-pr/335/head into gh-pr/335/base
Owner

@⁠GDAgent on GitHub · 2026-11-23 20:24 UTC · original
GDAgent:fix/d3d12-device-slots-127-133 → main · +642 −3 · 4 files · 2 commits · closed without merging

Builds on #334 (cl_edition.rs: caller-edition detection). Stacked on it: only the last commit (2a9c3ed) belongs to this PR; please review git diff 18a07ac.. until #334 lands, then I will rebase onto main.

What

Newer GDK titles create their resources through two device methods that main answers with the generic E_NOTIMPL stub:

  • Device slot 133: CreatePlacedResourceX, new form. Same as the existing slot 44 but the description is a D3D12_RESOURCE_DESC1 (its first fields are identical to D3D12_RESOURCE_DESC, so it is passed through unchanged) and the initial-state argument is a barrier layout instead of a resource state.
  • Device slot 127: CreateCommittedResource3: heap properties, heap flags, D3D12_RESOURCE_DESC1, barrier layout, optional clear value, optional protected session, castable-format list, riid, out pointer.

Both are routed through the existing PC-layout creation paths (create_placed_resource_x, create_committed_resource), so all current placed/committed fixups apply. The barrier layout becomes a legacy resource state through layout_state (generic read 0xac3, render target 4, UAV 8, depth write 0x10 / read 0x20, shader resource 0xc0, copy source 0x800, copy dest 0x400, resolve source 0x2000 / dest 0x1000, shading-rate source 0x1000000; the direct-queue and compute-queue variants map the same way; common, present, undefined and layouts without a legacy state map to common, 0).

Routing uses the caller's GXDK edition from #334: 2504+ callers get the new meaning; older callers go to the handler that was registered before this layer, and with none, E_NOTIMPL (as before this change; no success is faked). The protected-session and castable-format arguments are not applied on the legacy path; when a caller passes either, the call is logged with that fact.

Why / evidence

A very popular AAA title built with a 2504+ GDK reaches both calls right after list creation. In native Windows 11 runs (not run under Proton), calls to slot 133 and then slot 127 came back with an unlogged E_NOTIMPL and stopped the title's GPU-memory setup; with this change both create the resources (hr=0) and the title proceeds to descriptor-heap creation. The next blocker in that title (descriptor heaps placed at title-chosen addresses) is a separate topic and not addressed here. The argument order was read from the title's call sites; the barrier-layout values follow D3D12_BARRIER_LAYOUT.

I did not add the log-and-E_NOTIMPL stubs for device slots 91-159 and the log-and-return-0 probes for list slots 128-159 that I used while finding these slots: main already returns E_NOTIMPL for unmapped device slots, and a probe that returns 0 would claim success.

Tests

cargo test -p d3d12_xs --lib cl_edition (generic, no title data), added by this PR:

  • layout-to-state map: representative layouts of every group, the queue variants, undefined/common/unknown layouts;
  • slot 133 and 127 routing with fake creation functions: a 2504 caller reaches the PC-layout creation with the converted state and unchanged va/flags; an older caller reaches the previous handler with the raw layout argument and does not reach the creation function;
  • older caller with no previous handler: E_NOTIMPL, creation function not called;
  • device install routes both slots once, keeps the previous occupants, ignores short tables.

13 passed (9 from #334, 4 new). TOMBOX_REMOVED_EXIT_MS=off cargo test -p d3d12_xs --lib -- --test-threads=1 on this branch: 677 passed, 4 failed, 71 ignored; the 4 are the same pre-existing failures listed in #334. Native Windows 11; not run under Proton.

Not verified

  • The title runs mentioned above used the same logic on a different base (a branch that also carries the ray-tracing work); this exact branch was built and unit-tested but not re-run in a title.
  • Not run on the console; no title other than the one described.
  • Castable formats and the protected session are not applied (logged when present); a title relying on cast views of a committed resource may need more.
  • D3D12_RESOURCE_DESC1's extra field (sampler-feedback mip region) is ignored; no sampler-feedback resource has been created through this path.
  • The layout-to-state map was written from the D3D12_BARRIER_LAYOUT documentation, and only the layouts of the one title above were exercised.
**@⁠GDAgent** on GitHub · 2026-11-23 20:24 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/335) `GDAgent:fix/d3d12-device-slots-127-133` → `main` · +642 −3 · 4 files · 2 commits · closed without merging Builds on #334 (`cl_edition.rs`: caller-edition detection). Stacked on it: only the last commit (`2a9c3ed`) belongs to this PR; please review `git diff 18a07ac..` until #334 lands, then I will rebase onto `main`. ## What Newer GDK titles create their resources through two device methods that `main` answers with the generic `E_NOTIMPL` stub: - Device slot 133: `CreatePlacedResourceX`, new form. Same as the existing slot 44 but the description is a `D3D12_RESOURCE_DESC1` (its first fields are identical to `D3D12_RESOURCE_DESC`, so it is passed through unchanged) and the initial-state argument is a barrier layout instead of a resource state. - Device slot 127: `CreateCommittedResource3`: heap properties, heap flags, `D3D12_RESOURCE_DESC1`, barrier layout, optional clear value, optional protected session, castable-format list, riid, out pointer. Both are routed through the existing PC-layout creation paths (`create_placed_resource_x`, `create_committed_resource`), so all current placed/committed fixups apply. The barrier layout becomes a legacy resource state through `layout_state` (generic read 0xac3, render target 4, UAV 8, depth write 0x10 / read 0x20, shader resource 0xc0, copy source 0x800, copy dest 0x400, resolve source 0x2000 / dest 0x1000, shading-rate source 0x1000000; the direct-queue and compute-queue variants map the same way; common, present, undefined and layouts without a legacy state map to common, 0). Routing uses the caller's GXDK edition from #334: 2504+ callers get the new meaning; older callers go to the handler that was registered before this layer, and with none, `E_NOTIMPL` (as before this change; no success is faked). The protected-session and castable-format arguments are not applied on the legacy path; when a caller passes either, the call is logged with that fact. ## Why / evidence A very popular AAA title built with a 2504+ GDK reaches both calls right after list creation. In native Windows 11 runs (not run under Proton), calls to slot 133 and then slot 127 came back with an unlogged `E_NOTIMPL` and stopped the title's GPU-memory setup; with this change both create the resources (`hr=0`) and the title proceeds to descriptor-heap creation. The next blocker in that title (descriptor heaps placed at title-chosen addresses) is a separate topic and not addressed here. The argument order was read from the title's call sites; the barrier-layout values follow `D3D12_BARRIER_LAYOUT`. I did not add the log-and-`E_NOTIMPL` stubs for device slots 91-159 and the log-and-return-0 probes for list slots 128-159 that I used while finding these slots: `main` already returns `E_NOTIMPL` for unmapped device slots, and a probe that returns 0 would claim success. ## Tests `cargo test -p d3d12_xs --lib cl_edition` (generic, no title data), added by this PR: - layout-to-state map: representative layouts of every group, the queue variants, undefined/common/unknown layouts; - slot 133 and 127 routing with fake creation functions: a 2504 caller reaches the PC-layout creation with the converted state and unchanged va/flags; an older caller reaches the previous handler with the raw layout argument and does not reach the creation function; - older caller with no previous handler: `E_NOTIMPL`, creation function not called; - device install routes both slots once, keeps the previous occupants, ignores short tables. 13 passed (9 from #334, 4 new). `TOMBOX_REMOVED_EXIT_MS=off cargo test -p d3d12_xs --lib -- --test-threads=1` on this branch: 677 passed, 4 failed, 71 ignored; the 4 are the same pre-existing failures listed in #334. Native Windows 11; not run under Proton. ## Not verified - The title runs mentioned above used the same logic on a different base (a branch that also carries the ray-tracing work); this exact branch was built and unit-tested but not re-run in a title. - Not run on the console; no title other than the one described. - Castable formats and the protected session are not applied (logged when present); a title relying on cast views of a committed resource may need more. - `D3D12_RESOURCE_DESC1`'s extra field (sampler-feedback mip region) is ignored; no sampler-feedback resource has been created through this path. - The layout-to-state map was written from the `D3D12_BARRIER_LAYOUT` documentation, and only the layouts of the one title above were exercised.
Command-list vtable slots 131 and 132 change meaning with the GXDK edition
the calling module was built with. New cl_edition module reads the
_xbld_edition_sdktype=GXDK,<edition> fields from the caller's .xbld section
(bounded by SizeOfImage, highest edition wins, cached per module). The
caller is the first stack return address outside the emulator that follows a
call instruction: unwinder first, then a raw scan bounded by the thread's
stack limits.

For editions 2504 and newer the slots are a list synchronisation command,
recorded as a global UAV barrier (skipped on copy lists). For older editions
they go to the handler registered before this layer; with none, the command
is ignored and logged, without claiming success.

The shim table grows from 128 to 256 entries so slots 131/132 exist at all.
GXDK 2504+ callers create resources through device slot 133, the new form
of CreatePlacedResourceX (resource desc 1, barrier layout in place of the
initial state), and slot 127, CreateCommittedResource3. Both used to hit
the generic E_NOTIMPL stub.

Routed by the caller's GXDK edition (cl_edition): 2504+ callers go to the
existing PC-layout creation paths with the barrier layout converted to a
legacy resource state; older callers go to the handler registered before
this layer, or E_NOTIMPL when there is none. The protected session and
castable formats of slot 127 are not applied and are logged when passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:19:20 +00:00
github-bot closed this pull request 2026-11-26 06:19:20 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:50 UTC · original

Applied on main in 495cadf (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/335#issuecomment-7164360008) Applied on main in 495cadf (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.