Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise full_screen_draw #458

Merged
merged 2 commits into from
May 29, 2024
Merged

Conversation

swiftcoder
Copy link
Contributor

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.

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 frametime (mostly in creating and destroying the vertex buffer many times per from).

After the patch it is reduced to 5%. 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.
Copy link
Owner

@asny asny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💪 How well did you test this? It seems like gl_VertexID is pretty well supported, but it wouldn't be the first time there were inconsistencies in OpenGL/WebGL implementations.

src/core/program.rs Outdated Show resolved Hide resolved
@swiftcoder
Copy link
Contributor Author

swiftcoder commented May 29, 2024

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
Copy link
Owner

asny commented May 29, 2024

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 🙂

@asny asny merged commit a69b708 into asny:master May 29, 2024
5 checks passed
@swiftcoder swiftcoder deleted the optimise-full_screen_draw branch May 29, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants