build(linux): generate glad sources at compile time#4798
build(linux): generate glad sources at compile time#4798ReenigneArcher merged 5 commits intomasterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4798 +/- ##
==========================================
- Coverage 17.89% 17.86% -0.03%
==========================================
Files 106 106
Lines 21944 21958 +14
Branches 9841 9810 -31
==========================================
- Hits 3926 3923 -3
- Misses 15734 16128 +394
+ Partials 2284 1907 -377
Flags with carried forward coverage won't be shown. Click here to find out more.
|
171ecb6 to
c6cfc9a
Compare
Bundle ReportBundle size has no change ✅ |
ecdb427 to
3f48d4e
Compare
|
@psyke83, @garnacho, could I request a review from you both? This PR addresses an issue from #2507 (comment) so would appreciate any feedback. Note: I used AI to help resolve some of the compilation issues that occurred when switching to the generated sources. I'm pretty confident in the majority of changes in this PR, if I have any doubts they're in the cpp code.
I'm printing out the generated sources here (https://github.com/LizardByte/Sunshine/actions/runs/22600512276/job/65481219548?pr=4798#step:12:65) as well, for comparison purposes. I did a spot check and things seemed mostly the same, but some differences. Probably due to bumping from glad 2.0.0-beta to glad 2.0.8, as well as any manual edits that were made in the past. I confirmed some of the changed added in #4417, were generated in the new generated source, but things are slightly different. third-party/glad/include/glad/egl.h typedef EGLenum(EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC)(EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
typedef EGLenum(EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
GLAD_API_CALL PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT;
#define eglQueryDmaBufFormatsEXT glad_eglQueryDmaBufFormatsEXT
GLAD_API_CALL PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT;
#define eglQueryDmaBufModifiersEXT glad_eglQueryDmaBufModifiersEXTbecomes typedef EGLBoolean(GLAD_API_PTR *PFNEGLQUERYDMABUFFORMATSEXTPROC)(EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
typedef EGLBoolean(GLAD_API_PTR *PFNEGLQUERYDMABUFMODIFIERSEXTPROC)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
// ...
GLAD_API_CALL PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT;
#define eglQueryDmaBufFormatsEXT glad_eglQueryDmaBufFormatsEXT
GLAD_API_CALL PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT;
#define eglQueryDmaBufModifiersEXT glad_eglQueryDmaBufModifiersEXTthird-party/glad/src/egl.c PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT = NULL;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT = NULL;
// ...
static void glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers( GLADuserptrloadfunc load, void* userptr) {
glad_eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC) load(userptr, "eglQueryDmaBufFormatsEXT");
glad_eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC) load(userptr, "eglQueryDmaBufModifiersEXT");
}
// ...
glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers(load, userptr);
if (!glad_egl_find_extensions_egl(display)) return 0;
return version;becomes PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT = NULL;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT = NULL;
// ...
static void glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers(GLADuserptrloadfunc load, void *userptr) {
if (!GLAD_EGL_EXT_image_dma_buf_import_modifiers) {
return;
}
glad_eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC) load(userptr, "eglQueryDmaBufFormatsEXT");
glad_eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC) load(userptr, "eglQueryDmaBufModifiersEXT");
}
// ...
if (!glad_egl_find_extensions_egl(display)) {
return 0;
}
glad_egl_load_EGL_EXT_image_dma_buf_import_modifiers(load, userptr);
return version;I also don't run Linux, so I have not tested that this actually works. I could setup a Linux machine if needed to test, but it would probably take me a couple weeks as I have some other commitments coming up soon. |
5e520e2 to
bd7ff4d
Compare
73f0faf to
1435bb0
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1435bb0 to
de68304
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
1680d61 to
597a241
Compare
This comment was marked as resolved.
This comment was marked as resolved.
GL_OES_EGL_image (glEGLImageTargetTexture2DOES) is GLES-only and must be loaded at runtime via eglGetProcAddress. Replace the previous global pointer with a static internal symbol and an accessor (egl_image_target_texture_2d()) declared in the header, update the typedef to use void* for GLeglImageOES, and load the function with a GLADapiproc cast. Add availability checks and error logging before using the function to avoid null calls, and adjust related call sites. Also remove a now-unnecessary vector reserve in surface_descriptor_to_egl_attribs.
* misc.cpp: phase 1 load (symbols only, defaults to EGL 1.0). * graphics.cpp: phase 2 load using correct display configuration with eglGetPlatformDisplayEXT (initializes proper EGL version dispatch). * Retain eglGetPlatformDisplay fallback if proprietary drivers need it. * Add missing/required extensions to GLAD makefile based on existing extensions queried & new eglGetPlatformDisplayEXT requirement. * Remove hardcoded definitions that are part of previously missing extensions.
Remove the temporary CI step that printed and diffed generated glad sources against the versions on master. The removed step installed lint deps, ran clang-format on generated files, fetched the master tree, and compared each generated glad file (egl/gl) to its pre-committed counterpart for verification. This cleans up the ci-linux workflow now that the verification is complete and reduces CI noise and runtime.
e74ea2e to
38c33c2
Compare
|



Description
The glad third-party directory was not following good practices, and should be a submodule. For glad this will require an extra generation step in cmake.
Motivation for this is 2 fold.
TODO:
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage