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