runtime: main builds with MSVC again (console descriptor heap of #9577, acphal context sizes of #9515) #82

Closed
github-bot wants to merge 2 commits from gh-pr/82/head into gh-pr/82/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:14 UTC · original
ubiquitarianism:old-pr/9809 → main · +91 −18 · 6 files · 2 commits · closed without merging

Carried over from old PR 9809 by dhillonjagga in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9809, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
dhillonjagga: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: not claimed. GitHub refused my comment on #9677 ("You can't perform that action at this time"). New item, not in the tables; I found no open PR for either break.

Depends on: none. It follows up #9577 and #9515, both merged.

What and why

main does not compile with MSVC since the merge round that brought #9577 and #9515 (checked at f48adad76; the same lines are on 2d53a8055). One commit per cause.

1. runtime/shims/acphal.cpp (#9515)

acphal.cpp(146): error C2338: static assertion failed: 'SHAPE_XMA_CONTEXT is 64 bytes per GDK'
acphal.cpp(167): error C2338: static assertion failed: 'SHAPE_PCM_CONTEXT is 32 bytes per GDK'

The bit-fields of SHAPE_XMA_CONTEXT fill five 32-bit words and those of SHAPE_PCM_CONTEXT six, so with reserved[10] and reserved[1] the structures were 60 and 28 bytes. The shim uses only their size (the stride of the context arrays it allocates), so the reserved tails now cover the rest. The field offsets are not checked against a console; the author of #9515 may know whether a field is missing instead.

2. Device slot 14's console descriptor heap (#9577)

d3d12_xs_device.cpp(1606): error C3083: 'd3d12': the symbol to the left of a '::' must be a type
d3d12_vulkan_device.cpp(9995): error C2665: 'DescriptorHeap::DescriptorHeap': cannot convert argument 1 from 'const DeviceState' to 'DeviceState &'
d3d12_vulkan_device.cpp(9996): error C2248: 'Device::identity': cannot access private member
d3d12_console_descriptor_heap_test.cpp(45): error C2819: 'Ref<ID3D12DescriptorHeap>' does not have an overloaded member 'operator ->'
d3d12_console_descriptor_heap_test.cpp(68): error C2660: 'create_device_proxy': function does not take 2 arguments
  • Compile. The proxy called rt::d3d12::create_console_descriptor_heap by name. d3d12_xs_device.cpp does not include d3d12_com.h, and it is built into programs without the Vulkan layer, where the name would not link either. Slot 14 now asks a handler, as slot 133 does (set_placed_at_va_handler). The heap is made by a Device member, which has the state and identity the free function could not reach.
  • Behaviour, and the part to decide. With that compiled in and the handler always registered, 21 of 294 runtime tests fail here, 9 with an access violation (d3d12_descriptor, d3d12_present, d3d12_draw, xbox_present, d3d12_f16_halves and others). The proxy takes the 16 bytes after the description as address and size whenever the first is not zero; a caller that passes the 16-byte PC description has unrelated bytes there, and the heap writes its descriptors to that address. So the layer registers the handler only with LEONIDA_CONSOLE_DESCRIPTOR_HEAP=1 (documented in docs/boot.md), which a retail boot would set for stop 13 of docs/retail_boot_chain.md; without it slot 14 creates the heap from the 16 PC bytes, as before #9577. If you would rather have it on by default with a rule that tells the two descriptions apart, or revert #9577, say so and I will change this.
  • The test. Ref gets operator->, create_device_proxy its three arguments and a device reference of its own, and the heap proxy's start is read from the heap behind it (slots 9 and 10 of a heap proxy return the handle in RAX, so a PC call reads a result buffer the proxy never writes). It now checks slot 14 with and without the handler.

Tested

NVIDIA GeForce RTX 3080 Ti, driver 617.42, Windows 11 (26300), no Resizable BAR; MSVC 14.51 (VS Build Tools 2026), Vulkan SDK 1.4.363; at f48adad76.

  • scripts\build_runtime.ps1: all 748 targets build. Before: it stops at the errors above.
  • ctest: 290 of 294 pass, among them d3d12_console_descriptor_heap, acphal, device_proxy, xs_proxy_mock* and queue_proxy. The four failures do not go through this code: d3d12_com (line 345, a Close() result), d3d12_vulkan_device, d3d12_depth_resolve, d3d12_indirect_rt.
  • python -I tests/test_acphal_abi.py: OK. python -I tests/test_docs_env_vars.py reports only LEONIDA_RNG_SEED (bcrypt_rng.cpp:80), which is not from this change.
  • Not tested: the clang-cl / Linux cross build, and a retail boot as far as slot 14 (on this main mine stops earlier, at DStorageGetFactory).

AI-assisted: yes (Claude Code, Claude Fable 5.2).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule here.)

🤖 Generated with Claude Code

**@⁠Andretuta** on GitHub · 2026-11-24 02:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/82) `ubiquitarianism:old-pr/9809` → `main` · +91 −18 · 6 files · 2 commits · closed without merging > Carried over from **old PR 9809** by `dhillonjagga` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9809`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > This branch conflicts with the current `main` and needs a rebase. > `dhillonjagga`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: not claimed. GitHub refused my comment on `#9677` ("You can't perform that action at this time"). New item, not in the tables; I found no open PR for either break. Depends on: none. It follows up `#9577` and `#9515`, both merged. ### What and why `main` does not compile with MSVC since the merge round that brought `#9577` and `#9515` (checked at f48adad76; the same lines are on 2d53a8055). One commit per cause. **1. `runtime/shims/acphal.cpp` (`#9515`)** ``` acphal.cpp(146): error C2338: static assertion failed: 'SHAPE_XMA_CONTEXT is 64 bytes per GDK' acphal.cpp(167): error C2338: static assertion failed: 'SHAPE_PCM_CONTEXT is 32 bytes per GDK' ``` The bit-fields of `SHAPE_XMA_CONTEXT` fill five 32-bit words and those of `SHAPE_PCM_CONTEXT` six, so with `reserved[10]` and `reserved[1]` the structures were 60 and 28 bytes. The shim uses only their size (the stride of the context arrays it allocates), so the reserved tails now cover the rest. The field offsets are not checked against a console; the author of `#9515` may know whether a field is missing instead. **2. Device slot 14's console descriptor heap (`#9577`)** ``` d3d12_xs_device.cpp(1606): error C3083: 'd3d12': the symbol to the left of a '::' must be a type d3d12_vulkan_device.cpp(9995): error C2665: 'DescriptorHeap::DescriptorHeap': cannot convert argument 1 from 'const DeviceState' to 'DeviceState &' d3d12_vulkan_device.cpp(9996): error C2248: 'Device::identity': cannot access private member d3d12_console_descriptor_heap_test.cpp(45): error C2819: 'Ref<ID3D12DescriptorHeap>' does not have an overloaded member 'operator ->' d3d12_console_descriptor_heap_test.cpp(68): error C2660: 'create_device_proxy': function does not take 2 arguments ``` - **Compile.** The proxy called `rt::d3d12::create_console_descriptor_heap` by name. `d3d12_xs_device.cpp` does not include `d3d12_com.h`, and it is built into programs without the Vulkan layer, where the name would not link either. Slot 14 now asks a handler, as slot 133 does (`set_placed_at_va_handler`). The heap is made by a `Device` member, which has the state and identity the free function could not reach. - **Behaviour, and the part to decide.** With that compiled in and the handler always registered, 21 of 294 runtime tests fail here, 9 with an access violation (`d3d12_descriptor`, `d3d12_present`, `d3d12_draw`, `xbox_present`, `d3d12_f16_halves` and others). The proxy takes the 16 bytes after the description as address and size whenever the first is not zero; a caller that passes the 16-byte PC description has unrelated bytes there, and the heap writes its descriptors to that address. So the layer registers the handler only with `LEONIDA_CONSOLE_DESCRIPTOR_HEAP=1` (documented in `docs/boot.md`), which a retail boot would set for stop 13 of `docs/retail_boot_chain.md`; without it slot 14 creates the heap from the 16 PC bytes, as before `#9577`. If you would rather have it on by default with a rule that tells the two descriptions apart, or revert `#9577`, say so and I will change this. - **The test.** `Ref` gets `operator->`, `create_device_proxy` its three arguments and a device reference of its own, and the heap proxy's start is read from the heap behind it (slots 9 and 10 of a heap proxy return the handle in RAX, so a PC call reads a result buffer the proxy never writes). It now checks slot 14 with and without the handler. ### Tested NVIDIA GeForce RTX 3080 Ti, driver 617.42, Windows 11 (26300), no Resizable BAR; MSVC 14.51 (VS Build Tools 2026), Vulkan SDK 1.4.363; at f48adad76. - `scripts\build_runtime.ps1`: all 748 targets build. Before: it stops at the errors above. - `ctest`: 290 of 294 pass, among them `d3d12_console_descriptor_heap`, `acphal`, `device_proxy`, `xs_proxy_mock*` and `queue_proxy`. The four failures do not go through this code: `d3d12_com` (line 345, a `Close()` result), `d3d12_vulkan_device`, `d3d12_depth_resolve`, `d3d12_indirect_rt`. - `python -I tests/test_acphal_abi.py`: OK. `python -I tests/test_docs_env_vars.py` reports only `LEONIDA_RNG_SEED` (`bcrypt_rng.cpp:80`), which is not from this change. - Not tested: the clang-cl / Linux cross build, and a retail boot as far as slot 14 (on this `main` mine stops earlier, at `DStorageGetFactory`). AI-assisted: yes (Claude Code, Claude Fable 5.2). ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule here.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since #9515 main does not compile with MSVC (14.51, at f48adad76):

  acphal.cpp(146): error C2338: static assertion failed: 'SHAPE_XMA_CONTEXT is 64 bytes per GDK'
  acphal.cpp(167): error C2338: static assertion failed: 'SHAPE_PCM_CONTEXT is 32 bytes per GDK'

