VirtualBox

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

Last change on this file since 39507 was 39507, checked in by vboxsync, 13 years ago

crOpenGL: fix destroyed context refference in TLS

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 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}
87
88#ifdef RT_OS_WINDOWS
89#define WIN32_LEAN_AND_MEAN
90#include <windows.h>
91BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
92{
93 (void) lpvReserved;
94
95 switch (fdwReason)
96 {
97 case DLL_THREAD_ATTACH:
98 {
99 crStateOnThreadAttachDetach(GL_TRUE);
100 break;
101 }
102
103 case DLL_THREAD_DETACH:
104 {
105 crStateOnThreadAttachDetach(GL_FALSE);
106 break;
107 }
108
109 case DLL_PROCESS_ATTACH:
110 case DLL_PROCESS_DETACH:
111 default:
112 break;
113 }
114
115 return TRUE;
116}
117#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette