On iOS/iPad 15.3.1 gl.drawElements with gl.UNSIGNED_INT index buffer containing ~0 to restart gl.TRIANGLE_FAN geometry is incredibly slow. I haven't checked UNSIGNED_SHORT, UNSIGNED_BYTE types but switching to gl.TRIANGLES without primitive restarts works OK.
Thanks for the report. If you have a self contained test case, feel free to attach / link that, it always helps. (Primitive restart is "emulated" when running on Metal, and the implementation might not be as tuned as the older OpenGL-based implementation)
Created attachment 454105 [details] gl.drawElements primitive restart / regular performance comparison
You're welcome Kimmo. Thank you for letting me know it has to be emulated in metal. Please find performance comparison attached. Note, adding burst loop was necessary to show the difference. If I'd call gl.drawElements simply once per frame, there was no performance difference between TRIANGLES w/o restarts and TRIANGLE_FAN with restarts.
After playing a while with the test case, I've noticed TRIANGLE_STRIP with primitive restart IS NOT affected.
Created attachment 454113 [details] Added TRIANGLE_STRIP to the test
Finally it appears the problem has nothing to do with primitive restarts. I've narrowed regression to drawElements with mode=TRIANGLE_FAN. drawArrays is NOT AFFECTED.
Created attachment 454117 [details] drawElements with mode = TRIANGLE_STRIP vs TRIANGLE_FAN vs TRIANGLES
<rdar://problem/90106467>
Still reproducible on iOS/iPad 15.4.1
Still reproducible on iOS/iPad 15.7
Disabling WebGL via Metal solves the problem
Thanks for continuing to investigate. I filed upstream ANGLE bug at: https://bugs.chromium.org/p/angleproject/issues/detail?id=7748 Metal does not support TRIANGLE_FAN drawing mode natively. ANGLE emulates it. The GPU implementation of the emulation is turned off when primitive restart is supported. For WebGL2 primitive restart is enabled. To get an idea of the perf difference after the emulation is fixed to work with primitive restart, you can try to change the test case: - use WebGL1 or - change to drawArrays, where the emulation generates the emulated buffer once per draw after modification.
Thanks Kimmo, Please note, performance issue happens also in drawArrays with triangle fan mode. (last attachment)
Oops, I messed drawArrays / drawElements test cases, I'll re-check what's going on ...
So, you are right, that's only drawElements issue, I'm sorry for making unnecessary comments :(