The bit-fields of SHAPE_XMA_CONTEXT fill five 32-bit words and those of SHAPE_PCM_CONTEXT six, so with
reserved[10] and reserved[1] the structures were 60 and 28 bytes. The shim uses only their size, as the stride
of the context arrays it allocates, so the reserved tails now cover the rest: reserved[11] and reserved[2].
The field offsets are not checked against a console here.

Tested: MSVC 14.51, Windows 11: the file compiles; ctest acphal passes; python -I tests/test_acphal_abi.py OK.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Since #9577 main does not compile with MSVC (14.51, at f48adad76):

  d3d12_xs_device.cpp(1606): error C3083: 'd3d12': the symbol to the left of a '::' must be a type
  d3d12_vulkan_device.cpp(9995): error C2665: 'DescriptorHeap::DescriptorHeap': cannot convert argument 1
      from 'const DeviceState' to 'DeviceState &'
  d3d12_vulkan_device.cpp(9996): error C2248: 'Device::identity': cannot access private member
  d3d12_console_descriptor_heap_test.cpp(45): error C2819: 'Ref<ID3D12DescriptorHeap>' does not have an
      overloaded member 'operator ->'
  d3d12_console_descriptor_heap_test.cpp(68): error C2660: 'create_device_proxy': function does not take
      2 arguments

