Merge branch '7.8'
[mesa.git] / src / mesa / main / mtypes.h
index 052fbaaaeab0e7d0fe50f665688f2b783c447a34..7657efb07737db55fecd8b7aec36f6ad16d4a206 100644 (file)
 #endif
 
 
+/**
+ * \name 64-bit extension of GLbitfield.
+ */
+/*@{*/
+typedef GLuint64 GLbitfield64;
+
+#define BITFIELD64_ONE         1ULL
+#define BITFIELD64_ALLONES     ~0ULL
+
+/** Set a single bit */
+#define BITFIELD64_BIT(b)      (BITFIELD64_ONE << (b))
+
+/** Set a mask of the least significant \c b bits */
+#define BITFIELD64_MASK(b)     (((b) >= 64) ? BITFIELD64_ALLONES : \
+                               (BITFIELD64_BIT(b) - 1))
+
+/**
+ * Set all bits from l (low bit) to h (high bit), inclusive.
+ *
+ * \note \C BITFIELD_64_RANGE(0, 63) return 64 set bits.
+ */
+#define BITFIELD64_RANGE(l, h) (BITFIELD64_MASK((h) + 1) & ~BITFIELD64_MASK(l))
+/*@}*/
+
+
 /**
  * \name Some forward type declarations
  */
@@ -539,7 +564,7 @@ struct gl_colorbuffer_attrib
    GLclampf ClearColor[4];             /**< Color to use for glClear */
 
    GLuint IndexMask;                   /**< Color index write mask */
-   GLubyte ColorMask[4];               /**< Each flag is 0xff or 0x0 */
+   GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */
 
    GLenum DrawBuffer[MAX_DRAW_BUFFERS];        /**< Which buffer to draw into */
 
@@ -556,7 +581,7 @@ struct gl_colorbuffer_attrib
     * \name Blending
     */
    /*@{*/
-   GLboolean BlendEnabled;             /**< Blending enabled flag */
+   GLbitfield BlendEnabled;            /**< Per-buffer blend enable flags */
    GLenum BlendSrcRGB;                 /**< Blending source operator */
    GLenum BlendDstRGB;                 /**< Blending destination operator */
    GLenum BlendSrcA;                   /**< GL_INGR_blend_func_separate */
@@ -605,8 +630,7 @@ struct gl_current_attrib
    GLfloat RasterDistance;
    GLfloat RasterColor[4];
    GLfloat RasterSecondaryColor[4];
-   GLfloat RasterIndex;
-   GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];
+   GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
    GLboolean RasterPosValid;
    /*@}*/
 };
@@ -938,7 +962,7 @@ struct gl_point_attrib
    GLfloat Threshold;          /**< GL_EXT_point_parameters */
    GLboolean _Attenuated;      /**< True if Params != [1, 0, 0] */
    GLboolean PointSprite;      /**< GL_NV/ARB_point_sprite */
-   GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_ARB_point_sprite */
+   GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
    GLenum SpriteRMode;         /**< GL_NV_point_sprite (only!) */
    GLenum SpriteOrigin;                /**< GL_ARB_point_sprite */
 };
@@ -1114,104 +1138,21 @@ typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
                                const void *texel);
 
 
-/**
- * This macro defines the (many) parameters to the texstore functions.
- * \param dims  either 1 or 2 or 3
- * \param baseInternalFormat  user-specified base internal format
- * \param dstFormat  destination Mesa texture format
- * \param dstAddr  destination image address
- * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels
- * \param dstRowStride  destination image row stride, in bytes
- * \param dstImageOffsets  offset of each 2D slice within 3D texture, in texels
- * \param srcWidth/Height/Depth  source image size, in pixels
- * \param srcFormat  incoming image format
- * \param srcType  incoming image data type
- * \param srcAddr  source image address
- * \param srcPacking  source image packing parameters
- */
-#define TEXSTORE_PARAMS \
-       GLcontext *ctx, GLuint dims, \
-       GLenum baseInternalFormat, \
-       const struct gl_texture_format *dstFormat, \
-       GLvoid *dstAddr, \
-       GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
-       GLint dstRowStride, const GLuint *dstImageOffsets, \
-       GLint srcWidth, GLint srcHeight, GLint srcDepth, \
-       GLenum srcFormat, GLenum srcType, \
-       const GLvoid *srcAddr, \
-       const struct gl_pixelstore_attrib *srcPacking
-
-
-
-/**
- * Texture image storage function.
- */
-typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
-
-
-/**
- * Texture format record 
- */
-struct gl_texture_format
-{
-   GLint MesaFormat;           /**< One of the MESA_FORMAT_* values */
-
-   GLenum BaseFormat;          /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
-                                *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
-                                *   GL_INTENSITY, GL_COLOR_INDEX or
-                                *   GL_DEPTH_COMPONENT.
-                                */
-   GLenum DataType;            /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
-
-   /**
-    * Bits per texel component.  These are just rough approximations
-    * for compressed texture formats.
-    */
-   /*@{*/
-   GLubyte RedBits;
-   GLubyte GreenBits;
-   GLubyte BlueBits;
-   GLubyte AlphaBits;
-   GLubyte LuminanceBits;
-   GLubyte IntensityBits;
-   GLubyte IndexBits;
-   GLubyte DepthBits;
-   GLubyte StencilBits;        /**< GL_EXT_packed_depth_stencil */
-   /*@}*/
-
-   GLuint TexelBytes;          /**< Bytes per texel, 0 if compressed format */
-
-   StoreTexImageFunc StoreImage;
-
-   /**
-    * \name Texel fetch function pointers
-    */
-   /*@{*/
-   FetchTexelFuncC FetchTexel1D;
-   FetchTexelFuncC FetchTexel2D;
-   FetchTexelFuncC FetchTexel3D;
-   FetchTexelFuncF FetchTexel1Df;
-   FetchTexelFuncF FetchTexel2Df;
-   FetchTexelFuncF FetchTexel3Df;
-   /*@}*/
-
-   StoreTexelFunc StoreTexel;
-};
-
-
 /**
  * Texture image state.  Describes the dimensions of a texture image,
  * the texel format and pointers to Texel Fetch functions.
  */
 struct gl_texture_image
 {
+   GLint InternalFormat;       /**< Internal format as given by the user */
    GLenum _BaseFormat;         /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
                                 *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
                                 *   GL_INTENSITY, GL_COLOR_INDEX,
                                 *   GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
                                  *   only. Used for choosing TexEnv arithmetic.
                                 */
-   GLint InternalFormat;       /**< Internal format as given by the user */
+   GLuint TexFormat;            /**< The actual format: MESA_FORMAT_x */
+
    GLuint Border;              /**< 0 or 1 */
    GLuint Width;               /**< = 2^WidthLog2 + 2*Border */
    GLuint Height;              /**< = 2^HeightLog2 + 2*Border */
@@ -1229,16 +1170,11 @@ struct gl_texture_image
    GLboolean IsClientData;     /**< Data owned by client? */
    GLboolean _IsPowerOfTwo;    /**< Are all dimensions powers of two? */
 
-   const struct gl_texture_format *TexFormat;
-
    struct gl_texture_object *TexObject;  /**< Pointer back to parent object */
 
    FetchTexelFuncC FetchTexelc;        /**< GLchan texel fetch function pointer */
    FetchTexelFuncF FetchTexelf;        /**< Float texel fetch function pointer */
 
-   GLboolean IsCompressed;     /**< GL_ARB_texture_compression */
-   GLuint CompressedSize;      /**< GL_ARB_texture_compression */
-
    GLuint RowStride;           /**< Padded width in units of texels */
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
@@ -1280,7 +1216,11 @@ struct gl_texture_object
    GLuint Name;                        /**< the user-visible texture object ID */
    GLenum Target;               /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
    GLfloat Priority;           /**< in [0,1] */
-   GLfloat BorderColor[4];     /**< unclamped */
+   union {
+      GLfloat f[4];
+      GLuint ui[4];
+      GLint i[4];
+   } BorderColor;               /**< Interpreted according to texture format */
    GLenum WrapS;               /**< S-axis texture image wrap mode */
    GLenum WrapT;               /**< T-axis texture image wrap mode */
    GLenum WrapR;               /**< R-axis texture image wrap mode */
@@ -1304,6 +1244,7 @@ struct gl_texture_object
    GLboolean GenerateMipmap;    /**< GL_SGIS_generate_mipmap */
    GLboolean _Complete;                /**< Is texture object complete? */
    GLboolean _RenderToTexture;  /**< Any rendering to this texture? */
+   GLboolean Purgeable;         /**< Is the buffer purgeable under memory pressure? */
 
    /** Actual texture images, indexed by [cube face] and [mipmap level] */
    struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
@@ -1420,7 +1361,7 @@ struct gl_texture_unit
 struct gl_texture_attrib
 {
    GLuint CurrentUnit;   /**< GL_ACTIVE_TEXTURE */
-   struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
+   struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
 
    struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
 
@@ -1485,6 +1426,7 @@ struct gl_viewport_attrib
  */
 struct gl_buffer_object
 {
+   _glthread_Mutex Mutex;
    GLint RefCount;
    GLuint Name;
    GLenum Usage;        /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
@@ -1498,6 +1440,7 @@ struct gl_buffer_object
    GLsizeiptr Length;   /**< Mapped length */
    /*@}*/
    GLboolean Written;   /**< Ever written to? (for debugging) */
+   GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
 };
 
 
@@ -1758,7 +1701,7 @@ struct gl_program
    struct prog_instruction *Instructions;
 
    GLbitfield InputsRead;     /**< Bitmask of which input regs are read */
-   GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
+   GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
    GLbitfield InputFlags[MAX_PROGRAM_INPUTS];   /**< PROG_PARAM_BIT_x flags */
    GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
    GLbitfield TexturesUsed[MAX_TEXTURE_UNITS];  /**< TEXTURE_x_BIT bitmask */
@@ -1821,6 +1764,8 @@ struct gl_fragment_program
    struct gl_program Base;   /**< base class */
    GLenum FogOption;
    GLboolean UsesKill;          /**< shader uses KIL instruction */
+   GLboolean OriginUpperLeft;
+   GLboolean PixelCenterInteger;
 };
 
 
@@ -1962,6 +1907,15 @@ struct gl_query_state
    struct _mesa_HashTable *QueryObjects;
    struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
    struct gl_query_object *CurrentTimerObject;     /* GL_EXT_timer_query */
+
+   /** GL_NV_conditional_render */
+   struct gl_query_object *CondRenderQuery;
+
+   /** GL_EXT_transform_feedback */
+   struct gl_query_object *PrimitivesGenerated;
+   struct gl_query_object *PrimitivesWritten;
+
+   GLenum CondRenderMode;
 };
 
 
