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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
From 83339a659017402745437c03240d1837cad3649f Mon Sep 17 00:00:00 2001
From: Chia-I Wu <olvaffe@gmail.com>
Date: Thu, 14 Jan 2010 16:05:36 +0800
Subject: [PATCH 3/6] st/egl: Add support for loading st_api modules.
---
src/gallium/state_trackers/egl/common/egl_st_api.c | 116 ++++++++++++++++++++
src/gallium/state_trackers/egl/common/egl_st_api.h | 46 ++++++++
2 files changed, 162 insertions(+), 0 deletions(-)
create mode 100644 src/gallium/state_trackers/egl/common/egl_st_api.c
create mode 100644 src/gallium/state_trackers/egl/common/egl_st_api.h
diff --git a/src/gallium/state_trackers/egl/common/egl_st_api.c b/src/gallium/state_trackers/egl/common/egl_st_api.c
new file mode 100644
index 0000000..bfcc49e
--- /dev/null
+++ b/src/gallium/state_trackers/egl/common/egl_st_api.c
@@ -0,0 +1,116 @@
+#include "util/u_memory.h"
+#include "util/u_dl.h"
+#include "eglimage.h"
+
+#include "egl_st_api.h"
+
+struct egl_g3d_st_manager {
+ struct st_manager base;
+ _EGLDisplay *display;
+};
+
+static INLINE struct egl_g3d_st_manager *
+egl_g3d_st_manager(struct st_manager *smapi)
+{
+ return (struct egl_g3d_st_manager *) smapi;
+}
+
+static void *
+egl_g3d_st_manager_lock_resource(struct st_manager *smapi,
+ struct st_context_iface *stctxi,
+ enum st_manager_resource_type type,
+ void *res)
+{
+ struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi);
+ void *ret;
+
+ switch (type) {
+ case ST_MANAGER_RESOURCE_EGL_IMAGE:
+ {
+ EGLImageKHR handle = (EGLImageKHR) res;
+ _EGLImage *img = _eglLookupImage(handle, gsmapi->display);
+
+ /* TODO retrieve the pipe texture of the image */
+ (void) img;
+
+ ret = NULL;
+ }
+ break;
+ default:
+ ret = NULL;
+ break;
+ }
+
+ return ret;
+}
+
+static void
+egl_g3d_st_manager_unlock_resource(struct st_manager *smapi,
+ struct st_context_iface *stctxi,
+ enum st_manager_resource_type type,
+ void *res)
+{
+}
+
+struct st_manager *
+egl_g3d_create_st_manager(_EGLDisplay *dpy)
+{
+ struct egl_g3d_st_manager *gsmapi;
+
+ gsmapi = CALLOC_STRUCT(egl_g3d_st_manager);
+ if (gsmapi) {
+ gsmapi->display = dpy;
+
+ gsmapi->base.lock_resource = egl_g3d_st_manager_lock_resource;
+ gsmapi->base.unlock_resource = egl_g3d_st_manager_unlock_resource;
+ }
+
+ return &gsmapi->base;;
+}
+
+void
+egl_g3d_destroy_st_manager(struct st_manager *smapi)
+{
+ struct egl_g3d_st_manager *gsmapi = egl_g3d_st_manager(smapi);
+ free(gsmapi);
+}
+
+struct st_api *
+egl_g3d_create_st_api(enum st_api_type api)
+{
+ const char *stmod_name;
+ struct util_dl_library *lib;
+ const struct st_module *mod;
+
+ switch (api) {
+ case ST_API_OPENGL:
+ stmod_name = ST_MODULE_OPENGL_SYMBOL;
+ break;
+ case ST_API_OPENGL_ES1:
+ stmod_name = ST_MODULE_OPENGL_ES1_SYMBOL;
+ break;
+ case ST_API_OPENGL_ES2:
+ stmod_name = ST_MODULE_OPENGL_ES2_SYMBOL;
+ break;
+ case ST_API_OPENVG:
+ stmod_name = ST_MODULE_OPENVG_SYMBOL;
+ break;
+ default:
+ stmod_name = NULL;
+ break;
+ }
+ if (!stmod_name)
+ return NULL;
+
+ mod = NULL;
+ lib = util_dl_open(NULL);
+ if (lib) {
+ mod = (const struct st_module *)
+ util_dl_get_proc_address(lib, stmod_name);
+ util_dl_close(lib);
+ }
+ if (!mod || mod->api != api)
+ return NULL;
+
+ return mod->create_api();
+}
diff --git a/src/gallium/state_trackers/egl/common/egl_st_api.h b/src/gallium/state_trackers/egl/common/egl_st_api.h
new file mode 100644
index 0000000..f39f318
--- /dev/null
+++ b/src/gallium/state_trackers/egl/common/egl_st_api.h
@@ -0,0 +1,46 @@
+#ifndef _EGL_ST_API_H_
+#define _EGL_ST_API_H_
+
+#include "pipe/p_compiler.h"
+#include "state_tracker/st_api.h"
+#include "egltypedefs.h"
+
+struct st_manager *
+egl_g3d_create_st_manager(_EGLDisplay *dpy);
+
+void
+egl_g3d_destroy_st_manager(struct st_manager *smapi);
+
+struct st_api *
+egl_g3d_create_st_api(enum st_api_type api);
+
+/**
+ * Return the EGL_<api>_BIT of the st api.
+ */
+static INLINE int
+egl_g3d_st_api_bit(enum st_api_type api)
+{
+ int bit;
+
+ switch (api) {
+ case ST_API_OPENGL:
+ bit = EGL_OPENGL_BIT;
+ break;
+ case ST_API_OPENGL_ES1:
+ bit = EGL_OPENGL_ES_BIT;
+ break;
+ case ST_API_OPENGL_ES2:
+ bit = EGL_OPENGL_ES2_BIT;
+ break;
+ case ST_API_OPENVG:
+ bit = EGL_OPENVG_BIT;
+ break;
+ default:
+ bit = 0;
+ break;
+ }
+
+ return bit;
+}
+
+#endif /* _EGL_ST_API_H_ */
--
1.6.4.3
|