Proposal: architecture overview and the CPU trunk #131

Closed
opened 2026-11-21 16:47:24 +00:00 by Leyukaka · 10 comments
Leyukaka commented 2026-11-21 16:47:24 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T16:47:24Z.


This is a proposed docs/architecture.md for discussion before any PR. It maps the components and their data flow, lists where the boundaries are weak or duplicated, collects what each CPU path refuses today, and ends with a proposal on the CPU trunk.

That proposal differs from the direction stated in the README and on #46: it suggests making native mapping plus a shared shim layer the path expected to reach startup, with static translation kept as the reference and for functions that need patching. I've put it here first so you can accept, reject or reshape it. Steps 1, 2 and 5 of the "first steps" list are useful under either direction, and I'm happy to start with those whatever you decide on the rest.

How it was produced: an AI-assisted review. A first draft was written from the code; Codex and Grok each reviewed the repository independently, read-only; Fable checked every factual claim against a46f1ff, and its corrections were applied. A human contributor took the decisions and reviewed the result. Every claim points to a file so it can be checked. If something is wrong, I'll fix the page before any PR.

AI-assisted.


Architecture

This page describes how the parts of Xbox2Windows fit together, where their boundaries are weak, and one proposal for what to do next. Measured results and reproduction commands stay in experiments.md; this page links to them instead of repeating them.

How this page was produced

This page came out of an AI-assisted architecture review meant to move the project forward as a whole, not one test at a time:

  • A coordinating agent wrote a first draft from the code.
  • Codex and Grok each reviewed the repository independently, in read-only mode, without seeing the draft or each other's report.
  • Fable checked every factual claim of the merged text against the code at commit a46f1ff, and the corrections were applied.
  • Points that needed a decision rather than a fact were sent to a human contributor. That contributor makes those decisions, works with the models in the loop, and reviewed this page before it was proposed.

Claims point to files and lines so they can be checked. The proposal at the end is a suggestion from this review. It is not a decision of the maintainers.

What the tree is today

Xbox2Windows is an evidence lab for running Xbox Series X|S (Scarlett) software on x64 Windows. CI uses only fixtures built from this repository. Some results come from pinned local package DLLs and are recorded in docs/experiments.md with their SHA-256. No title executable has been run, and the inspected build did not contain one. Title CPU execution, startup and frame rate are unverified (README, first paragraph).

The Scarlett CPU code is already x64 PE32+. The work is therefore about three things:

  • making that code callable on Windows;
  • replacing the Xbox system and graphics APIs it imports;
  • translating the GPU programs it ships.

Components

