startup-runtime: DirectStorage status arrays start pending, and there is no error record #1836

Open
opened 2026-11-24 19:23:10 +00:00 by Jess-Doit · 5 comments
Jess-Doit commented 2026-11-24 19:23:10 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T19:23:10Z.


Problem

The DirectStorage stand-in (src/startup_stubs/xcrdapi.cpp) differs from the documented status-array and error-reporting behaviour in three places:

  1. New status-array slots start pending. factory_create_status_array sets every slot to E_PENDING, so IsComplete(i) is false and GetHResult(i) is E_PENDING for a slot nothing has been enqueued into. Microsoft's Win32 implementation of the console API starts every slot complete with S_OK:

    • m_completeFlags.resize(capacity, true); m_resultCodes.resize(capacity, HRESULT_FROM_WIN32(S_OK));
    • Only EnqueueStatus marks a slot not complete.

    A caller that polls IsComplete before it first reuses a ring slot would wait forever.

  2. No error record. Queue slot 10, RetrieveErrorRecord(DSTORAGE_ERROR_RECORD*), is not implemented and traps. Slot 9, GetErrorEvent, returns an event that is never signaled, so a failed request leaves no record and no signal.

  3. CancelRequestsWithTag is a no-op (slot 7).

Sources:

  • Microsoft's Xbox-GDK-Samples, MIT: Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/.
    • DirectStorageWin32WrapperStatusArray.cpp has the initial slot state.
    • dstorage_win32.h has the IDStorageQueue method order (EnqueueRequest, EnqueueStatus, EnqueueSignal, Submit, CancelRequestsWithTag, Close, GetErrorEvent, RetrieveErrorRecord, Query) and the DSTORAGE_ERROR_RECORD layout.
  • Microsoft's DirectStorage documentation for IDStorageStatusArray and DSTORAGE_ERROR_RECORD.

Proposed slices

  1. Initial status-array state. New slots report complete with S_OK until EnqueueStatus marks them pending. A source-built consumer checks a fresh array, a pending slot after EnqueueStatus and before its turn, and the completed result. A control that restores E_PENDING must fail.
  2. Error record and error event.
    • Implement slot 10 with the documented layout: FailureCount, then the first failure in enqueue order, with its HRESULT, options, destination, source and request fields.
    • Signal the error event on the first failure, and reset the count when the record is retrieved.
    • A consumer checks a failing request's record and the event, a success that leaves the record empty, and the reset.
  3. Cancellation, as a later slice: cancel pending requests by tag, without counting a cancelled request as a failure, as the documentation states.

Done when

Each slice lands with a source-built consumer fixture and a control that must fail, and docs/startup-runtime.md records the behaviour. No game data.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589619598 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T19:23:10Z. --- ## Problem The DirectStorage stand-in (`src/startup_stubs/xcrdapi.cpp`) differs from the documented status-array and error-reporting behaviour in three places: 1. **New status-array slots start pending.** `factory_create_status_array` sets every slot to `E_PENDING`, so `IsComplete(i)` is false and `GetHResult(i)` is `E_PENDING` for a slot nothing has been enqueued into. Microsoft's Win32 implementation of the console API starts every slot complete with `S_OK`: - `m_completeFlags.resize(capacity, true); m_resultCodes.resize(capacity, HRESULT_FROM_WIN32(S_OK));` - Only `EnqueueStatus` marks a slot not complete. A caller that polls `IsComplete` before it first reuses a ring slot would wait forever. 2. **No error record.** Queue slot 10, `RetrieveErrorRecord(DSTORAGE_ERROR_RECORD*)`, is not implemented and traps. Slot 9, `GetErrorEvent`, returns an event that is never signaled, so a failed request leaves no record and no signal. 3. **`CancelRequestsWithTag` is a no-op** (slot 7). **Sources:** - Microsoft's Xbox-GDK-Samples, MIT: `Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/`. - `DirectStorageWin32WrapperStatusArray.cpp` has the initial slot state. - `dstorage_win32.h` has the `IDStorageQueue` method order (`EnqueueRequest`, `EnqueueStatus`, `EnqueueSignal`, `Submit`, `CancelRequestsWithTag`, `Close`, `GetErrorEvent`, `RetrieveErrorRecord`, `Query`) and the `DSTORAGE_ERROR_RECORD` layout. - Microsoft's DirectStorage documentation for `IDStorageStatusArray` and `DSTORAGE_ERROR_RECORD`. ## Proposed slices 1. **Initial status-array state.** New slots report complete with `S_OK` until `EnqueueStatus` marks them pending. A source-built consumer checks a fresh array, a pending slot after `EnqueueStatus` and before its turn, and the completed result. A control that restores `E_PENDING` must fail. 2. **Error record and error event.** - Implement slot 10 with the documented layout: `FailureCount`, then the first failure in enqueue order, with its HRESULT, options, destination, source and request fields. - Signal the error event on the first failure, and reset the count when the record is retrieved. - A consumer checks a failing request's record and the event, a success that leaves the record empty, and the reset. 3. **Cancellation**, as a later slice: cancel pending requests by tag, without counting a cancelled request as a failure, as the documentation states. ## Done when Each slice lands with a source-built consumer fixture and a control that must fail, and `docs/startup-runtime.md` records the behaviour. No game data. AI-assisted (Claude Code).
Jess-Doit commented 2026-11-24 20:01:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T19:23:20Z.