The proxy (d3d12_xs_device.cpp) called rt::d3d12::create_console_descriptor_heap by name. It does not include
d3d12_com.h, and it is built into programs without the Vulkan layer, where the name would not link either.
Slot 14 now asks a handler, as slot 133 does (set_placed_at_va_handler). The heap is made by a Device member,
which has the state and identity the free function could not reach.

With that compiled in and the handler always registered, 21 of 294 runtime tests fail on this machine, 9 of
them with an access violation (d3d12_descriptor, d3d12_present, d3d12_draw, xbox_present and others): the
proxy takes the 16 bytes after the description as address and size whenever the first is not zero, a caller
that passes the 16-byte PC description has unrelated bytes there, and the heap writes its descriptors to that
address. So the layer registers the handler only with LEONIDA_CONSOLE_DESCRIPTOR_HEAP=1 (docs/boot.md), which
is what a retail boot sets to pass stop 13 of docs/retail_boot_chain.md; without it slot 14 creates the heap
from the 16 PC bytes, as before #9577. A rule that tells the two descriptions apart would make the switch
unnecessary; none is measured here.

The test: Ref gets operator->, create_device_proxy its three arguments and a device reference of its own, and
the heap proxy's start is read from the heap behind it (slots 9 and 10 of a heap proxy return the handle in
RAX, so a PC call reads a result buffer the proxy never writes). It checks slot 14 with and without the handler.

