Skip to content

Commit

Permalink
More printouts in the compute lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorWalter committed Feb 28, 2024
1 parent 56f8a1e commit 2fdb17f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/compute_lib/compute_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,29 @@ int compute_lib_init(compute_lib_instance_t* inst)
return COMPUTE_LIB_ERROR_CREATE_GBM_CTX;
}

fprintf(stderr, "[ComputeLib]: Getting platform display - GBM...\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;
}
}
else {
fprintf(stderr, "[ComputeLib]: Getting platform display - surfaceless...\n");
inst->dpy = eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA, NULL, NULL);
if (inst->dpy == NULL) {
compute_lib_deinit(inst);
return COMPUTE_LIB_ERROR_EGL_PLATFORM_DISPLAY;
}
}

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]: Creating EGL query string...\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);
Expand All @@ -99,6 +103,7 @@ int compute_lib_init(compute_lib_instance_t* inst)

EGLConfig egl_cfg;
EGLint egl_count;
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;
Expand All @@ -108,12 +113,14 @@ int compute_lib_init(compute_lib_instance_t* inst)
return COMPUTE_LIB_ERROR_EGL_BIND_API;
}

fprintf(stderr, "[ComputeLib]: Creating 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]: Attaching EGL context to surface...\n");
if (!eglMakeCurrent(inst->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, inst->ctx)) {
compute_lib_deinit(inst);
return COMPUTE_LIB_ERROR_EGL_MAKE_CURRENT;
Expand All @@ -123,10 +130,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 debugging...\n");
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(compute_lib_gl_callback, (const void*) inst);

inst->initialised = true;
fprintf(stderr, "[ComputeLib]: Initialized.\n");

return 0;
}
Expand Down

0 comments on commit 2fdb17f

Please sign in to comment.