Bug 30787

Summary: Invalid asm shader does not generate draw-time error when used with GLSL shader
Product: Mesa Reporter: Ian Romanick <idr>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: 7.9   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Ian Romanick 2010-10-11 21:38:09 UTC
When a GLSL shader provides some stages (e.g., only vertex processing) and an *invalid* assembly shader provides the rest (e.g., only fragment processing), the expected draw-time error is not generated.  This is caused by the following code from _mesa_valid_to_render.  Note that if there is a GLSL shader active, the validity of the assembly shaders is not verified.

   if (ctx->Shader.CurrentProgram) {
      /* using shaders */
      if (!ctx->Shader.CurrentProgram->LinkStatus) {
         _mesa_error(ctx, GL_INVALID_OPERATION,
                     "%s(shader not linked)", where);
         return GL_FALSE;
      }
#if 0 /* not normally enabled */
      {
         char errMsg[100];
         if (!_mesa_validate_shader_program(ctx, ctx->Shader.CurrentProgram,
                                            errMsg)) {
            _mesa_warning(ctx, "Shader program %u is invalid: %s",
                          ctx->Shader.CurrentProgram->Name, errMsg);
         }
      }
#endif
   }
   else {
      if (ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) {
         _mesa_error(ctx, GL_INVALID_OPERATION,
                     "%s(vertex program not valid)", where);
         return GL_FALSE;
      }
      if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
         _mesa_error(ctx, GL_INVALID_OPERATION,
                     "%s(fragment program not valid)", where);
         return GL_FALSE;
      }
   }

This bug is exercised by the piglit tests glsl-invalid-asm-01 and glsl-invalid-asm-02.  Both of these tests pass on NVIDIA's closed-source Linux driver but fail on Mesa.
Comment 1 Ian Romanick 2010-10-12 10:56:35 UTC
Fixed on master with the following commit.  I'll close the bug once it's cherry picked to the 7.9 branch.

commit b2b9b22c1013ebf02aa6f0d9c1c7b5267523d973
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Oct 12 10:51:47 2010 -0700

    mesa: Validate assembly shaders when GLSL shaders are used
    
    If an GLSL shader is used that does not provide all stages and
    assembly shaders are provided for the missing stages, validate the
    assembly shaders.
    
    Fixes bugzilla #30787 and piglit tests glsl-invalid-asm0[12].
    
    NOTE: this is a candidate for the 7.9 branch.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.