VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_protocol.h@ 50613

Last change on this file since 50613 was 50041, checked in by vboxsync, 11 years ago

crOpenGL: crOpenGL: 1. workaround point sprite driver bugs; 2. workaround multi-string shader source driver bug; 3. proper GLhandle for OSX; 4. extended dumping; 5. misc fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 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_PROTOCOL_H
8#define CR_PROTOCOL_H
9
10#include <iprt/types.h>
11#include <iprt/cdefs.h>
12#ifdef DEBUG_misha
13#include "cr_error.h"
14#endif
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/*For now guest is allowed to connect host opengl service if protocol version matches exactly*/
21/*Note: that after any change to this file, or glapi_parser\apispec.txt version should be changed*/
22#define CR_PROTOCOL_VERSION_MAJOR 9
23#define CR_PROTOCOL_VERSION_MINOR 1
24
25/* new TexPresent mechanism is available */
26#define CR_VBOX_CAP_TEX_PRESENT 0x00000001
27/* vbva command submission mechanism supported */
28#define CR_VBOX_CAP_CMDVBVA 0x00000002
29
30
31#define CR_PRESENT_SCREEN_MASK 0xffff
32#define CR_PRESENT_FLAGS_OFFSET 16
33#define CR_PRESENT_FLAGS_MASK 0xffff0000
34#define CR_PRESENT_DEFINE_FLAG(_f) (1 << (CR_PRESENT_FLAGS_OFFSET + _f))
35
36#define CR_PRESENT_FLAG_CLEAR_RECTS CR_PRESENT_DEFINE_FLAG(0)
37#define CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD CR_PRESENT_DEFINE_FLAG(1)
38
39#define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK)
40#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) & CR_PRESENT_FLAGS_MASK)
41
42typedef enum {
43 /* first message types is 'wGL\001', so we can immediately
44 recognize bad message types */
45 CR_MESSAGE_OPCODES = 0x77474c01,
46 CR_MESSAGE_WRITEBACK,
47 CR_MESSAGE_READBACK,
48 CR_MESSAGE_READ_PIXELS,
49 CR_MESSAGE_MULTI_BODY,
50 CR_MESSAGE_MULTI_TAIL,
51 CR_MESSAGE_FLOW_CONTROL,
52 CR_MESSAGE_OOB,
53 CR_MESSAGE_NEWCLIENT,
54 CR_MESSAGE_GATHER,
55 CR_MESSAGE_ERROR,
56 CR_MESSAGE_CRUT,
57 CR_MESSAGE_REDIR_PTR
58} CRMessageType;
59
60typedef union {
61 /* pointers are usually 4 bytes, but on 64-bit machines (Alpha,
62 * SGI-n64, etc.) they are 8 bytes. Pass network pointers around
63 * as an opaque array of bytes, since the interpretation & size of
64 * the pointer only matter to the machine which emitted the
65 * pointer (and will eventually receive the pointer back again) */
66 unsigned int ptrAlign[2];
67 unsigned char ptrSize[8];
68 /* hack to make this packet big */
69 /* unsigned int junk[512]; */
70} CRNetworkPointer;
71
72#if 0 //def DEBUG_misha
73#define CRDBGPTR_SETZ(_p) crMemset((_p), 0, sizeof (CRNetworkPointer))
74#define CRDBGPTR_CHECKZ(_p) do { \
75 CRNetworkPointer _ptr = {0}; \
76 CRASSERT(!crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
77 } while (0)
78#define CRDBGPTR_CHECKNZ(_p) do { \
79 CRNetworkPointer _ptr = {0}; \
80 CRASSERT(crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
81 } while (0)
82# if 0
83# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { \
84 crDebug(_tStr "%d:0x%08x%08x", (_id), (_p)->ptrAlign[1], (_p)->ptrAlign[0]); \
85 } while (0)
86# else
87# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { } while (0)
88# endif
89#define CRDBGPTR_PRINTWB(_id, _p) _CRDBGPTR_PRINT("wbptr:", _id, _p)
90#define CRDBGPTR_PRINTRB(_id, _p) _CRDBGPTR_PRINT("rbptr:", _id, _p)
91#else
92#define CRDBGPTR_SETZ(_p) do { } while (0)
93#define CRDBGPTR_CHECKZ(_p) do { } while (0)
94#define CRDBGPTR_CHECKNZ(_p) do { } while (0)
95#define CRDBGPTR_PRINTWB(_id, _p) do { } while (0)
96#define CRDBGPTR_PRINTRB(_id, _p) do { } while (0)
97#endif
98
99#ifdef VBOX_WITH_CRHGSMI
100typedef struct CRVBOXHGSMI_CMDDATA {
101 union
102 {
103 struct VBOXVDMACMD_CHROMIUM_CMD *pHgsmiCmd;
104 struct VBOXCMDVBVA_CRCMD_CMD *pVbvaCmd;
105 void *pvCmd;
106 };
107 int *pCmdRc;
108 char *pWriteback;
109 unsigned int *pcbWriteback;
110 unsigned int cbWriteback;
111 bool fHgsmiCmd;
112} CRVBOXHGSMI_CMDDATA, *PCRVBOXHGSMI_CMDDATA;
113
114#ifdef DEBUG
115# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { \
116 CRASSERT(!(_pData)->pvCmd == !(_pData)->pCmdRc); \
117 CRASSERT(!(_pData)->pWriteback == !(_pData)->pcbWriteback); \
118 CRASSERT(!(_pData)->pWriteback == !(_pData)->cbWriteback); \
119 if ((_pData)->pWriteback) \
120 { \
121 CRASSERT((_pData)->pvCmd); \
122 } \
123 } while (0)
124
125# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { \
126 CRASSERT(!(_pData)->pvCmd); \
127 CRASSERT(!(_pData)->pCmdRc); \
128 CRASSERT(!(_pData)->pWriteback); \
129 CRASSERT(!(_pData)->pcbWriteback); \
130 CRASSERT(!(_pData)->cbWriteback); \
131 } while (0)
132
133# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { \
134 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
135 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SET(_pData)); \
136 } while (0)
137
138# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { \
139 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
140 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData)); \
141 } while (0)
142#else
143# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { } while (0)
144# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { } while (0)
145# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { } while (0)
146# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { } while (0)
147#endif
148
149#define CRVBOXHGSMI_CMDDATA_IS_HGSMICMD(_pData) (!!(_pData)->fHgsmiCmd)
150#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pvCmd)
151#define CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData) (!!(_pData)->pWriteback)
152
153#define CRVBOXHGSMI_CMDDATA_CLEANUP(_pData) do { \
154 crMemset(_pData, 0, sizeof (CRVBOXHGSMI_CMDDATA)); \
155 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
156 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
157 } while (0)
158
159#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd) do { \
160 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
161 (_pData)->pvCmd = (_pCmd); \
162 (_pData)->pCmdRc = &(_pHdr)->result; \
163 (_pData)->fHgsmiCmd = (_fHgsmiCmd); \
164 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
165 } while (0)
166
167#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb, _fHgsmiCmd) do { \
168 CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd); \
169 (_pData)->pWriteback = (_pWb); \
170 (_pData)->pcbWriteback = (_pcbWb); \
171 (_pData)->cbWriteback = (_cbWb); \
172 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
173 } while (0)
174
175#define CRVBOXHGSMI_CMDDATA_RC(_pData, _rc) do { \
176 *(_pData)->pCmdRc = (_rc); \
177 } while (0)
178#endif
179
180typedef struct {
181 CRMessageType type;
182 unsigned int conn_id;
183} CRMessageHeader;
184
185typedef struct CRMessageOpcodes {
186 CRMessageHeader header;
187 unsigned int numOpcodes;
188} CRMessageOpcodes;
189
190typedef struct CRMessageRedirPtr {
191 CRMessageHeader header;
192 CRMessageHeader* pMessage;
193#ifdef VBOX_WITH_CRHGSMI
194 CRVBOXHGSMI_CMDDATA CmdData;
195#endif
196} CRMessageRedirPtr;
197
198typedef struct CRMessageWriteback {
199 CRMessageHeader header;
200 CRNetworkPointer writeback_ptr;
201} CRMessageWriteback;
202
203typedef struct CRMessageReadback {
204 CRMessageHeader header;
205 CRNetworkPointer writeback_ptr;
206 CRNetworkPointer readback_ptr;
207} CRMessageReadback;
208
209typedef struct CRMessageMulti {
210 CRMessageHeader header;
211} CRMessageMulti;
212
213typedef struct CRMessageFlowControl {
214 CRMessageHeader header;
215 unsigned int credits;
216} CRMessageFlowControl;
217
218typedef struct CRMessageReadPixels {
219 CRMessageHeader header;
220 int width, height;
221 unsigned int bytes_per_row;
222 unsigned int stride;
223 int alignment;
224 int skipRows;
225 int skipPixels;
226 int rowLength;
227 int format;
228 int type;
229 CRNetworkPointer pixels;
230} CRMessageReadPixels;
231
232typedef struct CRMessageNewClient {
233 CRMessageHeader header;
234} CRMessageNewClient;
235
236typedef struct CRMessageGather {
237 CRMessageHeader header;
238 unsigned long offset;
239 unsigned long len;
240} CRMessageGather;
241
242typedef union {
243 CRMessageHeader header;
244 CRMessageOpcodes opcodes;
245 CRMessageRedirPtr redirptr;
246 CRMessageWriteback writeback;
247 CRMessageReadback readback;
248 CRMessageReadPixels readPixels;
249 CRMessageMulti multi;
250 CRMessageFlowControl flowControl;
251 CRMessageNewClient newclient;
252 CRMessageGather gather;
253} CRMessage;
254
255DECLEXPORT(void) crNetworkPointerWrite( CRNetworkPointer *dst, void *src );
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif /* CR_PROTOCOL_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