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 | #ifndef CR_PACKSPU_H
|
---|
8 | #define CR_PACKSPU_H
|
---|
9 |
|
---|
10 | #ifdef WINDOWS
|
---|
11 | #define PACKSPU_APIENTRY __stdcall
|
---|
12 | #else
|
---|
13 | #define PACKSPU_APIENTRY
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include "cr_glstate.h"
|
---|
17 | #include "cr_netserver.h"
|
---|
18 | #include "cr_pack.h"
|
---|
19 | #include "cr_spu.h"
|
---|
20 | #include "cr_threads.h"
|
---|
21 | #include "state/cr_client.h"
|
---|
22 | #ifdef VBOX_WITH_CRPACKSPU_DUMPER
|
---|
23 | # include "cr_dump.h"
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | extern uint32_t g_u32VBoxHostCaps;
|
---|
27 |
|
---|
28 | typedef struct thread_info_t ThreadInfo;
|
---|
29 | typedef struct context_info_t ContextInfo;
|
---|
30 | typedef struct zvabuffer_info_t ZvaBufferInfo;
|
---|
31 |
|
---|
32 | struct zvabuffer_info_t
|
---|
33 | {
|
---|
34 | /* GL_ARRAY_BUFFER_ARB buffer */
|
---|
35 | GLuint idBuffer;
|
---|
36 | /* buffer length */
|
---|
37 | GLuint cbBuffer;
|
---|
38 | /* number of values stored in the buffer currently */
|
---|
39 | GLuint cValues;
|
---|
40 | /* current buffer value */
|
---|
41 | union
|
---|
42 | {
|
---|
43 | GLfloat f[4];
|
---|
44 | GLuint ui[4];
|
---|
45 | GLubyte ub[4];
|
---|
46 | GLshort s[4];
|
---|
47 | GLushort us[4];
|
---|
48 | } Value;
|
---|
49 | };
|
---|
50 |
|
---|
51 | struct thread_info_t {
|
---|
52 | unsigned long id;
|
---|
53 | CRNetServer netServer;
|
---|
54 | CRPackBuffer buffer;
|
---|
55 | CRPackBuffer normBuffer;
|
---|
56 | CRPackBuffer BeginEndBuffer;
|
---|
57 | GLenum BeginEndMode;
|
---|
58 | int BeginEndState;
|
---|
59 | ContextInfo *currentContext;
|
---|
60 | CRPackContext *packer;
|
---|
61 | int writeback;
|
---|
62 | GLboolean bInjectThread;
|
---|
63 | GLboolean inUse;
|
---|
64 | };
|
---|
65 |
|
---|
66 | struct context_info_t {
|
---|
67 | CRContext *clientState; /* used to store client-side GL state */
|
---|
68 | GLint serverCtx; /* context ID returned by server */
|
---|
69 | GLboolean fAutoFlush;
|
---|
70 | GLboolean fCheckZerroVertAttr;
|
---|
71 | ThreadInfo *currentThread;
|
---|
72 | ZvaBufferInfo zvaBufferInfo;
|
---|
73 | GLubyte glVersion[100]; /* GL_VERSION string */
|
---|
74 | GLubyte pszRealVendor[100];
|
---|
75 | GLubyte pszRealVersion[100];
|
---|
76 | GLubyte pszRealRenderer[100];
|
---|
77 | };
|
---|
78 |
|
---|
79 | typedef struct {
|
---|
80 | int id;
|
---|
81 | int swap;
|
---|
82 |
|
---|
83 | /* config options */
|
---|
84 | int emit_GATHER_POST_SWAPBUFFERS;
|
---|
85 | int swapbuffer_sync;
|
---|
86 |
|
---|
87 | int ReadPixels;
|
---|
88 |
|
---|
89 | char *name;
|
---|
90 | int buffer_size;
|
---|
91 |
|
---|
92 | int numThreads; /*number of used threads in the next array, doesn't need to be cont*/
|
---|
93 | ThreadInfo thread[MAX_THREADS];
|
---|
94 | int idxThreadInUse; /*index of any used thread*/
|
---|
95 |
|
---|
96 | #if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
|
---|
97 | bool bIsWDDMCrHgsmi;
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | SPUDispatchTable self;
|
---|
101 |
|
---|
102 | #ifdef VBOX_WITH_CRPACKSPU_DUMPER
|
---|
103 | CR_RECORDER Recorder;
|
---|
104 | CR_DBGPRINT_DUMPER Dumper;
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | int numContexts;
|
---|
108 | ContextInfo context[CR_MAX_CONTEXTS];
|
---|
109 | } PackSPU;
|
---|
110 |
|
---|
111 | extern PackSPU pack_spu;
|
---|
112 |
|
---|
113 | #define THREAD_OFFSET_MAGIC 2000
|
---|
114 |
|
---|
115 | #ifdef CHROMIUM_THREADSAFE
|
---|
116 | extern CRmutex _PackMutex;
|
---|
117 | extern CRtsd _PackTSD;
|
---|
118 | #define GET_THREAD_VAL() (crGetTSD(&_PackTSD))
|
---|
119 | #define GET_THREAD_IDX(_id) ((_id) - THREAD_OFFSET_MAGIC)
|
---|
120 | #define GET_THREAD_VAL_ID(_id) (&(pack_spu.thread[GET_THREAD_IDX(_id)]))
|
---|
121 | #else
|
---|
122 | #define GET_THREAD_VAL() (&(pack_spu.thread[0]))
|
---|
123 | #endif
|
---|
124 | #define GET_THREAD(T) ThreadInfo *T = GET_THREAD_VAL()
|
---|
125 | #define GET_THREAD_ID(T, _id) ThreadInfo *T = GET_THREAD_VAL_ID(_id)
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 | #define GET_CONTEXT(C) \
|
---|
130 | GET_THREAD(thread); \
|
---|
131 | ContextInfo *C = thread->currentContext
|
---|
132 |
|
---|
133 | #ifdef DEBUG_misha
|
---|
134 | # define CRPACKSPU_WRITEBACK_ASSERT_ZERO(_writeback) Assert(!(_writeback))
|
---|
135 | #else
|
---|
136 | # define CRPACKSPU_WRITEBACK_ASSERT_ZERO(_writeback) do {} while (0)
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | #define CRPACKSPU_WRITEBACK_WAIT(_thread, _writeback) do {\
|
---|
140 | if (g_u32VBoxHostCaps & CR_VBOX_CAP_CMDVBVA) { \
|
---|
141 | CRPACKSPU_WRITEBACK_ASSERT_ZERO(_writeback); \
|
---|
142 | (_writeback) = 0; \
|
---|
143 | break; \
|
---|
144 | } \
|
---|
145 | CR_WRITEBACK_WAIT((_thread)->netServer.conn, _writeback); \
|
---|
146 | } while (0)
|
---|
147 |
|
---|
148 | #if defined(WINDOWS) && defined(VBOX_WITH_WDDM) && defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
|
---|
149 | # define CRPACKSPU_IS_WDDM_CRHGSMI() (pack_spu.bIsWDDMCrHgsmi)
|
---|
150 | #else
|
---|
151 | # define CRPACKSPU_IS_WDDM_CRHGSMI() (GL_FALSE)
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | extern void packspuCreateFunctions( void );
|
---|
155 | extern void packspuSetVBoxConfiguration( const SPU *child_spu );
|
---|
156 | extern void packspuConnectToServer( CRNetServer *server
|
---|
157 | #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
|
---|
158 | , struct VBOXUHGSMI *pHgsmi
|
---|
159 | #endif
|
---|
160 | );
|
---|
161 | extern void packspuFlush( void *arg );
|
---|
162 | extern void packspuHuge( CROpcode opcode, void *buf );
|
---|
163 |
|
---|
164 | extern void packspuInitStrings(void);
|
---|
165 |
|
---|
166 | extern GLboolean packspuSyncOnFlushes(void);
|
---|
167 |
|
---|
168 | extern ThreadInfo *packspuNewThread(
|
---|
169 | #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
|
---|
170 | struct VBOXUHGSMI *pHgsmi
|
---|
171 | #else
|
---|
172 | void
|
---|
173 | #endif
|
---|
174 | );
|
---|
175 |
|
---|
176 | extern ThreadInfo *packspuNewCtxThread( struct VBOXUHGSMI *pHgsmi );
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 | #define MAGIC_OFFSET 3000
|
---|
181 |
|
---|
182 | #endif /* CR_PACKSPU_H */
|
---|