# About Mali GPU index buffer processing (group of 4 indices)

Hello. I have some questions about Mali GPU (After Valhall) index buffer shading.

Related Video : https://youtu.be/BD1zXW7Uz8Q?t=2838

Related Q&A :

According to Q&A and Video, I understood index buffer is processed like below
[0, 7, 15] => [0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15]
About this, I wonder how 4 indices are picked in each groups.
for example,

a. pick 3 indices at right side of target index.
ex.) [1, 5, 7]
-> 1, 2, 3, 4
-> 5, 6, 7, 8
-> 7 (already processed)
b. pick 3 indices at right side of target index, if count if not enough, pick at left side too.
ex.) [1, 5, 13]
-> 1, 2, 3, 4
-> 5, 6, 7, 8
-> 10, 11, 12, 13
c, pick 3 indices at left side of target index.
ex.) [1, 10, 15]
-> 1
-> 7, 8, 9, 10
-> 12, 13, 14, 15
Does ARM GPU uses one of these method when it makes group? or use other?
(Background)
I'm currently testing a LOD System using procedural draw call which is adjusting index count base on LOD Level and this is why I wanted to ask above question.
ex.)
- LOD 0 : index count 100
- LOD 1 : index count 50
- LOD 2 : index count 10
This system re-orders index buffer.
-> ex.)
original triangles : [a(1, 2, 3), b(2, 3, 4), c(3, 4, 5), d(...), e, f, g, h, i]
reorder result : [a, i, e, b, c, f, d, g, h]
=> index does not increase linearly. it jumps.

Because of the way ARM GPU shades indices, IDVS position shader invocations has increased after LOD System applied.
To prevent increasing, I wanted to add some duplicated vertices but I think i need to know the way of making index group to find optimal way to put duplicate vertices.
And I wonder if you know any libraries that can be applied to situations like this.
Thank you for reading!
I hope you have a good day.

• Hi seungchan,

Index groups always round down to a naturally aligned base index (i.e. where (base % 4) == 0).

ex.) [1, 5, 7]

Groups will be 0-3, 4-7

ex.) [1, 5, 13]

Groups will be 0-3, 4-7, 12-15

ex.) [1, 10, 15]

Groups will be 0-3, 8-11, 12-15

reorder result : [a, i, e, b, c, f, d, g, h]

One thing to watch out for with reordering is a loss of reuse locality (e.g. "a" and "b" share an edge, but are now some distance apart). Mali uses a post-transform cache for positions, so if the index reuse is too far apart you may end up reshading the same index multiple times.

Our new Frame Advisor tool can give more feedback on geometry efficiency metrics and how much additional shading you will experience.

Cheers,
Pete