KhronosGroup / KhronosGroup/SPIRV-Tools

spirv-opt takes a long time to optimize a large shader with debugPrintfEXT()

Open
#4,241 6 comments 0 reactions 1 assignee Claimed by @s-perron View on GitHub
component:optimization
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

This [ZIP file](https://github.com/KhronosGroup/SPIRV-Tools/files/6327176/shaders.zip) contains two large, nearly identical shaders in SPIR-V form that differ only as follow:
- `shader-with-debugPrintfEXT.spv` has `debugPrintfEXT()` statements
- `shader-without-debugPrintfEXT.spv` doesn't

They were compiled with glslangValidator from Vulkan SDK 1.2.170.0 [1].

Running spirv-opt on `shader-without-debugPrintfEXT.spv` (_without_ `debugPrintfEXT()` statements) takes 21 seconds.

**Running spirv-opt on `shader-with-debugPrintfEXT.spv` (with `debugPrintfEXT()` statements) takes 172 seconds (2 min 52).**

Is there any fundamental reason why a few `debugPrintfEXT()` statements would cause optimization times to explode, or is this a bug?

---

[1] Full output of `glslangvalidator --version`:
```
Glslang Version: 10:11.1.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.1.0
GLSL Version: 4.60 glslang Khronos. 11.1.0
SPIR-V Version 0x00010500, Revision 4
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 10
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.