Repository navigation
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Built and ran this at 4291ad57 on Windows 11, RTX 5070 Ti:
bary_fallback_gs_test.exe-> exit 0: "interface, one-hot constants, clip/cull forwarding, PS-module locations and the refusals all as expected".d3d12_bary_fallback_test.exe-> exit 0: "the layer drew a--bary-fallbackPS through its pass-through geometry shader, 2016 pixels inside the triangle hold their barycentrics and location 0, 2016 outside stayed clear; a line topology, a PSO's own GS and a VS writing Layer refused".ctest -R 'bary_fallback'-> 6/6 passed (0.26 s total).
The fallback path works end to end on this device and the guarded refusals are enforced. No blocking issue.
|
Tested
AI-assisted review. |
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted Windows CPU verification at 4291ad57. Built the focused tests under MSVC 19.38 and Vulkan SDK 1.4.363. Six CTests passed, including four offline module checks. Python helper and CTest registration tests passed 31/31 with uv CPython 3.12.13.
The C++ and Python emitters matched instruction for instruction after normalizing IDs on four sparse, empty, clip or cull cases. Two mixed clip/cull variants matched references built from both Python templates and validated for Vulkan 1.0. With the actual f16 linker moving fragment input IDs from 4/5 to 27/28, the generated GS consumed locations 0, 6, 27 and 28 and emitted those plus barycentrics at 29, omitting the old vertex-only location 4. Synthetic offline checks, no GPU execution.
|
Tested 4291ad5 on NVIDIA GeForce RTX 3070 (Ampere), driver 617.42, Windows 11 24H2, MSVC 19.44 RelWithDebInfo: pass. This device has
No game files. AI-assisted (Claude). |
|
Tested 4291ad5 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1; the device has VK_KHR_fragment_shader_barycentric, so this exercises the pass-through GS on a device that doesn't need it) and NVIDIA RTX 5080 (driver 616.92). AI-assisted. |
Flyander
left a comment
There was a problem hiding this comment.
The generated fallback geometry stage also needs to account for built-in fragment inputs. In particular, PrimitiveId becomes a pipeline-linking requirement when this new GS is present.
| std::vector<std::uint32_t> locations; | ||
| for (const auto& [location, var] : inputs) | ||
| if (location != bary) locations.push_back(location); | ||
| return bary_fallback_gs(locations, bary, vs.clip_distance_count, vs.cull_distance_count, error); |
There was a problem hiding this comment.
[P2] Forward or reject fragment PrimitiveId before adding the fallback GS. This generator copies only located inputs plus clip/cull distances and emits no BuiltIn PrimitiveId output. If ps_words reads PrimitiveId, the pipeline has Fragment and Geometry stages but the GS does not write the matching output, violating VUID-VkGraphicsPipelineCreateInfo-pStages-00740. Validation reports the invalid pipeline; without validation, the fragment ID is undefined. Detect that built-in and either pass it through or return a clear unsupported error. Vulkan VUID.
…ometry shader A PS translated with --bary-fallback (ItsNotRexed#804) reads its raw barycentrics from an input location (bary_fallback_input in the index), and nothing in the layer wrote it. create_graphics now builds the pass-through GS that tools/bary_fallback_gs.py writes for the GPU tests (runtime/src/bary_fallback_gs.h): Position, the linked PS's input locations and the VS's clip/cull distance arrays copied per vertex, and the one-hot barycentrics. A PSO with its own GS, a non-triangle topology, no geometryShader, a VS writing Layer/ViewportIndex or a PS with PerVertexKHR inputs is E_NOTIMPL with a log. Tests: bary_fallback_gs_test (module interface, clip/cull forwarding, refusals; spirv-val on the generated modules), d3d12_bary_fallback_test (a stand-in PS drawn through a PSO: every covered pixel holds its barycentrics), shader_library_test (the new index fields). The C++ module matches the Python template instruction for instruction. RX 5700 XT, AMD 26.11.2, Windows 11: ctest 159/159; the new D3D12 test also passes under the Khronos validation layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4291ad5 to
267a0db
Compare
|
Rebased onto
Re-tested on the RX 5700 XT (AMD 26.11.2, Windows 11): full Thanks @Kam471, @whattheflop, @SweatierKey, @MKmajster and @Vonsek for the runs on NVIDIA, RDNA2 and Linux. AI-assisted (Claude Code). |
|
Tested the rebased I also extended the synthetic barycentric draw locally to check the interaction introduced by the rebase. The test masks only the native D24 attachment capability in the test device's format query. The runtime then uses a real The only local code change for the extension is in the synthetic test. AI-assisted. |
|
Tested 267a0db (already contains main 98fa503) on Windows 11, RTX 4080 SUPER + Intel UHD 770 (MSVC 14.51): pass. Full runtime build.
|
Claimed in #4084 (#4084 (comment)), new D3D item: the runtime half of the barycentric fallback.
What
A PS translated with
--bary-fallback(#804) reads its raw barycentrics from an ordinary vec3 input, at the location its index entry gives asbary_fallback_input. On a device withoutVK_KHR_fragment_shader_barycentric(RDNA1 on AMD's Windows driver and on RADV, GCN on RADV, NVIDIA Pascal) that is the only way those shaders run: 321 of the game's pixel shaders read the pair. Nothing inruntime/wrote that input, so the GPU tests drew these shaders (withtools/bary_fallback_gs.py) and a PSO could not.create_graphicsnow adds the pass-through geometry shader when the PSO's PS hasbary_fallback_input:runtime/src/bary_fallback_gs.hbuilds it as SPIR-V words: the moduletools/bary_fallback_gs.pywrites (Position and the PS's vec4 inputs copied per vertex, (1,0,0) / (0,1,0) / (0,0,1) at the barycentric location). For the same input the two modules have the same instructions in the same order; only the id numbering differs.link_f16_halves, which can move a PS's decoded-half inputs, and not from the index. The VS'sClipDistance/CullDistancearrays are forwarded too, from the index'sclip_distance_count/cull_distance_count, both at once if the VS writes both.E_NOTIMPLand a log: a PSO that has its own GS, a non-triangle topology, a device withoutgeometryShader, a VS that writesLayer/ViewportIndex(a GS can't read those to forward them), and a PS withPerVertexKHRinputs.ShaderEntryreadsbary_fallback_input, the two distance counts, and whether the VS writesLayer/ViewportIndex(from itscapabilities).#3898 and #3332 change the GS template in
tools/bary_fallback_gs.py. If either lands first, I'll mirror the change inbary_fallback_gs.h.Tests
On an RX 5700 XT (RDNA1, no barycentric extension), AMD Adrenalin 26.11.2, Vulkan 1.4.315, Windows 11. The full run was at aa2988c. After the rebase onto 03b09a0, this change's tests and the D3D12 draw, geometry and f16-halves tests passed again:
bary_fallback_gs_test(CPU): the module's interface and one-hot constants, clip/cull forwarding, locations taken from the PS module, and each refusal. CMake runsspirv-valon four generated modules (plain, no inputs, clip, clip+cull) where the Vulkan SDK has it: all valid.d3d12_bary_fallback_test(GPU): a GLSL stand-in with a translated PS's interface, drawn through a PSO. The 2016 pixels inside the triangle hold the barycentrics of their centre within 2/255, plus the VS output at location 0. The 2016 pixels outside stay clear. The line-topology, own-GS and Layer-VS PSOs are refused. It passes withLEONIDA_VK_VALIDATION=1too, with no messages.shader_library_test: the new index fields.ctest: 159/159 passed. 10 more skipped here because they need game files or something this machine lacks.tests/test_bary_fallback_gs.py(27) andtests/test_ctest_registration.py(4) pass.No game files were used. AI-assisted (Claude Code).