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"
38 #include "svga_winsys.h"
40 #include "svga3d_reg.h"
42 #include "pipe/p_defines.h"
47 struct svga_winsys_context
;
48 struct svga_winsys_buffer
;
49 struct svga_winsys_surface
;
50 struct svga_winsys_gb_shader
;
51 struct svga_winsys_gb_query
;
55 * SVGA Device Interoperability
59 SVGA3D_FIFOReserve(struct svga_winsys_context
*swc
, uint32 cmd
, uint32 cmdSize
, uint32 nr_relocs
);
62 SVGA_FIFOCommitAll(struct svga_winsys_context
*swc
);
65 * Return the last command id put in the command buffer.
67 static inline SVGAFifo3dCmdId
68 SVGA3D_GetLastCommand(const struct svga_winsys_context
*swc
)
70 return swc
->last_command
;
74 * Reset/clear the last command put in the command buffer.
75 * To be called when buffer is flushed.
78 SVGA3D_ResetLastCommand(struct svga_winsys_context
*swc
)
80 swc
->last_command
= 0;
89 SVGA3D_DefineContext(struct svga_winsys_context
*swc
);
92 SVGA3D_DestroyContext(struct svga_winsys_context
*swc
);
100 SVGA3D_BeginDefineSurface(struct svga_winsys_context
*swc
,
101 struct svga_winsys_surface
*sid
,
102 SVGA3dSurfaceFlags flags
,
103 SVGA3dSurfaceFormat format
,
104 SVGA3dSurfaceFace
**faces
,
105 SVGA3dSize
**mipSizes
,
108 SVGA3D_DefineSurface2D(struct svga_winsys_context
*swc
,
109 struct svga_winsys_surface
*sid
,
112 SVGA3dSurfaceFormat format
);
114 SVGA3D_DestroySurface(struct svga_winsys_context
*swc
,
115 struct svga_winsys_surface
*sid
);
123 SVGA3D_SurfaceDMA(struct svga_winsys_context
*swc
,
124 struct svga_transfer
*st
,
125 SVGA3dTransferType transfer
,
126 const SVGA3dCopyBox
*boxes
,
128 SVGA3dSurfaceDMAFlags flags
);
131 SVGA3D_BufferDMA(struct svga_winsys_context
*swc
,
132 struct svga_winsys_buffer
*guest
,
133 struct svga_winsys_surface
*host
,
134 SVGA3dTransferType transfer
,
138 SVGA3dSurfaceDMAFlags flags
);
146 SVGA3D_BeginClear(struct svga_winsys_context
*swc
,
147 SVGA3dClearFlag flags
,
148 uint32 color
, float depth
, uint32 stencil
,
149 SVGA3dRect
**rects
, uint32 numRects
);
152 SVGA3D_ClearRect(struct svga_winsys_context
*swc
,
153 SVGA3dClearFlag flags
, uint32 color
, float depth
,
154 uint32 stencil
, uint32 x
, uint32 y
, uint32 w
, uint32 h
);
157 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context
*swc
,
158 SVGA3dVertexDecl
**decls
,
159 uint32 numVertexDecls
,
160 SVGA3dPrimitiveRange
**ranges
,
168 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context
*swc
,
169 struct pipe_surface
*src
,
170 struct pipe_surface
*dest
,
171 SVGA3dCopyBox
**boxes
, uint32 numBoxes
);
175 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context
*swc
,
176 struct pipe_surface
*src
,
177 struct pipe_surface
*dest
,
178 SVGA3dBox
*boxSrc
, SVGA3dBox
*boxDest
,
179 SVGA3dStretchBltMode mode
);
182 * Shared FFP/Shader Render State
186 SVGA3D_SetRenderTarget(struct svga_winsys_context
*swc
,
187 SVGA3dRenderTargetType type
,
188 struct pipe_surface
*surface
);
191 SVGA3D_SetZRange(struct svga_winsys_context
*swc
,
192 float zMin
, float zMax
);
195 SVGA3D_SetViewport(struct svga_winsys_context
*swc
,
199 SVGA3D_SetScissorRect(struct svga_winsys_context
*swc
,
203 SVGA3D_SetClipPlane(struct svga_winsys_context
*swc
,
204 uint32 index
, const float *plane
);
207 SVGA3D_BeginSetTextureState(struct svga_winsys_context
*swc
,
208 SVGA3dTextureState
**states
,
212 SVGA3D_BeginSetRenderState(struct svga_winsys_context
*swc
,
213 SVGA3dRenderState
**states
,
222 SVGA3D_DefineShader(struct svga_winsys_context
*swc
,
223 uint32 shid
, SVGA3dShaderType type
,
224 const uint32
*bytecode
, uint32 bytecodeLen
);
227 SVGA3D_DestroyShader(struct svga_winsys_context
*swc
,
228 uint32 shid
, SVGA3dShaderType type
);
231 SVGA3D_SetShaderConst(struct svga_winsys_context
*swc
,
232 uint32 reg
, SVGA3dShaderType type
,
233 SVGA3dShaderConstType ctype
, const void *value
);
236 SVGA3D_SetShaderConsts(struct svga_winsys_context
*swc
,
239 SVGA3dShaderType type
,
240 SVGA3dShaderConstType ctype
,
244 SVGA3D_SetShader(struct svga_winsys_context
*swc
,
245 SVGA3dShaderType type
, uint32 shid
);
249 * Guest-backed surface functions
253 SVGA3D_BindGBShader(struct svga_winsys_context
*swc
,
254 struct svga_winsys_gb_shader
*gbshader
);
257 SVGA3D_SetGBShader(struct svga_winsys_context
*swc
,
258 SVGA3dShaderType type
,
259 struct svga_winsys_gb_shader
*gbshader
);
262 SVGA3D_BindGBSurface(struct svga_winsys_context
*swc
,
263 struct svga_winsys_surface
*surface
);
266 SVGA3D_UpdateGBImage(struct svga_winsys_context
*swc
,
267 struct svga_winsys_surface
*surface
,
268 const SVGA3dBox
*box
,
269 unsigned face
, unsigned mipLevel
);
272 SVGA3D_UpdateGBSurface(struct svga_winsys_context
*swc
,
273 struct svga_winsys_surface
*surface
);
277 SVGA3D_ReadbackGBImage(struct svga_winsys_context
*swc
,
278 struct svga_winsys_surface
*surface
,
279 unsigned face
, unsigned mipLevel
);
283 SVGA3D_ReadbackGBSurface(struct svga_winsys_context
*swc
,
284 struct svga_winsys_surface
*surface
);
288 SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context
*swc
,
289 struct svga_winsys_surface
*surface
,
290 unsigned face
, unsigned mipLevel
,
291 const SVGA3dBox
*box
,
296 SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context
*swc
,
297 struct svga_winsys_surface
*surface
,
298 unsigned face
, unsigned mipLevel
,
299 const SVGA3dBox
*box
,
304 SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context
*swc
,
307 SVGA3dShaderType shaderType
,
308 SVGA3dShaderConstType constType
,
316 SVGA3D_BeginQuery(struct svga_winsys_context
*swc
,
317 SVGA3dQueryType type
);
320 SVGA3D_EndQuery(struct svga_winsys_context
*swc
,
321 SVGA3dQueryType type
,
322 struct svga_winsys_buffer
*buffer
);
325 SVGA3D_WaitForQuery(struct svga_winsys_context
*swc
,
326 SVGA3dQueryType type
,
327 struct svga_winsys_buffer
*buffer
);
336 SVGA3D_vgpu10_PredCopyRegion(struct svga_winsys_context
*swc
,
337 struct svga_winsys_surface
*dstSurf
,
338 uint32 dstSubResource
,
339 struct svga_winsys_surface
*srcSurf
,
340 uint32 srcSubResource
,
341 const SVGA3dCopyBox
*box
);
344 SVGA3D_vgpu10_PredCopy(struct svga_winsys_context
*swc
,
345 struct svga_winsys_surface
*dstSurf
,
346 struct svga_winsys_surface
*srcSurf
);
349 SVGA3D_vgpu10_SetViewports(struct svga_winsys_context
*swc
,
350 unsigned count
, const SVGA3dViewport
*viewports
);
353 SVGA3D_vgpu10_SetShader(struct svga_winsys_context
*swc
,
354 SVGA3dShaderType type
,
355 struct svga_winsys_gb_shader
*gbshader
,
356 SVGA3dShaderId shaderId
);
359 SVGA3D_vgpu10_SetShaderResources(struct svga_winsys_context
*swc
,
360 SVGA3dShaderType type
,
363 const SVGA3dShaderResourceViewId ids
[],
364 struct svga_winsys_surface
**views
);
367 SVGA3D_vgpu10_SetSamplers(struct svga_winsys_context
*swc
,
370 SVGA3dShaderType type
,
371 const SVGA3dSamplerId
*samplerIds
);
374 SVGA3D_vgpu10_SetRenderTargets(struct svga_winsys_context
*swc
,
375 unsigned color_count
,
376 struct pipe_surface
**color_surfs
,
377 struct pipe_surface
*depth_stencil_surf
);
380 SVGA3D_vgpu10_SetBlendState(struct svga_winsys_context
*swc
,
381 SVGA3dBlendStateId blendId
,
382 const float *blendFactor
, uint32 sampleMask
);
385 SVGA3D_vgpu10_SetDepthStencilState(struct svga_winsys_context
*swc
,
386 SVGA3dDepthStencilStateId depthStencilId
,
390 SVGA3D_vgpu10_SetRasterizerState(struct svga_winsys_context
*swc
,
391 SVGA3dRasterizerStateId rasterizerId
);
394 SVGA3D_vgpu10_SetPredication(struct svga_winsys_context
*swc
,
395 SVGA3dQueryId queryId
,
396 uint32 predicateValue
);
399 SVGA3D_vgpu10_SetSOTargets(struct svga_winsys_context
*swc
,
400 unsigned count
, const SVGA3dSoTarget
*targets
,
401 struct svga_winsys_surface
**surfaces
);
404 SVGA3D_vgpu10_SetScissorRects(struct svga_winsys_context
*swc
,
406 const SVGASignedRect
*rects
);
409 SVGA3D_vgpu10_SetStreamOutput(struct svga_winsys_context
*swc
,
410 SVGA3dStreamOutputId soid
);
413 SVGA3D_vgpu10_Draw(struct svga_winsys_context
*swc
,
414 uint32 vertexCount
, uint32 startVertexLocation
);
417 SVGA3D_vgpu10_DrawIndexed(struct svga_winsys_context
*swc
,
418 uint32 indexCount
, uint32 startIndexLocation
,
419 int32 baseVertexLocation
);
422 SVGA3D_vgpu10_DrawInstanced(struct svga_winsys_context
*swc
,
423 uint32 vertexCountPerInstance
,
424 uint32 instanceCount
,
425 uint32 startVertexLocation
,
426 uint32 startInstanceLocation
);
429 SVGA3D_vgpu10_DrawIndexedInstanced(struct svga_winsys_context
*swc
,
430 uint32 indexCountPerInstance
,
431 uint32 instanceCount
,
432 uint32 startIndexLocation
,
433 int32 baseVertexLocation
,
434 uint32 startInstanceLocation
);
437 SVGA3D_vgpu10_DrawAuto(struct svga_winsys_context
*swc
);
440 SVGA3D_vgpu10_DefineQuery(struct svga_winsys_context
*swc
,
441 SVGA3dQueryId queryId
,
442 SVGA3dQueryType type
,
443 SVGA3dDXQueryFlags flags
);
446 SVGA3D_vgpu10_DestroyQuery(struct svga_winsys_context
*swc
,
447 SVGA3dQueryId queryId
);
450 SVGA3D_vgpu10_BindQuery(struct svga_winsys_context
*swc
,
451 struct svga_winsys_gb_query
*gbQuery
,
452 SVGA3dQueryId queryId
);
455 SVGA3D_vgpu10_SetQueryOffset(struct svga_winsys_context
*swc
,
456 SVGA3dQueryId queryId
,
460 SVGA3D_vgpu10_BeginQuery(struct svga_winsys_context
*swc
,
461 SVGA3dQueryId queryId
);
464 SVGA3D_vgpu10_EndQuery(struct svga_winsys_context
*swc
,
465 SVGA3dQueryId queryId
);
468 SVGA3D_vgpu10_ClearRenderTargetView(struct svga_winsys_context
*swc
,
469 struct pipe_surface
*color_surf
,
473 SVGA3D_vgpu10_ClearDepthStencilView(struct svga_winsys_context
*swc
,
474 struct pipe_surface
*ds_surf
,
475 uint16 flags
, uint16 stencil
, float depth
);
478 SVGA3D_vgpu10_DefineShaderResourceView(struct svga_winsys_context
*swc
,
479 SVGA3dShaderResourceViewId shaderResourceViewId
,
480 struct svga_winsys_surface
*surf
,
481 SVGA3dSurfaceFormat format
,
482 SVGA3dResourceType resourceDimension
,
483 const SVGA3dShaderResourceViewDesc
*desc
);
486 SVGA3D_vgpu10_DestroyShaderResourceView(struct svga_winsys_context
*swc
,
487 SVGA3dShaderResourceViewId shaderResourceViewId
);
490 SVGA3D_vgpu10_DefineRenderTargetView(struct svga_winsys_context
*swc
,
491 SVGA3dRenderTargetViewId renderTargetViewId
,
492 struct svga_winsys_surface
*surface
,
493 SVGA3dSurfaceFormat format
,
494 SVGA3dResourceType resourceDimension
,
495 const SVGA3dRenderTargetViewDesc
*desc
);
498 SVGA3D_vgpu10_DestroyRenderTargetView(struct svga_winsys_context
*swc
,
499 SVGA3dRenderTargetViewId renderTargetViewId
);
502 SVGA3D_vgpu10_DefineDepthStencilView(struct svga_winsys_context
*swc
,
503 SVGA3dDepthStencilViewId depthStencilViewId
,
504 struct svga_winsys_surface
*surface
,
505 SVGA3dSurfaceFormat format
,
506 SVGA3dResourceType resourceDimension
,
507 const SVGA3dRenderTargetViewDesc
*desc
);
511 SVGA3D_vgpu10_DestroyDepthStencilView(struct svga_winsys_context
*swc
,
512 SVGA3dDepthStencilViewId depthStencilViewId
);
515 SVGA3D_vgpu10_DefineElementLayout(struct svga_winsys_context
*swc
,
517 SVGA3dElementLayoutId elementLayoutId
,
518 const SVGA3dInputElementDesc
*elements
);
521 SVGA3D_vgpu10_DestroyElementLayout(struct svga_winsys_context
*swc
,
522 SVGA3dElementLayoutId elementLayoutId
);
525 SVGA3D_vgpu10_DefineBlendState(struct svga_winsys_context
*swc
,
526 SVGA3dBlendStateId blendId
,
527 uint8 alphaToCoverageEnable
,
528 uint8 independentBlendEnable
,
529 const SVGA3dDXBlendStatePerRT
*perRT
);
532 SVGA3D_vgpu10_DestroyBlendState(struct svga_winsys_context
*swc
,
533 SVGA3dBlendStateId blendId
);
536 SVGA3D_vgpu10_DefineDepthStencilState(struct svga_winsys_context
*swc
,
537 SVGA3dDepthStencilStateId depthStencilId
,
539 SVGA3dDepthWriteMask depthWriteMask
,
540 SVGA3dComparisonFunc depthFunc
,
544 uint8 stencilReadMask
,
545 uint8 stencilWriteMask
,
546 uint8 frontStencilFailOp
,
547 uint8 frontStencilDepthFailOp
,
548 uint8 frontStencilPassOp
,
549 SVGA3dComparisonFunc frontStencilFunc
,
550 uint8 backStencilFailOp
,
551 uint8 backStencilDepthFailOp
,
552 uint8 backStencilPassOp
,
553 SVGA3dComparisonFunc backStencilFunc
);
556 SVGA3D_vgpu10_DestroyDepthStencilState(struct svga_winsys_context
*swc
,
557 SVGA3dDepthStencilStateId depthStencilId
);
560 SVGA3D_vgpu10_DefineRasterizerState(struct svga_winsys_context
*swc
,
561 SVGA3dRasterizerStateId rasterizerId
,
563 SVGA3dCullMode cullMode
,
564 uint8 frontCounterClockwise
,
566 float depthBiasClamp
,
567 float slopeScaledDepthBias
,
568 uint8 depthClipEnable
,
570 uint8 multisampleEnable
,
571 uint8 antialiasedLineEnable
,
573 uint8 lineStippleEnable
,
574 uint8 lineStippleFactor
,
575 uint16 lineStipplePattern
,
576 uint8 provokingVertexLast
);
579 SVGA3D_vgpu10_DestroyRasterizerState(struct svga_winsys_context
*swc
,
580 SVGA3dRasterizerStateId rasterizerId
);
583 SVGA3D_vgpu10_DefineSamplerState(struct svga_winsys_context
*swc
,
584 SVGA3dSamplerId samplerId
,
591 uint8 comparisonFunc
,
592 SVGA3dRGBAFloat borderColor
,
597 SVGA3D_vgpu10_DestroySamplerState(struct svga_winsys_context
*swc
,
598 SVGA3dSamplerId samplerId
);
601 SVGA3D_vgpu10_DestroyShader(struct svga_winsys_context
*swc
,
602 SVGA3dShaderId shaderId
);
605 SVGA3D_vgpu10_DefineAndBindShader(struct svga_winsys_context
*swc
,
606 struct svga_winsys_gb_shader
*gbshader
,
607 SVGA3dShaderId shaderId
,
608 SVGA3dShaderType type
,
612 SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context
*swc
,
613 SVGA3dStreamOutputId soid
,
614 uint32 numOutputStreamEntries
,
615 uint32 streamOutputStrideInBytes
[SVGA3D_DX_MAX_SOTARGETS
],
616 const SVGA3dStreamOutputDeclarationEntry decl
[SVGA3D_MAX_STREAMOUT_DECLS
]);
619 SVGA3D_vgpu10_DestroyStreamOutput(struct svga_winsys_context
*swc
,
620 SVGA3dStreamOutputId soid
);
623 SVGA3D_vgpu10_ReadbackSubResource(struct svga_winsys_context
*swc
,
624 struct svga_winsys_surface
*surface
,
625 unsigned subResource
);
628 SVGA3D_vgpu10_SetInputLayout(struct svga_winsys_context
*swc
,
629 SVGA3dElementLayoutId elementLayoutId
);
632 SVGA3D_vgpu10_SetVertexBuffers(struct svga_winsys_context
*swc
,
635 const SVGA3dVertexBuffer
*bufferInfo
,
636 struct svga_winsys_surface
**surfaces
);
639 SVGA3D_vgpu10_SetTopology(struct svga_winsys_context
*swc
,
640 SVGA3dPrimitiveType topology
);
643 SVGA3D_vgpu10_SetIndexBuffer(struct svga_winsys_context
*swc
,
644 struct svga_winsys_surface
*indexes
,
645 SVGA3dSurfaceFormat format
, uint32 offset
);
648 SVGA3D_vgpu10_SetSingleConstantBuffer(struct svga_winsys_context
*swc
,
650 SVGA3dShaderType type
,
651 struct svga_winsys_surface
*surface
,
652 uint32 offsetInBytes
,
656 SVGA3D_vgpu10_UpdateSubResource(struct svga_winsys_context
*swc
,
657 struct svga_winsys_surface
*surface
,
658 const SVGA3dBox
*box
,
659 unsigned subResource
);
662 SVGA3D_vgpu10_GenMips(struct svga_winsys_context
*swc
,
663 const SVGA3dShaderResourceViewId shaderResourceViewId
,
664 struct svga_winsys_surface
*view
);
667 SVGA3D_vgpu10_BufferCopy(struct svga_winsys_context
*swc
,
668 struct svga_winsys_surface
*src
,
669 struct svga_winsys_surface
*dst
,
670 unsigned srcx
, unsigned dstx
, unsigned width
);
673 SVGA3D_vgpu10_TransferFromBuffer(struct svga_winsys_context
*swc
,
674 struct svga_winsys_surface
*src
,
675 unsigned srcOffset
, unsigned srcPitch
,
676 unsigned srcSlicePitch
,
677 struct svga_winsys_surface
*dst
,
678 unsigned dstSubResource
,
681 #endif /* __SVGA3D_H__ */