-
Notifications
You must be signed in to change notification settings - Fork 70
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
Too many vertices in ImDrawList using 16-bit indices #8
Comments
It’s not something I’ve investigated, as I have been working with 32 bit indices. I think we’d need to implement some sort of culling scheme. As it is, there is no culling...every point is sent to the DrawList, even if it is outside the plot area. Seems like low hanging fruit, so maybe I can take a look. This of course won’t solve your issue if all 4x4096 points are in the plot area. If that’s the case, then it might be possible to decimate the data. |
I added a simple culling solution. Line segments are only rendered if both endpoints are in the plot area. For every segment that is culled, 6 indices will be freed. Let me know if this helps at all. |
Could you also please try @ocornut's suggestion:
|
Hi, the above solution is not working in my case. Same error: void AddDrawListToDrawData(ImVector<ImDrawList*>, ImDrawList): Assertion `draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"' failed. Anyhow, performances are improved by this solution |
This solution at least is "fixing" the assert check and application is not quitting, but the results are poor. |
Oh wow, that's no good! Then it seems that the only real path forward is to decimate data. I can think of a couple ways of doing this, each with their pros/cons. I'll ponder the issue and report back later. For now, I would suggest either:
|
The other obvious answer is to just use 32 bit indices, but I assume there's a reason you can't do that (is this an OpenGL2 limitation?) |
Thanks, if this is the solution (or "workaround") I will try to use 32 bit indices. There is another small issue (off topic): when you interact with plot are (zoom and pan) it looks like it's missing focusing of the window. I mean that if there is another window on top and you interact with plot, focus remain on the window on top. |
Make sure your renderer actually does handle the VtxOffset field, not just set the flag claiming it handles it. Use the Metrics window to confirm that your output it what you think it is and your clipping works as intended. PS: Lines with >1.0f thickness are more vertex expensive than line with ==1.0f thickness. However a change coming soon to imgui will reduce the cpu and vtx cost of both either way. Neither should be a bottleneck for you, you should just handle VtxOffset to allow large meshes with 16-bit indices. |
@ozlb, I can confirm that mahi-gui, which uses the official ImGui OpenGL3 renderer that supports VtxOffset, works perfectly fine with 16-bit indices. As you can see in the example below, it's having no issues with over 600k indices. I tested this in Release and Debug mode. Therefore, I would suggest you address the VtxOffset issue with your rendering backend as @ocornut suggests. I will leave this issue open as a reminder that data decimation needs to be added at some point (if for no other reason than performance). @ocornut, I think I'm already drawing plot lines as efficiently as possible since I bypass the built-in drawing functions. I adapted the latter half of |
I will try to study and try to understand what should be done in order let it work properly. |
Thanks! Anyhow there is still present the "focusing" bug, could you please check or give an advise on how to fix? |
Plotting in real time mode 4 channels (items) with PlotItemBufferPoint max_points at 4096 will crash after some time.. (around 128[s])
void AddDrawListToDrawData(ImVector<ImDrawList*>, ImDrawList): Assertion `draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices.
In order to solve the issue, is there any other solution than uncomment '#define ImDrawIdx unsigned int' line in imconfig.h." ?
The text was updated successfully, but these errors were encountered: