1cdc920a0Smrg/* 2cdc920a0Smrg * (C) Copyright IBM Corporation 2004, 2005 3cdc920a0Smrg * All Rights Reserved. 4cdc920a0Smrg * 5cdc920a0Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6cdc920a0Smrg * copy of this software and associated documentation files (the "Software"), 7cdc920a0Smrg * to deal in the Software without restriction, including without limitation 8cdc920a0Smrg * the rights to use, copy, modify, merge, publish, distribute, sub license, 9cdc920a0Smrg * and/or sell copies of the Software, and to permit persons to whom the 10cdc920a0Smrg * Software is furnished to do so, subject to the following conditions: 11cdc920a0Smrg * 12cdc920a0Smrg * The above copyright notice and this permission notice (including the next 13cdc920a0Smrg * paragraph) shall be included in all copies or substantial portions of the 14cdc920a0Smrg * Software. 15cdc920a0Smrg * 16cdc920a0Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17cdc920a0Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18cdc920a0Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19cdc920a0Smrg * IBM, 20cdc920a0Smrg * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21cdc920a0Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22cdc920a0Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23cdc920a0Smrg * SOFTWARE. 24cdc920a0Smrg */ 25cdc920a0Smrg 26cdc920a0Smrg#ifndef _INDIRECT_VA_PRIVATE_ 27cdc920a0Smrg#define _INDIRECT_VA_PRIVATE_ 28cdc920a0Smrg 29cdc920a0Smrg/** 30cdc920a0Smrg * \file indirect_va_private.h 31cdc920a0Smrg * 32cdc920a0Smrg * \author Ian Romanick <idr@us.ibm.com> 33cdc920a0Smrg */ 34cdc920a0Smrg 35cdc920a0Smrg#include <inttypes.h> 36cdc920a0Smrg 37cdc920a0Smrg#include "glxclient.h" 38cdc920a0Smrg#include "indirect.h" 39cdc920a0Smrg#include <GL/glxproto.h> 40cdc920a0Smrg 41cdc920a0Smrg 42cdc920a0Smrg/** 43cdc920a0Smrg * State descriptor for a single array of vertex data. 44cdc920a0Smrg */ 45cdc920a0Smrgstruct array_state 46cdc920a0Smrg{ 47cdc920a0Smrg /** 48cdc920a0Smrg * Pointer to the application supplied data. 49cdc920a0Smrg */ 50cdc920a0Smrg const void *data; 51cdc920a0Smrg 52cdc920a0Smrg /** 53cdc920a0Smrg * Enum representing the type of the application supplied data. 54cdc920a0Smrg */ 55cdc920a0Smrg GLenum data_type; 56cdc920a0Smrg 57cdc920a0Smrg /** 58cdc920a0Smrg * Stride value supplied by the application. This value is not used 59cdc920a0Smrg * internally. It is only kept so that it can be queried by the 60cdc920a0Smrg * application using glGet*v. 61cdc920a0Smrg */ 62cdc920a0Smrg GLsizei user_stride; 63cdc920a0Smrg 64cdc920a0Smrg /** 65cdc920a0Smrg * Calculated size, in bytes, of a single element in the array. This 66cdc920a0Smrg * is calculated based on \c count and the size of the data type 67cdc920a0Smrg * represented by \c data_type. 68cdc920a0Smrg */ 69cdc920a0Smrg GLsizei element_size; 70cdc920a0Smrg 71cdc920a0Smrg /** 72cdc920a0Smrg * Actual byte-stride from one element to the next. This value will 73cdc920a0Smrg * be equal to either \c user_stride or \c element_stride. 74cdc920a0Smrg */ 75cdc920a0Smrg GLsizei true_stride; 76cdc920a0Smrg 77cdc920a0Smrg /** 78cdc920a0Smrg * Number of data values in each element. 79cdc920a0Smrg */ 80cdc920a0Smrg GLint count; 81cdc920a0Smrg 82cdc920a0Smrg /** 83cdc920a0Smrg * "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed). 84cdc920a0Smrg * This is used for mapping integral types to floating point types. 85cdc920a0Smrg */ 86cdc920a0Smrg GLboolean normalized; 87cdc920a0Smrg 88cdc920a0Smrg /** 89cdc920a0Smrg * Pre-calculated GLX protocol command header. 9001e04c3fSmrg * This contains two 16-bit words: the command length and the command 9101e04c3fSmrg * opcode. 92cdc920a0Smrg */ 9301e04c3fSmrg uint16_t header[2]; 94cdc920a0Smrg 95cdc920a0Smrg /** 96cdc920a0Smrg * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set 97cdc920a0Smrg * to \c GL_FALSE. 98cdc920a0Smrg */ 99cdc920a0Smrg GLboolean enabled; 100cdc920a0Smrg 101cdc920a0Smrg /** 102cdc920a0Smrg * For multi-arrayed data (e.g., texture coordinates, generic vertex 103cdc920a0Smrg * program attributes, etc.), this specifies which array this is. 104cdc920a0Smrg */ 105cdc920a0Smrg unsigned index; 106cdc920a0Smrg 107cdc920a0Smrg /** 108cdc920a0Smrg * Per-array-type key. For most arrays, this will be the GL enum for 109cdc920a0Smrg * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY 110cdc920a0Smrg * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, 111cdc920a0Smrg * etc.). 112cdc920a0Smrg */ 113cdc920a0Smrg GLenum key; 114cdc920a0Smrg 115cdc920a0Smrg /** 116cdc920a0Smrg * If this array can be used with the "classic" \c glDrawArrays protocol, 117cdc920a0Smrg * this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE. 118cdc920a0Smrg */ 119cdc920a0Smrg GLboolean old_DrawArrays_possible; 120cdc920a0Smrg}; 121cdc920a0Smrg 122cdc920a0Smrg 123cdc920a0Smrg/** 124cdc920a0Smrg * Array state that is pushed / poped by \c glPushClientAttrib and 125cdc920a0Smrg * \c glPopClientAttrib. 126cdc920a0Smrg */ 127cdc920a0Smrgstruct array_stack_state 128cdc920a0Smrg{ 129cdc920a0Smrg /** 130cdc920a0Smrg * Pointer to the application supplied data. 131cdc920a0Smrg */ 132cdc920a0Smrg const void *data; 133cdc920a0Smrg 134cdc920a0Smrg /** 135cdc920a0Smrg * Enum representing the type of the application supplied data. 136cdc920a0Smrg */ 137cdc920a0Smrg GLenum data_type; 138cdc920a0Smrg 139cdc920a0Smrg /** 140cdc920a0Smrg * Stride value supplied by the application. This value is not used 141cdc920a0Smrg * internally. It is only kept so that it can be queried by the 142cdc920a0Smrg * application using glGet*v. 143cdc920a0Smrg */ 144cdc920a0Smrg GLsizei user_stride; 145cdc920a0Smrg 146cdc920a0Smrg /** 147cdc920a0Smrg * Number of data values in each element. 148cdc920a0Smrg */ 149cdc920a0Smrg GLint count; 150cdc920a0Smrg 151cdc920a0Smrg /** 152cdc920a0Smrg * Per-array-type key. For most arrays, this will be the GL enum for 153cdc920a0Smrg * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY 154cdc920a0Smrg * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data, 155cdc920a0Smrg * etc.). 156cdc920a0Smrg */ 157cdc920a0Smrg GLenum key; 158cdc920a0Smrg 159cdc920a0Smrg /** 160cdc920a0Smrg * For multi-arrayed data (e.g., texture coordinates, generic vertex 161cdc920a0Smrg * program attributes, etc.), this specifies which array this is. 162cdc920a0Smrg */ 163cdc920a0Smrg unsigned index; 164cdc920a0Smrg 165cdc920a0Smrg /** 166cdc920a0Smrg * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set 167cdc920a0Smrg * to \c GL_FALSE. 168cdc920a0Smrg */ 169cdc920a0Smrg GLboolean enabled; 170cdc920a0Smrg}; 171cdc920a0Smrg 172cdc920a0Smrg 173cdc920a0Smrg/** 174cdc920a0Smrg * Collection of all the vertex array state. 175cdc920a0Smrg */ 176cdc920a0Smrgstruct array_state_vector 177cdc920a0Smrg{ 178cdc920a0Smrg /** 179cdc920a0Smrg * Number of arrays tracked by \c ::arrays. 180cdc920a0Smrg */ 181cdc920a0Smrg size_t num_arrays; 182cdc920a0Smrg 183cdc920a0Smrg /** 184cdc920a0Smrg * Array of vertex array state. This array contains all of the valid 185cdc920a0Smrg * vertex arrays. If a vertex array isn't in this array, then it isn't 186cdc920a0Smrg * valid. For example, if an implementation does not support 187cdc920a0Smrg * EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this 188cdc920a0Smrg * array. 189cdc920a0Smrg */ 190cdc920a0Smrg struct array_state *arrays; 191cdc920a0Smrg 192cdc920a0Smrg /** 193cdc920a0Smrg * Number of currently enabled client-side arrays. The value of this 194cdc920a0Smrg * field is only valid if \c array_info_cache_valid is true. 195cdc920a0Smrg */ 196cdc920a0Smrg size_t enabled_client_array_count; 197cdc920a0Smrg 198cdc920a0Smrg /** 199cdc920a0Smrg * \name ARRAY_INFO cache. 200cdc920a0Smrg * 201cdc920a0Smrg * These fields track the state of the ARRAY_INFO cache. The 202cdc920a0Smrg * \c array_info_cache_size is the size of the actual data stored in 203cdc920a0Smrg * \c array_info_cache. \c array_info_cache_buffer_size is the size of 204cdc920a0Smrg * the buffer. This will always be greater than or equal to 205cdc920a0Smrg * \c array_info_cache_size. 206cdc920a0Smrg * 207cdc920a0Smrg * \note 208cdc920a0Smrg * There are some bytes of extra data before \c array_info_cache that is 209cdc920a0Smrg * used to hold the header for RenderLarge commands. This is 210cdc920a0Smrg * \b not included in \c array_info_cache_size or 211cdc920a0Smrg * \c array_info_cache_buffer_size. \c array_info_cache_base stores a 212cdc920a0Smrg * pointer to the true start of the buffer (i.e., what malloc returned). 213cdc920a0Smrg */ 214cdc920a0Smrg /*@{ */ 215cdc920a0Smrg size_t array_info_cache_size; 216cdc920a0Smrg size_t array_info_cache_buffer_size; 217cdc920a0Smrg void *array_info_cache; 218cdc920a0Smrg void *array_info_cache_base; 219cdc920a0Smrg /*@} */ 220cdc920a0Smrg 221cdc920a0Smrg 222cdc920a0Smrg /** 223cdc920a0Smrg * Is the cache of ARRAY_INFO data valid? The cache can become invalid 224cdc920a0Smrg * when one of several state changes occur. Among these chages are 225cdc920a0Smrg * modifying the array settings for an enabled array and enabling / 226cdc920a0Smrg * disabling an array. 227cdc920a0Smrg */ 228cdc920a0Smrg GLboolean array_info_cache_valid; 229cdc920a0Smrg 230cdc920a0Smrg /** 231cdc920a0Smrg * Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use 232cdc920a0Smrg * of this protocol is disabled with really old servers (i.e., servers 233cdc920a0Smrg * that don't support GL 1.1 or EXT_vertex_arrays) or when an environment 234cdc920a0Smrg * variable is set. 235cdc920a0Smrg * 236cdc920a0Smrg * \todo 237cdc920a0Smrg * GL 1.1 and EXT_vertex_arrays use identical protocol, but have different 238cdc920a0Smrg * opcodes for \c glDrawArrays. For servers that advertise one or the 239cdc920a0Smrg * other, there should be a way to select which opcode to use. 240cdc920a0Smrg */ 241cdc920a0Smrg GLboolean old_DrawArrays_possible; 242cdc920a0Smrg 243cdc920a0Smrg /** 244cdc920a0Smrg * Is it possible to use the new GL X.X / ARB_vertex_buffer_object 245cdc920a0Smrg * protocol? 246cdc920a0Smrg * 247cdc920a0Smrg * \todo 248cdc920a0Smrg * This protocol has not yet been defined by the ARB, but is currently a 249cdc920a0Smrg * work in progress. This field is a place-holder. 250cdc920a0Smrg */ 251cdc920a0Smrg GLboolean new_DrawArrays_possible; 252cdc920a0Smrg 253cdc920a0Smrg /** 254cdc920a0Smrg * Active texture unit set by \c glClientActiveTexture. 255cdc920a0Smrg * 256cdc920a0Smrg * \sa __glXGetActiveTextureUnit 257cdc920a0Smrg */ 258cdc920a0Smrg unsigned active_texture_unit; 259cdc920a0Smrg 260cdc920a0Smrg /** 261cdc920a0Smrg * Number of supported texture units. Even if ARB_multitexture / 262cdc920a0Smrg * GL 1.3 are not supported, this will be at least 1. When multitexture 263cdc920a0Smrg * is supported, this will be the value queried by calling 264cdc920a0Smrg * \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS. 265cdc920a0Smrg * 266cdc920a0Smrg * \todo 267cdc920a0Smrg * Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS 268cdc920a0Smrg * instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program / 269cdc920a0Smrg * NV_fragment_program are supported). 270cdc920a0Smrg */ 271cdc920a0Smrg unsigned num_texture_units; 272cdc920a0Smrg 273cdc920a0Smrg /** 274cdc920a0Smrg * Number of generic vertex program attribs. If GL_ARB_vertex_program 275cdc920a0Smrg * is not supported, this will be zero. Otherwise it will be the value 276cdc920a0Smrg * queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB 277cdc920a0Smrg * and \c GL_MAX_PROGRAM_ATTRIBS_ARB. 278cdc920a0Smrg */ 279cdc920a0Smrg unsigned num_vertex_program_attribs; 280cdc920a0Smrg 281cdc920a0Smrg /** 282cdc920a0Smrg * \n Methods for implementing various GL functions. 283cdc920a0Smrg * 284cdc920a0Smrg * These method pointers are only valid \c array_info_cache_valid is set. 285cdc920a0Smrg * When each function starts, it much check \c array_info_cache_valid. 286cdc920a0Smrg * If it is not set, it must call \c fill_array_info_cache and call 287cdc920a0Smrg * the new method. 288cdc920a0Smrg * 289cdc920a0Smrg * \sa fill_array_info_cache 290cdc920a0Smrg * 291cdc920a0Smrg * \todo 292cdc920a0Smrg * Write code to plug these functions directly into the dispatch table. 293cdc920a0Smrg */ 294cdc920a0Smrg /*@{ */ 295cdc920a0Smrg void (*DrawArrays) (GLenum, GLint, GLsizei); 296cdc920a0Smrg void (*DrawElements) (GLenum mode, GLsizei count, GLenum type, 297cdc920a0Smrg const GLvoid * indices); 298cdc920a0Smrg /*@} */ 299cdc920a0Smrg 300cdc920a0Smrg struct array_stack_state *stack; 301cdc920a0Smrg unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; 302cdc920a0Smrg unsigned stack_index; 303cdc920a0Smrg}; 304cdc920a0Smrg 305cdc920a0Smrg#endif /* _INDIRECT_VA_PRIVATE_ */ 306