reprend #2029: runtime: guard overflow/div-by-zero and remove duplicate passes in d3d12_xs_alloc_size #2739

Merged
OreoFR merged 3 commits from upstream-pr/2739 into main 2026-11-30 16:50:48 +00:00
OreoFR commented 2026-11-30 13:39:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:39:53Z.


Carries #2029 by @IlyassRS3, because it conflicts with main after #2566 and the reminder to merge main (https://github.com/ProjectLeonida/mandy/pull/2029#issuecomment-7232641357) got no answer within the delay of the carry rule. If the author comes back, this carry is dropped.

Item: RT-XS-ALLOC-SIZE-OVERFLOW-AND-SINGLE-PASS-CARRY (claimed in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7280119323; original item RT-XS-ALLOC-SIZE-OVERFLOW-AND-SINGLE-PASS).

What this branch is

  • The author's branch at 0c4bdde51, unchanged (no rebase, author commits kept).
  • A merge of main (from the carry preparation of 29/11) that resolves the conflict, then a merge of current main f9f3ec4c6, which had a new conflict (below). Both merge commits carry Co-authored-by the author.
  • Nothing else: the change itself is the original PR's; see #2029 for what and why, and the verifications posted there.

What conflicted and how it was resolved

  • runtime/shims/d3d12_xs_alloc_size.h: the PR's one-pass console_placement, with main's title_descs/title_layout and console_unordered_access_size added to the per-description overloads.
  • runtime/CMakeLists.txt (2 hunks): xs_alloc_size_test and appnotify_test both kept.
  • New with f9f3ec4c6: runtime/shims/d3d12_xs_alloc_size.h, align_up_saturating: main (#2027) returns value when to == 0, the PR when to <= 1; for to == 1 the rounding gives value as well, so both agree; the PR's guard and comment kept. main's d3d12_xs_alloc_size_test (#2027) and the PR's xs_alloc_size_test are both built: CI runs main's test against the PR's rewrite.

A function is rewritten (console_placement in one pass): please read it against main's version.

Tests

  • On this branch (main f9f3ec4c6 merged), Windows 11, Python 3.12, no GPU used: C++ only: left to this PR's CI (no local C++ build in this run).
  • Earlier merge: ctest 502 tests, xs_alloc_size passes; red (main's header): 6 FAIL.
  • python -I scripts/check_no_game_data.py on every file this PR changes: clean.
  • CI on this PR covers the rest (C++ build and ctest, the full translator suite).

Depends on: none.

Needs a careful human read of the resolution and an independent verifier before merge (red/green on another machine).

AI-assisted (Claude Code, oreofr-agent).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5566398299 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2739). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-30T13:39:53Z. --- Carries #2029 by @IlyassRS3, because it conflicts with `main` after #2566 and the reminder to merge `main` (https://github.com/ProjectLeonida/mandy/pull/2029#issuecomment-7232641357) got no answer within the delay of the carry rule. If the author comes back, this carry is dropped. Item: `RT-XS-ALLOC-SIZE-OVERFLOW-AND-SINGLE-PASS-CARRY` (claimed in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7280119323; original item `RT-XS-ALLOC-SIZE-OVERFLOW-AND-SINGLE-PASS`). ### What this branch is - The author's branch at `0c4bdde51`, unchanged (no rebase, author commits kept). - A merge of `main` (from the carry preparation of 29/11) that resolves the conflict, then a merge of current `main` `f9f3ec4c6`, which had a new conflict (below). Both merge commits carry `Co-authored-by` the author. - Nothing else: the change itself is the original PR's; see #2029 for what and why, and the verifications posted there. ### What conflicted and how it was resolved - `runtime/shims/d3d12_xs_alloc_size.h`: the PR's one-pass `console_placement`, with `main`'s `title_descs`/`title_layout` and `console_unordered_access_size` added to the per-description overloads. - `runtime/CMakeLists.txt` (2 hunks): `xs_alloc_size_test` and `appnotify_test` both kept. - New with `f9f3ec4c6`: `runtime/shims/d3d12_xs_alloc_size.h`, `align_up_saturating`: `main` (#2027) returns `value` when `to == 0`, the PR when `to <= 1`; for `to == 1` the rounding gives `value` as well, so both agree; the PR's guard and comment kept. `main`'s `d3d12_xs_alloc_size_test` (#2027) and the PR's `xs_alloc_size_test` are both built: CI runs `main`'s test against the PR's rewrite. **A function is rewritten** (`console_placement` in one pass): please read it against `main`'s version. ### Tests - On this branch (`main` `f9f3ec4c6` merged), Windows 11, Python 3.12, no GPU used: C++ only: left to this PR's CI (no local C++ build in this run). - Earlier merge: `ctest` 502 tests, `xs_alloc_size` passes; red (`main`'s header): 6 FAIL. - `python -I scripts/check_no_game_data.py` on every file this PR changes: clean. - CI on this PR covers the rest (C++ build and `ctest`, the full translator suite). Depends on: none. **Needs a careful human read of the resolution and an independent verifier before merge** (red/green on another machine). AI-assisted (Claude Code, oreofr-agent). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kal0s-design commented 2026-11-30 14:13:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-11-30T14:13:31Z.


Independent red/green on another machine, as the description asks. Head ff55c339e merged onto current main b17b22d33 (no conflict, tree d87fc9b6b). Native Windows 11, MSVC 19.50 x64. Each test was built alone with the CMake target's include dirs and defines (/Ishims /Isrc /DWIN32_LEAN_AND_MEAN /DNOMINMAX /W4 /permissive- /utf-8), under AddressSanitizer with the debug CRT (/Od /MDd /fsanitize=address).

  • Red: main's runtime + this PR's test/xs_alloc_size_test.cpp: FAILED (4 failures):

    • render target multi-mip slice accumulation overflow returns 0
    • depth-stencil multi-plane slice accumulation overflow returns 0
    • pc_one called exactly once per descriptor even when each is non-null
    • count > 16 heap-spill path calls pc_one once per entry

    (The earlier merge's "6 FAIL" was against an older main.) Same at /O2 /MD: exit 1.

  • Green: the merged tree: xs_alloc_size_test: OK (0 failures) under ASan, no report; also OK at /O2 /MD.

  • The rewritten console_placement against main's own test: main's test/d3d12_xs_alloc_size_test.cpp (#2027) built against this PR's header: 62/62 checks passed under ASan, the same as against main's header (62/62).

  • Only warnings: xg_xs_layout.h(163) C4996 (getenv) and (347) C4334, identical on main. Not in this PR's files.

I didn't do a line-by-line read of the conflict resolution beyond these two test files.

GPUs tested: n/a (CPU unit tests). AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7281033639 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2739#issuecomment-7281033639). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-30T14:13:31Z. --- **Independent red/green on another machine**, as the description asks. Head `ff55c339e` merged onto current `main` `b17b22d33` (no conflict, tree `d87fc9b6b`). Native Windows 11, MSVC 19.50 x64. Each test was built alone with the CMake target's include dirs and defines (`/Ishims /Isrc /DWIN32_LEAN_AND_MEAN /DNOMINMAX /W4 /permissive- /utf-8`), under AddressSanitizer with the debug CRT (`/Od /MDd /fsanitize=address`). - **Red**: `main`'s runtime + this PR's `test/xs_alloc_size_test.cpp`: `FAILED (4 failures)`: - `render target multi-mip slice accumulation overflow returns 0` - `depth-stencil multi-plane slice accumulation overflow returns 0` - `pc_one called exactly once per descriptor even when each is non-null` - `count > 16 heap-spill path calls pc_one once per entry` (The earlier merge's "6 FAIL" was against an older `main`.) Same at `/O2 /MD`: exit 1. - **Green**: the merged tree: `xs_alloc_size_test: OK (0 failures)` under ASan, no report; also OK at `/O2 /MD`. - **The rewritten `console_placement` against `main`'s own test**: `main`'s `test/d3d12_xs_alloc_size_test.cpp` (#2027) built against this PR's header: `62/62 checks passed` under ASan, the same as against `main`'s header (62/62). - Only warnings: `xg_xs_layout.h(163)` C4996 (`getenv`) and `(347)` C4334, identical on `main`. Not in this PR's files. I didn't do a line-by-line read of the conflict resolution beyond these two test files. GPUs tested: n/a (CPU unit tests). AI-assisted: yes.
KelboLive commented 2026-11-30 15:30:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T15:30:15Z.


Independent check on Windows (not the author), at ff55c339e.

  • Configured the branch's runtime and built xs_alloc_size_test (MSVC 14.52.37025, Windows SDK 10.0.26100).
  • Ran it: xs_alloc_size_test: OK (0 failures) — exit 0.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.

Based on f9f3ec4c6; a rebase on current main before merge would keep history linear.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7283104644 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2739#issuecomment-7283104644). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T15:30:15Z. --- Independent check on Windows (not the author), at `ff55c339e`. - Configured the branch's `runtime` and built `xs_alloc_size_test` (MSVC 14.52.37025, Windows SDK 10.0.26100). - Ran it: `xs_alloc_size_test: OK (0 failures)` — exit 0. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. Based on `f9f3ec4c6`; a rebase on current `main` before merge would keep history linear. AI-assisted: yes (opencode).
MoonEyes commented 2026-11-30 15:48:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T15:48:11Z.


Verified by MoonEyes (another owner than OreoFR) on head ff55c339e merged with main be7690805: Windows 11, MSVC 2022 x64, RelWithDebInfo, RTX 4060 8 GB (NVIDIA). ctest -R ^xs_alloc_size$: 1/1 passed; with d3d12_xs_alloc_size.h of main 4 failures.

Unit test only: no run of the title (this is the Vulkan path).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7283614084 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2739#issuecomment-7283614084). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T15:48:11Z. --- Verified by MoonEyes (another owner than OreoFR) on head `ff55c339e` merged with `main` `be7690805`: Windows 11, MSVC 2022 x64, RelWithDebInfo, RTX 4060 8 GB (NVIDIA). `ctest -R ^xs_alloc_size$`: 1/1 passed; with `d3d12_xs_alloc_size.h` of `main` 4 failures. Unit test only: no run of the title (this is the Vulkan path). AI-assisted (Claude Code).
MoonEyes commented 2026-11-30 16:50:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T16:50:45Z.


Merging. Head ff55c339e merges cleanly with main 6dbbe6df5 and does not force a rebase of #2566. Vulkan path: Moon's written OK for this PR without a run in the game; ctest red and green on Windows 11, and by another person. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7285318732 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2739#issuecomment-7285318732). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T16:50:45Z. --- Merging. Head `ff55c339e` merges cleanly with `main` `6dbbe6df5` and does not force a rebase of #2566. Vulkan path: Moon's written OK for this PR without a run in the game; ctest red and green on Windows 11, and by another person. Merged by MoonEyes. AI-assisted (Claude Code).
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!2739
No description provided.