Esempio n. 1
0
static void
dri3_free_front_buffer(struct vl_dri3_screen *scrn,
                        struct vl_dri3_buffer *buffer)
{
   xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
   xshmfence_unmap_shm(buffer->shm_fence);
   FREE(buffer);
}
Esempio n. 2
0
static void
dri3_free_front_buffer(struct vl_dri3_screen *scrn,
                        struct vl_dri3_buffer *buffer)
{
   xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
   xshmfence_unmap_shm(buffer->shm_fence);
   pipe_resource_reference(&buffer->texture, NULL);
   FREE(buffer);
}
Esempio n. 3
0
/** dri3_free_render_buffer
 *
 * Free everything associated with one render buffer including pixmap, fence
 * stuff and the driver image
 */
static void
dri3_free_render_buffer(struct loader_dri3_drawable *draw,
                        struct loader_dri3_buffer *buffer)
{
   if (buffer->own_pixmap)
      xcb_free_pixmap(draw->conn, buffer->pixmap);
   xcb_sync_destroy_fence(draw->conn, buffer->sync_fence);
   xshmfence_unmap_shm(buffer->shm_fence);
   (draw->ext->image->destroyImage)(buffer->image);
   if (buffer->linear_buffer)
      (draw->ext->image->destroyImage)(buffer->linear_buffer);
   free(buffer);
}
Esempio n. 4
0
static void
dri3_free_back_buffer(struct vl_dri3_screen *scrn,
                        struct vl_dri3_buffer *buffer)
{
   xcb_free_pixmap(scrn->conn, buffer->pixmap);
   xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
   xshmfence_unmap_shm(buffer->shm_fence);
   if (!scrn->output_texture)
      pipe_resource_reference(&buffer->texture, NULL);
   if (buffer->linear_texture)
       pipe_resource_reference(&buffer->linear_texture, NULL);
   FREE(buffer);
}
Esempio n. 5
0
static void
x11_image_finish(struct x11_swapchain *chain,
                 const VkAllocationCallbacks* pAllocator,
                 struct x11_image *image)
{
   xcb_void_cookie_t cookie;

   cookie = xcb_sync_destroy_fence(chain->conn, image->sync_fence);
   xcb_discard_reply(chain->conn, cookie.sequence);
   xshmfence_unmap_shm(image->shm_fence);

   cookie = xcb_free_pixmap(chain->conn, image->pixmap);
   xcb_discard_reply(chain->conn, cookie.sequence);

   chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
                                        image->image, image->memory);
}
Esempio n. 6
0
/** dri3_get_pixmap_buffer
 *
 * Get the DRM object for a pixmap from the X server and
 * wrap that with a __DRIimage structure using createImageFromFds
 */
static struct loader_dri3_buffer *
dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format,
                       enum loader_dri3_buffer_type buffer_type,
                       struct loader_dri3_drawable *draw)
{
   int                                  buf_id = loader_dri3_pixmap_buf_id(buffer_type);
   struct loader_dri3_buffer            *buffer = draw->buffers[buf_id];
   xcb_drawable_t                       pixmap;
   xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie;
   xcb_dri3_buffer_from_pixmap_reply_t  *bp_reply;
   xcb_sync_fence_t                     sync_fence;
   struct xshmfence                     *shm_fence;
   int                                  fence_fd;

   if (buffer)
      return buffer;

   pixmap = draw->drawable;

   buffer = calloc(1, sizeof *buffer);
   if (!buffer)
      goto no_buffer;

   fence_fd = xshmfence_alloc_shm();
   if (fence_fd < 0)
      goto no_fence;
   shm_fence = xshmfence_map_shm(fence_fd);
   if (shm_fence == NULL) {
      close (fence_fd);
      goto no_fence;
   }

   xcb_dri3_fence_from_fd(draw->conn,
                          pixmap,
                          (sync_fence = xcb_generate_id(draw->conn)),
                          false,
                          fence_fd);

