CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS => cl_prop::<cl_uint>(0),
CL_DEVICE_PIPE_MAX_PACKET_SIZE => cl_prop::<cl_uint>(0),
CL_DEVICE_PIPE_SUPPORT => cl_prop::<bool>(false),
- CL_DEVICE_PLATFORM => cl_prop::<cl_platform_id>(get_platform()),
+ CL_DEVICE_PLATFORM => cl_prop::<cl_platform_id>(Platform::get().as_ptr()),
CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT => cl_prop::<cl_uint>(0),
CL_DEVICE_PREFERRED_INTEROP_USER_SYNC => cl_prop::<bool>(true),
CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT => cl_prop::<cl_uint>(0),
// specific OpenCL platform. If the platforms argument is NULL, then this argument is ignored. The
// number of OpenCL platforms returned is the minimum of the value specified by num_entries or the
// number of OpenCL platforms available.
- platforms.write_checked(get_platform());
+ platforms.write_checked(Platform::get().as_ptr());
// num_platforms returns the number of OpenCL platforms available. If num_platforms is NULL, then
// this argument is ignored.
],
};
-pub fn get_platform() -> cl_platform_id {
- &PLATFORM as *const Platform as *mut _cl_platform_id
+impl Platform {
+ pub fn as_ptr(&self) -> cl_platform_id {
+ (self as *const Self) as cl_platform_id
+ }
+
+ pub fn get() -> &'static Self {
+ &PLATFORM
+ }
}
pub trait GetPlatformRef {
impl GetPlatformRef for cl_platform_id {
fn get_ref(&self) -> CLResult<&'static Platform> {
- if !self.is_null() && *self == get_platform() {
- Ok(&PLATFORM)
+ if !self.is_null() && *self == Platform::get().as_ptr() {
+ Ok(Platform::get())
} else {
Err(CL_INVALID_PLATFORM)
}