blob: 27efd063d4b60609e32f2609fb3a7db15f2b8a0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* 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.1 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/>.
*
*/
#ifndef __CL_CONTEXT_H__
#define __CL_CONTEXT_H__
#include <stdint.h>
#include <pthread.h>
#include "CL/cl.h"
#include "CL/cl_ext.h"
typedef enum _cl_gl_context_type {
CL_GL_NOSHARE,
CL_GL_EGL_DISPLAY,
CL_GL_GLX_DISPLAY,
CL_GL_WGL_HDC,
CL_GL_CGL_SHAREGROUP
} _cl_gl_context_type;
typedef struct _cl_context_prop {
cl_context_properties platform_id;
enum _cl_gl_context_type gl_type;
cl_context_properties gl_context;
union {
cl_context_properties egl_display;
cl_context_properties glx_display;
cl_context_properties wgl_hdc;
cl_context_properties cgl_sharegroup;
};
} _cl_context_prop;
#define IS_EGL_CONTEXT(ctx) (ctx->props.gl_type == CL_GL_EGL_DISPLAY)
#define EGL_DISP(ctx) (EGLDisplay)(ctx->props.egl_display)
#define EGL_CTX(ctx) (EGLContext)(ctx->props.gl_context)
typedef struct _cl_context {
uint64_t magic; /* To identify it as a context */
volatile int ref_n; /* We reference count this object */
cl_device_id *devices; /* All information about the devices */
cl_uint device_num; /* The device number */
cl_command_queue queues; /* All command queues currently allocated */
cl_program programs; /* All programs currently allocated */
cl_mem buffers; /* All memory object currently allocated */
cl_sampler samplers; /* All sampler object currently allocated */
cl_event events; /* All event object currently allocated */
pthread_mutex_t lock; /* The lock to protect the context. */
pthread_cond_t cond; /* The condition we wait on. */
struct _cl_context_prop props;
cl_context_properties *prop_user; /* a copy of user passed context properties when create context */
cl_uint prop_len; /* count of the properties */
void (CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *);
/* User's callback when error occur in context */
void *user_data; /* A pointer to user supplied data */
void *pdata; /* Driver private data. */
} _cl_context;
#endif /* __CL_CONTEXT_H__ */
|