From 7b899fbc17a1bd119fa389eabd8d5fde39853a43 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Wed, 13 Dec 2023 20:27:31 -0400 Subject: [PATCH] opengl: add version checks when setting debug names. --- src/modules/graphics/opengl/Buffer.cpp | 2 +- src/modules/graphics/opengl/Texture.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/graphics/opengl/Buffer.cpp b/src/modules/graphics/opengl/Buffer.cpp index be437d3ec..04a843559 100644 --- a/src/modules/graphics/opengl/Buffer.cpp +++ b/src/modules/graphics/opengl/Buffer.cpp @@ -164,7 +164,7 @@ bool Buffer::load(const void *initialdata) glTexBuffer(target, glformat, buffer); } - if (!debugName.empty()) + if (!debugName.empty() && (GLAD_VERSION_4_3 || GLAD_ES_VERSION_3_2)) glObjectLabel(GL_BUFFER, buffer, -1, debugName.c_str()); return (glGetError() == GL_NO_ERROR); diff --git a/src/modules/graphics/opengl/Texture.cpp b/src/modules/graphics/opengl/Texture.cpp index 9343a9f68..afa4e1e01 100644 --- a/src/modules/graphics/opengl/Texture.cpp +++ b/src/modules/graphics/opengl/Texture.cpp @@ -422,12 +422,18 @@ bool Texture::loadVolatile() setGraphicsMemorySize(memsize); - if (!debugName.empty()) + if (!debugName.empty() && (GLAD_VERSION_4_3 || GLAD_ES_VERSION_3_2)) { if (texture) glObjectLabel(GL_TEXTURE, texture, -1, debugName.c_str()); - else - glObjectLabel(GL_FRAMEBUFFER, renderbuffer, -1, debugName.c_str()); + + if (renderbuffer) + { + std::string rname = debugName; + if (actualSamples > 1) + rname += " (MSAA buffer)"; + glObjectLabel(GL_RENDERBUFFER, renderbuffer, -1, rname.c_str()); + } } return true;