WIP: Fix invalid SPIR-V in mesh shader compute fallback #1341

Closed
MikeMuratore wants to merge 1 commit from fix-pascal-fallback-spirv into main
MikeMuratore commented 2026-11-09 22:10:19 +00:00 (Migrated from github.com)

Fix invalid SPIR-V in the compute fallback used by GPUs without mesh shaders

On a GTX 1070, the game repeatedly stopped at a black screen after the intro. The NVIDIA driver raised access violation 0xc0000005 in vkCreateComputePipelines for the task stage of program a5da9f84b72d1471. Removing forced subgroup selection alone did not resolve it.

The fallback-generated modules contained four validation defects:

  • Byte offsets used as push-constant structure member indices.
  • Missing Aligned operands on physical-storage-buffer loads and stores.
  • A boolean stored directly into a u32 physical buffer.
  • Function variables declared outside the beginning of the entry block.

This draft adds a compatibility repair at shader module creation, limited to modules the translator explicitly names mesh_fallback_records. It covers cached and newly generated modules without invalidating the shader cache. A direct fix in the emitters may be preferable for the final upstream implementation; feedback on that approach is welcome.

Validation and gameplay evidence:

  • The tested diagnostic renderer was built against v2.0.9 (b784c68), with no compilation failures.
  • Read-only inspection covered 1,302 cached fallback program records and 1,566 unique shader modules. The repair changed 549 unique modules.
  • All corrected modules passed Khronos SPIRV-Tools v2026.4 validation for Vulkan 1.3 with uniform-buffer-standard-layout enabled, matching a feature enabled by the runtime on the test system.
  • The native C++ repair produced byte-for-byte identical outputs to all 1,566 validator-tested modules.
  • The first targeted repair allowed both task and mesh stages of a5da9f84b72d1471 to compile successfully. The next program, 507e946d64f2d55e, exposed the same failure pattern.
  • The general repair got the user into Kokiri Forest. After resolving a separate Windows commit-limit failure with additional page-file capacity and lower game settings, the user reported progressing almost through Kokiri Forest.

Test system: GTX 1070 8 GB, i7-6700K, 16 GB RAM, Windows 10 22H2. This does not establish full-game stability or compatibility with every GTX 10-series card, AMD, Intel, or Linux.

The focused patch is based on upstream main 7dbdcdc. Its application to that revision is checked locally. That cleaned-up current-main integration has not been rebuilt or gameplay-tested yet. The tested build also retained diagnostic logging and the earlier subgroup-selection experiment; those extra changes are omitted from this focused PR. Further testing with upstream's subgroup selection retained is needed.

No game assets, executable builds, shader binaries/caches, keys, or saves are included. Validation summaries contain counts only. Page-file changes are local troubleshooting and are not part of the patch.

Implementation and shader analysis were assisted by Codex; gameplay testing was performed by the author on the hardware above.

Fix invalid SPIR-V in the compute fallback used by GPUs without mesh shaders On a GTX 1070, the game repeatedly stopped at a black screen after the intro. The NVIDIA driver raised access violation 0xc0000005 in vkCreateComputePipelines for the task stage of program a5da9f84b72d1471. Removing forced subgroup selection alone did not resolve it. The fallback-generated modules contained four validation defects: - Byte offsets used as push-constant structure member indices. - Missing Aligned operands on physical-storage-buffer loads and stores. - A boolean stored directly into a u32 physical buffer. - Function variables declared outside the beginning of the entry block. This draft adds a compatibility repair at shader module creation, limited to modules the translator explicitly names mesh_fallback_records. It covers cached and newly generated modules without invalidating the shader cache. A direct fix in the emitters may be preferable for the final upstream implementation; feedback on that approach is welcome. Validation and gameplay evidence: - The tested diagnostic renderer was built against v2.0.9 (b784c68), with no compilation failures. - Read-only inspection covered 1,302 cached fallback program records and 1,566 unique shader modules. The repair changed 549 unique modules. - All corrected modules passed Khronos SPIRV-Tools v2026.4 validation for Vulkan 1.3 with uniform-buffer-standard-layout enabled, matching a feature enabled by the runtime on the test system. - The native C++ repair produced byte-for-byte identical outputs to all 1,566 validator-tested modules. - The first targeted repair allowed both task and mesh stages of a5da9f84b72d1471 to compile successfully. The next program, 507e946d64f2d55e, exposed the same failure pattern. - The general repair got the user into Kokiri Forest. After resolving a separate Windows commit-limit failure with additional page-file capacity and lower game settings, the user reported progressing almost through Kokiri Forest. Test system: GTX 1070 8 GB, i7-6700K, 16 GB RAM, Windows 10 22H2. This does not establish full-game stability or compatibility with every GTX 10-series card, AMD, Intel, or Linux. The focused patch is based on upstream main 7dbdcdc. Its application to that revision is checked locally. That cleaned-up current-main integration has not been rebuilt or gameplay-tested yet. The tested build also retained diagnostic logging and the earlier subgroup-selection experiment; those extra changes are omitted from this focused PR. Further testing with upstream's subgroup selection retained is needed. No game assets, executable builds, shader binaries/caches, keys, or saves are included. Validation summaries contain counts only. Page-file changes are local troubleshooting and are not part of the patch. Implementation and shader analysis were assisted by Codex; gameplay testing was performed by the author on the hardware above.
NotRexed commented 2026-11-09 22:50:41 +00:00 (Migrated from github.com)

Closing as superseded by #1314, which fixes the same four fallback SPIR-V defects (push member index, the bool stored as u32, Aligned on the PhysicalStorageBuffer accesses, spirv-val clean) in the emitters themselves, with a GTX 1070 test. #1314 is in the current test batch. If your GTX 1070 still crashes once it lands, please reopen or comment with the log. Thanks!

Closing as superseded by #1314, which fixes the same four fallback SPIR-V defects (push member index, the bool stored as u32, `Aligned` on the PhysicalStorageBuffer accesses, spirv-val clean) in the emitters themselves, with a GTX 1070 test. #1314 is in the current test batch. If your GTX 1070 still crashes once it lands, please reopen or comment with the log. Thanks!
Commenting is not possible because the repository is archived.
No description provided.