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_face
; /* 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
;
127 SVGA_FIFOCommitAll(struct svga_winsys_context
*swc
)
134 *----------------------------------------------------------------------
136 * SVGA3D_DefineContext --
138 * Create a new context, to be referred to with the provided ID.
140 * Context objects encapsulate all render state, and shader
141 * objects are per-context.
143 * Surfaces are not per-context. The same surface can be shared
144 * between multiple contexts, and surface operations can occur
147 * If the provided context ID already existed, it is redefined.
149 * Context IDs are arbitrary small non-negative integers,
150 * global to the entire SVGA device.
158 *----------------------------------------------------------------------
162 SVGA3D_DefineContext(struct svga_winsys_context
*swc
) // IN
164 SVGA3dCmdDefineContext
*cmd
;
166 cmd
= SVGA3D_FIFOReserve(swc
,
167 SVGA_3D_CMD_CONTEXT_DEFINE
, sizeof *cmd
, 0);
169 return PIPE_ERROR_OUT_OF_MEMORY
;
180 *----------------------------------------------------------------------
182 * SVGA3D_DestroyContext --
184 * Delete a context created with SVGA3D_DefineContext.
192 *----------------------------------------------------------------------
196 SVGA3D_DestroyContext(struct svga_winsys_context
*swc
) // IN
198 SVGA3dCmdDestroyContext
*cmd
;
200 cmd
= SVGA3D_FIFOReserve(swc
,
201 SVGA_3D_CMD_CONTEXT_DESTROY
, sizeof *cmd
, 0);
203 return PIPE_ERROR_OUT_OF_MEMORY
;
214 *----------------------------------------------------------------------
216 * SVGA3D_BeginDefineSurface --
218 * Begin a SURFACE_DEFINE command. This reserves space for it in
219 * the FIFO, and returns pointers to the command's faces and
222 * This function must be paired with SVGA_FIFOCommitAll().
223 * The faces and mipSizes arrays are initialized to zero.
225 * This creates a "surface" object in the SVGA3D device,
226 * with the provided surface ID (sid). Surfaces are generic
227 * containers for host VRAM objects like textures, vertex
228 * buffers, and depth/stencil buffers.
230 * Surfaces are hierarchical:
232 * - Surface may have multiple faces (for cube maps)
234 * - Each face has a list of mipmap levels
236 * - Each mipmap image may have multiple volume
237 * slices, if the image is three dimensional.
239 * - Each slice is a 2D array of 'blocks'
241 * - Each block may be one or more pixels.
242 * (Usually 1, more for DXT or YUV formats.)
244 * Surfaces are generic host VRAM objects. The SVGA3D device
245 * may optimize surfaces according to the format they were
246 * created with, but this format does not limit the ways in
247 * which the surface may be used. For example, a depth surface
248 * can be used as a texture, or a floating point image may
249 * be used as a vertex buffer. Some surface usages may be
250 * lower performance, due to software emulation, but any
251 * usage should work with any surface.
253 * If 'sid' is already defined, the old surface is deleted
254 * and this new surface replaces it.
256 * Surface IDs are arbitrary small non-negative integers,
257 * global to the entire SVGA device.
260 * Returns pointers to arrays allocated in the FIFO for 'faces'
264 * Begins a FIFO reservation.
266 *----------------------------------------------------------------------
270 SVGA3D_BeginDefineSurface(struct svga_winsys_context
*swc
,
271 struct svga_winsys_surface
*sid
, // IN
272 SVGA3dSurfaceFlags flags
, // IN
273 SVGA3dSurfaceFormat format
, // IN
274 SVGA3dSurfaceFace
**faces
, // OUT
275 SVGA3dSize
**mipSizes
, // OUT
276 uint32 numMipSizes
) // IN
278 SVGA3dCmdDefineSurface
*cmd
;
280 cmd
= SVGA3D_FIFOReserve(swc
,
281 SVGA_3D_CMD_SURFACE_DEFINE
, sizeof *cmd
+
282 sizeof **mipSizes
* numMipSizes
, 1);
284 return PIPE_ERROR_OUT_OF_MEMORY
;
286 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
287 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
288 cmd
->surfaceFlags
= flags
;
289 cmd
->format
= format
;
291 *faces
= &cmd
->face
[0];
292 *mipSizes
= (SVGA3dSize
*) &cmd
[1];
294 memset(*faces
, 0, sizeof **faces
* SVGA3D_MAX_SURFACE_FACES
);
295 memset(*mipSizes
, 0, sizeof **mipSizes
* numMipSizes
);
302 *----------------------------------------------------------------------
304 * SVGA3D_DefineSurface2D --
306 * This is a simplified version of SVGA3D_BeginDefineSurface(),
307 * which does not support cube maps, mipmaps, or volume textures.
315 *----------------------------------------------------------------------
319 SVGA3D_DefineSurface2D(struct svga_winsys_context
*swc
, // IN
320 struct svga_winsys_surface
*sid
, // IN
323 SVGA3dSurfaceFormat format
) // IN
325 SVGA3dSize
*mipSizes
;
326 SVGA3dSurfaceFace
*faces
;
329 ret
= SVGA3D_BeginDefineSurface(swc
,
330 sid
, 0, format
, &faces
, &mipSizes
, 1);
334 faces
[0].numMipLevels
= 1;
336 mipSizes
[0].width
= width
;
337 mipSizes
[0].height
= height
;
338 mipSizes
[0].depth
= 1;
347 *----------------------------------------------------------------------
349 * SVGA3D_DestroySurface --
351 * Release the host VRAM encapsulated by a particular surface ID.
359 *----------------------------------------------------------------------
363 SVGA3D_DestroySurface(struct svga_winsys_context
*swc
,
364 struct svga_winsys_surface
*sid
) // IN
366 SVGA3dCmdDestroySurface
*cmd
;
368 cmd
= SVGA3D_FIFOReserve(swc
,
369 SVGA_3D_CMD_SURFACE_DESTROY
, sizeof *cmd
, 1);
371 return PIPE_ERROR_OUT_OF_MEMORY
;
373 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, sid
,
374 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
382 *----------------------------------------------------------------------
384 * SVGA3D_SurfaceDMA--
386 * Emit a SURFACE_DMA command.
388 * When the SVGA3D device asynchronously processes this FIFO
389 * command, a DMA operation is performed between host VRAM and
390 * a generic SVGAGuestPtr. The guest pointer may refer to guest
391 * VRAM (provided by the SVGA PCI device) or to guest system
392 * memory that has been set up as a Guest Memory Region (GMR)
393 * by the SVGA device.
395 * The guest's DMA buffer must remain valid (not freed, paged out,
396 * or overwritten) until the host has finished processing this
397 * command. The guest can determine that the host has finished
398 * by using the SVGA device's FIFO Fence mechanism.
400 * The guest's image buffer can be an arbitrary size and shape.
401 * Guest image data is interpreted according to the SVGA3D surface
402 * format specified when the surface was defined.
404 * The caller may optionally define the guest image's pitch.
405 * guestImage->pitch can either be zero (assume image is tightly
406 * packed) or it must be the number of bytes between vertically
407 * adjacent image blocks.
409 * The provided copybox list specifies which regions of the source
410 * image are to be copied, and where they appear on the destination.
412 * NOTE: srcx/srcy are always on the guest image and x/y are
413 * always on the host image, regardless of the actual transfer
416 * For efficiency, the SVGA3D device is free to copy more data
417 * than specified. For example, it may round copy boxes outwards
418 * such that they lie on particular alignment boundaries.
420 *----------------------------------------------------------------------
424 SVGA3D_SurfaceDMA(struct svga_winsys_context
*swc
,
425 struct svga_transfer
*st
, // IN
426 SVGA3dTransferType transfer
, // IN
427 const SVGA3dCopyBox
*boxes
, // IN
428 uint32 numBoxes
, // IN
429 SVGA3dSurfaceDMAFlags flags
) // IN
431 struct svga_texture
*texture
= svga_texture(st
->base
.resource
);
432 SVGA3dCmdSurfaceDMA
*cmd
;
433 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
434 uint32 boxesSize
= sizeof *boxes
* numBoxes
;
435 unsigned region_flags
;
436 unsigned surface_flags
;
438 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
439 region_flags
= SVGA_RELOC_READ
;
440 surface_flags
= SVGA_RELOC_WRITE
;
442 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
443 region_flags
= SVGA_RELOC_WRITE
;
444 surface_flags
= SVGA_RELOC_READ
;
448 return PIPE_ERROR_BAD_INPUT
;
451 cmd
= SVGA3D_FIFOReserve(swc
,
452 SVGA_3D_CMD_SURFACE_DMA
,
453 sizeof *cmd
+ boxesSize
+ sizeof *pSuffix
,
456 return PIPE_ERROR_OUT_OF_MEMORY
;
458 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, st
->hwbuf
, 0, region_flags
);
459 cmd
->guest
.pitch
= st
->base
.stride
;
461 swc
->surface_relocation(swc
, &cmd
->host
.sid
, NULL
,
462 texture
->handle
, surface_flags
);
463 cmd
->host
.face
= st
->face
; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
464 cmd
->host
.mipmap
= st
->base
.level
;
466 cmd
->transfer
= transfer
;
468 memcpy(&cmd
[1], boxes
, boxesSize
);
470 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ boxesSize
);
471 pSuffix
->suffixSize
= sizeof *pSuffix
;
472 pSuffix
->maximumOffset
= st
->hw_nblocksy
*st
->base
.stride
;
473 pSuffix
->flags
= flags
;
482 SVGA3D_BufferDMA(struct svga_winsys_context
*swc
,
483 struct svga_winsys_buffer
*guest
,
484 struct svga_winsys_surface
*host
,
485 SVGA3dTransferType transfer
, // IN
487 uint32 guest_offset
, // IN
488 uint32 host_offset
, // IN
489 SVGA3dSurfaceDMAFlags flags
) // IN
491 SVGA3dCmdSurfaceDMA
*cmd
;
493 SVGA3dCmdSurfaceDMASuffix
*pSuffix
;
494 unsigned region_flags
;
495 unsigned surface_flags
;
497 assert(!swc
->have_gb_objects
);
499 if (transfer
== SVGA3D_WRITE_HOST_VRAM
) {
500 region_flags
= SVGA_RELOC_READ
;
501 surface_flags
= SVGA_RELOC_WRITE
;
503 else if (transfer
== SVGA3D_READ_HOST_VRAM
) {
504 region_flags
= SVGA_RELOC_WRITE
;
505 surface_flags
= SVGA_RELOC_READ
;
509 return PIPE_ERROR_BAD_INPUT
;
512 cmd
= SVGA3D_FIFOReserve(swc
,
513 SVGA_3D_CMD_SURFACE_DMA
,
514 sizeof *cmd
+ sizeof *box
+ sizeof *pSuffix
,
517 return PIPE_ERROR_OUT_OF_MEMORY
;
519 swc
->region_relocation(swc
, &cmd
->guest
.ptr
, guest
, 0, region_flags
);
520 cmd
->guest
.pitch
= 0;
522 swc
->surface_relocation(swc
, &cmd
->host
.sid
,
523 NULL
, host
, surface_flags
);
525 cmd
->host
.mipmap
= 0;
527 cmd
->transfer
= transfer
;
529 box
= (SVGA3dCopyBox
*)&cmd
[1];
530 box
->x
= host_offset
;
536 box
->srcx
= guest_offset
;
540 pSuffix
= (SVGA3dCmdSurfaceDMASuffix
*)((uint8_t*)cmd
+ sizeof *cmd
+ sizeof *box
);
541 pSuffix
->suffixSize
= sizeof *pSuffix
;
542 pSuffix
->maximumOffset
= guest_offset
+ size
;
543 pSuffix
->flags
= flags
;
552 *----------------------------------------------------------------------
554 * SVGA3D_SetRenderTarget --
556 * Bind a surface object to a particular render target attachment
557 * point on the current context. Render target attachment points
558 * exist for color buffers, a depth buffer, and a stencil buffer.
560 * The SVGA3D device is quite lenient about the types of surfaces
561 * that may be used as render targets. The color buffers must
562 * all be the same size, but the depth and stencil buffers do not
563 * have to be the same size as the color buffer. All attachments
566 * Some combinations of render target formats may require software
567 * emulation, depending on the capabilities of the host graphics
568 * API and graphics hardware.
576 *----------------------------------------------------------------------
580 SVGA3D_SetRenderTarget(struct svga_winsys_context
*swc
,
581 SVGA3dRenderTargetType type
, // IN
582 struct pipe_surface
*surface
) // IN
584 SVGA3dCmdSetRenderTarget
*cmd
;
586 cmd
= SVGA3D_FIFOReserve(swc
,
587 SVGA_3D_CMD_SETRENDERTARGET
, sizeof *cmd
, 1);
589 return PIPE_ERROR_OUT_OF_MEMORY
;
593 surface_to_surfaceid(swc
, surface
, &cmd
->target
, SVGA_RELOC_WRITE
);
601 *----------------------------------------------------------------------
603 * SVGA3D_DefineShader --
605 * Upload the bytecode for a new shader. The bytecode is "SVGA3D
606 * format", which is theoretically a binary-compatible superset
607 * of Microsoft's DirectX shader bytecode. In practice, the
608 * SVGA3D bytecode doesn't yet have any extensions to DirectX's
611 * The SVGA3D device supports shader models 1.1 through 2.0.
613 * The caller chooses a shader ID (small positive integer) by
614 * which this shader will be identified in future commands. This
615 * ID is in a namespace which is per-context and per-shader-type.
617 * 'bytecodeLen' is specified in bytes. It must be a multiple of 4.
625 *----------------------------------------------------------------------
629 SVGA3D_DefineShader(struct svga_winsys_context
*swc
,
631 SVGA3dShaderType type
, // IN
632 const uint32
*bytecode
, // IN
633 uint32 bytecodeLen
) // IN
635 SVGA3dCmdDefineShader
*cmd
;
637 assert(bytecodeLen
% 4 == 0);
639 cmd
= SVGA3D_FIFOReserve(swc
,
640 SVGA_3D_CMD_SHADER_DEFINE
, sizeof *cmd
+ bytecodeLen
,
643 return PIPE_ERROR_OUT_OF_MEMORY
;
648 memcpy(&cmd
[1], bytecode
, bytecodeLen
);
656 *----------------------------------------------------------------------
658 * SVGA3D_DestroyShader --
660 * Delete a shader that was created by SVGA3D_DefineShader. If
661 * the shader was the current vertex or pixel shader for its
662 * context, rendering results are undefined until a new shader is
671 *----------------------------------------------------------------------
675 SVGA3D_DestroyShader(struct svga_winsys_context
*swc
,
677 SVGA3dShaderType type
) // IN
679 SVGA3dCmdDestroyShader
*cmd
;
681 cmd
= SVGA3D_FIFOReserve(swc
,
682 SVGA_3D_CMD_SHADER_DESTROY
, sizeof *cmd
,
685 return PIPE_ERROR_OUT_OF_MEMORY
;
697 *----------------------------------------------------------------------
699 * SVGA3D_SetShaderConst --
701 * Set the value of a shader constant.
703 * Shader constants are analogous to uniform variables in GLSL,
704 * except that they belong to the render context rather than to
705 * an individual shader.
707 * Constants may have one of three types: A 4-vector of floats,
708 * a 4-vector of integers, or a single boolean flag.
716 *----------------------------------------------------------------------
720 SVGA3D_SetShaderConst(struct svga_winsys_context
*swc
,
722 SVGA3dShaderType type
, // IN
723 SVGA3dShaderConstType ctype
, // IN
724 const void *value
) // IN
726 SVGA3dCmdSetShaderConst
*cmd
;
728 cmd
= SVGA3D_FIFOReserve(swc
,
729 SVGA_3D_CMD_SET_SHADER_CONST
, sizeof *cmd
,
732 return PIPE_ERROR_OUT_OF_MEMORY
;
741 case SVGA3D_CONST_TYPE_FLOAT
:
742 case SVGA3D_CONST_TYPE_INT
:
743 memcpy(&cmd
->values
, value
, sizeof cmd
->values
);
746 case SVGA3D_CONST_TYPE_BOOL
:
747 memset(&cmd
->values
, 0, sizeof cmd
->values
);
748 cmd
->values
[0] = *(uint32
*)value
;
763 *----------------------------------------------------------------------
765 * SVGA3D_SetShaderConsts --
767 * Set the value of successive shader constants.
769 * Shader constants are analogous to uniform variables in GLSL,
770 * except that they belong to the render context rather than to
771 * an individual shader.
773 * Constants may have one of three types: A 4-vector of floats,
774 * a 4-vector of integers, or a single boolean flag.
782 *----------------------------------------------------------------------
786 SVGA3D_SetShaderConsts(struct svga_winsys_context
*swc
,
788 uint32 numRegs
, // IN
789 SVGA3dShaderType type
, // IN
790 SVGA3dShaderConstType ctype
, // IN
791 const void *values
) // IN
793 SVGA3dCmdSetShaderConst
*cmd
;
795 cmd
= SVGA3D_FIFOReserve(swc
,
796 SVGA_3D_CMD_SET_SHADER_CONST
,
797 sizeof *cmd
+ (numRegs
- 1) * sizeof cmd
->values
,
800 return PIPE_ERROR_OUT_OF_MEMORY
;
807 memcpy(&cmd
->values
, values
, numRegs
* sizeof cmd
->values
);
819 *----------------------------------------------------------------------
821 * SVGA3D_SetShader --
823 * Switch active shaders. This binds a new vertex or pixel shader
824 * to the specified context.
826 * A shader ID of SVGA3D_INVALID_ID unbinds any shader, switching
827 * back to the fixed function vertex or pixel pipeline.
835 *----------------------------------------------------------------------
839 SVGA3D_SetShader(struct svga_winsys_context
*swc
,
840 SVGA3dShaderType type
, // IN
843 SVGA3dCmdSetShader
*cmd
;
845 cmd
= SVGA3D_FIFOReserve(swc
,
846 SVGA_3D_CMD_SET_SHADER
, sizeof *cmd
,
849 return PIPE_ERROR_OUT_OF_MEMORY
;
861 *----------------------------------------------------------------------
863 * SVGA3D_BeginClear --
865 * Begin a CLEAR command. This reserves space for it in the FIFO,
866 * and returns a pointer to the command's rectangle array. This
867 * function must be paired with SVGA_FIFOCommitAll().
869 * Clear is a rendering operation which fills a list of
870 * rectangles with constant values on all render target types
871 * indicated by 'flags'.
873 * Clear is not affected by clipping, depth test, or other
874 * render state which affects the fragment pipeline.
880 * May write to attached render target surfaces.
882 *----------------------------------------------------------------------
886 SVGA3D_BeginClear(struct svga_winsys_context
*swc
,
887 SVGA3dClearFlag flags
, // IN
890 uint32 stencil
, // IN
891 SVGA3dRect
**rects
, // OUT
892 uint32 numRects
) // IN
896 cmd
= SVGA3D_FIFOReserve(swc
,
898 sizeof *cmd
+ sizeof **rects
* numRects
,
901 return PIPE_ERROR_OUT_OF_MEMORY
;
904 cmd
->clearFlag
= flags
;
907 cmd
->stencil
= stencil
;
908 *rects
= (SVGA3dRect
*) &cmd
[1];
915 *----------------------------------------------------------------------
917 * SVGA3D_ClearRect --
919 * This is a simplified version of SVGA3D_BeginClear().
927 *----------------------------------------------------------------------
931 SVGA3D_ClearRect(struct svga_winsys_context
*swc
,
932 SVGA3dClearFlag flags
, // IN
935 uint32 stencil
, // IN
944 ret
= SVGA3D_BeginClear(swc
, flags
, color
, depth
, stencil
, &rect
, 1);
946 return PIPE_ERROR_OUT_OF_MEMORY
;
948 memset(rect
, 0, sizeof *rect
);
960 *----------------------------------------------------------------------
962 * SVGA3D_BeginDrawPrimitives --
964 * Begin a DRAW_PRIMITIVES command. This reserves space for it in
965 * the FIFO, and returns a pointer to the command's arrays.
966 * This function must be paired with SVGA_FIFOCommitAll().
968 * Drawing commands consist of two variable-length arrays:
969 * SVGA3dVertexDecl elements declare a set of vertex buffers to
970 * use while rendering, and SVGA3dPrimitiveRange elements specify
971 * groups of primitives each with an optional index buffer.
973 * The decls and ranges arrays are initialized to zero.
979 * May write to attached render target surfaces.
981 *----------------------------------------------------------------------
985 SVGA3D_BeginDrawPrimitives(struct svga_winsys_context
*swc
,
986 SVGA3dVertexDecl
**decls
, // OUT
987 uint32 numVertexDecls
, // IN
988 SVGA3dPrimitiveRange
**ranges
, // OUT
989 uint32 numRanges
) // IN
991 SVGA3dCmdDrawPrimitives
*cmd
;
992 SVGA3dVertexDecl
*declArray
;
993 SVGA3dPrimitiveRange
*rangeArray
;
994 uint32 declSize
= sizeof **decls
* numVertexDecls
;
995 uint32 rangeSize
= sizeof **ranges
* numRanges
;
997 cmd
= SVGA3D_FIFOReserve(swc
,
998 SVGA_3D_CMD_DRAW_PRIMITIVES
,
999 sizeof *cmd
+ declSize
+ rangeSize
,
1000 numVertexDecls
+ numRanges
);
1002 return PIPE_ERROR_OUT_OF_MEMORY
;
1004 cmd
->cid
= swc
->cid
;
1005 cmd
->numVertexDecls
= numVertexDecls
;
1006 cmd
->numRanges
= numRanges
;
1008 declArray
= (SVGA3dVertexDecl
*) &cmd
[1];
1009 rangeArray
= (SVGA3dPrimitiveRange
*) &declArray
[numVertexDecls
];
1011 memset(declArray
, 0, declSize
);
1012 memset(rangeArray
, 0, rangeSize
);
1015 *ranges
= rangeArray
;
1022 *----------------------------------------------------------------------
1024 * SVGA3D_BeginSurfaceCopy --
1026 * Begin a SURFACE_COPY command. This reserves space for it in
1027 * the FIFO, and returns a pointer to the command's arrays. This
1028 * function must be paired with SVGA_FIFOCommitAll().
1030 * The box array is initialized with zeroes.
1036 * Asynchronously copies a list of boxes from surface to surface.
1038 *----------------------------------------------------------------------
1042 SVGA3D_BeginSurfaceCopy(struct svga_winsys_context
*swc
,
1043 struct pipe_surface
*src
, // IN
1044 struct pipe_surface
*dest
, // IN
1045 SVGA3dCopyBox
**boxes
, // OUT
1046 uint32 numBoxes
) // IN
1048 SVGA3dCmdSurfaceCopy
*cmd
;
1049 uint32 boxesSize
= sizeof **boxes
* numBoxes
;
1051 cmd
= SVGA3D_FIFOReserve(swc
,
1052 SVGA_3D_CMD_SURFACE_COPY
, sizeof *cmd
+ boxesSize
,
1055 return PIPE_ERROR_OUT_OF_MEMORY
;
1057 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1058 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1059 *boxes
= (SVGA3dCopyBox
*) &cmd
[1];
1061 memset(*boxes
, 0, boxesSize
);
1068 *----------------------------------------------------------------------
1070 * SVGA3D_SurfaceStretchBlt --
1072 * Issue a SURFACE_STRETCHBLT command: an asynchronous
1073 * surface-to-surface blit, with scaling.
1079 * Asynchronously copies one box from surface to surface.
1081 *----------------------------------------------------------------------
1085 SVGA3D_SurfaceStretchBlt(struct svga_winsys_context
*swc
,
1086 struct pipe_surface
*src
, // IN
1087 struct pipe_surface
*dest
, // IN
1088 SVGA3dBox
*boxSrc
, // IN
1089 SVGA3dBox
*boxDest
, // IN
1090 SVGA3dStretchBltMode mode
) // IN
1092 SVGA3dCmdSurfaceStretchBlt
*cmd
;
1094 cmd
= SVGA3D_FIFOReserve(swc
,
1095 SVGA_3D_CMD_SURFACE_STRETCHBLT
, sizeof *cmd
,
1098 return PIPE_ERROR_OUT_OF_MEMORY
;
1100 surface_to_surfaceid(swc
, src
, &cmd
->src
, SVGA_RELOC_READ
);
1101 surface_to_surfaceid(swc
, dest
, &cmd
->dest
, SVGA_RELOC_WRITE
);
1102 cmd
->boxSrc
= *boxSrc
;
1103 cmd
->boxDest
= *boxDest
;
1112 *----------------------------------------------------------------------
1114 * SVGA3D_SetViewport --
1116 * Set the current context's viewport rectangle. The viewport
1117 * is clipped to the dimensions of the current render target,
1118 * then all rendering is clipped to the viewport.
1126 *----------------------------------------------------------------------
1130 SVGA3D_SetViewport(struct svga_winsys_context
*swc
,
1131 SVGA3dRect
*rect
) // IN
1133 SVGA3dCmdSetViewport
*cmd
;
1135 cmd
= SVGA3D_FIFOReserve(swc
,
1136 SVGA_3D_CMD_SETVIEWPORT
, sizeof *cmd
,
1139 return PIPE_ERROR_OUT_OF_MEMORY
;
1141 cmd
->cid
= swc
->cid
;
1152 *----------------------------------------------------------------------
1154 * SVGA3D_SetScissorRect --
1156 * Set the current context's scissor rectangle. If scissoring
1157 * is enabled then all rendering is clipped to the scissor bounds.
1165 *----------------------------------------------------------------------
1169 SVGA3D_SetScissorRect(struct svga_winsys_context
*swc
,
1170 SVGA3dRect
*rect
) // IN
1172 SVGA3dCmdSetScissorRect
*cmd
;
1174 cmd
= SVGA3D_FIFOReserve(swc
,
1175 SVGA_3D_CMD_SETSCISSORRECT
, sizeof *cmd
,
1178 return PIPE_ERROR_OUT_OF_MEMORY
;
1180 cmd
->cid
= swc
->cid
;
1188 *----------------------------------------------------------------------
1190 * SVGA3D_SetClipPlane --
1192 * Set one of the current context's clip planes. If the clip
1193 * plane is enabled then all 3d rendering is clipped against
1202 *----------------------------------------------------------------------
1206 SVGA3D_SetClipPlane(struct svga_winsys_context
*swc
,
1207 uint32 index
, const float *plane
)
1209 SVGA3dCmdSetClipPlane
*cmd
;
1211 cmd
= SVGA3D_FIFOReserve(swc
,
1212 SVGA_3D_CMD_SETCLIPPLANE
, sizeof *cmd
,
1215 return PIPE_ERROR_OUT_OF_MEMORY
;
1217 cmd
->cid
= swc
->cid
;
1219 cmd
->plane
[0] = plane
[0];
1220 cmd
->plane
[1] = plane
[1];
1221 cmd
->plane
[2] = plane
[2];
1222 cmd
->plane
[3] = plane
[3];
1229 *----------------------------------------------------------------------
1231 * SVGA3D_SetZRange --
1233 * Set the range of the depth buffer to use. 'min' and 'max'
1234 * are values between 0.0 and 1.0.
1242 *----------------------------------------------------------------------
1246 SVGA3D_SetZRange(struct svga_winsys_context
*swc
,
1250 SVGA3dCmdSetZRange
*cmd
;
1252 cmd
= SVGA3D_FIFOReserve(swc
,
1253 SVGA_3D_CMD_SETZRANGE
, sizeof *cmd
,
1256 return PIPE_ERROR_OUT_OF_MEMORY
;
1258 cmd
->cid
= swc
->cid
;
1259 cmd
->zRange
.min
= zMin
;
1260 cmd
->zRange
.max
= zMax
;
1268 *----------------------------------------------------------------------
1270 * SVGA3D_BeginSetTextureState --
1272 * Begin a SETTEXTURESTATE command. This reserves space for it in
1273 * the FIFO, and returns a pointer to the command's texture state
1274 * array. This function must be paired with SVGA_FIFOCommitAll().
1276 * This command sets rendering state which is per-texture-unit.
1278 * XXX: Individual texture states need documentation. However,
1279 * they are very similar to the texture states defined by
1280 * Direct3D. The D3D documentation is a good starting point
1281 * for understanding SVGA3D texture states.
1289 *----------------------------------------------------------------------
1293 SVGA3D_BeginSetTextureState(struct svga_winsys_context
*swc
,
1294 SVGA3dTextureState
**states
, // OUT
1295 uint32 numStates
) // IN
1297 SVGA3dCmdSetTextureState
*cmd
;
1299 cmd
= SVGA3D_FIFOReserve(swc
,
1300 SVGA_3D_CMD_SETTEXTURESTATE
,
1301 sizeof *cmd
+ sizeof **states
* numStates
,
1304 return PIPE_ERROR_OUT_OF_MEMORY
;
1306 cmd
->cid
= swc
->cid
;
1307 *states
= (SVGA3dTextureState
*) &cmd
[1];
1314 *----------------------------------------------------------------------
1316 * SVGA3D_BeginSetRenderState --
1318 * Begin a SETRENDERSTATE command. This reserves space for it in
1319 * the FIFO, and returns a pointer to the command's texture state
1320 * array. This function must be paired with SVGA_FIFOCommitAll().
1322 * This command sets rendering state which is global to the context.
1324 * XXX: Individual render states need documentation. However,
1325 * they are very similar to the render states defined by
1326 * Direct3D. The D3D documentation is a good starting point
1327 * for understanding SVGA3D render states.
1335 *----------------------------------------------------------------------
1339 SVGA3D_BeginSetRenderState(struct svga_winsys_context
*swc
,
1340 SVGA3dRenderState
**states
, // OUT
1341 uint32 numStates
) // IN
1343 SVGA3dCmdSetRenderState
*cmd
;
1345 cmd
= SVGA3D_FIFOReserve(swc
,
1346 SVGA_3D_CMD_SETRENDERSTATE
,
1347 sizeof *cmd
+ sizeof **states
* numStates
,
1350 return PIPE_ERROR_OUT_OF_MEMORY
;
1352 cmd
->cid
= swc
->cid
;
1353 *states
= (SVGA3dRenderState
*) &cmd
[1];
1360 *----------------------------------------------------------------------
1362 * SVGA3D_BeginGBQuery--
1364 * GB resource version of SVGA3D_BeginQuery.
1370 * Commits space in the FIFO memory.
1372 *----------------------------------------------------------------------
1375 static enum pipe_error
1376 SVGA3D_BeginGBQuery(struct svga_winsys_context
*swc
,
1377 SVGA3dQueryType type
) // IN
1379 SVGA3dCmdBeginGBQuery
*cmd
;
1381 cmd
= SVGA3D_FIFOReserve(swc
,
1382 SVGA_3D_CMD_BEGIN_GB_QUERY
,
1386 return PIPE_ERROR_OUT_OF_MEMORY
;
1388 swc
->context_relocation(swc
, &cmd
->cid
);
1398 *----------------------------------------------------------------------
1400 * SVGA3D_BeginQuery--
1402 * Issues a SVGA_3D_CMD_BEGIN_QUERY command.
1408 * Commits space in the FIFO memory.
1410 *----------------------------------------------------------------------
1414 SVGA3D_BeginQuery(struct svga_winsys_context
*swc
,
1415 SVGA3dQueryType type
) // IN
1417 SVGA3dCmdBeginQuery
*cmd
;
1419 if (swc
->have_gb_objects
)
1420 return SVGA3D_BeginGBQuery(swc
, type
);
1422 cmd
= SVGA3D_FIFOReserve(swc
,
1423 SVGA_3D_CMD_BEGIN_QUERY
,
1427 return PIPE_ERROR_OUT_OF_MEMORY
;
1429 cmd
->cid
= swc
->cid
;
1439 *----------------------------------------------------------------------
1441 * SVGA3D_EndGBQuery--
1443 * GB resource version of SVGA3D_EndQuery.
1449 * Commits space in the FIFO memory.
1451 *----------------------------------------------------------------------
1454 static enum pipe_error
1455 SVGA3D_EndGBQuery(struct svga_winsys_context
*swc
,
1456 SVGA3dQueryType type
, // IN
1457 struct svga_winsys_buffer
*buffer
) // IN/OUT
1459 SVGA3dCmdEndGBQuery
*cmd
;
1461 cmd
= SVGA3D_FIFOReserve(swc
,
1462 SVGA_3D_CMD_END_GB_QUERY
,
1466 return PIPE_ERROR_OUT_OF_MEMORY
;
1468 swc
->context_relocation(swc
, &cmd
->cid
);
1471 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1472 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1481 *----------------------------------------------------------------------
1485 * Issues a SVGA_3D_CMD_END_QUERY command.
1491 * Commits space in the FIFO memory.
1493 *----------------------------------------------------------------------
1497 SVGA3D_EndQuery(struct svga_winsys_context
*swc
,
1498 SVGA3dQueryType type
, // IN
1499 struct svga_winsys_buffer
*buffer
) // IN/OUT
1501 SVGA3dCmdEndQuery
*cmd
;
1503 if (swc
->have_gb_objects
)
1504 return SVGA3D_EndGBQuery(swc
, type
, buffer
);
1506 cmd
= SVGA3D_FIFOReserve(swc
,
1507 SVGA_3D_CMD_END_QUERY
,
1511 return PIPE_ERROR_OUT_OF_MEMORY
;
1513 cmd
->cid
= swc
->cid
;
1516 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1517 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1526 *----------------------------------------------------------------------
1528 * SVGA3D_WaitForGBQuery--
1530 * GB resource version of SVGA3D_WaitForQuery.
1536 * Commits space in the FIFO memory.
1538 *----------------------------------------------------------------------
1541 static enum pipe_error
1542 SVGA3D_WaitForGBQuery(struct svga_winsys_context
*swc
,
1543 SVGA3dQueryType type
, // IN
1544 struct svga_winsys_buffer
*buffer
) // IN/OUT
1546 SVGA3dCmdWaitForGBQuery
*cmd
;
1548 cmd
= SVGA3D_FIFOReserve(swc
,
1549 SVGA_3D_CMD_WAIT_FOR_GB_QUERY
,
1553 return PIPE_ERROR_OUT_OF_MEMORY
;
1555 swc
->context_relocation(swc
, &cmd
->cid
);
1558 swc
->mob_relocation(swc
, &cmd
->mobid
, &cmd
->offset
, buffer
,
1559 0, SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1568 *----------------------------------------------------------------------
1570 * SVGA3D_WaitForQuery--
1572 * Issues a SVGA_3D_CMD_WAIT_FOR_QUERY command. This reserves space
1573 * for it in the FIFO. This doesn't actually wait for the query to
1574 * finish but instead tells the host to start a wait at the driver
1575 * level. The caller can wait on the status variable in the
1576 * guestPtr memory or send an insert fence instruction after this
1577 * command and wait on the fence.
1583 * Commits space in the FIFO memory.
1585 *----------------------------------------------------------------------
1589 SVGA3D_WaitForQuery(struct svga_winsys_context
*swc
,
1590 SVGA3dQueryType type
, // IN
1591 struct svga_winsys_buffer
*buffer
) // IN/OUT
1593 SVGA3dCmdWaitForQuery
*cmd
;
1595 if (swc
->have_gb_objects
)
1596 return SVGA3D_WaitForGBQuery(swc
, type
, buffer
);
1598 cmd
= SVGA3D_FIFOReserve(swc
,
1599 SVGA_3D_CMD_WAIT_FOR_QUERY
,
1603 return PIPE_ERROR_OUT_OF_MEMORY
;
1605 cmd
->cid
= swc
->cid
;
1608 swc
->region_relocation(swc
, &cmd
->guestResult
, buffer
, 0,
1609 SVGA_RELOC_READ
| SVGA_RELOC_WRITE
);
1618 SVGA3D_DefineGBShader(struct svga_winsys_context
*swc
,
1619 struct svga_winsys_gb_shader
*gbshader
,
1620 SVGA3dShaderType type
,
1623 SVGA3dCmdDefineGBShader
*cmd
;
1625 assert(sizeInBytes
% 4 == 0);
1626 assert(type
== SVGA3D_SHADERTYPE_VS
||
1627 type
== SVGA3D_SHADERTYPE_PS
);
1629 cmd
= SVGA3D_FIFOReserve(swc
,
1630 SVGA_3D_CMD_DEFINE_GB_SHADER
,
1632 1); /* one relocation */
1635 return PIPE_ERROR_OUT_OF_MEMORY
;
1637 swc
->shader_relocation(swc
, &cmd
->shid
, NULL
, NULL
, gbshader
);
1639 cmd
->sizeInBytes
= sizeInBytes
;
1648 SVGA3D_BindGBShader(struct svga_winsys_context
*swc
,
1649 struct svga_winsys_gb_shader
*gbshader
)
1651 SVGA3dCmdBindGBShader
*cmd
=
1652 SVGA3D_FIFOReserve(swc
,
1653 SVGA_3D_CMD_BIND_GB_SHADER
,
1655 1); /* one relocation */
1658 return PIPE_ERROR_OUT_OF_MEMORY
;
1660 swc
->shader_relocation(swc
, &cmd
->shid
, &cmd
->mobid
,
1661 &cmd
->offsetInBytes
, gbshader
);
1670 SVGA3D_SetGBShader(struct svga_winsys_context
*swc
,
1671 SVGA3dShaderType type
, // IN
1672 struct svga_winsys_gb_shader
*gbshader
)
1674 SVGA3dCmdSetShader
*cmd
;
1676 cmd
= SVGA3D_FIFOReserve(swc
,
1677 SVGA_3D_CMD_SET_SHADER
,
1679 2); /* two relocations */
1681 return PIPE_ERROR_OUT_OF_MEMORY
;
1683 swc
->context_relocation(swc
, &cmd
->cid
);
1686 swc
->shader_relocation(swc
, &cmd
->shid
, NULL
, NULL
, gbshader
);
1688 cmd
->shid
= SVGA_ID_INVALID
;
1696 SVGA3D_DestroyGBShader(struct svga_winsys_context
*swc
,
1697 struct svga_winsys_gb_shader
*gbshader
)
1699 SVGA3dCmdDestroyGBShader
*cmd
=
1700 SVGA3D_FIFOReserve(swc
,
1701 SVGA_3D_CMD_DESTROY_GB_SHADER
,
1703 1); /* one relocation */
1706 return PIPE_ERROR_OUT_OF_MEMORY
;
1708 swc
->shader_relocation(swc
, &cmd
->shid
, NULL
, NULL
, gbshader
);
1717 * \param flags mask of SVGA_RELOC_READ / _WRITE
1720 SVGA3D_BindGBSurface(struct svga_winsys_context
*swc
,
1721 struct svga_winsys_surface
*surface
)
1723 SVGA3dCmdBindGBSurface
*cmd
=
1724 SVGA3D_FIFOReserve(swc
,
1725 SVGA_3D_CMD_BIND_GB_SURFACE
,
1727 2); /* two relocations */
1730 return PIPE_ERROR_OUT_OF_MEMORY
;
1732 swc
->surface_relocation(swc
, &cmd
->sid
, &cmd
->mobid
, surface
,
1733 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1742 SVGA3D_DefineGBContext(struct svga_winsys_context
*swc
)
1744 SVGA3dCmdDefineGBContext
*cmd
=
1745 SVGA3D_FIFOReserve(swc
,
1746 SVGA_3D_CMD_DEFINE_GB_CONTEXT
,
1748 1); /* one relocation */
1751 return PIPE_ERROR_OUT_OF_MEMORY
;
1753 swc
->context_relocation(swc
, &cmd
->cid
);
1762 SVGA3D_DestroyGBContext(struct svga_winsys_context
*swc
)
1764 SVGA3dCmdDestroyGBContext
*cmd
=
1765 SVGA3D_FIFOReserve(swc
,
1766 SVGA_3D_CMD_DESTROY_GB_CONTEXT
,
1768 1); /* one relocation */
1771 return PIPE_ERROR_OUT_OF_MEMORY
;
1773 swc
->context_relocation(swc
, &cmd
->cid
);
1782 SVGA3D_BindGBContext(struct svga_winsys_context
*swc
)
1784 SVGA3dCmdBindGBContext
*cmd
=
1785 SVGA3D_FIFOReserve(swc
,
1786 SVGA_3D_CMD_BIND_GB_CONTEXT
,
1788 2); /* two relocations */
1791 return PIPE_ERROR_OUT_OF_MEMORY
;
1793 swc
->context_relocation(swc
, &cmd
->cid
);
1794 swc
->context_relocation(swc
, &cmd
->mobid
);
1795 cmd
->validContents
= 0; /* XXX pass as a parameter? */
1804 SVGA3D_InvalidateGBContext(struct svga_winsys_context
*swc
)
1806 SVGA3dCmdInvalidateGBContext
*cmd
=
1807 SVGA3D_FIFOReserve(swc
,
1808 SVGA_3D_CMD_INVALIDATE_GB_CONTEXT
,
1810 1); /* one relocation */
1813 return PIPE_ERROR_OUT_OF_MEMORY
;
1815 swc
->context_relocation(swc
, &cmd
->cid
);
1825 * Update an image in a guest-backed surface.
1826 * (Inform the device that the guest-contents have been updated.)
1829 SVGA3D_UpdateGBImage(struct svga_winsys_context
*swc
,
1830 struct svga_winsys_surface
*surface
,
1831 const SVGA3dBox
*box
,
1832 unsigned face
, unsigned mipLevel
)
1835 SVGA3dCmdUpdateGBImage
*cmd
=
1836 SVGA3D_FIFOReserve(swc
,
1837 SVGA_3D_CMD_UPDATE_GB_IMAGE
,
1839 1); /* one relocation */
1842 return PIPE_ERROR_OUT_OF_MEMORY
;
1844 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1845 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1846 cmd
->image
.face
= face
;
1847 cmd
->image
.mipmap
= mipLevel
;
1857 * Update an entire guest-backed surface.
1858 * (Inform the device that the guest-contents have been updated.)
1861 SVGA3D_UpdateGBSurface(struct svga_winsys_context
*swc
,
1862 struct svga_winsys_surface
*surface
)
1864 SVGA3dCmdUpdateGBSurface
*cmd
=
1865 SVGA3D_FIFOReserve(swc
,
1866 SVGA_3D_CMD_UPDATE_GB_SURFACE
,
1868 1); /* one relocation */
1871 return PIPE_ERROR_OUT_OF_MEMORY
;
1873 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1874 SVGA_RELOC_WRITE
| SVGA_RELOC_INTERNAL
);
1883 * Readback an image in a guest-backed surface.
1884 * (Request the device to flush the dirty contents into the guest.)
1887 SVGA3D_ReadbackGBImage(struct svga_winsys_context
*swc
,
1888 struct svga_winsys_surface
*surface
,
1889 unsigned face
, unsigned mipLevel
)
1891 SVGA3dCmdReadbackGBImage
*cmd
=
1892 SVGA3D_FIFOReserve(swc
,
1893 SVGA_3D_CMD_READBACK_GB_IMAGE
,
1895 1); /* one relocation */
1898 return PIPE_ERROR_OUT_OF_MEMORY
;
1900 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1901 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1902 cmd
->image
.face
= face
;
1903 cmd
->image
.mipmap
= mipLevel
;
1912 * Readback an entire guest-backed surface.
1913 * (Request the device to flush the dirty contents into the guest.)
1916 SVGA3D_ReadbackGBSurface(struct svga_winsys_context
*swc
,
1917 struct svga_winsys_surface
*surface
)
1919 SVGA3dCmdReadbackGBSurface
*cmd
=
1920 SVGA3D_FIFOReserve(swc
,
1921 SVGA_3D_CMD_READBACK_GB_SURFACE
,
1923 1); /* one relocation */
1926 return PIPE_ERROR_OUT_OF_MEMORY
;
1928 swc
->surface_relocation(swc
, &cmd
->sid
, NULL
, surface
,
1929 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1938 SVGA3D_ReadbackGBImagePartial(struct svga_winsys_context
*swc
,
1939 struct svga_winsys_surface
*surface
,
1940 unsigned face
, unsigned mipLevel
,
1941 const SVGA3dBox
*box
,
1944 SVGA3dCmdReadbackGBImagePartial
*cmd
=
1945 SVGA3D_FIFOReserve(swc
,
1946 SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL
,
1948 1); /* one relocation */
1950 return PIPE_ERROR_OUT_OF_MEMORY
;
1952 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1953 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1954 cmd
->image
.face
= face
;
1955 cmd
->image
.mipmap
= mipLevel
;
1957 cmd
->invertBox
= invertBox
;
1966 SVGA3D_InvalidateGBImagePartial(struct svga_winsys_context
*swc
,
1967 struct svga_winsys_surface
*surface
,
1968 unsigned face
, unsigned mipLevel
,
1969 const SVGA3dBox
*box
,
1972 SVGA3dCmdInvalidateGBImagePartial
*cmd
=
1973 SVGA3D_FIFOReserve(swc
,
1974 SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL
,
1976 1); /* one relocation */
1978 return PIPE_ERROR_OUT_OF_MEMORY
;
1980 swc
->surface_relocation(swc
, &cmd
->image
.sid
, NULL
, surface
,
1981 SVGA_RELOC_READ
| SVGA_RELOC_INTERNAL
);
1982 cmd
->image
.face
= face
;
1983 cmd
->image
.mipmap
= mipLevel
;
1985 cmd
->invertBox
= invertBox
;
1994 SVGA3D_SetGBShaderConstsInline(struct svga_winsys_context
*swc
,
1997 SVGA3dShaderType shaderType
,
1998 SVGA3dShaderConstType constType
,
2001 SVGA3dCmdSetGBShaderConstInline
*cmd
;
2003 assert(numRegs
> 0);
2005 cmd
= SVGA3D_FIFOReserve(swc
,
2006 SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE
,
2007 sizeof *cmd
+ numRegs
* sizeof(float[4]),
2008 0); /* no relocations */
2010 return PIPE_ERROR_OUT_OF_MEMORY
;
2012 cmd
->cid
= swc
->cid
;
2013 cmd
->regStart
= regStart
;
2014 cmd
->shaderType
= shaderType
;
2015 cmd
->constType
= constType
;
2017 memcpy(&cmd
[1], values
, numRegs
* sizeof(float[4]));