1 /**********************************************************
2 * Copyright 2008-2013 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 **********************************************************/
27 * @file svga_cmd_vgpu10.c
29 * Command construction utility for the vgpu10 SVGA3D protocol.
31 * \author Mingcheng Chen
36 #include "svga_winsys.h"
37 #include "svga_resource_buffer.h"
38 #include "svga_resource_texture.h"
39 #include "svga_surface.h"
44 * Emit a surface relocation for RenderTargetViewId
47 view_relocation(struct svga_winsys_context
*swc
, // IN
48 struct pipe_surface
*surface
, // IN
49 SVGA3dRenderTargetViewId
*id
, // OUT
53 struct svga_surface
*s
= svga_surface(surface
);
55 swc
->surface_relocation(swc
, id
, NULL
, s
->handle
, flags
);
58 swc
->surface_relocation(swc
, id
, NULL
, NULL
, flags
);
64 * Emit a surface relocation for a ResourceId.
67 surface_to_resourceid(struct svga_winsys_context
*swc
, // IN
68 struct svga_winsys_surface
*surface
, // IN
69 SVGA3dSurfaceId
*sid
, // OUT
73 swc
->surface_relocation(swc
, sid
, NULL
, surface
, flags
);
76 swc
->surface_relocation(swc
, sid
, NULL
, NULL
, flags
);
81 #define SVGA3D_CREATE_COMMAND(CommandName, CommandCode) \
82 SVGA3dCmdDX##CommandName *cmd; \
84 cmd = SVGA3D_FIFOReserve(swc, SVGA_3D_CMD_DX_##CommandCode, \
85 sizeof(SVGA3dCmdDX##CommandName), 0); \
87 return PIPE_ERROR_OUT_OF_MEMORY; \
90 #define SVGA3D_CREATE_CMD_COUNT(CommandName, CommandCode, ElementClassName) \
91 SVGA3dCmdDX##CommandName *cmd; \
94 cmd = SVGA3D_FIFOReserve(swc, SVGA_3D_CMD_DX_##CommandCode, \
95 sizeof(SVGA3dCmdDX##CommandName) + \
96 count * sizeof(ElementClassName), 0); \
98 return PIPE_ERROR_OUT_OF_MEMORY; \
101 #define SVGA3D_COPY_BASIC(VariableName) \
103 cmd->VariableName = VariableName; \
106 #define SVGA3D_COPY_BASIC_2(VariableName1, VariableName2) \
108 SVGA3D_COPY_BASIC(VariableName1); \
109 SVGA3D_COPY_BASIC(VariableName2); \
112 #define SVGA3D_COPY_BASIC_3(VariableName1, VariableName2, VariableName3) \
114 SVGA3D_COPY_BASIC_2(VariableName1, VariableName2); \
115 SVGA3D_COPY_BASIC(VariableName3); \
118 #define SVGA3D_COPY_BASIC_4(VariableName1, VariableName2, VariableName3, \
121 SVGA3D_COPY_BASIC_2(VariableName1, VariableName2); \
122 SVGA3D_COPY_BASIC_2(VariableName3, VariableName4); \
125 #define SVGA3D_COPY_BASIC_5(VariableName1, VariableName2, VariableName3, \
126 VariableName4, VariableName5) \
128 SVGA3D_COPY_BASIC_3(VariableName1, VariableName2, VariableName3); \
129 SVGA3D_COPY_BASIC_2(VariableName4, VariableName5); \
132 #define SVGA3D_COPY_BASIC_6(VariableName1, VariableName2, VariableName3, \
133 VariableName4, VariableName5, VariableName6) \
135 SVGA3D_COPY_BASIC_3(VariableName1, VariableName2, VariableName3); \
136 SVGA3D_COPY_BASIC_3(VariableName4, VariableName5, VariableName6); \
139 #define SVGA3D_COPY_BASIC_7(VariableName1, VariableName2, VariableName3, \
140 VariableName4, VariableName5, VariableName6, \
143 SVGA3D_COPY_BASIC_4(VariableName1, VariableName2, VariableName3, \
145 SVGA3D_COPY_BASIC_3(VariableName5, VariableName6, VariableName7); \
148 #define SVGA3D_COPY_BASIC_8(VariableName1, VariableName2, VariableName3, \
149 VariableName4, VariableName5, VariableName6, \
150 VariableName7, VariableName8) \
152 SVGA3D_COPY_BASIC_4(VariableName1, VariableName2, VariableName3, \
154 SVGA3D_COPY_BASIC_4(VariableName5, VariableName6, VariableName7, \
158 #define SVGA3D_COPY_BASIC_9(VariableName1, VariableName2, VariableName3, \
159 VariableName4, VariableName5, VariableName6, \
160 VariableName7, VariableName8, VariableName9) \
162 SVGA3D_COPY_BASIC_5(VariableName1, VariableName2, VariableName3, \
163 VariableName4, VariableName5); \
164 SVGA3D_COPY_BASIC_4(VariableName6, VariableName7, VariableName8, \
170 SVGA3D_vgpu10_PredCopyRegion(struct svga_winsys_context
*swc
,
171 struct svga_winsys_surface
*dstSurf
,
172 uint32 dstSubResource
,
173 struct svga_winsys_surface
*srcSurf
,
174 uint32 srcSubResource
,
175 const SVGA3dCopyBox
*box
)
177 SVGA3dCmdDXPredCopyRegion
*cmd
=
178 SVGA3D_FIFOReserve(swc
,
179 SVGA_3D_CMD_DX_PRED_COPY_REGION
,
180 sizeof(SVGA3dCmdDXPredCopyRegion
),
181 2); /* two relocations */
183 return PIPE_ERROR_OUT_OF_MEMORY
;
185 swc
->surface_relocation(swc
, &cmd
->dstSid
, NULL
, dstSurf
, SVGA_RELOC_WRITE
);
186 swc
->surface_relocation(swc
, &cmd
->srcSid
, NULL
, srcSurf
, SVGA_RELOC_READ
);
187 cmd
->dstSubResource
= dstSubResource
;
188 cmd
->srcSubResource
= srcSubResource
;
198 SVGA3D_vgpu10_PredCopy(struct svga_winsys_context
*swc
,
199 struct svga_winsys_surface
*dstSurf
,
200 struct svga_winsys_surface
*srcSurf
)
202 SVGA3dCmdDXPredCopy
*cmd
=
203 SVGA3D_FIFOReserve(swc
,
204 SVGA_3D_CMD_DX_PRED_COPY
,
205 sizeof(SVGA3dCmdDXPredCopy
),
206 2); /* two relocations */
208 return PIPE_ERROR_OUT_OF_MEMORY
;
210 swc
->surface_relocation(swc
, &cmd
->dstSid
, NULL
, dstSurf
, SVGA_RELOC_WRITE
);
211 swc
->surface_relocation(swc
, &cmd
->srcSid
, NULL
, srcSurf
, SVGA_RELOC_READ
);
219 SVGA3D_vgpu10_SetViewports(struct svga_winsys_context
*swc
,
221 const SVGA3dViewport
*viewports
)
223 SVGA3D_CREATE_CMD_COUNT(SetViewports
, SET_VIEWPORTS
, SVGA3dViewport
);
226 memcpy(cmd
+ 1, viewports
, count
* sizeof(SVGA3dViewport
));
234 SVGA3D_vgpu10_SetShader(struct svga_winsys_context
*swc
,
235 SVGA3dShaderType type
,
236 struct svga_winsys_gb_shader
*gbshader
,
237 SVGA3dShaderId shaderId
)
239 SVGA3dCmdDXSetShader
*cmd
= SVGA3D_FIFOReserve(swc
,
240 SVGA_3D_CMD_DX_SET_SHADER
,
242 1); /* one relocation */
244 return PIPE_ERROR_OUT_OF_MEMORY
;
246 swc
->shader_relocation(swc
, &cmd
->shaderId
, NULL
, NULL
, gbshader
, 0);
249 cmd
->shaderId
= shaderId
;
257 SVGA3D_vgpu10_SetShaderResources(struct svga_winsys_context
*swc
,
258 SVGA3dShaderType type
,
261 const SVGA3dShaderResourceViewId ids
[],
262 struct svga_winsys_surface
**views
)
264 SVGA3dCmdDXSetShaderResources
*cmd
;
265 SVGA3dShaderResourceViewId
*cmd_ids
;
268 cmd
= SVGA3D_FIFOReserve(swc
,
269 SVGA_3D_CMD_DX_SET_SHADER_RESOURCES
,
270 sizeof(SVGA3dCmdDXSetShaderResources
) +
271 count
* sizeof(SVGA3dShaderResourceViewId
),
272 count
); /* 'count' relocations */
274 return PIPE_ERROR_OUT_OF_MEMORY
;
278 cmd
->startView
= startView
;
280 cmd_ids
= (SVGA3dShaderResourceViewId
*) (cmd
+ 1);
281 for (i
= 0; i
< count
; i
++) {
282 swc
->surface_relocation(swc
, cmd_ids
+ i
, NULL
, views
[i
],
293 SVGA3D_vgpu10_SetSamplers(struct svga_winsys_context
*swc
,
296 SVGA3dShaderType type
,
297 const SVGA3dSamplerId
*samplerIds
)
299 SVGA3D_CREATE_CMD_COUNT(SetSamplers
, SET_SAMPLERS
, SVGA3dSamplerId
);
301 SVGA3D_COPY_BASIC_2(startSampler
, type
);
302 memcpy(cmd
+ 1, samplerIds
, count
* sizeof(SVGA3dSamplerId
));
310 SVGA3D_vgpu10_ClearRenderTargetView(struct svga_winsys_context
*swc
,
311 struct pipe_surface
*color_surf
,
314 SVGA3dCmdDXClearRenderTargetView
*cmd
;
315 struct svga_surface
*ss
= svga_surface(color_surf
);
317 cmd
= SVGA3D_FIFOReserve(swc
,
318 SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW
,
319 sizeof(SVGA3dCmdDXClearRenderTargetView
),
320 1); /* one relocation */
322 return PIPE_ERROR_OUT_OF_MEMORY
;
325 /* NOTE: The following is pretty tricky. We need to emit a view/surface
326 * relocation and we have to provide a pointer to an ID which lies in
327 * the bounds of the command space which we just allocated. However,
328 * we then need to overwrite it with the original RenderTargetViewId.
330 view_relocation(swc
, color_surf
, &cmd
->renderTargetViewId
,
332 cmd
->renderTargetViewId
= ss
->view_id
;
334 COPY_4V(cmd
->rgba
.value
, rgba
);
342 SVGA3D_vgpu10_SetRenderTargets(struct svga_winsys_context
*swc
,
343 unsigned color_count
,
344 struct pipe_surface
**color_surfs
,
345 struct pipe_surface
*depth_stencil_surf
)
347 const unsigned surf_count
= color_count
+ 1;
348 SVGA3dCmdDXSetRenderTargets
*cmd
;
349 SVGA3dRenderTargetViewId
*ctarget
;
350 struct svga_surface
*ss
;
353 assert(surf_count
> 0);
355 cmd
= SVGA3D_FIFOReserve(swc
,
356 SVGA_3D_CMD_DX_SET_RENDERTARGETS
,
357 sizeof(SVGA3dCmdDXSetRenderTargets
) +
358 color_count
* sizeof(SVGA3dRenderTargetViewId
),
359 surf_count
); /* 'surf_count' relocations */
361 return PIPE_ERROR_OUT_OF_MEMORY
;
363 /* NOTE: See earlier comment about the tricky handling of the ViewIds.
366 /* Depth / Stencil buffer */
367 if (depth_stencil_surf
) {
368 ss
= svga_surface(depth_stencil_surf
);
369 view_relocation(swc
, depth_stencil_surf
, &cmd
->depthStencilViewId
,
371 cmd
->depthStencilViewId
= ss
->view_id
;
374 /* no depth/stencil buffer - still need a relocation */
375 view_relocation(swc
, NULL
, &cmd
->depthStencilViewId
,
377 cmd
->depthStencilViewId
= SVGA3D_INVALID_ID
;
381 ctarget
= (SVGA3dRenderTargetViewId
*) &cmd
[1];
382 for (i
= 0; i
< color_count
; i
++) {
383 if (color_surfs
[i
]) {
384 ss
= svga_surface(color_surfs
[i
]);
385 view_relocation(swc
, color_surfs
[i
], ctarget
+ i
, SVGA_RELOC_WRITE
);
386 ctarget
[i
] = ss
->view_id
;
389 view_relocation(swc
, NULL
, ctarget
+ i
, SVGA_RELOC_WRITE
);
390 ctarget
[i
] = SVGA3D_INVALID_ID
;
400 SVGA3D_vgpu10_SetBlendState(struct svga_winsys_context
*swc
,
401 SVGA3dBlendStateId blendId
,
402 const float *blendFactor
,
405 SVGA3D_CREATE_COMMAND(SetBlendState
, SET_BLEND_STATE
);
407 SVGA3D_COPY_BASIC_2(blendId
, sampleMask
);
408 memcpy(cmd
->blendFactor
, blendFactor
, sizeof(float) * 4);
415 SVGA3D_vgpu10_SetDepthStencilState(struct svga_winsys_context
*swc
,
416 SVGA3dDepthStencilStateId depthStencilId
,
419 SVGA3D_CREATE_COMMAND(SetDepthStencilState
, SET_DEPTHSTENCIL_STATE
);
421 SVGA3D_COPY_BASIC_2(depthStencilId
, stencilRef
);
428 SVGA3D_vgpu10_SetRasterizerState(struct svga_winsys_context
*swc
,
429 SVGA3dRasterizerStateId rasterizerId
)
431 SVGA3D_CREATE_COMMAND(SetRasterizerState
, SET_RASTERIZER_STATE
);
433 cmd
->rasterizerId
= rasterizerId
;
440 SVGA3D_vgpu10_SetPredication(struct svga_winsys_context
*swc
,
441 SVGA3dQueryId queryId
,
442 uint32 predicateValue
)
444 SVGA3dCmdDXSetPredication
*cmd
;
446 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_SET_PREDICATION
,
450 return PIPE_ERROR_OUT_OF_MEMORY
;
452 cmd
->queryId
= queryId
;
453 cmd
->predicateValue
= predicateValue
;
459 SVGA3D_vgpu10_SetSOTargets(struct svga_winsys_context
*swc
,
461 const SVGA3dSoTarget
*targets
,
462 struct svga_winsys_surface
**surfaces
)
464 SVGA3dCmdDXSetSOTargets
*cmd
;
468 cmd
= SVGA3D_FIFOReserve(swc
,
469 SVGA_3D_CMD_DX_SET_SOTARGETS
,
470 sizeof(SVGA3dCmdDXSetSOTargets
) +
471 count
* sizeof(SVGA3dSoTarget
),
475 return PIPE_ERROR_OUT_OF_MEMORY
;
478 sot
= (SVGA3dSoTarget
*)(cmd
+ 1);
479 for (i
= 0; i
< count
; i
++, sot
++) {
481 sot
->offset
= targets
[i
].offset
;
482 sot
->sizeInBytes
= targets
[i
].sizeInBytes
;
483 swc
->surface_relocation(swc
, &sot
->sid
, NULL
, surfaces
[i
],
488 sot
->sizeInBytes
= ~0u;
489 swc
->surface_relocation(swc
, &sot
->sid
, NULL
, NULL
,
498 SVGA3D_vgpu10_SetScissorRects(struct svga_winsys_context
*swc
,
500 const SVGASignedRect
*rects
)
502 SVGA3dCmdDXSetScissorRects
*cmd
;
505 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_SET_SCISSORRECTS
,
506 sizeof(SVGA3dCmdDXSetScissorRects
) +
507 count
* sizeof(SVGASignedRect
),
510 return PIPE_ERROR_OUT_OF_MEMORY
;
513 memcpy(cmd
+ 1, rects
, count
* sizeof(SVGASignedRect
));
520 SVGA3D_vgpu10_SetStreamOutput(struct svga_winsys_context
*swc
,
521 SVGA3dStreamOutputId soid
)
523 SVGA3D_CREATE_COMMAND(SetStreamOutput
, SET_STREAMOUTPUT
);
532 SVGA3D_vgpu10_Draw(struct svga_winsys_context
*swc
,
534 uint32 startVertexLocation
)
536 SVGA3D_CREATE_COMMAND(Draw
, DRAW
);
538 SVGA3D_COPY_BASIC_2(vertexCount
, startVertexLocation
);
540 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
542 swc
->num_draw_commands
++;
547 SVGA3D_vgpu10_DrawIndexed(struct svga_winsys_context
*swc
,
549 uint32 startIndexLocation
,
550 int32 baseVertexLocation
)
552 SVGA3D_CREATE_COMMAND(DrawIndexed
, DRAW_INDEXED
);
554 SVGA3D_COPY_BASIC_3(indexCount
, startIndexLocation
,
557 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
559 swc
->num_draw_commands
++;
564 SVGA3D_vgpu10_DrawInstanced(struct svga_winsys_context
*swc
,
565 uint32 vertexCountPerInstance
,
566 uint32 instanceCount
,
567 uint32 startVertexLocation
,
568 uint32 startInstanceLocation
)
570 SVGA3D_CREATE_COMMAND(DrawInstanced
, DRAW_INSTANCED
);
572 SVGA3D_COPY_BASIC_4(vertexCountPerInstance
, instanceCount
,
573 startVertexLocation
, startInstanceLocation
);
575 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
577 swc
->num_draw_commands
++;
582 SVGA3D_vgpu10_DrawIndexedInstanced(struct svga_winsys_context
*swc
,
583 uint32 indexCountPerInstance
,
584 uint32 instanceCount
,
585 uint32 startIndexLocation
,
586 int32 baseVertexLocation
,
587 uint32 startInstanceLocation
)
589 SVGA3D_CREATE_COMMAND(DrawIndexedInstanced
, DRAW_INDEXED_INSTANCED
);
591 SVGA3D_COPY_BASIC_5(indexCountPerInstance
, instanceCount
,
592 startIndexLocation
, baseVertexLocation
,
593 startInstanceLocation
);
596 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
598 swc
->num_draw_commands
++;
603 SVGA3D_vgpu10_DrawAuto(struct svga_winsys_context
*swc
)
605 SVGA3D_CREATE_COMMAND(DrawAuto
, DRAW_AUTO
);
608 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
610 swc
->num_draw_commands
++;
615 SVGA3D_vgpu10_DefineQuery(struct svga_winsys_context
*swc
,
616 SVGA3dQueryId queryId
,
617 SVGA3dQueryType type
,
618 SVGA3dDXQueryFlags flags
)
620 SVGA3D_CREATE_COMMAND(DefineQuery
, DEFINE_QUERY
);
622 SVGA3D_COPY_BASIC_3(queryId
, type
, flags
);
629 SVGA3D_vgpu10_DestroyQuery(struct svga_winsys_context
*swc
,
630 SVGA3dQueryId queryId
)
632 SVGA3D_CREATE_COMMAND(DestroyQuery
, DESTROY_QUERY
);
634 cmd
->queryId
= queryId
;
641 SVGA3D_vgpu10_BindQuery(struct svga_winsys_context
*swc
,
642 struct svga_winsys_gb_query
*gbQuery
,
643 SVGA3dQueryId queryId
)
645 SVGA3dCmdDXBindQuery
*cmd
= SVGA3D_FIFOReserve(swc
,
646 SVGA_3D_CMD_DX_BIND_QUERY
,
650 return PIPE_ERROR_OUT_OF_MEMORY
;
652 cmd
->queryId
= queryId
;
653 swc
->query_relocation(swc
, &cmd
->mobid
, gbQuery
);
660 SVGA3D_vgpu10_SetQueryOffset(struct svga_winsys_context
*swc
,
661 SVGA3dQueryId queryId
,
664 SVGA3D_CREATE_COMMAND(SetQueryOffset
, SET_QUERY_OFFSET
);
665 SVGA3D_COPY_BASIC_2(queryId
, mobOffset
);
671 SVGA3D_vgpu10_BeginQuery(struct svga_winsys_context
*swc
,
672 SVGA3dQueryId queryId
)
674 SVGA3D_CREATE_COMMAND(BeginQuery
, BEGIN_QUERY
);
675 cmd
->queryId
= queryId
;
681 SVGA3D_vgpu10_EndQuery(struct svga_winsys_context
*swc
,
682 SVGA3dQueryId queryId
)
684 SVGA3D_CREATE_COMMAND(EndQuery
, END_QUERY
);
685 cmd
->queryId
= queryId
;
692 SVGA3D_vgpu10_ClearDepthStencilView(struct svga_winsys_context
*swc
,
693 struct pipe_surface
*ds_surf
,
698 SVGA3dCmdDXClearDepthStencilView
*cmd
;
699 struct svga_surface
*ss
= svga_surface(ds_surf
);
701 cmd
= SVGA3D_FIFOReserve(swc
,
702 SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW
,
703 sizeof(SVGA3dCmdDXClearDepthStencilView
),
704 1); /* one relocation */
706 return PIPE_ERROR_OUT_OF_MEMORY
;
708 /* NOTE: The following is pretty tricky. We need to emit a view/surface
709 * relocation and we have to provide a pointer to an ID which lies in
710 * the bounds of the command space which we just allocated. However,
711 * we then need to overwrite it with the original DepthStencilViewId.
713 view_relocation(swc
, ds_surf
, &cmd
->depthStencilViewId
,
715 cmd
->depthStencilViewId
= ss
->view_id
;
717 cmd
->stencil
= stencil
;
725 SVGA3D_vgpu10_DefineShaderResourceView(struct svga_winsys_context
*swc
,
726 SVGA3dShaderResourceViewId shaderResourceViewId
,
727 struct svga_winsys_surface
*surface
,
728 SVGA3dSurfaceFormat format
,
729 SVGA3dResourceType resourceDimension
,
730 const SVGA3dShaderResourceViewDesc
*desc
)
732 SVGA3dCmdDXDefineShaderResourceView
*cmd
;
734 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW
,
735 sizeof(SVGA3dCmdDXDefineShaderResourceView
),
736 1); /* one relocation */
738 return PIPE_ERROR_OUT_OF_MEMORY
;
740 SVGA3D_COPY_BASIC_3(shaderResourceViewId
, format
, resourceDimension
);
742 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
752 SVGA3D_vgpu10_DestroyShaderResourceView(struct svga_winsys_context
*swc
,
753 SVGA3dShaderResourceViewId shaderResourceViewId
)
755 SVGA3D_CREATE_COMMAND(DestroyShaderResourceView
,
756 DESTROY_SHADERRESOURCE_VIEW
);
758 cmd
->shaderResourceViewId
= shaderResourceViewId
;
766 SVGA3D_vgpu10_DefineRenderTargetView(struct svga_winsys_context
*swc
,
767 SVGA3dRenderTargetViewId renderTargetViewId
,
768 struct svga_winsys_surface
*surface
,
769 SVGA3dSurfaceFormat format
,
770 SVGA3dResourceType resourceDimension
,
771 const SVGA3dRenderTargetViewDesc
*desc
)
773 SVGA3dCmdDXDefineRenderTargetView
*cmd
;
775 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW
,
776 sizeof(SVGA3dCmdDXDefineRenderTargetView
),
777 1); /* one relocation */
779 return PIPE_ERROR_OUT_OF_MEMORY
;
781 SVGA3D_COPY_BASIC_3(renderTargetViewId
, format
, resourceDimension
);
784 surface_to_resourceid(swc
, surface
,
786 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
793 SVGA3D_vgpu10_DestroyRenderTargetView(struct svga_winsys_context
*swc
,
794 SVGA3dRenderTargetViewId renderTargetViewId
)
796 SVGA3D_CREATE_COMMAND(DestroyRenderTargetView
, DESTROY_RENDERTARGET_VIEW
);
798 cmd
->renderTargetViewId
= renderTargetViewId
;
806 SVGA3D_vgpu10_DefineDepthStencilView(struct svga_winsys_context
*swc
,
807 SVGA3dDepthStencilViewId depthStencilViewId
,
808 struct svga_winsys_surface
*surface
,
809 SVGA3dSurfaceFormat format
,
810 SVGA3dResourceType resourceDimension
,
811 const SVGA3dRenderTargetViewDesc
*desc
)
813 SVGA3dCmdDXDefineDepthStencilView
*cmd
;
815 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW
,
816 sizeof(SVGA3dCmdDXDefineDepthStencilView
),
817 1); /* one relocation */
819 return PIPE_ERROR_OUT_OF_MEMORY
;
821 SVGA3D_COPY_BASIC_3(depthStencilViewId
, format
, resourceDimension
);
822 cmd
->mipSlice
= desc
->tex
.mipSlice
;
823 cmd
->firstArraySlice
= desc
->tex
.firstArraySlice
;
824 cmd
->arraySize
= desc
->tex
.arraySize
;
829 surface_to_resourceid(swc
, surface
,
831 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
838 SVGA3D_vgpu10_DestroyDepthStencilView(struct svga_winsys_context
*swc
,
839 SVGA3dDepthStencilViewId depthStencilViewId
)
841 SVGA3D_CREATE_COMMAND(DestroyDepthStencilView
, DESTROY_DEPTHSTENCIL_VIEW
);
843 cmd
->depthStencilViewId
= depthStencilViewId
;
850 SVGA3D_vgpu10_DefineElementLayout(struct svga_winsys_context
*swc
,
852 SVGA3dElementLayoutId elementLayoutId
,
853 const SVGA3dInputElementDesc
*elements
)
855 SVGA3dCmdDXDefineElementLayout
*cmd
;
858 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT
,
859 sizeof(SVGA3dCmdDXDefineElementLayout
) +
860 count
* sizeof(SVGA3dInputElementDesc
), 0);
862 return PIPE_ERROR_OUT_OF_MEMORY
;
864 /* check that all offsets are multiples of four */
865 for (i
= 0; i
< count
; i
++) {
866 assert(elements
[i
].alignedByteOffset
% 4 == 0);
868 (void) i
; /* silence unused var in release build */
870 cmd
->elementLayoutId
= elementLayoutId
;
871 memcpy(cmd
+ 1, elements
, count
* sizeof(SVGA3dInputElementDesc
));
878 SVGA3D_vgpu10_DestroyElementLayout(struct svga_winsys_context
*swc
,
879 SVGA3dElementLayoutId elementLayoutId
)
881 SVGA3D_CREATE_COMMAND(DestroyElementLayout
, DESTROY_ELEMENTLAYOUT
);
883 cmd
->elementLayoutId
= elementLayoutId
;
890 SVGA3D_vgpu10_DefineBlendState(struct svga_winsys_context
*swc
,
891 SVGA3dBlendStateId blendId
,
892 uint8 alphaToCoverageEnable
,
893 uint8 independentBlendEnable
,
894 const SVGA3dDXBlendStatePerRT
*perRT
)
896 SVGA3D_CREATE_COMMAND(DefineBlendState
, DEFINE_BLEND_STATE
);
898 cmd
->blendId
= blendId
;
899 cmd
->alphaToCoverageEnable
= alphaToCoverageEnable
;
900 cmd
->independentBlendEnable
= independentBlendEnable
;
901 memcpy(cmd
->perRT
, perRT
, sizeof(cmd
->perRT
));
909 SVGA3D_vgpu10_DestroyBlendState(struct svga_winsys_context
*swc
,
910 SVGA3dBlendStateId blendId
)
912 SVGA3D_CREATE_COMMAND(DestroyBlendState
, DESTROY_BLEND_STATE
);
914 cmd
->blendId
= blendId
;
921 SVGA3D_vgpu10_DefineDepthStencilState(struct svga_winsys_context
*swc
,
922 SVGA3dDepthStencilStateId depthStencilId
,
924 SVGA3dDepthWriteMask depthWriteMask
,
925 SVGA3dComparisonFunc depthFunc
,
929 uint8 stencilReadMask
,
930 uint8 stencilWriteMask
,
931 uint8 frontStencilFailOp
,
932 uint8 frontStencilDepthFailOp
,
933 uint8 frontStencilPassOp
,
934 SVGA3dComparisonFunc frontStencilFunc
,
935 uint8 backStencilFailOp
,
936 uint8 backStencilDepthFailOp
,
937 uint8 backStencilPassOp
,
938 SVGA3dComparisonFunc backStencilFunc
)
940 SVGA3D_CREATE_COMMAND(DefineDepthStencilState
, DEFINE_DEPTHSTENCIL_STATE
);
942 SVGA3D_COPY_BASIC_9(depthStencilId
, depthEnable
,
943 depthWriteMask
, depthFunc
,
944 stencilEnable
, frontEnable
,
945 backEnable
, stencilReadMask
,
947 SVGA3D_COPY_BASIC_8(frontStencilFailOp
, frontStencilDepthFailOp
,
948 frontStencilPassOp
, frontStencilFunc
,
949 backStencilFailOp
, backStencilDepthFailOp
,
950 backStencilPassOp
, backStencilFunc
);
957 SVGA3D_vgpu10_DestroyDepthStencilState(struct svga_winsys_context
*swc
,
958 SVGA3dDepthStencilStateId depthStencilId
)
960 SVGA3D_CREATE_COMMAND(DestroyDepthStencilState
,
961 DESTROY_DEPTHSTENCIL_STATE
);
963 cmd
->depthStencilId
= depthStencilId
;
970 SVGA3D_vgpu10_DefineRasterizerState(struct svga_winsys_context
*swc
,
971 SVGA3dRasterizerStateId rasterizerId
,
973 SVGA3dCullMode cullMode
,
974 uint8 frontCounterClockwise
,
976 float depthBiasClamp
,
977 float slopeScaledDepthBias
,
978 uint8 depthClipEnable
,
980 uint8 multisampleEnable
,
981 uint8 antialiasedLineEnable
,
983 uint8 lineStippleEnable
,
984 uint8 lineStippleFactor
,
985 uint16 lineStipplePattern
,
986 uint8 provokingVertexLast
)
988 SVGA3D_CREATE_COMMAND(DefineRasterizerState
, DEFINE_RASTERIZER_STATE
);
990 SVGA3D_COPY_BASIC_5(rasterizerId
, fillMode
,
991 cullMode
, frontCounterClockwise
,
993 SVGA3D_COPY_BASIC_6(depthBiasClamp
, slopeScaledDepthBias
,
994 depthClipEnable
, scissorEnable
,
995 multisampleEnable
, antialiasedLineEnable
);
996 cmd
->lineWidth
= lineWidth
;
997 cmd
->lineStippleEnable
= lineStippleEnable
;
998 cmd
->lineStippleFactor
= lineStippleFactor
;
999 cmd
->lineStipplePattern
= lineStipplePattern
;
1000 cmd
->provokingVertexLast
= provokingVertexLast
;
1007 SVGA3D_vgpu10_DestroyRasterizerState(struct svga_winsys_context
*swc
,
1008 SVGA3dRasterizerStateId rasterizerId
)
1010 SVGA3D_CREATE_COMMAND(DestroyRasterizerState
, DESTROY_RASTERIZER_STATE
);
1012 cmd
->rasterizerId
= rasterizerId
;
1019 SVGA3D_vgpu10_DefineSamplerState(struct svga_winsys_context
*swc
,
1020 SVGA3dSamplerId samplerId
,
1021 SVGA3dFilter filter
,
1026 uint8 maxAnisotropy
,
1027 uint8 comparisonFunc
,
1028 SVGA3dRGBAFloat borderColor
,
1032 SVGA3D_CREATE_COMMAND(DefineSamplerState
, DEFINE_SAMPLER_STATE
);
1034 SVGA3D_COPY_BASIC_6(samplerId
, filter
,
1036 addressW
, mipLODBias
);
1037 SVGA3D_COPY_BASIC_5(maxAnisotropy
, comparisonFunc
,
1038 borderColor
, minLOD
,
1048 SVGA3D_vgpu10_DestroySamplerState(struct svga_winsys_context
*swc
,
1049 SVGA3dSamplerId samplerId
)
1051 SVGA3D_CREATE_COMMAND(DestroySamplerState
, DESTROY_SAMPLER_STATE
);
1053 cmd
->samplerId
= samplerId
;
1061 SVGA3D_vgpu10_DefineAndBindShader(struct svga_winsys_context
*swc
,
1062 struct svga_winsys_gb_shader
*gbshader
,
1063 SVGA3dShaderId shaderId
,
1064 SVGA3dShaderType type
,
1067 SVGA3dCmdHeader
*header
;
1068 SVGA3dCmdDXDefineShader
*dcmd
;
1069 SVGA3dCmdDXBindShader
*bcmd
;
1070 unsigned totalSize
= 2 * sizeof(*header
) +
1071 sizeof(*dcmd
) + sizeof(*bcmd
);
1073 /* Make sure there is room for both commands */
1074 header
= swc
->reserve(swc
, totalSize
, 2);
1076 return PIPE_ERROR_OUT_OF_MEMORY
;
1078 /* DXDefineShader command */
1079 header
->id
= SVGA_3D_CMD_DX_DEFINE_SHADER
;
1080 header
->size
= sizeof(*dcmd
);
1081 dcmd
= (SVGA3dCmdDXDefineShader
*)(header
+ 1);
1082 dcmd
->shaderId
= shaderId
;
1084 dcmd
->sizeInBytes
= sizeInBytes
;
1086 /* DXBindShader command */
1087 header
= (SVGA3dCmdHeader
*)(dcmd
+ 1);
1089 header
->id
= SVGA_3D_CMD_DX_BIND_SHADER
;
1090 header
->size
= sizeof(*bcmd
);
1091 bcmd
= (SVGA3dCmdDXBindShader
*)(header
+ 1);
1093 bcmd
->cid
= swc
->cid
;
1094 swc
->shader_relocation(swc
, NULL
, &bcmd
->mobid
,
1095 &bcmd
->offsetInBytes
, gbshader
, 0);
1097 bcmd
->shid
= shaderId
;
1104 SVGA3D_vgpu10_DestroyShader(struct svga_winsys_context
*swc
,
1105 SVGA3dShaderId shaderId
)
1107 SVGA3D_CREATE_COMMAND(DestroyShader
, DESTROY_SHADER
);
1109 cmd
->shaderId
= shaderId
;
1116 SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context
*swc
,
1117 SVGA3dStreamOutputId soid
,
1118 uint32 numOutputStreamEntries
,
1119 uint32 streamOutputStrideInBytes
[SVGA3D_DX_MAX_SOTARGETS
],
1120 const SVGA3dStreamOutputDeclarationEntry decl
[SVGA3D_MAX_STREAMOUT_DECLS
])
1123 SVGA3D_CREATE_COMMAND(DefineStreamOutput
, DEFINE_STREAMOUTPUT
);
1126 cmd
->numOutputStreamEntries
= numOutputStreamEntries
;
1128 for (i
= 0; i
< ARRAY_SIZE(cmd
->streamOutputStrideInBytes
); i
++)
1129 cmd
->streamOutputStrideInBytes
[i
] = streamOutputStrideInBytes
[i
];
1131 memcpy(cmd
->decl
, decl
,
1132 sizeof(SVGA3dStreamOutputDeclarationEntry
)
1133 * SVGA3D_MAX_DX10_STREAMOUT_DECLS
);
1135 cmd
->rasterizedStream
= 0;
1141 SVGA3D_vgpu10_DestroyStreamOutput(struct svga_winsys_context
*swc
,
1142 SVGA3dStreamOutputId soid
)
1144 SVGA3D_CREATE_COMMAND(DestroyStreamOutput
, DESTROY_STREAMOUTPUT
);
1153 SVGA3D_vgpu10_SetInputLayout(struct svga_winsys_context
*swc
,
1154 SVGA3dElementLayoutId elementLayoutId
)
1156 SVGA3D_CREATE_COMMAND(SetInputLayout
, SET_INPUT_LAYOUT
);
1158 cmd
->elementLayoutId
= elementLayoutId
;
1165 SVGA3D_vgpu10_SetVertexBuffers(struct svga_winsys_context
*swc
,
1168 const SVGA3dVertexBuffer
*bufferInfo
,
1169 struct svga_winsys_surface
**surfaces
)
1171 SVGA3dCmdDXSetVertexBuffers
*cmd
;
1172 SVGA3dVertexBuffer
*bufs
;
1177 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS
,
1178 sizeof(SVGA3dCmdDXSetVertexBuffers
) +
1179 count
* sizeof(SVGA3dVertexBuffer
),
1180 count
); /* 'count' relocations */
1182 return PIPE_ERROR_OUT_OF_MEMORY
;
1184 cmd
->startBuffer
= startBuffer
;
1186 bufs
= (SVGA3dVertexBuffer
*) &cmd
[1];
1187 for (i
= 0; i
< count
; i
++) {
1188 bufs
[i
].stride
= bufferInfo
[i
].stride
;
1189 bufs
[i
].offset
= bufferInfo
[i
].offset
;
1190 assert(bufs
[i
].stride
% 4 == 0);
1191 assert(bufs
[i
].offset
% 4 == 0);
1192 swc
->surface_relocation(swc
, &bufs
[i
].sid
, NULL
, surfaces
[i
],
1201 SVGA3D_vgpu10_SetTopology(struct svga_winsys_context
*swc
,
1202 SVGA3dPrimitiveType topology
)
1204 SVGA3D_CREATE_COMMAND(SetTopology
, SET_TOPOLOGY
);
1206 cmd
->topology
= topology
;
1213 SVGA3D_vgpu10_SetIndexBuffer(struct svga_winsys_context
*swc
,
1214 struct svga_winsys_surface
*indexes
,
1215 SVGA3dSurfaceFormat format
,
1218 SVGA3dCmdDXSetIndexBuffer
*cmd
;
1220 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_SET_INDEX_BUFFER
,
1221 sizeof(SVGA3dCmdDXSetIndexBuffer
),
1222 1); /* one relocations */
1224 return PIPE_ERROR_OUT_OF_MEMORY
;
1226 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, indexes
, SVGA_RELOC_READ
);
1227 SVGA3D_COPY_BASIC_2(format
, offset
);
1234 SVGA3D_vgpu10_SetSingleConstantBuffer(struct svga_winsys_context
*swc
,
1236 SVGA3dShaderType type
,
1237 struct svga_winsys_surface
*surface
,
1238 uint32 offsetInBytes
,
1241 SVGA3dCmdDXSetSingleConstantBuffer
*cmd
;
1243 assert(offsetInBytes
% 256 == 0);
1245 assert(sizeInBytes
== 0);
1247 assert(sizeInBytes
> 0);
1249 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER
,
1250 sizeof(SVGA3dCmdDXSetSingleConstantBuffer
),
1251 1); /* one relocation */
1253 return PIPE_ERROR_OUT_OF_MEMORY
;
1257 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
, SVGA_RELOC_READ
);
1258 cmd
->offsetInBytes
= offsetInBytes
;
1259 cmd
->sizeInBytes
= sizeInBytes
;
1268 SVGA3D_vgpu10_ReadbackSubResource(struct svga_winsys_context
*swc
,
1269 struct svga_winsys_surface
*surface
,
1270 unsigned subResource
)
1272 SVGA3dCmdDXReadbackSubResource
*cmd
;
1274 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_READBACK_SUBRESOURCE
,
1275 sizeof(SVGA3dCmdDXReadbackSubResource
),
1278 return PIPE_ERROR_OUT_OF_MEMORY
;
1280 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1281 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1282 cmd
->subResource
= subResource
;
1289 SVGA3D_vgpu10_UpdateSubResource(struct svga_winsys_context
*swc
,
1290 struct svga_winsys_surface
*surface
,
1291 const SVGA3dBox
*box
,
1292 unsigned subResource
)
1294 SVGA3dCmdDXUpdateSubResource
*cmd
;
1296 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE
,
1297 sizeof(SVGA3dCmdDXUpdateSubResource
),
1300 return PIPE_ERROR_OUT_OF_MEMORY
;
1302 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1303 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1304 cmd
->subResource
= subResource
;
1312 SVGA3D_vgpu10_GenMips(struct svga_winsys_context
*swc
,
1313 SVGA3dShaderResourceViewId shaderResourceViewId
,
1314 struct svga_winsys_surface
*view
)
1316 SVGA3dCmdDXGenMips
*cmd
;
1318 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_GENMIPS
,
1319 sizeof(SVGA3dCmdDXGenMips
), 1);
1322 return PIPE_ERROR_OUT_OF_MEMORY
;
1324 swc
->surface_relocation(swc
, &cmd
->shaderResourceViewId
, NULL
, view
,
1326 cmd
->shaderResourceViewId
= shaderResourceViewId
;
1334 SVGA3D_vgpu10_BufferCopy(struct svga_winsys_context
*swc
,
1335 struct svga_winsys_surface
*src
,
1336 struct svga_winsys_surface
*dst
,
1337 unsigned srcx
, unsigned dstx
, unsigned width
)
1339 SVGA3dCmdDXBufferCopy
*cmd
;
1341 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_BUFFER_COPY
, sizeof *cmd
, 2);
1344 return PIPE_ERROR_OUT_OF_MEMORY
;
1346 swc
->surface_relocation(swc
, &cmd
->dest
, NULL
, dst
, SVGA_RELOC_WRITE
);
1347 swc
->surface_relocation(swc
, &cmd
->src
, NULL
, src
, SVGA_RELOC_READ
);
1357 SVGA3D_vgpu10_TransferFromBuffer(struct svga_winsys_context
*swc
,
1358 struct svga_winsys_surface
*src
,
1359 unsigned srcOffset
, unsigned srcPitch
,
1360 unsigned srcSlicePitch
,
1361 struct svga_winsys_surface
*dst
,
1362 unsigned dstSubResource
,
1365 SVGA3dCmdDXTransferFromBuffer
*cmd
;
1367 cmd
= SVGA3D_FIFOReserve(swc
, SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER
,
1368 sizeof(SVGA3dCmdDXTransferFromBuffer
), 2);
1371 return PIPE_ERROR_OUT_OF_MEMORY
;
1373 swc
->surface_relocation(swc
, &cmd
->srcSid
, NULL
, src
, SVGA_RELOC_READ
);
1374 swc
->surface_relocation(swc
, &cmd
->destSid
, NULL
, dst
, SVGA_RELOC_WRITE
);
1375 cmd
->srcOffset
= srcOffset
;
1376 cmd
->srcPitch
= srcPitch
;
1377 cmd
->srcSlicePitch
= srcSlicePitch
;
1378 cmd
->destSubResource
= dstSubResource
;
1379 cmd
->destBox
= *dstBox
;
1386 SVGA3D_vgpu10_IntraSurfaceCopy(struct svga_winsys_context
*swc
,
1387 struct svga_winsys_surface
*surface
,
1388 unsigned level
, unsigned face
,
1389 const SVGA3dCopyBox
*box
)
1391 SVGA3dCmdIntraSurfaceCopy
*cmd
=
1392 SVGA3D_FIFOReserve(swc
,
1393 SVGA_3D_CMD_INTRA_SURFACE_COPY
,
1394 sizeof(SVGA3dCmdIntraSurfaceCopy
),
1395 1); /* one relocation */
1397 return PIPE_ERROR_OUT_OF_MEMORY
;
1399 swc
->surface_relocation(swc
, &cmd
->surface
.sid
, NULL
, surface
, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1400 cmd
->surface
.face
= face
;
1401 cmd
->surface
.mipmap
= level
;
1410 SVGA3D_vgpu10_ResolveCopy(struct svga_winsys_context
*swc
,
1411 unsigned dstSubResource
,
1412 struct svga_winsys_surface
*dst
,
1413 unsigned srcSubResource
,
1414 struct svga_winsys_surface
*src
,
1415 const SVGA3dSurfaceFormat copyFormat
)
1417 SVGA3dCmdDXResolveCopy
*cmd
=
1418 SVGA3D_FIFOReserve(swc
,
1419 SVGA_3D_CMD_DX_RESOLVE_COPY
,
1420 sizeof(SVGA3dCmdDXResolveCopy
),
1421 2); /* two relocations */
1423 return PIPE_ERROR_OUT_OF_MEMORY
;
1425 cmd
->dstSubResource
= dstSubResource
;
1426 swc
->surface_relocation(swc
, &cmd
->dstSid
, NULL
, dst
, SVGA_RELOC_WRITE
);
1427 cmd
->srcSubResource
= srcSubResource
;
1428 swc
->surface_relocation(swc
, &cmd
->srcSid
, NULL
, src
, SVGA_RELOC_READ
);
1429 cmd
->copyFormat
= copyFormat
;
1438 SVGA3D_sm5_DrawIndexedInstancedIndirect(struct svga_winsys_context
*swc
,
1439 struct svga_winsys_surface
*argBuffer
,
1442 SVGA3dCmdDXDrawIndexedInstancedIndirect
*cmd
=
1443 SVGA3D_FIFOReserve(swc
,
1444 SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT
,
1445 sizeof(SVGA3dCmdDXDrawIndexedInstancedIndirect
),
1446 1); /* one relocation */
1448 return PIPE_ERROR_OUT_OF_MEMORY
;
1450 swc
->surface_relocation(swc
, &cmd
->argsBufferSid
, NULL
, argBuffer
,
1452 cmd
->byteOffsetForArgs
= argOffset
;
1461 SVGA3D_sm5_DrawInstancedIndirect(struct svga_winsys_context
*swc
,
1462 struct svga_winsys_surface
*argBuffer
,
1465 SVGA3dCmdDXDrawInstancedIndirect
*cmd
=
1466 SVGA3D_FIFOReserve(swc
,
1467 SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT
,
1468 sizeof(SVGA3dCmdDXDrawInstancedIndirect
),
1469 1); /* one relocation */
1471 return PIPE_ERROR_OUT_OF_MEMORY
;
1473 swc
->surface_relocation(swc
, &cmd
->argsBufferSid
, NULL
, argBuffer
,
1475 cmd
->byteOffsetForArgs
= argOffset
;
1484 SVGA3D_sm5_Dispatch(struct svga_winsys_context
*swc
,
1485 const uint32 threadGroupCount
[3])
1487 SVGA3dCmdDXDispatch
*cmd
;
1489 cmd
= SVGA3D_FIFOReserve(swc
,
1490 SVGA_3D_CMD_DX_DISPATCH
,
1491 sizeof(SVGA3dCmdDXDispatch
),
1494 return PIPE_ERROR_OUT_OF_MEMORY
;
1496 cmd
->threadGroupCountX
= threadGroupCount
[0];
1497 cmd
->threadGroupCountY
= threadGroupCount
[1];
1498 cmd
->threadGroupCountZ
= threadGroupCount
[2];
1506 SVGA3D_sm5_DispatchIndirect(struct svga_winsys_context
*swc
,
1507 struct svga_winsys_surface
*argBuffer
,
1510 SVGA3dCmdDXDispatchIndirect
*cmd
;
1512 cmd
= SVGA3D_FIFOReserve(swc
,
1513 SVGA_3D_CMD_DX_DISPATCH_INDIRECT
,
1514 sizeof(SVGA3dCmdDXDispatchIndirect
),
1517 return PIPE_ERROR_OUT_OF_MEMORY
;
1519 swc
->surface_relocation(swc
, &cmd
->argsBufferSid
, NULL
, argBuffer
,
1521 cmd
->byteOffsetForArgs
= argOffset
;
1529 * We don't want any flush between DefineStreamOutputWithMob and
1530 * BindStreamOutput because it will cause partial state in command
1531 * buffer. This function make that sure there is enough room for
1532 * both commands before issuing them
1536 SVGA3D_sm5_DefineAndBindStreamOutput(struct svga_winsys_context
*swc
,
1537 SVGA3dStreamOutputId soid
,
1538 uint32 numOutputStreamEntries
,
1539 uint32 numOutputStreamStrides
,
1540 uint32 streamOutputStrideInBytes
[SVGA3D_DX_MAX_SOTARGETS
],
1541 struct svga_winsys_buffer
*declBuf
,
1542 uint32 rasterizedStream
,
1546 SVGA3dCmdHeader
*header
;
1547 SVGA3dCmdDXDefineStreamOutputWithMob
*dcmd
;
1548 SVGA3dCmdDXBindStreamOutput
*bcmd
;
1550 unsigned totalSize
= 2 * sizeof(*header
) +
1551 sizeof(*dcmd
) + sizeof(*bcmd
);
1553 /* Make sure there is room for both commands */
1554 header
= swc
->reserve(swc
, totalSize
, 2);
1556 return PIPE_ERROR_OUT_OF_MEMORY
;
1558 /* DXDefineStreamOutputWithMob command */
1559 header
->id
= SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB
;
1560 header
->size
= sizeof(*dcmd
);
1561 dcmd
= (SVGA3dCmdDXDefineStreamOutputWithMob
*)(header
+ 1);
1563 dcmd
->numOutputStreamEntries
= numOutputStreamEntries
;
1564 dcmd
->numOutputStreamStrides
= numOutputStreamStrides
;
1565 dcmd
->rasterizedStream
= rasterizedStream
;
1567 for (i
= 0; i
< ARRAY_SIZE(dcmd
->streamOutputStrideInBytes
); i
++)
1568 dcmd
->streamOutputStrideInBytes
[i
] = streamOutputStrideInBytes
[i
];
1571 /* DXBindStreamOutput command */
1572 header
= (SVGA3dCmdHeader
*)(dcmd
+ 1);
1574 header
->id
= SVGA_3D_CMD_DX_BIND_STREAMOUTPUT
;
1575 header
->size
= sizeof(*bcmd
);
1576 bcmd
= (SVGA3dCmdDXBindStreamOutput
*)(header
+ 1);
1579 bcmd
->offsetInBytes
= 0;
1580 swc
->mob_relocation(swc
, &bcmd
->mobid
,
1581 &bcmd
->offsetInBytes
, declBuf
, 0,
1584 bcmd
->sizeInBytes
= sizeInBytes
;
1585 bcmd
->offsetInBytes
= 0;