Skip to content

Commit

Permalink
CRenderSystemGLES: allow using OpenGL debugging callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
lrusak committed Nov 3, 2018
1 parent 439637b commit d2e95ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions xbmc/rendering/gles/RenderSystemGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include "guilib/DirtyRegion.h"
#include "windowing/GraphicContext.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "RenderSystemGLES.h"
#include "rendering/MatrixGL.h"
#include "utils/log.h"
#include "utils/EGLUtils.h"
#include "utils/GLUtils.h"
#include "utils/TimeUtils.h"
#include "utils/SystemInfo.h"
Expand All @@ -31,6 +33,11 @@ CRenderSystemGLES::~CRenderSystemGLES()

bool CRenderSystemGLES::InitRenderSystem()
{
if(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_openGlDebugging)
{
EnableDebugging();
}

GLint maxTextureSize;

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
Expand Down Expand Up @@ -628,3 +635,17 @@ GLint CRenderSystemGLES::GUIShaderGetModel()

return -1;
}

void CRenderSystemGLES::EnableDebugging()
{
PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallback = CEGLUtils::GetRequiredProcAddress<PFNGLDEBUGMESSAGECALLBACKKHRPROC>("glDebugMessageCallbackKHR");
PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControl = CEGLUtils::GetRequiredProcAddress<PFNGLDEBUGMESSAGECONTROLKHRPROC>("glDebugMessageControlKHR");

glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
glDebugMessageCallback(reinterpret_cast<GLDEBUGPROCKHR>(GlErrorCallback), nullptr);

// ignore shader compilation information
glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER_KHR, GL_DEBUG_TYPE_OTHER_KHR, GL_DONT_CARE, 0, nullptr, GL_FALSE);

CLog::Log(LOGDEBUG, "OpenGL(ES): debugging enabled");
}
3 changes: 3 additions & 0 deletions xbmc/rendering/gles/RenderSystemGLES.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ class CRenderSystemGLES : public CRenderSystemBase
ESHADERMETHOD m_method = SM_DEFAULT;

GLint m_viewPort[4];

private:
void EnableDebugging();
};

2 changes: 2 additions & 0 deletions xbmc/utils/EGLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ bool CEGLContextUtils::CreateContext(CEGLAttributesVec contextAttribs)
if (CEGLUtils::HasExtension(m_eglDisplay, "EGL_IMG_context_priority"))
contextAttribs.Add({{EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG}});

contextAttribs.Add({{EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR}});

m_eglContext = eglCreateContext(m_eglDisplay, eglConfig,
EGL_NO_CONTEXT, contextAttribs.Get());

Expand Down

0 comments on commit d2e95ca

Please sign in to comment.