14a49301eSmrg/************************************************************************** 201e04c3fSmrg * 3af69d88dSmrg * Copyright 2007 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 501e04c3fSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 1301e04c3fSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 1701e04c3fSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2501e04c3fSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg 294a49301eSmrg/** 304a49301eSmrg * @file 3101e04c3fSmrg * 324a49301eSmrg * Abstract graphics pipe state objects. 334a49301eSmrg * 344a49301eSmrg * Basic notes: 354a49301eSmrg * 1. Want compact representations, so we use bitfields. 364a49301eSmrg * 2. Put bitfields before other (GLfloat) fields. 3701e04c3fSmrg * 3. enum bitfields need to be at least one bit extra in size so the most 3801e04c3fSmrg * significant bit is zero. MSVC treats enums as signed so if the high 3901e04c3fSmrg * bit is set, the value will be interpreted as a negative number. 4001e04c3fSmrg * That causes trouble in various places. 414a49301eSmrg */ 424a49301eSmrg 434a49301eSmrg 444a49301eSmrg#ifndef PIPE_STATE_H 454a49301eSmrg#define PIPE_STATE_H 464a49301eSmrg 474a49301eSmrg#include "p_compiler.h" 484a49301eSmrg#include "p_defines.h" 494a49301eSmrg#include "p_format.h" 504a49301eSmrg 514a49301eSmrg 524a49301eSmrg#ifdef __cplusplus 534a49301eSmrgextern "C" { 544a49301eSmrg#endif 554a49301eSmrg 567ec681f3Smrgstruct gl_buffer_object; 574a49301eSmrg 584a49301eSmrg/** 594a49301eSmrg * Implementation limits 604a49301eSmrg */ 614a49301eSmrg#define PIPE_MAX_ATTRIBS 32 62af69d88dSmrg#define PIPE_MAX_CLIP_PLANES 8 634a49301eSmrg#define PIPE_MAX_COLOR_BUFS 8 64cdc920a0Smrg#define PIPE_MAX_CONSTANT_BUFFERS 32 6501e04c3fSmrg#define PIPE_MAX_SAMPLERS 32 6601e04c3fSmrg#define PIPE_MAX_SHADER_INPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */ 6701e04c3fSmrg#define PIPE_MAX_SHADER_OUTPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */ 6801e04c3fSmrg#define PIPE_MAX_SHADER_SAMPLER_VIEWS 128 6901e04c3fSmrg#define PIPE_MAX_SHADER_BUFFERS 32 7001e04c3fSmrg#define PIPE_MAX_SHADER_IMAGES 32 714a49301eSmrg#define PIPE_MAX_TEXTURE_LEVELS 16 723464ebd5Sriastradh#define PIPE_MAX_SO_BUFFERS 4 73af69d88dSmrg#define PIPE_MAX_SO_OUTPUTS 64 74af69d88dSmrg#define PIPE_MAX_VIEWPORTS 16 75af69d88dSmrg#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8 76af69d88dSmrg#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2 7701e04c3fSmrg#define PIPE_MAX_WINDOW_RECTANGLES 8 7801e04c3fSmrg#define PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE 4 794a49301eSmrg 8001e04c3fSmrg#define PIPE_MAX_HW_ATOMIC_BUFFERS 32 819f464c52Smaya#define PIPE_MAX_VERTEX_STREAMS 4 824a49301eSmrg 83cdc920a0Smrgstruct pipe_reference 84cdc920a0Smrg{ 85cdc920a0Smrg int32_t count; /* atomic */ 86cdc920a0Smrg}; 874a49301eSmrg 884a49301eSmrg 894a49301eSmrg 904a49301eSmrg/** 914a49301eSmrg * Primitive (point/line/tri) rasterization info 924a49301eSmrg */ 934a49301eSmrgstruct pipe_rasterizer_state 944a49301eSmrg{ 954a49301eSmrg unsigned flatshade:1; 964a49301eSmrg unsigned light_twoside:1; 973464ebd5Sriastradh unsigned clamp_vertex_color:1; 983464ebd5Sriastradh unsigned clamp_fragment_color:1; 993464ebd5Sriastradh unsigned front_ccw:1; 1003464ebd5Sriastradh unsigned cull_face:2; /**< PIPE_FACE_x */ 1013464ebd5Sriastradh unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */ 1023464ebd5Sriastradh unsigned fill_back:2; /**< PIPE_POLYGON_MODE_x */ 1033464ebd5Sriastradh unsigned offset_point:1; 1043464ebd5Sriastradh unsigned offset_line:1; 1053464ebd5Sriastradh unsigned offset_tri:1; 1064a49301eSmrg unsigned scissor:1; 1074a49301eSmrg unsigned poly_smooth:1; 1084a49301eSmrg unsigned poly_stipple_enable:1; 1094a49301eSmrg unsigned point_smooth:1; 110cdc920a0Smrg unsigned sprite_coord_mode:1; /**< PIPE_SPRITE_COORD_ */ 111cdc920a0Smrg unsigned point_quad_rasterization:1; /** points rasterized as quads or points */ 112af69d88dSmrg unsigned point_tri_clip:1; /** large points clipped as tris or points */ 1134a49301eSmrg unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ 1144a49301eSmrg unsigned multisample:1; /* XXX maybe more ms state in future */ 1157ec681f3Smrg unsigned no_ms_sample_mask_out:1; 11601e04c3fSmrg unsigned force_persample_interp:1; 1174a49301eSmrg unsigned line_smooth:1; 1184a49301eSmrg unsigned line_stipple_enable:1; 1194a49301eSmrg unsigned line_last_pixel:1; 1207ec681f3Smrg unsigned line_rectangular:1; /** lines rasterized as rectangles or parallelograms */ 12101e04c3fSmrg unsigned conservative_raster_mode:2; /**< PIPE_CONSERVATIVE_RASTER_x */ 1224a49301eSmrg 1233464ebd5Sriastradh /** 1244a49301eSmrg * Use the first vertex of a primitive as the provoking vertex for 1254a49301eSmrg * flat shading. 1264a49301eSmrg */ 1273464ebd5Sriastradh unsigned flatshade_first:1; 1284a49301eSmrg 129af69d88dSmrg unsigned half_pixel_center:1; 130af69d88dSmrg unsigned bottom_edge_rule:1; 131af69d88dSmrg 13201e04c3fSmrg /* 13301e04c3fSmrg * Conservative rasterization subpixel precision bias in bits 13401e04c3fSmrg */ 13501e04c3fSmrg unsigned subpixel_precision_x:4; 13601e04c3fSmrg unsigned subpixel_precision_y:4; 13701e04c3fSmrg 1383464ebd5Sriastradh /** 139af69d88dSmrg * When true, rasterization is disabled and no pixels are written. 140af69d88dSmrg * This only makes sense with the Stream Out functionality. 141af69d88dSmrg */ 142af69d88dSmrg unsigned rasterizer_discard:1; 143af69d88dSmrg 14401e04c3fSmrg /** 14501e04c3fSmrg * Exposed by PIPE_CAP_TILE_RASTER_ORDER. When true, 14601e04c3fSmrg * tile_raster_order_increasing_* indicate the order that the rasterizer 14701e04c3fSmrg * should render tiles, to meet the requirements of 14801e04c3fSmrg * GL_MESA_tile_raster_order. 14901e04c3fSmrg */ 15001e04c3fSmrg unsigned tile_raster_order_fixed:1; 15101e04c3fSmrg unsigned tile_raster_order_increasing_x:1; 15201e04c3fSmrg unsigned tile_raster_order_increasing_y:1; 15301e04c3fSmrg 154af69d88dSmrg /** 155af69d88dSmrg * When false, depth clipping is disabled and the depth value will be 156af69d88dSmrg * clamped later at the per-pixel level before depth testing. 157af69d88dSmrg * This depends on PIPE_CAP_DEPTH_CLIP_DISABLE. 15801e04c3fSmrg * 15901e04c3fSmrg * If PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE is unsupported, depth_clip_near 16001e04c3fSmrg * is equal to depth_clip_far. 161af69d88dSmrg */ 16201e04c3fSmrg unsigned depth_clip_near:1; 16301e04c3fSmrg unsigned depth_clip_far:1; 164af69d88dSmrg 1657ec681f3Smrg /** 1667ec681f3Smrg * When true, depth clamp is enabled. 1677ec681f3Smrg * If PIPE_CAP_DEPTH_CLAMP_ENABLE is unsupported, this is always the inverse 1687ec681f3Smrg * of depth_clip_far. 1697ec681f3Smrg */ 1707ec681f3Smrg unsigned depth_clamp:1; 1717ec681f3Smrg 172af69d88dSmrg /** 173af69d88dSmrg * When true clip space in the z axis goes from [0..1] (D3D). When false 174af69d88dSmrg * [-1, 1] (GL). 1754a49301eSmrg * 176af69d88dSmrg * NOTE: D3D will always use depth clamping. 177af69d88dSmrg */ 178af69d88dSmrg unsigned clip_halfz:1; 179af69d88dSmrg 18001e04c3fSmrg /** 18101e04c3fSmrg * When true do not scale offset_units and use same rules for unorm and 18201e04c3fSmrg * float depth buffers (D3D9). When false use GL/D3D1X behaviour. 18301e04c3fSmrg * This depends on PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED. 18401e04c3fSmrg */ 18501e04c3fSmrg unsigned offset_units_unscaled:1; 18601e04c3fSmrg 187af69d88dSmrg /** 188af69d88dSmrg * Enable bits for clipping half-spaces. 189af69d88dSmrg * This applies to both user clip planes and shader clip distances. 190af69d88dSmrg * Note that if the bound shader exports any clip distances, these 191af69d88dSmrg * replace all user clip planes, and clip half-spaces enabled here 192af69d88dSmrg * but not written by the shader count as disabled. 1934a49301eSmrg */ 194af69d88dSmrg unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES; 1954a49301eSmrg 1963464ebd5Sriastradh unsigned line_stipple_factor:8; /**< [1..256] actually */ 1973464ebd5Sriastradh unsigned line_stipple_pattern:16; 1983464ebd5Sriastradh 19901e04c3fSmrg /** 20001e04c3fSmrg * Replace the given TEXCOORD inputs with point coordinates, max. 8 inputs. 20101e04c3fSmrg * If TEXCOORD (including PCOORD) are unsupported, replace GENERIC inputs 20201e04c3fSmrg * instead. Max. 9 inputs: 8x GENERIC to emulate TEXCOORD, and 1x GENERIC 20301e04c3fSmrg * to emulate PCOORD. 20401e04c3fSmrg */ 20501e04c3fSmrg uint16_t sprite_coord_enable; /* 0-7: TEXCOORD/GENERIC, 8: PCOORD */ 2063464ebd5Sriastradh 2074a49301eSmrg float line_width; 2084a49301eSmrg float point_size; /**< used when no per-vertex size */ 2094a49301eSmrg float offset_units; 2104a49301eSmrg float offset_scale; 211af69d88dSmrg float offset_clamp; 21201e04c3fSmrg float conservative_raster_dilate; 2134a49301eSmrg}; 2144a49301eSmrg 2154a49301eSmrg 2164a49301eSmrgstruct pipe_poly_stipple 2174a49301eSmrg{ 2184a49301eSmrg unsigned stipple[32]; 2194a49301eSmrg}; 2204a49301eSmrg 2214a49301eSmrg 2224a49301eSmrgstruct pipe_viewport_state 2234a49301eSmrg{ 22401e04c3fSmrg float scale[3]; 22501e04c3fSmrg float translate[3]; 2267ec681f3Smrg enum pipe_viewport_swizzle swizzle_x:8; 2277ec681f3Smrg enum pipe_viewport_swizzle swizzle_y:8; 2287ec681f3Smrg enum pipe_viewport_swizzle swizzle_z:8; 2297ec681f3Smrg enum pipe_viewport_swizzle swizzle_w:8; 2304a49301eSmrg}; 2314a49301eSmrg 2324a49301eSmrg 2334a49301eSmrgstruct pipe_scissor_state 2344a49301eSmrg{ 2354a49301eSmrg unsigned minx:16; 2364a49301eSmrg unsigned miny:16; 2374a49301eSmrg unsigned maxx:16; 2384a49301eSmrg unsigned maxy:16; 2394a49301eSmrg}; 2404a49301eSmrg 2414a49301eSmrg 2424a49301eSmrgstruct pipe_clip_state 2434a49301eSmrg{ 2444a49301eSmrg float ucp[PIPE_MAX_CLIP_PLANES][4]; 245af69d88dSmrg}; 246af69d88dSmrg 24701e04c3fSmrg/** 24801e04c3fSmrg * A single output for vertex transform feedback. 24901e04c3fSmrg */ 25001e04c3fSmrgstruct pipe_stream_output 25101e04c3fSmrg{ 25201e04c3fSmrg unsigned register_index:6; /**< 0 to 63 (OUT index) */ 25301e04c3fSmrg unsigned start_component:2; /** 0 to 3 */ 25401e04c3fSmrg unsigned num_components:3; /** 1 to 4 */ 25501e04c3fSmrg unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */ 25601e04c3fSmrg unsigned dst_offset:16; /**< offset into the buffer in dwords */ 25701e04c3fSmrg unsigned stream:2; /**< 0 to 3 */ 25801e04c3fSmrg}; 259af69d88dSmrg 260af69d88dSmrg/** 261af69d88dSmrg * Stream output for vertex transform feedback. 262af69d88dSmrg */ 263af69d88dSmrgstruct pipe_stream_output_info 264af69d88dSmrg{ 265af69d88dSmrg unsigned num_outputs; 266af69d88dSmrg /** stride for an entire vertex for each buffer in dwords */ 26701e04c3fSmrg uint16_t stride[PIPE_MAX_SO_BUFFERS]; 268af69d88dSmrg 269af69d88dSmrg /** 270af69d88dSmrg * Array of stream outputs, in the order they are to be written in. 271af69d88dSmrg * Selected components are tightly packed into the output buffer. 272af69d88dSmrg */ 27301e04c3fSmrg struct pipe_stream_output output[PIPE_MAX_SO_OUTPUTS]; 2744a49301eSmrg}; 2754a49301eSmrg 27601e04c3fSmrg/** 27701e04c3fSmrg * The 'type' parameter identifies whether the shader state contains TGSI 27801e04c3fSmrg * tokens, etc. If the driver returns 'PIPE_SHADER_IR_TGSI' for the 27901e04c3fSmrg * 'PIPE_SHADER_CAP_PREFERRED_IR' shader param, the ir will *always* be 28001e04c3fSmrg * 'PIPE_SHADER_IR_TGSI' and the tokens ptr will be valid. If the driver 28101e04c3fSmrg * requests a different 'pipe_shader_ir' type, then it must check the 'type' 28201e04c3fSmrg * enum to see if it is getting TGSI tokens or its preferred IR. 28301e04c3fSmrg * 28401e04c3fSmrg * TODO pipe_compute_state should probably get similar treatment to handle 28501e04c3fSmrg * multiple IR's in a cleaner way.. 28601e04c3fSmrg * 28701e04c3fSmrg * NOTE: since it is expected that the consumer will want to perform 28801e04c3fSmrg * additional passes on the nir_shader, the driver takes ownership of 2897ec681f3Smrg * the nir_shader. If gallium frontends need to hang on to the IR (for 29001e04c3fSmrg * example, variant management), it should use nir_shader_clone(). 29101e04c3fSmrg */ 2924a49301eSmrgstruct pipe_shader_state 2934a49301eSmrg{ 29401e04c3fSmrg enum pipe_shader_ir type; 29501e04c3fSmrg /* TODO move tokens into union. */ 2964a49301eSmrg const struct tgsi_token *tokens; 29701e04c3fSmrg union { 29801e04c3fSmrg void *native; 29901e04c3fSmrg void *nir; 30001e04c3fSmrg } ir; 301af69d88dSmrg struct pipe_stream_output_info stream_output; 3024a49301eSmrg}; 3034a49301eSmrg 30401e04c3fSmrgstatic inline void 30501e04c3fSmrgpipe_shader_state_from_tgsi(struct pipe_shader_state *state, 30601e04c3fSmrg const struct tgsi_token *tokens) 30701e04c3fSmrg{ 30801e04c3fSmrg state->type = PIPE_SHADER_IR_TGSI; 30901e04c3fSmrg state->tokens = tokens; 31001e04c3fSmrg memset(&state->stream_output, 0, sizeof(state->stream_output)); 31101e04c3fSmrg} 3124a49301eSmrg 3134a49301eSmrg 3144a49301eSmrgstruct pipe_stencil_state 3154a49301eSmrg{ 3164a49301eSmrg unsigned enabled:1; /**< stencil[0]: stencil enabled, stencil[1]: two-side enabled */ 3174a49301eSmrg unsigned func:3; /**< PIPE_FUNC_x */ 3184a49301eSmrg unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */ 3194a49301eSmrg unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */ 3204a49301eSmrg unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */ 321cdc920a0Smrg unsigned valuemask:8; 322cdc920a0Smrg unsigned writemask:8; 3234a49301eSmrg}; 3244a49301eSmrg 3254a49301eSmrg 3264a49301eSmrgstruct pipe_depth_stencil_alpha_state 3274a49301eSmrg{ 3284a49301eSmrg struct pipe_stencil_state stencil[2]; /**< [0] = front, [1] = back */ 3297ec681f3Smrg 3307ec681f3Smrg unsigned alpha_enabled:1; /**< alpha test enabled? */ 3317ec681f3Smrg unsigned alpha_func:3; /**< PIPE_FUNC_x */ 3327ec681f3Smrg 3337ec681f3Smrg unsigned depth_enabled:1; /**< depth test enabled? */ 3347ec681f3Smrg unsigned depth_writemask:1; /**< allow depth buffer writes? */ 3357ec681f3Smrg unsigned depth_func:3; /**< depth test func (PIPE_FUNC_x) */ 3367ec681f3Smrg unsigned depth_bounds_test:1; /**< depth bounds test enabled? */ 3377ec681f3Smrg 3387ec681f3Smrg float alpha_ref_value; /**< reference value */ 3397ec681f3Smrg double depth_bounds_min; /**< minimum depth bound */ 3407ec681f3Smrg double depth_bounds_max; /**< maximum depth bound */ 3414a49301eSmrg}; 3424a49301eSmrg 3434a49301eSmrg 344cdc920a0Smrgstruct pipe_rt_blend_state 3454a49301eSmrg{ 3464a49301eSmrg unsigned blend_enable:1; 3474a49301eSmrg 3484a49301eSmrg unsigned rgb_func:3; /**< PIPE_BLEND_x */ 3494a49301eSmrg unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 3504a49301eSmrg unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 3514a49301eSmrg 3524a49301eSmrg unsigned alpha_func:3; /**< PIPE_BLEND_x */ 3534a49301eSmrg unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ 3544a49301eSmrg unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ 3554a49301eSmrg 356cdc920a0Smrg unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ 357cdc920a0Smrg}; 358cdc920a0Smrg 35901e04c3fSmrg 360cdc920a0Smrgstruct pipe_blend_state 361cdc920a0Smrg{ 362cdc920a0Smrg unsigned independent_blend_enable:1; 3634a49301eSmrg unsigned logicop_enable:1; 3644a49301eSmrg unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ 3654a49301eSmrg unsigned dither:1; 3663464ebd5Sriastradh unsigned alpha_to_coverage:1; 3677ec681f3Smrg unsigned alpha_to_coverage_dither:1; 3683464ebd5Sriastradh unsigned alpha_to_one:1; 3697ec681f3Smrg unsigned max_rt:3; /* index of max rt, Ie. # of cbufs minus 1 */ 3707ec681f3Smrg unsigned advanced_blend_func:4; 371cdc920a0Smrg struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS]; 3724a49301eSmrg}; 3734a49301eSmrg 3744a49301eSmrg 3754a49301eSmrgstruct pipe_blend_color 3764a49301eSmrg{ 3774a49301eSmrg float color[4]; 3784a49301eSmrg}; 3794a49301eSmrg 38001e04c3fSmrg 381cdc920a0Smrgstruct pipe_stencil_ref 382cdc920a0Smrg{ 383cdc920a0Smrg ubyte ref_value[2]; 384cdc920a0Smrg}; 3854a49301eSmrg 38601e04c3fSmrg 38701e04c3fSmrg/** 38801e04c3fSmrg * Note that pipe_surfaces are "texture views for rendering" 38901e04c3fSmrg * and so in the case of ARB_framebuffer_no_attachment there 39001e04c3fSmrg * is no pipe_surface state available such that we may 39101e04c3fSmrg * extract the number of samples and layers. 39201e04c3fSmrg */ 3934a49301eSmrgstruct pipe_framebuffer_state 3944a49301eSmrg{ 39501e04c3fSmrg uint16_t width, height; 39601e04c3fSmrg uint16_t layers; /**< Number of layers in a no-attachment framebuffer */ 39701e04c3fSmrg ubyte samples; /**< Number of samples in a no-attachment framebuffer */ 3984a49301eSmrg 3993464ebd5Sriastradh /** multiple color buffers for multiple render targets */ 40001e04c3fSmrg ubyte nr_cbufs; 4014a49301eSmrg struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; 4024a49301eSmrg 4034a49301eSmrg struct pipe_surface *zsbuf; /**< Z/stencil buffer */ 4044a49301eSmrg}; 4054a49301eSmrg 4064a49301eSmrg 4074a49301eSmrg/** 4084a49301eSmrg * Texture sampler state. 4094a49301eSmrg */ 4104a49301eSmrgstruct pipe_sampler_state 4114a49301eSmrg{ 4124a49301eSmrg unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */ 4134a49301eSmrg unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */ 4144a49301eSmrg unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */ 41501e04c3fSmrg unsigned min_img_filter:1; /**< PIPE_TEX_FILTER_x */ 4164a49301eSmrg unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */ 41701e04c3fSmrg unsigned mag_img_filter:1; /**< PIPE_TEX_FILTER_x */ 4184a49301eSmrg unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ 4194a49301eSmrg unsigned compare_func:3; /**< PIPE_FUNC_x */ 4204a49301eSmrg unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ 42101e04c3fSmrg unsigned max_anisotropy:5; 4223464ebd5Sriastradh unsigned seamless_cube_map:1; 4237ec681f3Smrg unsigned border_color_is_integer:1; 4247ec681f3Smrg unsigned reduction_mode:2; /**< PIPE_TEX_REDUCTION_x */ 4257ec681f3Smrg unsigned pad:5; /**< take bits from this for new members */ 4264a49301eSmrg float lod_bias; /**< LOD/lambda bias */ 4274a49301eSmrg float min_lod, max_lod; /**< LOD clamp range, after bias */ 428af69d88dSmrg union pipe_color_union border_color; 4294a49301eSmrg}; 4304a49301eSmrg 43101e04c3fSmrgunion pipe_surface_desc { 43201e04c3fSmrg struct { 43301e04c3fSmrg unsigned level; 43401e04c3fSmrg unsigned first_layer:16; 43501e04c3fSmrg unsigned last_layer:16; 43601e04c3fSmrg } tex; 43701e04c3fSmrg struct { 43801e04c3fSmrg unsigned first_element; 43901e04c3fSmrg unsigned last_element; 44001e04c3fSmrg } buf; 44101e04c3fSmrg}; 4424a49301eSmrg 4434a49301eSmrg/** 4443464ebd5Sriastradh * A view into a texture that can be bound to a color render target / 4453464ebd5Sriastradh * depth stencil attachment point. 4464a49301eSmrg */ 4474a49301eSmrgstruct pipe_surface 4484a49301eSmrg{ 4494a49301eSmrg struct pipe_reference reference; 45001e04c3fSmrg enum pipe_format format:16; 45101e04c3fSmrg unsigned writable:1; /**< writable shader resource */ 4523464ebd5Sriastradh struct pipe_resource *texture; /**< resource into which this is a view */ 453af69d88dSmrg struct pipe_context *context; /**< context this surface belongs to */ 4543464ebd5Sriastradh 4553464ebd5Sriastradh /* XXX width/height should be removed */ 45601e04c3fSmrg uint16_t width; /**< logical width in pixels */ 45701e04c3fSmrg uint16_t height; /**< logical height in pixels */ 4583464ebd5Sriastradh 4599f464c52Smaya /** 4609f464c52Smaya * Number of samples for the surface. This will be 0 if rendering 4619f464c52Smaya * should use the resource's nr_samples, or another value if the resource 4629f464c52Smaya * is bound using FramebufferTexture2DMultisampleEXT. 4639f464c52Smaya */ 4649f464c52Smaya unsigned nr_samples:8; 4659f464c52Smaya 46601e04c3fSmrg union pipe_surface_desc u; 46701e04c3fSmrg}; 4683464ebd5Sriastradh 46901e04c3fSmrg 47001e04c3fSmrg/** 47101e04c3fSmrg * A view into a texture that can be bound to a shader stage. 47201e04c3fSmrg */ 47301e04c3fSmrgstruct pipe_sampler_view 47401e04c3fSmrg{ 4757ec681f3Smrg /* Put the refcount on its own cache line to prevent "False sharing". */ 4767ec681f3Smrg EXCLUSIVE_CACHELINE(struct pipe_reference reference); 4777ec681f3Smrg 47801e04c3fSmrg enum pipe_format format:15; /**< typed PIPE_FORMAT_x */ 47901e04c3fSmrg enum pipe_texture_target target:5; /**< PIPE_TEXTURE_x */ 48001e04c3fSmrg unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ 48101e04c3fSmrg unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ 48201e04c3fSmrg unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ 48301e04c3fSmrg unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */ 48401e04c3fSmrg struct pipe_resource *texture; /**< texture into which this is a view */ 48501e04c3fSmrg struct pipe_context *context; /**< context this view belongs to */ 4863464ebd5Sriastradh union { 4873464ebd5Sriastradh struct { 48801e04c3fSmrg unsigned first_layer:16; /**< first layer to use for array textures */ 48901e04c3fSmrg unsigned last_layer:16; /**< last layer to use for array textures */ 49001e04c3fSmrg unsigned first_level:8; /**< first mipmap level to use */ 49101e04c3fSmrg unsigned last_level:8; /**< last mipmap level to use */ 4923464ebd5Sriastradh } tex; 4933464ebd5Sriastradh struct { 49401e04c3fSmrg unsigned offset; /**< offset in bytes */ 49501e04c3fSmrg unsigned size; /**< size of the readable sub-range in bytes */ 4963464ebd5Sriastradh } buf; 4973464ebd5Sriastradh } u; 4984a49301eSmrg}; 4994a49301eSmrg 5004a49301eSmrg 5014a49301eSmrg/** 50201e04c3fSmrg * A description of a buffer or texture image that can be bound to a shader 50301e04c3fSmrg * stage. 5044a49301eSmrg */ 50501e04c3fSmrgstruct pipe_image_view 5064a49301eSmrg{ 50701e04c3fSmrg struct pipe_resource *resource; /**< resource into which this is a view */ 5083464ebd5Sriastradh enum pipe_format format; /**< typed PIPE_FORMAT_x */ 50901e04c3fSmrg uint16_t access; /**< PIPE_IMAGE_ACCESS_x */ 51001e04c3fSmrg uint16_t shader_access; /**< PIPE_IMAGE_ACCESS_x */ 51101e04c3fSmrg 5123464ebd5Sriastradh union { 5133464ebd5Sriastradh struct { 5143464ebd5Sriastradh unsigned first_layer:16; /**< first layer to use for array textures */ 5153464ebd5Sriastradh unsigned last_layer:16; /**< last layer to use for array textures */ 51601e04c3fSmrg unsigned level:8; /**< mipmap level to use */ 5173464ebd5Sriastradh } tex; 5183464ebd5Sriastradh struct { 51901e04c3fSmrg unsigned offset; /**< offset in bytes */ 52001e04c3fSmrg unsigned size; /**< size of the accessible sub-range in bytes */ 5213464ebd5Sriastradh } buf; 5223464ebd5Sriastradh } u; 5233464ebd5Sriastradh}; 5243464ebd5Sriastradh 5254a49301eSmrg 5263464ebd5Sriastradh/** 5273464ebd5Sriastradh * Subregion of 1D/2D/3D image resource. 5283464ebd5Sriastradh */ 5293464ebd5Sriastradhstruct pipe_box 5303464ebd5Sriastradh{ 53101e04c3fSmrg /* Fields only used by textures use int16_t instead of int. 53201e04c3fSmrg * x and width are used by buffers, so they need the full 32-bit range. 53301e04c3fSmrg */ 534af69d88dSmrg int x; 53501e04c3fSmrg int16_t y; 53601e04c3fSmrg int16_t z; 537af69d88dSmrg int width; 53801e04c3fSmrg int16_t height; 53901e04c3fSmrg int16_t depth; 5404a49301eSmrg}; 5414a49301eSmrg 5424a49301eSmrg 5434a49301eSmrg/** 5443464ebd5Sriastradh * A memory object/resource such as a vertex buffer or texture. 5454a49301eSmrg */ 5463464ebd5Sriastradhstruct pipe_resource 5473464ebd5Sriastradh{ 5487ec681f3Smrg /* Put the refcount on its own cache line to prevent "False sharing". */ 5497ec681f3Smrg EXCLUSIVE_CACHELINE(struct pipe_reference reference); 5504a49301eSmrg 55101e04c3fSmrg unsigned width0; /**< Used by both buffers and textures. */ 55201e04c3fSmrg uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */ 55301e04c3fSmrg uint16_t depth0; 55401e04c3fSmrg uint16_t array_size; 5554a49301eSmrg 55601e04c3fSmrg enum pipe_format format:16; /**< PIPE_FORMAT_x */ 55701e04c3fSmrg enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */ 5584a49301eSmrg unsigned last_level:8; /**< Index of last mipmap level present/defined */ 5594a49301eSmrg 56001e04c3fSmrg /** Number of samples determining quality, driving rasterizer, shading, 56101e04c3fSmrg * and framebuffer. 56201e04c3fSmrg */ 56301e04c3fSmrg unsigned nr_samples:8; 56401e04c3fSmrg 56501e04c3fSmrg /** Multiple samples within a pixel can have the same value. 56601e04c3fSmrg * nr_storage_samples determines how many slots for different values 56701e04c3fSmrg * there are per pixel. Only color buffers can set this lower than 56801e04c3fSmrg * nr_samples. 56901e04c3fSmrg */ 57001e04c3fSmrg unsigned nr_storage_samples:8; 57101e04c3fSmrg 57201e04c3fSmrg unsigned usage:8; /**< PIPE_USAGE_x (not a bitmask) */ 5733464ebd5Sriastradh unsigned bind; /**< bitmask of PIPE_BIND_x */ 5743464ebd5Sriastradh unsigned flags; /**< bitmask of PIPE_RESOURCE_FLAG_x */ 57501e04c3fSmrg 57601e04c3fSmrg /** 57701e04c3fSmrg * For planar images, ie. YUV EGLImage external, etc, pointer to the 57801e04c3fSmrg * next plane. 57901e04c3fSmrg */ 58001e04c3fSmrg struct pipe_resource *next; 58101e04c3fSmrg /* The screen pointer should be last for optimal structure packing. */ 58201e04c3fSmrg struct pipe_screen *screen; /**< screen that this texture belongs to */ 5833464ebd5Sriastradh}; 5844a49301eSmrg 5857ec681f3Smrg/** 5867ec681f3Smrg * Opaque object used for separate resource/memory allocations. 5877ec681f3Smrg */ 5887ec681f3Smrgstruct pipe_memory_allocation; 5893464ebd5Sriastradh 5903464ebd5Sriastradh/** 5913464ebd5Sriastradh * Transfer object. For data transfer to/from a resource. 5923464ebd5Sriastradh */ 5933464ebd5Sriastradhstruct pipe_transfer 5943464ebd5Sriastradh{ 5953464ebd5Sriastradh struct pipe_resource *resource; /**< resource to transfer to/from */ 5967ec681f3Smrg enum pipe_map_flags usage:24; 5977ec681f3Smrg unsigned level:8; /**< texture mipmap level */ 5983464ebd5Sriastradh struct pipe_box box; /**< region of the resource to access */ 5993464ebd5Sriastradh unsigned stride; /**< row stride in bytes */ 6003464ebd5Sriastradh unsigned layer_stride; /**< image/layer stride in bytes */ 6017ec681f3Smrg 6027ec681f3Smrg /* Offset into a driver-internal staging buffer to make use of unused 6037ec681f3Smrg * padding in this structure. 6047ec681f3Smrg */ 6057ec681f3Smrg unsigned offset; 6063464ebd5Sriastradh}; 6073464ebd5Sriastradh 6083464ebd5Sriastradh 6094a49301eSmrg/** 6104a49301eSmrg * A vertex buffer. Typically, all the vertex data/attributes for 6114a49301eSmrg * drawing something will be in one buffer. But it's also possible, for 6124a49301eSmrg * example, to put colors in one buffer and texcoords in another. 6134a49301eSmrg */ 6144a49301eSmrgstruct pipe_vertex_buffer 6154a49301eSmrg{ 61601e04c3fSmrg uint16_t stride; /**< stride to same attrib in next vertex, in bytes */ 61701e04c3fSmrg bool is_user_buffer; 6184a49301eSmrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 61901e04c3fSmrg 62001e04c3fSmrg union { 62101e04c3fSmrg struct pipe_resource *resource; /**< the actual buffer */ 62201e04c3fSmrg const void *user; /**< pointer to a user buffer */ 62301e04c3fSmrg } buffer; 624af69d88dSmrg}; 625af69d88dSmrg 626af69d88dSmrg 627af69d88dSmrg/** 628af69d88dSmrg * A constant buffer. A subrange of an existing buffer can be set 629af69d88dSmrg * as a constant buffer. 630af69d88dSmrg */ 63101e04c3fSmrgstruct pipe_constant_buffer 63201e04c3fSmrg{ 633af69d88dSmrg struct pipe_resource *buffer; /**< the actual buffer */ 634af69d88dSmrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 635af69d88dSmrg unsigned buffer_size; /**< how much data can be read in shader */ 636af69d88dSmrg const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */ 637af69d88dSmrg}; 638af69d88dSmrg 639af69d88dSmrg 64001e04c3fSmrg/** 64101e04c3fSmrg * An untyped shader buffer supporting loads, stores, and atomics. 64201e04c3fSmrg */ 64301e04c3fSmrgstruct pipe_shader_buffer { 64401e04c3fSmrg struct pipe_resource *buffer; /**< the actual buffer */ 64501e04c3fSmrg unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ 64601e04c3fSmrg unsigned buffer_size; /**< how much data can be read in shader */ 64701e04c3fSmrg}; 64801e04c3fSmrg 64901e04c3fSmrg 650af69d88dSmrg/** 651af69d88dSmrg * A stream output target. The structure specifies the range vertices can 652af69d88dSmrg * be written to. 653af69d88dSmrg * 654af69d88dSmrg * In addition to that, the structure should internally maintain the offset 655af69d88dSmrg * into the buffer, which should be incremented everytime something is written 656af69d88dSmrg * (appended) to it. The internal offset is buffer_offset + how many bytes 657af69d88dSmrg * have been written. The internal offset can be stored on the device 658af69d88dSmrg * and the CPU actually doesn't have to query it. 659af69d88dSmrg * 660af69d88dSmrg * Note that the buffer_size variable is actually specifying the available 66101e04c3fSmrg * space in the buffer, not the size of the attached buffer. 66201e04c3fSmrg * In other words in majority of cases buffer_size would simply be 663af69d88dSmrg * 'buffer->width0 - buffer_offset', so buffer_size refers to the size 664af69d88dSmrg * of the buffer left, after accounting for buffer offset, for stream output 665af69d88dSmrg * to write to. 666af69d88dSmrg * 667af69d88dSmrg * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have 668af69d88dSmrg * actually been written. 669af69d88dSmrg */ 670af69d88dSmrgstruct pipe_stream_output_target 671af69d88dSmrg{ 672af69d88dSmrg struct pipe_reference reference; 673af69d88dSmrg struct pipe_resource *buffer; /**< the output buffer */ 674af69d88dSmrg struct pipe_context *context; /**< context this SO target belongs to */ 675af69d88dSmrg 676af69d88dSmrg unsigned buffer_offset; /**< offset where data should be written, in bytes */ 677af69d88dSmrg unsigned buffer_size; /**< how much data is allowed to be written */ 6784a49301eSmrg}; 6794a49301eSmrg 6804a49301eSmrg 6814a49301eSmrg/** 6824a49301eSmrg * Information to describe a vertex attribute (position, color, etc) 6834a49301eSmrg */ 6844a49301eSmrgstruct pipe_vertex_element 6854a49301eSmrg{ 6864a49301eSmrg /** Offset of this attribute, in bytes, from the start of the vertex */ 6877ec681f3Smrg uint16_t src_offset; 68801e04c3fSmrg 68901e04c3fSmrg /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does 69001e04c3fSmrg * this attribute live in? 69101e04c3fSmrg */ 6927ec681f3Smrg uint8_t vertex_buffer_index:7; 6937ec681f3Smrg 6947ec681f3Smrg /** 6957ec681f3Smrg * Whether this element refers to a dual-slot vertex shader input. 6967ec681f3Smrg * The purpose of this field is to do dual-slot lowering when the CSO is 6977ec681f3Smrg * created instead of during every state change. 6987ec681f3Smrg * 6997ec681f3Smrg * It's lowered by util_lower_uint64_vertex_elements. 7007ec681f3Smrg */ 7017ec681f3Smrg bool dual_slot:1; 70201e04c3fSmrg 7037ec681f3Smrg /** 7047ec681f3Smrg * This has only 8 bits because all vertex formats should be <= 255. 7057ec681f3Smrg */ 7067ec681f3Smrg uint8_t src_format; /* low 8 bits of enum pipe_format. */ 7074a49301eSmrg 708cdc920a0Smrg /** Instance data rate divisor. 0 means this is per-vertex data, 709cdc920a0Smrg * n means per-instance data used for n consecutive instances (n > 0). 710cdc920a0Smrg */ 711cdc920a0Smrg unsigned instance_divisor; 7123464ebd5Sriastradh}; 7133464ebd5Sriastradh 7147ec681f3Smrg/** 7157ec681f3Smrg * Opaque refcounted constant state object encapsulating a vertex buffer, 7167ec681f3Smrg * index buffer, and vertex elements. Used by display lists to bind those 7177ec681f3Smrg * states and pass buffer references quickly. 7187ec681f3Smrg * 7197ec681f3Smrg * The state contains 1 index buffer, 0 or 1 vertex buffer, and 0 or more 7207ec681f3Smrg * vertex elements. 7217ec681f3Smrg * 7227ec681f3Smrg * Constraints on the buffers to get the fastest codepath: 7237ec681f3Smrg * - All buffer contents are considered immutable and read-only after 7247ec681f3Smrg * initialization. This implies the following things. 7257ec681f3Smrg * - No place is required to track whether these buffers are busy. 7267ec681f3Smrg * - All CPU mappings of these buffers can be forced to UNSYNCHRONIZED by 7277ec681f3Smrg * both drivers and common code unconditionally. 7287ec681f3Smrg * - Buffer invalidation can be skipped by both drivers and common code 7297ec681f3Smrg * unconditionally. 7307ec681f3Smrg */ 7317ec681f3Smrgstruct pipe_vertex_state { 7327ec681f3Smrg struct pipe_reference reference; 7337ec681f3Smrg struct pipe_screen *screen; 7347ec681f3Smrg 7357ec681f3Smrg /* The following structure is used as a key for util_vertex_state_cache 7367ec681f3Smrg * to deduplicate identical state objects and thus enable more 7377ec681f3Smrg * opportunities for draw merging. 7387ec681f3Smrg */ 7397ec681f3Smrg struct { 7407ec681f3Smrg struct pipe_resource *indexbuf; 7417ec681f3Smrg struct pipe_vertex_buffer vbuffer; 7427ec681f3Smrg unsigned num_elements; 7437ec681f3Smrg struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS]; 7447ec681f3Smrg uint32_t full_velem_mask; 7457ec681f3Smrg } input; 7467ec681f3Smrg}; 7473464ebd5Sriastradh 74801e04c3fSmrgstruct pipe_draw_indirect_info 7493464ebd5Sriastradh{ 75001e04c3fSmrg unsigned offset; /**< must be 4 byte aligned */ 75101e04c3fSmrg unsigned stride; /**< must be 4 byte aligned */ 75201e04c3fSmrg unsigned draw_count; /**< number of indirect draws */ 75301e04c3fSmrg unsigned indirect_draw_count_offset; /**< must be 4 byte aligned */ 75401e04c3fSmrg 75501e04c3fSmrg /* Indirect draw parameters resource is laid out as follows: 75601e04c3fSmrg * 75701e04c3fSmrg * if using indexed drawing: 75801e04c3fSmrg * struct { 75901e04c3fSmrg * uint32_t count; 76001e04c3fSmrg * uint32_t instance_count; 76101e04c3fSmrg * uint32_t start; 76201e04c3fSmrg * int32_t index_bias; 76301e04c3fSmrg * uint32_t start_instance; 76401e04c3fSmrg * }; 76501e04c3fSmrg * otherwise: 76601e04c3fSmrg * struct { 76701e04c3fSmrg * uint32_t count; 76801e04c3fSmrg * uint32_t instance_count; 76901e04c3fSmrg * uint32_t start; 77001e04c3fSmrg * uint32_t start_instance; 77101e04c3fSmrg * }; 7727ec681f3Smrg * 7737ec681f3Smrg * If NULL, count_from_stream_output != NULL. 77401e04c3fSmrg */ 77501e04c3fSmrg struct pipe_resource *buffer; 77601e04c3fSmrg 77701e04c3fSmrg /* Indirect draw count resource: If not NULL, contains a 32-bit value which 77801e04c3fSmrg * is to be used as the real draw_count. 77901e04c3fSmrg */ 78001e04c3fSmrg struct pipe_resource *indirect_draw_count; 7817ec681f3Smrg 7827ec681f3Smrg /** 7837ec681f3Smrg * Stream output target. If not NULL, it's used to provide the 'count' 7847ec681f3Smrg * parameter based on the number vertices captured by the stream output 7857ec681f3Smrg * stage. (or generally, based on the number of bytes captured) 7867ec681f3Smrg * 7877ec681f3Smrg * Only 'mode', 'start_instance', and 'instance_count' are taken into 7887ec681f3Smrg * account, all the other variables from pipe_draw_info are ignored. 7897ec681f3Smrg * 7907ec681f3Smrg * 'start' is implicitly 0 and 'count' is set as discussed above. 7917ec681f3Smrg * The draw command is non-indexed. 7927ec681f3Smrg * 7937ec681f3Smrg * Note that this only provides the count. The vertex buffers must 7947ec681f3Smrg * be set via set_vertex_buffers manually. 7957ec681f3Smrg */ 7967ec681f3Smrg struct pipe_stream_output_target *count_from_stream_output; 7977ec681f3Smrg}; 7987ec681f3Smrg 7997ec681f3Smrgstruct pipe_draw_start_count_bias { 8007ec681f3Smrg unsigned start; 8017ec681f3Smrg unsigned count; 8027ec681f3Smrg int index_bias; /**< a bias to be added to each index */ 8033464ebd5Sriastradh}; 8043464ebd5Sriastradh 8057ec681f3Smrg/** 8067ec681f3Smrg * Draw vertex state description. It's translated to pipe_draw_info as follows: 8077ec681f3Smrg * - mode comes from this structure 8087ec681f3Smrg * - index_size is 4 8097ec681f3Smrg * - instance_count is 1 8107ec681f3Smrg * - index.resource comes from pipe_vertex_state 8117ec681f3Smrg * - everything else is 0 8127ec681f3Smrg */ 8137ec681f3Smrgstruct pipe_draw_vertex_state_info { 8147ec681f3Smrg#if defined(__GNUC__) 8157ec681f3Smrg /* sizeof(mode) == 1 because it's a packed enum. */ 8167ec681f3Smrg enum pipe_prim_type mode; /**< the mode of the primitive */ 8177ec681f3Smrg#else 8187ec681f3Smrg /* sizeof(mode) == 1 is required by draw merging in u_threaded_context. */ 8197ec681f3Smrg uint8_t mode; /**< the mode of the primitive */ 8207ec681f3Smrg#endif 8217ec681f3Smrg bool take_vertex_state_ownership; /**< for skipping reference counting */ 8227ec681f3Smrg}; 8233464ebd5Sriastradh 8243464ebd5Sriastradh/** 8253464ebd5Sriastradh * Information to describe a draw_vbo call. 8263464ebd5Sriastradh */ 8273464ebd5Sriastradhstruct pipe_draw_info 8283464ebd5Sriastradh{ 8297ec681f3Smrg#if defined(__GNUC__) 8307ec681f3Smrg /* sizeof(mode) == 1 because it's a packed enum. */ 8317ec681f3Smrg enum pipe_prim_type mode; /**< the mode of the primitive */ 8327ec681f3Smrg#else 8337ec681f3Smrg /* sizeof(mode) == 1 is required by draw merging in u_threaded_context. */ 8347ec681f3Smrg uint8_t mode; /**< the mode of the primitive */ 8357ec681f3Smrg#endif 8367ec681f3Smrg uint8_t index_size; /**< if 0, the draw is not indexed. */ 8377ec681f3Smrg uint8_t view_mask; /**< mask of multiviews for this draw */ 8387ec681f3Smrg bool primitive_restart:1; 8397ec681f3Smrg bool has_user_indices:1; /**< if true, use index.user_buffer */ 8407ec681f3Smrg bool index_bounds_valid:1; /**< whether min_index and max_index are valid; 8417ec681f3Smrg they're always invalid if index_size == 0 */ 8427ec681f3Smrg bool increment_draw_id:1; /**< whether drawid increments for direct draws */ 8437ec681f3Smrg bool take_index_buffer_ownership:1; /**< callee inherits caller's refcount 8447ec681f3Smrg (no need to reference indexbuf, but still needs to unreference it) */ 8457ec681f3Smrg bool index_bias_varies:1; /**< true if index_bias varies between draws */ 8467ec681f3Smrg uint8_t _pad:2; 8473464ebd5Sriastradh 8483464ebd5Sriastradh unsigned start_instance; /**< first instance id */ 8493464ebd5Sriastradh unsigned instance_count; /**< number of instances */ 8503464ebd5Sriastradh 8513464ebd5Sriastradh /** 8523464ebd5Sriastradh * Primitive restart enable/index (only applies to indexed drawing) 8533464ebd5Sriastradh */ 8543464ebd5Sriastradh unsigned restart_index; 855af69d88dSmrg 8567ec681f3Smrg /* Pointers must be placed appropriately for optimal structure packing on 8577ec681f3Smrg * 64-bit CPUs. 8587ec681f3Smrg */ 85901e04c3fSmrg 86001e04c3fSmrg /** 86101e04c3fSmrg * An index buffer. When an index buffer is bound, all indices to vertices 86201e04c3fSmrg * will be looked up from the buffer. 86301e04c3fSmrg * 86401e04c3fSmrg * If has_user_indices, use index.user, else use index.resource. 86501e04c3fSmrg */ 86601e04c3fSmrg union { 86701e04c3fSmrg struct pipe_resource *resource; /**< real buffer */ 8687ec681f3Smrg struct gl_buffer_object *gl_bo; /**< for the GL frontend, not passed to drivers */ 86901e04c3fSmrg const void *user; /**< pointer to a user buffer */ 87001e04c3fSmrg } index; 87101e04c3fSmrg 8727ec681f3Smrg /* These must be last for better packing in u_threaded_context. */ 8737ec681f3Smrg unsigned min_index; /**< the min index */ 8747ec681f3Smrg unsigned max_index; /**< the max index */ 875af69d88dSmrg}; 876af69d88dSmrg 877af69d88dSmrg 878af69d88dSmrg/** 879af69d88dSmrg * Information to describe a blit call. 880af69d88dSmrg */ 881af69d88dSmrgstruct pipe_blit_info 882af69d88dSmrg{ 883af69d88dSmrg struct { 884af69d88dSmrg struct pipe_resource *resource; 885af69d88dSmrg unsigned level; 886af69d88dSmrg struct pipe_box box; /**< negative width, height only legal for src */ 887af69d88dSmrg /* For pipe_surface-like format casting: */ 888af69d88dSmrg enum pipe_format format; /**< must be supported for sampling (src) 889af69d88dSmrg or rendering (dst), ZS is always supported */ 890af69d88dSmrg } dst, src; 891af69d88dSmrg 892af69d88dSmrg unsigned mask; /**< bitmask of PIPE_MASK_R/G/B/A/Z/S */ 893af69d88dSmrg unsigned filter; /**< PIPE_TEX_FILTER_* */ 8947ec681f3Smrg bool sample0_only; 8957ec681f3Smrg bool scissor_enable; 896af69d88dSmrg struct pipe_scissor_state scissor; 897af69d88dSmrg 89801e04c3fSmrg /* Window rectangles can either be inclusive or exclusive. */ 8997ec681f3Smrg bool window_rectangle_include; 90001e04c3fSmrg unsigned num_window_rectangles; 90101e04c3fSmrg struct pipe_scissor_state window_rectangles[PIPE_MAX_WINDOW_RECTANGLES]; 90201e04c3fSmrg 9037ec681f3Smrg bool render_condition_enable; /**< whether the blit should honor the 9047ec681f3Smrg current render condition */ 9057ec681f3Smrg bool alpha_blend; /* dst.rgb = src.rgb * src.a + dst.rgb * (1 - src.a) */ 9067ec681f3Smrg bool is_dri_blit_image; 9074a49301eSmrg}; 9084a49301eSmrg 90901e04c3fSmrg/** 91001e04c3fSmrg * Information to describe a launch_grid call. 91101e04c3fSmrg */ 91201e04c3fSmrgstruct pipe_grid_info 91301e04c3fSmrg{ 91401e04c3fSmrg /** 91501e04c3fSmrg * For drivers that use PIPE_SHADER_IR_NATIVE as their prefered IR, this 91601e04c3fSmrg * value will be the index of the kernel in the opencl.kernels metadata 91701e04c3fSmrg * list. 91801e04c3fSmrg */ 91901e04c3fSmrg uint32_t pc; 92001e04c3fSmrg 92101e04c3fSmrg /** 92201e04c3fSmrg * Will be used to initialize the INPUT resource, and it should point to a 92301e04c3fSmrg * buffer of at least pipe_compute_state::req_input_mem bytes. 92401e04c3fSmrg */ 92501e04c3fSmrg void *input; 92601e04c3fSmrg 92701e04c3fSmrg /** 92801e04c3fSmrg * Grid number of dimensions, 1-3, e.g. the work_dim parameter passed to 92901e04c3fSmrg * clEnqueueNDRangeKernel. Note block[] and grid[] must be padded with 93001e04c3fSmrg * 1 for non-used dimensions. 93101e04c3fSmrg */ 93201e04c3fSmrg uint work_dim; 93301e04c3fSmrg 93401e04c3fSmrg /** 93501e04c3fSmrg * Determine the layout of the working block (in thread units) to be used. 93601e04c3fSmrg */ 93701e04c3fSmrg uint block[3]; 93801e04c3fSmrg 9399f464c52Smaya /** 9409f464c52Smaya * last_block allows disabling threads at the farthermost grid boundary. 9419f464c52Smaya * Full blocks as specified by "block" are launched, but the threads 9429f464c52Smaya * outside of "last_block" dimensions are disabled. 9439f464c52Smaya * 9449f464c52Smaya * If a block touches the grid boundary in the i-th axis, threads with 9459f464c52Smaya * THREAD_ID[i] >= last_block[i] are disabled. 9469f464c52Smaya * 9479f464c52Smaya * If last_block[i] is 0, it has the same behavior as last_block[i] = block[i], 9489f464c52Smaya * meaning no effect. 9499f464c52Smaya * 9509f464c52Smaya * It's equivalent to doing this at the beginning of the compute shader: 9519f464c52Smaya * 9529f464c52Smaya * for (i = 0; i < 3; i++) { 9539f464c52Smaya * if (block_id[i] == grid[i] - 1 && 9549f464c52Smaya * last_block[i] && thread_id[i] >= last_block[i]) 9559f464c52Smaya * return; 9569f464c52Smaya * } 9579f464c52Smaya */ 9589f464c52Smaya uint last_block[3]; 9599f464c52Smaya 96001e04c3fSmrg /** 96101e04c3fSmrg * Determine the layout of the grid (in block units) to be used. 96201e04c3fSmrg */ 96301e04c3fSmrg uint grid[3]; 96401e04c3fSmrg 9657ec681f3Smrg /** 9667ec681f3Smrg * Base offsets to launch grids from 9677ec681f3Smrg */ 9687ec681f3Smrg uint grid_base[3]; 9697ec681f3Smrg 97001e04c3fSmrg /* Indirect compute parameters resource: If not NULL, block sizes are taken 97101e04c3fSmrg * from this buffer instead, which is laid out as follows: 97201e04c3fSmrg * 97301e04c3fSmrg * struct { 97401e04c3fSmrg * uint32_t num_blocks_x; 97501e04c3fSmrg * uint32_t num_blocks_y; 97601e04c3fSmrg * uint32_t num_blocks_z; 97701e04c3fSmrg * }; 97801e04c3fSmrg */ 97901e04c3fSmrg struct pipe_resource *indirect; 98001e04c3fSmrg unsigned indirect_offset; /**< must be 4 byte aligned */ 98101e04c3fSmrg}; 9824a49301eSmrg 983af69d88dSmrg/** 9847ec681f3Smrg * Structure used as a header for serialized compute programs. 985af69d88dSmrg */ 9867ec681f3Smrgstruct pipe_binary_program_header 987af69d88dSmrg{ 988af69d88dSmrg uint32_t num_bytes; /**< Number of bytes in the LLVM bytecode program. */ 9897ec681f3Smrg char blob[]; 990af69d88dSmrg}; 991af69d88dSmrg 992af69d88dSmrgstruct pipe_compute_state 993af69d88dSmrg{ 99401e04c3fSmrg enum pipe_shader_ir ir_type; /**< IR type contained in prog. */ 995af69d88dSmrg const void *prog; /**< Compute program to be executed. */ 996af69d88dSmrg unsigned req_local_mem; /**< Required size of the LOCAL resource. */ 997af69d88dSmrg unsigned req_private_mem; /**< Required size of the PRIVATE resource. */ 998af69d88dSmrg unsigned req_input_mem; /**< Required size of the INPUT resource. */ 999af69d88dSmrg}; 1000af69d88dSmrg 100101e04c3fSmrg/** 100201e04c3fSmrg * Structure that contains a callback for debug messages from the driver back 10037ec681f3Smrg * to the gallium frontend. 100401e04c3fSmrg */ 100501e04c3fSmrgstruct pipe_debug_callback 100601e04c3fSmrg{ 100701e04c3fSmrg /** 100801e04c3fSmrg * When set to \c true, the callback may be called asynchronously from a 100901e04c3fSmrg * driver-created thread. 101001e04c3fSmrg */ 101101e04c3fSmrg bool async; 101201e04c3fSmrg 101301e04c3fSmrg /** 101401e04c3fSmrg * Callback for the driver to report debug/performance/etc information back 10157ec681f3Smrg * to the gallium frontend. 101601e04c3fSmrg * 101701e04c3fSmrg * \param data user-supplied data pointer 101801e04c3fSmrg * \param id message type identifier, if pointed value is 0, then a 101901e04c3fSmrg * new id is assigned 102001e04c3fSmrg * \param type PIPE_DEBUG_TYPE_* 102101e04c3fSmrg * \param format printf-style format string 102201e04c3fSmrg * \param args args for format string 102301e04c3fSmrg */ 102401e04c3fSmrg void (*debug_message)(void *data, 102501e04c3fSmrg unsigned *id, 102601e04c3fSmrg enum pipe_debug_type type, 102701e04c3fSmrg const char *fmt, 102801e04c3fSmrg va_list args); 102901e04c3fSmrg void *data; 103001e04c3fSmrg}; 103101e04c3fSmrg 103201e04c3fSmrg/** 103301e04c3fSmrg * Structure that contains a callback for device reset messages from the driver 10347ec681f3Smrg * back to the gallium frontend. 103501e04c3fSmrg * 103601e04c3fSmrg * The callback must not be called from driver-created threads. 103701e04c3fSmrg */ 103801e04c3fSmrgstruct pipe_device_reset_callback 103901e04c3fSmrg{ 104001e04c3fSmrg /** 104101e04c3fSmrg * Callback for the driver to report when a device reset is detected. 104201e04c3fSmrg * 104301e04c3fSmrg * \param data user-supplied data pointer 104401e04c3fSmrg * \param status PIPE_*_RESET 104501e04c3fSmrg */ 104601e04c3fSmrg void (*reset)(void *data, enum pipe_reset_status status); 104701e04c3fSmrg 104801e04c3fSmrg void *data; 104901e04c3fSmrg}; 105001e04c3fSmrg 105101e04c3fSmrg/** 105201e04c3fSmrg * Information about memory usage. All sizes are in kilobytes. 105301e04c3fSmrg */ 105401e04c3fSmrgstruct pipe_memory_info 105501e04c3fSmrg{ 105601e04c3fSmrg unsigned total_device_memory; /**< size of device memory, e.g. VRAM */ 105701e04c3fSmrg unsigned avail_device_memory; /**< free device memory at the moment */ 105801e04c3fSmrg unsigned total_staging_memory; /**< size of staging memory, e.g. GART */ 105901e04c3fSmrg unsigned avail_staging_memory; /**< free staging memory at the moment */ 106001e04c3fSmrg unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */ 106101e04c3fSmrg unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */ 106201e04c3fSmrg}; 106301e04c3fSmrg 106401e04c3fSmrg/** 106501e04c3fSmrg * Structure that contains information about external memory 106601e04c3fSmrg */ 106701e04c3fSmrgstruct pipe_memory_object 106801e04c3fSmrg{ 106901e04c3fSmrg bool dedicated; 107001e04c3fSmrg}; 107101e04c3fSmrg 10724a49301eSmrg#ifdef __cplusplus 10734a49301eSmrg} 10744a49301eSmrg#endif 107501e04c3fSmrg 10764a49301eSmrg#endif 1077