Skip to content

fix(kyty): place mesh per-primitive built-ins in a Block struct - #328

Merged
simnJS merged 1 commit into
simnJS:AnyKytyfrom
birdmarty:fix/kyty-mesh-per-primitive-block
Nov 26, 2026
Merged

simnJS merged 1 commit into
simnJS:AnyKytyfrom
birdmarty:fix/kyty-mesh-per-primitive-block

Conversation

@birdmarty

@birdmarty birdmarty commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Place MeshEXT PerPrimitiveEXT built-in outputs (BuiltIn CullPrimitiveEXT, and BuiltIn Layer when the shader exports layer) inside a Block-decorated OpTypeStruct array (gl_MeshPerPrimitiveEXT / gl_MeshPrimitivesEXT) with member-level BuiltIn and PerPrimitiveEXT decorations instead of emitting standalone OpVariable output arrays.

On AMD's Windows Vulkan driver (amdvlk64.dll 26.10.1 / 2.0.353 on RX 6800), vkCreateGraphicsPipelines crashes with an access violation (0xc0000005, read of 0x4 at amdvlk64.dll+0x21f30d1) when compiling a MeshEXT shader that declares BuiltIn Layer with PerPrimitiveEXT as a standalone OpVariable (reproduced in both VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT pipeline libraries and whole graphics pipelines, including with a minimal 20-line synthetic MeshEXT shader). Moving the per-primitive built-ins into a Block struct matches GL_EXT_mesh_shader / glslang, validates cleanly under spirv-val and VK_LAYER_KHRONOS_validation, compiles without crashing, and routes culled and layered primitives to the expected render target layers.

Adds:

  • kyty_shim_mesh_per_primitive_block — wave64 SPIR-V codegen and spirv-val checks for host subgroup sizes 32 and 64, both with and without layer export.
  • kyty_shim_mesh_per_primitive_block_draw — uses the device's actual props11.subgroupSize (with VkPhysicalDeviceMeshShaderPropertiesEXT limits check), builds both pre-rasterization pipeline libraries and whole graphics pipelines for both the layered 2-member Block struct ({CullPrimitiveEXT, Layer}) and cull-only 1-member Block struct ({CullPrimitiveEXT}), and runs dynamic-cull draws controlled by push-constant user data (s8/s9) across all cull combinations with 2-layer pixel readback.
  • Scoped llvmpipe exclusion (driverID == eMesaLlvmpipe && driverVersion <= VK_MAKE_API_VERSION(0, 26, 2, 4) in MeshPerPrimitiveBlock.cpp, returning exit code 77 with the device has no ...) because Mesa 25.2.8 / LLVM 20.1.2 llvmpipe still aborts with LLVM ERROR: Cannot emit physreg copy instruction even with subgroupSize = 8 (lane_count = 1, no GroupNonUniformBallot), matching 1d69682 / Mesa #14376. Not listed in tools/lavapipe_skip.txt, so offline CI runs the fixture and records the version-specific skip.

Tested

Machine: Windows 11 Pro (10.0.26300), Intel Core i9-9900K, AMD Radeon RX 6800 (vendor 0x1002, device 0x73bf), AMD proprietary driver 26.10.1 (2.0.353, Vulkan 1.4.315), Vulkan SDK 1.4.363.0 (VK_LAYER_KHRONOS_validation).

  • New regression tests with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT, and VK_LOADER_DEBUG=layer (confirmed VK_LAYER_KHRONOS_validation inserted at instance and device):
    • Without this fix (ea03d75): kyty_shim_mesh_per_primitive_block fails (BuiltIn Layer must not be a standalone output variable); kyty_shim_mesh_per_primitive_block_draw crashes with SEGFAULT in amdvlk64.dll (0 VUID- lines).
    • With this fix: both kyty_shim_mesh_per_primitive_block and kyty_shim_mesh_per_primitive_block_draw pass on AMD Radeon RX 6800 with 0 VUID- and 0 SYNC- findings:
    Start 1766: kyty_shim_mesh_per_primitive_block
1766: kyty_shim_mesh_per_primitive_block: ok
1/2 Test #1766: kyty_shim_mesh_per_primitive_block ........   Passed    1.42 sec
    Start 1767: kyty_shim_mesh_per_primitive_block_draw
