Skip to content
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

Support for drawing many vertices using DrawCmd::vtx_offset #51

Open
4bb4 opened this issue Mar 15, 2021 · 2 comments
Open

Support for drawing many vertices using DrawCmd::vtx_offset #51

4bb4 opened this issue Mar 15, 2021 · 2 comments

Comments

@4bb4
Copy link

4bb4 commented Mar 15, 2021

(Disclaimer: I'm not sure this even is the right place in the stack to ask this, but maybe if it's not, someone can point me to the correct place instead)

I've been using imgui-wgpu-rs with implot-rs for a while and it's been working well (aside from #44 (comment), which I've still not been able to fix :D) until I plot a large amount of data. At that point, I hit imgui's "large meshes" limit (https://github.com/ocornut/imgui/blob/master/imconfig.h#L91). With the Glium backend, things still work because it advertises that it supports VtxOffset through the backend flags.

imgui-wgpu-rs doesn't advertise this flag, and when I just overwrote it myself to see if it'd work anyway, I got visual artifacts. Now my question is: Would it be possible for imgui-wgpu-rs to add support for these VtxOffsets? I have no knowledge of imgui's internals so far, but I'd be willing to put some effort towards making such support happen. I'd probably need some pointers for where to get started though.

Thanks in advance for any help / explanations!

@4bb4
Copy link
Author

4bb4 commented Mar 15, 2021

Eyeballing the code of the two backends, I can see that the loop in https://github.com/Yatekii/imgui-wgpu-rs/blob/master/src/lib.rs#L539 looks similar to the loop in https://github.com/imgui-rs/imgui-rs/blob/master/imgui-glium-renderer/src/lib.rs#L213, and what Glium seems to do with the vtx_offset is slice into the vertex buffer (https://github.com/imgui-rs/imgui-rs/blob/master/imgui-glium-renderer/src/lib.rs#L242). I'll see if I can naively cobble something together that works.

@4bb4
Copy link
Author

4bb4 commented Mar 15, 2021

Update: I was able to add VtxOffset support for version v0.12.0 (which I need for a project for now) in https://github.com/4bb4/imgui-wgpu-rs/tree/51-support-for-vtxoffset-v0.12.0 - it's not a lot of work (see 4bb4@fb8abdf).

Before this, drawing more than 64k vertices would crash with the aforementioned imgui assert, but with this change in place, I was able to draw upwards of 800k vertices without any issues! I've not created a PR to master here because I can't really test things on account of that other issue still being there with implot, but feel free to just apply the linked commit yourself.

Or, of course, if any of my changes don't make sense / destroy performance / set computers on fire, please also do let me know :D I don't really know what I'm doing after all, I just played with things until everything worked and looked roughly like the Glium implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant