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

Allow positional buffer updates #419

Closed
wants to merge 2 commits into from
Closed

Allow positional buffer updates #419

wants to merge 2 commits into from

Conversation

thefiredman
Copy link

It is inefficient to stream all positional data for some use cases,

buffer_update_at now lets you specify a starting point:

so instead of streaming all your data at once like this example:

self.ctx.buffer_update(
    self.bindings.vertex_buffers[1],
    BufferSource::slice(&self.pos[..]),
);

you can only update the portion that has changed for instance:

self.ctx.buffer_update_at(
    self.bindings.vertex_buffers[1],
    BufferSource::slice(&self.pos[0..3]),
    3, // starting point
);

I'm aware this is error prone, and should be reviewed but I think this'll be useful for some especially those who want to dynamically change their instanced data. It so error prone in fact maybe it should not be added at all. 🤷🏻

@thefiredman thefiredman marked this pull request as draft February 8, 2024 07:59
@thefiredman thefiredman changed the title allow positional buffer updates Allow positional buffer updates Feb 8, 2024
@thefiredman thefiredman marked this pull request as ready for review February 8, 2024 08:10
@thefiredman thefiredman closed this Feb 9, 2024
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