int xa_copy_prepare(struct xa_context *ctx, struct xa_surface *dst, struct xa_surface *src) { if (src == dst || dst->srf != NULL) return -XA_ERR_INVAL; if (src->tex->format != dst->tex->format) { int ret = xa_surface_psurf_create(ctx, dst); if (ret != XA_ERR_NONE) return ret; renderer_copy_prepare(ctx, dst->srf, src->tex); ctx->simple_copy = 0; } else ctx->simple_copy = 1; ctx->src = src; ctx->dst = dst; return 0; }
XA_EXPORT int xa_copy_prepare(struct xa_context *ctx, struct xa_surface *dst, struct xa_surface *src) { if (src == dst) return -XA_ERR_INVAL; if (src->tex->format != dst->tex->format) { int ret = xa_ctx_srf_create(ctx, dst); if (ret != XA_ERR_NONE) return ret; renderer_copy_prepare(ctx, ctx->srf, src->tex, src->fdesc.xa_format, dst->fdesc.xa_format); ctx->simple_copy = 0; } else ctx->simple_copy = 1; ctx->src = src; ctx->dst = dst; xa_ctx_srf_destroy(ctx); return 0; }
static Bool ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, int alu, Pixel planeMask) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); exa_debug_printf("ExaPrepareCopy\n"); if (!exa->accel) return FALSE; if (!exa->pipe) XORG_FALLBACK("accel not enabled"); if (!priv || !priv->tex) XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex"); if (!src_priv || !src_priv->tex) XORG_FALLBACK("pSrc %s", !src_priv ? "!priv" : "!priv->tex"); if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) XORG_FALLBACK("planeMask is not solid"); if (alu != GXcopy) XORG_FALLBACK("alu not GXcopy"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, priv->tex->target, 0, PIPE_BIND_RENDER_TARGET)) XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format)); if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format, src_priv->tex->target, 0, PIPE_BIND_SAMPLER_VIEW)) XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format)); exa->copy.src = src_priv; exa->copy.dst = priv; /* XXX this used to use resource_copy_region for same-surface copies, * but they were redefined to not allow overlaps (some of the util code * always assumed this anyway). * Drivers should implement accelerated resource_copy_region or it will * be slow - disable for now. */ if (0 && exa->copy.src != exa->copy.dst) { exa->copy.use_surface_copy = TRUE; } else { struct pipe_surface surf_tmpl; exa->copy.use_surface_copy = FALSE; if (exa->copy.dst == exa->copy.src) exa->copy.src_texture = renderer_clone_texture( exa->renderer, exa->copy.src->tex ); else pipe_resource_reference(&exa->copy.src_texture, exa->copy.src->tex); memset(&surf_tmpl, 0, sizeof(surf_tmpl)); u_surface_default_template(&surf_tmpl, exa->copy.dst->tex, PIPE_BIND_RENDER_TARGET); exa->copy.dst_surface = exa->pipe->create_surface(exa->pipe, exa->copy.dst->tex, &surf_tmpl); renderer_copy_prepare(exa->renderer, exa->copy.dst_surface, exa->copy.src_texture ); } return TRUE; }
static Bool ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, int alu, Pixel planeMask) { ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); struct exa_context *exa = ms->exa; struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); #if DEBUG_PRINT debug_printf("ExaPrepareCopy\n"); #endif if (!exa->accel) return FALSE; if (!exa->pipe) XORG_FALLBACK("accle not enabled"); if (!priv || !priv->tex) XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex"); if (!src_priv || !src_priv->tex) XORG_FALLBACK("pSrc %s", !src_priv ? "!priv" : "!priv->tex"); if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) XORG_FALLBACK("planeMask is not solid"); if (alu != GXcopy) XORG_FALLBACK("alu not GXcopy"); if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, priv->tex->target, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format)); if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format, src_priv->tex->target, PIPE_TEXTURE_USAGE_SAMPLER, 0)) XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format)); exa->copy.src = src_priv; exa->copy.dst = priv; /* For same-surface copies, the pipe->surface_copy path is clearly * superior, providing it is implemented. In other cases it's not * clear what the better path would be, and eventually we'd * probably want to gather timings and choose dynamically. */ if (exa->pipe->surface_copy && exa->copy.src == exa->copy.dst) { exa->copy.use_surface_copy = TRUE; exa->copy.src_surface = exa->scrn->get_tex_surface( exa->scrn, exa->copy.src->tex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); exa->copy.dst_surface = exa->scrn->get_tex_surface( exa->scrn, exa->copy.dst->tex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); } else { exa->copy.use_surface_copy = FALSE; if (exa->copy.dst == exa->copy.src) exa->copy.src_texture = renderer_clone_texture( exa->renderer, exa->copy.src->tex ); else pipe_texture_reference(&exa->copy.src_texture, exa->copy.src->tex); exa->copy.dst_surface = exa->scrn->get_tex_surface(exa->scrn, exa->copy.dst->tex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); renderer_copy_prepare(exa->renderer, exa->copy.dst_surface, exa->copy.src_texture ); } return TRUE; }