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