[PR #2304] runtime: forward mixed clip and cull distances in the fallback geometry shader #2307

Open
opened 2026-11-26 21:20:45 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2304
Author: @ecox982745
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: reviewed-bary-mixed-distances


📝 Commits (7)

  • e7987db Translate computed I/J pairs when a GPU has no per-vertex inputs.
  • b9191a3 Merge remote-tracking branch 'origin/main' into fix/computed-ij-no-pervertex
  • 483f012 runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs
  • b456a8c Merge branch 'pr-1497' into rt-bary-fallback-per-vertex
  • fad05e2 Merge branch 'pr-1426' into rt-bary-fallback-per-vertex
  • 07d0699 runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX)
  • 096a262 runtime: forward mixed clip and cull distances in bary fallback

📊 Changes

23 files changed (+2798 additions, -103 deletions)

View changed files

📝 docs/design.md (+3 -3)
📝 docs/testing.md (+4 -1)
📝 make_game.py (+22 -4)
📝 runtime/CMakeLists.txt (+10 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+91 -7)
📝 runtime/src/shader_library.h (+34 -0)
➕ runtime/src/spirv_bary_fallback.h (+546 -0)
➕ runtime/test/d3d12_bary_fallback_test.cpp (+1000 -0)
📝 runtime/test/shader_library_test.cpp (+86 -0)
📝 runtime/test/shaders/build.py (+9 -7)
📝 runtime/test/shaders/check.py (+5 -4)
➕ runtime/test/spirv_bary_fallback_test.cpp (+658 -0)
📝 runtime/test/vk_test_device.h (+2 -0)
📝 scripts/run_gpu_tests.py (+6 -5)
📝 tests/semantic/support.py (+4 -2)
📝 tests/semantic/test_interp_computed_ij.py (+153 -14)
📝 tests/test_make_game_translator_flags.py (+20 -5)
📝 tests/test_run_gpu_tests.py (+21 -18)
📝 tests/test_shader_build_fallbacks.py (+22 -14)
📝 tests/test_vk_subgroup_info.py (+14 -0)

...and 3 more files

📄 Description

Claimed in the coordination issue as RT-BARY-FALLBACK-MIXED-DISTANCES.

Depends on: #1930 (which builds on #1426).

What changed

The fallback geometry shader now forwards both ClipDistance and CullDistance when a vertex shader writes both arrays. Each array keeps its own length. This allows the rasterizer to clip part of a primitive and to cull a whole primitive.

ZroIsHere wrote the implementation and CPU test in mrgenty/leonida#1. This draft brings that work upstream at the request of the #1930 author. The published head is the original commit 096a26220. Review the two-file change.

Verification

I reapplied the original commit locally on top of the updated #1930 head 682de2894. The resulting commit fcbc57c0d has a byte-identical two-file diff and merges cleanly with main at 73516a290.

  • The stock CPU generator test passed on the rebased commit. All ten generated SPIR-V modules passed spirv-val --target-env vulkan1.2.
  • I repeated 44 synthetic Vulkan draws on an NVIDIA GeForce RTX 4090 (Windows 11, driver 616.64). All 22 pairs matched the direct vertex-to-fragment path byte for byte across 90,112 RGBA32F pixels. The cases used clip/cull lengths of (1,1), (2,1), (1,2), and (4,4) and covered both partial clipping and whole-primitive culling. The validation layer reported zero errors. Earlier hardware run on the published commit.
  • The project’s game-data check on the two changed files and git diff --check both passed. All fixtures were synthetic.

Integration status

The public draft still points to 096a26220. GitHub rejected the rebased branch update because the dependency now includes upstream CI workflow changes and the connected OAuth app lacks the workflow scope. The fallback change itself touches only the runtime shader builder and its test. To reproduce the verified rebase, cherry-pick 096a26220 onto 682de2894. This draft is waiting on #1930 and publication of the rebased head.

