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:
- Check it's not a stale cache. The cache key includes
GLSLANG_VERSION_*, but if you bypassed the version bump and only changedSpvOptions, bump the trailingvNtag inSpirv_cache::make_settings_saltand uninstall + install on device to wipe/data/data/<pkg>/files/spirv_cache/. - Check the fork fix is in the active build. Inspect
.cpm_cache/glslang/<hash>/SPIRV/SpvBuilder.cppforvariableOperand; if missing, delete the cache + the corresponding_deps/glslang-*dirs and rebuild so CPM re-clones the pinnedtksuoran/glslangcommit. - 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:
DebugTypeArray: Component Count must be ...-- glslang #4186 (open upstream), affects spec-constant-sized arrays. Workaround: avoid the spec-constant arithmetic in array dimensions, or omit debug info for that one shader (last resort).
`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:
scripts\build_android.bat quest- Force-stop + install (or uninstall + install if the salt didn't change and you suspect the cache is stale).
- Launch via the headset-prompt protocol (see
erhe-quest-launch). - Re-grep logcat to confirm the offending shader name no longer appears in the
Abort message.
Cross-references
doc/reference/glslang_bug_report_debugglobalvariable.md-- root-cause writeup of the recurringDebugGlobalVariablefamily of issues.- The
glslangCPMAddPackagein the rootCMakeLists.txt-- thetksuoran/glslangfork pin that carries the fix. doc/quest.mdsection "Vulkan validation layer" -- end-to-end guide for enabling the validation layer.erhe-quest-validationskill -- enable validation if it isn't on yet.erhe-quest-launchskill -- canonical build/install/launch sequence + headset prompt rule.