Example #1
0
static struct pipe_context *
ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
{
   struct ilo_screen *is = ilo_screen(screen);
   struct ilo_context *ilo;

   ilo = CALLOC_STRUCT(ilo_context);
   if (!ilo)
      return NULL;

   ilo->winsys = is->dev.winsys;
   ilo->dev = &is->dev;

   /*
    * initialize first, otherwise it may not be safe to call
    * ilo_context_destroy() on errors
    */
   slab_create(&ilo->transfer_mempool,
         sizeof(struct ilo_transfer), 64);

   ilo->shader_cache = ilo_shader_cache_create();
   ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache);
   if (ilo->cp)
      ilo->render = ilo_render_create(&ilo->cp->builder);

   if (!ilo->cp || !ilo->shader_cache || !ilo->render) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   ilo_cp_set_submit_callback(ilo->cp,
         ilo_context_cp_submitted, (void *) ilo);

   ilo->base.screen = screen;
   ilo->base.priv = priv;

   ilo->base.destroy = ilo_context_destroy;
   ilo->base.flush = ilo_flush;
   ilo->base.render_condition = ilo_render_condition;

   ilo_init_draw_functions(ilo);
   ilo_init_query_functions(ilo);
   ilo_init_state_functions(ilo);
   ilo_init_blit_functions(ilo);
   ilo_init_transfer_functions(ilo);
   ilo_init_video_functions(ilo);
   ilo_init_gpgpu_functions(ilo);

   ilo_init_draw(ilo);
   ilo_state_vector_init(ilo->dev, &ilo->state_vector);

   /*
    * These must be called last as u_upload/u_blitter are clients of the pipe
    * context.
    */
   ilo->uploader = u_upload_create(&ilo->base, 1024 * 1024,
         PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_INDEX_BUFFER,
                                   PIPE_USAGE_STREAM);
   if (!ilo->uploader) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   ilo->blitter = ilo_blitter_create(ilo);
   if (!ilo->blitter) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   return &ilo->base;
}
Example #2
0
static struct pipe_context *
ilo_context_create(struct pipe_screen *screen, void *priv)
{
   struct ilo_screen *is = ilo_screen(screen);
   struct ilo_context *ilo;

   ilo = CALLOC_STRUCT(ilo_context);
   if (!ilo)
      return NULL;

   ilo->winsys = is->winsys;
   ilo->dev = &is->dev;

   /*
    * initialize first, otherwise it may not be safe to call
    * ilo_context_destroy() on errors
    */
   util_slab_create(&ilo->transfer_mempool,
         sizeof(struct ilo_transfer), 64, UTIL_SLAB_SINGLETHREADED);

   /* 8192 DWords */
   ilo->cp = ilo_cp_create(ilo->winsys, 8192, is->dev.has_llc);
   ilo->shader_cache = ilo_shader_cache_create();
   if (ilo->cp)
      ilo->hw3d = ilo_3d_create(ilo->cp, ilo->dev);

   if (!ilo->cp || !ilo->shader_cache || !ilo->hw3d) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   ilo_cp_set_flush_callback(ilo->cp,
         ilo_context_cp_flushed, (void *) ilo);

   ilo->base.screen = screen;
   ilo->base.priv = priv;

   ilo->base.destroy = ilo_context_destroy;
   ilo->base.flush = ilo_flush;

   ilo_init_3d_functions(ilo);
   ilo_init_query_functions(ilo);
   ilo_init_state_functions(ilo);
   ilo_init_blit_functions(ilo);
   ilo_init_transfer_functions(ilo);
   ilo_init_video_functions(ilo);
   ilo_init_gpgpu_functions(ilo);

   ilo_init_states(ilo);

   /*
    * These must be called last as u_upload/u_blitter are clients of the pipe
    * context.
    */
   ilo->uploader = u_upload_create(&ilo->base, 1024 * 1024, 16,
         PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_INDEX_BUFFER);
   if (!ilo->uploader) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   ilo->blitter = ilo_blitter_create(ilo);
   if (!ilo->blitter) {
      ilo_context_destroy(&ilo->base);
      return NULL;
   }

   return &ilo->base;
}