glsl: simplify ES Vertex/Fragment shader requirements
We really just needed to skip the existing ES < 3.1 check if we have a compute shader, all other scenarios are already covered. * No shaders is a link error. * Geom or Tess without Vertex is a link error which means we always require a Vertex shader and hence a Fragment shader. * Finally a Compute shader linked with any other stage is a link error. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -4566,22 +4566,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
if (!prog->LinkStatus)
|
if (!prog->LinkStatus)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* OpenGL ES requires that a vertex shader and a fragment shader both be
|
/* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both
|
||||||
* present in a linked program. GL_ARB_ES2_compatibility doesn't say
|
* be present in a linked program. GL_ARB_ES2_compatibility doesn't say
|
||||||
* anything about shader linking when one of the shaders (vertex or
|
* anything about shader linking when one of the shaders (vertex or
|
||||||
* fragment shader) is absent. So, the extension shouldn't change the
|
* fragment shader) is absent. So, the extension shouldn't change the
|
||||||
* behavior specified in GLSL specification.
|
* behavior specified in GLSL specification.
|
||||||
*/
|
*
|
||||||
if (!prog->SeparateShader && ctx->API == API_OPENGLES2) {
|
* From OpenGL ES 3.1 specification (7.3 Program Objects):
|
||||||
/* With ES < 3.1 one needs to have always vertex + fragment shader. */
|
|
||||||
if (ctx->Version < 31) {
|
|
||||||
if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
|
|
||||||
linker_error(prog, "program lacks a vertex shader\n");
|
|
||||||
} else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
|
|
||||||
linker_error(prog, "program lacks a fragment shader\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* From OpenGL ES 3.1 specification (7.3 Program Objects):
|
|
||||||
* "Linking can fail for a variety of reasons as specified in the
|
* "Linking can fail for a variety of reasons as specified in the
|
||||||
* OpenGL ES Shading Language Specification, as well as any of the
|
* OpenGL ES Shading Language Specification, as well as any of the
|
||||||
* following reasons:
|
* following reasons:
|
||||||
@@ -4592,12 +4583,21 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
* fragment shader, and program is not separable, and does not
|
* fragment shader, and program is not separable, and does not
|
||||||
* contain objects to form both a vertex shader and fragment
|
* contain objects to form both a vertex shader and fragment
|
||||||
* shader."
|
* shader."
|
||||||
|
*
|
||||||
|
* However, the only scenario in 3.1+ where we don't require them both is
|
||||||
|
* when we have a compute shader. For example:
|
||||||
|
*
|
||||||
|
* - No shaders is a link error.
|
||||||
|
* - Geom or Tess without a Vertex shader is a link error which means we
|
||||||
|
* always require a Vertex shader and hence a Fragment shader.
|
||||||
|
* - Finally a Compute shader linked with any other stage is a link error.
|
||||||
*/
|
*/
|
||||||
if (!!prog->_LinkedShaders[MESA_SHADER_VERTEX] ^
|
if (!prog->SeparateShader && ctx->API == API_OPENGLES2 &&
|
||||||
!!prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
|
num_shaders[MESA_SHADER_COMPUTE] == 0) {
|
||||||
linker_error(prog, "Program needs to contain both vertex and "
|
if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
|
||||||
"fragment shaders.\n");
|
linker_error(prog, "program lacks a vertex shader\n");
|
||||||
}
|
} else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
|
||||||
|
linker_error(prog, "program lacks a fragment shader\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user