Merge branch '7.8'
[mesa.git] / src / gallium / drivers / svga / svga_cmd.h
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
44 struct pipe_surface;
45 struct svga_transfer;
46 struct svga_winsys_context;
47 struct svga_winsys_buffer;
48 struct svga_winsys_surface;
49
50
51 /*
52 * SVGA Device Interoperability
53 */
54
55 void *
56 SVGA3D_FIFOReserve(struct svga_winsys_context *swc, uint32 cmd, uint32 cmdSize, uint32 nr_relocs);
57
58 void
59 SVGA_FIFOCommitAll(struct svga_winsys_context *swc);
60
61
62 /*
63 * Context Management
64 */
65
66 enum pipe_error
67 SVGA3D_DefineContext(struct svga_winsys_context *swc);
68
69 enum pipe_error
70 SVGA3D_DestroyContext(struct svga_winsys_context *swc);
71
72
73 /*
74 * Surface Management
75 */
76
77 enum pipe_error
78 SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
79 struct svga_winsys_surface *sid,
80 SVGA3dSurfaceFlags flags,
81 SVGA3dSurfaceFormat format,
82 SVGA3dSurfaceFace **faces,
83 SVGA3dSize **mipSizes,
84 uint32 numMipSizes);
85 enum pipe_error
86 SVGA3D_DefineSurface2D(struct svga_winsys_context *swc,
87 struct svga_winsys_surface *sid,
88 uint32 width,
89 uint32 height,
90 SVGA3dSurfaceFormat format);
91 enum pipe_error
92 SVGA3D_DestroySurface(struct svga_winsys_context *swc,
93 struct svga_winsys_surface *sid);
94
95
96 /*
97 * Surface Operations
98 */
99
100 enum pipe_error
101 SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
102 struct svga_transfer *st,
103 SVGA3dTransferType transfer,
104 const SVGA3dCopyBox *boxes,
105 uint32 numBoxes);
106
107 enum pipe_error
108 SVGA3D_BufferDMA(struct svga_winsys_context *swc,
109 struct svga_winsys_buffer *guest,
110 struct svga_winsys_surface *host,
111 SVGA3dTransferType transfer,
112 uint32 size,
113 uint32 guest_offset,
114 uint32 host_offset,
115 SVGA3dSurfaceDMAFlags flags);
116
117 /*
118 * Drawing Operations
119 */
120
121
122 enum pipe_error
123 SVGA3D_BeginClear(struct svga_winsys_context *swc,
124 SVGA3dClearFlag flags,
125 uint32 color, float depth, uint32 stencil,
126 SVGA3dRect **rects, uint32 numRects);
127
128 enum pipe_error
129 SVGA3D_ClearRect(struct svga_winsys_context *swc,
130 SVGA3dClearFlag flags, uint32 color, float depth,
131 uint32 stencil, uint32 x, uint32 y, uint32 w, uint32 h);
132
133 enum pipe_error
134 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
135 SVGA3dVertexDecl **decls,
136 uint32 numVertexDecls,
137 SVGA3dPrimitiveRange **ranges,
138 uint32 numRanges);
139
140 /*
141 * Blits
142 */
143
144 enum pipe_error
145 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
146 struct pipe_surface *src,
147 struct pipe_surface *dest,
148 SVGA3dCopyBox **boxes, uint32 numBoxes);
149
150
151 enum pipe_error
152 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
153 struct pipe_surface *src,
154 struct pipe_surface *dest,
155 SVGA3dBox *boxSrc, SVGA3dBox *boxDest,
156 SVGA3dStretchBltMode mode);
157
158 /*
159 * Shared FFP/Shader Render State
160 */
161
162 enum pipe_error
163 SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
164 SVGA3dRenderTargetType type,
165 struct pipe_surface *surface);
166
167 enum pipe_error
168 SVGA3D_SetZRange(struct svga_winsys_context *swc,
169 float zMin, float zMax);
170
171 enum pipe_error
172 SVGA3D_SetViewport(struct svga_winsys_context *swc,
173 SVGA3dRect *rect);
174
175 enum pipe_error
176 SVGA3D_SetScissorRect(struct svga_winsys_context *swc,
177 SVGA3dRect *rect);
178
179 enum pipe_error
180 SVGA3D_SetClipPlane(struct svga_winsys_context *swc,
181 uint32 index, const float *plane);
182
183 enum pipe_error
184 SVGA3D_BeginSetTextureState(struct svga_winsys_context *swc,
185 SVGA3dTextureState **states,
186 uint32 numStates);
187
188 enum pipe_error
189 SVGA3D_BeginSetRenderState(struct svga_winsys_context *swc,
190 SVGA3dRenderState **states,
191 uint32 numStates);
192
193
194 /*
195 * Shaders
196 */
197
198 enum pipe_error
199 SVGA3D_DefineShader(struct svga_winsys_context *swc,
200 uint32 shid, SVGA3dShaderType type,
201 const uint32 *bytecode, uint32 bytecodeLen);
202
203 enum pipe_error
204 SVGA3D_DestroyShader(struct svga_winsys_context *swc,
205 uint32 shid, SVGA3dShaderType type);
206
207 enum pipe_error
208 SVGA3D_SetShaderConst(struct svga_winsys_context *swc,
209 uint32 reg, SVGA3dShaderType type,
210 SVGA3dShaderConstType ctype, const void *value);
211
212 enum pipe_error
213 SVGA3D_SetShader(struct svga_winsys_context *swc,
214 SVGA3dShaderType type, uint32 shid);
215
216
217 /*
218 * Queries
219 */
220
221 enum pipe_error
222 SVGA3D_BeginQuery(struct svga_winsys_context *swc,
223 SVGA3dQueryType type);
224
225 enum pipe_error
226 SVGA3D_EndQuery(struct svga_winsys_context *swc,
227 SVGA3dQueryType type,
228 struct svga_winsys_buffer *buffer);
229
230 enum pipe_error
231 SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
232 SVGA3dQueryType type,
233 struct svga_winsys_buffer *buffer);
234
235 #endif /* __SVGA3D_H__ */