• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_entry_points.py using data from cl.xml.
3 //
4 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style license that can be
6 // found in the LICENSE file.
7 //
8 // entry_points_cl_autogen.cpp:
9 //   Defines the CL entry points.
10 
11 #include "libGLESv2/entry_points_cl_autogen.h"
12 
13 #include "libANGLE/validationCL_autogen.h"
14 #include "libGLESv2/cl_stubs_autogen.h"
15 #include "libGLESv2/entry_points_cl_utils.h"
16 
17 namespace cl
18 {
19 
20 // CL 1.0
clGetPlatformIDs(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)21 cl_int CL_API_CALL clGetPlatformIDs(cl_uint num_entries,
22                                     cl_platform_id *platforms,
23                                     cl_uint *num_platforms)
24 {
25     InitBackEnds(false);
26 
27     CL_EVENT(GetPlatformIDs,
28              "num_entries = %u, platforms = 0x%016" PRIxPTR ", num_platforms = 0x%016" PRIxPTR "",
29              num_entries, (uintptr_t)platforms, (uintptr_t)num_platforms);
30 
31     ANGLE_CL_VALIDATE_ERROR(GetPlatformIDs, num_entries, platforms, num_platforms);
32 
33     return GetPlatformIDs(num_entries, platforms, num_platforms);
34 }
35 
clGetPlatformInfo(cl_platform_id platform,cl_platform_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)36 cl_int CL_API_CALL clGetPlatformInfo(cl_platform_id platform,
37                                      cl_platform_info param_name,
38                                      size_t param_value_size,
39                                      void *param_value,
40                                      size_t *param_value_size_ret)
41 {
42     InitBackEnds(false);
43 
44     CL_EVENT(GetPlatformInfo,
45              "platform = 0x%016" PRIxPTR
46              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
47              ", param_value_size_ret = 0x%016" PRIxPTR "",
48              (uintptr_t)platform, param_name, param_value_size, (uintptr_t)param_value,
49              (uintptr_t)param_value_size_ret);
50 
51     PlatformInfo param_namePacked = PackParam<PlatformInfo>(param_name);
52 
53     ANGLE_CL_VALIDATE_ERROR(GetPlatformInfo, platform, param_namePacked, param_value_size,
54                             param_value, param_value_size_ret);
55 
56     return GetPlatformInfo(platform, param_namePacked, param_value_size, param_value,
57                            param_value_size_ret);
58 }
59 
clGetDeviceIDs(cl_platform_id platform,cl_device_type device_type,cl_uint num_entries,cl_device_id * devices,cl_uint * num_devices)60 cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
61                                   cl_device_type device_type,
62                                   cl_uint num_entries,
63                                   cl_device_id *devices,
64                                   cl_uint *num_devices)
65 {
66     InitBackEnds(false);
67 
68     CL_EVENT(GetDeviceIDs,
69              "platform = 0x%016" PRIxPTR
70              ", device_type = %llu, num_entries = %u, devices = 0x%016" PRIxPTR
71              ", num_devices = 0x%016" PRIxPTR "",
72              (uintptr_t)platform, static_cast<unsigned long long>(device_type), num_entries,
73              (uintptr_t)devices, (uintptr_t)num_devices);
74 
75     DeviceType device_typePacked = PackParam<DeviceType>(device_type);
76 
77     ANGLE_CL_VALIDATE_ERROR(GetDeviceIDs, platform, device_typePacked, num_entries, devices,
78                             num_devices);
79 
80     return GetDeviceIDs(platform, device_typePacked, num_entries, devices, num_devices);
81 }
82 
clGetDeviceInfo(cl_device_id device,cl_device_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)83 cl_int CL_API_CALL clGetDeviceInfo(cl_device_id device,
84                                    cl_device_info param_name,
85                                    size_t param_value_size,
86                                    void *param_value,
87                                    size_t *param_value_size_ret)
88 {
89     CL_EVENT(GetDeviceInfo,
90              "device = 0x%016" PRIxPTR
91              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
92              ", param_value_size_ret = 0x%016" PRIxPTR "",
93              (uintptr_t)device, param_name, param_value_size, (uintptr_t)param_value,
94              (uintptr_t)param_value_size_ret);
95 
96     DeviceInfo param_namePacked = PackParam<DeviceInfo>(param_name);
97 
98     ANGLE_CL_VALIDATE_ERROR(GetDeviceInfo, device, param_namePacked, param_value_size, param_value,
99                             param_value_size_ret);
100 
101     return GetDeviceInfo(device, param_namePacked, param_value_size, param_value,
102                          param_value_size_ret);
103 }
104 
clCreateContext(const cl_context_properties * properties,cl_uint num_devices,const cl_device_id * devices,void (CL_CALLBACK * pfn_notify)(const char * errinfo,const void * private_info,size_t cb,void * user_data),void * user_data,cl_int * errcode_ret)105 cl_context CL_API_CALL clCreateContext(const cl_context_properties *properties,
106                                        cl_uint num_devices,
107                                        const cl_device_id *devices,
108                                        void(CL_CALLBACK *pfn_notify)(const char *errinfo,
109                                                                      const void *private_info,
110                                                                      size_t cb,
111                                                                      void *user_data),
112                                        void *user_data,
113                                        cl_int *errcode_ret)
114 {
115     InitBackEnds(false);
116 
117     CL_EVENT(CreateContext,
118              "properties = 0x%016" PRIxPTR ", num_devices = %u, devices = 0x%016" PRIxPTR
119              ", pfn_notify = 0x%016" PRIxPTR ", user_data = 0x%016" PRIxPTR
120              ", errcode_ret = 0x%016" PRIxPTR "",
121              (uintptr_t)properties, num_devices, (uintptr_t)devices, (uintptr_t)pfn_notify,
122              (uintptr_t)user_data, (uintptr_t)errcode_ret);
123 
124     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateContext, properties, num_devices, devices, pfn_notify,
125                                   user_data);
126 
127     cl_int errorCode = CL_SUCCESS;
128     cl_context object =
129         CreateContext(properties, num_devices, devices, pfn_notify, user_data, errorCode);
130 
131     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
132     if (errcode_ret != nullptr)
133     {
134         *errcode_ret = errorCode;
135     }
136     return object;
137 }
138 
139 cl_context CL_API_CALL
clCreateContextFromType(const cl_context_properties * properties,cl_device_type device_type,void (CL_CALLBACK * pfn_notify)(const char * errinfo,const void * private_info,size_t cb,void * user_data),void * user_data,cl_int * errcode_ret)140 clCreateContextFromType(const cl_context_properties *properties,
141                         cl_device_type device_type,
142                         void(CL_CALLBACK *pfn_notify)(const char *errinfo,
143                                                       const void *private_info,
144                                                       size_t cb,
145                                                       void *user_data),
146                         void *user_data,
147                         cl_int *errcode_ret)
148 {
149     InitBackEnds(false);
150 
151     CL_EVENT(CreateContextFromType,
152              "properties = 0x%016" PRIxPTR ", device_type = %llu, pfn_notify = 0x%016" PRIxPTR
153              ", user_data = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
154              (uintptr_t)properties, static_cast<unsigned long long>(device_type),
155              (uintptr_t)pfn_notify, (uintptr_t)user_data, (uintptr_t)errcode_ret);
156 
157     DeviceType device_typePacked = PackParam<DeviceType>(device_type);
158 
159     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateContextFromType, properties, device_typePacked, pfn_notify,
160                                   user_data);
161 
162     cl_int errorCode = CL_SUCCESS;
163     cl_context object =
164         CreateContextFromType(properties, device_typePacked, pfn_notify, user_data, errorCode);
165 
166     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
167     if (errcode_ret != nullptr)
168     {
169         *errcode_ret = errorCode;
170     }
171     return object;
172 }
173 
clRetainContext(cl_context context)174 cl_int CL_API_CALL clRetainContext(cl_context context)
175 {
176     CL_EVENT(RetainContext, "context = 0x%016" PRIxPTR "", (uintptr_t)context);
177 
178     ANGLE_CL_VALIDATE_ERROR(RetainContext, context);
179 
180     return RetainContext(context);
181 }
182 
clReleaseContext(cl_context context)183 cl_int CL_API_CALL clReleaseContext(cl_context context)
184 {
185     CL_EVENT(ReleaseContext, "context = 0x%016" PRIxPTR "", (uintptr_t)context);
186 
187     ANGLE_CL_VALIDATE_ERROR(ReleaseContext, context);
188 
189     return ReleaseContext(context);
190 }
191 
clGetContextInfo(cl_context context,cl_context_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)192 cl_int CL_API_CALL clGetContextInfo(cl_context context,
193                                     cl_context_info param_name,
194                                     size_t param_value_size,
195                                     void *param_value,
196                                     size_t *param_value_size_ret)
197 {
198     CL_EVENT(GetContextInfo,
199              "context = 0x%016" PRIxPTR
200              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
201              ", param_value_size_ret = 0x%016" PRIxPTR "",
202              (uintptr_t)context, param_name, param_value_size, (uintptr_t)param_value,
203              (uintptr_t)param_value_size_ret);
204 
205     ContextInfo param_namePacked = PackParam<ContextInfo>(param_name);
206 
207     ANGLE_CL_VALIDATE_ERROR(GetContextInfo, context, param_namePacked, param_value_size,
208                             param_value, param_value_size_ret);
209 
210     return GetContextInfo(context, param_namePacked, param_value_size, param_value,
211                           param_value_size_ret);
212 }
213 
clRetainCommandQueue(cl_command_queue command_queue)214 cl_int CL_API_CALL clRetainCommandQueue(cl_command_queue command_queue)
215 {
216     CL_EVENT(RetainCommandQueue, "command_queue = 0x%016" PRIxPTR "", (uintptr_t)command_queue);
217 
218     ANGLE_CL_VALIDATE_ERROR(RetainCommandQueue, command_queue);
219 
220     return RetainCommandQueue(command_queue);
221 }
222 
clReleaseCommandQueue(cl_command_queue command_queue)223 cl_int CL_API_CALL clReleaseCommandQueue(cl_command_queue command_queue)
224 {
225     CL_EVENT(ReleaseCommandQueue, "command_queue = 0x%016" PRIxPTR "", (uintptr_t)command_queue);
226 
227     ANGLE_CL_VALIDATE_ERROR(ReleaseCommandQueue, command_queue);
228 
229     return ReleaseCommandQueue(command_queue);
230 }
231 
clGetCommandQueueInfo(cl_command_queue command_queue,cl_command_queue_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)232 cl_int CL_API_CALL clGetCommandQueueInfo(cl_command_queue command_queue,
233                                          cl_command_queue_info param_name,
234                                          size_t param_value_size,
235                                          void *param_value,
236                                          size_t *param_value_size_ret)
237 {
238     CL_EVENT(GetCommandQueueInfo,
239              "command_queue = 0x%016" PRIxPTR
240              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
241              ", param_value_size_ret = 0x%016" PRIxPTR "",
242              (uintptr_t)command_queue, param_name, param_value_size, (uintptr_t)param_value,
243              (uintptr_t)param_value_size_ret);
244 
245     CommandQueueInfo param_namePacked = PackParam<CommandQueueInfo>(param_name);
246 
247     ANGLE_CL_VALIDATE_ERROR(GetCommandQueueInfo, command_queue, param_namePacked, param_value_size,
248                             param_value, param_value_size_ret);
249 
250     return GetCommandQueueInfo(command_queue, param_namePacked, param_value_size, param_value,
251                                param_value_size_ret);
252 }
253 
clCreateBuffer(cl_context context,cl_mem_flags flags,size_t size,void * host_ptr,cl_int * errcode_ret)254 cl_mem CL_API_CALL clCreateBuffer(cl_context context,
255                                   cl_mem_flags flags,
256                                   size_t size,
257                                   void *host_ptr,
258                                   cl_int *errcode_ret)
259 {
260     CL_EVENT(CreateBuffer,
261              "context = 0x%016" PRIxPTR ", flags = %llu, size = %zu, host_ptr = 0x%016" PRIxPTR
262              ", errcode_ret = 0x%016" PRIxPTR "",
263              (uintptr_t)context, static_cast<unsigned long long>(flags), size, (uintptr_t)host_ptr,
264              (uintptr_t)errcode_ret);
265 
266     MemFlags flagsPacked = PackParam<MemFlags>(flags);
267 
268     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateBuffer, context, flagsPacked, size, host_ptr);
269 
270     cl_int errorCode = CL_SUCCESS;
271     cl_mem object    = CreateBuffer(context, flagsPacked, size, host_ptr, errorCode);
272 
273     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
274     if (errcode_ret != nullptr)
275     {
276         *errcode_ret = errorCode;
277     }
278     return object;
279 }
280 
clRetainMemObject(cl_mem memobj)281 cl_int CL_API_CALL clRetainMemObject(cl_mem memobj)
282 {
283     CL_EVENT(RetainMemObject, "memobj = 0x%016" PRIxPTR "", (uintptr_t)memobj);
284 
285     ANGLE_CL_VALIDATE_ERROR(RetainMemObject, memobj);
286 
287     return RetainMemObject(memobj);
288 }
289 
clReleaseMemObject(cl_mem memobj)290 cl_int CL_API_CALL clReleaseMemObject(cl_mem memobj)
291 {
292     CL_EVENT(ReleaseMemObject, "memobj = 0x%016" PRIxPTR "", (uintptr_t)memobj);
293 
294     ANGLE_CL_VALIDATE_ERROR(ReleaseMemObject, memobj);
295 
296     return ReleaseMemObject(memobj);
297 }
298 
clGetSupportedImageFormats(cl_context context,cl_mem_flags flags,cl_mem_object_type image_type,cl_uint num_entries,cl_image_format * image_formats,cl_uint * num_image_formats)299 cl_int CL_API_CALL clGetSupportedImageFormats(cl_context context,
300                                               cl_mem_flags flags,
301                                               cl_mem_object_type image_type,
302                                               cl_uint num_entries,
303                                               cl_image_format *image_formats,
304                                               cl_uint *num_image_formats)
305 {
306     CL_EVENT(GetSupportedImageFormats,
307              "context = 0x%016" PRIxPTR
308              ", flags = %llu, image_type = %u, num_entries = %u, image_formats = 0x%016" PRIxPTR
309              ", num_image_formats = 0x%016" PRIxPTR "",
310              (uintptr_t)context, static_cast<unsigned long long>(flags), image_type, num_entries,
311              (uintptr_t)image_formats, (uintptr_t)num_image_formats);
312 
313     MemFlags flagsPacked           = PackParam<MemFlags>(flags);
314     MemObjectType image_typePacked = PackParam<MemObjectType>(image_type);
315 
316     ANGLE_CL_VALIDATE_ERROR(GetSupportedImageFormats, context, flagsPacked, image_typePacked,
317                             num_entries, image_formats, num_image_formats);
318 
319     return GetSupportedImageFormats(context, flagsPacked, image_typePacked, num_entries,
320                                     image_formats, num_image_formats);
321 }
322 
clGetMemObjectInfo(cl_mem memobj,cl_mem_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)323 cl_int CL_API_CALL clGetMemObjectInfo(cl_mem memobj,
324                                       cl_mem_info param_name,
325                                       size_t param_value_size,
326                                       void *param_value,
327                                       size_t *param_value_size_ret)
328 {
329     CL_EVENT(GetMemObjectInfo,
330              "memobj = 0x%016" PRIxPTR
331              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
332              ", param_value_size_ret = 0x%016" PRIxPTR "",
333              (uintptr_t)memobj, param_name, param_value_size, (uintptr_t)param_value,
334              (uintptr_t)param_value_size_ret);
335 
336     MemInfo param_namePacked = PackParam<MemInfo>(param_name);
337 
338     ANGLE_CL_VALIDATE_ERROR(GetMemObjectInfo, memobj, param_namePacked, param_value_size,
339                             param_value, param_value_size_ret);
340 
341     return GetMemObjectInfo(memobj, param_namePacked, param_value_size, param_value,
342                             param_value_size_ret);
343 }
344 
clGetImageInfo(cl_mem image,cl_image_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)345 cl_int CL_API_CALL clGetImageInfo(cl_mem image,
346                                   cl_image_info param_name,
347                                   size_t param_value_size,
348                                   void *param_value,
349                                   size_t *param_value_size_ret)
350 {
351     CL_EVENT(GetImageInfo,
352              "image = 0x%016" PRIxPTR
353              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
354              ", param_value_size_ret = 0x%016" PRIxPTR "",
355              (uintptr_t)image, param_name, param_value_size, (uintptr_t)param_value,
356              (uintptr_t)param_value_size_ret);
357 
358     ImageInfo param_namePacked = PackParam<ImageInfo>(param_name);
359 
360     ANGLE_CL_VALIDATE_ERROR(GetImageInfo, image, param_namePacked, param_value_size, param_value,
361                             param_value_size_ret);
362 
363     return GetImageInfo(image, param_namePacked, param_value_size, param_value,
364                         param_value_size_ret);
365 }
366 
clRetainSampler(cl_sampler sampler)367 cl_int CL_API_CALL clRetainSampler(cl_sampler sampler)
368 {
369     CL_EVENT(RetainSampler, "sampler = 0x%016" PRIxPTR "", (uintptr_t)sampler);
370 
371     ANGLE_CL_VALIDATE_ERROR(RetainSampler, sampler);
372 
373     return RetainSampler(sampler);
374 }
375 
clReleaseSampler(cl_sampler sampler)376 cl_int CL_API_CALL clReleaseSampler(cl_sampler sampler)
377 {
378     CL_EVENT(ReleaseSampler, "sampler = 0x%016" PRIxPTR "", (uintptr_t)sampler);
379 
380     ANGLE_CL_VALIDATE_ERROR(ReleaseSampler, sampler);
381 
382     return ReleaseSampler(sampler);
383 }
384 
clGetSamplerInfo(cl_sampler sampler,cl_sampler_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)385 cl_int CL_API_CALL clGetSamplerInfo(cl_sampler sampler,
386                                     cl_sampler_info param_name,
387                                     size_t param_value_size,
388                                     void *param_value,
389                                     size_t *param_value_size_ret)
390 {
391     CL_EVENT(GetSamplerInfo,
392              "sampler = 0x%016" PRIxPTR
393              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
394              ", param_value_size_ret = 0x%016" PRIxPTR "",
395              (uintptr_t)sampler, param_name, param_value_size, (uintptr_t)param_value,
396              (uintptr_t)param_value_size_ret);
397 
398     SamplerInfo param_namePacked = PackParam<SamplerInfo>(param_name);
399 
400     ANGLE_CL_VALIDATE_ERROR(GetSamplerInfo, sampler, param_namePacked, param_value_size,
401                             param_value, param_value_size_ret);
402 
403     return GetSamplerInfo(sampler, param_namePacked, param_value_size, param_value,
404                           param_value_size_ret);
405 }
406 
clCreateProgramWithSource(cl_context context,cl_uint count,const char ** strings,const size_t * lengths,cl_int * errcode_ret)407 cl_program CL_API_CALL clCreateProgramWithSource(cl_context context,
408                                                  cl_uint count,
409                                                  const char **strings,
410                                                  const size_t *lengths,
411                                                  cl_int *errcode_ret)
412 {
413     CL_EVENT(CreateProgramWithSource,
414              "context = 0x%016" PRIxPTR ", count = %u, strings = 0x%016" PRIxPTR
415              ", lengths = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
416              (uintptr_t)context, count, (uintptr_t)strings, (uintptr_t)lengths,
417              (uintptr_t)errcode_ret);
418 
419     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateProgramWithSource, context, count, strings, lengths);
420 
421     cl_int errorCode  = CL_SUCCESS;
422     cl_program object = CreateProgramWithSource(context, count, strings, lengths, errorCode);
423 
424     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
425     if (errcode_ret != nullptr)
426     {
427         *errcode_ret = errorCode;
428     }
429     return object;
430 }
431 
clCreateProgramWithBinary(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const size_t * lengths,const unsigned char ** binaries,cl_int * binary_status,cl_int * errcode_ret)432 cl_program CL_API_CALL clCreateProgramWithBinary(cl_context context,
433                                                  cl_uint num_devices,
434                                                  const cl_device_id *device_list,
435                                                  const size_t *lengths,
436                                                  const unsigned char **binaries,
437                                                  cl_int *binary_status,
438                                                  cl_int *errcode_ret)
439 {
440     CL_EVENT(CreateProgramWithBinary,
441              "context = 0x%016" PRIxPTR ", num_devices = %u, device_list = 0x%016" PRIxPTR
442              ", lengths = 0x%016" PRIxPTR ", binaries = 0x%016" PRIxPTR
443              ", binary_status = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
444              (uintptr_t)context, num_devices, (uintptr_t)device_list, (uintptr_t)lengths,
445              (uintptr_t)binaries, (uintptr_t)binary_status, (uintptr_t)errcode_ret);
446 
447     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateProgramWithBinary, context, num_devices, device_list,
448                                   lengths, binaries, binary_status);
449 
450     cl_int errorCode  = CL_SUCCESS;
451     cl_program object = CreateProgramWithBinary(context, num_devices, device_list, lengths,
452                                                 binaries, binary_status, errorCode);
453 
454     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
455     if (errcode_ret != nullptr)
456     {
457         *errcode_ret = errorCode;
458     }
459     return object;
460 }
461 
clRetainProgram(cl_program program)462 cl_int CL_API_CALL clRetainProgram(cl_program program)
463 {
464     CL_EVENT(RetainProgram, "program = 0x%016" PRIxPTR "", (uintptr_t)program);
465 
466     ANGLE_CL_VALIDATE_ERROR(RetainProgram, program);
467 
468     return RetainProgram(program);
469 }
470 
clReleaseProgram(cl_program program)471 cl_int CL_API_CALL clReleaseProgram(cl_program program)
472 {
473     CL_EVENT(ReleaseProgram, "program = 0x%016" PRIxPTR "", (uintptr_t)program);
474 
475     ANGLE_CL_VALIDATE_ERROR(ReleaseProgram, program);
476 
477     return ReleaseProgram(program);
478 }
479 
clBuildProgram(cl_program program,cl_uint num_devices,const cl_device_id * device_list,const char * options,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)480 cl_int CL_API_CALL clBuildProgram(cl_program program,
481                                   cl_uint num_devices,
482                                   const cl_device_id *device_list,
483                                   const char *options,
484                                   void(CL_CALLBACK *pfn_notify)(cl_program program,
485                                                                 void *user_data),
486                                   void *user_data)
487 {
488     CL_EVENT(BuildProgram,
489              "program = 0x%016" PRIxPTR ", num_devices = %u, device_list = 0x%016" PRIxPTR
490              ", options = 0x%016" PRIxPTR ", pfn_notify = 0x%016" PRIxPTR
491              ", user_data = 0x%016" PRIxPTR "",
492              (uintptr_t)program, num_devices, (uintptr_t)device_list, (uintptr_t)options,
493              (uintptr_t)pfn_notify, (uintptr_t)user_data);
494 
495     ANGLE_CL_VALIDATE_ERROR(BuildProgram, program, num_devices, device_list, options, pfn_notify,
496                             user_data);
497 
498     return BuildProgram(program, num_devices, device_list, options, pfn_notify, user_data);
499 }
500 
clGetProgramInfo(cl_program program,cl_program_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)501 cl_int CL_API_CALL clGetProgramInfo(cl_program program,
502                                     cl_program_info param_name,
503                                     size_t param_value_size,
504                                     void *param_value,
505                                     size_t *param_value_size_ret)
506 {
507     CL_EVENT(GetProgramInfo,
508              "program = 0x%016" PRIxPTR
509              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
510              ", param_value_size_ret = 0x%016" PRIxPTR "",
511              (uintptr_t)program, param_name, param_value_size, (uintptr_t)param_value,
512              (uintptr_t)param_value_size_ret);
513 
514     ProgramInfo param_namePacked = PackParam<ProgramInfo>(param_name);
515 
516     ANGLE_CL_VALIDATE_ERROR(GetProgramInfo, program, param_namePacked, param_value_size,
517                             param_value, param_value_size_ret);
518 
519     return GetProgramInfo(program, param_namePacked, param_value_size, param_value,
520                           param_value_size_ret);
521 }
522 
clGetProgramBuildInfo(cl_program program,cl_device_id device,cl_program_build_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)523 cl_int CL_API_CALL clGetProgramBuildInfo(cl_program program,
524                                          cl_device_id device,
525                                          cl_program_build_info param_name,
526                                          size_t param_value_size,
527                                          void *param_value,
528                                          size_t *param_value_size_ret)
529 {
530     CL_EVENT(GetProgramBuildInfo,
531              "program = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR
532              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
533              ", param_value_size_ret = 0x%016" PRIxPTR "",
534              (uintptr_t)program, (uintptr_t)device, param_name, param_value_size,
535              (uintptr_t)param_value, (uintptr_t)param_value_size_ret);
536 
537     ProgramBuildInfo param_namePacked = PackParam<ProgramBuildInfo>(param_name);
538 
539     ANGLE_CL_VALIDATE_ERROR(GetProgramBuildInfo, program, device, param_namePacked,
540                             param_value_size, param_value, param_value_size_ret);
541 
542     return GetProgramBuildInfo(program, device, param_namePacked, param_value_size, param_value,
543                                param_value_size_ret);
544 }
545 
clCreateKernel(cl_program program,const char * kernel_name,cl_int * errcode_ret)546 cl_kernel CL_API_CALL clCreateKernel(cl_program program,
547                                      const char *kernel_name,
548                                      cl_int *errcode_ret)
549 {
550     CL_EVENT(CreateKernel,
551              "program = 0x%016" PRIxPTR ", kernel_name = 0x%016" PRIxPTR
552              ", errcode_ret = 0x%016" PRIxPTR "",
553              (uintptr_t)program, (uintptr_t)kernel_name, (uintptr_t)errcode_ret);
554 
555     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateKernel, program, kernel_name);
556 
557     cl_int errorCode = CL_SUCCESS;
558     cl_kernel object = CreateKernel(program, kernel_name, errorCode);
559 
560     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
561     if (errcode_ret != nullptr)
562     {
563         *errcode_ret = errorCode;
564     }
565     return object;
566 }
567 
clCreateKernelsInProgram(cl_program program,cl_uint num_kernels,cl_kernel * kernels,cl_uint * num_kernels_ret)568 cl_int CL_API_CALL clCreateKernelsInProgram(cl_program program,
569                                             cl_uint num_kernels,
570                                             cl_kernel *kernels,
571                                             cl_uint *num_kernels_ret)
572 {
573     CL_EVENT(CreateKernelsInProgram,
574              "program = 0x%016" PRIxPTR ", num_kernels = %u, kernels = 0x%016" PRIxPTR
575              ", num_kernels_ret = 0x%016" PRIxPTR "",
576              (uintptr_t)program, num_kernels, (uintptr_t)kernels, (uintptr_t)num_kernels_ret);
577 
578     ANGLE_CL_VALIDATE_ERROR(CreateKernelsInProgram, program, num_kernels, kernels, num_kernels_ret);
579 
580     return CreateKernelsInProgram(program, num_kernels, kernels, num_kernels_ret);
581 }
582 
clRetainKernel(cl_kernel kernel)583 cl_int CL_API_CALL clRetainKernel(cl_kernel kernel)
584 {
585     CL_EVENT(RetainKernel, "kernel = 0x%016" PRIxPTR "", (uintptr_t)kernel);
586 
587     ANGLE_CL_VALIDATE_ERROR(RetainKernel, kernel);
588 
589     return RetainKernel(kernel);
590 }
591 
clReleaseKernel(cl_kernel kernel)592 cl_int CL_API_CALL clReleaseKernel(cl_kernel kernel)
593 {
594     CL_EVENT(ReleaseKernel, "kernel = 0x%016" PRIxPTR "", (uintptr_t)kernel);
595 
596     ANGLE_CL_VALIDATE_ERROR(ReleaseKernel, kernel);
597 
598     return ReleaseKernel(kernel);
599 }
600 
clSetKernelArg(cl_kernel kernel,cl_uint arg_index,size_t arg_size,const void * arg_value)601 cl_int CL_API_CALL clSetKernelArg(cl_kernel kernel,
602                                   cl_uint arg_index,
603                                   size_t arg_size,
604                                   const void *arg_value)
605 {
606     CL_EVENT(SetKernelArg,
607              "kernel = 0x%016" PRIxPTR
608              ", arg_index = %u, arg_size = %zu, arg_value = 0x%016" PRIxPTR "",
609              (uintptr_t)kernel, arg_index, arg_size, (uintptr_t)arg_value);
610 
611     ANGLE_CL_VALIDATE_ERROR(SetKernelArg, kernel, arg_index, arg_size, arg_value);
612 
613     return SetKernelArg(kernel, arg_index, arg_size, arg_value);
614 }
615 
clGetKernelInfo(cl_kernel kernel,cl_kernel_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)616 cl_int CL_API_CALL clGetKernelInfo(cl_kernel kernel,
617                                    cl_kernel_info param_name,
618                                    size_t param_value_size,
619                                    void *param_value,
620                                    size_t *param_value_size_ret)
621 {
622     CL_EVENT(GetKernelInfo,
623              "kernel = 0x%016" PRIxPTR
624              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
625              ", param_value_size_ret = 0x%016" PRIxPTR "",
626              (uintptr_t)kernel, param_name, param_value_size, (uintptr_t)param_value,
627              (uintptr_t)param_value_size_ret);
628 
629     KernelInfo param_namePacked = PackParam<KernelInfo>(param_name);
630 
631     ANGLE_CL_VALIDATE_ERROR(GetKernelInfo, kernel, param_namePacked, param_value_size, param_value,
632                             param_value_size_ret);
633 
634     return GetKernelInfo(kernel, param_namePacked, param_value_size, param_value,
635                          param_value_size_ret);
636 }
637 
clGetKernelWorkGroupInfo(cl_kernel kernel,cl_device_id device,cl_kernel_work_group_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)638 cl_int CL_API_CALL clGetKernelWorkGroupInfo(cl_kernel kernel,
639                                             cl_device_id device,
640                                             cl_kernel_work_group_info param_name,
641                                             size_t param_value_size,
642                                             void *param_value,
643                                             size_t *param_value_size_ret)
644 {
645     CL_EVENT(GetKernelWorkGroupInfo,
646              "kernel = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR
647              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
648              ", param_value_size_ret = 0x%016" PRIxPTR "",
649              (uintptr_t)kernel, (uintptr_t)device, param_name, param_value_size,
650              (uintptr_t)param_value, (uintptr_t)param_value_size_ret);
651 
652     KernelWorkGroupInfo param_namePacked = PackParam<KernelWorkGroupInfo>(param_name);
653 
654     ANGLE_CL_VALIDATE_ERROR(GetKernelWorkGroupInfo, kernel, device, param_namePacked,
655                             param_value_size, param_value, param_value_size_ret);
656 
657     return GetKernelWorkGroupInfo(kernel, device, param_namePacked, param_value_size, param_value,
658                                   param_value_size_ret);
659 }
660 
clWaitForEvents(cl_uint num_events,const cl_event * event_list)661 cl_int CL_API_CALL clWaitForEvents(cl_uint num_events, const cl_event *event_list)
662 {
663     CL_EVENT(WaitForEvents, "num_events = %u, event_list = 0x%016" PRIxPTR "", num_events,
664              (uintptr_t)event_list);
665 
666     ANGLE_CL_VALIDATE_ERROR(WaitForEvents, num_events, event_list);
667 
668     return WaitForEvents(num_events, event_list);
669 }
670 
clGetEventInfo(cl_event event,cl_event_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)671 cl_int CL_API_CALL clGetEventInfo(cl_event event,
672                                   cl_event_info param_name,
673                                   size_t param_value_size,
674                                   void *param_value,
675                                   size_t *param_value_size_ret)
676 {
677     CL_EVENT(GetEventInfo,
678              "event = 0x%016" PRIxPTR
679              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
680              ", param_value_size_ret = 0x%016" PRIxPTR "",
681              (uintptr_t)event, param_name, param_value_size, (uintptr_t)param_value,
682              (uintptr_t)param_value_size_ret);
683 
684     EventInfo param_namePacked = PackParam<EventInfo>(param_name);
685 
686     ANGLE_CL_VALIDATE_ERROR(GetEventInfo, event, param_namePacked, param_value_size, param_value,
687                             param_value_size_ret);
688 
689     return GetEventInfo(event, param_namePacked, param_value_size, param_value,
690                         param_value_size_ret);
691 }
692 
clRetainEvent(cl_event event)693 cl_int CL_API_CALL clRetainEvent(cl_event event)
694 {
695     CL_EVENT(RetainEvent, "event = 0x%016" PRIxPTR "", (uintptr_t)event);
696 
697     ANGLE_CL_VALIDATE_ERROR(RetainEvent, event);
698 
699     return RetainEvent(event);
700 }
701 
clReleaseEvent(cl_event event)702 cl_int CL_API_CALL clReleaseEvent(cl_event event)
703 {
704     CL_EVENT(ReleaseEvent, "event = 0x%016" PRIxPTR "", (uintptr_t)event);
705 
706     ANGLE_CL_VALIDATE_ERROR(ReleaseEvent, event);
707 
708     return ReleaseEvent(event);
709 }
710 
clGetEventProfilingInfo(cl_event event,cl_profiling_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)711 cl_int CL_API_CALL clGetEventProfilingInfo(cl_event event,
712                                            cl_profiling_info param_name,
713                                            size_t param_value_size,
714                                            void *param_value,
715                                            size_t *param_value_size_ret)
716 {
717     CL_EVENT(GetEventProfilingInfo,
718              "event = 0x%016" PRIxPTR
719              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
720              ", param_value_size_ret = 0x%016" PRIxPTR "",
721              (uintptr_t)event, param_name, param_value_size, (uintptr_t)param_value,
722              (uintptr_t)param_value_size_ret);
723 
724     ProfilingInfo param_namePacked = PackParam<ProfilingInfo>(param_name);
725 
726     ANGLE_CL_VALIDATE_ERROR(GetEventProfilingInfo, event, param_namePacked, param_value_size,
727                             param_value, param_value_size_ret);
728 
729     return GetEventProfilingInfo(event, param_namePacked, param_value_size, param_value,
730                                  param_value_size_ret);
731 }
732 
clFlush(cl_command_queue command_queue)733 cl_int CL_API_CALL clFlush(cl_command_queue command_queue)
734 {
735     CL_EVENT(Flush, "command_queue = 0x%016" PRIxPTR "", (uintptr_t)command_queue);
736 
737     ANGLE_CL_VALIDATE_ERROR(Flush, command_queue);
738 
739     return Flush(command_queue);
740 }
741 
clFinish(cl_command_queue command_queue)742 cl_int CL_API_CALL clFinish(cl_command_queue command_queue)
743 {
744     CL_EVENT(Finish, "command_queue = 0x%016" PRIxPTR "", (uintptr_t)command_queue);
745 
746     ANGLE_CL_VALIDATE_ERROR(Finish, command_queue);
747 
748     return Finish(command_queue);
749 }
750 
clEnqueueReadBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_read,size_t offset,size_t size,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)751 cl_int CL_API_CALL clEnqueueReadBuffer(cl_command_queue command_queue,
752                                        cl_mem buffer,
753                                        cl_bool blocking_read,
754                                        size_t offset,
755                                        size_t size,
756                                        void *ptr,
757                                        cl_uint num_events_in_wait_list,
758                                        const cl_event *event_wait_list,
759                                        cl_event *event)
760 {
761     CL_EVENT(EnqueueReadBuffer,
762              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
763              ", blocking_read = %u, offset = %zu, size = %zu, ptr = 0x%016" PRIxPTR
764              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
765              ", event = 0x%016" PRIxPTR "",
766              (uintptr_t)command_queue, (uintptr_t)buffer, blocking_read, offset, size,
767              (uintptr_t)ptr, num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
768 
769     ANGLE_CL_VALIDATE_ERROR(EnqueueReadBuffer, command_queue, buffer, blocking_read, offset, size,
770                             ptr, num_events_in_wait_list, event_wait_list, event);
771 
772     return EnqueueReadBuffer(command_queue, buffer, blocking_read, offset, size, ptr,
773                              num_events_in_wait_list, event_wait_list, event);
774 }
775 
clEnqueueWriteBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,size_t offset,size_t size,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)776 cl_int CL_API_CALL clEnqueueWriteBuffer(cl_command_queue command_queue,
777                                         cl_mem buffer,
778                                         cl_bool blocking_write,
779                                         size_t offset,
780                                         size_t size,
781                                         const void *ptr,
782                                         cl_uint num_events_in_wait_list,
783                                         const cl_event *event_wait_list,
784                                         cl_event *event)
785 {
786     CL_EVENT(EnqueueWriteBuffer,
787              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
788              ", blocking_write = %u, offset = %zu, size = %zu, ptr = 0x%016" PRIxPTR
789              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
790              ", event = 0x%016" PRIxPTR "",
791              (uintptr_t)command_queue, (uintptr_t)buffer, blocking_write, offset, size,
792              (uintptr_t)ptr, num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
793 
794     ANGLE_CL_VALIDATE_ERROR(EnqueueWriteBuffer, command_queue, buffer, blocking_write, offset, size,
795                             ptr, num_events_in_wait_list, event_wait_list, event);
796 
797     return EnqueueWriteBuffer(command_queue, buffer, blocking_write, offset, size, ptr,
798                               num_events_in_wait_list, event_wait_list, event);
799 }
800 
clEnqueueCopyBuffer(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_buffer,size_t src_offset,size_t dst_offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)801 cl_int CL_API_CALL clEnqueueCopyBuffer(cl_command_queue command_queue,
802                                        cl_mem src_buffer,
803                                        cl_mem dst_buffer,
804                                        size_t src_offset,
805                                        size_t dst_offset,
806                                        size_t size,
807                                        cl_uint num_events_in_wait_list,
808                                        const cl_event *event_wait_list,
809                                        cl_event *event)
810 {
811     CL_EVENT(EnqueueCopyBuffer,
812              "command_queue = 0x%016" PRIxPTR ", src_buffer = 0x%016" PRIxPTR
813              ", dst_buffer = 0x%016" PRIxPTR
814              ", src_offset = %zu, dst_offset = %zu, size = %zu, num_events_in_wait_list = %u, "
815              "event_wait_list = 0x%016" PRIxPTR ", event = 0x%016" PRIxPTR "",
816              (uintptr_t)command_queue, (uintptr_t)src_buffer, (uintptr_t)dst_buffer, src_offset,
817              dst_offset, size, num_events_in_wait_list, (uintptr_t)event_wait_list,
818              (uintptr_t)event);
819 
820     ANGLE_CL_VALIDATE_ERROR(EnqueueCopyBuffer, command_queue, src_buffer, dst_buffer, src_offset,
821                             dst_offset, size, num_events_in_wait_list, event_wait_list, event);
822 
823     return EnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size,
824                              num_events_in_wait_list, event_wait_list, event);
825 }
826 
clEnqueueReadImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_read,const size_t * origin,const size_t * region,size_t row_pitch,size_t slice_pitch,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)827 cl_int CL_API_CALL clEnqueueReadImage(cl_command_queue command_queue,
828                                       cl_mem image,
829                                       cl_bool blocking_read,
830                                       const size_t *origin,
831                                       const size_t *region,
832                                       size_t row_pitch,
833                                       size_t slice_pitch,
834                                       void *ptr,
835                                       cl_uint num_events_in_wait_list,
836                                       const cl_event *event_wait_list,
837                                       cl_event *event)
838 {
839     CL_EVENT(EnqueueReadImage,
840              "command_queue = 0x%016" PRIxPTR ", image = 0x%016" PRIxPTR
841              ", blocking_read = %u, origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
842              ", row_pitch = %zu, slice_pitch = %zu, ptr = 0x%016" PRIxPTR
843              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
844              ", event = 0x%016" PRIxPTR "",
845              (uintptr_t)command_queue, (uintptr_t)image, blocking_read, (uintptr_t)origin,
846              (uintptr_t)region, row_pitch, slice_pitch, (uintptr_t)ptr, num_events_in_wait_list,
847              (uintptr_t)event_wait_list, (uintptr_t)event);
848 
849     ANGLE_CL_VALIDATE_ERROR(EnqueueReadImage, command_queue, image, blocking_read, origin, region,
850                             row_pitch, slice_pitch, ptr, num_events_in_wait_list, event_wait_list,
851                             event);
852 
853     return EnqueueReadImage(command_queue, image, blocking_read, origin, region, row_pitch,
854                             slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event);
855 }
856 
clEnqueueWriteImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_write,const size_t * origin,const size_t * region,size_t input_row_pitch,size_t input_slice_pitch,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)857 cl_int CL_API_CALL clEnqueueWriteImage(cl_command_queue command_queue,
858                                        cl_mem image,
859                                        cl_bool blocking_write,
860                                        const size_t *origin,
861                                        const size_t *region,
862                                        size_t input_row_pitch,
863                                        size_t input_slice_pitch,
864                                        const void *ptr,
865                                        cl_uint num_events_in_wait_list,
866                                        const cl_event *event_wait_list,
867                                        cl_event *event)
868 {
869     CL_EVENT(EnqueueWriteImage,
870              "command_queue = 0x%016" PRIxPTR ", image = 0x%016" PRIxPTR
871              ", blocking_write = %u, origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
872              ", input_row_pitch = %zu, input_slice_pitch = %zu, ptr = 0x%016" PRIxPTR
873              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
874              ", event = 0x%016" PRIxPTR "",
875              (uintptr_t)command_queue, (uintptr_t)image, blocking_write, (uintptr_t)origin,
876              (uintptr_t)region, input_row_pitch, input_slice_pitch, (uintptr_t)ptr,
877              num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
878 
879     ANGLE_CL_VALIDATE_ERROR(EnqueueWriteImage, command_queue, image, blocking_write, origin, region,
880                             input_row_pitch, input_slice_pitch, ptr, num_events_in_wait_list,
881                             event_wait_list, event);
882 
883     return EnqueueWriteImage(command_queue, image, blocking_write, origin, region, input_row_pitch,
884                              input_slice_pitch, ptr, num_events_in_wait_list, event_wait_list,
885                              event);
886 }
887 
clEnqueueCopyImage(cl_command_queue command_queue,cl_mem src_image,cl_mem dst_image,const size_t * src_origin,const size_t * dst_origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)888 cl_int CL_API_CALL clEnqueueCopyImage(cl_command_queue command_queue,
889                                       cl_mem src_image,
890                                       cl_mem dst_image,
891                                       const size_t *src_origin,
892                                       const size_t *dst_origin,
893                                       const size_t *region,
894                                       cl_uint num_events_in_wait_list,
895                                       const cl_event *event_wait_list,
896                                       cl_event *event)
897 {
898     CL_EVENT(EnqueueCopyImage,
899              "command_queue = 0x%016" PRIxPTR ", src_image = 0x%016" PRIxPTR
900              ", dst_image = 0x%016" PRIxPTR ", src_origin = 0x%016" PRIxPTR
901              ", dst_origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
902              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
903              ", event = 0x%016" PRIxPTR "",
904              (uintptr_t)command_queue, (uintptr_t)src_image, (uintptr_t)dst_image,
905              (uintptr_t)src_origin, (uintptr_t)dst_origin, (uintptr_t)region,
906              num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
907 
908     ANGLE_CL_VALIDATE_ERROR(EnqueueCopyImage, command_queue, src_image, dst_image, src_origin,
909                             dst_origin, region, num_events_in_wait_list, event_wait_list, event);
910 
911     return EnqueueCopyImage(command_queue, src_image, dst_image, src_origin, dst_origin, region,
912                             num_events_in_wait_list, event_wait_list, event);
913 }
914 
clEnqueueCopyImageToBuffer(cl_command_queue command_queue,cl_mem src_image,cl_mem dst_buffer,const size_t * src_origin,const size_t * region,size_t dst_offset,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)915 cl_int CL_API_CALL clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
916                                               cl_mem src_image,
917                                               cl_mem dst_buffer,
918                                               const size_t *src_origin,
919                                               const size_t *region,
920                                               size_t dst_offset,
921                                               cl_uint num_events_in_wait_list,
922                                               const cl_event *event_wait_list,
923                                               cl_event *event)
924 {
925     CL_EVENT(EnqueueCopyImageToBuffer,
926              "command_queue = 0x%016" PRIxPTR ", src_image = 0x%016" PRIxPTR
927              ", dst_buffer = 0x%016" PRIxPTR ", src_origin = 0x%016" PRIxPTR
928              ", region = 0x%016" PRIxPTR
929              ", dst_offset = %zu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
930              ", event = 0x%016" PRIxPTR "",
931              (uintptr_t)command_queue, (uintptr_t)src_image, (uintptr_t)dst_buffer,
932              (uintptr_t)src_origin, (uintptr_t)region, dst_offset, num_events_in_wait_list,
933              (uintptr_t)event_wait_list, (uintptr_t)event);
934 
935     ANGLE_CL_VALIDATE_ERROR(EnqueueCopyImageToBuffer, command_queue, src_image, dst_buffer,
936                             src_origin, region, dst_offset, num_events_in_wait_list,
937                             event_wait_list, event);
938 
939     return EnqueueCopyImageToBuffer(command_queue, src_image, dst_buffer, src_origin, region,
940                                     dst_offset, num_events_in_wait_list, event_wait_list, event);
941 }
942 
clEnqueueCopyBufferToImage(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_image,size_t src_offset,const size_t * dst_origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)943 cl_int CL_API_CALL clEnqueueCopyBufferToImage(cl_command_queue command_queue,
944                                               cl_mem src_buffer,
945                                               cl_mem dst_image,
946                                               size_t src_offset,
947                                               const size_t *dst_origin,
948                                               const size_t *region,
949                                               cl_uint num_events_in_wait_list,
950                                               const cl_event *event_wait_list,
951                                               cl_event *event)
952 {
953     CL_EVENT(EnqueueCopyBufferToImage,
954              "command_queue = 0x%016" PRIxPTR ", src_buffer = 0x%016" PRIxPTR
955              ", dst_image = 0x%016" PRIxPTR ", src_offset = %zu, dst_origin = 0x%016" PRIxPTR
956              ", region = 0x%016" PRIxPTR
957              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
958              ", event = 0x%016" PRIxPTR "",
959              (uintptr_t)command_queue, (uintptr_t)src_buffer, (uintptr_t)dst_image, src_offset,
960              (uintptr_t)dst_origin, (uintptr_t)region, num_events_in_wait_list,
961              (uintptr_t)event_wait_list, (uintptr_t)event);
962 
963     ANGLE_CL_VALIDATE_ERROR(EnqueueCopyBufferToImage, command_queue, src_buffer, dst_image,
964                             src_offset, dst_origin, region, num_events_in_wait_list,
965                             event_wait_list, event);
966 
967     return EnqueueCopyBufferToImage(command_queue, src_buffer, dst_image, src_offset, dst_origin,
968                                     region, num_events_in_wait_list, event_wait_list, event);
969 }
970 
clEnqueueMapBuffer(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_map,cl_map_flags map_flags,size_t offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event,cl_int * errcode_ret)971 void *CL_API_CALL clEnqueueMapBuffer(cl_command_queue command_queue,
972                                      cl_mem buffer,
973                                      cl_bool blocking_map,
974                                      cl_map_flags map_flags,
975                                      size_t offset,
976                                      size_t size,
977                                      cl_uint num_events_in_wait_list,
978                                      const cl_event *event_wait_list,
979                                      cl_event *event,
980                                      cl_int *errcode_ret)
981 {
982     CL_EVENT(EnqueueMapBuffer,
983              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
984              ", blocking_map = %u, map_flags = %llu, offset = %zu, size = %zu, "
985              "num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
986              ", event = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
987              (uintptr_t)command_queue, (uintptr_t)buffer, blocking_map,
988              static_cast<unsigned long long>(map_flags), offset, size, num_events_in_wait_list,
989              (uintptr_t)event_wait_list, (uintptr_t)event, (uintptr_t)errcode_ret);
990 
991     MapFlags map_flagsPacked = PackParam<MapFlags>(map_flags);
992 
993     ANGLE_CL_VALIDATE_ERRCODE_RET(EnqueueMapBuffer, command_queue, buffer, blocking_map,
994                                   map_flagsPacked, offset, size, num_events_in_wait_list,
995                                   event_wait_list, event);
996 
997     cl_int errorCode = CL_SUCCESS;
998     void *object =
999         EnqueueMapBuffer(command_queue, buffer, blocking_map, map_flagsPacked, offset, size,
1000                          num_events_in_wait_list, event_wait_list, event, errorCode);
1001 
1002     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1003     if (errcode_ret != nullptr)
1004     {
1005         *errcode_ret = errorCode;
1006     }
1007     return object;
1008 }
1009 
clEnqueueMapImage(cl_command_queue command_queue,cl_mem image,cl_bool blocking_map,cl_map_flags map_flags,const size_t * origin,const size_t * region,size_t * image_row_pitch,size_t * image_slice_pitch,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event,cl_int * errcode_ret)1010 void *CL_API_CALL clEnqueueMapImage(cl_command_queue command_queue,
1011                                     cl_mem image,
1012                                     cl_bool blocking_map,
1013                                     cl_map_flags map_flags,
1014                                     const size_t *origin,
1015                                     const size_t *region,
1016                                     size_t *image_row_pitch,
1017                                     size_t *image_slice_pitch,
1018                                     cl_uint num_events_in_wait_list,
1019                                     const cl_event *event_wait_list,
1020                                     cl_event *event,
1021                                     cl_int *errcode_ret)
1022 {
1023     CL_EVENT(EnqueueMapImage,
1024              "command_queue = 0x%016" PRIxPTR ", image = 0x%016" PRIxPTR
1025              ", blocking_map = %u, map_flags = %llu, origin = 0x%016" PRIxPTR
1026              ", region = 0x%016" PRIxPTR ", image_row_pitch = 0x%016" PRIxPTR
1027              ", image_slice_pitch = 0x%016" PRIxPTR
1028              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1029              ", event = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
1030              (uintptr_t)command_queue, (uintptr_t)image, blocking_map,
1031              static_cast<unsigned long long>(map_flags), (uintptr_t)origin, (uintptr_t)region,
1032              (uintptr_t)image_row_pitch, (uintptr_t)image_slice_pitch, num_events_in_wait_list,
1033              (uintptr_t)event_wait_list, (uintptr_t)event, (uintptr_t)errcode_ret);
1034 
1035     MapFlags map_flagsPacked = PackParam<MapFlags>(map_flags);
1036 
1037     ANGLE_CL_VALIDATE_ERRCODE_RET(
1038         EnqueueMapImage, command_queue, image, blocking_map, map_flagsPacked, origin, region,
1039         image_row_pitch, image_slice_pitch, num_events_in_wait_list, event_wait_list, event);
1040 
1041     cl_int errorCode = CL_SUCCESS;
1042     void *object     = EnqueueMapImage(command_queue, image, blocking_map, map_flagsPacked, origin,
1043                                    region, image_row_pitch, image_slice_pitch,
1044                                    num_events_in_wait_list, event_wait_list, event, errorCode);
1045 
1046     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1047     if (errcode_ret != nullptr)
1048     {
1049         *errcode_ret = errorCode;
1050     }
1051     return object;
1052 }
1053 
clEnqueueUnmapMemObject(cl_command_queue command_queue,cl_mem memobj,void * mapped_ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1054 cl_int CL_API_CALL clEnqueueUnmapMemObject(cl_command_queue command_queue,
1055                                            cl_mem memobj,
1056                                            void *mapped_ptr,
1057                                            cl_uint num_events_in_wait_list,
1058                                            const cl_event *event_wait_list,
1059                                            cl_event *event)
1060 {
1061     CL_EVENT(EnqueueUnmapMemObject,
1062              "command_queue = 0x%016" PRIxPTR ", memobj = 0x%016" PRIxPTR
1063              ", mapped_ptr = 0x%016" PRIxPTR
1064              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1065              ", event = 0x%016" PRIxPTR "",
1066              (uintptr_t)command_queue, (uintptr_t)memobj, (uintptr_t)mapped_ptr,
1067              num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
1068 
1069     ANGLE_CL_VALIDATE_ERROR(EnqueueUnmapMemObject, command_queue, memobj, mapped_ptr,
1070                             num_events_in_wait_list, event_wait_list, event);
1071 
1072     return EnqueueUnmapMemObject(command_queue, memobj, mapped_ptr, num_events_in_wait_list,
1073                                  event_wait_list, event);
1074 }
1075 
clEnqueueNDRangeKernel(cl_command_queue command_queue,cl_kernel kernel,cl_uint work_dim,const size_t * global_work_offset,const size_t * global_work_size,const size_t * local_work_size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1076 cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue command_queue,
1077                                           cl_kernel kernel,
1078                                           cl_uint work_dim,
1079                                           const size_t *global_work_offset,
1080                                           const size_t *global_work_size,
1081                                           const size_t *local_work_size,
1082                                           cl_uint num_events_in_wait_list,
1083                                           const cl_event *event_wait_list,
1084                                           cl_event *event)
1085 {
1086     CL_EVENT(EnqueueNDRangeKernel,
1087              "command_queue = 0x%016" PRIxPTR ", kernel = 0x%016" PRIxPTR
1088              ", work_dim = %u, global_work_offset = 0x%016" PRIxPTR
1089              ", global_work_size = 0x%016" PRIxPTR ", local_work_size = 0x%016" PRIxPTR
1090              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1091              ", event = 0x%016" PRIxPTR "",
1092              (uintptr_t)command_queue, (uintptr_t)kernel, work_dim, (uintptr_t)global_work_offset,
1093              (uintptr_t)global_work_size, (uintptr_t)local_work_size, num_events_in_wait_list,
1094              (uintptr_t)event_wait_list, (uintptr_t)event);
1095 
1096     ANGLE_CL_VALIDATE_ERROR(EnqueueNDRangeKernel, command_queue, kernel, work_dim,
1097                             global_work_offset, global_work_size, local_work_size,
1098                             num_events_in_wait_list, event_wait_list, event);
1099 
1100     return EnqueueNDRangeKernel(command_queue, kernel, work_dim, global_work_offset,
1101                                 global_work_size, local_work_size, num_events_in_wait_list,
1102                                 event_wait_list, event);
1103 }
1104 
clEnqueueNativeKernel(cl_command_queue command_queue,void (CL_CALLBACK * user_func)(void *),void * args,size_t cb_args,cl_uint num_mem_objects,const cl_mem * mem_list,const void ** args_mem_loc,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1105 cl_int CL_API_CALL clEnqueueNativeKernel(cl_command_queue command_queue,
1106                                          void(CL_CALLBACK *user_func)(void *),
1107                                          void *args,
1108                                          size_t cb_args,
1109                                          cl_uint num_mem_objects,
1110                                          const cl_mem *mem_list,
1111                                          const void **args_mem_loc,
1112                                          cl_uint num_events_in_wait_list,
1113                                          const cl_event *event_wait_list,
1114                                          cl_event *event)
1115 {
1116     CL_EVENT(EnqueueNativeKernel,
1117              "command_queue = 0x%016" PRIxPTR ", user_func = 0x%016" PRIxPTR
1118              ", args = 0x%016" PRIxPTR
1119              ", cb_args = %zu, num_mem_objects = %u, mem_list = 0x%016" PRIxPTR
1120              ", args_mem_loc = 0x%016" PRIxPTR
1121              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1122              ", event = 0x%016" PRIxPTR "",
1123              (uintptr_t)command_queue, (uintptr_t)user_func, (uintptr_t)args, cb_args,
1124              num_mem_objects, (uintptr_t)mem_list, (uintptr_t)args_mem_loc, num_events_in_wait_list,
1125              (uintptr_t)event_wait_list, (uintptr_t)event);
1126 
1127     ANGLE_CL_VALIDATE_ERROR(EnqueueNativeKernel, command_queue, user_func, args, cb_args,
1128                             num_mem_objects, mem_list, args_mem_loc, num_events_in_wait_list,
1129                             event_wait_list, event);
1130 
1131     return EnqueueNativeKernel(command_queue, user_func, args, cb_args, num_mem_objects, mem_list,
1132                                args_mem_loc, num_events_in_wait_list, event_wait_list, event);
1133 }
1134 
clSetCommandQueueProperty(cl_command_queue command_queue,cl_command_queue_properties properties,cl_bool enable,cl_command_queue_properties * old_properties)1135 cl_int CL_API_CALL clSetCommandQueueProperty(cl_command_queue command_queue,
1136                                              cl_command_queue_properties properties,
1137                                              cl_bool enable,
1138                                              cl_command_queue_properties *old_properties)
1139 {
1140     CL_EVENT(SetCommandQueueProperty,
1141              "command_queue = 0x%016" PRIxPTR
1142              ", properties = %llu, enable = %u, old_properties = 0x%016" PRIxPTR "",
1143              (uintptr_t)command_queue, static_cast<unsigned long long>(properties), enable,
1144              (uintptr_t)old_properties);
1145 
1146     CommandQueueProperties propertiesPacked = PackParam<CommandQueueProperties>(properties);
1147 
1148     ANGLE_CL_VALIDATE_ERROR(SetCommandQueueProperty, command_queue, propertiesPacked, enable,
1149                             old_properties);
1150 
1151     return SetCommandQueueProperty(command_queue, propertiesPacked, enable, old_properties);
1152 }
1153 
clCreateImage2D(cl_context context,cl_mem_flags flags,const cl_image_format * image_format,size_t image_width,size_t image_height,size_t image_row_pitch,void * host_ptr,cl_int * errcode_ret)1154 cl_mem CL_API_CALL clCreateImage2D(cl_context context,
1155                                    cl_mem_flags flags,
1156                                    const cl_image_format *image_format,
1157                                    size_t image_width,
1158                                    size_t image_height,
1159                                    size_t image_row_pitch,
1160                                    void *host_ptr,
1161                                    cl_int *errcode_ret)
1162 {
1163     CL_EVENT(
1164         CreateImage2D,
1165         "context = 0x%016" PRIxPTR ", flags = %llu, image_format = 0x%016" PRIxPTR
1166         ", image_width = %zu, image_height = %zu, image_row_pitch = %zu, host_ptr = 0x%016" PRIxPTR
1167         ", errcode_ret = 0x%016" PRIxPTR "",
1168         (uintptr_t)context, static_cast<unsigned long long>(flags), (uintptr_t)image_format,
1169         image_width, image_height, image_row_pitch, (uintptr_t)host_ptr, (uintptr_t)errcode_ret);
1170 
1171     MemFlags flagsPacked = PackParam<MemFlags>(flags);
1172 
1173     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateImage2D, context, flagsPacked, image_format, image_width,
1174                                   image_height, image_row_pitch, host_ptr);
1175 
1176     cl_int errorCode = CL_SUCCESS;
1177     cl_mem object    = CreateImage2D(context, flagsPacked, image_format, image_width, image_height,
1178                                   image_row_pitch, host_ptr, errorCode);
1179 
1180     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1181     if (errcode_ret != nullptr)
1182     {
1183         *errcode_ret = errorCode;
1184     }
1185     return object;
1186 }
1187 
clCreateImage3D(cl_context context,cl_mem_flags flags,const cl_image_format * image_format,size_t image_width,size_t image_height,size_t image_depth,size_t image_row_pitch,size_t image_slice_pitch,void * host_ptr,cl_int * errcode_ret)1188 cl_mem CL_API_CALL clCreateImage3D(cl_context context,
1189                                    cl_mem_flags flags,
1190                                    const cl_image_format *image_format,
1191                                    size_t image_width,
1192                                    size_t image_height,
1193                                    size_t image_depth,
1194                                    size_t image_row_pitch,
1195                                    size_t image_slice_pitch,
1196                                    void *host_ptr,
1197                                    cl_int *errcode_ret)
1198 {
1199     CL_EVENT(CreateImage3D,
1200              "context = 0x%016" PRIxPTR ", flags = %llu, image_format = 0x%016" PRIxPTR
1201              ", image_width = %zu, image_height = %zu, image_depth = %zu, image_row_pitch = %zu, "
1202              "image_slice_pitch = %zu, host_ptr = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR
1203              "",
1204              (uintptr_t)context, static_cast<unsigned long long>(flags), (uintptr_t)image_format,
1205              image_width, image_height, image_depth, image_row_pitch, image_slice_pitch,
1206              (uintptr_t)host_ptr, (uintptr_t)errcode_ret);
1207 
1208     MemFlags flagsPacked = PackParam<MemFlags>(flags);
1209 
1210     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateImage3D, context, flagsPacked, image_format, image_width,
1211                                   image_height, image_depth, image_row_pitch, image_slice_pitch,
1212                                   host_ptr);
1213 
1214     cl_int errorCode = CL_SUCCESS;
1215     cl_mem object =
1216         CreateImage3D(context, flagsPacked, image_format, image_width, image_height, image_depth,
1217                       image_row_pitch, image_slice_pitch, host_ptr, errorCode);
1218 
1219     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1220     if (errcode_ret != nullptr)
1221     {
1222         *errcode_ret = errorCode;
1223     }
1224     return object;
1225 }
1226 
clEnqueueMarker(cl_command_queue command_queue,cl_event * event)1227 cl_int CL_API_CALL clEnqueueMarker(cl_command_queue command_queue, cl_event *event)
1228 {
1229     CL_EVENT(EnqueueMarker, "command_queue = 0x%016" PRIxPTR ", event = 0x%016" PRIxPTR "",
1230              (uintptr_t)command_queue, (uintptr_t)event);
1231 
1232     ANGLE_CL_VALIDATE_ERROR(EnqueueMarker, command_queue, event);
1233 
1234     return EnqueueMarker(command_queue, event);
1235 }
1236 
clEnqueueWaitForEvents(cl_command_queue command_queue,cl_uint num_events,const cl_event * event_list)1237 cl_int CL_API_CALL clEnqueueWaitForEvents(cl_command_queue command_queue,
1238                                           cl_uint num_events,
1239                                           const cl_event *event_list)
1240 {
1241     CL_EVENT(EnqueueWaitForEvents,
1242              "command_queue = 0x%016" PRIxPTR ", num_events = %u, event_list = 0x%016" PRIxPTR "",
1243              (uintptr_t)command_queue, num_events, (uintptr_t)event_list);
1244 
1245     ANGLE_CL_VALIDATE_ERROR(EnqueueWaitForEvents, command_queue, num_events, event_list);
1246 
1247     return EnqueueWaitForEvents(command_queue, num_events, event_list);
1248 }
1249 
clEnqueueBarrier(cl_command_queue command_queue)1250 cl_int CL_API_CALL clEnqueueBarrier(cl_command_queue command_queue)
1251 {
1252     CL_EVENT(EnqueueBarrier, "command_queue = 0x%016" PRIxPTR "", (uintptr_t)command_queue);
1253 
1254     ANGLE_CL_VALIDATE_ERROR(EnqueueBarrier, command_queue);
1255 
1256     return EnqueueBarrier(command_queue);
1257 }
1258 
clUnloadCompiler()1259 cl_int CL_API_CALL clUnloadCompiler()
1260 {
1261     CL_EVENT(UnloadCompiler, "");
1262 
1263     ANGLE_CL_VALIDATE_ERROR(UnloadCompiler);
1264 
1265     return UnloadCompiler();
1266 }
1267 
clGetExtensionFunctionAddress(const char * func_name)1268 void *CL_API_CALL clGetExtensionFunctionAddress(const char *func_name)
1269 {
1270     CL_EVENT(GetExtensionFunctionAddress, "func_name = 0x%016" PRIxPTR "", (uintptr_t)func_name);
1271 
1272     ANGLE_CL_VALIDATE_POINTER(GetExtensionFunctionAddress, func_name);
1273 
1274     return GetExtensionFunctionAddress(func_name);
1275 }
1276 
clCreateCommandQueue(cl_context context,cl_device_id device,cl_command_queue_properties properties,cl_int * errcode_ret)1277 cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context context,
1278                                                   cl_device_id device,
1279                                                   cl_command_queue_properties properties,
1280                                                   cl_int *errcode_ret)
1281 {
1282     CL_EVENT(CreateCommandQueue,
1283              "context = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR
1284              ", properties = %llu, errcode_ret = 0x%016" PRIxPTR "",
1285              (uintptr_t)context, (uintptr_t)device, static_cast<unsigned long long>(properties),
1286              (uintptr_t)errcode_ret);
1287 
1288     CommandQueueProperties propertiesPacked = PackParam<CommandQueueProperties>(properties);
1289 
1290     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateCommandQueue, context, device, propertiesPacked);
1291 
1292     cl_int errorCode        = CL_SUCCESS;
1293     cl_command_queue object = CreateCommandQueue(context, device, propertiesPacked, errorCode);
1294 
1295     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1296     if (errcode_ret != nullptr)
1297     {
1298         *errcode_ret = errorCode;
1299     }
1300     return object;
1301 }
1302 
clCreateSampler(cl_context context,cl_bool normalized_coords,cl_addressing_mode addressing_mode,cl_filter_mode filter_mode,cl_int * errcode_ret)1303 cl_sampler CL_API_CALL clCreateSampler(cl_context context,
1304                                        cl_bool normalized_coords,
1305                                        cl_addressing_mode addressing_mode,
1306                                        cl_filter_mode filter_mode,
1307                                        cl_int *errcode_ret)
1308 {
1309     CL_EVENT(CreateSampler,
1310              "context = 0x%016" PRIxPTR
1311              ", normalized_coords = %u, addressing_mode = %u, filter_mode = %u, errcode_ret = "
1312              "0x%016" PRIxPTR "",
1313              (uintptr_t)context, normalized_coords, addressing_mode, filter_mode,
1314              (uintptr_t)errcode_ret);
1315 
1316     AddressingMode addressing_modePacked = PackParam<AddressingMode>(addressing_mode);
1317     FilterMode filter_modePacked         = PackParam<FilterMode>(filter_mode);
1318 
1319     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateSampler, context, normalized_coords, addressing_modePacked,
1320                                   filter_modePacked);
1321 
1322     cl_int errorCode  = CL_SUCCESS;
1323     cl_sampler object = CreateSampler(context, normalized_coords, addressing_modePacked,
1324                                       filter_modePacked, errorCode);
1325 
1326     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1327     if (errcode_ret != nullptr)
1328     {
1329         *errcode_ret = errorCode;
1330     }
1331     return object;
1332 }
1333 
clEnqueueTask(cl_command_queue command_queue,cl_kernel kernel,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1334 cl_int CL_API_CALL clEnqueueTask(cl_command_queue command_queue,
1335                                  cl_kernel kernel,
1336                                  cl_uint num_events_in_wait_list,
1337                                  const cl_event *event_wait_list,
1338                                  cl_event *event)
1339 {
1340     CL_EVENT(EnqueueTask,
1341              "command_queue = 0x%016" PRIxPTR ", kernel = 0x%016" PRIxPTR
1342              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1343              ", event = 0x%016" PRIxPTR "",
1344              (uintptr_t)command_queue, (uintptr_t)kernel, num_events_in_wait_list,
1345              (uintptr_t)event_wait_list, (uintptr_t)event);
1346 
1347     ANGLE_CL_VALIDATE_ERROR(EnqueueTask, command_queue, kernel, num_events_in_wait_list,
1348                             event_wait_list, event);
1349 
1350     return EnqueueTask(command_queue, kernel, num_events_in_wait_list, event_wait_list, event);
1351 }
1352 
1353 // CL 1.1
clCreateSubBuffer(cl_mem buffer,cl_mem_flags flags,cl_buffer_create_type buffer_create_type,const void * buffer_create_info,cl_int * errcode_ret)1354 cl_mem CL_API_CALL clCreateSubBuffer(cl_mem buffer,
1355                                      cl_mem_flags flags,
1356                                      cl_buffer_create_type buffer_create_type,
1357                                      const void *buffer_create_info,
1358                                      cl_int *errcode_ret)
1359 {
1360     CL_EVENT(CreateSubBuffer,
1361              "buffer = 0x%016" PRIxPTR
1362              ", flags = %llu, buffer_create_type = %u, buffer_create_info = 0x%016" PRIxPTR
1363              ", errcode_ret = 0x%016" PRIxPTR "",
1364              (uintptr_t)buffer, static_cast<unsigned long long>(flags), buffer_create_type,
1365              (uintptr_t)buffer_create_info, (uintptr_t)errcode_ret);
1366 
1367     MemFlags flagsPacked = PackParam<MemFlags>(flags);
1368 
1369     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateSubBuffer, buffer, flagsPacked, buffer_create_type,
1370                                   buffer_create_info);
1371 
1372     cl_int errorCode = CL_SUCCESS;
1373     cl_mem object =
1374         CreateSubBuffer(buffer, flagsPacked, buffer_create_type, buffer_create_info, errorCode);
1375 
1376     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1377     if (errcode_ret != nullptr)
1378     {
1379         *errcode_ret = errorCode;
1380     }
1381     return object;
1382 }
1383 
clSetMemObjectDestructorCallback(cl_mem memobj,void (CL_CALLBACK * pfn_notify)(cl_mem memobj,void * user_data),void * user_data)1384 cl_int CL_API_CALL clSetMemObjectDestructorCallback(cl_mem memobj,
1385                                                     void(CL_CALLBACK *pfn_notify)(cl_mem memobj,
1386                                                                                   void *user_data),
1387                                                     void *user_data)
1388 {
1389     CL_EVENT(SetMemObjectDestructorCallback,
1390              "memobj = 0x%016" PRIxPTR ", pfn_notify = 0x%016" PRIxPTR
1391              ", user_data = 0x%016" PRIxPTR "",
1392              (uintptr_t)memobj, (uintptr_t)pfn_notify, (uintptr_t)user_data);
1393 
1394     ANGLE_CL_VALIDATE_ERROR(SetMemObjectDestructorCallback, memobj, pfn_notify, user_data);
1395 
1396     return SetMemObjectDestructorCallback(memobj, pfn_notify, user_data);
1397 }
1398 
clCreateUserEvent(cl_context context,cl_int * errcode_ret)1399 cl_event CL_API_CALL clCreateUserEvent(cl_context context, cl_int *errcode_ret)
1400 {
1401     CL_EVENT(CreateUserEvent, "context = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
1402              (uintptr_t)context, (uintptr_t)errcode_ret);
1403 
1404     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateUserEvent, context);
1405 
1406     cl_int errorCode = CL_SUCCESS;
1407     cl_event object  = CreateUserEvent(context, errorCode);
1408 
1409     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1410     if (errcode_ret != nullptr)
1411     {
1412         *errcode_ret = errorCode;
1413     }
1414     return object;
1415 }
1416 
clSetUserEventStatus(cl_event event,cl_int execution_status)1417 cl_int CL_API_CALL clSetUserEventStatus(cl_event event, cl_int execution_status)
1418 {
1419     CL_EVENT(SetUserEventStatus, "event = 0x%016" PRIxPTR ", execution_status = %d",
1420              (uintptr_t)event, execution_status);
1421 
1422     ANGLE_CL_VALIDATE_ERROR(SetUserEventStatus, event, execution_status);
1423 
1424     return SetUserEventStatus(event, execution_status);
1425 }
1426 
clSetEventCallback(cl_event event,cl_int command_exec_callback_type,void (CL_CALLBACK * pfn_notify)(cl_event event,cl_int event_command_status,void * user_data),void * user_data)1427 cl_int CL_API_CALL clSetEventCallback(cl_event event,
1428                                       cl_int command_exec_callback_type,
1429                                       void(CL_CALLBACK *pfn_notify)(cl_event event,
1430                                                                     cl_int event_command_status,
1431                                                                     void *user_data),
1432                                       void *user_data)
1433 {
1434     CL_EVENT(
1435         SetEventCallback,
1436         "event = 0x%016" PRIxPTR ", command_exec_callback_type = %d, pfn_notify = 0x%016" PRIxPTR
1437         ", user_data = 0x%016" PRIxPTR "",
1438         (uintptr_t)event, command_exec_callback_type, (uintptr_t)pfn_notify, (uintptr_t)user_data);
1439 
1440     ANGLE_CL_VALIDATE_ERROR(SetEventCallback, event, command_exec_callback_type, pfn_notify,
1441                             user_data);
1442 
1443     return SetEventCallback(event, command_exec_callback_type, pfn_notify, user_data);
1444 }
1445 
clEnqueueReadBufferRect(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_read,const size_t * buffer_origin,const size_t * host_origin,const size_t * region,size_t buffer_row_pitch,size_t buffer_slice_pitch,size_t host_row_pitch,size_t host_slice_pitch,void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1446 cl_int CL_API_CALL clEnqueueReadBufferRect(cl_command_queue command_queue,
1447                                            cl_mem buffer,
1448                                            cl_bool blocking_read,
1449                                            const size_t *buffer_origin,
1450                                            const size_t *host_origin,
1451                                            const size_t *region,
1452                                            size_t buffer_row_pitch,
1453                                            size_t buffer_slice_pitch,
1454                                            size_t host_row_pitch,
1455                                            size_t host_slice_pitch,
1456                                            void *ptr,
1457                                            cl_uint num_events_in_wait_list,
1458                                            const cl_event *event_wait_list,
1459                                            cl_event *event)
1460 {
1461     CL_EVENT(EnqueueReadBufferRect,
1462              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
1463              ", blocking_read = %u, buffer_origin = 0x%016" PRIxPTR ", host_origin = 0x%016" PRIxPTR
1464              ", region = 0x%016" PRIxPTR
1465              ", buffer_row_pitch = %zu, buffer_slice_pitch = %zu, host_row_pitch = %zu, "
1466              "host_slice_pitch = %zu, ptr = 0x%016" PRIxPTR
1467              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1468              ", event = 0x%016" PRIxPTR "",
1469              (uintptr_t)command_queue, (uintptr_t)buffer, blocking_read, (uintptr_t)buffer_origin,
1470              (uintptr_t)host_origin, (uintptr_t)region, buffer_row_pitch, buffer_slice_pitch,
1471              host_row_pitch, host_slice_pitch, (uintptr_t)ptr, num_events_in_wait_list,
1472              (uintptr_t)event_wait_list, (uintptr_t)event);
1473 
1474     ANGLE_CL_VALIDATE_ERROR(EnqueueReadBufferRect, command_queue, buffer, blocking_read,
1475                             buffer_origin, host_origin, region, buffer_row_pitch,
1476                             buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr,
1477                             num_events_in_wait_list, event_wait_list, event);
1478 
1479     return EnqueueReadBufferRect(command_queue, buffer, blocking_read, buffer_origin, host_origin,
1480                                  region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch,
1481                                  host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list,
1482                                  event);
1483 }
1484 
clEnqueueWriteBufferRect(cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,const size_t * buffer_origin,const size_t * host_origin,const size_t * region,size_t buffer_row_pitch,size_t buffer_slice_pitch,size_t host_row_pitch,size_t host_slice_pitch,const void * ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1485 cl_int CL_API_CALL clEnqueueWriteBufferRect(cl_command_queue command_queue,
1486                                             cl_mem buffer,
1487                                             cl_bool blocking_write,
1488                                             const size_t *buffer_origin,
1489                                             const size_t *host_origin,
1490                                             const size_t *region,
1491                                             size_t buffer_row_pitch,
1492                                             size_t buffer_slice_pitch,
1493                                             size_t host_row_pitch,
1494                                             size_t host_slice_pitch,
1495                                             const void *ptr,
1496                                             cl_uint num_events_in_wait_list,
1497                                             const cl_event *event_wait_list,
1498                                             cl_event *event)
1499 {
1500     CL_EVENT(EnqueueWriteBufferRect,
1501              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
1502              ", blocking_write = %u, buffer_origin = 0x%016" PRIxPTR
1503              ", host_origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
1504              ", buffer_row_pitch = %zu, buffer_slice_pitch = %zu, host_row_pitch = %zu, "
1505              "host_slice_pitch = %zu, ptr = 0x%016" PRIxPTR
1506              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1507              ", event = 0x%016" PRIxPTR "",
1508              (uintptr_t)command_queue, (uintptr_t)buffer, blocking_write, (uintptr_t)buffer_origin,
1509              (uintptr_t)host_origin, (uintptr_t)region, buffer_row_pitch, buffer_slice_pitch,
1510              host_row_pitch, host_slice_pitch, (uintptr_t)ptr, num_events_in_wait_list,
1511              (uintptr_t)event_wait_list, (uintptr_t)event);
1512 
1513     ANGLE_CL_VALIDATE_ERROR(EnqueueWriteBufferRect, command_queue, buffer, blocking_write,
1514                             buffer_origin, host_origin, region, buffer_row_pitch,
1515                             buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr,
1516                             num_events_in_wait_list, event_wait_list, event);
1517 
1518     return EnqueueWriteBufferRect(command_queue, buffer, blocking_write, buffer_origin, host_origin,
1519                                   region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch,
1520                                   host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list,
1521                                   event);
1522 }
1523 
clEnqueueCopyBufferRect(cl_command_queue command_queue,cl_mem src_buffer,cl_mem dst_buffer,const size_t * src_origin,const size_t * dst_origin,const size_t * region,size_t src_row_pitch,size_t src_slice_pitch,size_t dst_row_pitch,size_t dst_slice_pitch,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1524 cl_int CL_API_CALL clEnqueueCopyBufferRect(cl_command_queue command_queue,
1525                                            cl_mem src_buffer,
1526                                            cl_mem dst_buffer,
1527                                            const size_t *src_origin,
1528                                            const size_t *dst_origin,
1529                                            const size_t *region,
1530                                            size_t src_row_pitch,
1531                                            size_t src_slice_pitch,
1532                                            size_t dst_row_pitch,
1533                                            size_t dst_slice_pitch,
1534                                            cl_uint num_events_in_wait_list,
1535                                            const cl_event *event_wait_list,
1536                                            cl_event *event)
1537 {
1538     CL_EVENT(EnqueueCopyBufferRect,
1539              "command_queue = 0x%016" PRIxPTR ", src_buffer = 0x%016" PRIxPTR
1540              ", dst_buffer = 0x%016" PRIxPTR ", src_origin = 0x%016" PRIxPTR
1541              ", dst_origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
1542              ", src_row_pitch = %zu, src_slice_pitch = %zu, dst_row_pitch = %zu, dst_slice_pitch = "
1543              "%zu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1544              ", event = 0x%016" PRIxPTR "",
1545              (uintptr_t)command_queue, (uintptr_t)src_buffer, (uintptr_t)dst_buffer,
1546              (uintptr_t)src_origin, (uintptr_t)dst_origin, (uintptr_t)region, src_row_pitch,
1547              src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events_in_wait_list,
1548              (uintptr_t)event_wait_list, (uintptr_t)event);
1549 
1550     ANGLE_CL_VALIDATE_ERROR(EnqueueCopyBufferRect, command_queue, src_buffer, dst_buffer,
1551                             src_origin, dst_origin, region, src_row_pitch, src_slice_pitch,
1552                             dst_row_pitch, dst_slice_pitch, num_events_in_wait_list,
1553                             event_wait_list, event);
1554 
1555     return EnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin,
1556                                  region, src_row_pitch, src_slice_pitch, dst_row_pitch,
1557                                  dst_slice_pitch, num_events_in_wait_list, event_wait_list, event);
1558 }
1559 
1560 // CL 1.2
clCreateSubDevices(cl_device_id in_device,const cl_device_partition_property * properties,cl_uint num_devices,cl_device_id * out_devices,cl_uint * num_devices_ret)1561 cl_int CL_API_CALL clCreateSubDevices(cl_device_id in_device,
1562                                       const cl_device_partition_property *properties,
1563                                       cl_uint num_devices,
1564                                       cl_device_id *out_devices,
1565                                       cl_uint *num_devices_ret)
1566 {
1567     CL_EVENT(CreateSubDevices,
1568              "in_device = 0x%016" PRIxPTR ", properties = 0x%016" PRIxPTR
1569              ", num_devices = %u, out_devices = 0x%016" PRIxPTR ", num_devices_ret = 0x%016" PRIxPTR
1570              "",
1571              (uintptr_t)in_device, (uintptr_t)properties, num_devices, (uintptr_t)out_devices,
1572              (uintptr_t)num_devices_ret);
1573 
1574     ANGLE_CL_VALIDATE_ERROR(CreateSubDevices, in_device, properties, num_devices, out_devices,
1575                             num_devices_ret);
1576 
1577     return CreateSubDevices(in_device, properties, num_devices, out_devices, num_devices_ret);
1578 }
1579 
clRetainDevice(cl_device_id device)1580 cl_int CL_API_CALL clRetainDevice(cl_device_id device)
1581 {
1582     CL_EVENT(RetainDevice, "device = 0x%016" PRIxPTR "", (uintptr_t)device);
1583 
1584     ANGLE_CL_VALIDATE_ERROR(RetainDevice, device);
1585 
1586     return RetainDevice(device);
1587 }
1588 
clReleaseDevice(cl_device_id device)1589 cl_int CL_API_CALL clReleaseDevice(cl_device_id device)
1590 {
1591     CL_EVENT(ReleaseDevice, "device = 0x%016" PRIxPTR "", (uintptr_t)device);
1592 
1593     ANGLE_CL_VALIDATE_ERROR(ReleaseDevice, device);
1594 
1595     return ReleaseDevice(device);
1596 }
1597 
clCreateImage(cl_context context,cl_mem_flags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int * errcode_ret)1598 cl_mem CL_API_CALL clCreateImage(cl_context context,
1599                                  cl_mem_flags flags,
1600                                  const cl_image_format *image_format,
1601                                  const cl_image_desc *image_desc,
1602                                  void *host_ptr,
1603                                  cl_int *errcode_ret)
1604 {
1605     CL_EVENT(CreateImage,
1606              "context = 0x%016" PRIxPTR ", flags = %llu, image_format = 0x%016" PRIxPTR
1607              ", image_desc = 0x%016" PRIxPTR ", host_ptr = 0x%016" PRIxPTR
1608              ", errcode_ret = 0x%016" PRIxPTR "",
1609              (uintptr_t)context, static_cast<unsigned long long>(flags), (uintptr_t)image_format,
1610              (uintptr_t)image_desc, (uintptr_t)host_ptr, (uintptr_t)errcode_ret);
1611 
1612     MemFlags flagsPacked = PackParam<MemFlags>(flags);
1613 
1614     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateImage, context, flagsPacked, image_format, image_desc,
1615                                   host_ptr);
1616 
1617     cl_int errorCode = CL_SUCCESS;
1618     cl_mem object =
1619         CreateImage(context, flagsPacked, image_format, image_desc, host_ptr, errorCode);
1620 
1621     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1622     if (errcode_ret != nullptr)
1623     {
1624         *errcode_ret = errorCode;
1625     }
1626     return object;
1627 }
1628 
clCreateProgramWithBuiltInKernels(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const char * kernel_names,cl_int * errcode_ret)1629 cl_program CL_API_CALL clCreateProgramWithBuiltInKernels(cl_context context,
1630                                                          cl_uint num_devices,
1631                                                          const cl_device_id *device_list,
1632                                                          const char *kernel_names,
1633                                                          cl_int *errcode_ret)
1634 {
1635     CL_EVENT(CreateProgramWithBuiltInKernels,
1636              "context = 0x%016" PRIxPTR ", num_devices = %u, device_list = 0x%016" PRIxPTR
1637              ", kernel_names = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
1638              (uintptr_t)context, num_devices, (uintptr_t)device_list, (uintptr_t)kernel_names,
1639              (uintptr_t)errcode_ret);
1640 
1641     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateProgramWithBuiltInKernels, context, num_devices,
1642                                   device_list, kernel_names);
1643 
1644     cl_int errorCode = CL_SUCCESS;
1645     cl_program object =
1646         CreateProgramWithBuiltInKernels(context, num_devices, device_list, kernel_names, errorCode);
1647 
1648     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1649     if (errcode_ret != nullptr)
1650     {
1651         *errcode_ret = errorCode;
1652     }
1653     return object;
1654 }
1655 
clCompileProgram(cl_program program,cl_uint num_devices,const cl_device_id * device_list,const char * options,cl_uint num_input_headers,const cl_program * input_headers,const char ** header_include_names,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)1656 cl_int CL_API_CALL clCompileProgram(cl_program program,
1657                                     cl_uint num_devices,
1658                                     const cl_device_id *device_list,
1659                                     const char *options,
1660                                     cl_uint num_input_headers,
1661                                     const cl_program *input_headers,
1662                                     const char **header_include_names,
1663                                     void(CL_CALLBACK *pfn_notify)(cl_program program,
1664                                                                   void *user_data),
1665                                     void *user_data)
1666 {
1667     CL_EVENT(CompileProgram,
1668              "program = 0x%016" PRIxPTR ", num_devices = %u, device_list = 0x%016" PRIxPTR
1669              ", options = 0x%016" PRIxPTR ", num_input_headers = %u, input_headers = 0x%016" PRIxPTR
1670              ", header_include_names = 0x%016" PRIxPTR ", pfn_notify = 0x%016" PRIxPTR
1671              ", user_data = 0x%016" PRIxPTR "",
1672              (uintptr_t)program, num_devices, (uintptr_t)device_list, (uintptr_t)options,
1673              num_input_headers, (uintptr_t)input_headers, (uintptr_t)header_include_names,
1674              (uintptr_t)pfn_notify, (uintptr_t)user_data);
1675 
1676     ANGLE_CL_VALIDATE_ERROR(CompileProgram, program, num_devices, device_list, options,
1677                             num_input_headers, input_headers, header_include_names, pfn_notify,
1678                             user_data);
1679 
1680     return CompileProgram(program, num_devices, device_list, options, num_input_headers,
1681                           input_headers, header_include_names, pfn_notify, user_data);
1682 }
1683 
clLinkProgram(cl_context context,cl_uint num_devices,const cl_device_id * device_list,const char * options,cl_uint num_input_programs,const cl_program * input_programs,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data,cl_int * errcode_ret)1684 cl_program CL_API_CALL clLinkProgram(cl_context context,
1685                                      cl_uint num_devices,
1686                                      const cl_device_id *device_list,
1687                                      const char *options,
1688                                      cl_uint num_input_programs,
1689                                      const cl_program *input_programs,
1690                                      void(CL_CALLBACK *pfn_notify)(cl_program program,
1691                                                                    void *user_data),
1692                                      void *user_data,
1693                                      cl_int *errcode_ret)
1694 {
1695     CL_EVENT(LinkProgram,
1696              "context = 0x%016" PRIxPTR ", num_devices = %u, device_list = 0x%016" PRIxPTR
1697              ", options = 0x%016" PRIxPTR
1698              ", num_input_programs = %u, input_programs = 0x%016" PRIxPTR
1699              ", pfn_notify = 0x%016" PRIxPTR ", user_data = 0x%016" PRIxPTR
1700              ", errcode_ret = 0x%016" PRIxPTR "",
1701              (uintptr_t)context, num_devices, (uintptr_t)device_list, (uintptr_t)options,
1702              num_input_programs, (uintptr_t)input_programs, (uintptr_t)pfn_notify,
1703              (uintptr_t)user_data, (uintptr_t)errcode_ret);
1704 
1705     ANGLE_CL_VALIDATE_ERRCODE_RET(LinkProgram, context, num_devices, device_list, options,
1706                                   num_input_programs, input_programs, pfn_notify, user_data);
1707 
1708     cl_int errorCode  = CL_SUCCESS;
1709     cl_program object = LinkProgram(context, num_devices, device_list, options, num_input_programs,
1710                                     input_programs, pfn_notify, user_data, errorCode);
1711 
1712     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1713     if (errcode_ret != nullptr)
1714     {
1715         *errcode_ret = errorCode;
1716     }
1717     return object;
1718 }
1719 
clUnloadPlatformCompiler(cl_platform_id platform)1720 cl_int CL_API_CALL clUnloadPlatformCompiler(cl_platform_id platform)
1721 {
1722     CL_EVENT(UnloadPlatformCompiler, "platform = 0x%016" PRIxPTR "", (uintptr_t)platform);
1723 
1724     ANGLE_CL_VALIDATE_ERROR(UnloadPlatformCompiler, platform);
1725 
1726     return UnloadPlatformCompiler(platform);
1727 }
1728 
clGetKernelArgInfo(cl_kernel kernel,cl_uint arg_index,cl_kernel_arg_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1729 cl_int CL_API_CALL clGetKernelArgInfo(cl_kernel kernel,
1730                                       cl_uint arg_index,
1731                                       cl_kernel_arg_info param_name,
1732                                       size_t param_value_size,
1733                                       void *param_value,
1734                                       size_t *param_value_size_ret)
1735 {
1736     CL_EVENT(
1737         GetKernelArgInfo,
1738         "kernel = 0x%016" PRIxPTR
1739         ", arg_index = %u, param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
1740         ", param_value_size_ret = 0x%016" PRIxPTR "",
1741         (uintptr_t)kernel, arg_index, param_name, param_value_size, (uintptr_t)param_value,
1742         (uintptr_t)param_value_size_ret);
1743 
1744     KernelArgInfo param_namePacked = PackParam<KernelArgInfo>(param_name);
1745 
1746     ANGLE_CL_VALIDATE_ERROR(GetKernelArgInfo, kernel, arg_index, param_namePacked, param_value_size,
1747                             param_value, param_value_size_ret);
1748 
1749     return GetKernelArgInfo(kernel, arg_index, param_namePacked, param_value_size, param_value,
1750                             param_value_size_ret);
1751 }
1752 
clEnqueueFillBuffer(cl_command_queue command_queue,cl_mem buffer,const void * pattern,size_t pattern_size,size_t offset,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1753 cl_int CL_API_CALL clEnqueueFillBuffer(cl_command_queue command_queue,
1754                                        cl_mem buffer,
1755                                        const void *pattern,
1756                                        size_t pattern_size,
1757                                        size_t offset,
1758                                        size_t size,
1759                                        cl_uint num_events_in_wait_list,
1760                                        const cl_event *event_wait_list,
1761                                        cl_event *event)
1762 {
1763     CL_EVENT(EnqueueFillBuffer,
1764              "command_queue = 0x%016" PRIxPTR ", buffer = 0x%016" PRIxPTR
1765              ", pattern = 0x%016" PRIxPTR
1766              ", pattern_size = %zu, offset = %zu, size = %zu, num_events_in_wait_list = %u, "
1767              "event_wait_list = 0x%016" PRIxPTR ", event = 0x%016" PRIxPTR "",
1768              (uintptr_t)command_queue, (uintptr_t)buffer, (uintptr_t)pattern, pattern_size, offset,
1769              size, num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
1770 
1771     ANGLE_CL_VALIDATE_ERROR(EnqueueFillBuffer, command_queue, buffer, pattern, pattern_size, offset,
1772                             size, num_events_in_wait_list, event_wait_list, event);
1773 
1774     return EnqueueFillBuffer(command_queue, buffer, pattern, pattern_size, offset, size,
1775                              num_events_in_wait_list, event_wait_list, event);
1776 }
1777 
clEnqueueFillImage(cl_command_queue command_queue,cl_mem image,const void * fill_color,const size_t * origin,const size_t * region,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1778 cl_int CL_API_CALL clEnqueueFillImage(cl_command_queue command_queue,
1779                                       cl_mem image,
1780                                       const void *fill_color,
1781                                       const size_t *origin,
1782                                       const size_t *region,
1783                                       cl_uint num_events_in_wait_list,
1784                                       const cl_event *event_wait_list,
1785                                       cl_event *event)
1786 {
1787     CL_EVENT(EnqueueFillImage,
1788              "command_queue = 0x%016" PRIxPTR ", image = 0x%016" PRIxPTR
1789              ", fill_color = 0x%016" PRIxPTR ", origin = 0x%016" PRIxPTR ", region = 0x%016" PRIxPTR
1790              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1791              ", event = 0x%016" PRIxPTR "",
1792              (uintptr_t)command_queue, (uintptr_t)image, (uintptr_t)fill_color, (uintptr_t)origin,
1793              (uintptr_t)region, num_events_in_wait_list, (uintptr_t)event_wait_list,
1794              (uintptr_t)event);
1795 
1796     ANGLE_CL_VALIDATE_ERROR(EnqueueFillImage, command_queue, image, fill_color, origin, region,
1797                             num_events_in_wait_list, event_wait_list, event);
1798 
1799     return EnqueueFillImage(command_queue, image, fill_color, origin, region,
1800                             num_events_in_wait_list, event_wait_list, event);
1801 }
1802 
clEnqueueMigrateMemObjects(cl_command_queue command_queue,cl_uint num_mem_objects,const cl_mem * mem_objects,cl_mem_migration_flags flags,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1803 cl_int CL_API_CALL clEnqueueMigrateMemObjects(cl_command_queue command_queue,
1804                                               cl_uint num_mem_objects,
1805                                               const cl_mem *mem_objects,
1806                                               cl_mem_migration_flags flags,
1807                                               cl_uint num_events_in_wait_list,
1808                                               const cl_event *event_wait_list,
1809                                               cl_event *event)
1810 {
1811     CL_EVENT(EnqueueMigrateMemObjects,
1812              "command_queue = 0x%016" PRIxPTR ", num_mem_objects = %u, mem_objects = 0x%016" PRIxPTR
1813              ", flags = %llu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1814              ", event = 0x%016" PRIxPTR "",
1815              (uintptr_t)command_queue, num_mem_objects, (uintptr_t)mem_objects,
1816              static_cast<unsigned long long>(flags), num_events_in_wait_list,
1817              (uintptr_t)event_wait_list, (uintptr_t)event);
1818 
1819     MemMigrationFlags flagsPacked = PackParam<MemMigrationFlags>(flags);
1820 
1821     ANGLE_CL_VALIDATE_ERROR(EnqueueMigrateMemObjects, command_queue, num_mem_objects, mem_objects,
1822                             flagsPacked, num_events_in_wait_list, event_wait_list, event);
1823 
1824     return EnqueueMigrateMemObjects(command_queue, num_mem_objects, mem_objects, flagsPacked,
1825                                     num_events_in_wait_list, event_wait_list, event);
1826 }
1827 
clEnqueueMarkerWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1828 cl_int CL_API_CALL clEnqueueMarkerWithWaitList(cl_command_queue command_queue,
1829                                                cl_uint num_events_in_wait_list,
1830                                                const cl_event *event_wait_list,
1831                                                cl_event *event)
1832 {
1833     CL_EVENT(EnqueueMarkerWithWaitList,
1834              "command_queue = 0x%016" PRIxPTR
1835              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1836              ", event = 0x%016" PRIxPTR "",
1837              (uintptr_t)command_queue, num_events_in_wait_list, (uintptr_t)event_wait_list,
1838              (uintptr_t)event);
1839 
1840     ANGLE_CL_VALIDATE_ERROR(EnqueueMarkerWithWaitList, command_queue, num_events_in_wait_list,
1841                             event_wait_list, event);
1842 
1843     return EnqueueMarkerWithWaitList(command_queue, num_events_in_wait_list, event_wait_list,
1844                                      event);
1845 }
1846 
clEnqueueBarrierWithWaitList(cl_command_queue command_queue,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)1847 cl_int CL_API_CALL clEnqueueBarrierWithWaitList(cl_command_queue command_queue,
1848                                                 cl_uint num_events_in_wait_list,
1849                                                 const cl_event *event_wait_list,
1850                                                 cl_event *event)
1851 {
1852     CL_EVENT(EnqueueBarrierWithWaitList,
1853              "command_queue = 0x%016" PRIxPTR
1854              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
1855              ", event = 0x%016" PRIxPTR "",
1856              (uintptr_t)command_queue, num_events_in_wait_list, (uintptr_t)event_wait_list,
1857              (uintptr_t)event);
1858 
1859     ANGLE_CL_VALIDATE_ERROR(EnqueueBarrierWithWaitList, command_queue, num_events_in_wait_list,
1860                             event_wait_list, event);
1861 
1862     return EnqueueBarrierWithWaitList(command_queue, num_events_in_wait_list, event_wait_list,
1863                                       event);
1864 }
1865 
clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,const char * func_name)1866 void *CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id platform,
1867                                                            const char *func_name)
1868 {
1869     CL_EVENT(GetExtensionFunctionAddressForPlatform,
1870              "platform = 0x%016" PRIxPTR ", func_name = 0x%016" PRIxPTR "", (uintptr_t)platform,
1871              (uintptr_t)func_name);
1872 
1873     ANGLE_CL_VALIDATE_POINTER(GetExtensionFunctionAddressForPlatform, platform, func_name);
1874 
1875     return GetExtensionFunctionAddressForPlatform(platform, func_name);
1876 }
1877 
1878 // CL 2.0
1879 cl_command_queue CL_API_CALL
clCreateCommandQueueWithProperties(cl_context context,cl_device_id device,const cl_queue_properties * properties,cl_int * errcode_ret)1880 clCreateCommandQueueWithProperties(cl_context context,
1881                                    cl_device_id device,
1882                                    const cl_queue_properties *properties,
1883                                    cl_int *errcode_ret)
1884 {
1885     CL_EVENT(CreateCommandQueueWithProperties,
1886              "context = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR ", properties = 0x%016" PRIxPTR
1887              ", errcode_ret = 0x%016" PRIxPTR "",
1888              (uintptr_t)context, (uintptr_t)device, (uintptr_t)properties, (uintptr_t)errcode_ret);
1889 
1890     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateCommandQueueWithProperties, context, device, properties);
1891 
1892     cl_int errorCode = CL_SUCCESS;
1893     cl_command_queue object =
1894         CreateCommandQueueWithProperties(context, device, properties, errorCode);
1895 
1896     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1897     if (errcode_ret != nullptr)
1898     {
1899         *errcode_ret = errorCode;
1900     }
1901     return object;
1902 }
1903 
clCreatePipe(cl_context context,cl_mem_flags flags,cl_uint pipe_packet_size,cl_uint pipe_max_packets,const cl_pipe_properties * properties,cl_int * errcode_ret)1904 cl_mem CL_API_CALL clCreatePipe(cl_context context,
1905                                 cl_mem_flags flags,
1906                                 cl_uint pipe_packet_size,
1907                                 cl_uint pipe_max_packets,
1908                                 const cl_pipe_properties *properties,
1909                                 cl_int *errcode_ret)
1910 {
1911     CL_EVENT(
1912         CreatePipe,
1913         "context = 0x%016" PRIxPTR
1914         ", flags = %llu, pipe_packet_size = %u, pipe_max_packets = %u, properties = 0x%016" PRIxPTR
1915         ", errcode_ret = 0x%016" PRIxPTR "",
1916         (uintptr_t)context, static_cast<unsigned long long>(flags), pipe_packet_size,
1917         pipe_max_packets, (uintptr_t)properties, (uintptr_t)errcode_ret);
1918 
1919     MemFlags flagsPacked = PackParam<MemFlags>(flags);
1920 
1921     ANGLE_CL_VALIDATE_ERRCODE_RET(CreatePipe, context, flagsPacked, pipe_packet_size,
1922                                   pipe_max_packets, properties);
1923 
1924     cl_int errorCode = CL_SUCCESS;
1925     cl_mem object =
1926         CreatePipe(context, flagsPacked, pipe_packet_size, pipe_max_packets, properties, errorCode);
1927 
1928     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1929     if (errcode_ret != nullptr)
1930     {
1931         *errcode_ret = errorCode;
1932     }
1933     return object;
1934 }
1935 
clGetPipeInfo(cl_mem pipe,cl_pipe_info param_name,size_t param_value_size,void * param_value,size_t * param_value_size_ret)1936 cl_int CL_API_CALL clGetPipeInfo(cl_mem pipe,
1937                                  cl_pipe_info param_name,
1938                                  size_t param_value_size,
1939                                  void *param_value,
1940                                  size_t *param_value_size_ret)
1941 {
1942     CL_EVENT(GetPipeInfo,
1943              "pipe = 0x%016" PRIxPTR
1944              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR
1945              ", param_value_size_ret = 0x%016" PRIxPTR "",
1946              (uintptr_t)pipe, param_name, param_value_size, (uintptr_t)param_value,
1947              (uintptr_t)param_value_size_ret);
1948 
1949     PipeInfo param_namePacked = PackParam<PipeInfo>(param_name);
1950 
1951     ANGLE_CL_VALIDATE_ERROR(GetPipeInfo, pipe, param_namePacked, param_value_size, param_value,
1952                             param_value_size_ret);
1953 
1954     return GetPipeInfo(pipe, param_namePacked, param_value_size, param_value, param_value_size_ret);
1955 }
1956 
clSVMAlloc(cl_context context,cl_svm_mem_flags flags,size_t size,cl_uint alignment)1957 void *CL_API_CALL clSVMAlloc(cl_context context,
1958                              cl_svm_mem_flags flags,
1959                              size_t size,
1960                              cl_uint alignment)
1961 {
1962     CL_EVENT(SVMAlloc, "context = 0x%016" PRIxPTR ", flags = %llu, size = %zu, alignment = %u",
1963              (uintptr_t)context, static_cast<unsigned long long>(flags), size, alignment);
1964 
1965     SVM_MemFlags flagsPacked = PackParam<SVM_MemFlags>(flags);
1966 
1967     ANGLE_CL_VALIDATE_POINTER(SVMAlloc, context, flagsPacked, size, alignment);
1968 
1969     return SVMAlloc(context, flagsPacked, size, alignment);
1970 }
1971 
clSVMFree(cl_context context,void * svm_pointer)1972 void CL_API_CALL clSVMFree(cl_context context, void *svm_pointer)
1973 {
1974     CL_EVENT(SVMFree, "context = 0x%016" PRIxPTR ", svm_pointer = 0x%016" PRIxPTR "",
1975              (uintptr_t)context, (uintptr_t)svm_pointer);
1976 
1977     ANGLE_CL_VALIDATE_VOID(SVMFree, context, svm_pointer);
1978 
1979     SVMFree(context, svm_pointer);
1980 }
1981 
1982 cl_sampler CL_API_CALL
clCreateSamplerWithProperties(cl_context context,const cl_sampler_properties * sampler_properties,cl_int * errcode_ret)1983 clCreateSamplerWithProperties(cl_context context,
1984                               const cl_sampler_properties *sampler_properties,
1985                               cl_int *errcode_ret)
1986 {
1987     CL_EVENT(CreateSamplerWithProperties,
1988              "context = 0x%016" PRIxPTR ", sampler_properties = 0x%016" PRIxPTR
1989              ", errcode_ret = 0x%016" PRIxPTR "",
1990              (uintptr_t)context, (uintptr_t)sampler_properties, (uintptr_t)errcode_ret);
1991 
1992     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateSamplerWithProperties, context, sampler_properties);
1993 
1994     cl_int errorCode  = CL_SUCCESS;
1995     cl_sampler object = CreateSamplerWithProperties(context, sampler_properties, errorCode);
1996 
1997     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
1998     if (errcode_ret != nullptr)
1999     {
2000         *errcode_ret = errorCode;
2001     }
2002     return object;
2003 }
2004 
clSetKernelArgSVMPointer(cl_kernel kernel,cl_uint arg_index,const void * arg_value)2005 cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
2006                                             cl_uint arg_index,
2007                                             const void *arg_value)
2008 {
2009     CL_EVENT(SetKernelArgSVMPointer,
2010              "kernel = 0x%016" PRIxPTR ", arg_index = %u, arg_value = 0x%016" PRIxPTR "",
2011              (uintptr_t)kernel, arg_index, (uintptr_t)arg_value);
2012 
2013     ANGLE_CL_VALIDATE_ERROR(SetKernelArgSVMPointer, kernel, arg_index, arg_value);
2014 
2015     return SetKernelArgSVMPointer(kernel, arg_index, arg_value);
2016 }
2017 
clSetKernelExecInfo(cl_kernel kernel,cl_kernel_exec_info param_name,size_t param_value_size,const void * param_value)2018 cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel kernel,
2019                                        cl_kernel_exec_info param_name,
2020                                        size_t param_value_size,
2021                                        const void *param_value)
2022 {
2023     CL_EVENT(SetKernelExecInfo,
2024              "kernel = 0x%016" PRIxPTR
2025              ", param_name = %u, param_value_size = %zu, param_value = 0x%016" PRIxPTR "",
2026              (uintptr_t)kernel, param_name, param_value_size, (uintptr_t)param_value);
2027 
2028     KernelExecInfo param_namePacked = PackParam<KernelExecInfo>(param_name);
2029 
2030     ANGLE_CL_VALIDATE_ERROR(SetKernelExecInfo, kernel, param_namePacked, param_value_size,
2031                             param_value);
2032 
2033     return SetKernelExecInfo(kernel, param_namePacked, param_value_size, param_value);
2034 }
2035 
clEnqueueSVMFree(cl_command_queue command_queue,cl_uint num_svm_pointers,void * svm_pointers[],void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue,cl_uint num_svm_pointers,void * svm_pointers[],void * user_data),void * user_data,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2036 cl_int CL_API_CALL clEnqueueSVMFree(cl_command_queue command_queue,
2037                                     cl_uint num_svm_pointers,
2038                                     void *svm_pointers[],
2039                                     void(CL_CALLBACK *pfn_free_func)(cl_command_queue queue,
2040                                                                      cl_uint num_svm_pointers,
2041                                                                      void *svm_pointers[],
2042                                                                      void *user_data),
2043                                     void *user_data,
2044                                     cl_uint num_events_in_wait_list,
2045                                     const cl_event *event_wait_list,
2046                                     cl_event *event)
2047 {
2048     CL_EVENT(EnqueueSVMFree,
2049              "command_queue = 0x%016" PRIxPTR
2050              ", num_svm_pointers = %u, svm_pointers = 0x%016" PRIxPTR
2051              ", pfn_free_func = 0x%016" PRIxPTR ", user_data = 0x%016" PRIxPTR
2052              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
2053              ", event = 0x%016" PRIxPTR "",
2054              (uintptr_t)command_queue, num_svm_pointers, (uintptr_t)svm_pointers,
2055              (uintptr_t)pfn_free_func, (uintptr_t)user_data, num_events_in_wait_list,
2056              (uintptr_t)event_wait_list, (uintptr_t)event);
2057 
2058     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMFree, command_queue, num_svm_pointers, svm_pointers,
2059                             pfn_free_func, user_data, num_events_in_wait_list, event_wait_list,
2060                             event);
2061 
2062     return EnqueueSVMFree(command_queue, num_svm_pointers, svm_pointers, pfn_free_func, user_data,
2063                           num_events_in_wait_list, event_wait_list, event);
2064 }
2065 
clEnqueueSVMMemcpy(cl_command_queue command_queue,cl_bool blocking_copy,void * dst_ptr,const void * src_ptr,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2066 cl_int CL_API_CALL clEnqueueSVMMemcpy(cl_command_queue command_queue,
2067                                       cl_bool blocking_copy,
2068                                       void *dst_ptr,
2069                                       const void *src_ptr,
2070                                       size_t size,
2071                                       cl_uint num_events_in_wait_list,
2072                                       const cl_event *event_wait_list,
2073                                       cl_event *event)
2074 {
2075     CL_EVENT(EnqueueSVMMemcpy,
2076              "command_queue = 0x%016" PRIxPTR ", blocking_copy = %u, dst_ptr = 0x%016" PRIxPTR
2077              ", src_ptr = 0x%016" PRIxPTR
2078              ", size = %zu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
2079              ", event = 0x%016" PRIxPTR "",
2080              (uintptr_t)command_queue, blocking_copy, (uintptr_t)dst_ptr, (uintptr_t)src_ptr, size,
2081              num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
2082 
2083     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMMemcpy, command_queue, blocking_copy, dst_ptr, src_ptr, size,
2084                             num_events_in_wait_list, event_wait_list, event);
2085 
2086     return EnqueueSVMMemcpy(command_queue, blocking_copy, dst_ptr, src_ptr, size,
2087                             num_events_in_wait_list, event_wait_list, event);
2088 }
2089 
clEnqueueSVMMemFill(cl_command_queue command_queue,void * svm_ptr,const void * pattern,size_t pattern_size,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2090 cl_int CL_API_CALL clEnqueueSVMMemFill(cl_command_queue command_queue,
2091                                        void *svm_ptr,
2092                                        const void *pattern,
2093                                        size_t pattern_size,
2094                                        size_t size,
2095                                        cl_uint num_events_in_wait_list,
2096                                        const cl_event *event_wait_list,
2097                                        cl_event *event)
2098 {
2099     CL_EVENT(EnqueueSVMMemFill,
2100              "command_queue = 0x%016" PRIxPTR ", svm_ptr = 0x%016" PRIxPTR
2101              ", pattern = 0x%016" PRIxPTR
2102              ", pattern_size = %zu, size = %zu, num_events_in_wait_list = %u, event_wait_list = "
2103              "0x%016" PRIxPTR ", event = 0x%016" PRIxPTR "",
2104              (uintptr_t)command_queue, (uintptr_t)svm_ptr, (uintptr_t)pattern, pattern_size, size,
2105              num_events_in_wait_list, (uintptr_t)event_wait_list, (uintptr_t)event);
2106 
2107     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMMemFill, command_queue, svm_ptr, pattern, pattern_size, size,
2108                             num_events_in_wait_list, event_wait_list, event);
2109 
2110     return EnqueueSVMMemFill(command_queue, svm_ptr, pattern, pattern_size, size,
2111                              num_events_in_wait_list, event_wait_list, event);
2112 }
2113 
clEnqueueSVMMap(cl_command_queue command_queue,cl_bool blocking_map,cl_map_flags flags,void * svm_ptr,size_t size,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2114 cl_int CL_API_CALL clEnqueueSVMMap(cl_command_queue command_queue,
2115                                    cl_bool blocking_map,
2116                                    cl_map_flags flags,
2117                                    void *svm_ptr,
2118                                    size_t size,
2119                                    cl_uint num_events_in_wait_list,
2120                                    const cl_event *event_wait_list,
2121                                    cl_event *event)
2122 {
2123     CL_EVENT(EnqueueSVMMap,
2124              "command_queue = 0x%016" PRIxPTR
2125              ", blocking_map = %u, flags = %llu, svm_ptr = 0x%016" PRIxPTR
2126              ", size = %zu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
2127              ", event = 0x%016" PRIxPTR "",
2128              (uintptr_t)command_queue, blocking_map, static_cast<unsigned long long>(flags),
2129              (uintptr_t)svm_ptr, size, num_events_in_wait_list, (uintptr_t)event_wait_list,
2130              (uintptr_t)event);
2131 
2132     MapFlags flagsPacked = PackParam<MapFlags>(flags);
2133 
2134     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMMap, command_queue, blocking_map, flagsPacked, svm_ptr, size,
2135                             num_events_in_wait_list, event_wait_list, event);
2136 
2137     return EnqueueSVMMap(command_queue, blocking_map, flagsPacked, svm_ptr, size,
2138                          num_events_in_wait_list, event_wait_list, event);
2139 }
2140 
clEnqueueSVMUnmap(cl_command_queue command_queue,void * svm_ptr,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2141 cl_int CL_API_CALL clEnqueueSVMUnmap(cl_command_queue command_queue,
2142                                      void *svm_ptr,
2143                                      cl_uint num_events_in_wait_list,
2144                                      const cl_event *event_wait_list,
2145                                      cl_event *event)
2146 {
2147     CL_EVENT(EnqueueSVMUnmap,
2148              "command_queue = 0x%016" PRIxPTR ", svm_ptr = 0x%016" PRIxPTR
2149              ", num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
2150              ", event = 0x%016" PRIxPTR "",
2151              (uintptr_t)command_queue, (uintptr_t)svm_ptr, num_events_in_wait_list,
2152              (uintptr_t)event_wait_list, (uintptr_t)event);
2153 
2154     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMUnmap, command_queue, svm_ptr, num_events_in_wait_list,
2155                             event_wait_list, event);
2156 
2157     return EnqueueSVMUnmap(command_queue, svm_ptr, num_events_in_wait_list, event_wait_list, event);
2158 }
2159 
2160 // CL 2.1
clSetDefaultDeviceCommandQueue(cl_context context,cl_device_id device,cl_command_queue command_queue)2161 cl_int CL_API_CALL clSetDefaultDeviceCommandQueue(cl_context context,
2162                                                   cl_device_id device,
2163                                                   cl_command_queue command_queue)
2164 {
2165     CL_EVENT(SetDefaultDeviceCommandQueue,
2166              "context = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR
2167              ", command_queue = 0x%016" PRIxPTR "",
2168              (uintptr_t)context, (uintptr_t)device, (uintptr_t)command_queue);
2169 
2170     ANGLE_CL_VALIDATE_ERROR(SetDefaultDeviceCommandQueue, context, device, command_queue);
2171 
2172     return SetDefaultDeviceCommandQueue(context, device, command_queue);
2173 }
2174 
clGetDeviceAndHostTimer(cl_device_id device,cl_ulong * device_timestamp,cl_ulong * host_timestamp)2175 cl_int CL_API_CALL clGetDeviceAndHostTimer(cl_device_id device,
2176                                            cl_ulong *device_timestamp,
2177                                            cl_ulong *host_timestamp)
2178 {
2179     CL_EVENT(GetDeviceAndHostTimer,
2180              "device = 0x%016" PRIxPTR ", device_timestamp = 0x%016" PRIxPTR
2181              ", host_timestamp = 0x%016" PRIxPTR "",
2182              (uintptr_t)device, (uintptr_t)device_timestamp, (uintptr_t)host_timestamp);
2183 
2184     ANGLE_CL_VALIDATE_ERROR(GetDeviceAndHostTimer, device, device_timestamp, host_timestamp);
2185 
2186     return GetDeviceAndHostTimer(device, device_timestamp, host_timestamp);
2187 }
2188 
clGetHostTimer(cl_device_id device,cl_ulong * host_timestamp)2189 cl_int CL_API_CALL clGetHostTimer(cl_device_id device, cl_ulong *host_timestamp)
2190 {
2191     CL_EVENT(GetHostTimer, "device = 0x%016" PRIxPTR ", host_timestamp = 0x%016" PRIxPTR "",
2192              (uintptr_t)device, (uintptr_t)host_timestamp);
2193 
2194     ANGLE_CL_VALIDATE_ERROR(GetHostTimer, device, host_timestamp);
2195 
2196     return GetHostTimer(device, host_timestamp);
2197 }
2198 
clCreateProgramWithIL(cl_context context,const void * il,size_t length,cl_int * errcode_ret)2199 cl_program CL_API_CALL clCreateProgramWithIL(cl_context context,
2200                                              const void *il,
2201                                              size_t length,
2202                                              cl_int *errcode_ret)
2203 {
2204     CL_EVENT(CreateProgramWithIL,
2205              "context = 0x%016" PRIxPTR ", il = 0x%016" PRIxPTR
2206              ", length = %zu, errcode_ret = 0x%016" PRIxPTR "",
2207              (uintptr_t)context, (uintptr_t)il, length, (uintptr_t)errcode_ret);
2208 
2209     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateProgramWithIL, context, il, length);
2210 
2211     cl_int errorCode  = CL_SUCCESS;
2212     cl_program object = CreateProgramWithIL(context, il, length, errorCode);
2213 
2214     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
2215     if (errcode_ret != nullptr)
2216     {
2217         *errcode_ret = errorCode;
2218     }
2219     return object;
2220 }
2221 
clCloneKernel(cl_kernel source_kernel,cl_int * errcode_ret)2222 cl_kernel CL_API_CALL clCloneKernel(cl_kernel source_kernel, cl_int *errcode_ret)
2223 {
2224     CL_EVENT(CloneKernel, "source_kernel = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
2225              (uintptr_t)source_kernel, (uintptr_t)errcode_ret);
2226 
2227     ANGLE_CL_VALIDATE_ERRCODE_RET(CloneKernel, source_kernel);
2228 
2229     cl_int errorCode = CL_SUCCESS;
2230     cl_kernel object = CloneKernel(source_kernel, errorCode);
2231 
2232     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
2233     if (errcode_ret != nullptr)
2234     {
2235         *errcode_ret = errorCode;
2236     }
2237     return object;
2238 }
2239 
clGetKernelSubGroupInfo(cl_kernel kernel,cl_device_id device,cl_kernel_sub_group_info param_name,size_t input_value_size,const void * input_value,size_t param_value_size,void * param_value,size_t * param_value_size_ret)2240 cl_int CL_API_CALL clGetKernelSubGroupInfo(cl_kernel kernel,
2241                                            cl_device_id device,
2242                                            cl_kernel_sub_group_info param_name,
2243                                            size_t input_value_size,
2244                                            const void *input_value,
2245                                            size_t param_value_size,
2246                                            void *param_value,
2247                                            size_t *param_value_size_ret)
2248 {
2249     CL_EVENT(GetKernelSubGroupInfo,
2250              "kernel = 0x%016" PRIxPTR ", device = 0x%016" PRIxPTR
2251              ", param_name = %u, input_value_size = %zu, input_value = 0x%016" PRIxPTR
2252              ", param_value_size = %zu, param_value = 0x%016" PRIxPTR
2253              ", param_value_size_ret = 0x%016" PRIxPTR "",
2254              (uintptr_t)kernel, (uintptr_t)device, param_name, input_value_size,
2255              (uintptr_t)input_value, param_value_size, (uintptr_t)param_value,
2256              (uintptr_t)param_value_size_ret);
2257 
2258     KernelSubGroupInfo param_namePacked = PackParam<KernelSubGroupInfo>(param_name);
2259 
2260     ANGLE_CL_VALIDATE_ERROR(GetKernelSubGroupInfo, kernel, device, param_namePacked,
2261                             input_value_size, input_value, param_value_size, param_value,
2262                             param_value_size_ret);
2263 
2264     return GetKernelSubGroupInfo(kernel, device, param_namePacked, input_value_size, input_value,
2265                                  param_value_size, param_value, param_value_size_ret);
2266 }
2267 
clEnqueueSVMMigrateMem(cl_command_queue command_queue,cl_uint num_svm_pointers,const void ** svm_pointers,const size_t * sizes,cl_mem_migration_flags flags,cl_uint num_events_in_wait_list,const cl_event * event_wait_list,cl_event * event)2268 cl_int CL_API_CALL clEnqueueSVMMigrateMem(cl_command_queue command_queue,
2269                                           cl_uint num_svm_pointers,
2270                                           const void **svm_pointers,
2271                                           const size_t *sizes,
2272                                           cl_mem_migration_flags flags,
2273                                           cl_uint num_events_in_wait_list,
2274                                           const cl_event *event_wait_list,
2275                                           cl_event *event)
2276 {
2277     CL_EVENT(EnqueueSVMMigrateMem,
2278              "command_queue = 0x%016" PRIxPTR
2279              ", num_svm_pointers = %u, svm_pointers = 0x%016" PRIxPTR ", sizes = 0x%016" PRIxPTR
2280              ", flags = %llu, num_events_in_wait_list = %u, event_wait_list = 0x%016" PRIxPTR
2281              ", event = 0x%016" PRIxPTR "",
2282              (uintptr_t)command_queue, num_svm_pointers, (uintptr_t)svm_pointers, (uintptr_t)sizes,
2283              static_cast<unsigned long long>(flags), num_events_in_wait_list,
2284              (uintptr_t)event_wait_list, (uintptr_t)event);
2285 
2286     MemMigrationFlags flagsPacked = PackParam<MemMigrationFlags>(flags);
2287 
2288     ANGLE_CL_VALIDATE_ERROR(EnqueueSVMMigrateMem, command_queue, num_svm_pointers, svm_pointers,
2289                             sizes, flagsPacked, num_events_in_wait_list, event_wait_list, event);
2290 
2291     return EnqueueSVMMigrateMem(command_queue, num_svm_pointers, svm_pointers, sizes, flagsPacked,
2292                                 num_events_in_wait_list, event_wait_list, event);
2293 }
2294 
2295 // CL 2.2
clSetProgramReleaseCallback(cl_program program,void (CL_CALLBACK * pfn_notify)(cl_program program,void * user_data),void * user_data)2296 cl_int CL_API_CALL clSetProgramReleaseCallback(cl_program program,
2297                                                void(CL_CALLBACK *pfn_notify)(cl_program program,
2298                                                                              void *user_data),
2299                                                void *user_data)
2300 {
2301     CL_EVENT(SetProgramReleaseCallback,
2302              "program = 0x%016" PRIxPTR ", pfn_notify = 0x%016" PRIxPTR
2303              ", user_data = 0x%016" PRIxPTR "",
2304              (uintptr_t)program, (uintptr_t)pfn_notify, (uintptr_t)user_data);
2305 
2306     ANGLE_CL_VALIDATE_ERROR(SetProgramReleaseCallback, program, pfn_notify, user_data);
2307 
2308     return SetProgramReleaseCallback(program, pfn_notify, user_data);
2309 }
2310 
clSetProgramSpecializationConstant(cl_program program,cl_uint spec_id,size_t spec_size,const void * spec_value)2311 cl_int CL_API_CALL clSetProgramSpecializationConstant(cl_program program,
2312                                                       cl_uint spec_id,
2313                                                       size_t spec_size,
2314                                                       const void *spec_value)
2315 {
2316     CL_EVENT(SetProgramSpecializationConstant,
2317              "program = 0x%016" PRIxPTR
2318              ", spec_id = %u, spec_size = %zu, spec_value = 0x%016" PRIxPTR "",
2319              (uintptr_t)program, spec_id, spec_size, (uintptr_t)spec_value);
2320 
2321     ANGLE_CL_VALIDATE_ERROR(SetProgramSpecializationConstant, program, spec_id, spec_size,
2322                             spec_value);
2323 
2324     return SetProgramSpecializationConstant(program, spec_id, spec_size, spec_value);
2325 }
2326 
2327 // CL 3.0
clSetContextDestructorCallback(cl_context context,void (CL_CALLBACK * pfn_notify)(cl_context context,void * user_data),void * user_data)2328 cl_int CL_API_CALL clSetContextDestructorCallback(cl_context context,
2329                                                   void(CL_CALLBACK *pfn_notify)(cl_context context,
2330                                                                                 void *user_data),
2331                                                   void *user_data)
2332 {
2333     CL_EVENT(SetContextDestructorCallback,
2334              "context = 0x%016" PRIxPTR ", pfn_notify = 0x%016" PRIxPTR
2335              ", user_data = 0x%016" PRIxPTR "",
2336              (uintptr_t)context, (uintptr_t)pfn_notify, (uintptr_t)user_data);
2337 
2338     ANGLE_CL_VALIDATE_ERROR(SetContextDestructorCallback, context, pfn_notify, user_data);
2339 
2340     return SetContextDestructorCallback(context, pfn_notify, user_data);
2341 }
2342 
clCreateBufferWithProperties(cl_context context,const cl_mem_properties * properties,cl_mem_flags flags,size_t size,void * host_ptr,cl_int * errcode_ret)2343 cl_mem CL_API_CALL clCreateBufferWithProperties(cl_context context,
2344                                                 const cl_mem_properties *properties,
2345                                                 cl_mem_flags flags,
2346                                                 size_t size,
2347                                                 void *host_ptr,
2348                                                 cl_int *errcode_ret)
2349 {
2350     CL_EVENT(CreateBufferWithProperties,
2351              "context = 0x%016" PRIxPTR ", properties = 0x%016" PRIxPTR
2352              ", flags = %llu, size = %zu, host_ptr = 0x%016" PRIxPTR
2353              ", errcode_ret = 0x%016" PRIxPTR "",
2354              (uintptr_t)context, (uintptr_t)properties, static_cast<unsigned long long>(flags),
2355              size, (uintptr_t)host_ptr, (uintptr_t)errcode_ret);
2356 
2357     MemFlags flagsPacked = PackParam<MemFlags>(flags);
2358 
2359     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateBufferWithProperties, context, properties, flagsPacked,
2360                                   size, host_ptr);
2361 
2362     cl_int errorCode = CL_SUCCESS;
2363     cl_mem object =
2364         CreateBufferWithProperties(context, properties, flagsPacked, size, host_ptr, errorCode);
2365 
2366     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
2367     if (errcode_ret != nullptr)
2368     {
2369         *errcode_ret = errorCode;
2370     }
2371     return object;
2372 }
2373 
clCreateImageWithProperties(cl_context context,const cl_mem_properties * properties,cl_mem_flags flags,const cl_image_format * image_format,const cl_image_desc * image_desc,void * host_ptr,cl_int * errcode_ret)2374 cl_mem CL_API_CALL clCreateImageWithProperties(cl_context context,
2375                                                const cl_mem_properties *properties,
2376                                                cl_mem_flags flags,
2377                                                const cl_image_format *image_format,
2378                                                const cl_image_desc *image_desc,
2379                                                void *host_ptr,
2380                                                cl_int *errcode_ret)
2381 {
2382     CL_EVENT(CreateImageWithProperties,
2383              "context = 0x%016" PRIxPTR ", properties = 0x%016" PRIxPTR
2384              ", flags = %llu, image_format = 0x%016" PRIxPTR ", image_desc = 0x%016" PRIxPTR
2385              ", host_ptr = 0x%016" PRIxPTR ", errcode_ret = 0x%016" PRIxPTR "",
2386              (uintptr_t)context, (uintptr_t)properties, static_cast<unsigned long long>(flags),
2387              (uintptr_t)image_format, (uintptr_t)image_desc, (uintptr_t)host_ptr,
2388              (uintptr_t)errcode_ret);
2389 
2390     MemFlags flagsPacked = PackParam<MemFlags>(flags);
2391 
2392     ANGLE_CL_VALIDATE_ERRCODE_RET(CreateImageWithProperties, context, properties, flagsPacked,
2393                                   image_format, image_desc, host_ptr);
2394 
2395     cl_int errorCode = CL_SUCCESS;
2396     cl_mem object    = CreateImageWithProperties(context, properties, flagsPacked, image_format,
2397                                               image_desc, host_ptr, errorCode);
2398 
2399     ASSERT((errorCode == CL_SUCCESS) == (object != nullptr));
2400     if (errcode_ret != nullptr)
2401     {
2402         *errcode_ret = errorCode;
2403     }
2404     return object;
2405 }
2406 
2407 // cl_khr_icd
clIcdGetPlatformIDsKHR(cl_uint num_entries,cl_platform_id * platforms,cl_uint * num_platforms)2408 cl_int CL_API_CALL clIcdGetPlatformIDsKHR(cl_uint num_entries,
2409                                           cl_platform_id *platforms,
2410                                           cl_uint *num_platforms)
2411 {
2412     InitBackEnds(true);
2413 
2414     CL_EVENT(IcdGetPlatformIDsKHR,
2415              "num_entries = %u, platforms = 0x%016" PRIxPTR ", num_platforms = 0x%016" PRIxPTR "",
2416              num_entries, (uintptr_t)platforms, (uintptr_t)num_platforms);
2417 
2418     ANGLE_CL_VALIDATE_ERROR(IcdGetPlatformIDsKHR, num_entries, platforms, num_platforms);
2419 
2420     return IcdGetPlatformIDsKHR(num_entries, platforms, num_platforms);
2421 }
2422 
2423 }  // namespace cl
2424