PDA

View Full Version : GLSL Compilers



debonair
06-07-2017, 04:55 PM
If we have varyings which are being assigned value by some calculation in VS and are being passed to FS, but not used in FS, does the optimization pass takes care of it? Or it assigns the memory and performs the interpolation too?

Is it specific to GPU? how about Mali and Adreno?

GClements
06-07-2017, 08:40 PM
It is likely that unnecessary code will be eliminated, and (unless you're using separable programs) the determination will be made for the program as a whole, not just individual shaders. But it's not required; 7.3.1 of the OpenGL 4.5 specification says:



Resources referenced in shader code are considered active unless the compiler and linker can conclusively determine that they have no observable effect on the results produced by the executable code of the program. For example, variables might be considered inactive if they are declared but not used in executable code, used only in a clause of an if statement that would never be executed, used only in functions that are never called, or used only in computations of temporary variables having no effect on any shader output. In cases where the compiler or linker cannot make a conclusive determination, any resource referenced by shader code will be considered active. The set of active resources for any interface is implementation-dependent because it depends on various analysis and optimizations performed by the compiler and linker.

Silence
06-08-2017, 02:35 AM
I guess that, in order to ensure this, you can follow the steps given in this thread (https://www.opengl.org/discussion_boards/showthread.php/199629-Shaders-optimization?p=1287168#post1287168).
You'll have to understand the output assembly however and as stated in the thread, outputs will be dependent on the driver.

On AMD devices, you can try this tool (https://github.com/GPUOpen-Tools/RGA/releases).