@@ -2027,6 +1981,13 @@ struct gl_shader_program
    /** User-defined attribute bindings (glBindAttribLocation) */
    struct gl_program_parameter_list *Attributes;
 
+   /** Transform feedback varyings */
+   struct {
+      GLenum BufferMode;
+      GLuint NumVarying;
+      GLchar **VaryingNames;  /**< Array [NumVarying] of char * */
+   } TransformFeedback;
+
    /* post-link info: */
    struct gl_vertex_program *VertexProgram;     /**< Linked vertex program */
    struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
@@ -2067,6 +2028,29 @@ struct gl_shader_state
 };
 
 
+/**
+ * Context state for transform feedback.
+ */
+struct gl_transform_feedback
+{
+   GLboolean Active;  /**< Is transform feedback enabled? */
+   GLenum Mode;       /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
+   /** Start of feedback data in dest buffer */
+   GLintptr Offset[MAX_FEEDBACK_ATTRIBS];
+   /** Max data to put into dest buffer (in bytes) */
+   GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS];
+   GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */
+
+   /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
+   struct gl_buffer_object *CurrentBuffer;
+
+   /** The feedback buffers */
+   GLuint BufferNames[MAX_FEEDBACK_ATTRIBS];
+   struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS];
+};
+
+
+
 /**
  * State which can be shared by multiple contexts:
  */
@@ -2157,20 +2141,13 @@ struct gl_renderbuffer
    GLuint Name;
    GLint RefCount;
    GLuint Width, Height;
+   GLboolean Purgeable;   /**< Is the buffer purgeable under memory pressure? */
+
    GLenum InternalFormat; /**< The user-specified format */
-   GLenum _ActualFormat;  /**< The driver-chosen format */
    GLenum _BaseFormat;    /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
                                GL_STENCIL_INDEX. */
-   GLenum ColorEncoding; /**< GL_LINEAR or GL_SRGB */
-   GLenum ComponentType; /**< GL_FLOAT, GL_INT, GL_UNSIGNED_INT,
-                              GL_UNSIGNED_NORMALIZED or GL_INDEX */
-   GLubyte RedBits;      /**< Bits of red per pixel */
-   GLubyte GreenBits;
-   GLubyte BlueBits;
-   GLubyte AlphaBits;
-   GLubyte IndexBits;
-   GLubyte DepthBits;
-   GLubyte StencilBits;
+   GLuint Format;         /**< The actual format: MESA_FORMAT_x */
+
    GLubyte NumSamples;
 
    GLenum DataType;      /**< Type of values passed to the Get/Put functions */
@@ -2390,6 +2367,7 @@ struct gl_constants
    GLuint MaxTextureCoordUnits;
    GLuint MaxTextureImageUnits;
    GLuint MaxVertexTextureImageUnits;
+   GLuint MaxCombinedTextureImageUnits;
    GLuint MaxTextureUnits;           /**< = MIN(CoordUnits, ImageUnits) */
    GLfloat MaxTextureMaxAnisotropy;  /**< GL_EXT_texture_filter_anisotropic */
    GLfloat MaxTextureLodBias;        /**< GL_EXT_texture_lod_bias */
@@ -2426,9 +2404,6 @@ struct gl_constants
 
    GLuint MaxDrawBuffers;    /**< GL_ARB_draw_buffers */
 
