Repository navigation
Conversation
|
I checked how this runtime builder handles the two kinds of fallback shader produced by #1426 ( I built
The computed input at location 0 is a flat array of three vec4s. The runtime currently reads only The GPU draws used this PR's |
bff5018 to
31ff719
Compare
|
[KEEP]
|
|
Independent verification (native Windows 11, validation on):
One scope note confirmed independently: this PR does not include #1426's per-vertex attribute mapping ( AI-assisted verification. |
31ff719 to
483f012
Compare
|
Tested
Could the runtime either forward only the locations the pixel shader reads, or refuse with a logged reason when the inputs exceed the limit? The test should then skip case 3 on such devices rather than fail. AI-assisted (Claude Code, Claude Opus 5.5). |
When `tools/rdna2spirv.py --bary-fallback` translates a pixel shader (for GPUs
without `VK_KHR_fragment_shader_barycentric` or drivers with broken
`BaryCoordKHR`), the emitted Fragment SPIR-V reads perspective barycentrics from
an ordinary smooth `vec3<f32>` `Input` recorded under
`"bary_fallback_input": {"location": N}` in `index.json`, while `"inputs"` lists
only the `vec4<f32>` user `param` locations exported by `stubs/vs_<inputs>.spv`.
Previously `vk_pipeline_check` ignored `"bary_fallback_input"` and built a
2-stage `VS_stub + PS` pipeline, leaving `Location N` unwritten by the preceding
stage (`VUID-RuntimeSpirv-OpEntryPoint-08743`), omitting the `geometryShader` /
`shaderClipDistance` / `shaderCullDistance` feature gates, and writing a 2-stage
entry into `pipeline_cache.bin` that misses the runtime's 3-stage `VS + GS + PS`
pipeline key.
- Parse `"bary_fallback_input"` in `vk_pipeline_check`'s `JsonParser` into
`ShaderMeta::bary_fallback_location` (accepting `null` or an object with an
unsigned 32-bit `"location" < 32`, rejecting non-objects, missing `"location"`,
and out-of-range locations with exit code 2 before loading Vulkan).
- Cache each loaded partner stub's SPIR-V words alongside its `VkShaderModule`
in `stub_cache` without re-reading disk per shader.
- Skip `--bary-fallback` `ps` entries with `no geometryShader` when the selected
device lacks `geometryShader`; otherwise synthesize the triangle pass-through
`VK_SHADER_STAGE_GEOMETRY_BIT` module in memory via
`leonida::build_bary_fallback_gs` (`runtime/src/spirv_bary_fallback.h`), gate
forwarded VS `ClipDistance` / `CullDistance` on `shaderClipDistance` /
`shaderCullDistance` before creating the GS module, compile the 3-stage
`VS + GS + PS` graphics pipeline, and fail the check (`PIPELINE FAIL`, exit 1)
if `build_bary_fallback_gs` rejects an incompatible `VS`/`PS` interface.
- Add CTest `vk_pipeline_check_bary_fallback`
(`runtime/test/check_vk_pipeline_bary_fallback.py`), index parser cases in
`tests/test_vk_pipeline_check_index.py`, and documentation in
`docs/pipeline_check.md`.
Depends on: ProjectLeonida#1497
Claim: ProjectLeonida#14 (comment)
AI-assisted: yes (Antigravity)
|
I opened a focused stacked follow-up for the low |
… 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)
483f012 to
53df7d1
Compare
When `tools/rdna2spirv.py --bary-fallback` translates a pixel shader (for GPUs
without `VK_KHR_fragment_shader_barycentric` or drivers with broken
`BaryCoordKHR`), the emitted Fragment SPIR-V reads perspective barycentrics from
an ordinary smooth `vec3<f32>` `Input` recorded under
`"bary_fallback_input": {"location": N}` in `index.json`, while `"inputs"` lists
only the `vec4<f32>` user `param` locations exported by `stubs/vs_<inputs>.spv`.
Previously `vk_pipeline_check` ignored `"bary_fallback_input"` and built a
2-stage `VS_stub + PS` pipeline, leaving `Location N` unwritten by the preceding
stage (`VUID-RuntimeSpirv-OpEntryPoint-08743`), omitting the `geometryShader` /
`shaderClipDistance` / `shaderCullDistance` feature gates, and writing a 2-stage
entry into `pipeline_cache.bin` that misses the runtime's 3-stage `VS + GS + PS`
pipeline key.
- Parse `"bary_fallback_input"` in `vk_pipeline_check`'s `JsonParser` into
`ShaderMeta::bary_fallback_location` (accepting `null` or an object with an
unsigned 32-bit `"location" < 32`, rejecting non-objects, missing `"location"`,
and out-of-range locations with exit code 2 before loading Vulkan).
- Cache each loaded partner stub's SPIR-V words alongside its `VkShaderModule`
in `stub_cache` without re-reading disk per shader.
- Skip `--bary-fallback` `ps` entries with `no geometryShader` when the selected
device lacks `geometryShader`; otherwise synthesize the triangle pass-through
`VK_SHADER_STAGE_GEOMETRY_BIT` module in memory via
`leonida::build_bary_fallback_gs` (`runtime/src/spirv_bary_fallback.h`), gate
forwarded VS `ClipDistance` / `CullDistance` on `shaderClipDistance` /
`shaderCullDistance` before creating the GS module, compile the 3-stage
`VS + GS + PS` graphics pipeline, and fail the check (`PIPELINE FAIL`, exit 1)
if `build_bary_fallback_gs` rejects an incompatible `VS`/`PS` interface.
- Add CTest `vk_pipeline_check_bary_fallback`
(`runtime/test/check_vk_pipeline_bary_fallback.py`), index parser cases in
`tests/test_vk_pipeline_check_index.py`, and documentation in
`docs/pipeline_check.md`.
Depends on: ProjectLeonida#1497
Claim: ProjectLeonida#14 (comment)
AI-assisted: yes (Antigravity)
|
Tested at your current head |
…mponent limits - Prune declared-but-unread PS Input variables on the VS -> GS interface in build_bary_fallback_gs (tracking pointer aliases through OpAccessChain, OpCopyObject, OpSelect, and OpPhi into OpLoad, GLSL.std.450 InterpolateAt*, OpFunctionCall, and OpCopyMemory*), zero-filling unread FSSM table inputs in the synthesized GS instead of reading them from the VS. - Record per-vertex input/output scalar component totals and highest 4 * Location + components bounds (VUID-RuntimeSpirv-Location-06272) in BaryFallbackGsInfo, and check them against maxGeometryInputComponents, maxGeometryOutputComponents, and maxGeometryTotalOutputComponents in create_graphics with explicit [rt] d3d12: refusal diagnostics. - Extend spirv_bary_fallback_test and d3d12_bary_fallback_test to cover unused-input pruning, 10-param f16 relocation within 64 geometry input components, simulated maxGeometryInputComponents=64 acceptance/refusal on any GPU, and clean refusal + draw skip on <120-component devices (such as RADV gfx1036) for the 16-param relocated f16 case. Co-authored-by: ZroFreaks <42916282+ZroIsHere@users.noreply.github.com>
|
Thanks for testing on RADV Updated in
Validated locally on NVIDIA GeForce GTX 1050 Ti (driver 582.28, Windows 10 19045) with AI-assisted: yes |
# Conflicts: # runtime/shims/d3d12_vulkan_device.cpp # runtime/test/d3d12_bary_fallback_test.cpp # runtime/test/spirv_bary_fallback_test.cpp
…(RT-BARY-FALLBACK-PER-VERTEX) ProjectLeonida#1497's precheck compares BaryFallbackGsInfo with maxGeometryInput/OutputComponents, but the info left out the per_vertex blocks: an attribute read only by a block had a GS Input that was not counted, and each vec4[3] output (Locations base..base+2, 12 components, zero-filled or not) was missing from the output bounds. Attribute 16 with its block at 14..16 reported 0/15 while the module needs 68/68, so a 64-component device would get it. Inputs are now counted from the GS's final Input map (a location shared by an ordinary output and a block once), and each block adds 12 output components and its last Location to the output bound. spirv_bary_fallback_test 7i checks 68/68, the 64/64 edge and a zero-filled block; it fails with the old count. Also fixes two leftovers of the ProjectLeonida#1497 merge in the tests: build_ps declared its uint type twice when a PS had both a block and an access chain, and an extra brace closed the D3D12 test's index.json early. Found by @ecox982745 and confirmed on a Vega 20 by @zmasi in ProjectLeonida#1930.
Independent Windows 11 + NVIDIA GeForce RTX 3090 Verification (
|
|
RUN of #1497 (red/green, GPU box, PR head only: it conflicts with main) Heads: PR head Commands (VS 2022 x64 environment, from the worktree root):
Author: this branch conflicts with current main in Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44 (VS 2022 Build Tools), CMake + Ninja, RelWithDebInfo, |
|
I tested a local merge of PR head The other changes merged cleanly. The resulting tree was
AI-assisted with OpenAI Codex (GPT-6.2 Sol). |
Claimed in the coordination issue as: RT-BARY-FALLBACK-PSO (#14 (comment))
What and why
On GPUs without
VK_KHR_fragment_shader_barycentric(for example NVIDIA Pascal),rdna2spirv.py --bary-fallbackemits a pixel shader's raw barycentrics as an ordinary perspective-interpolatedvec3<f32>Inputand records"bary_fallback_input": {"location": N}inspirv/index.json. Offlinetools/bary_fallback_gs.pyalready specified the triangle pass-through geometry shader shape, andPipelineState::create_graphicsalready supported explicit geometry stages (#2109), rectangle-list geometry stages (#984) and per-pipeline--f16-interp-fallbacklinking (spirv_f16_halves.h), butShaderLibrarydid not readbary_fallback_inputandcreate_graphicsdid not insert the pass-through geometry stage — leaving any graphics PSO with a--bary-fallbackPS without a stage writingbary_location.This PR wires
--bary-fallbackpixel shaders end to end into D3D12→Vulkan graphics PSO creation:runtime/src/shader_library.h: parses"bary_fallback_input": {"location": N}(exact non-negativeuint32_t) intoShaderEntry::bary_fallback_location.runtime/src/spirv_bary_fallback.h: pure C++20leonida::build_bary_fallback_gs(vs_words, ps_words, bary_location, gs_words, &info, &error)synthesizing a SPIR-V 1.5Geometrymodule (Trianglesin,Invocations 1,OutputTriangleStrip,OutputVertices 3) for the(VS, PS)pair:BuiltIn Positionacross the three triangle vertices and writes(1, 0, 0),(0, 1, 0),(0, 0, 1)toOutput vec3<f32>atbary_location;vec4<f32>Locationinput the PS declares (other thanbary_location) that the VS exports, leaves unread VS outputs unconsumed onVS -> GS(even if the VS exports an unread output atbary_location), and zero-fills any unexported PSLocationinput viaOpConstantNullwithout declaring a dangling GSInput(VUID-RuntimeSpirv-OpEntryPoint-08743);BuiltIn ClipDistanceorBuiltIn CullDistance(float[1..8]) and forwards it with the matching capability, rejecting mixedClipDistance+CullDistanceandShaderLayer/ShaderViewportIndex.runtime/shims/d3d12_vulkan_device.cpp: inPipelineState::create_graphicsandstage_words(StageSource::bary_fallbackfor lazy graphics pipeline builds), runsbuild_bary_fallback_gsafterlink_f16_halveson the post-link(vs, ps)words (clampingtop_locationagainstmaxGeometryInputComponents/maxGeometryOutputComponents) so relocated/synthesizedf16_halveslocations are forwarded automatically through the GS. Refuses mesh PSOs, explicitdesc.GS, rectangle-list PSOs, disabledgeometryShader/shaderClipDistance/shaderCullDistance(E_NOTIMPLviastream_unsupported), and non-trianglePrimitiveTopologyType(E_INVALIDARG).runtime/CMakeLists.txt,runtime/test/vk_test_device.h,runtime/test/*):shader_library_testwithbary_fallback_inputindex parsing checks;spirv_bary_fallback(spirv_bary_fallback_test.cpp), a portable pure-CPU test covering pass-through locations, unread VS locations, unexported PSFlatzero-fill,ClipDistance[2],CullDistance[3], combinedlink_f16_halves+build_bary_fallback_gs, and clean refusals;shaderClipDistanceandshaderCullDistancewhere available invktest::Deviceand addsd3d12_bary_fallback(d3d12_bary_fallback_test.cpp), exercising real Vulkan GPU draws through the Xbox-ABI proxy.Tested
ctest --output-on-failure -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$", plusLEONIDA_LAZY_GRAPHICS=0andLEONIDA_LAZY_GRAPHICS=1): 3/3 passed on all runs:d3d12_bary_fallbackverified all 256 pixels of: (1) a non-uniform-W (w = 1, 2, 4) triangle checking perspective-correct(b0, b1, b2)+ pass-throughLocation 0(center=(184,49,22,191)vs affine(128,64,64,191)), (2)ClipDistance[1]clippingndc_x < 0while preserving barycentrics onndc_x > 0, (3) a 16-param VS + collidingf16_halves+bary_fallback_inputPSO combininglink_f16_halvesrelocation/synthesis withbuild_bary_fallback_gs, plusE_INVALIDARG/E_NOTIMPLrefusal checks.spirv_bary_fallback_test --dump-dir(gs_basic,gs_unread_vs,gs_zero_fill,gs_clip2,gs_cull3,gs_f16_linked) and validated each withspirv-val --target-env vulkan1.2andspirv-val --target-env vulkan1.3(0 errors).spirv_f16_halves,d3d12_f16_halves,d3d12_geometry,d3d12_translated_draw(4/4 passed).python -I scripts/check_no_game_data.pyon all touched files,tests/test_bary_fallback_gs.py(29),tests/test_ctest_registration.py(5),tests/test_docs_links.py(16),tests/test_docs_table_rows.py(2),git diff --check.VK_LAYER_KHRONOS_validationis not installed on this Windows 10 host; no game shaders or executable were run.GPUs tested: NVIDIA GeForce GTX 1050 Ti (Pascal, 4 GB), driver 582.28, Vulkan 1.4.312, Windows 10 Pro 10.0.19045
AI-assisted: yes (Antigravity)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.