diff options
author | Zhigang Gong <zhigang.gong@linux.intel.com> | 2012-11-16 15:29:37 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-03-29 18:41:32 +0800 |
commit | 5c71a8498fec286df69c84e738f17f9d93d2606a (patch) | |
tree | 114d44c227785f7c8c14141ae53570db0934c4fb /src/cl_gl_api.c | |
parent | 73b26974ea77e6bf385e498d0cbb23e7cf7a5819 (diff) | |
download | beignet-5c71a8498fec286df69c84e738f17f9d93d2606a.tar.gz |
First implementation for extension cl_khr_gl_sharing.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/cl_gl_api.c')
-rw-r--r-- | src/cl_gl_api.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/src/cl_gl_api.c b/src/cl_gl_api.c new file mode 100644 index 00000000..3e9d88f9 --- /dev/null +++ b/src/cl_gl_api.c @@ -0,0 +1,128 @@ +/* + * Copyright © 2012 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: Zhigang Gong <zhigang.gong@intel.com> + */ +#include "cl_platform_id.h" +#include "cl_device_id.h" +#include "cl_context.h" +#include "cl_command_queue.h" +#include "cl_program.h" +#include "cl_kernel.h" +#include "cl_mem.h" +#include "cl_image.h" +#include "cl_sampler.h" +#include "cl_alloc.h" +#include "cl_utils.h" + +#include "CL/cl.h" +#include "CL/cl_gl.h" +#include "CL/cl_intel.h" + +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#define CHECK_GL_CONTEXT(CTX) \ +do { \ + if (UNLIKELY(CTX->props.gl_type == CL_GL_NOSHARE)) { \ + err = CL_INVALID_CONTEXT; \ + goto error; \ + } \ +} while (0) + + +cl_mem +clCreateFromGLBuffer(cl_context context, + cl_mem_flags flags, + GLuint bufobj, + cl_int * errcode_ret) +{ + cl_mem mem = NULL; + cl_int err = CL_SUCCESS; + CHECK_CONTEXT (context); + CHECK_GL_CONTEXT (context); + + mem = cl_mem_new_gl_buffer(context, flags, bufobj, &err); +error: + if (errcode_ret) + *errcode_ret = err; + return mem; +} + +cl_mem +clCreateFromGLTexture2D(cl_context context, + cl_mem_flags flags, + GLenum texture_target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) +{ + cl_mem mem = NULL; + cl_int err = CL_SUCCESS; + CHECK_CONTEXT (context); + CHECK_GL_CONTEXT (context); + + mem = cl_mem_new_gl_texture(context, flags, texture_target, miplevel, texture, 2, &err); +error: + if (errcode_ret) + *errcode_ret = err; + return mem; +} + +cl_mem +clCreateFromGLTexture3D(cl_context context, + cl_mem_flags flags, + GLenum texture_target, + GLint miplevel, + GLuint texture, + cl_int * errcode_ret) +{ + cl_mem mem = NULL; + cl_int err = CL_SUCCESS; + CHECK_CONTEXT (context); + CHECK_GL_CONTEXT (context); + + mem = cl_mem_new_gl_texture(context, flags, texture_target, miplevel, texture, 3, &err); +error: + if (errcode_ret) + *errcode_ret = err; + return mem; +} + +/* XXX NULL function currently. */ +cl_int clEnqueueAcquireGLObjects (cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) +{ + cl_int err = CL_SUCCESS; + return err; +} + +/* XXX NULL function currently. */ +cl_int clEnqueueReleaseGLObjects (cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem *mem_objects, + cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) +{ + cl_int err = CL_SUCCESS; + return err; +} |