summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-05-09 13:10:15 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-05-09 13:10:15 +0100
commit1a03812fb57e956b438cd42ac68978facb49a99d (patch)
treeac343109823d355ce7cff5816ab8e5cc90a5252a /src/gallium/auxiliary/draw/draw_pipe_vbuf.c
parent80474d576c2e92441f6bcc18faae71a38b91bd70 (diff)
draw: mimize cost of translate key compares, use cache universally
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pipe_vbuf.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 2a19e6916a..86a7d1c730 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -42,6 +42,7 @@
#include "draw_vertex.h"
#include "draw_pipe.h"
#include "translate/translate.h"
+#include "translate/translate_cache.h"
/**
@@ -75,6 +76,8 @@ struct vbuf_stage {
/* Cache point size somewhere it's address won't change:
*/
float point_size;
+
+ struct translate_cache *cache;
};
@@ -220,7 +223,6 @@ vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
/* Translate from pipeline vertices to hw vertices.
*/
dst_offset = 0;
- memset(&hw_key, 0, sizeof(hw_key));
for (i = 0; i < vbuf->vinfo->num_attribs; i++) {
unsigned emit_sz = 0;
@@ -277,12 +279,10 @@ vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
/* Don't bother with caching at this stage:
*/
if (!vbuf->translate ||
- memcmp(&vbuf->translate->key, &hw_key, sizeof(hw_key)) != 0)
+ translate_key_compare(&vbuf->translate->key, &hw_key) != 0)
{
- if (vbuf->translate)
- vbuf->translate->release(vbuf->translate);
-
- vbuf->translate = translate_create( &hw_key );
+ translate_key_sanitize(&hw_key);
+ vbuf->translate = translate_cache_find(vbuf->cache, &hw_key);
vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0);
}
@@ -433,6 +433,9 @@ static void vbuf_destroy( struct draw_stage *stage )
if (vbuf->render)
vbuf->render->destroy( vbuf->render );
+ if (vbuf->cache)
+ translate_cache_destroy(vbuf->cache);
+
FREE( stage );
}
@@ -463,6 +466,11 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
16 );
if (!vbuf->indices)
goto fail;
+
+ vbuf->cache = translate_cache_create();
+ if (!vbuf->cache)
+ goto fail;
+
vbuf->vertices = NULL;
vbuf->vertex_ptr = vbuf->vertices;