VirtualBox

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

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

crOpenGL: seamless fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 30.6 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, GLboolean fUseDefaultDEntry);
116void crServerMuralTerm(CRMuralInfo *mural);
117GLboolean crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
118void crServerMuralPosition(CRMuralInfo *mural, GLint x, GLint y, GLboolean fSkipCheckGeometry);
119void crServerMuralVisibleRegion( CRMuralInfo *mural, GLint cRects, const GLint *pRects );
120void crServerMuralShow( CRMuralInfo *mural, GLint state );
121int crServerMuralSynchRootVr(CRMuralInfo *mural, bool *pfChanged);
122
123GLint crServerGenerateID(GLint *pCounter);
124
125GLint crServerSPUWindowID(GLint serverWindow);
126
127GLuint crServerTranslateProgramID(GLuint id);
128
129CRMuralInfo * crServerGetDummyMural(GLint visualBits);
130
131void crServerPresentOutputRedirect(CRMuralInfo *pMural);
132void crServerOutputRedirectCheckEnableDisable(CRMuralInfo *pMural);
133
134void crServerCheckMuralGeometry(CRMuralInfo *mural);
135GLboolean crServerSupportRedirMuralFBO(void);
136
137void crVBoxServerNotifyEvent(int32_t idScreen, uint32_t uEvent, void*pvData);
138void crVBoxServerCheckVisibilityEvent(int32_t idScreen);
139
140void crServerDisplayTermAll();
141
142void crServerWindowSize(CRMuralInfo *pMural);
143void crServerWindowShow(CRMuralInfo *pMural);
144void crServerWindowVisibleRegion(CRMuralInfo *pMural);
145void crServerWindowReparent(CRMuralInfo *pMural);
146
147void crServerWindowSetIsVisible(CRMuralInfo *pMural, GLboolean fIsVisible);
148void crServerWindowCheckIsVisible(CRMuralInfo *pMural);
149
150int crVBoxServerUpdateMuralRootVisibleRegion(CRMuralInfo *pMI);
151
152#define CR_SERVER_REDIR_F_NONE 0x00
153/* the data should be displayed on host (unset when is on or when CR_SERVER_REDIR_F_FBO_RAM_VMFB is set) */
154#define CR_SERVER_REDIR_F_DISPLAY 0x01
155/* guest window data get redirected to FBO on host */
156#define CR_SERVER_REDIR_F_FBO 0x02
157/* used with CR_SERVER_REDIR_F_FBO only
158 * indicates that FBO data should be copied to RAM for further processing */
159#define CR_SERVER_REDIR_F_FBO_RAM 0x04
160/* used with CR_SERVER_REDIR_F_FBO_RAM only
161 * indicates that FBO data should be passed to VRDP backend */
162#define CR_SERVER_REDIR_F_FBO_RAM_VRDP 0x08
163/* used with CR_SERVER_REDIR_F_FBO_RAM only
164 * indicates that FBO data should be passed to VM Framebuffer */
165#define CR_SERVER_REDIR_F_FBO_RAM_VMFB 0x10
166/* used with CR_SERVER_REDIR_F_FBO_RAM only
167 * makes the RPW (Read Pixels Worker) mechanism to be used for GPU memory aquisition */
168#define CR_SERVER_REDIR_F_FBO_RPW 0x20
169
170
171#define CR_SERVER_REDIR_F_ALL 0x3f
172
173#define CR_SERVER_REDIR_FGROUP_REQUIRE_FBO (CR_SERVER_REDIR_F_ALL & ~CR_SERVER_REDIR_F_DISPLAY)
174#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)
175
176DECLINLINE(GLuint) crServerRedirModeAdjust(GLuint value)
177{
178 /* sanitize values */
179 value &= CR_SERVER_REDIR_F_ALL;
180
181 if (value & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO)
182 value |= CR_SERVER_REDIR_F_FBO;
183 if (value & CR_SERVER_REDIR_FGROUP_REQUIRE_FBO_RAM)
184 value |= CR_SERVER_REDIR_F_FBO_RAM;
185
186 return value;
187}
188
189int32_t crServerSetOffscreenRenderingMode(GLuint value);
190void crServerRedirMuralFBO(CRMuralInfo *mural, GLuint redir);
191void crServerDeleteMuralFBO(CRMuralInfo *mural);
192void crServerPresentFBO(CRMuralInfo *mural);
193GLboolean crServerIsRedirectedToFBO();
194GLint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer);
195void crServerMuralFBOSwapBuffers(CRMuralInfo *mural);
196
197void crServerVBoxCompositionDisableEnter(CRMuralInfo *mural);
198void crServerVBoxCompositionDisableLeave(CRMuralInfo *mural, GLboolean fForcePresentOnEnabled);
199void crServerVBoxCompositionPresent(CRMuralInfo *mural);
200DECLINLINE(GLboolean) crServerVBoxCompositionPresentNeeded(CRMuralInfo *mural)
201{
202 return mural->bVisible
203 && mural->width
204 && mural->height
205 && !mural->fRootVrOn ? !CrVrScrCompositorIsEmpty(&mural->Compositor) : !CrVrScrCompositorIsEmpty(&mural->RootVrCompositor);
206}
207
208#define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer)
209#define CR_SERVER_FBO_FB_IDX(_mural) (((_mural)->iBbBuffer + 1) % ((_mural)->cBuffers))
210/* returns a valid index to be used for negative _idx, i.e. for GL_NONE cases */
211//#define CR_SERVER_FBO_ADJUST_IDX(_mural, _idx) ((_idx) >= 0 ? (_idx) : CR_SERVER_FBO_BB_IDX(_mural))
212/* just a helper that uses CR_SERVER_FBO_ADJUST_IDX for getting mural's FBO id for buffer index*/
213//#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_mural)->aidFBOs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
214//#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_mural)->aidColorTexs[CR_SERVER_FBO_ADJUST_IDX((_mural), (_idx))])
215#define CR_SERVER_FBO_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidFBOs[(_idx)] : 0)
216#define CR_SERVER_FBO_TEX_FOR_IDX(_mural, _idx) ((_idx) >= 0 ? (_mural)->aidColorTexs[(_idx)] : 0)
217
218int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
219
220PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen);
221
222void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo );
223
224PCR_BLITTER crServerVBoxBlitterGet();
225
226DECLINLINE(void) crServerVBoxBlitterWinInit(CR_BLITTER_WINDOW *win, CRMuralInfo *mural)
227{
228 win->Base.id = mural->spuWindow;
229 win->Base.visualBits = mural->CreateInfo.visualBits;
230 win->width = mural->width;
231 win->height = mural->height;
232}
233
234DECLINLINE(void) crServerVBoxBlitterCtxInit(CR_BLITTER_CONTEXT *ctx, CRContextInfo *ctxInfo)
235{
236 ctx->Base.id = ctxInfo->SpuContext;
237 if (ctx->Base.id < 0)
238 ctx->Base.id = cr_server.MainContextInfo.SpuContext;
239 ctx->Base.visualBits = cr_server.curClient->currentCtxInfo->CreateInfo.visualBits;
240}
241
242/* display worker thread.
243 * see comments for CR_SERVER_RPW struct definition in cr_server.h */
244DECLINLINE(void) crServerXchgI8(int8_t *pu8Val1, int8_t *pu8Val2)
245{
246 int8_t tmp;
247 tmp = *pu8Val1;
248 *pu8Val1 = *pu8Val2;
249 *pu8Val2 = tmp;
250}
251
252#ifdef DEBUG_misha
253# define CR_SERVER_RPW_DEBUG
254#endif
255/* *
256 * _name : Draw, Submitted, Worker, Gpu
257 */
258
259#ifdef CR_SERVER_RPW_DEBUG
260# define crServerRpwEntryDbgVerify(_pE) crServerRpwEntryDbgDoVerify(_pE)
261#else
262# define crServerRpwEntryDbgVerify(_pE) do {} while (0)
263#endif
264
265
266#define CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name) ((_pEntry)->iTex##_name > 0)
267
268#define CR_SERVER_RPW_ENTRY_TEX_INVALIDATE(_pEntry, _name) do { \
269 crServerRpwEntryDbgVerify(_pEntry); \
270 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _name)); \
271 (_pEntry)->iTex##_name = -(_pEntry)->iTex##_name; \
272 crServerRpwEntryDbgVerify(_pEntry); \
273 } while (0)
274
275#define CR_SERVER_RPW_ENTRY_TEX_PROMOTE(_pEntry, _fromName, _toName) do { \
276 crServerRpwEntryDbgVerify(_pEntry); \
277 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
278 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
279 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
280 crServerRpwEntryDbgVerify(_pEntry); \
281 } while (0)
282
283#define CR_SERVER_RPW_ENTRY_TEX_XCHG_VALID(_pEntry, _fromName, _toName) do { \
284 crServerRpwEntryDbgVerify(_pEntry); \
285 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
286 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
287 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
288 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
289 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
290 crServerRpwEntryDbgVerify(_pEntry); \
291 } while (0)
292
293
294#define CR_SERVER_RPW_ENTRY_TEX_PROMOTE_KEEPVALID(_pEntry, _fromName, _toName) do { \
295 crServerRpwEntryDbgVerify(_pEntry); \
296 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
297 Assert(!CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
298 crServerXchgI8(&(_pEntry)->iTex##_fromName, &(_pEntry)->iTex##_toName); \
299 (_pEntry)->iTex##_fromName = -(_pEntry)->iTex##_fromName; \
300 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _fromName)); \
301 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(_pEntry, _toName)); \
302 crServerRpwEntryDbgVerify(_pEntry); \
303 } while (0)
304
305#define CR_SERVER_RPW_ENTRY_TEX(_pEntry, _name) ((_pEntry)->aidWorkerTexs[(_pEntry)->iTex##_name - 1])
306
307#define CR_SERVER_RPW_ENTRY_PBO_NEXT_ID(_i) (((_i) + 1) % 2)
308#define CR_SERVER_RPW_ENTRY_PBO_IS_ACTIVE(_pEntry) ((_pEntry)->iCurPBO >= 0)
309#define CR_SERVER_RPW_ENTRY_PBO_CUR(_pEntry) ((_pEntry)->aidPBOs[(_pEntry)->iCurPBO])
310#define CR_SERVER_RPW_ENTRY_PBO_COMPLETED(_pEntry) ((_pEntry)->aidPBOs[CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO)])
311#define CR_SERVER_RPW_ENTRY_PBO_FLIP(_pEntry) do { \
312 (_pEntry)->iCurPBO = CR_SERVER_RPW_ENTRY_PBO_NEXT_ID((_pEntry)->iCurPBO); \
313 } while (0)
314
315#ifdef CR_SERVER_RPW_DEBUG
316DECLINLINE(void) crServerRpwEntryDbgDoVerify(CR_SERVER_RPW_ENTRY *pEntry)
317{
318 int tstMask = 0;
319 int8_t iVal;
320 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw));
321
322#define CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(_v) do { \
323 iVal = RT_ABS(_v); \
324 Assert(iVal > 0); \
325 Assert(iVal < 5); \
326 Assert(!(tstMask & (1 << iVal))); \
327 tstMask |= (1 << iVal); \
328 } while (0)
329
330 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexDraw);
331 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexSubmitted);
332 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexWorker);
333 CR_VERVER_RPW_ENTRY_DBG_CHECKVAL(pEntry->iTexGpu);
334 Assert(tstMask == 0x1E);
335}
336#endif
337
338DECLINLINE(bool) crServerRpwIsInitialized(const CR_SERVER_RPW *pWorker)
339{
340 return !!pWorker->ctxId;
341}
342int crServerRpwInit(CR_SERVER_RPW *pWorker);
343int crServerRpwTerm(CR_SERVER_RPW *pWorker);
344DECLINLINE(bool) crServerRpwEntryIsInitialized(const CR_SERVER_RPW_ENTRY *pEntry)
345{
346 return !!pEntry->pfnData;
347}
348int crServerRpwEntryInit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height, PFNCR_SERVER_RPW_DATA pfnData);
349int crServerRpwEntryCleanup(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
350int crServerRpwEntryResize(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry, uint32_t width, uint32_t height);
351int crServerRpwEntrySubmit(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
352int crServerRpwEntryWaitComplete(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
353int crServerRpwEntryCancel(CR_SERVER_RPW *pWorker, CR_SERVER_RPW_ENTRY *pEntry);
354DECLINLINE(void) crServerRpwEntryDrawSettingsToTex(const CR_SERVER_RPW_ENTRY *pEntry, VBOXVR_TEXTURE *pTex)
355{
356 pTex->width = pEntry->Size.cx;
357 pTex->height = pEntry->Size.cy;
358 pTex->target = GL_TEXTURE_2D;
359 Assert(CR_SERVER_RPW_ENTRY_TEX_IS_VALID(pEntry, Draw));
360 pTex->hwid = CR_SERVER_RPW_ENTRY_TEX(pEntry, Draw);
361}
362/**/
363
364typedef struct CR_SERVER_CTX_SWITCH
365{
366 GLuint idDrawFBO, idReadFBO;
367 CRContext *pNewCtx;
368 CRContext *pOldCtx;
369} CR_SERVER_CTX_SWITCH;
370
371DECLINLINE(void) crServerCtxSwitchPrepare(CR_SERVER_CTX_SWITCH *pData, CRContext *pNewCtx)
372{
373 CRMuralInfo *pCurrentMural = cr_server.currentMural;
374 CRContextInfo *pCurCtxInfo = cr_server.currentCtxInfo;
375 GLuint idDrawFBO, idReadFBO;
376 CRContext *pCurCtx = pCurCtxInfo ? pCurCtxInfo->pContext : NULL;
377
378 CRASSERT(pCurCtx == crStateGetCurrent());
379
380 if (pCurrentMural)
381 {
382 idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
383 idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
384 }
385 else
386 {
387 idDrawFBO = 0;
388 idReadFBO = 0;
389 }
390
391 crStateSwitchPrepare(pNewCtx, pCurCtx, idDrawFBO, idReadFBO);
392
393 pData->idDrawFBO = idDrawFBO;
394 pData->idReadFBO = idReadFBO;
395 pData->pNewCtx = pNewCtx;
396 pData->pOldCtx = pCurCtx;
397}
398
399DECLINLINE(void) crServerCtxSwitchPostprocess(CR_SERVER_CTX_SWITCH *pData)
400{
401 crStateSwitchPostprocess(pData->pOldCtx, pData->pNewCtx, pData->idDrawFBO, pData->idReadFBO);
402}
403
404void crServerInitTmpCtxDispatch();
405
406int crServerVBoxParseNumerics(const char *pszStr, const int defaultVal);
407
408void CrDpRootUpdate(PCR_DISPLAY pDisplay);
409void CrDpEnter(PCR_DISPLAY pDisplay);
410void CrDpLeave(PCR_DISPLAY pDisplay);
411int CrDpInit(PCR_DISPLAY pDisplay);
412void CrDpTerm(PCR_DISPLAY pDisplay);
413
414DECLINLINE(bool) CrDpIsEmpty(PCR_DISPLAY pDisplay)
415{
416 return CrVrScrCompositorIsEmpty(&pDisplay->Mural.Compositor);
417}
418
419int CrDpSaveState(PCR_DISPLAY pDisplay, PSSMHANDLE pSSM);
420int CrDpLoadState(PCR_DISPLAY pDisplay, PSSMHANDLE pSSM, uint32_t version);
421
422void CrDpReparent(PCR_DISPLAY pDisplay, CRScreenInfo *pScreen);
423
424void CrDpResize(PCR_DISPLAY pDisplay, int32_t xPos, int32_t yPos, uint32_t width, uint32_t height);
425void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData, uint32_t fFlags, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
426void CrDpEntryCleanup(PCR_DISPLAY_ENTRY pEntry);
427int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions);
428int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, CR_DISPLAY_ENTRY_MAP *pMap);
429void CrDpRegionsClear(PCR_DISPLAY pDisplay);
430DECLINLINE(bool) CrDpEntryIsUsed(PCR_DISPLAY_ENTRY pEntry)
431{
432 return CrVrScrCompositorEntryIsInList(&pEntry->CEntry);
433}
434
435DECLINLINE(CRMuralInfo*) CrDpGetMural(PCR_DISPLAY pDisplay)
436{
437 return &pDisplay->Mural;
438}
439
440int CrDemGlobalInit();
441void CrDemTeGlobalTerm();
442void CrDemEnter(PCR_DISPLAY_ENTRY_MAP pMap);
443void CrDemLeave(PCR_DISPLAY_ENTRY_MAP pMap, PCR_DISPLAY_ENTRY pNewEntry, PCR_DISPLAY_ENTRY pReplacedEntry);
444int CrDemInit(PCR_DISPLAY_ENTRY_MAP pMap);
445void CrDemTerm(PCR_DISPLAY_ENTRY_MAP pMap);
446PCR_DISPLAY_ENTRY CrDemEntryAcquire(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture, uint32_t fFlags);
447void CrDemEntryRelease(PCR_DISPLAY_ENTRY pEntry);
448int CrDemEntrySaveState(PCR_DISPLAY_ENTRY pEntry, PSSMHANDLE pSSM);
449int CrDemEntryLoadState(PCR_DISPLAY_ENTRY_MAP pMap, PCR_DISPLAY_ENTRY *ppEntry, PSSMHANDLE pSSM);
450
451int crServerDisplaySaveState(PSSMHANDLE pSSM);
452int crServerDisplayLoadState(PSSMHANDLE pSSM, uint32_t u32Version);
453
454
455void crServerDEntryResized(CRMuralInfo *pMural, CR_DISPLAY_ENTRY *pDEntry);
456void crServerDEntryMoved(CRMuralInfo *pMural, CR_DISPLAY_ENTRY *pDEntry);
457void crServerDEntryVibleRegions(CRMuralInfo *pMural, CR_DISPLAY_ENTRY *pDEntry);
458void crServerDEntryCheckFBO(CRMuralInfo *pMural, CR_DISPLAY_ENTRY *pDEntry, CRContext *ctx);
459
460void crServerDEntryAllResized(CRMuralInfo *pMural);
461void crServerDEntryAllMoved(CRMuralInfo *pMural);
462void crServerDEntryAllVibleRegions(CRMuralInfo *pMural);
463
464//#define VBOX_WITH_CRSERVER_DUMPER
465#ifdef VBOX_WITH_CRSERVER_DUMPER
466void crServerDumpCheckTerm();
467int crServerDumpCheckInit();
468void crServerDumpBuffer(int idx);
469void crServerDumpTextures();
470void crServerDumpShader(GLint id);
471void crServerDumpProgram(GLint id);
472void crServerDumpCurrentProgram();
473void crServerDumpRecompileDumpCurrentProgram();
474void crServerRecompileCurrentProgram();
475void crServerDumpCurrentProgramUniforms();
476void crServerDumpCurrentProgramAttribs();
477void crServerDumpFramesCheck();
478void crServerDumpState();
479void crServerDumpDrawel(const char*pszFormat, ...);
480void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal);
481
482extern int64_t g_CrDbgDumpPid;
483extern unsigned long g_CrDbgDumpEnabled;
484extern unsigned long g_CrDbgDumpDraw;
485extern unsigned long g_CrDbgDumpDrawFramesSettings;
486extern unsigned long g_CrDbgDumpDrawFramesAppliedSettings;
487extern unsigned long g_CrDbgDumpDrawFramesCount;
488
489bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper);
490bool crServerDumpFilterOp(unsigned long event, CR_DUMPER *pDumper);
491
492//#define CR_SERVER_DUMP_MASK_OP 0x0000fffc
493//#define CR_SERVER_DUMP_OFF_OP 2
494//
495//#define CR_SERVER_DUMP_MASK_DIR 0x00000003
496//#define CR_SERVER_DUMP_OFF_DIR 0
497//
498//#define CR_SERVER_DUMP_MASK_DMP 0xffff0000
499//#define CR_SERVER_DUMP_OFF_DMP 16
500//
501//#define CR_SERVER_DUMP_MAKE_OP(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_OP))
502//#define CR_SERVER_DUMP_MAKE_DIR(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_DIR))
503//#define CR_SERVER_DUMP_MAKE_DMP(_v) (1 << ((_v) + CR_SERVER_DUMP_OFF_DMP))
504//
505//#define CR_SERVER_DUMP_GET_OP(_v) ((_v) & CR_SERVER_DUMP_MASK_OP)
506//#define CR_SERVER_DUMP_GET_DMP(_v) ((_v) & CR_SERVER_DUMP_MASK_DMP)
507//#define CR_SERVER_DUMP_GET_DIR(_v) ((_v) & CR_SERVER_DUMP_MASK_DIR)
508//
509//#define CR_SERVER_DUMP_ISANY_OP(_v1, _v2) (!!(CR_SERVER_DUMP_GET_OP(_v1) & CR_SERVER_DUMP_GET_OP(_v2)))
510//#define CR_SERVER_DUMP_ISANY_DIR(_v1, _v2) (!!(CR_SERVER_DUMP_GET_DIR(_v1) & CR_SERVER_DUMP_GET_DIR(_v2)))
511//#define CR_SERVER_DUMP_ISANY_DMP(_v1, _v2) (!!(CR_SERVER_DUMP_GET_DMP(_v1) & CR_SERVER_DUMP_GET_DMP(_v2)))
512//
513//#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))
514//#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))
515//#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))
516//
517//#define CR_SERVER_DUMP_F_DIR_ENTER CR_SERVER_DUMP_MAKE_DIR(0)
518//#define CR_SERVER_DUMP_F_DIR_LEAVE CR_SERVER_DUMP_MAKE_DIR(1)
519//
520//#define CR_SERVER_DUMP_F_OP_DRAW CR_SERVER_DUMP_MAKE_OP(0)
521//#define CR_SERVER_DUMP_F_OP_SWAPBUFFERS CR_SERVER_DUMP_MAKE_OP(1)
522//#define CR_SERVER_DUMP_F_OP_LINK_PROGRAM CR_SERVER_DUMP_MAKE_OP(2)
523//#define CR_SERVER_DUMP_F_OP_COMPILE_PROGRAM CR_SERVER_DUMP_MAKE_OP(3)
524//
525//#define CR_SERVER_DUMP_F_DMP_BUFF CR_SERVER_DUMP_MAKE_DMP(0)
526//#define CR_SERVER_DUMP_F_DMP_TEX CR_SERVER_DUMP_MAKE_DMP(0)
527//#define CR_SERVER_DUMP_F_DMP_PROGRAM CR_SERVER_DUMP_MAKE_DMP(0)
528//#define CR_SERVER_DUMP_F_DMP_PROGRAM_UNIFORMS CR_SERVER_DUMP_MAKE_DMP(0)
529//#define CR_SERVER_DUMP_F_DMP_STATE CR_SERVER_DUMP_MAKE_DMP(0)
530//
531//#define CR_SERVER_DUMP_GET_OP(_v) ((_v) & CR_SERVER_DUMP_MASK_OP)
532//#define CR_SERVER_DUMP_GET_DMP(_v) ((_v) & CR_SERVER_DUMP_MASK_DMP)
533//#define CR_SERVER_DUMP_GET_DIR(_v) ((_v) & CR_SERVER_DUMP_MASK_DIR)
534
535#define CR_SERVER_DUMP_F_DRAW_BUFF_ENTER 0x00000001
536#define CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE 0x00000002
537#define CR_SERVER_DUMP_F_DRAW_STATE_ENTER 0x00000004
538#define CR_SERVER_DUMP_F_DRAW_STATE_LEAVE 0x00000008
539#define CR_SERVER_DUMP_F_DRAW_TEX_ENTER 0x00000010
540#define CR_SERVER_DUMP_F_DRAW_TEX_LEAVE 0x00000020
541#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER 0x00000040
542#define CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE 0x00000080
543#define CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER 0x00000100
544#define CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE 0x00000200
545#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER 0x00000400
546#define CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE 0x00000800
547
548#define CR_SERVER_DUMP_F_DRAW_ENTER_ALL (CR_SERVER_DUMP_F_DRAW_BUFF_ENTER \
549 | CR_SERVER_DUMP_F_DRAW_TEX_ENTER \
550 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER \
551 | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER \
552 | CR_SERVER_DUMP_F_DRAW_STATE_ENTER \
553 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER)
554
555#define CR_SERVER_DUMP_F_DRAW_LEAVE_ALL (CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE \
556 | CR_SERVER_DUMP_F_DRAW_TEX_LEAVE \
557 | CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE \
558 | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE \
559 | CR_SERVER_DUMP_F_DRAW_STATE_LEAVE \
560 | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE)
561
562#define CR_SERVER_DUMP_F_DRAW_ALL (CR_SERVER_DUMP_F_DRAW_ENTER_ALL | CR_SERVER_DUMP_F_DRAW_LEAVE_ALL)
563
564#define CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER 0x00010000
565#define CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE 0x00020000
566#define CR_SERVER_DUMP_F_DRAWEL 0x00100000
567#define CR_SERVER_DUMP_F_COMPILE_SHADER 0x01000000
568#define CR_SERVER_DUMP_F_SHADER_SOURCE 0x02000000
569#define CR_SERVER_DUMP_F_LINK_PROGRAM 0x04000000
570
571
572#define CR_SERVER_DUMP_DEFAULT_FILTER_OP(_ev) ((((_ev) & g_CrDbgDumpDraw) != 0) \
573 || ((_ev) == CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER && g_CrDbgDumpDrawFramesCount))
574
575#define CR_SERVER_DUMP_DEFAULT_FILTER_DMP(_ev) (((_ev) & g_CrDbgDumpDraw) != 0)
576
577#define CR_SERVER_DUMP_FILTER_OP(_ev, _pDumper) (g_CrDbgDumpEnabled \
578 && (!g_CrDbgDumpPid \
579 || (g_CrDbgDumpPid > 0 && ((uint64_t)g_CrDbgDumpPid) == cr_server.curClient->pid) \
580 || (g_CrDbgDumpPid < 0 && ((uint64_t)(-g_CrDbgDumpPid)) != cr_server.curClient->pid)) \
581 && crServerDumpFilterOp((_ev), (_pDumper)))
582#define CR_SERVER_DUMP_FILTER_DMP(_ev, _pDumper) (crServerDumpFilterDmp((_ev), (_pDumper)))
583
584#define CR_SERVER_DUMP_DRAW_ENTER() do { \
585 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAW_ENTER_ALL, cr_server.Recorder.pDumper)) break; \
586 crServerDumpCheckInit(); \
587 crDmpStrF(cr_server.Recorder.pDumper, "==ENTER[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
588 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_STATE_ENTER, cr_server.Recorder.pDumper)) { crServerDumpState(); } \
589 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgram(); } \
590 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramUniforms(); } \
591 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramAttribs(); } \
592 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_ENTER, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
593 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_BUFF_ENTER, cr_server.Recorder.pDumper)) { crServerDumpBuffer(-1); } \
594 crDmpStrF(cr_server.Recorder.pDumper, "==Done ENTER[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
595 } while (0)
596
597#define CR_SERVER_DUMP_DRAW_LEAVE() do { \
598 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAW_LEAVE_ALL, cr_server.Recorder.pDumper)) break; \
599 crServerDumpCheckInit(); \
600 crDmpStrF(cr_server.Recorder.pDumper, "==LEAVE[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
601 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_TEX_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpTextures(); } \
602 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpBuffer(-1); } \
603 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramUniforms(); } \
604 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgramAttribs(); } \
605 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_PROGRAM_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpCurrentProgram(); } \
606 if (CR_SERVER_DUMP_FILTER_DMP(CR_SERVER_DUMP_F_DRAW_STATE_LEAVE, cr_server.Recorder.pDumper)) { crServerDumpState(); } \
607 crDmpStrF(cr_server.Recorder.pDumper, "==Done LEAVE[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
608 } while (0)
609
610#define CR_SERVER_DUMP_COMPILE_SHADER(_id) do { \
611 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_COMPILE_SHADER, cr_server.Recorder.pDumper)) break; \
612 crServerDumpCheckInit(); \
613 crDmpStrF(cr_server.Recorder.pDumper, "==[%d] %s", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
614 crServerDumpShader((_id)); \
615 crDmpStrF(cr_server.Recorder.pDumper, "==Done[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
616 } while (0)
617
618#define CR_SERVER_DUMP_SHADER_SOURCE(_id) do { \
619 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SHADER_SOURCE, cr_server.Recorder.pDumper)) break; \
620 crServerDumpCheckInit(); \
621 crDmpStrF(cr_server.Recorder.pDumper, "==[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
622 crServerDumpShader((_id)); \
623 crDmpStrF(cr_server.Recorder.pDumper, "==Done[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
624 } while (0)
625
626#define CR_SERVER_DUMP_LINK_PROGRAM(_id) do { \
627 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_LINK_PROGRAM, cr_server.Recorder.pDumper)) break; \
628 crServerDumpCheckInit(); \
629 crDmpStrF(cr_server.Recorder.pDumper, "==[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
630 crServerDumpProgram((_id)); \
631 crDmpStrF(cr_server.Recorder.pDumper, "==Done[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
632 } while (0)
633
634#define CR_SERVER_DUMP_SWAPBUFFERS_ENTER() do { \
635 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER, cr_server.Recorder.pDumper)) break; \
636 crServerDumpCheckInit(); \
637 crDmpStrF(cr_server.Recorder.pDumper, "==ENTER[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
638 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)); } \
639 if (g_CrDbgDumpDrawFramesCount) { crServerDumpFramesCheck(); } \
640 crDmpStrF(cr_server.Recorder.pDumper, "==Done ENTER[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
641 } while (0)
642
643#define CR_SERVER_DUMP_SWAPBUFFERS_LEAVE() do { \
644 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_SWAPBUFFERS_LEAVE, cr_server.Recorder.pDumper)) break; \
645 crDmpStrF(cr_server.Recorder.pDumper, "==LEAVE[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
646 crServerDumpCheckInit(); \
647 crDmpStrF(cr_server.Recorder.pDumper, "==Done LEAVE[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
648 } while (0)
649
650#define CR_SERVER_DUMP_DRAWEL_F(_msg) do { \
651 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
652 crServerDumpCheckInit(); \
653 crDmpStrF(cr_server.Recorder.pDumper, "==[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
654 crServerDumpDrawel _msg; \
655 } while (0)
656
657#define CR_SERVER_DUMP_DRAWEL_V(_index, _pszElFormat, _cbEl, _pvVal, _cVal) do { \
658 if (!CR_SERVER_DUMP_FILTER_OP(CR_SERVER_DUMP_F_DRAWEL, cr_server.Recorder.pDumper)) break; \
659 crServerDumpCheckInit(); \
660 crDmpStrF(cr_server.Recorder.pDumper, "==[%d] %s==", (uint32_t)cr_server.curClient->pid, __FUNCTION__); \
661 crServerDumpDrawelv((_index), (_pszElFormat), (_cbEl), (_pvVal), (_cVal)); \
662 } while (0)
663#else /* if !defined VBOX_WITH_CRSERVER_DUMPER */
664#define CR_SERVER_DUMP_DRAW_ENTER() do {} while (0)
665#define CR_SERVER_DUMP_DRAW_LEAVE() do {} while (0)
666#define CR_SERVER_DUMP_COMPILE_SHADER(_id) do {} while (0)
667#define CR_SERVER_DUMP_LINK_PROGRAM(_id) do {} while (0)
668#define CR_SERVER_DUMP_SWAPBUFFERS_ENTER() do {} while (0)
669#define CR_SERVER_DUMP_SWAPBUFFERS_LEAVE() do {} while (0)
670#define CR_SERVER_DUMP_SHADER_SOURCE(_id) do {} while (0)
671#define CR_SERVER_DUMP_DRAWEL_F(_msg) do {} while (0)
672#define CR_SERVER_DUMP_DRAWEL_V(_index, _pszElFormat, _cbEl, _pvVal, _cVal) do {} while (0)
673#endif /* !VBOX_WITH_CRSERVER_DUMPER */
674
675RT_C_DECLS_END
676
677#endif /* CR_SERVER_H */
Note: See TracBrowser for help on using the repository browser.

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