Lines 14-19
use crate::api::util::*;
Link Here
|
14 |
use mesa_rust_util::ptr::*; |
14 |
use mesa_rust_util::ptr::*; |
15 |
use rusticl_opencl_gen::*; |
15 |
use rusticl_opencl_gen::*; |
16 |
|
16 |
|
|
|
17 |
use std::ffi::c_char; |
18 |
use std::ffi::c_void; |
17 |
use std::ffi::CStr; |
19 |
use std::ffi::CStr; |
18 |
use std::ptr; |
20 |
use std::ptr; |
19 |
use std::sync::Arc; |
21 |
use std::sync::Arc; |
Lines 470-526
extern "C" fn clIcdGetPlatformIDsKHR(
Link Here
|
470 |
cl_get_platform_ids(num_entries, platforms, num_platforms) |
472 |
cl_get_platform_ids(num_entries, platforms, num_platforms) |
471 |
} |
473 |
} |
472 |
|
474 |
|
|
|
475 |
macro_rules! cl_ext_func { |
476 |
($func:ident: $api_type:ident) => {{ |
477 |
let _func: $api_type = Some($func); |
478 |
$func as *mut ::std::ffi::c_void |
479 |
}}; |
480 |
} |
481 |
|
482 |
#[rustfmt::skip] |
473 |
extern "C" fn cl_get_extension_function_address( |
483 |
extern "C" fn cl_get_extension_function_address( |
474 |
function_name: *const ::std::os::raw::c_char, |
484 |
function_name: *const c_char, |
475 |
) -> *mut ::std::ffi::c_void { |
485 |
) -> *mut c_void { |
476 |
if function_name.is_null() { |
486 |
if function_name.is_null() { |
477 |
return ptr::null_mut(); |
487 |
return ptr::null_mut(); |
478 |
} |
488 |
} |
479 |
match unsafe { CStr::from_ptr(function_name) }.to_str().unwrap() { |
489 |
match unsafe { CStr::from_ptr(function_name) }.to_str().unwrap() { |
480 |
// cl_khr_create_command_queue |
490 |
// cl_khr_create_command_queue |
481 |
"clCreateCommandQueueWithPropertiesKHR" => { |
491 |
"clCreateCommandQueueWithPropertiesKHR" => cl_ext_func!(cl_create_command_queue_with_properties: clCreateCommandQueueWithPropertiesKHR_fn), |
482 |
cl_create_command_queue_with_properties as *mut ::std::ffi::c_void |
|
|
483 |
} |
484 |
|
492 |
|
485 |
// cl_khr_icd |
493 |
// cl_khr_icd |
486 |
"clGetPlatformInfo" => cl_get_platform_info as *mut ::std::ffi::c_void, |
494 |
"clGetPlatformInfo" => cl_ext_func!(cl_get_platform_info: cl_api_clGetPlatformInfo), |
487 |
"clIcdGetPlatformIDsKHR" => cl_get_platform_ids as *mut ::std::ffi::c_void, |
495 |
"clIcdGetPlatformIDsKHR" => cl_ext_func!(cl_get_platform_ids: clIcdGetPlatformIDsKHR_fn), |
488 |
|
496 |
|
489 |
// cl_khr_il_program |
497 |
// cl_khr_il_program |
490 |
"clCreateProgramWithILKHR" => cl_create_program_with_il as *mut ::std::ffi::c_void, |
498 |
"clCreateProgramWithILKHR" => cl_ext_func!(cl_create_program_with_il: clCreateProgramWithILKHR_fn), |
491 |
|
499 |
|
492 |
// cl_khr_gl_sharing |
500 |
// cl_khr_gl_sharing |
493 |
"clCreateFromGLBuffer" => cl_create_from_gl_buffer as *mut ::std::ffi::c_void, |
501 |
"clCreateFromGLBuffer" => cl_ext_func!(cl_create_from_gl_buffer: cl_api_clCreateFromGLBuffer), |
494 |
"clCreateFromGLRenderbuffer" => cl_create_from_gl_renderbuffer as *mut ::std::ffi::c_void, |
502 |
"clCreateFromGLRenderbuffer" => cl_ext_func!(cl_create_from_gl_renderbuffer: cl_api_clCreateFromGLRenderbuffer), |
495 |
"clCreateFromGLTexture" => cl_create_from_gl_texture as *mut ::std::ffi::c_void, |
503 |
"clCreateFromGLTexture" => cl_ext_func!(cl_create_from_gl_texture: cl_api_clCreateFromGLTexture), |
496 |
"clCreateFromGLTexture2D" => cl_create_from_gl_texture_2d as *mut ::std::ffi::c_void, |
504 |
"clCreateFromGLTexture2D" => cl_ext_func!(cl_create_from_gl_texture_2d: cl_api_clCreateFromGLTexture2D), |
497 |
"clCreateFromGLTexture3D" => cl_create_from_gl_texture_3d as *mut ::std::ffi::c_void, |
505 |
"clCreateFromGLTexture3D" => cl_ext_func!(cl_create_from_gl_texture_3d: cl_api_clCreateFromGLTexture3D), |
498 |
"clEnqueueAcquireGLObjects" => cl_enqueue_acquire_gl_objects as *mut ::std::ffi::c_void, |
506 |
"clEnqueueAcquireGLObjects" => cl_ext_func!(cl_enqueue_acquire_gl_objects: cl_api_clEnqueueAcquireGLObjects), |
499 |
"clEnqueueReleaseGLObjects" => cl_enqueue_release_gl_objects as *mut ::std::ffi::c_void, |
507 |
"clEnqueueReleaseGLObjects" => cl_ext_func!(cl_enqueue_release_gl_objects: cl_api_clEnqueueReleaseGLObjects), |
500 |
"clGetGLContextInfoKHR" => cl_get_gl_context_info_khr as *mut ::std::ffi::c_void, |
508 |
"clGetGLContextInfoKHR" => cl_ext_func!(cl_get_gl_context_info_khr: cl_api_clGetGLContextInfoKHR), |
501 |
"clGetGLObjectInfo" => cl_get_gl_object_info as *mut ::std::ffi::c_void, |
509 |
"clGetGLObjectInfo" => cl_ext_func!(cl_get_gl_object_info: cl_api_clGetGLObjectInfo), |
502 |
"clGetGLTextureInfo" => cl_get_gl_texture_info as *mut ::std::ffi::c_void, |
510 |
"clGetGLTextureInfo" => cl_ext_func!(cl_get_gl_texture_info: cl_api_clGetGLTextureInfo), |
503 |
|
511 |
|
504 |
// cl_khr_suggested_local_work_size |
512 |
// cl_khr_suggested_local_work_size |
505 |
"clGetKernelSuggestedLocalWorkSizeKHR" => { |
513 |
"clGetKernelSuggestedLocalWorkSizeKHR" => cl_ext_func!(cl_get_kernel_suggested_local_work_size_khr: clGetKernelSuggestedLocalWorkSizeKHR_fn), |
506 |
cl_get_kernel_suggested_local_work_size_khr as *mut ::std::ffi::c_void |
|
|
507 |
} |
508 |
|
514 |
|
509 |
// cl_arm_shared_virtual_memory |
515 |
// cl_arm_shared_virtual_memory |
510 |
"clEnqueueSVMFreeARM" => cl_enqueue_svm_free_arm as *mut ::std::ffi::c_void, |
516 |
"clEnqueueSVMFreeARM" => cl_ext_func!(cl_enqueue_svm_free_arm: cl_api_clEnqueueSVMFree), |
511 |
"clEnqueueSVMMapARM" => cl_enqueue_svm_map_arm as *mut ::std::ffi::c_void, |
517 |
"clEnqueueSVMMapARM" => cl_ext_func!(cl_enqueue_svm_map_arm: cl_api_clEnqueueSVMMap), |
512 |
"clEnqueueSVMMemcpyARM" => cl_enqueue_svm_memcpy_arm as *mut ::std::ffi::c_void, |
518 |
"clEnqueueSVMMemcpyARM" => cl_ext_func!(cl_enqueue_svm_memcpy_arm: cl_api_clEnqueueSVMMemcpy), |
513 |
"clEnqueueSVMMemFillARM" => cl_enqueue_svm_mem_fill_arm as *mut ::std::ffi::c_void, |
519 |
"clEnqueueSVMMemFillARM" => cl_ext_func!(cl_enqueue_svm_mem_fill_arm: cl_api_clEnqueueSVMMemFill), |
514 |
"clEnqueueSVMUnmapARM" => cl_enqueue_svm_unmap_arm as *mut ::std::ffi::c_void, |
520 |
"clEnqueueSVMUnmapARM" => cl_ext_func!(cl_enqueue_svm_unmap_arm: cl_api_clEnqueueSVMUnmap), |
515 |
"clSetKernelArgSVMPointerARM" => cl_set_kernel_arg_svm_pointer as *mut ::std::ffi::c_void, |
521 |
"clSetKernelArgSVMPointerARM" => cl_ext_func!(cl_set_kernel_arg_svm_pointer: cl_api_clSetKernelArgSVMPointer), |
516 |
"clSetKernelExecInfoARM" => cl_set_kernel_exec_info as *mut ::std::ffi::c_void, |
522 |
"clSetKernelExecInfoARM" => cl_ext_func!(cl_set_kernel_exec_info: cl_api_clSetKernelExecInfo), |
517 |
"clSVMAllocARM" => cl_svm_alloc as *mut ::std::ffi::c_void, |
523 |
"clSVMAllocARM" => cl_ext_func!(cl_svm_alloc: cl_api_clSVMAlloc), |
518 |
"clSVMFreeARM" => cl_svm_free as *mut ::std::ffi::c_void, |
524 |
"clSVMFreeARM" => cl_ext_func!(cl_svm_free: cl_api_clSVMFree), |
519 |
|
525 |
|
520 |
// DPCPP bug https://github.com/intel/llvm/issues/9964 |
526 |
// DPCPP bug https://github.com/intel/llvm/issues/9964 |
521 |
"clSetProgramSpecializationConstant" => { |
527 |
"clSetProgramSpecializationConstant" => cl_ext_func!(cl_set_program_specialization_constant: cl_api_clSetProgramSpecializationConstant), |
522 |
cl_set_program_specialization_constant as *mut ::std::ffi::c_void |
|
|
523 |
} |
524 |
|
528 |
|
525 |
_ => ptr::null_mut(), |
529 |
_ => ptr::null_mut(), |
526 |
} |
530 |
} |