summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorAurélien Brooke <aurelien@bahiasoft.fr>2024-02-27 17:27:51 +0100
committerAurélien Brooke <aurelien@bahiasoft.fr>2024-03-02 02:31:40 +0100
commit179c664c3180ca277b1e421fcb8bffb20d81f84e (patch)
tree80c38ae4efc93b458773a0b1e197fb6cc8b234e5 /src/gui/rhi
parenta4a679ee796a476048ddee3f88025035cca3631a (diff)
rhi: add labels to OpenGL objects to make debugging easier in RenderDoc
Change-Id: Ide7d16f56ba8a0a23d5c2e29da4dccedfb12ef1b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhigles2.cpp33
-rw-r--r--src/gui/rhi/qrhigles2_p.h5
2 files changed, 37 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 23aedeb876..de1edb70b5 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -520,6 +520,14 @@ QT_BEGIN_NAMESPACE
#define GL_QUERY_RESULT_AVAILABLE 0x8867
#endif
+#ifndef GL_BUFFER
+#define GL_BUFFER 0x82E0
+#endif
+
+#ifndef GL_PROGRAM
+#define GL_PROGRAM 0x82E2
+#endif
+
/*!
Constructs a new QRhiGles2InitParams.
@@ -1050,6 +1058,16 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.timestamps = false;
}
+ // glObjectLabel is available on OpenGL ES 3.2+ and OpenGL 4.3+
+ if (caps.gles)
+ caps.objectLabel = caps.ctxMajor > 3 || (caps.ctxMajor == 3 && caps.ctxMinor >= 2);
+ else
+ caps.objectLabel = caps.ctxMajor > 4 || (caps.ctxMajor == 4 && caps.ctxMinor >= 3);
+ if (caps.objectLabel) {
+ glObjectLabel = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLuint, GLsizei, const GLchar *)>(
+ ctx->getProcAddress(QByteArrayLiteral("glObjectLabel")));
+ }
+
nativeHandlesStruct.context = ctx;
contextLost = false;
@@ -5126,6 +5144,9 @@ bool QGles2Buffer::create()
rhiD->f->glBindBuffer(targetForDataOps, buffer);
rhiD->f->glBufferData(targetForDataOps, nonZeroSize, nullptr, m_type == Dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
+ if (rhiD->glObjectLabel)
+ rhiD->glObjectLabel(GL_BUFFER, buffer, -1, m_objectName.constData());
+
usageState.access = AccessNone;
rhiD->registerResource(this);
@@ -5280,6 +5301,9 @@ bool QGles2RenderBuffer::create()
break;
}
+ if (rhiD->glObjectLabel)
+ rhiD->glObjectLabel(GL_RENDERBUFFER, renderbuffer, -1, m_objectName.constData());
+
owns = true;
generation += 1;
rhiD->registerResource(this);
@@ -5537,6 +5561,9 @@ bool QGles2Texture::create()
specified = false;
}
+ if (rhiD->glObjectLabel)
+ rhiD->glObjectLabel(GL_TEXTURE, texture, -1, m_objectName.constData());
+
owns = true;
generation += 1;
@@ -5840,6 +5867,9 @@ bool QGles2TextureRenderTarget::create()
return false;
}
+ if (rhiD->glObjectLabel)
+ rhiD->glObjectLabel(GL_FRAMEBUFFER, framebuffer, -1, m_objectName.constData());
+
QRhiRenderTargetAttachmentTracker::updateResIdList<QGles2Texture, QGles2RenderBuffer>(m_desc, &d.currentResIdList);
rhiD->registerResource(this);
@@ -6086,6 +6116,9 @@ bool QGles2GraphicsPipeline::create()
currentSrb = nullptr;
currentSrbGeneration = 0;
+ if (rhiD->glObjectLabel)
+ rhiD->glObjectLabel(GL_PROGRAM, program, -1, m_objectName.constData());
+
rhiD->pipelineCreationEnd();
generation += 1;
rhiD->registerResource(this);
diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h
index bd33a4fffb..215f075753 100644
--- a/src/gui/rhi/qrhigles2_p.h
+++ b/src/gui/rhi/qrhigles2_p.h
@@ -948,6 +948,7 @@ public:
GLint, GLsizei) = nullptr;
void (QOPENGLF_APIENTRYP glQueryCounter)(GLuint, GLenum) = nullptr;
void (QOPENGLF_APIENTRYP glGetQueryObjectui64v)(GLuint, GLenum, quint64 *) = nullptr;
+ void (QOPENGLF_APIENTRYP glObjectLabel)(GLenum, GLuint, GLsizei, const GLchar *) = nullptr;
uint vao = 0;
struct Caps {
@@ -1003,7 +1004,8 @@ public:
hasDrawBuffersFunc(false),
halfAttributes(false),
multiView(false),
- timestamps(false)
+ timestamps(false),
+ objectLabel(false)
{ }
int ctxMajor;
int ctxMinor;
@@ -1059,6 +1061,7 @@ public:
uint halfAttributes : 1;
uint multiView : 1;
uint timestamps : 1;
+ uint objectLabel : 1;
} caps;
QGles2SwapChain *currentSwapChain = nullptr;
QSet<GLint> supportedCompressedFormats;