1767: [Vulkan Loader] INFO | LAYER:   Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)
1767: [Vulkan Loader] INFO | LAYER:   Inserted device layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)
1767: [Vulkan Loader] DRIVER:                Using "AMD Radeon RX 6800" with driver: "C:\WINDOWS\System32\DriverStore\FileRepository\u0205305.inf_amd64_0a0a37c758a0b24b\B026653\amdvlk64.dll"
1767: kyty_shim_mesh_per_primitive_block_draw: ok, subgroup=64 gpl=on dynamic-cull+layer passed on AMD Radeon RX 6800 (AMD proprietary driver, 26.10.1 (AMD proprietary shader compiler))
2/2 Test #1767: kyty_shim_mesh_per_primitive_block_draw ...   Passed    0.67 sec
100% tests passed, 0 tests failed out of 2
  • CI llvmpipe (Ubuntu 24.04, Mesa 25.2.8 / LLVM 20.1.2, subgroupSize = 8):
    • Before scoping the exclusion, tested the updated fixture using actual props11.subgroupSize = 8 (lane_count = 1, words=757 layered + words=673 cull-only dynamic-cull shaders, 0 VUID- / SYNC- errors): llvmpipe still aborted with LLVM ERROR: Cannot emit physreg copy instruction.
    • With the scoped llvmpipe exclusion in MeshPerPrimitiveBlock.cpp and tools/lavapipe_skip.txt untouched: kyty_shim_mesh_per_primitive_block passes (0.01 sec), kyty_shim_mesh_per_primitive_block_draw exits 77 (kyty_shim_mesh_per_primitive_block_draw: skipped, the device has no mesh shader compiler that handles these programs (llvmpipe Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2))), check_skips.py reports skipped: kyty_shim_mesh_per_primitive_block_draw: expected, and the Khronos validation + synchronization validation pass finishes 95 tests passed, 2 skipped, 0 failed.
  • Focused shader tests compared on ea03d75 vs this branch with the same validation layer settings: kyty_shim_merged_hull, kyty_shim_recompiler_robustness, kyty_shim_recompiler_valid_spirv, kyty_shim_shader_store_encode, kyty_shim_wave_split_codegen, and kyty_shim_pair_codegen all pass on both with 0 VUID- lines (kyty_shim_merged_hull_draw fails identically on both ea03d75 and this branch with 0 of 4096 pixels, 0 VUID- lines).
  • Conventions and hygiene checks: tools/check_conventions.py --base origin/AnyKyty, tools/check_kyty_settings.py, tools/debt_fold.py --check, and tools/check_emutls_imports.py build/core/libs/libs all pass.
  • Lies of P (PPSA10621 01.012.000, [game test] Lies of P PPSA10621 01.012.000 #283):
    • Without this fix (7de61e3 and ea03d75): crashes at boot with 0xc0000005 (read of 0x4, amdvlk64.dll+0x21f30d1) when compiling stage=MS shader=d95bc66607ad635f, in both default GPL mode and KYTY_PIPELINE_LIBRARIES=0, with 0 VUID- lines under VK_LAYER_KHRONOS_validation / KYTY_VULKAN_VALIDATION=1.
    • With this fix: cold boot (60 s, flips 1007), warm boot (45 s, loaded 64 programs, 81 modules, 60 pipelines in 12 ms, flips 423), and cold boot with KYTY_VULKAN_VALIDATION=1 + VK_LOADER_DEBUG=layer (60 s, flips 1018, 0 VUID- lines) all compile d95bc66607ad635f, switch to 3200x1800, and sustain ~60 FPS with no crash. With KYTY_PIPELINE_LIBRARIES=0, the amdvlk64.dll+0x21f30d1 crash is also gone (gets past d95bc66607ad635f and 3200x1800), though a separate VK_ERROR_DEVICE_LOST occurs later in that non-default mode at tick 9–11.
  • Not tested: Linux / RADV, AMD Adrenalin 26.11.1, NVIDIA or Intel GPUs, console behaviour.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: Fixes [game test] Lies of P PPSA10621 01.012.000 #283
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6800, AMD proprietary driver 26.10.1 (2.0.353), Windows 11 Pro 26300
  • AI-assisted: yes (Antigravity)

@birdmarty birdmarty mentioned this pull request Nov 26, 2026
2 of 3 tasks

@simnJS simnJS left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SPIR-V check passes, but the draw aborts with LLVM ERROR: Cannot emit physreg copy instruction on both Linux jobs. Please use the actual supported mesh subgroup size in the draw fixture and check the dynamic cull case on the CI driver. If the driver still aborts, please verify a driver update or scope an exclusion to the affected configuration in both jobs, including offline CI’s skip check. Keep the wave64 SPIR-V checks for host sizes 32 and 64, with and without layer export, and attach the AMD validation run for the updated draw and pipeline library.

@birdmarty
birdmarty force-pushed the fix/kyty-mesh-per-primitive-block branch from 852e455 to 68da14a Compare November 26, 2026 17:26
@birdmarty

Copy link
Copy Markdown
Contributor Author

Addressed all review items in 68da14a and updated the PR description:

  1. Actual supported mesh subgroup size in the draw fixture: DrawMeshPerPrimitiveBlock now passes props11.subgroupSize directly (matching pipelineCache.cpp) and verifies VkPhysicalDeviceMeshShaderPropertiesEXT limits (maxMeshWorkGroupInvocations, maxMeshWorkGroupSize[0], maxMeshOutputVertices, maxMeshOutputPrimitives) instead of clamping < 64 to 32.
  2. Dynamic cull coverage on both Block layouts, checked on the CI llvmpipe driver:
    • Added runtime dynamic-cull control via push-constant user data (s8/s9 OR'd into primitive bits) and tested both pipelines (GPL pre-rasterization library + whole graphics pipeline for both {CullPrimitiveEXT, Layer} with 4 cull combinations and {CullPrimitiveEXT} cull-only with 3 cull combinations).
    • Tested this directly on the Ubuntu 24.04 CI llvmpipe driver (Mesa 25.2.8 / LLVM 20.1.2, subgroupSize = 8, lane_count = 1, words=757 layered and words=673 cull-only, no GroupNonUniformBallot): spirv-val and Vulkan validation + synchronization validation reported 0 VUID-/SYNC- errors, and llvmpipe still aborted with LLVM ERROR: Cannot emit physreg copy instruction (the same Mesa #14376 / 1d69682 llvmpipe mesh shared-memory JIT abort).
  3. Scoped llvmpipe exclusion in both jobs + offline CI skip check:
    • Scoped the skip in MeshPerPrimitiveBlock.cpp to driverID == vk::DriverId::eMesaLlvmpipe && driverVersion <= VK_MAKE_API_VERSION(0, 26, 2, 4) (covering Mesa 25.2.8 / LLVM 20.1.2 and Mesa 26.2.4 / LLVM 23.1 from 1d69682 without affecting hardware GPUs or future fixed Mesa releases), printing a skipped, the device has no mesh shader compiler that handles these programs (llvmpipe ...) reason and returning 77.
    • Added kyty_shim_mesh_per_primitive_block_draw to tools/lavapipe_skip.txt for tools/lavapipe_tests.sh / offline CI's skip check.
  4. Wave64 SPIR-V checks kept: kyty_shim_mesh_per_primitive_block still checks wave64 SPIR-V codegen and spirv-val for host subgroup sizes 32 and 64, with and without layer export.
  5. AMD RX 6800 validation run for the updated draw + pipeline library (ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT, VK_LOADER_DEBUG=layer — 0 VUID- and 0 SYNC- findings):
    Start 1766: kyty_shim_mesh_per_primitive_block
1766: kyty_shim_mesh_per_primitive_block: ok
1/2 Test #1766: kyty_shim_mesh_per_primitive_block ........   Passed    1.42 sec
    Start 1767: kyty_shim_mesh_per_primitive_block_draw
1767: [Vulkan Loader] INFO | LAYER:   Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)
1767: [Vulkan Loader] INFO | LAYER:   Inserted device layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)
1767: [Vulkan Loader] DRIVER:                Using "AMD Radeon RX 6800" with driver: "C:\WINDOWS\System32\DriverStore\FileRepository\u0205305.inf_amd64_0a0a37c758a0b24b\B026653\amdvlk64.dll"
1767: kyty_shim_mesh_per_primitive_block_draw: ok, subgroup=64 gpl=on dynamic-cull+layer passed on AMD Radeon RX 6800 (AMD proprietary driver, 26.10.1 (AMD proprietary shader compiler))
2/2 Test #1767: kyty_shim_mesh_per_primitive_block_draw ...   Passed    0.67 sec
100% tests passed, 0 tests failed out of 2

AI-assisted: yes (Antigravity).

@simnJS simnJS left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The subgroup change, both block layouts and the AMD validation run address the earlier fixture feedback. Please remove the unconditional draw entry in tools/lavapipe_skip.txt so offline CI runs the fixture and records its version-specific skip. Its the device has no reason already matches the skip checker. Please confirm the output on the affected runner and keep the wave64 structural check enabled.

Place MeshEXT PerPrimitiveEXT built-in outputs (CullPrimitiveEXT and,
when exported, Layer) inside a Block-decorated OpTypeStruct array
(gl_MeshPerPrimitiveEXT / gl_MeshPrimitivesEXT) with member-level
BuiltIn and PerPrimitiveEXT decorations instead of standalone output
array variables.

On AMD's Windows Vulkan driver (amdvlk64.dll 26.10.1 / 2.0.353 on RX
6800), compiling a MeshEXT pipeline whose PerPrimitiveEXT BuiltIn Layer
is a standalone OpVariable crashes inside vkCreateGraphicsPipelines
(0xc0000005, read of 0x4) in both pre-rasterization pipeline libraries
and whole pipelines. Grouping per-primitive built-ins in a Block struct
matches GL_EXT_mesh_shader / glslang, passes spirv-val and
VK_LAYER_KHRONOS_validation with zero errors, and compiles and renders
correctly.
@mjnhbg3

