d3d12_xs: strip buffer-only read states from texture barriers and initial states #18

Closed
QuentinDanblon wants to merge 0 commits from upstream-pr/18 into main
QuentinDanblon commented 2026-11-21 17:30:23 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T17:30:23Z.


Library / area: d3d12_xs (resource barriers, resource creation states)

Exports changed (exports.txt rows): none

Source of the behaviour: PC D3D12 accepts VERTEX_AND_CONSTANT_BUFFER (0x1) and INDEX_BUFFER (0x2) only on buffers. Ported from brcly/TomBox (crates declare MIT OR Apache-2.0), GDAgent: dde663f and barriers.rs.

Xbox titles transition textures with the 0x3 bits set (render-target reads 0x8c3, GENERIC_READ 0xac3) and also pass them as creation states. On PC, command-list Close fails and the device is removed. At 226938c, xone_barrier::sanitize only stripped 0x400000 and turned aliasing barriers into UAV barriers. The graphics path (cmdlist_x.rs resource_barrier_x) and CreateCommittedResource / CreatePlacedResource / CreatePlacedResourceX passed the bits through. The copy queue was already safe (dma_list.rs copy_legal_barriers).

Changes:

  • xone_barrier.rs: a pure rewrite() drops 0x3 from both states of a transition on a non-buffer resource (GetDesc slot 10, same ABI as cl_ext.rs/present.rs). It removes transitions that the rewrite collapses to before == after. It keeps the title's own no-op transitions, split flags, subresource, opaque barrier bytes and order. It allocates only on the first change.
  • resource_barrier_x and the cmdlist_validate replay use the rewritten (possibly shorter) count. An empty batch is not forwarded.
  • Creation paths use initial_state(dim, s), so gpu_va, placed (upload.rs barriers) and rtcap track the same PC-legal state.
  • Separate commit: declare COND_POOL_TEST. cargo test -p d3d12_xs --lib did not compile at 226938c (E0425 in gpu_wait.rs:666,720).

Tests: cargo test -p d3d12_xs xone_barrier: 6 passed. They cover a mixed batch (order, flags, collapse, opaque bytes, input untouched), a fully collapsed batch, a clean batch left untouched, aliasing, and the 0x400000 strip. Full cargo test -p d3d12_xs: lib 237 passed, 6 ignored (hw); process_debug_off/on passed. Not run against a title; I don't have one.

Build note: a fresh checkout of 226938c does not build d3d12_xs. compat-common/backend_data/* is not in the repo, and query_accum.dxil needs TOMBOX_DXC_DIR. I built with local placeholders, which are not committed.

  • cargo test -p d3d12_xs passes
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6532122635 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/18). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T17:30:23Z. --- **Library / area:** d3d12_xs (resource barriers, resource creation states) **Exports changed (exports.txt rows):** none **Source of the behaviour:** PC D3D12 accepts VERTEX_AND_CONSTANT_BUFFER (0x1) and INDEX_BUFFER (0x2) only on buffers. Ported from brcly/TomBox (crates declare MIT OR Apache-2.0), GDAgent: [dde663f](https://github.com/brcly/TomBox/commit/dde663f25bc650edfe062c7752628fcf17895d06) and [barriers.rs](https://github.com/brcly/TomBox/blob/master/crates/compat/d3d12_xs/src/barriers.rs). Xbox titles transition textures with the 0x3 bits set (render-target reads 0x8c3, GENERIC_READ 0xac3) and also pass them as creation states. On PC, command-list Close fails and the device is removed. At 226938c, `xone_barrier::sanitize` only stripped 0x400000 and turned aliasing barriers into UAV barriers. The graphics path (`cmdlist_x.rs` `resource_barrier_x`) and `CreateCommittedResource` / `CreatePlacedResource` / `CreatePlacedResourceX` passed the bits through. The copy queue was already safe (`dma_list.rs` `copy_legal_barriers`). Changes: - `xone_barrier.rs`: a pure `rewrite()` drops 0x3 from both states of a transition on a non-buffer resource (`GetDesc` slot 10, same ABI as `cl_ext.rs`/`present.rs`). It removes transitions that the rewrite collapses to before == after. It keeps the title's own no-op transitions, split flags, subresource, opaque barrier bytes and order. It allocates only on the first change. - `resource_barrier_x` and the `cmdlist_validate` replay use the rewritten (possibly shorter) count. An empty batch is not forwarded. - Creation paths use `initial_state(dim, s)`, so `gpu_va`, `placed` (upload.rs barriers) and `rtcap` track the same PC-legal state. - Separate commit: declare `COND_POOL_TEST`. `cargo test -p d3d12_xs --lib` did not compile at 226938c (E0425 in gpu_wait.rs:666,720). Tests: `cargo test -p d3d12_xs xone_barrier`: 6 passed. They cover a mixed batch (order, flags, collapse, opaque bytes, input untouched), a fully collapsed batch, a clean batch left untouched, aliasing, and the 0x400000 strip. Full `cargo test -p d3d12_xs`: lib 237 passed, 6 ignored (hw); process_debug_off/on passed. Not run against a title; I don't have one. Build note: a fresh checkout of 226938c does not build d3d12_xs. `compat-common/backend_data/*` is not in the repo, and `query_accum.dxil` needs `TOMBOX_DXC_DIR`. I built with local placeholders, which are not committed. - [x] `cargo test -p d3d12_xs` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
QuentinDanblon commented 2026-11-21 21:03:18 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T21:03:18Z.


Merged in the source sync 1159c96 (adapted). Thanks! Closing.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7069201330 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/18#issuecomment-7069201330). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T21:03:18Z. --- Merged in the source sync 1159c96 (adapted). Thanks! Closing.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!18
No description provided.