diff options
author | Christoph Bumiller <[email protected]> | 2010-04-20 21:18:15 +0200 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2010-04-20 22:07:58 +0200 |
commit | 3c9df0bda67cdcbc340a4f20997f7a3345cbe9cb (patch) | |
tree | 3882dae688fa0540617398a18a56901048d86af2 /src/gallium/drivers | |
parent | caa05ef41996f7d0ac6b77f2fe86b1771cb10e43 (diff) |
nv50: support vertex index bias
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/nv50/nv50_push.c | 39 | ||||
-rw-r--r-- | src/gallium/drivers/nv50/nv50_vbo.c | 9 |
2 files changed, 41 insertions, 7 deletions
diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c index c54fed5a36f..244242b8434 100644 --- a/src/gallium/drivers/nv50/nv50_push.c +++ b/src/gallium/drivers/nv50/nv50_push.c @@ -13,6 +13,7 @@ struct push_context { unsigned vtx_size; void *idxbuf; + int32_t idxbias; unsigned idxsize; float edgeflag; @@ -144,6 +145,16 @@ emit_elt08(void *priv, unsigned start, unsigned count) } 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) { struct push_context *ctx = priv; @@ -154,6 +165,16 @@ emit_elt16(void *priv, unsigned start, unsigned count) } 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) { struct push_context *ctx = priv; @@ -164,6 +185,16 @@ emit_elt32(void *priv, unsigned start, unsigned count) } 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) { while (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; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 911eabca1cf..34719c956a0 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -401,14 +401,17 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 13 + 16*3)) return; - assert(indexBias == 0); - if (nv50->vbo_fifo) { nv50_push_elements_instanced(pipe, indexBuffer, indexSize, indexBias, mode, start, count, startInstance, instanceCount); return; - } else + } + + /* indices are uint32 internally, so large indexBias means negative */ + BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_BASE, 1); + OUT_RING (chan, indexBias); + if (!(indexBuffer->bind & PIPE_BIND_INDEX_BUFFER) || indexSize == 1) { nv50_draw_elements_inline(pipe, indexBuffer, indexSize, mode, start, count, startInstance, |