aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xorg/xorg_renderer.c
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-11-09 18:01:55 -0500
committerZack Rusin <[email protected]>2009-11-09 18:04:21 -0500
commita6d527d7b82579feae9db20657d47a3f86115bb4 (patch)
tree8670a87d2b616b4a7ca838e37ae470af62ddfa06 /src/gallium/state_trackers/xorg/xorg_renderer.c
parent216319fc0fe5dc3f298dd602812afa0f28a4ee60 (diff)
st/xorg: fix composite batching
quite a large performance optimization (text demo from 1.6fps to 9fps)
Diffstat (limited to 'src/gallium/state_trackers/xorg/xorg_renderer.c')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 947f4ca5313..c7a04836a5e 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -21,6 +21,8 @@ enum AxisOrientation {
#define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y)))
#define floatIsZero(x) (floatsEqual((x) + 1, 1))
+#define NUM_COMPONENTS 4
+
static INLINE boolean is_affine(float *matrix)
{
return floatIsZero(matrix[2]) && floatIsZero(matrix[5])
@@ -62,6 +64,7 @@ renderer_draw(struct xorg_renderer *r)
{
struct pipe_context *pipe = r->pipe;
struct pipe_buffer *buf = 0;
+ int num_verts = r->num_vertices/(r->num_attributes * NUM_COMPONENTS);
if (!r->num_vertices)
return;
@@ -72,7 +75,7 @@ renderer_draw(struct xorg_renderer *r)
if (buf) {
util_draw_vertex_buffer(pipe, buf, 0,
PIPE_PRIM_QUADS,
- 4, /* verts */
+ num_verts, /* verts */
r->num_attributes); /* attribs/vert */
pipe_buffer_reference(&buf, NULL);
@@ -84,8 +87,9 @@ renderer_draw_conditional(struct xorg_renderer *r,
int next_batch)
{
if (r->num_vertices + next_batch >= BUF_SIZE ||
- (next_batch == 0 && r->num_vertices))
+ (next_batch == 0 && r->num_vertices)) {
renderer_draw(r);
+ }
}
static void
@@ -892,6 +896,7 @@ void renderer_begin_textures(struct xorg_renderer *r,
int num_textures)
{
r->num_attributes = 1 + num_textures;
+ r->num_vertices = 0;
}
void renderer_texture(struct xorg_renderer *r,