VirtualBox

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

Last change on this file since 55382 was 51313, checked in by vboxsync, 11 years ago

crOpenGL: bugfixes and work-arounds for wine issues

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