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
;
129 SVGA_FIFOCommitAll(struct svga_winsys_context
*swc
)
136 *----------------------------------------------------------------------
138 * SVGA3D_DefineContext --
140 * Create a new context, to be referred to with the provided ID.
142 * Context objects encapsulate all render state, and shader
143 * objects are per-context.
145 * Surfaces are not per-context. The same surface can be shared
146 * between multiple contexts, and surface operations can occur
149 * If the provided context ID already existed, it is redefined.
151 * Context IDs are arbitrary small non-negative integers,
152 * global to the entire SVGA device.
160 *----------------------------------------------------------------------
164 SVGA3D_DefineContext(struct svga_winsys_context
*swc
) // IN
166 SVGA3dCmdDefineContext
*cmd
;
168 cmd
= SVGA3D_FIFOReserve(swc
,
169 SVGA_3D_CMD_CONTEXT_DEFINE
, sizeof *cmd
, 0);
171 return PIPE_ERROR_OUT_OF_MEMORY
;
182 *----------------------------------------------------------------------
184 * SVGA3D_DestroyContext --
186 * Delete a context created with SVGA3D_DefineContext.
194 *----------------------------------------------------------------------
198 SVGA3D_DestroyContext(struct svga_winsys_context
*swc
) // IN
200 SVGA3dCmdDestroyContext
*cmd
;
202 cmd
= SVGA3D_FIFOReserve(swc
,
203 SVGA_3D_CMD_CONTEXT_DESTROY
, sizeof *cmd
, 0);
205 return PIPE_ERROR_OUT_OF_MEMORY
;
216 *----------------------------------------------------------------------
218 * SVGA3D_BeginDefineSurface --
220 * Begin a SURFACE_DEFINE command. This reserves space for it in
221 * the FIFO, and returns pointers to the command's faces and
224 * This function must be paired with SVGA_FIFOCommitAll().
225 * The faces and mipSizes arrays are initialized to zero.
227 * This creates a "surface" object in the SVGA3D device,
228 * with the provided surface ID (sid). Surfaces are generic
229 * containers for host VRAM objects like textures, vertex
230 * buffers, and depth/stencil buffers.
232 * Surfaces are hierarchical:
234 * - Surface may have multiple faces (for cube maps)
236 * - Each face has a list of mipmap levels
238 * - Each mipmap image may have multiple volume
239 * slices, if the image is three dimensional.
241 * - Each slice is a 2D array of 'blocks'
243 * - Each block may be one or more pixels.
244 * (Usually 1, more for DXT or YUV formats.)
246 * Surfaces are generic host VRAM objects. The SVGA3D device
247 * may optimize surfaces according to the format they were
248 * created with, but this format does not limit the ways in
249 * which the surface may be used. For example, a depth surface
250 * can be used as a texture, or a floating point image may
251 * be used as a vertex buffer. Some surface usages may be
252 * lower performance, due to software emulation, but any
253 * usage should work with any surface.
255 * If 'sid' is already defined, the old surface is deleted
256 * and this new surface replaces it.
258 * Surface IDs are arbitrary small non-negative integers,
259 * global to the entire SVGA device.
262 * Returns pointers to arrays allocated in the FIFO for 'faces'
266 * Begins a FIFO reservation.
268 *----------------------------------------------------------------------
272 SVGA3D_BeginDefineSurface(struct svga_winsys_context
*swc
,
273 struct svga_winsys_surface
*sid
, // IN
274 SVGA3dSurfaceFlags flags
, // IN
275 SVGA3dSurfaceFormat format
, // IN
276 SVGA3dSurfaceFace
**faces
, // OUT
277 SVGA3dSize
**mipSizes
, // OUT
278 uint32 numMipSizes
) // IN
280 SVGA3dCmdDefineSurface
*cmd
;
282 cmd
= SVGA3D_FIFOReserve(swc
,
283 SVGA_3D_CMD_SURFACE_DEFINE
, sizeof *cmd
+
284 sizeof **mipSizes
* numMipSizes
, 1);
286 return PIPE_ERROR_OUT_OF_MEMORY
;
288 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
289 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
290 cmd
->surfaceFlags
= flags
;
291 cmd
->format
= format
;
293 *faces
= &cmd
->face
[0];
294 *mipSizes
= (SVGA3dSize
*) &cmd
[1];
296 memset(*faces
, 0, sizeof **faces
* SVGA3D_MAX_SURFACE_FACES
);
297 memset(*mipSizes
, 0, sizeof **mipSizes
* numMipSizes
);
304 *----------------------------------------------------------------------
306 * SVGA3D_DefineSurface2D --
308 * This is a simplified version of SVGA3D_BeginDefineSurface(),
309 * which does not support cube maps, mipmaps, or volume textures.
317 *----------------------------------------------------------------------
321 SVGA3D_DefineSurface2D(struct svga_winsys_context
*swc
, // IN
322 struct svga_winsys_surface
*sid
, // IN
325 SVGA3dSurfaceFormat format
) // IN
327 SVGA3dSize
*mipSizes
;
328 SVGA3dSurfaceFace
*faces
;
331 ret
= SVGA3D_BeginDefineSurface(swc
,
332 sid
, 0, format
, &faces
, &mipSizes
, 1);
336 faces
[0].numMipLevels
= 1;
338 mipSizes
[0].width
= width
;
339 mipSizes
[0].height
= height
;
340 mipSizes
[0].depth
= 1;
349 *----------------------------------------------------------------------
351 * SVGA3D_DestroySurface --
353 * Release the host VRAM encapsulated by a particular surface ID.
361 *----------------------------------------------------------------------
365 SVGA3D_DestroySurface(struct svga_winsys_context
*swc
,
366 struct svga_winsys_surface
*sid
) // IN
368 SVGA3dCmdDestroySurface
*cmd
;
370 cmd
= SVGA3D_FIFOReserve(swc
,
371 SVGA_3D_CMD_SURFACE_DESTROY
, sizeof *cmd
, 1);
373 return PIPE_ERROR_OUT_OF_MEMORY
;
375 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
376 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
384 *----------------------------------------------------------------------
386 * SVGA3D_SurfaceDMA--
388 * Emit a SURFACE_DMA command.
390 * When the SVGA3D device asynchronously processes this FIFO
391 * command, a DMA operation is performed between host VRAM and
392 * a generic SVGAGuestPtr. The guest pointer may refer to guest
393 * VRAM (provided by the SVGA PCI device) or to guest system
394 * memory that has been set up as a Guest Memory Region (GMR)
395 * by the SVGA device.
397 * The guest's DMA buffer must remain valid (not freed, paged out,
398 * or overwritten) until the host has finished processing this
399 * command. The guest can determine that the host has finished
400 * by using the SVGA device's FIFO Fence mechanism.
402 * The guest's image buffer can be an arbitrary size and shape.
403 * Guest image data is interpreted according to the SVGA3D surface
404 * format specified when the surface was defined.
406 * The caller may optionally define the guest image's pitch.
407 * guestImage->pitch can either be zero (assume image is tightly
408 * packed) or it must be the number of bytes between vertically
409 * adjacent image blocks.
411 * The provided copybox list specifies which regions of the source
412 * image are to be copied, and where they appear on the destination.
414 * NOTE: srcx/srcy are always on the guest image and x/y are
415 * always on the host image, regardless of the actual transfer
418 * For efficiency, the SVGA3D device is free to copy more data
419 * than specified. For example, it may round copy boxes outwards
420 * such that they lie on particular alignment boundaries.
422 *----------------------------------------------------------------------
426 SVGA3D_SurfaceDMA(struct svga_winsys_context
*swc
,
427 struct svga_transfer
*st
, // IN
428 SVGA3dTransferType transfer
, // IN
429 const SVGA3dCopyBox
*boxes
, // IN
430 uint32 numBoxes
, // IN
431 SVGA3dSurfaceDMAFlags flags
) // IN
433 struct svga_texture
*texture
= svga_texture(st
->base
.resource
);
434 SVGA3dCmdSurfaceDMA
*cmd
;
435 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
436 uint32 boxesSize
= sizeof *boxes
* numBoxes
;
437 unsigned region_flags
;
438 unsigned surface_flags
;
440 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
441 region_flags
= SVGA_RELOC_READ
;
442 surface_flags
= SVGA_RELOC_WRITE
;
444 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
445 region_flags
= SVGA_RELOC_WRITE
;
446 surface_flags
= SVGA_RELOC_READ
;
450 return PIPE_ERROR_BAD_INPUT
;
453 cmd
= SVGA3D_FIFOReserve(swc
,
454 SVGA_3D_CMD_SURFACE_DMA
,
455 sizeof *cmd
+ boxesSize
+ sizeof *pSuffix
,
458 return PIPE_ERROR_OUT_OF_MEMORY
;
460 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, st
->hwbuf
, 0, region_flags
);
461 cmd
->guest
.pitch
= st
->base
.stride
;
463 swc
->surface_relocation(swc
, &cmd
->host
.sid
, NULL
,
464 texture
->handle
, surface_flags
);
465 cmd
->host
.face
= st
->slice
; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
466 cmd
->host
.mipmap
= st
->base
.level
;
468 cmd
->transfer
= transfer
;
470 memcpy(&cmd
[1], boxes
, boxesSize
);
472 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ boxesSize
);
473 pSuffix
->suffixSize
= sizeof *pSuffix
;
474 pSuffix
->maximumOffset
= st
->hw_nblocksy
*st
->base
.stride
;
475 pSuffix
->flags
= flags
;
478 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
485 SVGA3D_BufferDMA(struct svga_winsys_context
*swc
,
486 struct svga_winsys_buffer
*guest
,
487 struct svga_winsys_surface
*host
,
488 SVGA3dTransferType transfer
, // IN
490 uint32 guest_offset
, // IN
491 uint32 host_offset
, // IN
492 SVGA3dSurfaceDMAFlags flags
) // IN
494 SVGA3dCmdSurfaceDMA
*cmd
;
496 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
497 unsigned region_flags
;
498 unsigned surface_flags
;
500 assert(!swc
->have_gb_objects
);
502 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
503 region_flags
= SVGA_RELOC_READ
;
504 surface_flags
= SVGA_RELOC_WRITE
;
506 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
507 region_flags
= SVGA_RELOC_WRITE
;
508 surface_flags
= SVGA_RELOC_READ
;
512 return PIPE_ERROR_BAD_INPUT
;
515 cmd
= SVGA3D_FIFOReserve(swc
,
516 SVGA_3D_CMD_SURFACE_DMA
,
517 sizeof *cmd
+ sizeof *box
+ sizeof *pSuffix
,
520 return PIPE_ERROR_OUT_OF_MEMORY
;
522 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, guest
, 0, region_flags
);
523 cmd
->guest
.pitch
= 0;
525 swc
->surface_relocation(swc
, &cmd
->host
.sid
,
526 NULL
, host
, surface_flags
);
528 cmd
->host
.mipmap
= 0;
530 cmd
->transfer
= transfer
;
532 box
= (SVGA3dCopyBox
*)&cmd
[1];
533 box
->x
= host_offset
;
539 box
->srcx
= guest_offset
;
543 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ sizeof *box
);
544 pSuffix
->suffixSize
= sizeof *pSuffix
;
545 pSuffix
->maximumOffset
= guest_offset
+ size
;
546 pSuffix
->flags
= flags
;
549 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
556 *----------------------------------------------------------------------
558 * SVGA3D_SetRenderTarget --
560 * Bind a surface object to a particular render target attachment
561 * point on the current context. Render target attachment points
562 * exist for color buffers, a depth buffer, and a stencil buffer.
564 * The SVGA3D device is quite lenient about the types of surfaces
565 * that may be used as render targets. The color buffers must
566 * all be the same size, but the depth and stencil buffers do not
567 * have to be the same size as the color buffer. All attachments
570 * Some combinations of render target formats may require software
571 * emulation, depending on the capabilities of the host graphics
572 * API and graphics hardware.
580 *----------------------------------------------------------------------
584 SVGA3D_SetRenderTarget(struct svga_winsys_context
*swc
,
585 SVGA3dRenderTargetType type
, // IN
586 struct pipe_surface
*surface
) // IN
588 SVGA3dCmdSetRenderTarget
*cmd
;
590 cmd
= SVGA3D_FIFOReserve(swc
,
591 SVGA_3D_CMD_SETRENDERTARGET
, sizeof *cmd
, 1);
593 return PIPE_ERROR_OUT_OF_MEMORY
;
597 surface_to_surfaceid(swc
, surface
, &cmd
->target
, SVGA_RELOC_WRITE
);
605 *----------------------------------------------------------------------
607 * SVGA3D_DefineShader --
609 * Upload the bytecode for a new shader. The bytecode is "SVGA3D
610 * format", which is theoretically a binary-compatible superset
611 * of Microsoft's DirectX shader bytecode. In practice, the
612 * SVGA3D bytecode doesn't yet have any extensions to DirectX's
615 * The SVGA3D device supports shader models 1.1 through 2.0.
617 * The caller chooses a shader ID (small positive integer) by
618 * which this shader will be identified in future commands. This
619 * ID is in a namespace which is per-context and per-shader-type.
621 * 'bytecodeLen' is specified in bytes. It must be a multiple of 4.
629 *----------------------------------------------------------------------
633 SVGA3D_DefineShader(struct svga_winsys_context
*swc
,
635 SVGA3dShaderType type
, // IN
636 const uint32
*bytecode
, // IN
637 uint32 bytecodeLen
) // IN
639 SVGA3dCmdDefineShader
*cmd
;
641 assert(bytecodeLen
% 4 == 0);
643 cmd
= SVGA3D_FIFOReserve(swc
,
644 SVGA_3D_CMD_SHADER_DEFINE
, sizeof *cmd
+ bytecodeLen
,
647 return PIPE_ERROR_OUT_OF_MEMORY
;
652 memcpy(&cmd
[1], bytecode
, bytecodeLen
);
660 *----------------------------------------------------------------------
662 * SVGA3D_DestroyShader --
664 * Delete a shader that was created by SVGA3D_DefineShader. If
665 * the shader was the current vertex or pixel shader for its
666 * context, rendering results are undefined until a new shader is
675 *----------------------------------------------------------------------
679 SVGA3D_DestroyShader(struct svga_winsys_context
*swc
,
681 SVGA3dShaderType type
) // IN
683 SVGA3dCmdDestroyShader
*cmd
;
685 cmd
= SVGA3D_FIFOReserve(swc
,
686 SVGA_3D_CMD_SHADER_DESTROY
, sizeof *cmd
,
689 return PIPE_ERROR_OUT_OF_MEMORY
;
701 *----------------------------------------------------------------------
703 * SVGA3D_SetShaderConst --
705 * Set the value of a shader constant.
707 * Shader constants are analogous to uniform variables in GLSL,
708 * except that they belong to the render context rather than to
709 * an individual shader.
711 * Constants may have one of three types: A 4-vector of floats,
712 * a 4-vector of integers, or a single boolean flag.
720 *----------------------------------------------------------------------
724 SVGA3D_SetShaderConst(struct svga_winsys_context
*swc
,
726 SVGA3dShaderType type
, // IN
727 SVGA3dShaderConstType ctype
, // IN
728 const void *value
) // IN
730 SVGA3dCmdSetShaderConst
*cmd
;
732 cmd
= SVGA3D_FIFOReserve(swc
,
733 SVGA_3D_CMD_SET_SHADER_CONST
, sizeof *cmd
,
736 return PIPE_ERROR_OUT_OF_MEMORY
;
745 case SVGA3D_CONST_TYPE_FLOAT
:
746 case SVGA3D_CONST_TYPE_INT
:
747 memcpy(&cmd
->values
, value
, sizeof cmd
->values
);
750 case SVGA3D_CONST_TYPE_BOOL
:
751 memset(&cmd
->values
, 0, sizeof cmd
->values
);
752 cmd
->values
[0] = *(uint32
*)value
;
767 *----------------------------------------------------------------------
769 * SVGA3D_SetShaderConsts --
771 * Set the value of successive shader constants.
773 * Shader constants are analogous to uniform variables in GLSL,
774 * except that they belong to the render context rather than to
775 * an individual shader.
777 * Constants may have one of three types: A 4-vector of floats,
778 * a 4-vector of integers, or a single boolean flag.
786 *----------------------------------------------------------------------
790 SVGA3D_SetShaderConsts(struct svga_winsys_context
*swc
,
792 uint32 numRegs
, // IN
793 SVGA3dShaderType type
, // IN
794 SVGA3dShaderConstType ctype
, // IN
795 const void *values
) // IN
797 SVGA3dCmdSetShaderConst
*cmd
;
799 cmd
= SVGA3D_FIFOReserve(swc
,
800 SVGA_3D_CMD_SET_SHADER_CONST
,
801 sizeof *cmd
+ (numRegs
- 1) * sizeof cmd
->values
,
804 return PIPE_ERROR_OUT_OF_MEMORY
;
811 memcpy(&cmd
->values
, values
, numRegs
* sizeof cmd
->values
);
823 *----------------------------------------------------------------------
825 * SVGA3D_SetShader --
827 * Switch active shaders. This binds a new vertex or pixel shader
828 * to the specified context.
830 * A shader ID of SVGA3D_INVALID_ID unbinds any shader, switching
831 * back to the fixed function vertex or pixel pipeline.
839 *----------------------------------------------------------------------
843 SVGA3D_SetShader(struct svga_winsys_context
*swc
,
844 SVGA3dShaderType type
, // IN
847 SVGA3dCmdSetShader
*cmd
;
849 assert(type
== SVGA3D_SHADERTYPE_VS
|| type
== SVGA3D_SHADERTYPE_PS
);
851 cmd
= SVGA3D_FIFOReserve(swc
,
852 SVGA_3D_CMD_SET_SHADER
, sizeof *cmd
,
855 return PIPE_ERROR_OUT_OF_MEMORY
;
867 *----------------------------------------------------------------------
869 * SVGA3D_BeginClear --
871 * Begin a CLEAR command. This reserves space for it in the FIFO,
872 * and returns a pointer to the command's rectangle array. This
873 * function must be paired with SVGA_FIFOCommitAll().
875 * Clear is a rendering operation which fills a list of
876 * rectangles with constant values on all render target types
877 * indicated by 'flags'.
879 * Clear is not affected by clipping, depth test, or other
880 * render state which affects the fragment pipeline.
886 * May write to attached render target surfaces.
888 *----------------------------------------------------------------------
892 SVGA3D_BeginClear(struct svga_winsys_context
*swc
,
893 SVGA3dClearFlag flags
, // IN
896 uint32 stencil
, // IN
897 SVGA3dRect
**rects
, // OUT
898 uint32 numRects
) // IN
902 cmd
= SVGA3D_FIFOReserve(swc
,
904 sizeof *cmd
+ sizeof **rects
* numRects
,
907 return PIPE_ERROR_OUT_OF_MEMORY
;
910 cmd
->clearFlag
= flags
;
913 cmd
->stencil
= stencil
;
914 *rects
= (SVGA3dRect
*) &cmd
[1];
921 *----------------------------------------------------------------------
923 * SVGA3D_ClearRect --
925 * This is a simplified version of SVGA3D_BeginClear().
933 *----------------------------------------------------------------------
937 SVGA3D_ClearRect(struct svga_winsys_context
*swc
,
938 SVGA3dClearFlag flags
, // IN
941 uint32 stencil
, // IN
950 ret
= SVGA3D_BeginClear(swc
, flags
, color
, depth
, stencil
, &rect
, 1);
952 return PIPE_ERROR_OUT_OF_MEMORY
;
954 memset(rect
, 0, sizeof *rect
);
966 *----------------------------------------------------------------------
968 * SVGA3D_BeginDrawPrimitives --
970 * Begin a DRAW_PRIMITIVES command. This reserves space for it in
971 * the FIFO, and returns a pointer to the command's arrays.
972 * This function must be paired with SVGA_FIFOCommitAll().
974 * Drawing commands consist of two variable-length arrays:
975 * SVGA3dVertexDecl elements declare a set of vertex buffers to
976 * use while rendering, and SVGA3dPrimitiveRange elements specify
977 * groups of primitives each with an optional index buffer.
979 * The decls and ranges arrays are initialized to zero.
985 * May write to attached render target surfaces.
987 *----------------------------------------------------------------------
991 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context
*swc
,
992 SVGA3dVertexDecl
**decls
, // OUT
993 uint32 numVertexDecls
, // IN
994 SVGA3dPrimitiveRange
**ranges
, // OUT
995 uint32 numRanges
) // IN
997 SVGA3dCmdDrawPrimitives
*cmd
;
998 SVGA3dVertexDecl
*declArray
;
999 SVGA3dPrimitiveRange
*rangeArray
;
1000 uint32 declSize
= sizeof **decls
* numVertexDecls
;
1001 uint32 rangeSize
= sizeof **ranges
* numRanges
;
1003 cmd
= SVGA3D_FIFOReserve(swc
,
1004 SVGA_3D_CMD_DRAW_PRIMITIVES
,
1005 sizeof *cmd
+ declSize
+ rangeSize
,
1006 numVertexDecls
+ numRanges
);
1008 return PIPE_ERROR_OUT_OF_MEMORY
;
1010 cmd
->cid
= swc
->cid
;
1011 cmd
->numVertexDecls
= numVertexDecls
;
1012 cmd
->numRanges
= numRanges
;
1014 declArray
= (SVGA3dVertexDecl
*) &cmd
[1];
1015 rangeArray
= (SVGA3dPrimitiveRange
*) &declArray
[numVertexDecls
];
1017 memset(declArray
, 0, declSize
);
1018 memset(rangeArray
, 0, rangeSize
);
1021 *ranges
= rangeArray
;
1023 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1030 *----------------------------------------------------------------------
1032 * SVGA3D_BeginSurfaceCopy --
1034 * Begin a SURFACE_COPY command. This reserves space for it in
1035 * the FIFO, and returns a pointer to the command's arrays. This
1036 * function must be paired with SVGA_FIFOCommitAll().
1038 * The box array is initialized with zeroes.
1044 * Asynchronously copies a list of boxes from surface to surface.
1046 *----------------------------------------------------------------------
1050 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context
*swc
,
1051 struct pipe_surface
*src
, // IN
1052 struct pipe_surface
*dest
, // IN
1053 SVGA3dCopyBox
**boxes
, // OUT
1054 uint32 numBoxes
) // IN
1056 SVGA3dCmdSurfaceCopy
*cmd
;
1057 uint32 boxesSize
= sizeof **boxes
* numBoxes
;
1059 cmd
= SVGA3D_FIFOReserve(swc
,
1060 SVGA_3D_CMD_SURFACE_COPY
, sizeof *cmd
+ boxesSize
,
1063 return PIPE_ERROR_OUT_OF_MEMORY
;
1065 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1066 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1067 *boxes
= (SVGA3dCopyBox
*) &cmd
[1];
1069 memset(*boxes
, 0, boxesSize
);
1076 *----------------------------------------------------------------------
1078 * SVGA3D_SurfaceStretchBlt --
1080 * Issue a SURFACE_STRETCHBLT command: an asynchronous
1081 * surface-to-surface blit, with scaling.
1087 * Asynchronously copies one box from surface to surface.
1089 *----------------------------------------------------------------------
1093 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context
*swc
,
1094 struct pipe_surface
*src
, // IN
1095 struct pipe_surface
*dest
, // IN
1096 SVGA3dBox
*boxSrc
, // IN
1097 SVGA3dBox
*boxDest
, // IN
1098 SVGA3dStretchBltMode mode
) // IN
1100 SVGA3dCmdSurfaceStretchBlt
*cmd
;
1102 cmd
= SVGA3D_FIFOReserve(swc
,
1103 SVGA_3D_CMD_SURFACE_STRETCHBLT
, sizeof *cmd
,
1106 return PIPE_ERROR_OUT_OF_MEMORY
;
1108 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1109 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1110 cmd
->boxSrc
= *boxSrc
;
1111 cmd
->boxDest
= *boxDest
;
1120 *----------------------------------------------------------------------
1122 * SVGA3D_SetViewport --
1124 * Set the current context's viewport rectangle. The viewport
1125 * is clipped to the dimensions of the current render target,
1126 * then all rendering is clipped to the viewport.
1134 *----------------------------------------------------------------------
1138 SVGA3D_SetViewport(struct svga_winsys_context
*swc
,
1139 SVGA3dRect
*rect
) // IN
1141 SVGA3dCmdSetViewport
*cmd
;
1143 cmd
= SVGA3D_FIFOReserve(swc
,
1144 SVGA_3D_CMD_SETVIEWPORT
, sizeof *cmd
,
1147 return PIPE_ERROR_OUT_OF_MEMORY
;
1149 cmd
->cid
= swc
->cid
;
1160 *----------------------------------------------------------------------
1162 * SVGA3D_SetScissorRect --
1164 * Set the current context's scissor rectangle. If scissoring
1165 * is enabled then all rendering is clipped to the scissor bounds.
1173 *----------------------------------------------------------------------
1177 SVGA3D_SetScissorRect(struct svga_winsys_context
*swc
,
1178 SVGA3dRect
*rect
) // IN
1180 SVGA3dCmdSetScissorRect
*cmd
;
1182 cmd
= SVGA3D_FIFOReserve(swc
,
1183 SVGA_3D_CMD_SETSCISSORRECT
, sizeof *cmd
,
1186 return PIPE_ERROR_OUT_OF_MEMORY
;
1188 cmd
->cid
= swc
->cid
;
1196 *----------------------------------------------------------------------
1198 * SVGA3D_SetClipPlane --
1200 * Set one of the current context's clip planes. If the clip
1201 * plane is enabled then all 3d rendering is clipped against
1210 *----------------------------------------------------------------------
1214 SVGA3D_SetClipPlane(struct svga_winsys_context
*swc
,
1215 uint32 index
, const float *plane
)
1217 SVGA3dCmdSetClipPlane
*cmd
;
1219 cmd
= SVGA3D_FIFOReserve(swc
,
1220 SVGA_3D_CMD_SETCLIPPLANE
, sizeof *cmd
,
1223 return PIPE_ERROR_OUT_OF_MEMORY
;
1225 cmd
->cid
= swc
->cid
;
1227 cmd
->plane
[0] = plane
[0];
1228 cmd
->plane
[1] = plane
[1];
1229 cmd
->plane
[2] = plane
[2];
1230 cmd
->plane
[3] = plane
[3];
1237 *----------------------------------------------------------------------
1239 * SVGA3D_SetZRange --
1241 * Set the range of the depth buffer to use. 'min' and 'max'
1242 * are values between 0.0 and 1.0.
1250 *----------------------------------------------------------------------
1254 SVGA3D_SetZRange(struct svga_winsys_context
*swc
,
1258 SVGA3dCmdSetZRange
*cmd
;
1260 cmd
= SVGA3D_FIFOReserve(swc
,
1261 SVGA_3D_CMD_SETZRANGE
, sizeof *cmd
,
1264 return PIPE_ERROR_OUT_OF_MEMORY
;
1266 cmd
->cid
= swc
->cid
;
1267 cmd
->zRange
.min
= zMin
;
1268 cmd
->zRange
.max
= zMax
;
1276 *----------------------------------------------------------------------
1278 * SVGA3D_BeginSetTextureState --
1280 * Begin a SETTEXTURESTATE command. This reserves space for it in
1281 * the FIFO, and returns a pointer to the command's texture state
1282 * array. This function must be paired with SVGA_FIFOCommitAll().
1284 * This command sets rendering state which is per-texture-unit.
1286 * XXX: Individual texture states need documentation. However,
1287 * they are very similar to the texture states defined by
1288 * Direct3D. The D3D documentation is a good starting point
1289 * for understanding SVGA3D texture states.
1297 *----------------------------------------------------------------------
1301 SVGA3D_BeginSetTextureState(struct svga_winsys_context
*swc
,
1302 SVGA3dTextureState
**states
, // OUT
1303 uint32 numStates
) // IN
1305 SVGA3dCmdSetTextureState
*cmd
;
1307 cmd
= SVGA3D_FIFOReserve(swc
,
1308 SVGA_3D_CMD_SETTEXTURESTATE
,
1309 sizeof *cmd
+ sizeof **states
* numStates
,
1312 return PIPE_ERROR_OUT_OF_MEMORY
;
1314 cmd
->cid
= swc
->cid
;
1315 *states
= (SVGA3dTextureState
*) &cmd
[1];
1322 *----------------------------------------------------------------------
1324 * SVGA3D_BeginSetRenderState --
1326 * Begin a SETRENDERSTATE command. This reserves space for it in
1327 * the FIFO, and returns a pointer to the command's texture state
1328 * array. This function must be paired with SVGA_FIFOCommitAll().
1330 * This command sets rendering state which is global to the context.
1332 * XXX: Individual render states need documentation. However,
1333 * they are very similar to the render states defined by
1334 * Direct3D. The D3D documentation is a good starting point
1335 * for understanding SVGA3D render states.
1343 *----------------------------------------------------------------------
1347 SVGA3D_BeginSetRenderState(struct svga_winsys_context
*swc
,
1348 SVGA3dRenderState
**states
, // OUT
1349 uint32 numStates
) // IN
1351 SVGA3dCmdSetRenderState
*cmd
;
1353 cmd
= SVGA3D_FIFOReserve(swc
,
1354 SVGA_3D_CMD_SETRENDERSTATE
,
1355 sizeof *cmd
+ sizeof **states
* numStates
,
1358 return PIPE_ERROR_OUT_OF_MEMORY
;
1360 cmd
->cid
= swc
->cid
;
1361 *states
= (SVGA3dRenderState
*) &cmd
[1];
1368 *----------------------------------------------------------------------
1370 * SVGA3D_BeginGBQuery--
1372 * GB resource version of SVGA3D_BeginQuery.
1378 * Commits space in the FIFO memory.
1380 *----------------------------------------------------------------------
1383 static enum pipe_error
1384 SVGA3D_BeginGBQuery(struct svga_winsys_context
*swc
,
1385 SVGA3dQueryType type
) // IN
1387 SVGA3dCmdBeginGBQuery
*cmd
;
1389 cmd
= SVGA3D_FIFOReserve(swc
,
1390 SVGA_3D_CMD_BEGIN_GB_QUERY
,
1394 return PIPE_ERROR_OUT_OF_MEMORY
;
1396 cmd
->cid
= swc
->cid
;
1406 *----------------------------------------------------------------------
1408 * SVGA3D_BeginQuery--
1410 * Issues a SVGA_3D_CMD_BEGIN_QUERY command.
1416 * Commits space in the FIFO memory.
1418 *----------------------------------------------------------------------
1422 SVGA3D_BeginQuery(struct svga_winsys_context
*swc
,
1423 SVGA3dQueryType type
) // IN
1425 SVGA3dCmdBeginQuery
*cmd
;
1427 if (swc
->have_gb_objects
)
1428 return SVGA3D_BeginGBQuery(swc
, type
);
1430 cmd
= SVGA3D_FIFOReserve(swc
,
1431 SVGA_3D_CMD_BEGIN_QUERY
,
1435 return PIPE_ERROR_OUT_OF_MEMORY
;
1437 cmd
->cid
= swc
->cid
;
1447 *----------------------------------------------------------------------
1449 * SVGA3D_EndGBQuery--
1451 * GB resource version of SVGA3D_EndQuery.
1457 * Commits space in the FIFO memory.
1459 *----------------------------------------------------------------------
1462 static enum pipe_error
1463 SVGA3D_EndGBQuery(struct svga_winsys_context
*swc
,
1464 SVGA3dQueryType type
, // IN
1465 struct svga_winsys_buffer
*buffer
) // IN/OUT
1467 SVGA3dCmdEndGBQuery
*cmd
;
1469 cmd
= SVGA3D_FIFOReserve(swc
,
1470 SVGA_3D_CMD_END_GB_QUERY
,
1474 return PIPE_ERROR_OUT_OF_MEMORY
;
1476 cmd
->cid
= swc
->cid
;
1479 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1480 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1489 *----------------------------------------------------------------------
1493 * Issues a SVGA_3D_CMD_END_QUERY command.
1499 * Commits space in the FIFO memory.
1501 *----------------------------------------------------------------------
1505 SVGA3D_EndQuery(struct svga_winsys_context
*swc
,
1506 SVGA3dQueryType type
, // IN
1507 struct svga_winsys_buffer
*buffer
) // IN/OUT
1509 SVGA3dCmdEndQuery
*cmd
;
1511 if (swc
->have_gb_objects
)
1512 return SVGA3D_EndGBQuery(swc
, type
, buffer
);
1514 cmd
= SVGA3D_FIFOReserve(swc
,
1515 SVGA_3D_CMD_END_QUERY
,
1519 return PIPE_ERROR_OUT_OF_MEMORY
;
1521 cmd
->cid
= swc
->cid
;
1524 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1525 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1534 *----------------------------------------------------------------------
1536 * SVGA3D_WaitForGBQuery--
1538 * GB resource version of SVGA3D_WaitForQuery.
1544 * Commits space in the FIFO memory.
1546 *----------------------------------------------------------------------
1549 static enum pipe_error
1550 SVGA3D_WaitForGBQuery(struct svga_winsys_context
*swc
,
1551 SVGA3dQueryType type
, // IN
1552 struct svga_winsys_buffer
*buffer
) // IN/OUT
1554 SVGA3dCmdWaitForGBQuery
*cmd
;
1556 cmd
= SVGA3D_FIFOReserve(swc
,
1557 SVGA_3D_CMD_WAIT_FOR_GB_QUERY
,
1561 return PIPE_ERROR_OUT_OF_MEMORY
;
1563 cmd
->cid
= swc
->cid
;
1566 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1567 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1576 *----------------------------------------------------------------------
1578 * SVGA3D_WaitForQuery--
1580 * Issues a SVGA_3D_CMD_WAIT_FOR_QUERY command. This reserves space
1581 * for it in the FIFO. This doesn't actually wait for the query to
1582 * finish but instead tells the host to start a wait at the driver
1583 * level. The caller can wait on the status variable in the
1584 * guestPtr memory or send an insert fence instruction after this
1585 * command and wait on the fence.
1591 * Commits space in the FIFO memory.
1593 *----------------------------------------------------------------------
1597 SVGA3D_WaitForQuery(struct svga_winsys_context
*swc
,
1598 SVGA3dQueryType type
, // IN
1599 struct svga_winsys_buffer
*buffer
) // IN/OUT
1601 SVGA3dCmdWaitForQuery
*cmd
;
1603 if (swc
->have_gb_objects
)
1604 return SVGA3D_WaitForGBQuery(swc
, type
, buffer
);
1606 cmd
= SVGA3D_FIFOReserve(swc
,
1607 SVGA_3D_CMD_WAIT_FOR_QUERY
,
1611 return PIPE_ERROR_OUT_OF_MEMORY
;
1613 cmd
->cid
= swc
->cid
;
1616 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1617 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1626 SVGA3D_BindGBShader(struct svga_winsys_context
*swc
,
1627 struct svga_winsys_gb_shader
*gbshader
)
1629 SVGA3dCmdBindGBShader
*cmd
=
1630 SVGA3D_FIFOReserve(swc
,
1631 SVGA_3D_CMD_BIND_GB_SHADER
,
1633 2); /* two relocations */
1636 return PIPE_ERROR_OUT_OF_MEMORY
;
1638 swc
->shader_relocation(swc
, &cmd
->shid
, &cmd
->mobid
,
1639 &cmd
->offsetInBytes
, gbshader
, 0);
1648 SVGA3D_SetGBShader(struct svga_winsys_context
*swc
,
1649 SVGA3dShaderType type
, // IN
1650 struct svga_winsys_gb_shader
*gbshader
)
1652 SVGA3dCmdSetShader
*cmd
;
1654 assert(type
== SVGA3D_SHADERTYPE_VS
|| type
== SVGA3D_SHADERTYPE_PS
);
1656 cmd
= SVGA3D_FIFOReserve(swc
,
1657 SVGA_3D_CMD_SET_SHADER
,
1659 2); /* two relocations */
1661 return PIPE_ERROR_OUT_OF_MEMORY
;
1663 cmd
->cid
= swc
->cid
;
1666 swc
->shader_relocation(swc
, &cmd
->shid
, NULL
, NULL
, gbshader
, 0);
1668 cmd
->shid
= SVGA_ID_INVALID
;
1676 * \param flags mask of SVGA_RELOC_READ / _WRITE
1679 SVGA3D_BindGBSurface(struct svga_winsys_context
*swc
,
1680 struct svga_winsys_surface
*surface
)
1682 SVGA3dCmdBindGBSurface
*cmd
=
1683 SVGA3D_FIFOReserve(swc
,
1684 SVGA_3D_CMD_BIND_GB_SURFACE
,
1686 2); /* two relocations */
1689 return PIPE_ERROR_OUT_OF_MEMORY
;
1691 swc
->surface_relocation(swc
, &cmd
->sid
, &cmd
->mobid
, surface
,
1692 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1701 * Update an image in a guest-backed surface.
1702 * (Inform the device that the guest-contents have been updated.)
1705 SVGA3D_UpdateGBImage(struct svga_winsys_context
*swc
,
1706 struct svga_winsys_surface
*surface
,
1707 const SVGA3dBox
*box
,
1708 unsigned face
, unsigned mipLevel
)
1711 SVGA3dCmdUpdateGBImage
*cmd
=
1712 SVGA3D_FIFOReserve(swc
,
1713 SVGA_3D_CMD_UPDATE_GB_IMAGE
,
1715 1); /* one relocation */
1718 return PIPE_ERROR_OUT_OF_MEMORY
;
1720 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1721 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1722 cmd
->image
.face
= face
;
1723 cmd
->image
.mipmap
= mipLevel
;
1727 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1734 * Update an entire guest-backed surface.
1735 * (Inform the device that the guest-contents have been updated.)
1738 SVGA3D_UpdateGBSurface(struct svga_winsys_context
*swc
,
1739 struct svga_winsys_surface
*surface
)
1741 SVGA3dCmdUpdateGBSurface
*cmd
=
1742 SVGA3D_FIFOReserve(swc
,
1743 SVGA_3D_CMD_UPDATE_GB_SURFACE
,
1745 1); /* one relocation */
1748 return PIPE_ERROR_OUT_OF_MEMORY
;
1750 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1751 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1754 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1761 * Readback an image in a guest-backed surface.
1762 * (Request the device to flush the dirty contents into the guest.)
1765 SVGA3D_ReadbackGBImage(struct svga_winsys_context
*swc
,
1766 struct svga_winsys_surface
*surface
,
1767 unsigned face
, unsigned mipLevel
)
1769 SVGA3dCmdReadbackGBImage
*cmd
=
1770 SVGA3D_FIFOReserve(swc
,
1771 SVGA_3D_CMD_READBACK_GB_IMAGE
,
1773 1); /* one relocation */
1776 return PIPE_ERROR_OUT_OF_MEMORY
;
1778 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1779 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1780 cmd
->image
.face
= face
;
1781 cmd
->image
.mipmap
= mipLevel
;
1784 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1791 * Readback an entire guest-backed surface.
1792 * (Request the device to flush the dirty contents into the guest.)
1795 SVGA3D_ReadbackGBSurface(struct svga_winsys_context
*swc
,
1796 struct svga_winsys_surface
*surface
)
1798 SVGA3dCmdReadbackGBSurface
*cmd
=
1799 SVGA3D_FIFOReserve(swc
,
1800 SVGA_3D_CMD_READBACK_GB_SURFACE
,
1802 1); /* one relocation */
1805 return PIPE_ERROR_OUT_OF_MEMORY
;
1807 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1808 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1811 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1818 SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context
*swc
,
1819 struct svga_winsys_surface
*surface
,
1820 unsigned face
, unsigned mipLevel
,
1821 const SVGA3dBox
*box
,
1824 SVGA3dCmdReadbackGBImagePartial
*cmd
=
1825 SVGA3D_FIFOReserve(swc
,
1826 SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL
,
1828 1); /* one relocation */
1830 return PIPE_ERROR_OUT_OF_MEMORY
;
1832 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1833 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1834 cmd
->image
.face
= face
;
1835 cmd
->image
.mipmap
= mipLevel
;
1837 cmd
->invertBox
= invertBox
;
1840 swc
->hints
|= SVGA_HINT_FLAG_CAN_PRE_FLUSH
;
1847 SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context
*swc
,
1848 struct svga_winsys_surface
*surface
,
1849 unsigned face
, unsigned mipLevel
,
1850 const SVGA3dBox
*box
,
1853 SVGA3dCmdInvalidateGBImagePartial
*cmd
=
1854 SVGA3D_FIFOReserve(swc
,
1855 SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL
,
1857 1); /* one relocation */
1859 return PIPE_ERROR_OUT_OF_MEMORY
;
1861 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1862 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1863 cmd
->image
.face
= face
;
1864 cmd
->image
.mipmap
= mipLevel
;
1866 cmd
->invertBox
= invertBox
;
1874 SVGA3D_InvalidateGBSurface(struct svga_winsys_context
*swc
,
1875 struct svga_winsys_surface
*surface
)
1877 SVGA3dCmdInvalidateGBSurface
*cmd
=
1878 SVGA3D_FIFOReserve(swc
,
1879 SVGA_3D_CMD_INVALIDATE_GB_SURFACE
,
1881 1); /* one relocation */
1883 return PIPE_ERROR_OUT_OF_MEMORY
;
1885 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1886 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1893 SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context
*swc
,
1896 SVGA3dShaderType shaderType
,
1897 SVGA3dShaderConstType constType
,
1900 SVGA3dCmdSetGBShaderConstInline
*cmd
;
1902 assert(numRegs
> 0);
1904 cmd
= SVGA3D_FIFOReserve(swc
,
1905 SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE
,
1906 sizeof *cmd
+ numRegs
* sizeof(float[4]),
1907 0); /* no relocations */
1909 return PIPE_ERROR_OUT_OF_MEMORY
;
1911 cmd
->cid
= swc
->cid
;
1912 cmd
->regStart
= regStart
;
1913 cmd
->shaderType
= shaderType
;
1914 cmd
->constType
= constType
;
1916 memcpy(&cmd
[1], values
, numRegs
* sizeof(float[4]));