feat(tools): add a shader scan that counts DXBC containers and their parts #15

Manually merged
github merged 2 commits from gh-pr/15/head into gh-pr/15/base 2026-11-26 19:14:05 +00:00
Owner

@⁠Callimann8 on GitHub · 2026-11-21 12:19 UTC · original
Callimann8:claude/project-thread-myl17b → main · +179 −0 · 3 files · 2 commits · merged 2026-11-21 12:32 UTC

What

Adds tools/shader_scan.py, a read-only scan that finds every DXBC container in a package (loose .cso files or embedded in other files) and reports counts by kind (dxil, dxbc, mixed, rootsig, other) and by part tag. Part tags that are not standard DXBC parts point at console-specific data.

The goal is to answer the shader question in #4 with data from titles people own: do console packages keep DXIL next to the native code, or only console-specific parts? --json writes names, offsets and part tags only, never shader bytes. Shaders inside compressed archives are not found; this is noted in the docs.

Documented in a new "Shader formats" section of docs/dev/GAME_TESTING.md.

Tested

Linux, Python 3: new tools/tests/test_shader_scan.py (synthetic containers: kind classification, embedded containers next to false DXBC magic, truncated container rejected, folder summary). All tools/tests pass, python tools/check_conventions.py passes. Not run on a real title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment (n/a, tools only)
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md (none changed)
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none (supports the #4 design discussion)
  • Unblocks: none
  • Source of behaviour: DXBC container layout as documented in public DirectX shader tooling (DirectXShaderCompiler DxilContainer.h)
  • AI-assisted: yes
**@⁠Callimann8** on GitHub · 2026-11-21 12:19 UTC · [original](https://github.com/Dark3581/AnyBox/pull/15) `Callimann8:claude/project-thread-myl17b` → `main` · +179 −0 · 3 files · 2 commits · merged 2026-11-21 12:32 UTC ### What Adds `tools/shader_scan.py`, a read-only scan that finds every DXBC container in a package (loose `.cso` files or embedded in other files) and reports counts by kind (`dxil`, `dxbc`, `mixed`, `rootsig`, `other`) and by part tag. Part tags that are not standard DXBC parts point at console-specific data. The goal is to answer the shader question in #4 with data from titles people own: do console packages keep DXIL next to the native code, or only console-specific parts? `--json` writes names, offsets and part tags only, never shader bytes. Shaders inside compressed archives are not found; this is noted in the docs. Documented in a new "Shader formats" section of `docs/dev/GAME_TESTING.md`. ### Tested Linux, Python 3: new `tools/tests/test_shader_scan.py` (synthetic containers: kind classification, embedded containers next to false `DXBC` magic, truncated container rejected, folder summary). All `tools/tests` pass, `python tools/check_conventions.py` passes. Not run on a real title. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment (n/a, tools only) - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` (none changed) - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none (supports the #4 design discussion) - [x] Unblocks: none - [x] Source of behaviour: DXBC container layout as documented in public DirectX shader tooling (DirectXShaderCompiler `DxilContainer.h`) - [x] AI-assisted: yes
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:04 +00:00
github manually merged commit acdc48371c into gh-pr/15/base 2026-11-26 19:14:05 +00:00
Author
Owner

@⁠Callimann8 on GitHub · 2026-11-21 12:19 UTC · original

Some input on the approach, from reading the code and public sources only (no GXDK material).

1. Target the desktop D3D12 interfaces, not Vulkan directly.
AnyBox runs titles on the Windows loader, so desktop d3d12.dll is always there. D3D12.X is a D3D12 dialect: heaps, descriptors, root signatures, command lists and fences are the same model, so most methods should map close to 1:1 and the D3D12 debug layer can validate the result. Going to Vulkan does not need its own layer: on Linux, vkd3d-proton already turns desktop D3D12 into Vulkan, so a D3D12.X to D3D12 layer gets Vulkan for free under Wine/Proton. A direct Vulkan backend only pays off if some console feature can be expressed in Vulkan but not in D3D12, and I don't know of one that would justify a second translation stack.

2. Shaders decide the size of the project, whichever API is chosen.
Console shaders are compiled offline for one fixed GPU. If packages keep DXIL next to the console-specific data, the layer can hand the DXIL to desktop D3D12 and the shader path is small. If they hold only native GPU code, AnyBox needs an ISA to DXIL (or SPIR-V) recompiler, like the ones console emulators write (Xenia for Xbox 360 microcode, shadPS4 for GCN). That is a different scale of project. A PR adds tools/shader_scan.py, which counts the DXBC containers in a package and their part tags (names and offsets only), so owners can post a summary line here and settle this with data.

3. Interface layouts have to come from titles.
The console D3D12 headers ship only in the licensed GXDK and can't be used. Unlike exports, vtable calls don't show up in import audits or on the needs page. A first code step that fits "implement or stop": D3D12XboxCreateDevice returns a device whose every vtable slot calls AbxNotImplemented with the interface and slot index in the run report. Each run then names the next method a title needs, and tools/ghidra/ImportCallArgs.java (or a vtable variant of it) shows the arguments at the call sites.

4. Small pieces that can go in early.
The four root signature serialize/deserialize exports take only public desktop structs and could be forwarded to the host d3d12.dll, with a debt note that the blob format was not checked against a console. They matter only once a device exists.

Suggested order: shader data from a few titles, then the reporting stub device, then methods one by one in the order titles hit them.

**@⁠Callimann8** on GitHub · 2026-11-21 12:19 UTC · [original](https://github.com/Dark3581/AnyBox/pull/15#issuecomment-7062486660) Some input on the approach, from reading the code and public sources only (no GXDK material). **1. Target the desktop D3D12 interfaces, not Vulkan directly.** AnyBox runs titles on the Windows loader, so desktop `d3d12.dll` is always there. D3D12.X is a D3D12 dialect: heaps, descriptors, root signatures, command lists and fences are the same model, so most methods should map close to 1:1 and the D3D12 debug layer can validate the result. Going to Vulkan does not need its own layer: on Linux, vkd3d-proton already turns desktop D3D12 into Vulkan, so a D3D12.X to D3D12 layer gets Vulkan for free under Wine/Proton. A direct Vulkan backend only pays off if some console feature can be expressed in Vulkan but not in D3D12, and I don't know of one that would justify a second translation stack. **2. Shaders decide the size of the project, whichever API is chosen.** Console shaders are compiled offline for one fixed GPU. If packages keep DXIL next to the console-specific data, the layer can hand the DXIL to desktop D3D12 and the shader path is small. If they hold only native GPU code, AnyBox needs an ISA to DXIL (or SPIR-V) recompiler, like the ones console emulators write (Xenia for Xbox 360 microcode, shadPS4 for GCN). That is a different scale of project. A PR adds `tools/shader_scan.py`, which counts the DXBC containers in a package and their part tags (names and offsets only), so owners can post a summary line here and settle this with data. **3. Interface layouts have to come from titles.** The console D3D12 headers ship only in the licensed GXDK and can't be used. Unlike exports, vtable calls don't show up in import audits or on the needs page. A first code step that fits "implement or stop": `D3D12XboxCreateDevice` returns a device whose every vtable slot calls `AbxNotImplemented` with the interface and slot index in the run report. Each run then names the next method a title needs, and `tools/ghidra/ImportCallArgs.java` (or a vtable variant of it) shows the arguments at the call sites. **4. Small pieces that can go in early.** The four root signature serialize/deserialize exports take only public desktop structs and could be forwarded to the host `d3d12.dll`, with a debt note that the blob format was not checked against a console. They matter only once a device exists. Suggested order: shader data from a few titles, then the reporting stub device, then methods one by one in the order titles hit them.
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-21 12:32 UTC · original · approved these changes

Reviewed — looks good

Merging as it is. The container check is strict enough that it found no false positives on real binaries, and it gives #4 a way to get data.

What I ran

Head acdc483, merged locally onto current main (ddd30ef, after #14, #12 and #13; no conflicts). Python 3.13 on Windows 10. Tools-only change, so no library build.

Results

Check Result Note
Tool tests passed 39/39, including the 5 new ones
tools/check_conventions.py passed
Real binaries passed scanned four Windows system DLLs that embed compiled shaders: 501 containers in dwmcore.dll and d2d1.dll (495 dxbc, 6 other), none in the two others. Every container ended inside its file and had a valid part table
Edge inputs passed empty file, a 4-byte file holding only DXBC, and a missing path: the first two report nothing, the missing path prints an error and the scan goes on
CI passed Windows, relinker on Linux and macOS, conventions

Findings

Blocking

None.

Non-blocking

  • tools/shader_scan.py:96: the JSON keys are each path exactly as given on the command line, so an absolute path (C:\Users\<name>\...) puts the contributor's folder and user name into a file the docs suggest sharing. Making the keys relative to the scanned folder would keep them to package names only.
  • tools/shader_scan.py:35: the 6 other containers above hold only LIBF/LIBH parts, which are D3D11 function-linking libraries and a standard part, not console data. other is also the bucket the docs say points at console-specific data, so a title with shader libraries would read as console-specific. A library kind, or a list of the standard part tags with unknown ones reported separately, would make the summary answer #4 directly.

Not verified

A real console package, as you noted.

Thanks, a small, focused tool that's easy to run.

**@⁠Dark3581** on GitHub · 2026-11-21 12:32 UTC · [original](https://github.com/Dark3581/AnyBox/pull/15#pullrequestreview-6005202322) · **approved these changes** # Reviewed — looks good Merging as it is. The container check is strict enough that it found no false positives on real binaries, and it gives #4 a way to get data. ## What I ran Head `acdc483`, merged locally onto current `main` (`ddd30ef`, after #14, #12 and #13; no conflicts). Python 3.13 on Windows 10. Tools-only change, so no library build. ## Results | Check | Result | Note | | - | - | - | | Tool tests | passed | 39/39, including the 5 new ones | | `tools/check_conventions.py` | passed | | | Real binaries | passed | scanned four Windows system DLLs that embed compiled shaders: 501 containers in `dwmcore.dll` and `d2d1.dll` (495 `dxbc`, 6 `other`), none in the two others. Every container ended inside its file and had a valid part table | | Edge inputs | passed | empty file, a 4-byte file holding only `DXBC`, and a missing path: the first two report nothing, the missing path prints an error and the scan goes on | | CI | passed | Windows, relinker on Linux and macOS, conventions | ## Findings ### Blocking None. ### Non-blocking - `tools/shader_scan.py:96`: the JSON keys are each path exactly as given on the command line, so an absolute path (`C:\Users\<name>\...`) puts the contributor's folder and user name into a file the docs suggest sharing. Making the keys relative to the scanned folder would keep them to package names only. - `tools/shader_scan.py:35`: the 6 `other` containers above hold only `LIBF`/`LIBH` parts, which are D3D11 function-linking libraries and a standard part, not console data. `other` is also the bucket the docs say points at console-specific data, so a title with shader libraries would read as console-specific. A `library` kind, or a list of the standard part tags with unknown ones reported separately, would make the summary answer #4 directly. ## Not verified A real console package, as you noted. Thanks, a small, focused tool that's easy to run.
This discussion has been locked. Commenting is limited to contributors.
No description provided.