KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.9k stars 816 forks source link

Generate nonsemantic shader debug information with source doesn't work on large shaders #3497

Closed helviett closed 4 months ago

helviett commented 5 months ago

If you take almost any preprocessed shader from https://github.com/ConfettiFX/The-Forge you won't be able to compile it with -gVS option. Reproduction steps:

  1. Clone latest https://github.com/ConfettiFX/The-Forge release
  2. Apply this patch to avoid python warning and get error message: glslang_gVS.patch
  3. set FSL_COMPILER_VK env variable to the folder that contains desired glslangValidator executable (e.g. $env:FSL_COMPILER_VK="C:\VulkanSDK\1.3.268.0\Bin\" in powershell)
  4. Run from the root of the git repository py.exe .\Common_3\Tools\ForgeShadingLanguage\fsl.py --compile -b CompiledShaders -d PreprocessedShaders -l VULKAN --debug .\Examples_3\Unit_Tests\src\01_Transformations\Shaders\FSL\ShaderList.fsl
  5. Converted GLSL from FSL will be in PreprocessedShader/VULKAN folder, compiled SPIR-V will be in CompiledShaders/VULKAN folder
  6. You can try the same with any file named ShaderList.fsl inside Examples_3 folder

If you're a bit lazy to follow all the steps:

  1. Here is preprocessed shaders from 01_Transformations: PreprocessedShaders.zip
  2. You can compiler them with the following command: glslangValidator.exe -D_DEBUG -gVS -V PreprocessedShaders/VULKAN/skybox.vert -o CompiledShaders/VULKAN/skybox.vert_0.spv -IPath\To\The-Forge\Common_3\Tools\ForgeShadingLanguage -S vert --target-env spirv1.3 -DVK_EXT_DESCRIPTOR_INDEXING_ENABLED=0 -DVK_FEATURE_TEXTURE_ARRAY_DYNAMIC_INDEXING_ENABLED=0

I can preprocess entire The-Forge for you if you're going to fix this annoying issue. Debugging SPIR-V is okay but I prefer to look at GLSL code.

arcady-lunarg commented 5 months ago

Thanks, I can indeed reproduce this issue. Preliminarily I think the issue is with how #line directives are handled in preprocessed code and how that corresponds to OpDebugSource opcodes. This is definitely something that should be fixed.

arcady-lunarg commented 5 months ago

Good news, looks like this is also fixed by #3496 so I will try to get that reviewed and merged as soon as I can.

arcady-lunarg commented 4 months ago

Update, #3496 has been merged, could you confirm that your issue is fixed and close it if so?

helviett commented 4 months ago

@arcady-lunarg sorry, couldn't check it earlier. I tested every ShaderList in https://github.com/ConfettiFX/The-Forge and can confirm that everything compiles now.