1/**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28#ifndef PIPE_CONTEXT_H
29#define PIPE_CONTEXT_H
30
31#include "p_compiler.h"
32#include "p_format.h"
33#include "p_video_enums.h"
34#include "p_defines.h"
35#include <stdio.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41
42struct pipe_blend_color;
43struct pipe_blend_state;
44struct pipe_blit_info;
45struct pipe_box;
46struct pipe_clip_state;
47struct pipe_constant_buffer;
48struct pipe_debug_callback;
49struct pipe_depth_stencil_alpha_state;
50struct pipe_device_reset_callback;
51struct pipe_draw_info;
52struct pipe_grid_info;
53struct pipe_fence_handle;
54struct pipe_framebuffer_state;
55struct pipe_image_view;
56struct pipe_index_buffer;
57struct pipe_query;
58struct pipe_poly_stipple;
59struct pipe_rasterizer_state;
60struct pipe_resolve_info;
61struct pipe_resource;
62struct pipe_sampler_state;
63struct pipe_sampler_view;
64struct pipe_scissor_state;
65struct pipe_shader_buffer;
66struct pipe_shader_state;
67struct pipe_stencil_ref;
68struct pipe_stream_output_target;
69struct pipe_surface;
70struct pipe_transfer;
71struct pipe_vertex_buffer;
72struct pipe_vertex_element;
73struct pipe_video_buffer;
74struct pipe_video_codec;
75struct pipe_viewport_state;
76struct pipe_compute_state;
77union pipe_color_union;
78union pipe_query_result;
79
80/**
81 * Gallium rendering context.  Basically:
82 *  - state setting functions
83 *  - VBO drawing functions
84 *  - surface functions
85 */
86struct pipe_context {
87   struct pipe_screen *screen;
88
89   void *priv;  /**< context private data (for DRI for example) */
90   void *draw;  /**< private, for draw module (temporary?) */
91
92   void (*destroy)( struct pipe_context * );
93
94   /**
95    * VBO drawing
96    */
97   /*@{*/
98   void (*draw_vbo)( struct pipe_context *pipe,
99                     const struct pipe_draw_info *info );
100   /*@}*/
101
102   /**
103    * Predicate subsequent rendering on occlusion query result
104    * \param query  the query predicate, or NULL if no predicate
105    * \param condition whether to skip on FALSE or TRUE query results
106    * \param mode  one of PIPE_RENDER_COND_x
107    */
108   void (*render_condition)( struct pipe_context *pipe,
109                             struct pipe_query *query,
110                             boolean condition,
111                             uint mode );
112
113   /**
114    * Query objects
115    */
116   /*@{*/
117   struct pipe_query *(*create_query)( struct pipe_context *pipe,
118                                       unsigned query_type,
119                                       unsigned index );
120
121   /**
122    * Create a query object that queries all given query types simultaneously.
123    *
124    * This can only be used for those query types for which
125    * get_driver_query_info indicates that it must be used. Only one batch
126    * query object may be active at a time.
127    *
128    * There may be additional constraints on which query types can be used
129    * together, in particular those that are implied by
130    * get_driver_query_group_info.
131    *
132    * \param num_queries the number of query types
133    * \param query_types array of \p num_queries query types
134    * \return a query object, or NULL on error.
135    */
136   struct pipe_query *(*create_batch_query)( struct pipe_context *pipe,
137                                             unsigned num_queries,
138                                             unsigned *query_types );
139
140   void (*destroy_query)(struct pipe_context *pipe,
141                         struct pipe_query *q);
142
143   boolean (*begin_query)(struct pipe_context *pipe, struct pipe_query *q);
144   bool (*end_query)(struct pipe_context *pipe, struct pipe_query *q);
145
146   /**
147    * Get results of a query.
148    * \param wait  if true, this query will block until the result is ready
149    * \return TRUE if results are ready, FALSE otherwise
150    */
151   boolean (*get_query_result)(struct pipe_context *pipe,
152                               struct pipe_query *q,
153                               boolean wait,
154                               union pipe_query_result *result);
155
156   /**
157    * Get results of a query, storing into resource. Note that this may not
158    * be used with batch queries.
159    *
160    * \param wait  if true, this query will block until the result is ready
161    * \param result_type  the type of the value being stored:
162    * \param index  for queries that return multiple pieces of data, which
163    *               item of that data to store (e.g. for
164    *               PIPE_QUERY_PIPELINE_STATISTICS).
165    *               When the index is -1, instead of the value of the query
166    *               the driver should instead write a 1 or 0 to the appropriate
167    *               location with 1 meaning that the query result is available.
168    */
169   void (*get_query_result_resource)(struct pipe_context *pipe,
170                                     struct pipe_query *q,
171                                     boolean wait,
172                                     enum pipe_query_value_type result_type,
173                                     int index,
174                                     struct pipe_resource *resource,
175                                     unsigned offset);
176
177   /**
178    * Set whether all current non-driver queries except TIME_ELAPSED are
179    * active or paused.
180    */
181   void (*set_active_query_state)(struct pipe_context *pipe, boolean enable);
182
183   /*@}*/
184
185   /**
186    * State functions (create/bind/destroy state objects)
187    */
188   /*@{*/
189   void * (*create_blend_state)(struct pipe_context *,
190                                const struct pipe_blend_state *);
191   void   (*bind_blend_state)(struct pipe_context *, void *);
192   void   (*delete_blend_state)(struct pipe_context *, void  *);
193
194   void * (*create_sampler_state)(struct pipe_context *,
195                                  const struct pipe_sampler_state *);
196   void   (*bind_sampler_states)(struct pipe_context *,
197                                 enum pipe_shader_type shader,
198                                 unsigned start_slot, unsigned num_samplers,
199                                 void **samplers);
200   void   (*delete_sampler_state)(struct pipe_context *, void *);
201
202   void * (*create_rasterizer_state)(struct pipe_context *,
203                                     const struct pipe_rasterizer_state *);
204   void   (*bind_rasterizer_state)(struct pipe_context *, void *);
205   void   (*delete_rasterizer_state)(struct pipe_context *, void *);
206
207   void * (*create_depth_stencil_alpha_state)(struct pipe_context *,
208                                        const struct pipe_depth_stencil_alpha_state *);
209   void   (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *);
210   void   (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *);
211
212   void * (*create_fs_state)(struct pipe_context *,
213                             const struct pipe_shader_state *);
214   void   (*bind_fs_state)(struct pipe_context *, void *);
215   void   (*delete_fs_state)(struct pipe_context *, void *);
216
217   void * (*create_vs_state)(struct pipe_context *,
218                             const struct pipe_shader_state *);
219   void   (*bind_vs_state)(struct pipe_context *, void *);
220   void   (*delete_vs_state)(struct pipe_context *, void *);
221
222   void * (*create_gs_state)(struct pipe_context *,
223                             const struct pipe_shader_state *);
224   void   (*bind_gs_state)(struct pipe_context *, void *);
225   void   (*delete_gs_state)(struct pipe_context *, void *);
226
227   void * (*create_tcs_state)(struct pipe_context *,
228                              const struct pipe_shader_state *);
229   void   (*bind_tcs_state)(struct pipe_context *, void *);
230   void   (*delete_tcs_state)(struct pipe_context *, void *);
231
232   void * (*create_tes_state)(struct pipe_context *,
233                              const struct pipe_shader_state *);
234   void   (*bind_tes_state)(struct pipe_context *, void *);
235   void   (*delete_tes_state)(struct pipe_context *, void *);
236
237   void * (*create_vertex_elements_state)(struct pipe_context *,
238                                          unsigned num_elements,
239                                          const struct pipe_vertex_element *);
240   void   (*bind_vertex_elements_state)(struct pipe_context *, void *);
241   void   (*delete_vertex_elements_state)(struct pipe_context *, void *);
242
243   /*@}*/
244
245   /**
246    * Parameter-like state (or properties)
247    */
248   /*@{*/
249   void (*set_blend_color)( struct pipe_context *,
250                            const struct pipe_blend_color * );
251
252   void (*set_stencil_ref)( struct pipe_context *,
253                            const struct pipe_stencil_ref * );
254
255   void (*set_sample_mask)( struct pipe_context *,
256                            unsigned sample_mask );
257
258   void (*set_min_samples)( struct pipe_context *,
259                            unsigned min_samples );
260
261   void (*set_clip_state)( struct pipe_context *,
262                            const struct pipe_clip_state * );
263
264   void (*set_constant_buffer)( struct pipe_context *,
265                                uint shader, uint index,
266                                const struct pipe_constant_buffer *buf );
267
268   void (*set_framebuffer_state)( struct pipe_context *,
269                                  const struct pipe_framebuffer_state * );
270
271   void (*set_polygon_stipple)( struct pipe_context *,
272				const struct pipe_poly_stipple * );
273
274   void (*set_scissor_states)( struct pipe_context *,
275                               unsigned start_slot,
276                               unsigned num_scissors,
277                               const struct pipe_scissor_state * );
278
279   void (*set_window_rectangles)( struct pipe_context *,
280                                  boolean include,
281                                  unsigned num_rectangles,
282                                  const struct pipe_scissor_state * );
283
284   void (*set_viewport_states)( struct pipe_context *,
285                                unsigned start_slot,
286                                unsigned num_viewports,
287                                const struct pipe_viewport_state *);
288
289   void (*set_sampler_views)(struct pipe_context *,
290                             enum pipe_shader_type shader,
291                             unsigned start_slot, unsigned num_views,
292                             struct pipe_sampler_view **);
293
294   void (*set_tess_state)(struct pipe_context *,
295                          const float default_outer_level[4],
296                          const float default_inner_level[2]);
297
298   /**
299    * Sets the debug callback. If the pointer is null, then no callback is
300    * set, otherwise a copy of the data should be made.
301    */
302   void (*set_debug_callback)(struct pipe_context *,
303                              const struct pipe_debug_callback *);
304
305   /**
306    * Bind an array of shader buffers that will be used by a shader.
307    * Any buffers that were previously bound to the specified range
308    * will be unbound.
309    *
310    * \param shader     selects shader stage
311    * \param start_slot first buffer slot to bind.
312    * \param count      number of consecutive buffers to bind.
313    * \param buffers    array of pointers to the buffers to bind, it
314    *                   should contain at least \a count elements
315    *                   unless it's NULL, in which case no buffers will
316    *                   be bound.
317    */
318   void (*set_shader_buffers)(struct pipe_context *,
319                              enum pipe_shader_type shader,
320                              unsigned start_slot, unsigned count,
321                              const struct pipe_shader_buffer *buffers);
322
323   /**
324    * Bind an array of images that will be used by a shader.
325    * Any images that were previously bound to the specified range
326    * will be unbound.
327    *
328    * \param shader     selects shader stage
329    * \param start_slot first image slot to bind.
330    * \param count      number of consecutive images to bind.
331    * \param buffers    array of the images to bind, it
332    *                   should contain at least \a count elements
333    *                   unless it's NULL, in which case no images will
334    *                   be bound.
335    */
336   void (*set_shader_images)(struct pipe_context *,
337                             enum pipe_shader_type shader,
338                             unsigned start_slot, unsigned count,
339                             const struct pipe_image_view *images);
340
341   void (*set_vertex_buffers)( struct pipe_context *,
342                               unsigned start_slot,
343                               unsigned num_buffers,
344                               const struct pipe_vertex_buffer * );
345
346   void (*set_index_buffer)( struct pipe_context *pipe,
347                             const struct pipe_index_buffer * );
348
349   /*@}*/
350
351   /**
352    * Stream output functions.
353    */
354   /*@{*/
355
356   struct pipe_stream_output_target *(*create_stream_output_target)(
357                        struct pipe_context *,
358                        struct pipe_resource *,
359                        unsigned buffer_offset,
360                        unsigned buffer_size);
361
362   void (*stream_output_target_destroy)(struct pipe_context *,
363                                        struct pipe_stream_output_target *);
364
365   void (*set_stream_output_targets)(struct pipe_context *,
366                              unsigned num_targets,
367                              struct pipe_stream_output_target **targets,
368                              const unsigned *offsets);
369
370   /*@}*/
371
372
373   /**
374    * Resource functions for blit-like functionality
375    *
376    * If a driver supports multisampling, blit must implement color resolve.
377    */
378   /*@{*/
379
380   /**
381    * Copy a block of pixels from one resource to another.
382    * The resource must be of the same format.
383    * Resources with nr_samples > 1 are not allowed.
384    */
385   void (*resource_copy_region)(struct pipe_context *pipe,
386                                struct pipe_resource *dst,
387                                unsigned dst_level,
388                                unsigned dstx, unsigned dsty, unsigned dstz,
389                                struct pipe_resource *src,
390                                unsigned src_level,
391                                const struct pipe_box *src_box);
392
393   /* Optimal hardware path for blitting pixels.
394    * Scaling, format conversion, up- and downsampling (resolve) are allowed.
395    */
396   void (*blit)(struct pipe_context *pipe,
397                const struct pipe_blit_info *info);
398
399   /*@}*/
400
401   /**
402    * Clear the specified set of currently bound buffers to specified values.
403    * The entire buffers are cleared (no scissor, no colormask, etc).
404    *
405    * \param buffers  bitfield of PIPE_CLEAR_* values.
406    * \param color  pointer to a union of fiu array for each of r, g, b, a.
407    * \param depth  depth clear value in [0,1].
408    * \param stencil  stencil clear value
409    */
410   void (*clear)(struct pipe_context *pipe,
411                 unsigned buffers,
412                 const union pipe_color_union *color,
413                 double depth,
414                 unsigned stencil);
415
416   /**
417    * Clear a color rendertarget surface.
418    * \param color  pointer to an union of fiu array for each of r, g, b, a.
419    */
420   void (*clear_render_target)(struct pipe_context *pipe,
421                               struct pipe_surface *dst,
422                               const union pipe_color_union *color,
423                               unsigned dstx, unsigned dsty,
424                               unsigned width, unsigned height,
425                               bool render_condition_enabled);
426
427   /**
428    * Clear a depth-stencil surface.
429    * \param clear_flags  bitfield of PIPE_CLEAR_DEPTH/STENCIL values.
430    * \param depth  depth clear value in [0,1].
431    * \param stencil  stencil clear value
432    */
433   void (*clear_depth_stencil)(struct pipe_context *pipe,
434                               struct pipe_surface *dst,
435                               unsigned clear_flags,
436                               double depth,
437                               unsigned stencil,
438                               unsigned dstx, unsigned dsty,
439                               unsigned width, unsigned height,
440                               bool render_condition_enabled);
441
442   /**
443    * Clear the texture with the specified texel. Not guaranteed to be a
444    * renderable format. Data provided in the resource's format.
445    */
446   void (*clear_texture)(struct pipe_context *pipe,
447                         struct pipe_resource *res,
448                         unsigned level,
449                         const struct pipe_box *box,
450                         const void *data);
451
452   /**
453    * Clear a buffer. Runs a memset over the specified region with the element
454    * value passed in through clear_value of size clear_value_size.
455    */
456   void (*clear_buffer)(struct pipe_context *pipe,
457                        struct pipe_resource *res,
458                        unsigned offset,
459                        unsigned size,
460                        const void *clear_value,
461                        int clear_value_size);
462
463   /**
464    * Flush draw commands
465    *
466    * NOTE: use screen->fence_reference() (or equivalent) to transfer
467    * new fence ref to **fence, to ensure that previous fence is unref'd
468    *
469    * \param fence  if not NULL, an old fence to unref and transfer a
470    *    new fence reference to
471    * \param flags  bitfield of enum pipe_flush_flags values.
472    */
473   void (*flush)(struct pipe_context *pipe,
474                 struct pipe_fence_handle **fence,
475                 unsigned flags);
476
477   /**
478    * Create a fence from a native sync fd.
479    *
480    * This is used for importing a foreign/external fence fd.
481    *
482    * \param fence  if not NULL, an old fence to unref and transfer a
483    *    new fence reference to
484    * \param fd     native fence fd
485    */
486   void (*create_fence_fd)(struct pipe_context *pipe,
487                           struct pipe_fence_handle **fence,
488                           int fd);
489
490   /**
491    * Insert commands to have GPU wait for fence to be signaled.
492    */
493   void (*fence_server_sync)(struct pipe_context *pipe,
494                             struct pipe_fence_handle *fence);
495
496   /**
497    * Create a view on a texture to be used by a shader stage.
498    */
499   struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,
500                                                     struct pipe_resource *texture,
501                                                     const struct pipe_sampler_view *templat);
502
503   void (*sampler_view_destroy)(struct pipe_context *ctx,
504                                struct pipe_sampler_view *view);
505
506
507   /**
508    * Get a surface which is a "view" into a resource, used by
509    * render target / depth stencil stages.
510    */
511   struct pipe_surface *(*create_surface)(struct pipe_context *ctx,
512                                          struct pipe_resource *resource,
513                                          const struct pipe_surface *templat);
514
515   void (*surface_destroy)(struct pipe_context *ctx,
516                           struct pipe_surface *);
517
518
519   /**
520    * Map a resource.
521    *
522    * Transfers are (by default) context-private and allow uploads to be
523    * interleaved with rendering.
524    *
525    * out_transfer will contain the transfer object that must be passed
526    * to all the other transfer functions. It also contains useful
527    * information (like texture strides).
528    */
529   void *(*transfer_map)(struct pipe_context *,
530                         struct pipe_resource *resource,
531                         unsigned level,
532                         unsigned usage,  /* a combination of PIPE_TRANSFER_x */
533                         const struct pipe_box *,
534                         struct pipe_transfer **out_transfer);
535
536   /* If transfer was created with WRITE|FLUSH_EXPLICIT, only the
537    * regions specified with this call are guaranteed to be written to
538    * the resource.
539    */
540   void (*transfer_flush_region)( struct pipe_context *,
541				  struct pipe_transfer *transfer,
542				  const struct pipe_box *);
543
544   void (*transfer_unmap)(struct pipe_context *,
545                          struct pipe_transfer *transfer);
546
547   /* One-shot transfer operation with data supplied in a user
548    * pointer.
549    */
550   void (*buffer_subdata)(struct pipe_context *,
551                          struct pipe_resource *,
552                          unsigned usage, /* a combination of PIPE_TRANSFER_x */
553                          unsigned offset,
554                          unsigned size,
555                          const void *data);
556
557   void (*texture_subdata)(struct pipe_context *,
558                           struct pipe_resource *,
559                           unsigned level,
560                           unsigned usage, /* a combination of PIPE_TRANSFER_x */
561                           const struct pipe_box *,
562                           const void *data,
563                           unsigned stride,
564                           unsigned layer_stride);
565
566   /**
567    * Flush any pending framebuffer writes and invalidate texture caches.
568    */
569   void (*texture_barrier)(struct pipe_context *, unsigned flags);
570
571   /**
572    * Flush caches according to flags.
573    */
574   void (*memory_barrier)(struct pipe_context *, unsigned flags);
575
576   /**
577    * Creates a video codec for a specific video format/profile
578    */
579   struct pipe_video_codec *(*create_video_codec)( struct pipe_context *context,
580                                                   const struct pipe_video_codec *templat );
581
582   /**
583    * Creates a video buffer as decoding target
584    */
585   struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,
586                                                     const struct pipe_video_buffer *templat );
587
588   /**
589    * Compute kernel execution
590    */
591   /*@{*/
592   /**
593    * Define the compute program and parameters to be used by
594    * pipe_context::launch_grid.
595    */
596   void *(*create_compute_state)(struct pipe_context *context,
597				 const struct pipe_compute_state *);
598   void (*bind_compute_state)(struct pipe_context *, void *);
599   void (*delete_compute_state)(struct pipe_context *, void *);
600
601   /**
602    * Bind an array of shader resources that will be used by the
603    * compute program.  Any resources that were previously bound to
604    * the specified range will be unbound after this call.
605    *
606    * \param start      first resource to bind.
607    * \param count      number of consecutive resources to bind.
608    * \param resources  array of pointers to the resources to bind, it
609    *                   should contain at least \a count elements
610    *                   unless it's NULL, in which case no new
611    *                   resources will be bound.
612    */
613   void (*set_compute_resources)(struct pipe_context *,
614                                 unsigned start, unsigned count,
615                                 struct pipe_surface **resources);
616
617   /**
618    * Bind an array of buffers to be mapped into the address space of
619    * the GLOBAL resource.  Any buffers that were previously bound
620    * between [first, first + count - 1] are unbound after this call.
621    *
622    * \param first      first buffer to map.
623    * \param count      number of consecutive buffers to map.
624    * \param resources  array of pointers to the buffers to map, it
625    *                   should contain at least \a count elements
626    *                   unless it's NULL, in which case no new
627    *                   resources will be bound.
628    * \param handles    array of pointers to the memory locations that
629    *                   will be updated with the address each buffer
630    *                   will be mapped to.  The base memory address of
631    *                   each of the buffers will be added to the value
632    *                   pointed to by its corresponding handle to form
633    *                   the final address argument.  It should contain
634    *                   at least \a count elements, unless \a
635    *                   resources is NULL in which case \a handles
636    *                   should be NULL as well.
637    *
638    * Note that the driver isn't required to make any guarantees about
639    * the contents of the \a handles array being valid anytime except
640    * during the subsequent calls to pipe_context::launch_grid.  This
641    * means that the only sensible location handles[i] may point to is
642    * somewhere within the INPUT buffer itself.  This is so to
643    * accommodate implementations that lack virtual memory but
644    * nevertheless migrate buffers on the fly, leading to resource
645    * base addresses that change on each kernel invocation or are
646    * unknown to the pipe driver.
647    */
648   void (*set_global_binding)(struct pipe_context *context,
649                              unsigned first, unsigned count,
650                              struct pipe_resource **resources,
651                              uint32_t **handles);
652
653   /**
654    * Launch the compute kernel starting from instruction \a pc of the
655    * currently bound compute program.
656    */
657   void (*launch_grid)(struct pipe_context *context,
658                       const struct pipe_grid_info *info);
659   /*@}*/
660
661   /**
662    * Get sample position for an individual sample point.
663    *
664    * \param sample_count - total number of samples
665    * \param sample_index - sample to get the position values for
666    * \param out_value - return value of 2 floats for x and y position for
667    *                    requested sample.
668    */
669   void (*get_sample_position)(struct pipe_context *context,
670                               unsigned sample_count,
671                               unsigned sample_index,
672                               float *out_value);
673
674   /**
675    * Query a timestamp in nanoseconds.  This is completely equivalent to
676    * pipe_screen::get_timestamp() but takes a context handle for drivers
677    * that require a context.
678    */
679   uint64_t (*get_timestamp)(struct pipe_context *);
680
681   /**
682    * Flush the resource cache, so that the resource can be used
683    * by an external client. Possible usage:
684    * - flushing a resource before presenting it on the screen
685    * - flushing a resource if some other process or device wants to use it
686    * This shouldn't be used to flush caches if the resource is only managed
687    * by a single pipe_screen and is not shared with another process.
688    * (i.e. you shouldn't use it to flush caches explicitly if you want to e.g.
689    * use the resource for texturing)
690    */
691   void (*flush_resource)(struct pipe_context *ctx,
692                          struct pipe_resource *resource);
693
694   /**
695    * Invalidate the contents of the resource. This is used to
696    *
697    * (1) implement EGL's semantic of undefined depth/stencil
698    * contenst after a swapbuffers.  This allows a tiled renderer (for
699    * example) to not store the depth buffer.
700    *
701    * (2) implement GL's InvalidateBufferData. For backwards compatibility,
702    * you must only rely on the usability for this purpose when
703    * PIPE_CAP_INVALIDATE_BUFFER is enabled.
704    */
705   void (*invalidate_resource)(struct pipe_context *ctx,
706                               struct pipe_resource *resource);
707
708   /**
709    * Return information about unexpected device resets.
710    */
711   enum pipe_reset_status (*get_device_reset_status)(struct pipe_context *ctx);
712
713   /**
714    * Sets the reset status callback. If the pointer is null, then no callback
715    * is set, otherwise a copy of the data should be made.
716    */
717   void (*set_device_reset_callback)(struct pipe_context *ctx,
718                                     const struct pipe_device_reset_callback *cb);
719
720   /**
721    * Dump driver-specific debug information into a stream. This is
722    * used by debugging tools.
723    *
724    * \param ctx        pipe context
725    * \param stream     where the output should be written to
726    * \param flags      a mask of PIPE_DUMP_* flags
727    */
728   void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream,
729                            unsigned flags);
730
731   /**
732    * Emit string marker in cmdstream
733    */
734   void (*emit_string_marker)(struct pipe_context *ctx,
735                              const char *string,
736                              int len);
737
738   /**
739    * Generate mipmap.
740    * \return TRUE if mipmap generation succeeds, FALSE otherwise
741    */
742   boolean (*generate_mipmap)(struct pipe_context *ctx,
743                              struct pipe_resource *resource,
744                              enum pipe_format format,
745                              unsigned base_level,
746                              unsigned last_level,
747                              unsigned first_layer,
748                              unsigned last_layer);
749};
750
751
752#ifdef __cplusplus
753}
754#endif
755
756#endif /* PIPE_CONTEXT_H */
757