1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Add GL function glDebugMessageCallback and glDebugMessageControl

This commit is contained in:
fzurita 2019-11-01 17:52:01 -04:00 committed by Sergey Lipskiy
parent 686c7799db
commit 9059bb38d3
6 changed files with 121 additions and 0 deletions

View File

@ -194,6 +194,8 @@ PFNGLTEXTUREBARRIERNVPROC ptrTextureBarrierNV;
PFNGLCLEARBUFFERFVPROC ptrClearBufferfv;
PFNGLENABLEIPROC ptrEnablei;
PFNGLDISABLEIPROC ptrDisablei;
PFNGLDEBUGMESSAGECALLBACKPROC ptrDebugMessageCallback;
PFNGLDEBUGMESSAGECONTROLPROC ptrDebugMessageControl;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC ptrEGLImageTargetTexture2DOES;
void initGLFunctions()
@ -378,5 +380,7 @@ void initGLFunctions()
GL_GET_PROC_ADR(PFNGLCLEARBUFFERFVPROC, ClearBufferfv);
GL_GET_PROC_ADR(PFNGLENABLEIPROC, Enablei);
GL_GET_PROC_ADR(PFNGLDISABLEIPROC, Disablei);
GL_GET_PROC_ADR(PFNGLDEBUGMESSAGECALLBACKPROC, DebugMessageCallback);
GL_GET_PROC_ADR(PFNGLDEBUGMESSAGECONTROLPROC, DebugMessageControl);
GL_GET_PROC_ADR(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC, EGLImageTargetTexture2DOES);
}

View File

@ -188,6 +188,9 @@ extern PFNGLTEXTUREBARRIERNVPROC ptrTextureBarrierNV;
extern PFNGLCLEARBUFFERFVPROC ptrClearBufferfv;
extern PFNGLENABLEIPROC ptrEnablei;
extern PFNGLDISABLEIPROC ptrDisablei;
extern PFNGLDEBUGMESSAGECALLBACKPROC ptrDebugMessageCallback;
extern PFNGLDEBUGMESSAGECONTROLPROC ptrDebugMessageControl;
typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, void* image);
extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC ptrEGLImageTargetTexture2DOES;
@ -327,6 +330,8 @@ void initGLFunctions();
#define glEnablei(...) opengl::FunctionWrapper::wrEnablei(__VA_ARGS__)
#define glDisablei(...) opengl::FunctionWrapper::wrDisablei(__VA_ARGS__)
#define glEGLImageTargetTexture2DOES(...) opengl::FunctionWrapper::wrEGLImageTargetTexture2DOES(__VA_ARGS__)
#define glDebugMessageCallback(...) opengl::FunctionWrapper::wrDebugMessageCallback(__VA_ARGS__)
#define glDebugMessageControl(...) opengl::FunctionWrapper::wrDebugMessageControl(__VA_ARGS__)
#define GL_TEXTURE_EXTERNAL_OES 0x8D65

View File

@ -4746,6 +4746,78 @@ private:
void* m_image;
};
class GlDebugMessageCallbackCommand : public OpenGlCommand
{
public:
GlDebugMessageCallbackCommand() :
OpenGlCommand(true, false, "glDebugMessageCallback")
{
}
static std::shared_ptr<OpenGlCommand> get(GLDEBUGPROC callback, const void *userParam)
{
static int poolId = OpenGlCommandPool::get().getNextAvailablePool();
auto ptr = getFromPool<GlDebugMessageCallbackCommand>(poolId);
ptr->set(callback, userParam);
return ptr;
}
void commandToExecute() override
{
ptrDebugMessageCallback(m_callback, m_userParam);
}
private:
void set(GLDEBUGPROC callback, const void *userParam)
{
m_callback = callback;
m_userParam = userParam;
}
GLDEBUGPROC m_callback;
const void* m_userParam;
};
class GlDebugMessageControlCommand : public OpenGlCommand
{
public:
GlDebugMessageControlCommand() :
OpenGlCommand(true, false, "glDebugMessageControl")
{
}
static std::shared_ptr<OpenGlCommand> get(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled)
{
static int poolId = OpenGlCommandPool::get().getNextAvailablePool();
auto ptr = getFromPool<GlDebugMessageControlCommand>(poolId);
ptr->set(source, type, severity, count, ids, enabled);
return ptr;
}
void commandToExecute() override
{
ptrDebugMessageControl(m_source, m_type, m_severity, m_count, m_ids, m_enabled);
}
private:
void set(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled)
{
m_source = source;
m_type = type;
m_severity = severity;
m_count = count;
m_ids = ids;
m_enabled = enabled;
}
GLenum m_source;
GLenum m_type;
GLenum m_severity;
GLsizei m_count;
const GLuint* m_ids;
GLboolean m_enabled;
};
class ShutdownCommand : public OpenGlCommand
{
public:

View File

@ -1310,6 +1310,24 @@ namespace opengl {
ptrEGLImageTargetTexture2DOES(target, image);
}
void FunctionWrapper::wrDebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
{
if (m_threaded_wrapper)
executeCommand(GlDebugMessageCallbackCommand::get(callback, userParam));
else
ptrDebugMessageCallback(callback, userParam);
}
void FunctionWrapper::wrDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled)
{
if (m_threaded_wrapper)
executeCommand(GlDebugMessageControlCommand::get(source, type, severity, count, ids, enabled));
else
ptrDebugMessageControl(source, type, severity, count, ids, enabled);
}
#if defined(OS_ANDROID)
EGLClientBuffer FunctionWrapper::ewrGetNativeClientBufferANDROID(const AHardwareBuffer *buffer)
{

View File

@ -172,6 +172,9 @@ namespace opengl {
static void wrFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
static void wrFinish();
static void wrEGLImageTargetTexture2DOES(GLenum target, void* image);
static void wrDebugMessageCallback(GLDEBUGPROC callback, const void *userParam);
static void wrDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
#if defined(OS_ANDROID)
static EGLClientBuffer ewrGetNativeClientBufferANDROID(const AHardwareBuffer *buffer);

View File

@ -13,6 +13,11 @@
using namespace opengl;
static void on_gl_error(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message, const void *userParam)
{
LOG(LOG_ERROR, "%s", message);
}
void GLInfo::init() {
const char * strDriverVersion = reinterpret_cast<const char *>(glGetString(GL_VERSION));
isGLESX = strstr(strDriverVersion, "OpenGL ES") != nullptr;
@ -158,4 +163,18 @@ void GLInfo::init() {
LOG(LOG_WARNING, "Your GPU does not support the extensions needed for N64 Depth Compare.");
}
}
#ifdef EGL
if (isGLESX)
{
ptrDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) eglGetProcAddress("glDebugMessageCallbackKHR");
ptrDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) eglGetProcAddress("glDebugMessageControlKHR");
}
#endif
#ifdef GL_DEBUG
glDebugMessageCallback(on_gl_error, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
#endif
}