d3d12, test: pass device_.f16_half_top_location in lazy graphics pipeline stage_words (RT-LAZY-PIPELINE-F16-TOP-LOCATION) #1953

Manually merged
github merged 1 commit from gh-pr/1953/head into gh-pr/1953/base 2026-11-26 10:12:37 +00:00
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 16:37 UTC · original
abnalstlll-byte:feat/rt-lazy-pipeline-f16-top-location → main · +267 −6 · 4 files · 1 commits · merged 2026-11-25 23:27 UTC

Summary

In runtime/shims/d3d12_vulkan_device.cpp:stage_words(), pass device_.f16_half_top_location when re-linking --f16-interp-fallback halves via leonida::link_f16_halves(), matching create_graphics() at line 8482.

Previously, stage_words() omitted the 6th top_location argument, causing it to default to 29. On devices where maxVertexOutputComponents < 124 (e.g. 64 components -> top_location = 14), lazy pipeline compilation could relocate vertex output locations beyond the hardware capability limit.

Validation

  • Added check #11 to runtime/test/spirv_f16_halves_test.cpp verifying that custom top_location = 14 correctly bounds relocated output locations to <= 14.
  • All checks in spirv_f16_halves_test pass.
  • Verified line endings with test_text_write_line_endings.py.
  • Clean-room: check_no_game_data.py clean; synthetic tests only, no game assets or GPU required.

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 16:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1953) `abnalstlll-byte:feat/rt-lazy-pipeline-f16-top-location` → `main` · +267 −6 · 4 files · 1 commits · merged 2026-11-25 23:27 UTC ### Summary In `runtime/shims/d3d12_vulkan_device.cpp:stage_words()`, pass `device_.f16_half_top_location` when re-linking `--f16-interp-fallback` halves via `leonida::link_f16_halves()`, matching `create_graphics()` at line 8482. Previously, `stage_words()` omitted the 6th `top_location` argument, causing it to default to 29. On devices where `maxVertexOutputComponents < 124` (e.g. 64 components -> `top_location = 14`), lazy pipeline compilation could relocate vertex output locations beyond the hardware capability limit. ### Validation - Added check #11 to `runtime/test/spirv_f16_halves_test.cpp` verifying that custom `top_location = 14` correctly bounds relocated output locations to `<= 14`. - All checks in `spirv_f16_halves_test` pass. - Verified line endings with `test_text_write_line_endings.py`. - Clean-room: `check_no_game_data.py` clean; synthetic tests only, no game assets or GPU required. AI-assisted (Claude Code)
Move per-pipeline f16 halves linking into a shared helper PipelineState::link_f16_halves
called by both eager create_graphics() and lazy stage_words() paths, always passing
device_.f16_half_top_location. Previously, stage_words() omitted top_location, causing
it to default to 29 and relocate outputs beyond the device limit on hardware where
maxVertexOutputComponents < 124 (e.g. top_location = 14 on 64-component limits).

Add f16_half_top_location to VulkanDeviceInfo (0 = read from device limits; non-zero =
override for testing low-limit devices).
Expose rt::d3d12::pipeline_stage_words() to allow inspecting linked lazy pipeline SPIR-V.
In runtime/test/d3d12_f16_halves_test.cpp, add low top_location = 14 tests verifying that
out-of-budget pipelines are rejected at CreateGraphicsPipelineState, in-budget pipelines
relocate within location 14 and execute correctly through the lazy path on first draw, and
explicitly verify that the linked SPIR-V stage modules' highest Location does not exceed 14.
Keep unit check #11 in runtime/test/spirv_f16_halves_test.cpp.

Tested:
- spirv_f16_halves_test (passed)
- python -I scripts/check_no_game_data.py runtime/shims/d3d12_com.h runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_f16_halves_test.cpp (clean)
No retail game data or keys.

AI-assisted (Claude Code, Claude Opus 5.5).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:12:36 +00:00
github manually merged commit 8dc07b3a4b into gh-pr/1953/base 2026-11-26 10:12:37 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 19:22 UTC · original

The bug is real and the fix is right: the eager path passes the device's limit, while the lazy stage_words() path falls back to 29.

But check #11 calls link_f16_halves(..., 14) directly, which main already supports, so it passes without the fix. Please add a test that goes through the lazy path with a low top location. Alternatively, move the link into one helper that both paths call, and test that.

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

**@⁠aslan2142** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7172198819) The bug is real and the fix is right: the eager path passes the device's limit, while the lazy `stage_words()` path falls back to 29. But check #11 calls `link_f16_halves(..., 14)` directly, which `main` already supports, so it passes without the fix. Please add a test that goes through the lazy path with a low top location. Alternatively, move the link into one helper that both paths call, and test that. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 21:26 UTC · original

