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