From d088d640fca415261a208d3cbede94a6522ebb6b Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Mar 2008 17:10:28 -0600 Subject: gallium: plug in vertex passthrough code Based on a patch from Zack. Basically, implement a new draw_arrays function that copies the incoming user-vertices to the hardware vertex buffer, doing format/type conversion as needed. The vertex fetch/store code is totally temporary for now. --- src/gallium/auxiliary/draw/draw_prim.c | 47 ++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/draw/draw_prim.c') diff --git a/src/gallium/auxiliary/draw/draw_prim.c b/src/gallium/auxiliary/draw/draw_prim.c index 7d6cd43410..ff71ba9b73 100644 --- a/src/gallium/auxiliary/draw/draw_prim.c +++ b/src/gallium/auxiliary/draw/draw_prim.c @@ -31,6 +31,7 @@ */ #include "pipe/p_debug.h" +#include "pipe/p_util.h" #include "draw_private.h" #include "draw_context.h" @@ -118,7 +119,42 @@ static void draw_prim_queue_flush( struct draw_context *draw ) draw_vertex_cache_unreference( draw ); } +static INLINE void fetch_and_store(struct draw_context *draw) +{ + unsigned i; + + /* run vertex shader on vertex cache entries, four per invokation */ +#if 0 + { + const struct vertex_info *vinfo = draw->render->get_vertex_info(draw->render); + memcpy(draw->vs.queue[0].vertex, draw->vs.queue[i + j].elt, + count * vinfo->size); + } +#elif 0 + draw_update_vertex_fetch(draw); + for (i = 0; i < draw->vs.queue_nr; i += 4) { + struct vertex_header *dests[4]; + unsigned elts[4]; + struct tgsi_exec_machine *machine = &draw->machine; + int j, n = MIN2(4, draw->vs.queue_nr - i); + + for (j = 0; j < n; j++) { + elts[j] = draw->vs.queue[i + j].elt; + dests[j] = draw->vs.queue[i + j].vertex; + } + for ( ; j < 4; j++) { + elts[j] = elts[0]; + dests[j] = draw->vs.queue[i + j].vertex; + } + //fetch directly into dests + draw->vertex_fetch.fetch_func(draw, machine, dests, count); + } +#endif + + draw->vs.post_nr = draw->vs.queue_nr; + draw->vs.queue_nr = 0; +} void draw_do_flush( struct draw_context *draw, unsigned flags ) { @@ -134,7 +170,10 @@ void draw_do_flush( struct draw_context *draw, unsigned flags ) if (flags >= DRAW_FLUSH_SHADER_QUEUE) { if (draw->vs.queue_nr) - (*draw->shader_queue_flush)(draw); + if (draw->rasterizer->bypass_vs) + fetch_and_store(draw); + else + (*draw->shader_queue_flush)(draw); if (flags >= DRAW_FLUSH_PRIM_QUEUE) { if (draw->pq.queue_nr) @@ -485,7 +524,11 @@ draw_arrays(struct draw_context *draw, unsigned prim, } /* drawing done here: */ - draw_prim(draw, prim, start, count); + if (!draw->rasterizer->bypass_vs || + !draw_passthrough_arrays(draw, prim, start, count)) { + /* we have to run the whole pipeline */ + draw_prim(draw, prim, start, count); + } } -- cgit v1.2.3