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