KhronosGroup / KhronosGroup/SPIRV-Tools
Opt: Add pass to optimize OpVariable Input/Output across stages
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
After other optimizations have occurred it's often the case that the output from one stage isn't actually used in any subsequent stages. Another side effect is that the input stage may access shader resources (UBO/Samplers) to produce output that is unused. This results in validation warnings during run-time that often do not cause real errors on the target Vulkan device due to internal optimizations performed by the driver during pipeline creation. These attachments illustrate this case.
[fragment_shader.txt](https://github.com/KhronosGroup/SPIRV-Tools/files/1402730/fragment_shader.txt)
[vertex_shader.txt](https://github.com/KhronosGroup/SPIRV-Tools/files/1402731/vertex_shader.txt)
I believe that removal of the unused Input/Output within a stage is covered by #833, but performing the cross stage optimization would also be beneficial.
Contributor guide
Research direction
Start by comparing the attached fragment_shader.txt and vertex_shader.txt examples to identify outputs that are unused by subsequent stages and inputs or resources that become unnecessary. Review how cross-stage OpVariable interfaces are represented in SPIR-V Tools; done means an optimization pass can remove the unused cross-stage interface and avoid the resulting validation warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100