summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-11-06 07:36:47 -0500
committerZack Rusin <[email protected]>2009-11-06 22:08:21 -0500
commit4322346f3fd03788a79d056ca7bce2db25bc9d88 (patch)
tree2ebf9af8ee85cc636c056b5d401f3064dc07daa3 /src/gallium
parente1730632aa5ca1dbb0edd484e2357246ec537abb (diff)
st/xorg: batch solid fill requests
instead of lots of very small transfers, one larger is a lot better for performance
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c14
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c46
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c88
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.h13
4 files changed, 66 insertions, 95 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index a8d779b8ad1..93fcdaf44d9 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -440,9 +440,11 @@ void xorg_composite(struct exa_context *exa,
int dstX, int dstY, int width, int height)
{
if (exa->num_bound_samplers == 0 ) { /* solid fill */
- renderer_draw_solid_rect(exa->renderer,
- dstX, dstY, dstX + width, dstY + height,
- exa->solid_color);
+ renderer_begin_solid(exa->renderer);
+ renderer_solid(exa->renderer,
+ dstX, dstY, dstX + width, dstY + height,
+ exa->solid_color);
+ renderer_draw_flush(exa->renderer);
} else {
int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY};
float *src_matrix = NULL;
@@ -492,6 +494,8 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs);
cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs);
+ renderer_begin_solid(exa->renderer);
+
return TRUE;
}
@@ -499,7 +503,7 @@ void xorg_solid(struct exa_context *exa,
struct exa_pixmap_priv *pixmap,
int x0, int y0, int x1, int y1)
{
- renderer_draw_solid_rect(exa->renderer,
- x0, y0, x1, y1, exa->solid_color);
+ renderer_solid(exa->renderer,
+ x0, y0, x1, y1, exa->solid_color);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index bd97baae2b6..99362e01f2c 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -46,7 +46,6 @@
#include "util/u_rect.h"
#define DEBUG_PRINT 0
-#define DEBUG_SOLID 0
#define ACCEL_ENABLED TRUE
/*
@@ -277,6 +276,8 @@ ExaDone(PixmapPtr pPixmap)
if (!priv)
return;
+ renderer_draw_flush(exa->renderer);
+
xorg_exa_common_done(exa);
}
@@ -319,10 +320,6 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
XORG_FALLBACK("format %s", pf_name(priv->tex->format));
}
-#if DEBUG_SOLID
- fg = 0xffff0000;
-#endif
-
return ACCEL_ENABLED && xorg_solid_bind_state(exa, priv, fg);
}
@@ -338,46 +335,7 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1);
#endif
-#if 0
- if (x0 == 0 && y0 == 0 &&
- x1 == priv->tex->width[0] &&
- y1 == priv->tex->height[0]) {
- exa->ctx->clear(exa->pipe, PIPE_CLEAR_COLOR,
- exa->solid_color, 1., 0);
- } else
-#endif
-
-#if DEBUG_SOLID
- exa->solid_color[0] = 0.f;
- exa->solid_color[1] = 1.f;
- exa->solid_color[2] = 0.f;
- exa->solid_color[3] = 1.f;
- xorg_solid(exa, priv, 0, 0, 1024, 768);
- exa->solid_color[0] = 1.f;
- exa->solid_color[1] = 0.f;
- exa->solid_color[2] = 0.f;
- exa->solid_color[3] = 1.f;
- xorg_solid(exa, priv, 0, 0, 300, 300);
- xorg_solid(exa, priv, 300, 300, 350, 350);
- xorg_solid(exa, priv, 350, 350, 500, 500);
-
- xorg_solid(exa, priv,
- priv->tex->width[0] - 10,
- priv->tex->height[0] - 10,
- priv->tex->width[0],
- priv->tex->height[0]);
-
- exa->solid_color[0] = 0.f;
- exa->solid_color[1] = 0.f;
- exa->solid_color[2] = 1.f;
- exa->solid_color[3] = 1.f;
-
- exa->has_solid_color = FALSE;
- ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff);
- ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500);
-#else
xorg_solid(exa, priv, x0, y0, x1, y1) ;
-#endif
}
static Bool
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 08aaef77350..52cde5428b7 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -57,6 +57,37 @@ renderer_buffer_create(struct xorg_renderer *r)
return buf;
}
+static INLINE void
+renderer_draw(struct xorg_renderer *r)
+{
+ struct pipe_context *pipe = r->pipe;
+ struct pipe_buffer *buf = 0;
+
+ if (!r->num_vertices)
+ return;
+
+ buf = renderer_buffer_create(r);
+
+
+ if (buf) {
+ util_draw_vertex_buffer(pipe, buf, 0,
+ PIPE_PRIM_QUADS,
+ 4, /* verts */
+ 2); /* attribs/vert */
+
+ pipe_buffer_reference(&buf, NULL);
+ }
+}
+
+static INLINE void
+renderer_draw_conditional(struct xorg_renderer *r,
+ int next_batch)
+{
+ if (r->num_vertices + next_batch >= BUF_SIZE ||
+ (next_batch == 0 && r->num_vertices))
+ renderer_draw(r);
+}
+
static void
renderer_init_state(struct xorg_renderer *r)
{
@@ -804,39 +835,6 @@ void renderer_copy_pixmap(struct xorg_renderer *r,
}
}
-void renderer_draw_solid_rect(struct xorg_renderer *r,
- int x0, int y0,
- int x1, int y1,
- float *color)
-{
- struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf = 0;
-
- /*
- debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
- x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
- /* 1st vertex */
- add_vertex_color(r, x0, y0, color);
- /* 2nd vertex */
- add_vertex_color(r, x1, y0, color);
- /* 3rd vertex */
- add_vertex_color(r, x1, y1, color);
- /* 4th vertex */
- add_vertex_color(r, x0, y1, color);
-
- buf = renderer_buffer_create(r);
-
-
- if (buf) {
- util_draw_vertex_buffer(pipe, buf, 0,
- PIPE_PRIM_QUADS,
- 4, /* verts */
- 2); /* attribs/vert */
-
- pipe_buffer_reference(&buf, NULL);
- }
-}
-
void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
@@ -923,17 +921,33 @@ void renderer_draw_yuv(struct xorg_renderer *r,
}
}
-void renderer_begin_solid(struct xorg_renderer *r,
- float *color)
+void renderer_begin_solid(struct xorg_renderer *r)
{
+ r->num_vertices = 0;
}
void renderer_solid(struct xorg_renderer *r,
int x0, int y0,
- int x1, int y1)
+ int x1, int y1,
+ float *color)
{
+ /*
+ debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
+ x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/
+
+ renderer_draw_conditional(r, 4 * 8);
+
+ /* 1st vertex */
+ add_vertex_color(r, x0, y0, color);
+ /* 2nd vertex */
+ add_vertex_color(r, x1, y0, color);
+ /* 3rd vertex */
+ add_vertex_color(r, x1, y1, color);
+ /* 4th vertex */
+ add_vertex_color(r, x0, y1, color);
}
-void renderer_end_solid(struct xorg_renderer *r)
+void renderer_draw_flush(struct xorg_renderer *r)
{
+ renderer_draw_conditional(r, 0);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
index 9ab554f63f9..2f85a8860bc 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.h
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.h
@@ -45,11 +45,6 @@ void renderer_copy_pixmap(struct xorg_renderer *r,
struct exa_pixmap_priv *src_priv, int sx, int sy,
int width, int height);
-void renderer_draw_solid_rect(struct xorg_renderer *r,
- int x0, int y0,
- int x1, int y1,
- float *color);
-
void renderer_draw_textures(struct xorg_renderer *r,
int *pos,
int width, int height,
@@ -63,12 +58,12 @@ void renderer_draw_yuv(struct xorg_renderer *r,
int dst_x, int dst_y, int dst_w, int dst_h,
struct pipe_texture **textures);
-void renderer_begin_solid(struct xorg_renderer *r,
- float *color);
+void renderer_begin_solid(struct xorg_renderer *r);
void renderer_solid(struct xorg_renderer *r,
int x0, int y0,
- int x1, int y1);
-void renderer_end_solid(struct xorg_renderer *r);
+ int x1, int y1,
+ float *color);
+void renderer_draw_flush(struct xorg_renderer *r);
#endif