glsl: move some GL ES checks to the NIR linker

Eventually we should aim to remove the GLSL IR linker.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22305>
This commit is contained in:
Timothy Arceri
2023-04-05 11:53:13 +10:00
committed by Marge Bot
parent bf8f11a2de
commit 5a29af262c
2 changed files with 35 additions and 35 deletions

View File

@@ -993,6 +993,41 @@ gl_nir_link_glsl(const struct gl_constants *consts,
gl_nir_link_assign_atomic_counter_resources(consts, prog);
gl_nir_link_check_atomic_counter_resources(consts, prog);
/* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both
* be present in a linked program. GL_ARB_ES2_compatibility doesn't say
* anything about shader linking when one of the shaders (vertex or
* fragment shader) is absent. So, the extension shouldn't change the
* behavior specified in GLSL specification.
*
* From OpenGL ES 3.1 specification (7.3 Program Objects):
* "Linking can fail for a variety of reasons as specified in the
* OpenGL ES Shading Language Specification, as well as any of the
* following reasons:
*
* ...
*
* * program contains objects to form either a vertex shader or
* fragment shader, and program is not separable, and does not
* contain objects to form both a vertex shader and fragment
* 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->SeparateShader && _mesa_is_api_gles2(api) &&
!prog->_LinkedShaders[MESA_SHADER_COMPUTE]) {
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");
}
}
if (prog->data->LinkStatus == LINKING_FAILURE)
return false;

View File

@@ -3899,41 +3899,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if(!link_varyings(consts, prog, mem_ctx))
goto done;
/* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both
* be present in a linked program. GL_ARB_ES2_compatibility doesn't say
* anything about shader linking when one of the shaders (vertex or
* fragment shader) is absent. So, the extension shouldn't change the
* behavior specified in GLSL specification.
*
* From OpenGL ES 3.1 specification (7.3 Program Objects):
* "Linking can fail for a variety of reasons as specified in the
* OpenGL ES Shading Language Specification, as well as any of the
* following reasons:
*
* ...
*
* * program contains objects to form either a vertex shader or
* fragment shader, and program is not separable, and does not
* contain objects to form both a vertex shader and fragment
* 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->SeparateShader && _mesa_is_gles2(ctx) &&
num_shaders[MESA_SHADER_COMPUTE] == 0) {
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");
}
}
done:
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
free(shader_list[i]);