**********************************************************/
#include "util/u_inlines.h"
+#include "util/u_prim.h"
#include "indices/u_indices.h"
#include "svga_cmd.h"
static enum pipe_error
translate_indices(struct svga_hwtnl *hwtnl, struct pipe_resource *src,
- unsigned offset, unsigned nr, unsigned index_size,
+ unsigned offset, unsigned prim, unsigned nr,
+ unsigned index_size,
u_translate_func translate, struct pipe_resource **out_buf)
{
struct pipe_context *pipe = &hwtnl->svga->pipe;
struct pipe_transfer *src_transfer = NULL;
struct pipe_transfer *dst_transfer = NULL;
- unsigned size = index_size * nr;
+ unsigned size;
const void *src_map = NULL;
struct pipe_resource *dst = NULL;
void *dst_map = NULL;
+ /* Need to trim vertex count to make sure we don't write too much data
+ * to the dst buffer in the translate() call.
+ */
+ u_trim_pipe_prim(prim, &nr);
+
+ size = index_size * nr;
+
dst = pipe_buffer_create(pipe->screen,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STATIC, size);
if (dst == NULL)
ret = translate_indices(hwtnl,
index_buffer,
start * index_size,
- gen_nr, gen_size, gen_func, &gen_buf);
+ gen_prim, gen_nr, gen_size, gen_func, &gen_buf);
if (ret != PIPE_OK)
goto done;