OpenGLRenderer: Implement debug region data

This commit is contained in:
Jérôme Leclercq 2021-02-20 19:10:32 +01:00
parent 8f9f943e2c
commit f7442982a4
3 changed files with 16 additions and 5 deletions

View File

@ -154,10 +154,12 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \
cb(glViewport, PFNGLVIEWPORTPROC) \
\
extCb(glObjectLabel, PFNGLOBJECTLABELPROC) \
\
extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \
\
extCb(glObjectLabel, PFNGLOBJECTLABELPROC) \
extCb(glPopDebugGroup, PFNGLPOPDEBUGGROUPPROC) \
extCb(glPushDebugGroup, PFNGLPUSHDEBUGGROUPPROC) \
\
extCb(glSpecializeShaderARB, PFNGLSPECIALIZESHADERARBPROC) \
#endif

View File

@ -63,9 +63,10 @@ namespace Nz
{
using T = std::decay_t<decltype(command)>;
if constexpr (std::is_same_v<T, BeginDebugRegionData> || std::is_same_v<T, EndDebugRegionData>)
if constexpr (std::is_same_v<T, BeginDebugRegionData>)
{
// TODO
if (context->glPushDebugGroup)
context->glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, command.regionName.size(), command.regionName.data());
}
else if constexpr (std::is_same_v<T, CopyBufferData>)
{
@ -88,6 +89,11 @@ namespace Nz
ApplyStates(*context, command.states);
context->glDrawElementsInstanced(ToOpenGL(command.states.pipeline->GetPipelineInfo().primitiveMode), command.indexCount, GL_UNSIGNED_SHORT, nullptr, command.instanceCount);
}
else if constexpr (std::is_same_v<T, EndDebugRegionData>)
{
if (context->glPopDebugGroup)
context->glPopDebugGroup();
}
else if constexpr (std::is_same_v<T, SetFrameBufferData>)
{
command.framebuffer->Activate();

View File

@ -644,8 +644,11 @@ namespace Nz::GL
void Context::HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const
{
if (id == 0)
return;
std::stringstream ss;
ss << "OpenGL debug message (ID: 0x" << std::to_string(id) << "):\n";
ss << "OpenGL debug message (ID: 0x" << id << "):\n";
ss << "Sent by context: " << this;
ss << "\n-Source: ";
switch (source)