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