Repository navigation
Translator: zero-based VS v0/v3 (VertexIndex - BaseVertex, InstanceIndex - BaseInstance); VS is legacy, not NGG (SHADER-33) - #436
Conversation
fd9aeed to
de5da76
Compare
|
GPU test of #436 at
AI-assisted (Claude Code). |
|
Tested de5da76 on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass.
Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0. |
|
Tested de5da76 on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass
No game files used. AI-assisted run (Claude Code). |
|
Tested
I did not run the native (non-emulated) suite on this GPU; without emulation the 64-wide tests skip by design. No game files were used. |
|
Tested de5da76 on the 1.0.2.1 package, RTX 4090 (621.14), Win11 26200: the corpus side reproduces on a second copy, and the fix behaves as described. (The earlier 4090 comment covered the GPU suite; this one is the corpus run.)
Translation, all 2,236 VS, this branch vs its parent
AI-assisted (Claude Code). |
|
I exercised the nonzero base through a synthetic guest's regular D3D12 import, including a V# fetch, submission, fence, and RGBA32_FLOAT readback. This pairs the translator at On Windows RTX 5080 and AMD Radeon Graphics, Negative control: in the validated VS module only, substitute raw |
|
I checked the indexed case at For firstIndex 0 the provoking raw index is 32, so the first two output words should be Two separately assembled and validated controls replaced only one subtraction at a time. Keeping raw VertexIndex shifted the two flat words by the signed vertexOffset (−12 / +4). Keeping raw InstanceIndex shifted them by |
…dex - BaseInstance); VS is legacy, not NGG (SHADER-33) Corpus (scripts/vs_input_survey.py, all 2,236 VS): no exp prim, no s_sendmsg, no v_mbcnt, every VS exports pos0/param, so the console runs them as legacy hardware VS. Their input VGPRs are Mesa's GFX10 legacy layout (radv_shader_args.c, declare_vs_input_vgprs, not is_ngg): v0 vertex id, v1 unused, v2 primitive id, v3 instance id; no VS reads v1/v2 on entry, 788 start with the fetch call and read attributes from v4. Those ids are zero-based on the hardware (ac_nir_lower_intrinsics_to_args.c: vertex_id is load_vertex_id_zero_base, instance_id is load_instance_id; the bases come in SGPRs), while Vulkan's VertexIndex/InstanceIndex include firstVertex|vertexOffset/firstInstance. The translator now seeds v0 = VertexIndex - BaseVertex and v3 = InstanceIndex - BaseInstance (DrawParameters; feature shaderDrawParameters in every VS's metadata). GPU test vs_base_ids.asm, drawn with VKH_DRAW=16,7 (new vk_harness option): 0x101 on every pixel, where before it was 0x7111. Run by check.py and run_gpu_tests.py. vk_harness, vk_pipeline_check, vk_bindless_test, vk_texture_test and the runtime's Vulkan device enable shaderDrawParameters. design.md's "Inputs and outputs" row replaces the "unverified" note. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
de5da76 to
07bd05f
Compare
# Conflicts: # scripts/run_gpu_tests.py # tests/test_shader_checks.py # tools/rdna2spirv.py
|
rebased this onto current main for you, since it's the open half of "VS input layout unverified" and it'd be a shame to lose it to conflicts ^^ branch: what changed:
tested on the rebased branch:
TL;DR: rebased + fixed the 10 semantic tests your change broke, and the new vs_base_ids test passes on a real gpu. branch is ready to pull if you want it. AI-assisted (Claude Code). |
# Conflicts: # runtime/test/shaders/check.py # scripts/run_gpu_tests.py # tests/test_shader_checks.py
|
Thanks @IAmNotSiob for the rebase and for catching the 10 Update: Tested
AI-assisted (Claude Code). |
# Conflicts: # runtime/test/shaders/check.py
# Conflicts: # tests/test_shader_checks.py
|
Tested
This adds a third NVIDIA data point for the measured legacy-VS layout and the zero-based |
# Conflicts: # docs/design.md
|
Tested Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows
The 13 skips are the same on both: the d3d12-run fixtures, plus AI-assisted (Claude Code); I checked the results. |
# Conflicts: # tests/test_shader_checks.py
|
Tested
No game files. AI-assisted (Claude Code). |
What and why
SHADER-33 (#156): confirm the vertex shader input layout, which
docs/design.mdmarked "unverified" (NGG or legacy). It's legacy. Checking it turned up a real translator bug in the same two registers.1. Legacy VS, measured (
scripts/vs_input_survey.py, all 2,236 VS of 1.0.2.1):exp prim, 0s_sendmsg(so noGS_ALLOC_REQ), 0v_mbcnt; every VS exportspos0andparam.radv_shader_args.c,declare_vs_input_vgprs, notis_ngg):v0vertex id,v1unused,v2primitive id,v3instance id. No VS readsv1/v2on entry. 788 start with the fetch call and read attributes fromv4up. Of the other 1,448, 1,052 readv0only, 386 readv0andv3, 10 read neither. An NGG VS would have its inputs atv5/v8.2. Those ids are zero-based on the hardware; Vulkan's aren't. Mesa
ac_nir_lower_intrinsics_to_args.c:vertex_idisload_vertex_id_zero_baseandinstance_idisload_instance_id, with the bases in thebase_vertex/start_instanceSGPRs. Vulkan'sVertexIndex/InstanceIndexincludefirstVertex/vertexOffset/firstInstance, so any draw with a non-zero base gave the shader different ids from the console.runtime/test/shaders/vs_base_ids.asm+ps_flat, drawn with the newvk_harnessoptionVKH_DRAW=16,7(firstVertex, firstInstance):maingives0x7111on every pixel (16 and 7 leaked into v0/v3), this branch gives0x101like the hardware. Wired intocheck.pyandrun_gpu_tests.py.tools/rdna2spirv.py:v0 = VertexIndex - BaseVertex,v3 = InstanceIndex - BaseInstance(SPIR-VDrawParameters). Every VS's metadata now lists the device featureshaderDrawParameters, whichvk_harness,vk_pipeline_check,vk_bindless_test,vk_texture_testand the runtime's Vulkan device (d3d12_vulkan_device.cpp, logged if missing) enable.docs/design.md"Inputs and outputs": the "unverified" note becomes the measured rule, with the references and the GPU check.@Ryx69: this changes what translated VS need from the device (
shaderDrawParameters) and relies on the D3D12 draw's base vertex / first instance reachingvkCmdDraw*unchanged, so it's relevant to D3D-4.Thanks to @eIBart0:
vs_input_survey.pyuses the same straight-line read-before-write rule as #240'sscripts/audit_shader4_regs.py.Tested
Windows 11, RTX 4090 driver 621.24, Vulkan SDK 1.4.363.0,
llvm-mc23.1.5 (MSYS2), MSVC 14.44, onmaind937b7f:vs_base_ids:0x101/0x102on 4096/4096 pixels withVKH_DRAWunset,16,7and1000,3(before the fix:0x7111with16,7).build.py57/57 translated and valid;check.py29 of 53 pass, 24 skipped (wave64 / mesh fixtures), 0 failed;run_gpu_tests.py35/59 passed, 24 skipped, 0 failed.spirv-val;vk_pipeline_checkcreates all 2,236 VS pipelines on the 4090 (1,057 wave32, 1,179 wave64), 0 failed.pytest tests --ignore=tests/semantic1332 passed; semantic tests OK (440);ctest18/18;tests/test_vs_input_survey.pyOK.tests/test_shader_checks.pycounts the new check.AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed (Mesa references and thevs_base_idsGPU test).🤖 Generated with Claude Code