NEW 237533
iOS/iPad 15.3.1 slow drawElements with TRIANGLE_FAN mode
https://bugs.webkit.org/show_bug.cgi?id=237533
Summary iOS/iPad 15.3.1 slow drawElements with TRIANGLE_FAN mode
Marcin
Reported 2022-03-07 08:23:10 PST
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.
Attachments
gl.drawElements primitive restart / regular performance comparison (9.31 KB, text/html)
2022-03-08 05:01 PST, Marcin
no flags
Added TRIANGLE_STRIP to the test (10.62 KB, text/html)
2022-03-08 05:51 PST, Marcin
no flags
drawElements with mode = TRIANGLE_STRIP vs TRIANGLE_FAN vs TRIANGLES (9.15 KB, text/html)
2022-03-08 06:57 PST, Marcin
no flags
Kimmo Kinnunen
Comment 1 2022-03-07 11:15:53 PST
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)
Marcin
Comment 2 2022-03-08 05:01:55 PST
Created attachment 454105 [details] gl.drawElements primitive restart / regular performance comparison
Marcin
Comment 3 2022-03-08 05:03:22 PST
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.
Marcin
Comment 4 2022-03-08 05:50:08 PST
After playing a while with the test case, I've noticed TRIANGLE_STRIP with primitive restart IS NOT affected.
Marcin
Comment 5 2022-03-08 05:51:27 PST
Created attachment 454113 [details] Added TRIANGLE_STRIP to the test
Marcin
Comment 6 2022-03-08 06:55:52 PST
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.
Marcin
Comment 7 2022-03-08 06:57:29 PST
Created attachment 454117 [details] drawElements with mode = TRIANGLE_STRIP vs TRIANGLE_FAN vs TRIANGLES
Radar WebKit Bug Importer
Comment 8 2022-03-10 10:17:26 PST
Marcin
Comment 9 2022-04-11 06:35:49 PDT
Still reproducible on iOS/iPad 15.4.1
Marcin
Comment 10 2022-10-03 02:26:19 PDT
Still reproducible on iOS/iPad 15.7
Marcin
Comment 11 2022-10-07 08:26:18 PDT
Disabling WebGL via Metal solves the problem
Kimmo Kinnunen
Comment 12 2022-10-11 01:27:35 PDT
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.
Marcin
Comment 13 2022-10-11 03:58:28 PDT
Thanks Kimmo, Please note, performance issue happens also in drawArrays with triangle fan mode. (last attachment)
Marcin
Comment 14 2022-10-11 04:01:13 PDT
Oops, I messed drawArrays / drawElements test cases, I'll re-check what's going on ...
Marcin
Comment 15 2022-10-11 05:14:50 PDT
So, you are right, that's only drawElements issue, I'm sorry for making unnecessary comments :(
Note You need to log in before you can comment on or make changes to this bug.