Component Data flow Main code Tests
Intake MicrosoftGame.Config, layout and PE files → startup locations, import inventory, dependency paths tools/intake_exe.py, tools/pe_inventory.py, tools/dependency_paths.py, tools/verify_build.py, tools/resource_inventory.py static_exe_intake, conditional_import_paths, layout_chunk_summary
CPU: static translation PE export and unwind ranges → per-shape lowering → C++ → MSVC DLL → differential check against the original tools/cpu_leaf_aot.py, tools/cpu_call_aot.py, tools/cpu_chained_aot.py, tools/cpu_ranges.py; the shared integer lowerer lower() in tools/ffx_version_query.py, reused by tools/bink_heap_aot.py and the tools/ffx_*.py profiles cpu_aot_*
CPU: native mapping PE file → private image with DIR64 relocations, imports bound by a host resolver, section protections, .pdata, DLL TLS callbacks and entry point → callable exports tools/pe_map.cpp cpu_native_map, cpu_native_seh, cpu_native_tls
Windows runtime Xbox API call → desktop behaviour src/era_heap.*, plus per-experiment providers in tests/ (for example tests/cpu/bink_heap_provider.cpp) era_heap_*, desktop_memory_query, cpu_aot_bink_heap
Shaders archive record → gfx1013 disassembly (LLVM) → HLSL → DXC → D3D12 readback tools/pixel_aot.py; tools/ffx_dispatch_aot.py (a second opcode table over the same disassembler); hand-written HLSL for BVH/DXR in tests/ pixel_aot_*, ffx_*, bvh_*
Textures and assets archive ranges → BC7 untile, mip tail, BCPack lane probes, script-state replay tools/bc7_tiles.py, tools/paged_resource.py, tools/bcpack_probe.py, tools/script_* bcpack_prefix_and_mip_tail, bc7_draw_*, script_*
Desktop GPU coverage packaged offscreen_check → adapter or WARP → Markdown report tests/offscreen_check.cpp, tools/gpu-check/, tools/package-gpu-check.ps1 *_warp, *_hardware, the hardware thread (#1)

src/ currently holds only era_heap.* and rgb9e5.hlsli. Most runtime behaviour lives in test-side providers and hosts.

Boundaries that are weak or duplicated

  • The two CPU paths bind imports differently. Static translation links a provider import library at build time (CMakeLists.txt, the cpu_translation targets). Native mapping binds through a resolver supplied by the host (tools/pe_map.cpp).
  • Intake and the mapper see different bytes. tools/cpu_ranges.py reads min(VirtualSize, SizeOfRawData), while pe_map maps VirtualSize and zero-fills the rest. Data past the raw size exists in a mapped image but is invisible to intake and to the translators.
  • Delay imports: intake records them (tools/pe_inventory.py); pe_map rejects them.
  • Heap behaviour: src/era_heap.cpp rejects any attribute bits outside 24–28, so it refuses the measured Bink word 0x05e50000. tests/cpu/bink_heap_provider.cpp accepts only that word. Each experiment therefore has its own heap.
  • The reusable lowerer is not separate. It lives in a tool named after one package function (tools/ffx_version_query.py).
  • Shared integration points: tests/offscreen_check.cpp hosts triangle, compute, DXR, BVH, FidelityFX, pixel readback and BC7. Together with CMakeLists.txt and docs/experiments.md, it is where unrelated contributions collide.

What each path refuses

These refusals are the current edge of the CPU work. Each one is a candidate for a fixture.

  • Static translators:
    • one prologue shape (tools/cpu_call_aot.py);
    • loops, more than 256 instructions or more than 2048 steps (tools/cpu_chained_aot.py);
    • any external edge without a named binding (lower() in tools/ffx_version_query.py).
  • pe_map refusals: each returns a named error.
    • delay imports;
    • non-empty TLS data templates, because implicit TLS needs a slot in ntdll's per-thread array;
    • an entry point or TLS callback outside an executable section;
    • unreadable TLS directories and callback lists;
    • more than 256 TLS callbacks;
    • imports without a resolver.
  • Not handled by pe_map:
    • a non-DLL image gets no TLS callback or entry-point call, which is what LoadLibrary does too, so an EXE's own startup is never run;
    • export lookup does not yet check page readability.

Imports and shims

An Xbox image imports from system DLLs such as kernelx, xmem and d3d12_xs, which do not exist on a desktop.

  • Measured edges: the dependency baseline for 16 package DLLs on Windows build 26200 records 1,337 edges, of which 1,329 resolve. The eight unresolved edges are six distinct interfaces across xmem.dll and d3d12_xs.dll (docs/experiments.md, "PE dependency baseline").
  • Host dependence (inference): resolution goes through the host's API-set schema (tools/pe_inventory.py), so the counts may change on another Windows build. This is an inference from the code and has not been measured.
  • Device calls: they go through vtable slots, not imports, so an import table never sees them (tools/ffx_device_init.py).
  • Hash pinning: the FidelityFX branch data is pinned to one loader hash (tools/dependency_paths.py). With another loader the tool reports no conditional edges and still exits 0. The translation tool (tools/ffx_version_query.py) raises on a hash mismatch instead.

There is no shared shim library and no shared contract for a shimmed call: structure sizes, error codes, allocation ownership and attribute words. Each experiment binds the few calls it needs.

GPU path

  • Three separate pipelines:
    • pixel_aot.py for one straight-line pixel subset;
    • ffx_dispatch_aot.py for four pinned compute programs;
    • hand-written HLSL for BVH, DXR and root signatures.
  • Assumptions supplied by the harness:
    • the caller passes the texture and interpolation SGPRs and the sampler words (docs/experiments.md, "Offline pixel shader recompilation");
    • the FidelityFX replay covers an 8×4 tile, and its full-wave LDS path is not translated (tools/ffx_dispatch_aot.py).
  • Desktop results only: for the Xbox BVH programs, the desktop validator reports an unrecognized dxil-ms-xb2 target (docs/experiments.md). Clearing root-flag bits makes root-signature serialization succeed but does not address those programs. The BVH and wave64 rows in the README are desktop results.

Evidence model and CI

  • CI coverage: Windows CI runs CTest without the _hardware tests; it also smoke-tests the GPU check package on WARP. An Ubuntu job assembles and translates gfx1013 fixtures with LLVM 15, and a Linux job runs the platform-independent Python checks (.github/workflows/windows.yml).
  • Package inputs: FFX_UPSCALER_IMAGE and BINK_HEAP_IMAGE are local-only. CI builds the source-built controls under the same test names.
  • Python requirement: the Python-driven tests, including every cpu_* PE test, are registered only if out/pe-env/Scripts/python.exe exists at configure time (CMakeLists.txt, if(EXISTS "${INTAKE_PYTHON}")). The README and CONTRIBUTING document this requirement. Configure still gives no warning, and the three smoke tests pass without these tests.
  • Negative controls: a new behaviour needs a control that fails without it. Examples are an altered provider, a damaged copy, a mutated input or a swapped descriptor. GPU tests report passes, failures and capability skips (exit code 77) separately.

Adding an experiment

  1. State the question and the completion condition in an issue.
  2. Build the smallest fixture that shows the behaviour: MASM in tests/cpu/ for machine-code shapes, C++ or HLSL elsewhere.
  3. Compare it with an independent reference: the Windows loader, a native caller, a CPU reference or DXR.
  4. Add a negative control, register both in CMakeLists.txt, and record the measurement in docs/experiments.md.
  5. Do not add a new lowerer or opcode table. Extend the existing one, or open an issue to split it out first.

Proposal for discussion: the CPU trunk

Current direction. The README and the maintainer's comment on #46 set static recompilation as the main direction, with the native run as an independent reference for checking translated calls and shims.

Proposal. This review recommends a different weighting. Make native mapping plus a shared shim layer the trunk that is expected to reach a title's startup. Keep static translation for differential evidence and for functions that must be patched or instrumented. The facts behind it:

  • Scarlett user code is already x64, and pe_map runs the original instructions. It already reproduces DIR64 relocations, ordinary imports and .pdata. For DLLs it also reproduces TLS callbacks and the entry point, compared with the Windows loader in cpu_native_tls. It raises and catches an exception inside a mapped image (cpu_native_seh).
  • Each static translator stops at the first function outside its shape: a loop, a second call, an indirect branch or another prologue (see What each path refuses). Each package slice depends on hand bindings and a pinned hash that public CI does not build.
  • A testable claim: none of the steps below needs a new translator. Each needs a loader or shim feature that the mapper path lacks today.

Steps 1, 2 and 5 are useful under either direction. The choice belongs to the maintainers.

First steps, using source-built fixtures only

  1. Harden pe_map. Add a readability check to export lookup. Reject a double release or a pointer that pe_map_image did not return. Write down a lifecycle contract for callbacks that map or release images.
  2. One XMem shim. A source-built xmem provider exporting XMemAlloc/XMemFree that accepts the measured attribute words, used by both era_heap_check and the Bink heap fixture.
  3. Delay imports in pe_map. A new source-built DLL with one /DELAYLOAD import. The delayed call is bound and compared with LoadLibrary. The existing intake_candidate.exe cannot serve: it is an EXE and has TLS data, both of which pe_map does not run.
  4. A process-startup fixture. A source-built EXE and two DLLs with static initialization, a TLS value read on two threads and an entry marker. Compare the initialization log and exit code with a normal Windows launch. This is the first test where "starts" means more than "a DLL export returns".
  5. Configure check. Warn or fail at configure time when the Python environment is missing, so cpu_* tests cannot disappear unnoticed.

Known inconsistencies

  • README: the summary row says five Radeon GPUs passed forced wave64, but the hardware table lists nine Radeon rows that passed, plus an RX 6600 LE that skipped.
  • CONTRIBUTING: src/ is described as the Windows runtime, but most runtime behaviour lives in test-side providers.
  • STATUS in tests/cpu/native_map_check.py: it names only the MapStatus values that test uses, not the full enum in tools/pe_map.cpp.
  • Package profiles: tools/cpu_chained_aot.py and tools/ffx_version_query.py copy from guest addresses supplied by the profile without a host-side bounds check.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531636477 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T16:47:24Z. --- This is a proposed `docs/architecture.md` for discussion before any PR. It maps the components and their data flow, lists where the boundaries are weak or duplicated, collects what each CPU path refuses today, and ends with a proposal on the CPU trunk. That proposal differs from the direction stated in the README and on #46: it suggests making native mapping plus a shared shim layer the path expected to reach startup, with static translation kept as the reference and for functions that need patching. I've put it here first so you can accept, reject or reshape it. Steps 1, 2 and 5 of the "first steps" list are useful under either direction, and I'm happy to start with those whatever you decide on the rest. How it was produced: an AI-assisted review. A first draft was written from the code; Codex and Grok each reviewed the repository independently, read-only; Fable checked every factual claim against `a46f1ff`, and its corrections were applied. A human contributor took the decisions and reviewed the result. Every claim points to a file so it can be checked. If something is wrong, I'll fix the page before any PR. _AI-assisted._ --- # Architecture This page describes how the parts of Xbox2Windows fit together, where their boundaries are weak, and one proposal for what to do next. Measured results and reproduction commands stay in [experiments.md](experiments.md); this page links to them instead of repeating them. ## How this page was produced This page came out of an AI-assisted architecture review meant to move the project forward as a whole, not one test at a time: - A coordinating agent wrote a first draft from the code. - Codex and Grok each reviewed the repository independently, in read-only mode, without seeing the draft or each other's report. - Fable checked every factual claim of the merged text against the code at commit `a46f1ff`, and the corrections were applied. - Points that needed a decision rather than a fact were sent to a human contributor. That contributor makes those decisions, works with the models in the loop, and reviewed this page before it was proposed. Claims point to files and lines so they can be checked. The [proposal](#proposal-for-discussion-the-cpu-trunk) at the end is a suggestion from this review. It is not a decision of the maintainers. ## What the tree is today Xbox2Windows is an evidence lab for running Xbox Series X|S (Scarlett) software on x64 Windows. CI uses only fixtures built from this repository. Some results come from pinned local package DLLs and are recorded in `docs/experiments.md` with their SHA-256. No title executable has been run, and the inspected build did not contain one. Title CPU execution, startup and frame rate are unverified (README, first paragraph). The Scarlett CPU code is already x64 PE32+. The work is therefore about three things: - making that code callable on Windows; - replacing the Xbox system and graphics APIs it imports; - translating the GPU programs it ships. ## Components | Component | Data flow | Main code | Tests | |---|---|---|---| | Intake | `MicrosoftGame.Config`, layout and PE files → startup locations, import inventory, dependency paths | `tools/intake_exe.py`, `tools/pe_inventory.py`, `tools/dependency_paths.py`, `tools/verify_build.py`, `tools/resource_inventory.py` | `static_exe_intake`, `conditional_import_paths`, `layout_chunk_summary` | | CPU: static translation | PE export and unwind ranges → per-shape lowering → C++ → MSVC DLL → differential check against the original | `tools/cpu_leaf_aot.py`, `tools/cpu_call_aot.py`, `tools/cpu_chained_aot.py`, `tools/cpu_ranges.py`; the shared integer lowerer `lower()` in `tools/ffx_version_query.py`, reused by `tools/bink_heap_aot.py` and the `tools/ffx_*.py` profiles | `cpu_aot_*` | | CPU: native mapping | PE file → private image with DIR64 relocations, imports bound by a host resolver, section protections, `.pdata`, DLL TLS callbacks and entry point → callable exports | `tools/pe_map.cpp` | `cpu_native_map`, `cpu_native_seh`, `cpu_native_tls` | | Windows runtime | Xbox API call → desktop behaviour | `src/era_heap.*`, plus per-experiment providers in `tests/` (for example `tests/cpu/bink_heap_provider.cpp`) | `era_heap_*`, `desktop_memory_query`, `cpu_aot_bink_heap` | | Shaders | archive record → gfx1013 disassembly (LLVM) → HLSL → DXC → D3D12 readback | `tools/pixel_aot.py`; `tools/ffx_dispatch_aot.py` (a second opcode table over the same disassembler); hand-written HLSL for BVH/DXR in `tests/` | `pixel_aot_*`, `ffx_*`, `bvh_*` | | Textures and assets | archive ranges → BC7 untile, mip tail, BCPack lane probes, script-state replay | `tools/bc7_tiles.py`, `tools/paged_resource.py`, `tools/bcpack_probe.py`, `tools/script_*` | `bcpack_prefix_and_mip_tail`, `bc7_draw_*`, `script_*` | | Desktop GPU coverage | packaged `offscreen_check` → adapter or WARP → Markdown report | `tests/offscreen_check.cpp`, `tools/gpu-check/`, `tools/package-gpu-check.ps1` | `*_warp`, `*_hardware`, the hardware thread (#1) | `src/` currently holds only `era_heap.*` and `rgb9e5.hlsli`. Most runtime behaviour lives in test-side providers and hosts. ### Boundaries that are weak or duplicated - **The two CPU paths bind imports differently.** Static translation links a provider import library at build time (`CMakeLists.txt`, the `cpu_translation` targets). Native mapping binds through a resolver supplied by the host (`tools/pe_map.cpp`). - **Intake and the mapper see different bytes.** `tools/cpu_ranges.py` reads `min(VirtualSize, SizeOfRawData)`, while `pe_map` maps `VirtualSize` and zero-fills the rest. Data past the raw size exists in a mapped image but is invisible to intake and to the translators. - **Delay imports:** intake records them (`tools/pe_inventory.py`); `pe_map` rejects them. - **Heap behaviour:** `src/era_heap.cpp` rejects any attribute bits outside 24–28, so it refuses the measured Bink word `0x05e50000`. `tests/cpu/bink_heap_provider.cpp` accepts only that word. Each experiment therefore has its own heap. - **The reusable lowerer is not separate.** It lives in a tool named after one package function (`tools/ffx_version_query.py`). - **Shared integration points:** `tests/offscreen_check.cpp` hosts triangle, compute, DXR, BVH, FidelityFX, pixel readback and BC7. Together with `CMakeLists.txt` and `docs/experiments.md`, it is where unrelated contributions collide. ## What each path refuses These refusals are the current edge of the CPU work. Each one is a candidate for a fixture. - **Static translators:** - one prologue shape (`tools/cpu_call_aot.py`); - loops, more than 256 instructions or more than 2048 steps (`tools/cpu_chained_aot.py`); - any external edge without a named binding (`lower()` in `tools/ffx_version_query.py`). - **`pe_map` refusals:** each returns a named error. - delay imports; - non-empty TLS data templates, because implicit TLS needs a slot in ntdll's per-thread array; - an entry point or TLS callback outside an executable section; - unreadable TLS directories and callback lists; - more than 256 TLS callbacks; - imports without a resolver. - **Not handled by `pe_map`:** - a non-DLL image gets no TLS callback or entry-point call, which is what `LoadLibrary` does too, so an EXE's own startup is never run; - export lookup does not yet check page readability. ## Imports and shims An Xbox image imports from system DLLs such as `kernelx`, `xmem` and `d3d12_xs`, which do not exist on a desktop. - **Measured edges:** the dependency baseline for 16 package DLLs on Windows build 26200 records 1,337 edges, of which 1,329 resolve. The eight unresolved edges are six distinct interfaces across `xmem.dll` and `d3d12_xs.dll` (`docs/experiments.md`, "PE dependency baseline"). - **Host dependence (inference):** resolution goes through the host's API-set schema (`tools/pe_inventory.py`), so the counts may change on another Windows build. This is an inference from the code and has not been measured. - **Device calls:** they go through vtable slots, not imports, so an import table never sees them (`tools/ffx_device_init.py`). - **Hash pinning:** the FidelityFX branch data is pinned to one loader hash (`tools/dependency_paths.py`). With another loader the tool reports no conditional edges and still exits 0. The translation tool (`tools/ffx_version_query.py`) raises on a hash mismatch instead. There is no shared shim library and no shared contract for a shimmed call: structure sizes, error codes, allocation ownership and attribute words. Each experiment binds the few calls it needs. ## GPU path - **Three separate pipelines:** - `pixel_aot.py` for one straight-line pixel subset; - `ffx_dispatch_aot.py` for four pinned compute programs; - hand-written HLSL for BVH, DXR and root signatures. - **Assumptions supplied by the harness:** - the caller passes the texture and interpolation SGPRs and the sampler words (`docs/experiments.md`, "Offline pixel shader recompilation"); - the FidelityFX replay covers an 8×4 tile, and its full-wave LDS path is not translated (`tools/ffx_dispatch_aot.py`). - **Desktop results only:** for the Xbox BVH programs, the desktop validator reports an unrecognized `dxil-ms-xb2` target (`docs/experiments.md`). Clearing root-flag bits makes root-signature serialization succeed but does not address those programs. The BVH and wave64 rows in the README are desktop results. ## Evidence model and CI - **CI coverage:** Windows CI runs CTest without the `_hardware` tests; it also smoke-tests the GPU check package on WARP. An Ubuntu job assembles and translates gfx1013 fixtures with LLVM 15, and a Linux job runs the platform-independent Python checks (`.github/workflows/windows.yml`). - **Package inputs:** `FFX_UPSCALER_IMAGE` and `BINK_HEAP_IMAGE` are local-only. CI builds the source-built controls under the same test names. - **Python requirement:** the Python-driven tests, including every `cpu_*` PE test, are registered only if `out/pe-env/Scripts/python.exe` exists at configure time (`CMakeLists.txt`, `if(EXISTS "${INTAKE_PYTHON}")`). The README and CONTRIBUTING document this requirement. Configure still gives no warning, and the three smoke tests pass without these tests. - **Negative controls:** a new behaviour needs a control that fails without it. Examples are an altered provider, a damaged copy, a mutated input or a swapped descriptor. GPU tests report passes, failures and capability skips (exit code 77) separately. ## Adding an experiment 1. State the question and the completion condition in an issue. 2. Build the smallest fixture that shows the behaviour: MASM in `tests/cpu/` for machine-code shapes, C++ or HLSL elsewhere. 3. Compare it with an independent reference: the Windows loader, a native caller, a CPU reference or DXR. 4. Add a negative control, register both in `CMakeLists.txt`, and record the measurement in `docs/experiments.md`. 5. Do not add a new lowerer or opcode table. Extend the existing one, or open an issue to split it out first. ## Proposal for discussion: the CPU trunk **Current direction.** The README and the maintainer's comment on #46 set static recompilation as the main direction, with the native run as an independent reference for checking translated calls and shims. **Proposal.** This review recommends a different weighting. Make native mapping plus a shared shim layer the trunk that is expected to reach a title's startup. Keep static translation for differential evidence and for functions that must be patched or instrumented. The facts behind it: - Scarlett user code is already x64, and `pe_map` runs the original instructions. It already reproduces DIR64 relocations, ordinary imports and `.pdata`. For DLLs it also reproduces TLS callbacks and the entry point, compared with the Windows loader in `cpu_native_tls`. It raises and catches an exception inside a mapped image (`cpu_native_seh`). - Each static translator stops at the first function outside its shape: a loop, a second call, an indirect branch or another prologue (see [What each path refuses](#what-each-path-refuses)). Each package slice depends on hand bindings and a pinned hash that public CI does not build. - A testable claim: none of the steps below needs a new translator. Each needs a loader or shim feature that the mapper path lacks today. Steps 1, 2 and 5 are useful under either direction. The choice belongs to the maintainers. ### First steps, using source-built fixtures only 1. **Harden `pe_map`.** Add a readability check to export lookup. Reject a double release or a pointer that `pe_map_image` did not return. Write down a lifecycle contract for callbacks that map or release images. 2. **One XMem shim.** A source-built `xmem` provider exporting `XMemAlloc`/`XMemFree` that accepts the measured attribute words, used by both `era_heap_check` and the Bink heap fixture. 3. **Delay imports in `pe_map`.** A new source-built DLL with one `/DELAYLOAD` import. The delayed call is bound and compared with `LoadLibrary`. The existing `intake_candidate.exe` cannot serve: it is an EXE and has TLS data, both of which `pe_map` does not run. 4. **A process-startup fixture.** A source-built EXE and two DLLs with static initialization, a TLS value read on two threads and an entry marker. Compare the initialization log and exit code with a normal Windows launch. This is the first test where "starts" means more than "a DLL export returns". 5. **Configure check.** Warn or fail at configure time when the Python environment is missing, so `cpu_*` tests cannot disappear unnoticed. ## Known inconsistencies - **README:** the summary row says five Radeon GPUs passed forced wave64, but the hardware table lists nine Radeon rows that passed, plus an RX 6600 LE that skipped. - **CONTRIBUTING:** `src/` is described as the Windows runtime, but most runtime behaviour lives in test-side providers. - **`STATUS` in `tests/cpu/native_map_check.py`:** it names only the `MapStatus` values that test uses, not the full enum in `tools/pe_map.cpp`. - **Package profiles:** `tools/cpu_chained_aot.py` and `tools/ffx_version_query.py` copy from guest addresses supplied by the profile without a host-side bounds check.
sof9816 commented 2026-11-24 06:47:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by sof9816 on 2026-11-21T16:57:34Z.


@R0Y00 @Leyukaka Is anyone already working on a source-built test where a mapped DLL triggers an offscreen draw? I saw the proposed EXE process-startup fixture here and the existing TLS work in #78 and #139.

The smaller test I have in mind would use the existing process-attach path, call a frame export, bind one graphics import to the existing offscreen renderer, and check a translated shader's pixel readback on an RTX 3060 Ti and WARP. With that import withheld, mapping should fail before a draw. All inputs would be source-built.

Would you prefer this as a small follow-up fixture, or would it overlap with the process-startup work? If someone has a branch underway, I can help verify it on Windows.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066097016 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7066097016). Originally posted by [sof9816](https://github.com/sof9816) on 2026-11-21T16:57:34Z. --- @R0Y00 @Leyukaka Is anyone already working on a source-built test where a mapped DLL triggers an offscreen draw? I saw the proposed EXE process-startup fixture here and the existing TLS work in #78 and #139. The smaller test I have in mind would use the existing process-attach path, call a frame export, bind one graphics import to the existing offscreen renderer, and check a translated shader's pixel readback on an RTX 3060 Ti and WARP. With that import withheld, mapping should fail before a draw. All inputs would be source-built. Would you prefer this as a small follow-up fixture, or would it overlap with the process-startup work? If someone has a branch underway, I can help verify it on Windows.
Leyukaka commented 2026-11-24 06:47:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T17:05:59Z.


I'm not working on that, and I don't think it overlaps with the process-startup fixture. That fixture is about EXE startup order, static initialization and TLS data across two threads; yours is about a mapped DLL reaching the renderer through one bound graphics import. Yours also covers the "first graphics integration" step that one of the reviews behind this proposal ranked third. The withheld-import control is a useful negative case.

On my side, the next pe_map change is a hardening PR (readability checks in export lookup, and pe_map_release returning 0 for unknown or already released pointers). It is stacked on #139 and touches pe_map_export and pe_map_release. If your fixture calls an export of the mapped DLL, it should work with either version.

Whether it should land before the process-startup work is the maintainer's call.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066209457 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7066209457). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T17:05:59Z. --- I'm not working on that, and I don't think it overlaps with the process-startup fixture. That fixture is about EXE startup order, static initialization and TLS data across two threads; yours is about a mapped DLL reaching the renderer through one bound graphics import. Yours also covers the "first graphics integration" step that one of the reviews behind this proposal ranked third. The withheld-import control is a useful negative case. On my side, the next `pe_map` change is a hardening PR (readability checks in export lookup, and `pe_map_release` returning 0 for unknown or already released pointers). It is stacked on #139 and touches `pe_map_export` and `pe_map_release`. If your fixture calls an export of the mapped DLL, it should work with either version. Whether it should land before the process-startup work is the maintainer's call. _AI-assisted._
R0Y00 commented 2026-11-24 06:47:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:17:01Z.


The source-built mapped-DLL draw is a good independent integration task. Please use a normal Windows load as the reference and compare the same exported draw and readback under pe_map. Track EXE startup separately; static recompilation remains the project objective.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066357037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7066357037). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T17:17:01Z. --- The source-built mapped-DLL draw is a good independent integration task. Please use a normal Windows load as the reference and compare the same exported draw and readback under pe_map. Track EXE startup separately; static recompilation remains the project objective.
sof9816 commented 2026-11-24 06:47:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by sof9816 on 2026-11-21T17:31:01Z.


