mtypes.h 141 KB
Newer Older
Jouk Jansen's avatar
 
Jouk Jansen committed
1 2
/*
 * Mesa 3-D graphics library
3
 *
4 5
 * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
 * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
6
 *
Jouk Jansen's avatar
 
Jouk Jansen committed
7 8 9 10 11 12
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
13
 *
Jouk Jansen's avatar
 
Jouk Jansen committed
14 15
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
16
 *
Jouk Jansen's avatar
 
Jouk Jansen committed
17 18 19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 21 22 23
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
Jouk Jansen's avatar
 
Jouk Jansen committed
24 25
 */

26 27 28 29 30 31
/**
 * \file mtypes.h
 * Main Mesa data structures.
 *
 * Please try to mark derived values with a leading underscore ('_').
 */
Jouk Jansen's avatar
 
Jouk Jansen committed
32

Brian Paul's avatar
Brian Paul committed
33 34
#ifndef MTYPES_H
#define MTYPES_H
35

Jouk Jansen's avatar
 
Jouk Jansen committed
36

37
#include <stdint.h>             /* uint32_t */
38
#include <stdbool.h>
39
#include "c11/threads.h"
40

41 42
#include "main/glheader.h"
#include "main/config.h"
Brian Paul's avatar
Brian Paul committed
43
#include "glapi/glapi.h"
Jouk Jansen's avatar
 
Jouk Jansen committed
44
#include "math/m_matrix.h"	/* GLmatrix */
45
#include "compiler/shader_enums.h"
46
#include "main/formats.h"       /* MESA_FORMAT_COUNT */
47
#include "compiler/glsl/list.h"
Jouk Jansen's avatar
 
Jouk Jansen committed
48

49

