diff options
author | Ian Romanick <[email protected]> | 2014-10-20 14:47:45 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-11-10 04:25:39 -0800 |
commit | 366540e9af86edc7451beb39204efbb4fe593973 (patch) | |
tree | 63e6a9f23f0f308bbbb921e9085df471199217e2 /src/mesa | |
parent | 3f5ebb98b74cca8488ee7093aab87125ee5341ed (diff) |
mesa: Get some gl_shader_program::LinkStatus checking out of the main path
I really wanted to remove 'shProg != NULL' as well, but that would have
required adding a dummy program as the default program. That seemed
like more churn than removing one test was worth.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index a1ca3678cf5..16e08d44cd6 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -178,7 +178,7 @@ validate_uniform_parameters(struct gl_context *ctx, unsigned *array_index, const char *caller) { - if (!shProg || !shProg->LinkStatus) { + if (shProg == NULL) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller); return NULL; } @@ -193,15 +193,28 @@ validate_uniform_parameters(struct gl_context *ctx, return NULL; } - /* Check that the given location is in bounds of uniform remap table. */ - if (location >= (GLint) shProg->NumUniformRemapTable) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); + /* Check that the given location is in bounds of uniform remap table. + * Unlinked programs will have NumUniformRemapTable == 0, so we can take + * the shProg->LinkStatus check out of the main path. + */ + if (unlikely(location >= (GLint) shProg->NumUniformRemapTable)) { + if (!shProg->LinkStatus) + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", + caller); + else + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", + caller, location); + return NULL; } - if (location == -1) + if (location == -1) { + if (!shProg->LinkStatus) + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", + caller); + return NULL; + } /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says: * |