VirtualBox

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

Last change on this file since 65381 was 65381, checked in by vboxsync, 8 years ago

bugref:8282: Additions/linux: submit DRM driver to the Linux kernel: move all graphics device-related header files to a separate sub-directory and add that to the include path where they are needed. The intention is too be able to remove the VBox/ include folder in the DRM driver package.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.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
29#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
30# include <VBoxCrHgsmi.h>
31# include <VBoxUhgsmi.h>
32#endif
33
34#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_WDDM)
35static bool isVBoxWDDMCrHgsmi(void)
36{
37#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
38 PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate();
39 if (pHgsmi)
40 {
41 VBoxCrHgsmiDestroy(pHgsmi);
42 return true;
43 }
44#endif
45 return false;
46}
47#endif /* RT_OS_WINDOWS && VBOX_WITH_WDDM */
48
49static SPUFunctions *
50packSPUInit( int id, SPU *child, SPU *self,
51 unsigned int context_id,
52 unsigned int num_contexts )
53{
54 ThreadInfo *thread;
55
56 (void) context_id;
57 (void) num_contexts;
58 (void) child;
59 (void) self;
60
61#if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS)
62 crInitMutex(&_PackMutex);
63#endif
64
65#ifdef CHROMIUM_THREADSAFE
66 crInitTSD(&_PackerTSD);
67 crInitTSD(&_PackTSD);
68#endif
69
70 pack_spu.id = id;
71
72 packspuSetVBoxConfiguration( child );
73
74#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
75 pack_spu.bIsWDDMCrHgsmi = isVBoxWDDMCrHgsmi();
76#endif
77
78#ifdef VBOX_WITH_CRPACKSPU_DUMPER
79 memset(&pack_spu.Dumper, 0, sizeof (pack_spu.Dumper));
80#endif
81
82 if (!CRPACKSPU_IS_WDDM_CRHGSMI())
83 {
84 /* This connects to the server, sets up the packer, etc. */
85 thread = packspuNewThread(
86#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
87 NULL
88#endif
89 );
90
91 if (!thread) {
92 return NULL;
93 }
94 CRASSERT( thread == &(pack_spu.thread[0]) );
95 pack_spu.idxThreadInUse = 0;
96 }
97
98 packspuCreateFunctions();
99 crStateInit();
100
101 return &pack_functions;
102}
103
104static void
105packSPUSelfDispatch(SPUDispatchTable *self)
106{
107 crSPUInitDispatchTable( &(pack_spu.self) );
108 crSPUCopyDispatchTable( &(pack_spu.self), self );
109}
110
111static int
112packSPUCleanup(void)
113{
114 int i;
115#ifdef CHROMIUM_THREADSAFE
116 crLockMutex(&_PackMutex);
117#endif
118 for (i=0; i<MAX_THREADS; ++i)
119 {
120 if (pack_spu.thread[i].inUse && pack_spu.thread[i].packer)
121 {
122 crPackDeleteContext(pack_spu.thread[i].packer);
123 }
124 }
125
126#ifdef CHROMIUM_THREADSAFE
127 crFreeTSD(&_PackerTSD);
128 crFreeTSD(&_PackTSD);
129 crUnlockMutex(&_PackMutex);
130# ifndef WINDOWS
131 crFreeMutex(&_PackMutex);
132# endif
133#endif /* CHROMIUM_THREADSAFE */
134 return 1;
135}
136
137extern SPUOptions packSPUOptions[];
138
139int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
140 SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
141 SPUOptionsPtr *options, int *flags )
142{
143 *name = "pack";
144 *super = NULL;
145 *init = packSPUInit;
146 *self = packSPUSelfDispatch;
147 *cleanup = packSPUCleanup;
148 *options = packSPUOptions;
149 *flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
150
151 return 1;
152}
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