st/xorg: fix composite batching

quite a large performance optimization (text demo from 1.6fps to 9fps)
This commit is contained in:
Zack Rusin 2009-11-09 18:01:55 -05:00
parent 216319fc0f
commit a6d527d7b8
3 changed files with 18 additions and 5 deletions

View file

@ -287,6 +287,14 @@ bind_samplers(struct exa_context *exa, int op,
exa->num_bound_samplers = 0;
#if 0
if ((pSrc && (exa->pipe->is_texture_referenced(exa->pipe, pSrc->tex, 0, 0) &
PIPE_REFERENCED_FOR_WRITE)) ||
(pMask && (exa->pipe->is_texture_referenced(exa->pipe, pMask->tex, 0, 0) &
PIPE_REFERENCED_FOR_WRITE)))
xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
#endif
memset(&src_sampler, 0, sizeof(struct pipe_sampler_state));
memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state));
@ -461,7 +469,7 @@ void xorg_composite(struct exa_context *exa,
if (exa->transform.has_mask)
mask_matrix = exa->transform.mask;
#if 1
#if 0
renderer_draw_textures(exa->renderer,
pos, width, height,
exa->bound_textures,

View file

@ -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,

View file

@ -11,9 +11,9 @@ struct exa_pixmap_priv;
* max number of attributes per vertex *
* max number of components per attribute
*
* currently the max is 5 quads
* currently the max is 100 quads
*/
#define BUF_SIZE (20 * 3 * 4)
#define BUF_SIZE (100 * 4 * 3 * 4)
struct xorg_renderer {
struct pipe_context *pipe;