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

Open
opened 2026-11-26 23:37:04 +00:00 by github-bot · 5 comments
Owner

@⁠Jess-Doit on GitHub · 2026-11-24 19:23 UTC · original

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** on GitHub · 2026-11-24 19:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843) ## 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:37:04 +00:00
Author
Owner

@⁠Jess-Doit on GitHub · 2026-11-24 19:23 UTC · original

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).

**@⁠Jess-Doit** on GitHub · 2026-11-24 19:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142024688) 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).
Author
Owner

@⁠chunfeng11221 on GitHub · 2026-11-24 19:48 UTC · original

Taking slice 3 (\CancelRequestsWithTag) on Windows 11 x64 / MSVC 19.44 — PR up at #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.

**@⁠chunfeng11221** on GitHub · 2026-11-24 19:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142626692) Taking slice 3 (\CancelRequestsWithTag\) on Windows 11 x64 / MSVC 19.44 — PR up at https://git.gtahub.st/github/R0Y00--Xbox2Windows/pulls/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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 19:54 UTC · original

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** on GitHub · 2026-11-24 19:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7142767208) 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 20:39 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-24 20:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7143874357) 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:57 UTC · original

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.

**@⁠tedin7** on GitHub · 2026-11-25 02:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/1843#issuecomment-7151419111) 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.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#1843
No description provided.