-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
ImDrawList: Support for large meshes (64k+ vertices) with 16-bits indices #2591
Comments
You can use this code to quickly check if large meshes are supported by your setup:
|
…(64k+ vertices) using 16-bits indices. To enable the feature, the renderer back-end needs to set 'io.BackendFlags |= ImGuiBackendFlags_HasVtxOffset' and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero. This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not support 32-bits indices. ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command. This is provided for convenience and consistency with VtxOffset. (#2591)
…y): Added support for large meshes (64k+ vertices) with 16-bits indices, enable 'ImGuiBackendFlags_HasVtxOffset' config flag in back-end. (#2591)
…asVtxOffset to match naming convention already used in viewport/docking branch. (#2591) + Fix OpenGL3 code missing flag.
…es) with 16-bits indices, enable 'ImGuiBackendFlags_HasVtxOffset' config flag in back-end. (ocornut#2591)
Everyone: the current version has a bug with Columns, working on fixing it now. |
Fixed now. |
…t channel is empty) (#2591) + fixed warnings with newer VS
Closing this now! |
Hello, I have Dear Imgui v1.75 configured with my project, but I see the assert Would the way to proceed be to remove the assert in order to avoid changing the data type of |
@gmin7 have you read the comment above that assert in its entirety, as well as this thread? The assert is there for a reason, if you remove it your display will be incorrect. |
Hello Omar, I hope you are fine. I am exploring ImGUI for a Seismic data visualization project compiled for WebAssembly. I want to display the seismic data gathered in several lines, and the size of the data can be big (for example, if you record 4seconds The problem starts when I try to port the ImGui desktop application (SDL2, OpenGL 3 - 32 bit indexes) to emscripten (WebAssembly) which uses WebGL 1.0 (OpenGL ES 2.0 - 16bits indexes). I have tried the solution you said above in my desktop application (trying to use a single code base working in both platforms) 2.- And commenting: I get a segmentation fault when I try to use your backend checker routine with 16bits indexes in the desktop:
In the desktop app (using your code for the backend checker),
For WebAssembly, emscripten implements by default WebGL 1.0, so the renderer will have no more than 16bits for the indexes. Use the the View menu to open the Backend checker window with your code. You won't be able to display more than 64K vrtx per window. The Backend checker is not crashing but some bad graphic artifacts will appear above 64K+ vertices. |
@ejyanezp
Yes using the above and this will require your backend to actually support that flag. Generally speaking you should probably look at https://github.com/epezent/implot |
Hello Omar, thanks for your answer and your time. BTW, I am already using implot, and I like it :), but thanks for your suggestions! :) They are welcome!. Now, this time I made the change correctly for my linux desktop App (for testing before the WebAssembly version): Then, I am not getting a segmentation fault, but the resulting images get glitched :( Should be somehing like (this is with 32bits): So, the question is: Any ideas, or any test you suggest, i will appreciated them. |
Hi Omar, you said: |
If backend declare support for imgui/examples/imgui_impl_dx9.cpp Line 202 in e8447de
|
Thanks for your answer @thedmd,
The command I am using to know the OpenGL version in my Ubuntu 20.04 machine is: The result is: So, if the code says On the other side, my question is because I want to render more than 64K vertices in internet browsers using WebAssembly and emscripten. So I guess that currently is not possible either, the following comment is at the beginning of the file imgui_impl_opengl3.cpp: // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. So, what alternatives do I have to render 64k+ vertices in a WebAssembly application?. Perhaps imgui is not the way to go? :( Thanks! |
All imgui_impl_XXX.cpp are examples and usually serve as convenient way to integrate ImGui with an application. imgui_impl_opengl3.cpp is not an exception. Vertex offset is relatively new thing in ImGui. Implementing it is possible in any OpenGL version (different extensions, different hoops to overcome). The thing is, nobody contributed such change yet. What can be done:
I would advocate for you to stay with ImGui and help to push it forward by contributing. But that's me. Choice is yours. :) |
Or just use |
Hello @ocornut, thanks for your answer. I tried using And it works fine in my desktop version, but not for WebAssembly (Emscripten), that is the problem. @thedmd, also thanks for your answer, If I find the way to add support to my OpenGL version I will be glad to contribute to the project. Now I have the scenario crystal clear. Txs to both! |
It should work in WebAssembly, you should investigate the cause of the issue. Are you sure you added the define in |
Never mind, I realize that the glDrawElements() call will compile but WebGL specs do not allow 16-bit indices. The simplest (but slow) solution is to Deindex the buffer, otherwise your plotting code needs to create new drawlists to avoid going over 64k. |
Hello Omar, I studied a little bit of OpenGL and WebGL, and now I have a little WebGL program to plot more than 1.5MM of points in a single scene. My application is plotting seismic signals, so I tested with a test file that has 64K points per geophone, and 24 geophones, that is 64.000 * 24 = 1.536.000 points (24 linestrips) |
I think I will have to define a class similar to |
Info: I'll be pushing a change to support large meshes (64k+ vertices) with 16-bits indices.
TL;DR;
Until now wiith 16-bits indices (default compile-time setting) the code would assert when trying to create a ImDrawList with more than 64k vertices, and visuals would get glitched.
The solution until now was to enable 32-bits indices by using
#define ImDrawIdx unsigned int
inimconfig.h
. However some hardware and api don't support 32-bits indices and this needed to be a compile-time setting I've been asked to come with a different solution.The new solution comes in the form of adding
VtxOffset
field toImDrawCmd
.The feature needs the renderer to be able to offset the base vertex number, which is not available in some api (GL ES 2) so this is optional. Making it optional also ensure zero breakage of existing changes.
The back-end needs to set:
Note that I've also added an
IdxOffset
field in ImDrawCmd, which is the equivalent of the summing ofcmd->ElemCount
that every render loop already did.Commit for this change in core imgui is: d1e8b69
Commit for supporting this in examples renderers is: b3dd03f
Feedback welcome. I don't rule out that there may be an issue with this.
@warrenm @bear24rw Would you mind adding corresponding support in the Metal back-end? It should be very easy but as I can't test Metal at the moment. You can refer for commit b3dd03f for how it was added to the other back-ends. Thank you very much!
(EDIT Renamed new flag to
ImGuiBackendFlags_RendererHasVtxOffset
)The text was updated successfully, but these errors were encountered: