Some context:
I'm looking for a simple way to run 'old' shaders (let's say #version 120) on a 'new' GLSL (let's say #version 150 core).
So far I came up with adding following header to my fragment shaders when targeting #version 150:
#version 150 core
#define texture2D texture
out vec4 _gl_FragData[gl_MaxDrawBuffers];
#define gl_FragData _gl_Fragdata
#define gl_FragColor gl_Fragdata[0]
Question:
I'm a bit concenrned about this line:
// In a fragment shader
out vec4 _gl_FragData[gl_MaxDrawBuffers];
With most shaders, _gl_FragData[1 ... gl_MaxDrawBuffers-1] will be unused, i.e. not written by the shader, and lack framebuffer attachements to receive the values. I'm worried if presence of those unused elements makes my shaders ill-formed (or has any undesirable effects or overhead).
GLSL 1.50 specification says that there is an implicitly defined deprecated out vec4 gl_FragData[gl_MaxDrawBuffers];, so presumably what I'm doing is fine and incurs no overhead.
But I also know that builtin gl_FragData is in some ways 'magical', and a similar user-provided declaration might have a different effect.
TL;DR:
If my fragment shader output is an array, am I allowed to not write to some of the elements at the end of the array, given that the values of those elements are discarded (not received by any framebuffer attachment point)?
A bit too-broad-ish, but: Does the presence of those unused indices have any undersirable effects or overhead on common implementations?