50 51 52 53 54
#ifdef __cplusplus
extern "C" {
#endif


Ian Romanick's avatar
Ian Romanick committed
55 56 57 58 59 60 61
/**
 * \name 64-bit extension of GLbitfield.
 */
/*@{*/
typedef GLuint64 GLbitfield64;

/** Set a single bit */
62
#define BITFIELD64_BIT(b)      ((GLbitfield64)1 << (b))
63 64 65 66 67 68
/** Set all bits up to excluding bit b */
#define BITFIELD64_MASK(b)      \
   ((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
/** Set count bits starting from bit b  */
#define BITFIELD64_RANGE(b, count) \
   (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
Ian Romanick's avatar
Ian Romanick committed
69 70


71
/**
72
 * \name Some forward type declarations
Jouk Jansen's avatar
 
Jouk Jansen committed
73
 */
74
/*@{*/
Jouk Jansen's avatar
 
Jouk Jansen committed
75
struct _mesa_HashTable;
76
struct gl_attrib_node;
77
struct gl_list_extensions;
78
struct gl_meta_state;
79
struct gl_program_cache;
Jouk Jansen's avatar
 
Jouk Jansen committed
80
struct gl_texture_object;
81
struct gl_debug_state;
82
struct gl_context;
83
struct st_context;
84
struct gl_uniform_storage;
Brian Paul's avatar
Brian Paul committed
85 86
struct prog_instruction;
struct gl_program_parameter_list;
87 88
struct set;
struct set_entry;
89
struct vbo_context;
90
/*@}*/
Jouk Jansen's avatar
 
Jouk Jansen committed
91 92


93
/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
94
#define PRIM_MAX                 GL_PATCHES
95
#define PRIM_OUTSIDE_BEGIN_END   (PRIM_MAX + 1)
96
#define PRIM_UNKNOWN             (PRIM_MAX + 2)
97

98
/**
99
 * Determine if the given gl_varying_slot appears in the fragment shader.
100
 */
101 102
static inline GLboolean
_mesa_varying_slot_in_fs(gl_varying_slot slot)
103
{
104 105 106 107 108 109 110
   switch (slot) {
   case VARYING_SLOT_PSIZ:
   case VARYING_SLOT_BFC0:
   case VARYING_SLOT_BFC1:
   case VARYING_SLOT_EDGE:
   case VARYING_SLOT_CLIP_VERTEX:
   case VARYING_SLOT_LAYER:
111 112
   case VARYING_SLOT_TESS_LEVEL_OUTER:
   case VARYING_SLOT_TESS_LEVEL_INNER:
113 114 115 116
      return GL_FALSE;
   default:
      return GL_TRUE;
   }
117 118
}

119
/**
120 121
 * Indexes for all renderbuffers
 */
122 123 124 125 126 127 128 129 130 131
typedef enum
{
   /* the four standard color buffers */
   BUFFER_FRONT_LEFT,
   BUFFER_BACK_LEFT,
   BUFFER_FRONT_RIGHT,
   BUFFER_BACK_RIGHT,
   BUFFER_DEPTH,
   BUFFER_STENCIL,
   BUFFER_ACCUM,
Brian Paul's avatar
Brian Paul committed
132 133
   /* optional aux buffer */
   BUFFER_AUX0,
134 135 136 137 138 139 140 141 142 143 144
   /* generic renderbuffers */
   BUFFER_COLOR0,
   BUFFER_COLOR1,
   BUFFER_COLOR2,
   BUFFER_COLOR3,
   BUFFER_COLOR4,
   BUFFER_COLOR5,
   BUFFER_COLOR6,
   BUFFER_COLOR7,
   BUFFER_COUNT
} gl_buffer_index;
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167

/**
 * Bit flags for all renderbuffers
 */
#define BUFFER_BIT_FRONT_LEFT   (1 << BUFFER_FRONT_LEFT)
#define BUFFER_BIT_BACK_LEFT    (1 << BUFFER_BACK_LEFT)
#define BUFFER_BIT_FRONT_RIGHT  (1 << BUFFER_FRONT_RIGHT)
#define BUFFER_BIT_BACK_RIGHT   (1 << BUFFER_BACK_RIGHT)
#define BUFFER_BIT_AUX0         (1 << BUFFER_AUX0)
#define BUFFER_BIT_AUX1         (1 << BUFFER_AUX1)
#define BUFFER_BIT_AUX2         (1 << BUFFER_AUX2)
#define BUFFER_BIT_AUX3         (1 << BUFFER_AUX3)
#define BUFFER_BIT_DEPTH        (1 << BUFFER_DEPTH)
#define BUFFER_BIT_STENCIL      (1 << BUFFER_STENCIL)
#define BUFFER_BIT_ACCUM        (1 << BUFFER_ACCUM)
#define BUFFER_BIT_COLOR0       (1 << BUFFER_COLOR0)
#define BUFFER_BIT_COLOR1       (1 << BUFFER_COLOR1)
#define BUFFER_BIT_COLOR2       (1 << BUFFER_COLOR2)
#define BUFFER_BIT_COLOR3       (1 << BUFFER_COLOR3)
#define BUFFER_BIT_COLOR4       (1 << BUFFER_COLOR4)
#define BUFFER_BIT_COLOR5       (1 << BUFFER_COLOR5)
#define BUFFER_BIT_COLOR6       (1 << BUFFER_COLOR6)
#define BUFFER_BIT_COLOR7       (1 << BUFFER_COLOR7)
168

Brian Paul's avatar
Brian Paul committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
/**
 * Mask of all the color buffer bits (but not accum).
 */
#define BUFFER_BITS_COLOR  (BUFFER_BIT_FRONT_LEFT | \
                            BUFFER_BIT_BACK_LEFT | \
                            BUFFER_BIT_FRONT_RIGHT | \
                            BUFFER_BIT_BACK_RIGHT | \
                            BUFFER_BIT_AUX0 | \
                            BUFFER_BIT_COLOR0 | \
                            BUFFER_BIT_COLOR1 | \
                            BUFFER_BIT_COLOR2 | \
                            BUFFER_BIT_COLOR3 | \
                            BUFFER_BIT_COLOR4 | \
                            BUFFER_BIT_COLOR5 | \
                            BUFFER_BIT_COLOR6 | \
                            BUFFER_BIT_COLOR7)

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
/**
 * Framebuffer configuration (aka visual / pixelformat)
 * Note: some of these fields should be boolean, but it appears that
 * code in drivers/dri/common/util.c requires int-sized fields.
 */
struct gl_config
{
   GLboolean rgbMode;
   GLboolean floatMode;
   GLuint doubleBufferMode;
   GLuint stereoMode;

   GLboolean haveAccumBuffer;
   GLboolean haveDepthBuffer;
   GLboolean haveStencilBuffer;

   GLint redBits, greenBits, blueBits, alphaBits;	/* bits per comp */
   GLuint redMask, greenMask, blueMask, alphaMask;
   GLint rgbBits;		/* total bits for rgb */
   GLint indexBits;		/* total bits for colorindex */

   GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
   GLint depthBits;
   GLint stencilBits;

   GLint numAuxBuffers;

   GLint level;

   /* EXT_visual_rating / GLX 1.2 */
   GLint visualRating;

   /* EXT_visual_info / GLX 1.2 */
   GLint transparentPixel;
   /*    colors are floats scaled to ints */
   GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
   GLint transparentIndex;

   /* ARB_multisample / SGIS_multisample */
   GLint sampleBuffers;
   GLint samples;

   /* SGIX_pbuffer / GLX 1.3 */
   GLint maxPbufferWidth;
   GLint maxPbufferHeight;
   GLint maxPbufferPixels;
   GLint optimalPbufferWidth;   /* Only for SGIX_pbuffer. */
   GLint optimalPbufferHeight;  /* Only for SGIX_pbuffer. */

   /* OML_swap_method */
   GLint swapMethod;

   /* EXT_texture_from_pixmap */
   GLint bindToTextureRgb;
   GLint bindToTextureRgba;
   GLint bindToMipmapTexture;
   GLint bindToTextureTargets;
   GLint yInverted;
244 245 246

   /* EXT_framebuffer_sRGB */
   GLint sRGBCapable;
247 248 249
};


250 251
/**
 * \name Bit flags used for updating material values.
Jouk Jansen's avatar
 
Jouk Jansen committed
252
 */
253
/*@{*/
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
#define MAT_ATTRIB_FRONT_AMBIENT           0 
#define MAT_ATTRIB_BACK_AMBIENT            1
#define MAT_ATTRIB_FRONT_DIFFUSE           2 
#define MAT_ATTRIB_BACK_DIFFUSE            3
#define MAT_ATTRIB_FRONT_SPECULAR          4 
#define MAT_ATTRIB_BACK_SPECULAR           5
#define MAT_ATTRIB_FRONT_EMISSION          6
#define MAT_ATTRIB_BACK_EMISSION           7
#define MAT_ATTRIB_FRONT_SHININESS         8
#define MAT_ATTRIB_BACK_SHININESS          9
#define MAT_ATTRIB_FRONT_INDEXES           10
#define MAT_ATTRIB_BACK_INDEXES            11
#define MAT_ATTRIB_MAX                     12

#define MAT_ATTRIB_AMBIENT(f)  (MAT_ATTRIB_FRONT_AMBIENT+(f))  
#define MAT_ATTRIB_DIFFUSE(f)  (MAT_ATTRIB_FRONT_DIFFUSE+(f))  
#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) 
#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) 
#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
#define MAT_ATTRIB_INDEXES(f)  (MAT_ATTRIB_FRONT_INDEXES+(f))  

#define MAT_INDEX_AMBIENT  0
#define MAT_INDEX_DIFFUSE  1
#define MAT_INDEX_SPECULAR 2

#define MAT_BIT_FRONT_AMBIENT         (1<<MAT_ATTRIB_FRONT_AMBIENT)
#define MAT_BIT_BACK_AMBIENT          (1<<MAT_ATTRIB_BACK_AMBIENT)
#define MAT_BIT_FRONT_DIFFUSE         (1<<MAT_ATTRIB_FRONT_DIFFUSE)
#define MAT_BIT_BACK_DIFFUSE          (1<<MAT_ATTRIB_BACK_DIFFUSE)
#define MAT_BIT_FRONT_SPECULAR        (1<<MAT_ATTRIB_FRONT_SPECULAR)
#define MAT_BIT_BACK_SPECULAR         (1<<MAT_ATTRIB_BACK_SPECULAR)
#define MAT_BIT_FRONT_EMISSION        (1<<MAT_ATTRIB_FRONT_EMISSION)
#define MAT_BIT_BACK_EMISSION         (1<<MAT_ATTRIB_BACK_EMISSION)
#define MAT_BIT_FRONT_SHININESS       (1<<MAT_ATTRIB_FRONT_SHININESS)
#define MAT_BIT_BACK_SHININESS        (1<<MAT_ATTRIB_BACK_SHININESS)
#define MAT_BIT_FRONT_INDEXES         (1<<MAT_ATTRIB_FRONT_INDEXES)
#define MAT_BIT_BACK_INDEXES          (1<<MAT_ATTRIB_BACK_INDEXES)


#define FRONT_MATERIAL_BITS	(MAT_BIT_FRONT_EMISSION | 	\
				 MAT_BIT_FRONT_AMBIENT |	\
				 MAT_BIT_FRONT_DIFFUSE | 	\
				 MAT_BIT_FRONT_SPECULAR |	\
				 MAT_BIT_FRONT_SHININESS | 	\
				 MAT_BIT_FRONT_INDEXES)

#define BACK_MATERIAL_BITS	(MAT_BIT_BACK_EMISSION |	\
				 MAT_BIT_BACK_AMBIENT |		\
				 MAT_BIT_BACK_DIFFUSE |		\
				 MAT_BIT_BACK_SPECULAR |	\
				 MAT_BIT_BACK_SHININESS |	\
				 MAT_BIT_BACK_INDEXES)
Jouk Jansen's avatar
 
Jouk Jansen committed
306 307

#define ALL_MATERIAL_BITS	(FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
308
/*@}*/
Jouk Jansen's avatar
 
Jouk Jansen committed
309 310


311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
/**
 * Material state.
 */
struct gl_material
{
   GLfloat Attrib[MAT_ATTRIB_MAX][4];
};


/**
 * Light state flags.
 */
/*@{*/
#define LIGHT_SPOT         0x1
#define LIGHT_LOCAL_VIEWER 0x2
#define LIGHT_POSITIONAL   0x4
#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
/*@}*/


331
/**
332
 * Light source state.
333
 */
334 335
struct gl_light
{
336
   struct gl_light *next;	/**< double linked list with sentinel */
Jouk Jansen's avatar
 
Jouk Jansen committed
337 338
   struct gl_light *prev;

339 340 341 342
   GLfloat Ambient[4];		/**< ambient color */
   GLfloat Diffuse[4];		/**< diffuse color */
   GLfloat Specular[4];		/**< specular color */
   GLfloat EyePosition[4];	/**< position in eye coordinates */
343
   GLfloat SpotDirection[4];	/**< spotlight direction in eye coordinates */
Jouk Jansen's avatar
 
Jouk Jansen committed
344
   GLfloat SpotExponent;
Jouk Jansen's avatar
 
Jouk Jansen committed
345
   GLfloat SpotCutoff;		/**< in degrees */
346
   GLfloat _CosCutoff;		/**< = MAX(0, cos(SpotCutoff)) */
Jouk Jansen's avatar
 
Jouk Jansen committed
347 348 349
   GLfloat ConstantAttenuation;
   GLfloat LinearAttenuation;
   GLfloat QuadraticAttenuation;
350
   GLboolean Enabled;		/**< On/off flag */
Jouk Jansen's avatar
 
Jouk Jansen committed
351

352 353 354 355
   /** 
    * \name Derived fields
    */
   /*@{*/
356
   GLbitfield _Flags;		/**< Mask of LIGHT_x bits defined above */
Jouk Jansen's avatar
 
Jouk Jansen committed
357

358 359 360
   GLfloat _Position[4];	/**< position in eye/obj coordinates */
   GLfloat _VP_inf_norm[3];	/**< Norm direction to infinite light */
   GLfloat _h_inf_norm[3];	/**< Norm( _VP_inf_norm + <0,0,1> ) */
361
   GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
362
   GLfloat _VP_inf_spot_attenuation;
Jouk Jansen's avatar
 
Jouk Jansen committed
363

364 365 366 367
   GLfloat _MatAmbient[2][3];	/**< material ambient * light ambient */
   GLfloat _MatDiffuse[2][3];	/**< material diffuse * light diffuse */
   GLfloat _MatSpecular[2][3];	/**< material spec * light specular */
   /*@}*/
Jouk Jansen's avatar
 
Jouk Jansen committed
368 369 370
};


371
/**
372
 * Light model state.
373
 */
374 375
struct gl_lightmodel
{
376 377 378 379 380
   GLfloat Ambient[4];		/**< ambient color */
   GLboolean LocalViewer;	/**< Local (or infinite) view point? */
   GLboolean TwoSide;		/**< Two (or one) sided lighting? */
   GLenum ColorControl;		/**< either GL_SINGLE_COLOR
				 *    or GL_SEPARATE_SPECULAR_COLOR */
Jouk Jansen's avatar
 
Jouk Jansen committed
381 382 383
};


384
/**
385
 * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
Jouk Jansen's avatar
 
Jouk Jansen committed
386
 */
387 388
struct gl_accum_attrib
{
389
   GLfloat ClearColor[4];	/**< Accumulation buffer clear color */
Jouk Jansen's avatar
 
Jouk Jansen committed
390 391
};

392 393 394 395 396 397 398

/**
 * Used for storing clear color, texture border color, etc.
 * The float values are typically unclamped.
 */
union gl_color_union
{
399 400 401 402
   GLfloat f[4];
   GLint i[4];
   GLuint ui[4];
};
Jouk Jansen's avatar
 
Jouk Jansen committed
403

404

405
/**
406
 * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
407
 */
408 409
struct gl_colorbuffer_attrib
{
410 411 412 413
   GLuint ClearIndex;                      /**< Index for glClear */
   union gl_color_union ClearColor;        /**< Color for glClear, unclamped */
   GLuint IndexMask;                       /**< Color index write mask */
   GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; /**< Each flag is 0xff or 0x0 */
414

415
   GLenum DrawBuffer[MAX_DRAW_BUFFERS];	/**< Which buffer to draw into */
416 417 418 419 420 421 422

   /** 
    * \name alpha testing
    */
   /*@{*/
   GLboolean AlphaEnabled;		/**< Alpha test enabled flag */
   GLenum AlphaFunc;			/**< Alpha test function */
423
   GLfloat AlphaRefUnclamped;
424 425 426 427 428 429 430
   GLclampf AlphaRef;			/**< Alpha reference value */
   /*@}*/

   /** 
    * \name Blending
    */
   /*@{*/
431
   GLbitfield BlendEnabled;		/**< Per-buffer blend enable flags */
432

433 434
   /* NOTE: this does _not_ depend on fragment clamping or any other clamping
    * control, only on the fixed-pointness of the render target.
435 436 437
    * The query does however depend on fragment color clamping.
    */
   GLfloat BlendColorUnclamped[4];               /**< Blending color */
438
   GLfloat BlendColor[4];		/**< Blending color */
439

440 441 442 443 444 445 446 447
   struct
   {
      GLenum SrcRGB;             /**< RGB blend source term */
      GLenum DstRGB;             /**< RGB blend dest term */
      GLenum SrcA;               /**< Alpha blend source term */
      GLenum DstA;               /**< Alpha blend dest term */
      GLenum EquationRGB;        /**< GL_ADD, GL_SUBTRACT, etc. */
      GLenum EquationA;          /**< GL_ADD, GL_SUBTRACT, etc. */
448 449 450 451 452
      /**
       * Set if any blend factor uses SRC1.  Computed at the time blend factors
       * get set.
       */
      GLboolean _UsesDualSrc;
453 454 455 456 457
   } Blend[MAX_DRAW_BUFFERS];
   /** Are the blend func terms currently different for each buffer/target? */
   GLboolean _BlendFuncPerBuffer;
   /** Are the blend equations currently different for each buffer/target? */
   GLboolean _BlendEquationPerBuffer;
458 459 460 461 462 463 464 465
   /*@}*/

   /** 
    * \name Logic op
    */
   /*@{*/
   GLboolean IndexLogicOpEnabled;	/**< Color index logic op enabled flag */
   GLboolean ColorLogicOpEnabled;	/**< RGBA logic op enabled flag */
466 467
   GLenum LogicOp;			/**< Logic operator */

468 469 470
   /*@}*/

   GLboolean DitherFlag;		/**< Dither enable flag */
471

472
   GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
473
   GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
474
   GLenum ClampReadColor;     /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
475

476
   GLboolean sRGBEnabled;    /**< Framebuffer sRGB blending/updating requested */
Jouk Jansen's avatar
 
Jouk Jansen committed
477 478 479
};


480
/**
481
 * Current attribute group (GL_CURRENT_BIT).
482
 */
483 484
struct gl_current_attrib
{
485
   /**
486
    * \name Current vertex attributes (color, texcoords, etc).
487
    * \note Values are valid only after FLUSH_VERTICES has been called.
488 489
    * \note Index and Edgeflag current values are stored as floats in the 
    * SIX and SEVEN attribute slots.
490
    * \note We need double storage for 64-bit vertex attributes
Jouk Jansen's avatar
 
Jouk Jansen committed
491
    */
492
   GLfloat Attrib[VERT_ATTRIB_MAX][4*2];
493

494
   /**
495 496
    * \name Current raster position attributes (always up to date after a
    * glRasterPos call).
Jouk Jansen's avatar
 
Jouk Jansen committed
497
    */
498 499 500 501
   GLfloat RasterPos[4];
   GLfloat RasterDistance;
   GLfloat RasterColor[4];
   GLfloat RasterSecondaryColor[4];
502
   GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
503
   GLboolean RasterPosValid;
Jouk Jansen's avatar
 
Jouk Jansen committed
504 505 506
};


507
/**
508
 * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
509
 */
510 511
struct gl_depthbuffer_attrib
{
512
   GLenum Func;			/**< Function for depth buffer compare */
Keith Whitwell's avatar
Keith Whitwell committed
513
   GLclampd Clear;		/**< Value to clear depth buffer to */
514 515 516 517
   GLboolean Test;		/**< Depth buffering enabled flag */
   GLboolean Mask;		/**< Depth buffer writable? */
   GLboolean BoundsTest;        /**< GL_EXT_depth_bounds_test */
   GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
Jouk Jansen's avatar
 
Jouk Jansen committed
518 519 520
};


521
/**
522
 * Evaluator attribute group (GL_EVAL_BIT).
523
 */
524 525
struct gl_eval_attrib
{
526 527 528 529
   /**
    * \name Enable bits 
    */
   /*@{*/
Jouk Jansen's avatar
 
Jouk Jansen committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
   GLboolean Map1Color4;
   GLboolean Map1Index;
   GLboolean Map1Normal;
   GLboolean Map1TextureCoord1;
   GLboolean Map1TextureCoord2;
   GLboolean Map1TextureCoord3;
   GLboolean Map1TextureCoord4;
   GLboolean Map1Vertex3;
   GLboolean Map1Vertex4;
   GLboolean Map2Color4;
   GLboolean Map2Index;
   GLboolean Map2Normal;
   GLboolean Map2TextureCoord1;
   GLboolean Map2TextureCoord2;
   GLboolean Map2TextureCoord3;
   GLboolean Map2TextureCoord4;
   GLboolean Map2Vertex3;
   GLboolean Map2Vertex4;
   GLboolean AutoNormal;
549 550 551 552 553 554
   /*@}*/
   
   /**
    * \name Map Grid endpoints and divisions and calculated du values
    */
   /*@{*/
Jouk Jansen's avatar
 
Jouk Jansen committed
555 556 557 558 559
   GLint MapGrid1un;
   GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
   GLint MapGrid2un, MapGrid2vn;
   GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
   GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
560
   /*@}*/
Jouk Jansen's avatar
 
Jouk Jansen committed
561 562 563
};


564
/**
565
 * Fog attribute group (GL_FOG_BIT).
566
 */
567 568
struct gl_fog_attrib
{
569
   GLboolean Enabled;		/**< Fog enabled flag */
570
   GLboolean ColorSumEnabled;
571
   GLfloat ColorUnclamped[4];            /**< Fog color */
572 573 574 575 576 577
   GLfloat Color[4];		/**< Fog color */
   GLfloat Density;		/**< Density >= 0.0 */
   GLfloat Start;		/**< Start distance in eye coords */
   GLfloat End;			/**< End distance in eye coords */
   GLfloat Index;		/**< Fog index */
   GLenum Mode;			/**< Fog mode */
Jouk Jansen's avatar
 
Jouk Jansen committed
578
   GLenum FogCoordinateSource;  /**< GL_EXT_fog_coord */
Michal Krol's avatar
Michal Krol committed
579
   GLfloat _Scale;		/**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
580
   GLenum FogDistanceMode;     /**< GL_NV_fog_distance */
Jouk Jansen's avatar
 
Jouk Jansen committed
581 582 583
};


584
/** 
585
 * Hint attribute group (GL_HINT_BIT).
586 587 588
 * 
 * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
 */
589 590
struct gl_hint_attrib
{
Jouk Jansen's avatar
 
Jouk Jansen committed
591 592 593 594 595
   GLenum PerspectiveCorrection;
   GLenum PointSmooth;
   GLenum LineSmooth;
   GLenum PolygonSmooth;
   GLenum Fog;
596
   GLenum TextureCompression;   /**< GL_ARB_texture_compression */
Brian Paul's avatar
Brian Paul committed
597
   GLenum GenerateMipmap;       /**< GL_SGIS_generate_mipmap */
Michal Krol's avatar
Michal Krol committed
598
   GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
Jouk Jansen's avatar
 
Jouk Jansen committed
599 600
};

Brian Paul's avatar
Brian Paul committed
601

602
/**
603
 * Lighting attribute group (GL_LIGHT_BIT).
604
 */
605 606 607
struct gl_light_attrib
{
   struct gl_light Light[MAX_LIGHTS];	/**< Array of light sources */
608
   struct gl_lightmodel Model;		/**< Lighting model */
Keith Whitwell's avatar
Keith Whitwell committed
609

610
   /**
611 612
    * Front and back material values.
    * Note: must call FLUSH_VERTICES() before using.
Keith Whitwell's avatar
Keith Whitwell committed
613
    */
614
   struct gl_material Material;
615 616

   GLboolean Enabled;			/**< Lighting enabled flag */
Dave Airlie's avatar
Dave Airlie committed
617 618
   GLboolean ColorMaterialEnabled;

619
   GLenum ShadeModel;			/**< GL_FLAT or GL_SMOOTH */
620
   GLenum ProvokingVertex;              /**< GL_EXT_provoking_vertex */
621 622
   GLenum ColorMaterialFace;		/**< GL_FRONT, BACK or FRONT_AND_BACK */
   GLenum ColorMaterialMode;		/**< GL_AMBIENT, GL_DIFFUSE, etc */
623
   GLbitfield _ColorMaterialBitmask;	/**< bitmask formed from Face and Mode */
Jouk Jansen's avatar
 
Jouk Jansen committed
624

Dave Airlie's avatar
Dave Airlie committed
625 626 627

   GLboolean _ClampVertexColor;
   GLenum ClampVertexColor;             /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
Jouk Jansen's avatar
 
Jouk Jansen committed
628

629
   /** 
630
    * Derived state for optimizations: 
631 632 633 634
    */
   /*@{*/
   GLboolean _NeedEyeCoords;		
   GLboolean _NeedVertices;		/**< Use fast shader? */
Dave Airlie's avatar
Dave Airlie committed
635 636
   struct gl_light EnabledList;         /**< List sentinel */

Jouk Jansen's avatar
 
Jouk Jansen committed
637
   GLfloat _BaseColor[2][3];
638
   /*@}*/
Jouk Jansen's avatar
 
Jouk Jansen committed
639 640 641
};


642
/**
643
 * Line attribute group (GL_LINE_BIT).
644
 */
645 646
struct gl_line_attrib
{
647 648 649 650 651
   GLboolean SmoothFlag;	/**< GL_LINE_SMOOTH enabled? */
   GLboolean StippleFlag;	/**< GL_LINE_STIPPLE enabled? */
   GLushort StipplePattern;	/**< Stipple pattern */
   GLint StippleFactor;		/**< Stipple repeat factor */
   GLfloat Width;		/**< Line width */
Jouk Jansen's avatar
 
Jouk Jansen committed
652 653 654
};


655
/**
656
 * Display list attribute group (GL_LIST_BIT).
657
 */
658 659
struct gl_list_attrib
{
Jouk Jansen's avatar
 
Jouk Jansen committed
660 661 662
   GLuint ListBase;
};

Brian Paul's avatar
Brian Paul committed
663

664
/**
665
 * Multisample attribute group (GL_MULTISAMPLE_BIT).
666
 */
667 668
struct gl_multisample_attrib
{
669 670 671 672 673
   GLboolean Enabled;
   GLboolean SampleAlphaToCoverage;
   GLboolean SampleAlphaToOne;
   GLboolean SampleCoverage;
   GLboolean SampleCoverageInvert;
674
   GLboolean SampleShading;
Chris Forbes's avatar
Chris Forbes committed
675 676 677

   /* ARB_texture_multisample / GL3.2 additions */
   GLboolean SampleMask;
678 679 680 681

   GLfloat SampleCoverageValue;
   GLfloat MinSampleShadingValue;

682 683
   /** The GL spec defines this as an array but >32x MSAA is madness */
   GLbitfield SampleMaskValue;
684 685 686
};


Brian's avatar
Brian committed
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
/**
 * A pixelmap (see glPixelMap)
 */
struct gl_pixelmap
{
   GLint Size;
   GLfloat Map[MAX_PIXEL_MAP_TABLE];
};


/**
 * Collection of all pixelmaps
 */
struct gl_pixelmaps
{
   struct gl_pixelmap RtoR;  /**< i.e. GL_PIXEL_MAP_R_TO_R */
   struct gl_pixelmap GtoG;
   struct gl_pixelmap BtoB;
   struct gl_pixelmap AtoA;
   struct gl_pixelmap ItoR;
   struct gl_pixelmap ItoG;
   struct gl_pixelmap ItoB;
   struct gl_pixelmap ItoA;
   struct gl_pixelmap ItoI;
   struct gl_pixelmap StoS;
};


715
/**
716
 * Pixel attribute group (GL_PIXEL_MODE_BIT).
717
 */
718 719
struct gl_pixel_attrib
{
720
   GLenum ReadBuffer;		/**< source buffer for glRead/CopyPixels() */
Brian's avatar
Brian committed
721 722 723 724

   /*--- Begin Pixel Transfer State ---*/
   /* Fields are in the order in which they're applied... */

725 726
   /** Scale & Bias (index shift, offset) */
   /*@{*/
Jouk Jansen's avatar
 
Jouk Jansen committed
727 728 729 730 731 732
   GLfloat RedBias, RedScale;
   GLfloat GreenBias, GreenScale;
   GLfloat BlueBias, BlueScale;
   GLfloat AlphaBias, AlphaScale;
   GLfloat DepthBias, DepthScale;
   GLint IndexShift, IndexOffset;
733
   /*@}*/
Brian's avatar
Brian committed
734 735 736

   /* Pixel Maps */
   /* Note: actual pixel maps are not part of this attrib group */
Jouk Jansen's avatar
 
Jouk Jansen committed
737 738
   GLboolean MapColorFlag;
   GLboolean MapStencilFlag;
Brian's avatar
Brian committed
739 740 741

   /*--- End Pixel Transfer State ---*/

Brian Paul's avatar
Brian Paul committed
742
   /** glPixelZoom */
Brian's avatar
Brian committed
743
   GLfloat ZoomX, ZoomY;
Jouk Jansen's avatar
 
Jouk Jansen committed
744 745 746
};


747
/**
748
 * Point attribute group (GL_POINT_BIT).
749
 */
750 751
struct gl_point_attrib
{
752 753 754 755
   GLfloat Size;		/**< User-specified point size */
   GLfloat Params[3];		/**< GL_EXT_point_parameters */
   GLfloat MinSize, MaxSize;	/**< GL_EXT_point_parameters */
   GLfloat Threshold;		/**< GL_EXT_point_parameters */
Dave Airlie's avatar
Dave Airlie committed
756
   GLboolean SmoothFlag;	/**< True if GL_POINT_SMOOTH is enabled */
757
   GLboolean _Attenuated;	/**< True if Params != [1, 0, 0] */
758
   GLboolean PointSprite;	/**< GL_NV/ARB_point_sprite */
759
   GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
760
   GLenum SpriteRMode;		/**< GL_NV_point_sprite (only!) */
761
   GLenum SpriteOrigin;		/**< GL_ARB_point_sprite */
Jouk Jansen's avatar
 
Jouk Jansen committed
762 763 764
};


765
/**
766
 * Polygon attribute group (GL_POLYGON_BIT).
767
 */
768 769
struct gl_polygon_attrib
{
770 771 772 773 774 775 776 777 778 779
   GLenum FrontFace;		/**< Either GL_CW or GL_CCW */
   GLenum FrontMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
   GLenum BackMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
   GLboolean _FrontBit;		/**< 0=GL_CCW, 1=GL_CW */
   GLboolean CullFlag;		/**< Culling on/off flag */
   GLboolean SmoothFlag;	/**< True if GL_POLYGON_SMOOTH is enabled */
   GLboolean StippleFlag;	/**< True if GL_POLYGON_STIPPLE is enabled */
   GLenum CullFaceMode;		/**< Culling mode GL_FRONT or GL_BACK */
   GLfloat OffsetFactor;	/**< Polygon offset factor, from user */
   GLfloat OffsetUnits;		/**< Polygon offset units, from user */
780
   GLfloat OffsetClamp;		/**< Polygon offset clamp, from user */
781 782 783
   GLboolean OffsetPoint;	/**< Offset in GL_POINT mode */
   GLboolean OffsetLine;	/**< Offset in GL_LINE mode */
   GLboolean OffsetFill;	/**< Offset in GL_FILL mode */
Jouk Jansen's avatar
 
Jouk Jansen committed
784 785 786
};


787
/**
788
 * Scissor attributes (GL_SCISSOR_BIT).
789
 */
790
struct gl_scissor_rect
791
{
792 793
   GLint X, Y;			/**< Lower left corner of box */
   GLsizei Width, Height;	/**< Size of box */
Jouk Jansen's avatar
 
Jouk Jansen committed
794
};
795 796 797 798 799
struct gl_scissor_attrib
{
   GLbitfield EnableFlags;	/**< Scissor test enabled? */
   struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
};
Jouk Jansen's avatar
 
Jouk Jansen committed
800 801


802
/**
803
 * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
804 805 806 807 808 809 810 811 812 813 814 815 816
 *
 * Three sets of stencil data are tracked so that OpenGL 2.0,
 * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
 * simultaneously.  In each of the stencil state arrays, element 0 corresponds
 * to GL_FRONT.  Element 1 corresponds to the OpenGL 2.0 /
 * GL_ATI_separate_stencil GL_BACK state.  Element 2 corresponds to the
 * GL_EXT_stencil_two_side GL_BACK state.
 *
 * The derived value \c _BackFace is either 1 or 2 depending on whether or
 * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
 *
 * The derived value \c _TestTwoSide is set when the front-face and back-face
 * stencil state are different.
817
 */
818 819
struct gl_stencil_attrib
{
820 821
   GLboolean Enabled;		/**< Enabled flag */
   GLboolean TestTwoSide;	/**< GL_EXT_stencil_two_side */
822
   GLubyte ActiveFace;		/**< GL_EXT_stencil_two_side (0 or 2) */
823
   GLboolean _Enabled;          /**< Enabled and stencil buffer present */
824
   GLboolean _WriteEnabled;     /**< _Enabled and non-zero writemasks */
825
   GLboolean _TestTwoSide;
826
   GLubyte _BackFace;           /**< Current back stencil state (1 or 2) */
827 828 829 830 831 832 833
   GLenum Function[3];		/**< Stencil function */
   GLenum FailFunc[3];		/**< Fail function */
   GLenum ZPassFunc[3];		/**< Depth buffer pass function */
   GLenum ZFailFunc[3];		/**< Depth buffer fail function */
   GLint Ref[3];		/**< Reference value */
   GLuint ValueMask[3];		/**< Value mask */
   GLuint WriteMask[3];		/**< Write mask */
834
   GLuint Clear;		/**< Clear value */
Jouk Jansen's avatar
 
Jouk Jansen committed
835 836 837
};


838
/**
839
 * An index for each type of texture object.  These correspond to the GL
Brian Paul's avatar
Brian Paul committed
840
 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
841
 * Note: the order is from highest priority to lowest priority.
842
 */
843 844
typedef enum
{
845 846
   TEXTURE_2D_MULTISAMPLE_INDEX,
   TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX,
847
   TEXTURE_CUBE_ARRAY_INDEX,
848
   TEXTURE_BUFFER_INDEX,
849 850
   TEXTURE_2D_ARRAY_INDEX,
   TEXTURE_1D_ARRAY_INDEX,
851
   TEXTURE_EXTERNAL_INDEX,
852 853 854 855 856 857
   TEXTURE_CUBE_INDEX,
   TEXTURE_3D_INDEX,
   TEXTURE_RECT_INDEX,
   TEXTURE_2D_INDEX,
   TEXTURE_1D_INDEX,
   NUM_TEXTURE_TARGETS
858
} gl_texture_index;
859

Brian Paul's avatar
Brian Paul committed
860

861 862 863 864
/**
 * Bit flags for each type of texture object
 */
/*@{*/
865 866
#define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
#define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
867
#define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
868
#define TEXTURE_BUFFER_BIT   (1 << TEXTURE_BUFFER_INDEX)
869 870
#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
871
#define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
872
#define TEXTURE_CUBE_BIT     (1 << TEXTURE_CUBE_INDEX)
873
#define TEXTURE_3D_BIT       (1 << TEXTURE_3D_INDEX)
874
#define TEXTURE_RECT_BIT     (1 << TEXTURE_RECT_INDEX)
875 876
#define TEXTURE_2D_BIT       (1 << TEXTURE_2D_INDEX)
#define TEXTURE_1D_BIT       (1 << TEXTURE_1D_INDEX)
877
/*@}*/
Brian Paul's avatar
Brian Paul committed
878 879


880
/**
881 882
 * Texture image state.  Drivers will typically create a subclass of this
 * with extra fields for memory buffers, etc.
883
 */
884 885
struct gl_texture_image
{
886
   GLint InternalFormat;	/**< Internal format as given by the user */
887
   GLenum _BaseFormat;		/**< Either GL_RGB, GL_RGBA, GL_ALPHA,
Brian Paul's avatar
Brian Paul committed
888
				 *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
889 890 891
				 *   GL_INTENSITY, GL_DEPTH_COMPONENT or
				 *   GL_DEPTH_STENCIL_EXT only. Used for
				 *   choosing TexEnv arithmetic.
Jouk Jansen's avatar
 
Jouk Jansen committed
892
				 */
893
   mesa_format TexFormat;         /**< The actual texture memory format */
894

895 896 897 898 899 900 901 902 903 904
   GLuint Border;		/**< 0 or 1 */
   GLuint Width;		/**< = 2^WidthLog2 + 2*Border */
   GLuint Height;		/**< = 2^HeightLog2 + 2*Border */
   GLuint Depth;		/**< = 2^DepthLog2 + 2*Border */
   GLuint Width2;		/**< = Width - 2*Border */
   GLuint Height2;		/**< = Height - 2*Border */
   GLuint Depth2;		/**< = Depth - 2*Border */
   GLuint WidthLog2;		/**< = log2(Width2) */
   GLuint HeightLog2;		/**< = log2(Height2) */
   GLuint DepthLog2;		/**< = log2(Depth2) */
905 906
   GLuint MaxNumLevels;		/**< = maximum possible number of mipmap
                                       levels, computed from the dimensions */
907

Brian Paul's avatar
Brian Paul committed
908
   struct gl_texture_object *TexObject;  /**< Pointer back to parent object */
909 910 911
   GLuint Level;                /**< Which mipmap level am I? */
   /** Cube map face: index into gl_texture_object::Image[] array */
   GLuint Face;
912 913

   /** GL_ARB_texture_multisample */
914 915
   GLuint NumSamples;            /**< Sample count, or 0 for non-multisample */
   GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */
Jouk Jansen's avatar
 
Jouk Jansen committed
916 917
};

918 919 920 921

/**
 * Indexes for cube map faces.
 */
922 923 924 925 926 927 928 929 930 931
typedef enum
{
   FACE_POS_X = 0,
   FACE_NEG_X = 1,
   FACE_POS_Y = 2,
   FACE_NEG_Y = 3,
   FACE_POS_Z = 4,
   FACE_NEG_Z = 5,
   MAX_FACES = 6
} gl_face_index;
932

Jouk Jansen's avatar
 
Jouk Jansen committed
933

934
/**
935 936
 * Sampler object state.  These objects are new with GL_ARB_sampler_objects
 * and OpenGL 3.3.  Legacy texture objects also contain a sampler object.
937
 */
938
struct gl_sampler_object
939
{
940
   mtx_t Mutex;
941 942
   GLuint Name;
   GLint RefCount;
943
   GLchar *Label;               /**< GL_KHR_debug */
944

945 946 947
   GLenum WrapS;		/**< S-axis texture image wrap mode */
   GLenum WrapT;		/**< T-axis texture image wrap mode */
   GLenum WrapR;		/**< R-axis texture image wrap mode */
948 949
   GLenum MinFilter;		/**< minification filter */
   GLenum MagFilter;		/**< magnification filter */
950
   union gl_color_union BorderColor;  /**< Interpreted according to texture format */
951 952
   GLfloat MinLod;		/**< min lambda, OpenGL 1.2 */
   GLfloat MaxLod;		/**< max lambda, OpenGL 1.2 */
953
   GLfloat LodBias;		/**< OpenGL 1.4 */
954 955 956
   GLfloat MaxAnisotropy;	/**< GL_EXT_texture_filter_anisotropic */
   GLenum CompareMode;		/**< GL_ARB_shadow */
   GLenum CompareFunc;		/**< GL_ARB_shadow */
957
   GLenum sRGBDecode;           /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
958
   GLboolean CubeMapSeamless;   /**< GL_AMD_seamless_cubemap_per_texture */
959 960 961 962 963
};


/**
 * Texture object state.  Contains the array of mipmap images, border color,
964
 * wrap modes, filter modes, and shadow/texcompare state.
965 966 967
 */
struct gl_texture_object
{
968
   mtx_t Mutex;      /**< for thread safety */
969 970
   GLint RefCount;             /**< reference count */
   GLuint Name;                /**< the user-visible texture object ID */
971
   GLchar *Label;               /**< GL_KHR_debug */
972
   GLenum Target;              /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
973 974
   gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
                                      Only valid when Target is valid. */
975 976 977

   struct gl_sampler_object Sampler;

978
   GLenum DepthMode;           /**< GL_ARB_depth_texture */
979
   bool StencilSampling;       /**< Should we sample stencil instead of depth? */
980 981 982 983 984 985

   GLfloat Priority;           /**< in [0,1] */
   GLint BaseLevel;            /**< min mipmap level, OpenGL 1.2 */
   GLint MaxLevel;             /**< max mipmap level, OpenGL 1.2 */
   GLint ImmutableLevels;      /**< ES 3.0 / ARB_texture_view */
   GLint _MaxLevel;            /**< actual max mipmap level (q in the spec) */
986
   GLfloat _MaxLambda;         /**< = _MaxLevel - BaseLevel (q - p in spec) */
987 988 989 990 991 992 993 994 995 996 997
   GLint CropRect[4];          /**< GL_OES_draw_texture */
   GLenum Swizzle[4];          /**< GL_EXT_texture_swizzle */
   GLuint _Swizzle;            /**< same as Swizzle, but SWIZZLE_* format */
   GLboolean GenerateMipmap;   /**< GL_SGIS_generate_mipmap */
   GLboolean _BaseComplete;    /**< Is the base texture level valid? */
   GLboolean _MipmapComplete;  /**< Is the whole mipmap valid? */
   GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */
   GLboolean _RenderToTexture; /**< Any rendering to this texture? */
   GLboolean Purgeable;        /**< Is the buffer purgeable under memory
                                    pressure? */
   GLboolean Immutable;        /**< GL_ARB_texture_storage */
998 999
   GLboolean _IsFloat;         /**< GL_OES_float_texture */
   GLboolean _IsHalfFloat;     /**< GL_OES_half_float_texture */
1000

1001 1002 1003 1004 1005
   GLuint MinLevel;            /**< GL_ARB_texture_view */
   GLuint MinLayer;            /**< GL_ARB_texture_view */
   GLuint NumLevels;           /**< GL_ARB_texture_view */
   GLuint NumLayers;           /**< GL_ARB_texture_view */

1006
   /** Actual texture images, indexed by [cube face] and [mipmap level] */
1007
   struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
Jouk Jansen's avatar
 
Jouk Jansen committed
1008

1009 1010 1011
   /** GL_ARB_texture_buffer_object */
   struct gl_buffer_object *BufferObject;
   GLenum BufferObjectFormat;
1012
   /** Equivalent Mesa format for BufferObjectFormat. */
1013
   mesa_format _BufferObjectFormat;
1014 1015 1016
   /** GL_ARB_texture_buffer_range */
   GLintptr BufferOffset;
   GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
1017

1018 1019
   /** GL_OES_EGL_image_external */
   GLint RequiredTextureImageUnits;
1020 1021 1022

   /** GL_ARB_shader_image_load_store */
   GLenum ImageFormatCompatibilityType;
Jouk Jansen's avatar
 
Jouk Jansen committed
1023 1024
};

1025

Brian Paul's avatar
Brian Paul committed
1026 1027 1028 1029
/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
#define MAX_COMBINER_TERMS 4


1030 1031 1032
/**
 * Texture combine environment state.
 */
1033 1034
struct gl_tex_env_combine_state
{
1035 1036
   GLenum ModeRGB;       /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
   GLenum ModeA;         /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
Brian Paul's avatar
Brian Paul committed
1037 1038 1039 1040 1041 1042
   /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
   GLenum SourceRGB[MAX_COMBINER_TERMS];
   GLenum SourceA[MAX_COMBINER_TERMS];
   /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
   GLenum OperandRGB[MAX_COMBINER_TERMS];
   GLenum OperandA[MAX_COMBINER_TERMS];
1043 1044
   GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
   GLuint ScaleShiftA;   /**< 0, 1 or 2 */
1045 1046
   GLuint _NumArgsRGB;   /**< Number of inputs used for the RGB combiner */
   GLuint _NumArgsA;     /**< Number of inputs used for the A combiner */
1047
};
Jouk Jansen's avatar
 
Jouk Jansen committed
1048

1049

1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
/**
 * TexGenEnabled flags.
 */
/*@{*/
#define S_BIT 1
#define T_BIT 2
#define R_BIT 4
#define Q_BIT 8
#define STR_BITS (S_BIT | T_BIT | R_BIT)
/*@}*/


/**
 * Bit flag versions of the corresponding GL_ constants.
 */
/*@{*/
#define TEXGEN_SPHERE_MAP        0x1
#define TEXGEN_OBJ_LINEAR        0x2
#define TEXGEN_EYE_LINEAR        0x4
#define TEXGEN_REFLECTION_MAP_NV 0x8
#define TEXGEN_NORMAL_MAP_NV     0x10

#define TEXGEN_NEED_NORMALS      (TEXGEN_SPHERE_MAP        | \
				  TEXGEN_REFLECTION_MAP_NV | \
				  TEXGEN_NORMAL_MAP_NV)
