From abb08e9335b5d7cb004dc9e6cec390ab6968abe5 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sat, 3 May 2008 22:32:17 -0400 Subject: implement linear emition and fetching and plug it in the varray paths --- src/gallium/auxiliary/draw/draw_pt_fetch.c | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/gallium/auxiliary/draw/draw_pt_fetch.c') diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 1f765b73ad..d7cc1807d7 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -167,6 +167,42 @@ void draw_pt_fetch_run( struct pt_fetch *fetch, } +void draw_pt_fetch_run_linear( struct pt_fetch *fetch, + unsigned start, + unsigned count, + char *verts ) +{ + struct draw_context *draw = fetch->draw; + struct translate *translate = fetch->translate; + unsigned i; + + for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { + translate->set_buffer(translate, + i, + ((char *)draw->pt.user.vbuffer[i] + + draw->pt.vertex_buffer[i].buffer_offset), + draw->pt.vertex_buffer[i].pitch ); + } + + translate->run( translate, + start, + count, + verts ); + + /* Edgeflags are hard to fit into a translate program, populate + * them separately if required. In the setup above they are + * defaulted to one, so only need this if there is reason to change + * that default: + */ + if (fetch->need_edgeflags) { + for (i = 0; i < count; i++) { + struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size); + vh->edgeflag = draw_pt_get_edgeflag( draw, start + i ); + } + } +} + + struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw ) { struct pt_fetch *fetch = CALLOC_STRUCT(pt_fetch); -- cgit v1.2.3 From 501be9c7dd0cc5f985c708fa0e5f35d7fd20deb4 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 9 May 2008 15:02:59 +0100 Subject: draw: fix translate double-free, minor cleanups --- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 3 --- src/gallium/auxiliary/draw/draw_pt_fetch.c | 3 ++- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pt_fetch.c') diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 2a19e6916a..64a9f9084f 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -427,9 +427,6 @@ static void vbuf_destroy( struct draw_stage *stage ) if(vbuf->indices) align_free( vbuf->indices ); - if(vbuf->translate) - vbuf->translate->release( vbuf->translate ); - if (vbuf->render) vbuf->render->destroy( vbuf->render ); diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index d62cd9358b..034e0eccb2 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -223,7 +223,8 @@ struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw ) void draw_pt_fetch_destroy( struct pt_fetch *fetch ) { - translate_cache_destroy(fetch->cache); + if (fetch->cache) + translate_cache_destroy(fetch->cache); FREE(fetch); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index 8df4241b82..bdbb039f9e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -320,7 +320,8 @@ static void fetch_emit_destroy( struct draw_pt_middle_end *middle ) { struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle; - translate_cache_destroy(feme->cache); + if (feme->cache) + translate_cache_destroy(feme->cache); FREE(middle); } -- cgit v1.2.3 From 7ddb925b8bc6c18eba953e34d2b630a3a6593f05 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 9 May 2008 13:10:15 +0100 Subject: draw: mimize cost of translate key compares, use cache universally --- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 20 ++++++++++++++------ src/gallium/auxiliary/draw/draw_pt_emit.c | 10 +++++----- src/gallium/auxiliary/draw/draw_pt_fetch.c | 7 ++----- src/gallium/auxiliary/draw/draw_pt_fetch_emit.c | 3 ++- 4 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_pt_fetch.c') diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index 64a9f9084f..67b9a9503d 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); } @@ -430,6 +430,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 ); } @@ -460,6 +463,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; diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index 999b2007a2..4a854f4362 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -49,7 +49,6 @@ void draw_pt_emit_prepare( struct pt_emit *emit, const struct vertex_info *vinfo; unsigned dst_offset; struct translate_key hw_key; - unsigned keysize; unsigned i; boolean ok; @@ -62,7 +61,7 @@ void draw_pt_emit_prepare( struct pt_emit *emit, /* Must do this after set_primitive() above: */ vinfo = draw->render->get_vertex_info(draw->render); - keysize = 2*4 + vinfo->num_attribs * sizeof(hw_key.element[0]); + /* Translate from pipeline vertices to hw vertices. */ @@ -121,9 +120,9 @@ void draw_pt_emit_prepare( struct pt_emit *emit, hw_key.output_stride = vinfo->size * 4; if (!emit->translate || - memcmp(&emit->translate->key, &hw_key, keysize) != 0) + translate_key_compare(&emit->translate->key, &hw_key) != 0) { - memset((char *)&hw_key + keysize, 0, sizeof(hw_key) - keysize); + translate_key_sanitize(&hw_key); emit->translate = translate_cache_find(emit->cache, &hw_key); } } @@ -244,7 +243,8 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw ) void draw_pt_emit_destroy( struct pt_emit *emit ) { - translate_cache_destroy(emit->cache); + if (emit->cache) + translate_cache_destroy(emit->cache); FREE(emit); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 034e0eccb2..07f4c99164 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -62,11 +62,8 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, unsigned i, nr = 0; unsigned dst_offset = 0; struct translate_key key; - unsigned keysize; fetch->vertex_size = vertex_size; - keysize = (2*4 + - (draw->pt.nr_vertex_elements + 1) * sizeof(key.element[0])); /* Always emit/leave space for a vertex header. * @@ -111,9 +108,9 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch, if (!fetch->translate || - memcmp(&fetch->translate->key, &key, keysize) != 0) + translate_key_compare(&fetch->translate->key, &key) != 0) { - memset((char *)&key + keysize, 0, sizeof(key) - keysize); + translate_key_sanitize(&key); fetch->translate = translate_cache_find(fetch->cache, &key); { diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index bdbb039f9e..a1d041a74f 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -174,8 +174,9 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle, /* Don't bother with caching at this stage: */ if (!feme->translate || - memcmp(&feme->translate->key, &key, sizeof(key)) != 0) + translate_key_compare(&feme->translate->key, &key) != 0) { + translate_key_sanitize(&key); feme->translate = translate_cache_find(feme->cache, &key); -- cgit v1.2.3