… | |
… | |
11 | // this. This breaks 100% of the opencl 1.1 apps, for what reason? |
11 | // this. This breaks 100% of the opencl 1.1 apps, for what reason? |
12 | // after all, the functions are deprecated, not removed. |
12 | // after all, the functions are deprecated, not removed. |
13 | // in addition, you cannot test for this in any future-proof way. |
13 | // in addition, you cannot test for this in any future-proof way. |
14 | // each time a new opencl version comes out, you need to make a new |
14 | // each time a new opencl version comes out, you need to make a new |
15 | // release. |
15 | // release. |
16 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
17 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS /* just guessing, you stupid idiots */ |
16 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS /* just guessing, you stupid idiots */ |
|
|
17 | |
|
|
18 | #ifndef PREFER_1_! |
|
|
19 | #define PREFER_1_1 1 |
|
|
20 | #endif |
|
|
21 | |
|
|
22 | #if PREFER_1_1 |
|
|
23 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
24 | #endif |
18 | |
25 | |
19 | #ifdef __APPLE__ |
26 | #ifdef __APPLE__ |
20 | #include <OpenCL/opencl.h> |
27 | #include <OpenCL/opencl.h> |
21 | #else |
28 | #else |
22 | #include <CL/opencl.h> |
29 | #include <CL/opencl.h> |
23 | #endif |
30 | #endif |
24 | |
31 | |
25 | #if 0 // testing |
|
|
26 | #undef CL_USE_DEPRECATED_OPENCL_1_1_APIS |
|
|
27 | #undef CL_VERSION_1_2 |
32 | #ifndef CL_VERSION_1_2 |
|
|
33 | #undef PREFER_1_1 |
|
|
34 | #define PREFER_1_1 1 |
28 | #endif |
35 | #endif |
29 | |
36 | |
30 | typedef cl_platform_id OpenCL__Platform; |
37 | typedef cl_platform_id OpenCL__Platform; |
31 | typedef cl_device_id OpenCL__Device; |
38 | typedef cl_device_id OpenCL__Device; |
32 | typedef cl_context OpenCL__Context; |
39 | typedef cl_context OpenCL__Context; |
… | |
… | |
765 | image2d (OpenCL::Context self, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t row_pitch = 0, SV *data = &PL_sv_undef) |
772 | image2d (OpenCL::Context self, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t row_pitch = 0, SV *data = &PL_sv_undef) |
766 | PPCODE: |
773 | PPCODE: |
767 | STRLEN len; |
774 | STRLEN len; |
768 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
775 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
769 | const cl_image_format format = { channel_order, channel_type }; |
776 | const cl_image_format format = { channel_order, channel_type }; |
770 | #if CL_VERSION_1_2 |
777 | #if PREFER_1_1 |
|
|
778 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (self, flags, &format, width, height, row_pitch, ptr, &res)); |
|
|
779 | #else |
771 | const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE2D, width, height, 0, 0, row_pitch, 0, 0, 0, 0 }; |
780 | const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE2D, width, height, 0, 0, row_pitch, 0, 0, 0, 0 }; |
772 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res)); |
781 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res)); |
773 | #else |
|
|
774 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (self, flags, &format, width, height, row_pitch, ptr, &res)); |
|
|
775 | #endif |
782 | #endif |
776 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
783 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
777 | |
784 | |
778 | void |
785 | void |
779 | image3d (OpenCL::Context self, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef) |
786 | image3d (OpenCL::Context self, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef) |
780 | PPCODE: |
787 | PPCODE: |
781 | STRLEN len; |
788 | STRLEN len; |
782 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
789 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
783 | const cl_image_format format = { channel_order, channel_type }; |
790 | const cl_image_format format = { channel_order, channel_type }; |
784 | #if CL_VERSION_1_2 |
791 | #if PREFER_1_1 |
|
|
792 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
|
|
793 | #else |
785 | const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE3D, width, height, depth, 0, row_pitch, slice_pitch, 0, 0, 0 }; |
794 | const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE3D, width, height, depth, 0, row_pitch, slice_pitch, 0, 0, 0 }; |
786 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res)); |
795 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage, (self, flags, &format, &desc, ptr, &res)); |
787 | #else |
|
|
788 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
|
|
789 | #endif |
796 | #endif |
790 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
797 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
791 | |
798 | |
792 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
799 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
793 | |
800 | |
… | |
… | |
806 | #if CL_VERSION_1_2 |
813 | #if CL_VERSION_1_2 |
807 | |
814 | |
808 | void |
815 | void |
809 | gl_texture (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
816 | gl_texture (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
810 | ALIAS: |
817 | ALIAS: |
811 | gl_texture2d = 0 |
|
|
812 | gl_texture3d = 0 |
|
|
813 | PPCODE: |
818 | PPCODE: |
814 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture, (self, flags, target, miplevel, texture, &res)); |
819 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture, (self, flags, target, miplevel, texture, &res)); |
815 | cl_gl_object_type type; |
820 | cl_gl_object_type type; |
816 | NEED_SUCCESS (GetGLObjectInfo, (mem, &type, 0)); // TODO: use target instead? |
821 | NEED_SUCCESS (GetGLObjectInfo, (mem, &type, 0)); // TODO: use target instead? |
817 | char *klass = "OpenCL::Memory"; |
822 | char *klass = "OpenCL::Memory"; |
… | |
… | |
824 | case CL_GL_OBJECT_TEXTURE2D_ARRAY: klass = "OpenCL::Image2DArray"; break; |
829 | case CL_GL_OBJECT_TEXTURE2D_ARRAY: klass = "OpenCL::Image2DArray"; break; |
825 | case CL_GL_OBJECT_TEXTURE3D: klass = "OpenCL::Image3D"; break; |
830 | case CL_GL_OBJECT_TEXTURE3D: klass = "OpenCL::Image3D"; break; |
826 | } |
831 | } |
827 | XPUSH_NEW_OBJ (klass, mem); |
832 | XPUSH_NEW_OBJ (klass, mem); |
828 | |
833 | |
|
|
834 | #endif |
|
|
835 | |
|
|
836 | void |
|
|
837 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
|
|
838 | PPCODE: |
|
|
839 | #if PREFER_1_1 |
|
|
840 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
829 | #else |
841 | #else |
830 | |
|
|
831 | void |
|
|
832 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
|
|
833 | PPCODE: |
|
|
834 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
842 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture , (self, flags, target, miplevel, texture, &res)); |
|
|
843 | #endif |
835 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
844 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
836 | |
845 | |
837 | void |
846 | void |
838 | gl_texture3d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
847 | gl_texture3d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
839 | PPCODE: |
848 | PPCODE: |
|
|
849 | #if PREFER_1_1 |
840 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
850 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
|
|
851 | #else |
|
|
852 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture , (self, flags, target, miplevel, texture, &res)); |
|
|
853 | #endif |
841 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
854 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
842 | |
|
|
843 | #endif |
|
|
844 | |
855 | |
845 | #endif |
856 | #endif |
846 | |
857 | |
847 | void |
858 | void |
848 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |
859 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |