VirtualBox

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

Last change on this file since 70836 was 69474, checked in by vboxsync, 7 years ago

*: scm updates - header files should have 'svn:keywords=Id Revision' too (doesn't mean they have to use them).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 9.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_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#define CR_CMDVBVA_VERSION 1
21
22#pragma pack(1)
23typedef struct CR_CAPS_INFO
24{
25 uint32_t u32Caps;
26 uint32_t u32CmdVbvaVersion;
27} CR_CAPS_INFO;
28#pragma pack()
29
30
31/*For now guest is allowed to connect host opengl service if protocol version matches exactly*/
32/*Note: that after any change to this file, or glapi_parser\apispec.txt version should be changed*/
33#define CR_PROTOCOL_VERSION_MAJOR 9
34#define CR_PROTOCOL_VERSION_MINOR 1
35
36/* new TexPresent mechanism is available */
37#define CR_VBOX_CAP_TEX_PRESENT 0x00000001
38/* vbva command submission mechanism supported */
39#define CR_VBOX_CAP_CMDVBVA 0x00000002
40/* host supports Command Blocks, i.e. CR_CMDBLOCKBEGIN_OPCODE and CR_CMDBLOCKEND_OPCODE opcodes.
41 * Command Block can be used by guest to prevent clients from blocking each other.
42 * The Command Block allows multiple command buffers to be processed with one run.
43 * Command Block commands have to obey to the following rules:
44 * CR_CMDBLOCKBEGIN_OPCODE - must be the first command in the command buffer, specifying the command block start
45 * CR_CMDBLOCKEND_OPCODE - must be the last command in the command buffer, specifying the command block end
46 * If not placed accordingly, CR_CMDBLOCK** commands are ignored.
47 * Server copies the command block buffer commands to its internal storage
48 * and processes them with one run when the command block end is signalled
49 */
50#define CR_VBOX_CAP_CMDBLOCKS 0x00000004
51/* GetAttribsLocations support */
52#define CR_VBOX_CAP_GETATTRIBSLOCATIONS 0x00000008
53/* flush command blocks for execution */
54#define CR_VBOX_CAP_CMDBLOCKS_FLUSH 0x00000010
55/* Notify guest if host reports minimal OpenGL capabilities. */
56#define CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT 0x00000020
57
58#define CR_VBOX_CAPS_ALL 0x0000003f
59
60
61#define CR_PRESENT_SCREEN_MASK 0xffff
62#define CR_PRESENT_FLAGS_OFFSET 16
63#define CR_PRESENT_FLAGS_MASK 0xffff0000
64#define CR_PRESENT_DEFINE_FLAG(_f) (1 << (CR_PRESENT_FLAGS_OFFSET + _f))
65
66#define CR_PRESENT_FLAG_CLEAR_RECTS CR_PRESENT_DEFINE_FLAG(0)
67#define CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD CR_PRESENT_DEFINE_FLAG(1)
68
69#define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK)
70#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) & CR_PRESENT_FLAGS_MASK)
71
72typedef enum {
73 /* first message types is 'wGL\001', so we can immediately
74 recognize bad message types */
75 CR_MESSAGE_OPCODES = 0x77474c01,
76 CR_MESSAGE_WRITEBACK,
77 CR_MESSAGE_READBACK,
78 CR_MESSAGE_READ_PIXELS,
79 CR_MESSAGE_MULTI_BODY,
80 CR_MESSAGE_MULTI_TAIL,
81 CR_MESSAGE_FLOW_CONTROL,
82 CR_MESSAGE_OOB,
83 CR_MESSAGE_NEWCLIENT,
84 CR_MESSAGE_GATHER,
85 CR_MESSAGE_ERROR,
86 CR_MESSAGE_CRUT,
87 CR_MESSAGE_REDIR_PTR
88} CRMessageType;
89
90typedef union {
91 /* pointers are usually 4 bytes, but on 64-bit machines (Alpha,
92 * SGI-n64, etc.) they are 8 bytes. Pass network pointers around
93 * as an opaque array of bytes, since the interpretation & size of
94 * the pointer only matter to the machine which emitted the
95 * pointer (and will eventually receive the pointer back again) */
96 unsigned int ptrAlign[2];
97 unsigned char ptrSize[8];
98 /* hack to make this packet big */
99 /* unsigned int junk[512]; */
100} CRNetworkPointer;
101
102#if 0 /*def DEBUG_misha*/
103#define CRDBGPTR_SETZ(_p) crMemset((_p), 0, sizeof (CRNetworkPointer))
104#define CRDBGPTR_CHECKZ(_p) do { \
105 CRNetworkPointer _ptr = {0}; \
106 CRASSERT(!crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
107 } while (0)
108#define CRDBGPTR_CHECKNZ(_p) do { \
109 CRNetworkPointer _ptr = {0}; \
110 CRASSERT(crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \
111 } while (0)
112# if 0
113# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { \
114 crDebug(_tStr "%d:0x%08x%08x", (_id), (_p)->ptrAlign[1], (_p)->ptrAlign[0]); \
115 } while (0)
116# else
117# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { } while (0)
118# endif
119#define CRDBGPTR_PRINTWB(_id, _p) _CRDBGPTR_PRINT("wbptr:", _id, _p)
120#define CRDBGPTR_PRINTRB(_id, _p) _CRDBGPTR_PRINT("rbptr:", _id, _p)
121#else
122#define CRDBGPTR_SETZ(_p) do { } while (0)
123#define CRDBGPTR_CHECKZ(_p) do { } while (0)
124#define CRDBGPTR_CHECKNZ(_p) do { } while (0)
125#define CRDBGPTR_PRINTWB(_id, _p) do { } while (0)
126#define CRDBGPTR_PRINTRB(_id, _p) do { } while (0)
127#endif
128
129#ifdef VBOX_WITH_CRHGSMI
130typedef struct CRVBOXHGSMI_CMDDATA {
131 union
132 {
133 struct VBOXVDMACMD_CHROMIUM_CMD *pHgsmiCmd;
134 struct VBOXCMDVBVA_CRCMD_CMD *pVbvaCmd;
135 const void *pvCmd;
136 };
137 int *pCmdRc;
138 char *pWriteback;
139 unsigned int *pcbWriteback;
140 unsigned int cbWriteback;
141 bool fHgsmiCmd;
142} CRVBOXHGSMI_CMDDATA, *PCRVBOXHGSMI_CMDDATA;
143
144#ifdef DEBUG
145# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { \
146 CRASSERT(!(_pData)->pvCmd == !(_pData)->pCmdRc); \
147 CRASSERT(!(_pData)->pWriteback == !(_pData)->pcbWriteback); \
148 CRASSERT(!(_pData)->pWriteback == !(_pData)->cbWriteback); \
149 if ((_pData)->pWriteback) \
150 { \
151 CRASSERT((_pData)->pvCmd); \
152 } \
153 } while (0)
154
155# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { \
156 CRASSERT(!(_pData)->pvCmd); \
157 CRASSERT(!(_pData)->pCmdRc); \
158 CRASSERT(!(_pData)->pWriteback); \
159 CRASSERT(!(_pData)->pcbWriteback); \
160 CRASSERT(!(_pData)->cbWriteback); \
161 } while (0)
162
163# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { \
164 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
165 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SET(_pData)); \
166 } while (0)
167
168# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { \
169 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
170 CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData)); \
171 } while (0)
172#else
173# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { } while (0)
174# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { } while (0)
175# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { } while (0)
176# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { } while (0)
177#endif
178
179#define CRVBOXHGSMI_CMDDATA_IS_HGSMICMD(_pData) (!!(_pData)->fHgsmiCmd)
180#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pvCmd)
181#define CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData) (!!(_pData)->pWriteback)
182
183#define CRVBOXHGSMI_CMDDATA_CLEANUP(_pData) do { \
184 crMemset(_pData, 0, sizeof (CRVBOXHGSMI_CMDDATA)); \
185 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
186 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
187 } while (0)
188
189#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd) do { \
190 CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
191 (_pData)->pvCmd = (_pCmd); \
192 (_pData)->pCmdRc = &(_pHdr)->result; \
193 (_pData)->fHgsmiCmd = (_fHgsmiCmd); \
194 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
195 } while (0)
196
197#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb, _fHgsmiCmd) do { \
198 CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd); \
199 (_pData)->pWriteback = (_pWb); \
200 (_pData)->pcbWriteback = (_pcbWb); \
201 (_pData)->cbWriteback = (_cbWb); \
202 CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
203 } while (0)
204
205#define CRVBOXHGSMI_CMDDATA_RC(_pData, _rc) do { \
206 *(_pData)->pCmdRc = (_rc); \
207 } while (0)
208#endif
209
210typedef struct {
211 CRMessageType type;
212 unsigned int conn_id;
213} CRMessageHeader;
214
215typedef struct CRMessageOpcodes {
216 CRMessageHeader header;
217 unsigned int numOpcodes;
218} CRMessageOpcodes;
219
220typedef struct CRMessageRedirPtr {
221 CRMessageHeader header;
222 CRMessageHeader* pMessage;
223#ifdef VBOX_WITH_CRHGSMI
224 CRVBOXHGSMI_CMDDATA CmdData;
225#endif
226} CRMessageRedirPtr;
227
228typedef struct CRMessageWriteback {
229 CRMessageHeader header;
230 CRNetworkPointer writeback_ptr;
231} CRMessageWriteback;
232
233typedef struct CRMessageReadback {
234 CRMessageHeader header;
235 CRNetworkPointer writeback_ptr;
236 CRNetworkPointer readback_ptr;
237} CRMessageReadback;
238
239typedef struct CRMessageMulti {
240 CRMessageHeader header;
241} CRMessageMulti;
242
243typedef struct CRMessageFlowControl {
244 CRMessageHeader header;
245 unsigned int credits;
246} CRMessageFlowControl;
247
248typedef struct CRMessageReadPixels {
249 CRMessageHeader header;
250 int width, height;
251 unsigned int bytes_per_row;
252 unsigned int stride;
253 int alignment;
254 int skipRows;
255 int skipPixels;
256 int rowLength;
257 int format;
258 int type;
259 CRNetworkPointer pixels;
260} CRMessageReadPixels;
261
262typedef struct CRMessageNewClient {
263 CRMessageHeader header;
264} CRMessageNewClient;
265
266typedef struct CRMessageGather {
267 CRMessageHeader header;
268 unsigned long offset;
269 unsigned long len;
270} CRMessageGather;
271
272typedef union {
273 CRMessageHeader header;
274 CRMessageOpcodes opcodes;
275 CRMessageRedirPtr redirptr;
276 CRMessageWriteback writeback;
277 CRMessageReadback readback;
278 CRMessageReadPixels readPixels;
279 CRMessageMulti multi;
280 CRMessageFlowControl flowControl;
281 CRMessageNewClient newclient;
282 CRMessageGather gather;
283} CRMessage;
284
285DECLEXPORT(void) crNetworkPointerWrite( CRNetworkPointer *dst, void *src );
286
287#ifdef __cplusplus
288}
289#endif
290
291#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