Erhe quest shader failure

From tksuoran/erhe · View interactive version

Erhe quest shader failure is an AI agent skill from the GitHub repository tksuoran/erhe. Triage erhe editor aborts on Quest where vkCreateShaderModule fails with spirv-val (VUID-VkShaderModuleCreateInfo-pCode-08737), or any Shader_stages compile/link error. Identifies which shader / stage failed by reading the immediately-preceding "Creating shader module" log line, then maps known VUID

How to use this skill

Skill file

Quest shader failure triage

When the validation layer rejects a SPIR-V module inside vkCreateShaderModule, the editor's device-error callback aborts via ERHE_FATAL (the device_message lambda in editor.cpp; search for Message_severity::error). Identifying the failing shader is the first step before deciding whether the cause is in our shader source, in the SPIR-V cache, or in glslang itself.

Step 1: pull logs and identify the failing shader

$LOCALAPPDATA/Android/Sdk/platform-tools/adb.exe logcat -d -v time \
  | grep -E "Creating shader module|VALIDATION ERROR|Abort message|spirv-val produced"

erhe::graphics::Shader_stages_impl::create_shader_module logs Creating shader module: <name> <stage> immediately before each vkCreateShaderModule call - at info level while the validation layer is enabled (the case this skill triages), at trace level otherwise (see vulkan_shader_stages.cpp). The last such log line preceding the VALIDATION ERROR is the shader+stage that tripped the validator. Example:

[I] Creating shader module: visualize_depth fragment
[E] VALIDATION ERROR [a5625282 VUID-VkShaderModuleCreateInfo-pCode-08737] vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
[E] NonSemantic.Shader.DebugInfo.100 DebugGlobalVariable: expected operand Variable must be a result id of OpVariable or OpConstant or DebugInfoNone
[E]   %680 = OpExtInst %void %1 DebugGlobalVariable %681 %644 %36 %uint_133 %uint_0 %34 %681 %679 %uint_8

Failing shader: visualize_depth fragment. Failing instruction: DebugGlobalVariable whose Variable operand (%679) is not in the spec's allowed set.

Step 2: map the VUID

`VUID-VkShaderModuleCreateInfo-pCode-08737` with `DebugGlobalVariable`

Cause: glslang 16.x emits DebugGlobalVariable with Variable = OpConstantComposite / OpSpecConstantComposite for global const composites and the synthesised gl_WorkGroupSize. The fix lives in the tksuoran/glslang fork (branch erhe) pinned by CMakeLists.txt's glslang CPMAddPackage (CPM PATCHES is banned repo-wide); it substitutes DebugInfoNone and resolves this for every shader.

If a fresh shader you just added still fails:

  1. Check it's not a stale cache. The cache key includes GLSLANG_VERSION_*, but if you bypassed the version bump and only changed SpvOptions, bump the trailing vN tag in Spirv_cache::make_settings_salt and uninstall + install on device to wipe /data/data/<pkg>/files/spirv_cache/.
  2. Check the fork fix is in the active build. Inspect .cpm_cache/glslang/<hash>/SPIRV/SpvBuilder.cpp for variableOperand; if missing, delete the cache + the corresponding _deps/glslang-* dirs and rebuild so CPM re-clones the pinned tksuoran/glslang commit.
  3. Disassemble the SPIR-V to identify %679 (or whatever the validator points at):

```

"$VULKAN_SDK/Bin/spirv-dis.exe" <cached.spv> | grep -B2 "%679 ="

```

If it's an OpConstantComposite, the fork fix should have caught it -- check (2). If it's something else (e.g. OpSpecConstantOp), this is a different glslang bug; see doc/reference/glslang_bug_report_debugglobalvariable.md for the related glslang #4186 family.

NEVER disable NonSemantic.Shader.DebugInfo.100 in glsl_to_spirv.cpp SpvOptions to silence this. The runtime debug info is wanted, the validation layer is wanted, and per-shader / per-bug fixes are the agreed approach. (Standing user decision.)

`VUID-VkShaderModuleCreateInfo-pCode-08737` without `DebugGlobalVariable`

Different VUID body, same enclosing VUID number. Read the actual spirv-val produced an error: <body> line carefully. Common variants:

`VUID-VkDeviceCreateInfo-pNext-02829`

Aliased feature struct in pNext chain (e.g. VkPhysicalDeviceVulkan11Features + VkPhysicalDevice16BitStorageFeatures). Fixed in commit 524888f8; if it returns, search vulkan_device_init.cpp for newly-added pNext entries that the 1.1 / 1.2 / 1.3 Features struct subsumes.

Generic `Shader compilation/linking failed`

Editor aborts via ERHE_FATAL("Shader compilation/linking failed ...") in editor.cpp. The GLSL error log + source go to logs/shader_error.txt under ERHE_AI_DRIVER=1 (the clipboard otherwise); on device, grep logcat for the GLSL ERROR: lines. Most often a typo, a missing extension declaration, or a layout/binding mismatch with the C++ side's bind_group_layout.

Step 3: rebuild + re-test

After applying a source-level fix:

  1. scripts\build_android.bat quest
  2. Force-stop + install (or uninstall + install if the salt didn't change and you suspect the cache is stale).
  3. Launch via the headset-prompt protocol (see erhe-quest-launch).
  4. Re-grep logcat to confirm the offending shader name no longer appears in the Abort message.

Cross-references

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.