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