Tizen 2.0 Release
[profile/ivi/osmesa.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                   SVGA3dSurfaceDMAFlags flags);
107
108 enum pipe_error
109 SVGA3D_BufferDMA(struct svga_winsys_context *swc,
110                  struct svga_winsys_buffer *guest,
111                  struct svga_winsys_surface *host,
112                  SVGA3dTransferType transfer,
113                  uint32 size,
114                  uint32 guest_offset,
115                  uint32 host_offset,
116                  SVGA3dSurfaceDMAFlags flags);
117
118 /*
119  * Drawing Operations
120  */
121
122
123 enum pipe_error
124 SVGA3D_BeginClear(struct svga_winsys_context *swc,
125                   SVGA3dClearFlag flags,
126                   uint32 color, float depth, uint32 stencil,
127                   SVGA3dRect **rects, uint32 numRects);
128
129 enum pipe_error
130 SVGA3D_ClearRect(struct svga_winsys_context *swc,
131                  SVGA3dClearFlag flags, uint32 color, float depth,
132                  uint32 stencil, uint32 x, uint32 y, uint32 w, uint32 h);
133
134 enum pipe_error
135 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context *swc,
136                            SVGA3dVertexDecl **decls,
137                            uint32 numVertexDecls,
138                            SVGA3dPrimitiveRange **ranges,
139                            uint32 numRanges);
140
141 /*
142  * Blits
143  */
144
145 enum pipe_error
146 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
147                         struct pipe_surface *src,
148                         struct pipe_surface *dest,
149                         SVGA3dCopyBox **boxes, uint32 numBoxes);
150
151
152 enum pipe_error
153 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
154                          struct pipe_surface *src,
155                          struct pipe_surface *dest,
156                          SVGA3dBox *boxSrc, SVGA3dBox *boxDest,
157                          SVGA3dStretchBltMode mode);
158
159 /*
160  * Shared FFP/Shader Render State
161  */
162
163 enum pipe_error
164 SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
165                        SVGA3dRenderTargetType type,
166                        struct pipe_surface *surface);
167
168 enum pipe_error
169 SVGA3D_SetZRange(struct svga_winsys_context *swc,
170                  float zMin, float zMax);
171
172 enum pipe_error
173 SVGA3D_SetViewport(struct svga_winsys_context *swc,
174                    SVGA3dRect *rect);
175
176 enum pipe_error
177 SVGA3D_SetScissorRect(struct svga_winsys_context *swc,
178                       SVGA3dRect *rect);
179
180 enum pipe_error
181 SVGA3D_SetClipPlane(struct svga_winsys_context *swc,
182                     uint32 index, const float *plane);
183
184 enum pipe_error
185 SVGA3D_BeginSetTextureState(struct svga_winsys_context *swc,
186                             SVGA3dTextureState **states,
187                             uint32 numStates);
188
189 enum pipe_error
190 SVGA3D_BeginSetRenderState(struct svga_winsys_context *swc,
191                            SVGA3dRenderState **states,
192                            uint32 numStates);
193
194
195 /*
196  * Shaders
197  */
198
199 enum pipe_error
200 SVGA3D_DefineShader(struct svga_winsys_context *swc,
201                     uint32 shid, SVGA3dShaderType type,
202                     const uint32 *bytecode, uint32 bytecodeLen);
203
204 enum pipe_error
205 SVGA3D_DestroyShader(struct svga_winsys_context *swc,
206                      uint32 shid, SVGA3dShaderType type);
207
208 enum pipe_error
209 SVGA3D_SetShaderConst(struct svga_winsys_context *swc,
210                       uint32 reg, SVGA3dShaderType type,
211                       SVGA3dShaderConstType ctype, const void *value);
212
213 enum pipe_error
214 SVGA3D_SetShader(struct svga_winsys_context *swc,
215                  SVGA3dShaderType type, uint32 shid);
216
217
218 /*
219  * Queries
220  */
221
222 enum pipe_error
223 SVGA3D_BeginQuery(struct svga_winsys_context *swc,
224                   SVGA3dQueryType type);
225
226 enum pipe_error
227 SVGA3D_EndQuery(struct svga_winsys_context *swc,
228                 SVGA3dQueryType type,
229                 struct svga_winsys_buffer *buffer);
230
231 enum pipe_error
232 SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
233                     SVGA3dQueryType type,
234                     struct svga_winsys_buffer *buffer);
235
236 #endif /* __SVGA3D_H__ */