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
Updating collections #1505
Comments
@rougier Any advice? |
Of course i understand this is about different types of declarations in the shaders. I am not very familiar with those yet. |
This should work, I don't see where's the problem. Can you check what is the code at line 271 on gloo/buffer ? |
@rougier First sorry for the delay, i just was en vacances. So, no it clearly does not work! I show more code below, this is the latest version of the vispy master branch. It appears that in the
But writing in a
My understanding is that each vertex of this points collection has 'position', 'size' and 'collection_index' (by the way, does this one handle the color?) fields, and it is forbidden to set only one field as this represents non-contiguous data in the memory? Note also that V is a |
Note also that i have the same error for other collection objects, e.g. lines:
|
Ouch. That may be a structural difference between vispy and glumpy. I originally coded collections for glumpy and we ported them to vispy. In glumpy, I compute the smallest contiguous chunk of memory to uploadi it at once to the GPU. In vispy, I don't quite remember how we coded the data buffer but it might be possible we forbid such update. To solve the problem would thus require to (maybe) rething the data buffer a little bit. If it is not clear, there's also an explanation at https://www.labri.fr/perso/nrougier/from-python-to-numpy/#memory-aware-array |
Thank you for the explanation (and nice book by the way). |
Yes, for vispy I think we decided at some point to not have a CPU image and this prevent us to to upload non contiguous data to a GPU buffer from what I remember. For glumpy, I chose a different option, the advantage being to be able to upload non contiguous data and to batch all updates in one operation. One potential solution for vispy and collection would be to split the single GPU buffer into several one but this may impact performances. |
Oh, i can't go down to write my own shaders as i would like to draw antialiased lines, this would be too difficult! Maybe do i start to understand enough to try editing myself the buffer classes. What about having an optional CPU buffer (default would be not to have it), which, if activated, makes it possible to write non-contiguous data? Do you see any difficulty with this? |
I'm not sure how much work is needed. but you can have a look at glumpy to check for the implementation of the CPU implementation and see differences with vispy. |
@rougier The disadvantages of having a CPU backed buffer were mentioned so just wanted to make sure I'm understanding this properly.
If I'm understanding the existing vispy version of collections and this issue, we don't necessarily need to have the entire buffer's data to send the individual vertex update, we just need to have a single "dtype"s data to send the right "block" of data.
@rougier Does that sound right at all? Could you point us at the relevant functions in glumpy's versions of the buffers? iirc you thought that vispy might be used by glumpy in a scipy:numpy-like relationship. If we want this to happen at some point in the future we'll need to resolve these inconsistencies. It doesn't sound like it is impossible to have both of these options and it doesn't sound like the user shouldn't be able to configure them if they are worried about all levels of performance. |
You're right. The other problem with the GPU only version is that all pending upload operations cannot be agglomerated into a single operation. If you have many operations, this can slow down things a lot. But for very large buffers, I don't know if the glumpy approach is good. We would need some benchmarks at some point. Concerning the scipy/numpy relationship, you're right. It is the way I generally present glumpy and vispy . I did not implement the vispy scene stuff which is a real strength of vispy. But it would make sense to have two packages (and possibly later, some toolkits). However, the other problem is also the shader variables handling that may be not compatible at all. @campagnola @almarklein @rossant what do you think / remember of these choices ? |
@rougier Hello, I am back on this issue. I had a look at how Buffers are implemented in glumpy, I see that they inherit from GPUdata, which itself inherits from np.ndarray and provides mechanisms for keeping track of the memory range that has been modified. So please find here how I propose to implement CPU buffers in vispy and please comment and/or give alternative suggestions:
How does this sound? |
Yes, that sounds like a reasonable approach. Instead of For the DataBufferView, I can't find where it is defined in glumpy, do you know? |
Thanks. You mean I don't know anything about glumpy except now for this Buffer and GPUData classes i studied, so i can't answer your question! |
Actually I meant |
Oh, |
Indeed! My question was: what should i do with the vispy And similar question for the |
I think you'll need it for the index buffer but probably not for he data buffer view (since it is merely a view on a data buffer that has been already declared with |
ARGHH!! I have finally made this feature of an optional CPU buffer (see PR #1538), but Collections still have a log of other bugs. Now i do not get an error any more when setting, for example I have a demo of my program scheduled Friday for which i need fast updates (as opposed to the slow updates in the current stable version that uses individual Scenegraph points and lines). I won't pursue now with collections, and rather return to my alternative path of writing my own shaders. But i would appreciate if @rougier you can comment. |
Where is this |
It is an attribute of the BaseCollection class. I have the impression that the Better is to give an example, but for it to not give execution error, you need to run it on top of PR #1538. You will see that when method
|
Note that |
sure, but size has to be local so i see no way to successfully change the property |
Hello, I don't find how to update basic values of collections.
For example, i can create a points collection:
But trying to change its vertices coordinates:
Gives me the error:
Besides, I managed to update the colors:
This was possible only with
color="shared"
when constructing the PointCollection object, whilecolor="local"
resulted in the same error as above when trying to update the color; but i could not guess appropriately what these keywords mean. I tried a similarposition="shared"
but this was not accepted. In general i am suffering from the lack of documentation!The text was updated successfully, but these errors were encountered: