microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.06k stars 677 forks source link

[SPIR-V] Debug info should use DebugBuildIdentifier and DebugStoragePath with -Fd flag #4501

Open baldurk opened 2 years ago

baldurk commented 2 years ago

This is a request for the NonSemantic.Shader.DebugInfo.100 SPIR-V debug info to use the DebugBuildIdentifier and DebugStoragePath opcodes to support split debuginfo files. For context how it works on the DXIL path:

The -Fd flag allows the user to specify a directory where unstripped debug-info filled copy of the shader will be saved before the actual output via -Fo contains only the stripped shader. (The reverse is -Qembed_debug which is the implicit default, with a warning when not explicitly stated).

The filename in the directory is generated based on a hash of the shader. Depending on the -Zsb or -Zss flags that hash either does or doesn't consider the input shader source or debug info itself - allowing debug info to be potentially shared among shader variants that differ in the source but compile to the same executable instructions. (Note: -Zsb only considering the output shader and not the source/debug info corresponds to the IdentifierPossibleDuplicates flag in DebugBuildIdentifier).

The stripped shader still contains the hash identifier (via DebugBuildIdentifier), and optionally the directory's path on the user's machine (via DebugStoragePath). This allows tools at a later date to look up the unstripped debug shader on disk without needing to keep all the debug info embedded as an application loads it into memory and passes it to the vulkan implementation for processing. The identifier and path are separate to allow for relocation - the user could configure a tool with alternate search directories to locate the same debug file (identified by that hash).

kuhar commented 2 years ago

This is assigned to @greg-lunarg.