svga_cmd.h revision 848b8605
1/**********************************************************
2 * Copyright 2008-2009 VMware, Inc.  All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26/*
27 * svga_cmd.h --
28 *
29 *      Command construction utility for the SVGA3D protocol used by
30 *      the VMware SVGA device, based on the svgautil library.
31 */
32
33#ifndef __SVGA3D_H__
34#define __SVGA3D_H__
35
36
37#include "svga_types.h"
38#include "svga_reg.h"
39#include "svga3d_reg.h"
40
41#include "pipe/p_defines.h"
42
43
44struct pipe_surface;
45struct svga_transfer;
46struct svga_winsys_context;
47struct svga_winsys_buffer;
48struct svga_winsys_surface;
49struct svga_winsys_gb_shader;
50
51
52/*
53 * SVGA Device Interoperability
54 */
55
56void *
57SVGA3D_FIFOReserve(struct svga_winsys_context *swc, uint32 cmd, uint32 cmdSize, uint32 nr_relocs);
58
59void
60SVGA_FIFOCommitAll(struct svga_winsys_context *swc);
61
62
63/*
64 * Context Management
65 */
66
67enum pipe_error
68SVGA3D_DefineContext(struct svga_winsys_context *swc);
69
70enum pipe_error
71SVGA3D_DestroyContext(struct svga_winsys_context *swc);
72
73
74/*
75 * Surface Management
76 */
77
78enum pipe_error
79SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
80                          struct svga_winsys_surface *sid,
81                          SVGA3dSurfaceFlags flags,
82                          SVGA3dSurfaceFormat format,
83                          SVGA3dSurfaceFace **faces,
84                          SVGA3dSize **mipSizes,
85                          uint32 numMipSizes);
86enum pipe_error
87SVGA3D_DefineSurface2D(struct svga_winsys_context *swc,
88                       struct svga_winsys_surface *sid,
89                       uint32 width,
90                       uint32 height,
91                       SVGA3dSurfaceFormat format);
92enum pipe_error
93SVGA3D_DestroySurface(struct svga_winsys_context *swc,
94                      struct svga_winsys_surface *sid);
95
96
97/*
98 * Surface Operations
99 */
100
101enum pipe_error
102SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
103                  struct svga_transfer *st,
104                  SVGA3dTransferType transfer,
105                  const SVGA3dCopyBox *boxes,
106                  uint32 numBoxes,
107                  SVGA3dSurfaceDMAFlags flags);
108
109enum pipe_error
110SVGA3D_BufferDMA(struct svga_winsys_context *swc,
111                 struct svga_winsys_buffer *guest,
112                 struct svga_winsys_surface *host,
113                 SVGA3dTransferType transfer,
114                 uint32 size,
115                 uint32 guest_offset,
116                 uint32 host_offset,
117                 SVGA3dSurfaceDMAFlags flags);
118
119/*
120 * Drawing Operations
121 */
122
123
124enum pipe_error
125SVGA3D_BeginClear(struct svga_winsys_context *swc,
126                  SVGA3dClearFlag flags,
127                  uint32 color, float depth, uint32 stencil,
128                  SVGA3dRect **rects, uint32 numRects);
129
130enum pipe_error
131SVGA3D_ClearRect(struct svga_winsys_context *swc,
132                 SVGA3dClearFlag flags, uint32 color, float depth,
133                 uint32 stencil, uint32 x, uint32 y, uint32 w, uint32 h);
134
135enum pipe_error
136SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
137                           SVGA3dVertexDecl **decls,
138                           uint32 numVertexDecls,
139                           SVGA3dPrimitiveRange **ranges,
140                           uint32 numRanges);
141
142/*
143 * Blits
144 */
145
146enum pipe_error
147SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
148                        struct pipe_surface *src,
149                        struct pipe_surface *dest,
150                        SVGA3dCopyBox **boxes, uint32 numBoxes);
151
152
153enum pipe_error
154SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
155                         struct pipe_surface *src,
156                         struct pipe_surface *dest,
157                         SVGA3dBox *boxSrc, SVGA3dBox *boxDest,
158                         SVGA3dStretchBltMode mode);
159
160/*
161 * Shared FFP/Shader Render State
162 */
163
164enum pipe_error
165SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
166                       SVGA3dRenderTargetType type,
167                       struct pipe_surface *surface);
168
169enum pipe_error
170SVGA3D_SetZRange(struct svga_winsys_context *swc,
171                 float zMin, float zMax);
172
173enum pipe_error
174SVGA3D_SetViewport(struct svga_winsys_context *swc,
175                   SVGA3dRect *rect);
176
177enum pipe_error
178SVGA3D_SetScissorRect(struct svga_winsys_context *swc,
179                      SVGA3dRect *rect);
180
181enum pipe_error
182SVGA3D_SetClipPlane(struct svga_winsys_context *swc,
183                    uint32 index, const float *plane);
184
185enum pipe_error
186SVGA3D_BeginSetTextureState(struct svga_winsys_context *swc,
187                            SVGA3dTextureState **states,
188                            uint32 numStates);
189
190enum pipe_error
191SVGA3D_BeginSetRenderState(struct svga_winsys_context *swc,
192                           SVGA3dRenderState **states,
193                           uint32 numStates);
194
195
196/*
197 * Shaders
198 */
199
200enum pipe_error
201SVGA3D_DefineShader(struct svga_winsys_context *swc,
202                    uint32 shid, SVGA3dShaderType type,
203                    const uint32 *bytecode, uint32 bytecodeLen);
204
205enum pipe_error
206SVGA3D_DestroyShader(struct svga_winsys_context *swc,
207                     uint32 shid, SVGA3dShaderType type);
208
209enum pipe_error
210SVGA3D_SetShaderConst(struct svga_winsys_context *swc,
211                      uint32 reg, SVGA3dShaderType type,
212                      SVGA3dShaderConstType ctype, const void *value);
213
214enum pipe_error
215SVGA3D_SetShaderConsts(struct svga_winsys_context *swc,
216                       uint32 reg,
217                       uint32 numRegs,
218                       SVGA3dShaderType type,
219                       SVGA3dShaderConstType ctype,
220                       const void *values);
221
222enum pipe_error
223SVGA3D_SetShader(struct svga_winsys_context *swc,
224                 SVGA3dShaderType type, uint32 shid);
225
226
227/*
228 * Guest-backed surface functions
229 */
230
231enum pipe_error
232SVGA3D_DefineGBShader(struct svga_winsys_context *swc,
233                      struct svga_winsys_gb_shader *gbshader,
234                      SVGA3dShaderType type,
235                      uint32 sizeInBytes);
236
237enum pipe_error
238SVGA3D_BindGBShader(struct svga_winsys_context *swc,
239                    struct svga_winsys_gb_shader *gbshader);
240
241enum pipe_error
242SVGA3D_SetGBShader(struct svga_winsys_context *swc,
243                   SVGA3dShaderType type,
244                   struct svga_winsys_gb_shader *gbshader);
245
246enum pipe_error
247SVGA3D_DestroyGBShader(struct svga_winsys_context *swc,
248                       struct svga_winsys_gb_shader *gbshader);
249
250enum pipe_error
251SVGA3D_BindGBSurface(struct svga_winsys_context *swc,
252                     struct svga_winsys_surface *surface);
253
254enum pipe_error
255SVGA3D_DefineGBContext(struct svga_winsys_context *swc);
256
257enum pipe_error
258SVGA3D_DestroyGBContext(struct svga_winsys_context *swc);
259
260enum pipe_error
261SVGA3D_BindGBContext(struct svga_winsys_context *swc);
262
263enum pipe_error
264SVGA3D_InvalidateGBContext(struct svga_winsys_context *swc);
265
266enum pipe_error
267SVGA3D_UpdateGBImage(struct svga_winsys_context *swc,
268                     struct svga_winsys_surface *surface,
269                     const SVGA3dBox *box,
270                     unsigned face, unsigned mipLevel);
271
272enum pipe_error
273SVGA3D_UpdateGBSurface(struct svga_winsys_context *swc,
274                       struct svga_winsys_surface *surface);
275
276
277enum pipe_error
278SVGA3D_ReadbackGBImage(struct svga_winsys_context *swc,
279                       struct svga_winsys_surface *surface,
280                       unsigned face, unsigned mipLevel);
281
282
283enum pipe_error
284SVGA3D_ReadbackGBSurface(struct svga_winsys_context *swc,
285                         struct svga_winsys_surface *surface);
286
287
288enum pipe_error
289SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context *swc,
290                              struct svga_winsys_surface *surface,
291                              unsigned face, unsigned mipLevel,
292                              const SVGA3dBox *box,
293                              bool invertBox);
294
295
296enum pipe_error
297SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context *swc,
298                                struct svga_winsys_surface *surface,
299                                unsigned face, unsigned mipLevel,
300                                const SVGA3dBox *box,
301                                bool invertBox);
302
303
304enum pipe_error
305SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context *swc,
306                               unsigned regStart,
307                               unsigned numRegs,
308                               SVGA3dShaderType shaderType,
309                               SVGA3dShaderConstType constType,
310                               const void *values);
311
312/*
313 * Queries
314 */
315
316enum pipe_error
317SVGA3D_BeginQuery(struct svga_winsys_context *swc,
318                  SVGA3dQueryType type);
319
320enum pipe_error
321SVGA3D_EndQuery(struct svga_winsys_context *swc,
322                SVGA3dQueryType type,
323                struct svga_winsys_buffer *buffer);
324
325enum pipe_error
326SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
327                    SVGA3dQueryType type,
328                    struct svga_winsys_buffer *buffer);
329
330#endif /* __SVGA3D_H__ */
331