opencl-bindings 1.0.0pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/lib/opencl.rb +1347 -0
- data/lib/opencl_ext.rb +311 -0
- data/lib/opencl_gl.rb +119 -0
- data/lib/opencl_gl_ext.rb +115 -0
- data/sample/hello.cl +19 -0
- data/sample/hello.rb +69 -0
- data/sample/hello_clu.rb +59 -0
- data/sample/util/clu.rb +1470 -0
- metadata +56 -0
data/lib/opencl_ext.rb
ADDED
@@ -0,0 +1,311 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'fiddle/import'
|
3
|
+
require_relative 'opencl'
|
4
|
+
|
5
|
+
# OpenCL 1.2 - Platform-dependent extensions
|
6
|
+
|
7
|
+
module OpenCL
|
8
|
+
|
9
|
+
#
|
10
|
+
# cl_khr_fp16 extension
|
11
|
+
#
|
12
|
+
|
13
|
+
CL_DEVICE_HALF_FP_CONFIG = 0x1033
|
14
|
+
|
15
|
+
#
|
16
|
+
# cl_khr_icd
|
17
|
+
#
|
18
|
+
|
19
|
+
# cl_platform_info
|
20
|
+
CL_PLATFORM_ICD_SUFFIX_KHR = 0x0920
|
21
|
+
|
22
|
+
# Additional Error Codes
|
23
|
+
CL_PLATFORM_NOT_FOUND_KHR = -1001
|
24
|
+
|
25
|
+
#
|
26
|
+
# cl_khr_initalize_memory
|
27
|
+
#
|
28
|
+
|
29
|
+
CL_CONTEXT_MEMORY_INITIALIZE_KHR = 0x200E
|
30
|
+
|
31
|
+
#
|
32
|
+
# cl_khr_terminate_context
|
33
|
+
#
|
34
|
+
|
35
|
+
CL_DEVICE_TERMINATE_CAPABILITY_KHR = 0x200F
|
36
|
+
CL_CONTEXT_TERMINATE_KHR = 0x2010
|
37
|
+
|
38
|
+
#
|
39
|
+
# cl_khr_spir
|
40
|
+
#
|
41
|
+
|
42
|
+
CL_DEVICE_SPIR_VERSIONS = 0x40E0
|
43
|
+
CL_PROGRAM_BINARY_TYPE_INTERMEDIATE = 0x40E1
|
44
|
+
|
45
|
+
#
|
46
|
+
# cl_nv_device_attribute_query
|
47
|
+
#
|
48
|
+
|
49
|
+
CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000
|
50
|
+
CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001
|
51
|
+
CL_DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002
|
52
|
+
CL_DEVICE_WARP_SIZE_NV = 0x4003
|
53
|
+
CL_DEVICE_GPU_OVERLAP_NV = 0x4004
|
54
|
+
CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005
|
55
|
+
CL_DEVICE_INTEGRATED_MEMORY_NV = 0x4006
|
56
|
+
|
57
|
+
#
|
58
|
+
# cl_amd_device_attribute_query
|
59
|
+
#
|
60
|
+
|
61
|
+
CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036
|
62
|
+
|
63
|
+
#
|
64
|
+
# cl_arm_printf
|
65
|
+
#
|
66
|
+
|
67
|
+
CL_PRINTF_CALLBACK_ARM = 0x40B0
|
68
|
+
CL_PRINTF_BUFFERSIZE_ARM = 0x40B1
|
69
|
+
|
70
|
+
# cl_device_partition_property_ext
|
71
|
+
CL_DEVICE_PARTITION_EQUALLY_EXT = 0x4050
|
72
|
+
CL_DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051
|
73
|
+
CL_DEVICE_PARTITION_BY_NAMES_EXT = 0x4052
|
74
|
+
CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053
|
75
|
+
|
76
|
+
# clDeviceGetInfo selectors
|
77
|
+
CL_DEVICE_PARENT_DEVICE_EXT = 0x4054
|
78
|
+
CL_DEVICE_PARTITION_TYPES_EXT = 0x4055
|
79
|
+
CL_DEVICE_AFFINITY_DOMAINS_EXT = 0x4056
|
80
|
+
CL_DEVICE_REFERENCE_COUNT_EXT = 0x4057
|
81
|
+
CL_DEVICE_PARTITION_STYLE_EXT = 0x4058
|
82
|
+
|
83
|
+
# error codes
|
84
|
+
CL_DEVICE_PARTITION_FAILED_EXT = -1057
|
85
|
+
CL_INVALID_PARTITION_COUNT_EXT = -1058
|
86
|
+
CL_INVALID_PARTITION_NAME_EXT = -1059
|
87
|
+
|
88
|
+
# CL_AFFINITY_DOMAINs
|
89
|
+
CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1
|
90
|
+
CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2
|
91
|
+
CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3
|
92
|
+
CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4
|
93
|
+
CL_AFFINITY_DOMAIN_NUMA_EXT = 0x10
|
94
|
+
CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100
|
95
|
+
|
96
|
+
# cl_device_partition_property_ext list terminators
|
97
|
+
CL_PROPERTIES_LIST_END_EXT = 0
|
98
|
+
CL_PARTITION_BY_COUNTS_LIST_END_EXT = 0
|
99
|
+
CL_PARTITION_BY_NAMES_LIST_END_EXT = CL_ULONG_MAX # ((cl_device_partition_property_ext) 0 - 1)
|
100
|
+
|
101
|
+
#
|
102
|
+
# cl_qcom_ext_host_ptr
|
103
|
+
#
|
104
|
+
|
105
|
+
CL_MEM_EXT_HOST_PTR_QCOM = (1 << 29)
|
106
|
+
|
107
|
+
CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM = 0x40A0
|
108
|
+
CL_DEVICE_PAGE_SIZE_QCOM = 0x40A1
|
109
|
+
CL_IMAGE_ROW_ALIGNMENT_QCOM = 0x40A2
|
110
|
+
CL_IMAGE_SLICE_ALIGNMENT_QCOM = 0x40A3
|
111
|
+
CL_MEM_HOST_UNCACHED_QCOM = 0x40A4
|
112
|
+
CL_MEM_HOST_WRITEBACK_QCOM = 0x40A5
|
113
|
+
CL_MEM_HOST_WRITETHROUGH_QCOM = 0x40A6
|
114
|
+
CL_MEM_HOST_WRITE_COMBINING_QCOM = 0x40A7
|
115
|
+
|
116
|
+
#
|
117
|
+
# cl_qcom_ion_host_ptr
|
118
|
+
#
|
119
|
+
|
120
|
+
CL_MEM_ION_HOST_PTR_QCOM = 0x40A8
|
121
|
+
|
122
|
+
#
|
123
|
+
# cl_APPLE_query_kernel_names (from /OpenCL.framework/Headers/cl_ext.h)
|
124
|
+
#
|
125
|
+
|
126
|
+
CL_PROGRAM_NUM_KERNELS_APPLE = 0x10000004
|
127
|
+
CL_PROGRAM_KERNEL_NAMES_APPLE = 0x10000005
|
128
|
+
|
129
|
+
#
|
130
|
+
# cl_APPLE_fixed_alpha_channel_orders (from /OpenCL.framework/Headers/cl_ext.h)
|
131
|
+
#
|
132
|
+
|
133
|
+
CL_1RGB_APPLE = 0x10000006
|
134
|
+
CL_BGR1_APPLE = 0x10000007
|
135
|
+
|
136
|
+
#
|
137
|
+
# cl_APPLE_biased_fixed_point_image_formats (from /OpenCL.framework/Headers/cl_ext.h)
|
138
|
+
#
|
139
|
+
|
140
|
+
CL_SFIXED14_APPLE = 0x10000008
|
141
|
+
CL_BIASED_HALF_APPLE = 0x10000009
|
142
|
+
|
143
|
+
#
|
144
|
+
# YUV image support (from /OpenCL.framework/Headers/cl_ext.h)
|
145
|
+
#
|
146
|
+
|
147
|
+
CL_YCbYCr_APPLE = 0x10000010
|
148
|
+
CL_CbYCrY_APPLE = 0x10000011
|
149
|
+
|
150
|
+
#
|
151
|
+
# ABGR and xBGR formats for CoreImage CL-GPU support (from /OpenCL.framework/Headers/cl_ext.h)
|
152
|
+
#
|
153
|
+
|
154
|
+
CL_ABGR_APPLE = 0x10000012
|
155
|
+
|
156
|
+
# cl_platform_id : platform
|
157
|
+
def self.import_ext(platform)
|
158
|
+
return false unless @@cl_import_done
|
159
|
+
|
160
|
+
#
|
161
|
+
# cl_APPLE_SetMemObjectDestructor
|
162
|
+
#
|
163
|
+
|
164
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clSetMemObjectDestructorAPPLE')
|
165
|
+
unless addr.null?
|
166
|
+
# cl_mem : memobj
|
167
|
+
# void* : pfn_notify(char *, void *, size_t, void *),
|
168
|
+
# void* : user_data
|
169
|
+
extern 'cl_int clSetMemObjectDestructorAPPLE(cl_mem, void*, void*)', func_addr: addr
|
170
|
+
end
|
171
|
+
|
172
|
+
#
|
173
|
+
# cl_APPLE_ContextLoggingFunctions
|
174
|
+
#
|
175
|
+
|
176
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clLogMessagesToSystemLogAPPLE')
|
177
|
+
unless addr.null?
|
178
|
+
# const char * : errstr
|
179
|
+
# const void * : private_info
|
180
|
+
# size_t : cb
|
181
|
+
# void * : user_data
|
182
|
+
extern 'void clLogMessagesToSystemLogAPPLE(const char*, const void*, size_t, void*)', func_addr: addr
|
183
|
+
end
|
184
|
+
|
185
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clLogMessagesToStdoutAPPLE')
|
186
|
+
unless addr.null?
|
187
|
+
# const char * : errstr
|
188
|
+
# const void * : private_info
|
189
|
+
# size_t : cb
|
190
|
+
# void * : user_data
|
191
|
+
extern 'void clLogMessagesToStdoutAPPLE(const char*, const void*, size_t, void*)', func_addr: addr
|
192
|
+
end
|
193
|
+
|
194
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clLogMessagesToStderrAPPLE')
|
195
|
+
unless addr.null?
|
196
|
+
# const char * : errstr
|
197
|
+
# const void * : private_info
|
198
|
+
# size_t : cb
|
199
|
+
# void * : user_data
|
200
|
+
extern 'void clLogMessagesToStderrAPPLE(const char*, const void*, size_t, void*)', func_addr: addr
|
201
|
+
end
|
202
|
+
|
203
|
+
#
|
204
|
+
# cl_khr_icd
|
205
|
+
#
|
206
|
+
|
207
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clIcdGetPlatformIDsKHR')
|
208
|
+
unless addr.null?
|
209
|
+
# cl_uint : num_entries
|
210
|
+
# cl_platform_id * : platforms
|
211
|
+
# cl_uint * : num_platforms
|
212
|
+
extern 'cl_int clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id *, cl_uint *)', func_addr: addr
|
213
|
+
end
|
214
|
+
|
215
|
+
#
|
216
|
+
# cl_khr_terminate_context
|
217
|
+
#
|
218
|
+
|
219
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clTerminateContextKHR')
|
220
|
+
unless addr.null?
|
221
|
+
# cl_context : context
|
222
|
+
extern 'cl_int clTerminateContextKHR(cl_context)', func_addr: addr
|
223
|
+
end
|
224
|
+
|
225
|
+
#
|
226
|
+
# cl_ext_device_fission
|
227
|
+
#
|
228
|
+
|
229
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clReleaseDeviceEXT')
|
230
|
+
unless addr.null?
|
231
|
+
# cl_device_id : device
|
232
|
+
extern 'cl_int clReleaseDeviceEXT(cl_device_id)', func_addr: addr
|
233
|
+
end
|
234
|
+
|
235
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clRetainDeviceEXT')
|
236
|
+
unless addr.null?
|
237
|
+
# cl_device_id : device
|
238
|
+
extern 'cl_int clRetainDeviceEXT(cl_device_id)', func_addr: addr
|
239
|
+
end
|
240
|
+
|
241
|
+
typealias 'cl_device_partition_property_ext', 'cl_ulong'
|
242
|
+
|
243
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clCreateSubDevicesEXT')
|
244
|
+
unless addr.null?
|
245
|
+
# cl_device_id : device
|
246
|
+
# const cl_device_partition_property_ext * : properties
|
247
|
+
# cl_uint : num_entries
|
248
|
+
# cl_device_id * : out_devices
|
249
|
+
# cl_uint * : num_devices
|
250
|
+
extern 'cl_int clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext *, cl_uint, cl_device_id *, cl_uint *)', func_addr: addr
|
251
|
+
end
|
252
|
+
|
253
|
+
#
|
254
|
+
# cl_qcom_ext_host_ptr
|
255
|
+
#
|
256
|
+
|
257
|
+
typealias 'cl_image_pitch_info_qcom', 'cl_uint'
|
258
|
+
|
259
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clGetDeviceImageInfoQCOM')
|
260
|
+
unless addr.null?
|
261
|
+
# cl_device_id : device
|
262
|
+
# size_t : image_width
|
263
|
+
# size_t : image_height
|
264
|
+
# const cl_image_format* : image_format
|
265
|
+
# cl_image_pitch_info_qcom : param_name
|
266
|
+
# size_t : param_value_size
|
267
|
+
# void* : param_value
|
268
|
+
# size_t* : param_value_size_ret
|
269
|
+
extern 'cl_int clGetDeviceImageInfoQCOM(cl_device_id, size_t, size_t, const cl_image_format*, cl_image_pitch_info_qcom, size_t, void*, size_t*)', func_addr: addr
|
270
|
+
end
|
271
|
+
|
272
|
+
cl_mem_ext_host_ptr = struct(["cl_uint allocation_type",
|
273
|
+
"cl_uint host_cache_policy"])
|
274
|
+
|
275
|
+
#
|
276
|
+
# cl_qcom_ion_host_ptr
|
277
|
+
#
|
278
|
+
|
279
|
+
cl_mem_ion_host_ptr = struct(["cl_uint ext_host_ptr_allocation_type", # ext_host_ptr.allocation_type
|
280
|
+
"cl_uint ext_host_ptr_host_cache_policy", # ext_host_ptr.host_cache_policy
|
281
|
+
"int ion_filedesc",
|
282
|
+
"void* ion_hostptr"])
|
283
|
+
|
284
|
+
return true
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
=begin
|
290
|
+
Ruby-OpenCL : Yet another OpenCL wrapper for Ruby
|
291
|
+
Copyright (c) 2015 vaiorabbit <http://twitter.com/vaiorabbit>
|
292
|
+
|
293
|
+
This software is provided 'as-is', without any express or implied
|
294
|
+
warranty. In no event will the authors be held liable for any damages
|
295
|
+
arising from the use of this software.
|
296
|
+
|
297
|
+
Permission is granted to anyone to use this software for any purpose,
|
298
|
+
including commercial applications, and to alter it and redistribute it
|
299
|
+
freely, subject to the following restrictions:
|
300
|
+
|
301
|
+
1. The origin of this software must not be misrepresented; you must not
|
302
|
+
claim that you wrote the original software. If you use this software
|
303
|
+
in a product, an acknowledgment in the product documentation would be
|
304
|
+
appreciated but is not required.
|
305
|
+
|
306
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
307
|
+
misrepresented as being the original software.
|
308
|
+
|
309
|
+
3. This notice may not be removed or altered from any source
|
310
|
+
distribution.
|
311
|
+
=end
|
data/lib/opencl_gl.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'fiddle/import'
|
3
|
+
require_relative 'opencl'
|
4
|
+
|
5
|
+
# OpenCL 1.2 - Functions for OpenGL interoperability
|
6
|
+
|
7
|
+
module OpenCL
|
8
|
+
|
9
|
+
# define (from cl_gl.h)
|
10
|
+
|
11
|
+
# cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken
|
12
|
+
CL_GL_OBJECT_BUFFER = 0x2000
|
13
|
+
CL_GL_OBJECT_TEXTURE2D = 0x2001
|
14
|
+
CL_GL_OBJECT_TEXTURE3D = 0x2002
|
15
|
+
CL_GL_OBJECT_RENDERBUFFER = 0x2003
|
16
|
+
CL_GL_OBJECT_TEXTURE2D_ARRAY = 0x200E
|
17
|
+
CL_GL_OBJECT_TEXTURE1D = 0x200F
|
18
|
+
CL_GL_OBJECT_TEXTURE1D_ARRAY = 0x2010
|
19
|
+
CL_GL_OBJECT_TEXTURE_BUFFER = 0x2011
|
20
|
+
|
21
|
+
# cl_gl_texture_info
|
22
|
+
CL_GL_TEXTURE_TARGET = 0x2004
|
23
|
+
CL_GL_MIPMAP_LEVEL = 0x2005
|
24
|
+
CL_GL_NUM_SAMPLES = 0x2012
|
25
|
+
|
26
|
+
@@cl_gl_import_done = false
|
27
|
+
|
28
|
+
def self.import_gl
|
29
|
+
|
30
|
+
return false unless @@cl_import_done
|
31
|
+
|
32
|
+
# type (from cl_gl.h)
|
33
|
+
|
34
|
+
# aliases
|
35
|
+
typealias 'cl_gl_object_type', 'cl_uint'
|
36
|
+
typealias 'cl_gl_texture_info', 'cl_uint'
|
37
|
+
typealias 'cl_gl_platform_info', 'cl_uint'
|
38
|
+
|
39
|
+
# opaque pointer
|
40
|
+
typealias 'cl_GLsync', 'void*'
|
41
|
+
|
42
|
+
# cl_context : context
|
43
|
+
# cl_mem_flags : flags
|
44
|
+
# cl_GLuint : bufobj
|
45
|
+
# int * : errcode_ret
|
46
|
+
extern 'cl_mem clCreateFromGLBuffer(cl_context, cl_mem_flags, cl_GLuint, int *)'
|
47
|
+
|
48
|
+
# cl_context : context
|
49
|
+
# cl_mem_flags : flags
|
50
|
+
# cl_GLenum : target
|
51
|
+
# cl_GLint : miplevel
|
52
|
+
# cl_GLuint : texture
|
53
|
+
# cl_int * : errcode_ret
|
54
|
+
extern 'cl_mem clCreateFromGLTexture(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int *)'
|
55
|
+
|
56
|
+
# cl_context : context
|
57
|
+
# cl_mem_flags : flags
|
58
|
+
# cl_GLuint : renderbuffer
|
59
|
+
# cl_int * : errcode_ret
|
60
|
+
extern 'cl_mem clCreateFromGLRenderbuffer(cl_context, cl_mem_flags, cl_GLuint, cl_int *)'
|
61
|
+
|
62
|
+
# cl_mem : memobj
|
63
|
+
# cl_gl_object_type * : gl_object_type
|
64
|
+
# cl_GLuint * : gl_object_name
|
65
|
+
extern 'cl_int clGetGLObjectInfo(cl_mem, cl_gl_object_type *, cl_GLuint *)'
|
66
|
+
|
67
|
+
# cl_mem : memobj
|
68
|
+
# cl_gl_texture_info : param_name
|
69
|
+
# size_t : param_value_size
|
70
|
+
# void * : param_value
|
71
|
+
# size_t * : param_value_size_ret
|
72
|
+
extern 'cl_int clGetGLTextureInfo(cl_mem, cl_gl_texture_info, size_t, void *, size_t *)'
|
73
|
+
|
74
|
+
# cl_command_queue : command_queue
|
75
|
+
# cl_uint : num_objects
|
76
|
+
# const cl_mem * : mem_objects
|
77
|
+
# cl_uint : num_events_in_wait_list
|
78
|
+
# const cl_event * : event_wait_list
|
79
|
+
# cl_event * : event
|
80
|
+
extern 'cl_int clEnqueueAcquireGLObjects(cl_command_queue, cl_uint, const cl_mem *, cl_uint, const cl_event *, cl_event *)'
|
81
|
+
|
82
|
+
# cl_command_queue : command_queue
|
83
|
+
# cl_uint : num_objects
|
84
|
+
# const cl_mem * : mem_objects
|
85
|
+
# cl_uint : num_events_in_wait_list
|
86
|
+
# const cl_event * : event_wait_list
|
87
|
+
# cl_event * : event
|
88
|
+
extern 'cl_int clEnqueueReleaseGLObjects(cl_command_queue, cl_uint, const cl_mem *, cl_uint, const cl_event *, cl_event *)'
|
89
|
+
|
90
|
+
@@cl_gl_import_done = true
|
91
|
+
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
=begin
|
98
|
+
Ruby-OpenCL : Yet another OpenCL wrapper for Ruby
|
99
|
+
Copyright (c) 2015 vaiorabbit <http://twitter.com/vaiorabbit>
|
100
|
+
|
101
|
+
This software is provided 'as-is', without any express or implied
|
102
|
+
warranty. In no event will the authors be held liable for any damages
|
103
|
+
arising from the use of this software.
|
104
|
+
|
105
|
+
Permission is granted to anyone to use this software for any purpose,
|
106
|
+
including commercial applications, and to alter it and redistribute it
|
107
|
+
freely, subject to the following restrictions:
|
108
|
+
|
109
|
+
1. The origin of this software must not be misrepresented; you must not
|
110
|
+
claim that you wrote the original software. If you use this software
|
111
|
+
in a product, an acknowledgment in the product documentation would be
|
112
|
+
appreciated but is not required.
|
113
|
+
|
114
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
115
|
+
misrepresented as being the original software.
|
116
|
+
|
117
|
+
3. This notice may not be removed or altered from any source
|
118
|
+
distribution.
|
119
|
+
=end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'fiddle/import'
|
3
|
+
require_relative 'opencl'
|
4
|
+
|
5
|
+
# OpenCL 1.2 - Extensions for OpenGL interoperability
|
6
|
+
|
7
|
+
module OpenCL
|
8
|
+
|
9
|
+
#
|
10
|
+
# cl_khr_gl_sharing
|
11
|
+
#
|
12
|
+
|
13
|
+
# Additional Error Codes
|
14
|
+
CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000
|
15
|
+
|
16
|
+
# cl_gl_context_info
|
17
|
+
CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006
|
18
|
+
CL_DEVICES_FOR_GL_CONTEXT_KHR = 0x2007
|
19
|
+
|
20
|
+
# Additional cl_context_properties
|
21
|
+
CL_GL_CONTEXT_KHR = 0x2008
|
22
|
+
CL_EGL_DISPLAY_KHR = 0x2009
|
23
|
+
CL_GLX_DISPLAY_KHR = 0x200A
|
24
|
+
CL_WGL_HDC_KHR = 0x200B
|
25
|
+
CL_CGL_SHAREGROUP_KHR = 0x200C
|
26
|
+
|
27
|
+
#
|
28
|
+
# cl_khr_gl_event
|
29
|
+
#
|
30
|
+
|
31
|
+
CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D
|
32
|
+
|
33
|
+
#
|
34
|
+
# cl_APPLE_gl_sharing
|
35
|
+
#
|
36
|
+
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE = 0x10000000
|
37
|
+
CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE = 0x10000002
|
38
|
+
CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE = 0x10000003
|
39
|
+
CL_INVALID_GL_CONTEXT_APPLE = -1000
|
40
|
+
|
41
|
+
# cl_platform_id : platform
|
42
|
+
def self.import_gl_ext(platform)
|
43
|
+
return false unless (@@cl_import_done && @@cl_gl_import_done)
|
44
|
+
|
45
|
+
#
|
46
|
+
# cl_khr_gl_sharing
|
47
|
+
#
|
48
|
+
|
49
|
+
typealias 'cl_gl_context_info', 'cl_uint'
|
50
|
+
|
51
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clGetGLContextInfoKHR')
|
52
|
+
unless addr.null?
|
53
|
+
# const cl_context_properties * : properties
|
54
|
+
# cl_gl_context_info : param_name
|
55
|
+
# size_t : param_value_size
|
56
|
+
# void * : param_value
|
57
|
+
# size_t * : param_value_size_ret
|
58
|
+
extern 'cl_int clGetGLContextInfoKHR(const cl_context_properties*, cl_gl_context_info, size_t, void*, size_t*)', func_addr: addr
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# cl_khr_gl_event
|
63
|
+
#
|
64
|
+
|
65
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clCreateEventFromGLsyncKHR')
|
66
|
+
unless addr.null?
|
67
|
+
# cl_context : context
|
68
|
+
# cl_GLsync : cl_GLsync
|
69
|
+
# cl_int * : errcode_ret
|
70
|
+
extern 'cl_event clCreateEventFromGLsyncKHR(cl_context, cl_GLsync, cl_int*)', func_addr: addr
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# cl_APPLE_gl_sharing
|
75
|
+
#
|
76
|
+
|
77
|
+
addr = clGetExtensionFunctionAddressForPlatform(platform, 'clGetGLContextInfoAPPLE')
|
78
|
+
unless addr.null?
|
79
|
+
# cl_context : context
|
80
|
+
# void * : platform_gl_ctx
|
81
|
+
# cl_gl_platform_info : param_name
|
82
|
+
# size_t : param_value_size
|
83
|
+
# void * : param_value
|
84
|
+
# size_t * : param_value_size_ret
|
85
|
+
extern 'cl_int clGetGLContextInfoAPPLE ( cl_context, void *, cl_gl_platform_info, size_t, void *, size_t *)', func_addr: addr
|
86
|
+
end
|
87
|
+
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
=begin
|
94
|
+
Ruby-OpenCL : Yet another OpenCL wrapper for Ruby
|
95
|
+
Copyright (c) 2015 vaiorabbit <http://twitter.com/vaiorabbit>
|
96
|
+
|
97
|
+
This software is provided 'as-is', without any express or implied
|
98
|
+
warranty. In no event will the authors be held liable for any damages
|
99
|
+
arising from the use of this software.
|
100
|
+
|
101
|
+
Permission is granted to anyone to use this software for any purpose,
|
102
|
+
including commercial applications, and to alter it and redistribute it
|
103
|
+
freely, subject to the following restrictions:
|
104
|
+
|
105
|
+
1. The origin of this software must not be misrepresented; you must not
|
106
|
+
claim that you wrote the original software. If you use this software
|
107
|
+
in a product, an acknowledgment in the product documentation would be
|
108
|
+
appreciated but is not required.
|
109
|
+
|
110
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
111
|
+
misrepresented as being the original software.
|
112
|
+
|
113
|
+
3. This notice may not be removed or altered from any source
|
114
|
+
distribution.
|
115
|
+
=end
|