struct v3d_streamout_stateobj {
struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS];
+ /* Number of vertices we've written into the buffer so far. */
+ uint32_t offsets[PIPE_MAX_SO_BUFFERS];
unsigned num_targets;
};
vpm_start_offset += write_size;
vpm_size -= write_size;
}
+ so->base.stream_output.stride[buffer] =
+ stream_output->stride[buffer];
}
so->num_tf_outputs = slot_count;
}
job->draw_calls_queued++;
+ /* Increment the TF offsets by how many verts we wrote. XXX: This
+ * needs some clamping to the buffer size.
+ */
+ for (int i = 0; i < v3d->streamout.num_targets; i++)
+ v3d->streamout.offsets[i] += info->count;
+
if (v3d->zsa && job->zsbuf &&
(v3d->zsa->base.depth.enabled ||
v3d->zsa->base.stencil[0].enabled)) {
so->targets[i];
struct v3d_resource *rsc = target ?
v3d_resource(target->buffer) : NULL;
+ struct pipe_shader_state *vs = &v3d->prog.bind_vs->base;
+ struct pipe_stream_output_info *info = &vs->stream_output;
+ uint32_t offset = (v3d->streamout.offsets[i] *
+ info->stride[i] * 4);
#if V3D_VERSION >= 40
if (!target)
cl_emit(&job->bcl, TRANSFORM_FEEDBACK_BUFFER, output) {
output.buffer_address =
cl_address(rsc->bo,
- target->buffer_offset);
+ target->buffer_offset +
+ offset);
output.buffer_size_in_32_bit_words =
- target->buffer_size >> 2;
+ (target->buffer_size - offset) >> 2;
output.buffer_number = i;
}
#else /* V3D_VERSION < 40 */
if (target) {
output.address =
cl_address(rsc->bo,
- target->buffer_offset);
+ target->buffer_offset +
+ offset);
}
};
#endif /* V3D_VERSION < 40 */
assert(num_targets <= ARRAY_SIZE(so->targets));
- for (i = 0; i < num_targets; i++)
+ for (i = 0; i < num_targets; i++) {
+ if (offsets[i] != -1)
+ so->offsets[i] = offsets[i];
+
pipe_so_target_reference(&so->targets[i], targets[i]);
+ }
for (; i < so->num_targets; i++)
pipe_so_target_reference(&so->targets[i], NULL);