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

Opening a modal causues incorrect TotalVtx/IdxCount #6716

Closed
ZingBallyhoo opened this issue Aug 14, 2023 · 2 comments
Closed

Opening a modal causues incorrect TotalVtx/IdxCount #6716

ZingBallyhoo opened this issue Aug 14, 2023 · 2 comments

Comments

@ZingBallyhoo
Copy link

Version/Branch of Dear ImGui:

Version: 1.89.9 WIP (18982)
Branch: docking (unable to reproduce on master)

Back-end/Renderer/Compiler/OS

Back-ends: Multiple (tested on custom, imgui_impl_dx11.cpp & imgui_impl_opengl3.cpp)
Compiler: MSVC
Operating System: Windows 10

My Issue/Question:

When opening a modal on recent docking branch (upgrading from 1.89.4), the sum of vertex/index buffer counts across all draw lists becomes greater than TotalVtx/IdxCount. A backend that uses these values directly for buffer copying will have graphical corruption (I noticed this due to missing modal backgrounds)

Standalone, minimal, complete and verifiable example:

Add the following code to any ImGui_ImplXXX_RenderDrawData

int actualVertexCount = 0;
int actualIndexCount = 0;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
    const ImDrawList* cmd_list = draw_data->CmdLists[n];
    actualVertexCount += cmd_list->VtxBuffer.Size;
    actualIndexCount += cmd_list->IdxBuffer.Size;
}
printf("%d %d - %d %d\n", draw_data->TotalVtxCount, actualVertexCount, draw_data->TotalIdxCount, actualIndexCount);

Open any modal (e.g Demo -> Popups & Modal Windows -> Modals -> Delete)
Observe that the reported total (left part of pair) becomes less than the actual sum (right part of pair)

@ocornut
Copy link
Owner

ocornut commented Aug 14, 2023

Thank you. Confirmed as a bug. This is due to
#6406 (comment) and precisely this commit dbeeeae
Where we call AddDrawListToDrawDataEx() earlier than then afterward append a ImDrawCmd in RenderDimmedBackgrounds().

ocornut added a commit that referenced this issue Aug 14, 2023
… match the sum of individual ImDrawList's buffer sizes. (#6716)

Amend dbeeeae
@ocornut
Copy link
Owner

ocornut commented Aug 14, 2023

I have pushed a fix f422e78
Thank you for reporting !

@ocornut ocornut closed this as completed Aug 14, 2023
ocornut added a commit to ocornut/imgui_test_engine that referenced this issue Aug 15, 2023
Would consider expanding to check e.g. indices boundary but then if may not be enabled by default in test suite.
Ref ocornut/imgui#6716
ocornut added a commit that referenced this issue Aug 28, 2023
, #6716)

Fixes f422e78. Didn't crash because g.Windows[] is always larger than g.WindowsFocusOrder[].
ocornut added a commit that referenced this issue Sep 3, 2024
Among other things:
- merged cfd2395 (#7940, #7823), also see ac64b65 (#6716): moved above on 2023/08/14 in both branches.
- moving the RenderDimmedBackgrounds() call, from f422e78, see 676497f intently undoing ac64b65 -> confusing. (#6716)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants