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