17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 47117f1b4Smrg * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 57117f1b4Smrg * 67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 87117f1b4Smrg * to deal in the Software without restriction, including without limitation 97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 117117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 127117f1b4Smrg * 137117f1b4Smrg * The above copyright notice and this permission notice shall be included 147117f1b4Smrg * in all copies or substantial portions of the Software. 157117f1b4Smrg * 167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg * 247117f1b4Smrg * Authors: 25af69d88dSmrg * Keith Whitwell <keithw@vmware.com> 267117f1b4Smrg */ 277117f1b4Smrg 287117f1b4Smrg#ifndef _TNL_H 297117f1b4Smrg#define _TNL_H 307117f1b4Smrg 313464ebd5Sriastradh#include "main/glheader.h" 327117f1b4Smrg 333464ebd5Sriastradhstruct gl_context; 343464ebd5Sriastradhstruct gl_program; 3501e04c3fSmrgstruct gl_buffer_object; 3601e04c3fSmrgstruct gl_transform_feedback_object; 3701e04c3fSmrgstruct dd_function_table; 387117f1b4Smrg 397117f1b4Smrg 407117f1b4Smrg/* These are the public-access functions exported from tnl. (A few 417117f1b4Smrg * more are currently hooked into dispatch directly by the module 427117f1b4Smrg * itself.) 437117f1b4Smrg */ 447117f1b4Smrgextern GLboolean 453464ebd5Sriastradh_tnl_CreateContext( struct gl_context *ctx ); 467117f1b4Smrg 477117f1b4Smrgextern void 483464ebd5Sriastradh_tnl_DestroyContext( struct gl_context *ctx ); 497117f1b4Smrg 507117f1b4Smrgextern void 513464ebd5Sriastradh_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ); 527117f1b4Smrg 5301e04c3fSmrgextern void 5401e04c3fSmrg_tnl_init_driver_draw_function(struct dd_function_table *functions); 5501e04c3fSmrg 567117f1b4Smrg/* Functions to revive the tnl module after being unhooked from 577117f1b4Smrg * dispatch and/or driver callbacks. 587117f1b4Smrg */ 597117f1b4Smrg 607117f1b4Smrgextern void 613464ebd5Sriastradh_tnl_wakeup( struct gl_context *ctx ); 627117f1b4Smrg 637117f1b4Smrg/* Driver configuration options: 647117f1b4Smrg */ 657117f1b4Smrgextern void 663464ebd5Sriastradh_tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag ); 677117f1b4Smrg 687117f1b4Smrg 6901e04c3fSmrg/** 7001e04c3fSmrg * Vertex array information which is derived from gl_array_attributes 7101e04c3fSmrg * and gl_vertex_buffer_binding information. Used by the TNL module and 7201e04c3fSmrg * device drivers. 7301e04c3fSmrg */ 7401e04c3fSmrgstruct tnl_vertex_array 7501e04c3fSmrg{ 7601e04c3fSmrg /** Vertex attribute array */ 7701e04c3fSmrg const struct gl_array_attributes *VertexAttrib; 7801e04c3fSmrg /** Vertex buffer binding */ 7901e04c3fSmrg const struct gl_vertex_buffer_binding *BufferBinding; 8001e04c3fSmrg}; 8101e04c3fSmrg 8201e04c3fSmrg 8301e04c3fSmrgextern const struct tnl_vertex_array* 8401e04c3fSmrg_tnl_bind_inputs( struct gl_context *ctx ); 8501e04c3fSmrg 8601e04c3fSmrg 877117f1b4Smrg/* Control whether T&L does per-vertex fog 887117f1b4Smrg */ 897117f1b4Smrgextern void 903464ebd5Sriastradh_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value ); 917117f1b4Smrg 927117f1b4Smrgextern void 933464ebd5Sriastradh_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value ); 947117f1b4Smrg 95cdc920a0Smrgextern GLboolean 963464ebd5Sriastradh_tnl_program_string(struct gl_context *ctx, GLenum target, struct gl_program *program); 977117f1b4Smrg 987117f1b4Smrgstruct _mesa_prim; 997117f1b4Smrgstruct _mesa_index_buffer; 1007117f1b4Smrg 1017117f1b4Smrgvoid 10201e04c3fSmrg_tnl_draw_prims(struct gl_context *ctx, 10301e04c3fSmrg const struct tnl_vertex_array *arrays, 1044a49301eSmrg const struct _mesa_prim *prim, 1054a49301eSmrg GLuint nr_prims, 1064a49301eSmrg const struct _mesa_index_buffer *ib, 1074a49301eSmrg GLboolean index_bounds_valid, 1084a49301eSmrg GLuint min_index, 109af69d88dSmrg GLuint max_index, 1107ec681f3Smrg GLuint num_instances, 1117ec681f3Smrg GLuint base_instance); 1124a49301eSmrg 11301e04c3fSmrgvoid 11401e04c3fSmrg_tnl_draw(struct gl_context *ctx, 1157ec681f3Smrg const struct _mesa_prim *prim, unsigned nr_prims, 11601e04c3fSmrg const struct _mesa_index_buffer *ib, 1177ec681f3Smrg bool index_bounds_valid, bool primitive_restart, 1187ec681f3Smrg unsigned restart_index, unsigned min_index, unsigned max_index, 1197ec681f3Smrg unsigned num_instances, unsigned base_instance); 12001e04c3fSmrg 1214a49301eSmrgextern void 122af69d88dSmrg_tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]); 123c1f859d4Smrg 124c1f859d4Smrgextern void 125af69d88dSmrg_tnl_validate_shine_tables( struct gl_context *ctx ); 126c1f859d4Smrg 12701e04c3fSmrg 12801e04c3fSmrg 12901e04c3fSmrg/** 13001e04c3fSmrg * For indirect array drawing: 13101e04c3fSmrg * 13201e04c3fSmrg * typedef struct { 13301e04c3fSmrg * GLuint count; 13401e04c3fSmrg * GLuint primCount; 13501e04c3fSmrg * GLuint first; 13601e04c3fSmrg * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise 13701e04c3fSmrg * } DrawArraysIndirectCommand; 13801e04c3fSmrg * 13901e04c3fSmrg * For indirect indexed drawing: 14001e04c3fSmrg * 14101e04c3fSmrg * typedef struct { 14201e04c3fSmrg * GLuint count; 14301e04c3fSmrg * GLuint primCount; 14401e04c3fSmrg * GLuint firstIndex; 14501e04c3fSmrg * GLint baseVertex; 14601e04c3fSmrg * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise 14701e04c3fSmrg * } DrawElementsIndirectCommand; 14801e04c3fSmrg */ 14901e04c3fSmrg 15001e04c3fSmrg 15101e04c3fSmrg/** 15201e04c3fSmrg * Draw a number of primitives. 15301e04c3fSmrg * \param prims array [nr_prims] describing what to draw (prim type, 15401e04c3fSmrg * vertex count, first index, instance count, etc). 15501e04c3fSmrg * \param arrays array of vertex arrays for draw 15601e04c3fSmrg * \param ib index buffer for indexed drawing, NULL for array drawing 15701e04c3fSmrg * \param index_bounds_valid are min_index and max_index valid? 15801e04c3fSmrg * \param min_index lowest vertex index used 15901e04c3fSmrg * \param max_index highest vertex index used 16001e04c3fSmrg * \param tfb_vertcount if non-null, indicates which transform feedback 16101e04c3fSmrg * object has the vertex count. 16201e04c3fSmrg * \param tfb_stream If called via DrawTransformFeedbackStream, specifies the 16301e04c3fSmrg * vertex stream buffer from which to get the vertex count. 16401e04c3fSmrg * \param indirect If any prims are indirect, this specifies the buffer 16501e04c3fSmrg * to find the "DrawArrays/ElementsIndirectCommand" data. 16601e04c3fSmrg * This may be deprecated in the future 16701e04c3fSmrg */ 16801e04c3fSmrgtypedef void (*tnl_draw_func)(struct gl_context *ctx, 16901e04c3fSmrg const struct tnl_vertex_array* arrays, 17001e04c3fSmrg const struct _mesa_prim *prims, 17101e04c3fSmrg GLuint nr_prims, 17201e04c3fSmrg const struct _mesa_index_buffer *ib, 17301e04c3fSmrg GLboolean index_bounds_valid, 17401e04c3fSmrg GLuint min_index, 17501e04c3fSmrg GLuint max_index, 1767ec681f3Smrg GLuint num_instances, 1777ec681f3Smrg GLuint base_instance); 17801e04c3fSmrg 17901e04c3fSmrg 18001e04c3fSmrg/* Utility function to cope with various constraints on tnl modules or 18101e04c3fSmrg * hardware. This can be used to split an incoming set of arrays and 18201e04c3fSmrg * primitives against the following constraints: 18301e04c3fSmrg * - Maximum number of indices in index buffer. 18401e04c3fSmrg * - Maximum number of vertices referenced by index buffer. 18501e04c3fSmrg * - Maximum hardware vertex buffer size. 18601e04c3fSmrg */ 18701e04c3fSmrgstruct split_limits 18801e04c3fSmrg{ 18901e04c3fSmrg GLuint max_verts; 19001e04c3fSmrg GLuint max_indices; 19101e04c3fSmrg GLuint max_vb_size; /* bytes */ 19201e04c3fSmrg}; 19301e04c3fSmrg 19401e04c3fSmrgvoid 19501e04c3fSmrg_tnl_split_prims(struct gl_context *ctx, 19601e04c3fSmrg const struct tnl_vertex_array *arrays, 19701e04c3fSmrg const struct _mesa_prim *prim, 19801e04c3fSmrg GLuint nr_prims, 19901e04c3fSmrg const struct _mesa_index_buffer *ib, 20001e04c3fSmrg GLuint min_index, 20101e04c3fSmrg GLuint max_index, 2027ec681f3Smrg GLuint num_instances, 2037ec681f3Smrg GLuint base_instance, 20401e04c3fSmrg tnl_draw_func draw, 20501e04c3fSmrg const struct split_limits *limits); 20601e04c3fSmrg 20701e04c3fSmrg 2087117f1b4Smrg#endif 209