示例#1
0
文件: shaderapi.c 项目: UIKit0/mesa
/**
 * Compile a shader.
 */
static void
compile_shader(struct gl_context *ctx, GLuint shaderObj)
{
   struct gl_shader *sh;
   struct gl_shader_compiler_options *options;

   sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader");
   if (!sh)
      return;

   options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];

   /* set default pragma state for shader */
   sh->Pragmas = options->DefaultPragmas;

   /* this call will set the sh->CompileStatus field to indicate if
    * compilation was successful.
    */
   _mesa_glsl_compile_shader(ctx, sh);

   if (sh->CompileStatus == GL_FALSE && 
       (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
      _mesa_debug(ctx, "Error compiling shader %u:\n%s\n",
                  sh->Name, sh->InfoLog);
   }
}
示例#2
0
文件: shaderapi.c 项目: curro/mesa
/**
 * Compile a shader.
 */
static void
compile_shader(struct gl_context *ctx, GLuint shaderObj)
{
   struct gl_shader *sh;
   struct gl_shader_compiler_options *options;

   sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader");
   if (!sh)
      return;

   options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];

   /* set default pragma state for shader */
   sh->Pragmas = options->DefaultPragmas;

   /* this call will set the sh->CompileStatus field to indicate if
    * compilation was successful.
    */
   _mesa_glsl_compile_shader(ctx, sh);
}
示例#3
0
static void
compile_shaders(struct gl_context *ctx, struct gl_shader_program *prog) {
   for (unsigned i = 0; i < prog->NumShaders; i++) {
      _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
   }
}
示例#4
0
/**
 * Compile a shader.
 */
static void
compile_shader(struct gl_context *ctx, GLuint shaderObj)
{
   struct gl_shader *sh;
   struct gl_shader_compiler_options *options;

   sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader");
   if (!sh)
      return;

   options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];

   /* set default pragma state for shader */
   sh->Pragmas = options->DefaultPragmas;

   if (!sh->Source) {
      /* If the user called glCompileShader without first calling
       * glShaderSource, we should fail to compile, but not raise a GL_ERROR.
       */
      sh->CompileStatus = GL_FALSE;
   } else {
      if (ctx->Shader.Flags & GLSL_DUMP) {
         printf("GLSL source for %s shader %d:\n",
                _mesa_glsl_shader_target_name(sh->Type), sh->Name);
         printf("%s\n", sh->Source);
      }

      /* this call will set the shader->CompileStatus field to indicate if
       * compilation was successful.
       */
      _mesa_glsl_compile_shader(ctx, sh, false, false);

      if (ctx->Shader.Flags & GLSL_LOG) {
         _mesa_write_shader_to_file(sh);
      }

      if (ctx->Shader.Flags & GLSL_DUMP) {
         if (sh->CompileStatus) {
            printf("GLSL IR for shader %d:\n", sh->Name);
            _mesa_print_ir(sh->ir, NULL);
            printf("\n\n");
         } else {
            printf("GLSL shader %d failed to compile.\n", sh->Name);
         }
         if (sh->InfoLog && sh->InfoLog[0] != 0) {
            printf("GLSL shader %d info log:\n", sh->Name);
            printf("%s\n", sh->InfoLog);
         }
      }

   }

   if (!sh->CompileStatus) {
      if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) {
         fprintf(stderr, "GLSL source for %s shader %d:\n",
                 _mesa_glsl_shader_target_name(sh->Type), sh->Name);
         fprintf(stderr, "%s\n", sh->Source);
      }

      if (ctx->Shader.Flags & GLSL_REPORT_ERRORS) {
         _mesa_debug(ctx, "Error compiling shader %u:\n%s\n",
                     sh->Name, sh->InfoLog);
      }
   }
}