AI-assisted: Yes. The original author disclosed AI assistance. OpenAI Codex (GPT-6) performed independent hardware verification, prepared the rebase and submitted the upstream draft.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2304 **Author:** [@ecox982745](https://github.com/ecox982745) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `reviewed-bary-mixed-distances` --- ### 📝 Commits (7) - [`e7987db`](https://github.com/ubiquitarianism/leonida/commit/e7987db42050179a38945e3682e400252112ad96) Translate computed I/J pairs when a GPU has no per-vertex inputs. - [`b9191a3`](https://github.com/ubiquitarianism/leonida/commit/b9191a3186def22cf2eb10250045156264650d8b) Merge remote-tracking branch 'origin/main' into fix/computed-ij-no-pervertex - [`483f012`](https://github.com/ubiquitarianism/leonida/commit/483f0128ebf9c50dedcda5f2caf5a65b60c6f843) runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs - [`b456a8c`](https://github.com/ubiquitarianism/leonida/commit/b456a8ca6aa2dca9c690467f01b7bb56d8755e94) Merge branch 'pr-1497' into rt-bary-fallback-per-vertex - [`fad05e2`](https://github.com/ubiquitarianism/leonida/commit/fad05e241bc78a9a75c87723b279fc4cc4b43066) Merge branch 'pr-1426' into rt-bary-fallback-per-vertex - [`07d0699`](https://github.com/ubiquitarianism/leonida/commit/07d069924bffc3d103a7fcd4a4eef341d4517dd7) runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX) - [`096a262`](https://github.com/ubiquitarianism/leonida/commit/096a26220f15ee165469a35fa5370828c61d1158) runtime: forward mixed clip and cull distances in bary fallback ### 📊 Changes **23 files changed** (+2798 additions, -103 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+3 -3) 📝 `docs/testing.md` (+4 -1) 📝 `make_game.py` (+22 -4) 📝 `runtime/CMakeLists.txt` (+10 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+91 -7) 📝 `runtime/src/shader_library.h` (+34 -0) ➕ `runtime/src/spirv_bary_fallback.h` (+546 -0) ➕ `runtime/test/d3d12_bary_fallback_test.cpp` (+1000 -0) 📝 `runtime/test/shader_library_test.cpp` (+86 -0) 📝 `runtime/test/shaders/build.py` (+9 -7) 📝 `runtime/test/shaders/check.py` (+5 -4) ➕ `runtime/test/spirv_bary_fallback_test.cpp` (+658 -0) 📝 `runtime/test/vk_test_device.h` (+2 -0) 📝 `scripts/run_gpu_tests.py` (+6 -5) 📝 `tests/semantic/support.py` (+4 -2) 📝 `tests/semantic/test_interp_computed_ij.py` (+153 -14) 📝 `tests/test_make_game_translator_flags.py` (+20 -5) 📝 `tests/test_run_gpu_tests.py` (+21 -18) 📝 `tests/test_shader_build_fallbacks.py` (+22 -14) 📝 `tests/test_vk_subgroup_info.py` (+14 -0) _...and 3 more files_ </details> ### 📄 Description Claimed in the coordination issue as [RT-BARY-FALLBACK-MIXED-DISTANCES](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7178530779). Depends on: #1930 (which builds on #1426). ### What changed The fallback geometry shader now forwards both `ClipDistance` and `CullDistance` when a vertex shader writes both arrays. Each array keeps its own length. This allows the rasterizer to clip part of a primitive and to cull a whole primitive. ZroIsHere wrote the implementation and CPU test in [mrgenty/leonida#1](https://github.com/mrgenty/leonida/pull/1). This draft brings that work upstream at the [request of the #1930 author](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7192884641). The published head is the original commit `096a26220`. [Review the two-file change](https://github.com/mrgenty/leonida/pull/1/files). ### Verification I reapplied the original commit locally on top of the updated #1930 head `682de2894`. The resulting commit `fcbc57c0d` has a byte-identical two-file diff and merges cleanly with main at `73516a290`. - The stock CPU generator test passed on the rebased commit. All ten generated SPIR-V modules passed `spirv-val --target-env vulkan1.2`. - I repeated 44 synthetic Vulkan draws on an NVIDIA GeForce RTX 4090 (Windows 11, driver 616.64). All 22 pairs matched the direct vertex-to-fragment path byte for byte across 90,112 RGBA32F pixels. The cases used clip/cull lengths of (1,1), (2,1), (1,2), and (4,4) and covered both partial clipping and whole-primitive culling. The validation layer reported zero errors. [Earlier hardware run on the published commit](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7191224557). - The project’s game-data check on the two changed files and `git diff --check` both passed. All fixtures were synthetic. ### Integration status The public draft still points to `096a26220`. GitHub rejected the rebased branch update because the dependency now includes upstream CI workflow changes and the connected OAuth app lacks the `workflow` scope. The fallback change itself touches only the runtime shader builder and its test. To reproduce the verified rebase, cherry-pick `096a26220` onto `682de2894`. This draft is waiting on #1930 and publication of the rebased head. AI-assisted: Yes. The original author disclosed AI assistance. OpenAI Codex (GPT-6) performed independent hardware verification, prepared the rebase and submitted the upstream draft. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2307
No description provided.