Open wicast opened 1 year ago
This is great stuff!
YuAo/MetalLibraryArchive
looks a lot more complete than our Wiki page and mtl-info
(a cli tool in rust I found a while back).
- [ ] the llvm ir manipulation tool, there are some crates but relies on llvm-sys: Inkwell, llvm-ir. I haven't found any pure rust impl yet. Related issues: https://github.com/gfx-rs/wgpu/issues/4301
I bumped into https://github.com/woodruffw/mollusc a few days ago while I was looking for pure rust LLVM-IR crates.
But some of the local variable names are missing when compiles a complex shader: debug-symbol-terrain.wgsl and debug-symbol-terrain.spvasm. This needs more investigations.
The reason for this is that let
declarations become 'named expressions' and right now, we only add debug info to statements.
DXIL also makes use of LLVM's debug info (see SourceLevelDebuggingHLSL)
SPV
The inital debuggable spv-out is already merged, which can be used with renderdoc. Works fine with WGSL as source code.
But some of the local variable names are missing when compiles a complex shader: debug-symbol-terrain.wgsl and debug-symbol-terrain.spvasm. This needs more investigations.
See spec for more information: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpLine https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpString
TODOs:
Metal
.metallibsym
.metallibsym
is the Metal Companion Symbol file according to Apple doc.But with the help of https://github.com/YuAo/MetalLibraryArchive
I found that the
.metallibsym
is acturally a.metallib
with debug info + source code archive. They have the same structure. MetalLibraryArchive can unpack.metallibsym
directly.debug symbol
the full metal shader symbol should generate by
-gline-tables-only
and-frecord-sources
as the Xcode shows:-gline-tables-only
is a clang's parameter and the good news is metal is using llvm's debug info directly.BTW: The metal shader compiler support lots of clang parameters like
-g
,-O0
, etc.source code
source code is compressed with Bzip2 and embedded in the
.metallib
MetalLibraryArchive can unpack the source code data from
.metallib
.Other metallib reverse engine resource I found: https://worthdoingbadly.com/metalbitcode/
What's missing for generating debuggable
.metallib
.metallib
accept source code other than.metal
? We need to do some tests.DX/HLSL ecosystem
TODO Not investigated yet.