VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h@ 46515

Last change on this file since 46515 was 46515, checked in by vboxsync, 12 years ago

crOpenGL: more debugging/dumping

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 26.2 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#ifndef CR_SERVER_H
8#define CR_SERVER_H
9
10#include "cr_protocol.h"
11#include "cr_glstate.h"
12#include "spu_dispatch_table.h"
13
14#include "state/cr_currentpointers.h"
15
16#include "cr_server.h"
17
18#ifdef VBOX_WITH_CRHGSMI
19# include <VBox/VBoxVideo.h>
20
21#include <iprt/cdefs.h>
22
23RT_C_DECLS_BEGIN
24
25extern uint8_t* g_pvVRamBase;
26extern uint32_t g_cbVRam;
27extern HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion;
28extern PFNCRHGSMICMDCOMPLETION g_pfnCrHgsmiCompletion;
29
30#define VBOXCRHGSMI_PTR(_off, _t) ((_t*)(g_pvVRamBase + (_off)))
31#define VBOXCRHGSMI_PTR_SAFE(_off, _cb, _t) ((_t*)crServerCrHgsmiPtrGet(_off, _cb))
32
33DECLINLINE(void*) crServerCrHgsmiPtrGet(VBOXVIDEOOFFSET offBuffer, uint32_t cbBuffer)
34{
35 return ((offBuffer) + (cbBuffer) <= g_cbVRam ? VBOXCRHGSMI_PTR(offBuffer, void) : NULL);
36}
37
38DECLINLINE(void) crServerCrHgsmiCmdComplete(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, int cmdProcessingRc)
39{
40 g_pfnCrHgsmiCompletion(g_hCrHgsmiCompletion, pCmd, cmdProcessingRc);
41}
42
43#define VBOXCRHGSMI_CMD_COMPLETE(_pData, _rc) do { \
44 CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData); \
45 CRVBOXHGSMI_CMDDATA_RC(_pData, _rc); \
46 crServerCrHgsmiCmdComplete((_pData)->pCmd, VINF_SUCCESS); \
47 } while (0)
48
49#define VBOXCRHGSMI_CMD_CHECK_COMPLETE(_pData, _rc) do { \
50 if (CRVBOXHGSMI_CMDDATA_IS_SET(_pData)) { \
51 VBOXCRHGSMI_CMD_COMPLETE(_pData, _rc); \
52 } \
53 } while (0)
54
55#endif
56
57/*
58 * This is the base number for window and context IDs
59 */
60#define MAGIC_OFFSET 5000
61
62extern CRServer cr_server;
63
64/* Semaphore wait queue node */
65typedef struct _wqnode {
66 RunQueue *q;
67 struct _wqnode *next;
68} wqnode;
69
70typedef struct {
71 GLuint count;
72 GLuint num_waiting;
73 RunQueue **waiting;
74} CRServerBarrier;
75
76typedef struct {
77 GLuint count;
78 wqnode *waiting, *tail;
79} CRServerSemaphore;
80
81typedef struct {
82 GLuint id;
83 GLint projParamStart;
84 GLfloat projMat[16]; /* projection matrix, accumulated via calls to */
85 /* glProgramLocalParameterARB, glProgramParameterNV */
86} CRServerProgram;
87
88void crServerSetVBoxConfiguration();
89void crServerSetVBoxConfigurationHGCM();
90void crServerInitDispatch(void);
91void crServerReturnValue( const void *payload, unsigned int payload_len );
92void crServerWriteback(void);
93int crServerRecv( CRConnection *conn, CRMessage *msg, unsigned int len );
94void crServerSerializeRemoteStreams(void);
95void crServerAddToRunQueue( CRClient *client );
96void crServerDeleteClient( CRClient *client );
97
98
99void crServerApplyBaseProjection( const CRmatrix *baseProj );
100void crServerApplyViewMatrix( const CRmatrix *view );
101void crServerSetOutputBounds( const CRMuralInfo *mural, int extNum );
102void crServerComputeViewportBounds( const CRViewportState *v, CRMuralInfo *mural );
103
104GLboolean crServerInitializeBucketing(CRMuralInfo *mural);
105
106void crComputeOverlapGeom(double *quads, int nquad, CRPoly ***res);
107void crComputeKnockoutGeom(double *quads, int nquad, int my_quad_idx, CRPoly **res);
108
109int crServerGetCurrentEye(void);
110
111GLboolean crServerClientInBeginEnd(const CRClient *client);
112
113GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID);
114GLint crServerDispatchWindowCreateEx(const char *dpyName, GLint visBits, GLint preloadWinID);
115GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID);
116void crServerMuralTerm(CRMuralInfo *mural);
117void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
118int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects);
119
120GLint crServerGenerateID(GLint *pCounter);
121
122GLint crServerSPUWindowID(GLint serverWindow);
123
124GLuint crServerTranslateProgramID(GLuint id);
125
126CRMuralInfo * crServerGetDummyMural(GLint visualBits);
127
128void crServerSetupOutputRedirect(CRMuralInfo *mural);
129void crServerCheckMuralGeometry(CRMuralInfo *mural);
130GLboolean crServerSupportRedirMuralFBO(void);
131
132void crVBoxServerNotifyEvent(int32_t idScreen);
133
134#define CR_SERVER_REDIR_F_NONE 0x00
135/* the data should be displayed on host (unset when is on or when CR_SERVER_REDIR_F_FBO_RAM_VMFB is set) */
136#define CR_SERVER_REDIR_F_DISPLAY 0x01
137/* guest window data get redirected to FBO on host */
138#define CR_SERVER_REDIR_F_FBO 0x02
139/* used with CR_SERVER_REDIR_F_FBO only
140 * indicates that FBO data should be copied to RAM for further processing */
141#define CR_SERVER_REDIR_F_FBO_RAM 0x04
142/* used with CR_SERVER_REDIR_F_FBO_RAM only
143 * indicates that FBO data should be passed to VRDP backend */
144#define CR_SERVER_REDIR_F_FBO_RAM_VRDP 0x08
145/* used with CR_SERVER_REDIR_F_FBO_RAM only
146 * indicates that FBO data should be passed to VM Framebuffer */
147#define CR_SERVER_REDIR_F_FBO_RAM_VMFB 0x10
148/* used with CR_SERVER_REDIR_F_FBO_RAM only
149 * makes the RPW (Read Pixels Worker) mechanism to be used for GPU memory aquisition */
150#define CR_SERVER_REDIR_F_FBO_RPW 0x20
151
152
153#define CR_SERVER_REDIR_F_ALL 0x3f
154
155#define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO (CR_SERVER_REDIR_F_ALL & ~CR_SERVER_REDIR_F_DISPLAY)
156#define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM (CR_SERVER_REDIR_F_FBO_RAM_VRDP | CR_SERVER_REDIR_F_FBO_RAM_VMFB | CR_SERVER_REDIR_F_FBO_RPW)
157
158DECLINLINE(GLuint) crServerRedirModeAdjust(GLuint value)
159{
160 /* sanitize values */
161 value &= CR_SERVER_REDIR_F_ALL;
162
163 if (value & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO)
164 value |= CR_SERVER_REDIR_F_FBO;
165 if (value & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM)
166 value |= CR_SERVER_REDIR_F_FBO_RAM;
167
168 return value;
169}
170
171int32_t crServerSetOffscreenRenderingMode(GLuint value);
172void crServerRedirMuralFBO(CRMuralInfo *mural, GLuint redir);
173void crServerDeleteMuralFBO(CRMuralInfo *mural);
174void crServerPresentFBO(CRMuralInfo *mural);
175GLboolean crServerIsRedirectedToFBO();
176GLint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer);
177void crServerMuralFBOSwapBuffers(CRMuralInfo *mural);
178
179void crServerVBoxCompositionDisableEnter(CRMuralInfo *mural);
180void crServerVBoxCompositionDisableLeave(CRMuralInfo *mural, GLboolean fForcePresentOnEnabled);
181void crServerVBoxCompositionPresent(CRMuralInfo *mural);
182DECLINLINE(GLboolean) crServerVBoxCompositionPresentNeeded(CRMuralInfo *mural)
183{
184 return mural->bVisible
185 && mural->width
186 && mural->height
187 && !mural->fRootVrOn ? CrVrScrCompositorEntryIsInList(&mural->CEntry) : CrVrScrCompositorEntryIsInList(&mural->RootVrCEntry);
188}
189
190#define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer)
191#define CR_SERVER_FBO_FB_IDX(_mural) (((_mural)->iBbBuffer + 1) % ((_mural)->cBuffers))
192/* returns a valid index to be used for negative _idx, i.e. for GL_NONE cases */
193//#define CR_SERVER_FBO_ADJUST_IDX(_mural, _idx) ((_idx) >= 0 ? (_idx) : CR_SERVER_FBO_BB_IDX(_mural))
194/* just a helper that uses CR_SERVER_FBO_ADJUST_IDX for getting mural's FBO id for buffer index*/
195//#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_mural)->aidFBOs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
196//#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_mural)->aidColorTexs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
197#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidFBOs[(_idx)] : 0)
198#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidColorTexs[(_idx)] : 0)
199
200int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
201
202PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen);
203
204void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo );
205
206PCR_BLITTER crServerVBoxBlitterGet();
207
208DECLINLINE(void) crServerVBoxBlitterWinInit(CR_BLITTER_WINDOW *win, CRMuralInfo *mural)
209{
210 win->Base.id = mural->spuWindow;
211 win->Base.visualBits = mural->CreateInfo.visualBits;
212 win->width = mural->width;
213 win->height = mural->height;
214}
215
216DECLINLINE(void) crServerVBoxBlitterCtxInit(CR_BLITTER_CONTEXT *ctx, CRContextInfo *ctxInfo)
217{
218 ctx->Base.id = ctxInfo->SpuContext;
219 if (ctx->Base.id < 0)
220 ctx->Base.id = cr_server.MainContextInfo.SpuContext;
221 ctx->Base.visualBits = cr_server.curClient->currentCtxInfo->CreateInfo.visualBits;
222}
223
224/* display worker thread.
225 * see comments for CR_SERVER_RPW struct definition in cr_server.h */
226DECLINLINE(void) crServerXchgI8(int8_t *pu8Val1, int8_t *pu8Val2)
227{
228 int8_t tmp;
229 tmp = *pu8Val1;
230 *pu8Val1 = *pu8Val2;
231 *pu8Val2 = tmp;
232}
233
234#ifdef DEBUG_misha
235# define CR_SERVER_RPW_DEBUG
236#endif
237/* *
238 * _name : Draw, Submitted, Worker, Gpu
239 */
240
241#ifdef CR_SERVER_RPW_DEBUG
242# define crServerRpwEntryDbgVerify(_pE) crServerRpwEntryDbgDoVerify(_pE)
243#else
244# define crServerRpwEntryDbgVerify(_pE) do {} while (0)
245#endif
246
247
248#define CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name) ((_pEntry)->iTex##_name > 0)
249
250#define CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(_pEntry, _name) do { \
251 crServerRpwEntryDbgVerify(_pEntry); \
252 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name)); \
253 (_pEntry)->iTex##_name = -(_pEntry)->iTex##_name; \
254 crServerRpwEntryDbgVerify(_pEntry); \
255 } while (0)
256
257#define CR_SERVER_RPW_ENTRY_TEX_PROMOTE(_pEntry, _fromName, _toName) do { \
258 crServerRpwEntryDbgVerify(_pEntry); \
259 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
260 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
261 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
262 crServerRpwEntryDbgVerify(_pEntry); \
263 } while (0)
264
265#define CR_SERVER_RPW_ENTRY_TEX_XCHG_VALID(_pEntry, _fromName, _toName) do { \
266 crServerRpwEntryDbgVerify(_pEntry); \
267 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
268 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
269 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
270 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
271 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
272 crServerRpwEntryDbgVerify(_pEntry); \
273 } while (0)
274
275
276#define CR_SERVER_RPW_ENTRY_TEX_PROMOTE_KEEPVALID(_pEntry, _fromName, _toName) do { \
277 crServerRpwEntryDbgVerify(_pEntry); \
278 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
279 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
280 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
281 (_pEntry)->iTex##_fromName = -(_pEntry)->iTex##_fromName; \
282 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
283 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
284 crServerRpwEntryDbgVerify(_pEntry); \
285 } while (0)
286
287#define CR_SERVER_RPW_ENTRY_TEX(_pEntry, _name) ((_pEntry)->aidWorkerTexs[(_pEntry)->iTex##_name - 1])
288
289#define CR_SERVER_RPW_ENTRY_PBO_NEXT_ID(_i) (((_i) + 1) % 2)
290#define CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(_pEntry) ((_pEntry)->iCurPBO >= 0)
291#define CR_SERVER_RPW_ENTRY_PBO_CUR(_pEntry) ((_pEntry)->aidPBOs[(_pEntry)->iCurPBO])
292#define CR_SERVER_RPW_ENTRY_PBO_COMPLETED(_pEntry) ((_pEntry)->aidPBOs[CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO)])
293#define CR_SERVER_RPW_ENTRY_PBO_FLIP(_pEntry) do { \
294 (_pEntry)->iCurPBO = CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO); \
295 } while (0)
296
297#ifdef CR_SERVER_RPW_DEBUG
298DECLINLINE(void) crServerRpwEntryDbgDoVerify(CR_SERVER_RPW_ENTRY *pEntry)
299{
300 int tstMask = 0;
301 int8_t iVal;
302 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw));
303
304#define CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(_v) do { \
305 iVal = RT_ABS(_v); \
306 Assert(iVal > 0); \
307 Assert(iVal < 5); \
308 Assert(!(tstMask & (1 << iVal))); \
309 tstMask |= (1 << iVal); \
310 } while (0)
311
312 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexDraw);
313 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexSubmitted);
314 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexWorker);
315 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexGpu);
316 Assert(tstMask == 0x1E);
317}
318#endif
319
320DECLINLINE(bool) crServerRpwIsInitialized(const CR_SERVER_RPW *pWorker)
321{
322 return !!pWorker->ctxId;
323}
324int crServerRpwInit(CR_SERVER_RPW *pWorker);
325int crServerRpwTerm(CR_SERVER_RPW *pWorker);
326DECLINLINE(bool) crServerRpwEntryIsInitialized(const CR_SERVER_RPW_ENTRY *pEntry)
327{
328 return !!pEntry->pfnData;
329}
330int crServerRpwEntryInit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height, PFNCR_SERVER_RPW_DATA pfnData);
331int crServerRpwEntryCleanup(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
332int crServerRpwEntryResize(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height);
333int crServerRpwEntrySubmit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
334int crServerRpwEntryWaitComplete(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
335int crServerRpwEntryCancel(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
336DECLINLINE(void) crServerRpwEntryDrawSettingsToTex(const CR_SERVER_RPW_ENTRY *pEntry, VBOXVR_TEXTURE *pTex)
337{
338 pTex->width = pEntry->Size.cx;
339 pTex->height = pEntry->Size.cy;
340 pTex->target = GL_TEXTURE_2D;
341 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw));
342 pTex->hwid = CR_SERVER_RPW_ENTRY_TEX(pEntry, Draw);
343}
344/**/
345
346typedef struct CR_SERVER_CTX_SWITCH
347{
348 GLuint idDrawFBO, idReadFBO;
349 CRContext *pNewCtx;
350 CRContext *pOldCtx;
351} CR_SERVER_CTX_SWITCH;
352
353DECLINLINE(void) crServerCtxSwitchPrepare(CR_SERVER_CTX_SWITCH *pData, CRContext *pNewCtx)
354{
355 CRMuralInfo *pCurrentMural = cr_server.currentMural;
356 CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo;
357 GLuint idDrawFBO, idReadFBO;
358 CRContext *pCurCtx = pCurCtxInfo ? pCurCtxInfo->pContext : NULL;
359
360 CRASSERT(pCurCtx == crStateGetCurrent());
361
362 if (pCurrentMural)
363 {
364 idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
365 idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
366 }
367 else
368 {
369 idDrawFBO = 0;
370 idReadFBO = 0;
371 }
372
373 crStateSwitchPrepare(pNewCtx, pCurCtx, idDrawFBO, idReadFBO);
374
375 pData->idDrawFBO = idDrawFBO;
376 pData->idReadFBO = idReadFBO;
377 pData->pNewCtx = pNewCtx;
378 pData->pOldCtx = pCurCtx;
379}
380
381DECLINLINE(void) crServerCtxSwitchPostprocess(CR_SERVER_CTX_SWITCH *pData)
382{
383 crStateSwitchPostprocess(pData->pOldCtx, pData->pNewCtx, pData->idDrawFBO, pData->idReadFBO);
384}
385
386void crServerInitTmpCtxDispatch();
387
388//#define VBOX_WITH_CRSERVER_DUMPER
389#ifdef VBOX_WITH_CRSERVER_DUMPER
390void crServerDumpCheckTerm();
391int crServerDumpCheckInit();
392void crServerDumpBuffer(int idx);
393void crServerDumpTextures();
394void crServerDumpShader(GLint id);
395void crServerDumpProgram(GLint id);
396void crServerDumpCurrentProgram();
397void crServerDumpRecompileDumpCurrentProgram();
398void crServerRecompileCurrentProgram();
399void crServerDumpCurrentProgramUniforms();
400void crServerDumpCurrentProgramAttribs();
401void crServerDumpFramesCheck();
402void crServerDumpState();
403void crServerDumpDrawel(const char*pszFormat, ...);
404void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal);
405
406
407extern unsigned long g_CrDbgDumpEnabled;
408extern unsigned long g_CrDbgDumpDraw;
409extern unsigned long g_CrDbgDumpDrawFramesSettings;
410extern unsigned long g_CrDbgDumpDrawFramesAppliedSettings;
411extern unsigned long g_CrDbgDumpDrawFramesCount;
412
413bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper);
414bool crServerDumpFilterOp(unsigned long event, CR_DUMPER *pDumper);
415
416//#define CR_SERVER_DUMP_MASK_OP 0x0000fffc
417//#define CR_SERVER_DUMP_OFF_OP 2
418//
419//#define CR_SERVER_DUMP_MASK_DIR 0x00000003
420//#define CR_SERVER_DUMP_OFF_DIR 0
421//
422//#define CR_SERVER_DUMP_MASK_DMP 0xffff0000
423//#define CR_SERVER_DUMP_OFF_DMP 16
424//
425//#define CR_SERVER_DUMP_MAKE_OP(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_OP))
426//#define CR_SERVER_DUMP_MAKE_DIR(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_DIR))
427//#define CR_SERVER_DUMP_MAKE_DMP(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_DMP))
428//
429//#define CR_SERVER_DUMP_GET_OP(_v) ((_v) & CR_SERVER_DUMP_MASK_OP)
430//#define CR_SERVER_DUMP_GET_DMP(_v) ((_v) & CR_SERVER_DUMP_MASK_DMP)
431//#define CR_SERVER_DUMP_GET_DIR(_v) ((_v) & CR_SERVER_DUMP_MASK_DIR)
432//
433//#define CR_SERVER_DUMP_ISANY_OP(_v1, _v2) (!!(CR_SERVER_DUMP_GET_OP(_v1) & CR_SERVER_DUMP_GET_OP(_v2)))
434//#define CR_SERVER_DUMP_ISANY_DIR(_v1, _v2) (!!(CR_SERVER_DUMP_GET_DIR(_v1) & CR_SERVER_DUMP_GET_DIR(_v2)))
435//#define CR_SERVER_DUMP_ISANY_DMP(_v1, _v2) (!!(CR_SERVER_DUMP_GET_DMP(_v1) & CR_SERVER_DUMP_GET_DMP(_v2)))
436//
437//#define CR_SERVER_DUMP_ISANY_OP(_v1, _v2) ((CR_SERVER_DUMP_GET_OP(_v1) & CR_SERVER_DUMP_GET_OP(_v2)) == CR_SERVER_DUMP_GET_OP(_v2))
438//#define CR_SERVER_DUMP_ISANY_DIR(_v1, _v2) ((CR_SERVER_DUMP_GET_DIR(_v1) & CR_SERVER_DUMP_GET_DIR(_v2)) == CR_SERVER_DUMP_GET_DIR(_v2))
439//#define CR_SERVER_DUMP_ISANY_DMP(_v1, _v2) ((CR_SERVER_DUMP_GET_DMP(_v1) & CR_SERVER_DUMP_GET_DMP(_v2)) == CR_SERVER_DUMP_GET_DMP(_v2))
440//
441//#define CR_SERVER_DUMP_F_DIR_ENTER CR_SERVER_DUMP_MAKE_DIR(0)
442//#define CR_SERVER_DUMP_F_DIR_LEAVE CR_SERVER_DUMP_MAKE_DIR(1)
443//
444//#define CR_SERVER_DUMP_F_OP_DRAW CR_SERVER_DUMP_MAKE_OP(0)
445//#define CR_SERVER_DUMP_F_OP_SWAPBUFFERS CR_SERVER_DUMP_MAKE_OP(1)
446//#define CR_SERVER_DUMP_F_OP_LINK_PROGRAM CR_SERVER_DUMP_MAKE_OP(2)
447//#define CR_SERVER_DUMP_F_OP_COMPILE_PROGRAM CR_SERVER_DUMP_MAKE_OP(3)
448//
449//#define CR_SERVER_DUMP_F_DMP_BUFF CR_SERVER_DUMP_MAKE_DMP(0)
450//#define CR_SERVER_DUMP_F_DMP_TEX CR_SERVER_DUMP_MAKE_DMP(0)
451//#define CR_SERVER_DUMP_F_DMP_PROGRAM CR_SERVER_DUMP_MAKE_DMP(0)
452//#define CR_SERVER_DUMP_F_DMP_PROGRAM_UNIFORMS CR_SERVER_DUMP_MAKE_DMP(0)
453//#define CR_SERVER_DUMP_F_DMP_STATE CR_SERVER_DUMP_MAKE_DMP(0)
454//
455//#define CR_SERVER_DUMP_GET_OP(_v) ((_v) & CR_SERVER_DUMP_MASK_OP)
456//#define CR_SERVER_DUMP_GET_DMP(_v) ((_v) & CR_SERVER_DUMP_MASK_DMP)
457//#define CR_SERVER_DUMP_GET_DIR(_v) ((_v) & CR_SERVER_DUMP_MASK_DIR)
458
459#define CR_SERVER_DUMP_F_DRAW_BUFF_ENTER 0x00000001
460#define CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE 0x00000002
461#define CR_SERVER_DUMP_F_DRAW_STATE_ENTER 0x00000004
462#define CR_SERVER_DUMP_F_DRAW_STATE_LEAVE 0x00000008
463#define CR_SERVER_DUMP_F_DRAW_TEX_ENTER 0x00000010
464#define CR_SERVER_DUMP_F_DRAW_TEX_LEAVE 0x00000020
465#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER 0x00000040
466#define CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE 0x00000080
467#define CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER 0x00000100
468#define CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE 0x00000200
469#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER 0x00000400
470#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE 0x00000800
471
472#define CR_SERVER_DUMP_F_DRAW_ENTER_ALL (CR_SERVER_DUMP_F_DRAW_BUFF_ENTER \
473 | CR_SERVER_DUMP_F_DRAW_TEX_ENTER \
474 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER \
475 | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER \
476 | CR_SERVER_DUMP_F_DRAW_STATE_ENTER \
477 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER)
478
479#define CR_SERVER_DUMP_F_DRAW_LEAVE_ALL (CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE \
480 | CR_SERVER_DUMP_F_DRAW_TEX_LEAVE \
481 | CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE \
482 | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE \
483 | CR_SERVER_DUMP_F_DRAW_STATE_LEAVE \
484 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE)
485
486#define CR_SERVER_DUMP_F_DRAW_ALL (CR_SERVER_DUMP_F_DRAW_ENTER_ALL | CR_SERVER_DUMP_F_DRAW_LEAVE_ALL)
487
488#define CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER 0x00010000
489#define CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE 0x00020000
490#define CR_SERVER_DUMP_F_DRAWEL 0x00100000
491#define CR_SERVER_DUMP_F_COMPILE_SHADER 0x01000000
492#define CR_SERVER_DUMP_F_SHADER_SOURCE 0x02000000
493#define CR_SERVER_DUMP_F_LINK_PROGRAM 0x04000000
494
495
496#define CR_SERVER_DUMP_DEFAULT_FILTER_OP(_ev) ((((_ev) & g_CrDbgDumpDraw) != 0) \
497 || ((_ev) == CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER && g_CrDbgDumpDrawFramesCount))
498
499#define CR_SERVER_DUMP_DEFAULT_FILTER_DMP(_ev) (((_ev) & g_CrDbgDumpDraw) != 0)
500
501#define CR_SERVER_DUMP_FILTER_OP(_ev, _pDumper) (g_CrDbgDumpEnabled && crServerDumpFilterOp((_ev), (_pDumper)))
502#define CR_SERVER_DUMP_FILTER_DMP(_ev, _pDumper) (crServerDumpFilterDmp((_ev), (_pDumper)))
503
504#define CR_SERVER_DUMP_DRAW_ENTER() do { \
505 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAW_ENTER_ALL, cr_server.Recorder.pDumper)) break; \
506 crServerDumpCheckInit(); \
507 crDmpStrF(cr_server.Recorder.pDumper, "==ENTER %s==", __FUNCTION__); \
508 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_STATE_ENTER, cr_server.Recorder.pDumper)) { crServerDumpState(); } \
509 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgram(); } \
510 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramUniforms(); } \
511 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramAttribs(); } \
512 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_ENTER, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
513 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_BUFF_ENTER, cr_server.Recorder.pDumper)) { crServerDumpBuffer(-1); } \
514 crDmpStrF(cr_server.Recorder.pDumper, "==Done ENTER %s==", __FUNCTION__); \
515 } while (0)
516
517#define CR_SERVER_DUMP_DRAW_LEAVE() do { \
518 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAW_LEAVE_ALL, cr_server.Recorder.pDumper)) break; \
519 crServerDumpCheckInit(); \
520 crDmpStrF(cr_server.Recorder.pDumper, "==LEAVE %s==", __FUNCTION__); \
521 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
522 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpBuffer(-1); } \
523 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramUniforms(); } \
524 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramAttribs(); } \
525 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgram(); } \
526 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_STATE_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpState(); } \
527 crDmpStrF(cr_server.Recorder.pDumper, "==Done LEAVE %s==", __FUNCTION__); \
528 } while (0)
529
530#define CR_SERVER_DUMP_COMPILE_SHADER(_id) do { \
531 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_COMPILE_SHADER, cr_server.Recorder.pDumper)) break; \
532 crServerDumpCheckInit(); \
533 crDmpStrF(cr_server.Recorder.pDumper, "== %s", __FUNCTION__); \
534 crServerDumpShader((_id)); \
535 crDmpStrF(cr_server.Recorder.pDumper, "====="); \
536 } while (0)
537
538#define CR_SERVER_DUMP_SHADER_SOURCE(_id) do { \
539 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SHADER_SOURCE, cr_server.Recorder.pDumper)) break; \
540 crServerDumpCheckInit(); \
541 crDmpStrF(cr_server.Recorder.pDumper, "==%s==", __FUNCTION__); \
542 crServerDumpShader((_id)); \
543 crDmpStrF(cr_server.Recorder.pDumper, "==Done %s==", __FUNCTION__); \
544 } while (0)
545
546#define CR_SERVER_DUMP_LINK_PROGRAM(_id) do { \
547 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_LINK_PROGRAM, cr_server.Recorder.pDumper)) break; \
548 crServerDumpCheckInit(); \
549 crDmpStrF(cr_server.Recorder.pDumper, "==%s==", __FUNCTION__); \
550 crServerDumpProgram((_id)); \
551 crDmpStrF(cr_server.Recorder.pDumper, "==Done %s==", __FUNCTION__); \
552 } while (0)
553
554#define CR_SERVER_DUMP_SWAPBUFFERS_ENTER() do { \
555 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER, cr_server.Recorder.pDumper)) break; \
556 crServerDumpCheckInit(); \
557 crDmpStrF(cr_server.Recorder.pDumper, "==ENTER %s==", __FUNCTION__); \
558 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER, cr_server.Recorder.pDumper)) { crServerDumpBuffer(CR_SERVER_FBO_BB_IDX(cr_server.currentMural)); } \
559 if (g_CrDbgDumpDrawFramesCount) { crServerDumpFramesCheck(); } \
560 crDmpStrF(cr_server.Recorder.pDumper, "==Done ENTER %s==", __FUNCTION__); \
561 } while (0)
562
563#define CR_SERVER_DUMP_SWAPBUFFERS_LEAVE() do { \
564 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE, cr_server.Recorder.pDumper)) break; \
565 crDmpStrF(cr_server.Recorder.pDumper, "==LEAVE %s==", __FUNCTION__); \
566 crServerDumpCheckInit(); \
567 crDmpStrF(cr_server.Recorder.pDumper, "==Done LEAVE %s==", __FUNCTION__); \
568 } while (0)
569
570#define CR_SERVER_DUMP_DRAWEL_F(_msg) do { \
571 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
572 crServerDumpCheckInit(); \
573 crDmpStrF(cr_server.Recorder.pDumper, "==%s==", __FUNCTION__); \
574 crServerDumpDrawel _msg; \
575 } while (0)
576
577#define CR_SERVER_DUMP_DRAWEL_V(_index, _pszElFormat, _cbEl, _pvVal, _cVal) do { \
578 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
579 crServerDumpCheckInit(); \
580 crDmpStrF(cr_server.Recorder.pDumper, "==%s==", __FUNCTION__); \
581 crServerDumpDrawelv((_index), (_pszElFormat), (_cbEl), (_pvVal), (_cVal)); \
582 } while (0)
583#else /* if !defined VBOX_WITH_CRSERVER_DUMPER */
584#define CR_SERVER_DUMP_DRAW_ENTER() do {} while (0)
585#define CR_SERVER_DUMP_DRAW_LEAVE() do {} while (0)
586#define CR_SERVER_DUMP_COMPILE_SHADER(_id) do {} while (0)
587#define CR_SERVER_DUMP_LINK_PROGRAM(_id) do {} while (0)
588#define CR_SERVER_DUMP_SWAPBUFFERS_ENTER() do {} while (0)
589#define CR_SERVER_DUMP_SWAPBUFFERS_LEAVE() do {} while (0)
590#define CR_SERVER_DUMP_SHADER_SOURCE(_id) do {} while (0)
591#define CR_SERVER_DUMP_DRAWEL_F(_msg) do {} while (0)
592#define CR_SERVER_DUMP_DRAWEL_V(_index, _pszElFormat, _cbEl, _pvVal, _cVal) do {} while (0)
593#endif /* !VBOX_WITH_CRSERVER_DUMPER */
594
595RT_C_DECLS_END
596
597#endif /* CR_SERVER_H */
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