#define TEXGEN_NEED_EYE_COORD    (TEXGEN_SPHERE_MAP        | \
				  TEXGEN_REFLECTION_MAP_NV | \
				  TEXGEN_NORMAL_MAP_NV     | \
				  TEXGEN_EYE_LINEAR)
/*@}*/



/** Tex-gen enabled for texture unit? */
#define ENABLE_TEXGEN(unit) (1 << (unit))

/** Non-identity texture matrix for texture unit? */
#define ENABLE_TEXMAT(unit) (1 << (unit))


Brian Paul's avatar
Brian Paul committed
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
/**
 * Texture coord generation state.
 */
struct gl_texgen
{
   GLenum Mode;         /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
   GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
   GLfloat ObjectPlane[4];
   GLfloat EyePlane[4];
};


1102
/**
1103
 * Texture unit state.  Contains enable flags, texture environment/function/
1104
 * combiners, texgen state, and pointers to current texture objects.
1105
 */
1106 1107
struct gl_texture_unit
{
1108
   GLbitfield Enabled;          /**< bitmask of TEXTURE_*_BIT flags */
Jouk Jansen's avatar
 
Jouk Jansen committed
1109

1110
   GLenum EnvMode;              /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
1111 1112
   GLclampf EnvColor[4];
   GLfloat EnvColorUnclamped[4];
Brian Paul's avatar
Brian Paul committed
1113 1114 1115 1116 1117

