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