mesa: move index bounds code (st_prepare_indexed_draw) into draw.c

there is no other user

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26619>
This commit is contained in:
Marek Olšák 2023-12-07 15:45:38 -05:00 committed by Marge Bot
parent c6281a6f26
commit 3b16541a8f
3 changed files with 23 additions and 35 deletions

View file

@ -1574,6 +1574,23 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
}
#endif
static bool
validate_index_bounds(struct gl_context *ctx, struct pipe_draw_info *info,
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws)
{
assert(info->index_size);
/* Get index bounds for user buffers. */
if (!info->index_bounds_valid && ctx->st->draw_needs_minmax_index) {
/* Return if this fails, which means all draws have count == 0. */
if (!vbo_get_minmax_indices_gallium(ctx, info, draws, num_draws))
return false;
info->index_bounds_valid = true;
}
return true;
}
/**
* Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements.
@ -1655,8 +1672,7 @@ _mesa_validated_drawrangeelements(struct gl_context *ctx,
draw.count = count;
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
if (!st_prepare_indexed_draw(ctx, &info, &draw, 1))
if (!validate_index_bounds(ctx, &info, &draw, 1))
return;
ctx->Driver.DrawGallium(ctx, &info, ctx->DrawID, &draw, 1);
@ -2040,8 +2056,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx,
}
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
if (!st_prepare_indexed_draw(ctx, &info, draw, primcount))
if (!validate_index_bounds(ctx, &info, draw, primcount))
return;
ctx->Driver.DrawGallium(ctx, &info, 0, draw, primcount);
@ -2064,9 +2079,8 @@ _mesa_validated_multidrawelements(struct gl_context *ctx,
draw.count = count[i];
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
if (!st_prepare_indexed_draw(ctx, &info, &draw, 1))
return;
if (!validate_index_bounds(ctx, &info, &draw, 1))
continue;
ctx->Driver.DrawGallium(ctx, &info, i, &draw, 1);
}
@ -2506,9 +2520,8 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type,
draw.index_bias = cmd->baseVertex;
st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
if (!st_prepare_indexed_draw(ctx, &info, &draw, 1))
return;
if (!validate_index_bounds(ctx, &info, &draw, 1))
continue;
ctx->Driver.DrawGallium(ctx, &info, i, &draw, 1);
ptr += stride;

View file

@ -111,26 +111,6 @@ st_prepare_draw(struct gl_context *ctx, uint64_t state_mask)
}
}
bool
st_prepare_indexed_draw(struct gl_context *ctx, struct pipe_draw_info *info,
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws)
{
struct st_context *st = ctx->st;
assert(info->index_size);
/* Get index bounds for user buffers. */
if (!info->index_bounds_valid && st->draw_needs_minmax_index) {
/* Return if this fails, which means all draws have count == 0. */
if (!vbo_get_minmax_indices_gallium(ctx, info, draws, num_draws))
return false;
info->index_bounds_valid = true;
}
return true;
}
static void
st_draw_gallium(struct gl_context *ctx,
struct pipe_draw_info *info,

View file

@ -76,11 +76,6 @@ pointer_to_offset(const void *ptr)
void
st_prepare_draw(struct gl_context *ctx, uint64_t state_mask);
bool
st_prepare_indexed_draw(struct gl_context *ctx, struct pipe_draw_info *info,
const struct pipe_draw_start_count_bias *draws,
unsigned num_draws);
bool
st_draw_quad(struct st_context *st,
float x0, float y0, float x1, float y1, float z,