-
Notifications
You must be signed in to change notification settings - Fork 62
auto-replace buffers #974
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
base: main
Are you sure you want to change the base?
auto-replace buffers #974
Conversation
|
OK I got the basics down for lines. One caveat is that now there's no check to make sure that the buffer sizes match for data and colors for example. Consider this: lg = subplot.add_line(np.random.rand(100))
lg.data = np.random.rand(200)Now the last 100 line points are just black since they're not defined. A user has to explicitly set the colors of the new vertices that extend beyond the previously defined buffer. lg.colors = ["w"] * 200Or they can use a uniform color for things like this. |
|
ok for images I think easiest way is to create new world objects 🤔 EDIT: Yup this will be fine, I was initially worried that we'd have to re-add event handlers if we create a new world object, but I don't think that's necessary since EDIT again: Just tested with image click events, if an event handler is added to the graphic then when new tiles are created the graphic is still responsive to those events because it's the |
|
@clewis7 would like to get your review before I do the gc tests |
|
📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/replaceable-buffers |
|
I think we should make uniforms the default for all graphics 🤔. Also good time to start a "performance tips" section of the docs. Replacing the buffer has a huge performance hit so you don't want do it all the time. |
|
I found a memory leak, if Posted on pygfx: pygfx/pygfx#1264 For now I implemented manually destroying the |
|
@clewis7 what do you think about: For lines, default is: For scatters, default is: I think independent scatter colors is a more common usecase than lines. We can auto-determine it in the future based on the colors and cmap arg but I'll do that in the future. EDIT: But then the API is inconsistent between lines and scatters :/ |
I think this behavior is confusing. Perhaps it is better to just by default take the current color scheme and extend it to the new or fewer points. |
Hmmm, I do agree that scatters are more likley to have individual colors. How much a performance reduction is it if you make the lines also have |
closes #869
Replace positions related buffers when the user sets all the data with a new array that has a different number of positions (vertices) than the existing buffer. Example, user sets all line or scatter data,
line.data = <bigger or smaller array>.Implemented in all
BufferManagersubclasses, and the imageTextureArraysVertexPositionsVertexColorsVertexRotationsVertexPointSizesVertexMarkersMeshIndices, gets it automatically from parent classVertexPositionsTextureArrayif setting all the data with a new image that has different dimsisolated_buffer, OOC rendering is the better way to handle very large dataSlicing and setting data, i.e.
graphic.data[<slice>] = <array>is unchanged. New buffers are created only when the entire data is set with new data that needs a bigger or smaller buffer.