Skip to content

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

Open
birdmarty wants to merge 1 commit into
simnJS:AnyKytyfrom
birdmarty:fix/kyty-mesh-per-primitive-block
Open

birdmarty wants to merge 1 commit into
simnJS:AnyKytyfrom
birdmarty:fix/kyty-mesh-per-primitive-block

Conversation

@birdmarty

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 (SPIR-V codegen and spirv-val check for wave32 and wave64, with and without layer export) and kyty_shim_mesh_per_primitive_block_draw (builds both a pre-rasterization pipeline library and a whole mesh pipeline, draws one culled primitive on layer 0 and one visible primitive on layer 1, and reads back both layers).

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, 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: kyty_shim_mesh_per_primitive_block passes; kyty_shim_mesh_per_primitive_block_draw passes (layer0=0 layer1=16/16 on AMD Radeon RX 6800, 0 VUID- lines).
  • 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)

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.
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

1 participant