gallium: add PIPE_CAP_CLEAR_TEXTURE and clear_texture prototype
[mesa.git] / src / gallium / docs / source / context.rst
1 .. _context:
2
3 Context
4 =======
5
6 A Gallium rendering context encapsulates the state which effects 3D
7 rendering such as blend state, depth/stencil state, texture samplers,
8 etc.
9
10 Note that resource/texture allocation is not per-context but per-screen.
11
12
13 Methods
14 -------
15
16 CSO State
17 ^^^^^^^^^
18
19 All Constant State Object (CSO) state is created, bound, and destroyed,
20 with triplets of methods that all follow a specific naming scheme.
21 For example, ``create_blend_state``, ``bind_blend_state``, and
22 ``destroy_blend_state``.
23
24 CSO objects handled by the context object:
25
26 * :ref:`Blend`: ``*_blend_state``
27 * :ref:`Sampler`: Texture sampler states are bound separately for fragment,
28 vertex, geometry and compute shaders with the ``bind_sampler_states``
29 function. The ``start`` and ``num_samplers`` parameters indicate a range
30 of samplers to change. NOTE: at this time, start is always zero and
31 the CSO module will always replace all samplers at once (no sub-ranges).
32 This may change in the future.
33 * :ref:`Rasterizer`: ``*_rasterizer_state``
34 * :ref:`depth-stencil-alpha`: ``*_depth_stencil_alpha_state``
35 * :ref:`Shader`: These are create, bind and destroy methods for vertex,
36 fragment and geometry shaders.
37 * :ref:`vertexelements`: ``*_vertex_elements_state``
38
39
40 Resource Binding State
41 ^^^^^^^^^^^^^^^^^^^^^^
42
43 This state describes how resources in various flavours (textures,
44 buffers, surfaces) are bound to the driver.
45
46
47 * ``set_constant_buffer`` sets a constant buffer to be used for a given shader
48 type. index is used to indicate which buffer to set (some apis may allow
49 multiple ones to be set, and binding a specific one later, though drivers
50 are mostly restricted to the first one right now).
51
52 * ``set_framebuffer_state``
53
54 * ``set_vertex_buffers``
55
56 * ``set_index_buffer``
57
58
59 Non-CSO State
60 ^^^^^^^^^^^^^
61
62 These pieces of state are too small, variable, and/or trivial to have CSO
63 objects. They all follow simple, one-method binding calls, e.g.
64 ``set_blend_color``.
65
66 * ``set_stencil_ref`` sets the stencil front and back reference values
67 which are used as comparison values in stencil test.
68 * ``set_blend_color``
69 * ``set_sample_mask``
70 * ``set_min_samples`` sets the minimum number of samples that must be run.
71 * ``set_clip_state``
72 * ``set_polygon_stipple``
73 * ``set_scissor_states`` sets the bounds for the scissor test, which culls
74 pixels before blending to render targets. If the :ref:`Rasterizer` does
75 not have the scissor test enabled, then the scissor bounds never need to
76 be set since they will not be used. Note that scissor xmin and ymin are
77 inclusive, but xmax and ymax are exclusive. The inclusive ranges in x
78 and y would be [xmin..xmax-1] and [ymin..ymax-1]. The number of scissors
79 should be the same as the number of set viewports and can be up to
80 PIPE_MAX_VIEWPORTS.
81 * ``set_viewport_states``
82 * ``set_tess_state`` configures the default tessellation parameters:
83 * ``default_outer_level`` is the default value for the outer tessellation
84 levels. This corresponds to GL's ``PATCH_DEFAULT_OUTER_LEVEL``.
85 * ``default_inner_level`` is the default value for the inner tessellation
86 levels. This corresponds to GL's ``PATCH_DEFAULT_INNER_LEVEL``.
87 * ``set_debug_callback`` sets the callback to be used for reporting
88 various debug messages, eventually reported via KHR_debug and
89 similar mechanisms.
90
91
92 Sampler Views
93 ^^^^^^^^^^^^^
94
95 These are the means to bind textures to shader stages. To create one, specify
96 its format, swizzle and LOD range in sampler view template.
97
98 If texture format is different than template format, it is said the texture
99 is being cast to another format. Casting can be done only between compatible
100 formats, that is formats that have matching component order and sizes.
101
102 Swizzle fields specify they way in which fetched texel components are placed
103 in the result register. For example, ``swizzle_r`` specifies what is going to be
104 placed in first component of result register.
105
106 The ``first_level`` and ``last_level`` fields of sampler view template specify
107 the LOD range the texture is going to be constrained to. Note that these
108 values are in addition to the respective min_lod, max_lod values in the
109 pipe_sampler_state (that is if min_lod is 2.0, and first_level 3, the first mip
110 level used for sampling from the resource is effectively the fifth).
111
112 The ``first_layer`` and ``last_layer`` fields specify the layer range the
113 texture is going to be constrained to. Similar to the LOD range, this is added
114 to the array index which is used for sampling.
115
116 * ``set_sampler_views`` binds an array of sampler views to a shader stage.
117 Every binding point acquires a reference
118 to a respective sampler view and releases a reference to the previous
119 sampler view.
120
121 * ``create_sampler_view`` creates a new sampler view. ``texture`` is associated
122 with the sampler view which results in sampler view holding a reference
123 to the texture. Format specified in template must be compatible
124 with texture format.
125
126 * ``sampler_view_destroy`` destroys a sampler view and releases its reference
127 to associated texture.
128
129 Shader Resources
130 ^^^^^^^^^^^^^^^^
131
132 Shader resources are textures or buffers that may be read or written
133 from a shader without an associated sampler. This means that they
134 have no support for floating point coordinates, address wrap modes or
135 filtering.
136
137 There are 2 types of shader resources: buffers and images.
138
139 Buffers are specified using the ``set_shader_buffers`` method.
140
141 Images are specified using the ``set_shader_images`` method. When binding
142 images, the ``level``, ``first_layer`` and ``last_layer`` pipe_image_view
143 fields specify the mipmap level and the range of layers the image will be
144 constrained to.
145
146 Surfaces
147 ^^^^^^^^
148
149 These are the means to use resources as color render targets or depthstencil
150 attachments. To create one, specify the mip level, the range of layers, and
151 the bind flags (either PIPE_BIND_DEPTH_STENCIL or PIPE_BIND_RENDER_TARGET).
152 Note that layer values are in addition to what is indicated by the geometry
153 shader output variable XXX_FIXME (that is if first_layer is 3 and geometry
154 shader indicates index 2, the 5th layer of the resource will be used). These
155 first_layer and last_layer parameters will only be used for 1d array, 2d array,
156 cube, and 3d textures otherwise they are 0.
157
158 * ``create_surface`` creates a new surface.
159
160 * ``surface_destroy`` destroys a surface and releases its reference to the
161 associated resource.
162
163 Stream output targets
164 ^^^^^^^^^^^^^^^^^^^^^
165
166 Stream output, also known as transform feedback, allows writing the primitives
167 produced by the vertex pipeline to buffers. This is done after the geometry
168 shader or vertex shader if no geometry shader is present.
169
170 The stream output targets are views into buffer resources which can be bound
171 as stream outputs and specify a memory range where it's valid to write
172 primitives. The pipe driver must implement memory protection such that any
173 primitives written outside of the specified memory range are discarded.
174
175 Two stream output targets can use the same resource at the same time, but
176 with a disjoint memory range.
177
178 Additionally, the stream output target internally maintains the offset
179 into the buffer which is incremented everytime something is written to it.
180 The internal offset is equal to how much data has already been written.
181 It can be stored in device memory and the CPU actually doesn't have to query
182 it.
183
184 The stream output target can be used in a draw command to provide
185 the vertex count. The vertex count is derived from the internal offset
186 discussed above.
187
188 * ``create_stream_output_target`` create a new target.
189
190 * ``stream_output_target_destroy`` destroys a target. Users of this should
191 use pipe_so_target_reference instead.
192
193 * ``set_stream_output_targets`` binds stream output targets. The parameter
194 offset is an array which specifies the internal offset of the buffer. The
195 internal offset is, besides writing, used for reading the data during the
196 draw_auto stage, i.e. it specifies how much data there is in the buffer
197 for the purposes of the draw_auto stage. -1 means the buffer should
198 be appended to, and everything else sets the internal offset.
199
200 NOTE: The currently-bound vertex or geometry shader must be compiled with
201 the properly-filled-in structure pipe_stream_output_info describing which
202 outputs should be written to buffers and how. The structure is part of
203 pipe_shader_state.
204
205 Clearing
206 ^^^^^^^^
207
208 Clear is one of the most difficult concepts to nail down to a single
209 interface (due to both different requirements from APIs and also driver/hw
210 specific differences).
211
212 ``clear`` initializes some or all of the surfaces currently bound to
213 the framebuffer to particular RGBA, depth, or stencil values.
214 Currently, this does not take into account color or stencil write masks (as
215 used by GL), and always clears the whole surfaces (no scissoring as used by
216 GL clear or explicit rectangles like d3d9 uses). It can, however, also clear
217 only depth or stencil in a combined depth/stencil surface.
218 If a surface includes several layers then all layers will be cleared.
219
220 ``clear_render_target`` clears a single color rendertarget with the specified
221 color value. While it is only possible to clear one surface at a time (which can
222 include several layers), this surface need not be bound to the framebuffer.
223
224 ``clear_depth_stencil`` clears a single depth, stencil or depth/stencil surface
225 with the specified depth and stencil values (for combined depth/stencil buffers,
226 is is also possible to only clear one or the other part). While it is only
227 possible to clear one surface at a time (which can include several layers),
228 this surface need not be bound to the framebuffer.
229
230 ``clear_texture`` clears a non-PIPE_BUFFER resource's specified level
231 and bounding box with a clear value provided in that resource's native
232 format.
233
234 ``clear_buffer`` clears a PIPE_BUFFER resource with the specified clear value
235 (which may be multiple bytes in length). Logically this is a memset with a
236 multi-byte element value starting at offset bytes from resource start, going
237 for size bytes. It is guaranteed that size % clear_value_size == 0.
238
239
240 Drawing
241 ^^^^^^^
242
243 ``draw_vbo`` draws a specified primitive. The primitive mode and other
244 properties are described by ``pipe_draw_info``.
245
246 The ``mode``, ``start``, and ``count`` fields of ``pipe_draw_info`` specify the
247 the mode of the primitive and the vertices to be fetched, in the range between
248 ``start`` to ``start``+``count``-1, inclusive.
249
250 Every instance with instanceID in the range between ``start_instance`` and
251 ``start_instance``+``instance_count``-1, inclusive, will be drawn.
252
253 If there is an index buffer bound, and ``indexed`` field is true, all vertex
254 indices will be looked up in the index buffer.
255
256 In indexed draw, ``min_index`` and ``max_index`` respectively provide a lower
257 and upper bound of the indices contained in the index buffer inside the range
258 between ``start`` to ``start``+``count``-1. This allows the driver to
259 determine which subset of vertices will be referenced during te draw call
260 without having to scan the index buffer. Providing a over-estimation of the
261 the true bounds, for example, a ``min_index`` and ``max_index`` of 0 and
262 0xffffffff respectively, must give exactly the same rendering, albeit with less
263 performance due to unreferenced vertex buffers being unnecessarily DMA'ed or
264 processed. Providing a underestimation of the true bounds will result in
265 undefined behavior, but should not result in program or system failure.
266
267 In case of non-indexed draw, ``min_index`` should be set to
268 ``start`` and ``max_index`` should be set to ``start``+``count``-1.
269
270 ``index_bias`` is a value added to every vertex index after lookup and before
271 fetching vertex attributes.
272
273 When drawing indexed primitives, the primitive restart index can be
274 used to draw disjoint primitive strips. For example, several separate
275 line strips can be drawn by designating a special index value as the
276 restart index. The ``primitive_restart`` flag enables/disables this
277 feature. The ``restart_index`` field specifies the restart index value.
278
279 When primitive restart is in use, array indexes are compared to the
280 restart index before adding the index_bias offset.
281
282 If a given vertex element has ``instance_divisor`` set to 0, it is said
283 it contains per-vertex data and effective vertex attribute address needs
284 to be recalculated for every index.
285
286 attribAddr = ``stride`` * index + ``src_offset``
287
288 If a given vertex element has ``instance_divisor`` set to non-zero,
289 it is said it contains per-instance data and effective vertex attribute
290 address needs to recalculated for every ``instance_divisor``-th instance.
291
292 attribAddr = ``stride`` * instanceID / ``instance_divisor`` + ``src_offset``
293
294 In the above formulas, ``src_offset`` is taken from the given vertex element
295 and ``stride`` is taken from a vertex buffer associated with the given
296 vertex element.
297
298 The calculated attribAddr is used as an offset into the vertex buffer to
299 fetch the attribute data.
300
301 The value of ``instanceID`` can be read in a vertex shader through a system
302 value register declared with INSTANCEID semantic name.
303
304
305 Queries
306 ^^^^^^^
307
308 Queries gather some statistic from the 3D pipeline over one or more
309 draws. Queries may be nested, though not all state trackers exercise this.
310
311 Queries can be created with ``create_query`` and deleted with
312 ``destroy_query``. To start a query, use ``begin_query``, and when finished,
313 use ``end_query`` to end the query.
314
315 ``create_query`` takes a query type (``PIPE_QUERY_*``), as well as an index,
316 which is the vertex stream for ``PIPE_QUERY_PRIMITIVES_GENERATED`` and
317 ``PIPE_QUERY_PRIMITIVES_EMITTED``, and allocates a query structure.
318
319 ``begin_query`` will clear/reset previous query results.
320
321 ``get_query_result`` is used to retrieve the results of a query. If
322 the ``wait`` parameter is TRUE, then the ``get_query_result`` call
323 will block until the results of the query are ready (and TRUE will be
324 returned). Otherwise, if the ``wait`` parameter is FALSE, the call
325 will not block and the return value will be TRUE if the query has
326 completed or FALSE otherwise.
327
328 The interface currently includes the following types of queries:
329
330 ``PIPE_QUERY_OCCLUSION_COUNTER`` counts the number of fragments which
331 are written to the framebuffer without being culled by
332 :ref:`depth-stencil-alpha` testing or shader KILL instructions.
333 The result is an unsigned 64-bit integer.
334 This query can be used with ``render_condition``.
335
336 In cases where a boolean result of an occlusion query is enough,
337 ``PIPE_QUERY_OCCLUSION_PREDICATE`` should be used. It is just like
338 ``PIPE_QUERY_OCCLUSION_COUNTER`` except that the result is a boolean
339 value of FALSE for cases where COUNTER would result in 0 and TRUE
340 for all other cases.
341 This query can be used with ``render_condition``.
342
343 ``PIPE_QUERY_TIME_ELAPSED`` returns the amount of time, in nanoseconds,
344 the context takes to perform operations.
345 The result is an unsigned 64-bit integer.
346
347 ``PIPE_QUERY_TIMESTAMP`` returns a device/driver internal timestamp,
348 scaled to nanoseconds, recorded after all commands issued prior to
349 ``end_query`` have been processed.
350 This query does not require a call to ``begin_query``.
351 The result is an unsigned 64-bit integer.
352
353 ``PIPE_QUERY_TIMESTAMP_DISJOINT`` can be used to check the
354 internal timer resolution and whether the timestamp counter has become
355 unreliable due to things like throttling etc. - only if this is FALSE
356 a timestamp query (within the timestamp_disjoint query) should be trusted.
357 The result is a 64-bit integer specifying the timer resolution in Hz,
358 followed by a boolean value indicating whether the timestamp counter
359 is discontinuous or disjoint.
360
361 ``PIPE_QUERY_PRIMITIVES_GENERATED`` returns a 64-bit integer indicating
362 the number of primitives processed by the pipeline (regardless of whether
363 stream output is active or not).
364
365 ``PIPE_QUERY_PRIMITIVES_EMITTED`` returns a 64-bit integer indicating
366 the number of primitives written to stream output buffers.
367
368 ``PIPE_QUERY_SO_STATISTICS`` returns 2 64-bit integers corresponding to
369 the result of
370 ``PIPE_QUERY_PRIMITIVES_EMITTED`` and
371 the number of primitives that would have been written to stream output buffers
372 if they had infinite space available (primitives_storage_needed), in this order.
373 XXX the 2nd value is equivalent to ``PIPE_QUERY_PRIMITIVES_GENERATED`` but it is
374 unclear if it should be increased if stream output is not active.
375
376 ``PIPE_QUERY_SO_OVERFLOW_PREDICATE`` returns a boolean value indicating
377 whether the stream output targets have overflowed as a result of the
378 commands issued between ``begin_query`` and ``end_query``.
379 This query can be used with ``render_condition``.
380
381 ``PIPE_QUERY_GPU_FINISHED`` returns a boolean value indicating whether
382 all commands issued before ``end_query`` have completed. However, this
383 does not imply serialization.
384 This query does not require a call to ``begin_query``.
385
386 ``PIPE_QUERY_PIPELINE_STATISTICS`` returns an array of the following
387 64-bit integers:
388 Number of vertices read from vertex buffers.
389 Number of primitives read from vertex buffers.
390 Number of vertex shader threads launched.
391 Number of geometry shader threads launched.
392 Number of primitives generated by geometry shaders.
393 Number of primitives forwarded to the rasterizer.
394 Number of primitives rasterized.
395 Number of fragment shader threads launched.
396 Number of tessellation control shader threads launched.
397 Number of tessellation evaluation shader threads launched.
398 If a shader type is not supported by the device/driver,
399 the corresponding values should be set to 0.
400
401 Gallium does not guarantee the availability of any query types; one must
402 always check the capabilities of the :ref:`Screen` first.
403
404
405 Conditional Rendering
406 ^^^^^^^^^^^^^^^^^^^^^
407
408 A drawing command can be skipped depending on the outcome of a query
409 (typically an occlusion query, or streamout overflow predicate).
410 The ``render_condition`` function specifies the query which should be checked
411 prior to rendering anything. Functions always honoring render_condition include
412 (and are limited to) draw_vbo, clear, clear_render_target, clear_depth_stencil.
413 The blit function (but not resource_copy_region, which seems inconsistent)
414 can also optionally honor the current render condition.
415
416 If ``render_condition`` is called with ``query`` = NULL, conditional
417 rendering is disabled and drawing takes place normally.
418
419 If ``render_condition`` is called with a non-null ``query`` subsequent
420 drawing commands will be predicated on the outcome of the query.
421 Commands will be skipped if ``condition`` is equal to the predicate result
422 (for non-boolean queries such as OCCLUSION_QUERY, zero counts as FALSE,
423 non-zero as TRUE).
424
425 If ``mode`` is PIPE_RENDER_COND_WAIT the driver will wait for the
426 query to complete before deciding whether to render.
427
428 If ``mode`` is PIPE_RENDER_COND_NO_WAIT and the query has not yet
429 completed, the drawing command will be executed normally. If the query
430 has completed, drawing will be predicated on the outcome of the query.
431
432 If ``mode`` is PIPE_RENDER_COND_BY_REGION_WAIT or
433 PIPE_RENDER_COND_BY_REGION_NO_WAIT rendering will be predicated as above
434 for the non-REGION modes but in the case that an occlusion query returns
435 a non-zero result, regions which were occluded may be ommitted by subsequent
436 drawing commands. This can result in better performance with some GPUs.
437 Normally, if the occlusion query returned a non-zero result subsequent
438 drawing happens normally so fragments may be generated, shaded and
439 processed even where they're known to be obscured.
440
441
442 Flushing
443 ^^^^^^^^
444
445 ``flush``
446
447
448 ``flush_resource``
449
450 Flush the resource cache, so that the resource can be used
451 by an external client. Possible usage:
452 - flushing a resource before presenting it on the screen
453 - flushing a resource if some other process or device wants to use it
454 This shouldn't be used to flush caches if the resource is only managed
455 by a single pipe_screen and is not shared with another process.
456 (i.e. you shouldn't use it to flush caches explicitly if you want to e.g.
457 use the resource for texturing)
458
459
460
461 Resource Busy Queries
462 ^^^^^^^^^^^^^^^^^^^^^
463
464 ``is_resource_referenced``
465
466
467
468 Blitting
469 ^^^^^^^^
470
471 These methods emulate classic blitter controls.
472
473 These methods operate directly on ``pipe_resource`` objects, and stand
474 apart from any 3D state in the context. Blitting functionality may be
475 moved to a separate abstraction at some point in the future.
476
477 ``resource_copy_region`` blits a region of a resource to a region of another
478 resource, provided that both resources have the same format, or compatible
479 formats, i.e., formats for which copying the bytes from the source resource
480 unmodified to the destination resource will achieve the same effect of a
481 textured quad blitter.. The source and destination may be the same resource,
482 but overlapping blits are not permitted.
483 This can be considered the equivalent of a CPU memcpy.
484
485 ``blit`` blits a region of a resource to a region of another resource, including
486 scaling, format conversion, and up-/downsampling, as well as a destination clip
487 rectangle (scissors). It can also optionally honor the current render condition
488 (but either way the blit itself never contributes anything to queries currently
489 gathering data).
490 As opposed to manually drawing a textured quad, this lets the pipe driver choose
491 the optimal method for blitting (like using a special 2D engine), and usually
492 offers, for example, accelerated stencil-only copies even where
493 PIPE_CAP_SHADER_STENCIL_EXPORT is not available.
494
495
496 Transfers
497 ^^^^^^^^^
498
499 These methods are used to get data to/from a resource.
500
501 ``transfer_map`` creates a memory mapping and the transfer object
502 associated with it.
503 The returned pointer points to the start of the mapped range according to
504 the box region, not the beginning of the resource. If transfer_map fails,
505 the returned pointer to the buffer memory is NULL, and the pointer
506 to the transfer object remains unchanged (i.e. it can be non-NULL).
507
508 ``transfer_unmap`` remove the memory mapping for and destroy
509 the transfer object. The pointer into the resource should be considered
510 invalid and discarded.
511
512 ``transfer_inline_write`` performs a simplified transfer for simple writes.
513 Basically transfer_map, data write, and transfer_unmap all in one.
514
515
516 The box parameter to some of these functions defines a 1D, 2D or 3D
517 region of pixels. This is self-explanatory for 1D, 2D and 3D texture
518 targets.
519
520 For PIPE_TEXTURE_1D_ARRAY and PIPE_TEXTURE_2D_ARRAY, the box::z and box::depth
521 fields refer to the array dimension of the texture.
522
523 For PIPE_TEXTURE_CUBE, the box:z and box::depth fields refer to the
524 faces of the cube map (z + depth <= 6).
525
526 For PIPE_TEXTURE_CUBE_ARRAY, the box:z and box::depth fields refer to both
527 the face and array dimension of the texture (face = z % 6, array = z / 6).
528
529
530 .. _transfer_flush_region:
531
532 transfer_flush_region
533 %%%%%%%%%%%%%%%%%%%%%
534
535 If a transfer was created with ``FLUSH_EXPLICIT``, it will not automatically
536 be flushed on write or unmap. Flushes must be requested with
537 ``transfer_flush_region``. Flush ranges are relative to the mapped range, not
538 the beginning of the resource.
539
540
541
542 .. _texture_barrier:
543
544 texture_barrier
545 %%%%%%%%%%%%%%%
546
547 This function flushes all pending writes to the currently-set surfaces and
548 invalidates all read caches of the currently-set samplers.
549
550
551
552 .. _memory_barrier:
553
554 memory_barrier
555 %%%%%%%%%%%%%%%
556
557 This function flushes caches according to which of the PIPE_BARRIER_* flags
558 are set.
559
560
561
562 .. _pipe_transfer:
563
564 PIPE_TRANSFER
565 ^^^^^^^^^^^^^
566
567 These flags control the behavior of a transfer object.
568
569 ``PIPE_TRANSFER_READ``
570 Resource contents read back (or accessed directly) at transfer create time.
571
572 ``PIPE_TRANSFER_WRITE``
573 Resource contents will be written back at transfer_unmap time (or modified
574 as a result of being accessed directly).
575
576 ``PIPE_TRANSFER_MAP_DIRECTLY``
577 a transfer should directly map the resource. May return NULL if not supported.
578
579 ``PIPE_TRANSFER_DISCARD_RANGE``
580 The memory within the mapped region is discarded. Cannot be used with
581 ``PIPE_TRANSFER_READ``.
582
583 ``PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE``
584 Discards all memory backing the resource. It should not be used with
585 ``PIPE_TRANSFER_READ``.
586
587 ``PIPE_TRANSFER_DONTBLOCK``
588 Fail if the resource cannot be mapped immediately.
589
590 ``PIPE_TRANSFER_UNSYNCHRONIZED``
591 Do not synchronize pending operations on the resource when mapping. The
592 interaction of any writes to the map and any operations pending on the
593 resource are undefined. Cannot be used with ``PIPE_TRANSFER_READ``.
594
595 ``PIPE_TRANSFER_FLUSH_EXPLICIT``
596 Written ranges will be notified later with :ref:`transfer_flush_region`.
597 Cannot be used with ``PIPE_TRANSFER_READ``.
598
599 ``PIPE_TRANSFER_PERSISTENT``
600 Allows the resource to be used for rendering while mapped.
601 PIPE_RESOURCE_FLAG_MAP_PERSISTENT must be set when creating
602 the resource.
603 If COHERENT is not set, memory_barrier(PIPE_BARRIER_MAPPED_BUFFER)
604 must be called to ensure the device can see what the CPU has written.
605
606 ``PIPE_TRANSFER_COHERENT``
607 If PERSISTENT is set, this ensures any writes done by the device are
608 immediately visible to the CPU and vice versa.
609 PIPE_RESOURCE_FLAG_MAP_COHERENT must be set when creating
610 the resource.
611
612 Compute kernel execution
613 ^^^^^^^^^^^^^^^^^^^^^^^^
614
615 A compute program can be defined, bound or destroyed using
616 ``create_compute_state``, ``bind_compute_state`` or
617 ``destroy_compute_state`` respectively.
618
619 Any of the subroutines contained within the compute program can be
620 executed on the device using the ``launch_grid`` method. This method
621 will execute as many instances of the program as elements in the
622 specified N-dimensional grid, hopefully in parallel.
623
624 The compute program has access to four special resources:
625
626 * ``GLOBAL`` represents a memory space shared among all the threads
627 running on the device. An arbitrary buffer created with the
628 ``PIPE_BIND_GLOBAL`` flag can be mapped into it using the
629 ``set_global_binding`` method.
630
631 * ``LOCAL`` represents a memory space shared among all the threads
632 running in the same working group. The initial contents of this
633 resource are undefined.
634
635 * ``PRIVATE`` represents a memory space local to a single thread.
636 The initial contents of this resource are undefined.
637
638 * ``INPUT`` represents a read-only memory space that can be
639 initialized at ``launch_grid`` time.
640
641 These resources use a byte-based addressing scheme, and they can be
642 accessed from the compute program by means of the LOAD/STORE TGSI
643 opcodes. Additional resources to be accessed using the same opcodes
644 may be specified by the user with the ``set_compute_resources``
645 method.
646
647 In addition, normal texture sampling is allowed from the compute
648 program: ``bind_sampler_states`` may be used to set up texture
649 samplers for the compute stage and ``set_sampler_views`` may
650 be used to bind a number of sampler views to it.