VirtualBox

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

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

crOpenGL: more extended flexible caps info, backwards compatibility fixes

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