Bug 237533 - iOS/iPad 15.3.1 slow drawElements with TRIANGLE_FAN mode
Summary: iOS/iPad 15.3.1 slow drawElements with TRIANGLE_FAN mode
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: anglemetalregr
Blocks:
  Show dependency treegraph
 
Reported: 2022-03-07 08:23 PST by Marcin
Modified: 2022-10-11 05:14 PDT (History)
7 users (show)

See Also:


Attachments
gl.drawElements primitive restart / regular performance comparison (9.31 KB, text/html)
2022-03-08 05:01 PST, Marcin
no flags Details
Added TRIANGLE_STRIP to the test (10.62 KB, text/html)
2022-03-08 05:51 PST, Marcin
no flags Details
drawElements with mode = TRIANGLE_STRIP vs TRIANGLE_FAN vs TRIANGLES (9.15 KB, text/html)
2022-03-08 06:57 PST, Marcin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin 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.
Comment 1 Kimmo Kinnunen 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)
Comment 2 Marcin 2022-03-08 05:01:55 PST
Created attachment 454105 [details]
gl.drawElements primitive restart / regular performance comparison
Comment 3 Marcin 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.
Comment 4 Marcin 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.
Comment 5 Marcin 2022-03-08 05:51:27 PST
Created attachment 454113 [details]
Added TRIANGLE_STRIP to the test
Comment 6 Marcin 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.
Comment 7 Marcin 2022-03-08 06:57:29 PST
Created attachment 454117 [details]
drawElements with mode = TRIANGLE_STRIP vs TRIANGLE_FAN vs TRIANGLES
Comment 8 Radar WebKit Bug Importer 2022-03-10 10:17:26 PST
<rdar://problem/90106467>
Comment 9 Marcin 2022-04-11 06:35:49 PDT
Still reproducible on iOS/iPad 15.4.1
Comment 10 Marcin 2022-10-03 02:26:19 PDT
Still reproducible on iOS/iPad 15.7
Comment 11 Marcin 2022-10-07 08:26:18 PDT
Disabling WebGL via Metal solves the problem
Comment 12 Kimmo Kinnunen 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.
Comment 13 Marcin 2022-10-11 03:58:28 PDT
Thanks Kimmo,
Please note, performance issue happens also in drawArrays with triangle fan mode.
(last attachment)
Comment 14 Marcin 2022-10-11 04:01:13 PDT
Oops, I messed drawArrays / drawElements test cases, I'll re-check what's going on ...
Comment 15 Marcin 2022-10-11 05:14:50 PDT
So, you are right, that's only drawElements issue, I'm sorry for making unnecessary comments :(