util/vbuf: handle multidraws

this moves the handling from cso_conext to vbuf, which reduces overhead
for draws that aren't rewritten

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17686>
This commit is contained in:
Mike Blumenkrantz 2022-07-21 12:48:17 -04:00 committed by Marge Bot
parent 7c484b0c1c
commit 6b07893b31
3 changed files with 262 additions and 262 deletions

View File

@ -1642,7 +1642,7 @@ cso_draw_vbo(struct cso_context *cso,
indirect->count_from_stream_output == NULL);
if (vbuf) {
u_vbuf_draw_vbo(vbuf, info, drawid_offset, indirect, draw);
u_vbuf_draw_vbo(vbuf, info, drawid_offset, indirect, &draw, 1);
} else {
struct pipe_context *pipe = cso->pipe;
pipe->draw_vbo(pipe, info, drawid_offset, indirect, &draw, 1);
@ -1660,19 +1660,7 @@ cso_multi_draw(struct cso_context *cso,
struct u_vbuf *vbuf = cso->vbuf_current;
if (vbuf) {
/* Increase refcount to be able to use take_index_buffer_ownership with
* all draws.
*/
if (num_draws > 1 && info->take_index_buffer_ownership)
p_atomic_add(&info->index.resource->reference.count, num_draws - 1);
unsigned drawid = drawid_offset;
for (unsigned i = 0; i < num_draws; i++) {
u_vbuf_draw_vbo(vbuf, info, drawid, NULL, draws[i]);
if (info->increment_draw_id)
drawid++;
}
u_vbuf_draw_vbo(vbuf, info, drawid_offset, NULL, draws, num_draws);
} else {
struct pipe_context *pipe = cso->pipe;

View File

@ -1450,14 +1450,15 @@ u_vbuf_split_indexed_multidraw(struct u_vbuf *mgr, struct pipe_draw_info *info,
draw.index_bias = indirect_data[offset + 3];
info->start_instance = indirect_data[offset + 4];
u_vbuf_draw_vbo(mgr, info, drawid_offset, NULL, draw);
u_vbuf_draw_vbo(mgr, info, drawid_offset, NULL, &draw, 1);
}
}
void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
unsigned drawid_offset,
const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count_bias draw)
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws)
{
struct pipe_context *pipe = mgr->pipe;
int start_vertex;
@ -1495,12 +1496,21 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
u_vbuf_set_driver_vertex_buffers(mgr);
}
pipe->draw_vbo(pipe, info, drawid_offset, indirect, &draw, 1);
pipe->draw_vbo(pipe, info, drawid_offset, indirect, draws, num_draws);
return;
}
/* Increase refcount to be able to use take_index_buffer_ownership with
* all draws.
*/
if (num_draws > 1 && info->take_index_buffer_ownership)
p_atomic_add(&info->index.resource->reference.count, num_draws - 1);
new_info = *info;
new_draw = draw;
for (unsigned d = 0; d < num_draws; d++) {
new_draw = draws[d];
if (info->increment_draw_id)
drawid_offset++;
/* Handle indirect (multi)draws. */
if (indirect && indirect->buffer) {
@ -1776,6 +1786,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
util_primconvert_draw_vbo(mgr->pc, &new_info, drawid_offset, indirect, &new_draw, 1);
} else
pipe->draw_vbo(pipe, &new_info, drawid_offset, indirect, &new_draw, 1);
}
if (mgr->using_translate) {
u_vbuf_translate_end(mgr);

View File

@ -88,7 +88,8 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
unsigned drawid_offset,
const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count_bias draw);
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws);
void u_vbuf_get_minmax_index(struct pipe_context *pipe,
const struct pipe_draw_info *info,
const struct pipe_draw_start_count_bias *draw,