asny / three-d

2D/3D renderer - makes it simple to draw stuff across platforms (including web)
MIT License
1.29k stars 109 forks source link

Optimise full_screen_draw #458

Closed swiftcoder closed 4 months ago

swiftcoder commented 4 months ago

Get rid of the vertex buffer entirely, in favour of indexing vertex positions from an array within the vertex shader.

Before this patch full_screen_draw is taking 18% of my frame time (mostly in creating and destroying the vertex buffer multiple times per frame):

Screenshot 2024-05-26 at 12 23 11

After the patch it is reduced to 6%:

Screenshot 2024-05-26 at 12 24 07

Note that my app is very heavy on post-process effects - I expect the majority of apps will not see quite such a major difference.

swiftcoder commented 4 months ago

I've tested on Chrome+WebGL and native MacOS. Have not had a chance to fire it up on other platforms

Edit: Safari and Firefox for Mac both also work

asny commented 4 months ago

I've tested on Chrome+WebGL and native MacOS. Have not had a chance to fire it up on other platforms

Edit: Safari and Firefox for Mac both also work

Cool. That's good enough for me 🙂