VirtualBox

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

最後變更 在這個檔案從33475是 33475,由 vboxsync 提交於 14 年 前

crOpenGL/wddm: multithreading fix

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 2.2 KB
 
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#ifdef CHROMIUM_THREADSAFE
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
57 packspuCreateFunctions();
58 crStateInit();
59
60 return &pack_functions;
61}
62
63static void
64packSPUSelfDispatch(SPUDispatchTable *self)
65{
66 (void)self;
67}
68
69static int
70packSPUCleanup(void)
71{
72 int i;
73#ifdef CHROMIUM_THREADSAFE
74 crLockMutex(&_PackMutex);
75#endif
76 for (i=0; i<pack_spu.numThreads; ++i)
77 {
78 if (pack_spu.thread[i].packer)
79 {
80 crPackDeleteContext(pack_spu.thread[i].packer);
81 }
82 }
83
84 crFreeTSD(&_PackerTSD);
85 crFreeTSD(&_PackTSD);
86
87#ifdef CHROMIUM_THREADSAFE
88 crUnlockMutex(&_PackMutex);
89 crFreeMutex(&_PackMutex);
90#endif
91 return 1;
92}
93
94extern SPUOptions packSPUOptions[];
95
96int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
97 SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
98 SPUOptionsPtr *options, int *flags )
99{
100 *name = "pack";
101 *super = NULL;
102 *init = packSPUInit;
103 *self = packSPUSelfDispatch;
104 *cleanup = packSPUCleanup;
105 *options = packSPUOptions;
106 *flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
107
108 return 1;
109}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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