-   GLenum ColorReadFormat;   /**< GL_OES_read_format */
-   GLenum ColorReadType;     /**< GL_OES_read_format */
-
    GLuint MaxColorAttachments;   /**< GL_EXT_framebuffer_object */
    GLuint MaxRenderbufferSize;   /**< GL_EXT_framebuffer_object */
    GLuint MaxSamples;            /**< GL_ARB_framebuffer_object */
@@ -2445,6 +2420,14 @@ struct gl_constants
 
    /**< GL_EXT_provoking_vertex */
    GLboolean QuadsFollowProvokingVertexConvention;
+
+   /**< OpenGL version 3.x */
+   GLbitfield ContextFlags;  /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
+
+   /** GL_EXT_transform_feedback */
+   GLuint MaxTransformFeedbackSeparateAttribs;
+   GLuint MaxTransformFeedbackSeparateComponents;
+   GLuint MaxTransformFeedbackInterleavedComponents;
 };
 
 
@@ -2460,11 +2443,13 @@ struct gl_extensions
    GLboolean ARB_depth_clamp;
    GLboolean ARB_draw_buffers;
    GLboolean ARB_draw_elements_base_vertex;
+   GLboolean ARB_fragment_coord_conventions;
    GLboolean ARB_fragment_program;
    GLboolean ARB_fragment_program_shadow;
    GLboolean ARB_fragment_shader;
    GLboolean ARB_framebuffer_object;
    GLboolean ARB_half_float_pixel;
+   GLboolean ARB_half_float_vertex;
    GLboolean ARB_imaging;
    GLboolean ARB_map_buffer_range;
    GLboolean ARB_multisample;
@@ -2507,10 +2492,12 @@ struct gl_extensions
    GLboolean EXT_compiled_vertex_array;
    GLboolean EXT_copy_texture;
    GLboolean EXT_depth_bounds_test;
+   GLboolean EXT_draw_buffers2;
    GLboolean EXT_draw_range_elements;
-   GLboolean EXT_framebuffer_object;
    GLboolean EXT_fog_coord;
    GLboolean EXT_framebuffer_blit;
+   GLboolean EXT_framebuffer_multisample;
+   GLboolean EXT_framebuffer_object;
    GLboolean EXT_gpu_program_parameters;
    GLboolean EXT_histogram;
    GLboolean EXT_multi_draw_arrays;
@@ -2532,6 +2519,7 @@ struct gl_extensions
    GLboolean EXT_texture;
    GLboolean EXT_texture_object;
    GLboolean EXT_texture3D;
+   GLboolean EXT_texture_array;
    GLboolean EXT_texture_compression_s3tc;
    GLboolean EXT_texture_env_add;
    GLboolean EXT_texture_env_combine;
@@ -2541,6 +2529,7 @@ struct gl_extensions
    GLboolean EXT_texture_mirror_clamp;
    GLboolean EXT_texture_sRGB;
    GLboolean EXT_texture_swizzle;
+   GLboolean EXT_transform_feedback;
    GLboolean EXT_timer_query;
    GLboolean EXT_vertex_array;
    GLboolean EXT_vertex_array_bgra;
@@ -2549,6 +2538,7 @@ struct gl_extensions
    GLboolean APPLE_client_storage;
    GLboolean APPLE_packed_pixels;
    GLboolean APPLE_vertex_array_object;
+   GLboolean APPLE_object_purgeable;
    GLboolean ATI_envmap_bumpmap;
    GLboolean ATI_texture_mirror_once;
    GLboolean ATI_texture_env_combine3;
@@ -2563,6 +2553,7 @@ struct gl_extensions
    GLboolean MESA_texture_array;
    GLboolean MESA_texture_signed_rgba;
    GLboolean NV_blend_square;
+   GLboolean NV_conditional_render;
    GLboolean NV_fragment_program;
    GLboolean NV_fragment_program_option;
    GLboolean NV_light_max_exponent;
@@ -2581,8 +2572,13 @@ struct gl_extensions
    GLboolean SGIS_texture_lod;
    GLboolean TDFX_texture_compression_FXT1;
    GLboolean S3_s3tc;
+#if FEATURE_OES_draw_texture
+   GLboolean OES_draw_texture;
+#endif /* FEATURE_OES_draw_texture */
    /** The extension string */
    const GLubyte *String;
+   /** Number of supported extensions */
+   GLuint Count;
 };
 
 
@@ -2924,6 +2920,10 @@ struct __GLcontextRec
    /** Extension information */
    struct gl_extensions Extensions;
 
+   /** Version info */
+   GLuint VersionMajor, VersionMinor;
+   char *VersionString;
+
    /** \name State attribute stack (for glPush/PopAttrib) */
    /*@{*/
    GLuint AttribStackDepth;
@@ -2997,6 +2997,8 @@ struct __GLcontextRec
 
    struct gl_query_state Query;  /**< occlusion, timer queries */
 
+   struct gl_transform_feedback TransformFeedback;
+
    struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
    struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
    /*@}*/