Skip to content

Permit zero-temporary-value buffer binding #5737

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

Closed
wants to merge 1 commit into from

Conversation

rbtcollins
Copy link

@rbtcollins rbtcollins commented Jul 28, 2022

When using custom 3D renderers, p5 can support much larger models, but this particular bit of code showed up as a hotspot: I was passing in a Float32 already, and it was getting cloned.

Without this change, my particular workload runs at 7-12 fps. With it 45-50fps.

In principle p5 can make use of this itself, though having webGL ready representations as the source of truth is a much larger change - but even so, taking steps in that direction seems broadly useful.

Resolves #[Add issue number here]

Changes:

Screenshots of the change:

PR Checklist

Fixes: #5739

@welcome
Copy link

welcome bot commented Jul 28, 2022

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

@Qianqianye
Copy link
Contributor

Thank you @rbtcollins ! As a reminder, an issue needs to be opened before a pull request is opened, then you can tag the issue in the pull request. You can read more about it in the GitHub Issue Flow. This is necessary for tracking development and keeping discussion clear. I will close this PR for now for organizational purpose, and please feel free to open a new PR after an issue is opened. Thanks!

@rbtcollins
Copy link
Author

@Qianqianye hoop jumped through, you should be able to re-open this PR now.

@Qianqianye Qianqianye reopened this Jul 29, 2022
When using custom 3D renderers, p5 can support much larger models, but this particular bit of code showed up as a hotspot: I was passing in a Float32 already, and it was getting cloned.

Without this change, my particular workload runs at 7-12 fps. With it 45-50fps.

In principle p5 can make use of this itself, though having webGL ready representations as the source of truth is a much larger change - but even so, taking steps in that direction seems broadly useful.
@davepagurek
Copy link
Contributor

I'm going to close this PR for now because in the time since, we've started adding some tools to p5 to achieve something similar via p5.DataArray (and I think the else branch below also would let you do the workaround you mentioned where you manually replaced an array with a Float32Array):

if (values instanceof p5.DataArray) {
data = values.dataArray();
} else if (!(data instanceof (type || Float32Array))) {
data = new (type || Float32Array)(data);
}

I'm going to leave your issue open because we currently only internally use p5.DataArray for line data, which gets automatically created, so there's still some discussion to be had about the best way to do the same for developer-facing arrays like the vertices of a p5.Geometry. We'd love your feedback that if you have any ideas or opinions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_bindBuffer unnecessarily copies typed arrays
3 participants