   struct gl_texgen GenS;
   struct gl_texgen GenT;
   struct gl_texgen GenR;
   struct gl_texgen GenQ;
1118
   GLbitfield TexGenEnabled;	/**< Bitwise-OR of [STRQ]_BIT values */
Brian Paul's avatar
Brian Paul committed
1119 1120
   GLbitfield _GenFlags;	/**< Bitwise-OR of Gen[STRQ]._ModeBit */

1121 1122
   GLfloat LodBias;		/**< for biasing mipmap levels */

Dave Airlie's avatar
Dave Airlie committed
1123 1124 1125
   /** Texture targets that have a non-default texture bound */
   GLbitfield _BoundTextures;

1126 1127 1128
   /** Current sampler object (GL_ARB_sampler_objects) */
   struct gl_sampler_object *Sampler;

1129 1130 1131
   /** 
    * \name GL_EXT_texture_env_combine 
    */
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
   struct gl_tex_env_combine_state Combine;

   /**
    * Derived state based on \c EnvMode and the \c BaseFormat of the
    * currently enabled texture.
    */
   struct gl_tex_env_combine_state _EnvMode;

   /**
    * Currently enabled combiner state.  This will point to either
    * \c Combine or \c _EnvMode.
    */
   struct gl_tex_env_combine_state *_CurrentCombine;
Jouk Jansen's avatar
 
Jouk Jansen committed
1145

1146 1147 1148 1149 1150
   /** Current texture object pointers */
   struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];

   /** Points to highest priority, complete and enabled texture object */
   struct gl_texture_object *_Current;
