[Mesa-dev] [PATCH] mesa: remove validation of shaders that should be done elsewhere
Timothy Arceri
timothy.arceri at collabora.com
Tue Dec 8 05:17:59 PST 2015
In core profile even if re-linking fails rendering shouldn't fail as the
previous succesfully linked program will still be available. It also
shouldn't be possible to have an unlinked program as part of the
current rendering state.
This fixes a subtest in:
ES31-CTS.sepshaderobjs.StateInteraction
This change should improve performance on CPU limited benchmarks as noted
in commit d6c6b186cf308f.
>From Section 7.3 (Program Objects) of the OpenGL 4.5 spec:
"If a program object that is active for any shader stage is re-linked
unsuccessfully, the link status will be set to FALSE, but any existing
executables and associated state will remain part of the current rendering
state until a subsequent call to UseProgram, UseProgramStages, or
BindProgramPipeline removes them from use. If such a program is attached to
any program pipeline object, the existing executables and associated state
will remain part of the program pipeline object until a subsequent call to
UseProgramStages removes them from use. An unsuccessfully linked program may
not be made part of the current rendering state by UseProgram or added to
program pipeline objects by UseProgramStages until it is successfully
re-linked."
"void UseProgram(uint program);
...
An INVALID_OPERATION error is generated if program has not been linked, or
was last linked unsuccessfully. The current rendering state is not modified."
Cc: Tapani Pälli <tapani.palli at intel.com>
Cc: Ian Romanick <ian.d.romanick at intel.com>
Cc: Brian Paul <brianp at vmware.com>
---
src/mesa/main/context.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index be983d4..2340c11 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1930,6 +1930,7 @@ _mesa_check_blend_func_error(struct gl_context *ctx)
return GL_TRUE;
}
+
static bool
shader_linked_or_absent(struct gl_context *ctx,
const struct gl_shader_program *shProg,
@@ -1956,6 +1957,7 @@ shader_linked_or_absent(struct gl_context *ctx,
return true;
}
+
/**
* Prior to drawing anything with glBegin, glDrawArrays, etc. this function
* is called to see if it's valid to render. This involves checking that
@@ -1967,33 +1969,14 @@ shader_linked_or_absent(struct gl_context *ctx,
GLboolean
_mesa_valid_to_render(struct gl_context *ctx, const char *where)
{
- unsigned i;
-
/* This depends on having up to date derived state (shaders) */
if (ctx->NewState)
_mesa_update_state(ctx);
- if (ctx->API == API_OPENGL_CORE || ctx->API == API_OPENGLES2) {
- bool from_glsl_shader[MESA_SHADER_COMPUTE] = { false };
-
- for (i = 0; i < MESA_SHADER_COMPUTE; i++) {
- if (!shader_linked_or_absent(ctx, ctx->_Shader->CurrentProgram[i],
- &from_glsl_shader[i], where))
- return GL_FALSE;
- }
-
- /* In OpenGL Core Profile and OpenGL ES 2.0 / 3.0, there are no assembly
- * shaders. Don't check state related to those.
- */
- } else {
+ if (ctx->API == API_OPENGL_COMPAT) {
bool has_vertex_shader = false;
bool has_fragment_shader = false;
- /* In OpenGL Compatibility Profile, there is only vertex shader and
- * fragment shader. We take this path also for API_OPENGLES because
- * optimizing that path would make the other (more common) paths
- * slightly slower.
- */
if (!shader_linked_or_absent(ctx,
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX],
&has_vertex_shader, where))
--
2.4.3
More information about the mesa-dev
mailing list