Tested on an RTX 3080 Ti (driver 617.42, Windows 11, no Resizable BAR), MSVC 14.51, Vulkan SDK 1.4.363, at
f48adad76 with the acphal commit before this one: scripts\build_runtime.ps1 builds all 748 targets; ctest
290/294, d3d12_console_descriptor_heap among the passes. The four failures do not involve this code:
d3d12_com (line 345, a Close() result), d3d12_vulkan_device, d3d12_depth_resolve and d3d12_indirect_rt.
python -I tests/test_docs_env_vars.py reports only LEONIDA_RNG_SEED (bcrypt_rng.cpp:80), which is not from
this change. Not run: a retail boot up to slot 14 (on this main it stops
earlier, at DStorageGetFactory).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:43:36 +00:00
github-bot closed this pull request 2026-11-26 08:43:36 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:49 UTC · original

Thank you for this fix. The diagnosis was right, and current main already has it, so I'm closing this draft as superseded:

  • acphal.cpp: the SHAPE XMA/PCM contexts are 64 and 32 bytes (#2, db761be31, and the XMA context was reworked since then), so both static_asserts hold.
  • Slot 14: the proxy reaches the Vulkan layer through set_console_descriptor_heap_handler, the same way slot 133 does. Every Vulkan Device registers it, and a Device member builds the heap (#2, a7ffc53c1). #4 (37246f11d) takes the console layout only when the trailing size equals NumDescriptors * 32, so PC callers are no longer caught by the stack bytes after their desc.
  • d3d12_console_descriptor_heap_test compiles and passes (operator->, the reference handling of create_device_proxy, the start read through heap_proxy_real_heap).

The Runtime windows job compiles all of these files with MSVC 14.52 again. The remaining slot-14 false positive (a stray 32 after a one-descriptor desc) is handled in #1148. If anything from this branch is still missing, please open a new PR from current main. The old-pr/* branch stays, and #17 lists the carried-over drafts.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/82#issuecomment-7142639224) Thank you for this fix. The diagnosis was right, and current `main` already has it, so I'm closing this draft as superseded: - `acphal.cpp`: the SHAPE XMA/PCM contexts are 64 and 32 bytes (#2, `db761be31`, and the XMA context was reworked since then), so both `static_assert`s hold. - Slot 14: the proxy reaches the Vulkan layer through `set_console_descriptor_heap_handler`, the same way slot 133 does. Every Vulkan `Device` registers it, and a `Device` member builds the heap (#2, `a7ffc53c1`). #4 (`37246f11d`) takes the console layout only when the trailing size equals `NumDescriptors * 32`, so PC callers are no longer caught by the stack bytes after their desc. - `d3d12_console_descriptor_heap_test` compiles and passes (`operator->`, the reference handling of `create_device_proxy`, the start read through `heap_proxy_real_heap`). The Runtime `windows` job compiles all of these files with MSVC 14.52 again. The remaining slot-14 false positive (a stray `32` after a one-descriptor desc) is handled in #1148. If anything from this branch is still missing, please open a new PR from current `main`. The `old-pr/*` branch stays, and #17 lists the carried-over drafts. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.