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

functions for copying data to buffers directly on the GPU #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

micahscopes
Copy link

@micahscopes micahscopes commented May 3, 2023

For #11 I got inspired to just go ahead and implement what I was imagining.

This PR adds some utility functions for copying framebuffer data to a single buffer (readPixelsToWebGLBuffer) and also to multiple buffers (readPixelsToMultipleWebGLBuffers). Additionally, there's a simple GPULayer.copyToWebGLBuffer that uses readPixelsToWebGLBuffer.

This is WebGL2-only functionality. I'd like to support mobile devices in my application but I was running out of framebuffer attachments, so my plan is to concatenate a bunch of data into a single GPULayer and use the readPixelsToMultipleWebGLBuffers to read them out to various buffers that I can use as vertex/instance attribute buffers. This will also cut back on texture sampling.

Performance is still a ❔ but hopefully it'll be better!

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.

1 participant