svga: add some missing SVGA_STATS_* enum values, prefix strings
[mesa.git] / src / gallium / drivers / svga / svga_winsys.h
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
3 *
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:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
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
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26 /**
27 * @file
28 * VMware SVGA specific winsys interface.
29 *
30 * @author Jose Fonseca <jfonseca@vmware.com>
31 *
32 * Documentation taken from the VMware SVGA DDK.
33 */
34
35 #ifndef SVGA_WINSYS_H_
36 #define SVGA_WINSYS_H_
37
38 #include "svga_types.h"
39 #include "svga_reg.h"
40 #include "svga3d_reg.h"
41
42 #include "pipe/p_compiler.h"
43 #include "pipe/p_defines.h"
44
45 #include "svga_mksstats.h"
46
47 struct svga_winsys_screen;
48 struct svga_winsys_buffer;
49 struct pipe_screen;
50 struct pipe_context;
51 struct pipe_debug_callback;
52 struct pipe_fence_handle;
53 struct pipe_resource;
54 struct svga_region;
55 struct winsys_handle;
56
57
58 #define SVGA_BUFFER_USAGE_PINNED (1 << 0)
59 #define SVGA_BUFFER_USAGE_WRAPPED (1 << 1)
60 #define SVGA_BUFFER_USAGE_SHADER (1 << 2)
61
62 /**
63 * Relocation flags to help with dirty tracking
64 * SVGA_RELOC_WRITE - The command will cause a GPU write to this
65 * resource.
66 * SVGA_RELOC_READ - The command will cause a GPU read from this
67 * resource.
68 * SVGA_RELOC_INTERNAL The command will only transfer data internally
69 * within the resource, and optionally clear
70 * dirty bits
71 * SVGA_RELOC_DMA - Only set for resource buffer DMA uploads for winsys
72 * implementations that want to track the amount
73 * of such data referenced in the command stream.
74 */
75 #define SVGA_RELOC_WRITE (1 << 0)
76 #define SVGA_RELOC_READ (1 << 1)
77 #define SVGA_RELOC_INTERNAL (1 << 2)
78 #define SVGA_RELOC_DMA (1 << 3)
79
80 #define SVGA_FENCE_FLAG_EXEC (1 << 0)
81 #define SVGA_FENCE_FLAG_QUERY (1 << 1)
82
83 #define SVGA_SURFACE_USAGE_SHARED (1 << 0)
84 #define SVGA_SURFACE_USAGE_SCANOUT (1 << 1)
85
86 #define SVGA_QUERY_FLAG_SET (1 << 0)
87 #define SVGA_QUERY_FLAG_REF (1 << 1)
88
89 #define SVGA_HINT_FLAG_CAN_PRE_FLUSH (1 << 0) /* Can preemptively flush */
90
91 /**
92 * SVGA mks statistics info
93 */
94 struct svga_winsys_stats_timeframe {
95 void *counterTime;
96 uint64 startTime;
97 uint64 adjustedStartTime;
98 struct svga_winsys_stats_timeframe *enclosing;
99 };
100
101 enum svga_stats_count {
102 SVGA_STATS_COUNT_BLENDSTATE,
103 SVGA_STATS_COUNT_BLITBLITTERCOPY,
104 SVGA_STATS_COUNT_DEPTHSTENCILSTATE,
105 SVGA_STATS_COUNT_RASTERIZERSTATE,
106 SVGA_STATS_COUNT_SAMPLER,
107 SVGA_STATS_COUNT_SAMPLERVIEW,
108 SVGA_STATS_COUNT_SURFACEWRITEFLUSH,
109 SVGA_STATS_COUNT_TEXREADBACK,
110 SVGA_STATS_COUNT_VERTEXELEMENT,
111 SVGA_STATS_COUNT_MAX
112 };
113
114 enum svga_stats_time {
115 SVGA_STATS_TIME_BLIT,
116 SVGA_STATS_TIME_BLITBLITTER,
117 SVGA_STATS_TIME_BLITFALLBACK,
118 SVGA_STATS_TIME_BUFFERSFLUSH,
119 SVGA_STATS_TIME_BUFFERTRANSFERMAP,
120 SVGA_STATS_TIME_BUFFERTRANSFERUNMAP,
121 SVGA_STATS_TIME_CONTEXTFINISH,
122 SVGA_STATS_TIME_CONTEXTFLUSH,
123 SVGA_STATS_TIME_COPYREGION,
124 SVGA_STATS_TIME_COPYREGIONFALLBACK,
125 SVGA_STATS_TIME_CREATEBACKEDSURFACEVIEW,
126 SVGA_STATS_TIME_CREATEBUFFER,
127 SVGA_STATS_TIME_CREATECONTEXT,
128 SVGA_STATS_TIME_CREATEFS,
129 SVGA_STATS_TIME_CREATEGS,
130 SVGA_STATS_TIME_CREATESURFACE,
131 SVGA_STATS_TIME_CREATESURFACEVIEW,
132 SVGA_STATS_TIME_CREATETEXTURE,
133 SVGA_STATS_TIME_CREATEVS,
134 SVGA_STATS_TIME_DEFINESHADER,
135 SVGA_STATS_TIME_DESTROYSURFACE,
136 SVGA_STATS_TIME_DRAWVBO,
137 SVGA_STATS_TIME_DRAWARRAYS,
138 SVGA_STATS_TIME_DRAWELEMENTS,
139 SVGA_STATS_TIME_EMITFS,
140 SVGA_STATS_TIME_EMITGS,
141 SVGA_STATS_TIME_EMITVS,
142 SVGA_STATS_TIME_EMULATESURFACEVIEW,
143 SVGA_STATS_TIME_FENCEFINISH,
144 SVGA_STATS_TIME_GENERATEINDICES,
145 SVGA_STATS_TIME_HWTNLDRAWARRAYS,
146 SVGA_STATS_TIME_HWTNLDRAWELEMENTS,
147 SVGA_STATS_TIME_HWTNLFLUSH,
148 SVGA_STATS_TIME_HWTNLPRIM,
149 SVGA_STATS_TIME_PROPAGATESURFACE,
150 SVGA_STATS_TIME_SETSAMPLERVIEWS,
151 SVGA_STATS_TIME_SURFACEFLUSH,
152 SVGA_STATS_TIME_SWTNLDRAWVBO,
153 SVGA_STATS_TIME_SWTNLUPDATEDRAW,
154 SVGA_STATS_TIME_SWTNLUPDATEVDECL,
155 SVGA_STATS_TIME_TEXTRANSFERMAP,
156 SVGA_STATS_TIME_TEXTRANSFERUNMAP,
157 SVGA_STATS_TIME_TGSIVGPU10TRANSLATE,
158 SVGA_STATS_TIME_TGSIVGPU9TRANSLATE,
159 SVGA_STATS_TIME_UPDATESTATE,
160 SVGA_STATS_TIME_VALIDATESURFACEVIEW,
161 SVGA_STATS_TIME_VBUFDRAWARRAYS,
162 SVGA_STATS_TIME_VBUFDRAWELEMENTS,
163 SVGA_STATS_TIME_VBUFRENDERALLOCVERT,
164 SVGA_STATS_TIME_VBUFRENDERMAPVERT,
165 SVGA_STATS_TIME_VBUFRENDERUNMAPVERT,
166 SVGA_STATS_TIME_VBUFSUBMITSTATE,
167 SVGA_STATS_TIME_MAX
168 };
169
170 #define SVGA_STATS_PREFIX "GuestGL_"
171
172 #define SVGA_STATS_COUNT_NAMES \
173 SVGA_STATS_PREFIX "BlendState", \
174 SVGA_STATS_PREFIX "BlitBlitterCopy", \
175 SVGA_STATS_PREFIX "DepthStencilState", \
176 SVGA_STATS_PREFIX "RasterizerState", \
177 SVGA_STATS_PREFIX "Sampler", \
178 SVGA_STATS_PREFIX "SamplerView", \
179 SVGA_STATS_PREFIX "SurfaceWriteFlush", \
180 SVGA_STATS_PREFIX "TextureReadback", \
181 SVGA_STATS_PREFIX "VertexElement" \
182
183 #define SVGA_STATS_TIME_NAMES \
184 SVGA_STATS_PREFIX "Blit", \
185 SVGA_STATS_PREFIX "BlitBlitter", \
186 SVGA_STATS_PREFIX "BlitFallback", \
187 SVGA_STATS_PREFIX "BuffersFlush", \
188 SVGA_STATS_PREFIX "BufferTransferMap", \
189 SVGA_STATS_PREFIX "BufferTransferUnmap", \
190 SVGA_STATS_PREFIX "ContextFinish", \
191 SVGA_STATS_PREFIX "ContextFlush", \
192 SVGA_STATS_PREFIX "CopyRegion", \
193 SVGA_STATS_PREFIX "CopyRegionFallback", \
194 SVGA_STATS_PREFIX "CreateBackedSurfaceView", \
195 SVGA_STATS_PREFIX "CreateBuffer", \
196 SVGA_STATS_PREFIX "CreateContext", \
197 SVGA_STATS_PREFIX "CreateFS", \
198 SVGA_STATS_PREFIX "CreateGS", \
199 SVGA_STATS_PREFIX "CreateSurface", \
200 SVGA_STATS_PREFIX "CreateSurfaceView", \
201 SVGA_STATS_PREFIX "CreateTexture", \
202 SVGA_STATS_PREFIX "CreateVS", \
203 SVGA_STATS_PREFIX "DefineShader", \
204 SVGA_STATS_PREFIX "DestroySurface", \
205 SVGA_STATS_PREFIX "DrawVBO", \
206 SVGA_STATS_PREFIX "DrawArrays", \
207 SVGA_STATS_PREFIX "DrawElements", \
208 SVGA_STATS_PREFIX "EmitFS", \
209 SVGA_STATS_PREFIX "EmitGS", \
210 SVGA_STATS_PREFIX "EmitVS", \
211 SVGA_STATS_PREFIX "EmulateSurfaceView", \
212 SVGA_STATS_PREFIX "FenceFinish", \
213 SVGA_STATS_PREFIX "GenerateIndices", \
214 SVGA_STATS_PREFIX "HWtnlDrawArrays", \
215 SVGA_STATS_PREFIX "HWtnlDrawElements", \
216 SVGA_STATS_PREFIX "HWtnlFlush", \
217 SVGA_STATS_PREFIX "HWtnlPrim", \
218 SVGA_STATS_PREFIX "PropagateSurface", \
219 SVGA_STATS_PREFIX "SetSamplerViews", \
220 SVGA_STATS_PREFIX "SurfaceFlush", \
221 SVGA_STATS_PREFIX "SwtnlDrawVBO", \
222 SVGA_STATS_PREFIX "SwtnlUpdateDraw", \
223 SVGA_STATS_PREFIX "SwtnlUpdateVDecl", \
224 SVGA_STATS_PREFIX "TextureTransferMap", \
225 SVGA_STATS_PREFIX "TextureTransferUnmap", \
226 SVGA_STATS_PREFIX "TGSIVGPU10Translate", \
227 SVGA_STATS_PREFIX "TGSIVGPU9Translate", \
228 SVGA_STATS_PREFIX "UpdateState", \
229 SVGA_STATS_PREFIX "ValidateSurfaceView", \
230 SVGA_STATS_PREFIX "VbufDrawArrays", \
231 SVGA_STATS_PREFIX "VbufDrawElements", \
232 SVGA_STATS_PREFIX "VbufRenderAllocVertices", \
233 SVGA_STATS_PREFIX "VbufRenderMapVertices", \
234 SVGA_STATS_PREFIX "VbufRenderUnmapVertices", \
235 SVGA_STATS_PREFIX "VbufSubmitState"
236
237
238 /** Opaque surface handle */
239 struct svga_winsys_surface;
240
241 /** Opaque guest-backed objects */
242 struct svga_winsys_gb_shader;
243 struct svga_winsys_gb_query;
244
245
246 /**
247 * SVGA per-context winsys interface.
248 */
249 struct svga_winsys_context
250 {
251 void
252 (*destroy)(struct svga_winsys_context *swc);
253
254 void *
255 (*reserve)(struct svga_winsys_context *swc,
256 uint32_t nr_bytes, uint32_t nr_relocs );
257
258 /**
259 * Returns current size of command buffer, in bytes.
260 */
261 unsigned
262 (*get_command_buffer_size)(struct svga_winsys_context *swc);
263
264 /**
265 * Emit a relocation for a host surface.
266 *
267 * @param flags bitmask of SVGA_RELOC_* flags
268 *
269 * NOTE: Order of this call does matter. It should be the same order
270 * as relocations appear in the command buffer.
271 */
272 void
273 (*surface_relocation)(struct svga_winsys_context *swc,
274 uint32 *sid,
275 uint32 *mobid,
276 struct svga_winsys_surface *surface,
277 unsigned flags);
278
279 /**
280 * Emit a relocation for a guest memory region.
281 *
282 * @param flags bitmask of SVGA_RELOC_* flags
283 *
284 * NOTE: Order of this call does matter. It should be the same order
285 * as relocations appear in the command buffer.
286 */
287 void
288 (*region_relocation)(struct svga_winsys_context *swc,
289 struct SVGAGuestPtr *ptr,
290 struct svga_winsys_buffer *buffer,
291 uint32 offset,
292 unsigned flags);
293
294 /**
295 * Emit a relocation for a guest-backed shader object.
296 *
297 * NOTE: Order of this call does matter. It should be the same order
298 * as relocations appear in the command buffer.
299 */
300 void
301 (*shader_relocation)(struct svga_winsys_context *swc,
302 uint32 *shid,
303 uint32 *mobid,
304 uint32 *offset,
305 struct svga_winsys_gb_shader *shader,
306 unsigned flags);
307
308 /**
309 * Emit a relocation for a guest-backed context.
310 *
311 * NOTE: Order of this call does matter. It should be the same order
312 * as relocations appear in the command buffer.
313 */
314 void
315 (*context_relocation)(struct svga_winsys_context *swc, uint32 *cid);
316
317 /**
318 * Emit a relocation for a guest Memory OBject.
319 *
320 * @param flags bitmask of SVGA_RELOC_* flags
321 * @param offset_into_mob Buffer starts at this offset into the MOB.
322 *
323 * Note that not all commands accept an offset into the MOB and
324 * those commands can't use suballocated buffer pools. To trap
325 * errors from improper buffer pool usage, set the offset_into_mob
326 * pointer to NULL.
327 */
328 void
329 (*mob_relocation)(struct svga_winsys_context *swc,
330 SVGAMobId *id,
331 uint32 *offset_into_mob,
332 struct svga_winsys_buffer *buffer,
333 uint32 offset,
334 unsigned flags);
335
336 /**
337 * Emit a relocation for a guest-backed query object.
338 *
339 * NOTE: Order of this call does matter. It should be the same order
340 * as relocations appear in the command buffer.
341 */
342 void
343 (*query_relocation)(struct svga_winsys_context *swc,
344 SVGAMobId *id,
345 struct svga_winsys_gb_query *query);
346
347 /**
348 * Bind queries to context.
349 * \param flags exactly one of SVGA_QUERY_FLAG_SET/REF
350 */
351 enum pipe_error
352 (*query_bind)(struct svga_winsys_context *sws,
353 struct svga_winsys_gb_query *query,
354 unsigned flags);
355
356 void
357 (*commit)(struct svga_winsys_context *swc);
358
359 enum pipe_error
360 (*flush)(struct svga_winsys_context *swc,
361 struct pipe_fence_handle **pfence);
362
363 /**
364 * Context ID used to fill in the commands
365 *
366 * Context IDs are arbitrary small non-negative integers,
367 * global to the entire SVGA device.
368 */
369 uint32 cid;
370
371 /**
372 * Flags to hint the current context state
373 */
374 uint32 hints;
375
376 /**
377 ** BEGIN new functions for guest-backed surfaces.
378 **/
379
380 boolean have_gb_objects;
381
382 /**
383 * Map a guest-backed surface.
384 * \param flags bitmaks of PIPE_TRANSFER_x flags
385 *
386 * The surface_map() member is allowed to fail due to a
387 * shortage of command buffer space, if the
388 * PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE bit is set in flags.
389 * In that case, the caller must flush the current command
390 * buffer and reissue the map.
391 */
392 void *
393 (*surface_map)(struct svga_winsys_context *swc,
394 struct svga_winsys_surface *surface,
395 unsigned flags, boolean *retry);
396
397 /**
398 * Unmap a guest-backed surface.
399 * \param rebind returns a flag indicating whether the caller should
400 * issue a SVGA3D_BindGBSurface() call.
401 */
402 void
403 (*surface_unmap)(struct svga_winsys_context *swc,
404 struct svga_winsys_surface *surface,
405 boolean *rebind);
406
407 /**
408 * Invalidate the content of this surface
409 */
410 void
411 (*surface_invalidate)(struct svga_winsys_context *swc,
412 struct svga_winsys_surface *surface);
413
414 /**
415 * Create and define a DX GB shader that resides in the device COTable.
416 * Caller of this function will issue the DXDefineShader command.
417 */
418 struct svga_winsys_gb_shader *
419 (*shader_create)(struct svga_winsys_context *swc,
420 uint32 shaderId,
421 SVGA3dShaderType shaderType,
422 const uint32 *bytecode,
423 uint32 bytecodeLen);
424
425 /**
426 * Destroy a DX GB shader.
427 * This function will issue the DXDestroyShader command.
428 */
429 void
430 (*shader_destroy)(struct svga_winsys_context *swc,
431 struct svga_winsys_gb_shader *shader);
432
433 /**
434 * Rebind a DX GB resource to a context.
435 * This is called to reference a DX GB resource in the command stream in
436 * order to page in the associated resource in case the memory has been
437 * paged out, and to fence it if necessary after command submission.
438 */
439 enum pipe_error
440 (*resource_rebind)(struct svga_winsys_context *swc,
441 struct svga_winsys_surface *surface,
442 struct svga_winsys_gb_shader *shader,
443 unsigned flags);
444
445 /** To report perf/conformance/etc issues to the state tracker */
446 struct pipe_debug_callback *debug_callback;
447
448 /** The more recent command issued to command buffer */
449 SVGAFifo3dCmdId last_command;
450 };
451
452
453 /**
454 * SVGA per-screen winsys interface.
455 */
456 struct svga_winsys_screen
457 {
458 void
459 (*destroy)(struct svga_winsys_screen *sws);
460
461 SVGA3dHardwareVersion
462 (*get_hw_version)(struct svga_winsys_screen *sws);
463
464 boolean
465 (*get_cap)(struct svga_winsys_screen *sws,
466 SVGA3dDevCapIndex index,
467 SVGA3dDevCapResult *result);
468
469 /**
470 * Create a new context.
471 *
472 * Context objects encapsulate all render state, and shader
473 * objects are per-context.
474 *
475 * Surfaces are not per-context. The same surface can be shared
476 * between multiple contexts, and surface operations can occur
477 * without a context.
478 */
479 struct svga_winsys_context *
480 (*context_create)(struct svga_winsys_screen *sws);
481
482
483 /**
484 * This creates a "surface" object in the SVGA3D device.
485 *
486 * \param sws Pointer to an svga_winsys_context
487 * \param flags Device surface create flags
488 * \param format Format Device surface format
489 * \param usage Winsys usage: bitmask of SVGA_SURFACE_USAGE_x flags
490 * \param size Surface size given in device format
491 * \param numLayers Number of layers of the surface (or cube faces)
492 * \param numMipLevels Number of mipmap levels for each face
493 *
494 * Returns the surface ID (sid). Surfaces are generic
495 * containers for host VRAM objects like textures, vertex
496 * buffers, and depth/stencil buffers.
497 *
498 * Surfaces are hierarchial:
499 *
500 * - Surface may have multiple faces (for cube maps)
501 *
502 * - Each face has a list of mipmap levels
503 *
504 * - Each mipmap image may have multiple volume
505 * slices for 3D image, or multiple 2D slices for texture array.
506 *
507 * - Each slice is a 2D array of 'blocks'
508 *
509 * - Each block may be one or more pixels.
510 * (Usually 1, more for DXT or YUV formats.)
511 *
512 * Surfaces are generic host VRAM objects. The SVGA3D device
513 * may optimize surfaces according to the format they were
514 * created with, but this format does not limit the ways in
515 * which the surface may be used. For example, a depth surface
516 * can be used as a texture, or a floating point image may
517 * be used as a vertex buffer. Some surface usages may be
518 * lower performance, due to software emulation, but any
519 * usage should work with any surface.
520 */
521 struct svga_winsys_surface *
522 (*surface_create)(struct svga_winsys_screen *sws,
523 SVGA3dSurfaceFlags flags,
524 SVGA3dSurfaceFormat format,
525 unsigned usage,
526 SVGA3dSize size,
527 uint32 numLayers,
528 uint32 numMipLevels,
529 unsigned sampleCount);
530
531 /**
532 * Creates a surface from a winsys handle.
533 * Used to implement pipe_screen::resource_from_handle.
534 */
535 struct svga_winsys_surface *
536 (*surface_from_handle)(struct svga_winsys_screen *sws,
537 struct winsys_handle *whandle,
538 SVGA3dSurfaceFormat *format);
539
540 /**
541 * Get a winsys_handle from a surface.
542 * Used to implement pipe_screen::resource_get_handle.
543 */
544 boolean
545 (*surface_get_handle)(struct svga_winsys_screen *sws,
546 struct svga_winsys_surface *surface,
547 unsigned stride,
548 struct winsys_handle *whandle);
549
550 /**
551 * Whether this surface is sitting in a validate list
552 */
553 boolean
554 (*surface_is_flushed)(struct svga_winsys_screen *sws,
555 struct svga_winsys_surface *surface);
556
557 /**
558 * Reference a SVGA3D surface object. This allows sharing of a
559 * surface between different objects.
560 */
561 void
562 (*surface_reference)(struct svga_winsys_screen *sws,
563 struct svga_winsys_surface **pdst,
564 struct svga_winsys_surface *src);
565
566 /**
567 * Check if a resource (texture, buffer) of the given size
568 * and format can be created.
569 * \Return TRUE if OK, FALSE if too large.
570 */
571 boolean
572 (*surface_can_create)(struct svga_winsys_screen *sws,
573 SVGA3dSurfaceFormat format,
574 SVGA3dSize size,
575 uint32 numLayers,
576 uint32 numMipLevels);
577
578 /**
579 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
580 *
581 * @param usage bitmask of SVGA_BUFFER_USAGE_* flags.
582 *
583 * alignment indicates the client's alignment requirements, eg for
584 * SSE instructions.
585 */
586 struct svga_winsys_buffer *
587 (*buffer_create)( struct svga_winsys_screen *sws,
588 unsigned alignment,
589 unsigned usage,
590 unsigned size );
591
592 /**
593 * Map the entire data store of a buffer object into the client's address.
594 * usage is a bitmask of PIPE_TRANSFER_*
595 */
596 void *
597 (*buffer_map)( struct svga_winsys_screen *sws,
598 struct svga_winsys_buffer *buf,
599 unsigned usage );
600
601 void
602 (*buffer_unmap)( struct svga_winsys_screen *sws,
603 struct svga_winsys_buffer *buf );
604
605 void
606 (*buffer_destroy)( struct svga_winsys_screen *sws,
607 struct svga_winsys_buffer *buf );
608
609
610 /**
611 * Reference a fence object.
612 */
613 void
614 (*fence_reference)( struct svga_winsys_screen *sws,
615 struct pipe_fence_handle **pdst,
616 struct pipe_fence_handle *src );
617
618 /**
619 * Checks whether the fence has been signalled.
620 * \param flags driver-specific meaning
621 * \return zero on success.
622 */
623 int (*fence_signalled)( struct svga_winsys_screen *sws,
624 struct pipe_fence_handle *fence,
625 unsigned flag );
626
627 /**
628 * Wait for the fence to finish.
629 * \param flags driver-specific meaning
630 * \return zero on success.
631 */
632 int (*fence_finish)( struct svga_winsys_screen *sws,
633 struct pipe_fence_handle *fence,
634 unsigned flag );
635
636
637 /**
638 ** BEGIN new functions for guest-backed surfaces.
639 **/
640
641 /** Are guest-backed objects enabled? */
642 bool have_gb_objects;
643
644 /** Can we do DMA with guest-backed objects enabled? */
645 bool have_gb_dma;
646
647 /**
648 * Create and define a GB shader.
649 */
650 struct svga_winsys_gb_shader *
651 (*shader_create)(struct svga_winsys_screen *sws,
652 SVGA3dShaderType shaderType,
653 const uint32 *bytecode,
654 uint32 bytecodeLen);
655
656 /**
657 * Destroy a GB shader. It's safe to call this function even
658 * if the shader is referenced in a context's command stream.
659 */
660 void
661 (*shader_destroy)(struct svga_winsys_screen *sws,
662 struct svga_winsys_gb_shader *shader);
663
664 /**
665 * Create and define a GB query.
666 */
667 struct svga_winsys_gb_query *
668 (*query_create)(struct svga_winsys_screen *sws, uint32 len);
669
670 /**
671 * Destroy a GB query.
672 */
673 void
674 (*query_destroy)(struct svga_winsys_screen *sws,
675 struct svga_winsys_gb_query *query);
676
677 /**
678 * Initialize the query state of the query that resides in the slot
679 * specified in offset
680 * \return zero on success.
681 */
682 int
683 (*query_init)(struct svga_winsys_screen *sws,
684 struct svga_winsys_gb_query *query,
685 unsigned offset,
686 SVGA3dQueryState queryState);
687
688 /**
689 * Inquire for the query state and result of the query that resides
690 * in the slot specified in offset
691 */
692 void
693 (*query_get_result)(struct svga_winsys_screen *sws,
694 struct svga_winsys_gb_query *query,
695 unsigned offset,
696 SVGA3dQueryState *queryState,
697 void *result, uint32 resultLen);
698
699 /**
700 * Increment a statistic counter
701 */
702 void
703 (*stats_inc)(enum svga_stats_count);
704
705 /**
706 * Push a time frame onto the stack
707 */
708 void
709 (*stats_time_push)(enum svga_stats_time, struct svga_winsys_stats_timeframe *);
710
711 /**
712 * Pop a time frame.
713 */
714 void
715 (*stats_time_pop)();
716
717
718 /** Have VGPU v10 hardware? */
719 boolean have_vgpu10;
720
721 /** To rebind resources at the beginnning of a new command buffer */
722 boolean need_to_rebind_resources;
723
724 boolean have_generate_mipmap_cmd;
725 boolean have_set_predication_cmd;
726 boolean have_transfer_from_buffer_cmd;
727 };
728
729
730 struct svga_winsys_screen *
731 svga_winsys_screen(struct pipe_screen *screen);
732
733 struct svga_winsys_context *
734 svga_winsys_context(struct pipe_context *context);
735
736 struct pipe_resource *
737 svga_screen_buffer_wrap_surface(struct pipe_screen *screen,
738 enum SVGA3dSurfaceFormat format,
739 struct svga_winsys_surface *srf);
740
741 struct svga_winsys_surface *
742 svga_screen_buffer_get_winsys_surface(struct pipe_resource *buffer);
743
744 #endif /* SVGA_WINSYS_H_ */