rusticl/version: use cl_version instead of cl_uint and provide a From impl
authorKarol Herbst <git@karolherbst.de>
Sat, 17 Jun 2023 19:43:40 +0000 (21:43 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sat, 17 Jun 2023 22:20:05 +0000 (22:20 +0000)
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/23707>

src/gallium/frontends/rusticl/api/device.rs
src/gallium/frontends/rusticl/core/version.rs

index 060f0f3..b24717f 100644 (file)
@@ -201,7 +201,7 @@ impl CLInfo<cl_device_info> for cl_device_id {
                 cl_prop::<cl_uint>(dev.screen().device_node_mask().unwrap_or_default())
             }
             CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT => cl_prop::<bool>(false),
-            CL_DEVICE_NUMERIC_VERSION => cl_prop::<cl_version>(dev.cl_version as cl_version),
+            CL_DEVICE_NUMERIC_VERSION => cl_prop::<cl_version>(dev.cl_version.into()),
             CL_DEVICE_OPENCL_C_ALL_VERSIONS => cl_prop::<&Vec<cl_name_version>>(&dev.clc_versions),
             CL_DEVICE_OPENCL_C_FEATURES => cl_prop::<&Vec<cl_name_version>>(&dev.clc_features),
             CL_DEVICE_OPENCL_C_VERSION => {
index 73ee874..b0df221 100644 (file)
@@ -3,15 +3,14 @@ use rusticl_opencl_gen::*;
 use std::convert::TryFrom;
 use std::os::raw::c_char;
 
-pub const CL1_0_VER: u32 = mk_cl_version(1, 0, 0);
-pub const CL1_1_VER: u32 = mk_cl_version(1, 1, 0);
-pub const CL1_2_VER: u32 = mk_cl_version(1, 2, 0);
-pub const CL2_0_VER: u32 = mk_cl_version(2, 0, 0);
-pub const CL2_1_VER: u32 = mk_cl_version(2, 1, 0);
-pub const CL2_2_VER: u32 = mk_cl_version(2, 2, 0);
-pub const CL3_0_VER: u32 = mk_cl_version(3, 0, 0);
+pub const CL1_0_VER: cl_version = mk_cl_version(1, 0, 0);
+pub const CL1_1_VER: cl_version = mk_cl_version(1, 1, 0);
+pub const CL1_2_VER: cl_version = mk_cl_version(1, 2, 0);
+pub const CL2_0_VER: cl_version = mk_cl_version(2, 0, 0);
+pub const CL2_1_VER: cl_version = mk_cl_version(2, 1, 0);
+pub const CL2_2_VER: cl_version = mk_cl_version(2, 2, 0);
+pub const CL3_0_VER: cl_version = mk_cl_version(3, 0, 0);
 
-#[allow(dead_code)]
 #[repr(u32)]
 #[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)]
 pub enum CLVersion {
@@ -72,10 +71,16 @@ impl CLVersion {
     }
 }
 
-impl TryFrom<u32> for CLVersion {
+impl From<CLVersion> for cl_version {
+    fn from(cl_version: CLVersion) -> Self {
+        cl_version as Self
+    }
+}
+
+impl TryFrom<cl_version> for CLVersion {
     type Error = cl_int;
 
-    fn try_from(value: u32) -> Result<Self, Self::Error> {
+    fn try_from(value: cl_version) -> Result<Self, Self::Error> {
         Ok(match value {
             CL1_0_VER => CLVersion::Cl1_0,
             CL1_1_VER => CLVersion::Cl1_1,