diff options
author | Zack Rusin <[email protected]> | 2009-11-06 08:31:16 -0500 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2009-11-06 22:08:21 -0500 |
commit | e521bf7706a5527ad5750baef78feaa961f73ecc (patch) | |
tree | c350f914792a79b0af3eb887c2f8b244bc401dd4 /src/gallium/state_trackers/xorg | |
parent | 4322346f3fd03788a79d056ca7bce2db25bc9d88 (diff) |
st/xorg: implement batching for the composite op
something is broken so disabled for now
Diffstat (limited to 'src/gallium/state_trackers/xorg')
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_composite.c | 18 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_exa.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_renderer.c | 200 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_renderer.h | 29 |
4 files changed, 161 insertions, 90 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 93fcdaf44d9..8947d0a67c4 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -431,6 +431,14 @@ boolean xorg_composite_bind_state(struct exa_context *exa, setup_transforms(exa, pSrcPicture, pMaskPicture); + if (exa->num_bound_samplers == 0 ) { /* solid fill */ + renderer_begin_solid(exa->renderer); + } else { + renderer_begin_textures(exa->renderer, + exa->bound_textures, + exa->num_bound_samplers); + } + return TRUE; } @@ -440,11 +448,9 @@ void xorg_composite(struct exa_context *exa, int dstX, int dstY, int width, int height) { if (exa->num_bound_samplers == 0 ) { /* solid fill */ - 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; @@ -455,11 +461,19 @@ void xorg_composite(struct exa_context *exa, if (exa->transform.has_mask) mask_matrix = exa->transform.mask; +#if 1 renderer_draw_textures(exa->renderer, pos, width, height, exa->bound_textures, exa->num_bound_samplers, src_matrix, mask_matrix); +#else + renderer_texture(exa->renderer, + pos, width, height, + exa->bound_textures, + exa->num_bound_samplers, + src_matrix, mask_matrix); +#endif } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 99362e01f2c..20cfa25d97f 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -89,6 +89,8 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp) static void xorg_exa_common_done(struct exa_context *exa) { + renderer_draw_flush(exa->renderer); + exa->copy.src = NULL; exa->copy.dst = NULL; exa->transform.has_src = FALSE; @@ -276,8 +278,6 @@ ExaDone(PixmapPtr pPixmap) if (!priv) return; - renderer_draw_flush(exa->renderer); - xorg_exa_common_done(exa); } diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 52cde5428b7..947f4ca5313 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -73,7 +73,7 @@ renderer_draw(struct xorg_renderer *r) util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, 4, /* verts */ - 2); /* attribs/vert */ + r->num_attributes); /* attribs/vert */ pipe_buffer_reference(&buf, NULL); } @@ -138,11 +138,11 @@ add_vertex_1tex(struct xorg_renderer *r, r->num_vertices += 8; } -static struct pipe_buffer * -setup_vertex_data1(struct xorg_renderer *r, - float srcX, float srcY, float dstX, float dstY, - float width, float height, - struct pipe_texture *src, float *src_matrix) +static void +add_vertex_data1(struct xorg_renderer *r, + float srcX, float srcY, float dstX, float dstY, + float width, float height, + struct pipe_texture *src, float *src_matrix) { float s0, t0, s1, t1; float pt0[2], pt1[2]; @@ -170,8 +170,6 @@ setup_vertex_data1(struct xorg_renderer *r, add_vertex_1tex(r, dstX + width, dstY + height, s1, t1); /* 4th vertex */ add_vertex_1tex(r, dstX, dstY + height, s0, t1); - - return renderer_buffer_create(r); } static struct pipe_buffer * @@ -217,13 +215,13 @@ add_vertex_2tex(struct xorg_renderer *r, r->num_vertices += 12; } -static struct pipe_buffer * -setup_vertex_data2(struct xorg_renderer *r, - float srcX, float srcY, float maskX, float maskY, - float dstX, float dstY, float width, float height, - struct pipe_texture *src, - struct pipe_texture *mask, - float *src_matrix, float *mask_matrix) +static void +add_vertex_data2(struct xorg_renderer *r, + float srcX, float srcY, float maskX, float maskY, + float dstX, float dstY, float width, float height, + struct pipe_texture *src, + struct pipe_texture *mask, + float *src_matrix, float *mask_matrix) { float src_s0, src_t0, src_s1, src_t1; float mask_s0, mask_t0, mask_s1, mask_t1; @@ -272,9 +270,6 @@ setup_vertex_data2(struct xorg_renderer *r, /* 4th vertex */ add_vertex_2tex(r, dstX, dstY + height, src_s0, src_t1, mask_s0, mask_t1); - - - return renderer_buffer_create(r); } static struct pipe_buffer * @@ -835,67 +830,6 @@ void renderer_copy_pixmap(struct xorg_renderer *r, } } -void renderer_draw_textures(struct xorg_renderer *r, - int *pos, - int width, int height, - struct pipe_texture **textures, - int num_textures, - float *src_matrix, float *mask_matrix) -{ - struct pipe_context *pipe = r->pipe; - struct pipe_buffer *buf = 0; - -#if 0 - if (src_matrix) { - debug_printf("src_matrix = \n"); - debug_printf("%f, %f, %f\n", src_matrix[0], src_matrix[1], src_matrix[2]); - debug_printf("%f, %f, %f\n", src_matrix[3], src_matrix[4], src_matrix[5]); - debug_printf("%f, %f, %f\n", src_matrix[6], src_matrix[7], src_matrix[8]); - } - if (mask_matrix) { - debug_printf("mask_matrix = \n"); - debug_printf("%f, %f, %f\n", mask_matrix[0], mask_matrix[1], mask_matrix[2]); - debug_printf("%f, %f, %f\n", mask_matrix[3], mask_matrix[4], mask_matrix[5]); - debug_printf("%f, %f, %f\n", mask_matrix[6], mask_matrix[7], mask_matrix[8]); - } -#endif - - switch(num_textures) { - case 1: - buf = setup_vertex_data1(r, - pos[0], pos[1], /* src */ - pos[4], pos[5], /* dst */ - width, height, - textures[0], src_matrix); - break; - case 2: - buf = setup_vertex_data2(r, - pos[0], pos[1], /* src */ - pos[2], pos[3], /* mask */ - pos[4], pos[5], /* dst */ - width, height, - textures[0], textures[1], - src_matrix, mask_matrix); - break; - case 3: - default: - debug_assert(!"Unsupported number of textures"); - break; - } - - if (buf) { - int num_attribs = 1; /*pos*/ - num_attribs += num_textures; - - util_draw_vertex_buffer(pipe, buf, 0, - PIPE_PRIM_QUADS, - 4, /* verts */ - num_attribs); /* attribs/vert */ - - pipe_buffer_reference(&buf, NULL); - } -} - void renderer_draw_yuv(struct xorg_renderer *r, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, @@ -924,6 +858,7 @@ void renderer_draw_yuv(struct xorg_renderer *r, void renderer_begin_solid(struct xorg_renderer *r) { r->num_vertices = 0; + r->num_attributes = 2; } void renderer_solid(struct xorg_renderer *r, @@ -951,3 +886,110 @@ void renderer_draw_flush(struct xorg_renderer *r) { renderer_draw_conditional(r, 0); } + +void renderer_begin_textures(struct xorg_renderer *r, + struct pipe_texture **textures, + int num_textures) +{ + r->num_attributes = 1 + num_textures; +} + +void renderer_texture(struct xorg_renderer *r, + int *pos, + int width, int height, + struct pipe_texture **textures, + int num_textures, + float *src_matrix, + float *mask_matrix) +{ + +#if 0 + if (src_matrix) { + debug_printf("src_matrix = \n"); + debug_printf("%f, %f, %f\n", src_matrix[0], src_matrix[1], src_matrix[2]); + debug_printf("%f, %f, %f\n", src_matrix[3], src_matrix[4], src_matrix[5]); + debug_printf("%f, %f, %f\n", src_matrix[6], src_matrix[7], src_matrix[8]); + } + if (mask_matrix) { + debug_printf("mask_matrix = \n"); + debug_printf("%f, %f, %f\n", mask_matrix[0], mask_matrix[1], mask_matrix[2]); + debug_printf("%f, %f, %f\n", mask_matrix[3], mask_matrix[4], mask_matrix[5]); + debug_printf("%f, %f, %f\n", mask_matrix[6], mask_matrix[7], mask_matrix[8]); + } +#endif + + switch(r->num_attributes) { + case 2: + renderer_draw_conditional(r, 4 * 8); + add_vertex_data1(r, + pos[0], pos[1], /* src */ + pos[4], pos[5], /* dst */ + width, height, + textures[0], src_matrix); + break; + case 3: + renderer_draw_conditional(r, 4 * 12); + add_vertex_data2(r, + pos[0], pos[1], /* src */ + pos[2], pos[3], /* mask */ + pos[4], pos[5], /* dst */ + width, height, + textures[0], textures[1], + src_matrix, mask_matrix); + break; + default: + debug_assert(!"Unsupported number of textures"); + break; + } +} + + +void renderer_draw_textures(struct xorg_renderer *r, + int *pos, + int width, int height, + struct pipe_texture **textures, + int num_textures, + float *src_matrix, float *mask_matrix) +{ +#if 0 + if (src_matrix) { + debug_printf("src_matrix = \n"); + debug_printf("%f, %f, %f\n", src_matrix[0], src_matrix[1], src_matrix[2]); + debug_printf("%f, %f, %f\n", src_matrix[3], src_matrix[4], src_matrix[5]); + debug_printf("%f, %f, %f\n", src_matrix[6], src_matrix[7], src_matrix[8]); + } + if (mask_matrix) { + debug_printf("mask_matrix = \n"); + debug_printf("%f, %f, %f\n", mask_matrix[0], mask_matrix[1], mask_matrix[2]); + debug_printf("%f, %f, %f\n", mask_matrix[3], mask_matrix[4], mask_matrix[5]); + debug_printf("%f, %f, %f\n", mask_matrix[6], mask_matrix[7], mask_matrix[8]); + } +#endif + + r->num_attributes = 1 + num_textures; + switch(num_textures) { + case 1: + add_vertex_data1(r, + pos[0], pos[1], /* src */ + pos[4], pos[5], /* dst */ + width, height, + textures[0], src_matrix); + break; + case 2: + add_vertex_data2(r, + pos[0], pos[1], /* src */ + pos[2], pos[3], /* mask */ + pos[4], pos[5], /* dst */ + width, height, + textures[0], textures[1], + src_matrix, mask_matrix); + break; + case 3: + default: + debug_assert(!"Unsupported number of textures"); + break; + } + + renderer_draw(r); +} + diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h index 2f85a8860bc..780d97fe85a 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.h +++ b/src/gallium/state_trackers/xorg/xorg_renderer.h @@ -26,6 +26,8 @@ struct xorg_renderer { float vertices[BUF_SIZE]; int num_vertices; + + int num_attributes; }; struct xorg_renderer *renderer_create(struct pipe_context *pipe); @@ -45,13 +47,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_textures(struct xorg_renderer *r, - int *pos, - int width, int height, - struct pipe_texture **textures, - int num_textures, - float *src_matrix, - float *mask_matrix); void renderer_draw_yuv(struct xorg_renderer *r, int src_x, int src_y, int src_w, int src_h, @@ -64,6 +59,26 @@ void renderer_solid(struct xorg_renderer *r, int x1, int y1, float *color); +void renderer_begin_textures(struct xorg_renderer *r, + struct pipe_texture **textures, + int num_textures); +void renderer_texture(struct xorg_renderer *r, + int *pos, + int width, int height, + struct pipe_texture **textures, + int num_textures, + float *src_matrix, + float *mask_matrix); + void renderer_draw_flush(struct xorg_renderer *r); + +void renderer_draw_textures(struct xorg_renderer *r, + int *pos, + int width, int height, + struct pipe_texture **textures, + int num_textures, + float *src_matrix, float *mask_matrix); + + #endif |