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