Skip to content

runtime: preserve raw vertex exports for computed barycentrics - #2

Closed
marcelofrayha wants to merge 1 commit into
mrgenty:rt-bary-fallback-per-vertexfrom
marcelofrayha:rt-bary-computed-raw-exports
Closed

marcelofrayha wants to merge 1 commit into
mrgenty:rt-bary-fallback-per-vertexfrom
marcelofrayha:rt-bary-computed-raw-exports

Conversation

@marcelofrayha

@marcelofrayha marcelofrayha commented Nov 26, 2026 •

Copy link
Copy Markdown

Claim: RT-BARY-FALLBACK-PER-VERTEX-RAW-EXPORTS

Depends on: ProjectLeonida#1930 (this PR targets its head branch), ProjectLeonida#1497, ProjectLeonida#1426.

This PR contains only the computed-I/J raw-export fix. The VS→GS packing change remains in robot00f/leonida#2 and is not included or required to reproduce this issue.

After FP16 linking, a decoded half can occupy the location of a missing raw VS attribute. The geometry shader could then forward that unrelated half to a computed-I/J array. Capture the VS's original raw Location→ID mapping before linking and use it for computed I/J; ordinary FP16 varyings still use their linked locations. Missing raw attributes stay zero-filled whether the half was relocated or left in a static VS slot.

Tested

  • CPU: spirv_bary_fallback and spirv_f16_halves, including relocated and static half regressions. All 12 emitted synthetic modules pass spirv-val for Vulkan 1.2 and 1.3.
  • Translated regression on runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX) ProjectLeonida/mandy#1930 alone, no packing patch: the PS reads decoded FP16 halves from attr0 and computed I/J from missing attr14. The baseline returns 0.5 for the missing attribute; the fix restores zero on all 4,096 pixels without changing the FP16 channels. Vulkan harness under Wine 10.0, with no Khronos validation errors.
  • D3D12 synthetic test under Wine 10.0: all cases passed on Lavapipe in eager and lazy modes, validation-clean. On RADV the inherited 16-varying FP16 test still stops at the existing 64-component geometry input limit; that separate issue is covered by runtime: pack barycentric geometry inputs for 64-component devices robot00f/pascalVI#2, not this PR.
  • git diff --check and scripts/check_no_game_data.py passed. The full translator semantic suite passed on the same translator sources (6,357 tests across 498 files); this PR changes only runtime code and tests. No retail shaders or game data used.

GPUs tested: AMD Radeon RX 5700 XT (RADV Mesa 26.0.8, Linux / Wine 10.0) and Lavapipe (software).

AI-assisted: yes (OpenCode).

A decoded FP16 half can occupy the location of a missing raw attribute. Pass the original raw vertex exports to the geometry builder in eager and lazy PSO paths so computed I/J keeps zero-filling that attribute. Cover relocated and static half aliases independently of geometry-input packing.

RT-BARY-FALLBACK-PER-VERTEX-RAW-EXPORTS. AI-assisted.
@marcelofrayha
marcelofrayha force-pushed the rt-bary-computed-raw-exports branch from 7f63a48 to ac6f0ed Compare November 26, 2026 22:58
mrgenty added a commit that referenced this pull request Nov 26, 2026
… linking (RT-BARY-FALLBACK-PER-VERTEX)

With both --bary-fallback and --f16-interp-fallback, create_graphics (and the lazy stage_words) links the f16
halves into the VS before the geometry stage is built. Linking may place a decoded half on a Location no raw VS
output used; when that Location is a computed-I/J attribute the VS does not export, build_bary_fallback_gs read the
half as that attribute and forwarded it instead of zero-filling the array.

- link_f16_halves can return the Locations of the VS's raw outputs as they were before linking, and
  build_bary_fallback_gs forwards a computed-I/J attribute only from one of them. Both call sites pass the set when
  the halves were linked.
- link_f16_halves also keeps halves off the second and third Locations of a per_vertex vec4[3] block, which has a
  Location decoration on its first only.

spirv_bary_fallback_test 7f-7h: a relocated half and a static half on a missing attribute's Location (zero-filled;
without the set the half is forwarded), and a block whose third Location linking would otherwise choose (the
builder refused it).

Reported, with a GPU reproduction, by @marcelofrayha in #2; the fix follows his commit 7f63a48,
and the block reservation his bdff821, adapted to this branch without the geometry-input packing.

Co-authored-by: Marcelo Frayha <marcelofrayha@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrgenty

mrgenty commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks, this was a real bug and the reproduction made it easy to confirm. I took the raw-export fix and the vec4[3] block reservation into ProjectLeonida#1930 as 0b753295, with you as co-author, adapted to that branch. To keep ProjectLeonida#1930 to one topic I've left out the geometry-input packing from robot00f#2. It belongs with that PR or as its own stacked PR once ProjectLeonida#1930 and ProjectLeonida#1497 land. Closing this in favour of 0b753295.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants