Beispiel #1
0
static void
tex_destroy(struct ilo_texture *tex)
{
   if (tex->hiz.bo)
      intel_bo_unreference(tex->hiz.bo);

   if (tex->separate_s8)
      tex_destroy(tex->separate_s8);

   intel_bo_unreference(tex->bo);
   tex_free_slices(tex);
   FREE(tex);
}
Beispiel #2
0
/**
 * Reallocate the parser bo.
 */
static void
ilo_cp_realloc_bo(struct ilo_cp *cp)
{
    struct intel_bo *bo;

    /*
     * allocate the new bo before unreferencing the old one so that they
     * won't point at the same address, which is needed for jmpbuf
     */
    bo = intel_winsys_alloc_buffer(cp->winsys,
                                   "batch buffer", cp->bo_size * 4, 0);
    if (unlikely(!bo)) {
        /* reuse the old one */
        bo = cp->bo;
        intel_bo_reference(bo);
    }

    if (cp->bo)
        intel_bo_unreference(cp->bo);
    cp->bo = bo;

    if (!cp->sys) {
        intel_bo_map(cp->bo, true);
        cp->ptr = intel_bo_get_virtual(cp->bo);
    }
}
Beispiel #3
0
/**
 * Flush the command parser and execute the commands.  When the parser buffer
 * is empty, the callback is not invoked.
 */
void
ilo_cp_flush_internal(struct ilo_cp *cp)
{
    const bool do_exec = !(ilo_debug & ILO_DEBUG_NOHW);
    struct intel_bo *bo;
    unsigned used;
    int err;

    bo = ilo_cp_end_batch(cp, &used);
    if (!bo)
        return;

    if (likely(do_exec)) {
        err = intel_winsys_submit_bo(cp->winsys, cp->ring,
                                     bo, used, cp->render_ctx, cp->one_off_flags);
    }
    else {
        err = 0;
    }

    cp->one_off_flags = 0;

    if (!err) {
        if (cp->last_submitted_bo)
            intel_bo_unreference(cp->last_submitted_bo);
        cp->last_submitted_bo = bo;
        intel_bo_reference(cp->last_submitted_bo);

        if (cp->flush_callback)
            cp->flush_callback(cp, cp->flush_callback_data);
    }

    ilo_builder_begin(&cp->builder);
}
Beispiel #4
0
/**
 * Allocate a query bo for reading hardware statistics.
 *
 * \param reg_count specifies how many registers need to be read.
 * \param repeat_count specifies how many times the registers are read.  If
 *        zero or negative, a 4KB bo is allocated.
 */
bool
ilo_query_alloc_bo(struct ilo_query *q, int reg_count, int repeat_count,
                   struct intel_winsys *winsys)
{
   const char *name;
   int reg_total;

   name = query_info[q->type].name;

   reg_total = reg_count * repeat_count;
   if (reg_total <= 0)
      reg_total = 4096 / sizeof(uint64_t);

   /* (re-)allocate the bo */
   if (q->reg_total < reg_total) {
      /* registers are 64-bit */
      const int size = reg_total * sizeof(uint64_t);

      if (q->bo)
         intel_bo_unreference(q->bo);

      q->bo = intel_winsys_alloc_buffer(winsys,
            name, size, INTEL_DOMAIN_INSTRUCTION);
      q->reg_total = (q->bo) ? reg_total : 0;
   }

   /* avoid partial reads */
   if (reg_count)
      q->reg_total -= q->reg_total % reg_count;

   q->reg_read = 0;

   return (q->bo != NULL);
}
Beispiel #5
0
static void
ilo_fence_reference(struct pipe_screen *screen,
                    struct pipe_fence_handle **p,
                    struct pipe_fence_handle *f)
{
   struct ilo_fence **ptr = (struct ilo_fence **) p;
   struct ilo_fence *fence = ilo_fence(f);

   if (!ptr) {
      /* still need to reference fence */
      if (fence)
         pipe_reference(NULL, &fence->reference);
      return;
   }

   /* reference fence and dereference the one pointed to by ptr */
   if (*ptr && pipe_reference(&(*ptr)->reference, &fence->reference)) {
      struct ilo_fence *old = *ptr;

      if (old->bo)
         intel_bo_unreference(old->bo);
      FREE(old);
   }

   *ptr = fence;
}
Beispiel #6
0
static void
ilo_context_destroy(struct pipe_context *pipe)
{
   struct ilo_context *ilo = ilo_context(pipe);

   ilo_cleanup_states(ilo);

   if (ilo->last_cp_bo)
      intel_bo_unreference(ilo->last_cp_bo);

   if (ilo->uploader)
      u_upload_destroy(ilo->uploader);

   if (ilo->blitter)
      ilo_blitter_destroy(ilo->blitter);
   if (ilo->hw3d)
      ilo_3d_destroy(ilo->hw3d);
   if (ilo->shader_cache)
      ilo_shader_cache_destroy(ilo->shader_cache);
   if (ilo->cp)
      ilo_cp_destroy(ilo->cp);

   util_slab_destroy(&ilo->transfer_mempool);

   FREE(ilo);
}
Beispiel #7
0
void
ilo_3d_pipeline_destroy(struct ilo_3d_pipeline *p)
{
   if (p->workaround_bo)
      intel_bo_unreference(p->workaround_bo);

   FREE(p);
}
Beispiel #8
0
static void
ilo_destroy_query(struct pipe_context *pipe, struct pipe_query *query)
{
   struct ilo_query *q = ilo_query(query);

   if (q->bo)
      intel_bo_unreference(q->bo);

   FREE(q);
}
Beispiel #9
0
bool
ilo_buffer_rename_bo(struct ilo_buffer *buf)
{
   struct intel_bo *old_bo = buf->bo;

   if (buf_create_bo(buf)) {
      intel_bo_unreference(old_bo);
      return true;
   }
   else {
      buf->bo = old_bo;
      return false;
   }
}
Beispiel #10
0
static boolean
ilo_fence_signalled(struct pipe_screen *screen,
                    struct pipe_fence_handle *f)
{
   struct ilo_fence *fence = ilo_fence(f);

   /* mark signalled if the bo is idle */
   if (fence->bo && !intel_bo_is_busy(fence->bo)) {
      intel_bo_unreference(fence->bo);
      fence->bo = NULL;
   }

   return (fence->bo == NULL);
}
Beispiel #11
0
static void
ilo_context_cp_flushed(struct ilo_cp *cp, void *data)
{
   struct ilo_context *ilo = ilo_context(data);

   if (ilo->last_cp_bo)
      intel_bo_unreference(ilo->last_cp_bo);

   /* remember the just flushed bo, on which fences could wait */
   ilo->last_cp_bo = cp->bo;
   intel_bo_reference(ilo->last_cp_bo);

   ilo_3d_cp_flushed(ilo->hw3d);
}
Beispiel #12
0
/**
 * Destroy the command parser.
 */
void
ilo_cp_destroy(struct ilo_cp *cp)
{
    if (cp->bo) {
        if (!cp->sys)
            intel_bo_unmap(cp->bo);

        intel_bo_unreference(cp->bo);
    }

    if (cp->render_ctx)
        intel_winsys_destroy_context(cp->winsys, cp->render_ctx);

    FREE(cp->sys);
    FREE(cp);
}
Beispiel #13
0
bool
ilo_texture_rename_bo(struct ilo_texture *tex)
{
   struct intel_bo *old_bo = tex->bo;

   /* an imported texture cannot be renamed */
   if (tex->imported)
      return false;

   if (tex_create_bo(tex)) {
      intel_bo_unreference(old_bo);
      return true;
   }
   else {
      tex->bo = old_bo;
      return false;
   }
}
Beispiel #14
0
static boolean
ilo_fence_finish(struct pipe_screen *screen,
                 struct pipe_fence_handle *f,
                 uint64_t timeout)
{
   struct ilo_fence *fence = ilo_fence(f);
   const int64_t wait_timeout = (timeout > INT64_MAX) ? -1 : timeout;

   /* already signalled */
   if (!fence->bo)
      return true;

   /* wait and see if it returns error */
   if (intel_bo_wait(fence->bo, wait_timeout))
      return false;

   /* mark signalled */
   intel_bo_unreference(fence->bo);
   fence->bo = NULL;

   return true;
}
Beispiel #15
0
static bool
tex_import_handle(struct ilo_texture *tex,
                  const struct winsys_handle *handle)
{
   struct ilo_screen *is = ilo_screen(tex->base.screen);
   const char *name = resource_get_bo_name(&tex->base);
   enum intel_tiling_mode tiling;
   unsigned long pitch;

   tex->bo = intel_winsys_import_handle(is->winsys, name, handle,
         tex->layout.bo_height, &tiling, &pitch);
   if (!tex->bo)
      return false;

   if (!ilo_layout_update_for_imported_bo(&tex->layout, tiling, pitch)) {
      ilo_err("imported handle has incompatible tiling/pitch\n");
      intel_bo_unreference(tex->bo);
      tex->bo = NULL;
      return false;
   }

   return true;
}
Beispiel #16
0
static bool
buf_create_bo(struct ilo_buffer *buf)
{
   struct ilo_screen *is = ilo_screen(buf->base.screen);
   const char *name;
   struct intel_bo *bo;

   switch (buf->base.bind) {
   case PIPE_BIND_VERTEX_BUFFER:
      name = "vertex buffer";
      break;
   case PIPE_BIND_INDEX_BUFFER:
      name = "index buffer";
      break;
   case PIPE_BIND_CONSTANT_BUFFER:
      name = "constant buffer";
      break;
   case PIPE_BIND_STREAM_OUTPUT:
      name = "stream output";
      break;
   default:
      name = "unknown buffer";
      break;
   }

   bo = intel_winsys_alloc_buffer(is->winsys,
         name, buf->bo_size, buf->bo_flags);
   if (!bo)
      return false;

   if (buf->bo)
      intel_bo_unreference(buf->bo);

   buf->bo = bo;

   return true;
}
Beispiel #17
0
static void
buf_destroy(struct ilo_buffer *buf)
{
   intel_bo_unreference(buf->bo);
   FREE(buf);
}
Beispiel #18
0
static bool
tex_create_bo(struct ilo_texture *tex,
              const struct winsys_handle *handle)
{
   struct ilo_screen *is = ilo_screen(tex->base.screen);
   const char *name;
   struct intel_bo *bo;
   enum intel_tiling_mode tiling;
   unsigned long pitch;

   switch (tex->base.target) {
   case PIPE_TEXTURE_1D:
      name = "1D texture";
      break;
   case PIPE_TEXTURE_2D:
      name = "2D texture";
      break;
   case PIPE_TEXTURE_3D:
      name = "3D texture";
      break;
   case PIPE_TEXTURE_CUBE:
      name = "cube texture";
      break;
   case PIPE_TEXTURE_RECT:
      name = "rectangle texture";
      break;
   case PIPE_TEXTURE_1D_ARRAY:
      name = "1D array texture";
      break;
   case PIPE_TEXTURE_2D_ARRAY:
      name = "2D array texture";
      break;
   case PIPE_TEXTURE_CUBE_ARRAY:
      name = "cube array texture";
      break;
   default:
      name ="unknown texture";
      break;
   }

   if (handle) {
      bo = intel_winsys_import_handle(is->winsys, name, handle,
            tex->bo_width, tex->bo_height, tex->bo_cpp,
            &tiling, &pitch);
   }
   else {
      bo = intel_winsys_alloc_texture(is->winsys, name,
            tex->bo_width, tex->bo_height, tex->bo_cpp,
            tex->tiling, tex->bo_flags, &pitch);

      tiling = tex->tiling;
   }

   if (!bo)
      return false;

   if (tex->bo)
      intel_bo_unreference(tex->bo);

   tex->bo = bo;
   tex->tiling = tiling;
   tex->bo_stride = pitch;

   return true;
}