Skip to content

Commit b8b0f9d

Browse files
committed
Backends: OpenGL3: Reverted use of glBufferSubData(). (#4468, #4504, #3381, #2981, #4825, #4832, #5127)
1 parent f0ad810 commit b8b0f9d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

backends/imgui_impl_opengl3.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
// CHANGELOG
1616
// (minor and older changes stripped away, please see git history for details)
17+
// 2022-11-09: OpenGL: Reverted use of glBufferSubData(), too many corruptions issues + old issues seemingly can't be reproed with Intel drivers nowadays (revert 2021-12-15 and 2022-05-23 changes).
1718
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
1819
// 2022-09-27: OpenGL: Added ability to '#define IMGUI_IMPL_OPENGL_DEBUG'.
1920
// 2022-05-23: OpenGL: Reworking 2021-12-15 "Using buffer orphaning" so it only happens on Intel GPU, seems to cause problems otherwise. (#4468, #4825, #4832, #5127).
@@ -272,12 +273,15 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
272273
}
273274
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
274275

276+
bd->UseBufferSubData = false;
277+
/*
275278
// Query vendor to enable glBufferSubData kludge
276279
#ifdef _WIN32
277280
if (const char* vendor = (const char*)glGetString(GL_VENDOR))
278281
if (strncmp(vendor, "Intel", 5) == 0)
279282
bd->UseBufferSubData = true;
280283
#endif
284+
*/
281285
#else
282286
bd->GlVersion = 200; // GLES 2
283287
#endif
@@ -495,9 +499,13 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
495499
const ImDrawList* cmd_list = draw_data->CmdLists[n];
496500

497501
// Upload vertex/index buffers
498-
// - On Intel windows drivers we got reports that regular glBufferData() led to accumulating leaks when using multi-viewports, so we started using orphaning + glBufferSubData(). (See https://github.com/ocornut/imgui/issues/4468)
499-
// - On NVIDIA drivers we got reports that using orphaning + glBufferSubData() led to glitches when using multi-viewports.
500-
// - OpenGL drivers are in a very sorry state in 2022, for now we are switching code path based on vendors.
502+
// - OpenGL drivers are in a very sorry state nowadays....
503+
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
504+
// of leaks on Intel GPU when using multi-viewports on Windows.
505+
// - After this we kept hearing of various display corruptions issues. We started disabling on non-Intel GPU, but issues still got reported on Intel.
506+
// - We are now back to using exclusively glBufferData(). So bd->UseBufferSubData IS ALWAYS FALSE in this code.
507+
// We are keeping the old code path for a while in case people finding new issues may want to test the bd->UseBufferSubData path.
508+
// - See https://github.com/ocornut/imgui/issues/4468 and please report any corruption issues.
501509
const GLsizeiptr vtx_buffer_size = (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert);
502510
const GLsizeiptr idx_buffer_size = (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx);
503511
if (bd->UseBufferSubData)

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ Other Changes:
204204
(e.g. for multi-viewport support) and don't capture mouse when drag and dropping. (#5710)
205205
- Backends: Win32: Convert WM_CHAR values with MultiByteToWideChar() when window class was
206206
registered as MBCS (not Unicode). (#5725, #1807, #471, #2815, #1060) [@or75, @ocornut]
207+
- Backends: OpenGL3: Reverted use of glBufferSubData(), too many corruptions issues were reported,
208+
and old leaks issues seemingly can't be reproed with Intel drivers nowadays (revert earlier changes).
209+
(#4468, #4504, #3381, #2981, #4825, #4832, #5127).
207210
- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
208211
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
209212
- Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz]

0 commit comments

Comments
 (0)