[Mesa-dev] [PATCH 1/2] glsl: don't attempt to link empty program
Ian Romanick
idr at freedesktop.org
Mon Jan 25 11:24:48 PST 2016
On 01/25/2016 03:56 AM, Timothy Arceri wrote:
> Previously an empty program would go through the entire
> link_shaders() function and we would have to be careful
> not to cause a segfault.
>
> We also now set link_status to false by throwing an error,
> it was previously set to true.
>
> From Section 7.3 (PROGRAM OBJECTS) of the OpenGL 4.5 spec:
>
> "Linking can fail for a variety of reasons as specified in the
> OpenGL Shading Language Specification, as well as any of the
> following reasons:
>
> - No shader objects are attached to program."
As mentioned in feedback on the piglit test, this only applies to core
profile. When the code is updated to correctly apply the restriction,
the above spec quotation should be added to the code. It should also
be mentioned that this is an explicit difference from compatibility
profile. Something like:
/* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec says:
*
* "Linking can fail for a variety of reasons as specified in the
* OpenGL Shading Language Specification, as well as any of the
* following reasons:
*
* - No shader objects are attached to program."
*
* The Compatibility Profile specification does not list error. In
* Compatibility Profile missing shader stages are replaced by
* fixed-function. This applies to the case where all stages are
* missing.
*/
> "# Please enter the commit message for your changes. Lines starting
Huh? :)
> ---
>
> Fixes required in piglit due to the change in the link_status flag:
>
> http://patchwork.freedesktop.org/patch/71555/
>
> src/glsl/linker.cpp | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index 6657777..927e2f3 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
> @@ -4105,14 +4105,21 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
> void
> link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
> {
> + prog->Validated = false;
> + prog->_Used = false;
> +
> + /* Don't attempt to link an empty program */
> + if (prog->NumShaders == 0) {
> + linker_error(prog, "no shaders attached to the program\n");
> + return;
> + }
> +
> tfeedback_decl *tfeedback_decls = NULL;
> unsigned num_tfeedback_decls = prog->TransformFeedback.NumVarying;
>
> void *mem_ctx = ralloc_context(NULL); // temporary linker context
>
> prog->LinkStatus = true; /* All error paths will set this to false */
> - prog->Validated = false;
> - prog->_Used = false;
>
> prog->ARB_fragment_coord_conventions_enable = false;
>
>
More information about the mesa-dev
mailing list