Example #1
0
/**
 * Upload the pixel transfer color map texture.
 */
static void
update_pixel_transfer(struct st_context *st)
{
   struct gl_context *ctx = st->ctx;

   if (ctx->Pixel.MapColorFlag) {
      /* create the colormap/texture now if not already done */
      if (!st->pixel_xfer.pixelmap_texture) {
         st->pixel_xfer.pixelmap_texture = st_create_color_map_texture(ctx);
         st->pixel_xfer.pixelmap_sampler_view =
            st_create_texture_sampler_view(st->pipe,
                                           st->pixel_xfer.pixelmap_texture);
      }
      load_color_map_texture(ctx, st->pixel_xfer.pixelmap_texture);
   }
}
/**
 * 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;
}