68d1a35cc7396785fbe40e2747a3a85e67e94ff1
[mesa.git] / src / gallium / docs / source / screen.rst
1 .. _screen:
2
3 Screen
4 ======
5
6 A screen is an object representing the context-independent part of a device.
7
8 Flags and enumerations
9 ----------------------
10
11 XXX some of these don't belong in this section.
12
13
14 .. _pipe_cap:
15
16 PIPE_CAP_*
17 ^^^^^^^^^^
18
19 Capability queries return information about the features and limits of the
20 driver/GPU. For floating-point values, use :ref:`get_paramf`, and for boolean
21 or integer values, use :ref:`get_param`.
22
23 The integer capabilities:
24
25 * ``PIPE_CAP_NPOT_TEXTURES``: Whether :term:`NPOT` textures may have repeat modes,
26 normalized coordinates, and mipmaps.
27 * ``PIPE_CAP_TWO_SIDED_STENCIL``: Whether the stencil test can also affect back-facing
28 polygons.
29 * ``PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS``: How many dual-source blend RTs are support.
30 :ref:`Blend` for more information.
31 * ``PIPE_CAP_ANISOTROPIC_FILTER``: Whether textures can be filtered anisotropically.
32 * ``PIPE_CAP_POINT_SPRITE``: Whether point sprites are available.
33 * ``PIPE_CAP_MAX_RENDER_TARGETS``: The maximum number of render targets that may be
34 bound.
35 * ``PIPE_CAP_OCCLUSION_QUERY``: Whether occlusion queries are available.
36 * ``PIPE_CAP_QUERY_TIME_ELAPSED``: Whether PIPE_QUERY_TIME_ELAPSED queries are available.
37 * ``PIPE_CAP_TEXTURE_SHADOW_MAP``: indicates whether the fragment shader hardware
38 can do the depth texture / Z comparison operation in TEX instructions
39 for shadow testing.
40 * ``PIPE_CAP_TEXTURE_SWIZZLE``: Whether swizzling through sampler views is
41 supported.
42 * ``PIPE_CAP_MAX_TEXTURE_2D_LEVELS``: The maximum number of mipmap levels available
43 for a 2D texture.
44 * ``PIPE_CAP_MAX_TEXTURE_3D_LEVELS``: The maximum number of mipmap levels available
45 for a 3D texture.
46 * ``PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS``: The maximum number of mipmap levels available
47 for a cubemap.
48 * ``PIPE_CAP_TEXTURE_MIRROR_CLAMP``: Whether mirrored texture coordinates with clamp
49 are supported.
50 * ``PIPE_CAP_BLEND_EQUATION_SEPARATE``: Whether alpha blend equations may be different
51 from color blend equations, in :ref:`Blend` state.
52 * ``PIPE_CAP_SM3``: Whether the vertex shader and fragment shader support equivalent
53 opcodes to the Shader Model 3 specification. XXX oh god this is horrible
54 * ``PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS``: The maximum number of stream buffers.
55 * ``PIPE_CAP_PRIMITIVE_RESTART``: Whether primitive restart is supported.
56 * ``PIPE_CAP_MAX_COMBINED_SAMPLERS``: The total number of samplers accessible from
57 the vertex and fragment shader, inclusive.
58 * ``PIPE_CAP_INDEP_BLEND_ENABLE``: Whether per-rendertarget blend enabling and channel
59 masks are supported. If 0, then the first rendertarget's blend mask is
60 replicated across all MRTs.
61 * ``PIPE_CAP_INDEP_BLEND_FUNC``: Whether per-rendertarget blend functions are
62 available. If 0, then the first rendertarget's blend functions affect all
63 MRTs.
64 * ``PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS``: The maximum number of texture array
65 layers supported. If 0, the array textures are not supported at all and
66 the ARRAY texture targets are invalid.
67 * ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT``: Whether the TGSI property
68 FS_COORD_ORIGIN with value UPPER_LEFT is supported.
69 * ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT``: Whether the TGSI property
70 FS_COORD_ORIGIN with value LOWER_LEFT is supported.
71 * ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER``: Whether the TGSI
72 property FS_COORD_PIXEL_CENTER with value HALF_INTEGER is supported.
73 * ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER``: Whether the TGSI
74 property FS_COORD_PIXEL_CENTER with value INTEGER is supported.
75 * ``PIPE_CAP_DEPTH_CLIP_DISABLE``: Whether the driver is capable of disabling
76 depth clipping (through pipe_rasterizer_state)
77 * ``PIPE_CAP_SHADER_STENCIL_EXPORT``: Whether a stencil reference value can be
78 written from a fragment shader.
79 * ``PIPE_CAP_TGSI_INSTANCEID``: Whether TGSI_SEMANTIC_INSTANCEID is supported
80 in the vertex shader.
81 * ``PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR``: Whether the driver supports
82 per-instance vertex attribs.
83 * ``PIPE_CAP_FRAGMENT_COLOR_CLAMPED``: Whether fragment color clamping is
84 supported. That is, is the pipe_rasterizer_state::clamp_fragment_color
85 flag supported by the driver? If not, the state tracker will insert
86 clamping code into the fragment shaders when needed.
87
88 * ``PIPE_CAP_MIXED_COLORBUFFER_FORMATS``: Whether mixed colorbuffer formats are
89 supported, e.g. RGBA8 and RGBA32F as the first and second colorbuffer, resp.
90 * ``PIPE_CAP_VERTEX_COLOR_UNCLAMPED``: Whether the driver is capable of
91 outputting unclamped vertex colors from a vertex shader. If unsupported,
92 the vertex colors are always clamped. This is the default for DX9 hardware.
93 * ``PIPE_CAP_VERTEX_COLOR_CLAMPED``: Whether the driver is capable of
94 clamping vertex colors when they come out of a vertex shader, as specified
95 by the pipe_rasterizer_state::clamp_vertex_color flag. If unsupported,
96 the vertex colors are never clamped. This is the default for DX10 hardware.
97 If both clamped and unclamped CAPs are supported, the clamping can be
98 controlled through pipe_rasterizer_state. If the driver cannot do vertex
99 color clamping, the state tracker may insert clamping code into the vertex
100 shader.
101 * ``PIPE_CAP_GLSL_FEATURE_LEVEL``: Whether the driver supports features
102 equivalent to a specific GLSL version. E.g. for GLSL 1.3, report 130.
103 * ``PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION``: Whether quads adhere to
104 the flatshade_first setting in ``pipe_rasterizer_state``.
105 * ``PIPE_CAP_USER_VERTEX_BUFFERS``: Whether the driver supports user vertex
106 buffers. If not, the state tracker must upload all data which is not in hw
107 resources.
108 * ``PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY``: This CAP describes a hw
109 limitation. If true, pipe_vertex_buffer::buffer_offset must always be aligned
110 to 4. If false, there are no restrictions on the offset.
111 * ``PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY``: This CAP describes a hw
112 limitation. If true, pipe_vertex_buffer::stride must always be aligned to 4.
113 If false, there are no restrictions on the stride.
114 * ``PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY``: This CAP describes
115 a hw limitation. If true, pipe_vertex_element::src_offset must always be
116 aligned to 4. If false, there are no restrictions on src_offset.
117 * ``PIPE_CAP_COMPUTE``: Whether the implementation supports the
118 compute entry points defined in pipe_context and pipe_screen.
119 * ``PIPE_CAP_USER_INDEX_BUFFERS``: Whether user index buffers are supported.
120 If not, the state tracker must upload all indices which are not in hw
121 resources.
122 * ``PIPE_CAP_USER_CONSTANT_BUFFERS``: Whether user constant buffers are
123 supported. If not, the state tracker must upload constants which are not in hw
124 resources.
125 * ``PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT``: Describes the required
126 alignment of pipe_constant_buffer::buffer_offset.
127 * ``PIPE_CAP_START_INSTANCE``: Whether the driver supports
128 pipe_draw_info::start_instance.
129 * ``PIPE_CAP_QUERY_TIMESTAMP``: Whether PIPE_QUERY_TIMESTAMP and
130 the pipe_screen::get_timestamp hook are implemented.
131 * ``PIPE_CAP_TEXTURE_MULTISAMPLE``: Whether all MSAA resources supported
132 for rendering are also supported for texturing.
133 * ``PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT``: The minimum alignment that should be
134 expected for a pointer returned by transfer_map if the resource is
135 PIPE_BUFFER. In other words, the pointer returned by transfer_map is
136 always aligned to this value.
137 * ``PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT``: Describes the required
138 alignment for pipe_sampler_view::u.buf.first_element, in bytes.
139 If a driver does not support first/last_element, it should return 0.
140
141
142 .. _pipe_capf:
143
144 PIPE_CAPF_*
145 ^^^^^^^^^^^^^^^^
146
147 The floating-point capabilities are:
148
149 * ``PIPE_CAPF_MAX_LINE_WIDTH``: The maximum width of a regular line.
150 * ``PIPE_CAPF_MAX_LINE_WIDTH_AA``: The maximum width of a smoothed line.
151 * ``PIPE_CAPF_MAX_POINT_WIDTH``: The maximum width and height of a point.
152 * ``PIPE_CAPF_MAX_POINT_WIDTH_AA``: The maximum width and height of a smoothed point.
153 * ``PIPE_CAPF_MAX_TEXTURE_ANISOTROPY``: The maximum level of anisotropy that can be
154 applied to anisotropically filtered textures.
155 * ``PIPE_CAPF_MAX_TEXTURE_LOD_BIAS``: The maximum :term:`LOD` bias that may be applied
156 to filtered textures.
157 * ``PIPE_CAPF_GUARD_BAND_LEFT``,
158 ``PIPE_CAPF_GUARD_BAND_TOP``,
159 ``PIPE_CAPF_GUARD_BAND_RIGHT``,
160 ``PIPE_CAPF_GUARD_BAND_BOTTOM``: TODO
161
162
163 .. _pipe_shader_cap:
164
165 PIPE_SHADER_CAP_*
166 ^^^^^^^^^^^^^^^^^
167
168 These are per-shader-stage capabitity queries. Different shader stages may
169 support different features.
170
171 * ``PIPE_SHADER_CAP_MAX_INSTRUCTIONS``: The maximum number of instructions.
172 * ``PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS``: The maximum number of arithmetic instructions.
173 * ``PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS``: The maximum number of texture instructions.
174 * ``PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS``: The maximum number of texture indirections.
175 * ``PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH``: The maximum nested control flow depth.
176 * ``PIPE_SHADER_CAP_MAX_INPUTS``: The maximum number of input registers.
177 * ``PIPE_SHADER_CAP_MAX_CONSTS``: The maximum number of constants.
178 * ``PIPE_SHADER_CAP_MAX_CONST_BUFFERS``: Maximum number of constant buffers that can be bound
179 to any shader stage using ``set_constant_buffer``. If 0 or 1, the pipe will
180 only permit binding one constant buffer per shader, and the shaders will
181 not permit two-dimensional access to constants.
182
183 If a value greater than 0 is returned, the driver can have multiple
184 constant buffers bound to shader stages. The CONST register file can
185 be accessed with two-dimensional indices, like in the example below.
186
187 DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0
188 DCL CONST[3][0] # declare first vector of constbuf 3
189 MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0
190
191 For backwards compatibility, one-dimensional access to CONST register
192 file is still supported. In that case, the constbuf index is assumed
193 to be 0.
194
195 * ``PIPE_SHADER_CAP_MAX_TEMPS``: The maximum number of temporary registers.
196 * ``PIPE_SHADER_CAP_MAX_ADDRS``: The maximum number of address registers.
197 * ``PIPE_SHADER_CAP_MAX_PREDS``: The maximum number of predicate registers.
198 * ``PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED``: Whether the continue opcode is supported.
199 * ``PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR``: Whether indirect addressing
200 of the input file is supported.
201 * ``PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR``: Whether indirect addressing
202 of the output file is supported.
203 * ``PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR``: Whether indirect addressing
204 of the temporary file is supported.
205 * ``PIPE_SHADER_CAP_INDIRECT_CONST_ADDR``: Whether indirect addressing
206 of the constant file is supported.
207 * ``PIPE_SHADER_CAP_SUBROUTINES``: Whether subroutines are supported, i.e.
208 BGNSUB, ENDSUB, CAL, and RET, including RET in the main block.
209 * ``PIPE_SHADER_CAP_INTEGERS``: Whether integer opcodes are supported.
210 If unsupported, only float opcodes are supported.
211 * ``PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS``: THe maximum number of texture
212 samplers.
213 * ``PIPE_SHADER_CAP_PREFERRED_IR``: Preferred representation of the
214 program. It should be one of the ``pipe_shader_ir`` enum values.
215
216
217 .. _pipe_compute_cap:
218
219 PIPE_COMPUTE_CAP_*
220 ^^^^^^^^^^^^^^^^^^
221
222 Compute-specific capabilities. They can be queried using
223 pipe_screen::get_compute_param.
224
225 * ``PIPE_COMPUTE_CAP_IR_TARGET``: A description of the target as a target
226 triple specification of the form ``processor-manufacturer-os`` that will
227 be passed on to the compiler. This CAP is only relevant for drivers
228 that specify PIPE_SHADER_IR_LLVM for their preferred IR.
229 Value type: null-terminated string.
230 * ``PIPE_COMPUTE_CAP_GRID_DIMENSION``: Number of supported dimensions
231 for grid and block coordinates. Value type: ``uint64_t``.
232 * ``PIPE_COMPUTE_CAP_MAX_GRID_SIZE``: Maximum grid size in block
233 units. Value type: ``uint64_t []``.
234 * ``PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE``: Maximum block size in thread
235 units. Value type: ``uint64_t []``.
236 * ``PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK``: Maximum number of threads that
237 a single block can contain. Value type: ``uint64_t``.
238 This may be less than the product of the components of MAX_BLOCK_SIZE and is
239 usually limited by the number of threads that can be resident simultaneously
240 on a compute unit.
241 * ``PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE``: Maximum size of the GLOBAL
242 resource. Value type: ``uint64_t``.
243 * ``PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE``: Maximum size of the LOCAL
244 resource. Value type: ``uint64_t``.
245 * ``PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE``: Maximum size of the PRIVATE
246 resource. Value type: ``uint64_t``.
247 * ``PIPE_COMPUTE_CAP_MAX_INPUT_SIZE``: Maximum size of the INPUT
248 resource. Value type: ``uint64_t``.
249 * ``PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE``: Maximum size of a memory object
250 allocation in bytes. Value type: ``uint64_t``.
251
252 .. _pipe_bind:
253
254 PIPE_BIND_*
255 ^^^^^^^^^^^
256
257 These flags indicate how a resource will be used and are specified at resource
258 creation time. Resources may be used in different roles
259 during their lifecycle. Bind flags are cumulative and may be combined to create
260 a resource which can be used for multiple things.
261 Depending on the pipe driver's memory management and these bind flags,
262 resources might be created and handled quite differently.
263
264 * ``PIPE_BIND_RENDER_TARGET``: A color buffer or pixel buffer which will be
265 rendered to. Any surface/resource attached to pipe_framebuffer_state::cbufs
266 must have this flag set.
267 * ``PIPE_BIND_DEPTH_STENCIL``: A depth (Z) buffer and/or stencil buffer. Any
268 depth/stencil surface/resource attached to pipe_framebuffer_state::zsbuf must
269 have this flag set.
270 * ``PIPE_BIND_BLENDABLE``: Used in conjunction with PIPE_BIND_RENDER_TARGET to
271 query whether a device supports blending for a given format.
272 If this flag is set, surface creation may fail if blending is not supported
273 for the specified format. If it is not set, a driver may choose to ignore
274 blending on surfaces with formats that would require emulation.
275 * ``PIPE_BIND_DISPLAY_TARGET``: A surface that can be presented to screen. Arguments to
276 pipe_screen::flush_front_buffer must have this flag set.
277 * ``PIPE_BIND_SAMPLER_VIEW``: A texture that may be sampled from in a fragment
278 or vertex shader.
279 * ``PIPE_BIND_VERTEX_BUFFER``: A vertex buffer.
280 * ``PIPE_BIND_INDEX_BUFFER``: An vertex index/element buffer.
281 * ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants.
282 * ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to.
283 * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from.
284 * ``PIPE_BIND_STREAM_OUTPUT``: A stream output buffer.
285 * ``PIPE_BIND_CUSTOM``:
286 * ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer.
287 * ``PIPE_BIND_SHARED``: A sharable buffer that can be given to another
288 process.
289 * ``PIPE_BIND_GLOBAL``: A buffer that can be mapped into the global
290 address space of a compute program.
291 * ``PIPE_BIND_SHADER_RESOURCE``: A buffer or texture that can be
292 bound to the graphics pipeline as a shader resource.
293 * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be
294 bound to the compute program as a shader resource.
295
296 .. _pipe_usage:
297
298 PIPE_USAGE_*
299 ^^^^^^^^^^^^
300
301 The PIPE_USAGE enums are hints about the expected usage pattern of a resource.
302
303 * ``PIPE_USAGE_DEFAULT``: Expect many uploads to the resource, intermixed with draws.
304 * ``PIPE_USAGE_DYNAMIC``: Expect many uploads to the resource, intermixed with draws.
305 * ``PIPE_USAGE_STATIC``: Same as immutable (?)
306 * ``PIPE_USAGE_IMMUTABLE``: Resource will not be changed after first upload.
307 * ``PIPE_USAGE_STREAM``: Upload will be followed by draw, followed by upload, ...
308
309
310 Methods
311 -------
312
313 XXX to-do
314
315 get_name
316 ^^^^^^^^
317
318 Returns an identifying name for the screen.
319
320 get_vendor
321 ^^^^^^^^^^
322
323 Returns the screen vendor.
324
325 .. _get_param:
326
327 get_param
328 ^^^^^^^^^
329
330 Get an integer/boolean screen parameter.
331
332 **param** is one of the :ref:`PIPE_CAP` names.
333
334 .. _get_paramf:
335
336 get_paramf
337 ^^^^^^^^^^
338
339 Get a floating-point screen parameter.
340
341 **param** is one of the :ref:`PIPE_CAP` names.
342
343 context_create
344 ^^^^^^^^^^^^^^
345
346 Create a pipe_context.
347
348 **priv** is private data of the caller, which may be put to various
349 unspecified uses, typically to do with implementing swapbuffers
350 and/or front-buffer rendering.
351
352 is_format_supported
353 ^^^^^^^^^^^^^^^^^^^
354
355 Determine if a resource in the given format can be used in a specific manner.
356
357 **format** the resource format
358
359 **target** one of the PIPE_TEXTURE_x flags
360
361 **sample_count** the number of samples. 0 and 1 mean no multisampling,
362 the maximum allowed legal value is 32.
363
364 **bindings** is a bitmask of :ref:`PIPE_BIND` flags.
365
366 **geom_flags** is a bitmask of PIPE_TEXTURE_GEOM_x flags.
367
368 Returns TRUE if all usages can be satisfied.
369
370
371 can_create_resource
372 ^^^^^^^^^^^^^^^^^^^
373
374 Check if a resource can actually be created (but don't actually allocate any
375 memory). This is used to implement OpenGL's proxy textures. Typically, a
376 driver will simply check if the total size of the given resource is less than
377 some limit.
378
379
380 .. _resource_create:
381
382 resource_create
383 ^^^^^^^^^^^^^^^
384
385 Create a new resource from a template.
386 The following fields of the pipe_resource must be specified in the template:
387
388 **target** one of the pipe_texture_target enums.
389 Note that PIPE_BUFFER and PIPE_TEXTURE_X are not really fundamentally different.
390 Modern APIs allow using buffers as shader resources.
391
392 **format** one of the pipe_format enums.
393
394 **width0** the width of the base mip level of the texture or size of the buffer.
395
396 **height0** the height of the base mip level of the texture
397 (1 for 1D or 1D array textures).
398
399 **depth0** the depth of the base mip level of the texture
400 (1 for everything else).
401
402 **array_size** the array size for 1D and 2D array textures.
403 For cube maps this must be 6, for other textures 1.
404
405 **last_level** the last mip map level present.
406
407 **nr_samples** the nr of msaa samples. 0 (or 1) specifies a resource
408 which isn't multisampled.
409
410 **usage** one of the PIPE_USAGE flags.
411
412 **bind** bitmask of the PIPE_BIND flags.
413
414 **flags** bitmask of PIPE_RESOURCE_FLAG flags.
415
416
417
418 resource_destroy
419 ^^^^^^^^^^^^^^^^
420
421 Destroy a resource. A resource is destroyed if it has no more references.
422
423
424
425 get_timestamp
426 ^^^^^^^^^^^^^
427
428 Query a timestamp in nanoseconds. The returned value should match
429 PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't
430 wait for rendering to complete (which cannot be achieved with queries).