-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Fix for ImDrawListSplitter::Merge - corrupted data in buffer (64k+ vertices) with 16-bits indices #3129 #3163
Conversation
Is the backend checker something that should be added? Only on the win32/dx11 example? |
Index data generation in draw list was corrupted, so this is not related to backend. All supporting vtxOffset were affected. |
@ocornut , @ShironekoBen Can you please take a look at this fix? |
Looked a little bit at this and talked to @thedmd for help. Two observations:
|
Cool - looks pretty good to me. Just a couple of thoughts from here:
(edit: ignore this, I'm an idiot, see below) Edit: Oops, sorry - read that assert backwards - it's checking for the opposite of what I thought it was. In that case the assert makes sense, although I do wonder if we can be sure the clip region is the same at that point? |
Guys, would also take a look at my PR #3232 |
…ertex count exceeds index size (ocornut#3129)
… drop empty commands.
…plitter generating incorrect vertex offsets when vertex count exceeds index size (ocornut#3129)"
158c7c2
to
dcedb28
Compare
Fixed by 84862ec |
We spent a long while working on this (thanks @thedmd for the precious help), it's been quite complicated to get it right without altering performance (the initial PR for #3163 had too much overhead in column switching). Because the matter was so confusing we split the work leading to this only many commits: 78d5ccf We simplified much of the ImDrawList command handling code, and in turn some code could get further optimizations (columns switch are now faster). |
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…t always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…oken by fixes ocornut#3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…zing border not always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
…ixes #3163, code was accidently relying on SetCurrentChannel not updating rectangle) + Used shortcut in PushTableBackground/PopTableBackground
…t always showing due to unset clip rect.
This is fix for ImDrawListSplitter::Merge - corrupted data in buffer (64k+ vertices) with 16-bits indices #3129
Thanks for @ShironekoBen for finding underlying issue and making initial patch.
Basically issue was caused by draw commands cached while making channel split and when switching channels, they internal state (texture ID, clip rect and vertex offset) may no longer match on in ImDrawList.
Another partial fix will be to not create draw commands while preparing split since check now is always present in SetCurrentChannel. Fill will be partial because on heavy use of vertices we can still hit state when draw command is stale.
Pre-allocating single draw command on split may no longer be necessary since SetCurrentChannel always check for validity after switch. Also for sparse channel splits there are a lot of unused draw commands allocated, just to be discarded on merge.
This is a case for Node Editor where each node has few assigned channels, where most of them are empty (one for selection, one for highlights, one for background, etc) most of the time. So maybe this change can also be considered.
Introduction of channel merging based on bounding boxes may further reduce number of generated draw commands. They number can quickly explode when 16-bit indices are used with large meshes:
Code used for testing:
https://gist.github.com/thedmd/e384a83c0fe9e82ec0f69c869510ad44
Repro on non-patched ImGui copy:
TestSplitterBug()