mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 02:20:11 +01:00
u_primconvert: Refactor to remove recursion from util_primconvert_draw_vbo
This prevents having unused copies of pipe_draw_info and pipe_draw_start_count_bias on the stack, and makes it easier to do things once for a multi-draw, which will matter in the next patch. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Sil Vilerino <sivileri@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16182>
This commit is contained in:
parent
0474bbcfb9
commit
12d88d500d
1 changed files with 21 additions and 19 deletions
|
|
@ -105,7 +105,6 @@ util_primconvert_save_flatshade_first(struct primconvert_context *pc, bool flats
|
|||
static bool
|
||||
primconvert_init_draw(struct primconvert_context *pc,
|
||||
const struct pipe_draw_info *info,
|
||||
const struct pipe_draw_indirect_info *indirect,
|
||||
const struct pipe_draw_start_count_bias *draws,
|
||||
struct pipe_draw_info *new_info,
|
||||
struct pipe_draw_start_count_bias *new_draw)
|
||||
|
|
@ -270,6 +269,23 @@ primconvert_init_draw(struct primconvert_context *pc,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
util_primconvert_draw_single_vbo(struct primconvert_context *pc,
|
||||
const struct pipe_draw_info *info,
|
||||
unsigned drawid_offset,
|
||||
const struct pipe_draw_start_count_bias *draw)
|
||||
{
|
||||
struct pipe_draw_info new_info;
|
||||
struct pipe_draw_start_count_bias new_draw;
|
||||
|
||||
if (!primconvert_init_draw(pc, info, draw, &new_info, &new_draw))
|
||||
return;
|
||||
/* to the translated draw: */
|
||||
pc->pipe->draw_vbo(pc->pipe, &new_info, drawid_offset, NULL, &new_draw, 1);
|
||||
|
||||
pipe_resource_reference(&new_info.index.resource, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
util_primconvert_draw_vbo(struct primconvert_context *pc,
|
||||
const struct pipe_draw_info *info,
|
||||
|
|
@ -278,9 +294,6 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
|
|||
const struct pipe_draw_start_count_bias *draws,
|
||||
unsigned num_draws)
|
||||
{
|
||||
struct pipe_draw_info new_info;
|
||||
struct pipe_draw_start_count_bias new_draw;
|
||||
|
||||
if (indirect && indirect->buffer) {
|
||||
/* this is stupid, but we're already doing a readback,
|
||||
* so this thing may as well get the rest of the job done
|
||||
|
|
@ -291,28 +304,17 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
|
|||
return;
|
||||
|
||||
for (unsigned i = 0; i < draw_count; i++)
|
||||
util_primconvert_draw_vbo(pc, &new_draws[i].info, drawid_offset + i, NULL, &new_draws[i].draw, 1);
|
||||
util_primconvert_draw_single_vbo(pc, &new_draws[i].info, drawid_offset + i, &new_draws[i].draw);
|
||||
free(new_draws);
|
||||
return;
|
||||
}
|
||||
|
||||
if (num_draws > 1) {
|
||||
} else {
|
||||
unsigned drawid = drawid_offset;
|
||||
for (unsigned i = 0; i < num_draws; i++) {
|
||||
if (draws[i].count && info->instance_count)
|
||||
util_primconvert_draw_vbo(pc, info, drawid, NULL, &draws[i], 1);
|
||||
util_primconvert_draw_single_vbo(pc, info, drawid, &draws[i]);
|
||||
if (info->increment_draw_id)
|
||||
drawid++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!primconvert_init_draw(pc, info, indirect, draws, &new_info, &new_draw))
|
||||
return;
|
||||
/* to the translated draw: */
|
||||
pc->pipe->draw_vbo(pc->pipe, &new_info, drawid_offset, NULL, &new_draw, 1);
|
||||
|
||||
pipe_resource_reference(&new_info.index.resource, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -344,7 +346,7 @@ util_primconvert_draw_vertex_state(struct primconvert_context *pc,
|
|||
dinfo.index_size = 4;
|
||||
dinfo.instance_count = 1;
|
||||
dinfo.index.resource = vstate->input.indexbuf;
|
||||
if (!primconvert_init_draw(pc, &dinfo, NULL, draws, &new_info, &new_draw))
|
||||
if (!primconvert_init_draw(pc, &dinfo, draws, &new_info, &new_draw))
|
||||
return;
|
||||
|
||||
struct pipe_vertex_state *new_state = pc->pipe->screen->create_vertex_state(pc->pipe->screen,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue