runtime/shims: fix acphal context sizes and guard Vulkan heap helper on non-Vulkan builds #87

Closed
Andretuta wants to merge 2 commits from upstream-pr/87 into main
Andretuta commented 2026-11-24 02:15:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:15:27Z.


Carried over from old PR 9815 by piyonchu in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9815, 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.
piyonchu: 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):

Fixes two CPU-only Windows MSVC build regressions on main (2d53a8055):

Changes

  1. runtime/shims/acphal.cpp:
    • Fix SHAPE_XMA_CONTEXT padding (reserved[10] -> reserved[11]): the preceding 24-bit bitfield group followed by 26-bit currentByteOffset splits into separate 32-bit storage units under MSVC, making the struct 60 bytes and failing static_assert(sizeof(SHAPE_XMA_CONTEXT) == 64). Static analysis of game_scarlett_master.exe confirms shl r8, 6 (64-byte stride) when zeroing the XMA context array.
    • Fix SHAPE_PCM_CONTEXT padding (reserved[1] -> reserved[2]): 6 32-bit bitfield words + 1 reserved dword was 28 bytes, failing static_assert(sizeof(SHAPE_PCM_CONTEXT) == 32).
  2. runtime/shims/d3d12_xs_device.cpp:
    • Include "d3d12_com.h" and call rt::d3d12::create_console_descriptor_heap(...) only when LEONIDA_VULKAN_DEVICE is defined, so CPU-only gta6rt builds (without Vulkan headers/device) compile and link cleanly and fall back to standard CreateDescriptorHeap.

Verification

  • Full cmake -S runtime -B build_fix + cmake --build build_fix --config Release -j: built gta6rt.exe and all CPU test targets cleanly on MSVC 19.44 (10.0.26100.0 SDK).
  • ctest --test-dir build_fix -C Release -R "acphal|device_proxy|xs_proxy|com_shim|bcrypt_rng": 12/12 passed.
  • python tests/test_acphal_abi.py: 4/4 OK.
  • python tests/test_ctest_registration.py: 4/4 OK.
  • gta6rt.exe --dry-run game_scarlett_master.exe: resolves AcpHal.dll (9/9 exports via shim).
  • python scripts/check_no_game_data.py, git diff --check.
  • Claimed on #9677 (https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116626255).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464798809 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/87). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:15:27Z. --- > Carried over from **old PR 9815** by `piyonchu` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9815`, 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. > `piyonchu`: 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): Fixes two CPU-only Windows MSVC build regressions on `main` (`2d53a8055`): ### Changes 1. [`runtime/shims/acphal.cpp`](runtime/shims/acphal.cpp): - Fix `SHAPE_XMA_CONTEXT` padding (`reserved[10]` -> `reserved[11]`): the preceding 24-bit bitfield group followed by 26-bit `currentByteOffset` splits into separate 32-bit storage units under MSVC, making the struct 60 bytes and failing `static_assert(sizeof(SHAPE_XMA_CONTEXT) == 64)`. Static analysis of `game_scarlett_master.exe` confirms `shl r8, 6` (64-byte stride) when zeroing the XMA context array. - Fix `SHAPE_PCM_CONTEXT` padding (`reserved[1]` -> `reserved[2]`): 6 32-bit bitfield words + 1 reserved dword was 28 bytes, failing `static_assert(sizeof(SHAPE_PCM_CONTEXT) == 32)`. 2. [`runtime/shims/d3d12_xs_device.cpp`](runtime/shims/d3d12_xs_device.cpp): - Include `"d3d12_com.h"` and call `rt::d3d12::create_console_descriptor_heap(...)` only when `LEONIDA_VULKAN_DEVICE` is defined, so CPU-only `gta6rt` builds (without Vulkan headers/device) compile and link cleanly and fall back to standard `CreateDescriptorHeap`. ### Verification - Full `cmake -S runtime -B build_fix` + `cmake --build build_fix --config Release -j`: built `gta6rt.exe` and all CPU test targets cleanly on MSVC 19.44 (`10.0.26100.0` SDK). - `ctest --test-dir build_fix -C Release -R "acphal|device_proxy|xs_proxy|com_shim|bcrypt_rng"`: `12/12` passed. - `python tests/test_acphal_abi.py`: `4/4` OK. - `python tests/test_ctest_registration.py`: `4/4` OK. - `gta6rt.exe --dry-run game_scarlett_master.exe`: resolves `AcpHal.dll` (9/9 exports via `shim`). - `python scripts/check_no_game_data.py`, `git diff --check`. - Claimed on `#9677` (`https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116626255`). AI-assisted: yes
aslan2142 commented 2026-11-24 19:49:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:49:28Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142640267 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/87#issuecomment-7142640267). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:49:28Z. --- 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

Sign in to join this conversation.
No reviewers
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
ProjectLeonida/mandy!87
No description provided.