Corbin Simpson | e7d05f1 | 2010-06-16 16:52:52 -0700 | [diff] [blame] | 1 | .. _context: |
| 2 | |
Corbin Simpson | 8283e20 | 2009-12-20 15:28:00 -0800 | [diff] [blame] | 3 | Context |
| 4 | ======= |
| 5 | |
| 6 | The context object represents the purest, most directly accessible, abilities |
| 7 | of the device's 3D rendering pipeline. |
| 8 | |
| 9 | Methods |
| 10 | ------- |
| 11 | |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 12 | CSO State |
| 13 | ^^^^^^^^^ |
| 14 | |
| 15 | All CSO state is created, bound, and destroyed, with triplets of methods that |
| 16 | all follow a specific naming scheme. For example, ``create_blend_state``, |
| 17 | ``bind_blend_state``, and ``destroy_blend_state``. |
| 18 | |
| 19 | CSO objects handled by the context object: |
| 20 | |
| 21 | * :ref:`Blend`: ``*_blend_state`` |
| 22 | * :ref:`Sampler`: These are special; they can be bound to either vertex or |
| 23 | fragment samplers, and they are bound in groups. |
| 24 | ``bind_fragment_sampler_states``, ``bind_vertex_sampler_states`` |
| 25 | * :ref:`Rasterizer`: ``*_rasterizer_state`` |
| 26 | * :ref:`Depth, Stencil, & Alpha`: ``*_depth_stencil_alpha_state`` |
| 27 | * :ref:`Shader`: These have two sets of methods. ``*_fs_state`` is for |
| 28 | fragment shaders, and ``*_vs_state`` is for vertex shaders. |
Roland Scheidegger | 8397c80 | 2010-03-01 18:42:47 +0100 | [diff] [blame] | 29 | * :ref:`Vertex Elements`: ``*_vertex_elements_state`` |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 30 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 31 | |
| 32 | Resource Binding State |
| 33 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 34 | |
| 35 | This state describes how resources in various flavours (textures, |
| 36 | buffers, surfaces) are bound to the driver. |
| 37 | |
| 38 | |
Roland Scheidegger | bf575b6 | 2010-01-15 18:25:14 +0100 | [diff] [blame] | 39 | * ``set_constant_buffer`` sets a constant buffer to be used for a given shader |
| 40 | type. index is used to indicate which buffer to set (some apis may allow |
| 41 | multiple ones to be set, and binding a specific one later, though drivers |
| 42 | are mostly restricted to the first one right now). |
| 43 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 44 | * ``set_framebuffer_state`` |
Michal Krol | e81caad | 2010-02-25 15:33:15 +0100 | [diff] [blame] | 45 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 46 | * ``set_vertex_buffers`` |
| 47 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 48 | * ``set_index_buffer`` |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 49 | |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 50 | Non-CSO State |
| 51 | ^^^^^^^^^^^^^ |
| 52 | |
| 53 | These pieces of state are too small, variable, and/or trivial to have CSO |
| 54 | objects. They all follow simple, one-method binding calls, e.g. |
Roland Scheidegger | 98f8c4d0 | 2010-02-09 21:48:43 +0100 | [diff] [blame] | 55 | ``set_blend_color``. |
Corbin Simpson | 8e1768c | 2010-03-19 00:07:55 -0700 | [diff] [blame] | 56 | |
Roland Scheidegger | 98f8c4d0 | 2010-02-09 21:48:43 +0100 | [diff] [blame] | 57 | * ``set_stencil_ref`` sets the stencil front and back reference values |
| 58 | which are used as comparison values in stencil test. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 59 | * ``set_blend_color`` |
Roland Scheidegger | aac2cccc | 2010-04-26 19:50:57 +0200 | [diff] [blame] | 60 | * ``set_sample_mask`` |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 61 | * ``set_clip_state`` |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 62 | * ``set_polygon_stipple`` |
Corbin Simpson | 8cf1af4 | 2010-01-25 01:12:30 -0800 | [diff] [blame] | 63 | * ``set_scissor_state`` sets the bounds for the scissor test, which culls |
| 64 | pixels before blending to render targets. If the :ref:`Rasterizer` does |
| 65 | not have the scissor test enabled, then the scissor bounds never need to |
Keith Whitwell | bc3cff2 | 2010-08-20 11:38:33 +0100 | [diff] [blame] | 66 | be set since they will not be used. Note that scissor xmin and ymin are |
| 67 | inclusive, but xmax and ymax are exclusive. The inclusive ranges in x |
| 68 | and y would be [xmin..xmax-1] and [ymin..ymax-1]. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 69 | * ``set_viewport_state`` |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 70 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 71 | |
Michal Krol | e4b8a30 | 2010-03-16 10:58:33 +0100 | [diff] [blame] | 72 | Sampler Views |
| 73 | ^^^^^^^^^^^^^ |
| 74 | |
| 75 | These are the means to bind textures to shader stages. To create one, specify |
| 76 | its format, swizzle and LOD range in sampler view template. |
| 77 | |
| 78 | If texture format is different than template format, it is said the texture |
| 79 | is being cast to another format. Casting can be done only between compatible |
| 80 | formats, that is formats that have matching component order and sizes. |
| 81 | |
| 82 | Swizzle fields specify they way in which fetched texel components are placed |
Michal Krol | 980da4a | 2010-03-19 09:08:33 +0100 | [diff] [blame] | 83 | in the result register. For example, ``swizzle_r`` specifies what is going to be |
| 84 | placed in first component of result register. |
Michal Krol | e4b8a30 | 2010-03-16 10:58:33 +0100 | [diff] [blame] | 85 | |
Michal Krol | 980da4a | 2010-03-19 09:08:33 +0100 | [diff] [blame] | 86 | The ``first_level`` and ``last_level`` fields of sampler view template specify |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 87 | the LOD range the texture is going to be constrained to. Note that these |
| 88 | values are in addition to the respective min_lod, max_lod values in the |
| 89 | pipe_sampler_state (that is if min_lod is 2.0, and first_level 3, the first mip |
| 90 | level used for sampling from the resource is effectively the fifth). |
| 91 | |
| 92 | The ``first_layer`` and ``last_layer`` fields specify the layer range the |
| 93 | texture is going to be constrained to. Similar to the LOD range, this is added |
| 94 | to the array index which is used for sampling. |
Michal Krol | e4b8a30 | 2010-03-16 10:58:33 +0100 | [diff] [blame] | 95 | |
| 96 | * ``set_fragment_sampler_views`` binds an array of sampler views to |
| 97 | fragment shader stage. Every binding point acquires a reference |
| 98 | to a respective sampler view and releases a reference to the previous |
| 99 | sampler view. |
| 100 | |
| 101 | * ``set_vertex_sampler_views`` binds an array of sampler views to vertex |
| 102 | shader stage. Every binding point acquires a reference to a respective |
| 103 | sampler view and releases a reference to the previous sampler view. |
| 104 | |
Michal Krol | 980da4a | 2010-03-19 09:08:33 +0100 | [diff] [blame] | 105 | * ``create_sampler_view`` creates a new sampler view. ``texture`` is associated |
Michal Krol | e4b8a30 | 2010-03-16 10:58:33 +0100 | [diff] [blame] | 106 | with the sampler view which results in sampler view holding a reference |
| 107 | to the texture. Format specified in template must be compatible |
| 108 | with texture format. |
| 109 | |
| 110 | * ``sampler_view_destroy`` destroys a sampler view and releases its reference |
| 111 | to associated texture. |
| 112 | |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 113 | Surfaces |
| 114 | ^^^^^^^^ |
| 115 | |
| 116 | These are the means to use resources as color render targets or depthstencil |
| 117 | attachments. To create one, specify the mip level, the range of layers, and |
| 118 | the bind flags (either PIPE_BIND_DEPTH_STENCIL or PIPE_BIND_RENDER_TARGET). |
| 119 | Note that layer values are in addition to what is indicated by the geometry |
| 120 | shader output variable XXX_FIXME (that is if first_layer is 3 and geometry |
| 121 | shader indicates index 2, the 5th layer of the resource will be used). These |
| 122 | first_layer and last_layer parameters will only be used for 1d array, 2d array, |
| 123 | cube, and 3d textures otherwise they are 0. |
| 124 | |
| 125 | * ``create_surface`` creates a new surface. |
| 126 | |
| 127 | * ``surface_destroy`` destroys a surface and releases its reference to the |
| 128 | associated resource. |
Michal Krol | e4b8a30 | 2010-03-16 10:58:33 +0100 | [diff] [blame] | 129 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 130 | Clearing |
| 131 | ^^^^^^^^ |
| 132 | |
Roland Scheidegger | 0cd70b5 | 2010-05-28 23:57:47 +0200 | [diff] [blame] | 133 | Clear is one of the most difficult concepts to nail down to a single |
| 134 | interface (due to both different requirements from APIs and also driver/hw |
| 135 | specific differences). |
| 136 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 137 | ``clear`` initializes some or all of the surfaces currently bound to |
| 138 | the framebuffer to particular RGBA, depth, or stencil values. |
Roland Scheidegger | 0cd70b5 | 2010-05-28 23:57:47 +0200 | [diff] [blame] | 139 | Currently, this does not take into account color or stencil write masks (as |
| 140 | used by GL), and always clears the whole surfaces (no scissoring as used by |
| 141 | GL clear or explicit rectangles like d3d9 uses). It can, however, also clear |
| 142 | only depth or stencil in a combined depth/stencil surface, if the driver |
| 143 | supports PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE. |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 144 | If a surface includes several layers then all layers will be cleared. |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 145 | |
Roland Scheidegger | a6e5c6c | 2010-06-03 16:33:25 +0200 | [diff] [blame] | 146 | ``clear_render_target`` clears a single color rendertarget with the specified |
| 147 | color value. While it is only possible to clear one surface at a time (which can |
Roland Scheidegger | 0cd70b5 | 2010-05-28 23:57:47 +0200 | [diff] [blame] | 148 | include several layers), this surface need not be bound to the framebuffer. |
| 149 | |
Corbin Simpson | 517a4fb | 2010-06-16 11:10:46 -0700 | [diff] [blame] | 150 | ``clear_depth_stencil`` clears a single depth, stencil or depth/stencil surface |
Roland Scheidegger | a6e5c6c | 2010-06-03 16:33:25 +0200 | [diff] [blame] | 151 | with the specified depth and stencil values (for combined depth/stencil buffers, |
Roland Scheidegger | 0cd70b5 | 2010-05-28 23:57:47 +0200 | [diff] [blame] | 152 | is is also possible to only clear one or the other part). While it is only |
| 153 | possible to clear one surface at a time (which can include several layers), |
| 154 | this surface need not be bound to the framebuffer. |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 155 | |
| 156 | |
| 157 | Drawing |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 158 | ^^^^^^^ |
| 159 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 160 | ``draw_vbo`` draws a specified primitive. The primitive mode and other |
| 161 | properties are described by ``pipe_draw_info``. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 162 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 163 | The ``mode``, ``start``, and ``count`` fields of ``pipe_draw_info`` specify the |
| 164 | the mode of the primitive and the vertices to be fetched, in the range between |
| 165 | ``start`` to ``start``+``count``-1, inclusive. |
Michal Krol | ffd2848 | 2010-01-14 18:55:52 +0100 | [diff] [blame] | 166 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 167 | Every instance with instanceID in the range between ``start_instance`` and |
| 168 | ``start_instance``+``instance_count``-1, inclusive, will be drawn. |
Michal Krol | ffd2848 | 2010-01-14 18:55:52 +0100 | [diff] [blame] | 169 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 170 | All vertex indices must fall inside the range given by ``min_index`` and |
| 171 | ``max_index``. In case non-indexed draw, ``min_index`` should be set to |
| 172 | ``start`` and ``max_index`` should be set to ``start``+``count``-1. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 173 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 174 | ``index_bias`` is a value added to every vertex index before fetching vertex |
| 175 | attributes. It does not affect ``min_index`` and ``max_index``. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 176 | |
Chia-I Wu | e7f69c4 | 2010-07-17 22:00:04 +0800 | [diff] [blame] | 177 | If there is an index buffer bound, and ``indexed`` field is true, all vertex |
| 178 | indices will be looked up in the index buffer. ``min_index``, ``max_index``, |
| 179 | and ``index_bias`` apply after index lookup. |
José Fonseca | 493a1bb | 2010-04-20 10:22:28 +0200 | [diff] [blame] | 180 | |
Brian Paul | adf35e8 | 2010-10-21 19:03:38 -0600 | [diff] [blame] | 181 | When drawing indexed primitives, the primitive restart index can be |
| 182 | used to draw disjoint primitive strips. For example, several separate |
| 183 | line strips can be drawn by designating a special index value as the |
| 184 | restart index. The ``primitive_restart`` flag enables/disables this |
| 185 | feature. The ``restart_index`` field specifies the restart index value. |
| 186 | |
| 187 | When primitive restart is in use, array indexes are compared to the |
| 188 | restart index before adding the index_bias offset. |
| 189 | |
Michal Krol | ffd2848 | 2010-01-14 18:55:52 +0100 | [diff] [blame] | 190 | If a given vertex element has ``instance_divisor`` set to 0, it is said |
| 191 | it contains per-vertex data and effective vertex attribute address needs |
| 192 | to be recalculated for every index. |
| 193 | |
| 194 | attribAddr = ``stride`` * index + ``src_offset`` |
| 195 | |
| 196 | If a given vertex element has ``instance_divisor`` set to non-zero, |
| 197 | it is said it contains per-instance data and effective vertex attribute |
| 198 | address needs to recalculated for every ``instance_divisor``-th instance. |
| 199 | |
| 200 | attribAddr = ``stride`` * instanceID / ``instance_divisor`` + ``src_offset`` |
| 201 | |
| 202 | In the above formulas, ``src_offset`` is taken from the given vertex element |
| 203 | and ``stride`` is taken from a vertex buffer associated with the given |
| 204 | vertex element. |
| 205 | |
| 206 | The calculated attribAddr is used as an offset into the vertex buffer to |
| 207 | fetch the attribute data. |
| 208 | |
| 209 | The value of ``instanceID`` can be read in a vertex shader through a system |
| 210 | value register declared with INSTANCEID semantic name. |
| 211 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 212 | |
| 213 | Queries |
| 214 | ^^^^^^^ |
| 215 | |
| 216 | Queries gather some statistic from the 3D pipeline over one or more |
| 217 | draws. Queries may be nested, though no state tracker currently |
| 218 | exercises this. |
| 219 | |
| 220 | Queries can be created with ``create_query`` and deleted with |
Brian Paul | 98f3f1c | 2010-01-29 12:36:26 -0700 | [diff] [blame] | 221 | ``destroy_query``. To start a query, use ``begin_query``, and when finished, |
| 222 | use ``end_query`` to end the query. |
| 223 | |
| 224 | ``get_query_result`` is used to retrieve the results of a query. If |
| 225 | the ``wait`` parameter is TRUE, then the ``get_query_result`` call |
| 226 | will block until the results of the query are ready (and TRUE will be |
| 227 | returned). Otherwise, if the ``wait`` parameter is FALSE, the call |
| 228 | will not block and the return value will be TRUE if the query has |
| 229 | completed or FALSE otherwise. |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 230 | |
Corbin Simpson | f1cf6b0 | 2010-05-17 12:00:59 -0700 | [diff] [blame] | 231 | The most common type of query is the occlusion query, |
| 232 | ``PIPE_QUERY_OCCLUSION_COUNTER``, which counts the number of fragments which |
| 233 | are written to the framebuffer without being culled by |
| 234 | :ref:`Depth, Stencil, & Alpha` testing or shader KILL instructions. |
Brian Paul | 34613c6 | 2011-01-18 16:34:22 -0700 | [diff] [blame] | 235 | The result is an unsigned 64-bit integer. |
Zack Rusin | 0657fc0 | 2011-01-26 00:01:51 -0500 | [diff] [blame] | 236 | In cases where a boolean result of an occlusion query is enough, |
| 237 | ``PIPE_QUERY_OCCLUSION_PREDICATE`` should be used. It is just like |
| 238 | ``PIPE_QUERY_OCCLUSION_COUNTER`` except that the result is a boolean |
| 239 | value of FALSE for cases where COUNTER would result in 0 and TRUE |
| 240 | for all other cases. |
Corbin Simpson | f1cf6b0 | 2010-05-17 12:00:59 -0700 | [diff] [blame] | 241 | |
| 242 | Another type of query, ``PIPE_QUERY_TIME_ELAPSED``, returns the amount of |
Mathias Fröhlich | 7f19b65 | 2010-05-19 08:46:51 -0600 | [diff] [blame] | 243 | time, in nanoseconds, the context takes to perform operations. |
Brian Paul | 34613c6 | 2011-01-18 16:34:22 -0700 | [diff] [blame] | 244 | The result is an unsigned 64-bit integer. |
Corbin Simpson | f1cf6b0 | 2010-05-17 12:00:59 -0700 | [diff] [blame] | 245 | |
| 246 | Gallium does not guarantee the availability of any query types; one must |
| 247 | always check the capabilities of the :ref:`Screen` first. |
Brian Paul | 6c1549a | 2010-01-21 11:52:36 -0700 | [diff] [blame] | 248 | |
| 249 | |
| 250 | Conditional Rendering |
| 251 | ^^^^^^^^^^^^^^^^^^^^^ |
| 252 | |
| 253 | A drawing command can be skipped depending on the outcome of a query |
| 254 | (typically an occlusion query). The ``render_condition`` function specifies |
| 255 | the query which should be checked prior to rendering anything. |
| 256 | |
| 257 | If ``render_condition`` is called with ``query`` = NULL, conditional |
| 258 | rendering is disabled and drawing takes place normally. |
| 259 | |
| 260 | If ``render_condition`` is called with a non-null ``query`` subsequent |
| 261 | drawing commands will be predicated on the outcome of the query. If |
| 262 | the query result is zero subsequent drawing commands will be skipped. |
| 263 | |
| 264 | If ``mode`` is PIPE_RENDER_COND_WAIT the driver will wait for the |
| 265 | query to complete before deciding whether to render. |
| 266 | |
| 267 | If ``mode`` is PIPE_RENDER_COND_NO_WAIT and the query has not yet |
| 268 | completed, the drawing command will be executed normally. If the query |
| 269 | has completed, drawing will be predicated on the outcome of the query. |
| 270 | |
| 271 | If ``mode`` is PIPE_RENDER_COND_BY_REGION_WAIT or |
| 272 | PIPE_RENDER_COND_BY_REGION_NO_WAIT rendering will be predicated as above |
| 273 | for the non-REGION modes but in the case that an occulusion query returns |
| 274 | a non-zero result, regions which were occluded may be ommitted by subsequent |
| 275 | drawing commands. This can result in better performance with some GPUs. |
| 276 | Normally, if the occlusion query returned a non-zero result subsequent |
| 277 | drawing happens normally so fragments may be generated, shaded and |
| 278 | processed even where they're known to be obscured. |
| 279 | |
| 280 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 281 | Flushing |
| 282 | ^^^^^^^^ |
| 283 | |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 284 | ``flush`` |
| 285 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 286 | |
| 287 | Resource Busy Queries |
| 288 | ^^^^^^^^^^^^^^^^^^^^^ |
| 289 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 290 | ``is_resource_referenced`` |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 291 | |
| 292 | |
| 293 | |
| 294 | Blitting |
| 295 | ^^^^^^^^ |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 296 | |
Roland Scheidegger | 379db6a | 2010-05-17 21:02:24 +0200 | [diff] [blame] | 297 | These methods emulate classic blitter controls. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 298 | |
Roland Scheidegger | aac2cccc | 2010-04-26 19:50:57 +0200 | [diff] [blame] | 299 | These methods operate directly on ``pipe_resource`` objects, and stand |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 300 | apart from any 3D state in the context. Blitting functionality may be |
| 301 | moved to a separate abstraction at some point in the future. |
| 302 | |
Roland Scheidegger | 4c70014 | 2010-12-02 04:33:43 +0100 | [diff] [blame] | 303 | ``resource_copy_region`` blits a region of a resource to a region of another |
| 304 | resource, provided that both resources have the same format, or compatible |
| 305 | formats, i.e., formats for which copying the bytes from the source resource |
| 306 | unmodified to the destination resource will achieve the same effect of a |
| 307 | textured quad blitter.. The source and destination may be the same resource, |
| 308 | but overlapping blits are not permitted. |
Roland Scheidegger | aac2cccc | 2010-04-26 19:50:57 +0200 | [diff] [blame] | 309 | |
| 310 | ``resource_resolve`` resolves a multisampled resource into a non-multisampled |
| 311 | one. Formats and dimensions must match. This function must be present if a driver |
| 312 | supports multisampling. |
Corbin Simpson | a524aab | 2009-12-20 19:41:50 -0800 | [diff] [blame] | 313 | |
Keith Whitwell | f3347fe | 2009-12-21 23:44:32 +0000 | [diff] [blame] | 314 | The interfaces to these calls are likely to change to make it easier |
| 315 | for a driver to batch multiple blits with the same source and |
| 316 | destination. |
| 317 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 318 | |
Zack Rusin | 2c22b8e | 2010-06-01 12:47:23 -0400 | [diff] [blame] | 319 | Stream Output |
| 320 | ^^^^^^^^^^^^^ |
| 321 | |
| 322 | Stream output, also known as transform feedback allows writing the results of the |
| 323 | vertex pipeline (after the geometry shader or vertex shader if no geometry shader |
| 324 | is present) to be written to a buffer created with a ``PIPE_BIND_STREAM_OUTPUT`` |
| 325 | flag. |
| 326 | |
| 327 | First a stream output state needs to be created with the |
| 328 | ``create_stream_output_state`` call. It specific the details of what's being written, |
| 329 | to which buffer and with what kind of a writemask. |
| 330 | |
| 331 | Then target buffers needs to be set with the call to ``set_stream_output_buffers`` |
| 332 | which sets the buffers and the offsets from the start of those buffer to where |
| 333 | the data will be written to. |
| 334 | |
| 335 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 336 | Transfers |
| 337 | ^^^^^^^^^ |
| 338 | |
| 339 | These methods are used to get data to/from a resource. |
| 340 | |
| 341 | ``get_transfer`` creates a transfer object. |
| 342 | |
| 343 | ``transfer_destroy`` destroys the transfer object. May cause |
| 344 | data to be written to the resource at this point. |
| 345 | |
| 346 | ``transfer_map`` creates a memory mapping for the transfer object. |
| 347 | The returned map points to the start of the mapped range according to |
| 348 | the box region, not the beginning of the resource. |
| 349 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 350 | ``transfer_unmap`` remove the memory mapping for the transfer object. |
| 351 | Any pointers into the map should be considered invalid and discarded. |
| 352 | |
| 353 | ``transfer_inline_write`` performs a simplified transfer for simple writes. |
| 354 | Basically get_transfer, transfer_map, data write, transfer_unmap, and |
| 355 | transfer_destroy all in one. |
| 356 | |
Brian Paul | c5fb051 | 2011-01-28 20:25:27 -0700 | [diff] [blame^] | 357 | |
| 358 | The box parameter to some of these functions defines a 1D, 2D or 3D |
| 359 | region of pixels. This is self-explanatory for 1D, 2D and 3D texture |
| 360 | targets. |
| 361 | |
| 362 | For PIPE_TEXTURE_1D_ARRAY, the box::y and box::height fields refer to the |
| 363 | array dimension of the texture. |
| 364 | |
| 365 | For PIPE_TEXTURE_2D_ARRAY, the box::z and box::depth fields refer to the |
| 366 | array dimension of the texture. |
| 367 | |
| 368 | For PIPE_TEXTURE_CUBE, the box:z and box::depth fields refer to the |
| 369 | faces of the cube map (z + depth <= 6). |
| 370 | |
| 371 | |
| 372 | |
Corbin Simpson | bb81f65 | 2010-05-17 12:58:29 -0700 | [diff] [blame] | 373 | .. _transfer_flush_region: |
| 374 | |
| 375 | transfer_flush_region |
| 376 | %%%%%%%%%%%%%%%%%%%%% |
| 377 | |
| 378 | If a transfer was created with ``FLUSH_EXPLICIT``, it will not automatically |
| 379 | be flushed on write or unmap. Flushes must be requested with |
| 380 | ``transfer_flush_region``. Flush ranges are relative to the mapped range, not |
| 381 | the beginning of the resource. |
| 382 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 383 | .. _pipe_transfer: |
| 384 | |
| 385 | PIPE_TRANSFER |
| 386 | ^^^^^^^^^^^^^ |
| 387 | |
| 388 | These flags control the behavior of a transfer object. |
| 389 | |
| 390 | * ``READ``: resource contents are read at transfer create time. |
| 391 | * ``WRITE``: resource contents will be written back at transfer destroy time. |
| 392 | * ``MAP_DIRECTLY``: a transfer should directly map the resource. May return |
| 393 | NULL if not supported. |
| 394 | * ``DISCARD``: The memory within the mapped region is discarded. |
| 395 | Cannot be used with ``READ``. |
| 396 | * ``DONTBLOCK``: Fail if the resource cannot be mapped immediately. |
| 397 | * ``UNSYNCHRONIZED``: Do not synchronize pending operations on the resource |
| 398 | when mapping. The interaction of any writes to the map and any |
| 399 | operations pending on the resource are undefined. Cannot be used with |
| 400 | ``READ``. |
| 401 | * ``FLUSH_EXPLICIT``: Written ranges will be notified later with |
Corbin Simpson | bb81f65 | 2010-05-17 12:58:29 -0700 | [diff] [blame] | 402 | :ref:`transfer_flush_region`. Cannot be used with ``READ``. |