mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-24 14:58:10 +02:00
rusticl/platform: move getter into the type
Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22280>
This commit is contained in:
parent
3e59a2860e
commit
53025688bb
3 changed files with 12 additions and 6 deletions
|
|
@ -143,7 +143,7 @@ impl CLInfo<cl_device_info> for cl_device_id {
|
|||
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),
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pub fn get_platform_ids(
|
|||
// 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.
|
||||
|
|
|
|||
|
|
@ -18,8 +18,14 @@ static PLATFORM: Platform = Platform {
|
|||
],
|
||||
};
|
||||
|
||||
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 {
|
||||
|
|
@ -28,8 +34,8 @@ 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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue