vl: ...
[mesa.git] / src / gallium / drivers / nv50 / nv50_push.c
index c54fed5a36fc529a82362ea878bf9949b2f8d8b1..244242b84342e200dbcd0db0dc8f05759b0b718a 100644 (file)
@@ -13,6 +13,7 @@ struct push_context {
    unsigned vtx_size;
 
    void *idxbuf;
+   int32_t idxbias;
    unsigned idxsize;
 
    float edgeflag;
@@ -143,6 +144,16 @@ emit_elt08(void *priv, unsigned start, unsigned count)
       emit_vertex(ctx, idxbuf[start++]);
 }
 
+static void
+emit_elt08_biased(void *priv, unsigned start, unsigned count)
+{
+   struct push_context *ctx = priv;
+   uint8_t *idxbuf = ctx->idxbuf;
+
+   while (count--)
+      emit_vertex(ctx, idxbuf[start++] + ctx->idxbias);
+}
+
 static void
 emit_elt16(void *priv, unsigned start, unsigned count)
 {
@@ -153,6 +164,16 @@ emit_elt16(void *priv, unsigned start, unsigned count)
       emit_vertex(ctx, idxbuf[start++]);
 }
 
+static void
+emit_elt16_biased(void *priv, unsigned start, unsigned count)
+{
+   struct push_context *ctx = priv;
+   uint16_t *idxbuf = ctx->idxbuf;
+
+   while (count--)
+      emit_vertex(ctx, idxbuf[start++] + ctx->idxbias);
+}
+
 static void
 emit_elt32(void *priv, unsigned start, unsigned count)
 {
@@ -163,6 +184,16 @@ emit_elt32(void *priv, unsigned start, unsigned count)
       emit_vertex(ctx, idxbuf[start++]);
 }
 
+static void
+emit_elt32_biased(void *priv, unsigned start, unsigned count)
+{
+   struct push_context *ctx = priv;
+   uint32_t *idxbuf = ctx->idxbuf;
+
+   while (count--)
+      emit_vertex(ctx, idxbuf[start++] + ctx->idxbias);
+}
+
 static void
 emit_verts(void *priv, unsigned start, unsigned count)
 {
@@ -269,8 +300,8 @@ nv50_push_elements_instanced(struct pipe_context *pipe,
          return;
       }
       ctx.idxbuf = bo->map;
+      ctx.idxbias = idxbias;
       ctx.idxsize = idxsize;
-      assert(idxbias == 0);
       nouveau_bo_unmap(bo);
    }
 
@@ -278,12 +309,12 @@ nv50_push_elements_instanced(struct pipe_context *pipe,
    s.edge = emit_edgeflag;
    if (idxbuf) {
       if (idxsize == 1)
-         s.emit = emit_elt08;
+         s.emit = idxbias ? emit_elt08_biased : emit_elt08;
       else
       if (idxsize == 2)
-         s.emit = emit_elt16;
+         s.emit = idxbias ? emit_elt16_biased : emit_elt16;
       else
-         s.emit = emit_elt32;
+         s.emit = idxbias ? emit_elt32_biased : emit_elt32;
    } else
       s.emit = emit_verts;