1 | /* $Id$ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox OpenGL DRI driver functions
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | * --------------------------------------------------------------------
|
---|
22 | *
|
---|
23 | * This file is based in part on the tdfx driver from X.Org/Mesa, with the
|
---|
24 | * following copyright notice:
|
---|
25 | *
|
---|
26 | * Copyright 2000 VA Linux Systems Inc., Fremont, California.
|
---|
27 | *
|
---|
28 | * All Rights Reserved.
|
---|
29 | *
|
---|
30 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
31 | * copy of this software and associated documentation files (the "Software"),
|
---|
32 | * to deal in the Software without restriction, including without limitation
|
---|
33 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
34 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
35 | * Software is furnished to do so, subject to the following conditions:
|
---|
36 | *
|
---|
37 | * The above copyright notice and this permission notice (including the next
|
---|
38 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
39 | * Software.
|
---|
40 | *
|
---|
41 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
42 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
43 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
44 | * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
45 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
---|
46 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
---|
47 | * SOFTWARE.
|
---|
48 | *
|
---|
49 | * Original rewrite:
|
---|
50 | * Gareth Hughes <[email protected]>, 29 Sep - 1 Oct 2000
|
---|
51 | *
|
---|
52 | * Authors:
|
---|
53 | * Gareth Hughes <[email protected]>
|
---|
54 | */
|
---|
55 |
|
---|
56 | #include "cr_error.h"
|
---|
57 | #include "cr_gl.h"
|
---|
58 | #include "stub.h"
|
---|
59 | #include "dri_drv.h"
|
---|
60 | #include "DD_gl.h"
|
---|
61 |
|
---|
62 | /** @todo some of those are or'ed with GL_VERSIONS and ain't needed here*/
|
---|
63 | #define need_GL_ARB_occlusion_query
|
---|
64 | #define need_GL_ARB_point_parameters
|
---|
65 | #define need_GL_NV_point_sprite
|
---|
66 | #define need_GL_ARB_texture_compression
|
---|
67 | #define need_GL_ARB_transpose_matrix
|
---|
68 | #define need_GL_ARB_vertex_buffer_object
|
---|
69 | #define need_GL_ARB_vertex_program
|
---|
70 | #define need_GL_ARB_window_pos
|
---|
71 | #define need_GL_EXT_blend_color
|
---|
72 | #define need_GL_EXT_blend_minmax
|
---|
73 | #define need_GL_EXT_blend_func_separate
|
---|
74 | #define need_GL_EXT_fog_coord
|
---|
75 | #define need_GL_EXT_multi_draw_arrays
|
---|
76 | #define need_GL_EXT_secondary_color
|
---|
77 | #define need_GL_EXT_texture_object
|
---|
78 | #define need_GL_EXT_texture3D
|
---|
79 | #define need_GL_VERSION_1_3
|
---|
80 | #define need_GL_VERSION_1_4
|
---|
81 | #define need_GL_VERSION_1_5
|
---|
82 |
|
---|
83 | #include "drivers/dri/common/extension_helper.h"
|
---|
84 |
|
---|
85 | /** @todo add more which are supported by chromium like GL_NV_vertex_program etc.*/
|
---|
86 | static const struct dri_extension vbox_extensions[] = {
|
---|
87 | { "GL_ARB_depth_texture", NULL },
|
---|
88 | { "GL_ARB_fragment_program", NULL },
|
---|
89 | { "GL_ARB_multitexture", NULL },
|
---|
90 | { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions },
|
---|
91 | { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
|
---|
92 | { "GL_NV_point_sprite", GL_NV_point_sprite_functions },
|
---|
93 | { "GL_ARB_shadow", NULL },
|
---|
94 | { "GL_ARB_shadow_ambient", NULL },
|
---|
95 | { "GL_ARB_texture_border_clamp", NULL },
|
---|
96 | { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
|
---|
97 | { "GL_ARB_texture_cube_map", NULL },
|
---|
98 | { "GL_ARB_texture_env_add", NULL },
|
---|
99 | { "GL_ARB_texture_env_combine", NULL },
|
---|
100 | { "GL_EXT_texture_env_combine", NULL },
|
---|
101 | { "GL_ARB_texture_env_crossbar", NULL },
|
---|
102 | { "GL_ARB_texture_env_dot3", NULL },
|
---|
103 | { "GL_EXT_texture_env_dot3", NULL },
|
---|
104 | { "GL_ARB_texture_mirrored_repeat", NULL },
|
---|
105 | { "GL_ARB_texture_non_power_of_two", NULL },
|
---|
106 | { "GL_ARB_transpose_matrix", GL_ARB_transpose_matrix_functions },
|
---|
107 | { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
|
---|
108 | { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
|
---|
109 | { "GL_ARB_window_pos", GL_ARB_window_pos_functions },
|
---|
110 | { "GL_EXT_blend_color", GL_EXT_blend_color_functions },
|
---|
111 | { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
|
---|
112 | { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
|
---|
113 | { "GL_EXT_blend_subtract", NULL },
|
---|
114 | { "GL_EXT_texture_env_add", NULL }, /** @todo that's an alias to GL_ARB version, remove it?*/
|
---|
115 | { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
|
---|
116 | { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
|
---|
117 | { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
|
---|
118 | { "GL_EXT_shadow_funcs", NULL },
|
---|
119 | { "GL_EXT_stencil_wrap", NULL },
|
---|
120 | { "GL_EXT_texture_cube_map", NULL }, /** @todo another alias*/
|
---|
121 | { "GL_EXT_texture_edge_clamp", NULL },
|
---|
122 | { "GL_EXT_texture_filter_anisotropic", NULL },
|
---|
123 | { "GL_EXT_texture_lod_bias", NULL },
|
---|
124 | { "GL_EXT_texture_object", GL_EXT_texture_object_functions },
|
---|
125 | { "GL_EXT_texture3D", GL_EXT_texture3D_functions },
|
---|
126 | { "GL_NV_texgen_reflection", NULL },
|
---|
127 | { "GL_ARB_texture_rectangle", NULL },
|
---|
128 | { "GL_SGIS_generate_mipmap", NULL },
|
---|
129 | { "GL_SGIS_texture_edge_clamp", NULL } /** @todo another alias*/
|
---|
130 | };
|
---|
131 |
|
---|
132 | static void
|
---|
133 | vboxdriInitExtensions(GLcontext * ctx)
|
---|
134 | {
|
---|
135 | /** @todo have to check extensions supported by host here first */
|
---|
136 | driInitExtensions(ctx, vbox_extensions, GL_FALSE);
|
---|
137 | }
|
---|
138 |
|
---|
139 | static GLvertexformat vboxdriTnlVtxFmt;
|
---|
140 |
|
---|
141 |
|
---|
142 | /* This callback tells us that Mesa's internal state has changed. We probably
|
---|
143 | * don't need to handle this ourselves, so just pass it on to other parts of
|
---|
144 | * Mesa we may be using, as the swrast driver and others do */
|
---|
145 | static void
|
---|
146 | vboxDDUpdateState(GLcontext * ctx, GLuint new_state)
|
---|
147 | {
|
---|
148 | _swrast_InvalidateState(ctx, new_state);
|
---|
149 | _swsetup_InvalidateState(ctx, new_state);
|
---|
150 | _vbo_InvalidateState(ctx, new_state);
|
---|
151 | _tnl_InvalidateState(ctx, new_state);
|
---|
152 | }
|
---|
153 |
|
---|
154 | #if 0 /* See comment in vboxdriInitFuncs */
|
---|
155 | static void
|
---|
156 | vboxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
|
---|
157 | {
|
---|
158 | /*do something, note it's obsolete*/
|
---|
159 | }
|
---|
160 |
|
---|
161 | static void
|
---|
162 | vboxDDResizeBuffer( GLcontext *ctx, GLframebuffer *fb,
|
---|
163 | GLuint width, GLuint height)
|
---|
164 | {
|
---|
165 | /*do something, note it's obsolete*/
|
---|
166 | }
|
---|
167 |
|
---|
168 | static void
|
---|
169 | vboxDDError(GLcontext *ctx)
|
---|
170 | {
|
---|
171 | //__GLcontextRec::ErrorValue contains the error value.
|
---|
172 | }
|
---|
173 | #endif
|
---|
174 |
|
---|
175 | static void
|
---|
176 | vboxDDDrawPixels(GLcontext *ctx,
|
---|
177 | GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
178 | GLenum format, GLenum type,
|
---|
179 | const struct gl_pixelstore_attrib *unpack,
|
---|
180 | const GLvoid *pixels)
|
---|
181 | {
|
---|
182 | }
|
---|
183 |
|
---|
184 | static void
|
---|
185 | vboxDDReadPixels(GLcontext *ctx,
|
---|
186 | GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
187 | GLenum format, GLenum type,
|
---|
188 | const struct gl_pixelstore_attrib *unpack,
|
---|
189 | GLvoid *dest)
|
---|
190 | {
|
---|
191 | }
|
---|
192 |
|
---|
193 | static void
|
---|
194 | vboxDDCopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
---|
195 | GLsizei width, GLsizei height,
|
---|
196 | GLint dstx, GLint dsty, GLenum type)
|
---|
197 | {
|
---|
198 | }
|
---|
199 |
|
---|
200 | static void
|
---|
201 | vboxDDBitmap(GLcontext *ctx,
|
---|
202 | GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
203 | const struct gl_pixelstore_attrib *unpack,
|
---|
204 | const GLubyte *bitmap)
|
---|
205 | {
|
---|
206 | }
|
---|
207 |
|
---|
208 | static void
|
---|
209 | vboxDDTexImage1D(GLcontext *ctx, GLenum target, GLint level,
|
---|
210 | GLint internalFormat,
|
---|
211 | GLint width, GLint border,
|
---|
212 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
213 | const struct gl_pixelstore_attrib *packing,
|
---|
214 | struct gl_texture_object *texObj,
|
---|
215 | struct gl_texture_image *texImage)
|
---|
216 | {
|
---|
217 | }
|
---|
218 |
|
---|
219 | static void
|
---|
220 | vboxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
---|
221 | GLint internalFormat,
|
---|
222 | GLint width, GLint height, GLint border,
|
---|
223 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
224 | const struct gl_pixelstore_attrib *packing,
|
---|
225 | struct gl_texture_object *texObj,
|
---|
226 | struct gl_texture_image *texImage)
|
---|
227 | {
|
---|
228 | }
|
---|
229 |
|
---|
230 | static void
|
---|
231 | vboxDDTexImage3D(GLcontext *ctx, GLenum target, GLint level,
|
---|
232 | GLint internalFormat,
|
---|
233 | GLint width, GLint height, GLint depth, GLint border,
|
---|
234 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
235 | const struct gl_pixelstore_attrib *packing,
|
---|
236 | struct gl_texture_object *texObj,
|
---|
237 | struct gl_texture_image *texImage)
|
---|
238 | {
|
---|
239 | }
|
---|
240 |
|
---|
241 | static void
|
---|
242 | vboxDDTexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
|
---|
243 | GLint xoffset, GLsizei width,
|
---|
244 | GLenum format, GLenum type,
|
---|
245 | const GLvoid *pixels,
|
---|
246 | const struct gl_pixelstore_attrib *packing,
|
---|
247 | struct gl_texture_object *texObj,
|
---|
248 | struct gl_texture_image *texImage)
|
---|
249 | {
|
---|
250 | }
|
---|
251 |
|
---|
252 | static void
|
---|
253 | vboxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
---|
254 | GLint xoffset, GLint yoffset,
|
---|
255 | GLsizei width, GLsizei height,
|
---|
256 | GLenum format, GLenum type,
|
---|
257 | const GLvoid *pixels,
|
---|
258 | const struct gl_pixelstore_attrib *packing,
|
---|
259 | struct gl_texture_object *texObj,
|
---|
260 | struct gl_texture_image *texImage)
|
---|
261 | {
|
---|
262 | }
|
---|
263 |
|
---|
264 |
|
---|
265 | static void
|
---|
266 | vboxDDTexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
|
---|
267 | GLint xoffset, GLint yoffset, GLint zoffset,
|
---|
268 | GLsizei width, GLsizei height, GLint depth,
|
---|
269 | GLenum format, GLenum type,
|
---|
270 | const GLvoid *pixels,
|
---|
271 | const struct gl_pixelstore_attrib *packing,
|
---|
272 | struct gl_texture_object *texObj,
|
---|
273 | struct gl_texture_image *texImage)
|
---|
274 | {
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|
278 | static void
|
---|
279 | vboxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level,
|
---|
280 | GLenum format, GLenum type, GLvoid *pixels,
|
---|
281 | struct gl_texture_object *texObj,
|
---|
282 | struct gl_texture_image *texImage)
|
---|
283 | {
|
---|
284 | }
|
---|
285 |
|
---|
286 | static void
|
---|
287 | vboxDDBindTexture(GLcontext *ctx, GLenum target,
|
---|
288 | struct gl_texture_object *tObj)
|
---|
289 | {
|
---|
290 | }
|
---|
291 |
|
---|
292 | static GLboolean
|
---|
293 | vboxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *t)
|
---|
294 | {
|
---|
295 | }
|
---|
296 |
|
---|
297 | static void
|
---|
298 | vboxDDPrioritizeTexture(GLcontext *ctx, struct gl_texture_object *t,
|
---|
299 | GLclampf priority)
|
---|
300 | {
|
---|
301 | }
|
---|
302 |
|
---|
303 | static void
|
---|
304 | vboxDDBlendColor(GLcontext *ctx, const GLfloat color[4])
|
---|
305 | {
|
---|
306 | }
|
---|
307 |
|
---|
308 | static void
|
---|
309 | vboxDDClearColor(GLcontext *ctx, const GLfloat color[4])
|
---|
310 | {
|
---|
311 | }
|
---|
312 |
|
---|
313 | static void
|
---|
314 | vboxDDClearIndex(GLcontext *ctx, GLuint index)
|
---|
315 | {
|
---|
316 | }
|
---|
317 |
|
---|
318 | static void
|
---|
319 | vboxDDClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
|
---|
320 | {
|
---|
321 | }
|
---|
322 |
|
---|
323 | /*@todo Enable or disable server-side gl capabilities, not related to glEnable? */
|
---|
324 | static void
|
---|
325 | vboxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
|
---|
326 | {
|
---|
327 | if (state)
|
---|
328 | cr_glEnable(cap);
|
---|
329 | else
|
---|
330 | cr_glDisable(cap);
|
---|
331 | }
|
---|
332 |
|
---|
333 | static void
|
---|
334 | vboxDDRenderMode(GLcontext *ctx, GLenum mode)
|
---|
335 | {
|
---|
336 | cr_glRenderMode(mode);
|
---|
337 | }
|
---|
338 |
|
---|
339 | static void
|
---|
340 | vboxDDTexParameter(GLcontext *ctx, GLenum target,
|
---|
341 | struct gl_texture_object *texObj,
|
---|
342 | GLenum pname, const GLfloat *params)
|
---|
343 | {
|
---|
344 | }
|
---|
345 |
|
---|
346 | /*Note, checking glGetError before and after those calls is the only way
|
---|
347 | *to return if we succeded to get value or not, but it will add 2 sync calls and
|
---|
348 | *will reset glGetError value returned in case application calls it explicitly
|
---|
349 | */
|
---|
350 | static GLboolean
|
---|
351 | vboxDDGetBooleanv(GLcontext *ctx, GLenum pname, GLboolean *result)
|
---|
352 | {
|
---|
353 | cr_glGetBooleanv(pname, result);
|
---|
354 | return GL_TRUE;
|
---|
355 | }
|
---|
356 |
|
---|
357 | static GLboolean
|
---|
358 | vboxDDGetDoublev(GLcontext *ctx, GLenum pname, GLdouble *result)
|
---|
359 | {
|
---|
360 | cr_glGetDoublev(pname, result);
|
---|
361 | return GL_TRUE;
|
---|
362 | }
|
---|
363 |
|
---|
364 | static GLboolean
|
---|
365 | vboxDDGetFloatv(GLcontext *ctx, GLenum pname, GLfloat *result)
|
---|
366 | {
|
---|
367 | cr_glGetFloatv(pname, result);
|
---|
368 | return GL_TRUE;
|
---|
369 | }
|
---|
370 |
|
---|
371 | static GLboolean
|
---|
372 | vboxDDGetIntegerv(GLcontext *ctx, GLenum pname, GLint *result)
|
---|
373 | {
|
---|
374 | cr_glGetIntegerv(pname, result);
|
---|
375 | return GL_TRUE;
|
---|
376 | }
|
---|
377 |
|
---|
378 | static GLboolean
|
---|
379 | vboxDDGetPointerv(GLcontext *ctx, GLenum pname, GLvoid **result)
|
---|
380 | {
|
---|
381 | cr_glGetPointerv(pname, result);
|
---|
382 | return GL_TRUE;
|
---|
383 | }
|
---|
384 |
|
---|
385 | /** @todo
|
---|
386 | * change stub's createcontext to reuse driver private part of mesa's ctx to store stub ctx info.
|
---|
387 | */
|
---|
388 | #define VBOX_GL_FUNC(func) vboxDD_gl##func
|
---|
389 | static void
|
---|
390 | vboxdriInitFuncs(struct dd_function_table *driver)
|
---|
391 | {
|
---|
392 | driver->GetString = VBOX_GL_FUNC(GetString);
|
---|
393 | driver->UpdateState = vboxDDUpdateState;
|
---|
394 | #if 0
|
---|
395 | /* I assume that we don't need to change these. In that case, prefer the
|
---|
396 | * default implementation over a stub. */
|
---|
397 | driver->GetBufferSize = vboxDDGetBufferSize;
|
---|
398 | driver->ResizeBuffers = vboxDDResizeBuffer;
|
---|
399 | driver->Error = vboxDDError;
|
---|
400 | #endif
|
---|
401 |
|
---|
402 | driver->Finish = VBOX_GL_FUNC(Finish);
|
---|
403 | driver->Flush = VBOX_GL_FUNC(Flush);
|
---|
404 |
|
---|
405 | /* framebuffer/image functions */
|
---|
406 | driver->Clear = VBOX_GL_FUNC(Clear);
|
---|
407 | driver->Accum = VBOX_GL_FUNC(Accum);
|
---|
408 | // driver->RasterPos = VBOX_GL_FUNC(RasterPos); /* No such element in *driver */
|
---|
409 | driver->DrawPixels = vboxDDDrawPixels;
|
---|
410 | driver->ReadPixels = vboxDDReadPixels;
|
---|
411 | driver->CopyPixels = vboxDDCopyPixels;
|
---|
412 | driver->Bitmap = vboxDDBitmap;
|
---|
413 |
|
---|
414 | /* Texture functions */
|
---|
415 | /** @todo deal with texnames and gl_texture_object pointers which are passed here*/
|
---|
416 | driver->ChooseTextureFormat = NULL;
|
---|
417 | driver->TexImage1D = vboxDDTexImage1D;
|
---|
418 | driver->TexImage2D = vboxDDTexImage2D;
|
---|
419 | driver->TexImage3D = vboxDDTexImage3D;
|
---|
420 | driver->TexSubImage1D = vboxDDTexSubImage1D;
|
---|
421 | driver->TexSubImage2D = vboxDDTexSubImage2D;
|
---|
422 | driver->TexSubImage3D = vboxDDTexSubImage3D;
|
---|
423 | driver->GetTexImage = vboxDDGetTexImage;
|
---|
424 | driver->CopyTexImage1D = VBOX_GL_FUNC(CopyTexImage1D);
|
---|
425 | driver->CopyTexImage2D = VBOX_GL_FUNC(CopyTexImage2D);
|
---|
426 | driver->CopyTexSubImage1D = VBOX_GL_FUNC(CopyTexSubImage1D);
|
---|
427 | driver->CopyTexSubImage2D = VBOX_GL_FUNC(CopyTexSubImage2D);
|
---|
428 | driver->CopyTexSubImage3D = VBOX_GL_FUNC(CopyTexSubImage3D);
|
---|
429 | // driver->GenerateMipmap = VBOX_GL_FUNC(GenerateMipmap); /** @todo or NULL */
|
---|
430 | // driver->TestProxyTexImage = vboxDDTestProxyTexImage; /** @todo just pass to glTexImage as we take care or proxy textures there */
|
---|
431 | // driver->CompressedTexImage1D = VBOX_GL_FUNC(CompressedTexImage1D);
|
---|
432 | // driver->CompressedTexImage2D = VBOX_GL_FUNC(CompressedTexImage2D);
|
---|
433 | // driver->CompressedTexImage3D = VBOX_GL_FUNC(CompressedTexImage3D);
|
---|
434 | // driver->CompressedTexSubImage1D = VBOX_GL_FUNC(CompressedTexSubImage1D);
|
---|
435 | // driver->CompressedTexSubImage2D = VBOX_GL_FUNC(CompressedTexSubImage2D);
|
---|
436 | // driver->CompressedTexSubImage3D = VBOX_GL_FUNC(CompressedTexSubImage3D);
|
---|
437 | // driver->GetCompressedTexImage = VBOX_GL_FUNC(GetCompressedTexImage);
|
---|
438 | // driver->CompressedTextureSize = NULL; /** @todo */
|
---|
439 | driver->BindTexture = vboxDDBindTexture;
|
---|
440 | // driver->NewTextureObject = vboxDDNewTextureObject; /** @todo */
|
---|
441 | // driver->DeleteTexture = vboxDDDeleteTexture; /** @todo */
|
---|
442 | // driver->NewTextureImage = vboxDDNewTextureImage; /** @todo */
|
---|
443 | // driver->FreeTexImageData = vboxDDFreeTexImageData; /** @todo */
|
---|
444 | // driver->MapTexture = vboxDDMapTexture; /** @todo */
|
---|
445 | // driver->UnmapTexture = vboxDDUnmapTexture; /** @todo */
|
---|
446 | // driver->TextureMemCpy = vboxDDTextureMemCpy; /** @todo */
|
---|
447 | driver->IsTextureResident = vboxDDIsTextureResident;
|
---|
448 | driver->PrioritizeTexture = vboxDDPrioritizeTexture;
|
---|
449 | driver->ActiveTexture = VBOX_GL_FUNC(ActiveTextureARB);
|
---|
450 | // driver->UpdateTexturePalette = vboxDDUpdateTexturePalette; /** @todo */
|
---|
451 |
|
---|
452 | /* imaging */
|
---|
453 | /*driver->CopyColorTable = _swrast_CopyColorTable;
|
---|
454 | driver->CopyColorSubTable = _swrast_CopyColorSubTable;
|
---|
455 | driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
|
---|
456 | driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;*/
|
---|
457 |
|
---|
458 | /* Vertex/fragment programs */
|
---|
459 | driver->BindProgram = NULL;
|
---|
460 | // driver->NewProgram = _mesa_new_program; /** @todo */
|
---|
461 | // driver->DeleteProgram = _mesa_delete_program; /** @todo */
|
---|
462 | driver->ProgramStringNotify = NULL;
|
---|
463 | #if FEATURE_MESA_program_debug
|
---|
464 | // driver->GetProgramRegister = _mesa_get_program_register; /** @todo */
|
---|
465 | #endif /* FEATURE_MESA_program_debug */
|
---|
466 | driver->IsProgramNative = NULL;
|
---|
467 |
|
---|
468 | /* simple state commands */
|
---|
469 | driver->AlphaFunc = VBOX_GL_FUNC(AlphaFunc);
|
---|
470 | driver->BlendColor = vboxDDBlendColor;
|
---|
471 | // driver->BlendEquationSeparate = VBOX_GL_FUNC(BlendEquationSeparate); /** @todo */
|
---|
472 | driver->BlendFuncSeparate = VBOX_GL_FUNC(BlendFuncSeparateEXT);
|
---|
473 | driver->ClearColor = vboxDDClearColor;
|
---|
474 | driver->ClearDepth = VBOX_GL_FUNC(ClearDepth);
|
---|
475 | driver->ClearIndex = vboxDDClearIndex;
|
---|
476 | driver->ClearStencil = VBOX_GL_FUNC(ClearStencil);
|
---|
477 | driver->ClipPlane = vboxDDClipPlane;
|
---|
478 | driver->ColorMask = VBOX_GL_FUNC(ColorMask);
|
---|
479 | driver->ColorMaterial = VBOX_GL_FUNC(ColorMaterial);
|
---|
480 | driver->CullFace = VBOX_GL_FUNC(CullFace);
|
---|
481 | driver->DrawBuffer = VBOX_GL_FUNC(DrawBuffer); /** @todo */
|
---|
482 | // driver->DrawBuffers = VBOX_GL_FUNC(DrawBuffers); /** @todo */
|
---|
483 | driver->FrontFace = VBOX_GL_FUNC(FrontFace);
|
---|
484 | driver->DepthFunc = VBOX_GL_FUNC(DepthFunc);
|
---|
485 | driver->DepthMask = VBOX_GL_FUNC(DepthMask);
|
---|
486 | driver->DepthRange = VBOX_GL_FUNC(DepthRange);
|
---|
487 | driver->Enable = vboxDDEnable;
|
---|
488 | driver->Fogfv = VBOX_GL_FUNC(Fogfv);
|
---|
489 | driver->Hint = VBOX_GL_FUNC(Hint);
|
---|
490 | driver->IndexMask = VBOX_GL_FUNC(IndexMask);
|
---|
491 | driver->Lightfv = VBOX_GL_FUNC(Lightfv);
|
---|
492 | driver->LightModelfv = VBOX_GL_FUNC(LightModelfv);
|
---|
493 | driver->LineStipple = VBOX_GL_FUNC(LineStipple);
|
---|
494 | driver->LineWidth = VBOX_GL_FUNC(LineWidth);
|
---|
495 | // driver->LogicOpcode = VBOX_GL_FUNC(LogicOpcode); /** @todo */
|
---|
496 | driver->PointParameterfv = VBOX_GL_FUNC(PointParameterfvARB);
|
---|
497 | driver->PointSize = VBOX_GL_FUNC(PointSize);
|
---|
498 | driver->PolygonMode = VBOX_GL_FUNC(PolygonMode);
|
---|
499 | driver->PolygonOffset = VBOX_GL_FUNC(PolygonOffset);
|
---|
500 | driver->PolygonStipple = VBOX_GL_FUNC(PolygonStipple);
|
---|
501 | driver->ReadBuffer = VBOX_GL_FUNC(ReadBuffer);
|
---|
502 | driver->RenderMode = vboxDDRenderMode;
|
---|
503 | driver->Scissor = VBOX_GL_FUNC(Scissor);
|
---|
504 | driver->ShadeModel = VBOX_GL_FUNC(ShadeModel);
|
---|
505 | // driver->StencilFuncSeparate = VBOX_GL_FUNC(StencilFuncSeparate); /** @todo */
|
---|
506 | // driver->StencilOpSeparate = VBOX_GL_FUNC(StencilOpSeparate); /** @todo */
|
---|
507 | // driver->StencilMaskSeparate = VBOX_GL_FUNC(StencilMaskSeparate); /** @todo */
|
---|
508 | driver->TexGen = VBOX_GL_FUNC(TexGenfv);
|
---|
509 | driver->TexEnv = VBOX_GL_FUNC(TexEnvfv);
|
---|
510 | driver->TexParameter = vboxDDTexParameter;
|
---|
511 | // driver->TextureMatrix = VBOX_GL_FUNC(TextureMatrix); /** @todo */
|
---|
512 | driver->Viewport = VBOX_GL_FUNC(Viewport);
|
---|
513 |
|
---|
514 | /* vertex arrays */
|
---|
515 | driver->VertexPointer = VBOX_GL_FUNC(VertexPointer);
|
---|
516 | driver->NormalPointer = VBOX_GL_FUNC(NormalPointer);
|
---|
517 | driver->ColorPointer = VBOX_GL_FUNC(ColorPointer);
|
---|
518 | driver->FogCoordPointer = VBOX_GL_FUNC(FogCoordPointerEXT);
|
---|
519 | driver->IndexPointer = VBOX_GL_FUNC(IndexPointer);
|
---|
520 | driver->SecondaryColorPointer = VBOX_GL_FUNC(SecondaryColorPointerEXT);
|
---|
521 | driver->TexCoordPointer = VBOX_GL_FUNC(TexCoordPointer);
|
---|
522 | driver->EdgeFlagPointer = VBOX_GL_FUNC(EdgeFlagPointer);
|
---|
523 | // driver->VertexAttribPointer = VBOX_GL_FUNC(VertexAttribPointer); /** @todo */
|
---|
524 | // driver->LockArraysEXT = VBOX_GL_FUNC(LockArraysEXT); /** @todo */
|
---|
525 | // driver->UnlockArraysEXT = VBOX_GL_FUNC(UnlockArraysEXT); /** @todo */
|
---|
526 |
|
---|
527 | /* state queries */
|
---|
528 | driver->GetBooleanv = vboxDDGetBooleanv;
|
---|
529 | driver->GetDoublev = vboxDDGetDoublev;
|
---|
530 | driver->GetFloatv = vboxDDGetFloatv;
|
---|
531 | driver->GetIntegerv = vboxDDGetIntegerv;
|
---|
532 | driver->GetPointerv = vboxDDGetPointerv;
|
---|
533 |
|
---|
534 | /** @todo */
|
---|
535 | #if FEATURE_ARB_vertex_buffer_object
|
---|
536 | // driver->NewBufferObject = _mesa_new_buffer_object;
|
---|
537 | // driver->DeleteBuffer = _mesa_delete_buffer_object;
|
---|
538 | // driver->BindBuffer = NULL;
|
---|
539 | // driver->BufferData = _mesa_buffer_data;
|
---|
540 | // driver->BufferSubData = _mesa_buffer_subdata;
|
---|
541 | // driver->GetBufferSubData = _mesa_buffer_get_subdata;
|
---|
542 | // driver->MapBuffer = _mesa_buffer_map;
|
---|
543 | // driver->UnmapBuffer = _mesa_buffer_unmap;
|
---|
544 | #endif
|
---|
545 |
|
---|
546 | /** @todo */
|
---|
547 | #if FEATURE_EXT_framebuffer_object
|
---|
548 | // driver->NewFramebuffer = _mesa_new_framebuffer;
|
---|
549 | // driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
|
---|
550 | // driver->RenderTexture = _mesa_render_texture;
|
---|
551 | // driver->FinishRenderTexture = _mesa_finish_render_texture;
|
---|
552 | // driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
|
---|
553 | #endif
|
---|
554 |
|
---|
555 | /** @todo */
|
---|
556 | #if FEATURE_EXT_framebuffer_blit
|
---|
557 | // driver->BlitFramebuffer = _swrast_BlitFramebuffer;
|
---|
558 | #endif
|
---|
559 |
|
---|
560 | /* query objects */
|
---|
561 | // driver->NewQueryObject = VBOX_GL_FUNC(NewQueryObject); /** @todo */
|
---|
562 | // driver->DeleteQuery = VBOX_GL_FUNC(DeleteQuery); /** @todo */
|
---|
563 | // driver->BeginQuery = VBOX_GL_FUNC(BeginQuery); /** @todo */
|
---|
564 | // driver->EndQuery = VBOX_GL_FUNC(EndQuery); /** @todo */
|
---|
565 | // driver->WaitQuery = VBOX_GL_FUNC(WaitQuery); /** @todo */
|
---|
566 |
|
---|
567 | /* APPLE_vertex_array_object */
|
---|
568 | /*
|
---|
569 | driver->NewArrayObject = _mesa_new_array_object;
|
---|
570 | driver->DeleteArrayObject = _mesa_delete_array_object;
|
---|
571 | driver->BindArrayObject = NULL;
|
---|
572 | */
|
---|
573 |
|
---|
574 | /* T&L stuff */
|
---|
575 | driver->NeedValidate = GL_FALSE;
|
---|
576 | driver->ValidateTnlModule = NULL;
|
---|
577 | driver->CurrentExecPrimitive = 0;
|
---|
578 | driver->CurrentSavePrimitive = 0;
|
---|
579 | driver->NeedFlush = 0;
|
---|
580 | driver->SaveNeedFlush = 0;
|
---|
581 |
|
---|
582 | // driver->ProgramStringNotify = _tnl_program_string; /** @todo */
|
---|
583 | driver->FlushVertices = NULL;
|
---|
584 | driver->SaveFlushVertices = NULL;
|
---|
585 | driver->NotifySaveBegin = NULL;
|
---|
586 | driver->LightingSpaceChange = NULL;
|
---|
587 |
|
---|
588 | /* display list */
|
---|
589 | driver->NewList = VBOX_GL_FUNC(NewList);
|
---|
590 | driver->EndList = VBOX_GL_FUNC(EndList);
|
---|
591 | // driver->BeginCallList = VBOX_GL_FUNC(BeginCallList); /** @todo */
|
---|
592 | // driver->EndCallList = VBOX_GL_FUNC(EndCallList); /** @todo */
|
---|
593 |
|
---|
594 |
|
---|
595 | /* shaders */
|
---|
596 | /*
|
---|
597 | driver->AttachShader = _mesa_attach_shader;
|
---|
598 | driver->BindAttribLocation = _mesa_bind_attrib_location;
|
---|
599 | driver->CompileShader = _mesa_compile_shader;
|
---|
600 | driver->CreateProgram = _mesa_create_program;
|
---|
601 | driver->CreateShader = _mesa_create_shader;
|
---|
602 | driver->DeleteProgram2 = _mesa_delete_program2;
|
---|
603 | driver->DeleteShader = _mesa_delete_shader;
|
---|
604 | driver->DetachShader = _mesa_detach_shader;
|
---|
605 | driver->GetActiveAttrib = _mesa_get_active_attrib;
|
---|
606 | driver->GetActiveUniform = _mesa_get_active_uniform;
|
---|
607 | driver->GetAttachedShaders = _mesa_get_attached_shaders;
|
---|
608 | driver->GetAttribLocation = _mesa_get_attrib_location;
|
---|
609 | driver->GetHandle = _mesa_get_handle;
|
---|
610 | driver->GetProgramiv = _mesa_get_programiv;
|
---|
611 | driver->GetProgramInfoLog = _mesa_get_program_info_log;
|
---|
612 | driver->GetShaderiv = _mesa_get_shaderiv;
|
---|
613 | driver->GetShaderInfoLog = _mesa_get_shader_info_log;
|
---|
614 | driver->GetShaderSource = _mesa_get_shader_source;
|
---|
615 | driver->GetUniformfv = _mesa_get_uniformfv;
|
---|
616 | driver->GetUniformiv = _mesa_get_uniformiv;
|
---|
617 | driver->GetUniformLocation = _mesa_get_uniform_location;
|
---|
618 | driver->IsProgram = _mesa_is_program;
|
---|
619 | driver->IsShader = _mesa_is_shader;
|
---|
620 | driver->LinkProgram = _mesa_link_program;
|
---|
621 | driver->ShaderSource = _mesa_shader_source;
|
---|
622 | driver->Uniform = _mesa_uniform;
|
---|
623 | driver->UniformMatrix = _mesa_uniform_matrix;
|
---|
624 | driver->UseProgram = _mesa_use_program;
|
---|
625 | driver->ValidateProgram = _mesa_validate_program;
|
---|
626 | */
|
---|
627 | }
|
---|
628 |
|
---|
629 | static void
|
---|
630 | vboxdriInitTnlVtxFmt(GLvertexformat *pVtxFmt)
|
---|
631 | {
|
---|
632 | pVtxFmt->ArrayElement = VBOX_GL_FUNC(ArrayElement);
|
---|
633 | pVtxFmt->Begin = VBOX_GL_FUNC(Begin);
|
---|
634 | pVtxFmt->CallList = VBOX_GL_FUNC(CallList);
|
---|
635 | pVtxFmt->CallLists = VBOX_GL_FUNC(CallLists);
|
---|
636 | pVtxFmt->Color3f = VBOX_GL_FUNC(Color3f);
|
---|
637 | pVtxFmt->Color3fv = VBOX_GL_FUNC(Color3fv);
|
---|
638 | pVtxFmt->Color4f = VBOX_GL_FUNC(Color4f);
|
---|
639 | pVtxFmt->Color4fv = VBOX_GL_FUNC(Color4fv);
|
---|
640 | pVtxFmt->EdgeFlag = VBOX_GL_FUNC(EdgeFlag);
|
---|
641 | pVtxFmt->End = VBOX_GL_FUNC(End);
|
---|
642 | pVtxFmt->EvalCoord1f = VBOX_GL_FUNC(EvalCoord1f);
|
---|
643 | pVtxFmt->EvalCoord1fv = VBOX_GL_FUNC(EvalCoord1fv);
|
---|
644 | pVtxFmt->EvalCoord2f = VBOX_GL_FUNC(EvalCoord2f);
|
---|
645 | pVtxFmt->EvalCoord2fv = VBOX_GL_FUNC(EvalCoord2fv);
|
---|
646 | pVtxFmt->EvalPoint1 = VBOX_GL_FUNC(EvalPoint1);
|
---|
647 | pVtxFmt->EvalPoint2 = VBOX_GL_FUNC(EvalPoint2);
|
---|
648 | pVtxFmt->FogCoordfEXT = VBOX_GL_FUNC(FogCoordfEXT);
|
---|
649 | pVtxFmt->FogCoordfvEXT = VBOX_GL_FUNC(FogCoordfvEXT);
|
---|
650 | pVtxFmt->Indexf = VBOX_GL_FUNC(Indexf);
|
---|
651 | pVtxFmt->Indexfv = VBOX_GL_FUNC(Indexfv);
|
---|
652 | pVtxFmt->Materialfv = VBOX_GL_FUNC(Materialfv);
|
---|
653 | pVtxFmt->MultiTexCoord1fARB = VBOX_GL_FUNC(MultiTexCoord1fARB);
|
---|
654 | pVtxFmt->MultiTexCoord1fvARB = VBOX_GL_FUNC(MultiTexCoord1fvARB);
|
---|
655 | pVtxFmt->MultiTexCoord2fARB = VBOX_GL_FUNC(MultiTexCoord2fARB);
|
---|
656 | pVtxFmt->MultiTexCoord2fvARB = VBOX_GL_FUNC(MultiTexCoord2fvARB);
|
---|
657 | pVtxFmt->MultiTexCoord3fARB = VBOX_GL_FUNC(MultiTexCoord3fARB);
|
---|
658 | pVtxFmt->MultiTexCoord3fvARB = VBOX_GL_FUNC(MultiTexCoord3fvARB);
|
---|
659 | pVtxFmt->MultiTexCoord4fARB = VBOX_GL_FUNC(MultiTexCoord4fARB);
|
---|
660 | pVtxFmt->MultiTexCoord4fvARB = VBOX_GL_FUNC(MultiTexCoord4fvARB);
|
---|
661 | pVtxFmt->Normal3f = VBOX_GL_FUNC(Normal3f);
|
---|
662 | pVtxFmt->Normal3fv = VBOX_GL_FUNC(Normal3fv);
|
---|
663 | pVtxFmt->SecondaryColor3fEXT = VBOX_GL_FUNC(SecondaryColor3fEXT);
|
---|
664 | pVtxFmt->SecondaryColor3fvEXT = VBOX_GL_FUNC(SecondaryColor3fvEXT);
|
---|
665 | pVtxFmt->TexCoord1f = VBOX_GL_FUNC(TexCoord1f);
|
---|
666 | pVtxFmt->TexCoord1fv = VBOX_GL_FUNC(TexCoord1fv);
|
---|
667 | pVtxFmt->TexCoord2f = VBOX_GL_FUNC(TexCoord2f);
|
---|
668 | pVtxFmt->TexCoord2fv = VBOX_GL_FUNC(TexCoord2fv);
|
---|
669 | pVtxFmt->TexCoord3f = VBOX_GL_FUNC(TexCoord3f);
|
---|
670 | pVtxFmt->TexCoord3fv = VBOX_GL_FUNC(TexCoord3fv);
|
---|
671 | pVtxFmt->TexCoord4f = VBOX_GL_FUNC(TexCoord4f);
|
---|
672 | pVtxFmt->TexCoord4fv = VBOX_GL_FUNC(TexCoord4fv);
|
---|
673 | pVtxFmt->Vertex2f = VBOX_GL_FUNC(Vertex2f);
|
---|
674 | pVtxFmt->Vertex2fv = VBOX_GL_FUNC(Vertex2fv);
|
---|
675 | pVtxFmt->Vertex3f = VBOX_GL_FUNC(Vertex3f);
|
---|
676 | pVtxFmt->Vertex3fv = VBOX_GL_FUNC(Vertex3fv);
|
---|
677 | pVtxFmt->Vertex4f = VBOX_GL_FUNC(Vertex4f);
|
---|
678 | pVtxFmt->Vertex4fv = VBOX_GL_FUNC(Vertex4fv);
|
---|
679 | pVtxFmt->VertexAttrib1fNV = VBOX_GL_FUNC(VertexAttrib1fARB);
|
---|
680 | pVtxFmt->VertexAttrib1fvNV = VBOX_GL_FUNC(VertexAttrib1fvARB);
|
---|
681 | pVtxFmt->VertexAttrib2fNV = VBOX_GL_FUNC(VertexAttrib2fARB);
|
---|
682 | pVtxFmt->VertexAttrib2fvNV = VBOX_GL_FUNC(VertexAttrib2fvARB);
|
---|
683 | pVtxFmt->VertexAttrib3fNV = VBOX_GL_FUNC(VertexAttrib3fARB);
|
---|
684 | pVtxFmt->VertexAttrib3fvNV = VBOX_GL_FUNC(VertexAttrib3fvARB);
|
---|
685 | pVtxFmt->VertexAttrib4fNV = VBOX_GL_FUNC(VertexAttrib4fARB);
|
---|
686 | pVtxFmt->VertexAttrib4fvNV = VBOX_GL_FUNC(VertexAttrib4fvARB);
|
---|
687 | pVtxFmt->VertexAttrib1fARB = VBOX_GL_FUNC(VertexAttrib1fARB);
|
---|
688 | pVtxFmt->VertexAttrib1fvARB = VBOX_GL_FUNC(VertexAttrib1fvARB);
|
---|
689 | pVtxFmt->VertexAttrib2fARB = VBOX_GL_FUNC(VertexAttrib2fARB);
|
---|
690 | pVtxFmt->VertexAttrib2fvARB = VBOX_GL_FUNC(VertexAttrib2fvARB);
|
---|
691 | pVtxFmt->VertexAttrib3fARB = VBOX_GL_FUNC(VertexAttrib3fARB);
|
---|
692 | pVtxFmt->VertexAttrib3fvARB = VBOX_GL_FUNC(VertexAttrib3fvARB);
|
---|
693 | pVtxFmt->VertexAttrib4fARB = VBOX_GL_FUNC(VertexAttrib4fARB);
|
---|
694 | pVtxFmt->VertexAttrib4fvARB = VBOX_GL_FUNC(VertexAttrib4fvARB);
|
---|
695 |
|
---|
696 | pVtxFmt->EvalMesh1 = VBOX_GL_FUNC(EvalMesh1);
|
---|
697 | pVtxFmt->EvalMesh2 = VBOX_GL_FUNC(EvalMesh2);
|
---|
698 | pVtxFmt->Rectf = VBOX_GL_FUNC(Rectf);
|
---|
699 |
|
---|
700 | pVtxFmt->DrawArrays = VBOX_GL_FUNC(DrawArrays);
|
---|
701 | pVtxFmt->DrawElements = VBOX_GL_FUNC(DrawElements);
|
---|
702 | pVtxFmt->DrawRangeElements = VBOX_GL_FUNC(DrawRangeElements);
|
---|
703 | }
|
---|
704 | #undef VBOX_GL_FUNC
|
---|
705 |
|
---|
706 | static void
|
---|
707 | vboxdriExtSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
|
---|
708 | unsigned long long offset, GLint depth, GLuint pitch)
|
---|
709 | {
|
---|
710 | }
|
---|
711 |
|
---|
712 |
|
---|
713 | static void
|
---|
714 | vboxdriExtSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
|
---|
715 | {
|
---|
716 | }
|
---|
717 |
|
---|
718 | /** @todo not sure we need it from start*/
|
---|
719 | static const __DRItexOffsetExtension vboxdriTexOffsetExtension = {
|
---|
720 | { __DRI_TEX_OFFSET },
|
---|
721 | vboxdriExtSetTexOffset,
|
---|
722 | };
|
---|
723 |
|
---|
724 | /* This DRI extension is required to support EXT_texture_from_pixmap,
|
---|
725 | * which in turn is required by compiz.
|
---|
726 | */
|
---|
727 | static const __DRItexBufferExtension vboxdriTexBufferExtension = {
|
---|
728 | { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
|
---|
729 | vboxdriExtSetTexBuffer,
|
---|
730 | };
|
---|
731 |
|
---|
732 | /* List of DRI extensions supported by VBox DRI driver */
|
---|
733 | static const __DRIextension *vboxdriExtensions[] = {
|
---|
734 | &vboxdriTexOffsetExtension.base,
|
---|
735 | &vboxdriTexBufferExtension.base,
|
---|
736 | NULL
|
---|
737 | };
|
---|
738 |
|
---|
739 | static __GLcontextModes *vboxdriFillInModes(unsigned pixel_bits,
|
---|
740 | unsigned depth_bits,
|
---|
741 | unsigned stencil_bits,
|
---|
742 | GLboolean have_back_buffer)
|
---|
743 | {
|
---|
744 | unsigned deep = (depth_bits > 17);
|
---|
745 |
|
---|
746 | /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
|
---|
747 | * enough to add support. Basically, if a context is created with an
|
---|
748 | * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
|
---|
749 | * will never be used.
|
---|
750 | */
|
---|
751 |
|
---|
752 | static const GLenum db_modes[2] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML };
|
---|
753 | uint8_t depth_bits_array[4];
|
---|
754 | uint8_t stencil_bits_array[4];
|
---|
755 | if(deep) {
|
---|
756 | depth_bits_array[0] = 0;
|
---|
757 | depth_bits_array[1] = 24;
|
---|
758 | stencil_bits_array[0] = 0;
|
---|
759 | stencil_bits_array[1] = 8;
|
---|
760 | } else {
|
---|
761 | depth_bits_array[0] = depth_bits;
|
---|
762 | depth_bits_array[1] = 0;
|
---|
763 | depth_bits_array[2] = depth_bits;
|
---|
764 | depth_bits_array[3] = 0;
|
---|
765 | stencil_bits_array[0] = 0;
|
---|
766 | stencil_bits_array[1] = 0;
|
---|
767 | stencil_bits_array[2] = 8;
|
---|
768 | stencil_bits_array[3] = 8;
|
---|
769 | }
|
---|
770 |
|
---|
771 | return driCreateConfigs(
|
---|
772 | deep ? GL_RGBA : GL_RGB,
|
---|
773 | deep ? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_SHORT_5_6_5,
|
---|
774 | depth_bits_array,
|
---|
775 | stencil_bits_array,
|
---|
776 | deep ? 2 : 4,
|
---|
777 | db_modes, 2);
|
---|
778 | }
|
---|
779 |
|
---|
780 | /**
|
---|
781 | * This is the driver specific part of the createNewScreen entry point.
|
---|
782 | * Called when using legacy DRI.
|
---|
783 | *
|
---|
784 | * return the __GLcontextModes supported by this driver
|
---|
785 | */
|
---|
786 | static const __DRIconfig **vboxdriInitScreen(__DRIscreenPrivate *psp)
|
---|
787 | {
|
---|
788 | static const __DRIversion ddx_expected = { 1, 1, 0 };
|
---|
789 | static const __DRIversion dri_expected = { 4, 0, 0 };
|
---|
790 | static const __DRIversion drm_expected = { 1, 0, 0 };
|
---|
791 | //PVBoxDRI = (PVBoxDRI) psp->pDevPrivate;
|
---|
792 |
|
---|
793 | /* Initialise our call table in chromium. */
|
---|
794 | if (!stubInit())
|
---|
795 | {
|
---|
796 | crDebug("vboxdriInitScreen: stubInit failed");
|
---|
797 | return NULL;
|
---|
798 | }
|
---|
799 |
|
---|
800 | if ( ! driCheckDriDdxDrmVersions2( "tdfx",
|
---|
801 | &psp->dri_version, & dri_expected,
|
---|
802 | &psp->ddx_version, & ddx_expected,
|
---|
803 | &psp->drm_version, & drm_expected ) )
|
---|
804 | return NULL;
|
---|
805 |
|
---|
806 | /* Calling driInitExtensions here, with a NULL context pointer,
|
---|
807 | * does not actually enable the extensions. It just makes sure
|
---|
808 | * that all the dispatch offsets for all the extensions that
|
---|
809 | * *might* be enables are known. This is needed because the
|
---|
810 | * dispatch offsets need to be known when _mesa_context_create is
|
---|
811 | * called, but we can't enable the extensions until we have a
|
---|
812 | * context pointer.
|
---|
813 | *
|
---|
814 | * Hello chicken. Hello egg. How are you two today?
|
---|
815 | */
|
---|
816 | vboxdriInitExtensions(NULL);
|
---|
817 |
|
---|
818 | /** @todo check size of DRIRec (passed from X.Org driver), allocate private
|
---|
819 | * structure if necessary, parse options if necessary, map VRAM if
|
---|
820 | * necessary. */
|
---|
821 | psp->extensions = vboxdriExtensions;
|
---|
822 |
|
---|
823 | /* Initialise VtxFmt call table. */
|
---|
824 | vboxdriInitTnlVtxFmt(&vboxdriTnlVtxFmt);
|
---|
825 |
|
---|
826 | /*return (const __DRIconfig **)
|
---|
827 | vboxdriFillInModes(psp, dri_priv->cpp * 8,
|
---|
828 | (dri_priv->cpp == 2) ? 16 : 24,
|
---|
829 | (dri_priv->cpp == 2) ? 0 : 8, 1);*/
|
---|
830 |
|
---|
831 | /** @todo This should depend on what the host can do, not the guest.
|
---|
832 | * However, we will probably want to discover that in the X.Org driver,
|
---|
833 | * not here. */
|
---|
834 | return (const __DRIconfig **) vboxdriFillInModes(psp, 24, 24, 8, 1);
|
---|
835 | }
|
---|
836 |
|
---|
837 | static void
|
---|
838 | vboxdriDestroyScreen(__DRIscreenPrivate * sPriv)
|
---|
839 | {
|
---|
840 | crDebug("vboxdriDestroyScreen");
|
---|
841 | #if 0 /* From the tdfx driver */
|
---|
842 | /* free all option information */
|
---|
843 | driDestroyOptionInfo (&sPriv->private->optionCache);
|
---|
844 | FREE(sPriv->private);
|
---|
845 | sPriv->private = NULL;
|
---|
846 | #endif
|
---|
847 | }
|
---|
848 |
|
---|
849 | static GLboolean
|
---|
850 | vboxdriCreateContext(const __GLcontextModes * mesaVis,
|
---|
851 | __DRIcontextPrivate * driContextPriv,
|
---|
852 | void *sharedContextPrivate)
|
---|
853 | {
|
---|
854 | //__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
---|
855 | struct dd_function_table functions;
|
---|
856 | GLcontext *ctx, *shareCtx;
|
---|
857 |
|
---|
858 | #if 0 /* We shouldn't need this sort of thing. */
|
---|
859 | XVisualInfo *vis;
|
---|
860 | vis->visual->visualid;
|
---|
861 | context->dpy = dpy;
|
---|
862 | context->visual = vis;
|
---|
863 |
|
---|
864 | GLXContext vboxctx = glXCreateContext(dpy, mesaVis->visualID, GL_TRUE);
|
---|
865 | #endif
|
---|
866 | /* We should be allocating a private context structure, where we will
|
---|
867 | * remember the Mesa context (ctx) among other things. The TDFX driver
|
---|
868 | * also saves importand information in driContextPriv in there - is this
|
---|
869 | * not always available to us? */
|
---|
870 | //driContextPriv->driverPrivate = vboxctx;
|
---|
871 |
|
---|
872 | /* Initialise the default driver functions then plug in our vbox ones,
|
---|
873 | * which will actually replace most of the defaults. */
|
---|
874 | /** @todo we should also pass some information from the visual back to the
|
---|
875 | * host. */
|
---|
876 | _mesa_init_driver_functions(&functions);
|
---|
877 | vboxdriInitFuncs(&functions);
|
---|
878 |
|
---|
879 | /* Allocate context information for Mesa. */
|
---|
880 | if (sharedContextPrivate)
|
---|
881 | shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
|
---|
882 | else
|
---|
883 | shareCtx = NULL;
|
---|
884 | /** @todo save ctx, or be more confident that we can don't need to. */
|
---|
885 | ctx = _mesa_create_context(mesaVis, shareCtx, &functions,
|
---|
886 | driContextPriv->driverPrivate);
|
---|
887 | if (!ctx)
|
---|
888 | {
|
---|
889 | crDebug("vboxdriCreateContext: _mesa_create_context failed");
|
---|
890 | return GL_FALSE;
|
---|
891 | }
|
---|
892 |
|
---|
893 | /* The TDFX driver parses its configuration files here, via
|
---|
894 | * driParseConfigFiles. We will probably get any information via guest
|
---|
895 | * properties. */
|
---|
896 |
|
---|
897 | /* Set various context configuration. We take these values from the
|
---|
898 | * TDFX driver. */
|
---|
899 | /** @r=Leonid, stub.spu->dispatch_table.GetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,&value) etc.
|
---|
900 | * Those would be cached where possible, see include/state/cr_limits.h, VBoxOGLgen/packspu_get.c
|
---|
901 | * Note, that ctx->Const.MaxTextureImageUnits is *not* related to GL_MAX_TEXTURE_UNITS_ARB,
|
---|
902 | * use GL_MAX_TEXTURE_IMAGE_UNITS_ARB instead.
|
---|
903 | * Also, those could fail if we haven't made ctx in our stub yet.
|
---|
904 | */
|
---|
905 | ctx->Const.MaxTextureLevels = 9;
|
---|
906 | ctx->Const.MaxTextureUnits = 1;
|
---|
907 | ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
|
---|
908 | ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
|
---|
909 |
|
---|
910 | /* No wide points.
|
---|
911 | */
|
---|
912 | ctx->Const.MinPointSize = 1.0;
|
---|
913 | ctx->Const.MinPointSizeAA = 1.0;
|
---|
914 | ctx->Const.MaxPointSize = 1.0;
|
---|
915 | ctx->Const.MaxPointSizeAA = 1.0;
|
---|
916 |
|
---|
917 | /* Disable wide lines as we can't antialias them correctly in
|
---|
918 | * hardware.
|
---|
919 | */
|
---|
920 | /** @note That applies to the TDFX, not to us, but as I don't yet know
|
---|
921 | * what to use instead I am leaving the values for now. */
|
---|
922 | ctx->Const.MinLineWidth = 1.0;
|
---|
923 | ctx->Const.MinLineWidthAA = 1.0;
|
---|
924 | ctx->Const.MaxLineWidth = 1.0;
|
---|
925 | ctx->Const.MaxLineWidthAA = 1.0;
|
---|
926 | ctx->Const.LineWidthGranularity = 1.0;
|
---|
927 |
|
---|
928 | /* Initialize the software rasterizer and helper modules - again, TDFX */
|
---|
929 | _swrast_CreateContext( ctx );
|
---|
930 | _vbo_CreateContext( ctx );
|
---|
931 | _tnl_CreateContext( ctx );
|
---|
932 | _swsetup_CreateContext( ctx );
|
---|
933 |
|
---|
934 | /* Install the customized pipeline, TDFX */
|
---|
935 | _tnl_destroy_pipeline( ctx );
|
---|
936 | _tnl_install_pipeline( ctx, tdfx_pipeline );
|
---|
937 |
|
---|
938 | /* Configure swrast and T&L to match hardware characteristics, TDFX */
|
---|
939 | _swrast_allow_pixel_fog( ctx, GL_TRUE );
|
---|
940 | _swrast_allow_vertex_fog( ctx, GL_FALSE );
|
---|
941 | _tnl_allow_pixel_fog( ctx, GL_TRUE );
|
---|
942 | _tnl_allow_vertex_fog( ctx, GL_FALSE );
|
---|
943 | /*ctx->DriverCtx = ;*/
|
---|
944 |
|
---|
945 | /* This was *not* in the TDFX driver. */
|
---|
946 | _mesa_install_exec_vtxfmt(ctx, &vboxdriTnlVtxFmt);
|
---|
947 |
|
---|
948 | vboxdriInitExtensions(ctx);
|
---|
949 |
|
---|
950 | return GL_TRUE;
|
---|
951 | }
|
---|
952 |
|
---|
953 |
|
---|
954 | static void
|
---|
955 | vboxdriDestroyContext(__DRIcontextPrivate *driContextPriv)
|
---|
956 | {
|
---|
957 | // glXDestroyContext(driContextPriv->driverPrivate);
|
---|
958 | //_mesa_destroy_context ?
|
---|
959 | }
|
---|
960 |
|
---|
961 | /**
|
---|
962 | * This is called when we need to set up GL rendering to a new X window.
|
---|
963 | */
|
---|
964 | static GLboolean
|
---|
965 | vboxdriCreateBuffer(__DRIscreenPrivate * driScrnPriv,
|
---|
966 | __DRIdrawablePrivate * driDrawPriv,
|
---|
967 | const __GLcontextModes * mesaVis, GLboolean isPixmap)
|
---|
968 | {
|
---|
969 | return GL_FALSE;
|
---|
970 | }
|
---|
971 |
|
---|
972 | static void
|
---|
973 | vboxdriDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
|
---|
974 | {
|
---|
975 | }
|
---|
976 |
|
---|
977 | static void
|
---|
978 | vboxdriSwapBuffers(__DRIdrawablePrivate * dPriv)
|
---|
979 | {
|
---|
980 | }
|
---|
981 |
|
---|
982 |
|
---|
983 | GLboolean
|
---|
984 | vboxdriMakeCurrent(__DRIcontextPrivate * driContextPriv,
|
---|
985 | __DRIdrawablePrivate * driDrawPriv,
|
---|
986 | __DRIdrawablePrivate * driReadPriv)
|
---|
987 | {
|
---|
988 | return GL_FALSE;
|
---|
989 | }
|
---|
990 |
|
---|
991 | GLboolean
|
---|
992 | vboxdriUnbindContext(__DRIcontextPrivate * driContextPriv)
|
---|
993 | {
|
---|
994 | return GL_TRUE;
|
---|
995 | }
|
---|
996 |
|
---|
997 |
|
---|
998 | /* This structure is used by dri_util from mesa, don't rename it! */
|
---|
999 | DECLEXPORT(const struct __DriverAPIRec) driDriverAPI = {
|
---|
1000 | .InitScreen = vboxdriInitScreen,
|
---|
1001 | .DestroyScreen = vboxdriDestroyScreen,
|
---|
1002 | .CreateContext = vboxdriCreateContext,
|
---|
1003 | .DestroyContext = vboxdriDestroyContext,
|
---|
1004 | .CreateBuffer = vboxdriCreateBuffer,
|
---|
1005 | .DestroyBuffer = vboxdriDestroyBuffer,
|
---|
1006 | .SwapBuffers = vboxdriSwapBuffers,
|
---|
1007 | .MakeCurrent = vboxdriMakeCurrent,
|
---|
1008 | .UnbindContext = vboxdriUnbindContext,
|
---|
1009 | .GetSwapInfo = NULL,
|
---|
1010 | .WaitForMSC = NULL,
|
---|
1011 | .WaitForSBC = NULL,
|
---|
1012 | .SwapBuffersMSC = NULL,
|
---|
1013 | .CopySubBuffer = NULL,
|
---|
1014 | .GetDrawableMSC = NULL,
|
---|
1015 | .InitScreen2 = NULL
|
---|
1016 | };
|
---|