fix: add debug capabilities for gl and egl
Clang Lint CI / lint-no-video (push) Failing after 44s
Clang Build CI / run-no-video (push) Successful in 1m7s
Clang Build CI / run-video (push) Successful in 1m7s
Clang Build CI / build-release (push) Successful in 1m26s
Clang Lint CI / lint-video (push) Successful in 1m46s
Clang Lint CI / lint-no-video (push) Failing after 44s
Clang Build CI / run-no-video (push) Successful in 1m7s
Clang Build CI / run-video (push) Successful in 1m7s
Clang Build CI / build-release (push) Successful in 1m26s
Clang Lint CI / lint-video (push) Successful in 1m46s
This commit is contained in:
+51
-4
@@ -26,7 +26,7 @@
|
||||
|
||||
static const GLuint unused_uniform = (GLuint)-1;
|
||||
|
||||
bool check_glerror_ro(const char *context) {
|
||||
static bool check_glerror_ro(const char *context) {
|
||||
unsigned int code;
|
||||
|
||||
code = glGetError();
|
||||
@@ -39,7 +39,7 @@ bool check_glerror_ro(const char *context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_glerror(ShaderProgram *program, const char *context) {
|
||||
static bool check_glerror(ShaderProgram *program, const char *context) {
|
||||
if (check_glerror_ro(context)) {
|
||||
program->error = true;
|
||||
return true;
|
||||
@@ -47,7 +47,20 @@ bool check_glerror(ShaderProgram *program, const char *context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_eglerror_ro(const char *context) {
|
||||
#ifdef GL_DEBUG
|
||||
|
||||
static void gl_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||
GLenum severity,
|
||||
__attribute__((unused)) GLsizei length,
|
||||
const GLchar *message,
|
||||
__attribute__((unused)) const void *userParam) {
|
||||
log_debug("GL Debug: source=%x, type=%x, id=%d, severity=%x, message=%s",
|
||||
source, type, id, severity, message ? message : "(null)");
|
||||
}
|
||||
|
||||
#endif /* GL_DEBUG */
|
||||
|
||||
static bool check_eglerror_ro(const char *context) {
|
||||
#ifdef VIDEO_IN
|
||||
unsigned int code;
|
||||
|
||||
@@ -61,7 +74,7 @@ bool check_eglerror_ro(const char *context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_eglerror(ShaderProgram *program, const char *context) {
|
||||
static bool check_eglerror(ShaderProgram *program, const char *context) {
|
||||
if (check_eglerror_ro(context)) {
|
||||
program->error = true;
|
||||
return true;
|
||||
@@ -69,9 +82,29 @@ bool check_eglerror(ShaderProgram *program, const char *context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
#ifdef EGL_DEBUG
|
||||
|
||||
static void egl_debug_callback(EGLenum error, const char *command,
|
||||
EGLint messageType, EGLLabelKHR threadLabel,
|
||||
EGLLabelKHR objectLabel, const char *message) {
|
||||
log_debug("EGL Debug: error=%04x, command=%s, type=%d, "
|
||||
"thread=%p, object=%p, message=%s",
|
||||
error, command ? command : "(null)", messageType, threadLabel,
|
||||
objectLabel, message ? message : "(null)");
|
||||
}
|
||||
|
||||
#endif /* EGL_DEBUG */
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
static bool init_gl(ShaderProgram *program) {
|
||||
gladLoadGL(glfwGetProcAddress);
|
||||
|
||||
#ifdef GL_DEBUG
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(gl_debug_callback, NULL);
|
||||
#endif /* GL_DEBUG */
|
||||
|
||||
#ifdef VIDEO_IN
|
||||
program->egl_display = glfwGetEGLDisplay();
|
||||
if (program->egl_display == EGL_NO_DISPLAY) {
|
||||
@@ -81,6 +114,20 @@ static bool init_gl(ShaderProgram *program) {
|
||||
}
|
||||
|
||||
gladLoadEGL(program->egl_display, glfwGetProcAddress);
|
||||
|
||||
#ifdef EGL_DEBUG
|
||||
{
|
||||
PFNEGLDEBUGMESSAGECONTROLKHRPROC debug_ctrl =
|
||||
(PFNEGLDEBUGMESSAGECONTROLKHRPROC)glfwGetProcAddress(
|
||||
"eglDebugMessageControlKHR");
|
||||
if (debug_ctrl != NULL) {
|
||||
const EGLAttrib attrib_list[] = {EGL_NONE};
|
||||
debug_ctrl(egl_debug_callback, attrib_list);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* EGL_DEBUG */
|
||||
|
||||
#endif /* VIDEO_IN */
|
||||
|
||||
return !check_glerror(program, "init_gl") &&
|
||||
|
||||
@@ -59,6 +59,9 @@ create_window(GLFWmonitor *monitor, const char *title, Window *shared_context,
|
||||
// Context related hints
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
|
||||
#ifdef GL_DEBUG
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
|
||||
#endif
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
// create fullscreen window in selected monitor
|
||||
|
||||
Reference in New Issue
Block a user