1 module dcl.event; 2 3 import dcl.base; 4 import dcl.context; 5 import dcl.commandqueue; 6 7 /// 8 struct CLEvent 9 { 10 /// 11 cl_event id; 12 13 alias id this; 14 15 /// 16 enum Command 17 { 18 NDRANGE_KERNEL = CL_COMMAND_NDRANGE_KERNEL, /// 19 TASK = CL_COMMAND_TASK, /// 20 NATIVE_KERNEL = CL_COMMAND_NATIVE_KERNEL, /// 21 READ_BUFFER = CL_COMMAND_READ_BUFFER, /// 22 WRITE_BUFFER = CL_COMMAND_WRITE_BUFFER, /// 23 COPY_BUFFER = CL_COMMAND_COPY_BUFFER, /// 24 READ_IMAGE = CL_COMMAND_READ_IMAGE, /// 25 WRITE_IMAGE = CL_COMMAND_WRITE_IMAGE, /// 26 COPY_IMAGE = CL_COMMAND_COPY_IMAGE, /// 27 COPY_BUFFER_TO_IMAGE = CL_COMMAND_COPY_BUFFER_TO_IMAGE, /// 28 COPY_IMAGE_TO_BUFFER = CL_COMMAND_COPY_IMAGE_TO_BUFFER, /// 29 MAP_BUFFER = CL_COMMAND_MAP_BUFFER, /// 30 MAP_IMAGE = CL_COMMAND_MAP_IMAGE, /// 31 UNMAP_MEM_OBJECT = CL_COMMAND_UNMAP_MEM_OBJECT, /// 32 MARKER = CL_COMMAND_MARKER, /// 33 ACQUIRE_GL_OBJECTS = CL_COMMAND_ACQUIRE_GL_OBJECTS, /// 34 RELEASE_GL_OBJECTS = CL_COMMAND_RELEASE_GL_OBJECTS, /// 35 READ_BUFFER_RECT = CL_COMMAND_READ_BUFFER_RECT, /// 36 WRITE_BUFFER_RECT = CL_COMMAND_WRITE_BUFFER_RECT, /// 37 COPY_BUFFER_RECT = CL_COMMAND_COPY_BUFFER_RECT, /// 38 USER = CL_COMMAND_USER, /// 39 BARRIER = CL_COMMAND_BARRIER, /// 40 MIGRATE_MEM_OBJECTS = CL_COMMAND_MIGRATE_MEM_OBJECTS, /// 41 FILL_BUFFER = CL_COMMAND_FILL_BUFFER, /// 42 FILL_IMAGE = CL_COMMAND_FILL_IMAGE /// 43 } 44 45 /// 46 enum Status 47 { 48 QUEUED = CL_QUEUED, /// 49 SUBMITTED = CL_SUBMITTED,/// 50 RUNNING = CL_RUNNING, /// 51 COMPLETE = CL_COMPLETE /// 52 } 53 54 static private enum info_list = 55 [ 56 "cl_context:CLContext context", 57 "cl_command_queue:CLCommandQueue command_queue:queue", 58 "cl_command_type:Command command_type:command", 59 "cl_int:Status command_execution_status:status", 60 "uint reference_count:refcount" 61 ]; 62 63 mixin( infoMixin( "event", info_list ) ); 64 65 static private enum prof_list = 66 [ 67 "ulong queued", 68 "ulong submit", 69 "ulong start", 70 "ulong end" 71 ]; 72 73 mixin( infoMixin( "event_profiling", "profiling_command", prof_list ) ); 74 75 /// 76 void retain() { checkCall!clRetainEvent(id); } 77 78 /// 79 void release() { checkCall!clReleaseEvent(id); } 80 } 81 82 unittest 83 { 84 assertEq( CLEvent.sizeof, cl_event.sizeof ); 85 } 86 87 class CLUserEvent 88 { 89 CLEvent event; 90 91 alias event this; 92 93 this( CLContext ctx ) 94 { 95 event = CLEvent( checkCode!clCreateUserEvent(ctx.id) ); 96 } 97 98 void setComplite() 99 { checkCall!clSetUserEventStatus( event, CLEvent.Status.COMPLETE ); } 100 101 void setError( int val ) in{ assert( val < 0 ); } body 102 { checkCall!clSetUserEventStatus( event, val ); } 103 }