CL_GL.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. (******************************************************************************
  2. * Copyright (c) 2011 The Khronos Group Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and/or associated documentation files (the
  6. * "Materials"), to deal in the Materials without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Materials, and to
  9. * permit persons to whom the Materials are furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included
  13. * in all copies or substantial portions of the Materials.
  14. *
  15. * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
  22. ******************************************************************************)
  23. (************************************************************************)
  24. (* *)
  25. (* OpenCL1.2 and Delphi and Windows *)
  26. (* *)
  27. (* headers versions: 0.07 *)
  28. (* file name : CL_GL.pas *)
  29. (* last modify : 10.12.11 *)
  30. (* license : BSD *)
  31. (* *)
  32. (* created by : Maksym Tymkovych (niello) *)
  33. (* Site : www.niello.org.ua *)
  34. (* e-mail : [email protected] *)
  35. (* ICQ : 446-769-253 *)
  36. (* *)
  37. (* updated by : Alexander Kiselev (Igroman) *)
  38. (* Site : http://Igroman14.livejournal.com *)
  39. (* e-mail : [email protected] *)
  40. (* ICQ : 207-381-695 *)
  41. (* (c) 2010 *)
  42. (* *)
  43. (********************** Copyright (c) niello 2008-2011 ******************)
  44. (*
  45. * cl_gl.h contains Khronos-approved (KHR) OpenCL extensions which have
  46. * OpenGL dependencies. The application is responsible for #including
  47. * OpenGL or OpenGL ES headers before #including cl_gl.h.
  48. *)
  49. unit CL_GL;
  50. interface
  51. {$INCLUDE OpenCL.inc}
  52. uses
  53. dglOpenGL,
  54. CL,
  55. CL_Platform;
  56. type
  57. PCL_gl_object_type = ^TCL_gl_object_type;
  58. TCL_gl_object_type = TCL_uint;
  59. PCL_gl_texture_info = ^TCL_gl_texture_info;
  60. TCL_gl_texture_info = TCL_uint;
  61. PCL_gl_platform_info= ^TCL_gl_platform_info;
  62. TCL_gl_platform_info= TCL_uint;
  63. Tcl_GLsync = ^Integer;
  64. const
  65. (* cl_gl_object_type *)
  66. CL_GL_OBJECT_BUFFER = $2000;
  67. CL_GL_OBJECT_TEXTURE2D = $2001;
  68. CL_GL_OBJECT_TEXTURE3D = $2002;
  69. CL_GL_OBJECT_RENDERBUFFER = $2003;
  70. (* cl_gl_texture_info *)
  71. CL_GL_TEXTURE_TARGET = $2004;
  72. CL_GL_MIPMAP_LEVEL = $2005;
  73. (* Additional Error Codes *)
  74. (*
  75. Returned by clCreateContext, clCreateContextFromType, and
  76. clGetGLContextInfoKHR when an invalid OpenGL context or share group
  77. object handle is specified in <properties>:
  78. *)
  79. CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000;
  80. (* cl_gl_context_info *)
  81. (*
  82. Accepted as the <param_name> argument of clGetGLContextInfoKHR:
  83. *)
  84. CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = $2006;
  85. CL_DEVICES_FOR_GL_CONTEXT_KHR = $2007;
  86. (* Additional cl_context_properties *)
  87. (*
  88. Accepted as an attribute name in the 'properties' argument of
  89. clCreateContext and clCreateContextFromType:
  90. *)
  91. CL_GL_CONTEXT_KHR = $2008;
  92. CL_EGL_DISPLAY_KHR = $2009;
  93. CL_GLX_DISPLAY_KHR = $200A;
  94. CL_WGL_HDC_KHR = $200B;
  95. CL_CGL_SHAREGROUP_KHR = $200C;
  96. type
  97. {$IFDEF CL_VERSION_1_0}
  98. {$IFDEF DYNLINK}TclCreateFromGLBuffer = {$ENDIF}function {$IFNDEF DYNLINK}clCreateFromGLBuffer{$ENDIF}(
  99. context: Pcl_context; (* context *)
  100. flags: Tcl_mem_flags; (* flags *)
  101. bufobj: GLuint; (* bufobj *)
  102. errcode_ret: PInteger (* errcode_ret *)
  103. ): PCL_mem;
  104. extdecl; {$IFNDEF DYNLINK}external name 'clCreateFromGLBuffer';{$ENDIF}
  105. {$ENDIF}
  106. {$IFDEF CL_VERSION_1_0}
  107. {$IFDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
  108. {$IFDEF DYNLINK}TclCreateFromGLTexture2D = {$ENDIF}function {$IFNDEF DYNLINK}clCreateFromGLTexture2D{$ENDIF}(
  109. context: Pcl_context; (* context *)
  110. flags: Tcl_mem_flags; (* flags *)
  111. target: GLenum; (* target *)
  112. miplevel: GLint; (* miplevel *)
  113. texture: GLuint; (* texture *)
  114. errcode_ret: Pcl_int (* errcode_ret *)
  115. ): PCL_mem;
  116. extdecl; {$IFNDEF DYNLINK}external name 'clCreateFromGLTexture2D';{$ENDIF}
  117. {$ENDIF}
  118. {$ENDIF}
  119. {$IFDEF CL_VERSION_1_0}
  120. {$IFDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
  121. {$IFDEF DYNLINK}TclCreateFromGLTexture3D = {$ENDIF}function {$IFNDEF DYNLINK}clCreateFromGLTexture3D{$ENDIF}(
  122. context: Pcl_context; (* context *)
  123. flags: Tcl_mem_flags; (* flags *)
  124. target: GLenum; (* target *)
  125. miplevel: GLint; (* miplevel *)
  126. texture: GLuint; (* texture *)
  127. errcode_ret: Pcl_int (* errcode_ret *)
  128. ): PCL_mem;
  129. extdecl; {$IFNDEF DYNLINK}external name 'clCreateFromGLTexture3D';{$ENDIF}
  130. {$ENDIF}
  131. {$ENDIF}
  132. {$IFDEF CL_VERSION_1_2}
  133. {$IFDEF DYNLINK}TclCreateFromGLTexture = {$ENDIF}function {$IFNDEF DYNLINK}clCreateFromGLTexture{$ENDIF}(
  134. context: Pcl_context; (* context *)
  135. flags: Tcl_mem_flags; (* flags *)
  136. target: GLenum; (* target *)
  137. miplevel: GLint; (* miplevel *)
  138. texture: GLuint; (* texture *)
  139. errcode_ret: Pcl_int (* errcode_ret *)
  140. ): PCL_mem;
  141. extdecl; {$IFNDEF DYNLINK}external name 'clCreateFromGLTexture';{$ENDIF}
  142. {$ENDIF}
  143. {$IFDEF CL_VERSION_1_0}
  144. {$IFDEF DYNLINK}TclCreateFromGLRenderbuffer = {$ENDIF}function {$IFNDEF DYNLINK}clCreateFromGLRenderbuffer{$ENDIF}(
  145. context: Pcl_context; (* context *)
  146. flags: Tcl_mem_flags; (* flags *)
  147. renderbuffer: GLuint; (* renderbuffer *)
  148. errcode_ret: Pcl_int (* errcode_ret *)
  149. ): Pcl_mem;
  150. extdecl; {$IFNDEF DYNLINK}external name 'clCreateFromGLRenderbuffer';{$ENDIF}
  151. {$ENDIF}
  152. {$IFDEF CL_VERSION_1_0}
  153. {$IFDEF DYNLINK}TclGetGLObjectInfo = {$ENDIF}function {$IFNDEF DYNLINK}clGetGLObjectInfo{$ENDIF}(
  154. memobj: Pcl_mem; (* memobj *)
  155. gl_object_type: Pcl_gl_object_type; (* gl_object_type *)
  156. gl_object_name: PGLuint (* gl_object_name *)
  157. ): TCL_int;
  158. extdecl; {$IFNDEF DYNLINK}external name 'clGetGLObjectInfo';{$ENDIF}
  159. {$ENDIF}
  160. {$IFDEF CL_VERSION_1_0}
  161. {$IFDEF DYNLINK}TclGetGLTextureInfo = {$ENDIF}function {$IFNDEF DYNLINK}clGetGLTextureInfo{$ENDIF}(
  162. memobj: Pcl_mem; (* memobj *)
  163. param_name: Tcl_gl_texture_info; (* param_name *)
  164. param_value_size: Tsize_t; (* param_value_size *)
  165. param_value: Pointer; (* param_value *)
  166. param_value_size_ret: Psize_t (* param_value_size_ret *)
  167. ): TCL_int;
  168. extdecl; {$IFNDEF DYNLINK}external name 'clGetGLTextureInfo';{$ENDIF}
  169. {$ENDIF}
  170. {$IFDEF CL_VERSION_1_0}
  171. {$IFDEF DYNLINK}TclEnqueueAcquireGLObjects = {$ENDIF}function {$IFNDEF DYNLINK}clEnqueueAcquireGLObjects{$ENDIF}(
  172. command_queue: Pcl_command_queue; (* command_queue *)
  173. num_objects: Tcl_uint; (* num_objects *)
  174. const mem_objects: PPcl_mem; (* mem_objects *)
  175. num_events_in_wait_list: Tcl_uint; (* num_events_in_wait_list *)
  176. const event_wait_list: PPcl_event; (* event_wait_list *)
  177. event: PPcl_event (* event *)
  178. ): TCL_int;
  179. extdecl; {$IFNDEF DYNLINK}external name 'clEnqueueAcquireGLObjects';{$ENDIF}
  180. {$ENDIF}
  181. {$IFDEF CL_VERSION_1_0}
  182. {$IFDEF DYNLINK}TclEnqueueReleaseGLObjects = {$ENDIF}function {$IFNDEF DYNLINK}clEnqueueReleaseGLObjects{$ENDIF}(
  183. command_queue: Pcl_command_queue; (* command_queue *)
  184. num_objects: Tcl_uint; (* num_objects *)
  185. const mem_objects: PPcl_mem; (* mem_objects *)
  186. num_events_in_wait_list: Tcl_uint; (* num_events_in_wait_list *)
  187. const event_wait_list: PPcl_event; (* event_wait_list *)
  188. event: PPcl_event (* event *)
  189. ): TCL_int;
  190. extdecl; {$IFNDEF DYNLINK}external name 'clEnqueueReleaseGLObjects';{$ENDIF}
  191. {$ENDIF}
  192. type
  193. Pcl_gl_context_info = ^Tcl_gl_context_info;
  194. Tcl_gl_context_info = Tcl_uint;
  195. {$IFDEF CL_VERSION_1_0}
  196. {$IFDEF DYNLINK}TclGetGLContextInfoKHR = {$ENDIF}function {$IFNDEF DYNLINK}clGetGLContextInfoKHR{$ENDIF}(
  197. const properties: Pcl_context_properties;(* properties *)
  198. param_name: Tcl_gl_context_info; (* param_name *)
  199. param_value_size: Tsize_t; (* param_value_size *)
  200. param_value: Pointer; (* param_value *)
  201. param_value_size_ret : Psize_t (* param_value_size_ret *)
  202. ): TCL_int;
  203. extdecl; {$IFNDEF DYNLINK}external name 'clGetGLContextInfoKHR';{$ENDIF}
  204. {$ENDIF}
  205. var
  206. {$IFDEF CL_VERSION_1_0}
  207. clCreateFromGLBuffer: TclCreateFromGLBuffer;
  208. {$IFDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
  209. clCreateFromGLTexture2D: TclCreateFromGLTexture2D;
  210. clCreateFromGLTexture3D: TclCreateFromGLTexture3D;
  211. {$ENDIF}
  212. clCreateFromGLRenderbuffer: TclCreateFromGLRenderbuffer;
  213. clGetGLObjectInfo: TclGetGLObjectInfo;
  214. clGetGLTextureInfo: TclGetGLTextureInfo;
  215. clEnqueueAcquireGLObjects: TclEnqueueAcquireGLObjects;
  216. clEnqueueReleaseGLObjects: TclEnqueueReleaseGLObjects;
  217. clGetGLContextInfoKHR: TclGetGLContextInfoKHR;
  218. {$ENDIF}
  219. {$IFDEF CL_VERSION_1_2}
  220. clCreateFromGLTexture: TclCreateFromGLTexture;
  221. {$ENDIF}
  222. function InitCL_GL: Boolean;
  223. implementation
  224. function InitCL_GL: Boolean;
  225. begin
  226. Result := False;
  227. if OCL_LibHandle <> nil then
  228. begin
  229. {$IFDEF CL_VERSION_1_0}
  230. clCreateFromGLBuffer := TclCreateFromGLBuffer(oclGetProcAddress('clCreateFromGLBuffer', OCL_LibHandle));
  231. {$IFDEF CL_USE_DEPRECATED_OPENCL_1_1_APIS}
  232. clCreateFromGLTexture2D := TclCreateFromGLTexture2D(oclGetProcAddress('clCreateFromGLTexture2D', OCL_LibHandle));
  233. clCreateFromGLTexture3D := TclCreateFromGLTexture3D(oclGetProcAddress('clCreateFromGLTexture3D', OCL_LibHandle));
  234. {$ENDIF}
  235. clCreateFromGLRenderbuffer := TclCreateFromGLRenderbuffer(oclGetProcAddress('clCreateFromGLRenderbuffer', OCL_LibHandle));
  236. clGetGLObjectInfo := TclGetGLObjectInfo(oclGetProcAddress('clGetGLObjectInfo', OCL_LibHandle));
  237. clGetGLTextureInfo := TclGetGLTextureInfo(oclGetProcAddress('clGetGLTextureInfo', OCL_LibHandle));
  238. clEnqueueAcquireGLObjects := TclEnqueueAcquireGLObjects(oclGetProcAddress('clEnqueueAcquireGLObjects', OCL_LibHandle));
  239. clEnqueueReleaseGLObjects := TclEnqueueReleaseGLObjects(oclGetProcAddress('clEnqueueReleaseGLObjects', OCL_LibHandle));
  240. clGetGLContextInfoKHR := TclGetGLContextInfoKHR(clGetExtensionFunctionAddress('clGetGLContextInfoKHR'));
  241. {$ENDIF}
  242. {$IFDEF CL_VERSION_1_2}
  243. clCreateFromGLTexture := TclCreateFromGLTexture(oclGetProcAddress('clCreateFromGLTexture', OCL_LibHandle));
  244. {$ENDIF}
  245. Result := True;
  246. end;
  247. end;
  248. end.