1848b8605Smrg/************************************************************************** 2b8e80941Smrg * 3848b8605Smrg * Copyright 2007 VMware, Inc. 4848b8605Smrg * All Rights Reserved. 5b8e80941Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the 8848b8605Smrg * "Software"), to deal in the Software without restriction, including 9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 12848b8605Smrg * the following conditions: 13b8e80941Smrg * 14848b8605Smrg * The above copyright notice and this permission notice (including the 15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 16848b8605Smrg * of the Software. 17b8e80941Smrg * 18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25b8e80941Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg 29848b8605Smrg/** 30848b8605Smrg * @file 31b8e80941Smrg * 32848b8605Smrg * Abstract graphics pipe state objects. 33848b8605Smrg * 34848b8605Smrg * Basic notes: 35848b8605Smrg * 1. Want compact representations, so we use bitfields. 36848b8605Smrg * 2. Put bitfields before other (GLfloat) fields. 37b8e80941Smrg * 3. enum bitfields need to be at least one bit extra in size so the most 38b8e80941Smrg * significant bit is zero. MSVC treats enums as signed so if the high 39b8e80941Smrg * bit is set, the value will be interpreted as a negative number. 40b8e80941Smrg * That causes trouble in various places. 41848b8605Smrg */ 42848b8605Smrg 43848b8605Smrg 44848b8605Smrg#ifndef PIPE_STATE_H 45848b8605Smrg#define PIPE_STATE_H 46848b8605Smrg 47848b8605Smrg#include "p_compiler.h" 48848b8605Smrg#include "p_defines.h" 49848b8605Smrg#include "p_format.h" 50848b8605Smrg 51848b8605Smrg 52848b8605Smrg#ifdef __cplusplus 53848b8605Smrgextern "C" { 54848b8605Smrg#endif 55848b8605Smrg 56848b8605Smrg 57848b8605Smrg/** 58848b8605Smrg * Implementation limits 59848b8605Smrg */ 60848b8605Smrg#define PIPE_MAX_ATTRIBS 32 61848b8605Smrg#define PIPE_MAX_CLIP_PLANES 8 62848b8605Smrg#define PIPE_MAX_COLOR_BUFS 8 63848b8605Smrg#define PIPE_MAX_CONSTANT_BUFFERS 32 64b8e80941Smrg#define PIPE_MAX_SAMPLERS 32 65b8e80941Smrg#define PIPE_MAX_SHADER_INPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */ 66b8e80941Smrg#define PIPE_MAX_SHADER_OUTPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */ 67b8e80941Smrg#define PIPE_MAX_SHADER_SAMPLER_VIEWS 128 68b8e80941Smrg#define PIPE_MAX_SHADER_BUFFERS 32 69b8e80941Smrg#define PIPE_MAX_SHADER_IMAGES 32 70848b8605Smrg#define PIPE_MAX_TEXTURE_LEVELS 16 71848b8605Smrg#define PIPE_MAX_SO_BUFFERS 4 72848b8605Smrg#define PIPE_MAX_SO_OUTPUTS 64 73848b8605Smrg#define PIPE_MAX_VIEWPORTS 16 74848b8605Smrg#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8 75848b8605Smrg#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2 76b8e80941Smrg#define PIPE_MAX_WINDOW_RECTANGLES 8 77b8e80941Smrg#define PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE 4 78848b8605Smrg 79b8e80941Smrg#define PIPE_MAX_HW_ATOMIC_BUFFERS 32 80b8e80941Smrg#define PIPE_MAX_VERTEX_STREAMS 4 81848b8605Smrg 82848b8605Smrgstruct pipe_reference 83848b8605Smrg{ 84848b8605Smrg int32_t count; /* atomic */ 85848b8605Smrg}; 86848b8605Smrg 87848b8605Smrg 88848b8605Smrg 89848b8605Smrg/** 90848b8605Smrg * Primitive (point/line/tri) rasterization info 91848b8605Smrg */ 92848b8605Smrgstruct pipe_rasterizer_state 93848b8605Smrg{ 94848b8605Smrg unsigned flatshade:1; 95848b8605Smrg unsigned light_twoside:1; 96848b8605Smrg unsigned clamp_vertex_color:1; 97848b8605Smrg unsigned clamp_fragment_color:1; 98848b8605Smrg unsigned front_ccw:1; 99848b8605Smrg unsigned cull_face:2; /**< PIPE_FACE_x */ 100848b8605Smrg unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */ 101848b8605Smrg unsigned fill_back:2; /**< PIPE_POLYGON_MODE_x */ 102848b8605Smrg unsigned offset_point:1; 103848b8605Smrg unsigned offset_line:1; 104848b8605Smrg unsigned offset_tri:1; 105848b8605Smrg unsigned scissor:1; 106848b8605Smrg unsigned poly_smooth:1; 107848b8605Smrg unsigned poly_stipple_enable:1; 108848b8605Smrg unsigned point_smooth:1; 109848b8605Smrg unsigned sprite_coord_mode:1; /**< PIPE_SPRITE_COORD_ */ 110848b8605Smrg unsigned point_quad_rasterization:1; /** points rasterized as quads or points */ 111848b8605Smrg unsigned point_tri_clip:1; /** large points clipped as tris or points */ 112848b8605Smrg unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ 113848b8605Smrg unsigned multisample:1; /* XXX maybe more ms state in future */ 114b8e80941Smrg unsigned force_persample_interp:1; 115848b8605Smrg unsigned line_smooth:1; 116848b8605Smrg unsigned line_stipple_enable:1; 117848b8605Smrg unsigned line_last_pixel:1; 118b8e80941Smrg unsigned conservative_raster_mode:2; /**< PIPE_CONSERVATIVE_RASTER_x */ 119848b8605Smrg 120848b8605Smrg /** 121848b8605Smrg * Use the first vertex of a primitive as the provoking vertex for 122848b8605Smrg * flat shading. 123848b8605Smrg */ 124848b8605Smrg unsigned flatshade_first:1; 125848b8605Smrg 126848b8605Smrg unsigned half_pixel_center:1; 127848b8605Smrg unsigned bottom_edge_rule:1; 128848b8605Smrg 129b8e80941Smrg /* 130b8e80941Smrg * Conservative rasterization subpixel precision bias in bits 131b8e80941Smrg */ 132b8e80941Smrg unsigned subpixel_precision_x:4; 133b8e80941Smrg unsigned subpixel_precision_y:4; 134b8e80941Smrg 135848b8605Smrg /** 136848b8605Smrg * When true, rasterization is disabled and no pixels are written. 137848b8605Smrg * This only makes sense with the Stream Out functionality. 138848b8605Smrg */ 139848b8605Smrg unsigned rasterizer_discard:1; 140848b8605Smrg 141b8e80941Smrg /** 142b8e80941Smrg * Exposed by PIPE_CAP_TILE_RASTER_ORDER. When true, 143b8e80941Smrg * tile_raster_order_increasing_* indicate the order that the rasterizer 144b8e80941Smrg * should render tiles, to meet the requirements of 145b8e80941Smrg * GL_MESA_tile_raster_order. 146b8e80941Smrg */ 147b8e80941Smrg unsigned tile_raster_order_fixed:1; 148b8e80941Smrg unsigned tile_raster_order_increasing_x:1; 149b8e80941Smrg unsigned tile_raster_order_increasing_y:1; 150b8e80941Smrg 151848b8605Smrg /** 152848b8605Smrg * When false, depth clipping is disabled and the depth value will be 153848b8605Smrg * clamped later at the per-pixel level before depth testing. 154848b8605Smrg * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE. 155b8e80941Smrg * 156b8e80941Smrg * If PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE is unsupported, depth_clip_near 157b8e80941Smrg * is equal to depth_clip_far. 158848b8605Smrg */ 159b8e80941Smrg unsigned depth_clip_near:1; 160b8e80941Smrg unsigned depth_clip_far:1; 161848b8605Smrg 162848b8605Smrg /** 163848b8605Smrg * When true clip space in the z axis goes from [0..1] (D3D). When false 164848b8605Smrg * [-1, 1] (GL). 165848b8605Smrg * 166848b8605Smrg * NOTE: D3D will always use depth clamping. 167848b8605Smrg */ 168848b8605Smrg unsigned clip_halfz:1; 169848b8605Smrg 170b8e80941Smrg /** 171b8e80941Smrg * When true do not scale offset_units and use same rules for unorm and 172b8e80941Smrg * float depth buffers (D3D9). When false use GL/D3D1X behaviour. 173b8e80941Smrg * This depends on PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED. 174b8e80941Smrg */ 175b8e80941Smrg unsigned offset_units_unscaled:1; 176b8e80941Smrg 177848b8605Smrg /** 178848b8605Smrg * Enable bits for clipping half-spaces. 179848b8605Smrg * This applies to both user clip planes and shader clip distances. 180848b8605Smrg * Note that if the bound shader exports any clip distances, these 181848b8605Smrg * replace all user clip planes, and clip half-spaces enabled here 182848b8605Smrg * but not written by the shader count as disabled. 183848b8605Smrg */ 184848b8605Smrg unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES; 185848b8605Smrg 186848b8605Smrg unsigned line_stipple_factor:8; /**< [1..256] actually */ 187848b8605Smrg unsigned line_stipple_pattern:16; 188848b8605Smrg 189b8e80941Smrg /** 190b8e80941Smrg * Replace the given TEXCOORD inputs with point coordinates, max. 8 inputs. 191b8e80941Smrg * If TEXCOORD (including PCOORD) are unsupported, replace GENERIC inputs 192b8e80941Smrg * instead. Max. 9 inputs: 8x GENERIC to emulate TEXCOORD, and 1x GENERIC 193b8e80941Smrg * to emulate PCOORD. 194b8e80941Smrg */ 195b8e80941Smrg uint16_t sprite_coord_enable; /* 0-7: TEXCOORD/GENERIC, 8: PCOORD */ 196848b8605Smrg 197848b8605Smrg float line_width; 198848b8605Smrg float point_size; /**< used when no per-vertex size */ 199848b8605Smrg float offset_units; 200848b8605Smrg float offset_scale; 201848b8605Smrg float offset_clamp; 202b8e80941Smrg float conservative_raster_dilate; 203848b8605Smrg}; 204848b8605Smrg 205848b8605Smrg 206848b8605Smrgstruct pipe_poly_stipple 207848b8605Smrg{ 208848b8605Smrg unsigned stipple[32]; 209848b8605Smrg}; 210848b8605Smrg 211848b8605Smrg 212848b8605Smrgstruct pipe_viewport_state 213848b8605Smrg{ 214b8e80941Smrg float scale[3]; 215b8e80941Smrg float translate[3]; 216848b8605Smrg}; 217848b8605Smrg 218848b8605Smrg 219848b8605Smrgstruct pipe_scissor_state 220848b8605Smrg{ 221848b8605Smrg unsigned minx:16; 222848b8605Smrg unsigned miny:16; 223848b8605Smrg unsigned maxx:16; 224848b8605Smrg unsigned maxy:16; 225848b8605Smrg}; 226848b8605Smrg 227848b8605Smrg 228848b8605Smrgstruct pipe_clip_state 229848b8605Smrg{ 230848b8605Smrg float ucp[PIPE_MAX_CLIP_PLANES][4]; 231848b8605Smrg}; 232848b8605Smrg 233b8e80941Smrg/** 234b8e80941Smrg * A single output for vertex transform feedback. 235b8e80941Smrg */ 236b8e80941Smrgstruct pipe_stream_output 237b8e80941Smrg{ 238b8e80941Smrg unsigned register_index:6; /**< 0 to 63 (OUT index) */ 239b8e80941Smrg unsigned start_component:2; /** 0 to 3 */ 240b8e80941Smrg unsigned num_components:3; /** 1 to 4 */ 241b8e80941Smrg unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */ 242b8e80941Smrg unsigned dst_offset:16; /**< offset into the buffer in dwords */ 243b8e80941Smrg unsigned stream:2; /**< 0 to 3 */ 244b8e80941Smrg}; 245848b8605Smrg 246848b8605Smrg/** 247848b8605Smrg * Stream output for vertex transform feedback. 248848b8605Smrg */ 249848b8605Smrgstruct pipe_stream_output_info 250848b8605Smrg{ 251848b8605Smrg unsigned num_outputs; 252848b8605Smrg /** stride for an entire vertex for each buffer in dwords */ 253b8e80941Smrg uint16_t stride[PIPE_MAX_SO_BUFFERS]; 254848b8605Smrg 255848b8605Smrg /** 256848b8605Smrg * Array of stream outputs, in the order they are to be written in. 257848b8605Smrg * Selected components are tightly packed into the output buffer. 258848b8605Smrg */ 259b8e80941Smrg struct pipe_stream_output output[PIPE_MAX_SO_OUTPUTS]; 260848b8605Smrg}; 261848b8605Smrg 262b8e80941Smrg/** 263b8e80941Smrg * The 'type' parameter identifies whether the shader state contains TGSI 264b8e80941Smrg * tokens, etc. If the driver returns 'PIPE_SHADER_IR_TGSI' for the 265b8e80941Smrg * 'PIPE_SHADER_CAP_PREFERRED_IR' shader param, the ir will *always* be 266b8e80941Smrg * 'PIPE_SHADER_IR_TGSI' and the tokens ptr will be valid. If the driver 267b8e80941Smrg * requests a different 'pipe_shader_ir' type, then it must check the 'type' 268b8e80941Smrg * enum to see if it is getting TGSI tokens or its preferred IR. 269b8e80941Smrg * 270b8e80941Smrg * TODO pipe_compute_state should probably get similar treatment to handle 271b8e80941Smrg * multiple IR's in a cleaner way.. 272b8e80941Smrg * 273b8e80941Smrg * NOTE: since it is expected that the consumer will want to perform 274b8e80941Smrg * additional passes on the nir_shader, the driver takes ownership of 275b8e80941Smrg * the nir_shader. If state trackers need to hang on to the IR (for 276b8e80941Smrg * example, variant management), it should use nir_shader_clone(). 277b8e80941Smrg */ 278848b8605Smrgstruct pipe_shader_state 279848b8605Smrg{ 280b8e80941Smrg enum pipe_shader_ir type; 281b8e80941Smrg /* TODO move tokens into union. */ 282848b8605Smrg const struct tgsi_token *tokens; 283b8e80941Smrg union { 284b8e80941Smrg void *native; 285b8e80941Smrg void *nir; 286b8e80941Smrg } ir; 287848b8605Smrg struct pipe_stream_output_info stream_output; 288848b8605Smrg}; 289848b8605Smrg 290b8e80941Smrgstatic inline void 291b8e80941Smrgpipe_shader_state_from_tgsi(struct pipe_shader_state *state, 292b8e80941Smrg const struct tgsi_token *tokens) 293b8e80941Smrg{ 294b8e80941Smrg state->type = PIPE_SHADER_IR_TGSI; 295b8e80941Smrg state->tokens = tokens; 296b8e80941Smrg memset(&state->stream_output, 0, sizeof(state->stream_output)); 297b8e80941Smrg} 298848b8605Smrg 299b8e80941Smrgstruct pipe_depth_state 300848b8605Smrg{ 301848b8605Smrg unsigned enabled:1; /**< depth test enabled? */ 302848b8605Smrg unsigned writemask:1; /**< allow depth buffer writes? */ 303848b8605Smrg unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ 304b8e80941Smrg unsigned bounds_test:1; /**< depth bounds test enabled? */ 305b8e80941Smrg float bounds_min; /**< minimum depth bound */ 306b8e80941Smrg float bounds_max; /**< maximum depth bound */ 307848b8605Smrg}; 308848b8605Smrg 309848b8605Smrg 310848b8605Smrgstruct pipe_stencil_state 311848b8605Smrg{ 312848b8605Smrg unsigned enabled:1; /**< stencil[0]: stencil enabled, stencil[1]: two-side enabled */ 313848b8605Smrg unsigned func:3; /**< PIPE_FUNC_x */ 314848b8605Smrg unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ 315848b8605Smrg unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ 316848b8605Smrg unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ 317848b8605Smrg unsigned valuemask:8; 318848b8605Smrg unsigned writemask:8; 319848b8605Smrg}; 320848b8605Smrg 321848b8605Smrg 322848b8605Smrgstruct pipe_alpha_state 323848b8605Smrg{ 324848b8605Smrg unsigned enabled:1; 325848b8605Smrg unsigned func:3; /**< PIPE_FUNC_x */ 326848b8605Smrg float ref_value; /**< reference value */ 327848b8605Smrg}; 328848b8605Smrg 329848b8605Smrg 330848b8605Smrgstruct pipe_depth_stencil_alpha_state 331848b8605Smrg{ 332848b8605Smrg struct pipe_depth_state depth; 333848b8605Smrg struct pipe_stencil_state stencil[2]; /**< [0] = front, [1] = back */ 334848b8605Smrg struct pipe_alpha_state alpha; 335848b8605Smrg}; 336848b8605Smrg 337848b8605Smrg 338848b8605Smrgstruct pipe_rt_blend_state 339848b8605Smrg{ 340848b8605Smrg unsigned blend_enable:1; 341848b8605Smrg 342848b8605Smrg unsigned rgb_func:3; /**< PIPE_BLEND_x */ 343848b8605Smrg unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 344848b8605Smrg unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 345848b8605Smrg 346848b8605Smrg unsigned alpha_func:3; /**< PIPE_BLEND_x */ 347848b8605Smrg unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 348848b8605Smrg unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 349848b8605Smrg 350848b8605Smrg unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ 351848b8605Smrg}; 352848b8605Smrg 353b8e80941Smrg 354848b8605Smrgstruct pipe_blend_state 355848b8605Smrg{ 356848b8605Smrg unsigned independent_blend_enable:1; 357848b8605Smrg unsigned logicop_enable:1; 358848b8605Smrg unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ 359848b8605Smrg unsigned dither:1; 360848b8605Smrg unsigned alpha_to_coverage:1; 361848b8605Smrg unsigned alpha_to_one:1; 362848b8605Smrg struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS]; 363848b8605Smrg}; 364848b8605Smrg 365848b8605Smrg 366848b8605Smrgstruct pipe_blend_color 367848b8605Smrg{ 368848b8605Smrg float color[4]; 369848b8605Smrg}; 370848b8605Smrg 371b8e80941Smrg 372848b8605Smrgstruct pipe_stencil_ref 373848b8605Smrg{ 374848b8605Smrg ubyte ref_value[2]; 375848b8605Smrg}; 376848b8605Smrg 377b8e80941Smrg 378b8e80941Smrg/** 379b8e80941Smrg * Note that pipe_surfaces are "texture views for rendering" 380b8e80941Smrg * and so in the case of ARB_framebuffer_no_attachment there 381b8e80941Smrg * is no pipe_surface state available such that we may 382b8e80941Smrg * extract the number of samples and layers. 383b8e80941Smrg */ 384848b8605Smrgstruct pipe_framebuffer_state 385848b8605Smrg{ 386b8e80941Smrg uint16_t width, height; 387b8e80941Smrg uint16_t layers; /**< Number of layers in a no-attachment framebuffer */ 388b8e80941Smrg ubyte samples; /**< Number of samples in a no-attachment framebuffer */ 389848b8605Smrg 390848b8605Smrg /** multiple color buffers for multiple render targets */ 391b8e80941Smrg ubyte nr_cbufs; 392848b8605Smrg struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; 393848b8605Smrg 394848b8605Smrg struct pipe_surface *zsbuf; /**< Z/stencil buffer */ 395848b8605Smrg}; 396848b8605Smrg 397848b8605Smrg 398848b8605Smrg/** 399848b8605Smrg * Texture sampler state. 400848b8605Smrg */ 401848b8605Smrgstruct pipe_sampler_state 402848b8605Smrg{ 403848b8605Smrg unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */ 404848b8605Smrg unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */ 405848b8605Smrg unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */ 406b8e80941Smrg unsigned min_img_filter:1; /**< PIPE_TEX_FILTER_x */ 407848b8605Smrg unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */ 408b8e80941Smrg unsigned mag_img_filter:1; /**< PIPE_TEX_FILTER_x */ 409848b8605Smrg unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ 410848b8605Smrg unsigned compare_func:3; /**< PIPE_FUNC_x */ 411848b8605Smrg unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ 412b8e80941Smrg unsigned max_anisotropy:5; 413848b8605Smrg unsigned seamless_cube_map:1; 414848b8605Smrg float lod_bias; /**< LOD/lambda bias */ 415848b8605Smrg float min_lod, max_lod; /**< LOD clamp range, after bias */ 416848b8605Smrg union pipe_color_union border_color; 417848b8605Smrg}; 418848b8605Smrg 419b8e80941Smrgunion pipe_surface_desc { 420b8e80941Smrg struct { 421b8e80941Smrg unsigned level; 422b8e80941Smrg unsigned first_layer:16; 423b8e80941Smrg unsigned last_layer:16; 424b8e80941Smrg } tex; 425b8e80941Smrg struct { 426b8e80941Smrg unsigned first_element; 427b8e80941Smrg unsigned last_element; 428b8e80941Smrg } buf; 429b8e80941Smrg}; 430848b8605Smrg 431848b8605Smrg/** 432848b8605Smrg * A view into a texture that can be bound to a color render target / 433848b8605Smrg * depth stencil attachment point. 434848b8605Smrg */ 435848b8605Smrgstruct pipe_surface 436848b8605Smrg{ 437848b8605Smrg struct pipe_reference reference; 438b8e80941Smrg enum pipe_format format:16; 439b8e80941Smrg unsigned writable:1; /**< writable shader resource */ 440848b8605Smrg struct pipe_resource *texture; /**< resource into which this is a view */ 441848b8605Smrg struct pipe_context *context; /**< context this surface belongs to */ 442848b8605Smrg 443848b8605Smrg /* XXX width/height should be removed */ 444b8e80941Smrg uint16_t width; /**< logical width in pixels */ 445b8e80941Smrg uint16_t height; /**< logical height in pixels */ 446b8e80941Smrg 447b8e80941Smrg /** 448b8e80941Smrg * Number of samples for the surface. This will be 0 if rendering 449b8e80941Smrg * should use the resource's nr_samples, or another value if the resource 450b8e80941Smrg * is bound using FramebufferTexture2DMultisampleEXT. 451b8e80941Smrg */ 452b8e80941Smrg unsigned nr_samples:8; 453b8e80941Smrg 454b8e80941Smrg union pipe_surface_desc u; 455b8e80941Smrg}; 456848b8605Smrg 457848b8605Smrg 458b8e80941Smrg/** 459b8e80941Smrg * A view into a texture that can be bound to a shader stage. 460b8e80941Smrg */ 461b8e80941Smrgstruct pipe_sampler_view 462b8e80941Smrg{ 463b8e80941Smrg struct pipe_reference reference; 464b8e80941Smrg enum pipe_format format:15; /**< typed PIPE_FORMAT_x */ 465b8e80941Smrg enum pipe_texture_target target:5; /**< PIPE_TEXTURE_x */ 466b8e80941Smrg unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ 467b8e80941Smrg unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ 468b8e80941Smrg unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ 469b8e80941Smrg unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */ 470b8e80941Smrg struct pipe_resource *texture; /**< texture into which this is a view */ 471b8e80941Smrg struct pipe_context *context; /**< context this view belongs to */ 472848b8605Smrg union { 473848b8605Smrg struct { 474b8e80941Smrg unsigned first_layer:16; /**< first layer to use for array textures */ 475b8e80941Smrg unsigned last_layer:16; /**< last layer to use for array textures */ 476b8e80941Smrg unsigned first_level:8; /**< first mipmap level to use */ 477b8e80941Smrg unsigned last_level:8; /**< last mipmap level to use */ 478848b8605Smrg } tex; 479848b8605Smrg struct { 480b8e80941Smrg unsigned offset; /**< offset in bytes */ 481b8e80941Smrg unsigned size; /**< size of the readable sub-range in bytes */ 482848b8605Smrg } buf; 483848b8605Smrg } u; 484848b8605Smrg}; 485848b8605Smrg 486848b8605Smrg 487848b8605Smrg/** 488b8e80941Smrg * A description of a buffer or texture image that can be bound to a shader 489b8e80941Smrg * stage. 490848b8605Smrg */ 491b8e80941Smrgstruct pipe_image_view 492848b8605Smrg{ 493b8e80941Smrg struct pipe_resource *resource; /**< resource into which this is a view */ 494848b8605Smrg enum pipe_format format; /**< typed PIPE_FORMAT_x */ 495b8e80941Smrg uint16_t access; /**< PIPE_IMAGE_ACCESS_x */ 496b8e80941Smrg uint16_t shader_access; /**< PIPE_IMAGE_ACCESS_x */ 497b8e80941Smrg 498848b8605Smrg union { 499848b8605Smrg struct { 500848b8605Smrg unsigned first_layer:16; /**< first layer to use for array textures */ 501848b8605Smrg unsigned last_layer:16; /**< last layer to use for array textures */ 502b8e80941Smrg unsigned level:8; /**< mipmap level to use */ 503848b8605Smrg } tex; 504848b8605Smrg struct { 505b8e80941Smrg unsigned offset; /**< offset in bytes */ 506b8e80941Smrg unsigned size; /**< size of the accessible sub-range in bytes */ 507848b8605Smrg } buf; 508848b8605Smrg } u; 509848b8605Smrg}; 510848b8605Smrg 511848b8605Smrg 512848b8605Smrg/** 513848b8605Smrg * Subregion of 1D/2D/3D image resource. 514848b8605Smrg */ 515848b8605Smrgstruct pipe_box 516848b8605Smrg{ 517b8e80941Smrg /* Fields only used by textures use int16_t instead of int. 518b8e80941Smrg * x and width are used by buffers, so they need the full 32-bit range. 519b8e80941Smrg */ 520848b8605Smrg int x; 521b8e80941Smrg int16_t y; 522b8e80941Smrg int16_t z; 523848b8605Smrg int width; 524b8e80941Smrg int16_t height; 525b8e80941Smrg int16_t depth; 526848b8605Smrg}; 527848b8605Smrg 528848b8605Smrg 529848b8605Smrg/** 530848b8605Smrg * A memory object/resource such as a vertex buffer or texture. 531848b8605Smrg */ 532848b8605Smrgstruct pipe_resource 533848b8605Smrg{ 534848b8605Smrg struct pipe_reference reference; 535848b8605Smrg 536b8e80941Smrg unsigned width0; /**< Used by both buffers and textures. */ 537b8e80941Smrg uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */ 538b8e80941Smrg uint16_t depth0; 539b8e80941Smrg uint16_t array_size; 540848b8605Smrg 541b8e80941Smrg enum pipe_format format:16; /**< PIPE_FORMAT_x */ 542b8e80941Smrg enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */ 543848b8605Smrg unsigned last_level:8; /**< Index of last mipmap level present/defined */ 544848b8605Smrg 545b8e80941Smrg /** Number of samples determining quality, driving rasterizer, shading, 546b8e80941Smrg * and framebuffer. 547b8e80941Smrg */ 548b8e80941Smrg unsigned nr_samples:8; 549b8e80941Smrg 550b8e80941Smrg /** Multiple samples within a pixel can have the same value. 551b8e80941Smrg * nr_storage_samples determines how many slots for different values 552b8e80941Smrg * there are per pixel. Only color buffers can set this lower than 553b8e80941Smrg * nr_samples. 554b8e80941Smrg */ 555b8e80941Smrg unsigned nr_storage_samples:8; 556b8e80941Smrg 557b8e80941Smrg unsigned usage:8; /**< PIPE_USAGE_x (not a bitmask) */ 558848b8605Smrg unsigned bind; /**< bitmask of PIPE_BIND_x */ 559848b8605Smrg unsigned flags; /**< bitmask of PIPE_RESOURCE_FLAG_x */ 560b8e80941Smrg 561b8e80941Smrg /** 562b8e80941Smrg * For planar images, ie. YUV EGLImage external, etc, pointer to the 563b8e80941Smrg * next plane. 564b8e80941Smrg */ 565b8e80941Smrg struct pipe_resource *next; 566b8e80941Smrg /* The screen pointer should be last for optimal structure packing. */ 567b8e80941Smrg struct pipe_screen *screen; /**< screen that this texture belongs to */ 568848b8605Smrg}; 569848b8605Smrg 570848b8605Smrg 571848b8605Smrg/** 572848b8605Smrg * Transfer object. For data transfer to/from a resource. 573848b8605Smrg */ 574848b8605Smrgstruct pipe_transfer 575848b8605Smrg{ 576848b8605Smrg struct pipe_resource *resource; /**< resource to transfer to/from */ 577848b8605Smrg unsigned level; /**< texture mipmap level */ 578848b8605Smrg enum pipe_transfer_usage usage; 579848b8605Smrg struct pipe_box box; /**< region of the resource to access */ 580848b8605Smrg unsigned stride; /**< row stride in bytes */ 581848b8605Smrg unsigned layer_stride; /**< image/layer stride in bytes */ 582848b8605Smrg}; 583848b8605Smrg 584848b8605Smrg 585848b8605Smrg/** 586848b8605Smrg * A vertex buffer. Typically, all the vertex data/attributes for 587848b8605Smrg * drawing something will be in one buffer. But it's also possible, for 588848b8605Smrg * example, to put colors in one buffer and texcoords in another. 589848b8605Smrg */ 590848b8605Smrgstruct pipe_vertex_buffer 591848b8605Smrg{ 592b8e80941Smrg uint16_t stride; /**< stride to same attrib in next vertex, in bytes */ 593b8e80941Smrg bool is_user_buffer; 594848b8605Smrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 595b8e80941Smrg 596b8e80941Smrg union { 597b8e80941Smrg struct pipe_resource *resource; /**< the actual buffer */ 598b8e80941Smrg const void *user; /**< pointer to a user buffer */ 599b8e80941Smrg } buffer; 600848b8605Smrg}; 601848b8605Smrg 602848b8605Smrg 603848b8605Smrg/** 604848b8605Smrg * A constant buffer. A subrange of an existing buffer can be set 605848b8605Smrg * as a constant buffer. 606848b8605Smrg */ 607b8e80941Smrgstruct pipe_constant_buffer 608b8e80941Smrg{ 609848b8605Smrg struct pipe_resource *buffer; /**< the actual buffer */ 610848b8605Smrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 611848b8605Smrg unsigned buffer_size; /**< how much data can be read in shader */ 612848b8605Smrg const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */ 613848b8605Smrg}; 614848b8605Smrg 615848b8605Smrg 616b8e80941Smrg/** 617b8e80941Smrg * An untyped shader buffer supporting loads, stores, and atomics. 618b8e80941Smrg */ 619b8e80941Smrgstruct pipe_shader_buffer { 620b8e80941Smrg struct pipe_resource *buffer; /**< the actual buffer */ 621b8e80941Smrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 622b8e80941Smrg unsigned buffer_size; /**< how much data can be read in shader */ 623b8e80941Smrg}; 624b8e80941Smrg 625b8e80941Smrg 626848b8605Smrg/** 627848b8605Smrg * A stream output target. The structure specifies the range vertices can 628848b8605Smrg * be written to. 629848b8605Smrg * 630848b8605Smrg * In addition to that, the structure should internally maintain the offset 631848b8605Smrg * into the buffer, which should be incremented everytime something is written 632848b8605Smrg * (appended) to it. The internal offset is buffer_offset + how many bytes 633848b8605Smrg * have been written. The internal offset can be stored on the device 634848b8605Smrg * and the CPU actually doesn't have to query it. 635848b8605Smrg * 636848b8605Smrg * Note that the buffer_size variable is actually specifying the available 637b8e80941Smrg * space in the buffer, not the size of the attached buffer. 638b8e80941Smrg * In other words in majority of cases buffer_size would simply be 639848b8605Smrg * 'buffer->width0 - buffer_offset', so buffer_size refers to the size 640848b8605Smrg * of the buffer left, after accounting for buffer offset, for stream output 641848b8605Smrg * to write to. 642848b8605Smrg * 643848b8605Smrg * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have 644848b8605Smrg * actually been written. 645848b8605Smrg */ 646848b8605Smrgstruct pipe_stream_output_target 647848b8605Smrg{ 648848b8605Smrg struct pipe_reference reference; 649848b8605Smrg struct pipe_resource *buffer; /**< the output buffer */ 650848b8605Smrg struct pipe_context *context; /**< context this SO target belongs to */ 651848b8605Smrg 652848b8605Smrg unsigned buffer_offset; /**< offset where data should be written, in bytes */ 653848b8605Smrg unsigned buffer_size; /**< how much data is allowed to be written */ 654848b8605Smrg}; 655848b8605Smrg 656848b8605Smrg 657848b8605Smrg/** 658848b8605Smrg * Information to describe a vertex attribute (position, color, etc) 659848b8605Smrg */ 660848b8605Smrgstruct pipe_vertex_element 661848b8605Smrg{ 662848b8605Smrg /** Offset of this attribute, in bytes, from the start of the vertex */ 663b8e80941Smrg unsigned src_offset:16; 664b8e80941Smrg 665b8e80941Smrg /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does 666b8e80941Smrg * this attribute live in? 667b8e80941Smrg */ 668b8e80941Smrg unsigned vertex_buffer_index:5; 669b8e80941Smrg 670b8e80941Smrg enum pipe_format src_format:11; 671848b8605Smrg 672848b8605Smrg /** Instance data rate divisor. 0 means this is per-vertex data, 673848b8605Smrg * n means per-instance data used for n consecutive instances (n > 0). 674848b8605Smrg */ 675848b8605Smrg unsigned instance_divisor; 676848b8605Smrg}; 677848b8605Smrg 678848b8605Smrg 679b8e80941Smrgstruct pipe_draw_indirect_info 680848b8605Smrg{ 681b8e80941Smrg unsigned offset; /**< must be 4 byte aligned */ 682b8e80941Smrg unsigned stride; /**< must be 4 byte aligned */ 683b8e80941Smrg unsigned draw_count; /**< number of indirect draws */ 684b8e80941Smrg unsigned indirect_draw_count_offset; /**< must be 4 byte aligned */ 685b8e80941Smrg 686b8e80941Smrg /* Indirect draw parameters resource is laid out as follows: 687b8e80941Smrg * 688b8e80941Smrg * if using indexed drawing: 689b8e80941Smrg * struct { 690b8e80941Smrg * uint32_t count; 691b8e80941Smrg * uint32_t instance_count; 692b8e80941Smrg * uint32_t start; 693b8e80941Smrg * int32_t index_bias; 694b8e80941Smrg * uint32_t start_instance; 695b8e80941Smrg * }; 696b8e80941Smrg * otherwise: 697b8e80941Smrg * struct { 698b8e80941Smrg * uint32_t count; 699b8e80941Smrg * uint32_t instance_count; 700b8e80941Smrg * uint32_t start; 701b8e80941Smrg * uint32_t start_instance; 702b8e80941Smrg * }; 703b8e80941Smrg */ 704b8e80941Smrg struct pipe_resource *buffer; 705b8e80941Smrg 706b8e80941Smrg /* Indirect draw count resource: If not NULL, contains a 32-bit value which 707b8e80941Smrg * is to be used as the real draw_count. 708b8e80941Smrg */ 709b8e80941Smrg struct pipe_resource *indirect_draw_count; 710848b8605Smrg}; 711848b8605Smrg 712848b8605Smrg 713848b8605Smrg/** 714848b8605Smrg * Information to describe a draw_vbo call. 715848b8605Smrg */ 716848b8605Smrgstruct pipe_draw_info 717848b8605Smrg{ 718b8e80941Smrg ubyte index_size; /**< if 0, the draw is not indexed. */ 719b8e80941Smrg enum pipe_prim_type mode:8; /**< the mode of the primitive */ 720b8e80941Smrg unsigned primitive_restart:1; 721b8e80941Smrg unsigned has_user_indices:1; /**< if true, use index.user_buffer */ 722b8e80941Smrg ubyte vertices_per_patch; /**< the number of vertices per patch */ 723848b8605Smrg 724b8e80941Smrg /** 725b8e80941Smrg * Direct draws: start is the index of the first vertex 726b8e80941Smrg * Non-indexed indirect draws: not used 727b8e80941Smrg * Indexed indirect draws: start is added to the indirect start. 728b8e80941Smrg */ 729b8e80941Smrg unsigned start; 730848b8605Smrg unsigned count; /**< number of vertices */ 731848b8605Smrg 732848b8605Smrg unsigned start_instance; /**< first instance id */ 733848b8605Smrg unsigned instance_count; /**< number of instances */ 734848b8605Smrg 735b8e80941Smrg unsigned drawid; /**< id of this draw in a multidraw */ 736b8e80941Smrg 737848b8605Smrg /** 738848b8605Smrg * For indexed drawing, these fields apply after index lookup. 739848b8605Smrg */ 740848b8605Smrg int index_bias; /**< a bias to be added to each index */ 741848b8605Smrg unsigned min_index; /**< the min index */ 742848b8605Smrg unsigned max_index; /**< the max index */ 743848b8605Smrg 744848b8605Smrg /** 745848b8605Smrg * Primitive restart enable/index (only applies to indexed drawing) 746848b8605Smrg */ 747848b8605Smrg unsigned restart_index; 748848b8605Smrg 749b8e80941Smrg /* Pointers must be at the end for an optimal structure layout on 64-bit. */ 750b8e80941Smrg 751b8e80941Smrg /** 752b8e80941Smrg * An index buffer. When an index buffer is bound, all indices to vertices 753b8e80941Smrg * will be looked up from the buffer. 754b8e80941Smrg * 755b8e80941Smrg * If has_user_indices, use index.user, else use index.resource. 756b8e80941Smrg */ 757b8e80941Smrg union { 758b8e80941Smrg struct pipe_resource *resource; /**< real buffer */ 759b8e80941Smrg const void *user; /**< pointer to a user buffer */ 760b8e80941Smrg } index; 761b8e80941Smrg 762b8e80941Smrg struct pipe_draw_indirect_info *indirect; /**< Indirect draw. */ 763b8e80941Smrg 764848b8605Smrg /** 765848b8605Smrg * Stream output target. If not NULL, it's used to provide the 'count' 766848b8605Smrg * parameter based on the number vertices captured by the stream output 767848b8605Smrg * stage. (or generally, based on the number of bytes captured) 768848b8605Smrg * 769848b8605Smrg * Only 'mode', 'start_instance', and 'instance_count' are taken into 770848b8605Smrg * account, all the other variables from pipe_draw_info are ignored. 771848b8605Smrg * 772848b8605Smrg * 'start' is implicitly 0 and 'count' is set as discussed above. 773848b8605Smrg * The draw command is non-indexed. 774848b8605Smrg * 775848b8605Smrg * Note that this only provides the count. The vertex buffers must 776848b8605Smrg * be set via set_vertex_buffers manually. 777848b8605Smrg */ 778848b8605Smrg struct pipe_stream_output_target *count_from_stream_output; 779848b8605Smrg}; 780848b8605Smrg 781848b8605Smrg 782848b8605Smrg/** 783848b8605Smrg * Information to describe a blit call. 784848b8605Smrg */ 785848b8605Smrgstruct pipe_blit_info 786848b8605Smrg{ 787848b8605Smrg struct { 788848b8605Smrg struct pipe_resource *resource; 789848b8605Smrg unsigned level; 790848b8605Smrg struct pipe_box box; /**< negative width, height only legal for src */ 791848b8605Smrg /* For pipe_surface-like format casting: */ 792848b8605Smrg enum pipe_format format; /**< must be supported for sampling (src) 793848b8605Smrg or rendering (dst), ZS is always supported */ 794848b8605Smrg } dst, src; 795848b8605Smrg 796848b8605Smrg unsigned mask; /**< bitmask of PIPE_MASK_R/G/B/A/Z/S */ 797848b8605Smrg unsigned filter; /**< PIPE_TEX_FILTER_* */ 798848b8605Smrg 799848b8605Smrg boolean scissor_enable; 800848b8605Smrg struct pipe_scissor_state scissor; 801848b8605Smrg 802b8e80941Smrg /* Window rectangles can either be inclusive or exclusive. */ 803b8e80941Smrg boolean window_rectangle_include; 804b8e80941Smrg unsigned num_window_rectangles; 805b8e80941Smrg struct pipe_scissor_state window_rectangles[PIPE_MAX_WINDOW_RECTANGLES]; 806b8e80941Smrg 807848b8605Smrg boolean render_condition_enable; /**< whether the blit should honor the 808848b8605Smrg current render condition */ 809b8e80941Smrg boolean alpha_blend; /* dst.rgb = src.rgb * src.a + dst.rgb * (1 - src.a) */ 810848b8605Smrg}; 811848b8605Smrg 812b8e80941Smrg/** 813b8e80941Smrg * Information to describe a launch_grid call. 814b8e80941Smrg */ 815b8e80941Smrgstruct pipe_grid_info 816b8e80941Smrg{ 817b8e80941Smrg /** 818b8e80941Smrg * For drivers that use PIPE_SHADER_IR_NATIVE as their prefered IR, this 819b8e80941Smrg * value will be the index of the kernel in the opencl.kernels metadata 820b8e80941Smrg * list. 821b8e80941Smrg */ 822b8e80941Smrg uint32_t pc; 823b8e80941Smrg 824b8e80941Smrg /** 825b8e80941Smrg * Will be used to initialize the INPUT resource, and it should point to a 826b8e80941Smrg * buffer of at least pipe_compute_state::req_input_mem bytes. 827b8e80941Smrg */ 828b8e80941Smrg void *input; 829b8e80941Smrg 830b8e80941Smrg /** 831b8e80941Smrg * Grid number of dimensions, 1-3, e.g. the work_dim parameter passed to 832b8e80941Smrg * clEnqueueNDRangeKernel. Note block[] and grid[] must be padded with 833b8e80941Smrg * 1 for non-used dimensions. 834b8e80941Smrg */ 835b8e80941Smrg uint work_dim; 836b8e80941Smrg 837b8e80941Smrg /** 838b8e80941Smrg * Determine the layout of the working block (in thread units) to be used. 839b8e80941Smrg */ 840b8e80941Smrg uint block[3]; 841b8e80941Smrg 842b8e80941Smrg /** 843b8e80941Smrg * last_block allows disabling threads at the farthermost grid boundary. 844b8e80941Smrg * Full blocks as specified by "block" are launched, but the threads 845b8e80941Smrg * outside of "last_block" dimensions are disabled. 846b8e80941Smrg * 847b8e80941Smrg * If a block touches the grid boundary in the i-th axis, threads with 848b8e80941Smrg * THREAD_ID[i] >= last_block[i] are disabled. 849b8e80941Smrg * 850b8e80941Smrg * If last_block[i] is 0, it has the same behavior as last_block[i] = block[i], 851b8e80941Smrg * meaning no effect. 852b8e80941Smrg * 853b8e80941Smrg * It's equivalent to doing this at the beginning of the compute shader: 854b8e80941Smrg * 855b8e80941Smrg * for (i = 0; i < 3; i++) { 856b8e80941Smrg * if (block_id[i] == grid[i] - 1 && 857b8e80941Smrg * last_block[i] && thread_id[i] >= last_block[i]) 858b8e80941Smrg * return; 859b8e80941Smrg * } 860b8e80941Smrg */ 861b8e80941Smrg uint last_block[3]; 862b8e80941Smrg 863b8e80941Smrg /** 864b8e80941Smrg * Determine the layout of the grid (in block units) to be used. 865b8e80941Smrg */ 866b8e80941Smrg uint grid[3]; 867b8e80941Smrg 868b8e80941Smrg /* Indirect compute parameters resource: If not NULL, block sizes are taken 869b8e80941Smrg * from this buffer instead, which is laid out as follows: 870b8e80941Smrg * 871b8e80941Smrg * struct { 872b8e80941Smrg * uint32_t num_blocks_x; 873b8e80941Smrg * uint32_t num_blocks_y; 874b8e80941Smrg * uint32_t num_blocks_z; 875b8e80941Smrg * }; 876b8e80941Smrg */ 877b8e80941Smrg struct pipe_resource *indirect; 878b8e80941Smrg unsigned indirect_offset; /**< must be 4 byte aligned */ 879b8e80941Smrg}; 880848b8605Smrg 881848b8605Smrg/** 882848b8605Smrg * Structure used as a header for serialized LLVM programs. 883848b8605Smrg */ 884848b8605Smrgstruct pipe_llvm_program_header 885848b8605Smrg{ 886848b8605Smrg uint32_t num_bytes; /**< Number of bytes in the LLVM bytecode program. */ 887848b8605Smrg}; 888848b8605Smrg 889848b8605Smrgstruct pipe_compute_state 890848b8605Smrg{ 891b8e80941Smrg enum pipe_shader_ir ir_type; /**< IR type contained in prog. */ 892848b8605Smrg const void *prog; /**< Compute program to be executed. */ 893848b8605Smrg unsigned req_local_mem; /**< Required size of the LOCAL resource. */ 894848b8605Smrg unsigned req_private_mem; /**< Required size of the PRIVATE resource. */ 895848b8605Smrg unsigned req_input_mem; /**< Required size of the INPUT resource. */ 896848b8605Smrg}; 897848b8605Smrg 898b8e80941Smrg/** 899b8e80941Smrg * Structure that contains a callback for debug messages from the driver back 900b8e80941Smrg * to the state tracker. 901b8e80941Smrg */ 902b8e80941Smrgstruct pipe_debug_callback 903b8e80941Smrg{ 904b8e80941Smrg /** 905b8e80941Smrg * When set to \c true, the callback may be called asynchronously from a 906b8e80941Smrg * driver-created thread. 907b8e80941Smrg */ 908b8e80941Smrg bool async; 909b8e80941Smrg 910b8e80941Smrg /** 911b8e80941Smrg * Callback for the driver to report debug/performance/etc information back 912b8e80941Smrg * to the state tracker. 913b8e80941Smrg * 914b8e80941Smrg * \param data user-supplied data pointer 915b8e80941Smrg * \param id message type identifier, if pointed value is 0, then a 916b8e80941Smrg * new id is assigned 917b8e80941Smrg * \param type PIPE_DEBUG_TYPE_* 918b8e80941Smrg * \param format printf-style format string 919b8e80941Smrg * \param args args for format string 920b8e80941Smrg */ 921b8e80941Smrg void (*debug_message)(void *data, 922b8e80941Smrg unsigned *id, 923b8e80941Smrg enum pipe_debug_type type, 924b8e80941Smrg const char *fmt, 925b8e80941Smrg va_list args); 926b8e80941Smrg void *data; 927b8e80941Smrg}; 928b8e80941Smrg 929b8e80941Smrg/** 930b8e80941Smrg * Structure that contains a callback for device reset messages from the driver 931b8e80941Smrg * back to the state tracker. 932b8e80941Smrg * 933b8e80941Smrg * The callback must not be called from driver-created threads. 934b8e80941Smrg */ 935b8e80941Smrgstruct pipe_device_reset_callback 936b8e80941Smrg{ 937b8e80941Smrg /** 938b8e80941Smrg * Callback for the driver to report when a device reset is detected. 939b8e80941Smrg * 940b8e80941Smrg * \param data user-supplied data pointer 941b8e80941Smrg * \param status PIPE_*_RESET 942b8e80941Smrg */ 943b8e80941Smrg void (*reset)(void *data, enum pipe_reset_status status); 944b8e80941Smrg 945b8e80941Smrg void *data; 946b8e80941Smrg}; 947b8e80941Smrg 948b8e80941Smrg/** 949b8e80941Smrg * Information about memory usage. All sizes are in kilobytes. 950b8e80941Smrg */ 951b8e80941Smrgstruct pipe_memory_info 952b8e80941Smrg{ 953b8e80941Smrg unsigned total_device_memory; /**< size of device memory, e.g. VRAM */ 954b8e80941Smrg unsigned avail_device_memory; /**< free device memory at the moment */ 955b8e80941Smrg unsigned total_staging_memory; /**< size of staging memory, e.g. GART */ 956b8e80941Smrg unsigned avail_staging_memory; /**< free staging memory at the moment */ 957b8e80941Smrg unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */ 958b8e80941Smrg unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */ 959b8e80941Smrg}; 960b8e80941Smrg 961b8e80941Smrg/** 962b8e80941Smrg * Structure that contains information about external memory 963b8e80941Smrg */ 964b8e80941Smrgstruct pipe_memory_object 965b8e80941Smrg{ 966b8e80941Smrg bool dedicated; 967b8e80941Smrg}; 968b8e80941Smrg 969848b8605Smrg#ifdef __cplusplus 970848b8605Smrg} 971848b8605Smrg#endif 972b8e80941Smrg 973848b8605Smrg#endif 974