Path: blob/21.2-virgl/src/gallium/include/pipe/p_state.h
4566 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/262728/**29* @file30*31* Abstract graphics pipe state objects.32*33* Basic notes:34* 1. Want compact representations, so we use bitfields.35* 2. Put bitfields before other (GLfloat) fields.36* 3. enum bitfields need to be at least one bit extra in size so the most37* significant bit is zero. MSVC treats enums as signed so if the high38* bit is set, the value will be interpreted as a negative number.39* That causes trouble in various places.40*/414243#ifndef PIPE_STATE_H44#define PIPE_STATE_H4546#include "p_compiler.h"47#include "p_defines.h"48#include "p_format.h"495051#ifdef __cplusplus52extern "C" {53#endif5455struct gl_buffer_object;5657/**58* Implementation limits59*/60#define PIPE_MAX_ATTRIBS 3261#define PIPE_MAX_CLIP_PLANES 862#define PIPE_MAX_COLOR_BUFS 863#define PIPE_MAX_CONSTANT_BUFFERS 3264#define PIPE_MAX_SAMPLERS 3265#define PIPE_MAX_SHADER_INPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */66#define PIPE_MAX_SHADER_OUTPUTS 80 /* 32 GENERIC + 32 PATCH + 16 others */67#define PIPE_MAX_SHADER_SAMPLER_VIEWS 12868#define PIPE_MAX_SHADER_BUFFERS 3269#define PIPE_MAX_SHADER_IMAGES 3270#define PIPE_MAX_TEXTURE_LEVELS 1671#define PIPE_MAX_SO_BUFFERS 472#define PIPE_MAX_SO_OUTPUTS 6473#define PIPE_MAX_VIEWPORTS 1674#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 875#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 276#define PIPE_MAX_WINDOW_RECTANGLES 877#define PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE 47879#define PIPE_MAX_HW_ATOMIC_BUFFERS 3280#define PIPE_MAX_VERTEX_STREAMS 48182struct pipe_reference83{84int32_t count; /* atomic */85};86878889/**90* Primitive (point/line/tri) rasterization info91*/92struct pipe_rasterizer_state93{94unsigned flatshade:1;95unsigned light_twoside:1;96unsigned clamp_vertex_color:1;97unsigned clamp_fragment_color:1;98unsigned front_ccw:1;99unsigned cull_face:2; /**< PIPE_FACE_x */100unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */101unsigned fill_back:2; /**< PIPE_POLYGON_MODE_x */102unsigned offset_point:1;103unsigned offset_line:1;104unsigned offset_tri:1;105unsigned scissor:1;106unsigned poly_smooth:1;107unsigned poly_stipple_enable:1;108unsigned point_smooth:1;109unsigned sprite_coord_mode:1; /**< PIPE_SPRITE_COORD_ */110unsigned point_quad_rasterization:1; /** points rasterized as quads or points */111unsigned point_tri_clip:1; /** large points clipped as tris or points */112unsigned point_size_per_vertex:1; /**< size computed in vertex shader */113unsigned multisample:1; /* XXX maybe more ms state in future */114unsigned no_ms_sample_mask_out:1;115unsigned force_persample_interp:1;116unsigned line_smooth:1;117unsigned line_stipple_enable:1;118unsigned line_last_pixel:1;119unsigned line_rectangular:1; /** lines rasterized as rectangles or parallelograms */120unsigned conservative_raster_mode:2; /**< PIPE_CONSERVATIVE_RASTER_x */121122/**123* Use the first vertex of a primitive as the provoking vertex for124* flat shading.125*/126unsigned flatshade_first:1;127128unsigned half_pixel_center:1;129unsigned bottom_edge_rule:1;130131/*132* Conservative rasterization subpixel precision bias in bits133*/134unsigned subpixel_precision_x:4;135unsigned subpixel_precision_y:4;136137/**138* When true, rasterization is disabled and no pixels are written.139* This only makes sense with the Stream Out functionality.140*/141unsigned rasterizer_discard:1;142143/**144* Exposed by PIPE_CAP_TILE_RASTER_ORDER. When true,145* tile_raster_order_increasing_* indicate the order that the rasterizer146* should render tiles, to meet the requirements of147* GL_MESA_tile_raster_order.148*/149unsigned tile_raster_order_fixed:1;150unsigned tile_raster_order_increasing_x:1;151unsigned tile_raster_order_increasing_y:1;152153/**154* When false, depth clipping is disabled and the depth value will be155* clamped later at the per-pixel level before depth testing.156* This depends on PIPE_CAP_DEPTH_CLIP_DISABLE.157*158* If PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE is unsupported, depth_clip_near159* is equal to depth_clip_far.160*/161unsigned depth_clip_near:1;162unsigned depth_clip_far:1;163164/**165* When true clip space in the z axis goes from [0..1] (D3D). When false166* [-1, 1] (GL).167*168* NOTE: D3D will always use depth clamping.169*/170unsigned clip_halfz:1;171172/**173* When true do not scale offset_units and use same rules for unorm and174* float depth buffers (D3D9). When false use GL/D3D1X behaviour.175* This depends on PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED.176*/177unsigned offset_units_unscaled:1;178179/**180* Enable bits for clipping half-spaces.181* This applies to both user clip planes and shader clip distances.182* Note that if the bound shader exports any clip distances, these183* replace all user clip planes, and clip half-spaces enabled here184* but not written by the shader count as disabled.185*/186unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES;187188unsigned line_stipple_factor:8; /**< [1..256] actually */189unsigned line_stipple_pattern:16;190191/**192* Replace the given TEXCOORD inputs with point coordinates, max. 8 inputs.193* If TEXCOORD (including PCOORD) are unsupported, replace GENERIC inputs194* instead. Max. 9 inputs: 8x GENERIC to emulate TEXCOORD, and 1x GENERIC195* to emulate PCOORD.196*/197uint16_t sprite_coord_enable; /* 0-7: TEXCOORD/GENERIC, 8: PCOORD */198199float line_width;200float point_size; /**< used when no per-vertex size */201float offset_units;202float offset_scale;203float offset_clamp;204float conservative_raster_dilate;205};206207208struct pipe_poly_stipple209{210unsigned stipple[32];211};212213214struct pipe_viewport_state215{216float scale[3];217float translate[3];218enum pipe_viewport_swizzle swizzle_x:8;219enum pipe_viewport_swizzle swizzle_y:8;220enum pipe_viewport_swizzle swizzle_z:8;221enum pipe_viewport_swizzle swizzle_w:8;222};223224225struct pipe_scissor_state226{227unsigned minx:16;228unsigned miny:16;229unsigned maxx:16;230unsigned maxy:16;231};232233234struct pipe_clip_state235{236float ucp[PIPE_MAX_CLIP_PLANES][4];237};238239/**240* A single output for vertex transform feedback.241*/242struct pipe_stream_output243{244unsigned register_index:6; /**< 0 to 63 (OUT index) */245unsigned start_component:2; /** 0 to 3 */246unsigned num_components:3; /** 1 to 4 */247unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */248unsigned dst_offset:16; /**< offset into the buffer in dwords */249unsigned stream:2; /**< 0 to 3 */250};251252/**253* Stream output for vertex transform feedback.254*/255struct pipe_stream_output_info256{257unsigned num_outputs;258/** stride for an entire vertex for each buffer in dwords */259uint16_t stride[PIPE_MAX_SO_BUFFERS];260261/**262* Array of stream outputs, in the order they are to be written in.263* Selected components are tightly packed into the output buffer.264*/265struct pipe_stream_output output[PIPE_MAX_SO_OUTPUTS];266};267268/**269* The 'type' parameter identifies whether the shader state contains TGSI270* tokens, etc. If the driver returns 'PIPE_SHADER_IR_TGSI' for the271* 'PIPE_SHADER_CAP_PREFERRED_IR' shader param, the ir will *always* be272* 'PIPE_SHADER_IR_TGSI' and the tokens ptr will be valid. If the driver273* requests a different 'pipe_shader_ir' type, then it must check the 'type'274* enum to see if it is getting TGSI tokens or its preferred IR.275*276* TODO pipe_compute_state should probably get similar treatment to handle277* multiple IR's in a cleaner way..278*279* NOTE: since it is expected that the consumer will want to perform280* additional passes on the nir_shader, the driver takes ownership of281* the nir_shader. If gallium frontends need to hang on to the IR (for282* example, variant management), it should use nir_shader_clone().283*/284struct pipe_shader_state285{286enum pipe_shader_ir type;287/* TODO move tokens into union. */288const struct tgsi_token *tokens;289union {290void *native;291void *nir;292} ir;293struct pipe_stream_output_info stream_output;294};295296static inline void297pipe_shader_state_from_tgsi(struct pipe_shader_state *state,298const struct tgsi_token *tokens)299{300state->type = PIPE_SHADER_IR_TGSI;301state->tokens = tokens;302memset(&state->stream_output, 0, sizeof(state->stream_output));303}304305306struct pipe_stencil_state307{308unsigned enabled:1; /**< stencil[0]: stencil enabled, stencil[1]: two-side enabled */309unsigned func:3; /**< PIPE_FUNC_x */310unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */311unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */312unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */313unsigned valuemask:8;314unsigned writemask:8;315};316317318struct pipe_depth_stencil_alpha_state319{320struct pipe_stencil_state stencil[2]; /**< [0] = front, [1] = back */321322unsigned alpha_enabled:1; /**< alpha test enabled? */323unsigned alpha_func:3; /**< PIPE_FUNC_x */324325unsigned depth_enabled:1; /**< depth test enabled? */326unsigned depth_writemask:1; /**< allow depth buffer writes? */327unsigned depth_func:3; /**< depth test func (PIPE_FUNC_x) */328unsigned depth_bounds_test:1; /**< depth bounds test enabled? */329330float alpha_ref_value; /**< reference value */331double depth_bounds_min; /**< minimum depth bound */332double depth_bounds_max; /**< maximum depth bound */333};334335336struct pipe_rt_blend_state337{338unsigned blend_enable:1;339340unsigned rgb_func:3; /**< PIPE_BLEND_x */341unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */342unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */343344unsigned alpha_func:3; /**< PIPE_BLEND_x */345unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */346unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */347348unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */349};350351352struct pipe_blend_state353{354unsigned independent_blend_enable:1;355unsigned logicop_enable:1;356unsigned logicop_func:4; /**< PIPE_LOGICOP_x */357unsigned dither:1;358unsigned alpha_to_coverage:1;359unsigned alpha_to_coverage_dither:1;360unsigned alpha_to_one:1;361unsigned max_rt:3; /* index of max rt, Ie. # of cbufs minus 1 */362unsigned advanced_blend_func:4;363struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];364};365366367struct pipe_blend_color368{369float color[4];370};371372373struct pipe_stencil_ref374{375ubyte ref_value[2];376};377378379/**380* Note that pipe_surfaces are "texture views for rendering"381* and so in the case of ARB_framebuffer_no_attachment there382* is no pipe_surface state available such that we may383* extract the number of samples and layers.384*/385struct pipe_framebuffer_state386{387uint16_t width, height;388uint16_t layers; /**< Number of layers in a no-attachment framebuffer */389ubyte samples; /**< Number of samples in a no-attachment framebuffer */390391/** multiple color buffers for multiple render targets */392ubyte nr_cbufs;393struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];394395struct pipe_surface *zsbuf; /**< Z/stencil buffer */396};397398399/**400* Texture sampler state.401*/402struct pipe_sampler_state403{404unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */405unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */406unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */407unsigned min_img_filter:1; /**< PIPE_TEX_FILTER_x */408unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */409unsigned mag_img_filter:1; /**< PIPE_TEX_FILTER_x */410unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */411unsigned compare_func:3; /**< PIPE_FUNC_x */412unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */413unsigned max_anisotropy:5;414unsigned seamless_cube_map:1;415unsigned border_color_is_integer:1;416unsigned reduction_mode:2; /**< PIPE_TEX_REDUCTION_x */417float lod_bias; /**< LOD/lambda bias */418float min_lod, max_lod; /**< LOD clamp range, after bias */419union pipe_color_union border_color;420};421422union pipe_surface_desc {423struct {424unsigned level;425unsigned first_layer:16;426unsigned last_layer:16;427} tex;428struct {429unsigned first_element;430unsigned last_element;431} buf;432};433434/**435* A view into a texture that can be bound to a color render target /436* depth stencil attachment point.437*/438struct pipe_surface439{440struct pipe_reference reference;441enum pipe_format format:16;442unsigned writable:1; /**< writable shader resource */443struct pipe_resource *texture; /**< resource into which this is a view */444struct pipe_context *context; /**< context this surface belongs to */445446/* XXX width/height should be removed */447uint16_t width; /**< logical width in pixels */448uint16_t height; /**< logical height in pixels */449450/**451* Number of samples for the surface. This will be 0 if rendering452* should use the resource's nr_samples, or another value if the resource453* is bound using FramebufferTexture2DMultisampleEXT.454*/455unsigned nr_samples:8;456457union pipe_surface_desc u;458};459460461/**462* A view into a texture that can be bound to a shader stage.463*/464struct pipe_sampler_view465{466struct pipe_reference reference;467enum pipe_format format:15; /**< typed PIPE_FORMAT_x */468enum pipe_texture_target target:5; /**< PIPE_TEXTURE_x */469unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */470unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */471unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */472unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */473struct pipe_resource *texture; /**< texture into which this is a view */474struct pipe_context *context; /**< context this view belongs to */475union {476struct {477unsigned first_layer:16; /**< first layer to use for array textures */478unsigned last_layer:16; /**< last layer to use for array textures */479unsigned first_level:8; /**< first mipmap level to use */480unsigned last_level:8; /**< last mipmap level to use */481} tex;482struct {483unsigned offset; /**< offset in bytes */484unsigned size; /**< size of the readable sub-range in bytes */485} buf;486} u;487};488489490/**491* A description of a buffer or texture image that can be bound to a shader492* stage.493*/494struct pipe_image_view495{496struct pipe_resource *resource; /**< resource into which this is a view */497enum pipe_format format; /**< typed PIPE_FORMAT_x */498uint16_t access; /**< PIPE_IMAGE_ACCESS_x */499uint16_t shader_access; /**< PIPE_IMAGE_ACCESS_x */500501union {502struct {503unsigned first_layer:16; /**< first layer to use for array textures */504unsigned last_layer:16; /**< last layer to use for array textures */505unsigned level:8; /**< mipmap level to use */506} tex;507struct {508unsigned offset; /**< offset in bytes */509unsigned size; /**< size of the accessible sub-range in bytes */510} buf;511} u;512};513514515/**516* Subregion of 1D/2D/3D image resource.517*/518struct pipe_box519{520/* Fields only used by textures use int16_t instead of int.521* x and width are used by buffers, so they need the full 32-bit range.522*/523int x;524int16_t y;525int16_t z;526int width;527int16_t height;528int16_t depth;529};530531532/**533* A memory object/resource such as a vertex buffer or texture.534*/535struct pipe_resource536{537struct pipe_reference reference;538539unsigned width0; /**< Used by both buffers and textures. */540uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */541uint16_t depth0;542uint16_t array_size;543544enum pipe_format format:16; /**< PIPE_FORMAT_x */545enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */546unsigned last_level:8; /**< Index of last mipmap level present/defined */547548/** Number of samples determining quality, driving rasterizer, shading,549* and framebuffer.550*/551unsigned nr_samples:8;552553/** Multiple samples within a pixel can have the same value.554* nr_storage_samples determines how many slots for different values555* there are per pixel. Only color buffers can set this lower than556* nr_samples.557*/558unsigned nr_storage_samples:8;559560unsigned usage:8; /**< PIPE_USAGE_x (not a bitmask) */561unsigned bind; /**< bitmask of PIPE_BIND_x */562unsigned flags; /**< bitmask of PIPE_RESOURCE_FLAG_x */563564/**565* For planar images, ie. YUV EGLImage external, etc, pointer to the566* next plane.567*/568struct pipe_resource *next;569/* The screen pointer should be last for optimal structure packing. */570struct pipe_screen *screen; /**< screen that this texture belongs to */571};572573/**574* Opaque object used for separate resource/memory allocations.575*/576struct pipe_memory_allocation;577578/**579* Transfer object. For data transfer to/from a resource.580*/581struct pipe_transfer582{583struct pipe_resource *resource; /**< resource to transfer to/from */584enum pipe_map_flags usage:24;585unsigned level:8; /**< texture mipmap level */586struct pipe_box box; /**< region of the resource to access */587unsigned stride; /**< row stride in bytes */588unsigned layer_stride; /**< image/layer stride in bytes */589590/* Offset into a driver-internal staging buffer to make use of unused591* padding in this structure.592*/593unsigned offset;594};595596597/**598* A vertex buffer. Typically, all the vertex data/attributes for599* drawing something will be in one buffer. But it's also possible, for600* example, to put colors in one buffer and texcoords in another.601*/602struct pipe_vertex_buffer603{604uint16_t stride; /**< stride to same attrib in next vertex, in bytes */605bool is_user_buffer;606unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */607608union {609struct pipe_resource *resource; /**< the actual buffer */610const void *user; /**< pointer to a user buffer */611} buffer;612};613614615/**616* A constant buffer. A subrange of an existing buffer can be set617* as a constant buffer.618*/619struct pipe_constant_buffer620{621struct pipe_resource *buffer; /**< the actual buffer */622unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */623unsigned buffer_size; /**< how much data can be read in shader */624const void *user_buffer; /**< pointer to a user buffer if buffer == NULL */625};626627628/**629* An untyped shader buffer supporting loads, stores, and atomics.630*/631struct pipe_shader_buffer {632struct pipe_resource *buffer; /**< the actual buffer */633unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */634unsigned buffer_size; /**< how much data can be read in shader */635};636637638/**639* A stream output target. The structure specifies the range vertices can640* be written to.641*642* In addition to that, the structure should internally maintain the offset643* into the buffer, which should be incremented everytime something is written644* (appended) to it. The internal offset is buffer_offset + how many bytes645* have been written. The internal offset can be stored on the device646* and the CPU actually doesn't have to query it.647*648* Note that the buffer_size variable is actually specifying the available649* space in the buffer, not the size of the attached buffer.650* In other words in majority of cases buffer_size would simply be651* 'buffer->width0 - buffer_offset', so buffer_size refers to the size652* of the buffer left, after accounting for buffer offset, for stream output653* to write to.654*655* Use PIPE_QUERY_SO_STATISTICS to know how many primitives have656* actually been written.657*/658struct pipe_stream_output_target659{660struct pipe_reference reference;661struct pipe_resource *buffer; /**< the output buffer */662struct pipe_context *context; /**< context this SO target belongs to */663664unsigned buffer_offset; /**< offset where data should be written, in bytes */665unsigned buffer_size; /**< how much data is allowed to be written */666};667668669/**670* Information to describe a vertex attribute (position, color, etc)671*/672struct pipe_vertex_element673{674/** Offset of this attribute, in bytes, from the start of the vertex */675unsigned src_offset:16;676677/** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does678* this attribute live in?679*/680unsigned vertex_buffer_index:5;681682enum pipe_format src_format:11;683684/** Instance data rate divisor. 0 means this is per-vertex data,685* n means per-instance data used for n consecutive instances (n > 0).686*/687unsigned instance_divisor;688};689690691struct pipe_draw_indirect_info692{693unsigned offset; /**< must be 4 byte aligned */694unsigned stride; /**< must be 4 byte aligned */695unsigned draw_count; /**< number of indirect draws */696unsigned indirect_draw_count_offset; /**< must be 4 byte aligned */697698/* Indirect draw parameters resource is laid out as follows:699*700* if using indexed drawing:701* struct {702* uint32_t count;703* uint32_t instance_count;704* uint32_t start;705* int32_t index_bias;706* uint32_t start_instance;707* };708* otherwise:709* struct {710* uint32_t count;711* uint32_t instance_count;712* uint32_t start;713* uint32_t start_instance;714* };715*716* If NULL, count_from_stream_output != NULL.717*/718struct pipe_resource *buffer;719720/* Indirect draw count resource: If not NULL, contains a 32-bit value which721* is to be used as the real draw_count.722*/723struct pipe_resource *indirect_draw_count;724725/**726* Stream output target. If not NULL, it's used to provide the 'count'727* parameter based on the number vertices captured by the stream output728* stage. (or generally, based on the number of bytes captured)729*730* Only 'mode', 'start_instance', and 'instance_count' are taken into731* account, all the other variables from pipe_draw_info are ignored.732*733* 'start' is implicitly 0 and 'count' is set as discussed above.734* The draw command is non-indexed.735*736* Note that this only provides the count. The vertex buffers must737* be set via set_vertex_buffers manually.738*/739struct pipe_stream_output_target *count_from_stream_output;740};741742struct pipe_draw_start_count_bias {743unsigned start;744unsigned count;745int index_bias; /**< a bias to be added to each index */746};747748/**749* Information to describe a draw_vbo call.750*/751struct pipe_draw_info752{753enum pipe_prim_type mode:8; /**< the mode of the primitive */754ubyte vertices_per_patch; /**< the number of vertices per patch */755unsigned index_size:4; /**< if 0, the draw is not indexed. */756unsigned view_mask:6; /**< mask of multiviews for this draw */757bool primitive_restart:1;758bool has_user_indices:1; /**< if true, use index.user_buffer */759bool index_bounds_valid:1; /**< whether min_index and max_index are valid;760they're always invalid if index_size == 0 */761bool increment_draw_id:1; /**< whether drawid increments for direct draws */762bool take_index_buffer_ownership:1; /**< callee inherits caller's refcount763(no need to reference indexbuf, but still needs to unreference it) */764bool index_bias_varies:1; /**< true if index_bias varies between draws */765766unsigned start_instance; /**< first instance id */767unsigned instance_count; /**< number of instances */768769/**770* Primitive restart enable/index (only applies to indexed drawing)771*/772unsigned restart_index;773774/* Pointers must be placed appropriately for optimal structure packing on775* 64-bit CPUs.776*/777778/**779* An index buffer. When an index buffer is bound, all indices to vertices780* will be looked up from the buffer.781*782* If has_user_indices, use index.user, else use index.resource.783*/784union {785struct pipe_resource *resource; /**< real buffer */786struct gl_buffer_object *gl_bo; /**< for the GL frontend, not passed to drivers */787const void *user; /**< pointer to a user buffer */788} index;789790/* These must be last for better packing in u_threaded_context. */791unsigned min_index; /**< the min index */792unsigned max_index; /**< the max index */793};794795796/**797* Information to describe a blit call.798*/799struct pipe_blit_info800{801struct {802struct pipe_resource *resource;803unsigned level;804struct pipe_box box; /**< negative width, height only legal for src */805/* For pipe_surface-like format casting: */806enum pipe_format format; /**< must be supported for sampling (src)807or rendering (dst), ZS is always supported */808} dst, src;809810unsigned mask; /**< bitmask of PIPE_MASK_R/G/B/A/Z/S */811unsigned filter; /**< PIPE_TEX_FILTER_* */812813bool scissor_enable;814struct pipe_scissor_state scissor;815816/* Window rectangles can either be inclusive or exclusive. */817bool window_rectangle_include;818unsigned num_window_rectangles;819struct pipe_scissor_state window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];820821bool render_condition_enable; /**< whether the blit should honor the822current render condition */823bool alpha_blend; /* dst.rgb = src.rgb * src.a + dst.rgb * (1 - src.a) */824};825826/**827* Information to describe a launch_grid call.828*/829struct pipe_grid_info830{831/**832* For drivers that use PIPE_SHADER_IR_NATIVE as their prefered IR, this833* value will be the index of the kernel in the opencl.kernels metadata834* list.835*/836uint32_t pc;837838/**839* Will be used to initialize the INPUT resource, and it should point to a840* buffer of at least pipe_compute_state::req_input_mem bytes.841*/842void *input;843844/**845* Grid number of dimensions, 1-3, e.g. the work_dim parameter passed to846* clEnqueueNDRangeKernel. Note block[] and grid[] must be padded with847* 1 for non-used dimensions.848*/849uint work_dim;850851/**852* Determine the layout of the working block (in thread units) to be used.853*/854uint block[3];855856/**857* last_block allows disabling threads at the farthermost grid boundary.858* Full blocks as specified by "block" are launched, but the threads859* outside of "last_block" dimensions are disabled.860*861* If a block touches the grid boundary in the i-th axis, threads with862* THREAD_ID[i] >= last_block[i] are disabled.863*864* If last_block[i] is 0, it has the same behavior as last_block[i] = block[i],865* meaning no effect.866*867* It's equivalent to doing this at the beginning of the compute shader:868*869* for (i = 0; i < 3; i++) {870* if (block_id[i] == grid[i] - 1 &&871* last_block[i] && thread_id[i] >= last_block[i])872* return;873* }874*/875uint last_block[3];876877/**878* Determine the layout of the grid (in block units) to be used.879*/880uint grid[3];881882/**883* Base offsets to launch grids from884*/885uint grid_base[3];886887/* Indirect compute parameters resource: If not NULL, block sizes are taken888* from this buffer instead, which is laid out as follows:889*890* struct {891* uint32_t num_blocks_x;892* uint32_t num_blocks_y;893* uint32_t num_blocks_z;894* };895*/896struct pipe_resource *indirect;897unsigned indirect_offset; /**< must be 4 byte aligned */898};899900/**901* Structure used as a header for serialized compute programs.902*/903struct pipe_binary_program_header904{905uint32_t num_bytes; /**< Number of bytes in the LLVM bytecode program. */906char blob[];907};908909struct pipe_compute_state910{911enum pipe_shader_ir ir_type; /**< IR type contained in prog. */912const void *prog; /**< Compute program to be executed. */913unsigned req_local_mem; /**< Required size of the LOCAL resource. */914unsigned req_private_mem; /**< Required size of the PRIVATE resource. */915unsigned req_input_mem; /**< Required size of the INPUT resource. */916};917918/**919* Structure that contains a callback for debug messages from the driver back920* to the gallium frontend.921*/922struct pipe_debug_callback923{924/**925* When set to \c true, the callback may be called asynchronously from a926* driver-created thread.927*/928bool async;929930/**931* Callback for the driver to report debug/performance/etc information back932* to the gallium frontend.933*934* \param data user-supplied data pointer935* \param id message type identifier, if pointed value is 0, then a936* new id is assigned937* \param type PIPE_DEBUG_TYPE_*938* \param format printf-style format string939* \param args args for format string940*/941void (*debug_message)(void *data,942unsigned *id,943enum pipe_debug_type type,944const char *fmt,945va_list args);946void *data;947};948949/**950* Structure that contains a callback for device reset messages from the driver951* back to the gallium frontend.952*953* The callback must not be called from driver-created threads.954*/955struct pipe_device_reset_callback956{957/**958* Callback for the driver to report when a device reset is detected.959*960* \param data user-supplied data pointer961* \param status PIPE_*_RESET962*/963void (*reset)(void *data, enum pipe_reset_status status);964965void *data;966};967968/**969* Information about memory usage. All sizes are in kilobytes.970*/971struct pipe_memory_info972{973unsigned total_device_memory; /**< size of device memory, e.g. VRAM */974unsigned avail_device_memory; /**< free device memory at the moment */975unsigned total_staging_memory; /**< size of staging memory, e.g. GART */976unsigned avail_staging_memory; /**< free staging memory at the moment */977unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */978unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */979};980981/**982* Structure that contains information about external memory983*/984struct pipe_memory_object985{986bool dedicated;987};988989#ifdef __cplusplus990}991#endif992993#endif994995996