@Leyukaka Is anyone already implementing the separate source-built EXE startup fixture in step 4? I found the proposal but no branch for it. If there is a branch or PR, I'd like to build it on Windows 11 and compare DLL initialization, TLS on the main and worker threads, and the process exit code with a normal Windows launch. I'll keep this separate from the mapped-DLL draw PR.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066540125 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7066540125). Originally posted by [sof9816](https://github.com/sof9816) on 2026-11-21T17:31:01Z. --- @Leyukaka Is anyone already implementing the separate source-built EXE startup fixture in step 4? I found the proposal but no branch for it. If there is a branch or PR, I'd like to build it on Windows 11 and compare DLL initialization, TLS on the main and worker threads, and the process exit code with a normal Windows launch. I'll keep this separate from the mapped-DLL draw PR.
Leyukaka commented 2026-11-24 06:47:44 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T18:01:14Z.


No one is working on it on my side, and there is no branch, so it's yours if you want it. As the maintainer asked above, keeping it separate from the mapped-DLL draw makes sense.

One thing that may help: #139 changes cpu_tls_sink to record the calling thread for each call, so notifications can be filtered per thread. That would make the main-thread versus worker-thread TLS comparison straightforward. It also adds a one-shot hook armed for a single thread. The sink_record signature is unchanged.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066940256 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7066940256). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T18:01:14Z. --- No one is working on it on my side, and there is no branch, so it's yours if you want it. As the maintainer asked above, keeping it separate from the mapped-DLL draw makes sense. One thing that may help: #139 changes `cpu_tls_sink` to record the calling thread for each call, so notifications can be filtered per thread. That would make the main-thread versus worker-thread TLS comparison straightforward. It also adds a one-shot hook armed for a single thread. The `sink_record` signature is unchanged. _AI-assisted._
Leyukaka commented 2026-11-24 06:47:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T18:07:29Z.


A short status note following up on this proposal. The counts are measured on ccfa703. The percentages are my own rough estimates of how far each area is from "a title starts on Windows", not measurements, so please correct anything you see differently.

Repository at ccfa703: 307 commits from 25 authors (counted by name), 110 merged PRs, 25 open PRs and 15 open issues. Locally, 103 CTest tests pass on Windows 11 build 26300; the two wave64 tests are skipped on this adapter.

Area Rough estimate Covered by tests today Main gaps
Native image mapping (pe_map) ~60% relocations, ordinary and delay imports, sections, SEH, TLS callbacks and entry point; thread notifications in #139 implicit TLS data, EXE startup, CRT initialization, API sets at run time
Static CPU recompilation ~5–10% leaf, call, chained-range and jump-table shapes, version-2 unwind, several package slices whole-module coverage, indirect calls at scale, full flag and SSE/AVX semantics
Xbox API shims ~2–3% ERA/XMem allocation and XMemVirtualQuery, a few D3D12 device calls the eight unresolved edges (six xmem.dll/d3d12_xs.dll interfaces), the behaviour behind the 1,329 edges that resolve on the desktop, COM and vtable interfaces
Shaders ~10% a gfx1013 pixel subset (ALU, comparisons, two textures) and some FSR4 compute passes branches, other stages, Xbox DXIL intrinsics
D3D12 command translation ~1–2% individual heap, resource and view calls command lists
Assets (archives, BC7/BCPack, scripts) ~15% BC7 and mip tails, BCPack prefixes, script state and paths full BCPack decoding, run-time loading
Title executable 0% — absent from the inspected files

Mapping is the smaller of these problems, so its higher number says little about the whole. Overall, the project is roughly 3–5% of the way to a title starting. Static recompilation remains the objective, and the mapper serves as the reference that translated calls and shims are checked against.

From this proposal's step list:

  • Step 1, hardening pe_map (#163, #164): ready locally. It waits for #139 to merge.
  • Step 2, XMem: partly covered by #134. era_heap now accepts the measured words; a shared XMem provider for mapped images is still open.
  • Step 3, delay imports: covered by #127.
  • Step 4, process startup: tracked in #165. sof9816 has expressed interest; it stays separate from #154.
  • Step 5, missing-Python warning: covered by #148.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067019407 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7067019407). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T18:07:29Z. --- A short status note following up on this proposal. The counts are measured on `ccfa703`. The percentages are my own rough estimates of how far each area is from "a title starts on Windows", not measurements, so please correct anything you see differently. **Repository at `ccfa703`:** 307 commits from 25 authors (counted by name), 110 merged PRs, 25 open PRs and 15 open issues. Locally, 103 CTest tests pass on Windows 11 build 26300; the two wave64 tests are skipped on this adapter. | Area | Rough estimate | Covered by tests today | Main gaps | |---|---|---|---| | Native image mapping (`pe_map`) | ~60% | relocations, ordinary and delay imports, sections, SEH, TLS callbacks and entry point; thread notifications in #139 | implicit TLS data, EXE startup, CRT initialization, API sets at run time | | Static CPU recompilation | ~5–10% | leaf, call, chained-range and jump-table shapes, version-2 unwind, several package slices | whole-module coverage, indirect calls at scale, full flag and SSE/AVX semantics | | Xbox API shims | ~2–3% | ERA/XMem allocation and `XMemVirtualQuery`, a few D3D12 device calls | the eight unresolved edges (six `xmem.dll`/`d3d12_xs.dll` interfaces), the behaviour behind the 1,329 edges that resolve on the desktop, COM and vtable interfaces | | Shaders | ~10% | a gfx1013 pixel subset (ALU, comparisons, two textures) and some FSR4 compute passes | branches, other stages, Xbox DXIL intrinsics | | D3D12 command translation | ~1–2% | individual heap, resource and view calls | command lists | | Assets (archives, BC7/BCPack, scripts) | ~15% | BC7 and mip tails, BCPack prefixes, script state and paths | full BCPack decoding, run-time loading | | Title executable | 0% | — | absent from the inspected files | Mapping is the smaller of these problems, so its higher number says little about the whole. Overall, the project is roughly 3–5% of the way to a title starting. Static recompilation remains the objective, and the mapper serves as the reference that translated calls and shims are checked against. From this proposal's step list: - **Step 1, hardening `pe_map`** (#163, #164): ready locally. It waits for #139 to merge. - **Step 2, XMem:** partly covered by #134. `era_heap` now accepts the measured words; a shared XMem provider for mapped images is still open. - **Step 3, delay imports:** covered by #127. - **Step 4, process startup:** tracked in #165. sof9816 has expressed interest; it stays separate from #154. - **Step 5, missing-Python warning:** covered by #148. _AI-assisted._
R0Y00 commented 2026-11-24 06:47:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:12:06Z.


Step 2 has a proposed shared provider in #183. Lead decision requested before exposing its four named exports: should the desktop provider register graphics allocations as GPU-intended and guarantee that the working-set query returns FALSE, sets ERROR_NOT_SUPPORTED and leaves the buffer untouched? The PR distinguishes these desktop policies from the caller observations. #189/#188 separately reuse the allocator in the existing Bink fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067077062 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7067077062). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:12:06Z. --- Step 2 has a proposed shared provider in #183. Lead decision requested before exposing its four named exports: should the desktop provider register graphics allocations as GPU-intended and guarantee that the working-set query returns FALSE, sets ERROR_NOT_SUPPORTED and leaves the buffer untouched? The PR distinguishes these desktop policies from the caller observations. #189/#188 separately reuse the allocator in the existing Bink fixture.
R0Y00 commented 2026-11-24 06:47:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:26:26Z.


Lead decision for #183. Adopt the following contract for the shared x64 Windows provider.

  • XMemAlloc accepts the size and attribute word and uses the shared ERA allocation implementation. Record a successful graphics-type allocation as GPU-intended for desktop query classification. Registration follows the allocation lifetime. This flag alone provides no D3D12 residency or GPU-access guarantee.
  • XMemFree takes the original base and matching attributes, removes any graphics registration on release, and accepts null as a no-op.
  • XMemVirtualQuery takes process, address and a 64-byte output buffer and returns a 32-bit success flag. Preserve the tested desktop query fields and the untouched-output failure case.
  • XMemGetWorkingSetStatistics returns FALSE, sets ERROR_NOT_SUPPORTED, and leaves the output untouched. The translated caller takes its existing failure branch. Selector units and console accounting remain open in #126 and related research.

These are Windows adapter policies. Please review #183 against the four export tests and the normal required CI; the interface decision is settled. Static recompilation remains the CPU objective.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067256125 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7067256125). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:26:26Z. --- Lead decision for #183. Adopt the following contract for the shared x64 Windows provider. - XMemAlloc accepts the size and attribute word and uses the shared ERA allocation implementation. Record a successful graphics-type allocation as GPU-intended for desktop query classification. Registration follows the allocation lifetime. This flag alone provides no D3D12 residency or GPU-access guarantee. - XMemFree takes the original base and matching attributes, removes any graphics registration on release, and accepts null as a no-op. - XMemVirtualQuery takes process, address and a 64-byte output buffer and returns a 32-bit success flag. Preserve the tested desktop query fields and the untouched-output failure case. - XMemGetWorkingSetStatistics returns FALSE, sets ERROR_NOT_SUPPORTED, and leaves the output untouched. The translated caller takes its existing failure branch. Selector units and console accounting remain open in #126 and related research. These are Windows adapter policies. Please review #183 against the four export tests and the normal required CI; the interface decision is settled. Static recompilation remains the CPU objective.
R0Y00 commented 2026-11-24 06:48:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T03:24:40Z.


For the next development cycle we will allocate maintainer-led development and review time as follows.

Area Share Current work
CPU/GPU end-to-end integration 30% Carry the verified shadow scene from #773 into the native, mapped and AOT EXE comparison under #730. Coordinate with the contributor already developing it.
Xbox runtime and D3D12 compatibility 30% Verify observable initialization, error propagation and resource lifetime. #787 covers release after compute setup fails.
GPU virtual addresses, descriptors and shader bindings 20% Prioritize a concrete producer/consumer pair with distinct bindings, expected readback and a swapped or stale binding control.
CPU AOT across functions 15% Review the two-import implementation in #785 against #767, including the native call trace and return-width checks.
Other instruction forms, tooling and documentation 5% Continue reviewing independent contributions. Work that directly unblocks an integration case follows that case's priority.

These are approximate shares of maintainer effort across the cycle. Count a change once under its main deliverable. Contributors can continue existing claims. Please link the consuming fixture or measured blocker when claiming new work. We will revisit the mix when the next integration run identifies its first blocker.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7090720540 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7090720540). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T03:24:40Z. --- For the next development cycle we will allocate maintainer-led development and review time as follows. | Area | Share | Current work | |---|---:|---| | CPU/GPU end-to-end integration | 30% | Carry the verified shadow scene from #773 into the native, mapped and AOT EXE comparison under #730. Coordinate with the contributor already developing it. | | Xbox runtime and D3D12 compatibility | 30% | Verify observable initialization, error propagation and resource lifetime. #787 covers release after compute setup fails. | | GPU virtual addresses, descriptors and shader bindings | 20% | Prioritize a concrete producer/consumer pair with distinct bindings, expected readback and a swapped or stale binding control. | | CPU AOT across functions | 15% | Review the two-import implementation in #785 against #767, including the native call trace and return-width checks. | | Other instruction forms, tooling and documentation | 5% | Continue reviewing independent contributions. Work that directly unblocks an integration case follows that case's priority. | These are approximate shares of maintainer effort across the cycle. Count a change once under its main deliverable. Contributors can continue existing claims. Please link the consuming fixture or measured blocker when claiming new work. We will revisit the mix when the next integration run identifies its first blocker.
Leyukaka commented 2026-11-29 00:48:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T00:48:15Z.


The five first steps are done: export and release checks in pe_map (#163, #164), the shared XMem provider (#183), delay imports (#127), the process-startup fixture (#165), the missing-Python warning (#148). The CPU trunk proposal was not adopted (11-21: static recompilation remains the objective), and the 11-23 allocation sets the current priorities. Closing.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7248361742 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/132#issuecomment-7248361742). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T00:48:15Z. --- The five first steps are done: export and release checks in `pe_map` (#163, #164), the shared XMem provider (#183), delay imports (#127), the process-startup fixture (#165), the missing-Python warning (#148). The CPU trunk proposal was not adopted (11-21: static recompilation remains the objective), and the 11-23 allocation sets the current priorities. Closing.
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#131
No description provided.