st/xorg: start adding support for surface fills
This commit is contained in:
@@ -41,8 +41,8 @@ static const struct xorg_composite_blend xorg_blends[] = {
|
||||
};
|
||||
|
||||
static INLINE void
|
||||
pixel_to_float4(PictFormatPtr format,
|
||||
CARD32 pixel, float *color)
|
||||
render_pixel_to_float4(PictFormatPtr format,
|
||||
CARD32 pixel, float *color)
|
||||
{
|
||||
CARD32 r, g, b, a;
|
||||
|
||||
@@ -291,16 +291,15 @@ boolean xorg_composite_accelerated(int op,
|
||||
}
|
||||
|
||||
static void
|
||||
bind_framebuffer_state(struct exa_context *exa, PicturePtr pDstPicture,
|
||||
struct exa_pixmap_priv *pDst)
|
||||
bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
|
||||
{
|
||||
unsigned i;
|
||||
struct pipe_framebuffer_state state;
|
||||
struct pipe_surface *surface = exa_gpu_surface(exa, pDst);
|
||||
memset(&state, 0, sizeof(struct pipe_framebuffer_state));
|
||||
|
||||
state.width = pDstPicture->pDrawable->width;
|
||||
state.height = pDstPicture->pDrawable->height;
|
||||
state.width = pDst->tex->width[0];
|
||||
state.height = pDst->tex->height[0];
|
||||
|
||||
state.nr_cbufs = 1;
|
||||
state.cbufs[0] = surface;
|
||||
@@ -338,10 +337,10 @@ set_viewport(struct exa_context *exa, int width, int height,
|
||||
}
|
||||
|
||||
static void
|
||||
bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture)
|
||||
bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
|
||||
{
|
||||
int width = pDstPicture->pDrawable->width;
|
||||
int height = pDstPicture->pDrawable->height;
|
||||
int width = pDst->tex->width[0];
|
||||
int height = pDst->tex->height[0];
|
||||
|
||||
set_viewport(exa, width, height, Y0_TOP);
|
||||
}
|
||||
@@ -395,9 +394,9 @@ bind_shaders(struct exa_context *exa, int op,
|
||||
if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
|
||||
fs_traits |= FS_SOLID_FILL;
|
||||
vs_traits |= VS_SOLID_FILL;
|
||||
pixel_to_float4(pSrcPicture->pFormat,
|
||||
pSrcPicture->pSourcePict->solidFill.color,
|
||||
exa->solid_color);
|
||||
render_pixel_to_float4(pSrcPicture->pFormat,
|
||||
pSrcPicture->pSourcePict->solidFill.color,
|
||||
exa->solid_color);
|
||||
} else {
|
||||
debug_assert("!gradients not supported");
|
||||
}
|
||||
@@ -530,8 +529,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
|
||||
struct exa_pixmap_priv *pMask,
|
||||
struct exa_pixmap_priv *pDst)
|
||||
{
|
||||
bind_framebuffer_state(exa, pDstPicture, pDst);
|
||||
bind_viewport_state(exa, pDstPicture);
|
||||
bind_framebuffer_state(exa, pDst);
|
||||
bind_viewport_state(exa, pDst);
|
||||
bind_blend_state(exa, op, pSrcPicture, pMaskPicture);
|
||||
bind_rasterizer_state(exa);
|
||||
bind_shaders(exa, op, pSrcPicture, pMaskPicture);
|
||||
@@ -582,3 +581,17 @@ void xorg_composite(struct exa_context *exa,
|
||||
}
|
||||
}
|
||||
|
||||
boolean xorg_solid_bind_state(struct exa_context *exa,
|
||||
struct exa_pixmap_priv *pixmap,
|
||||
Pixel fg)
|
||||
{
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void xorg_solid(struct exa_context *exa,
|
||||
struct exa_pixmap_priv *pixmap,
|
||||
int x0, int y0, int x1, int y1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,11 @@ void xorg_composite(struct exa_context *exa,
|
||||
int srcX, int srcY, int maskX, int maskY,
|
||||
int dstX, int dstY, int width, int height);
|
||||
|
||||
boolean xorg_solid_bind_state(struct exa_context *exa,
|
||||
struct exa_pixmap_priv *pixmap,
|
||||
Pixel fg);
|
||||
void xorg_solid(struct exa_context *exa,
|
||||
struct exa_pixmap_priv *pixmap,
|
||||
int x0, int y0, int x1, int y1);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,22 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static INLINE void
|
||||
pixel_to_float4(Pixel pixel, float *color)
|
||||
{
|
||||
CARD32 r, g, b, a;
|
||||
|
||||
a = (pixel >> 24) & 0xff;
|
||||
r = (pixel >> 16) & 0xff;
|
||||
g = (pixel >> 8) & 0xff;
|
||||
b = (pixel >> 0) & 0xff;
|
||||
color[0] = ((float)r) / 255.;
|
||||
color[1] = ((float)g) / 255.;
|
||||
color[2] = ((float)b) / 255.;
|
||||
color[3] = ((float)a) / 255.;
|
||||
}
|
||||
|
||||
/*
|
||||
* Static exported EXA functions
|
||||
*/
|
||||
@@ -250,6 +266,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
|
||||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
|
||||
struct exa_context *exa = ms->exa;
|
||||
|
||||
debug_printf("ExaPrepareSolid\n");
|
||||
if (pPixmap->drawable.depth < 15)
|
||||
return FALSE;
|
||||
|
||||
@@ -262,12 +279,10 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
|
||||
if (alu != GXcopy)
|
||||
return FALSE;
|
||||
|
||||
if (!exa->ctx || !exa->ctx->surface_fill)
|
||||
if (!exa->ctx)
|
||||
return FALSE;
|
||||
|
||||
priv->color = fg;
|
||||
|
||||
return TRUE;
|
||||
return xorg_solid_bind_state(exa, priv, fg);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -277,12 +292,9 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
|
||||
modesettingPtr ms = modesettingPTR(pScrn);
|
||||
struct exa_context *exa = ms->exa;
|
||||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
|
||||
struct pipe_surface *surf = exa_gpu_surface(exa, priv);
|
||||
|
||||
exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0,
|
||||
priv->color);
|
||||
|
||||
exa->scrn->tex_surface_destroy(surf);
|
||||
debug_printf("\tExaSolid\n");
|
||||
xorg_solid(exa, priv, x0, y0, x1, y1) ;
|
||||
}
|
||||
|
||||
static Bool
|
||||
@@ -295,6 +307,8 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
|
||||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
|
||||
struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
|
||||
|
||||
debug_printf("ExaPrepareCopy\n");
|
||||
|
||||
if (alu != GXcopy)
|
||||
return FALSE;
|
||||
|
||||
@@ -328,6 +342,8 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
|
||||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
|
||||
struct pipe_surface *surf = exa_gpu_surface(exa, priv);
|
||||
|
||||
debug_printf("\tExaCopy\n");
|
||||
|
||||
exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf,
|
||||
srcX, srcY, width, height);
|
||||
exa->scrn->tex_surface_destroy(surf);
|
||||
@@ -342,6 +358,8 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
|
||||
modesettingPtr ms = modesettingPTR(pScrn);
|
||||
struct exa_context *exa = ms->exa;
|
||||
|
||||
debug_printf("ExaPrepareComposite\n");
|
||||
|
||||
return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
|
||||
pDstPicture,
|
||||
exaGetPixmapDriverPrivate(pSrc),
|
||||
@@ -358,6 +376,8 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
|
||||
struct exa_context *exa = ms->exa;
|
||||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
|
||||
|
||||
debug_printf("\tExaComposite\n");
|
||||
|
||||
xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
|
||||
dstX, dstY, width, height);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct exa_pixmap_priv
|
||||
|
||||
struct pipe_texture *tex;
|
||||
struct pipe_texture *depth_stencil_tex;
|
||||
unsigned int color;
|
||||
float solid_color[4];
|
||||
struct pipe_surface *src_surf; /* for copies */
|
||||
|
||||
struct pipe_transfer *map_transfer;
|
||||
|
||||
@@ -318,8 +318,8 @@ create_fs(struct pipe_context *pipe,
|
||||
TGSI_SEMANTIC_POSITION,
|
||||
0,
|
||||
TGSI_INTERPOLATE_PERSPECTIVE);
|
||||
}
|
||||
if (is_fill) {
|
||||
} else {
|
||||
debug_assert(is_fill);
|
||||
if (is_solid)
|
||||
src_input = ureg_DECL_fs_input(ureg,
|
||||
TGSI_SEMANTIC_COLOR,
|
||||
|
||||
Reference in New Issue
Block a user