-
Notifications
You must be signed in to change notification settings - Fork 63
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
VAO instance cache may be invalid #191
Comments
Right. I guess that is driver dependent. More data needs to be added to the key. Potential key values
This is a semi-hot path, so it should ideally be as light as possible. |
It could also add some unique identifier in the |
Program.extra is for user use, it seems inappropriate to use it here. Your suggestion of using "The id() of the object" may be a better idea. |
Python's |
Yes, I forgot it. The use of Program.extra that you mentioned might be the simplest method, but from an interface design perspective, extra should be for the user to use, and the user could overwrite it with a new object at any time. Similarly, adding an additional identifier member in Program might also be a way. Perhaps this is the most intuitive way. But this requires modifications in moderngl. |
WeakValueDictionary is definitely the only solution here as far as I can see. |
I don't know what I was thinking when suggesting storing Also remember that you don't have to use the VAO wrapper. It's just a convenient way to auto map buffers with different programs also supporting a sub-set of the buffers. You can just do An alternative is just keeping the old program around in some cache. Will have to ponder more on this one. |
The VAO instance method uses the program id as a key to cache VertexArray internally.
However, if the original Program is released, and a new Program is created, the opengl id of the new Program may be the same as the original program.
But the vertex attributes of the new Program have a different layout. At this time, calling the VAO instance method to get the VertexArray from the cache will be wrong!
This is a potential error behavior, difficult to be discovered.
A better way might be to remember the layout of the vertices, see if they are consistent, and then decide whether to reuse the VertexArray in the cache.
Source code with potential issues:
The text was updated successfully, but these errors were encountered: