Add GL_EXT_function_control_attributes#335
Conversation
|
tl;dr - agree that GLSL should just have a simple way to just expose this and 💯 support this idea @Karpov-Ruslan I realize that the goal is to stop Basically I have tried doing this for GPU-AV inside VVL and found that NO ONE actually will honor your
... so more of a "heads up"... if you only care about SPIR-V binary size, that is a VERY valid reason as well! |
To be honest, I didn’t even consider it. Sad to hear that. However, SPIR-V Function Control is about hints to the compiler. If the driver developers don't take this into account, it's their full right. Perhaps in the future more and more drivers will support this, so we need to be prepared. |
This extension allows to use
[[inline]]and[[noinline]]attributes on functions to give a hint to the compiler.One of the side effects of this extension is the ability to fine-tune function inlining when using spirv-opt. Let's say I have a GLSL compute shader:
I'll take this shader and compile it to SPIR-V using glslang (https://godbolt.org/z/adfrb5soW), and then I'll want to use spirv-opt with the
-Osflag, which should reduce the size of incoming SPIR-V. But in this case the size will be increased (https://godbolt.org/z/fxv5rjGo9). However, by adding the[[noinline]]attribute to thefuncfunction, theDontInlineFunction Control bit will be added to this function in SPIR-V, so spirv-opt will not inline this function and the size of the outgoing SPIR-V will indeed be reduced (https://godbolt.org/z/d6daKEK5n).