[Mesa-dev] [PATCH] nv50, nvc0: fix start_instance in manual push path
Ilia Mirkin
imirkin at alum.mit.edu
Sun Jun 19 01:58:00 UTC 2016
The start instance is applied as an offset into the buffer directly,
ignoring the divisor, not as an instance id offset that respects the
divisor.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: "11.2 12.0" <mesa-stable at lists.freedesktop.org>
---
src/gallium/drivers/nouveau/nv50/nv50_push.c | 10 +++++++---
src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c | 12 +++++++-----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_push.c b/src/gallium/drivers/nouveau/nv50/nv50_push.c
index cbef95d..af27fb8 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_push.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_push.c
@@ -247,6 +247,7 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info)
ctx.need_vertex_id = nv50->screen->base.class_3d >= NV84_3D_CLASS &&
nv50->vertprog->vp.need_vertex_id && (nv50->vertex->num_elements < 32);
ctx.index_bias = info->index_bias;
+ ctx.instance_id = 0;
/* For indexed draws, gl_VertexID must be emitted for every vertex. */
ctx.packet_vertex_limit =
@@ -264,8 +265,12 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info)
else
data = vb->user_buffer;
- if (apply_bias && likely(!(nv50->vertex->instance_bufs & (1 << i))))
- data += (ptrdiff_t)info->index_bias * vb->stride;
+ if (likely(!(nv50->vertex->instance_bufs & (1 << i)))) {
+ if (apply_bias)
+ data += (ptrdiff_t)info->index_bias * vb->stride;
+ } else {
+ data += (ptrdiff_t)info->start_instance * vb->stride;
+ }
ctx.translate->set_buffer(ctx.translate, i, data, vb->stride, ~0);
}
@@ -301,7 +306,6 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info)
ctx.restart_index = 0;
}
- ctx.instance_id = info->start_instance;
ctx.prim = nv50_prim_gl(info->mode);
if (info->primitive_restart) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c
index 20b6742..2f4e8b6 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c
@@ -44,6 +44,7 @@ nvc0_push_context_init(struct nvc0_context *nvc0, struct push_context *ctx)
ctx->translate = nvc0->vertex->translate;
ctx->vertex_size = nvc0->vertex->size;
+ ctx->instance_id = 0;
ctx->need_vertex_id =
nvc0->vertprog->vp.need_vertex_id && (nvc0->vertex->num_elements < 32);
@@ -58,7 +59,8 @@ nvc0_push_context_init(struct nvc0_context *nvc0, struct push_context *ctx)
}
static inline void
-nvc0_vertex_configure_translate(struct nvc0_context *nvc0, int32_t index_bias)
+nvc0_vertex_configure_translate(struct nvc0_context *nvc0, int32_t index_bias,
+ uint32_t start_instance)
{
struct translate *translate = nvc0->vertex->translate;
unsigned i;
@@ -73,8 +75,10 @@ nvc0_vertex_configure_translate(struct nvc0_context *nvc0, int32_t index_bias)
map = nouveau_resource_map_offset(&nvc0->base,
nv04_resource(vb->buffer), vb->buffer_offset, NOUVEAU_BO_RD);
- if (index_bias && !unlikely(nvc0->vertex->instance_bufs & (1 << i)))
+ if (!unlikely(nvc0->vertex->instance_bufs & (1 << i)))
map += (intptr_t)index_bias * vb->stride;
+ else
+ map += (intptr_t)start_instance * vb->stride;
translate->set_buffer(translate, i, map, vb->stride, ~0);
}
@@ -470,7 +474,7 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct pipe_draw_info *info)
nvc0_push_context_init(nvc0, &ctx);
- nvc0_vertex_configure_translate(nvc0, info->index_bias);
+ nvc0_vertex_configure_translate(nvc0, info->index_bias, info->start_instance);
if (nvc0->state.index_bias) {
/* this is already taken care of by translate */
@@ -515,8 +519,6 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct pipe_draw_info *info)
index_size = 0;
}
- ctx.instance_id = info->start_instance;
-
prim = nvc0_prim_gl(info->mode);
do {
PUSH_SPACE(ctx.push, 9);
--
2.7.3
More information about the mesa-dev
mailing list