VirtualBox

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

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

crOgl/wddm: per-context connections

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

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