Skip to content

runtime: forward mixed clip and cull distances in bary fallback - #1

Closed
ZroIsHere wants to merge 5 commits into
mrgenty:rt-bary-fallback-per-vertexfrom
ZroIsHere:fix/bary-fallback-mixed-distances
Closed

ZroIsHere wants to merge 5 commits into
mrgenty:rt-bary-fallback-per-vertexfrom
ZroIsHere:fix/bary-fallback-mixed-distances

Conversation

@ZroIsHere

Copy link
Copy Markdown

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

Depends on: ProjectLeonida#1930

What and why

The synthesized fallback geometry shader previously rejected a valid vertex shader when it wrote both ClipDistance and CullDistance. Vulkan permits both arrays in the same stage (subject to maxCombinedClipAndCullDistances), so rejecting them prevents otherwise supported graphics PSOs from using the barycentric fallback.

The generator now declares and forwards each built-in independently, with its own array type, input/output variable and capability. The existing geometry-stage checks already require shaderClipDistance and shaderCullDistance for the corresponding arrays.

Verification

  • Added coverage for a mixed clip/cull module, asserting both capabilities and both input/output built-ins.
  • Local tests were not run. CI is expected to validate the SPIR-V generator tests.
  • GPU tested: n/a; module-generation change.
  • AI-assisted: yes.

robot00f and others added 5 commits November 25, 2026 11:26
… PSOs

When a translated pixel shader carries `"bary_fallback_input": {"location": N}`
in `spirv/index.json` (`rdna2spirv.py --bary-fallback` for GPUs without
`VK_KHR_fragment_shader_barycentric`), `PipelineState::create_graphics` now
synthesizes the triangle pass-through Geometry SPIR-V 1.5 module in memory
(`leonida::build_bary_fallback_gs` in `runtime/src/spirv_bary_fallback.h`)
after `--f16-interp-fallback` VS/PS location linking:

- Parses `bary_fallback_input.location` in `ShaderLibrary::load_index` into
  `ShaderEntry::bary_fallback_location`.
- Copies `BuiltIn Position` and every `vec4<f32>` `Location` input read by the
  PS (other than `bary_location`) that the VS exports, while zero-filling any
  unexported PS `Location` input without declaring a dangling GS `Input` and
  leaving unread VS outputs unconsumed (`VUID-RuntimeSpirv-OpEntryPoint-08743`).
- Forwards a VS `BuiltIn ClipDistance` or `BuiltIn CullDistance` `float[1..8]`
  array (checking `shaderClipDistance` / `shaderCullDistance`), and emits
  `(1, 0, 0)`, `(0, 1, 0)`, `(0, 0, 1)` at `bary_location` across the 3 strip
  vertices so perspective interpolation matches `BaryCoordKHR`.
- Supports both eager and lazy graphics pipeline builds (`StageSource::bary_fallback`
  in `stage_words`), clamps `--f16-interp-fallback` `top_location` against
  `maxGeometryInputComponents` / `maxGeometryOutputComponents`, and refuses
  mesh PSOs, explicit GS or rectangle-list stages, missing `geometryShader`, or
  non-triangle topologies with clear HRESULTs (`E_NOTIMPL` / `E_INVALIDARG`).
- Adds `spirv_bary_fallback` (portable CPU test) and `d3d12_bary_fallback`
  (end-to-end Vulkan GPU D3D12 PSO test).

Claim: RT-BARY-FALLBACK-PSO
AI-assisted: yes (Antigravity)
…pairs (RT-BARY-FALLBACK-PER-VERTEX)

A pixel shader with a computed I/J pair, translated with --bary-fallback, reads the pair's attribute as a Flat
vec4[3] at the first of three locations its index entry gives under bary_fallback_input.per_vertex. The runtime's
geometry-stage builder read only bary_fallback_input.location and refused that input ("PS pass-through Input at
Location 0 is not vec4<f32>"), so such a PSO was never created.

- shader_library.h: parse per_vertex (attribute -> first location) into ShaderEntry::bary_fallback_per_vertex; one
  malformed entry drops the whole map.
- spirv_bary_fallback.h: build_bary_fallback_gs takes the map and writes the triangle's three values of each mapped
  VS output to the PS's Flat vec4[3] (element k = vertex k, the same at every emitted vertex), as
  tools/bary_fallback_gs.py does. An attribute the VS does not export is zero-filled. A vec4[3] the map does not
  name, a block that runs into another input or the barycentric location, and two attributes at one first location
  are refused. The old signature stays as a wrapper with an empty map.
- d3d12_vulkan_device.cpp: both call sites (eager and lazy) pass the entry's map.
- Tests: spirv_bary_fallback (five per-vertex cases), shader_library (twelve per_vertex parsing cases),
  d3d12_bary_fallback (two draws of a synthetic computed-I/J PS and one refusal).
- docs/design.md: the runtime builder in the "Barycentric fallback" row, with what was and was not checked.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@mrgenty

mrgenty commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Superseded by ProjectLeonida#2304.

@mrgenty mrgenty closed this Nov 26, 2026
mrgenty pushed a commit that referenced this pull request Nov 28, 2026
Titles import gameinput.dll by ordinal only (VIctory's gameinput module
registers #1 and nothing else). The loader looks ordinal imports up as
#<n>, so the SDL3 shim was never bound and the import went to the
host's GameInput.dll. Not built here: no SDL3 in this configuration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mrgenty pushed a commit that referenced this pull request Nov 28, 2026
Port VIctory's GameInput module (gameinput.rs, gameinput/dualsense.rs,
GPL-3.0-or-later) as shims/gameinput_xinput.cpp: XInput pads 0-3, a
wired DualSense over HID, the keyboard as its own device, and a keyboard
pad that stands in while no other pad is connected. Readings per change
with a 32-deep history, blocking and async device enumeration,
UnregisterCallback waiting for a running callback, FindDeviceFromId and
XInput rumble, all as VIctory runs the title.

It is built into gta6rt when the SDL3 shim is not (the main build has no
SDL3), instead of binding the import to the host's GameInput.dll, which
has no keyboard pad; LEONIDA_GAMEINPUT=host keeps that path and
LEONIDA_KEYBOARD_PAD=off drops the keyboard pad. Registered by name and
ordinal #1. gameinput_xinput_test runs it over a fake host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mrgenty pushed a commit that referenced this pull request Nov 28, 2026
…ate-decay

fix(gpu): resolve D3D12 error 538 in buffer comparisons
mrgenty pushed a commit that referenced this pull request Nov 28, 2026
Keep diagnostic end markers after the comparison while retaining its separate queue call and the existing fence.

Refs: #1
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.

3 participants