VirtualBox

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

Last change on this file since 43409 was 42536, checked in by vboxsync, 12 years ago

crOpenGL/wddm: WOW64 fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.6 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#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
50 pack_spu.bRunningUnderWDDM = !!GetModuleHandle(VBOX_MODNAME_DISPD3D);
51#endif
52
53 if (!CRPACKSPU_IS_WDDM_CRHGSMI())
54 {
55 /* This connects to the server, sets up the packer, etc. */
56 thread = packspuNewThread(
57#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
58 NULL
59#endif
60 );
61
62 if (!thread) {
63 return NULL;
64 }
65 CRASSERT( thread == &(pack_spu.thread[0]) );
66 pack_spu.idxThreadInUse = 0;
67 }
68
69 packspuCreateFunctions();
70 crStateInit();
71
72 return &pack_functions;
73}
74
75static void
76packSPUSelfDispatch(SPUDispatchTable *self)
77{
78 (void)self;
79}
80
81static int
82packSPUCleanup(void)
83{
84 int i;
85#ifdef CHROMIUM_THREADSAFE
86 crLockMutex(&_PackMutex);
87#endif
88 for (i=0; i<MAX_THREADS; ++i)
89 {
90 if (pack_spu.thread[i].inUse && pack_spu.thread[i].packer)
91 {
92 crPackDeleteContext(pack_spu.thread[i].packer);
93 }
94 }
95
96 crFreeTSD(&_PackerTSD);
97 crFreeTSD(&_PackTSD);
98
99#ifdef CHROMIUM_THREADSAFE
100 crUnlockMutex(&_PackMutex);
101# ifndef WINDOWS
102 crFreeMutex(&_PackMutex);
103# endif
104#endif
105 return 1;
106}
107
108extern SPUOptions packSPUOptions[];
109
110int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
111 SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
112 SPUOptionsPtr *options, int *flags )
113{
114 *name = "pack";
115 *super = NULL;
116 *init = packSPUInit;
117 *self = packSPUSelfDispatch;
118 *cleanup = packSPUCleanup;
119 *options = packSPUOptions;
120 *flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
121
122 return 1;
123}
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