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

Merged
abnalstlll-byte merged 1 commit from upstream-pr/1953 into main 2026-11-25 23:27:58 +00:00
abnalstlll-byte commented 2026-11-25 16:37:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T16:37:35Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5495257123 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1953). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T16:37:35Z. --- ### 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)
aslan2142 commented 2026-11-25 19:22:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T19:22:11Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172198819 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7172198819). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T19:22:11Z. --- 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).
abnalstlll-byte commented 2026-11-25 21:26:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T21:26:57Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7175090775 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7175090775). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T21:26:57Z. --- 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)
aslan2142 commented 2026-11-25 22:06:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:06:46Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7175950614 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7175950614). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:06:46Z. --- 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).
abnalstlll-byte commented 2026-11-25 22:25:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-25T22:25:41Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176348739 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1953#issuecomment-7176348739). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-25T22:25:41Z. --- 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).
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!1953
No description provided.