aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/svga/svga_draw_arrays.c
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2011-03-09 12:39:14 +0100
committerThomas Hellstrom <[email protected]>2011-03-10 14:30:50 +0100
commit6d4e337f3890105c7d8a2f132412c137d2570d25 (patch)
treedda501f467a5d7213902159cc8574628241428d0 /src/gallium/drivers/svga/svga_draw_arrays.c
parent9b7f3776359640d452697f3a487a345820abebf0 (diff)
gallium/svga: Only upload parts of vertexarrays that are actually used
Make sure we only upload parts of vertex arrays that are actually used by a draw command. Signed-off-by: Thomas Hellstrom <[email protected]>
Diffstat (limited to 'src/gallium/drivers/svga/svga_draw_arrays.c')
-rw-r--r--src/gallium/drivers/svga/svga_draw_arrays.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index a6518042eb9..1bb29cc2335 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -32,6 +32,7 @@
#include "svga_draw.h"
#include "svga_draw_private.h"
#include "svga_context.h"
+#include "svga_resource_buffer.h"
#define DBG 0
@@ -191,6 +192,8 @@ simple_draw_arrays( struct svga_hwtnl *hwtnl,
SVGA3dPrimitiveRange range;
unsigned hw_prim;
unsigned hw_count;
+ unsigned i;
+ unsigned src_offs;
hw_prim = svga_translate_prim(prim, count, &hw_count);
if (hw_count == 0)
@@ -209,6 +212,22 @@ simple_draw_arrays( struct svga_hwtnl *hwtnl,
* looking at those numbers knows to adjust them by
* range.indexBias.
*/
+
+ for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
+ struct pipe_resource *vb = hwtnl->cmd.vdecl_vb[i];
+ struct svga_buffer *sbuf = svga_buffer(vb);
+ unsigned stride = hwtnl->cmd.vdecl[i].array.stride;
+ unsigned tmp_src_offs = sbuf->source_offset;
+
+ if (stride)
+ tmp_src_offs /= stride;
+ assert(i == 0 || tmp_src_offs == src_offs);
+ src_offs = tmp_src_offs;
+ }
+
+ range.indexBias = start - src_offs;
+ assert(range.indexBias >= 0);
+
return svga_hwtnl_prim( hwtnl, &range, 0, count - 1, NULL );
}