gallium: add pipe_draw_info::index_bounds_valid
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7441>
This commit is contained in:
parent
920bbfb3a0
commit
72ff53098c
|
@ -108,6 +108,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc,
|
||||||
unsigned ib_offset;
|
unsigned ib_offset;
|
||||||
|
|
||||||
util_draw_init_info(&new_info);
|
util_draw_init_info(&new_info);
|
||||||
|
new_info.index_bounds_valid = info->index_bounds_valid;
|
||||||
new_info.min_index = info->min_index;
|
new_info.min_index = info->min_index;
|
||||||
new_info.max_index = info->max_index;
|
new_info.max_index = info->max_index;
|
||||||
new_info.index_bias = info->index_bias;
|
new_info.index_bias = info->index_bias;
|
||||||
|
|
|
@ -104,6 +104,7 @@ util_draw_arrays_instanced(struct pipe_context *pipe,
|
||||||
info.count = count;
|
info.count = count;
|
||||||
info.start_instance = start_instance;
|
info.start_instance = start_instance;
|
||||||
info.instance_count = instance_count;
|
info.instance_count = instance_count;
|
||||||
|
info.index_bounds_valid = true;
|
||||||
info.min_index = start;
|
info.min_index = start;
|
||||||
info.max_index = start + count - 1;
|
info.max_index = start + count - 1;
|
||||||
|
|
||||||
|
|
|
@ -1373,6 +1373,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
|
||||||
* These values determine the user buffer bounds to upload.
|
* These values determine the user buffer bounds to upload.
|
||||||
*/
|
*/
|
||||||
new_info.index_bias = index_bias0;
|
new_info.index_bias = index_bias0;
|
||||||
|
new_info.index_bounds_valid = true;
|
||||||
new_info.min_index = ~0u;
|
new_info.min_index = ~0u;
|
||||||
new_info.max_index = 0;
|
new_info.max_index = 0;
|
||||||
new_info.start_instance = ~0u;
|
new_info.start_instance = ~0u;
|
||||||
|
@ -1469,7 +1470,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
|
||||||
if (u_vbuf_need_minmax_index(mgr)) {
|
if (u_vbuf_need_minmax_index(mgr)) {
|
||||||
unsigned max_index;
|
unsigned max_index;
|
||||||
|
|
||||||
if (new_info.max_index != ~0u) {
|
if (new_info.index_bounds_valid) {
|
||||||
min_index = new_info.min_index;
|
min_index = new_info.min_index;
|
||||||
max_index = new_info.max_index;
|
max_index = new_info.max_index;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ lima_draw_vbo_indexed(struct pipe_context *pctx,
|
||||||
|
|
||||||
/* Mali Utgard GPU always need min/max index info for index draw,
|
/* Mali Utgard GPU always need min/max index info for index draw,
|
||||||
* compute it if upper layer does not do for us */
|
* compute it if upper layer does not do for us */
|
||||||
if (info->max_index != ~0u) {
|
if (info->index_bounds_valid) {
|
||||||
ctx->min_index = info->min_index;
|
ctx->min_index = info->min_index;
|
||||||
ctx->max_index = info->max_index;
|
ctx->max_index = info->max_index;
|
||||||
needs_indices = false;
|
needs_indices = false;
|
||||||
|
|
|
@ -69,7 +69,7 @@ panfrost_get_index_buffer_bounded(struct panfrost_context *ctx,
|
||||||
bool needs_indices = true;
|
bool needs_indices = true;
|
||||||
mali_ptr out = 0;
|
mali_ptr out = 0;
|
||||||
|
|
||||||
if (info->max_index != ~0u) {
|
if (info->index_bounds_valid) {
|
||||||
*min_index = info->min_index;
|
*min_index = info->min_index;
|
||||||
*max_index = info->max_index;
|
*max_index = info->max_index;
|
||||||
needs_indices = false;
|
needs_indices = false;
|
||||||
|
|
|
@ -1840,6 +1840,7 @@ static void handle_update_buffer(struct lvp_cmd_buffer_entry *cmd,
|
||||||
static void handle_draw_indexed(struct lvp_cmd_buffer_entry *cmd,
|
static void handle_draw_indexed(struct lvp_cmd_buffer_entry *cmd,
|
||||||
struct rendering_state *state)
|
struct rendering_state *state)
|
||||||
{
|
{
|
||||||
|
state->info.index_bounds_valid = false;
|
||||||
state->info.min_index = 0;
|
state->info.min_index = 0;
|
||||||
state->info.max_index = ~0;
|
state->info.max_index = ~0;
|
||||||
state->info.index_size = state->index_size;
|
state->info.index_size = state->index_size;
|
||||||
|
@ -1864,6 +1865,7 @@ static void handle_draw_indirect(struct lvp_cmd_buffer_entry *cmd,
|
||||||
struct rendering_state *state, bool indexed)
|
struct rendering_state *state, bool indexed)
|
||||||
{
|
{
|
||||||
if (indexed) {
|
if (indexed) {
|
||||||
|
state->info.index_bounds_valid = false;
|
||||||
state->info.index_size = state->index_size;
|
state->info.index_size = state->index_size;
|
||||||
state->info.index.resource = state->index_buffer;
|
state->info.index.resource = state->index_buffer;
|
||||||
state->info.max_index = ~0;
|
state->info.max_index = ~0;
|
||||||
|
|
|
@ -2358,6 +2358,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive,
|
||||||
info.index_size = context->index_size;
|
info.index_size = context->index_size;
|
||||||
info.start = context->index_offset / context->index_size + StartIndex;
|
info.start = context->index_offset / context->index_size + StartIndex;
|
||||||
info.index_bias = BaseVertexIndex;
|
info.index_bias = BaseVertexIndex;
|
||||||
|
info.index_bounds_valid = true;
|
||||||
/* These don't include index bias: */
|
/* These don't include index bias: */
|
||||||
info.min_index = MinVertexIndex;
|
info.min_index = MinVertexIndex;
|
||||||
info.max_index = MinVertexIndex + NumVertices - 1;
|
info.max_index = MinVertexIndex + NumVertices - 1;
|
||||||
|
@ -2409,6 +2410,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf,
|
||||||
info.index_size = index_size;
|
info.index_size = index_size;
|
||||||
info.start = index_offset / info.index_size;
|
info.start = index_offset / info.index_size;
|
||||||
info.index_bias = 0;
|
info.index_bias = 0;
|
||||||
|
info.index_bounds_valid = true;
|
||||||
info.min_index = MinVertexIndex;
|
info.min_index = MinVertexIndex;
|
||||||
info.max_index = MinVertexIndex + NumVertices - 1;
|
info.max_index = MinVertexIndex + NumVertices - 1;
|
||||||
info.has_user_indices = ibuf == NULL;
|
info.has_user_indices = ibuf == NULL;
|
||||||
|
|
|
@ -761,8 +761,10 @@ struct pipe_draw_info
|
||||||
ubyte vertices_per_patch; /**< the number of vertices per patch */
|
ubyte vertices_per_patch; /**< the number of vertices per patch */
|
||||||
ubyte index_size; /**< if 0, the draw is not indexed. */
|
ubyte index_size; /**< if 0, the draw is not indexed. */
|
||||||
bool primitive_restart:1;
|
bool primitive_restart:1;
|
||||||
bool has_user_indices:1; /**< if true, use index.user_buffer */
|
bool has_user_indices:1; /**< if true, use index.user_buffer */
|
||||||
char _pad:6; /**< padding for memcmp */
|
bool index_bounds_valid:1; /**< whether min_index and max_index are valid;
|
||||||
|
they're always invalid if index_size == 0 */
|
||||||
|
char _pad:5; /**< padding for memcmp */
|
||||||
|
|
||||||
unsigned start_instance; /**< first instance id */
|
unsigned start_instance; /**< first instance id */
|
||||||
unsigned instance_count; /**< number of instances */
|
unsigned instance_count; /**< number of instances */
|
||||||
|
|
|
@ -188,9 +188,11 @@ st_draw_vbo(struct gl_context *ctx,
|
||||||
if (!index_bounds_valid && st->draw_needs_minmax_index) {
|
if (!index_bounds_valid && st->draw_needs_minmax_index) {
|
||||||
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
|
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
|
||||||
nr_prims);
|
nr_prims);
|
||||||
|
index_bounds_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.index_size = 1 << ib->index_size_shift;
|
info.index_size = 1 << ib->index_size_shift;
|
||||||
|
info.index_bounds_valid = index_bounds_valid;
|
||||||
info.min_index = min_index;
|
info.min_index = min_index;
|
||||||
info.max_index = max_index;
|
info.max_index = max_index;
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,10 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
|
|
||||||
st_validate_state(st, ST_PIPELINE_RENDER);
|
st_validate_state(st, ST_PIPELINE_RENDER);
|
||||||
|
|
||||||
if (ib && !index_bounds_valid)
|
if (ib && !index_bounds_valid) {
|
||||||
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
|
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
|
||||||
|
index_bounds_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* must get these after state validation! */
|
/* must get these after state validation! */
|
||||||
struct st_common_variant_key key;
|
struct st_common_variant_key key;
|
||||||
|
@ -201,6 +203,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
info.index_size = index_size;
|
info.index_size = index_size;
|
||||||
|
info.index_bounds_valid = index_bounds_valid;
|
||||||
info.min_index = min_index;
|
info.min_index = min_index;
|
||||||
info.max_index = max_index;
|
info.max_index = max_index;
|
||||||
info.has_user_indices = true;
|
info.has_user_indices = true;
|
||||||
|
|
Loading…
Reference in New Issue