VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c@ 41971

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

back out r74471 since it causes crashes

  • 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_mem.h"
8#include "cr_spu.h"
9#include "cr_glstate.h"
10#include "packspu.h"
11#include "cr_packfunctions.h"
12#include <stdio.h>
13
14extern SPUNamedFunctionTable _cr_pack_table[];
15
16SPUFunctions pack_functions = {
17 NULL, /* CHILD COPY */
18 NULL, /* DATA */
19 _cr_pack_table /* THE ACTUAL FUNCTIONS */
20};
21
22PackSPU pack_spu;
23
24#ifdef CHROMIUM_THREADSAFE
25CRtsd _PackTSD;
26CRmutex _PackMutex;
27#endif
28
29static SPUFunctions *
30packSPUInit( int id, SPU *child, SPU *self,
31 unsigned int context_id,
32 unsigned int num_contexts )
33{
34 ThreadInfo *thread;
35
36 (void) context_id;
37 (void) num_contexts;
38 (void) child;
39 (void) self;
40
41#if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS)
42 crInitMutex(&_PackMutex);
43#endif
44
45 pack_spu.id = id;
46
47 packspuSetVBoxConfiguration( child );
48
49 /* This connects to the server, sets up the packer, etc. */
50 thread = packspuNewThread( crThreadID() );
51
52 if (!thread) {
53 return NULL;
54 }
55 CRASSERT( thread == &(pack_spu.thread[0]) );
56 pack_spu.idxThreadInUse = 0;
57
58 packspuCreateFunctions();
59 crStateInit();
60
61 return &pack_functions;
62}
63
64static void
65packSPUSelfDispatch(SPUDispatchTable *self)
66{
67 (void)self;
68}
69
70static int
71packSPUCleanup(void)
72{
73 int i;
74#ifdef CHROMIUM_THREADSAFE
75 crLockMutex(&_PackMutex);
76#endif
77 for (i=0; i<MAX_THREADS; ++i)
78 {
79 if (pack_spu.thread[i].inUse && pack_spu.thread[i].packer)
80 {
81 crPackDeleteContext(pack_spu.thread[i].packer);
82 }
83 }
84
85 crFreeTSD(&_PackerTSD);
86 crFreeTSD(&_PackTSD);
87
88#ifdef CHROMIUM_THREADSAFE
89 crUnlockMutex(&_PackMutex);
90# ifndef WINDOWS
91 crFreeMutex(&_PackMutex);
92# endif
93#endif
94 return 1;
95}
96
97extern SPUOptions packSPUOptions[];
98
99int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
100 SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
101 SPUOptionsPtr *options, int *flags )
102{
103 *name = "pack";
104 *super = NULL;
105 *init = packSPUInit;
106 *self = packSPUSelfDispatch;
107 *cleanup = packSPUCleanup;
108 *options = packSPUOptions;
109 *flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
110
111 return 1;
112}
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