asahi: clamp draw count for mdi

spec req. KHR-GL43.indirect_parameters_tests.MultiDrawArraysIndirectCount

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26614>
This commit is contained in:
Alyssa Rosenzweig 2023-12-04 15:27:40 -04:00
parent fdec9dcf05
commit d11c9f9836
3 changed files with 12 additions and 1 deletions

View file

@ -351,12 +351,19 @@ process_multidraw(global struct agx_ia_state *s, uint local_id,
uintptr_t draw_ptr = s->draws;
uint draw_stride = s->draw_stride;
/* Determine the number of draws. This is given by the application, but must
* be clamped to the minimum provided to the driver, implementing spec text:
*
* The actual number of executed draw calls is the minimum of the count
* specified in countBuffer and maxDrawCount.
*/
uint len = min(*(s->count), s->max_draws);
/* Prefix sum the vertex counts (multiplied by instance counts) across draws.
* The number of draws is expected to be small, so this serialization should
* be ok in practice. See libagx_prefix_sum for algorithm details.
*/
uint i, count = 0;
uint len = *(s->count);
uint len_remainder = len % 32;
uint len_rounded_down = len - len_remainder;

View file

@ -73,6 +73,9 @@ struct agx_ia_state {
/* When unrolling primitive restart, output draw descriptors */
GLOBAL(uint) out_draws;
/* Input: maximum draw count, count is clamped to this */
uint32_t max_draws;
/* Primitive restart index, if unrolling */
uint32_t restart_index;

View file

@ -3510,6 +3510,7 @@ agx_upload_ia_params(struct agx_batch *batch, const struct pipe_draw_info *info,
agx_batch_reads(batch, rsrc);
ia.count = rsrc->bo->ptr.gpu + indirect->indirect_draw_count_offset;
ia.max_draws = indirect->draw_count;
ia.draw_stride = indirect->stride;
/* MDI requires prefix sums, but not for our current unroll path */