VirtualBox

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

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

crOpenGL: command blocks flushing

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