1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
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
24 **********************************************************/
29 * Command construction utility for the SVGA3D protocol used by
30 * the VMware SVGA device, based on the svgautil library.
37 #include "svga_types.h"
39 #include "svga3d_reg.h"
41 #include "pipe/p_defines.h"
46 struct svga_winsys_context
;
47 struct svga_winsys_buffer
;
48 struct svga_winsys_surface
;
49 struct svga_winsys_gb_shader
;
50 struct svga_winsys_gb_query
;
54 * SVGA Device Interoperability
58 SVGA3D_FIFOReserve(struct svga_winsys_context
*swc
, uint32 cmd
, uint32 cmdSize
, uint32 nr_relocs
);
61 SVGA_FIFOCommitAll(struct svga_winsys_context
*swc
);
69 SVGA3D_DefineContext(struct svga_winsys_context
*swc
);
72 SVGA3D_DestroyContext(struct svga_winsys_context
*swc
);
80 SVGA3D_BeginDefineSurface(struct svga_winsys_context
*swc
,
81 struct svga_winsys_surface
*sid
,
82 SVGA3dSurfaceFlags flags
,
83 SVGA3dSurfaceFormat format
,
84 SVGA3dSurfaceFace
**faces
,
85 SVGA3dSize
**mipSizes
,
88 SVGA3D_DefineSurface2D(struct svga_winsys_context
*swc
,
89 struct svga_winsys_surface
*sid
,
92 SVGA3dSurfaceFormat format
);
94 SVGA3D_DestroySurface(struct svga_winsys_context
*swc
,
95 struct svga_winsys_surface
*sid
);
103 SVGA3D_SurfaceDMA(struct svga_winsys_context
*swc
,
104 struct svga_transfer
*st
,
105 SVGA3dTransferType transfer
,
106 const SVGA3dCopyBox
*boxes
,
108 SVGA3dSurfaceDMAFlags flags
);
111 SVGA3D_BufferDMA(struct svga_winsys_context
*swc
,
112 struct svga_winsys_buffer
*guest
,
113 struct svga_winsys_surface
*host
,
114 SVGA3dTransferType transfer
,
118 SVGA3dSurfaceDMAFlags flags
);
126 SVGA3D_BeginClear(struct svga_winsys_context
*swc
,
127 SVGA3dClearFlag flags
,
128 uint32 color
, float depth
, uint32 stencil
,
129 SVGA3dRect
**rects
, uint32 numRects
);
132 SVGA3D_ClearRect(struct svga_winsys_context
*swc
,
133 SVGA3dClearFlag flags
, uint32 color
, float depth
,
134 uint32 stencil
, uint32 x
, uint32 y
, uint32 w
, uint32 h
);
137 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context
*swc
,
138 SVGA3dVertexDecl
**decls
,
139 uint32 numVertexDecls
,
140 SVGA3dPrimitiveRange
**ranges
,
148 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context
*swc
,
149 struct pipe_surface
*src
,
150 struct pipe_surface
*dest
,
151 SVGA3dCopyBox
**boxes
, uint32 numBoxes
);
155 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context
*swc
,
156 struct pipe_surface
*src
,
157 struct pipe_surface
*dest
,
158 SVGA3dBox
*boxSrc
, SVGA3dBox
*boxDest
,
159 SVGA3dStretchBltMode mode
);
162 * Shared FFP/Shader Render State
166 SVGA3D_SetRenderTarget(struct svga_winsys_context
*swc
,
167 SVGA3dRenderTargetType type
,
168 struct pipe_surface
*surface
);
171 SVGA3D_SetZRange(struct svga_winsys_context
*swc
,
172 float zMin
, float zMax
);
175 SVGA3D_SetViewport(struct svga_winsys_context
*swc
,
179 SVGA3D_SetScissorRect(struct svga_winsys_context
*swc
,
183 SVGA3D_SetClipPlane(struct svga_winsys_context
*swc
,
184 uint32 index
, const float *plane
);
187 SVGA3D_BeginSetTextureState(struct svga_winsys_context
*swc
,
188 SVGA3dTextureState
**states
,
192 SVGA3D_BeginSetRenderState(struct svga_winsys_context
*swc
,
193 SVGA3dRenderState
**states
,
202 SVGA3D_DefineShader(struct svga_winsys_context
*swc
,
203 uint32 shid
, SVGA3dShaderType type
,
204 const uint32
*bytecode
, uint32 bytecodeLen
);
207 SVGA3D_DestroyShader(struct svga_winsys_context
*swc
,
208 uint32 shid
, SVGA3dShaderType type
);
211 SVGA3D_SetShaderConst(struct svga_winsys_context
*swc
,
212 uint32 reg
, SVGA3dShaderType type
,
213 SVGA3dShaderConstType ctype
, const void *value
);
216 SVGA3D_SetShaderConsts(struct svga_winsys_context
*swc
,
219 SVGA3dShaderType type
,
220 SVGA3dShaderConstType ctype
,
224 SVGA3D_SetShader(struct svga_winsys_context
*swc
,
225 SVGA3dShaderType type
, uint32 shid
);
229 * Guest-backed surface functions
233 SVGA3D_BindGBShader(struct svga_winsys_context
*swc
,
234 struct svga_winsys_gb_shader
*gbshader
);
237 SVGA3D_SetGBShader(struct svga_winsys_context
*swc
,
238 SVGA3dShaderType type
,
239 struct svga_winsys_gb_shader
*gbshader
);
242 SVGA3D_BindGBSurface(struct svga_winsys_context
*swc
,
243 struct svga_winsys_surface
*surface
);
246 SVGA3D_UpdateGBImage(struct svga_winsys_context
*swc
,
247 struct svga_winsys_surface
*surface
,
248 const SVGA3dBox
*box
,
249 unsigned face
, unsigned mipLevel
);
252 SVGA3D_UpdateGBSurface(struct svga_winsys_context
*swc
,
253 struct svga_winsys_surface
*surface
);
257 SVGA3D_ReadbackGBImage(struct svga_winsys_context
*swc
,
258 struct svga_winsys_surface
*surface
,
259 unsigned face
, unsigned mipLevel
);
263 SVGA3D_ReadbackGBSurface(struct svga_winsys_context
*swc
,
264 struct svga_winsys_surface
*surface
);
268 SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context
*swc
,
269 struct svga_winsys_surface
*surface
,
270 unsigned face
, unsigned mipLevel
,
271 const SVGA3dBox
*box
,
276 SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context
*swc
,
277 struct svga_winsys_surface
*surface
,
278 unsigned face
, unsigned mipLevel
,
279 const SVGA3dBox
*box
,
284 SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context
*swc
,
287 SVGA3dShaderType shaderType
,
288 SVGA3dShaderConstType constType
,
296 SVGA3D_BeginQuery(struct svga_winsys_context
*swc
,
297 SVGA3dQueryType type
);
300 SVGA3D_EndQuery(struct svga_winsys_context
*swc
,
301 SVGA3dQueryType type
,
302 struct svga_winsys_buffer
*buffer
);
305 SVGA3D_WaitForQuery(struct svga_winsys_context
*swc
,
306 SVGA3dQueryType type
,
307 struct svga_winsys_buffer
*buffer
);
316 SVGA3D_vgpu10_PredCopyRegion(struct svga_winsys_context
*swc
,
317 struct svga_winsys_surface
*dstSurf
,
318 uint32 dstSubResource
,
319 struct svga_winsys_surface
*srcSurf
,
320 uint32 srcSubResource
,
321 const SVGA3dCopyBox
*box
);
324 SVGA3D_vgpu10_PredCopy(struct svga_winsys_context
*swc
,
325 struct svga_winsys_surface
*dstSurf
,
326 struct svga_winsys_surface
*srcSurf
);
329 SVGA3D_vgpu10_SetViewports(struct svga_winsys_context
*swc
,
330 unsigned count
, const SVGA3dViewport
*viewports
);
333 SVGA3D_vgpu10_SetShader(struct svga_winsys_context
*swc
,
334 SVGA3dShaderType type
,
335 struct svga_winsys_gb_shader
*gbshader
,
336 SVGA3dShaderId shaderId
);
339 SVGA3D_vgpu10_SetShaderResources(struct svga_winsys_context
*swc
,
340 SVGA3dShaderType type
,
343 const SVGA3dShaderResourceViewId ids
[],
344 struct svga_winsys_surface
**views
);
347 SVGA3D_vgpu10_SetSamplers(struct svga_winsys_context
*swc
,
350 SVGA3dShaderType type
,
351 const SVGA3dSamplerId
*samplerIds
);
354 SVGA3D_vgpu10_SetRenderTargets(struct svga_winsys_context
*swc
,
355 unsigned color_count
,
356 struct pipe_surface
**color_surfs
,
357 struct pipe_surface
*depth_stencil_surf
);
360 SVGA3D_vgpu10_SetBlendState(struct svga_winsys_context
*swc
,
361 SVGA3dBlendStateId blendId
,
362 const float *blendFactor
, uint32 sampleMask
);
365 SVGA3D_vgpu10_SetDepthStencilState(struct svga_winsys_context
*swc
,
366 SVGA3dDepthStencilStateId depthStencilId
,
370 SVGA3D_vgpu10_SetRasterizerState(struct svga_winsys_context
*swc
,
371 SVGA3dRasterizerStateId rasterizerId
);
374 SVGA3D_vgpu10_SetPredication(struct svga_winsys_context
*swc
,
375 SVGA3dQueryId queryId
,
376 uint32 predicateValue
);
379 SVGA3D_vgpu10_SetSOTargets(struct svga_winsys_context
*swc
,
380 unsigned count
, const SVGA3dSoTarget
*targets
,
381 struct svga_winsys_surface
**surfaces
);
384 SVGA3D_vgpu10_SetScissorRects(struct svga_winsys_context
*swc
,
386 const SVGASignedRect
*rects
);
389 SVGA3D_vgpu10_SetStreamOutput(struct svga_winsys_context
*swc
,
390 SVGA3dStreamOutputId soid
);
393 SVGA3D_vgpu10_Draw(struct svga_winsys_context
*swc
,
394 uint32 vertexCount
, uint32 startVertexLocation
);
397 SVGA3D_vgpu10_DrawIndexed(struct svga_winsys_context
*swc
,
398 uint32 indexCount
, uint32 startIndexLocation
,
399 int32 baseVertexLocation
);
402 SVGA3D_vgpu10_DrawInstanced(struct svga_winsys_context
*swc
,
403 uint32 vertexCountPerInstance
,
404 uint32 instanceCount
,
405 uint32 startVertexLocation
,
406 uint32 startInstanceLocation
);
409 SVGA3D_vgpu10_DrawIndexedInstanced(struct svga_winsys_context
*swc
,
410 uint32 indexCountPerInstance
,
411 uint32 instanceCount
,
412 uint32 startIndexLocation
,
413 int32 baseVertexLocation
,
414 uint32 startInstanceLocation
);
417 SVGA3D_vgpu10_DrawAuto(struct svga_winsys_context
*swc
);
420 SVGA3D_vgpu10_DefineQuery(struct svga_winsys_context
*swc
,
421 SVGA3dQueryId queryId
,
422 SVGA3dQueryType type
,
423 SVGA3dDXQueryFlags flags
);
426 SVGA3D_vgpu10_DestroyQuery(struct svga_winsys_context
*swc
,
427 SVGA3dQueryId queryId
);
430 SVGA3D_vgpu10_BindQuery(struct svga_winsys_context
*swc
,
431 struct svga_winsys_gb_query
*gbQuery
,
432 SVGA3dQueryId queryId
);
435 SVGA3D_vgpu10_SetQueryOffset(struct svga_winsys_context
*swc
,
436 SVGA3dQueryId queryId
,
440 SVGA3D_vgpu10_BeginQuery(struct svga_winsys_context
*swc
,
441 SVGA3dQueryId queryId
);
444 SVGA3D_vgpu10_EndQuery(struct svga_winsys_context
*swc
,
445 SVGA3dQueryId queryId
);
448 SVGA3D_vgpu10_ClearRenderTargetView(struct svga_winsys_context
*swc
,
449 struct pipe_surface
*color_surf
,
453 SVGA3D_vgpu10_ClearDepthStencilView(struct svga_winsys_context
*swc
,
454 struct pipe_surface
*ds_surf
,
455 uint16 flags
, uint16 stencil
, float depth
);
458 SVGA3D_vgpu10_DefineShaderResourceView(struct svga_winsys_context
*swc
,
459 SVGA3dShaderResourceViewId shaderResourceViewId
,
460 struct svga_winsys_surface
*surf
,
461 SVGA3dSurfaceFormat format
,
462 SVGA3dResourceType resourceDimension
,
463 const SVGA3dShaderResourceViewDesc
*desc
);
466 SVGA3D_vgpu10_DestroyShaderResourceView(struct svga_winsys_context
*swc
,
467 SVGA3dShaderResourceViewId shaderResourceViewId
);
470 SVGA3D_vgpu10_DefineRenderTargetView(struct svga_winsys_context
*swc
,
471 SVGA3dRenderTargetViewId renderTargetViewId
,
472 struct svga_winsys_surface
*surface
,
473 SVGA3dSurfaceFormat format
,
474 SVGA3dResourceType resourceDimension
,
475 const SVGA3dRenderTargetViewDesc
*desc
);
478 SVGA3D_vgpu10_DestroyRenderTargetView(struct svga_winsys_context
*swc
,
479 SVGA3dRenderTargetViewId renderTargetViewId
);
482 SVGA3D_vgpu10_DefineDepthStencilView(struct svga_winsys_context
*swc
,
483 SVGA3dDepthStencilViewId depthStencilViewId
,
484 struct svga_winsys_surface
*surface
,
485 SVGA3dSurfaceFormat format
,
486 SVGA3dResourceType resourceDimension
,
487 const SVGA3dRenderTargetViewDesc
*desc
);
491 SVGA3D_vgpu10_DestroyDepthStencilView(struct svga_winsys_context
*swc
,
492 SVGA3dDepthStencilViewId depthStencilViewId
);
495 SVGA3D_vgpu10_DefineElementLayout(struct svga_winsys_context
*swc
,
497 SVGA3dElementLayoutId elementLayoutId
,
498 const SVGA3dInputElementDesc
*elements
);
501 SVGA3D_vgpu10_DestroyElementLayout(struct svga_winsys_context
*swc
,
502 SVGA3dElementLayoutId elementLayoutId
);
505 SVGA3D_vgpu10_DefineBlendState(struct svga_winsys_context
*swc
,
506 SVGA3dBlendStateId blendId
,
507 uint8 alphaToCoverageEnable
,
508 uint8 independentBlendEnable
,
509 const SVGA3dDXBlendStatePerRT
*perRT
);
512 SVGA3D_vgpu10_DestroyBlendState(struct svga_winsys_context
*swc
,
513 SVGA3dBlendStateId blendId
);
516 SVGA3D_vgpu10_DefineDepthStencilState(struct svga_winsys_context
*swc
,
517 SVGA3dDepthStencilStateId depthStencilId
,
519 SVGA3dDepthWriteMask depthWriteMask
,
520 SVGA3dComparisonFunc depthFunc
,
524 uint8 stencilReadMask
,
525 uint8 stencilWriteMask
,
526 uint8 frontStencilFailOp
,
527 uint8 frontStencilDepthFailOp
,
528 uint8 frontStencilPassOp
,
529 SVGA3dComparisonFunc frontStencilFunc
,
530 uint8 backStencilFailOp
,
531 uint8 backStencilDepthFailOp
,
532 uint8 backStencilPassOp
,
533 SVGA3dComparisonFunc backStencilFunc
);
536 SVGA3D_vgpu10_DestroyDepthStencilState(struct svga_winsys_context
*swc
,
537 SVGA3dDepthStencilStateId depthStencilId
);
540 SVGA3D_vgpu10_DefineRasterizerState(struct svga_winsys_context
*swc
,
541 SVGA3dRasterizerStateId rasterizerId
,
543 SVGA3dCullMode cullMode
,
544 uint8 frontCounterClockwise
,
546 float depthBiasClamp
,
547 float slopeScaledDepthBias
,
548 uint8 depthClipEnable
,
550 uint8 multisampleEnable
,
551 uint8 antialiasedLineEnable
,
553 uint8 lineStippleEnable
,
554 uint8 lineStippleFactor
,
555 uint16 lineStipplePattern
,
556 uint8 provokingVertexLast
);
559 SVGA3D_vgpu10_DestroyRasterizerState(struct svga_winsys_context
*swc
,
560 SVGA3dRasterizerStateId rasterizerId
);
563 SVGA3D_vgpu10_DefineSamplerState(struct svga_winsys_context
*swc
,
564 SVGA3dSamplerId samplerId
,
571 uint8 comparisonFunc
,
572 SVGA3dRGBAFloat borderColor
,
577 SVGA3D_vgpu10_DestroySamplerState(struct svga_winsys_context
*swc
,
578 SVGA3dSamplerId samplerId
);
581 SVGA3D_vgpu10_DestroyShader(struct svga_winsys_context
*swc
,
582 SVGA3dShaderId shaderId
);
585 SVGA3D_vgpu10_DefineAndBindShader(struct svga_winsys_context
*swc
,
586 struct svga_winsys_gb_shader
*gbshader
,
587 SVGA3dShaderId shaderId
,
588 SVGA3dShaderType type
,
592 SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context
*swc
,
593 SVGA3dStreamOutputId soid
,
594 uint32 numOutputStreamEntries
,
595 uint32 streamOutputStrideInBytes
[SVGA3D_DX_MAX_SOTARGETS
],
596 const SVGA3dStreamOutputDeclarationEntry decl
[SVGA3D_MAX_STREAMOUT_DECLS
]);
599 SVGA3D_vgpu10_DestroyStreamOutput(struct svga_winsys_context
*swc
,
600 SVGA3dStreamOutputId soid
);
603 SVGA3D_vgpu10_ReadbackSubResource(struct svga_winsys_context
*swc
,
604 struct svga_winsys_surface
*surface
,
605 unsigned subResource
);
608 SVGA3D_vgpu10_SetInputLayout(struct svga_winsys_context
*swc
,
609 SVGA3dElementLayoutId elementLayoutId
);
612 SVGA3D_vgpu10_SetVertexBuffers(struct svga_winsys_context
*swc
,
615 const SVGA3dVertexBuffer
*bufferInfo
,
616 struct svga_winsys_surface
**surfaces
);
619 SVGA3D_vgpu10_SetTopology(struct svga_winsys_context
*swc
,
620 SVGA3dPrimitiveType topology
);
623 SVGA3D_vgpu10_SetIndexBuffer(struct svga_winsys_context
*swc
,
624 struct svga_winsys_surface
*indexes
,
625 SVGA3dSurfaceFormat format
, uint32 offset
);
628 SVGA3D_vgpu10_SetSingleConstantBuffer(struct svga_winsys_context
*swc
,
630 SVGA3dShaderType type
,
631 struct svga_winsys_surface
*surface
,
632 uint32 offsetInBytes
,
636 SVGA3D_vgpu10_UpdateSubResource(struct svga_winsys_context
*swc
,
637 struct svga_winsys_surface
*surface
,
638 const SVGA3dBox
*box
,
639 unsigned subResource
);
642 SVGA3D_vgpu10_GenMips(struct svga_winsys_context
*swc
,
643 const SVGA3dShaderResourceViewId shaderResourceViewId
,
644 struct svga_winsys_surface
*view
);
647 SVGA3D_vgpu10_BufferCopy(struct svga_winsys_context
*swc
,
648 struct svga_winsys_surface
*src
,
649 struct svga_winsys_surface
*dst
,
650 unsigned srcx
, unsigned dstx
, unsigned width
);
651 #endif /* __SVGA3D_H__ */