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