summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-09-09 11:33:33 -0400
committerZack Rusin <[email protected]>2009-09-10 17:21:06 -0400
commit6be1a98ab9d64584c3852b97e2f1d63697f7bf76 (patch)
treee03ae17bf95a2a6de64cb1eebc746496b805ca6f /src/gallium/state_trackers
parent3167c2e8a0a248c290ae8bfff23c88db8f39cd11 (diff)
st/xorg: implement exasolids with full pipelining
plus fix some small issues with the shaders
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c120
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c41
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.h2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.c4
4 files changed, 135 insertions, 32 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index 1f8fbd16103..778a8a183ea 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -40,6 +40,22 @@ static const struct xorg_composite_blend xorg_blends[] = {
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)
@@ -291,6 +307,15 @@ boolean xorg_composite_accelerated(int op,
}
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)
{
unsigned i;
@@ -342,6 +367,8 @@ bind_viewport_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);
}
@@ -349,7 +376,8 @@ static void
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;
@@ -389,6 +417,8 @@ bind_shaders(struct exa_context *exa, int op,
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) {
@@ -397,6 +427,7 @@ bind_shaders(struct exa_context *exa, int op,
render_pixel_to_float4(pSrcPicture->pFormat,
pSrcPicture->pSourcePict->solidFill.color,
exa->solid_color);
+ exa->has_solid_color = TRUE;
} else {
debug_assert("!gradients not supported");
}
@@ -511,10 +542,10 @@ setup_fs_constant_buffer(struct exa_context *exa)
}
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);
@@ -536,8 +567,8 @@ boolean xorg_composite_bind_state(struct exa_context *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;
}
@@ -572,10 +603,15 @@ void xorg_composite(struct exa_context *exa,
}
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);
}
@@ -585,7 +621,41 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
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;
}
@@ -593,5 +663,39 @@ void xorg_solid(struct exa_context *exa,
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);
+ }
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index cf4478a03d4..1eed3d86f7b 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -82,22 +82,6 @@ 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
*/
@@ -243,10 +227,15 @@ ExaDone(PixmapPtr pPixmap)
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;
@@ -266,7 +255,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");
+ debug_printf("ExaPrepareSolid - test\n");
if (pPixmap->drawable.depth < 15)
return FALSE;
@@ -282,6 +271,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
if (!exa->ctx)
return FALSE;
+ debug_printf(" ExaPrepareSolid(0x%x)\n", fg);
return xorg_solid_bind_state(exa, priv, fg);
}
@@ -293,8 +283,17 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
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
@@ -358,7 +357,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
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,
@@ -376,7 +375,7 @@ 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");
+ debug_printf("\tExaComposite\n");
xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
dstX, dstY, width, height);
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h
index a62c57bf4a3..64b6de70485 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa.h
@@ -26,6 +26,7 @@ struct exa_context
int num_bound_samplers;
float solid_color[4];
+ boolean has_solid_color;
};
@@ -36,7 +37,6 @@ struct exa_pixmap_priv
struct pipe_texture *tex;
struct pipe_texture *depth_stencil_tex;
- float solid_color[4];
struct pipe_surface *src_surf; /* for copies */
struct pipe_transfer *map_transfer;
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index 14d5605f392..2d2c2e884b3 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -268,8 +268,8 @@ create_vs(struct pipe_context *pipe,
}
if (is_fill) {
src = ureg_DECL_vs_input(ureg,
- TGSI_SEMANTIC_COLOR, 1);
- dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 1);
+ TGSI_SEMANTIC_COLOR, 0);
+ dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
ureg_MOV(ureg, dst, src);
}