Skip to content

Commit

Permalink
[GLES] Use LLGL_GLEXT_DEBUG macro instead of GL_KHR_debug.
Browse files Browse the repository at this point in the history
To avoid using <GLES2/gl2ext.h>, which mostly contains extensions LLGL doesn't explicitly load (e.g. OES, AMD, ARM specific extensions),
GL_KHR_debug has been replaced with the LLGL_GLEXT_DEBUG macro which is enabled when either GL_KHR_debug (for GL) or GL_ES_VERSION_3_2 (for GLES) is enabled.
  • Loading branch information
LukasBanana committed Aug 5, 2024
1 parent cd0a23c commit 956b4fd
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions sources/Renderer/OpenGL/Command/GLCommandAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static std::size_t AssembleGLCommand(const GLOpcode opcode, const void* pc, JITC
return sizeof(*cmd);
}
#endif
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
case GLOpcodePushDebugGroup:
{
auto cmd = reinterpret_cast<const GLCmdPushDebugGroup*>(pc);
Expand All @@ -471,7 +471,7 @@ static std::size_t AssembleGLCommand(const GLOpcode opcode, const void* pc, JITC
compiler.Call(glPopDebugGroup);
return 0;
}
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
default:
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ void GLDeferredCommandBuffer::DispatchIndirect(Buffer& buffer, std::uint64_t off

void GLDeferredCommandBuffer::PushDebugGroup(const char* name)
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
{
/* Push debug group name into command stream with default ID no. */
Expand All @@ -984,15 +984,15 @@ void GLDeferredCommandBuffer::PushDebugGroup(const char* name)
::memcpy(cmd + 1, name, croppedLength + 1);
}
}
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

void GLDeferredCommandBuffer::PopDebugGroup()
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
AllocOpcode(GLOpcodePopDebugGroup);
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

/* ----- Extensions ----- */
Expand Down
8 changes: 4 additions & 4 deletions sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ void GLImmediateCommandBuffer::DispatchIndirect(Buffer& buffer, std::uint64_t of

void GLImmediateCommandBuffer::PushDebugGroup(const char* name)
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
{
/* Push debug group name into command stream with default ID no. */
Expand All @@ -840,15 +840,15 @@ void GLImmediateCommandBuffer::PushDebugGroup(const char* name)

glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, id, static_cast<GLsizei>(croppedLength), name);
}
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

void GLImmediateCommandBuffer::PopDebugGroup()
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
glPopDebugGroup();
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

/* ----- Extensions ----- */
Expand Down
3 changes: 1 addition & 2 deletions sources/Renderer/OpenGL/GLESProfile/OpenGLES.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
# include <OpenGLES/ES3/gl.h>
# include <OpenGLES/ES3/glext.h>
#elif defined(LLGL_OS_ANDROID)
// Include all GLES 3.0 functions with static linkage as well as GLES2 extensions
// Include all GLES 3.0 functions with static linkage
# include <GLES3/gl3.h>
# include <GLES2/gl2ext.h>

// Include all GLES 3.1+ functions as extensions with dynamic linkage
# ifdef GL_GLES_PROTOTYPES
Expand Down
12 changes: 6 additions & 6 deletions sources/Renderer/OpenGL/GLObjectUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace LLGL
{


#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG

// Returns the length of the specified label with a maximum length determined by GL_MAX_LABEL_LENGTH
static GLsizei GetCroppedLength(const char* label)
Expand All @@ -28,19 +28,19 @@ static GLsizei GetCroppedLength(const char* label)
return static_cast<GLsizei>(croppedLength);
}

#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG

void GLSetObjectLabel(GLenum identifier, GLuint name, const char* label)
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
{
if (label != nullptr)
glObjectLabel(identifier, name, GetCroppedLength(label), label);
else
glObjectLabel(identifier, name, 0, nullptr);
}
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

void GLSetObjectLabelSubscript(GLenum identifier, GLuint name, const char* label, const char* subscript)
Expand Down Expand Up @@ -74,15 +74,15 @@ void GLSetObjectLabelIndexed(GLenum identifier, GLuint name, const char* label,

void GLSetObjectPtrLabel(void* ptr, const char* label)
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
{
if (label != nullptr)
glObjectPtrLabel(ptr, GetCroppedLength(label), label);
else
glObjectPtrLabel(ptr, 0, nullptr);
}
#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}


Expand Down
8 changes: 4 additions & 4 deletions sources/Renderer/OpenGL/GLRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void GLRenderSystem::RegisterNewGLContext(GLContext& /*context*/, const GLPixelF
EnableDebugCallback();
}

#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG

#ifdef LLGL_OPENGL
void APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* /*userParam*/)
Expand All @@ -607,7 +607,7 @@ void GL_APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum s
);
}

#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG

struct GLDebugMessageMetaData
{
Expand All @@ -616,7 +616,7 @@ struct GLDebugMessageMetaData

void GLRenderSystem::EnableDebugCallback(bool enable)
{
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG

if (HasExtension(GLExt::KHR_debug))
{
Expand Down Expand Up @@ -645,7 +645,7 @@ void GLRenderSystem::EnableDebugCallback(bool enable)
}
}

#endif // /GL_KHR_debug
#endif // /LLGL_GLEXT_DEBUG
}

static std::string GLGetString(GLenum name)
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/OpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#endif

#if GL_KHR_debug || GL_ES_VERSION_3_2
# define LLGL_GLEXT_DEBUG
# define LLGL_GLEXT_DEBUG 1
#endif

//TODO: which extension?
Expand Down
8 changes: 4 additions & 4 deletions sources/Renderer/OpenGL/RenderState/GLStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ static const GLenum g_stateCapsEnum[] =
{
GL_BLEND,
GL_CULL_FACE,
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
GL_DEBUG_OUTPUT,
GL_DEBUG_OUTPUT_SYNCHRONOUS,
#else
#else // LLGL_GLEXT_DEBUG
0,
0,
#endif
#endif // /LLGL_GLEXT_DEBUG
GL_DEPTH_TEST,
GL_DITHER,
GL_POLYGON_OFFSET_FILL,
Expand Down Expand Up @@ -1718,7 +1718,7 @@ void GLStateManager::DetermineLimits()
#endif

/* Get extension specific limits */
#if GL_KHR_debug
#if LLGL_GLEXT_DEBUG
if (HasExtension(GLExt::KHR_debug))
{
glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &limits_.maxDebugNameLength);
Expand Down

0 comments on commit 956b4fd

Please sign in to comment.