From 66720273737b4a4d72b5a8678f3ac8b63965c999 Mon Sep 17 00:00:00 2001 From: Viktor Walter Date: Tue, 27 Feb 2024 17:08:55 +0100 Subject: [PATCH] Printing out the GPU DRI path --- include/compute_lib/compute_lib.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/compute_lib/compute_lib.c b/include/compute_lib/compute_lib.c index fc8cf69..923c2ca 100644 --- a/include/compute_lib/compute_lib.c +++ b/include/compute_lib/compute_lib.c @@ -31,39 +31,41 @@ static void compute_lib_gl_callback(GLenum source, GLenum type, GLuint id, GLenu int compute_lib_init(compute_lib_instance_t* inst) { - fprintf(stderr, "[ComputeLib]: Checking if initialized... " ); + fprintf(stderr, "[ComputeLib]: Checking if initialized... \n" ); if (inst->initialised == true) { return COMPUTE_LIB_ERROR_ALREADY_INITIALISED; } - fprintf(stderr, "[ComputeLib]: Opening GPU DRI PATH... " ); + fprintf(stderr, "[ComputeLib]: Opening GPU DRI PATH at [%s]... \n", COMPUTE_LIB_GPU_DRI_PATH ); inst->fd = open(COMPUTE_LIB_GPU_DRI_PATH, O_RDWR); if (inst->fd <= 0) { + fprintf(stderr, "[ComputeLib]: Opening GPU DRI PATH at [%s] failed!, will deinit... \n", COMPUTE_LIB_GPU_DRI_PATH ); compute_lib_deinit(inst); + fprintf(stderr, "[ComputeLib]: Deinitialized. \n", COMPUTE_LIB_GPU_DRI_PATH ); return COMPUTE_LIB_ERROR_GPU_DRI_PATH; } - fprintf(stderr, "[ComputeLib]: Creating BGM device... " ); + fprintf(stderr, "[ComputeLib]: Creating BGM device... \n" ); inst->gbm = gbm_create_device(inst->fd); if (inst->gbm == NULL) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_CREATE_GBM_CTX; } - fprintf(stderr, "[ComputeLib]: Getting EGL platform display... " ); + fprintf(stderr, "[ComputeLib]: Getting EGL platform display... \n" ); inst->dpy = eglGetPlatformDisplay(EGL_PLATFORM_GBM_MESA, inst->gbm, NULL); if (inst->dpy == NULL) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_PLATFORM_DISPLAY; } - fprintf(stderr, "[ComputeLib]: Initializing EGL... " ); + fprintf(stderr, "[ComputeLib]: Initializing EGL... \n" ); if (!eglInitialize(inst->dpy, NULL, NULL)) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_INIT; } - fprintf(stderr, "[ComputeLib]: Getting EGL extensions... " ); + fprintf(stderr, "[ComputeLib]: Getting EGL extensions... \n" ); const char* egl_extension_st = eglQueryString(inst->dpy, EGL_EXTENSIONS); if (strstr(egl_extension_st, "EGL_KHR_create_context") == NULL) { compute_lib_deinit(inst); @@ -76,25 +78,25 @@ int compute_lib_init(compute_lib_instance_t* inst) EGLConfig egl_cfg; EGLint egl_count; - fprintf(stderr, "[ComputeLib]: Choosing EGL config... " ); + fprintf(stderr, "[ComputeLib]: Choosing EGL config... \n" ); if (!eglChooseConfig(inst->dpy, egl_config_attribs, &egl_cfg, 1, &egl_count)) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_CONFIG; } - fprintf(stderr, "[ComputeLib]: Binding EGL API... " ); + fprintf(stderr, "[ComputeLib]: Binding EGL API... \n" ); if (!eglBindAPI(EGL_OPENGL_ES_API)) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_BIND_API; } - fprintf(stderr, "[ComputeLib]: Crating EGL context... " ); + fprintf(stderr, "[ComputeLib]: Crating EGL context... \n" ); inst->ctx = eglCreateContext(inst->dpy, egl_cfg, EGL_NO_CONTEXT, egl_ctx_attribs); if (inst->ctx == EGL_NO_CONTEXT) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_CREATE_CTX; } - fprintf(stderr, "[ComputeLib]: Making EGL current... " ); + fprintf(stderr, "[ComputeLib]: Making EGL current... \n" ); if (!eglMakeCurrent(inst->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, inst->ctx)) { compute_lib_deinit(inst); return COMPUTE_LIB_ERROR_EGL_MAKE_CURRENT; @@ -104,12 +106,12 @@ int compute_lib_init(compute_lib_instance_t* inst) inst->error_total_cnt = 0; inst->error_queue = queue_create(64); - fprintf(stderr, "[ComputeLib]: Enabling GL output... " ); + fprintf(stderr, "[ComputeLib]: Enabling GL output... \n" ); glEnable(GL_DEBUG_OUTPUT); - fprintf(stderr, "[ComputeLib]: Setting message callback... " ); + fprintf(stderr, "[ComputeLib]: Setting message callback... \n" ); glDebugMessageCallback(compute_lib_gl_callback, (const void*) inst); - fprintf(stderr, "[ComputeLib]: Initialized... " ); + fprintf(stderr, "[ComputeLib]: Initialized... \n" ); inst->initialised = true; return 0;