1 module dcompute.driver.ocl.platform;
2 
3 import dcompute.driver.ocl;
4 import std.experimental.allocator.typed;
5 
6 struct Platform
7 {
8 	static void initialise()
9 	{
10 		DerelictCL.load();
11 	}
12     static struct Info
13     {
14         @(0x0900) immutable(char)* _profile;
15         @(0x0901) immutable(char)* _version_;
16         @(0x0902) immutable(char)* _name;
17         @(0x0903) immutable(char)* _vendor;
18         @(0x0904) immutable(char)* _extensions;
19         StringzAccessor!(_profile) profile;
20         StringzAccessor!(_version_) version_;
21         StringzAccessor!(_name) name;
22         StringzAccessor!(_vendor) vendor;
23         StringzAccessor!(_extensions) extensions;
24         // Extensions
25         //@(0x0920) khrICDSuffix;
26 
27     }
28 
29     mixin(generateGetInfo!(Info,clGetPlatformInfo));
30 
31     cl_platform_id raw;
32     static Platform[] getPlatforms(A)(A a)
33     {
34         auto allocator = TypedAllocator!(A)(a);
35         cl_uint numPlatforms;
36         status = cast(Status)clGetPlatformIDs(0,null,&numPlatforms);
37         checkErrors();
38         cl_platform_id[] ret = allocator.makeArray!(cl_platform_id)(numPlatforms);
39         status = cast(Status)clGetPlatformIDs(numPlatforms,cast(cl_platform_id*)ret.ptr,null);
40         checkErrors();
41         return cast(Platform[])ret;
42     }
43     
44     Device[] getDevices(A)(A a,Device.Type device_type = Device.Type.all)
45     {
46         auto allocator = TypedAllocator!(A)(a);
47         uint numDevices;
48         status = cast(Status)clGetDeviceIDs(
49             raw,
50             cast(cl_device_type)device_type,
51             0,
52             null,
53             &numDevices);
54         
55         auto deviceIDs = allocator.makeArray!cl_device_id(numDevices);
56         
57         status = cast(Status)clGetDeviceIDs(
58             raw,
59             cast(cl_device_type)device_type,
60             numDevices,
61             deviceIDs.ptr,
62             null);
63         
64         return cast(Device[])deviceIDs;
65     }
66     
67     // clGetExtensionFunctionAddressForPlatform
68 }