summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Herbst <git@karolherbst.de>2023-05-15 22:12:15 +0200
committerMarge Bot <emma+marge@anholt.net>2023-05-16 21:07:08 +0000
commit63c501809e1bc3e97013e49144985243249a13d5 (patch)
treeb871c50f6e325e5d0d4d28c776d4ccdc020188c4
parent508f81f913dd2925bce0e3dd2703c7a5efcc340f (diff)
downloadmesa-63c501809e1bc3e97013e49144985243249a13d5.tar.gz
rusticl/platform: generate extension constants via macro
Signed-off-by: Karol Herbst <git@karolherbst.de> Reviewed-by: Nora Allen <blackcatgames@protonmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23031>
-rw-r--r--src/gallium/frontends/rusticl/core/platform.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gallium/frontends/rusticl/core/platform.rs b/src/gallium/frontends/rusticl/core/platform.rs
index 666c475a9bf..c6b627ac697 100644
--- a/src/gallium/frontends/rusticl/core/platform.rs
+++ b/src/gallium/frontends/rusticl/core/platform.rs
@@ -26,12 +26,26 @@ pub struct PlatformFeatures {
static PLATFORM_ENV_ONCE: Once = Once::new();
static PLATFORM_ONCE: Once = Once::new();
-pub static PLATFORM_EXTENSIONS: [cl_name_version; 3] = [
- mk_cl_version_ext(1, 0, 0, "cl_khr_byte_addressable_store"),
- mk_cl_version_ext(1, 0, 0, "cl_khr_icd"),
- mk_cl_version_ext(1, 0, 0, "cl_khr_il_program"),
-];
-pub static PLATFORM_EXTENSION_STR: &str = "cl_khr_byte_addressable_store cl_khr_icd cl_khr_il_program";
+
+macro_rules! gen_cl_exts {
+ (@COUNT $e:expr) => { 1 };
+ (@COUNT $e:expr, $($es:expr),+) => { 1 + gen_cl_exts!(@COUNT $($es),*) };
+
+ (@CONCAT $e:tt) => { $e };
+ (@CONCAT $e:tt, $($es:tt),+) => { concat!($e, ' ', gen_cl_exts!(@CONCAT $($es),*)) };
+
+ ([$(($major:expr, $minor:expr, $patch:expr, $ext:tt)$(,)?)+]) => {
+ pub static PLATFORM_EXTENSION_STR: &str = concat!(gen_cl_exts!(@CONCAT $($ext),*));
+ pub static PLATFORM_EXTENSIONS: [cl_name_version; gen_cl_exts!(@COUNT $($ext),*)] = [
+ $(mk_cl_version_ext($major, $minor, $patch, $ext)),+
+ ];
+ }
+}
+gen_cl_exts!([
+ (1, 0, 0, "cl_khr_byte_addressable_store"),
+ (1, 0, 0, "cl_khr_icd"),
+ (1, 0, 0, "cl_khr_il_program"),
+]);
static mut PLATFORM: Platform = Platform {
dispatch: &DISPATCH,