   bp_cookie = xcb_dri3_buffer_from_pixmap(draw->conn, pixmap);
   bp_reply = xcb_dri3_buffer_from_pixmap_reply(draw->conn, bp_cookie, NULL);
   if (!bp_reply)
      goto no_image;

   buffer->image = loader_dri3_create_image(draw->conn, bp_reply, format,
                                            draw->dri_screen, draw->ext->image,
                                            buffer);
   if (!buffer->image)
      goto no_image;

   buffer->pixmap = pixmap;
   buffer->own_pixmap = false;
   buffer->width = bp_reply->width;
   buffer->height = bp_reply->height;
   buffer->buffer_type = buffer_type;
   buffer->shm_fence = shm_fence;
   buffer->sync_fence = sync_fence;

   draw->buffers[buf_id] = buffer;

   free(bp_reply);

   return buffer;

no_image:
   free(bp_reply);
   xcb_sync_destroy_fence(draw->conn, sync_fence);
   xshmfence_unmap_shm(shm_fence);
no_fence:
   free(buffer);
no_buffer:
   return NULL;
}
Esempio n. 7
0
/** dri3_get_pixmap_buffer
 *
 * Get the DRM object for a pixmap from the X server and
 * wrap that with a __DRIimage structure using createImageFromFds
 */
static struct loader_dri3_buffer *
dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format,
                       enum loader_dri3_buffer_type buffer_type,
                       struct loader_dri3_drawable *draw)
{
    int                                  buf_id = loader_dri3_pixmap_buf_id(buffer_type);
    struct loader_dri3_buffer            *buffer = draw->buffers[buf_id];
    xcb_drawable_t                       pixmap;
    xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie;
    xcb_dri3_buffer_from_pixmap_reply_t  *bp_reply;
    xcb_sync_fence_t                     sync_fence;
    struct xshmfence                     *shm_fence;
    int                                  fence_fd;
    __DRIscreen                          *cur_screen;

    if (buffer)
        return buffer;

    pixmap = draw->drawable;

    buffer = calloc(1, sizeof *buffer);
    if (!buffer)
        goto no_buffer;

    fence_fd = xshmfence_alloc_shm();
    if (fence_fd < 0)
        goto no_fence;
    shm_fence = xshmfence_map_shm(fence_fd);
    if (shm_fence == NULL) {
        close (fence_fd);
        goto no_fence;
    }

    xcb_dri3_fence_from_fd(draw->conn,
                           pixmap,
                           (sync_fence = xcb_generate_id(draw->conn)),
                           false,
                           fence_fd);

    bp_cookie = xcb_dri3_buffer_from_pixmap(draw->conn, pixmap);
    bp_reply = xcb_dri3_buffer_from_pixmap_reply(draw->conn, bp_cookie, NULL);
    if (!bp_reply)
        goto no_image;

    /* Get the currently-bound screen or revert to using the drawable's screen if
     * no contexts are currently bound. The latter case is at least necessary for
     * obs-studio, when using Window Capture (Xcomposite) as a Source.
     */
    cur_screen = draw->vtable->get_dri_screen(draw);
    if (!cur_screen) {
        cur_screen = draw->dri_screen;
    }

    buffer->image = loader_dri3_create_image(draw->conn, bp_reply, format,
                    cur_screen, draw->ext->image,
                    buffer);
    if (!buffer->image)
        goto no_image;

    buffer->pixmap = pixmap;
    buffer->own_pixmap = false;
    buffer->width = bp_reply->width;
    buffer->height = bp_reply->height;
    buffer->buffer_type = buffer_type;
    buffer->shm_fence = shm_fence;
    buffer->sync_fence = sync_fence;

    draw->buffers[buf_id] = buffer;

    free(bp_reply);

    return buffer;

no_image:
    free(bp_reply);
    xcb_sync_destroy_fence(draw->conn, sync_fence);
    xshmfence_unmap_shm(shm_fence);
no_fence:
    free(buffer);
no_buffer:
    return NULL;
}