ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.46k stars 10.34k forks source link

IM_ASSERT does not trigger past 64K vertex limit. #8151

Closed BluBloos closed 2 weeks ago

BluBloos commented 2 weeks ago

Version/Branch of Dear ImGui:

Version 1.91.4, Branch: docking

Back-ends:

sokol_imgui.h (although I think this is N/A)

Compiler, OS:

Windows 11 + MSVC

Full config/build information:

Dear ImGui 1.91.4 (19140)

sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: __WIN32
define: __WIN64
define: __MSC_VER=1938
define: __MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK

io.BackendPlatformName: NULL
io.BackendRendererName: NULL
io.ConfigFlags: 0x00000000
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000A
  HasMouseCursors
  RendererHasVtxOffset

io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 958.00,1048.00
io.DisplayFramebufferScale: 1.00,1.00

on a side note, I manually wrote the above. I didn't include the style information because I don't think that's relevant.

I had to manually write it because the "Copy to clipboard" button failed.

Details:

within imgui_draw.cpp there is an IM_ASSERT checking if (sizeof(ImDrawIdx) == 2) IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");.

the issue is that the assert is not triggering. according to my understanding, it should.

as a test, if I put IM_ASSERT( ImGui::GetIO().MetricsRenderVertices < (1<<16) && "too many vertices" ); before the other assert, it triggers.

to my understanding, there is a "concerning" comment within imgui.h. this comment is at the definition of _VtxCurrentIdx. it says: // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0..

if it gets reset to zero, how is the IM_ASSERT ever supposed to understand that the vertex count has exceeed the limit?

I only noticed that the vertex count was exceeding the limit because when it does, I see none of imgui and my application window only displays the stuff I'm rendering. I'm assuming that imgui is completely breaking past this limit (UB).

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

BluBloos commented 2 weeks ago

currently looking deeper into this issue to make sure this is actually an issue...

BluBloos commented 2 weeks ago

OK, since RendererHasVtxOffset this behaviour is expected. closing issue.