1151

Jouk Jansen's avatar
 
Jouk Jansen committed
1152 1153
};

1154

1155
/**
1156
 * Texture attribute group (GL_TEXTURE_BIT).
1157
 */
1158 1159
struct gl_texture_attrib
{
1160
   GLuint CurrentUnit;   /**< GL_ACTIVE_TEXTURE */
Dave Airlie's avatar
Dave Airlie committed
1161 1162 1163

   /** GL_ARB_seamless_cubemap */
   GLboolean CubeMapSeamless;
1164

1165
   struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
Jouk Jansen's avatar
 
Jouk Jansen committed
1166

1167 1168 1169
   /** GL_ARB_texture_buffer_object */
   struct gl_buffer_object *BufferObject;

1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
   /** Texture coord units/sets used for fragment texturing */
   GLbitfield _EnabledCoordUnits;

   /** Texture coord units that have texgen enabled */
   GLbitfield _TexGenEnabled;

   /** Texture coord units that have non-identity matrices */
   GLbitfield _TexMatEnabled;

   /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
   GLbitfield _GenFlags;
1181

1182
   /** Largest index of a texture unit with _Current != NULL. */
1183
   GLint _MaxEnabledTexImageUnit;
1184 1185 1186

   /** Largest index + 1 of texture units that have had any CurrentTex set. */
   GLint NumCurrentTexUsed;
Dave Airlie's avatar
Dave Airlie committed
1187 1188

   struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
Jouk Jansen's avatar
 
Jouk Jansen committed
1189 1190 1191
};


1192 1193 1194 1195 1196 1197 1198
/**
 * Data structure representing a single clip plane (e.g. one of the elements
 * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
 */
typedef GLfloat gl_clip_plane[4];


1199
/**
1200
 * Transformation attribute group (GL_TRANSFORM_BIT).
1201
 */
1202 1203
struct gl_transform_attrib
{
1204
   GLenum MatrixMode;				/**< Matrix mode */
1205 1206
   gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES];	/**< User clip planes */
   gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
1207
   GLbitfield ClipPlanesEnabled;                /**< on/off bitmask */