VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c@ 35263

Last change on this file since 35263 was 16074, checked in by vboxsync, 15 years ago

crOpenGL: fix guest app crashes with vertexarrays for multithreaded apps

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "cr_spu.h"
8#include "arrayspu.h"
9#include "cr_mem.h"
10#include <stdio.h>
11
12extern SPUNamedFunctionTable _cr_array_table[];
13
14extern SPUOptions arraySPUOptions[];
15
16static SPUFunctions array_functions = {
17 NULL, /* CHILD COPY */
18 NULL, /* DATA */
19 _cr_array_table /* THE ACTUAL FUNCTIONS */
20};
21
22static SPUFunctions *arraySPUInit( int id, SPU *child, SPU *self,
23 unsigned int context_id,
24 unsigned int num_contexts )
25{
26
27 (void) context_id;
28 (void) num_contexts;
29
30#ifdef CHROMIUM_THREADSAFE
31 crInitMutex(&_ArrayMutex);
32#endif
33
34 array_spu.id = id;
35 array_spu.has_child = 0;
36 if (child)
37 {
38 crSPUInitDispatchTable( &(array_spu.child) );
39 crSPUCopyDispatchTable( &(array_spu.child), &(child->dispatch_table) );
40 array_spu.has_child = 1;
41 }
42 crSPUInitDispatchTable( &(array_spu.super) );
43 crSPUCopyDispatchTable( &(array_spu.super), &(self->superSPU->dispatch_table) );
44 arrayspuSetVBoxConfiguration();
45
46 crStateInit();
47/*@todo seems default context ain't needed at all*/
48 array_spu.defaultctx = crStateCreateContext( NULL, 0, NULL );
49#ifdef CR_ARB_vertex_buffer_object
50 array_spu.defaultctx->bufferobject.retainBufferData = GL_TRUE;
51#endif
52 /* we call SetCurrent instead of MakeCurrent as the differencer
53 * isn't setup yet anyway */
54 crStateSetCurrent( array_spu.defaultctx );
55
56 array_spu.numContexts = 0;
57 crMemZero(array_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo));
58
59 return &array_functions;
60}
61
62static void arraySPUSelfDispatch(SPUDispatchTable *self)
63{
64 crSPUInitDispatchTable( &(array_spu.self) );
65 crSPUCopyDispatchTable( &(array_spu.self), self );
66}
67
68static int arraySPUCleanup(void)
69{
70 return 1;
71}
72
73int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
74 SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
75 SPUOptionsPtr *options, int *flags )
76{
77 *name = "array";
78 *super = "passthrough";
79 *init = arraySPUInit;
80 *self = arraySPUSelfDispatch;
81 *cleanup = arraySPUCleanup;
82 *options = arraySPUOptions;
83 *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
84
85 return 1;
86}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use