Пример #1
0
/**
 * Return a vertex program which implements the current fixed-function
 * transform/lighting/texgen operations.
 * XXX move this into core mesa (main/)
 */
struct gl_vertex_program *
_mesa_get_fixed_func_vertex_program(GLcontext *ctx)
{
   struct gl_vertex_program *prog;
   struct state_key key;

   /* Grab all the relevent state and put it in a single structure:
    */
   make_state_key(ctx, &key);

   /* Look for an already-prepared program for this state:
    */
   prog = (struct gl_vertex_program *)
      _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key));

   if (!prog) {
      /* OK, we'll have to build a new one */
      if (0)
         _mesa_printf("Build new TNL program\n");

      prog = (struct gl_vertex_program *)
         ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
      if (!prog)
         return NULL;

      create_new_program( &key, prog,
                          ctx->mvp_with_dp4,
                          ctx->Const.VertexProgram.MaxTemps );

#if 0
      if (ctx->Driver.ProgramStringNotify)
         ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
                                          &prog->Base );
#endif
      _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
                                 &key, sizeof(key), &prog->Base);
   }

   return prog;
}
Пример #2
0
/**
 * Return a vertex program which implements the current fixed-function
 * transform/lighting/texgen operations.
 */
struct gl_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
{
   struct gl_program *prog;
   struct state_key key;

   /* Grab all the relevant state and put it in a single structure:
    */
   make_state_key(ctx, &key);

   /* Look for an already-prepared program for this state:
    */
   prog = _mesa_search_program_cache(ctx->VertexProgram.Cache, &key,
                                     sizeof(key));

   if (!prog) {
      /* OK, we'll have to build a new one */
      if (0)
         printf("Build new TNL program\n");

      prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
      if (!prog)
         return NULL;

      create_new_program( &key, prog,
                          ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS,
                          ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );

      if (ctx->Driver.ProgramStringNotify)
         ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, prog);

      _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, &key,
                                 sizeof(key), prog);
   }

   return prog;
}
Пример #3
0
/**
 * Update st->pixel_xfer.program in response to new pixel-transfer state.
 */
static void
update_pixel_transfer(struct st_context *st)
{
   GLcontext *ctx = st->ctx;
   struct state_key key;
   struct gl_fragment_program *fp;

   make_state_key(st->ctx, &key);

   fp = (struct gl_fragment_program *)
      _mesa_search_program_cache(st->pixel_xfer.cache, &key, sizeof(key));
   if (!fp) {
      fp = get_pixel_transfer_program(st->ctx, &key);
      _mesa_program_cache_insert(st->ctx, st->pixel_xfer.cache,
                                 &key, sizeof(key), &fp->Base);
   }

   if (ctx->Pixel.MapColorFlag) {
      load_color_map_texture(ctx, st->pixel_xfer.pixelmap_texture);
   }
   st->pixel_xfer.pixelmap_enabled = ctx->Pixel.MapColorFlag;

   st->pixel_xfer.program = (struct st_fragment_program *) fp;
}