diff options
author | Martin Jansa <Martin.Jansa@gmail.com> | 2011-04-10 13:24:47 +0200 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2011-04-10 14:43:41 +0200 |
commit | 89500c583e0f1dc1b4ffdf72914e08e505e427e0 (patch) | |
tree | b073036cc61aa34ca5ac9eec4d617366e0dcb3d5 /meta-oe/recipes-graphics/mesa | |
parent | e66079da37992abd54486488aa06a99bf7a4198c (diff) | |
download | meta-openembedded-89500c583e0f1dc1b4ffdf72914e08e505e427e0.tar.gz |
recipes,classes: import a lot of recipes from meta-shr
* tested on shr-lite-image for om-gta02 and nokia900 (with meta-shr layer)
Diffstat (limited to 'meta-oe/recipes-graphics/mesa')
-rw-r--r-- | meta-oe/recipes-graphics/mesa/README | 12 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-7.10.2.inc | 19 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-7.10.2/glamo.patch | 2425 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-7.10.2/uclibc.patch | 26 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-common.inc | 53 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-dri.inc | 10 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-dri_7.10.2.bb | 4 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-xlib.inc | 2 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa-xlib_7.10.2.bb | 4 | ||||
-rw-r--r-- | meta-oe/recipes-graphics/mesa/mesa_7.10.2.bb | 6 |
10 files changed, 2561 insertions, 0 deletions
diff --git a/meta-oe/recipes-graphics/mesa/README b/meta-oe/recipes-graphics/mesa/README new file mode 100644 index 000000000..3c6de3ee4 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/README | |||
@@ -0,0 +1,12 @@ | |||
1 | mesa-common.inc | ||
2 | * Settings shared by ALL recipes | ||
3 | |||
4 | mesa-${PV}.inc | ||
5 | * Settings for particular version, mostly checksums and additional patches | ||
6 | * Patches are stored mesa-${PV} dir and -dri and xlib has adjusted FILESPATHPKG | ||
7 | |||
8 | mesa-dri.inc | ||
9 | * Setting shared by ALL dri recipes - defines what is mesa-dri | ||
10 | |||
11 | mesa-xlib.inc | ||
12 | * Setting shared by ALL xlib recipes - defines what is mesa-xlib | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-7.10.2.inc b/meta-oe/recipes-graphics/mesa/mesa-7.10.2.inc new file mode 100644 index 000000000..f49f49598 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-7.10.2.inc | |||
@@ -0,0 +1,19 @@ | |||
1 | SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \ | ||
2 | file://glamo.patch \ | ||
3 | file://uclibc.patch \ | ||
4 | " | ||
5 | |||
6 | DEPENDS += "talloc" | ||
7 | |||
8 | SRC_URI[archive.md5sum] = "f5de82852f1243f42cc004039e10b771" | ||
9 | SRC_URI[archive.sha256sum] = "8ced2678ce11cf30804694a92ea3ca6b82f158ae8995bdc626c7e85aac71c7c1" | ||
10 | |||
11 | EXTRA_OECONF += " --disable-gallium" | ||
12 | |||
13 | #needs more testing and updated glamo.patch before making default | ||
14 | DEFAULT_PREFERENCE = "-2" | ||
15 | |||
16 | do_configure_prepend() { | ||
17 | #check for python not python2, because python-native does not stage python2 binary/link | ||
18 | sed -i 's/AC_CHECK_PROGS(\[PYTHON2\], \[python2 python\])/AC_CHECK_PROGS(\[PYTHON2\], \[python python\])/g' ${S}/configure.ac | ||
19 | } | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-7.10.2/glamo.patch b/meta-oe/recipes-graphics/mesa/mesa-7.10.2/glamo.patch new file mode 100644 index 000000000..5aa45d57e --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-7.10.2/glamo.patch | |||
@@ -0,0 +1,2425 @@ | |||
1 | git diff upstream/7.10 and gitorious/7.10 | ||
2 | |||
3 | http://gitorious.org/mesa/mesa/commits/7.10 | ||
4 | |||
5 | diff --git a/configs/autoconf.in b/configs/autoconf.in | ||
6 | index e2d70c6..5874955 100644 | ||
7 | --- a/configs/autoconf.in | ||
8 | +++ b/configs/autoconf.in | ||
9 | @@ -120,7 +120,7 @@ OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @OSMESA_MESA_DEPS@ \ | ||
10 | $(EXTRA_LIB_PATH) @OSMESA_LIB_DEPS@ | ||
11 | EGL_LIB_DEPS = $(EXTRA_LIB_PATH) @EGL_LIB_DEPS@ | ||
12 | GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLU_MESA_DEPS@ \ | ||
13 | - $(EXTRA_LIB_PATH) @GLU_LIB_DEPS@ | ||
14 | + $(EXTRA_LIB_PATH) @GLU_LIB_DEPS@ -lstdc++ | ||
15 | GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLUT_MESA_DEPS@ \ | ||
16 | $(EXTRA_LIB_PATH) @GLUT_LIB_DEPS@ | ||
17 | GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLW_MESA_DEPS@ \ | ||
18 | diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile | ||
19 | new file mode 100644 | ||
20 | index 0000000..e77193d | ||
21 | --- /dev/null | ||
22 | +++ b/src/mesa/drivers/dri/glamo/Makefile | ||
23 | @@ -0,0 +1,22 @@ | ||
24 | +# src/mesa/drivers/dri/glamo/Makefile | ||
25 | + | ||
26 | +TOP = ../../../../.. | ||
27 | +include $(TOP)/configs/current | ||
28 | + | ||
29 | +LIBNAME = glamo_dri.so | ||
30 | + | ||
31 | +DRIVER_SOURCES = \ | ||
32 | + glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \ | ||
33 | + glamo_cmdq.c glamo_render.c | ||
34 | + | ||
35 | +C_SOURCES = \ | ||
36 | + $(COMMON_SOURCES) \ | ||
37 | + $(DRIVER_SOURCES) | ||
38 | + | ||
39 | +ASM_SOURCES = | ||
40 | + | ||
41 | +DRI_LIB_DEPS += -ldrm_glamo | ||
42 | + | ||
43 | +include ../Makefile.template | ||
44 | + | ||
45 | +symlinks: | ||
46 | diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c | ||
47 | new file mode 100644 | ||
48 | index 0000000..1334f8e | ||
49 | --- /dev/null | ||
50 | +++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c | ||
51 | @@ -0,0 +1,110 @@ | ||
52 | +/* | ||
53 | + * Command queue submission via DRM | ||
54 | + * | ||
55 | + * Copyright 2009 Thomas White <taw@bitwiz.org.uk> | ||
56 | + * | ||
57 | + * This program is free software; you can redistribute it and/or | ||
58 | + * modify it under the terms of the GNU General Public License as | ||
59 | + * published by the Free Software Foundation; either version 2 of | ||
60 | + * the License, or (at your option) any later version. | ||
61 | + * | ||
62 | + * This program is distributed in the hope that it will be useful, | ||
63 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
64 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
65 | + * GNU General Public License for more details. | ||
66 | + * | ||
67 | + * You should have received a copy of the GNU General Public License | ||
68 | + * along with this program; if not, write to the Free Software | ||
69 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
70 | + * MA 02111-1307 USA | ||
71 | + */ | ||
72 | + | ||
73 | + | ||
74 | +#include <stdint.h> | ||
75 | +#include <stdlib.h> | ||
76 | +#include <drm.h> | ||
77 | +#include <glamo_drm.h> | ||
78 | +#include <glamo_bo.h> | ||
79 | + | ||
80 | +#include "glamo_context.h" | ||
81 | +#include "glamo_cmdq.h" | ||
82 | + | ||
83 | + | ||
84 | +/* Submit the prepared command sequence to the kernel */ | ||
85 | +void glamoDRMDispatch(glamoContext *gCtx) | ||
86 | +{ | ||
87 | + drm_glamo_cmd_burst_t burst; | ||
88 | + int r; | ||
89 | + | ||
90 | + burst.base = gCtx->cmd_burst_base; | ||
91 | + burst.data = gCtx->cmdq_drm; | ||
92 | + burst.bufsz = gCtx->cmdq_drm_used * 2; /* -> bytes */ | ||
93 | + burst.nobjs = gCtx->cmdq_obj_used; | ||
94 | + burst.objs = gCtx->cmdq_objs; | ||
95 | + burst.obj_pos = gCtx->cmdq_obj_pos; | ||
96 | + | ||
97 | + r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST, | ||
98 | + &burst, sizeof(burst)); | ||
99 | + if ( r != 0 ) { | ||
100 | + fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n"); | ||
101 | + } | ||
102 | + | ||
103 | + /* Reset counts to zero for the next sequence */ | ||
104 | + gCtx->cmdq_obj_used = 0; | ||
105 | + gCtx->cmdq_drm_used = 0; | ||
106 | +} | ||
107 | + | ||
108 | + | ||
109 | +void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len) | ||
110 | +{ | ||
111 | + if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) { | ||
112 | + fprintf(stderr, "Burst command too large\n"); | ||
113 | + return; | ||
114 | + } | ||
115 | + | ||
116 | + /* Record command */ | ||
117 | + if ( len == 2 ) { | ||
118 | + gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff; | ||
119 | + } else if ( len == 4 ) { | ||
120 | + gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff; | ||
121 | + gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000; | ||
122 | + } else { | ||
123 | + fprintf(stderr, "Wrong command length!\n"); | ||
124 | + } | ||
125 | +} | ||
126 | + | ||
127 | + | ||
128 | +void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo) | ||
129 | +{ | ||
130 | + if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) { | ||
131 | + fprintf(stderr, "Burst command too large\n"); | ||
132 | + return; | ||
133 | + } | ||
134 | + | ||
135 | + /* Record object position */ | ||
136 | + gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle; | ||
137 | + /* -> bytes */ | ||
138 | + gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2; | ||
139 | + gCtx->cmdq_obj_used++; | ||
140 | + | ||
141 | + /* Record command */ | ||
142 | + gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000; | ||
143 | + gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000; | ||
144 | +} | ||
145 | + | ||
146 | + | ||
147 | +void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base) | ||
148 | +{ | ||
149 | + gCtx->cmd_burst_base = base; | ||
150 | +} | ||
151 | + | ||
152 | + | ||
153 | +void glamoInitCmdqCache(glamoContext *gCtx) | ||
154 | +{ | ||
155 | + gCtx->cmdq_objs = malloc(1024); | ||
156 | + gCtx->cmdq_obj_pos = malloc(1024); | ||
157 | + gCtx->cmdq_obj_used = 0; | ||
158 | + gCtx->cmdq_drm_used = 0; | ||
159 | + gCtx->cmdq_drm_size = 4 * 1024; | ||
160 | + gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size); | ||
161 | +} | ||
162 | diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h | ||
163 | new file mode 100644 | ||
164 | index 0000000..7420d7b | ||
165 | --- /dev/null | ||
166 | +++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h | ||
167 | @@ -0,0 +1,33 @@ | ||
168 | +/* | ||
169 | + * Command queue submission via DRM | ||
170 | + * | ||
171 | + * Copyright 2009 Thomas White <taw@bitwiz.org.uk> | ||
172 | + * | ||
173 | + * This program is free software; you can redistribute it and/or | ||
174 | + * modify it under the terms of the GNU General Public License as | ||
175 | + * published by the Free Software Foundation; either version 2 of | ||
176 | + * the License, or (at your option) any later version. | ||
177 | + * | ||
178 | + * This program is distributed in the hope that it will be useful, | ||
179 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
180 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
181 | + * GNU General Public License for more details. | ||
182 | + * | ||
183 | + * You should have received a copy of the GNU General Public License | ||
184 | + * along with this program; if not, write to the Free Software | ||
185 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
186 | + * MA 02111-1307 USA | ||
187 | + */ | ||
188 | + | ||
189 | + | ||
190 | +#include <stdint.h> | ||
191 | +#include <glamo_bo.h> | ||
192 | + | ||
193 | +#include "glamo_context.h" | ||
194 | + | ||
195 | + | ||
196 | +extern void glamoDRMDispatch(glamoContext *gCtx); | ||
197 | +extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo); | ||
198 | +extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len); | ||
199 | +extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base); | ||
200 | +extern void glamoInitCmdqCache(glamoContext *gCtx); | ||
201 | diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c | ||
202 | new file mode 100644 | ||
203 | index 0000000..39eb4e7 | ||
204 | --- /dev/null | ||
205 | +++ b/src/mesa/drivers/dri/glamo/glamo_context.c | ||
206 | @@ -0,0 +1,360 @@ | ||
207 | +/* | ||
208 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
209 | + * | ||
210 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
211 | + * Roughly based on sis_context.c (c) 2003 Eric Anholt | ||
212 | + * and radeon_common_context.c | ||
213 | + * | ||
214 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
215 | + * copy of this software and associated documentation files (the "Software"), | ||
216 | + * to deal in the Software without restriction, including without limitation | ||
217 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
218 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
219 | + * Software is furnished to do so, subject to the following conditions: | ||
220 | + * | ||
221 | + * The above copyright notice and this permission notice shall be included | ||
222 | + * in all copies or substantial portions of the Software. | ||
223 | + * | ||
224 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
225 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
226 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
227 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
228 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
229 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
230 | + */ | ||
231 | + | ||
232 | + | ||
233 | +#include "dri_util.h" | ||
234 | +#include "drirenderbuffer.h" | ||
235 | +#include "utils.h" | ||
236 | + | ||
237 | +#include "swrast/swrast.h" | ||
238 | +#include "swrast_setup/swrast_setup.h" | ||
239 | +#include "drivers/common/driverfuncs.h" | ||
240 | +#include "vbo/vbo.h" | ||
241 | +#include "tnl/tnl.h" | ||
242 | +#include "tnl/t_pipeline.h" | ||
243 | +#include "main/state.h" | ||
244 | + | ||
245 | +#include "glamo_context.h" | ||
246 | +#include "glamo_screen.h" | ||
247 | +#include "glamo_state.h" | ||
248 | +#include "glamo_fbo.h" | ||
249 | +#include "glamo_tris.h" | ||
250 | +#include "glamo_render.h" | ||
251 | +#include "glamo_cmdq.h" | ||
252 | + | ||
253 | +#include <glamo_bo.h> | ||
254 | +#include <glamo_bo_gem.h> | ||
255 | +#include <glamo_drm.h> | ||
256 | + | ||
257 | + | ||
258 | +#define DRIVER_DATE "20090913" | ||
259 | + | ||
260 | + | ||
261 | +static inline struct glamo_renderbuffer *glamo_get_renderbuffer( | ||
262 | + struct gl_framebuffer *fb, | ||
263 | + int att_index) | ||
264 | +{ | ||
265 | + if ( att_index >= 0 ) { | ||
266 | + struct glamo_renderbuffer *gr; | ||
267 | + gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer); | ||
268 | + return gr; | ||
269 | + } else { | ||
270 | + return NULL; | ||
271 | + } | ||
272 | +} | ||
273 | + | ||
274 | + | ||
275 | +static const GLubyte *glamoGetString(struct gl_context *ctx, GLenum name) | ||
276 | +{ | ||
277 | + static char buffer[128]; | ||
278 | + | ||
279 | + switch (name) { | ||
280 | + case GL_VENDOR: | ||
281 | + return (GLubyte *)"Thomas White"; | ||
282 | + case GL_RENDERER: { | ||
283 | + driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0); | ||
284 | + return (GLubyte *) buffer; | ||
285 | + } | ||
286 | + default: | ||
287 | + return 0; | ||
288 | + } | ||
289 | +} | ||
290 | + | ||
291 | + | ||
292 | +/* Called when Mesa needs to know the size of the framebuffer */ | ||
293 | +static void glamoBufferSize(struct gl_framebuffer *buffer, | ||
294 | + GLuint *width, GLuint *height) | ||
295 | +{ | ||
296 | + GET_CURRENT_CONTEXT(ctx); | ||
297 | + glamoContextPtr glamo = GLAMO_CONTEXT(ctx); | ||
298 | + | ||
299 | + *width = glamo->driDrawable->w; | ||
300 | + *height = glamo->driDrawable->h; | ||
301 | +} | ||
302 | + | ||
303 | + | ||
304 | +GLboolean glamoCreateContext(const struct gl_config *glVisual, | ||
305 | + __DRIcontext *driContextPriv, | ||
306 | + void *sharedContextPrivate) | ||
307 | +{ | ||
308 | + struct gl_context *ctx, *shareCtx; | ||
309 | + __DRIscreen *sPriv = driContextPriv->driScreenPriv; | ||
310 | + glamoContextPtr context; | ||
311 | + glamoScreenPtr glamoScreen; | ||
312 | + struct dd_function_table functions; | ||
313 | + | ||
314 | + context = (glamoContextPtr)CALLOC(sizeof(*context)); | ||
315 | + if ( context == NULL ) return GL_FALSE; | ||
316 | + | ||
317 | + _mesa_init_driver_functions(&functions); | ||
318 | + | ||
319 | + /* Allocate the Mesa context */ | ||
320 | + if ( sharedContextPrivate ) | ||
321 | + shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx; | ||
322 | + else | ||
323 | + shareCtx = NULL; | ||
324 | + context->glCtx = _mesa_create_context(glVisual, shareCtx, | ||
325 | + &functions, (void *)context); | ||
326 | + if ( context->glCtx == NULL ) { | ||
327 | + FREE(context); | ||
328 | + return GL_FALSE; | ||
329 | + } | ||
330 | + driContextPriv->driverPrivate = context; | ||
331 | + ctx = context->glCtx; | ||
332 | + | ||
333 | + glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private; | ||
334 | + | ||
335 | + ctx->Driver.GetString = glamoGetString; | ||
336 | + ctx->Driver.GetBufferSize = glamoBufferSize; | ||
337 | + | ||
338 | + context->driContext = driContextPriv; | ||
339 | + context->driScreen = sPriv; | ||
340 | + context->driDrawable = NULL; | ||
341 | + context->drm_fd = sPriv->fd; | ||
342 | + | ||
343 | + /* Initialize the software rasterizer and helper modules. */ | ||
344 | + _swrast_CreateContext(ctx); | ||
345 | + _vbo_CreateContext(ctx); | ||
346 | + _tnl_CreateContext(ctx); | ||
347 | + _swsetup_CreateContext(ctx); | ||
348 | + | ||
349 | + /* Install our pipeline (see glamo_render.c) */ | ||
350 | + _tnl_install_pipeline(ctx, glamo_pipeline); | ||
351 | + | ||
352 | + _swrast_allow_pixel_fog(ctx, GL_TRUE); | ||
353 | + _swrast_allow_vertex_fog(ctx, GL_FALSE); | ||
354 | + _tnl_allow_pixel_fog(ctx, GL_TRUE); | ||
355 | + _tnl_allow_vertex_fog(ctx, GL_FALSE); | ||
356 | + | ||
357 | + glamoInitCmdqCache(context); | ||
358 | + glamoInitStateFuncs(ctx); | ||
359 | + glamoInitTriFuncs(ctx); | ||
360 | + | ||
361 | + return GL_TRUE; | ||
362 | +} | ||
363 | + | ||
364 | + | ||
365 | +void glamoDestroyContext(__DRIcontext *driContextPriv) | ||
366 | +{ | ||
367 | + glamoContextPtr context; | ||
368 | + | ||
369 | + context = (glamoContextPtr)driContextPriv->driverPrivate; | ||
370 | + assert(context != NULL); | ||
371 | + | ||
372 | + if ( context != NULL ) { | ||
373 | + | ||
374 | + _swsetup_DestroyContext(context->glCtx); | ||
375 | + _tnl_DestroyContext(context->glCtx); | ||
376 | + _vbo_DestroyContext(context->glCtx); | ||
377 | + _swrast_DestroyContext(context->glCtx); | ||
378 | + | ||
379 | + _mesa_destroy_context(context->glCtx); | ||
380 | + | ||
381 | + } | ||
382 | + | ||
383 | + FREE(context); | ||
384 | +} | ||
385 | + | ||
386 | + | ||
387 | +void glamo_update_renderbuffers(__DRIcontext *context, | ||
388 | + __DRIdrawable *drawable) | ||
389 | +{ | ||
390 | + unsigned int attachments[10]; | ||
391 | + __DRIbuffer *buffers; | ||
392 | + __DRIscreen *screen; | ||
393 | + int i, count; | ||
394 | + struct glamo_framebuffer *draw; | ||
395 | + glamoContextPtr glamo; | ||
396 | + struct glamo_bo *bo; | ||
397 | + | ||
398 | + draw = drawable->driverPrivate; | ||
399 | + screen = context->driScreenPriv; | ||
400 | + glamo = (glamoContextPtr)context->driverPrivate; | ||
401 | + i = 0; | ||
402 | + if ( draw->color_rb[0] ) { | ||
403 | + attachments[i++] = __DRI_BUFFER_FRONT_LEFT; | ||
404 | + } | ||
405 | + if ( draw->color_rb[1] ) { | ||
406 | + attachments[i++] = __DRI_BUFFER_BACK_LEFT; | ||
407 | + } | ||
408 | + | ||
409 | + buffers = screen->dri2.loader->getBuffers(drawable, | ||
410 | + &drawable->w, | ||
411 | + &drawable->h, | ||
412 | + attachments, i, | ||
413 | + &count, | ||
414 | + drawable->loaderPrivate); | ||
415 | + if ( buffers == NULL ) return; | ||
416 | + | ||
417 | + /* Set one cliprect to cover the whole drawable */ | ||
418 | + drawable->x = 0; | ||
419 | + drawable->y = 0; | ||
420 | + drawable->backX = 0; | ||
421 | + drawable->backY = 0; | ||
422 | + drawable->numClipRects = 1; | ||
423 | + drawable->pClipRects[0].x1 = 0; | ||
424 | + drawable->pClipRects[0].y1 = 0; | ||
425 | + drawable->pClipRects[0].x2 = drawable->w; | ||
426 | + drawable->pClipRects[0].y2 = drawable->h; | ||
427 | + drawable->numBackClipRects = 1; | ||
428 | + drawable->pBackClipRects[0].x1 = 0; | ||
429 | + drawable->pBackClipRects[0].y1 = 0; | ||
430 | + drawable->pBackClipRects[0].x2 = drawable->w; | ||
431 | + drawable->pBackClipRects[0].y2 = drawable->h; | ||
432 | + | ||
433 | + /* For each attachment */ | ||
434 | + for ( i=0; i<count; i++ ) { | ||
435 | + | ||
436 | + struct glamo_renderbuffer *grb; | ||
437 | + | ||
438 | + switch ( buffers[i].attachment ) { | ||
439 | + case __DRI_BUFFER_FRONT_LEFT: | ||
440 | + grb = draw->color_rb[0]; | ||
441 | + break; | ||
442 | + case __DRI_BUFFER_BACK_LEFT: | ||
443 | + grb = draw->color_rb[1]; | ||
444 | + break; | ||
445 | + case __DRI_BUFFER_DEPTH: | ||
446 | + grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH); | ||
447 | + break; | ||
448 | + case __DRI_BUFFER_STENCIL: | ||
449 | + grb = glamo_get_renderbuffer(&draw->base, | ||
450 | + BUFFER_STENCIL); | ||
451 | + break; | ||
452 | + case __DRI_BUFFER_FAKE_FRONT_LEFT: | ||
453 | + grb = draw->color_rb[0]; | ||
454 | + break; | ||
455 | + case __DRI_BUFFER_ACCUM: | ||
456 | + default: | ||
457 | + fprintf(stderr, | ||
458 | + "Unhandled buffer attach event," | ||
459 | + " attachment type %d\n", buffers[i].attachment); | ||
460 | + return; | ||
461 | + } | ||
462 | + | ||
463 | + if ( grb == NULL ) { | ||
464 | + /* Don't know how to handle this type of buffer */ | ||
465 | + continue; | ||
466 | + } | ||
467 | + | ||
468 | + if ( grb->bo ) { | ||
469 | + uint32_t name = glamo_gem_get_name(grb->bo); | ||
470 | + if ( name == buffers[i].name ) { | ||
471 | + /* Buffer already attached. No action needed */ | ||
472 | + continue; | ||
473 | + } | ||
474 | + } | ||
475 | + | ||
476 | + grb->cpp = buffers[i].cpp; | ||
477 | + grb->pitch = buffers[i].pitch; | ||
478 | + grb->width = drawable->w; | ||
479 | + grb->height = drawable->h; | ||
480 | + | ||
481 | + bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name, | ||
482 | + 0, 0, GLAMO_GEM_DOMAIN_VRAM, | ||
483 | + buffers[i].flags); | ||
484 | + if ( bo == NULL ) { | ||
485 | + fprintf(stderr, "Failed to attach buffer %d\n", | ||
486 | + buffers[i].name); | ||
487 | + } | ||
488 | + | ||
489 | + glamo_renderbuffer_set_bo(grb, bo); | ||
490 | + glamo_bo_unref(bo); | ||
491 | + | ||
492 | + } | ||
493 | + | ||
494 | + driUpdateFramebufferSize(glamo->glCtx, drawable); | ||
495 | +} | ||
496 | + | ||
497 | + | ||
498 | +GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv, | ||
499 | + __DRIdrawable *driDrawPriv, | ||
500 | + __DRIdrawable *driReadPriv) | ||
501 | +{ | ||
502 | + struct glamo_framebuffer *draw_fb; | ||
503 | + struct gl_framebuffer *read_fb; | ||
504 | + glamoContextPtr glamo; | ||
505 | + | ||
506 | + if ( driContextPriv == NULL ) { | ||
507 | + _mesa_make_current(NULL, NULL, NULL); | ||
508 | + return GL_TRUE; | ||
509 | + } | ||
510 | + | ||
511 | + /* The Glamo context we're switching to */ | ||
512 | + glamo = (glamoContextPtr)driContextPriv->driverPrivate; | ||
513 | + | ||
514 | + glamo->driDrawable = driDrawPriv; | ||
515 | + | ||
516 | + /* These two will probably be the same */ | ||
517 | + draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate; | ||
518 | + read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate; | ||
519 | + | ||
520 | + glamo_update_renderbuffers(driContextPriv, driDrawPriv); | ||
521 | + if (driDrawPriv != driReadPriv) | ||
522 | + glamo_update_renderbuffers(driContextPriv, driReadPriv); | ||
523 | + | ||
524 | + _mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb); | ||
525 | + _mesa_update_state(glamo->glCtx); | ||
526 | + | ||
527 | + return GL_TRUE; | ||
528 | +} | ||
529 | + | ||
530 | + | ||
531 | +GLboolean glamoUnbindContext(__DRIcontext *driContextPriv) | ||
532 | +{ | ||
533 | + return GL_TRUE; | ||
534 | +} | ||
535 | + | ||
536 | + | ||
537 | +/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */ | ||
538 | +uint32_t float7s16(GLfloat in) | ||
539 | +{ | ||
540 | + uint32_t a, b; | ||
541 | + uint32_t sign, expo, mant; /* Sign, exponent, significand */ | ||
542 | + | ||
543 | + a = *(uint32_t *)∈ | ||
544 | + | ||
545 | + /* This is bad */ | ||
546 | + if ( a & 0x40000000 ) { | ||
547 | + printf(stderr, "Warning: Exponent won't fit into 7 bits\n"); | ||
548 | + } | ||
549 | + | ||
550 | + /* This hopefully isn't a big problem */ | ||
551 | + if ( a & 0x0000007f ) { | ||
552 | + printf(stderr, "Warning: Precision lost in FP conversion\n"); | ||
553 | + } | ||
554 | + | ||
555 | + /* Separate out the right bits */ | ||
556 | + mant = a & 0x007fff80; /* Bits 7-22 (bits 0-6 are lost) */ | ||
557 | + expo = a & 0x3f800000; /* Bits 23-29 (bit 30 is lost) */ | ||
558 | + sign = a & 0x80000000; /* Bit 31 */ | ||
559 | + | ||
560 | + /* Shift and recombine */ | ||
561 | + b = sign >> 8; /* Fills bit 23 */ | ||
562 | + b |= expo >> 7; /* Fills bits 16-22 */ | ||
563 | + b |= mant >> 7; /* Fills bits 0-15 */ | ||
564 | + | ||
565 | + return b; | ||
566 | +} | ||
567 | diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h | ||
568 | new file mode 100644 | ||
569 | index 0000000..8de3946 | ||
570 | --- /dev/null | ||
571 | +++ b/src/mesa/drivers/dri/glamo/glamo_context.h | ||
572 | @@ -0,0 +1,106 @@ | ||
573 | +/* | ||
574 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
575 | + * | ||
576 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
577 | + * Roughly based on sis_context.h (c) 2003 Eric Anholt | ||
578 | + * | ||
579 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
580 | + * copy of this software and associated documentation files (the "Software"), | ||
581 | + * to deal in the Software without restriction, including without limitation | ||
582 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
583 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
584 | + * Software is furnished to do so, subject to the following conditions: | ||
585 | + * | ||
586 | + * The above copyright notice and this permission notice shall be included | ||
587 | + * in all copies or substantial portions of the Software. | ||
588 | + * | ||
589 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
590 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
591 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
592 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
593 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
594 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
595 | + */ | ||
596 | + | ||
597 | +#ifndef __GLAMO_CONTEXT_H | ||
598 | +#define __GLAMO_CONTEXT_H | ||
599 | + | ||
600 | + | ||
601 | +#include "dri_util.h" | ||
602 | +#include "utils.h" | ||
603 | +#include "tnl/t_vertex.h" | ||
604 | + | ||
605 | +#include "glamo_screen.h" | ||
606 | + | ||
607 | + | ||
608 | +typedef struct glamo_context glamoContext; | ||
609 | +typedef struct glamo_context *glamoContextPtr; | ||
610 | + | ||
611 | +struct glamo_context { | ||
612 | + | ||
613 | + struct gl_context *glCtx; /* Must be first in this structure */ | ||
614 | + | ||
615 | + int drm_fd; /* DRM fd */ | ||
616 | + | ||
617 | + __DRIcontext *driContext; /* DRI context */ | ||
618 | + __DRIscreen *driScreen; /* DRI screen */ | ||
619 | + __DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */ | ||
620 | + | ||
621 | + glamoScreenPtr glamoScreen; /* Screen private DRI data */ | ||
622 | + | ||
623 | + driOptionCache optionCache; | ||
624 | + | ||
625 | + uint16_t *cmdq_drm; /* Command queue cache */ | ||
626 | + uint16_t cmd_burst_base; | ||
627 | + int cmdq_drm_used; | ||
628 | + int cmdq_drm_size; | ||
629 | + int cmdq_obj_used; | ||
630 | + uint32_t *cmdq_objs; | ||
631 | + unsigned int *cmdq_obj_pos; | ||
632 | + | ||
633 | + /* Information about the current primitive */ | ||
634 | + struct { | ||
635 | + GLuint id; | ||
636 | + uint32_t primitive; /* Current hardware primitive type */ | ||
637 | + struct glamo_bo *vb_bo; | ||
638 | + uint8_t *vb; | ||
639 | + unsigned int start_offset; /* Byte offset of start */ | ||
640 | + unsigned int current_offset; /* Byte offset of next vertex */ | ||
641 | + unsigned int count; /* Number of vertices */ | ||
642 | + } prim; | ||
643 | + | ||
644 | + /* Current vertex format and attributes */ | ||
645 | + int vertex_size; | ||
646 | + struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; | ||
647 | + | ||
648 | + /* State */ | ||
649 | + GLuint new_state; /* State which must be updated */ | ||
650 | + uint16_t col_clear; | ||
651 | + | ||
652 | +}; | ||
653 | + | ||
654 | +#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx)) | ||
655 | + | ||
656 | +#define TAG(x) glamo##x | ||
657 | +#include "tnl_dd/t_dd_vertex.h" | ||
658 | +#undef TAG | ||
659 | + | ||
660 | +extern GLboolean glamoCreateContext(const struct gl_config *glVis, | ||
661 | + __DRIcontext *driContextPriv, | ||
662 | + void *sharedContextPrivate); | ||
663 | +extern void glamoDestroyContext(__DRIcontext *dcp); | ||
664 | +extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv, | ||
665 | + __DRIdrawable *driDrawPriv, | ||
666 | + __DRIdrawable *driReadPriv); | ||
667 | +extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv); | ||
668 | +extern void glamo_update_renderbuffers(__DRIcontext *context, | ||
669 | + __DRIdrawable *drawable); | ||
670 | + | ||
671 | +#define GLAMO_PACKCOLOR565(r, g, b) \ | ||
672 | + ((((r) & 0xf8) << 8) \ | ||
673 | + | (((g) & 0xfc) << 3) \ | ||
674 | + | (((b) & 0xf8) >> 3)) | ||
675 | + | ||
676 | +extern uint32_t float7s16(GLfloat in); | ||
677 | + | ||
678 | +#endif /* __GLAMO_CONTEXT_H */ | ||
679 | diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c | ||
680 | new file mode 100644 | ||
681 | index 0000000..e25ca31 | ||
682 | --- /dev/null | ||
683 | +++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c | ||
684 | @@ -0,0 +1,130 @@ | ||
685 | +/* | ||
686 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
687 | + * | ||
688 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
689 | + * Roughly based on radeon_fbo.c (c) 2008 Red Hat Inc | ||
690 | + * | ||
691 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
692 | + * copy of this software and associated documentation files (the "Software"), | ||
693 | + * to deal in the Software without restriction, including without limitation | ||
694 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
695 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
696 | + * Software is furnished to do so, subject to the following conditions: | ||
697 | + * | ||
698 | + * The above copyright notice and this permission notice shall be included | ||
699 | + * in all copies or substantial portions of the Software. | ||
700 | + * | ||
701 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
702 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
703 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
704 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
705 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
706 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
707 | + */ | ||
708 | + | ||
709 | + | ||
710 | +#include "main/imports.h" | ||
711 | +#include "main/macros.h" | ||
712 | +#include "main/mtypes.h" | ||
713 | +#include "main/formats.h" | ||
714 | +#include "main/fbobject.h" | ||
715 | +#include "main/framebuffer.h" | ||
716 | +#include "main/renderbuffer.h" | ||
717 | +#include "main/context.h" | ||
718 | +#include "dri_util.h" | ||
719 | + | ||
720 | +/* This comes from libdrm_glamo */ | ||
721 | +#include <glamo_bo.h> | ||
722 | + | ||
723 | +#include "glamo_fbo.h" | ||
724 | + | ||
725 | + | ||
726 | +static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb) | ||
727 | +{ | ||
728 | + struct glamo_renderbuffer *grb = glamo_renderbuffer(rb); | ||
729 | + | ||
730 | + ASSERT(grb); | ||
731 | + | ||
732 | + if ( grb && grb->bo ) { | ||
733 | + glamo_bo_unref(grb->bo); | ||
734 | + } | ||
735 | + free(grb); | ||
736 | +} | ||
737 | + | ||
738 | + | ||
739 | +static void *glamo_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, | ||
740 | + GLint x, GLint y) | ||
741 | +{ | ||
742 | + return NULL; /* Can't be directly addressed */ | ||
743 | +} | ||
744 | + | ||
745 | + | ||
746 | +/* Called for each hardware renderbuffer when a _window_ is resized. | ||
747 | + * Just update fields. | ||
748 | + * Not used for user-created renderbuffers! | ||
749 | + */ | ||
750 | +static GLboolean glamo_alloc_window_storage(struct gl_context *ctx, | ||
751 | + struct gl_renderbuffer *rb, | ||
752 | + GLenum internalFormat, | ||
753 | + GLuint width, GLuint height) | ||
754 | +{ | ||
755 | + ASSERT(rb->Name == 0); | ||
756 | + rb->Width = width; | ||
757 | + rb->Height = height; | ||
758 | + rb->Format = internalFormat; | ||
759 | + return GL_TRUE; | ||
760 | +} | ||
761 | + | ||
762 | + | ||
763 | +/* Create a buffer, such as a colour or depth buffer */ | ||
764 | +struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format, | ||
765 | + __DRIdrawable *driDrawPriv) | ||
766 | +{ | ||
767 | + struct glamo_renderbuffer *grb; | ||
768 | + | ||
769 | + grb = CALLOC_STRUCT(glamo_renderbuffer); | ||
770 | + if ( !grb ) return NULL; | ||
771 | + | ||
772 | + _mesa_init_renderbuffer(&grb->base, 0); | ||
773 | + grb->base.ClassID = GLAMO_RB_CLASS; | ||
774 | + | ||
775 | + switch (format) { | ||
776 | + case GL_RGB5: | ||
777 | + grb->base.Format = MESA_FORMAT_RGB565; | ||
778 | + grb->base._BaseFormat = GL_RGB; | ||
779 | + | ||
780 | + grb->base.DataType = GL_UNSIGNED_BYTE; | ||
781 | + break; | ||
782 | + case GL_DEPTH_COMPONENT16: | ||
783 | + grb->base.DataType = GL_UNSIGNED_SHORT; | ||
784 | + grb->base._BaseFormat = GL_DEPTH_COMPONENT; | ||
785 | + break; | ||
786 | + default: | ||
787 | + fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format); | ||
788 | + _mesa_delete_renderbuffer(&grb->base); | ||
789 | + return NULL; | ||
790 | + } | ||
791 | + | ||
792 | + grb->dPriv = driDrawPriv; | ||
793 | + grb->base.InternalFormat = format; | ||
794 | + | ||
795 | + grb->base.Delete = glamo_delete_renderbuffer; | ||
796 | + grb->base.AllocStorage = glamo_alloc_window_storage; | ||
797 | + grb->base.GetPointer = glamo_get_pointer; | ||
798 | + | ||
799 | + return grb; | ||
800 | +} | ||
801 | + | ||
802 | + | ||
803 | +void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb, | ||
804 | + struct glamo_bo *bo) | ||
805 | +{ | ||
806 | + struct glamo_bo *old; | ||
807 | + old = grb->bo; | ||
808 | + grb->bo = bo; | ||
809 | + glamo_bo_ref(bo); | ||
810 | + if ( old ) glamo_bo_unref(old); | ||
811 | +} | ||
812 | + | ||
813 | + | ||
814 | +/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ | ||
815 | diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h | ||
816 | new file mode 100644 | ||
817 | index 0000000..48210dd | ||
818 | --- /dev/null | ||
819 | +++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h | ||
820 | @@ -0,0 +1,77 @@ | ||
821 | +/* | ||
822 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
823 | + * | ||
824 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
825 | + * | ||
826 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
827 | + * copy of this software and associated documentation files (the "Software"), | ||
828 | + * to deal in the Software without restriction, including without limitation | ||
829 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
830 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
831 | + * Software is furnished to do so, subject to the following conditions: | ||
832 | + * | ||
833 | + * The above copyright notice and this permission notice shall be included | ||
834 | + * in all copies or substantial portions of the Software. | ||
835 | + * | ||
836 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
837 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
838 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
839 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
840 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
841 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
842 | + */ | ||
843 | + | ||
844 | +#ifndef __GLAMO_FBO_H | ||
845 | +#define __GLAMO_FBO_H | ||
846 | + | ||
847 | + | ||
848 | +#include "main/mtypes.h" | ||
849 | +#include "dri_util.h" | ||
850 | + | ||
851 | + | ||
852 | +/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */ | ||
853 | +#define GLAMO_RB_CLASS (0xdeadbeef) | ||
854 | + | ||
855 | + | ||
856 | +struct glamo_renderbuffer | ||
857 | +{ | ||
858 | + struct gl_renderbuffer base; /* Must be first */ | ||
859 | + struct glamo_bo *bo; | ||
860 | + unsigned int cpp; | ||
861 | + unsigned int pitch; | ||
862 | + unsigned int width; | ||
863 | + unsigned int height; | ||
864 | + | ||
865 | + __DRIdrawable *dPriv; | ||
866 | +}; | ||
867 | + | ||
868 | + | ||
869 | +struct glamo_framebuffer | ||
870 | +{ | ||
871 | + struct gl_framebuffer base; | ||
872 | + struct glamo_renderbuffer *color_rb[2]; | ||
873 | +}; | ||
874 | + | ||
875 | + | ||
876 | +/* This is just a small wrapper function to return NULL if the gl_renderbuffer | ||
877 | + * is not a glamo_renderbuffer */ | ||
878 | +static inline struct glamo_renderbuffer | ||
879 | + *glamo_renderbuffer(struct gl_renderbuffer *rb) | ||
880 | +{ | ||
881 | + struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb; | ||
882 | + if ( grb && grb->base.ClassID == GLAMO_RB_CLASS ) | ||
883 | + return grb; | ||
884 | + else | ||
885 | + return NULL; | ||
886 | +} | ||
887 | + | ||
888 | + | ||
889 | +extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format, | ||
890 | + __DRIdrawable *driDrawPriv); | ||
891 | + | ||
892 | +extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb, | ||
893 | + struct glamo_bo *bo); | ||
894 | + | ||
895 | +#endif /* __GLAMO_FBO_H */ | ||
896 | + | ||
897 | +/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ | ||
898 | diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h | ||
899 | new file mode 100644 | ||
900 | index 0000000..02b2294 | ||
901 | --- /dev/null | ||
902 | +++ b/src/mesa/drivers/dri/glamo/glamo_regs.h | ||
903 | @@ -0,0 +1,174 @@ | ||
904 | +#ifndef _GLAMO_REGS_H | ||
905 | +#define _GLAMO_REGS_H | ||
906 | + | ||
907 | +/* Smedia Glamo 336x/337x driver | ||
908 | + * | ||
909 | + * (C) 2007 by OpenMoko, Inc. | ||
910 | + * Author: Harald Welte <laforge@openmoko.org> | ||
911 | + * All rights reserved. | ||
912 | + * | ||
913 | + * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk> | ||
914 | + * | ||
915 | + * This program is free software; you can redistribute it and/or | ||
916 | + * modify it under the terms of the GNU General Public License as | ||
917 | + * published by the Free Software Foundation; either version 2 of | ||
918 | + * the License, or (at your option) any later version. | ||
919 | + * | ||
920 | + * This program is distributed in the hope that it will be useful, | ||
921 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
922 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
923 | + * GNU General Public License for more details. | ||
924 | + * | ||
925 | + * You should have received a copy of the GNU General Public License | ||
926 | + * along with this program; if not, write to the Free Software | ||
927 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
928 | + * MA 02111-1307 USA | ||
929 | + */ | ||
930 | + | ||
931 | +enum glamo_regster_offsets { | ||
932 | + GLAMO_REGOFS_GENERIC = 0x0000, | ||
933 | + GLAMO_REGOFS_HOSTBUS = 0x0200, | ||
934 | + GLAMO_REGOFS_MEMORY = 0x0300, | ||
935 | + GLAMO_REGOFS_VIDCAP = 0x0400, | ||
936 | + GLAMO_REGOFS_ISP = 0x0500, | ||
937 | + GLAMO_REGOFS_JPEG = 0x0800, | ||
938 | + GLAMO_REGOFS_MPEG = 0x0c00, | ||
939 | + GLAMO_REGOFS_LCD = 0x1100, | ||
940 | + GLAMO_REGOFS_MMC = 0x1400, | ||
941 | + GLAMO_REGOFS_MPROC0 = 0x1500, | ||
942 | + GLAMO_REGOFS_MPROC1 = 0x1580, | ||
943 | + GLAMO_REGOFS_CMDQUEUE = 0x1600, | ||
944 | + GLAMO_REGOFS_RISC = 0x1680, | ||
945 | + GLAMO_REGOFS_2D = 0x1700, | ||
946 | + GLAMO_REGOFS_3D = 0x1b00, | ||
947 | +}; | ||
948 | + | ||
949 | + | ||
950 | +#define REG_MPEG(x) (GLAMO_REGOFS_MPEG+(x)) | ||
951 | + | ||
952 | +enum glamo_register_mpeg { | ||
953 | + // | ||
954 | + GLAMO_REG_MPEG_DC_ADDRL = REG_MPEG(0x3c), | ||
955 | + GLAMO_REG_MPEG_DC_ADDRH = REG_MPEG(0x3e), | ||
956 | + GLAMO_REG_MPEG_AC_ADDRL = REG_MPEG(0x40), | ||
957 | + GLAMO_REG_MPEG_AC_ADDRH = REG_MPEG(0x42), | ||
958 | + // | ||
959 | + GLAMO_REG_MPEG_SAFE_1 = REG_MPEG(0x60), | ||
960 | + GLAMO_REG_MPEG_SAFE_2 = REG_MPEG(0x62), | ||
961 | + GLAMO_REG_MPEG_SAFE_3 = REG_MPEG(0x64), | ||
962 | + // | ||
963 | + GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e), | ||
964 | + GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70), | ||
965 | + GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72), | ||
966 | + GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74), | ||
967 | + GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76), | ||
968 | + GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78), | ||
969 | + GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a), | ||
970 | + GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c), | ||
971 | + GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e), | ||
972 | + GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80), | ||
973 | + GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82), | ||
974 | + GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84), | ||
975 | + GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86), | ||
976 | + GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88), | ||
977 | + GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a), | ||
978 | + GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c), | ||
979 | + GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e), | ||
980 | + GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90), | ||
981 | + GLAMO_REG_MPEG_DEC_WIDTH = REG_MPEG(0x92), | ||
982 | + GLAMO_REG_MPEG_DEC_HEIGHT = REG_MPEG(0x94), | ||
983 | + GLAMO_REG_MPEG_SPECIAL = REG_MPEG(0x96), | ||
984 | + GLAMO_REG_MPEG_DEC_IN_ADDRL = REG_MPEG(0x98), | ||
985 | + GLAMO_REG_MPEG_DEC_IN_ADDRH = REG_MPEG(0x9a), | ||
986 | + // | ||
987 | + GLAMO_REG_MPEG_DEBLK_THRESHOLD = REG_MPEG(0xc0), | ||
988 | + // | ||
989 | + GLAMO_REG_MPEG_DEC_STATUS = REG_MPEG(0xc8), | ||
990 | + GLAMO_REG_MPEG_DEC_RB0 = REG_MPEG(0xca), | ||
991 | + GLAMO_REG_MPEG_DEC_RB1 = REG_MPEG(0xcc), | ||
992 | +}; | ||
993 | + | ||
994 | + | ||
995 | +#define REG_2D(x) (GLAMO_REGOFS_2D+(x)) | ||
996 | + | ||
997 | +enum glamo_register_2d { | ||
998 | + GLAMO_REG_2D_SRC_ADDRL = REG_2D(0x00), | ||
999 | + GLAMO_REG_2D_SRC_ADDRH = REG_2D(0x02), | ||
1000 | + GLAMO_REG_2D_SRC_PITCH = REG_2D(0x04), | ||
1001 | + GLAMO_REG_2D_SRC_X = REG_2D(0x06), | ||
1002 | + GLAMO_REG_2D_SRC_Y = REG_2D(0x08), | ||
1003 | + GLAMO_REG_2D_DST_X = REG_2D(0x0a), | ||
1004 | + GLAMO_REG_2D_DST_Y = REG_2D(0x0c), | ||
1005 | + GLAMO_REG_2D_DST_ADDRL = REG_2D(0x0e), | ||
1006 | + GLAMO_REG_2D_DST_ADDRH = REG_2D(0x10), | ||
1007 | + GLAMO_REG_2D_DST_PITCH = REG_2D(0x12), | ||
1008 | + GLAMO_REG_2D_DST_HEIGHT = REG_2D(0x14), | ||
1009 | + GLAMO_REG_2D_RECT_WIDTH = REG_2D(0x16), | ||
1010 | + GLAMO_REG_2D_RECT_HEIGHT = REG_2D(0x18), | ||
1011 | + GLAMO_REG_2D_PAT_ADDRL = REG_2D(0x1a), | ||
1012 | + GLAMO_REG_2D_PAT_ADDRH = REG_2D(0x1c), | ||
1013 | + GLAMO_REG_2D_PAT_FG = REG_2D(0x1e), | ||
1014 | + GLAMO_REG_2D_PAT_BG = REG_2D(0x20), | ||
1015 | + GLAMO_REG_2D_SRC_FG = REG_2D(0x22), | ||
1016 | + GLAMO_REG_2D_SRC_BG = REG_2D(0x24), | ||
1017 | + GLAMO_REG_2D_MASK1 = REG_2D(0x26), | ||
1018 | + GLAMO_REG_2D_MASK2 = REG_2D(0x28), | ||
1019 | + GLAMO_REG_2D_MASK3 = REG_2D(0x2a), | ||
1020 | + GLAMO_REG_2D_MASK4 = REG_2D(0x2c), | ||
1021 | + GLAMO_REG_2D_ROT_X = REG_2D(0x2e), | ||
1022 | + GLAMO_REG_2D_ROT_Y = REG_2D(0x30), | ||
1023 | + GLAMO_REG_2D_LEFT_CLIP = REG_2D(0x32), | ||
1024 | + GLAMO_REG_2D_TOP_CLIP = REG_2D(0x34), | ||
1025 | + GLAMO_REG_2D_RIGHT_CLIP = REG_2D(0x36), | ||
1026 | + GLAMO_REG_2D_BOTTOM_CLIP = REG_2D(0x38), | ||
1027 | + GLAMO_REG_2D_COMMAND1 = REG_2D(0x3A), | ||
1028 | + GLAMO_REG_2D_COMMAND2 = REG_2D(0x3C), | ||
1029 | + GLAMO_REG_2D_COMMAND3 = REG_2D(0x3E), | ||
1030 | + GLAMO_REG_2D_SAFE = REG_2D(0x40), | ||
1031 | + GLAMO_REG_2D_STATUS = REG_2D(0x42), | ||
1032 | + GLAMO_REG_2D_ID1 = REG_2D(0x44), | ||
1033 | + GLAMO_REG_2D_ID2 = REG_2D(0x46), | ||
1034 | + GLAMO_REG_2D_ID3 = REG_2D(0x48), | ||
1035 | +}; | ||
1036 | + | ||
1037 | + | ||
1038 | +/* No offset this time */ | ||
1039 | +#define REG_3D(x) (x) | ||
1040 | + | ||
1041 | +enum glamo_register_3d | ||
1042 | +{ | ||
1043 | + /* Fire the engine */ | ||
1044 | + G3D_FIRE = REG_3D(0x2058), | ||
1045 | + | ||
1046 | + /* Streams of vertex/colour/normal/texcoord data */ | ||
1047 | + G3D_ACTIVE_STREAMS = REG_3D(0x1f00), | ||
1048 | + G3D_LAST_STREAM__VCOLFMT = REG_3D(0x2030), | ||
1049 | + G3D_STREAM_MODE_0 = REG_3D(0x1f10), | ||
1050 | + G3D_STREAM_BASE_0 = REG_3D(0x1f14), | ||
1051 | + G3D_STREAM_MODE_1 = REG_3D(0x1f18), | ||
1052 | + G3D_STREAM_BASE_1 = REG_3D(0x1f1c), | ||
1053 | + G3D_STREAM_MODE_2 = REG_3D(0x1f20), | ||
1054 | + G3D_STREAM_BASE_2 = REG_3D(0x1f24), | ||
1055 | + G3D_STREAM_MODE_3 = REG_3D(0x1f28), | ||
1056 | + G3D_STREAM_BASE_3 = REG_3D(0x1f2c), | ||
1057 | + G3D_STREAM_MODE_4 = REG_3D(0x1f30), | ||
1058 | + G3D_STREAM_BASE_4 = REG_3D(0x1f34), | ||
1059 | + G3D_STREAM_MODE_5 = REG_3D(0x1f38), | ||
1060 | + G3D_STREAM_BASE_5 = REG_3D(0x1f3c), | ||
1061 | + G3D_STREAM_MODE_6 = REG_3D(0x1f40), | ||
1062 | + G3D_STREAM_BASE_6 = REG_3D(0x1f44), | ||
1063 | + G3D_STREAM_MODE_7 = REG_3D(0x1f48), | ||
1064 | + G3D_STREAM_BASE_7 = REG_3D(0x1f4c), | ||
1065 | + | ||
1066 | + /* Modelview*projection matrix */ | ||
1067 | + G3D_MATRIX_MVP = REG_3D(0x26a0), /* .. 0x27df */ | ||
1068 | + | ||
1069 | + /* Modelview matrix */ | ||
1070 | + G3D_MATRIX_MV = REG_3D(0x26e0), /* .. 0x270f */ | ||
1071 | + | ||
1072 | + /* Inverse MVP, 3x3 only */ | ||
1073 | + G3D_MATRIX_IMVP = REG_3D(0x2710), /* .. 0x2733 */ | ||
1074 | + | ||
1075 | +}; | ||
1076 | + | ||
1077 | +#endif /* _GLAMO_REGS_H */ | ||
1078 | diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c | ||
1079 | new file mode 100644 | ||
1080 | index 0000000..d8b21d5 | ||
1081 | --- /dev/null | ||
1082 | +++ b/src/mesa/drivers/dri/glamo/glamo_render.c | ||
1083 | @@ -0,0 +1,230 @@ | ||
1084 | +/* | ||
1085 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1086 | + * | ||
1087 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
1088 | + * | ||
1089 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1090 | + * copy of this software and associated documentation files (the "Software"), | ||
1091 | + * to deal in the Software without restriction, including without limitation | ||
1092 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1093 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1094 | + * Software is furnished to do so, subject to the following conditions: | ||
1095 | + * | ||
1096 | + * The above copyright notice and this permission notice shall be included | ||
1097 | + * in all copies or substantial portions of the Software. | ||
1098 | + * | ||
1099 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1100 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1101 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1102 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1103 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1104 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1105 | + * | ||
1106 | + * | ||
1107 | + * Based on intel_render.c, to which the following notice applies: | ||
1108 | + * | ||
1109 | + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. | ||
1110 | + * All Rights Reserved. | ||
1111 | + * | ||
1112 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1113 | + * copy of this software and associated documentation files (the | ||
1114 | + * "Software"), to deal in the Software without restriction, including | ||
1115 | + * without limitation the rights to use, copy, modify, merge, publish, | ||
1116 | + * distribute, sub license, and/or sell copies of the Software, and to | ||
1117 | + * permit persons to whom the Software is furnished to do so, subject to | ||
1118 | + * the following conditions: | ||
1119 | + * | ||
1120 | + * The above copyright notice and this permission notice (including the | ||
1121 | + * next paragraph) shall be included in all copies or substantial portions | ||
1122 | + * of the Software. | ||
1123 | + * | ||
1124 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1125 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
1126 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | ||
1127 | + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR | ||
1128 | + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
1129 | + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
1130 | + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1131 | + * | ||
1132 | + */ | ||
1133 | + | ||
1134 | + | ||
1135 | +/* | ||
1136 | + * Render unclipped vertex buffers by emitting vertices directly to | ||
1137 | + * dma buffers. Use strip/fan hardware acceleration where possible. | ||
1138 | + * | ||
1139 | + */ | ||
1140 | +#include "main/glheader.h" | ||
1141 | +#include "main/context.h" | ||
1142 | +#include "main/macros.h" | ||
1143 | +#include "main/imports.h" | ||
1144 | +#include "main/mtypes.h" | ||
1145 | +#include "main/enums.h" | ||
1146 | + | ||
1147 | +#include "tnl/t_context.h" | ||
1148 | +#include "tnl/t_vertex.h" | ||
1149 | +#include "tnl/t_pipeline.h" | ||
1150 | +#include "math/m_xform.h" | ||
1151 | + | ||
1152 | +#include "glamo_context.h" | ||
1153 | +#include "glamo_tris.h" | ||
1154 | +#include "glamo_regs.h" | ||
1155 | + | ||
1156 | +/* | ||
1157 | + * Render unclipped vertex buffers by emitting vertices directly to | ||
1158 | + * VRAM buffers. Use strip/fan hardware primitives where possible. | ||
1159 | + * Try to simulate missing primitives with indexed vertices. | ||
1160 | + */ | ||
1161 | +#define HAVE_POINTS 1 | ||
1162 | +#define HAVE_LINES 1 | ||
1163 | +#define HAVE_LINE_STRIPS 0 | ||
1164 | +#define HAVE_TRIANGLES 1 | ||
1165 | +#define HAVE_TRI_STRIPS 0 | ||
1166 | +#define HAVE_TRI_STRIP_1 0 | ||
1167 | +#define HAVE_TRI_FANS 0 | ||
1168 | +#define HAVE_POLYGONS 0 | ||
1169 | +#define HAVE_QUADS 0 | ||
1170 | +#define HAVE_QUAD_STRIPS 0 | ||
1171 | +#define HAVE_ELTS 0 | ||
1172 | + | ||
1173 | + | ||
1174 | +static void glamoFlushPrim(struct glamo_context *gCtx) | ||
1175 | +{ | ||
1176 | + printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count, | ||
1177 | + gCtx->prim.start_offset, gCtx->prim.current_offset); | ||
1178 | + | ||
1179 | + if ( gCtx->prim.vb_bo == NULL ) return; | ||
1180 | + | ||
1181 | + /* Upload to hardware */ | ||
1182 | + glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset, | ||
1183 | + gCtx->prim.vb); | ||
1184 | + | ||
1185 | + /* Dispatch to the hardware */ | ||
1186 | + glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0); | ||
1187 | + glamoDRMAddData(gCtx, 0x000f0300, 4); | ||
1188 | + glamoDRMAddBO(gCtx, gCtx->prim.vb_bo); | ||
1189 | + glamoDRMDispatch(gCtx); | ||
1190 | + | ||
1191 | + /* Please use a new BO for the next buffer */ | ||
1192 | + gCtx->prim.vb_bo = NULL; | ||
1193 | + | ||
1194 | + /* Continue from new start */ | ||
1195 | + gCtx->prim.start_offset = gCtx->prim.current_offset; | ||
1196 | +} | ||
1197 | + | ||
1198 | + | ||
1199 | +static inline GLuint glamoGetVBMax(struct glamo_context *gCtx) | ||
1200 | +{ | ||
1201 | + return GLAMO_VB_SIZE / gCtx->vertex_size; | ||
1202 | +} | ||
1203 | + | ||
1204 | + | ||
1205 | +static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx) | ||
1206 | +{ | ||
1207 | + /* How many more vertices can be accommodated? | ||
1208 | + * Each vertex takes up 4x 32-bit fixed point values */ | ||
1209 | + return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size; | ||
1210 | +} | ||
1211 | + | ||
1212 | + | ||
1213 | +#define LOCAL_VARS \ | ||
1214 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1215 | + | ||
1216 | +#define INIT(prim) | ||
1217 | + | ||
1218 | +#define FLUSH() glamoFlushPrim(gCtx) | ||
1219 | + | ||
1220 | +#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx) | ||
1221 | +#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx) | ||
1222 | + | ||
1223 | +#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr) | ||
1224 | + | ||
1225 | +#define EMIT_VERTS(ctx, j, nr, buf) \ | ||
1226 | + _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf) | ||
1227 | + | ||
1228 | +#define TAG(x) glamo_##x | ||
1229 | +#include "tnl_dd/t_dd_dmatmp.h" | ||
1230 | + | ||
1231 | + | ||
1232 | +/**********************************************************************/ | ||
1233 | +/* Render pipeline stage */ | ||
1234 | +/**********************************************************************/ | ||
1235 | + | ||
1236 | +static void glamoFireEngine(struct glamo_context *gCtx) | ||
1237 | +{ | ||
1238 | + glamoDRMStartBurst(gCtx, G3D_FIRE); | ||
1239 | + glamoDRMAddData(gCtx, 0, 2); /* Fire! */ | ||
1240 | + glamoDRMDispatch(gCtx); | ||
1241 | +} | ||
1242 | + | ||
1243 | + | ||
1244 | +static GLboolean glamoRunRender(struct gl_context *ctx, | ||
1245 | + struct tnl_pipeline_stage *stage) | ||
1246 | +{ | ||
1247 | + TNLcontext *tnl = TNL_CONTEXT(ctx); | ||
1248 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1249 | + struct vertex_buffer *VB = &tnl->vb; | ||
1250 | + GLuint i; | ||
1251 | + | ||
1252 | + printf("glamoRunRender\n"); | ||
1253 | + | ||
1254 | + /* Don't handle clipping */ | ||
1255 | + if ( !glamo_validate_render(ctx, VB) ) { | ||
1256 | + return GL_TRUE; /* Failed */ | ||
1257 | + } | ||
1258 | + | ||
1259 | + /* Validate GPU state */ | ||
1260 | + if ( gCtx->new_state ) { | ||
1261 | + if ( !glamoValidateState(ctx, gCtx->new_state) ) { | ||
1262 | + printf("Couldn't validate state...\n"); | ||
1263 | + } | ||
1264 | + } /* else nothing to update */ | ||
1265 | + | ||
1266 | + tnl->clipspace.new_inputs |= VERT_BIT_POS; | ||
1267 | + | ||
1268 | + tnl->Driver.Render.Start(ctx); | ||
1269 | + | ||
1270 | + for ( i=0; i<VB->PrimitiveCount; i++ ) { | ||
1271 | + | ||
1272 | + GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); | ||
1273 | + GLuint start = VB->Primitive[i].start; | ||
1274 | + GLuint length = VB->Primitive[i].count; | ||
1275 | + | ||
1276 | + if (!length) continue; | ||
1277 | + | ||
1278 | + glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start, | ||
1279 | + start + length, prim); | ||
1280 | + | ||
1281 | + } | ||
1282 | + | ||
1283 | + tnl->Driver.Render.Finish(ctx); | ||
1284 | + | ||
1285 | + glamoFireEngine(gCtx); | ||
1286 | + | ||
1287 | + return GL_FALSE; /* Ok */ | ||
1288 | +} | ||
1289 | + | ||
1290 | + | ||
1291 | +static const struct tnl_pipeline_stage _glamo_render_stage = { | ||
1292 | + "glamo render", | ||
1293 | + NULL, | ||
1294 | + NULL, | ||
1295 | + NULL, | ||
1296 | + NULL, | ||
1297 | + glamoRunRender | ||
1298 | +}; | ||
1299 | + | ||
1300 | + | ||
1301 | +const struct tnl_pipeline_stage *glamo_pipeline[] = { | ||
1302 | + &_tnl_vertex_transform_stage, | ||
1303 | + &_tnl_normal_transform_stage, | ||
1304 | + &_tnl_lighting_stage, | ||
1305 | + &_tnl_fog_coordinate_stage, | ||
1306 | + &_tnl_texgen_stage, | ||
1307 | + &_tnl_texture_transform_stage, | ||
1308 | + &_tnl_point_attenuation_stage, | ||
1309 | + &_tnl_vertex_program_stage, | ||
1310 | + &_glamo_render_stage, /* ADD: unclipped rastersetup-to-dma */ | ||
1311 | + &_tnl_render_stage, | ||
1312 | + 0, | ||
1313 | +}; | ||
1314 | diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h | ||
1315 | new file mode 100644 | ||
1316 | index 0000000..99c36a8 | ||
1317 | --- /dev/null | ||
1318 | +++ b/src/mesa/drivers/dri/glamo/glamo_render.h | ||
1319 | @@ -0,0 +1,31 @@ | ||
1320 | +/* | ||
1321 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1322 | + * | ||
1323 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
1324 | + * | ||
1325 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1326 | + * copy of this software and associated documentation files (the "Software"), | ||
1327 | + * to deal in the Software without restriction, including without limitation | ||
1328 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1329 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1330 | + * Software is furnished to do so, subject to the following conditions: | ||
1331 | + * | ||
1332 | + * The above copyright notice and this permission notice shall be included | ||
1333 | + * in all copies or substantial portions of the Software. | ||
1334 | + * | ||
1335 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1336 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1337 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1338 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1339 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1340 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1341 | + */ | ||
1342 | + | ||
1343 | +#ifndef __GLAMO_RENDER_H | ||
1344 | +#define __GLAMO_RENDER_H | ||
1345 | + | ||
1346 | +#include "main/mtypes.h" | ||
1347 | + | ||
1348 | +extern const struct tnl_pipeline_stage *glamo_pipeline[]; | ||
1349 | + | ||
1350 | +#endif /* __GLAMO_RENDER_H */ | ||
1351 | diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c | ||
1352 | new file mode 100644 | ||
1353 | index 0000000..cc8a730 | ||
1354 | --- /dev/null | ||
1355 | +++ b/src/mesa/drivers/dri/glamo/glamo_screen.c | ||
1356 | @@ -0,0 +1,250 @@ | ||
1357 | +/* | ||
1358 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1359 | + * | ||
1360 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
1361 | + * Roughly based on sis_screen.c (c) 2003 Eric Anholt | ||
1362 | + * | ||
1363 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1364 | + * copy of this software and associated documentation files (the "Software"), | ||
1365 | + * to deal in the Software without restriction, including without limitation | ||
1366 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1367 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1368 | + * Software is furnished to do so, subject to the following conditions: | ||
1369 | + * | ||
1370 | + * The above copyright notice and this permission notice shall be included | ||
1371 | + * in all copies or substantial portions of the Software. | ||
1372 | + * | ||
1373 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1374 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1375 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1376 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1377 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1378 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1379 | + */ | ||
1380 | + | ||
1381 | + | ||
1382 | +#include "dri_util.h" | ||
1383 | +#include "utils.h" | ||
1384 | +#include "xmlconfig.h" | ||
1385 | +#include "GL/internal/dri_interface.h" | ||
1386 | +#include "main/framebuffer.h" | ||
1387 | +#include "main/renderbuffer.h" | ||
1388 | + | ||
1389 | +#include "glamo_screen.h" | ||
1390 | +#include "glamo_context.h" | ||
1391 | +#include "glamo_fbo.h" | ||
1392 | + | ||
1393 | +/* This comes from libdrm_glamo */ | ||
1394 | +#include <glamo_bo_gem.h> | ||
1395 | + | ||
1396 | + | ||
1397 | +static int glamoInitDriver(__DRIscreen *psp) | ||
1398 | +{ | ||
1399 | + return 0; | ||
1400 | +} | ||
1401 | + | ||
1402 | + | ||
1403 | +static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv) | ||
1404 | +{ | ||
1405 | + glamoScreenPtr glamoScreen; | ||
1406 | + | ||
1407 | + /* Allocate the private area */ | ||
1408 | + glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen)); | ||
1409 | + if ( glamoScreen == NULL ) | ||
1410 | + return NULL; | ||
1411 | + | ||
1412 | + glamoScreen->driScreen = sPriv; | ||
1413 | + | ||
1414 | + /* This is our link to the kernel's memory manager, via libdrm */ | ||
1415 | + glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd); | ||
1416 | + | ||
1417 | + return glamoScreen; | ||
1418 | +} | ||
1419 | + | ||
1420 | + | ||
1421 | +static void glamoDestroyScreen(__DRIscreen *sPriv) | ||
1422 | +{ | ||
1423 | + glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private; | ||
1424 | + | ||
1425 | + if ( glamoScreen == NULL ) | ||
1426 | + return; | ||
1427 | + | ||
1428 | + FREE(glamoScreen); | ||
1429 | + sPriv->private = NULL; | ||
1430 | +} | ||
1431 | + | ||
1432 | + | ||
1433 | +static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv) | ||
1434 | +{ | ||
1435 | + __DRIconfig **configs; | ||
1436 | + uint8_t depth_bits_array[2]; | ||
1437 | + uint8_t stencil_bits_array[2]; | ||
1438 | + uint8_t msaa_samples_array[1]; | ||
1439 | + static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE }; | ||
1440 | + | ||
1441 | + /* Driver initialisation */ | ||
1442 | + if ( glamoInitDriver(sPriv) ) { | ||
1443 | + return NULL; | ||
1444 | + } | ||
1445 | + | ||
1446 | + /* Screen-specific initialisation */ | ||
1447 | + sPriv->private = glamoCreateScreen(sPriv); | ||
1448 | + if ( !sPriv->private ) { | ||
1449 | + glamoDestroyScreen(sPriv); | ||
1450 | + return NULL; | ||
1451 | + } | ||
1452 | + | ||
1453 | + depth_bits_array[0] = 0; | ||
1454 | + stencil_bits_array[0] = 0; | ||
1455 | + depth_bits_array[1] = 16; | ||
1456 | + stencil_bits_array[1] = 0; | ||
1457 | + msaa_samples_array[0] = 0; | ||
1458 | + | ||
1459 | + configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, | ||
1460 | + depth_bits_array, stencil_bits_array, 2, | ||
1461 | + db_modes, 2, msaa_samples_array, 1, GL_TRUE); | ||
1462 | + | ||
1463 | + if ( configs == NULL ) { | ||
1464 | + fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__); | ||
1465 | + return NULL; | ||
1466 | + } | ||
1467 | + | ||
1468 | + return (const __DRIconfig **)configs; | ||
1469 | +} | ||
1470 | + | ||
1471 | + | ||
1472 | +static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv) | ||
1473 | +{ | ||
1474 | + __DRIconfig **configs; | ||
1475 | + uint8_t depth_bits_array[2]; | ||
1476 | + uint8_t stencil_bits_array[2]; | ||
1477 | + uint8_t msaa_samples_array[1]; | ||
1478 | + static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE }; | ||
1479 | + | ||
1480 | + /* Driver initialisation */ | ||
1481 | + if ( glamoInitDriver(sPriv) ) { | ||
1482 | + return NULL; | ||
1483 | + } | ||
1484 | + | ||
1485 | + /* Screen-specific initialisation */ | ||
1486 | + sPriv->private = glamoCreateScreen(sPriv); | ||
1487 | + if ( !sPriv->private ) { | ||
1488 | + glamoDestroyScreen(sPriv); | ||
1489 | + return NULL; | ||
1490 | + } | ||
1491 | + | ||
1492 | + depth_bits_array[0] = 0; | ||
1493 | + stencil_bits_array[0] = 0; | ||
1494 | + depth_bits_array[1] = 16; | ||
1495 | + stencil_bits_array[1] = 0; | ||
1496 | + msaa_samples_array[0] = 0; | ||
1497 | + | ||
1498 | + configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, | ||
1499 | + depth_bits_array, stencil_bits_array, 2, | ||
1500 | + db_modes, 2, msaa_samples_array, 1, GL_TRUE); | ||
1501 | + | ||
1502 | + if ( configs == NULL ) { | ||
1503 | + fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__); | ||
1504 | + return NULL; | ||
1505 | + } | ||
1506 | + | ||
1507 | + return (const __DRIconfig **)configs; | ||
1508 | +} | ||
1509 | + | ||
1510 | + | ||
1511 | +/* Allocate buffers for a context. This is where the fun starts... */ | ||
1512 | +static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv, | ||
1513 | + __DRIdrawable *driDrawPriv, | ||
1514 | + const struct gl_config *mesaVis, | ||
1515 | + GLboolean isPixmap) | ||
1516 | +{ | ||
1517 | + struct glamo_framebuffer *gfb; | ||
1518 | + GLenum rgbFormat; | ||
1519 | + | ||
1520 | + if ( isPixmap ) return GL_FALSE; /* not implemented */ | ||
1521 | + | ||
1522 | + gfb = CALLOC_STRUCT(glamo_framebuffer); | ||
1523 | + if ( !gfb ) return GL_FALSE; | ||
1524 | + | ||
1525 | + _mesa_initialize_window_framebuffer(&gfb->base, mesaVis); | ||
1526 | + | ||
1527 | + /* we only support this one format at the moment */ | ||
1528 | + rgbFormat = GL_RGB5; | ||
1529 | + | ||
1530 | + /* Front color renderbuffer */ | ||
1531 | + gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv); | ||
1532 | + _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT, | ||
1533 | + &gfb->color_rb[0]->base); | ||
1534 | + | ||
1535 | + /* Back color renderbuffer, if requested */ | ||
1536 | + if ( mesaVis->doubleBufferMode ) { | ||
1537 | + gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv); | ||
1538 | + _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT, | ||
1539 | + &gfb->color_rb[1]->base); | ||
1540 | + } | ||
1541 | + | ||
1542 | + if ( mesaVis->depthBits == 16 ) { | ||
1543 | + struct glamo_renderbuffer *depth; | ||
1544 | + depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv); | ||
1545 | + _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base); | ||
1546 | + } | ||
1547 | + | ||
1548 | + /* Add software renderbuffers for the things we can't support in hardware */ | ||
1549 | + _mesa_add_soft_renderbuffers(&gfb->base, | ||
1550 | + GL_FALSE, /* color */ | ||
1551 | + GL_FALSE, /* depth */ | ||
1552 | + mesaVis->stencilBits > 0, /* stencil, if required */ | ||
1553 | + mesaVis->accumRedBits > 0, /* accum, if required */ | ||
1554 | + GL_FALSE, /* alpha */ | ||
1555 | + GL_FALSE /* aux */ | ||
1556 | + ); | ||
1557 | + driDrawPriv->driverPrivate = (void *)gfb; | ||
1558 | + | ||
1559 | + return (driDrawPriv->driverPrivate != NULL); | ||
1560 | +} | ||
1561 | + | ||
1562 | + | ||
1563 | +static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv) | ||
1564 | +{ | ||
1565 | +} | ||
1566 | + | ||
1567 | + | ||
1568 | +static void glamoSwapBuffers(__DRIdrawable *driDrawPriv) | ||
1569 | +{ | ||
1570 | + printf("glamoSwapBuffers\n"); fflush(stdout); | ||
1571 | +} | ||
1572 | + | ||
1573 | + | ||
1574 | +/* | ||
1575 | + * Mesa entry points | ||
1576 | + * | ||
1577 | + * See src/mesa/drivers/dri/common/dri_util.h for information about these | ||
1578 | + */ | ||
1579 | +const struct __DriverAPIRec driDriverAPI = { | ||
1580 | + .InitScreen = glamoInitScreen, | ||
1581 | + .DestroyScreen = glamoDestroyScreen, | ||
1582 | + .CreateContext = glamoCreateContext, | ||
1583 | + .DestroyContext = glamoDestroyContext, | ||
1584 | + .CreateBuffer = glamoCreateBuffer, | ||
1585 | + .DestroyBuffer = glamoDestroyBuffer, | ||
1586 | + .SwapBuffers = glamoSwapBuffers, | ||
1587 | + .MakeCurrent = glamoMakeCurrent, | ||
1588 | + .UnbindContext = glamoUnbindContext, | ||
1589 | + .GetSwapInfo = NULL, /* Not used */ | ||
1590 | + .WaitForMSC = NULL, | ||
1591 | + .WaitForSBC = NULL, | ||
1592 | + .SwapBuffersMSC = NULL, | ||
1593 | + .CopySubBuffer = NULL, | ||
1594 | + .GetDrawableMSC = NULL, /* Not used */ | ||
1595 | + .InitScreen2 = glamoInitScreen2, /* For DRI2 */ | ||
1596 | +}; | ||
1597 | + | ||
1598 | +/* This is the table of extensions that the loader will dlsym() for. */ | ||
1599 | +PUBLIC const __DRIextension *__driDriverExtensions[] = { | ||
1600 | + &driCoreExtension.base, | ||
1601 | + &driLegacyExtension.base, | ||
1602 | + &driDRI2Extension.base, | ||
1603 | + NULL | ||
1604 | +}; | ||
1605 | + | ||
1606 | +/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ | ||
1607 | diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h | ||
1608 | new file mode 100644 | ||
1609 | index 0000000..3f2eb5f | ||
1610 | --- /dev/null | ||
1611 | +++ b/src/mesa/drivers/dri/glamo/glamo_screen.h | ||
1612 | @@ -0,0 +1,44 @@ | ||
1613 | +/* | ||
1614 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1615 | + * | ||
1616 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
1617 | + * Roughly based on sis_screen.h (c) 2003 Eric Anholt | ||
1618 | + * | ||
1619 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1620 | + * copy of this software and associated documentation files (the "Software"), | ||
1621 | + * to deal in the Software without restriction, including without limitation | ||
1622 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1623 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1624 | + * Software is furnished to do so, subject to the following conditions: | ||
1625 | + * | ||
1626 | + * The above copyright notice and this permission notice shall be included | ||
1627 | + * in all copies or substantial portions of the Software. | ||
1628 | + * | ||
1629 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1630 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1631 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1632 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1633 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1634 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1635 | + */ | ||
1636 | + | ||
1637 | +#ifndef __GLAMO_SCREEN_H | ||
1638 | +#define __GLAMO_SCREEN_H | ||
1639 | + | ||
1640 | +#include "xmlconfig.h" | ||
1641 | +#include "dri_util.h" | ||
1642 | + | ||
1643 | +#include <glamo_bo_gem.h> | ||
1644 | + | ||
1645 | +typedef struct { | ||
1646 | + | ||
1647 | + __DRIscreen *driScreen; | ||
1648 | + driOptionCache optionCache; | ||
1649 | + | ||
1650 | + struct glamo_bo_manager *bom; | ||
1651 | + | ||
1652 | +} glamoScreenRec, *glamoScreenPtr; | ||
1653 | + | ||
1654 | +#endif /* __GLAMO_SCREEN_H */ | ||
1655 | + | ||
1656 | +/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ | ||
1657 | diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c | ||
1658 | new file mode 100644 | ||
1659 | index 0000000..3aa2f8b | ||
1660 | --- /dev/null | ||
1661 | +++ b/src/mesa/drivers/dri/glamo/glamo_state.c | ||
1662 | @@ -0,0 +1,305 @@ | ||
1663 | +/* | ||
1664 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1665 | + * | ||
1666 | + * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk> | ||
1667 | + * Roughly based on sis_state.c (c) 2003 Eric Anholt | ||
1668 | + * | ||
1669 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1670 | + * copy of this software and associated documentation files (the "Software"), | ||
1671 | + * to deal in the Software without restriction, including without limitation | ||
1672 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1673 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1674 | + * Software is furnished to do so, subject to the following conditions: | ||
1675 | + * | ||
1676 | + * The above copyright notice and this permission notice shall be included | ||
1677 | + * in all copies or substantial portions of the Software. | ||
1678 | + * | ||
1679 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1680 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1681 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1682 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1683 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1684 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1685 | + * | ||
1686 | + * | ||
1687 | + * Also partially based on intel_fbo.c, to which the following notice applies: | ||
1688 | + * | ||
1689 | + * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. | ||
1690 | + * All Rights Reserved. | ||
1691 | + * | ||
1692 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1693 | + * copy of this software and associated documentation files (the | ||
1694 | + * "Software"), to deal in the Software without restriction, including | ||
1695 | + * without limitation the rights to use, copy, modify, merge, publish, | ||
1696 | + * distribute, sub license, and/or sell copies of the Software, and to | ||
1697 | + * permit persons to whom the Software is furnished to do so, subject to | ||
1698 | + * the following conditions: | ||
1699 | + * | ||
1700 | + * The above copyright notice and this permission notice (including the | ||
1701 | + * next paragraph) shall be included in all copies or substantial portions | ||
1702 | + * of the Software. | ||
1703 | + * | ||
1704 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1705 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
1706 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | ||
1707 | + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR | ||
1708 | + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
1709 | + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
1710 | + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1711 | + */ | ||
1712 | + | ||
1713 | + | ||
1714 | +#include "main/context.h" | ||
1715 | +#include "main/framebuffer.h" | ||
1716 | +#include "main/api_arrayelt.h" | ||
1717 | +#include "main/macros.h" | ||
1718 | +#include "swrast/swrast.h" | ||
1719 | +#include "swrast_setup/swrast_setup.h" | ||
1720 | +#include "tnl/tnl.h" | ||
1721 | + | ||
1722 | +#include "glamo_fbo.h" | ||
1723 | +#include "glamo_state.h" | ||
1724 | +#include "glamo_context.h" | ||
1725 | +#include "glamo_cmdq.h" | ||
1726 | +#include "glamo_regs.h" | ||
1727 | + | ||
1728 | + | ||
1729 | +static void glamoResizeBuffers(struct gl_context *ctx, struct gl_framebuffer *fb, | ||
1730 | + GLuint width, GLuint height) | ||
1731 | +{ | ||
1732 | + struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb; | ||
1733 | + int i; | ||
1734 | + | ||
1735 | + _mesa_resize_framebuffer(ctx, fb, width, height); | ||
1736 | + | ||
1737 | + fb->Initialized = GL_TRUE; /* XXX remove someday */ | ||
1738 | + | ||
1739 | + if (fb->Name != 0) { | ||
1740 | + return; | ||
1741 | + } | ||
1742 | + | ||
1743 | + /* Make sure all window system renderbuffers are up to date */ | ||
1744 | + for (i = 0; i < 2; i++) { | ||
1745 | + struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base; | ||
1746 | + | ||
1747 | + /* only resize if size is changing */ | ||
1748 | + if (rb && (rb->Width != width || rb->Height != height)) { | ||
1749 | + rb->AllocStorage(ctx, rb, rb->InternalFormat, | ||
1750 | + width, height); | ||
1751 | + } | ||
1752 | + } | ||
1753 | +} | ||
1754 | + | ||
1755 | + | ||
1756 | +static void glamoClear(struct gl_context *ctx, GLbitfield mask) | ||
1757 | +{ | ||
1758 | + glamoContext *gCtx; | ||
1759 | + struct gl_framebuffer *fb; | ||
1760 | + int i; | ||
1761 | + | ||
1762 | + gCtx = GLAMO_CONTEXT(ctx); | ||
1763 | + fb = ctx->DrawBuffer; | ||
1764 | + | ||
1765 | + printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0], | ||
1766 | + ctx->Color.ClearColor[1], ctx->Color.ClearColor[2], | ||
1767 | + ctx->Color.ClearColor[3]); fflush(stdout); | ||
1768 | + | ||
1769 | + for (i = 0; i < fb->_NumColorDrawBuffers; i++) { | ||
1770 | + | ||
1771 | + struct glamo_renderbuffer *grb; | ||
1772 | + | ||
1773 | + grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]); | ||
1774 | + | ||
1775 | + glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X); | ||
1776 | + glamoDRMAddData(gCtx, fb->_Xmin, 2); /* dest X */ | ||
1777 | + glamoDRMAddData(gCtx, fb->_Ymin, 2); /* dest Y */ | ||
1778 | + glamoDRMAddBO(gCtx, grb->bo); /* dest L/H */ | ||
1779 | + glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2); /* dest pitch */ | ||
1780 | + glamoDRMAddData(gCtx, grb->height, 2); /* dest height */ | ||
1781 | + glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */ | ||
1782 | + glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */ | ||
1783 | + glamoDRMAddData(gCtx, 0x0000, 2); /* patt L */ | ||
1784 | + glamoDRMAddData(gCtx, 0x0000, 2); /* patt H */ | ||
1785 | + glamoDRMAddData(gCtx, gCtx->col_clear, 2); /* FG colour */ | ||
1786 | + glamoDRMDispatch(gCtx); | ||
1787 | + | ||
1788 | + glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1); | ||
1789 | + glamoDRMAddData(gCtx, 0x0000, 2); /* Cmd param 1 */ | ||
1790 | + glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */ | ||
1791 | + glamoDRMAddData(gCtx, 0x0000, 2); /* Cmd param 3 */ | ||
1792 | + glamoDRMDispatch(gCtx); | ||
1793 | + | ||
1794 | + } | ||
1795 | +} | ||
1796 | + | ||
1797 | + | ||
1798 | +static void glamoClearColor(struct gl_context *ctx, const GLfloat color[4]) | ||
1799 | +{ | ||
1800 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1801 | + GLubyte col_byte[4]; | ||
1802 | + | ||
1803 | + printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2], | ||
1804 | + color[3]); fflush(stdout); | ||
1805 | + | ||
1806 | + CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]); | ||
1807 | + CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]); | ||
1808 | + CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]); | ||
1809 | + CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]); | ||
1810 | + | ||
1811 | + gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1], | ||
1812 | + col_byte[2]); | ||
1813 | +} | ||
1814 | + | ||
1815 | + | ||
1816 | +static void glamoShadeModel(struct gl_context *ctx, GLenum mode) | ||
1817 | +{ | ||
1818 | + printf("glamoShadeModel\n"); fflush(stdout); | ||
1819 | +} | ||
1820 | + | ||
1821 | + | ||
1822 | +static void glamoViewport(struct gl_context *ctx, GLint x, GLint y, | ||
1823 | + GLsizei width, GLsizei height ) | ||
1824 | +{ | ||
1825 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1826 | + __DRIcontext *driContext = gCtx->driContext; | ||
1827 | + void (*old_viewport)(struct gl_context *ctx, GLint x, GLint y, | ||
1828 | + GLsizei w, GLsizei h); | ||
1829 | + | ||
1830 | + if ( !driContext->driScreenPriv->dri2.enabled ) return; | ||
1831 | + | ||
1832 | + /* TODO: Flush before fiddling with fake front buffer */ | ||
1833 | + | ||
1834 | + if ( ctx->DrawBuffer->Name == 0 ) { | ||
1835 | + | ||
1836 | + glamo_update_renderbuffers(driContext, | ||
1837 | + driContext->driDrawablePriv); | ||
1838 | + if ( driContext->driDrawablePriv | ||
1839 | + != driContext->driReadablePriv ) { | ||
1840 | + glamo_update_renderbuffers(driContext, | ||
1841 | + driContext->driReadablePriv); | ||
1842 | + } | ||
1843 | + | ||
1844 | + } | ||
1845 | + | ||
1846 | + old_viewport = ctx->Driver.Viewport; | ||
1847 | + ctx->Driver.Viewport = NULL; | ||
1848 | + gCtx->driDrawable = driContext->driDrawablePriv; | ||
1849 | + ctx->Driver.Viewport = old_viewport; | ||
1850 | +} | ||
1851 | + | ||
1852 | + | ||
1853 | +static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg, | ||
1854 | + GLfloat *matrix) | ||
1855 | +{ | ||
1856 | + int i; | ||
1857 | + char *type; | ||
1858 | + | ||
1859 | + switch ( mreg ) { | ||
1860 | + case G3D_MATRIX_MVP : | ||
1861 | + type = "MVP"; break; | ||
1862 | + case G3D_MATRIX_MV : | ||
1863 | + type = "MV"; break; | ||
1864 | + case G3D_MATRIX_IMVP : | ||
1865 | + type = "inverse MVP"; break; | ||
1866 | + default : | ||
1867 | + type = "unknown"; break; | ||
1868 | + } | ||
1869 | + printf("Uploading %s matrix...\n", type); | ||
1870 | + | ||
1871 | + glamoDRMStartBurst(gCtx, mreg); | ||
1872 | + if ( mreg != G3D_MATRIX_IMVP ) { | ||
1873 | + for ( i=0; i<16; i++ ) { | ||
1874 | + glamoDRMAddData(gCtx, float7s16(matrix[i]), 4); | ||
1875 | + } | ||
1876 | + } else { | ||
1877 | + /* Normal matrix needs special treatment */ | ||
1878 | + for ( i=0; i<3; i++ ) { | ||
1879 | + glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4); | ||
1880 | + glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4); | ||
1881 | + glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4); | ||
1882 | + } | ||
1883 | + } | ||
1884 | + glamoDRMDispatch(gCtx); | ||
1885 | +} | ||
1886 | + | ||
1887 | + | ||
1888 | +GLboolean glamoValidateState(struct gl_context *ctx, GLuint new_state) | ||
1889 | +{ | ||
1890 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1891 | + | ||
1892 | + if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) { | ||
1893 | + | ||
1894 | + glamoUploadMatrix(gCtx, G3D_MATRIX_MVP, | ||
1895 | + ctx->_ModelProjectMatrix.m); | ||
1896 | + | ||
1897 | + /* FIXME: The following two aren't needed unless lighting | ||
1898 | + * is in use... */ | ||
1899 | + glamoUploadMatrix(gCtx, G3D_MATRIX_MV, | ||
1900 | + ctx->ModelviewMatrixStack.Top->m); | ||
1901 | + _math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix)); | ||
1902 | + _math_matrix_analyse(&(ctx->_ModelProjectMatrix)); | ||
1903 | + glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP, | ||
1904 | + ctx->_ModelProjectMatrix.inv); | ||
1905 | + } | ||
1906 | + | ||
1907 | + gCtx->new_state = 0; | ||
1908 | + return GL_TRUE; | ||
1909 | +} | ||
1910 | + | ||
1911 | + | ||
1912 | +static void glamoUpdateState(struct gl_context *ctx, GLbitfield new_state) | ||
1913 | +{ | ||
1914 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
1915 | + | ||
1916 | + printf("glamoUpdateState\n"); | ||
1917 | + | ||
1918 | + _swrast_InvalidateState(ctx, new_state); | ||
1919 | + _swsetup_InvalidateState(ctx, new_state); | ||
1920 | + _vbo_InvalidateState(ctx, new_state); | ||
1921 | + _tnl_InvalidateState(ctx, new_state); | ||
1922 | + _ae_invalidate_state(ctx, new_state); | ||
1923 | + | ||
1924 | + /* Make a note that some state has changed, | ||
1925 | + * so that it can be sent to the GPU later. */ | ||
1926 | + gCtx->new_state |= new_state; | ||
1927 | +} | ||
1928 | + | ||
1929 | + | ||
1930 | +static void glamoFlush(struct gl_context *ctx) | ||
1931 | +{ | ||
1932 | + printf("glamoFlush\n"); | ||
1933 | +} | ||
1934 | + | ||
1935 | + | ||
1936 | +void glamoInitStateFuncs(struct gl_context *ctx) | ||
1937 | +{ | ||
1938 | + ctx->Driver.UpdateState = glamoUpdateState; | ||
1939 | + ctx->Driver.Clear = glamoClear; | ||
1940 | + ctx->Driver.ClearColor = glamoClearColor; | ||
1941 | + ctx->Driver.ClearDepth = NULL; | ||
1942 | + ctx->Driver.ClearStencil = NULL; | ||
1943 | + ctx->Driver.AlphaFunc = NULL; | ||
1944 | + ctx->Driver.BlendFuncSeparate = NULL; | ||
1945 | + ctx->Driver.ColorMask = NULL; | ||
1946 | + ctx->Driver.CullFace = NULL; | ||
1947 | + ctx->Driver.DepthMask = NULL; | ||
1948 | + ctx->Driver.DepthFunc = NULL; | ||
1949 | + ctx->Driver.DepthRange = NULL; | ||
1950 | + ctx->Driver.DrawBuffer = NULL; | ||
1951 | + ctx->Driver.Enable = NULL; | ||
1952 | + ctx->Driver.FrontFace = NULL; | ||
1953 | + ctx->Driver.Fogfv = NULL; | ||
1954 | + ctx->Driver.Hint = NULL; | ||
1955 | + ctx->Driver.Lightfv = NULL; | ||
1956 | + ctx->Driver.LogicOpcode = NULL; | ||
1957 | + ctx->Driver.PolygonMode = NULL; | ||
1958 | + ctx->Driver.PolygonStipple = NULL; | ||
1959 | + ctx->Driver.ReadBuffer = NULL; | ||
1960 | + ctx->Driver.RenderMode = NULL; | ||
1961 | + ctx->Driver.Scissor = NULL; | ||
1962 | + ctx->Driver.ShadeModel = glamoShadeModel; | ||
1963 | + ctx->Driver.LightModelfv = NULL; | ||
1964 | + ctx->Driver.Viewport = glamoViewport; | ||
1965 | + ctx->Driver.ResizeBuffers = glamoResizeBuffers; | ||
1966 | + ctx->Driver.Flush = glamoFlush; | ||
1967 | +} | ||
1968 | diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h | ||
1969 | new file mode 100644 | ||
1970 | index 0000000..c3872c0 | ||
1971 | --- /dev/null | ||
1972 | +++ b/src/mesa/drivers/dri/glamo/glamo_state.h | ||
1973 | @@ -0,0 +1,34 @@ | ||
1974 | +/* | ||
1975 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
1976 | + * | ||
1977 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
1978 | + * Roughly based on sis_state.h (c) 2003 Eric Anholt | ||
1979 | + * | ||
1980 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
1981 | + * copy of this software and associated documentation files (the "Software"), | ||
1982 | + * to deal in the Software without restriction, including without limitation | ||
1983 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
1984 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
1985 | + * Software is furnished to do so, subject to the following conditions: | ||
1986 | + * | ||
1987 | + * The above copyright notice and this permission notice shall be included | ||
1988 | + * in all copies or substantial portions of the Software. | ||
1989 | + * | ||
1990 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
1991 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1992 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
1993 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
1994 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
1995 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
1996 | + */ | ||
1997 | + | ||
1998 | +#ifndef __GLAMO_STATE_H | ||
1999 | +#define __GLAMO_STATE_H | ||
2000 | + | ||
2001 | +#include "main/context.h" | ||
2002 | + | ||
2003 | +extern void glamoInitStateFuncs(struct gl_context *ctx); | ||
2004 | + | ||
2005 | +#endif /* __GLAMO_STATE_H */ | ||
2006 | + | ||
2007 | +/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ | ||
2008 | diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c | ||
2009 | new file mode 100644 | ||
2010 | index 0000000..c45fe53 | ||
2011 | --- /dev/null | ||
2012 | +++ b/src/mesa/drivers/dri/glamo/glamo_tris.c | ||
2013 | @@ -0,0 +1,310 @@ | ||
2014 | +/* | ||
2015 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
2016 | + * | ||
2017 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
2018 | + * | ||
2019 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
2020 | + * copy of this software and associated documentation files (the "Software"), | ||
2021 | + * to deal in the Software without restriction, including without limitation | ||
2022 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
2023 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
2024 | + * Software is furnished to do so, subject to the following conditions: | ||
2025 | + * | ||
2026 | + * The above copyright notice and this permission notice shall be included | ||
2027 | + * in all copies or substantial portions of the Software. | ||
2028 | + * | ||
2029 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
2030 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
2031 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
2032 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
2033 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
2034 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
2035 | + * | ||
2036 | + * | ||
2037 | + * Based on intel_tris.c, to which the following notice applies: | ||
2038 | + * | ||
2039 | + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. | ||
2040 | + * All Rights Reserved. | ||
2041 | + * | ||
2042 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
2043 | + * copy of this software and associated documentation files (the | ||
2044 | + * "Software"), to deal in the Software without restriction, including | ||
2045 | + * without limitation the rights to use, copy, modify, merge, publish, | ||
2046 | + * distribute, sub license, and/or sell copies of the Software, and to | ||
2047 | + * permit persons to whom the Software is furnished to do so, subject to | ||
2048 | + * the following conditions: | ||
2049 | + * | ||
2050 | + * The above copyright notice and this permission notice (including the | ||
2051 | + * next paragraph) shall be included in all copies or substantial portions | ||
2052 | + * of the Software. | ||
2053 | + * | ||
2054 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
2055 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
2056 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | ||
2057 | + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR | ||
2058 | + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
2059 | + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
2060 | + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
2061 | + * | ||
2062 | + */ | ||
2063 | + | ||
2064 | + | ||
2065 | +#include <glamo_bo.h> | ||
2066 | +#include <glamo_bo_gem.h> | ||
2067 | +#include <glamo_drm.h> | ||
2068 | + | ||
2069 | +#include "main/mtypes.h" | ||
2070 | +#include "swrast/swrast.h" | ||
2071 | +#include "tnl/t_context.h" | ||
2072 | +#include "tnl/t_vertex.h" | ||
2073 | +#include "tnl/t_pipeline.h" | ||
2074 | + | ||
2075 | +#include "glamo_tris.h" | ||
2076 | +#include "glamo_context.h" | ||
2077 | + | ||
2078 | + | ||
2079 | +static void glamoRunPipeline(struct gl_context *ctx) | ||
2080 | +{ | ||
2081 | + printf("glamoRunPipeline\n"); | ||
2082 | + | ||
2083 | + /* TODO: Emit state */ | ||
2084 | + | ||
2085 | + _tnl_run_pipeline(ctx); | ||
2086 | +} | ||
2087 | + | ||
2088 | + | ||
2089 | +static void glamoRenderStart(struct gl_context *ctx) | ||
2090 | +{ | ||
2091 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
2092 | + | ||
2093 | + /* Decide which attributes will be used */ | ||
2094 | + gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS; | ||
2095 | + gCtx->vertex_attrs[0].format = EMIT_4F; | ||
2096 | + | ||
2097 | + gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1, | ||
2098 | + NULL, 0); | ||
2099 | +} | ||
2100 | + | ||
2101 | + | ||
2102 | +static void glamoRenderFinish(struct gl_context *ctx) | ||
2103 | +{ | ||
2104 | + printf("glamoRenderFinish\n"); | ||
2105 | +} | ||
2106 | + | ||
2107 | + | ||
2108 | +static void glamoPrimitiveNotify(struct gl_context *ctx, GLenum prim) | ||
2109 | +{ | ||
2110 | + printf("glamoPrimitiveNotify\n"); | ||
2111 | +} | ||
2112 | + | ||
2113 | + | ||
2114 | +uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count) | ||
2115 | +{ | ||
2116 | + uint32_t *addr; | ||
2117 | + | ||
2118 | + printf("glamoGetPrimSpace\n"); | ||
2119 | + | ||
2120 | + /* Check for space in the existing VB */ | ||
2121 | + if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset + | ||
2122 | + count * gCtx->vertex_size) > GLAMO_VB_SIZE) { | ||
2123 | + | ||
2124 | + /* Not enough space, or no VB existing. Start a new one... */ | ||
2125 | + if (gCtx->prim.vb == NULL) { | ||
2126 | + printf("Allocated %i bytes\n", GLAMO_VB_SIZE); | ||
2127 | + gCtx->prim.vb = malloc(GLAMO_VB_SIZE); | ||
2128 | + } | ||
2129 | + gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0, | ||
2130 | + GLAMO_VB_SIZE, 4, | ||
2131 | + GLAMO_GEM_DOMAIN_VRAM, 0); | ||
2132 | + gCtx->prim.start_offset = 0; | ||
2133 | + gCtx->prim.current_offset = 0; | ||
2134 | + } | ||
2135 | + | ||
2136 | + addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset); | ||
2137 | + gCtx->prim.current_offset += gCtx->vertex_size * count; | ||
2138 | + gCtx->prim.count += count; | ||
2139 | + | ||
2140 | + return addr; | ||
2141 | +} | ||
2142 | + | ||
2143 | + | ||
2144 | +#define COPY_DWORDS( j, vb, vertsize, v ) \ | ||
2145 | +do { \ | ||
2146 | + for ( j = 0 ; j < vertsize ; j++ ) { \ | ||
2147 | + vb[j] = ((GLuint *)v)[j]; \ | ||
2148 | + } \ | ||
2149 | + vb += vertsize; \ | ||
2150 | +} while (0) | ||
2151 | + | ||
2152 | + | ||
2153 | +static void glamo_draw_triangle(struct glamo_context *gCtx, | ||
2154 | + glamoVertexPtr v0, glamoVertexPtr v1, | ||
2155 | + glamoVertexPtr v2) | ||
2156 | +{ | ||
2157 | + GLuint *vb = glamoGetPrimSpace(gCtx, 3); | ||
2158 | + int j; | ||
2159 | + | ||
2160 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v0); | ||
2161 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v1); | ||
2162 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v2); | ||
2163 | +} | ||
2164 | + | ||
2165 | + | ||
2166 | +static void glamo_draw_line(struct glamo_context *gCtx, | ||
2167 | + glamoVertexPtr v0, glamoVertexPtr v1) | ||
2168 | +{ | ||
2169 | + GLuint *vb = glamoGetPrimSpace(gCtx, 2); | ||
2170 | + int j; | ||
2171 | + | ||
2172 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v0); | ||
2173 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v1); | ||
2174 | +} | ||
2175 | + | ||
2176 | + | ||
2177 | +static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0) | ||
2178 | +{ | ||
2179 | + GLuint *vb = glamoGetPrimSpace(gCtx, 2); | ||
2180 | + int j; | ||
2181 | + | ||
2182 | + COPY_DWORDS(j, vb, gCtx->vertex_size, v0); | ||
2183 | +} | ||
2184 | + | ||
2185 | + | ||
2186 | +#define TRI( a, b, c ) \ | ||
2187 | +do { \ | ||
2188 | + glamo_draw_triangle(gCtx, a, b, c ); \ | ||
2189 | +} while (0) | ||
2190 | + | ||
2191 | + | ||
2192 | +#define QUAD( a, b, c, d ) \ | ||
2193 | +printf("Drawing a quad\n"); \ | ||
2194 | +do { \ | ||
2195 | + glamo_draw_triangle(gCtx, a, b, d); \ | ||
2196 | + glamo_draw_triangle(gCtx, b, c, d); \ | ||
2197 | +} while (0) | ||
2198 | + | ||
2199 | + | ||
2200 | +#define LINE(v0, v1) \ | ||
2201 | +do { \ | ||
2202 | + glamo_draw_line(gCtx, v0, v1); \ | ||
2203 | +} while (0) | ||
2204 | + | ||
2205 | + | ||
2206 | +#define POINT(v0) \ | ||
2207 | +do { \ | ||
2208 | + glamo_draw_point(gCtx, v0); \ | ||
2209 | +} while (0) | ||
2210 | + | ||
2211 | + | ||
2212 | +#define IND (0) | ||
2213 | +#define TAG(x) x | ||
2214 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2215 | + | ||
2216 | +#define IND (0) | ||
2217 | +#define TAG(x) x##_offset | ||
2218 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2219 | + | ||
2220 | +#define IND (0) | ||
2221 | +#define TAG(x) x##_twoside | ||
2222 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2223 | + | ||
2224 | +#define IND (0) | ||
2225 | +#define TAG(x) x##_twoside_offset | ||
2226 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2227 | + | ||
2228 | +#define IND (0) | ||
2229 | +#define TAG(x) x##_unfilled | ||
2230 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2231 | + | ||
2232 | +#define IND (0) | ||
2233 | +#define TAG(x) x##_offset_unfilled | ||
2234 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2235 | + | ||
2236 | +#define IND (0) | ||
2237 | +#define TAG(x) x##_twoside_unfilled | ||
2238 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2239 | + | ||
2240 | +#define IND (0) | ||
2241 | +#define TAG(x) x##_twoside_offset_unfilled | ||
2242 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2243 | + | ||
2244 | +#define IND (0) | ||
2245 | +#define TAG(x) x##_fallback | ||
2246 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2247 | + | ||
2248 | +#define IND (0) | ||
2249 | +#define TAG(x) x##_offset_fallback | ||
2250 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2251 | + | ||
2252 | +#define IND (0) | ||
2253 | +#define TAG(x) x##_twoside_fallback | ||
2254 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2255 | + | ||
2256 | +#define IND (0) | ||
2257 | +#define TAG(x) x##_twoside_offset_fallback | ||
2258 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2259 | + | ||
2260 | +#define IND (0) | ||
2261 | +#define TAG(x) x##_unfilled_fallback | ||
2262 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2263 | + | ||
2264 | +#define IND (0) | ||
2265 | +#define TAG(x) x##_offset_unfilled_fallback | ||
2266 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2267 | + | ||
2268 | +#define IND (0) | ||
2269 | +#define TAG(x) x##_twoside_unfilled_fallback | ||
2270 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2271 | + | ||
2272 | +#define IND (0) | ||
2273 | +#define TAG(x) x##_twoside_offset_unfilled_fallback | ||
2274 | +#include "tnl_dd/t_dd_tritmp.h" | ||
2275 | + | ||
2276 | + | ||
2277 | +static void init_rast_tab() | ||
2278 | +{ | ||
2279 | + init(); | ||
2280 | + init_offset(); | ||
2281 | + init_twoside(); | ||
2282 | + init_twoside_offset(); | ||
2283 | + init_unfilled(); | ||
2284 | + init_offset_unfilled(); | ||
2285 | + init_twoside_unfilled(); | ||
2286 | + init_twoside_offset_unfilled(); | ||
2287 | + init_fallback(); | ||
2288 | + init_offset_fallback(); | ||
2289 | + init_twoside_fallback(); | ||
2290 | + init_twoside_offset_fallback(); | ||
2291 | + init_unfilled_fallback(); | ||
2292 | + init_offset_unfilled_fallback(); | ||
2293 | + init_twoside_unfilled_fallback(); | ||
2294 | + init_twoside_offset_unfilled_fallback(); | ||
2295 | +} | ||
2296 | + | ||
2297 | + | ||
2298 | +void glamoInitTriFuncs(struct gl_context *ctx) | ||
2299 | +{ | ||
2300 | + TNLcontext *tnl = TNL_CONTEXT(ctx); | ||
2301 | + struct glamo_context *gCtx = GLAMO_CONTEXT(ctx); | ||
2302 | + static int firsttime = 1; | ||
2303 | + | ||
2304 | + if (firsttime) { | ||
2305 | + init_rast_tab(); | ||
2306 | + firsttime = 0; | ||
2307 | + } | ||
2308 | + | ||
2309 | + gCtx->prim.start_offset = 0; | ||
2310 | + gCtx->prim.current_offset = 0; | ||
2311 | + gCtx->prim.vb_bo = NULL; | ||
2312 | + gCtx->prim.vb = NULL; | ||
2313 | + gCtx->prim.count = 0; | ||
2314 | + | ||
2315 | + tnl->Driver.RunPipeline = glamoRunPipeline; | ||
2316 | + tnl->Driver.Render.Start = glamoRenderStart; | ||
2317 | + tnl->Driver.Render.Finish = glamoRenderFinish; | ||
2318 | + tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify; | ||
2319 | + tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; | ||
2320 | + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; | ||
2321 | + tnl->Driver.Render.CopyPV = _tnl_copy_pv; | ||
2322 | + tnl->Driver.Render.Interp = _tnl_interp; | ||
2323 | +} | ||
2324 | diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h | ||
2325 | new file mode 100644 | ||
2326 | index 0000000..ea396c1 | ||
2327 | --- /dev/null | ||
2328 | +++ b/src/mesa/drivers/dri/glamo/glamo_tris.h | ||
2329 | @@ -0,0 +1,38 @@ | ||
2330 | +/* | ||
2331 | + * Direct Rendering Support for SMedia Glamo 336x/337x | ||
2332 | + * | ||
2333 | + * (c) 2009 Thomas White <taw@bitwiz.org.uk> | ||
2334 | + * | ||
2335 | + * Permission is hereby granted, free of charge, to any person obtaining a | ||
2336 | + * copy of this software and associated documentation files (the "Software"), | ||
2337 | + * to deal in the Software without restriction, including without limitation | ||
2338 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
2339 | + * and/or sell copies of the Software, and to permit persons to whom the | ||
2340 | + * Software is furnished to do so, subject to the following conditions: | ||
2341 | + * | ||
2342 | + * The above copyright notice and this permission notice shall be included | ||
2343 | + * in all copies or substantial portions of the Software. | ||
2344 | + * | ||
2345 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
2346 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
2347 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
2348 | + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
2349 | + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
2350 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
2351 | + */ | ||
2352 | + | ||
2353 | +#ifndef __GLAMO_TRIS_H | ||
2354 | +#define __GLAMO_TRIS_H | ||
2355 | + | ||
2356 | +#include "main/mtypes.h" | ||
2357 | + | ||
2358 | +#include "glamo_context.h" | ||
2359 | + | ||
2360 | +/* Amount of space reserved for vertex submission */ | ||
2361 | +#define GLAMO_VB_SIZE (32*1024) | ||
2362 | + | ||
2363 | +extern void glamoInitTriFuncs(struct gl_context *ctx); | ||
2364 | +extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, | ||
2365 | + unsigned int count); | ||
2366 | + | ||
2367 | +#endif /* __GLAMO_TRIS_H */ | ||
2368 | diff --git a/src/mesa/tnl_dd/t_dd_dmatmp.h b/src/mesa/tnl_dd/t_dd_dmatmp.h | ||
2369 | index 997fc0b..e3c9119 100644 | ||
2370 | --- a/src/mesa/tnl_dd/t_dd_dmatmp.h | ||
2371 | +++ b/src/mesa/tnl_dd/t_dd_dmatmp.h | ||
2372 | @@ -127,6 +127,8 @@ static void TAG(render_points_verts)( struct gl_context *ctx, | ||
2373 | currentsz = dmasz; | ||
2374 | } | ||
2375 | |||
2376 | + FLUSH(); | ||
2377 | + | ||
2378 | } else { | ||
2379 | fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); | ||
2380 | return; | ||
2381 | @@ -162,6 +164,8 @@ static void TAG(render_lines_verts)( struct gl_context *ctx, | ||
2382 | currentsz = dmasz; | ||
2383 | } | ||
2384 | |||
2385 | + FLUSH(); | ||
2386 | + | ||
2387 | } else { | ||
2388 | fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); | ||
2389 | return; | ||
2390 | @@ -191,7 +195,7 @@ static void TAG(render_line_strip_verts)( struct gl_context *ctx, | ||
2391 | TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) ); | ||
2392 | currentsz = dmasz; | ||
2393 | } | ||
2394 | - | ||
2395 | + | ||
2396 | FLUSH(); | ||
2397 | |||
2398 | } else { | ||
2399 | @@ -294,6 +298,8 @@ static void TAG(render_triangles_verts)( struct gl_context *ctx, | ||
2400 | TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) ); | ||
2401 | currentsz = dmasz; | ||
2402 | } | ||
2403 | + | ||
2404 | + FLUSH(); | ||
2405 | } | ||
2406 | |||
2407 | |||
2408 | @@ -567,6 +573,8 @@ static void TAG(render_quads_verts)( struct gl_context *ctx, | ||
2409 | TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) ); | ||
2410 | currentsz = dmasz; | ||
2411 | } | ||
2412 | + | ||
2413 | + FLUSH(); | ||
2414 | } | ||
2415 | else if (HAVE_ELTS) { | ||
2416 | /* Hardware doesn't have a quad primitive type -- try to | ||
2417 | @@ -640,6 +648,8 @@ static void TAG(render_quads_verts)( struct gl_context *ctx, | ||
2418 | tmp = EMIT_VERTS(ctx, j + 1, 3, tmp); | ||
2419 | (void) tmp; | ||
2420 | } | ||
2421 | + | ||
2422 | + FLUSH(); | ||
2423 | } | ||
2424 | else { | ||
2425 | /* Vertices won't fit in a single buffer, should never happen. | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-7.10.2/uclibc.patch b/meta-oe/recipes-graphics/mesa/mesa-7.10.2/uclibc.patch new file mode 100644 index 000000000..0508112df --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-7.10.2/uclibc.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | Index: Mesa-7.9.1/src/mesa/main/imports.c | ||
2 | =================================================================== | ||
3 | --- Mesa-7.9.1.orig/src/mesa/main/imports.c 2010-12-15 13:50:00.000000000 -0800 | ||
4 | +++ Mesa-7.9.1/src/mesa/main/imports.c 2011-01-10 12:23:48.848656001 -0800 | ||
5 | @@ -757,7 +757,7 @@ | ||
6 | float | ||
7 | _mesa_strtof( const char *s, char **end ) | ||
8 | { | ||
9 | -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) | ||
10 | +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && !defined(__UCLIBC__) | ||
11 | static locale_t loc = NULL; | ||
12 | if (!loc) { | ||
13 | loc = newlocale(LC_CTYPE_MASK, "C", NULL); | ||
14 | Index: Mesa-7.9.1/src/glsl/strtod.c | ||
15 | =================================================================== | ||
16 | --- Mesa-7.9.1.orig/src/glsl/strtod.c 2011-01-10 20:08:01.568656001 -0800 | ||
17 | +++ Mesa-7.9.1/src/glsl/strtod.c 2011-01-10 20:08:39.898656001 -0800 | ||
18 | @@ -44,7 +44,7 @@ | ||
19 | double | ||
20 | glsl_strtod(const char *s, char **end) | ||
21 | { | ||
22 | -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) | ||
23 | +#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && !defined(__UCLIBC__) | ||
24 | static locale_t loc = NULL; | ||
25 | if (!loc) { | ||
26 | loc = newlocale(LC_CTYPE_MASK, "C", NULL); | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-common.inc b/meta-oe/recipes-graphics/mesa/mesa-common.inc new file mode 100644 index 000000000..4073d6ffe --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-common.inc | |||
@@ -0,0 +1,53 @@ | |||
1 | SECTION = "x11" | ||
2 | |||
3 | DESCRIPTION = "An open source implementation of the OpenGL spec" | ||
4 | HOMEPAGE = "http://mesa3d.org" | ||
5 | LICENSE = "MIT" | ||
6 | LIC_FILES_CHKSUM = "file://docs/license.html;md5=7a3373c039b6b925c427755a4f779c1d" | ||
7 | |||
8 | INC_PR = "r11" | ||
9 | PE = "2" | ||
10 | |||
11 | PROTO_DEPS = "xf86driproto glproto" | ||
12 | LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes" | ||
13 | |||
14 | DEPENDS = "${PROTO_DEPS} ${LIB_DEPS}" | ||
15 | |||
16 | SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \ | ||
17 | " | ||
18 | S = "${WORKDIR}/Mesa-${PV}" | ||
19 | |||
20 | PROVIDES = "virtual/libgl" | ||
21 | |||
22 | inherit autotools pkgconfig | ||
23 | |||
24 | EXTRA_OECONF = "--enable-glu \ | ||
25 | --disable-glw \ | ||
26 | --disable-glut \ | ||
27 | " | ||
28 | |||
29 | inherit glx-use-tls | ||
30 | |||
31 | # Package contents vary according to ${MACHINE_DRI_MODULES}. | ||
32 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
33 | |||
34 | PACKAGES =+ "libegl libegl-dev libegl-dbg libglu libglu-dev libosmesa libosmesa-dev libgl libgl-dev" | ||
35 | FILES_${PN} += "${libdir}/dri/*.so" | ||
36 | FILES_libegl = "${libdir}/libEGL.so.* ${libdir}/egl/*.so" | ||
37 | FILES_libgl = "${libdir}/libGL.so.*" | ||
38 | FILES_libglu = "${libdir}/libGLU.so.*" | ||
39 | FILES_libosmesa = "${libdir}/libOSMesa.so.*" | ||
40 | |||
41 | FILES_libegl-dev = "${libdir}/libEGL.* ${includedir}/EGL" | ||
42 | FILES_libgl-dev = "${libdir}/libGL.* ${includedir}/GL" | ||
43 | FILES_libglu-dev = "${libdir}/libGLU.* ${includedir}/GL/glu*.h" | ||
44 | FILES_libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/osmesa.h" | ||
45 | |||
46 | FILES_${PN}-dbg += "${libdir}/dri/.debug/*" | ||
47 | FILES_libegl-dbg += "${libdir}/egl/.debug/*" | ||
48 | |||
49 | NATIVE_INSTALL_WORKS = "1" | ||
50 | do_install_append () { | ||
51 | install -d ${D}/${includedir}/GL | ||
52 | cp -pPr ${S}/include/GL/internal* ${D}/${includedir}/GL | ||
53 | } | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-dri.inc b/meta-oe/recipes-graphics/mesa/mesa-dri.inc new file mode 100644 index 000000000..4f42b7930 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-dri.inc | |||
@@ -0,0 +1,10 @@ | |||
1 | DEPENDS += "dri2proto expat libdrm makedepend-native" | ||
2 | |||
3 | #not supported in oe-core base.bbclass | ||
4 | #FILESPATHPKG =. "mesa-${PV}:mesa:" | ||
5 | FILESPATH =. "${FILE_DIRNAME}/mesa:${FILE_DIRNAME}/mesa-${PV}:" | ||
6 | |||
7 | # most of our targets do not have DRI so will use mesa-xlib | ||
8 | DEFAULT_PREFERENCE = "-1" | ||
9 | |||
10 | EXTRA_OECONF += " --with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}" | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-dri_7.10.2.bb b/meta-oe/recipes-graphics/mesa/mesa-dri_7.10.2.bb new file mode 100644 index 000000000..26b56e426 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-dri_7.10.2.bb | |||
@@ -0,0 +1,4 @@ | |||
1 | require mesa-common.inc | ||
2 | require mesa-${PV}.inc | ||
3 | require mesa-dri.inc | ||
4 | PR = "${INC_PR}.0" | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-xlib.inc b/meta-oe/recipes-graphics/mesa/mesa-xlib.inc new file mode 100644 index 000000000..cabe6e5ec --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-xlib.inc | |||
@@ -0,0 +1,2 @@ | |||
1 | FILESPATHPKG =. "mesa-${PV}:mesa:" | ||
2 | EXTRA_OECONF += " --with-driver=xlib" | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa-xlib_7.10.2.bb b/meta-oe/recipes-graphics/mesa/mesa-xlib_7.10.2.bb new file mode 100644 index 000000000..93bb8cd19 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa-xlib_7.10.2.bb | |||
@@ -0,0 +1,4 @@ | |||
1 | require mesa-common.inc | ||
2 | require mesa-${PV}.inc | ||
3 | require mesa-xlib.inc | ||
4 | PR = "${INC_PR}.0" | ||
diff --git a/meta-oe/recipes-graphics/mesa/mesa_7.10.2.bb b/meta-oe/recipes-graphics/mesa/mesa_7.10.2.bb new file mode 100644 index 000000000..4cb8db7f7 --- /dev/null +++ b/meta-oe/recipes-graphics/mesa/mesa_7.10.2.bb | |||
@@ -0,0 +1,6 @@ | |||
1 | # This is a dummy package so OE can use the poky mesa files | ||
2 | require mesa-dri_${PV}.bb | ||
3 | |||
4 | PR = "${INC_PR}.0" | ||
5 | |||
6 | EXTRA_OECONF += "--disable-egl" | ||