-
Notifications
You must be signed in to change notification settings - Fork 117
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
Allow adding debug annotations to OpenGL objects, as well as defining GPU "zones" to achieve functionality very similar to Tracy, but on the GPU. #1845
Conversation
Companion game PR is: beyond-all-reason/Beyond-All-Reason#4054 |
rts/Lua/LuaOpenGL.cpp
Outdated
glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &maxLength); | ||
|
||
if (strlen(message) >= maxLength) { | ||
luaL_error(L, "Message length exceeds GL_MAX_DEBUG_MESSAGE_LENGTH"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just trim the message to the appropriate length? Otherwise a portable way of preventing this error (GL.MAX_DEBUG_MESSAGE_LENGTH
lua constant?) would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GL.MAX_DEBUG_MESSAGE_LENGTH is openGL driver specific, and its quite long, and this is for functionality that only a handful of developers will ever use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being driver specific is exactly why failures should be graceful though.
Issues resolved, ready for merge |
Unsure.... |
Please remind me of your comments, I have forgotten them :( |
Basically guard injection of these functions into Lua space by checking for presence of |
Co-authored-by: sprunk <[email protected]>
rts/Lua/LuaOpenGL.cpp
Outdated
* @function gl.ObjectLabel labels an object for use with debugging tools | ||
* @param objectTypeIdentifier GLenum Specifies the type of object being labeled. | ||
* @param objectID GLuint Specifies the name or ID of the object to label. | ||
* @param label string A null-terminated string containing the label to be assigned to the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't Lua strings null terminated by default? Sounds redundant.
@@ -44,6 +45,7 @@ namespace springproc { | |||
cores. */ | |||
int GetNumPhysicalCores() const { return numPhysicalCores; } | |||
int GetNumLogicalCores() const { return numLogicalCores; } | |||
std::string GetCPUBrand() const { return cpuid_brand; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- looks unrelated to OpenGL driver debug messages (it looks ok so I don't mind that much, but maybe it's accidental part of some larger CPU related WIP?)
- perhaps would be good if it was a const reference? It doesn't look like something that would need copying by default and it's in a singleton so there's no worry about lifetime.
rts/Lua/LuaOpenGL.cpp
Outdated
glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &maxLength); | ||
|
||
if (strlen(message) >= maxLength) { | ||
luaL_error(L, "Message length exceeds GL_MAX_DEBUG_MESSAGE_LENGTH"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being driver specific is exactly why failures should be graceful though.
rts/Lua/LuaOpenGL.cpp
Outdated
if (GLEW_KHR_debug){ | ||
glPushDebugGroup((source ? GL_DEBUG_SOURCE_APPLICATION: GL_DEBUG_SOURCE_THIRD_PARTY) , id, -1, message); | ||
} | ||
else { | ||
luaL_error(L, "PushDebugGroup requires GL_KHR_debug extension"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as bd6c8c4
if (GLEW_KHR_debug){ | |
glPushDebugGroup((source ? GL_DEBUG_SOURCE_APPLICATION: GL_DEBUG_SOURCE_THIRD_PARTY) , id, -1, message); | |
} | |
else { | |
luaL_error(L, "PushDebugGroup requires GL_KHR_debug extension"); | |
} | |
if (!GLEW_KHR_debug) | |
return 0; | |
glPushDebugGroup((source ? GL_DEBUG_SOURCE_APPLICATION: GL_DEBUG_SOURCE_THIRD_PARTY) , id, -1, message); |
I'm going to redo this one. Because of multiple changes happened to |
Implements #1833
Assists in assigning OpenGL id's to actual human readable names in performance debuggging.
IMPORTANT nVidia nSight 2022.04 was the only version that reliably worked for me.
New callouts:
gl.ObjectLabel(objectTypeIdentifier, objectID, name)
gl.PushDebugGroup(objectID, name, bool thirdparty = false)
gl.PopDebugGroup()
Results, with only some minor modifications to LuaShader.lua to label, push and pop things: