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 |
|
---|
23 | RT_C_DECLS_BEGIN
|
---|
24 |
|
---|
25 | extern uint8_t* g_pvVRamBase;
|
---|
26 | extern uint32_t g_cbVRam;
|
---|
27 | extern HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion;
|
---|
28 | extern 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 |
|
---|
33 | DECLINLINE(void*) crServerCrHgsmiPtrGet(VBOXVIDEOOFFSET offBuffer, uint32_t cbBuffer)
|
---|
34 | {
|
---|
35 | return ((offBuffer) + (cbBuffer) <= g_cbVRam ? VBOXCRHGSMI_PTR(offBuffer, void) : NULL);
|
---|
36 | }
|
---|
37 |
|
---|
38 | DECLINLINE(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 |
|
---|
62 | extern CRServer cr_server;
|
---|
63 |
|
---|
64 | /* Semaphore wait queue node */
|
---|
65 | typedef struct _wqnode {
|
---|
66 | RunQueue *q;
|
---|
67 | struct _wqnode *next;
|
---|
68 | } wqnode;
|
---|
69 |
|
---|
70 | typedef struct {
|
---|
71 | GLuint count;
|
---|
72 | GLuint num_waiting;
|
---|
73 | RunQueue **waiting;
|
---|
74 | } CRServerBarrier;
|
---|
75 |
|
---|
76 | typedef struct {
|
---|
77 | GLuint count;
|
---|
78 | wqnode *waiting, *tail;
|
---|
79 | } CRServerSemaphore;
|
---|
80 |
|
---|
81 | typedef struct {
|
---|
82 | GLuint id;
|
---|
83 | GLint projParamStart;
|
---|
84 | GLfloat projMat[16]; /* projection matrix, accumulated via calls to */
|
---|
85 | /* glProgramLocalParameterARB, glProgramParameterNV */
|
---|
86 | } CRServerProgram;
|
---|
87 |
|
---|
88 | void crServerSetVBoxConfiguration();
|
---|
89 | void crServerSetVBoxConfigurationHGCM();
|
---|
90 | void crServerInitDispatch(void);
|
---|
91 | void crServerReturnValue( const void *payload, unsigned int payload_len );
|
---|
92 | void crServerWriteback(void);
|
---|
93 | int crServerRecv( CRConnection *conn, CRMessage *msg, unsigned int len );
|
---|
94 | void crServerSerializeRemoteStreams(void);
|
---|
95 | void crServerAddToRunQueue( CRClient *client );
|
---|
96 | void crServerDeleteClient( CRClient *client );
|
---|
97 |
|
---|
98 |
|
---|
99 | void crServerApplyBaseProjection( const CRmatrix *baseProj );
|
---|
100 | void crServerApplyViewMatrix( const CRmatrix *view );
|
---|
101 | void crServerSetOutputBounds( const CRMuralInfo *mural, int extNum );
|
---|
102 | void crServerComputeViewportBounds( const CRViewportState *v, CRMuralInfo *mural );
|
---|
103 |
|
---|
104 | GLboolean crServerInitializeBucketing(CRMuralInfo *mural);
|
---|
105 |
|
---|
106 | void crComputeOverlapGeom(double *quads, int nquad, CRPoly ***res);
|
---|
107 | void crComputeKnockoutGeom(double *quads, int nquad, int my_quad_idx, CRPoly **res);
|
---|
108 |
|
---|
109 | int crServerGetCurrentEye(void);
|
---|
110 |
|
---|
111 | GLboolean crServerClientInBeginEnd(const CRClient *client);
|
---|
112 |
|
---|
113 | GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID);
|
---|
114 | GLint crServerDispatchWindowCreateEx(const char *dpyName, GLint visBits, GLint preloadWinID);
|
---|
115 | GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID);
|
---|
116 | void crServerMuralTerm(CRMuralInfo *mural);
|
---|
117 | void crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height);
|
---|
118 | int crServerMuralSynchRootVr(CRMuralInfo *mural, uint32_t *pcRects, const RTRECT **ppRects);
|
---|
119 |
|
---|
120 | GLint crServerGenerateID(GLint *pCounter);
|
---|
121 |
|
---|
122 | GLint crServerSPUWindowID(GLint serverWindow);
|
---|
123 |
|
---|
124 | GLuint crServerTranslateProgramID(GLuint id);
|
---|
125 |
|
---|
126 | CRMuralInfo * crServerGetDummyMural(GLint visualBits);
|
---|
127 |
|
---|
128 | void crServerSetupOutputRedirect(CRMuralInfo *mural);
|
---|
129 | void crServerCheckMuralGeometry(CRMuralInfo *mural);
|
---|
130 | GLboolean crServerSupportRedirMuralFBO(void);
|
---|
131 |
|
---|
132 | #define CR_SERVER_REDIR_NONE 0
|
---|
133 | #define CR_SERVER_REDIR_FBO_BLT 1
|
---|
134 | #define CR_SERVER_REDIR_FBO_RAM 2
|
---|
135 | #define CR_SERVER_REDIR_MAXVAL CR_SERVER_REDIR_FBO_RAM
|
---|
136 |
|
---|
137 | int32_t crServerSetOffscreenRenderingMode(GLubyte value);
|
---|
138 | void crServerRedirMuralFBO(CRMuralInfo *mural, GLubyte redir);
|
---|
139 | void crServerDeleteMuralFBO(CRMuralInfo *mural);
|
---|
140 | void crServerPresentFBO(CRMuralInfo *mural);
|
---|
141 | GLboolean crServerIsRedirectedToFBO();
|
---|
142 | GLuint crServerMuralFBOIdxFromBufferName(CRMuralInfo *mural, GLenum buffer);
|
---|
143 | void crServerMuralFBOSwapBuffers(CRMuralInfo *mural);
|
---|
144 |
|
---|
145 | void crServerVBoxCompositionDisableEnter(CRMuralInfo *mural);
|
---|
146 | void crServerVBoxCompositionDisableLeave(CRMuralInfo *mural, GLboolean fForcePresentOnEnabled);
|
---|
147 | void crServerVBoxCompositionPresent(CRMuralInfo *mural);
|
---|
148 | DECLINLINE(GLboolean) crServerVBoxCompositionPresentNeeded(CRMuralInfo *mural)
|
---|
149 | {
|
---|
150 | return mural->bVisible
|
---|
151 | && mural->width
|
---|
152 | && mural->height
|
---|
153 | && !mural->fRootVrOn ? CrVrScrCompositorEntryIsInList(&mural->CEntry) : CrVrScrCompositorEntryIsInList(&mural->RootVrCEntry);
|
---|
154 | }
|
---|
155 |
|
---|
156 | #define CR_SERVER_FBO_BB_IDX(_mural) ((_mural)->iBbBuffer)
|
---|
157 | #define CR_SERVER_FBO_FB_IDX(_mural) (((_mural)->iBbBuffer + 1) % ((_mural)->cBuffers))
|
---|
158 |
|
---|
159 | int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer);
|
---|
160 |
|
---|
161 | PCR_DISPLAY crServerDisplayGetInitialized(uint32_t idScreen);
|
---|
162 |
|
---|
163 | void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo );
|
---|
164 |
|
---|
165 | RT_C_DECLS_END
|
---|
166 |
|
---|
167 | #endif /* CR_SERVER_H */
|
---|