1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2007 VMware, Inc. 4848b8605Smrg * All Rights Reserved. 5848b8605Smrg * 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: 13848b8605Smrg * 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. 17848b8605Smrg * 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. 25848b8605Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg/** 29848b8605Smrg * Private data structures, etc for the draw module. 30848b8605Smrg */ 31848b8605Smrg 32848b8605Smrg 33848b8605Smrg/** 34848b8605Smrg * Authors: 35848b8605Smrg * Keith Whitwell <keithw@vmware.com> 36848b8605Smrg * Brian Paul 37848b8605Smrg */ 38848b8605Smrg 39848b8605Smrg 40848b8605Smrg#ifndef DRAW_PRIVATE_H 41848b8605Smrg#define DRAW_PRIVATE_H 42848b8605Smrg 43848b8605Smrg 44848b8605Smrg#include "pipe/p_state.h" 45848b8605Smrg#include "pipe/p_defines.h" 46848b8605Smrg 47848b8605Smrg#include "tgsi/tgsi_scan.h" 48848b8605Smrg 49848b8605Smrg#ifdef HAVE_LLVM 50848b8605Smrgstruct gallivm_state; 51848b8605Smrg#endif 52848b8605Smrg 53848b8605Smrg 54848b8605Smrg/** Sum of frustum planes and user-defined planes */ 55848b8605Smrg#define DRAW_TOTAL_CLIP_PLANES (6 + PIPE_MAX_CLIP_PLANES) 56848b8605Smrg 57848b8605Smrg/** 58848b8605Smrg * The largest possible index of a vertex that can be fetched. 59848b8605Smrg */ 60848b8605Smrg#define DRAW_MAX_FETCH_IDX 0xffffffff 61848b8605Smrg 62848b8605Smrgstruct pipe_context; 63848b8605Smrgstruct draw_vertex_shader; 64848b8605Smrgstruct draw_context; 65848b8605Smrgstruct draw_stage; 66848b8605Smrgstruct vbuf_render; 67848b8605Smrgstruct tgsi_exec_machine; 68848b8605Smrgstruct tgsi_sampler; 69b8e80941Smrgstruct tgsi_image; 70b8e80941Smrgstruct tgsi_buffer; 71848b8605Smrgstruct draw_pt_front_end; 72848b8605Smrgstruct draw_assembler; 73848b8605Smrgstruct draw_llvm; 74848b8605Smrg 75848b8605Smrg 76848b8605Smrg/** 77848b8605Smrg * Represents the mapped vertex buffer. 78848b8605Smrg */ 79848b8605Smrgstruct draw_vertex_buffer { 80848b8605Smrg const void *map; 81848b8605Smrg uint32_t size; 82848b8605Smrg}; 83848b8605Smrg 84848b8605Smrg/** 85848b8605Smrg * Basic vertex info. 86848b8605Smrg * Carry some useful information around with the vertices in the prim pipe. 87848b8605Smrg */ 88848b8605Smrgstruct vertex_header { 89848b8605Smrg unsigned clipmask:DRAW_TOTAL_CLIP_PLANES; 90848b8605Smrg unsigned edgeflag:1; 91b8e80941Smrg unsigned pad:1; 92848b8605Smrg unsigned vertex_id:16; 93848b8605Smrg 94b8e80941Smrg float clip_pos[4]; 95848b8605Smrg 96848b8605Smrg /* This will probably become float (*data)[4] soon: 97848b8605Smrg */ 98848b8605Smrg float data[][4]; 99848b8605Smrg}; 100848b8605Smrg 101848b8605Smrg/* NOTE: It should match vertex_id size above */ 102848b8605Smrg#define UNDEFINED_VERTEX_ID 0xffff 103848b8605Smrg 104848b8605Smrg 105848b8605Smrg/* maximum number of shader variants we can cache */ 106b8e80941Smrg#define DRAW_MAX_SHADER_VARIANTS 512 107848b8605Smrg 108848b8605Smrg/** 109848b8605Smrg * Private context for the drawing module. 110848b8605Smrg */ 111848b8605Smrgstruct draw_context 112848b8605Smrg{ 113848b8605Smrg struct pipe_context *pipe; 114848b8605Smrg 115848b8605Smrg /** Drawing/primitive pipeline stages */ 116848b8605Smrg struct { 117848b8605Smrg struct draw_stage *first; /**< one of the following */ 118848b8605Smrg 119848b8605Smrg struct draw_stage *validate; 120848b8605Smrg 121848b8605Smrg /* stages (in logical order) */ 122848b8605Smrg struct draw_stage *flatshade; 123848b8605Smrg struct draw_stage *clip; 124848b8605Smrg struct draw_stage *cull; 125848b8605Smrg struct draw_stage *twoside; 126848b8605Smrg struct draw_stage *offset; 127848b8605Smrg struct draw_stage *unfilled; 128848b8605Smrg struct draw_stage *stipple; 129848b8605Smrg struct draw_stage *aapoint; 130848b8605Smrg struct draw_stage *aaline; 131848b8605Smrg struct draw_stage *pstipple; 132848b8605Smrg struct draw_stage *wide_line; 133848b8605Smrg struct draw_stage *wide_point; 134848b8605Smrg struct draw_stage *rasterize; 135848b8605Smrg 136848b8605Smrg float wide_point_threshold; /**< convert pnts to tris if larger than this */ 137848b8605Smrg float wide_line_threshold; /**< convert lines to tris if wider than this */ 138848b8605Smrg boolean wide_point_sprites; /**< convert points to tris for sprite mode */ 139848b8605Smrg boolean line_stipple; /**< do line stipple? */ 140848b8605Smrg boolean point_sprite; /**< convert points to quads for sprites? */ 141848b8605Smrg 142848b8605Smrg /* Temporary storage while the pipeline is being run: 143848b8605Smrg */ 144848b8605Smrg char *verts; 145848b8605Smrg unsigned vertex_stride; 146848b8605Smrg unsigned vertex_count; 147848b8605Smrg } pipeline; 148848b8605Smrg 149848b8605Smrg 150848b8605Smrg struct vbuf_render *render; 151848b8605Smrg 152848b8605Smrg /* Support prototype passthrough path: 153848b8605Smrg */ 154848b8605Smrg struct { 155848b8605Smrg /* Current active frontend */ 156848b8605Smrg struct draw_pt_front_end *frontend; 157848b8605Smrg unsigned prim; 158848b8605Smrg unsigned opt; /**< bitmask of PT_x flags */ 159848b8605Smrg unsigned eltSize; /* saved eltSize for flushing */ 160848b8605Smrg 161848b8605Smrg boolean rebind_parameters; 162848b8605Smrg 163848b8605Smrg struct { 164848b8605Smrg struct draw_pt_middle_end *fetch_emit; 165848b8605Smrg struct draw_pt_middle_end *fetch_shade_emit; 166848b8605Smrg struct draw_pt_middle_end *general; 167848b8605Smrg struct draw_pt_middle_end *llvm; 168848b8605Smrg } middle; 169848b8605Smrg 170848b8605Smrg struct { 171848b8605Smrg struct draw_pt_front_end *vsplit; 172848b8605Smrg } front; 173848b8605Smrg 174848b8605Smrg struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; 175848b8605Smrg unsigned nr_vertex_buffers; 176848b8605Smrg 177848b8605Smrg /* 178848b8605Smrg * This is the largest legal index value for the current set of 179848b8605Smrg * bound vertex buffers. Regardless of any other consideration, 180848b8605Smrg * all vertex lookups need to be clamped to 0..max_index to 181848b8605Smrg * prevent out-of-bound access. 182848b8605Smrg */ 183848b8605Smrg unsigned max_index; 184848b8605Smrg 185848b8605Smrg struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; 186848b8605Smrg unsigned nr_vertex_elements; 187848b8605Smrg 188848b8605Smrg /* user-space vertex data, buffers */ 189848b8605Smrg struct { 190848b8605Smrg /** vertex element/index buffer (ex: glDrawElements) */ 191848b8605Smrg const void *elts; 192848b8605Smrg /** bytes per index (0, 1, 2 or 4) */ 193848b8605Smrg unsigned eltSizeIB; 194848b8605Smrg unsigned eltSize; 195848b8605Smrg unsigned eltMax; 196848b8605Smrg int eltBias; 197848b8605Smrg unsigned min_index; 198848b8605Smrg unsigned max_index; 199848b8605Smrg 200848b8605Smrg /** vertex arrays */ 201848b8605Smrg struct draw_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS]; 202848b8605Smrg 203848b8605Smrg /** constant buffers (for vertex/geometry shader) */ 204848b8605Smrg const void *vs_constants[PIPE_MAX_CONSTANT_BUFFERS]; 205848b8605Smrg unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; 206848b8605Smrg const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS]; 207848b8605Smrg unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; 208848b8605Smrg 209848b8605Smrg /* pointer to planes */ 210848b8605Smrg float (*planes)[DRAW_TOTAL_CLIP_PLANES][4]; 211848b8605Smrg } user; 212848b8605Smrg 213848b8605Smrg boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */ 214848b8605Smrg boolean no_fse; /* disable FSE even when it is correct */ 215848b8605Smrg } pt; 216848b8605Smrg 217848b8605Smrg struct { 218848b8605Smrg boolean bypass_clip_xy; 219848b8605Smrg boolean bypass_clip_z; 220848b8605Smrg boolean guard_band_xy; 221848b8605Smrg boolean bypass_clip_points; 222848b8605Smrg } driver; 223848b8605Smrg 224848b8605Smrg boolean quads_always_flatshade_last; 225848b8605Smrg 226848b8605Smrg boolean flushing; /**< debugging/sanity */ 227848b8605Smrg boolean suspend_flushing; /**< internally set */ 228848b8605Smrg 229848b8605Smrg /* Flags set if API requires clipping in these planes and the 230848b8605Smrg * driver doesn't indicate that it can do it for us. 231848b8605Smrg */ 232848b8605Smrg boolean clip_xy; 233848b8605Smrg boolean clip_z; 234848b8605Smrg boolean clip_user; 235848b8605Smrg boolean guard_band_xy; 236848b8605Smrg boolean guard_band_points_xy; 237848b8605Smrg 238848b8605Smrg boolean force_passthrough; /**< never clip or shade */ 239848b8605Smrg 240848b8605Smrg boolean dump_vs; 241848b8605Smrg 242848b8605Smrg /** Depth format and bias related settings. */ 243848b8605Smrg boolean floating_point_depth; 244848b8605Smrg double mrd; /**< minimum resolvable depth value, for polygon offset */ 245848b8605Smrg 246848b8605Smrg /** Current rasterizer state given to us by the driver */ 247848b8605Smrg const struct pipe_rasterizer_state *rasterizer; 248848b8605Smrg /** Driver CSO handle for the current rasterizer state */ 249848b8605Smrg void *rast_handle; 250848b8605Smrg 251848b8605Smrg /** Rasterizer CSOs without culling/stipple/etc */ 252848b8605Smrg void *rasterizer_no_cull[2][2]; 253848b8605Smrg 254848b8605Smrg struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS]; 255848b8605Smrg boolean identity_viewport; 256b8e80941Smrg boolean bypass_viewport; 257848b8605Smrg 258848b8605Smrg /** Vertex shader state */ 259848b8605Smrg struct { 260848b8605Smrg struct draw_vertex_shader *vertex_shader; 261848b8605Smrg uint num_vs_outputs; /**< convenience, from vertex_shader */ 262848b8605Smrg uint position_output; 263848b8605Smrg uint edgeflag_output; 264848b8605Smrg uint clipvertex_output; 265b8e80941Smrg uint ccdistance_output[2]; 266848b8605Smrg 267848b8605Smrg /** Fields for TGSI interpreter / execution */ 268848b8605Smrg struct { 269848b8605Smrg struct tgsi_exec_machine *machine; 270848b8605Smrg 271848b8605Smrg struct tgsi_sampler *sampler; 272b8e80941Smrg struct tgsi_image *image; 273b8e80941Smrg struct tgsi_buffer *buffer; 274848b8605Smrg } tgsi; 275848b8605Smrg 276848b8605Smrg struct translate *fetch; 277848b8605Smrg struct translate_cache *fetch_cache; 278848b8605Smrg struct translate *emit; 279848b8605Smrg struct translate_cache *emit_cache; 280848b8605Smrg } vs; 281848b8605Smrg 282848b8605Smrg /** Geometry shader state */ 283848b8605Smrg struct { 284848b8605Smrg struct draw_geometry_shader *geometry_shader; 285848b8605Smrg uint num_gs_outputs; /**< convenience, from geometry_shader */ 286848b8605Smrg uint position_output; 287848b8605Smrg 288848b8605Smrg /** Fields for TGSI interpreter / execution */ 289848b8605Smrg struct { 290848b8605Smrg struct tgsi_exec_machine *machine; 291848b8605Smrg 292848b8605Smrg struct tgsi_sampler *sampler; 293b8e80941Smrg struct tgsi_image *image; 294b8e80941Smrg struct tgsi_buffer *buffer; 295848b8605Smrg } tgsi; 296848b8605Smrg 297848b8605Smrg } gs; 298848b8605Smrg 299848b8605Smrg /** Fragment shader state */ 300848b8605Smrg struct { 301848b8605Smrg struct draw_fragment_shader *fragment_shader; 302848b8605Smrg } fs; 303848b8605Smrg 304848b8605Smrg /** Stream output (vertex feedback) state */ 305848b8605Smrg struct { 306848b8605Smrg struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]; 307848b8605Smrg uint num_targets; 308848b8605Smrg } so; 309848b8605Smrg 310848b8605Smrg /* Clip derived state: 311848b8605Smrg */ 312848b8605Smrg float plane[DRAW_TOTAL_CLIP_PLANES][4]; 313848b8605Smrg 314848b8605Smrg /* If a prim stage introduces new vertex attributes, they'll be stored here 315848b8605Smrg */ 316848b8605Smrg struct { 317848b8605Smrg uint num; 318848b8605Smrg uint semantic_name[10]; 319848b8605Smrg uint semantic_index[10]; 320848b8605Smrg uint slot[10]; 321848b8605Smrg } extra_shader_outputs; 322848b8605Smrg 323848b8605Smrg unsigned instance_id; 324848b8605Smrg unsigned start_instance; 325848b8605Smrg unsigned start_index; 326848b8605Smrg 327848b8605Smrg struct draw_llvm *llvm; 328848b8605Smrg 329848b8605Smrg /** Texture sampler and sampler view state. 330848b8605Smrg * Note that we have arrays indexed by shader type. At this time 331848b8605Smrg * we only handle vertex and geometry shaders in the draw module, but 332848b8605Smrg * there may be more in the future (ex: hull and tessellation). 333848b8605Smrg */ 334848b8605Smrg struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; 335848b8605Smrg unsigned num_sampler_views[PIPE_SHADER_TYPES]; 336848b8605Smrg const struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; 337848b8605Smrg unsigned num_samplers[PIPE_SHADER_TYPES]; 338848b8605Smrg 339848b8605Smrg struct pipe_query_data_pipeline_statistics statistics; 340848b8605Smrg boolean collect_statistics; 341848b8605Smrg 342848b8605Smrg struct draw_assembler *ia; 343848b8605Smrg 344848b8605Smrg void *driver_private; 345848b8605Smrg}; 346848b8605Smrg 347848b8605Smrg 348848b8605Smrgstruct draw_fetch_info { 349848b8605Smrg boolean linear; 350848b8605Smrg unsigned start; 351848b8605Smrg const unsigned *elts; 352848b8605Smrg unsigned count; 353848b8605Smrg}; 354848b8605Smrg 355848b8605Smrgstruct draw_vertex_info { 356848b8605Smrg struct vertex_header *verts; 357848b8605Smrg unsigned vertex_size; 358848b8605Smrg unsigned stride; 359848b8605Smrg unsigned count; 360848b8605Smrg}; 361848b8605Smrg 362848b8605Smrg/* these flags are set if the primitive is a segment of a larger one */ 363b8e80941Smrg#define DRAW_SPLIT_BEFORE 0x1 364b8e80941Smrg#define DRAW_SPLIT_AFTER 0x2 365b8e80941Smrg#define DRAW_LINE_LOOP_AS_STRIP 0x4 366848b8605Smrg 367848b8605Smrgstruct draw_prim_info { 368848b8605Smrg boolean linear; 369848b8605Smrg unsigned start; 370848b8605Smrg 371848b8605Smrg const ushort *elts; 372848b8605Smrg unsigned count; 373848b8605Smrg 374848b8605Smrg unsigned prim; 375848b8605Smrg unsigned flags; 376848b8605Smrg unsigned *primitive_lengths; 377848b8605Smrg unsigned primitive_count; 378848b8605Smrg}; 379848b8605Smrg 380848b8605Smrg 381848b8605Smrg/******************************************************************************* 382848b8605Smrg * Draw common initialization code 383848b8605Smrg */ 384848b8605Smrgboolean draw_init(struct draw_context *draw); 385848b8605Smrgvoid draw_new_instance(struct draw_context *draw); 386848b8605Smrg 387848b8605Smrg/******************************************************************************* 388848b8605Smrg * Vertex shader code: 389848b8605Smrg */ 390848b8605Smrgboolean draw_vs_init( struct draw_context *draw ); 391848b8605Smrgvoid draw_vs_destroy( struct draw_context *draw ); 392848b8605Smrg 393848b8605Smrg 394848b8605Smrg/******************************************************************************* 395848b8605Smrg * Geometry shading code: 396848b8605Smrg */ 397848b8605Smrgboolean draw_gs_init( struct draw_context *draw ); 398848b8605Smrg 399848b8605Smrg 400848b8605Smrgvoid draw_gs_destroy( struct draw_context *draw ); 401848b8605Smrg 402848b8605Smrg/******************************************************************************* 403848b8605Smrg * Common shading code: 404848b8605Smrg */ 405848b8605Smrguint draw_current_shader_outputs(const struct draw_context *draw); 406848b8605Smrguint draw_current_shader_position_output(const struct draw_context *draw); 407848b8605Smrguint draw_current_shader_viewport_index_output(const struct draw_context *draw); 408848b8605Smrguint draw_current_shader_clipvertex_output(const struct draw_context *draw); 409b8e80941Smrguint draw_current_shader_ccdistance_output(const struct draw_context *draw, int index); 410848b8605Smrguint draw_current_shader_num_written_clipdistances(const struct draw_context *draw); 411848b8605Smrguint draw_current_shader_num_written_culldistances(const struct draw_context *draw); 412848b8605Smrgint draw_alloc_extra_vertex_attrib(struct draw_context *draw, 413848b8605Smrg uint semantic_name, uint semantic_index); 414848b8605Smrgvoid draw_remove_extra_vertex_attribs(struct draw_context *draw); 415848b8605Smrgboolean draw_current_shader_uses_viewport_index( 416848b8605Smrg const struct draw_context *draw); 417848b8605Smrg 418848b8605Smrg 419848b8605Smrg/******************************************************************************* 420848b8605Smrg * Vertex processing (was passthrough) code: 421848b8605Smrg */ 422848b8605Smrgboolean draw_pt_init( struct draw_context *draw ); 423848b8605Smrgvoid draw_pt_destroy( struct draw_context *draw ); 424848b8605Smrgvoid draw_pt_reset_vertex_ids( struct draw_context *draw ); 425848b8605Smrgvoid draw_pt_flush( struct draw_context *draw, unsigned flags ); 426848b8605Smrg 427848b8605Smrg 428848b8605Smrg/******************************************************************************* 429848b8605Smrg * Primitive processing (pipeline) code: 430848b8605Smrg */ 431848b8605Smrg 432848b8605Smrgboolean draw_pipeline_init( struct draw_context *draw ); 433848b8605Smrgvoid draw_pipeline_destroy( struct draw_context *draw ); 434848b8605Smrg 435848b8605Smrg 436848b8605Smrg 437848b8605Smrg 438848b8605Smrg 439848b8605Smrg/* 440848b8605Smrg * These flags are used by the pipeline when unfilled and/or line stipple modes 441848b8605Smrg * are operational. 442848b8605Smrg */ 443848b8605Smrg#define DRAW_PIPE_EDGE_FLAG_0 0x1 444848b8605Smrg#define DRAW_PIPE_EDGE_FLAG_1 0x2 445848b8605Smrg#define DRAW_PIPE_EDGE_FLAG_2 0x4 446848b8605Smrg#define DRAW_PIPE_EDGE_FLAG_ALL 0x7 447848b8605Smrg#define DRAW_PIPE_RESET_STIPPLE 0x8 448848b8605Smrg 449848b8605Smrgvoid draw_pipeline_run( struct draw_context *draw, 450848b8605Smrg const struct draw_vertex_info *vert, 451848b8605Smrg const struct draw_prim_info *prim); 452848b8605Smrg 453848b8605Smrgvoid draw_pipeline_run_linear( struct draw_context *draw, 454848b8605Smrg const struct draw_vertex_info *vert, 455848b8605Smrg const struct draw_prim_info *prim); 456848b8605Smrg 457848b8605Smrg 458848b8605Smrg 459848b8605Smrg 460848b8605Smrgvoid draw_pipeline_flush( struct draw_context *draw, 461848b8605Smrg unsigned flags ); 462848b8605Smrg 463848b8605Smrg 464848b8605Smrg 465848b8605Smrg/******************************************************************************* 466848b8605Smrg * Flushing 467848b8605Smrg */ 468848b8605Smrg 469848b8605Smrg#define DRAW_FLUSH_PARAMETER_CHANGE 0x1 /**< Constants, viewport, etc */ 470848b8605Smrg#define DRAW_FLUSH_STATE_CHANGE 0x2 /**< Other/heavy state changes */ 471848b8605Smrg#define DRAW_FLUSH_BACKEND 0x4 /**< Flush the output buffer */ 472848b8605Smrg 473848b8605Smrg 474848b8605Smrgvoid draw_do_flush( struct draw_context *draw, unsigned flags ); 475848b8605Smrg 476848b8605Smrg 477848b8605Smrg 478848b8605Smrgvoid * 479848b8605Smrgdraw_get_rasterizer_no_cull( struct draw_context *draw, 480848b8605Smrg boolean scissor, 481848b8605Smrg boolean flatshade ); 482848b8605Smrg 483848b8605Smrgvoid 484848b8605Smrgdraw_stats_clipper_primitives(struct draw_context *draw, 485848b8605Smrg const struct draw_prim_info *prim_info); 486848b8605Smrg 487b8e80941Smrgvoid draw_update_clip_flags(struct draw_context *draw); 488b8e80941Smrgvoid draw_update_viewport_flags(struct draw_context *draw); 489b8e80941Smrg 490848b8605Smrg/** 491848b8605Smrg * Return index i from the index buffer. 492b8e80941Smrg * If the index buffer would overflow we return index 0. 493848b8605Smrg */ 494848b8605Smrg#define DRAW_GET_IDX(_elts, _i) \ 495b8e80941Smrg (((_i) >= draw->pt.user.eltMax) ? 0 : (_elts)[_i]) 496848b8605Smrg 497848b8605Smrg/** 498848b8605Smrg * Return index of the given viewport clamping it 499848b8605Smrg * to be between 0 <= and < PIPE_MAX_VIEWPORTS 500848b8605Smrg */ 501b8e80941Smrgstatic inline unsigned 502848b8605Smrgdraw_clamp_viewport_idx(int idx) 503848b8605Smrg{ 504848b8605Smrg return ((PIPE_MAX_VIEWPORTS > idx && idx >= 0) ? idx : 0); 505848b8605Smrg} 506848b8605Smrg 507848b8605Smrg/** 508848b8605Smrg * Adds two unsigned integers and if the addition 509848b8605Smrg * overflows then it returns the value from 510b8e80941Smrg * the overflow_value variable. 511848b8605Smrg */ 512b8e80941Smrgstatic inline unsigned 513848b8605Smrgdraw_overflow_uadd(unsigned a, unsigned b, 514848b8605Smrg unsigned overflow_value) 515848b8605Smrg{ 516848b8605Smrg unsigned res = a + b; 517b8e80941Smrg if (res < a) { 518848b8605Smrg res = overflow_value; 519848b8605Smrg } 520848b8605Smrg return res; 521848b8605Smrg} 522848b8605Smrg 523848b8605Smrg#endif /* DRAW_PRIVATE_H */ 524