Beispiel #1
0
/**
 * Called via ctx->Driver.CompileShader()
 */
void
_mesa_compile_shader(GLcontext *ctx, GLuint shaderObj)
{
   struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj);

   if (!sh) {
      _mesa_error(ctx, GL_INVALID_VALUE, "glCompileShader(shaderObj)");
      return;
   }

   sh->CompileStatus = _slang_compile(ctx, sh);
}
Beispiel #2
0
/**
 * Search the shader program's list of shaders to find the one that
 * defines main().
 * This will involve shader concatenation and recompilation if needed.
 */
static struct gl_shader *
get_main_shader(GLcontext *ctx,
                struct gl_shader_program *shProg, GLenum type)
{
   struct gl_shader *shader = NULL;
   GLuint i;

   /*
    * Look for a shader that defines main() and has no unresolved references.
    */
   for (i = 0; i < shProg->NumShaders; i++) {
      shader = shProg->Shaders[i];
      if (shader->Type == type &&
          shader->Main &&
          !shader->UnresolvedRefs) {
         /* All set! */
         return shader;
      }
   }

   /*
    * There must have been unresolved references during the original
    * compilation.  Try concatenating all the shaders of the given type
    * and recompile that.
    */
   shader = concat_shaders(shProg, type);

   if (shader) {
      _slang_compile(ctx, shader);

      /* Finally, check if recompiling failed */
      if (!shader->CompileStatus ||
          !shader->Main ||
          shader->UnresolvedRefs) {
         link_error(shProg, "Unresolved symbols");
         _mesa_free_shader(ctx, shader);
         return NULL;
      }
   }

   return shader;
}