We using separated shader objects on Android (tested on different devices), I’ve encountered a pipeline validate error, which contracting the OpenGL ES specifcation. But I want to be sure:
I want to create a shader without may output variables, but want to use a shader that ignore them.
Vertex Shader
#version 310 es
#extension GL_ANDROID_extension_pack_es31a : enable
precision highp float;
out gl_PerVertex { vec4 gl_Position; float gl_PointSize; };
out vec2 texCoord0;
in vec4 attr_Vertex;
in vec2 attr_TexCoord;
void main()
{
gl_Position = attr_Vertex;
texCoord0 = attr_TexCoord;
}
Fragment Shader
#version 310 es
#extension GL_ANDROID_extension_pack_es31a : enable
precision highp float;
void main() {} // Do nothing, (ie, for a depth only shader)
Go this error during pipeline validation
glValidateProgramPipeline(ppo);
glGetProgramPipelineiv(ppo, GL_VALIDATE_STATUS, &status);
Output from glGetProgramPipelineInfoLog:
Error: output texCoord0 not declared in input from next stage.
On Android with ES 3.2, the message is
error: The fragment stage's input interface doesn't match preceding stage's output
However this is working on Desktop OpenGL (GL_ARB_shader_separated_objects) and iOS with GL_EXT_shader_separated_objects
I have many vertex shaders and want to perform a depth pass or other only with a special fragment shader which don’t need the input, or ignore them. For example several vertex shader, but using the same fragment shader for a different rendering pass.
Why output not declared in input from next stage is an error ? It should be at worst a warning, but not an error, and why it happens on ESSL 3.1 and not on Desktop (Also same shader on Desktop works - ie no error -)
According the documentation
With separable program objects, interfaces between shader stages may involve the outputs from one program object and the inputs from a second program object