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.
33 #include "svga_winsys.h"
34 #include "svga_resource_buffer.h"
35 #include "svga_resource_texture.h"
36 #include "svga_surface.h"
40 *----------------------------------------------------------------------
42 * surface_to_surfaceid --
44 * Utility function for surface ids.
45 * Can handle null surface. Does a surface_reallocation so you need
46 * to have allocated the fifo space before converting.
49 * param flags mask of SVGA_RELOC_READ / _WRITE
55 * One surface relocation is performed for texture handle.
57 *----------------------------------------------------------------------
61 surface_to_surfaceid(struct svga_winsys_context
*swc
, // IN
62 struct pipe_surface
*surface
, // IN
63 SVGA3dSurfaceImageId
*id
, // OUT
67 struct svga_surface
*s
= svga_surface(surface
);
68 swc
->surface_relocation(swc
, &id
->sid
, NULL
, s
->handle
, flags
);
69 id
->face
= s
->real_layer
; /* faces have the same order */
70 id
->mipmap
= s
->real_level
;
73 swc
->surface_relocation(swc
, &id
->sid
, NULL
, NULL
, flags
);
81 *----------------------------------------------------------------------
83 * SVGA3D_FIFOReserve --
85 * Reserve space for an SVGA3D FIFO command.
87 * The 2D SVGA commands have been around for a while, so they
88 * have a rather asymmetric structure. The SVGA3D protocol is
89 * more uniform: each command begins with a header containing the
90 * command number and the full size.
92 * This is a convenience wrapper around SVGA_FIFOReserve. We
93 * reserve space for the whole command, and write the header.
95 * This function must be paired with SVGA_FIFOCommitAll().
98 * Returns a pointer to the space reserved for command-specific
99 * data. It must be 'cmdSize' bytes long.
102 * Begins a FIFO reservation.
104 *----------------------------------------------------------------------
108 SVGA3D_FIFOReserve(struct svga_winsys_context
*swc
,
110 uint32 cmdSize
, // IN
111 uint32 nr_relocs
) // IN
113 SVGA3dCmdHeader
*header
;
115 header
= swc
->reserve(swc
, sizeof *header
+ cmdSize
, nr_relocs
);
120 header
->size
= cmdSize
;
122 swc
->last_command
= cmd
;
131 SVGA_FIFOCommitAll(struct svga_winsys_context
*swc
)
138 *----------------------------------------------------------------------
140 * SVGA3D_DefineContext --
142 * Create a new context, to be referred to with the provided ID.
144 * Context objects encapsulate all render state, and shader
145 * objects are per-context.
147 * Surfaces are not per-context. The same surface can be shared
148 * between multiple contexts, and surface operations can occur
151 * If the provided context ID already existed, it is redefined.
153 * Context IDs are arbitrary small non-negative integers,
154 * global to the entire SVGA device.
162 *----------------------------------------------------------------------
166 SVGA3D_DefineContext(struct svga_winsys_context
*swc
) // IN
168 SVGA3dCmdDefineContext
*cmd
;
170 cmd
= SVGA3D_FIFOReserve(swc
,
171 SVGA_3D_CMD_CONTEXT_DEFINE
, sizeof *cmd
, 0);
173 return PIPE_ERROR_OUT_OF_MEMORY
;
184 *----------------------------------------------------------------------
186 * SVGA3D_DestroyContext --
188 * Delete a context created with SVGA3D_DefineContext.
196 *----------------------------------------------------------------------
200 SVGA3D_DestroyContext(struct svga_winsys_context
*swc
) // IN
202 SVGA3dCmdDestroyContext
*cmd
;
204 cmd
= SVGA3D_FIFOReserve(swc
,
205 SVGA_3D_CMD_CONTEXT_DESTROY
, sizeof *cmd
, 0);
207 return PIPE_ERROR_OUT_OF_MEMORY
;
218 *----------------------------------------------------------------------
220 * SVGA3D_BeginDefineSurface --
222 * Begin a SURFACE_DEFINE command. This reserves space for it in
223 * the FIFO, and returns pointers to the command's faces and
226 * This function must be paired with SVGA_FIFOCommitAll().
227 * The faces and mipSizes arrays are initialized to zero.
229 * This creates a "surface" object in the SVGA3D device,
230 * with the provided surface ID (sid). Surfaces are generic
231 * containers for host VRAM objects like textures, vertex
232 * buffers, and depth/stencil buffers.
234 * Surfaces are hierarchical:
236 * - Surface may have multiple faces (for cube maps)
238 * - Each face has a list of mipmap levels
240 * - Each mipmap image may have multiple volume
241 * slices, if the image is three dimensional.
243 * - Each slice is a 2D array of 'blocks'
245 * - Each block may be one or more pixels.
246 * (Usually 1, more for DXT or YUV formats.)
248 * Surfaces are generic host VRAM objects. The SVGA3D device
249 * may optimize surfaces according to the format they were
250 * created with, but this format does not limit the ways in
251 * which the surface may be used. For example, a depth surface
252 * can be used as a texture, or a floating point image may
253 * be used as a vertex buffer. Some surface usages may be
254 * lower performance, due to software emulation, but any
255 * usage should work with any surface.
257 * If 'sid' is already defined, the old surface is deleted
258 * and this new surface replaces it.
260 * Surface IDs are arbitrary small non-negative integers,
261 * global to the entire SVGA device.
264 * Returns pointers to arrays allocated in the FIFO for 'faces'
268 * Begins a FIFO reservation.
270 *----------------------------------------------------------------------
274 SVGA3D_BeginDefineSurface(struct svga_winsys_context
*swc
,
275 struct svga_winsys_surface
*sid
, // IN
276 SVGA3dSurface1Flags flags
, // IN
277 SVGA3dSurfaceFormat format
, // IN
278 SVGA3dSurfaceFace
**faces
, // OUT
279 SVGA3dSize
**mipSizes
, // OUT
280 uint32 numMipSizes
) // IN
282 SVGA3dCmdDefineSurface
*cmd
;
284 cmd
= SVGA3D_FIFOReserve(swc
,
285 SVGA_3D_CMD_SURFACE_DEFINE
, sizeof *cmd
+
286 sizeof **mipSizes
* numMipSizes
, 1);
288 return PIPE_ERROR_OUT_OF_MEMORY
;
290 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
291 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
292 cmd
->surfaceFlags
= flags
;
293 cmd
->format
= format
;
295 *faces
= &cmd
->face
[0];
296 *mipSizes
= (SVGA3dSize
*) &cmd
[1];
298 memset(*faces
, 0, sizeof **faces
* SVGA3D_MAX_SURFACE_FACES
);
299 memset(*mipSizes
, 0, sizeof **mipSizes
* numMipSizes
);
306 *----------------------------------------------------------------------
308 * SVGA3D_DefineSurface2D --
310 * This is a simplified version of SVGA3D_BeginDefineSurface(),
311 * which does not support cube maps, mipmaps, or volume textures.
319 *----------------------------------------------------------------------
323 SVGA3D_DefineSurface2D(struct svga_winsys_context
*swc
, // IN
324 struct svga_winsys_surface
*sid
, // IN
327 SVGA3dSurfaceFormat format
) // IN
329 SVGA3dSize
*mipSizes
;
330 SVGA3dSurfaceFace
*faces
;
333 ret
= SVGA3D_BeginDefineSurface(swc
,
334 sid
, 0, format
, &faces
, &mipSizes
, 1);
338 faces
[0].numMipLevels
= 1;
340 mipSizes
[0].width
= width
;
341 mipSizes
[0].height
= height
;
342 mipSizes
[0].depth
= 1;
351 *----------------------------------------------------------------------
353 * SVGA3D_DestroySurface --
355 * Release the host VRAM encapsulated by a particular surface ID.
363 *----------------------------------------------------------------------
367 SVGA3D_DestroySurface(struct svga_winsys_context
*swc
,
368 struct svga_winsys_surface
*sid
) // IN
370 SVGA3dCmdDestroySurface
*cmd
;
372 cmd
= SVGA3D_FIFOReserve(swc
,
373 SVGA_3D_CMD_SURFACE_DESTROY
, sizeof *cmd
, 1);
375 return PIPE_ERROR_OUT_OF_MEMORY
;
377 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
378 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
386 *----------------------------------------------------------------------
388 * SVGA3D_SurfaceDMA--
390 * Emit a SURFACE_DMA command.
392 * When the SVGA3D device asynchronously processes this FIFO
393 * command, a DMA operation is performed between host VRAM and
394 * a generic SVGAGuestPtr. The guest pointer may refer to guest
395 * VRAM (provided by the SVGA PCI device) or to guest system
396 * memory that has been set up as a Guest Memory Region (GMR)
397 * by the SVGA device.
399 * The guest's DMA buffer must remain valid (not freed, paged out,
400 * or overwritten) until the host has finished processing this
401 * command. The guest can determine that the host has finished
402 * by using the SVGA device's FIFO Fence mechanism.
404 * The guest's image buffer can be an arbitrary size and shape.
405 * Guest image data is interpreted according to the SVGA3D surface
406 * format specified when the surface was defined.
408 * The caller may optionally define the guest image's pitch.
409 * guestImage->pitch can either be zero (assume image is tightly
410 * packed) or it must be the number of bytes between vertically
411 * adjacent image blocks.
413 * The provided copybox list specifies which regions of the source
414 * image are to be copied, and where they appear on the destination.
416 * NOTE: srcx/srcy are always on the guest image and x/y are
417 * always on the host image, regardless of the actual transfer
420 * For efficiency, the SVGA3D device is free to copy more data
421 * than specified. For example, it may round copy boxes outwards
422 * such that they lie on particular alignment boundaries.
424 *----------------------------------------------------------------------
428 SVGA3D_SurfaceDMA(struct svga_winsys_context
*swc
,
429 struct svga_transfer
*st
, // IN
430 SVGA3dTransferType transfer
, // IN
431 const SVGA3dCopyBox
*boxes
, // IN
432 uint32 numBoxes
, // IN
433 SVGA3dSurfaceDMAFlags flags
) // IN
435 struct svga_texture
*texture
= svga_texture(st
->base
.resource
);
436 SVGA3dCmdSurfaceDMA
*cmd
;
437 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
438 uint32 boxesSize
= sizeof *boxes
* numBoxes
;
439 unsigned region_flags
;
440 unsigned surface_flags
;
442 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
443 region_flags
= SVGA_RELOC_READ
;
444 surface_flags
= SVGA_RELOC_WRITE
;
446 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
447 region_flags
= SVGA_RELOC_WRITE
;
448 surface_flags
= SVGA_RELOC_READ
;
452 return PIPE_ERROR_BAD_INPUT
;
455 cmd
= SVGA3D_FIFOReserve(swc
,
456 SVGA_3D_CMD_SURFACE_DMA
,
457 sizeof *cmd
+ boxesSize
+ sizeof *pSuffix
,
460 return PIPE_ERROR_OUT_OF_MEMORY
;
462 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, st
->hwbuf
, 0, region_flags
);
463 cmd
->guest
.pitch
= st
->base
.stride
;
465 swc
->surface_relocation(swc
, &cmd
->host
.sid
, NULL
,
466 texture
->handle
, surface_flags
);
467 cmd
->host
.face
= st
->slice
; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
468 cmd
->host
.mipmap
= st
->base
.level
;
470 cmd
->transfer
= transfer
;
472 memcpy(&cmd
[1], boxes
, boxesSize
);
474 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ boxesSize
);
475 pSuffix
->suffixSize
= sizeof *pSuffix
;
476 pSuffix
->maximumOffset
= st
->hw_nblocksy
*st
->base
.stride
;
477 pSuffix
->flags
= flags
;
480 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
487 SVGA3D_BufferDMA(struct svga_winsys_context
*swc
,
488 struct svga_winsys_buffer
*guest
,
489 struct svga_winsys_surface
*host
,
490 SVGA3dTransferType transfer
, // IN
492 uint32 guest_offset
, // IN
493 uint32 host_offset
, // IN
494 SVGA3dSurfaceDMAFlags flags
) // IN
496 SVGA3dCmdSurfaceDMA
*cmd
;
498 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
499 unsigned region_flags
;
500 unsigned surface_flags
;
502 assert(!swc
->have_gb_objects
);
504 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
505 region_flags
= SVGA_RELOC_READ
;
506 surface_flags
= SVGA_RELOC_WRITE
;
508 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
509 region_flags
= SVGA_RELOC_WRITE
;
510 surface_flags
= SVGA_RELOC_READ
;
514 return PIPE_ERROR_BAD_INPUT
;
517 cmd
= SVGA3D_FIFOReserve(swc
,
518 SVGA_3D_CMD_SURFACE_DMA
,
519 sizeof *cmd
+ sizeof *box
+ sizeof *pSuffix
,
522 return PIPE_ERROR_OUT_OF_MEMORY
;
524 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, guest
, 0, region_flags
);
525 cmd
->guest
.pitch
= 0;
527 swc
->surface_relocation(swc
, &cmd
->host
.sid
,
528 NULL
, host
, surface_flags
);
530 cmd
->host
.mipmap
= 0;
532 cmd
->transfer
= transfer
;
534 box
= (SVGA3dCopyBox
*)&cmd
[1];
535 box
->x
= host_offset
;
541 box
->srcx
= guest_offset
;
545 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ sizeof *box
);
546 pSuffix
->suffixSize
= sizeof *pSuffix
;
547 pSuffix
->maximumOffset
= guest_offset
+ size
;
548 pSuffix
->flags
= flags
;
551 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
558 *----------------------------------------------------------------------
560 * SVGA3D_SetRenderTarget --
562 * Bind a surface object to a particular render target attachment
563 * point on the current context. Render target attachment points
564 * exist for color buffers, a depth buffer, and a stencil buffer.
566 * The SVGA3D device is quite lenient about the types of surfaces
567 * that may be used as render targets. The color buffers must
568 * all be the same size, but the depth and stencil buffers do not
569 * have to be the same size as the color buffer. All attachments
572 * Some combinations of render target formats may require software
573 * emulation, depending on the capabilities of the host graphics
574 * API and graphics hardware.
582 *----------------------------------------------------------------------
586 SVGA3D_SetRenderTarget(struct svga_winsys_context
*swc
,
587 SVGA3dRenderTargetType type
, // IN
588 struct pipe_surface
*surface
) // IN
590 SVGA3dCmdSetRenderTarget
*cmd
;
592 cmd
= SVGA3D_FIFOReserve(swc
,
593 SVGA_3D_CMD_SETRENDERTARGET
, sizeof *cmd
, 1);
595 return PIPE_ERROR_OUT_OF_MEMORY
;
599 surface_to_surfaceid(swc
, surface
, &cmd
->target
, SVGA_RELOC_WRITE
);
607 *----------------------------------------------------------------------
609 * SVGA3D_DefineShader --
611 * Upload the bytecode for a new shader. The bytecode is "SVGA3D
612 * format", which is theoretically a binary-compatible superset
613 * of Microsoft's DirectX shader bytecode. In practice, the
614 * SVGA3D bytecode doesn't yet have any extensions to DirectX's
617 * The SVGA3D device supports shader models 1.1 through 2.0.
619 * The caller chooses a shader ID (small positive integer) by
620 * which this shader will be identified in future commands. This
621 * ID is in a namespace which is per-context and per-shader-type.
623 * 'bytecodeLen' is specified in bytes. It must be a multiple of 4.
631 *----------------------------------------------------------------------
635 SVGA3D_DefineShader(struct svga_winsys_context
*swc
,
637 SVGA3dShaderType type
, // IN
638 const uint32
*bytecode
, // IN
639 uint32 bytecodeLen
) // IN
641 SVGA3dCmdDefineShader
*cmd
;
643 assert(bytecodeLen
% 4 == 0);
645 cmd
= SVGA3D_FIFOReserve(swc
,
646 SVGA_3D_CMD_SHADER_DEFINE
, sizeof *cmd
+ bytecodeLen
,
649 return PIPE_ERROR_OUT_OF_MEMORY
;
654 memcpy(&cmd
[1], bytecode
, bytecodeLen
);
662 *----------------------------------------------------------------------
664 * SVGA3D_DestroyShader --
666 * Delete a shader that was created by SVGA3D_DefineShader. If
667 * the shader was the current vertex or pixel shader for its
668 * context, rendering results are undefined until a new shader is
677 *----------------------------------------------------------------------
681 SVGA3D_DestroyShader(struct svga_winsys_context
*swc
,
683 SVGA3dShaderType type
) // IN
685 SVGA3dCmdDestroyShader
*cmd
;
687 cmd
= SVGA3D_FIFOReserve(swc
,
688 SVGA_3D_CMD_SHADER_DESTROY
, sizeof *cmd
,
691 return PIPE_ERROR_OUT_OF_MEMORY
;
703 *----------------------------------------------------------------------
705 * SVGA3D_SetShaderConst --
707 * Set the value of a shader constant.
709 * Shader constants are analogous to uniform variables in GLSL,
710 * except that they belong to the render context rather than to
711 * an individual shader.
713 * Constants may have one of three types: A 4-vector of floats,
714 * a 4-vector of integers, or a single boolean flag.
722 *----------------------------------------------------------------------
726 SVGA3D_SetShaderConst(struct svga_winsys_context
*swc
,
728 SVGA3dShaderType type
, // IN
729 SVGA3dShaderConstType ctype
, // IN
730 const void *value
) // IN
732 SVGA3dCmdSetShaderConst
*cmd
;
734 cmd
= SVGA3D_FIFOReserve(swc
,
735 SVGA_3D_CMD_SET_SHADER_CONST
, sizeof *cmd
,
738 return PIPE_ERROR_OUT_OF_MEMORY
;
747 case SVGA3D_CONST_TYPE_FLOAT
:
748 case SVGA3D_CONST_TYPE_INT
:
749 memcpy(&cmd
->values
, value
, sizeof cmd
->values
);
752 case SVGA3D_CONST_TYPE_BOOL
:
753 memset(&cmd
->values
, 0, sizeof cmd
->values
);
754 cmd
->values
[0] = *(uint32
*)value
;
769 *----------------------------------------------------------------------
771 * SVGA3D_SetShaderConsts --
773 * Set the value of successive shader constants.
775 * Shader constants are analogous to uniform variables in GLSL,
776 * except that they belong to the render context rather than to
777 * an individual shader.
779 * Constants may have one of three types: A 4-vector of floats,
780 * a 4-vector of integers, or a single boolean flag.
788 *----------------------------------------------------------------------
792 SVGA3D_SetShaderConsts(struct svga_winsys_context
*swc
,
794 uint32 numRegs
, // IN
795 SVGA3dShaderType type
, // IN
796 SVGA3dShaderConstType ctype
, // IN
797 const void *values
) // IN
799 SVGA3dCmdSetShaderConst
*cmd
;
801 cmd
= SVGA3D_FIFOReserve(swc
,
802 SVGA_3D_CMD_SET_SHADER_CONST
,
803 sizeof *cmd
+ (numRegs
- 1) * sizeof cmd
->values
,
806 return PIPE_ERROR_OUT_OF_MEMORY
;
813 memcpy(&cmd
->values
, values
, numRegs
* sizeof cmd
->values
);
825 *----------------------------------------------------------------------
827 * SVGA3D_SetShader --
829 * Switch active shaders. This binds a new vertex or pixel shader
830 * to the specified context.
832 * A shader ID of SVGA3D_INVALID_ID unbinds any shader, switching
833 * back to the fixed function vertex or pixel pipeline.
841 *----------------------------------------------------------------------
845 SVGA3D_SetShader(struct svga_winsys_context
*swc
,
846 SVGA3dShaderType type
, // IN
849 SVGA3dCmdSetShader
*cmd
;
851 assert(type
== SVGA3D_SHADERTYPE_VS
|| type
== SVGA3D_SHADERTYPE_PS
);
853 cmd
= SVGA3D_FIFOReserve(swc
,
854 SVGA_3D_CMD_SET_SHADER
, sizeof *cmd
,
857 return PIPE_ERROR_OUT_OF_MEMORY
;
869 *----------------------------------------------------------------------
871 * SVGA3D_BeginClear --
873 * Begin a CLEAR command. This reserves space for it in the FIFO,
874 * and returns a pointer to the command's rectangle array. This
875 * function must be paired with SVGA_FIFOCommitAll().
877 * Clear is a rendering operation which fills a list of
878 * rectangles with constant values on all render target types
879 * indicated by 'flags'.
881 * Clear is not affected by clipping, depth test, or other
882 * render state which affects the fragment pipeline.
888 * May write to attached render target surfaces.
890 *----------------------------------------------------------------------
894 SVGA3D_BeginClear(struct svga_winsys_context
*swc
,
895 SVGA3dClearFlag flags
, // IN
898 uint32 stencil
, // IN
899 SVGA3dRect
**rects
, // OUT
900 uint32 numRects
) // IN
904 cmd
= SVGA3D_FIFOReserve(swc
,
906 sizeof *cmd
+ sizeof **rects
* numRects
,
909 return PIPE_ERROR_OUT_OF_MEMORY
;
912 cmd
->clearFlag
= flags
;
915 cmd
->stencil
= stencil
;
916 *rects
= (SVGA3dRect
*) &cmd
[1];
923 *----------------------------------------------------------------------
925 * SVGA3D_ClearRect --
927 * This is a simplified version of SVGA3D_BeginClear().
935 *----------------------------------------------------------------------
939 SVGA3D_ClearRect(struct svga_winsys_context
*swc
,
940 SVGA3dClearFlag flags
, // IN
943 uint32 stencil
, // IN
952 ret
= SVGA3D_BeginClear(swc
, flags
, color
, depth
, stencil
, &rect
, 1);
954 return PIPE_ERROR_OUT_OF_MEMORY
;
956 memset(rect
, 0, sizeof *rect
);
968 *----------------------------------------------------------------------
970 * SVGA3D_BeginDrawPrimitives --
972 * Begin a DRAW_PRIMITIVES command. This reserves space for it in
973 * the FIFO, and returns a pointer to the command's arrays.
974 * This function must be paired with SVGA_FIFOCommitAll().
976 * Drawing commands consist of two variable-length arrays:
977 * SVGA3dVertexDecl elements declare a set of vertex buffers to
978 * use while rendering, and SVGA3dPrimitiveRange elements specify
979 * groups of primitives each with an optional index buffer.
981 * The decls and ranges arrays are initialized to zero.
987 * May write to attached render target surfaces.
989 *----------------------------------------------------------------------
993 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context
*swc
,
994 SVGA3dVertexDecl
**decls
, // OUT
995 uint32 numVertexDecls
, // IN
996 SVGA3dPrimitiveRange
**ranges
, // OUT
997 uint32 numRanges
) // IN
999 SVGA3dCmdDrawPrimitives
*cmd
;
1000 SVGA3dVertexDecl
*declArray
;
1001 SVGA3dPrimitiveRange
*rangeArray
;
1002 uint32 declSize
= sizeof **decls
* numVertexDecls
;
1003 uint32 rangeSize
= sizeof **ranges
* numRanges
;
1005 cmd
= SVGA3D_FIFOReserve(swc
,
1006 SVGA_3D_CMD_DRAW_PRIMITIVES
,
1007 sizeof *cmd
+ declSize
+ rangeSize
,
1008 numVertexDecls
+ numRanges
);
1010 return PIPE_ERROR_OUT_OF_MEMORY
;
1012 cmd
->cid
= swc
->cid
;
1013 cmd
->numVertexDecls
= numVertexDecls
;
1014 cmd
->numRanges
= numRanges
;
1016 declArray
= (SVGA3dVertexDecl
*) &cmd
[1];
1017 rangeArray
= (SVGA3dPrimitiveRange
*) &declArray
[numVertexDecls
];
1019 memset(declArray
, 0, declSize
);
1020 memset(rangeArray
, 0, rangeSize
);
1023 *ranges
= rangeArray
;
1025 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1027 swc
->num_draw_commands
++;
1034 *----------------------------------------------------------------------
1036 * SVGA3D_BeginSurfaceCopy --
1038 * Begin a SURFACE_COPY command. This reserves space for it in
1039 * the FIFO, and returns a pointer to the command's arrays. This
1040 * function must be paired with SVGA_FIFOCommitAll().
1042 * The box array is initialized with zeroes.
1048 * Asynchronously copies a list of boxes from surface to surface.
1050 *----------------------------------------------------------------------
1054 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context
*swc
,
1055 struct pipe_surface
*src
, // IN
1056 struct pipe_surface
*dest
, // IN
1057 SVGA3dCopyBox
**boxes
, // OUT
1058 uint32 numBoxes
) // IN
1060 SVGA3dCmdSurfaceCopy
*cmd
;
1061 uint32 boxesSize
= sizeof **boxes
* numBoxes
;
1063 cmd
= SVGA3D_FIFOReserve(swc
,
1064 SVGA_3D_CMD_SURFACE_COPY
, sizeof *cmd
+ boxesSize
,
1067 return PIPE_ERROR_OUT_OF_MEMORY
;
1069 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1070 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1071 *boxes
= (SVGA3dCopyBox
*) &cmd
[1];
1073 memset(*boxes
, 0, boxesSize
);
1080 *----------------------------------------------------------------------
1082 * SVGA3D_SurfaceStretchBlt --
1084 * Issue a SURFACE_STRETCHBLT command: an asynchronous
1085 * surface-to-surface blit, with scaling.
1091 * Asynchronously copies one box from surface to surface.
1093 *----------------------------------------------------------------------
1097 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context
*swc
,
1098 struct pipe_surface
*src
, // IN
1099 struct pipe_surface
*dest
, // IN
1100 SVGA3dBox
*boxSrc
, // IN
1101 SVGA3dBox
*boxDest
, // IN
1102 SVGA3dStretchBltMode mode
) // IN
1104 SVGA3dCmdSurfaceStretchBlt
*cmd
;
1106 cmd
= SVGA3D_FIFOReserve(swc
,
1107 SVGA_3D_CMD_SURFACE_STRETCHBLT
, sizeof *cmd
,
1110 return PIPE_ERROR_OUT_OF_MEMORY
;
1112 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1113 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1114 cmd
->boxSrc
= *boxSrc
;
1115 cmd
->boxDest
= *boxDest
;
1124 *----------------------------------------------------------------------
1126 * SVGA3D_SetViewport --
1128 * Set the current context's viewport rectangle. The viewport
1129 * is clipped to the dimensions of the current render target,
1130 * then all rendering is clipped to the viewport.
1138 *----------------------------------------------------------------------
1142 SVGA3D_SetViewport(struct svga_winsys_context
*swc
,
1143 SVGA3dRect
*rect
) // IN
1145 SVGA3dCmdSetViewport
*cmd
;
1147 cmd
= SVGA3D_FIFOReserve(swc
,
1148 SVGA_3D_CMD_SETVIEWPORT
, sizeof *cmd
,
1151 return PIPE_ERROR_OUT_OF_MEMORY
;
1153 cmd
->cid
= swc
->cid
;
1164 *----------------------------------------------------------------------
1166 * SVGA3D_SetScissorRect --
1168 * Set the current context's scissor rectangle. If scissoring
1169 * is enabled then all rendering is clipped to the scissor bounds.
1177 *----------------------------------------------------------------------
1181 SVGA3D_SetScissorRect(struct svga_winsys_context
*swc
,
1182 SVGA3dRect
*rect
) // IN
1184 SVGA3dCmdSetScissorRect
*cmd
;
1186 cmd
= SVGA3D_FIFOReserve(swc
,
1187 SVGA_3D_CMD_SETSCISSORRECT
, sizeof *cmd
,
1190 return PIPE_ERROR_OUT_OF_MEMORY
;
1192 cmd
->cid
= swc
->cid
;
1200 *----------------------------------------------------------------------
1202 * SVGA3D_SetClipPlane --
1204 * Set one of the current context's clip planes. If the clip
1205 * plane is enabled then all 3d rendering is clipped against
1214 *----------------------------------------------------------------------
1218 SVGA3D_SetClipPlane(struct svga_winsys_context
*swc
,
1219 uint32 index
, const float *plane
)
1221 SVGA3dCmdSetClipPlane
*cmd
;
1223 cmd
= SVGA3D_FIFOReserve(swc
,
1224 SVGA_3D_CMD_SETCLIPPLANE
, sizeof *cmd
,
1227 return PIPE_ERROR_OUT_OF_MEMORY
;
1229 cmd
->cid
= swc
->cid
;
1231 cmd
->plane
[0] = plane
[0];
1232 cmd
->plane
[1] = plane
[1];
1233 cmd
->plane
[2] = plane
[2];
1234 cmd
->plane
[3] = plane
[3];
1241 *----------------------------------------------------------------------
1243 * SVGA3D_SetZRange --
1245 * Set the range of the depth buffer to use. 'min' and 'max'
1246 * are values between 0.0 and 1.0.
1254 *----------------------------------------------------------------------
1258 SVGA3D_SetZRange(struct svga_winsys_context
*swc
,
1262 SVGA3dCmdSetZRange
*cmd
;
1264 cmd
= SVGA3D_FIFOReserve(swc
,
1265 SVGA_3D_CMD_SETZRANGE
, sizeof *cmd
,
1268 return PIPE_ERROR_OUT_OF_MEMORY
;
1270 cmd
->cid
= swc
->cid
;
1271 cmd
->zRange
.min
= zMin
;
1272 cmd
->zRange
.max
= zMax
;
1280 *----------------------------------------------------------------------
1282 * SVGA3D_BeginSetTextureState --
1284 * Begin a SETTEXTURESTATE command. This reserves space for it in
1285 * the FIFO, and returns a pointer to the command's texture state
1286 * array. This function must be paired with SVGA_FIFOCommitAll().
1288 * This command sets rendering state which is per-texture-unit.
1290 * XXX: Individual texture states need documentation. However,
1291 * they are very similar to the texture states defined by
1292 * Direct3D. The D3D documentation is a good starting point
1293 * for understanding SVGA3D texture states.
1301 *----------------------------------------------------------------------
1305 SVGA3D_BeginSetTextureState(struct svga_winsys_context
*swc
,
1306 SVGA3dTextureState
**states
, // OUT
1307 uint32 numStates
) // IN
1309 SVGA3dCmdSetTextureState
*cmd
;
1311 cmd
= SVGA3D_FIFOReserve(swc
,
1312 SVGA_3D_CMD_SETTEXTURESTATE
,
1313 sizeof *cmd
+ sizeof **states
* numStates
,
1316 return PIPE_ERROR_OUT_OF_MEMORY
;
1318 cmd
->cid
= swc
->cid
;
1319 *states
= (SVGA3dTextureState
*) &cmd
[1];
1326 *----------------------------------------------------------------------
1328 * SVGA3D_BeginSetRenderState --
1330 * Begin a SETRENDERSTATE command. This reserves space for it in
1331 * the FIFO, and returns a pointer to the command's texture state
1332 * array. This function must be paired with SVGA_FIFOCommitAll().
1334 * This command sets rendering state which is global to the context.
1336 * XXX: Individual render states need documentation. However,
1337 * they are very similar to the render states defined by
1338 * Direct3D. The D3D documentation is a good starting point
1339 * for understanding SVGA3D render states.
1347 *----------------------------------------------------------------------
1351 SVGA3D_BeginSetRenderState(struct svga_winsys_context
*swc
,
1352 SVGA3dRenderState
**states
, // OUT
1353 uint32 numStates
) // IN
1355 SVGA3dCmdSetRenderState
*cmd
;
1357 cmd
= SVGA3D_FIFOReserve(swc
,
1358 SVGA_3D_CMD_SETRENDERSTATE
,
1359 sizeof *cmd
+ sizeof **states
* numStates
,
1362 return PIPE_ERROR_OUT_OF_MEMORY
;
1364 cmd
->cid
= swc
->cid
;
1365 *states
= (SVGA3dRenderState
*) &cmd
[1];
1372 *----------------------------------------------------------------------
1374 * SVGA3D_BeginGBQuery--
1376 * GB resource version of SVGA3D_BeginQuery.
1382 * Commits space in the FIFO memory.
1384 *----------------------------------------------------------------------
1387 static enum pipe_error
1388 SVGA3D_BeginGBQuery(struct svga_winsys_context
*swc
,
1389 SVGA3dQueryType type
) // IN
1391 SVGA3dCmdBeginGBQuery
*cmd
;
1393 cmd
= SVGA3D_FIFOReserve(swc
,
1394 SVGA_3D_CMD_BEGIN_GB_QUERY
,
1398 return PIPE_ERROR_OUT_OF_MEMORY
;
1400 cmd
->cid
= swc
->cid
;
1410 *----------------------------------------------------------------------
1412 * SVGA3D_BeginQuery--
1414 * Issues a SVGA_3D_CMD_BEGIN_QUERY command.
1420 * Commits space in the FIFO memory.
1422 *----------------------------------------------------------------------
1426 SVGA3D_BeginQuery(struct svga_winsys_context
*swc
,
1427 SVGA3dQueryType type
) // IN
1429 SVGA3dCmdBeginQuery
*cmd
;
1431 if (swc
->have_gb_objects
)
1432 return SVGA3D_BeginGBQuery(swc
, type
);
1434 cmd
= SVGA3D_FIFOReserve(swc
,
1435 SVGA_3D_CMD_BEGIN_QUERY
,
1439 return PIPE_ERROR_OUT_OF_MEMORY
;
1441 cmd
->cid
= swc
->cid
;
1451 *----------------------------------------------------------------------
1453 * SVGA3D_EndGBQuery--
1455 * GB resource version of SVGA3D_EndQuery.
1461 * Commits space in the FIFO memory.
1463 *----------------------------------------------------------------------
1466 static enum pipe_error
1467 SVGA3D_EndGBQuery(struct svga_winsys_context
*swc
,
1468 SVGA3dQueryType type
, // IN
1469 struct svga_winsys_buffer
*buffer
) // IN/OUT
1471 SVGA3dCmdEndGBQuery
*cmd
;
1473 cmd
= SVGA3D_FIFOReserve(swc
,
1474 SVGA_3D_CMD_END_GB_QUERY
,
1478 return PIPE_ERROR_OUT_OF_MEMORY
;
1480 cmd
->cid
= swc
->cid
;
1483 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1484 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1493 *----------------------------------------------------------------------
1497 * Issues a SVGA_3D_CMD_END_QUERY command.
1503 * Commits space in the FIFO memory.
1505 *----------------------------------------------------------------------
1509 SVGA3D_EndQuery(struct svga_winsys_context
*swc
,
1510 SVGA3dQueryType type
, // IN
1511 struct svga_winsys_buffer
*buffer
) // IN/OUT
1513 SVGA3dCmdEndQuery
*cmd
;
1515 if (swc
->have_gb_objects
)
1516 return SVGA3D_EndGBQuery(swc
, type
, buffer
);
1518 cmd
= SVGA3D_FIFOReserve(swc
,
1519 SVGA_3D_CMD_END_QUERY
,
1523 return PIPE_ERROR_OUT_OF_MEMORY
;
1525 cmd
->cid
= swc
->cid
;
1528 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1529 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1538 *----------------------------------------------------------------------
1540 * SVGA3D_WaitForGBQuery--
1542 * GB resource version of SVGA3D_WaitForQuery.
1548 * Commits space in the FIFO memory.
1550 *----------------------------------------------------------------------
1553 static enum pipe_error
1554 SVGA3D_WaitForGBQuery(struct svga_winsys_context
*swc
,
1555 SVGA3dQueryType type
, // IN
1556 struct svga_winsys_buffer
*buffer
) // IN/OUT
1558 SVGA3dCmdWaitForGBQuery
*cmd
;
1560 cmd
= SVGA3D_FIFOReserve(swc
,
1561 SVGA_3D_CMD_WAIT_FOR_GB_QUERY
,
1565 return PIPE_ERROR_OUT_OF_MEMORY
;
1567 cmd
->cid
= swc
->cid
;
1570 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1571 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1580 *----------------------------------------------------------------------
1582 * SVGA3D_WaitForQuery--
1584 * Issues a SVGA_3D_CMD_WAIT_FOR_QUERY command. This reserves space
1585 * for it in the FIFO. This doesn't actually wait for the query to
1586 * finish but instead tells the host to start a wait at the driver
1587 * level. The caller can wait on the status variable in the
1588 * guestPtr memory or send an insert fence instruction after this
1589 * command and wait on the fence.
1595 * Commits space in the FIFO memory.
1597 *----------------------------------------------------------------------
1601 SVGA3D_WaitForQuery(struct svga_winsys_context
*swc
,
1602 SVGA3dQueryType type
, // IN
1603 struct svga_winsys_buffer
*buffer
) // IN/OUT
1605 SVGA3dCmdWaitForQuery
*cmd
;
1607 if (swc
->have_gb_objects
)
1608 return SVGA3D_WaitForGBQuery(swc
, type
, buffer
);
1610 cmd
= SVGA3D_FIFOReserve(swc
,
1611 SVGA_3D_CMD_WAIT_FOR_QUERY
,
1615 return PIPE_ERROR_OUT_OF_MEMORY
;
1617 cmd
->cid
= swc
->cid
;
1620 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1621 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1630 SVGA3D_BindGBShader(struct svga_winsys_context
*swc
,
1631 struct svga_winsys_gb_shader
*gbshader
)
1633 SVGA3dCmdBindGBShader
*cmd
=
1634 SVGA3D_FIFOReserve(swc
,
1635 SVGA_3D_CMD_BIND_GB_SHADER
,
1637 2); /* two relocations */
1640 return PIPE_ERROR_OUT_OF_MEMORY
;
1642 swc
->shader_relocation(swc
, &cmd
->shid
, &cmd
->mobid
,
1643 &cmd
->offsetInBytes
, gbshader
, 0);
1652 SVGA3D_SetGBShader(struct svga_winsys_context
*swc
,
1653 SVGA3dShaderType type
, // IN
1654 struct svga_winsys_gb_shader
*gbshader
)
1656 SVGA3dCmdSetShader
*cmd
;
1658 assert(type
== SVGA3D_SHADERTYPE_VS
|| type
== SVGA3D_SHADERTYPE_PS
);
1660 cmd
= SVGA3D_FIFOReserve(swc
,
1661 SVGA_3D_CMD_SET_SHADER
,
1663 2); /* two relocations */
1665 return PIPE_ERROR_OUT_OF_MEMORY
;
1667 cmd
->cid
= swc
->cid
;
1670 swc
->shader_relocation(swc
, &cmd
->shid
, NULL
, NULL
, gbshader
, 0);
1672 cmd
->shid
= SVGA_ID_INVALID
;
1680 * \param flags mask of SVGA_RELOC_READ / _WRITE
1683 SVGA3D_BindGBSurface(struct svga_winsys_context
*swc
,
1684 struct svga_winsys_surface
*surface
)
1686 SVGA3dCmdBindGBSurface
*cmd
=
1687 SVGA3D_FIFOReserve(swc
,
1688 SVGA_3D_CMD_BIND_GB_SURFACE
,
1690 2); /* two relocations */
1693 return PIPE_ERROR_OUT_OF_MEMORY
;
1695 swc
->surface_relocation(swc
, &cmd
->sid
, &cmd
->mobid
, surface
,
1696 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1705 * Update an image in a guest-backed surface.
1706 * (Inform the device that the guest-contents have been updated.)
1709 SVGA3D_UpdateGBImage(struct svga_winsys_context
*swc
,
1710 struct svga_winsys_surface
*surface
,
1711 const SVGA3dBox
*box
,
1712 unsigned face
, unsigned mipLevel
)
1715 SVGA3dCmdUpdateGBImage
*cmd
=
1716 SVGA3D_FIFOReserve(swc
,
1717 SVGA_3D_CMD_UPDATE_GB_IMAGE
,
1719 1); /* one relocation */
1722 return PIPE_ERROR_OUT_OF_MEMORY
;
1724 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1725 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1726 cmd
->image
.face
= face
;
1727 cmd
->image
.mipmap
= mipLevel
;
1731 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1738 * Update an entire guest-backed surface.
1739 * (Inform the device that the guest-contents have been updated.)
1742 SVGA3D_UpdateGBSurface(struct svga_winsys_context
*swc
,
1743 struct svga_winsys_surface
*surface
)
1745 SVGA3dCmdUpdateGBSurface
*cmd
=
1746 SVGA3D_FIFOReserve(swc
,
1747 SVGA_3D_CMD_UPDATE_GB_SURFACE
,
1749 1); /* one relocation */
1752 return PIPE_ERROR_OUT_OF_MEMORY
;
1754 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1755 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1758 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1765 * Readback an image in a guest-backed surface.
1766 * (Request the device to flush the dirty contents into the guest.)
1769 SVGA3D_ReadbackGBImage(struct svga_winsys_context
*swc
,
1770 struct svga_winsys_surface
*surface
,
1771 unsigned face
, unsigned mipLevel
)
1773 SVGA3dCmdReadbackGBImage
*cmd
=
1774 SVGA3D_FIFOReserve(swc
,
1775 SVGA_3D_CMD_READBACK_GB_IMAGE
,
1777 1); /* one relocation */
1780 return PIPE_ERROR_OUT_OF_MEMORY
;
1782 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1783 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1784 cmd
->image
.face
= face
;
1785 cmd
->image
.mipmap
= mipLevel
;
1788 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1795 * Readback an entire guest-backed surface.
1796 * (Request the device to flush the dirty contents into the guest.)
1799 SVGA3D_ReadbackGBSurface(struct svga_winsys_context
*swc
,
1800 struct svga_winsys_surface
*surface
)
1802 SVGA3dCmdReadbackGBSurface
*cmd
=
1803 SVGA3D_FIFOReserve(swc
,
1804 SVGA_3D_CMD_READBACK_GB_SURFACE
,
1806 1); /* one relocation */
1809 return PIPE_ERROR_OUT_OF_MEMORY
;
1811 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1812 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1815 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1822 SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context
*swc
,
1823 struct svga_winsys_surface
*surface
,
1824 unsigned face
, unsigned mipLevel
,
1825 const SVGA3dBox
*box
,
1828 SVGA3dCmdReadbackGBImagePartial
*cmd
=
1829 SVGA3D_FIFOReserve(swc
,
1830 SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL
,
1832 1); /* one relocation */
1834 return PIPE_ERROR_OUT_OF_MEMORY
;
1836 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1837 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1838 cmd
->image
.face
= face
;
1839 cmd
->image
.mipmap
= mipLevel
;
1841 cmd
->invertBox
= invertBox
;
1844 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1851 SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context
*swc
,
1852 struct svga_winsys_surface
*surface
,
1853 unsigned face
, unsigned mipLevel
,
1854 const SVGA3dBox
*box
,
1857 SVGA3dCmdInvalidateGBImagePartial
*cmd
=
1858 SVGA3D_FIFOReserve(swc
,
1859 SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL
,
1861 1); /* one relocation */
1863 return PIPE_ERROR_OUT_OF_MEMORY
;
1865 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1866 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1867 cmd
->image
.face
= face
;
1868 cmd
->image
.mipmap
= mipLevel
;
1870 cmd
->invertBox
= invertBox
;
1878 SVGA3D_InvalidateGBSurface(struct svga_winsys_context
*swc
,
1879 struct svga_winsys_surface
*surface
)
1881 SVGA3dCmdInvalidateGBSurface
*cmd
=
1882 SVGA3D_FIFOReserve(swc
,
1883 SVGA_3D_CMD_INVALIDATE_GB_SURFACE
,
1885 1); /* one relocation */
1887 return PIPE_ERROR_OUT_OF_MEMORY
;
1889 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1890 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1897 SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context
*swc
,
1900 SVGA3dShaderType shaderType
,
1901 SVGA3dShaderConstType constType
,
1904 SVGA3dCmdSetGBShaderConstInline
*cmd
;
1906 assert(numRegs
> 0);
1908 cmd
= SVGA3D_FIFOReserve(swc
,
1909 SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE
,
1910 sizeof *cmd
+ numRegs
* sizeof(float[4]),
1911 0); /* no relocations */
1913 return PIPE_ERROR_OUT_OF_MEMORY
;
1915 cmd
->cid
= swc
->cid
;
1916 cmd
->regStart
= regStart
;
1917 cmd
->shaderType
= shaderType
;
1918 cmd
->constType
= constType
;
1920 memcpy(&cmd
[1], values
, numRegs
* sizeof(float[4]));