LunarG / VulkanTools

Tools to aid in Vulkan development
Other
676 stars 176 forks source link

API Dump: Feature request, shader output in SPIR-V or even GLSL #1613

Open mark-lunarg opened 3 years ago

mark-lunarg commented 3 years ago

Was surprised to see that selecting the show_shader option in api dump resulted in only the binary data for the shaders being dumped. It'd be super-cool if they'd use SPIRV-Tools to spit out the SPIR-V or GLSL shader source.

charles-lunarg commented 3 years ago

I agree, this is a very worthwhile addition. Printing the binary is of limited use since it requires further processing to look at manually. But I don't think GLSL is an appropriate output format since spir-v can contain constructs which don't necessarily map to glsl. Just printing a textual form of spirv would be ideal.

https://github.com/KhronosGroup/SPIRV-Tools would be the candidate library for the disassembler, since its widely used and lightweight.

spencer-lunarg commented 1 week ago

update, I hit this the other day

  1. We should print hex array instead of binary, so if you print out something like
 0x07230203, 0x00010300, 0x0008000b, 0x000000bb, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x00000005, 0x00020011, ...

there is now support in SPIRV-Tools (https://github.com/KhronosGroup/SPIRV-Tools/pull/5870) and https://www.khronos.org/spir/visualizer/ to consume these hex strings

  1. We currently only check at VkCreateShaderModule, but there are multiple ways we need to worry about where SPIR-V comes in (see https://github.com/KhronosGroup/Vulkan-Guide/blob/main/chapters/ways_to_provide_spirv.adoc)