bgfx
bgfx copied to clipboard
example-22-windows crashes creating a new window
On windows, nvidia, with profile set to 4.3 in config. When I hit c to create a new window it crashes:
Output:
..\..\..\src\renderer_gl.cpp(788): BGFX src API, type Error, id 1282, severity High, 'GL_INVALID_OPERATION error generated. Invalid VAO bound.'
..\..\..\src\renderer_gl.cpp(2907): BGFX CHECK glVertexAttribDivisor(loc, 0); GL error 0x502: GL_INVALID_OPERATION
Callstack:
> example-22-windowsDebug.exe!bgfx::CallbackStub::fatal(bgfx::Fatal::Enum _code, const char * _str) Line 83 C++
example-22-windowsDebug.exe!bgfx::fatal(bgfx::Fatal::Enum _code, const char * _format, ...) Line 264 + 0x20 bytes C++
example-22-windowsDebug.exe!bgfx::ProgramGL::bindAttributes(const bgfx::VertexDecl & _vertexDecl, unsigned int _baseVertex) Line 2907 + 0x74 bytes C++
example-22-windowsDebug.exe!bgfx::RendererContextGL::submit(bgfx::Frame * _render, bgfx::ClearQuad & _clearQuad, bgfx::TextVideoMemBlitter & _textVideoMemBlitter) Line 5020 C++
example-22-windowsDebug.exe!bgfx::Context::renderFrame() Line 1177 + 0x3d bytes C++
example-22-windowsDebug.exe!bgfx::Context::renderThread(void * _userData) Line 1840 + 0x8 bytes C++
example-22-windowsDebug.exe!bx::Thread::threadFunc(void * _arg) Line 153 + 0x2b bytes C++
The crash is related to the default VAO going away in 3.2+. ProgramGL::bindAttributes is being called with an unbound (0) VAO in the case of multiple windows which causes glVertexAttribDivisor to throw GL_INVALID_OPERATION. Fixing the one crash leads to more, and after several hours I haven't managed to find an easy fix.
Since OpenGL 3.2 using Vertex Array Objects is mandatory.
https://www.khronos.org/opengl/wiki/Legacy_OpenGL#Removed_functionality
Additionally, we've been having a lot of trouble with clearQuad() crashing on glDrawArrays with multiple windows and multi-render targets. Our current fix is to "|| true" the "if (1 == numMrt)" to fall into the regular glClear which, for our case, works fine.
edit: also we're falling back to 3.1 for now to avoid the default VAO deprecated problem
Managed to get something working. I'm not sure it's an ideal fix, but hopefully it'll help @bkaradzic fix this one.
https://github.com/JoshuaBrookover/bgfx/commit/b04ec484b44c241b6282d778098820e39204c01d
The 22-windows example still crashes with OpenGL backend when pressing c
(the first window appears as expected), and this happens both on Windows and Linux.
Windows log:
[...]
bgfx\src\renderer_gl.cpp (1259): BGFX src API, type Error, id 1282, severity High, 'GL_INVALID_OPERATION error generated. Invalid VAO bound.'
bgfx\src\renderer_gl.cpp(5422): ASSERT 0 == gl_err -> glVertexAttribDivisor(loc, 0); GL error 0x502: GL_INVALID_OPERATION
bgfx\src\renderer_gl.cpp (5422): BGFX FATAL 0x00000000: glVertexAttribDivisor(loc, 0); GL error 0x502: GL_INVALID_OPERATION
Linux log:
[...]
/bgfx/src/renderer_gl.cpp(5438): ASSERT 0 == gl_err -> glVertexAttribPointer(loc , num , s_attribType[type] , normalized , _layout.m_stride , (void*)(uintptr_t)baseVertex); GL error 0x502: GL_INVALID_OPERATION
/bgfx/src/renderer_gl.cpp (5438): BGFX FATAL 0x00000000: glVertexAttribPointer(loc , num , s_attribType[type] , normalized , _layout.m_stride , (void*)(uintptr_t)baseVertex); GL error 0x502: GL_INVALID_OPERATION
Does anyone have a clue on how to fix this?
I tried to reproduce locally on Linux but I'm unable, it just works as expected. Try updating your drivers first. If that doesn't work I need more info about your setup.
I am running the 545 nvidia drivers, which are the latest one available on Ubuntu 22.04... btw, I tried both wayland and x.org, same result.
This is the output of nvidia-smi
:
Thu Feb 1 16:52:24 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06 Driver Version: 545.29.06 CUDA Version: 12.3 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce GTX 1080 Off | 00000000:27:00.0 On | N/A |
| 0% 53C P0 61W / 180W | 502MiB / 8192MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 1500 G /usr/lib/xorg/Xorg 339MiB |
| 0 N/A N/A 1670 G /usr/bin/gnome-shell 155MiB |
| 0 N/A N/A 4622 G /usr/lib/insync/insync 2MiB |
| 0 N/A N/A 14336 G /opt/Qt/Tools/QtCreator/bin/qtcreator 2MiB |
+---------------------------------------------------------------------------------------+
Let me know if you need some other info!