PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
};
+
+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 INLINE void
render_pixel_to_float4(PictFormatPtr format,
CARD32 pixel, float *color)
return FALSE;
}
+static void
+bind_clip_state(struct exa_context *exa)
+{
+ struct pipe_depth_stencil_alpha_state dsa;
+
+ memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state));
+ cso_set_depth_stencil_alpha(exa->cso, &dsa);
+}
+
static void
bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
{
int width = pDst->tex->width[0];
int height = pDst->tex->height[0];
+ debug_printf("Bind viewport (%d, %d)\n", width, height);
+
set_viewport(exa, width, height, Y0_TOP);
}
bind_blend_state(struct exa_context *exa, int op,
PicturePtr pSrcPicture, PicturePtr pMaskPicture)
{
- boolean component_alpha = pSrcPicture->componentAlpha;
+ boolean component_alpha = (pSrcPicture) ?
+ pSrcPicture->componentAlpha : FALSE;
struct xorg_composite_blend blend_opt;
struct pipe_blend_state blend;
unsigned vs_traits = 0, fs_traits = 0;
struct xorg_shader shader;
+ exa->has_solid_color = FALSE;
+
if (pSrcPicture) {
if (pSrcPicture->pSourcePict) {
if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
render_pixel_to_float4(pSrcPicture->pFormat,
pSrcPicture->pSourcePict->solidFill.color,
exa->solid_color);
+ exa->has_solid_color = TRUE;
} else {
debug_assert("!gradients not supported");
}
}
static void
-setup_constant_buffers(struct exa_context *exa, PicturePtr pDstPicture)
+setup_constant_buffers(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];
setup_vs_constant_buffer(exa, width, height);
setup_fs_constant_buffer(exa);
bind_shaders(exa, op, pSrcPicture, pMaskPicture);
bind_samplers(exa, op, pSrcPicture, pMaskPicture,
pDstPicture, pSrc, pMask, pDst);
-
- setup_constant_buffers(exa, pDstPicture);
+ bind_clip_state(exa);
+ setup_constant_buffers(exa, pDst);
return FALSE;
}
}
if (buf) {
+ int num_attribs = 1; /*pos*/
+ num_attribs += exa->num_bound_samplers;
+ if (exa->has_solid_color)
+ ++num_attribs;
+
util_draw_vertex_buffer(pipe, buf, 0,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
- 1 + exa->num_bound_samplers); /* attribs/vert */
+ num_attribs); /* attribs/vert */
pipe_buffer_reference(&buf, NULL);
}
struct exa_pixmap_priv *pixmap,
Pixel fg)
{
-
+ unsigned vs_traits, fs_traits;
+ struct xorg_shader shader;
+
+ pixel_to_float4(fg, exa->solid_color);
+ exa->has_solid_color = TRUE;
+
+ exa->solid_color[3] = 1.f;
+
+ debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
+ (fg >> 24) & 0xff, (fg >> 16) & 0xff,
+ (fg >> 8) & 0xff, (fg >> 0) & 0xff,
+ exa->solid_color[0], exa->solid_color[1],
+ exa->solid_color[2], exa->solid_color[3]);
+
+#if 0
+ exa->solid_color[0] = 1.f;
+ exa->solid_color[1] = 0.f;
+ exa->solid_color[2] = 0.f;
+ exa->solid_color[3] = 1.f;
+#endif
+
+ vs_traits = VS_SOLID_FILL;
+ fs_traits = FS_SOLID_FILL;
+
+ bind_framebuffer_state(exa, pixmap);
+ bind_viewport_state(exa, pixmap);
+ bind_rasterizer_state(exa);
+ bind_blend_state(exa, PictOpSrc, NULL, NULL);
+ setup_constant_buffers(exa, pixmap);
+ bind_clip_state(exa);
+
+ shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits);
+ cso_set_vertex_shader_handle(exa->cso, shader.vs);
+ cso_set_fragment_shader_handle(exa->cso, shader.fs);
+
return TRUE;
}
struct exa_pixmap_priv *pixmap,
int x0, int y0, int x1, int y1)
{
+ struct pipe_context *pipe = exa->ctx;
+ struct pipe_buffer *buf = 0;
+ float vertices[4][2][4];
+
+ x0 = 10; y0 = 10;
+ x1 = 300; y1 = 300;
+
+ /* 1st vertex */
+ setup_vertex0(vertices[0], x0, y0,
+ exa->solid_color);
+ /* 2nd vertex */
+ setup_vertex0(vertices[1], x1, y0,
+ exa->solid_color);
+ /* 3rd vertex */
+ setup_vertex0(vertices[2], x1, y1,
+ exa->solid_color);
+ /* 4th vertex */
+ setup_vertex0(vertices[3], x0, y1,
+ exa->solid_color);
+
+ buf = pipe_user_buffer_create(exa->ctx->screen,
+ vertices,
+ sizeof(vertices));
+
+
+ if (buf) {
+ debug_printf("Drawing buf is %p\n", buf);
+ util_draw_vertex_buffer(pipe, buf, 0,
+ PIPE_PRIM_TRIANGLE_FAN,
+ 4, /* verts */
+ 2); /* attribs/vert */
+
+ pipe_buffer_reference(&buf, NULL);
+ }
}
}
}
-
-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
*/
modesettingPtr ms = modesettingPTR(pScrn);
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
struct exa_context *exa = ms->exa;
+ struct pipe_fence_handle *fence = NULL;
if (!priv)
return;
+ exa->ctx->flush(exa->ctx, PIPE_FLUSH_RENDER_CACHE, &fence);
+ exa->ctx->screen->fence_finish(exa->ctx->screen, fence, 0);
+ exa->ctx->screen->fence_reference(exa->ctx->screen, &fence, NULL);
+
if (priv->src_surf)
exa->scrn->tex_surface_destroy(priv->src_surf);
priv->src_surf = NULL;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
struct exa_context *exa = ms->exa;
- debug_printf("ExaPrepareSolid\n");
+ debug_printf("ExaPrepareSolid - test\n");
if (pPixmap->drawable.depth < 15)
return FALSE;
if (!exa->ctx)
return FALSE;
+ debug_printf(" ExaPrepareSolid(0x%x)\n", fg);
return xorg_solid_bind_state(exa, priv, fg);
}
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
- debug_printf("\tExaSolid\n");
- xorg_solid(exa, priv, x0, y0, x1, y1) ;
+ debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
+
+#if 0
+ if (x0 == 0 && y0 == 0 &&
+ x1 == priv->tex->width[0] &&
+ y1 == priv->tex->height[0]) {
+ exa->ctx->clear(exa->ctx, PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL,
+ exa->solid_color, 1., 0);
+ } else
+#endif
+ xorg_solid(exa, priv, x0, y0, x1, y1) ;
}
static Bool
modesettingPtr ms = modesettingPTR(pScrn);
struct exa_context *exa = ms->exa;
- debug_printf("ExaPrepareComposite\n");
+ debug_printf("ExaPrepareComposite\n");
return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
pDstPicture,
struct exa_context *exa = ms->exa;
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
- debug_printf("\tExaComposite\n");
+ debug_printf("\tExaComposite\n");
xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
dstX, dstY, width, height);