From 1aded80ab7c3b44cab1ca98a639b14592c435f80 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Mon, 23 Jun 2014 05:25:59 +0800 Subject: [PATCH] get_apple_cgl_share_group --- TODOs | 1 - pyopencl/c_wrapper/wrap_cl_gl_core.h | 1 + pyopencl/cffi_cl.py | 4 ++++ src/c_wrapper/gl_obj.cpp | 11 +++++++++++ src/c_wrapper/gl_obj.h | 11 ----------- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/TODOs b/TODOs index dec695e7..42528d35 100644 --- a/TODOs +++ b/TODOs @@ -6,7 +6,6 @@ - CommandQueue.set_property - ?LocalMemory -- get_apple_cgl_share_group - GLBuffer - GLRenderBuffer - GLTexture diff --git a/pyopencl/c_wrapper/wrap_cl_gl_core.h b/pyopencl/c_wrapper/wrap_cl_gl_core.h index bacfdda5..2a381234 100644 --- a/pyopencl/c_wrapper/wrap_cl_gl_core.h +++ b/pyopencl/c_wrapper/wrap_cl_gl_core.h @@ -10,3 +10,4 @@ error *enqueue_acquire_gl_objects( error *enqueue_release_gl_objects( clobj_t *event, clobj_t queue, const clobj_t *mem_objects, uint32_t num_mem_objects, const clobj_t *wait_for, uint32_t num_wait_for); +cl_context_properties get_apple_cgl_share_group(); diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py index 8438355c..0f502325 100644 --- a/pyopencl/cffi_cl.py +++ b/pyopencl/cffi_cl.py @@ -1468,6 +1468,10 @@ if _lib.have_gl(): _lib.enqueue_acquire_gl_objects) enqueue_release_gl_objects = _create_gl_enqueue( _lib.enqueue_release_gl_objects) + try: + get_apple_cgl_share_group = _lib.get_apple_cgl_share_group + except AttributeError: + pass # }}} diff --git a/src/c_wrapper/gl_obj.cpp b/src/c_wrapper/gl_obj.cpp index 7358011b..6864f0d5 100644 --- a/src/c_wrapper/gl_obj.cpp +++ b/src/c_wrapper/gl_obj.cpp @@ -231,3 +231,14 @@ have_gl() return 0; #endif } + +#ifdef __APPLE__ +cl_context_properties +get_apple_cgl_share_group() +{ + CGLContextObj kCGLContext = CGLGetCurrentContext(); + CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext); + + return (cl_context_properties)kCGLShareGroup; +} +#endif /* __APPLE__ */ diff --git a/src/c_wrapper/gl_obj.h b/src/c_wrapper/gl_obj.h index f14637a5..c82aa9b1 100644 --- a/src/c_wrapper/gl_obj.h +++ b/src/c_wrapper/gl_obj.h @@ -9,17 +9,6 @@ namespace pyopencl { // {{{ gl interop -#ifdef __APPLE__ -static PYOPENCL_INLINE cl_context_properties -get_apple_cgl_share_group() -{ - CGLContextObj kCGLContext = CGLGetCurrentContext(); - CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext); - - return (cl_context_properties)kCGLShareGroup; -} -#endif /* __APPLE__ */ - class gl_buffer : public memory_object { public: PYOPENCL_DEF_CL_CLASS(GL_BUFFER); -- GitLab