mjnhbg3 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

I prepared the requested one-line skip-list fix against this PR's exact head 68da14a: birdmarty/AnyKyty#1. It removes the unconditional kyty_shim_mesh_per_primitive_block_draw exclusion, so offline CI will run the fixture and record its existing version-specific device skip on affected llvmpipe.

The companion diff is one deletion. Conventions and the skip-reason policy check pass locally; the original PR's affected Linux runner still needs to run after this is merged into the branch. The committed overlap audit reports only #335's workflow overlap inherited from this PR.

@birdmarty
birdmarty force-pushed the fix/kyty-mesh-per-primitive-block branch from 68da14a to 5d427a9 Compare November 26, 2026 19:09
@birdmarty

Copy link
Copy Markdown
Contributor Author

Removed kyty_shim_mesh_per_primitive_block_draw from tools/lavapipe_skip.txt in 5d427a9 (tools/lavapipe_skip.txt is untouched relative to AnyKyty) and updated the PR description.

Confirmed on the Ubuntu 24.04 Shim GPU tests on lavapipe runner (Mesa 25.2.8 / LLVM 20.1.2):

  • kyty_shim_mesh_per_primitive_block (wave64 structural check) passes (0.01 sec).
  • kyty_shim_mesh_per_primitive_block_draw runs and exits 77 with its version-specific skip:
65/97 Test #1718: kyty_shim_mesh_per_primitive_block ..........   Passed    0.01 sec
66/97 Test #1719: kyty_shim_mesh_per_primitive_block_draw .....***Skipped   0.03 sec
kyty_shim_mesh_per_primitive_block_draw: skipped, the device has no mesh shader compiler that handles these programs (llvmpipe Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2))
skipped: kyty_shim_mesh_per_primitive_block_draw: expected
  • The lavapipe validation + synchronization validation pass finishes 95 tests passed, 2 skipped, 0 failed under the Khronos validation layer with synchronization validation (0 known).

AI-assisted: yes (Antigravity).

@simnJS simnJS left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this revision and validated it together with the other changes in the integration branch. The Linux, Windows, sanitizer, and offline checks passed on the exact candidate.

@simnJS
simnJS merged commit 7a437b0 into simnJS:AnyKyty Nov 26, 2026
13 of 14 checks passed
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.

[game test] Lies of P PPSA10621 01.012.000

3 participants