vbo: add vbo_get_minmax_indices_gallium

to be used by st/mesa to get index bounds because it won't have _mesa_prim
with the new draw interface.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7679>
This commit is contained in:
Marek Olšák 2020-11-03 13:03:28 -05:00
parent bd54e34e4f
commit fc3d165354
2 changed files with 44 additions and 0 deletions

View File

@ -43,6 +43,8 @@ extern "C" {
#endif
struct gl_context;
struct pipe_draw_info;
struct pipe_draw_start_count;
/**
* Max number of primitives (number of glBegin/End pairs) per VBO.
@ -229,6 +231,12 @@ vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim,
bool primitive_restart,
unsigned restart_index);
void
vbo_get_minmax_indices_gallium(struct gl_context *ctx,
struct pipe_draw_info *info,
const struct pipe_draw_start_count *draws,
unsigned num_draws);
void
vbo_sw_primitive_restart(struct gl_context *ctx,
const struct _mesa_prim *prim,

View File

@ -34,6 +34,7 @@
#include "x86/common_x86_asm.h"
#include "util/hash_table.h"
#include "util/u_memory.h"
#include "pipe/p_state.h"
struct minmax_cache_key {
@ -393,3 +394,38 @@ vbo_get_minmax_indices(struct gl_context *ctx,
*max_index = MAX2(*max_index, tmp_max);
}
}
/**
* Same as vbo_get_minmax_index, but using gallium draw structures.
*/
void
vbo_get_minmax_indices_gallium(struct gl_context *ctx,
struct pipe_draw_info *info,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{
info->min_index = ~0;
info->max_index = 0;
for (unsigned i = 0; i < num_draws; i++) {
struct pipe_draw_start_count draw = draws[i];
/* Do combination if possible to reduce map/unmap count */
while ((i + 1 < num_draws) &&
(draws[i].start + draws[i].count == draws[i+1].start)) {
draw.count += draws[i+1].count;
i++;
}
unsigned tmp_min, tmp_max;
vbo_get_minmax_index(ctx, info->has_user_indices ?
NULL : info->index.gl_bo,
info->index.user,
(GLintptr)draw.start * info->index_size,
draw.count, info->index_size,
info->primitive_restart, info->restart_index,
&tmp_min, &tmp_max);
info->min_index = MIN2(info->min_index, tmp_min);
info->max_index = MAX2(info->max_index, tmp_max);
}
}