-
Notifications
You must be signed in to change notification settings - Fork 377
Description
Problem Description
When using GLSLang as my compiler, my end-users have created shaders that cause the spirv-opt passes to exceed the default 0x3FFFFF maximum ID value limit for SPIR-V. This causes spirv-opt to crash. To avoid this an option was added to GLSLang that expanded the ID maximum initially to 0x3FFFFFFF. Then after all of the work is done it checks the SPIR-V header to see what the actual maximum ID value is, and runs the CreateCompactIdsPass on the SPIR-V if the used ID max exceeds kDefaultMaxIdBound.
I see that Slang sets the maximum IDs to kDefaultMaxIdBound * 4. Is there any reason it's still limited to only 16M IDs, and not set to something far higher?
I also think SLANG_OPTIMIZATION_LEVEL_DEFAULT should still run the CompactIdsPass if the final SPIR-V's maximum used ID exceeds kDefaultMaxIdBound as well. This ensures the generated SPIR-V will run on any host in the event the optimization passes created much higher IDs.
Preferred Solution
- Increase the max IDs to something much larger. 0x3FFFFFFF is what GLSLang used.
- When optimization is set to SLANG_OPTIMIZATION_LEVEL_DEFAULT, check the final SPIR-V's maximum used ID, and run the CompactIdsPass only if it exceed
kDefaultMaxIdBound
I can make a PR for this if it makes sense.