2023-11-07 21:42:11 +01:00
|
|
|
#![allow(clippy::disallowed_macros)]
|
2018-11-22 12:13:11 +01:00
|
|
|
#[cfg(any(feature = "backend_egl", feature = "renderer_gl"))]
|
2020-05-20 00:13:06 +02:00
|
|
|
fn gl_generate() {
|
|
|
|
use gl_generator::{Api, Fallbacks, Profile, Registry};
|
|
|
|
use std::{env, fs::File, path::PathBuf};
|
2017-05-18 22:28:02 +02:00
|
|
|
|
|
|
|
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
|
|
|
|
|
2018-11-21 09:28:15 +01:00
|
|
|
if env::var_os("CARGO_FEATURE_BACKEND_EGL").is_some() {
|
2023-06-20 09:56:04 +02:00
|
|
|
let mut file = File::create(dest.join("egl_bindings.rs")).unwrap();
|
2018-11-21 09:28:15 +01:00
|
|
|
Registry::new(
|
|
|
|
Api::Egl,
|
|
|
|
(1, 5),
|
|
|
|
Profile::Core,
|
|
|
|
Fallbacks::All,
|
|
|
|
[
|
|
|
|
"EGL_KHR_create_context",
|
|
|
|
"EGL_EXT_create_context_robustness",
|
|
|
|
"EGL_KHR_create_context_no_error",
|
2021-04-07 00:53:37 +02:00
|
|
|
"EGL_KHR_no_config_context",
|
2023-03-15 13:04:41 +01:00
|
|
|
"EGL_EXT_pixel_format_float",
|
2021-11-03 07:15:21 +01:00
|
|
|
"EGL_EXT_device_base",
|
|
|
|
"EGL_EXT_device_enumeration",
|
|
|
|
"EGL_EXT_device_query",
|
|
|
|
"EGL_EXT_device_drm",
|
2022-03-09 13:41:17 +01:00
|
|
|
"EGL_EXT_device_drm_render_node",
|
2021-11-03 07:15:21 +01:00
|
|
|
"EGL_KHR_stream",
|
|
|
|
"EGL_KHR_stream_producer_eglsurface",
|
2018-11-21 09:28:15 +01:00
|
|
|
"EGL_EXT_platform_base",
|
2021-05-15 23:04:46 +02:00
|
|
|
"EGL_KHR_platform_x11",
|
2018-11-21 09:28:15 +01:00
|
|
|
"EGL_EXT_platform_x11",
|
2021-05-15 23:04:46 +02:00
|
|
|
"EGL_KHR_platform_wayland",
|
2018-11-21 09:28:15 +01:00
|
|
|
"EGL_EXT_platform_wayland",
|
2021-05-13 19:38:32 +02:00
|
|
|
"EGL_KHR_platform_gbm",
|
2021-04-07 00:53:37 +02:00
|
|
|
"EGL_MESA_platform_gbm",
|
2023-01-19 19:16:14 +01:00
|
|
|
"EGL_MESA_platform_surfaceless",
|
2021-11-03 07:15:21 +01:00
|
|
|
"EGL_EXT_platform_device",
|
2021-04-07 00:53:37 +02:00
|
|
|
"EGL_WL_bind_wayland_display",
|
2018-11-21 09:28:15 +01:00
|
|
|
"EGL_KHR_image_base",
|
2021-04-07 00:53:37 +02:00
|
|
|
"EGL_EXT_image_dma_buf_import",
|
|
|
|
"EGL_EXT_image_dma_buf_import_modifiers",
|
2022-02-11 20:47:00 +01:00
|
|
|
"EGL_MESA_image_dma_buf_export",
|
|
|
|
"EGL_KHR_gl_image",
|
2021-12-29 15:54:59 +01:00
|
|
|
"EGL_EXT_buffer_age",
|
|
|
|
"EGL_EXT_swap_buffers_with_damage",
|
2022-10-21 20:21:45 +02:00
|
|
|
"EGL_KHR_swap_buffers_with_damage",
|
2023-06-16 21:04:04 +02:00
|
|
|
"EGL_KHR_fence_sync",
|
|
|
|
"EGL_ANDROID_native_fence_sync",
|
2023-09-15 12:13:50 +02:00
|
|
|
"EGL_IMG_context_priority",
|
2018-11-21 09:28:15 +01:00
|
|
|
],
|
2018-12-08 18:31:08 +01:00
|
|
|
)
|
|
|
|
.write_bindings(gl_generator::GlobalGenerator, &mut file)
|
2018-11-21 09:28:15 +01:00
|
|
|
.unwrap();
|
|
|
|
}
|
2017-12-10 22:09:17 +01:00
|
|
|
|
2018-11-21 09:28:15 +01:00
|
|
|
if env::var_os("CARGO_FEATURE_RENDERER_GL").is_some() {
|
2023-06-20 09:56:04 +02:00
|
|
|
let mut file = File::create(dest.join("gl_bindings.rs")).unwrap();
|
2018-11-21 09:28:15 +01:00
|
|
|
Registry::new(
|
|
|
|
Api::Gles2,
|
|
|
|
(3, 2),
|
|
|
|
Profile::Compatibility,
|
|
|
|
Fallbacks::None,
|
2021-04-07 00:53:37 +02:00
|
|
|
[
|
|
|
|
"GL_OES_EGL_image",
|
|
|
|
"GL_OES_EGL_image_external",
|
|
|
|
"GL_EXT_texture_format_BGRA8888",
|
|
|
|
"GL_EXT_unpack_subimage",
|
2023-06-16 21:04:04 +02:00
|
|
|
"GL_OES_EGL_sync",
|
2021-04-07 00:53:37 +02:00
|
|
|
],
|
2018-12-08 18:31:08 +01:00
|
|
|
)
|
|
|
|
.write_bindings(gl_generator::StructGenerator, &mut file)
|
2018-11-21 09:28:15 +01:00
|
|
|
.unwrap();
|
|
|
|
}
|
2017-05-18 22:28:02 +02:00
|
|
|
}
|
2018-11-22 10:14:23 +01:00
|
|
|
|
2022-10-03 09:27:15 +02:00
|
|
|
#[cfg(all(feature = "backend_gbm", not(feature = "backend_gbm_has_fd_for_plane")))]
|
|
|
|
fn test_gbm_bo_fd_for_plane() {
|
|
|
|
let gbm = match pkg_config::probe_library("gbm") {
|
|
|
|
Ok(lib) => lib,
|
|
|
|
Err(_) => {
|
|
|
|
println!("cargo:warning=failed to find gbm, assuming gbm_bo_get_fd_for_plane is unavailable");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let has_gbm_bo_get_fd_for_plane = cc::Build::new()
|
|
|
|
.file("test_gbm_bo_get_fd_for_plane.c")
|
|
|
|
.includes(gbm.include_paths)
|
|
|
|
.warnings_into_errors(true)
|
2023-02-10 23:30:30 +01:00
|
|
|
.cargo_metadata(false)
|
2022-10-03 09:27:15 +02:00
|
|
|
.try_compile("test_gbm_bo_get_fd_for_plane")
|
|
|
|
.is_ok();
|
|
|
|
|
|
|
|
if has_gbm_bo_get_fd_for_plane {
|
|
|
|
println!("cargo:rustc-cfg=feature=\"backend_gbm_has_fd_for_plane\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-08 17:42:14 +01:00
|
|
|
#[cfg(all(
|
|
|
|
feature = "backend_gbm",
|
|
|
|
not(feature = "backend_gbm_has_create_with_modifiers2")
|
|
|
|
))]
|
|
|
|
fn test_gbm_bo_create_with_modifiers2() {
|
|
|
|
let gbm = match pkg_config::probe_library("gbm") {
|
|
|
|
Ok(lib) => lib,
|
|
|
|
Err(_) => {
|
|
|
|
println!(
|
|
|
|
"cargo:warning=failed to find gbm, assuming gbm_bo_create_with_modifiers2 is unavailable"
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let has_gbm_bo_create_with_modifiers2 = cc::Build::new()
|
|
|
|
.file("test_gbm_bo_create_with_modifiers2.c")
|
|
|
|
.includes(gbm.include_paths)
|
|
|
|
.warnings_into_errors(true)
|
2023-02-10 23:30:30 +01:00
|
|
|
.cargo_metadata(false)
|
2023-02-08 17:42:14 +01:00
|
|
|
.try_compile("test_gbm_bo_create_with_modifiers2")
|
|
|
|
.is_ok();
|
|
|
|
|
|
|
|
if has_gbm_bo_create_with_modifiers2 {
|
|
|
|
println!("cargo:rustc-cfg=feature=\"backend_gbm_has_create_with_modifiers2\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 00:13:06 +02:00
|
|
|
fn main() {
|
|
|
|
#[cfg(any(feature = "backend_egl", feature = "renderer_gl"))]
|
|
|
|
gl_generate();
|
|
|
|
|
2022-10-03 09:27:15 +02:00
|
|
|
#[cfg(all(feature = "backend_gbm", not(feature = "backend_gbm_has_fd_for_plane")))]
|
|
|
|
test_gbm_bo_fd_for_plane();
|
2023-02-08 17:42:14 +01:00
|
|
|
#[cfg(all(
|
|
|
|
feature = "backend_gbm",
|
|
|
|
not(feature = "backend_gbm_has_create_with_modifiers2")
|
|
|
|
))]
|
|
|
|
test_gbm_bo_create_with_modifiers2();
|
2020-05-20 00:13:06 +02:00
|
|
|
}
|