VirtualBox

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

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

crOpenGL: getAttribLocations

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