Claiming slices 1 and 2, with Windows 10 22H2. The startup stand-ins don't need a GPU for these.

  • Slice 1, initial status-array state: Claude Code.
  • Slice 2, RetrieveErrorRecord and the error event: Codex, driven with Claude Code.

Each slice will be a separate PR with a source-built consumer fixture and a control that must fail. Slice 3 (cancellation) is free for anyone.

AI-assisted (Claude Code, Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7142024688 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142024688). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T19:23:20Z. --- Claiming slices 1 and 2, with Windows 10 22H2. The startup stand-ins don't need a GPU for these. - **Slice 1, initial status-array state:** Claude Code. - **Slice 2, `RetrieveErrorRecord` and the error event:** Codex, driven with Claude Code. Each slice will be a separate PR with a source-built consumer fixture and a control that must fail. Slice 3 (cancellation) is free for anyone. AI-assisted (Claude Code, Codex).
chunfeng11221 commented 2026-11-24 20:01:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by chunfeng11221 on 2026-11-24T19:48:53Z.


Taking slice 3 (\CancelRequestsWithTag) on Windows 11 x64 / MSVC 19.44 — PR up at https://github.com/R0Y00/Xbox2Windows/pull/1869 with a source-built consumer fixture covering pre-Submit and post-Submit cancellation, bitmask/mismatch controls, and fail-first mutation checks (kept conflict-free with #1847). AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7142626692 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142626692). Originally posted by [chunfeng11221](https://github.com/chunfeng11221) on 2026-11-24T19:48:53Z. --- Taking slice 3 (\CancelRequestsWithTag\) on Windows 11 x64 / MSVC 19.44 — PR up at https://github.com/R0Y00/Xbox2Windows/pull/1869 with a source-built consumer fixture covering pre-Submit and post-Submit cancellation, bitmask/mismatch controls, and fail-first mutation checks (kept conflict-free with #1847). AI-assisted.
R0Y00 commented 2026-11-24 20:01:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T19:54:45Z.


The initial-state slice #1847 is on main at b509a670. Release verified fresh slots report S_OK, the fence-held slot alone becomes E_PENDING, and it completes after the fence is released. I also fixed the new fixture to supply a full 40-byte queue descriptor before the final Windows and Linux checks. The error-event/error-record slice stays with the existing claim; cancellation is tracked separately in #1869.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7142767208 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142767208). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T19:54:45Z. --- The initial-state slice #1847 is on main at b509a670. Release verified fresh slots report S_OK, the fence-held slot alone becomes E_PENDING, and it completes after the fence is released. I also fixed the new fixture to supply a full 40-byte queue descriptor before the final Windows and Linux checks. The error-event/error-record slice stays with the existing claim; cancellation is tracked separately in #1869.
R0Y00 commented 2026-11-24 21:01:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T20:39:13Z.


Error notification and retrieval (#1873) are on main at 3ad0069d. Release verified the first failed read record, the Xbox CommandType, the reset to NONE, repeat caller-owned event signaling and the worker-start failure path. Cancellation remains in #1869 pending consistent handling of the request tag and inflate sizing.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143874357 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7143874357). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T20:39:13Z. --- Error notification and retrieval (#1873) are on main at 3ad0069d. Release verified the first failed read record, the Xbox CommandType, the reset to NONE, repeat caller-owned event signaling and the worker-start failure path. Cancellation remains in #1869 pending consistent handling of the request tag and inflate sizing.
tedin7 commented 2026-11-25 03:01:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:57:33Z.


Taking a focused follow-up slice: distinct status HRESULTs for destination-too-small vs read-past-EOF (instead of generic E_FAIL), plus null-argument validation on OpenFile, CreateStatusArray and CreateQueue. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151419111 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7151419111). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:57:33Z. --- Taking a focused follow-up slice: distinct status HRESULTs for destination-too-small vs read-past-EOF (instead of generic E_FAIL), plus null-argument validation on OpenFile, CreateStatusArray and CreateQueue. AI-assisted.
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#1836
No description provided.