Thanks @⁠aslan2142! Updated in 34dff91b1:

  1. Unified helper: Moved the link_f16_halves call in PipelineState into a shared private helper PipelineState::link_f16_halves called by both the eager path (create_graphics()) and the lazy path (stage_words()), ensuring neither path can omit device_.f16_half_top_location.
  2. Device limit test support: Added std::uint32_t f16_half_top_location = 0 to VulkanDeviceInfo (0 = read from device limits; non-zero = override for tests).
  3. End-to-end lazy path GPU test: Added low op_location = 14 tests in
    untime/test/d3d12_f16_halves_test.cpp:
    • Verifies an out-of-budget 16-param VS is rejected at CreateGraphicsPipelineState.
    • Verifies an in-budget 10-param VS with colliding halves is created, built lazily at first draw via stage_words(), rendered on the GPU, and reads back pixel (64, 191, 128, 255) within +-1 LSB.
  4. Rebase: Cleanly rebased onto latest \main\ (\db1a22d29).

Verified locally on NVIDIA GeForce RTX 5060 Ti:

  • \spirv_f16_halves_test.exe: all checks passed
  • \d3d12_f16_halves_test.exe: 4/4 cases OK (including lazy build with top_location 14)

AI-assisted (Claude Code)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 21:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7175090775) Thanks @⁠aslan2142! Updated in 34dff91b1: 1. **Unified helper**: Moved the link_f16_halves call in PipelineState into a shared private helper PipelineState::link_f16_halves called by both the eager path (create_graphics()) and the lazy path (stage_words()), ensuring neither path can omit device_.f16_half_top_location. 2. **Device limit test support**: Added std::uint32_t f16_half_top_location = 0 to VulkanDeviceInfo (0 = read from device limits; non-zero = override for tests). 3. **End-to-end lazy path GPU test**: Added low op_location = 14 tests in untime/test/d3d12_f16_halves_test.cpp: - Verifies an out-of-budget 16-param VS is rejected at CreateGraphicsPipelineState. - Verifies an in-budget 10-param VS with colliding halves is created, built lazily at first draw via stage_words(), rendered on the GPU, and reads back pixel (64, 191, 128, 255) within +-1 LSB. 4. **Rebase**: Cleanly rebased onto latest \main\ (\db1a22d29\). Verified locally on NVIDIA GeForce RTX 5060 Ti: - \spirv_f16_halves_test.exe\: all checks passed - \d3d12_f16_halves_test.exe\: 4/4 cases OK (including lazy build with top_location 14) AI-assisted (Claude Code)
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:06 UTC · original

Thanks, the helper is the right shape: both paths now pass the device's top location.

  • The new test still passes without the fix. I reverted only the lazy stage_words() call to the old one and ran d3d12_f16_halves on lavapipe and RADV (gfx1036): it passes. Overriding f16_half_top_location to 14 changes what the runtime believes, but the device still accepts location 29, so the old code renders correctly too.
  • Suggestion: check the location the lazy path links to rather than the pixel, e.g. the linked SPIR-V's highest Location, expected at or below 14.
  • Tested: the full Windows suite under Wine on both devices, merged onto today's main: no test went from pass to fail.

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

**@⁠aslan2142** on GitHub · 2026-11-25 22:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7175950614) Thanks, the helper is the right shape: both paths now pass the device's top location. - **The new test still passes without the fix.** I reverted only the lazy `stage_words()` call to the old one and ran `d3d12_f16_halves` on lavapipe and RADV (gfx1036): it passes. Overriding `f16_half_top_location` to 14 changes what the runtime believes, but the device still accepts location 29, so the old code renders correctly too. - **Suggestion:** check the location the lazy path links to rather than the pixel, e.g. the linked SPIR-V's highest `Location`, expected at or below 14. - **Tested:** the full Windows suite under Wine on both devices, merged onto today's `main`: no test went from pass to fail. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 22:25 UTC · original

Thank you for the excellent suggestion @⁠aslan2142! Updated in commit 8dc07b3a4:

  • Rebased cleanly onto latest main.
  • Added
    t::d3d12::pipeline_stage_words()\ inspection helper for lazy pipelines.
  • In \d3d12_f16_halves_test.cpp, added explicit validation of the linked SPIR-V stage modules: parsing instructions and asserting that every relocated f16 half variable's \Location\ decoration is <= 14\ (specifically location 14). If \stage_words()\ were reverted to the old behavior defaulting \ op_location = 29, this check immediately fails with highest location 29 exceeding 14.

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

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 22:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7176348739) Thank you for the excellent suggestion @⁠aslan2142! Updated in commit 8dc07b3a4: - Rebased cleanly onto latest main. - Added \ t::d3d12::pipeline_stage_words()\ inspection helper for lazy pipelines. - In \d3d12_f16_halves_test.cpp\, added explicit validation of the linked SPIR-V stage modules: parsing instructions and asserting that every relocated f16 half variable's \Location\ decoration is \<= 14\ (specifically location 14). If \stage_words()\ were reverted to the old behavior defaulting \ op_location = 29\, this check immediately fails with highest location 29 exceeding 14. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.