[Mesa-dev] [PATCH 3/3] draw/so: maintain an exact number of written vertices
Zack Rusin
zackr at vmware.com
Fri Mar 29 06:59:48 PDT 2013
It's quite helpful during the rendering when we know
exactly the count of the vertices available in the
buffer.
Signed-off-by: Zack Rusin <zackr at vmware.com>
---
src/gallium/auxiliary/draw/draw_context.h | 1 +
src/gallium/auxiliary/draw/draw_pt.c | 18 +++++++++++-------
src/gallium/auxiliary/draw/draw_pt_so_emit.c | 4 +++-
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 369f6c8..b333457 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -60,6 +60,7 @@ struct draw_so_target {
struct pipe_stream_output_target target;
void *mapping;
int internal_offset;
+ int emitted_vertices;
};
struct draw_context *draw_create( struct pipe_context *pipe );
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index 50b9efa..7026dbf 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -468,10 +468,20 @@ draw_vbo(struct draw_context *draw,
assert(info->instance_count > 0);
if (info->indexed)
assert(draw->pt.user.elts);
+
+ count = info->count;
+ if (count == 0) {
+ if (info->count_from_stream_output)
+ count = draw->pt.max_index + 1;
+ }
draw->pt.user.eltBias = info->index_bias;
draw->pt.user.min_index = info->min_index;
- draw->pt.user.max_index = info->max_index;
+ if (info->count_from_stream_output) {
+ draw->pt.user.max_index = count;
+ } else {
+ draw->pt.user.max_index = info->max_index;
+ }
draw->pt.user.eltSize = info->indexed ? draw->pt.user.eltSizeIB : 0;
if (0)
@@ -518,12 +528,6 @@ draw_vbo(struct draw_context *draw,
draw->pt.max_index = index_limit - 1;
- count = info->count;
- if (count == 0) {
- if (info->count_from_stream_output)
- count = draw->pt.max_index + 1;
- }
-
/*
* TODO: We could use draw->pt.max_index to further narrow
* the min_index/max_index hints given by the state tracker.
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index 25584a9..ae071a6 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -174,8 +174,10 @@ static void so_emit_prim(struct pt_so_emit *so,
else
memcpy(buffer, &input[idx][start_comp], num_comps * sizeof(float));
}
- for (ob = 0; ob < draw->so.num_targets; ++ob)
+ for (ob = 0; ob < draw->so.num_targets; ++ob) {
draw->so.targets[ob]->internal_offset += state->stride[ob] * sizeof(float);
+ draw->so.targets[ob]->emitted_vertices += 1;
+ }
}
so->emitted_vertices += num_vertices;
++so->emitted_primitives;
--
1.7.10.4
More information about the mesa-dev
mailing list