1 module dcompute.driver.ocl.event;
2 
3 import dcompute.driver.ocl;
4 
5 struct Event
6 {
7     cl_event raw;
8     enum EnqueuedCommand
9     {
10         kernel            = 0x11F0,
11         task              = 0x11F1,
12         nativeKernel      = 0x11F2,
13         bufferRead        = 0x11F3,
14         bufferWrite       = 0x11F4,
15         bufferCopy        = 0x11F5,
16         imageRead         = 0x11F6,
17         imageWrite        = 0x11F7,
18         imageCopy         = 0x11F8,
19         imageToBufferCopy = 0x11F9,
20         bufferToImageCopy = 0x11FA,
21         bufferMap         = 0x11FB,
22         imageMap          = 0x11FC,
23         unmap             = 0x11FD,
24         marker            = 0x11FE,
25         acquireGLObjects  = 0x11FF,
26         releaseGLObjects  = 0x1200,
27         bufferRectRead    = 0x1201,
28         bufferRectWrite   = 0x1202,
29         bufferRectCopy    = 0x1203,
30         user              = 0x1204,
31         barrier           = 0x1205,
32         migrate           = 0x1206,
33         bufferFill        = 0x1207,
34         imageFill         = 0x1208,
35         
36         // Extensions
37         acquireD3D10Objects = 0x4017,
38         releaseD3D10Objects = 0x4018,
39         acquireDX9MediaSurfaces = 0x202B,
40         releaseDX9MediaSurfaces = 0x202C,
41         acquireD3D11Objects = 0x4020,
42         releaseD3D11Objects = 0x4021,
43         GLFenceSyncObject   = 0x200D,
44         EGLFenceSyncObject  = 0x202F,
45         acquireEGLObjects   = 0x202D,
46         releaseEGLObjects   = 0x202E,
47 
48     }
49     
50     
51     enum EcexutionStatus
52     {
53         complete  = 0x0,
54         running   = 0x1,
55         submitted = 0x2,
56         queued    = 0x3,
57     }
58     static struct Info
59     {
60         @(0x11D0) Queue queue;
61         @(0x11D1) EnqueuedCommand type;
62         @(0x11D2) uint referenceCount;
63         @(0x11D3) EcexutionStatus status;
64         @(0x11D4) Context context;
65     }
66     //mixin(generateGetInfo!(Info,clGetEventInfo));
67     
68     void retain()
69     {
70         status = cast(Status)clRetainEvent(raw);
71         checkErrors();
72     }
73     
74     void release()
75     {
76         status = cast(Status)clReleaseEvent(raw);
77         checkErrors();
78     }
79     void wait()
80     {
81         clWaitForEvents(1,&raw);
82     }
83 }
84 
85 void wait(Event[] e)
86 {
87     clWaitForEvents(cast(uint)e.length,cast(cl_event*)e.ptr);
88 }