broadcom/vc4: Implement GL_ARB_texture_barrier.
[mesa.git] / src / gallium / include / pipe / p_state.h
1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 /**
30 * @file
31 *
32 * Abstract graphics pipe state objects.
33 *
34 * Basic notes:
35 * 1. Want compact representations, so we use bitfields.
36 * 2. Put bitfields before other (GLfloat) fields.
37 */
38
39
40 #ifndef PIPE_STATE_H
41 #define PIPE_STATE_H
42
43 #include "p_compiler.h"
44 #include "p_defines.h"
45 #include "p_format.h"
46
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52
53 /**
54 * Implementation limits
55 */
56 #define PIPE_MAX_ATTRIBS 32
57 #define PIPE_MAX_CLIP_PLANES 8
58 #define PIPE_MAX_COLOR_BUFS 8
59 #define PIPE_MAX_CONSTANT_BUFFERS 32
60 #define PIPE_MAX_SAMPLERS 32
61 #define PIPE_MAX_SHADER_INPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */
62 #define PIPE_MAX_SHADER_OUTPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */
63 #define PIPE_MAX_SHADER_SAMPLER_VIEWS 32
64 #define PIPE_MAX_SHADER_BUFFERS 32
65 #define PIPE_MAX_SHADER_IMAGES 32
66 #define PIPE_MAX_TEXTURE_LEVELS 16
67 #define PIPE_MAX_SO_BUFFERS 4
68 #define PIPE_MAX_SO_OUTPUTS 64
69 #define PIPE_MAX_VIEWPORTS 16
70 #define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8
71 #define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2
72 #define PIPE_MAX_WINDOW_RECTANGLES 8
73
74
75 struct pipe_reference
76 {
77 int32_t count; /* atomic */
78 };
79
80
81
82 /**
83 * Primitive (point/line/tri) rasterization info
84 */
85 struct pipe_rasterizer_state
86 {
87 unsigned flatshade:1;
88 unsigned light_twoside:1;
89 unsigned clamp_vertex_color:1;
90 unsigned clamp_fragment_color:1;
91 unsigned front_ccw:1;
92 unsigned cull_face:2; /**< PIPE_FACE_x */
93 unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */
94 unsigned fill_back:2; /**< PIPE_POLYGON_MODE_x */
95 unsigned offset_point:1;
96 unsigned offset_line:1;
97 unsigned offset_tri:1;
98 unsigned scissor:1;
99 unsigned poly_smooth:1;
100 unsigned poly_stipple_enable:1;
101 unsigned point_smooth:1;
102 unsigned sprite_coord_mode:1; /**< PIPE_SPRITE_COORD_ */
103 unsigned point_quad_rasterization:1; /** points rasterized as quads or points */
104 unsigned point_tri_clip:1; /** large points clipped as tris or points */
105 unsigned point_size_per_vertex:1; /**< size computed in vertex shader */
106 unsigned multisample:1; /* XXX maybe more ms state in future */
107 unsigned force_persample_interp:1;
108 unsigned line_smooth:1;
109 unsigned line_stipple_enable:1;
110 unsigned line_last_pixel:1;
111
112 /**
113 * Use the first vertex of a primitive as the provoking vertex for
114 * flat shading.
115 */
116 unsigned flatshade_first:1;
117
118 unsigned half_pixel_center:1;
119 unsigned bottom_edge_rule:1;
120
121 /**
122 * When true, rasterization is disabled and no pixels are written.
123 * This only makes sense with the Stream Out functionality.
124 */
125 unsigned rasterizer_discard:1;
126
127 /**
128 * When false, depth clipping is disabled and the depth value will be
129 * clamped later at the per-pixel level before depth testing.
130 * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.
131 */
132 unsigned depth_clip:1;
133
134 /**
135 * When true clip space in the z axis goes from [0..1] (D3D). When false
136 * [-1, 1] (GL).
137 *
138 * NOTE: D3D will always use depth clamping.
139 */
140 unsigned clip_halfz:1;
141
142 /**
143 * When true do not scale offset_units and use same rules for unorm and
144 * float depth buffers (D3D9). When false use GL/D3D1X behaviour.
145 * This depends on PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED.
146 */
147 unsigned offset_units_unscaled:1;
148
149 /**
150 * Enable bits for clipping half-spaces.
151 * This applies to both user clip planes and shader clip distances.
152 * Note that if the bound shader exports any clip distances, these
153 * replace all user clip planes, and clip half-spaces enabled here
154 * but not written by the shader count as disabled.
155 */
156 unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES;
157
158 unsigned line_stipple_factor:8; /**< [1..256] actually */
159 unsigned line_stipple_pattern:16;
160
161 /**
162 * Replace the given TEXCOORD inputs with point coordinates, max. 8 inputs.
163 * If TEXCOORD (including PCOORD) are unsupported, replace GENERIC inputs
164 * instead. Max. 9 inputs: 8x GENERIC to emulate TEXCOORD, and 1x GENERIC
165 * to emulate PCOORD.
166 */
167 uint16_t sprite_coord_enable; /* 0-7: TEXCOORD/GENERIC, 8: PCOORD */
168
169 float line_width;
170 float point_size; /**< used when no per-vertex size */
171 float offset_units;
172 float offset_scale;
173 float offset_clamp;
174 };
175
176
177 struct pipe_poly_stipple
178 {
179 unsigned stipple[32];
180 };
181
182
183 struct pipe_viewport_state
184 {
185 float scale[3];
186 float translate[3];
187 };
188
189
190 struct pipe_scissor_state
191 {
192 unsigned minx:16;
193 unsigned miny:16;
194 unsigned maxx:16;
195 unsigned maxy:16;
196 };
197
198
199 struct pipe_clip_state
200 {
201 float ucp[PIPE_MAX_CLIP_PLANES][4];
202 };
203
204 /**
205 * A single output for vertex transform feedback.
206 */
207 struct pipe_stream_output
208 {
209 unsigned register_index:6; /**< 0 to 63 (OUT index) */
210 unsigned start_component:2; /** 0 to 3 */
211 unsigned num_components:3; /** 1 to 4 */
212 unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */
213 unsigned dst_offset:16; /**< offset into the buffer in dwords */
214 unsigned stream:2; /**< 0 to 3 */
215 };
216
217 /**
218 * Stream output for vertex transform feedback.
219 */
220 struct pipe_stream_output_info
221 {
222 unsigned num_outputs;
223 /** stride for an entire vertex for each buffer in dwords */
224 uint16_t stride[PIPE_MAX_SO_BUFFERS];
225
226 /**
227 * Array of stream outputs, in the order they are to be written in.
228 * Selected components are tightly packed into the output buffer.
229 */
230 struct pipe_stream_output output[PIPE_MAX_SO_OUTPUTS];
231 };
232
233 /**
234 * The 'type' parameter identifies whether the shader state contains TGSI
235 * tokens, etc. If the driver returns 'PIPE_SHADER_IR_TGSI' for the
236 * 'PIPE_SHADER_CAP_PREFERRED_IR' shader param, the ir will *always* be
237 * 'PIPE_SHADER_IR_TGSI' and the tokens ptr will be valid. If the driver
238 * requests a different 'pipe_shader_ir' type, then it must check the 'type'
239 * enum to see if it is getting TGSI tokens or its preferred IR.
240 *
241 * TODO pipe_compute_state should probably get similar treatment to handle
242 * multiple IR's in a cleaner way..
243 *
244 * NOTE: since it is expected that the consumer will want to perform
245 * additional passes on the nir_shader, the driver takes ownership of
246 * the nir_shader. If state trackers need to hang on to the IR (for
247 * example, variant management), it should use nir_shader_clone().
248 */
249 struct pipe_shader_state
250 {
251 enum pipe_shader_ir type;
252 /* TODO move tokens into union. */
253 const struct tgsi_token *tokens;
254 union {
255 void *llvm;
256 void *native;
257 void *nir;
258 } ir;
259 struct pipe_stream_output_info stream_output;
260 };
261
262 static inline void
263 pipe_shader_state_from_tgsi(struct pipe_shader_state *state,
264 const struct tgsi_token *tokens)
265 {
266 state->type = PIPE_SHADER_IR_TGSI;
267 state->tokens = tokens;
268 memset(&state->stream_output, 0, sizeof(state->stream_output));
269 }
270
271 struct pipe_depth_state
272 {
273 unsigned enabled:1; /**< depth test enabled? */
274 unsigned writemask:1; /**< allow depth buffer writes? */
275 unsigned func:3; /**< depth test func (PIPE_FUNC_x) */
276 unsigned bounds_test:1; /**< depth bounds test enabled? */
277 float bounds_min; /**< minimum depth bound */
278 float bounds_max; /**< maximum depth bound */
279 };
280
281
282 struct pipe_stencil_state
283 {
284 unsigned enabled:1; /**< stencil[0]: stencil enabled, stencil[1]: two-side enabled */
285 unsigned func:3; /**< PIPE_FUNC_x */
286 unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */
287 unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */
288 unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */
289 unsigned valuemask:8;
290 unsigned writemask:8;
291 };
292
293
294 struct pipe_alpha_state
295 {
296 unsigned enabled:1;
297 unsigned func:3; /**< PIPE_FUNC_x */
298 float ref_value; /**< reference value */
299 };
300
301
302 struct pipe_depth_stencil_alpha_state
303 {
304 struct pipe_depth_state depth;
305 struct pipe_stencil_state stencil[2]; /**< [0] = front, [1] = back */
306 struct pipe_alpha_state alpha;
307 };
308
309
310 struct pipe_rt_blend_state
311 {
312 unsigned blend_enable:1;
313
314 unsigned rgb_func:3; /**< PIPE_BLEND_x */
315 unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */
316 unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
317
318 unsigned alpha_func:3; /**< PIPE_BLEND_x */
319 unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */
320 unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
321
322 unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */
323 };
324
325
326 struct pipe_blend_state
327 {
328 unsigned independent_blend_enable:1;
329 unsigned logicop_enable:1;
330 unsigned logicop_func:4; /**< PIPE_LOGICOP_x */
331 unsigned dither:1;
332 unsigned alpha_to_coverage:1;
333 unsigned alpha_to_one:1;
334 struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
335 };
336
337
338 struct pipe_blend_color
339 {
340 float color[4];
341 };
342
343
344 struct pipe_stencil_ref
345 {
346 ubyte ref_value[2];
347 };
348
349
350 /**
351 * Note that pipe_surfaces are "texture views for rendering"
352 * and so in the case of ARB_framebuffer_no_attachment there
353 * is no pipe_surface state available such that we may
354 * extract the number of samples and layers.
355 */
356 struct pipe_framebuffer_state
357 {
358 uint16_t width, height;
359 uint16_t layers; /**< Number of layers in a no-attachment framebuffer */
360 ubyte samples; /**< Number of samples in a no-attachment framebuffer */
361
362 /** multiple color buffers for multiple render targets */
363 ubyte nr_cbufs;
364 struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];
365
366 struct pipe_surface *zsbuf; /**< Z/stencil buffer */
367 };
368
369
370 /**
371 * Texture sampler state.
372 */
373 struct pipe_sampler_state
374 {
375 unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */
376 unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */
377 unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */
378 unsigned min_img_filter:1; /**< PIPE_TEX_FILTER_x */
379 unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */
380 unsigned mag_img_filter:1; /**< PIPE_TEX_FILTER_x */
381 unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
382 unsigned compare_func:3; /**< PIPE_FUNC_x */
383 unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
384 unsigned max_anisotropy:5;
385 unsigned seamless_cube_map:1;
386 float lod_bias; /**< LOD/lambda bias */
387 float min_lod, max_lod; /**< LOD clamp range, after bias */
388 union pipe_color_union border_color;
389 };
390
391 union pipe_surface_desc {
392 struct {
393 unsigned level;
394 unsigned first_layer:16;
395 unsigned last_layer:16;
396 } tex;
397 struct {
398 unsigned first_element;
399 unsigned last_element;
400 } buf;
401 };
402
403 /**
404 * A view into a texture that can be bound to a color render target /
405 * depth stencil attachment point.
406 */
407 struct pipe_surface
408 {
409 struct pipe_reference reference;
410 enum pipe_format format:16;
411 unsigned writable:1; /**< writable shader resource */
412 struct pipe_resource *texture; /**< resource into which this is a view */
413 struct pipe_context *context; /**< context this surface belongs to */
414
415 /* XXX width/height should be removed */
416 uint16_t width; /**< logical width in pixels */
417 uint16_t height; /**< logical height in pixels */
418
419 union pipe_surface_desc u;
420 };
421
422
423 /**
424 * A view into a texture that can be bound to a shader stage.
425 */
426 struct pipe_sampler_view
427 {
428 struct pipe_reference reference;
429 enum pipe_format format:16; /**< typed PIPE_FORMAT_x */
430 enum pipe_texture_target target:4; /**< PIPE_TEXTURE_x */
431 unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */
432 unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */
433 unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */
434 unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */
435 struct pipe_resource *texture; /**< texture into which this is a view */
436 struct pipe_context *context; /**< context this view belongs to */
437 union {
438 struct {
439 unsigned first_layer:16; /**< first layer to use for array textures */
440 unsigned last_layer:16; /**< last layer to use for array textures */
441 unsigned first_level:8; /**< first mipmap level to use */
442 unsigned last_level:8; /**< last mipmap level to use */
443 } tex;
444 struct {
445 unsigned offset; /**< offset in bytes */
446 unsigned size; /**< size of the readable sub-range in bytes */
447 } buf;
448 } u;
449 };
450
451
452 /**
453 * A description of a buffer or texture image that can be bound to a shader
454 * stage.
455 */
456 struct pipe_image_view
457 {
458 struct pipe_resource *resource; /**< resource into which this is a view */
459 enum pipe_format format; /**< typed PIPE_FORMAT_x */
460 unsigned access; /**< PIPE_IMAGE_ACCESS_x */
461
462 union {
463 struct {
464 unsigned first_layer:16; /**< first layer to use for array textures */
465 unsigned last_layer:16; /**< last layer to use for array textures */
466 unsigned level:8; /**< mipmap level to use */
467 } tex;
468 struct {
469 unsigned offset; /**< offset in bytes */
470 unsigned size; /**< size of the accessible sub-range in bytes */
471 } buf;
472 } u;
473 };
474
475
476 /**
477 * Subregion of 1D/2D/3D image resource.
478 */
479 struct pipe_box
480 {
481 /* Fields only used by textures use int16_t instead of int.
482 * x and width are used by buffers, so they need the full 32-bit range.
483 */
484 int x;
485 int16_t y;
486 int16_t z;
487 int width;
488 int16_t height;
489 int16_t depth;
490 };
491
492
493 /**
494 * A memory object/resource such as a vertex buffer or texture.
495 */
496 struct pipe_resource
497 {
498 struct pipe_reference reference;
499 struct pipe_screen *screen; /**< screen that this texture belongs to */
500
501 unsigned width0; /**< Used by both buffers and textures. */
502 uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */
503 uint16_t depth0;
504 uint16_t array_size;
505
506 enum pipe_format format:16; /**< PIPE_FORMAT_x */
507 enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */
508 unsigned last_level:8; /**< Index of last mipmap level present/defined */
509 unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
510 unsigned usage:8; /**< PIPE_USAGE_x (not a bitmask) */
511
512 unsigned bind; /**< bitmask of PIPE_BIND_x */
513 unsigned flags; /**< bitmask of PIPE_RESOURCE_FLAG_x */
514
515 /**
516 * For planar images, ie. YUV EGLImage external, etc, pointer to the
517 * next plane.
518 */
519 struct pipe_resource *next;
520 };
521
522
523 /**
524 * Transfer object. For data transfer to/from a resource.
525 */
526 struct pipe_transfer
527 {
528 struct pipe_resource *resource; /**< resource to transfer to/from */
529 unsigned level; /**< texture mipmap level */
530 enum pipe_transfer_usage usage;
531 struct pipe_box box; /**< region of the resource to access */
532 unsigned stride; /**< row stride in bytes */
533 unsigned layer_stride; /**< image/layer stride in bytes */
534 };
535
536
537 /**
538 * A vertex buffer. Typically, all the vertex data/attributes for
539 * drawing something will be in one buffer. But it's also possible, for
540 * example, to put colors in one buffer and texcoords in another.
541 */
542 struct pipe_vertex_buffer
543 {
544 uint16_t stride; /**< stride to same attrib in next vertex, in bytes */
545 bool is_user_buffer;
546 unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
547
548 union {
549 struct pipe_resource *resource; /**< the actual buffer */
550 const void *user; /**< pointer to a user buffer */
551 } buffer;
552 };
553
554
555 /**
556 * A constant buffer. A subrange of an existing buffer can be set
557 * as a constant buffer.
558 */
559 struct pipe_constant_buffer
560 {
561 struct pipe_resource *buffer; /**< the actual buffer */
562 unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
563 unsigned buffer_size; /**< how much data can be read in shader */
564 const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */
565 };
566
567
568 /**
569 * An untyped shader buffer supporting loads, stores, and atomics.
570 */
571 struct pipe_shader_buffer {
572 struct pipe_resource *buffer; /**< the actual buffer */
573 unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
574 unsigned buffer_size; /**< how much data can be read in shader */
575 };
576
577
578 /**
579 * A stream output target. The structure specifies the range vertices can
580 * be written to.
581 *
582 * In addition to that, the structure should internally maintain the offset
583 * into the buffer, which should be incremented everytime something is written
584 * (appended) to it. The internal offset is buffer_offset + how many bytes
585 * have been written. The internal offset can be stored on the device
586 * and the CPU actually doesn't have to query it.
587 *
588 * Note that the buffer_size variable is actually specifying the available
589 * space in the buffer, not the size of the attached buffer.
590 * In other words in majority of cases buffer_size would simply be
591 * 'buffer->width0 - buffer_offset', so buffer_size refers to the size
592 * of the buffer left, after accounting for buffer offset, for stream output
593 * to write to.
594 *
595 * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have
596 * actually been written.
597 */
598 struct pipe_stream_output_target
599 {
600 struct pipe_reference reference;
601 struct pipe_resource *buffer; /**< the output buffer */
602 struct pipe_context *context; /**< context this SO target belongs to */
603
604 unsigned buffer_offset; /**< offset where data should be written, in bytes */
605 unsigned buffer_size; /**< how much data is allowed to be written */
606 };
607
608
609 /**
610 * Information to describe a vertex attribute (position, color, etc)
611 */
612 struct pipe_vertex_element
613 {
614 /** Offset of this attribute, in bytes, from the start of the vertex */
615 unsigned src_offset:16;
616
617 /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does
618 * this attribute live in?
619 */
620 unsigned vertex_buffer_index:5;
621
622 enum pipe_format src_format:11;
623
624 /** Instance data rate divisor. 0 means this is per-vertex data,
625 * n means per-instance data used for n consecutive instances (n > 0).
626 */
627 unsigned instance_divisor;
628 };
629
630
631 struct pipe_draw_indirect_info
632 {
633 unsigned offset; /**< must be 4 byte aligned */
634 unsigned stride; /**< must be 4 byte aligned */
635 unsigned draw_count; /**< number of indirect draws */
636 unsigned indirect_draw_count_offset; /**< must be 4 byte aligned */
637
638 /* Indirect draw parameters resource is laid out as follows:
639 *
640 * if using indexed drawing:
641 * struct {
642 * uint32_t count;
643 * uint32_t instance_count;
644 * uint32_t start;
645 * int32_t index_bias;
646 * uint32_t start_instance;
647 * };
648 * otherwise:
649 * struct {
650 * uint32_t count;
651 * uint32_t instance_count;
652 * uint32_t start;
653 * uint32_t start_instance;
654 * };
655 */
656 struct pipe_resource *buffer;
657
658 /* Indirect draw count resource: If not NULL, contains a 32-bit value which
659 * is to be used as the real draw_count.
660 */
661 struct pipe_resource *indirect_draw_count;
662 };
663
664
665 /**
666 * Information to describe a draw_vbo call.
667 */
668 struct pipe_draw_info
669 {
670 ubyte index_size; /**< if 0, the draw is not indexed. */
671 enum pipe_prim_type mode:8; /**< the mode of the primitive */
672 unsigned primitive_restart:1;
673 unsigned has_user_indices:1; /**< if true, use index.user_buffer */
674 ubyte vertices_per_patch; /**< the number of vertices per patch */
675
676 /**
677 * Direct draws: start is the index of the first vertex
678 * Non-indexed indirect draws: not used
679 * Indexed indirect draws: start is added to the indirect start.
680 */
681 unsigned start;
682 unsigned count; /**< number of vertices */
683
684 unsigned start_instance; /**< first instance id */
685 unsigned instance_count; /**< number of instances */
686
687 unsigned drawid; /**< id of this draw in a multidraw */
688
689 /**
690 * For indexed drawing, these fields apply after index lookup.
691 */
692 int index_bias; /**< a bias to be added to each index */
693 unsigned min_index; /**< the min index */
694 unsigned max_index; /**< the max index */
695
696 /**
697 * Primitive restart enable/index (only applies to indexed drawing)
698 */
699 unsigned restart_index;
700
701 /* Pointers must be at the end for an optimal structure layout on 64-bit. */
702
703 /**
704 * An index buffer. When an index buffer is bound, all indices to vertices
705 * will be looked up from the buffer.
706 *
707 * If has_user_indices, use index.user, else use index.resource.
708 */
709 union {
710 struct pipe_resource *resource; /**< real buffer */
711 const void *user; /**< pointer to a user buffer */
712 } index;
713
714 struct pipe_draw_indirect_info *indirect; /**< Indirect draw. */
715
716 /**
717 * Stream output target. If not NULL, it's used to provide the 'count'
718 * parameter based on the number vertices captured by the stream output
719 * stage. (or generally, based on the number of bytes captured)
720 *
721 * Only 'mode', 'start_instance', and 'instance_count' are taken into
722 * account, all the other variables from pipe_draw_info are ignored.
723 *
724 * 'start' is implicitly 0 and 'count' is set as discussed above.
725 * The draw command is non-indexed.
726 *
727 * Note that this only provides the count. The vertex buffers must
728 * be set via set_vertex_buffers manually.
729 */
730 struct pipe_stream_output_target *count_from_stream_output;
731 };
732
733
734 /**
735 * Information to describe a blit call.
736 */
737 struct pipe_blit_info
738 {
739 struct {
740 struct pipe_resource *resource;
741 unsigned level;
742 struct pipe_box box; /**< negative width, height only legal for src */
743 /* For pipe_surface-like format casting: */
744 enum pipe_format format; /**< must be supported for sampling (src)
745 or rendering (dst), ZS is always supported */
746 } dst, src;
747
748 unsigned mask; /**< bitmask of PIPE_MASK_R/G/B/A/Z/S */
749 unsigned filter; /**< PIPE_TEX_FILTER_* */
750
751 boolean scissor_enable;
752 struct pipe_scissor_state scissor;
753
754 /* Window rectangles can either be inclusive or exclusive. */
755 boolean window_rectangle_include;
756 unsigned num_window_rectangles;
757 struct pipe_scissor_state window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];
758
759 boolean render_condition_enable; /**< whether the blit should honor the
760 current render condition */
761 boolean alpha_blend; /* dst.rgb = src.rgb * src.a + dst.rgb * (1 - src.a) */
762 };
763
764 /**
765 * Information to describe a launch_grid call.
766 */
767 struct pipe_grid_info
768 {
769 /**
770 * For drivers that use PIPE_SHADER_IR_LLVM as their prefered IR, this value
771 * will be the index of the kernel in the opencl.kernels metadata list.
772 */
773 uint32_t pc;
774
775 /**
776 * Will be used to initialize the INPUT resource, and it should point to a
777 * buffer of at least pipe_compute_state::req_input_mem bytes.
778 */
779 void *input;
780
781 /**
782 * Grid number of dimensions, 1-3, e.g. the work_dim parameter passed to
783 * clEnqueueNDRangeKernel. Note block[] and grid[] must be padded with
784 * 1 for non-used dimensions.
785 */
786 uint work_dim;
787
788 /**
789 * Determine the layout of the working block (in thread units) to be used.
790 */
791 uint block[3];
792
793 /**
794 * Determine the layout of the grid (in block units) to be used.
795 */
796 uint grid[3];
797
798 /* Indirect compute parameters resource: If not NULL, block sizes are taken
799 * from this buffer instead, which is laid out as follows:
800 *
801 * struct {
802 * uint32_t num_blocks_x;
803 * uint32_t num_blocks_y;
804 * uint32_t num_blocks_z;
805 * };
806 */
807 struct pipe_resource *indirect;
808 unsigned indirect_offset; /**< must be 4 byte aligned */
809 };
810
811 /**
812 * Structure used as a header for serialized LLVM programs.
813 */
814 struct pipe_llvm_program_header
815 {
816 uint32_t num_bytes; /**< Number of bytes in the LLVM bytecode program. */
817 };
818
819 struct pipe_compute_state
820 {
821 enum pipe_shader_ir ir_type; /**< IR type contained in prog. */
822 const void *prog; /**< Compute program to be executed. */
823 unsigned req_local_mem; /**< Required size of the LOCAL resource. */
824 unsigned req_private_mem; /**< Required size of the PRIVATE resource. */
825 unsigned req_input_mem; /**< Required size of the INPUT resource. */
826 };
827
828 /**
829 * Structure that contains a callback for debug messages from the driver back
830 * to the state tracker.
831 */
832 struct pipe_debug_callback
833 {
834 /**
835 * When set to \c true, the callback may be called asynchronously from a
836 * driver-created thread.
837 */
838 bool async;
839
840 /**
841 * Callback for the driver to report debug/performance/etc information back
842 * to the state tracker.
843 *
844 * \param data user-supplied data pointer
845 * \param id message type identifier, if pointed value is 0, then a
846 * new id is assigned
847 * \param type PIPE_DEBUG_TYPE_*
848 * \param format printf-style format string
849 * \param args args for format string
850 */
851 void (*debug_message)(void *data,
852 unsigned *id,
853 enum pipe_debug_type type,
854 const char *fmt,
855 va_list args);
856 void *data;
857 };
858
859 /**
860 * Structure that contains a callback for device reset messages from the driver
861 * back to the state tracker.
862 *
863 * The callback must not be called from driver-created threads.
864 */
865 struct pipe_device_reset_callback
866 {
867 /**
868 * Callback for the driver to report when a device reset is detected.
869 *
870 * \param data user-supplied data pointer
871 * \param status PIPE_*_RESET
872 */
873 void (*reset)(void *data, enum pipe_reset_status status);
874
875 void *data;
876 };
877
878 /**
879 * Information about memory usage. All sizes are in kilobytes.
880 */
881 struct pipe_memory_info
882 {
883 unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
884 unsigned avail_device_memory; /**< free device memory at the moment */
885 unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
886 unsigned avail_staging_memory; /**< free staging memory at the moment */
887 unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
888 unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
889 };
890
891 /**
892 * Structure that contains information about external memory
893 */
894 struct pipe_memory_object
895 {
896 bool dedicated;
897 };
898
899 #ifdef __cplusplus
900 }
901 #endif
902
903 #endif