Path: blob/21.2-virgl/src/glx/indirect_vertex_array_priv.h
4558 views
/*1* (C) Copyright IBM Corporation 2004, 20052* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sub license,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* IBM,19* AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,20* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF21* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE22* SOFTWARE.23*/2425#ifndef _INDIRECT_VA_PRIVATE_26#define _INDIRECT_VA_PRIVATE_2728/**29* \file indirect_va_private.h30*31* \author Ian Romanick <[email protected]>32*/3334#include <inttypes.h>3536#include "glxclient.h"37#include "indirect.h"38#include <GL/glxproto.h>394041/**42* State descriptor for a single array of vertex data.43*/44struct array_state45{46/**47* Pointer to the application supplied data.48*/49const void *data;5051/**52* Enum representing the type of the application supplied data.53*/54GLenum data_type;5556/**57* Stride value supplied by the application. This value is not used58* internally. It is only kept so that it can be queried by the59* application using glGet*v.60*/61GLsizei user_stride;6263/**64* Calculated size, in bytes, of a single element in the array. This65* is calculated based on \c count and the size of the data type66* represented by \c data_type.67*/68GLsizei element_size;6970/**71* Actual byte-stride from one element to the next. This value will72* be equal to either \c user_stride or \c element_stride.73*/74GLsizei true_stride;7576/**77* Number of data values in each element.78*/79GLint count;8081/**82* "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).83* This is used for mapping integral types to floating point types.84*/85GLboolean normalized;8687/**88* Pre-calculated GLX protocol command header.89* This contains two 16-bit words: the command length and the command90* opcode.91*/92uint16_t header[2];9394/**95* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set96* to \c GL_FALSE.97*/98GLboolean enabled;99100/**101* For multi-arrayed data (e.g., texture coordinates, generic vertex102* program attributes, etc.), this specifies which array this is.103*/104unsigned index;105106/**107* Per-array-type key. For most arrays, this will be the GL enum for108* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY109* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,110* etc.).111*/112GLenum key;113114/**115* If this array can be used with the "classic" \c glDrawArrays protocol,116* this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.117*/118GLboolean old_DrawArrays_possible;119};120121122/**123* Array state that is pushed / poped by \c glPushClientAttrib and124* \c glPopClientAttrib.125*/126struct array_stack_state127{128/**129* Pointer to the application supplied data.130*/131const void *data;132133/**134* Enum representing the type of the application supplied data.135*/136GLenum data_type;137138/**139* Stride value supplied by the application. This value is not used140* internally. It is only kept so that it can be queried by the141* application using glGet*v.142*/143GLsizei user_stride;144145/**146* Number of data values in each element.147*/148GLint count;149150/**151* Per-array-type key. For most arrays, this will be the GL enum for152* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY153* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,154* etc.).155*/156GLenum key;157158/**159* For multi-arrayed data (e.g., texture coordinates, generic vertex160* program attributes, etc.), this specifies which array this is.161*/162unsigned index;163164/**165* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set166* to \c GL_FALSE.167*/168GLboolean enabled;169};170171172/**173* Collection of all the vertex array state.174*/175struct array_state_vector176{177/**178* Number of arrays tracked by \c ::arrays.179*/180size_t num_arrays;181182/**183* Array of vertex array state. This array contains all of the valid184* vertex arrays. If a vertex array isn't in this array, then it isn't185* valid. For example, if an implementation does not support186* EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this187* array.188*/189struct array_state *arrays;190191/**192* Number of currently enabled client-side arrays. The value of this193* field is only valid if \c array_info_cache_valid is true.194*/195size_t enabled_client_array_count;196197/**198* \name ARRAY_INFO cache.199*200* These fields track the state of the ARRAY_INFO cache. The201* \c array_info_cache_size is the size of the actual data stored in202* \c array_info_cache. \c array_info_cache_buffer_size is the size of203* the buffer. This will always be greater than or equal to204* \c array_info_cache_size.205*206* \note207* There are some bytes of extra data before \c array_info_cache that is208* used to hold the header for RenderLarge commands. This is209* \b not included in \c array_info_cache_size or210* \c array_info_cache_buffer_size. \c array_info_cache_base stores a211* pointer to the true start of the buffer (i.e., what malloc returned).212*/213/*@{ */214size_t array_info_cache_size;215size_t array_info_cache_buffer_size;216void *array_info_cache;217void *array_info_cache_base;218/*@} */219220221/**222* Is the cache of ARRAY_INFO data valid? The cache can become invalid223* when one of several state changes occur. Among these chages are224* modifying the array settings for an enabled array and enabling /225* disabling an array.226*/227GLboolean array_info_cache_valid;228229/**230* Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use231* of this protocol is disabled with really old servers (i.e., servers232* that don't support GL 1.1 or EXT_vertex_arrays) or when an environment233* variable is set.234*235* \todo236* GL 1.1 and EXT_vertex_arrays use identical protocol, but have different237* opcodes for \c glDrawArrays. For servers that advertise one or the238* other, there should be a way to select which opcode to use.239*/240GLboolean old_DrawArrays_possible;241242/**243* Is it possible to use the new GL X.X / ARB_vertex_buffer_object244* protocol?245*246* \todo247* This protocol has not yet been defined by the ARB, but is currently a248* work in progress. This field is a place-holder.249*/250GLboolean new_DrawArrays_possible;251252/**253* Active texture unit set by \c glClientActiveTexture.254*255* \sa __glXGetActiveTextureUnit256*/257unsigned active_texture_unit;258259/**260* Number of supported texture units. Even if ARB_multitexture /261* GL 1.3 are not supported, this will be at least 1. When multitexture262* is supported, this will be the value queried by calling263* \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS.264*265* \todo266* Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS267* instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /268* NV_fragment_program are supported).269*/270unsigned num_texture_units;271272/**273* Number of generic vertex program attribs. If GL_ARB_vertex_program274* is not supported, this will be zero. Otherwise it will be the value275* queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB276* and \c GL_MAX_PROGRAM_ATTRIBS_ARB.277*/278unsigned num_vertex_program_attribs;279280/**281* \n Methods for implementing various GL functions.282*283* These method pointers are only valid \c array_info_cache_valid is set.284* When each function starts, it much check \c array_info_cache_valid.285* If it is not set, it must call \c fill_array_info_cache and call286* the new method.287*288* \sa fill_array_info_cache289*290* \todo291* Write code to plug these functions directly into the dispatch table.292*/293/*@{ */294void (*DrawArrays) (GLenum, GLint, GLsizei);295void (*DrawElements) (GLenum mode, GLsizei count, GLenum type,296const GLvoid * indices);297/*@} */298299struct array_stack_state *stack;300unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];301unsigned stack_index;302};303304#endif /* _INDIRECT_VA_PRIVATE_ */305306307