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