From 52213f2cd11c6cc7210cea6896ed464fddfe3fec Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 18 Sep 2012 08:20:29 +0200 Subject: mesa git update 18 sep 2012 --- mesalib/docs/contents.html | 1 - mesalib/docs/subset-A.html | 3572 ----------------------- mesalib/docs/subset.html | 25 - mesalib/src/glsl/builtin_variables.cpp | 2 +- mesalib/src/mesa/drivers/dri/common/Makefile.am | 8 +- mesalib/src/mesa/drivers/dri/common/dri_test.c | 2 + mesalib/src/mesa/main/dd.h | 12 +- mesalib/src/mesa/main/teximage.c | 415 ++- mesalib/src/mesa/main/teximage.h | 9 +- mesalib/src/mesa/main/texobj.h | 8 +- mesalib/src/mesa/main/texstorage.c | 186 +- mesalib/src/mesa/main/uniforms.h | 2 - mesalib/src/mesa/main/version.c | 58 +- mesalib/src/mesa/state_tracker/st_cb_texture.c | 61 +- mesalib/src/mesa/state_tracker/st_texture.c | 13 + 15 files changed, 403 insertions(+), 3971 deletions(-) delete mode 100644 mesalib/docs/subset-A.html delete mode 100644 mesalib/docs/subset.html diff --git a/mesalib/docs/contents.html b/mesalib/docs/contents.html index efd751919..6fc7c584a 100644 --- a/mesalib/docs/contents.html +++ b/mesalib/docs/contents.html @@ -78,7 +78,6 @@
  • Help Wanted
  • Development Notes
  • Source Documentation -
  • Mesa Subset Driver
  • GL Dispatch diff --git a/mesalib/docs/subset-A.html b/mesalib/docs/subset-A.html deleted file mode 100644 index 6dcd84374..000000000 --- a/mesalib/docs/subset-A.html +++ /dev/null @@ -1,3572 +0,0 @@ - - - - - Mini GLX Specification - - - -

    Mesa Subset Specification

    -

    Tungsten Graphics, Inc.

    -

    February 26, 2003

    -

    Copyright © 2002-2003 by Tungsten Graphics, Inc., -Cedar Park, Texas. All Rights Reserved.
    -
    -Permission is granted to make and distribute verbatim copies of this -document provided the copyright notice and this permission notice are -preserved on all copies.
    -

    -

    OpenGL is a trademark of Silicon -Graphics, Inc..

    -

    1. Introduction

    -This document describes a subset of the Mesa implemented by Tungsten -Graphics, Inc. for embedded devices.  Prior to reading this -document the reader should be familiar with the OpenGL 1.2.1 -specification dated April 1, 1999 (available from http://www.opengl.org/developers/documentation/specs.html.) - Experience with OpenGL programming is highly advisable.
    -

    -Tungsten Graphics, Inc. is working with industry standards -organizations +in an attempt to standardize this Mesa subset and any -other possible subsets +as a result of this work.
    -
    -Appendix A contains a list of issues of which some may not be resolved.
    -
    -To summarize, the following major features of Mesa are omitted from the -subset:
    - -

    Further reductions are made at a lower level of detail.
    -

    -

    Mesa function names are printed in bold -face.  Function parameters are printed in italics.
    -

    -

    The Tungsten Graphics, Inc. Mesa subset library is hereafter -referred to as the subset.
    -
    -

    -

    2. Primitive Specification

    -

    2.1 glBegin, glEnd and glVertex Commands

    -The basic rendering primitives are points, lines and triangles. - Quadrilaterals and polygons are composed of triangles. - Primitives are drawn with the glBegin -and glEnd commands and a subset -of the glVertex commands:
    -
    -
    void glBegin(GLenummode)
    -void glEnd(void)
    -
    -void glVertex2f(GLfloat x, GLfloat y)
    -void glVertex2fv(const GLfloat -*v)
    -void glVertex3f(GLfloat x, GLfloat y, GLfloat z)
    -void glVertex3fv(const GLfloat -*v)
    -
    -
    -The mode parameter to glBegin may be one of the following
    -
    -
    GL_POINTS - a series of individual -points
    -GL_LINES - a series of disjoint line segments
    -GL_LINE_STRIP - series of connected line segments
    -GL_LINE_LOOP - a closed loop of line segments
    -GL_TRIANGLES - a series of individual triangles
    -GL_TRIANGLE_STRIP - a connected strip of triangles
    -GL_TRIANGLE_FAN - a sequence of triangles all sharing a common vertex
    -GL_QUADS - a sequence of individual quadrilaterals
    -GL_QUAD_STRIP - a connected strip of quadrilaterals
    -GL_POLYGON - a closed, convex polygon
    -
    -
    -
    -The glVertex commands take two -or three floating point coordinates, or a pointer to an array of two or -three floating point coordinates.  Vertices are actually 4-element -homogeneous coordinates.  The fourth component, unspecified by the -subset's glVertex commands, is -one.
    -
    - -

    2.2 Other Per-vertex Commands
    -

    -The glColor and glTexCoord commands may be used to -specify colors and texture coordinates for each vertex:
    -
    -
    void glColor3f(GLfloatred, GLfloat green, GLfloat blue)
    -void glColor3fv(const GLfloat *rgb)
    -void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
    -void glColor4fv(const GLfloat *rgba)
    -void glTexCoord2f(GLfloat s, GLfloat t)
    -void glTexCoord2fv(const -GLfloat *c)
    -
    -
    -The glColor commands specify -the color and optionally, the alpha value, for subsequent vertices. - For the glColor3 commands, -alpha is set to one.
    -
    -The glTexCoord2 commands -specify the texture coordinate for subsequent vertices.  Texture -coordinates are actually four-component coordinates: (s, t, r, q). - The glTexCoord2 commands -set s and t explicitly.  The r and q components are zero and one, -respectively.
    -
    -Only glVertex, glColor and glTexCoord commands are allowed -between glBegin and glEnd.  Calling any other -command between glBegin and glEnd will result in the error -GL_INVALID_OPERATION.
    -
    -

    2.3 Unsupported Commands

    -None of the following commands related to primitive specification are -supported by the subset:
    -
    -
    Per-Vertex commands:
    -
    -
    -
    glVertex2d, -glVertex2i, glVertex2s, glVertex3d, glVertex3i, glVertex3s, glVertex4d, -glVertex4i, glVertex4s, glVertex2dv, glVertex2iv, glVertex2sv, -glVertex3dv, glVertex3iv, glVertex3sv, glVertex4dv, glVertex4iv, -glVertex4sv,
    -glNormal3b, glNormal3d, glNormal3f, glNormal3i, glNormal3s,
    glNormal3bv, glNormal3dv, glNormal3fv, -glNormal3iv, glNormal3sv,
    -glIndexd, glIndexf, glIndexi, glIndexs, glIndexub, glIndexdv, -glIndexfv, glIndexiv, glIndexsv, glIndexubv,
    -glColor3b, glColor3d, glColor3i, glColor3s, glColor3ub, glColor3ui, -glColor3us,
    glColor3bv, -glColor3dv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv, -glColor3usv, lColor4b, -glColor4d, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us, glColor4bv, glColor4dv, glColor4iv, -glColor4sv, glColor4ubv, glColor4uiv, glColor4usv,
    -
    glTexCoord1d, glTexCoord1f, -glTexCoord1i, glTexCoord1s, glTexCoord2d, glTexCoord2i, glTexCoord2s, -glTexCoord3d, glTexCoord3f, glTexCoord3i, glTexCoord3s, glTexCoord4d, -glTexCoord4f, glTexCoord4i, glTexCoord4s, glTexCoord1dv, glTexCoord1fv, -glTexCoord1iv, glTexCoord1sv, glTexCoord2dv, glTexCoord2iv, -glTexCoord2sv, glTexCoord3dv, glTexCoord3fv, glTexCoord3iv, -glTexCoord3sv, glTexCoord4dv, glTexCoord4fv, glTexCoord4iv, -glTexCoord4sv,
    -glEdgeFlag, glEdgeFlagv

    -
    -
    -Vertex array commands:
    -
    glVertexPointer, -glColorPointer, glIndexPointer, glTexCoordPointer, glEdgeFlagPointer, -glNormalPointer, glInterleavedArrays, glArrayElement, glDrawArrays, -glDrawElements, glDrawRangeElements, glEnableClientState, -glDisableClientState
    -
    -
    -

    -Rectangle commands:
    -
    glRects, -glRecti, glRectf, glRectd, glRectsv, glRectiv, glRectfv, glRectdv,
    -
    -
    -
    -
    Lighting commands:
    -
    -
    glMaterialf, -glMateriali, glMaterialfv, glMaterialiv
    -

    -
    -
    Evaluator commands:
    -
    glEvalCoord1d, -glEvalCoord1f, glEvalCoord1dv, glEvalCoord1fv, glEvalCoord2d, glEvalCoord2f, -glEvalCoord2dv, glEvalCoord2fv,
    -
    glEvalPoint1, glEvalPoint2
    -
    -
    -
    -

    3. Coordinate Transformation

    -

    3.1 Vertex Transformation

    -Vertex coordinates are transformed by the current modelview and -projection matrices then mapped to window coordinates as specified by -the viewport.  The following coordinate transformation commands are -supported by the subset
    -
    -
    glMatrixMode(GLenum mode)
    -glLoadIdentity(void)
    -glPushMatrix(void)
    -glPopMatrix(void)
    -glLoadMatrixf(const GLfloat *m)
    -glMultMatrixf(const GLfloat *m)
    -glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
    -glTranslatef(GLfloat x, GLfloat y, GLfloat z)
    -glScalef(GLfloat x, GLfloat y, GLfloat z)
    -glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)

    -glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
    -glViewport(GLint x, GLint y, GLsize width, GLsizei height)
    -
    -
    -The glMatrixMode command -specifies the current matrix. - The mode parameter may be GL_MODELVIEW or GL_PROJECTION to specify -the modelview matrix or projection matrix.  Subsequent matrix -commands will effect the current matrix.  Also associated with the -modelview and projection matrices are a modelview matrix stack and -projection matrix stack.
    -
    -The glLoadIdentity command -replaces the current matrix with the identity matrix.  The matrix -elements are specified in column-major order.
    -
    -The glPushMatrix command pushes -a copy of the current matrix onto either the modelview matrix stack or -the projection matrix stack.  The glPopMatrix -command replaces the current matrix with a copy of the top matrix off -the modelview matrix stack or projection matrix stack, the pops the -stack.  Matrix stacks are useful for traversing and rendering -hierarchical models.
    -
    -The glMultMatrixf command -post-multiplies the current matrix by the specified matrix.  The -matrix elements are specified in column-major order.
    -
    -The glRotatef command -post-multiplies the current matrix by a rotation matrix defined by the -angle and rotation axis defined by x, y and z.
    -
    -The glTranslatef command -post-multiplies the current matrix by a translation matrix defined by -the x, y and z translation parameters.
    -
    -The glScalef command -post-multiplies the current matrix by a scaling matrix defined by the x, y and z scale factors.
    -
    -The glFrustum command -post-multiplies the current matrix by a perspective projection matrix. - The near and far values specify the position of -the hither and yon Z-axis clipping planes.  The left, right, bottom and top parameters are the X and Y -extents at the near clipping plane.  glFrustum is normally used to modify -the projection matrix.
    -
    -The glOrtho command -post-multiplies the current matrix by an orthographic projection matrix. - The near and far values specify the position of -the hither and yon Z-axis clipping planes.  The left, right, bottom and top parameters specify the X and -Y-axis clipping planes.  glOrtho -is normally used to modify the projection matrix.
    -
    -The glViewport command -specifies the mapping of coordinates from normalized device coordinates -to window coordinates.  The x -and y parameters specify the -viewport's lower-left corner in the window and the width and height parameters specify the size -of the viewport.  glViewport -does not effect the current matrix.
    -
    -A coordinate transformed to window coordinates is hereafter known as (xw, -yw, zw).
    -
    -

    3.2 Clipping

    -View-volume clipping automatically discards or trims primitives which -lie completely or partially outside of the view volume specified by glFrustum and glOrtho.  Note that the glViewport command does not define a -clipping region.
    -
    -Clipping occurs in clip coordinate -space - the coordinates produced after applying the projection -matrix.
    -
    -

    3.3 Current Raster Position

    -The current raster position specifies the location for drawing images -with glBitmap.  The current -raster position is set with the commands:
    -
    -
    void glRasterPos2f(GLfloatx, GLfloat y)
    -void glRasterPos2fv(const -GLfloat *v)
    -void glRasterPos2i(GLint x, GLint y)
    -void glRasterPos2iv(const -GLint *v)
    -
    -
    -glRasterPos specifies a -4-component coordinate (x, y, 0, 1).  The coordinate is processed -like a vertex; it is transformed by the modelview matrix, the projection -matrix and mapped to the viewport.  The resulting window coordinate -is stored as the current raster position.  The coordinate is -clipped-tested against the frustum like a vertex.  If the -coordinate is clipped, then the current raster position becomes invalid -and subsequent glBitmap commands -have no effect.
    -
    -glRasterPos also updates the -current raster color and current raster texture coordinates.  The -current raster color is updated (copied) from the current color (as -specified by glColor). - The current raster texture coordinate is updated (copied) from the -current texture coordinate (as specified by glTexCoord).
    -
    -

    3.4 Unsupported Commands

    -The following commands related to vertex transformation are not -supported by the subset:
    -
    -
    User-defined clip plane commands:
    -
    glClipPlane
    -
    -
    -
    -
    Lighting and material commands:
    -
    glLightModeli, -glLightModelf, glLightModeliv, -glLightModelfv, glLightf, -glLighti, glLightfv, glLightiv, glColorMaterial
    -
    -
    -
    Automatic texture coordinate generation -commands:
    -
    -
    -
    glTexGend, -glTexGenf, glTexGeni, glTexGendv, -glTexGenfv, glTexGeniv,
    -
    -
    -Double-valued commands:
    -
    glLoadMatrixd, -glMultMatrixd, glRotated, glTranslated, glScaled
    -
    -
    -Depth Range command:
    -
    glDepthRange -(the near value is always 0.0 and the far value is always 1.0)
    -
    -
    -Extra RasterPos commands:
    -
    glRasterPos2d, -glRasterPos2s, glRasterPos3d, glRasterPos3f, glRasterPos3i, -glRasterPos3s, glRasterPos4d, glRasterPos4f, glRasterPos4i, -glRasterPos4s, glRasterPos2dv, glRasterPos2sv, glRasterPos3dv, -glRasterPos3fv, glRasterPos3iv, glRasterPos3sv, glRasterPos4dv, -glRasterPos4fv, glRasterPos4iv, glRasterPos4sv
    -
    -
    -
    -
    -

    4. Rasterization

    -This section describes the commands and options for drawing points, -lines, triangles and bitmaps.  Rasterization -is the term for the process which produces fragments from the geometric -description of a primitive (a point, line, polygon or bitmap).  For -example, given the two coordinates for the end-points of a line segment, -rasterization determines which pixels in the frame buffer are modified -to draw the line.  A -fragment is a tuple which consists of a window coordinate, colors and -texture coordinates.  The fragments produced by rasterization are -subsequently processed by the per-fragment operations described later.
    -
    -

    4.1 Point Rasterization

    -Points are rendered with the command sequence glBegin(GL_POINTS), glVertex, ... glEnd.  The window coordinate (xw, -yw, zw) is truncated to rasterize the point. - The truncated coordinate with its associated color and texture -coordinate is sent as a single fragment to the per-fragment processing -stages.
    -
    -The glPointSize command is not -supported; only 1-pixel points are supported.
    -
    -Point smoothing (antialiasing) is also not supported.
    -
    -

    4.2 Line Rasterization

    -Lines are rendered with the command sequence glBegin(mode), glVertex, glVertex, ... glEnd where mode is one of GL_LINES, -GL_LINE_STRIP or GL_LINE_LOOP.  Lines are rasterized as described -in the OpenGL specification.  Note that OpenGL specifies the half-open convention for drawing -lines: the last fragment in a line segment is omitted so that endpoint -pixels shared by two line segments will only be drawn once instead of -twice.
    -
    -

    4.2.1 Line Width

    -The width of lines can be controlled by
    -
    -
    void glLineWidth(GLfloatwidth)
    -
    -
    -where width is the line width -in pixels.  The width defaults to 1.0.  Attempting to set the -width to a value less than or equal to zero will raise the error -GL_INVALID_VALUE.
    -
    -

    4.2.2 Line Stipple
    -

    -Lines may be stippled (i.e. dashed) with the command
    -
    -
    glLineStipple(GLintfactor, GLushort pattern)
    -
    -
    -pattern describes an on/off -pattern for the fragments produced by rasterization and factor specifies how many subsequent -fragments are kept or culled for each pattern bit.  Line stippling -can be enabled or disabled by the commands glEnable(GL_LINE_STIPPLE) and glDisable(GL_LINE_STIPPLE).
    -
    -

    4.2.3 Line Antialiasing

    -Lines may be antialiased.  For antialiased lines, each fragment -produced by rasterization is assigned a coverage value which describes how -much of the fragment's area is considered to be inside the line.  Later, the -alpha value of each fragment is multiplied by the coverage value. - By blending the fragments into the frame buffer, the edges of -lines appear smoothed.
    -
    -Line antialiasing can be enabled or disabled with the commands glEnable(GL_LINE_SMOOTH) and glDisable(GL_LINE_SMOOTH).
    -
    -

    4.3 Polygon Rasterization

    -Polygons, quadrilaterals and triangles share the same polygon -rasterization options.
    -
    -Triangles are rendered by the command sequence glBegin(mode),glVertex, glVertex, ... glEnd where mode may be one of GL_TRIANGLES, -GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN. - For GL_TRIANGLES mode, the number of vertices should be a multiple -of three - extra vertices will be ignored.  For GL_TRIANGLE_STRIP -and GL_TRIANGLE_FAN, at least three vertices should be specified. - If less than three are specified, nothing is drawn.  
    -
    -Quadrilaterals are rendered by -the command sequence glBegin(mode),glVertex, glVertex, ... glEnd where mode may be one of GL_QUADS or -GL_QUAD_STRIP.   For -GL_QUADS, the number of vertices should be a multiple of four - extra -vertices will be ignored.  For GL_QUAD_STRIP, the number of -vertices should be even and at least four.  Extra vertices (one) -will be ignored.
    -
    -Convex polygons are rendered -by the command sequence glBegin(GL_POLYGON),glVertex, glVertex, ... glEnd. - If less than three vertices are specified, nothing is drawn.
    -
    -

    4.3.1 Polygon Orientation

    -The winding order of vertices -(clockwise or counter-clockwise) is significant.  It is used to -determine the front-facing or back-facing orientation of polygons. - By default, a front-facing polygon's vertices are in -counter-clockwise order (in window coordinates).  Figures 2.4 and -2.5 of the OpenGL 1.2.1 specification illustrate the winding order for -front-facing triangles and quadrilaterals, respectively.
    -
    -The command
    -
    -
    void glFrontFace(GLenum mode)
    -
    -
    -specifies whether clockwise or counter-clockwise winding indicates a -front-facing polygon.  If mode -is GL_CW then polygons with clockwise winding are front-facing.  If mode is GL_CCW then polygons with -counter-clockwise winding are front-facing.  The default value is -GL_CCW.  If mode is not -GL_CCW or GL_CW then the error GL_INVALID_ENUM will be raised.
    -
    -

    4.3.2 Polygon Culling

    -Polygons may be culled (discarded) depending on whether they are -front-facing or back-facing.  The command
    -
    -
    void -glCullFace(GLenum mode)
    -
    -
    -specifies whether front-facing, back-facing or all polygons should be -culled.  If mode is -GL_FRONT then front-facing polygons will be culled.  If mode is GL_BACK then back-facing -polygons will be culled. Otherwise, if mode -is GL_FRONT_AND_BACK then all polygons will be culled.  Any other -value for mode will raise the -error GL_INVALID_ENUM.
    -
    -Polygon culling is enabled and disabled with the commands glEnable(GL_CULL_FACE) and glDisable(GL_CULL_FACE), -respectively.
    -
    -

    4.3.3 Polygon Antialiasing

    -Polygons may be antialiased in order to smooth their edges. - Polygon antialiasing is enabled and disabled with the commands glEnable(GL_POLYGON_SMOOTH) and glDisable(GL_POLYGON_SMOOTH).
    -
    -When polygon antialiasing is enabled each fragment produced by polygon, -triangle and quadrilateral rasterization will be given a coverage value which indicates how -much of the fragment is covered by the polygon.  Fragments -completely inside the polygon have coverage 1.0.  Fragments -completely outside the polygon have zero coverage (in theory). - Fragments which intersect the polygon's edge have a coverage value -in the range (0, 1).
    -
    -The fragment's alpha value is multiplied by the coverage value. - By enabling the appropriate blending mode, polygon edges will -appear smoothed.
    -
    -

    4.4 Shading

    -The command
    -
    -
    void glShadeModel(GLenummode)
    -
    -
    -determines whether colors are interpolated between vertices during -rasterization.  If mode is -GL_FLAT then vertex colors are not interpolated.  The color used -for drawing lines, triangles and quadrilaterals is that of the last -vertex used to specify each primitive.  For polygons, the color of -the first vertex specifies the color for the entire polygon.  If mode is GL_SMOOTH then vertex colors -are linearly interpolated to produce the fragment colors.
    -
    -

    4.5 Bitmap Rasterization

    -A bitmap is a monochromatic, binary image in which each image element -(or pixel) is represented by one bit.  Fragments are only generated -for the bits (pixels) which are set.  Bitmaps are commonly used to -draw text (glyphs) and markers.
    -
    -A bitmap is drawn with the command
    -
    -
    void glBitmap(GLsizeiwidth, GLsizei height, GLfloat xOrig, GLfloat yOrig, GLfloat xMove, GLfloat yMove, const  GLubyte *image)
    -
    -
    -width and height specify the image size in -pixels.  xOrig and yOrig specify the bitmap origin. - xMove and yMove are added to the current -raster position after the bitmap is rasterized.  image is a pointer to the bitmap -data.
    -
    -If the current raster position is not valid, glBitmap has no effect.
    -
    -

    4.5.1 Bitmap Unpacking

    -The first step in bitmap rendering is unpacking. - Unpacking is the process of extracting image data from -client memory subject to byte swapping, non-default row strides, etc. - The unpacking parameters are specified with the command
    -
    -
    void -glPixelStorei(GLenum pname, GLint value)
    -
    -
    -The following unpacking parameters may be set:
    -
    - - - - - - - - - - - - - - - - - - -
    Parameter (pname)
    -
    Value (value)
    -
    Default
    -
    GL_UNPACK_ROW_LENGTH
    -
    Width of the image in memory, in -pixels.
    -
    0
    -
    GL_UNPACK_LSB_FIRST
    -
    GL_FALSE indicates that the most -significant bit is unpacked first from each byte.  GL_TRUE -indicates that the least significant bit is unpacked first from each -byte.
    -
    GL_FALSE
    -
    -
    -
    -The GL_UNPACK_ROW_LENGTH specifies the stride (in pixels) for advancing -from one row of the image to the next.  If it's zero, the width parameter to glBitmap specifies the width of the -image in memory.
    -
    -GL_UNPACK_LSB_FIRST determines whether the least significant or most -significant bit in each byte is unpacked first.  Unpacking occurs -in left to right order (in image space).
    -
    -The value of bit (i, j) of the image (where i is the image row and j is -the image column) is found as follows:
    -
    -
    rowLength = (GL_UNPACK_ROW_LENGTH != 0) -? GL_UNPACK_ROW_LENGTH : width;
    -
    -byte = image[((rowLength + 7) -/ 8) * i + j / 8];
    -
    -if (GL_UNPACK_LSB_FIRST != 0)
    -    bitMask = 1 << (j % 8);
    -else
    -    bitMask = 128 >> (j % 8);
    -
    -if (byte & bitMask)
    -    bit = 1;
    -else
    -    bit = 0;
    -
    -
    - -

    4.5.2 Rasterization

    -If the current raster position is (xrp, yrp, zrp, -wrp), then the bitmap is rasterized according to the -following algorithm:
    -
    -for (j = 0; j < height; -j++) {
    -    for (i = 0; i < width; -i++) {
    -        if (bit(i,j)) {
    -            fragment.x = -floor(xrp - xOrig) -+ i;
    -            fragment.y = -floor(yrp - yOrig) -+ j;
    -            fragment.color -= GL_CURRENT_RASTER_COLOR;
    -            -fragment.texture = GL_CURRENT_RASTER_TEXTURE_COORDS;
    -            -ProcessFragment(fragment)
    -         }
    -    }
    -}
    -
    -After the bitmap has been rendered the current raster position is -updated as follows:
    -
    -
    xrp = xrp + xMove
    -yrp = yrp + yMove
    -
    -
    -

    4.5.3 Per-fragment Operations

    -XXX supported?  See issue in appendix A.
    -
    -

    4.6 Unsupported Commands

    -The following commands related to rasterization are not supported by -the subset.
    -
    -
    Point commands:
    -
    glPointSize
    -
    -
    -Polygon commands:
    -
    glPolygonStipple
    -glPolygonOffset
    -glPolygonMode
    -
    -
    -
    -
    Pixel storage commands:
    -
    -
    glPixelStoref
    -
    -
    -
    -

    5. Texture Mapping
    -

    -There are four elements to texture mapping: texture coordinate -specification, texture image specification, texture sampling and texture -application.
    -
    -Texture mapping is enabled and disabled with the commands glEnable(GL_TEXTURE_2D) and glDisable(GL_TEXTURE_2D).
    -
    -

    5.1 Texture Image Specification

    -A texture image is specified with the command:
    -
    -
    void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
    -
    -
    -target must be GL_TEXTURE_2D. - level indicates the -mipmap level for mipmap textures.  internalFormat -is a hint to indicate the preferred internal storage format for the -texture.  width and height indicate the image size in -pixels (or texels).  border must -be zero.  format and type describe the pixel format and -data type for the incoming image.  pixels -points to the incoming texture image.  These parameters are -described in more detail below.
    -
    -

    5.1.1 Texture Image Size and Mipmaps

    -

    -Texture images must have dimensions (width and height) that are powers -of two. For example: 256 x 256, 32 x 1024, 1 x 8, etc.  That is, it -must be the case that width = -2n and height = 2m -for some positive integers n and m.
    -
    -Mipmapping is a method of antialiasing or filtering textures to improve -their appearance.  A mipmap is a set of images consisting of a base -image and a set of filtered, reduced-resolution images.  If the -base image (level=0) is of -width 2n and height 2m then the level 1 image must -be of width 2n-1 and height 2m-1.  Each mipmap -level is half the width and height of the previous level, or at least -one.  The last mipmap level has a width and height of one.
    -
    -The following is an example of a mipmap's image levels:
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    mipmap level
    -
    width
    -
    height
    -
    0
    -
    256
    -
    64
    -
    1
    -
    128
    -
    32
    -
    2
    -
    64
    -
    16
    -
    3
    -
    32
    -
    8
    -
    4
    -
    16
    -
    4
    -
    5
    -
    8
    -
    2
    -
    6
    -
    4
    -
    1
    -
    7
    -
    2
    -
    1
    -
    8
    -
    1
    -
    1
    -
    -
    -If the width or height parameters are not powers of -two, the error GL_INVALID_VALUE is raised.  If the image levels in -a mipmap do not satisfy the restrictions listed above the texture is -considered to be inconsistent -and the system will behave as if the texturing is disabled.
    -
    -

    5.1.2 Texture Image Formats and Unpacking

    -The glTexImage2D command's format and type parameters describe the format -of the incoming texture image.  Accepted values for format are GL_INTENSITY, GL_RGB and -GL_RGBA.  The type -parameter must be GL_UNSIGNED_BYTE.  Pixel component values are -thus in the range 0 through 255.
    -
    -If format is GL_INTENSITY then -the image has one byte per pixel which specifies the pixel's red, green, -blue and alpha values.
    -
    -If format is GL_RGB then the -image has three bytes per pixel which specify the pixel's red, green and -blue values (in that order).  The alpha value defaults to 255.
    -
    -If format is GL_RGBA then the -image has four bytes per pixel which specify the pixel's red, green, -blue and alpha values (in that order).
    -
    -The command
    -
    -
    void -glPixelStorei(GLenum pname, -GLint value)
    -
    -
    -controls the unpacking of texture image data from client memory.  pname may be GL_UNPACK_ROW_LENGTH to -indicate the stride, in pixels, between subsequent rows of the image in -client memory.  If GL_UNPACK_ROW_LENGTH is zero (the default) then -the width parameter to glTexImage2D determines the stride.
    -
    -

    5.1.3 Internal Texture Format

    -glTexImage2D converts the incoming -texture image to one of the supported internal texture formats.
    -
    -The internalFormat parameter -indicates the desired internal format for the texture and may be either -GL_INTENSITY8, GL_RGB5 or GL_RGBA8.
    -
    -If internalFormat is -GL_INTENSITY8 then the texture has one byte per texel (texture element) -which indicates the texel's intensity (or brightness).  The -intensity is obtained from the incoming image's red channel.
    -
    -If internalFormat is GL_RGB5 -then the texture is stored with two bytes per texel:  5 bits per -red value, 5 bits per green value and 5 bits per blue value.
    -
    -If internalFormat is -GL_RGBA8 then the texture is stored with four bytes per texel:  8 -bits for each of the red, green,  blue and alpha values.
    -
    -The internal format is also significant to texture application (see -section 5.4).
    -
    -

    5.2 Texture Coordinates

    -Texture coordinates control the mapping from local polygon space to -texture image space.  Texture coordinates are set for each vertex -with the glTexCoord commands. - During line and polygon rasterization the vertex's texture -coordinates are interpolated across the primitive to produce a texture -coordinate for each fragment.  The fragment texture coordinates are -used to sample the current texture image.
    -
    -Texture coordinates are normally in the range [0, 1].  Values -outside that range are processed according to the texture wrap mode.  The -texture wrap mode is set with the command
    -
    -
    void glTexParameteri(GLenum target, GLenum pname, GLint value)
    -
    -
    -target must be GL_TEXTURE_2D. - If pname is -GL_TEXTURE_WRAP_S or GL_TEXTURE_WRAP_T then value must be either -GL_CLAMP_TO_EDGE or GL_REPEAT.
    -
    -For GL_CLAMP_TO_EDGE, texture coordinates are effectively clamped to -the interval [0, 1].
    -
    -For GL_REPEAT, the integer part of texture coordinates is ignored; only -the fractional part of the texture coordinates is used.  This -allows texture images to repeated or tiled across an object.
    -
    -

    5.3 Texture Sampling

    -Texture sampling is the process of using texture coordinates to extract -a color from the texture image.  Multiple, weighted samples may be -taken from the texture and combined during the filtering step.
    -
    -During texture coordinate interpolation a level of detail value (lambda) is -computed for each fragment.  For a mipmapped texture, lambda -determines which level (or levels) of the mipmap will be sampled to -obtain the texture color.
    -
    -If lambda indicates that multiple texels map to a single screen pixel, -then the texture minification -filter will be used.  Otherwise, if lambda indicates that a single -texel maps to multiple screen pixels, then the texture magnification filter will be used.
    -
    -

    5.3.1 Texture Minification

    -The texture minification filter is set with the glTexParameteri command by setting target to GL_TEXTURE_2D, setting pname to GL_TEXTURE_MIN_FILTER and -setting value to GL_NEAREST, -GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST,  -GL_NEAREST_MIPMAP_LINEAR,   GL_LINEAR_MIPMAP_NEAREST or -GL_LINEAR_MIPMAP_LINEAR.
    -
    -GL_NEAREST samples the texel nearest the texture coordinate in the -level 0 texture image.
    -
    -GL_LINEAR samples the four texels around the texture coordinate in the -level 0 texture image.  The four texels are linearly weighted to -compute the final texel value.
    -
    -GL_NEAREST_MIPMAP_NEAREST samples the texel nearest the texture -coordinate in the level N texture image.  N is the level of detail -and is computed by the partial derivatives of the texture coordinates -with respect to the window coordinates.
    -
    -GL_NEAREST_MIPMAP_LINEAR samples two texels nearest the texture -coordinates in the level N and N+1 texture images.  The two texels -are linearly weighted to compute the final texel value.  N is the -level of detail and is computed by the partial derivatives of the -texture coordinates with respect to the window coordinates.
    -
    -GL_LINEAR_MIPMAP_NEAREST samples four texels around the texture -coordinate in the level N texture image.  The four texels are -linearly weighted to compute the final texel value.  N is the level -of detail and is computed by the partial derivatives of the texture -coordinates with respect to the window coordinates.
    -
    -GL_LINEAR_MIPMAP_LINEAR samples four texels around the texture -coordinate in the level N texture image and four texels around the -texture coordinate in the level N+1 texture image.  The eight -texels are linearly weighted to compute the final texel value.  N -is the level of detail and is computed by the partial derivatives of the -texture coordinates with respect to the window coordinates.
    -
    -Filter modes other than GL_LINEAR and GL_NEAREST requires that the -texture have a complete set of mipmaps.  If the mipmap is -incomplete, it is as if texturing is disabled.

    -

    5.3.2 Texture Magnification

    -The texture magnification filter is set with the glTexParameteri command -by setting target to -GL_TEXTURE_2D, setting pname to -GL_TEXTURE_MAG_FILTER and setting value -to GL_NEAREST or GL_LINEAR.
    -
    -GL_NEAREST samples the texel nearest the texture coordinate in the -level 0 texture image.
    -
    -GL_LINEAR samples the four texels around the texture coordinate in the -level 0 texture image.  The four texels are linearly weighted to -compute the final texel value.
    -
    -

    5.4 Texture Application

    -The sampled texture value is combined with the incoming fragment color -to produce a new fragment color.  The fragment and texture colors -are combined according to the texture environment mode and the current -texture's base internal format.  The texture environment mode is -set with the command
    -
    -
    void -glTexEnvi(GLenum target, -GLenum pname, GLint value)
    -
    -
    -target must be GL_TEXTURE_ENV. - If pname is -GL_TEXTURE_ENV_MODE then value -must be one of GL_REPLACE, GL_MODULATE, GL_DECAL, or GL_BLEND.
    -
    -There is also a texture environment -color that can factor into texture application.  The texture -environment color can be set with the command
    -
    -
    void -glTexEnvfv(GLenum target, -GLenum pname, const GLfloat *value)
    -
    -
    -target must be GL_TEXTURE_ENV. - If pname is -GL_TEXTURE_ENV_COLOR then value must -point to an array of four values which specify the red, green, blue, -and alpha values of the texture environment color.  The values are -clamped to the range [0, 1].  The default color is (0, 0, 0, 0).
    -
    -The following table describes the arithmetic used for each combination -of environment mode and base internal format.  (Rf, Gf, Bf, Af) is -the incoming fragment color.  (Rt, Gt, Bt, At) is the sampled -texture color.  Lt is the sampled texture luminance.  'It' is the sampled texture -intensity.  (Rc, Gc, Bc, Ac) is the texture environment color. - (Rv, Gv, Bv, Av) is the resulting value.
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Base Internal Format
    -
    GL_REPLACE
    -
    GL_MODULATE
    -
    GL_DECAL
    -
    GL_BLEND
    -
    GL_INTENSITY
    -
    Rv = It
    -Gv = It
    -Bv = It
    -Bf = It
    -
    Rv = Rf * It
    -Gv = Gf * It
    -Bv = Bf * It
    -Av = Af * It
    undefined
    -
    Rv = Rf*(1-It) + Rc*It
    -Gv = Gf*(1-It) + Gc*It
    -Bv = Bf*(1-It) + Bc*It
    -Av = Af*(1-It) + Ac*It
    GL_RGB
    -
    Rv = Rt
    -Gv = Gt
    -Bv = Bt
    -Av = Af
    -
    Rv = Rf * Rt
    -Gv = Gf * Gt
    -Bv = Bf * Bt
    -Av = Af
    -
    Rv = Rt
    -Gv = Gt
    -Bv = Bt
    -Av = Af
    Rv = Rf*(1-Rt) + Rc*Rt
    -Gv = Gf*(1-Gt) + Gc*Gt
    -Bv = Bf*(1-Bt) + Bc*Bt
    -Av = Af
    GL_RGBA
    -
    Rv = Rt
    -Gv = Gt
    -Bv = Bt
    -Av = At
    -
    Rv = Rf * Rt
    -Gv = Gf * Gt
    -Bv = Bf * Bt
    -Av = Af * At
    Rv = Rf*(1-At) + Rt*At
    -Gv = Gf*(1-At) + Gt*At
    -Bv = Bf*(1-At) + Bt*At
    -Av = Af
    -
    Rv = Rf*(1-Rt) + Rc*Rt
    -Gv = Gf*(1-Gt) + Gc*Gt
    -Bv = Bf*(1-Bt) + Bc*Bt
    -Av = Af*At
    -
    -
    -
    -

    5.5 Texture Objects

    -Texture objects encapsulate a set of texture images (mipmap) and -related state into a named object.  This facilitates use of -multiple textures in an application.  Texture objects are named -with GLuints (unsigned integers).  There is a default texture -object with the name/identifier zero which can never be deleted.
    -
    -

    5.5.1 Creating Texture Objects

    -A texture object is created by binding a new GLuint identifier to the -GL_TEXTURE_2D target with the command:
    -
    -
    void glBindTexture(GLenum target, GLuint textureID)
    -
    -
    -target must be GL_TEXTURE_2D. - textureID may be any -unsigned integer.  If textureID -does not name an existing texture object, a new texture object with that -ID will be created, initialized to the default state.  Whether the -ID is new or existed previously, that named texture object is bound as -the current texture object. - Subsequent glTexParameter andglTexImage2D calls will effect the -current texture object.
    -
    -

    5.5.2 Deleting Texture Objects

    -One or more texture objects may be deleted with the command:
    -
    -
    void glDeleteTextures(GLsizein, const GLuint *textureIDs)
    -
    -
    -textureIDs is an array of n texture IDs.  The named -texture objects will be deleted.  If the current texture object is -deleted the default texture object (number 0) will be bound as the -current texture object.
    -
    -

    5.5.3 Allocating Texture Object Identifiers

    -A list of new, unused texture IDs can be obtained by calling the command
    -
    -
    void glGenTextures(GLsizei n, GLuint *textureIDs)
    -
    -
    -An array of n unused texture -IDs will be returned in the textureIDs -array.
    -
    -
    -

    6. Per-fragment Operations

    -The fragments produced by rasterization are subjected to a number of -operations which either modify the fragment or test the fragment -(discarding the fragment if the test fails.)  This chapter -describes the per-fragment operations.  They are presented in the -order in which they're performed.  If a fragment fails a test it is -discarded and not subjected to subsequent tests or modifications.
    -
    -

    6.1 Scissor Test

    -The scissor test limits rendering to a 2-D rectangular region of the -framebuffer.  The command
    -
    -
    void glScissor(GLintx, GLint y, GLsizei width, GLsizei height)
    -
    -
    -defines a clipping region with the lower-left corner at (x, y) and the given width and height.  The scissor test is -enabled and disabled with the command glEnable(GL_SCISSOR_TEST) -and glDisable(GL_SCISSOR_TEST).
    -
    -If the incoming fragment's position is (xf, yf) -then the fragment will pass the test if x <= xf < x + width and y <= yf < y + height.  Otherwise, the -fragment is discarded.
    -
    -If width or height is less than zero the error -GL_INVALID_VALUE is raised.  The default scissor rectangle bounds -are (0, 0, w, h) where w is the initial window width and h is the -initial window height.  The scissor test is disabled by default.
    -
    -

    6.2 Alpha Test

    -The alpha test compares the fragment's alpha value against a reference -value and discards the fragment if the comparison fails.  The test -is specified by the command
    -
    -
    void glAlphaFunc(GLenummode, GLclampf reference)
    -
    -
    -mode specifies an inequality -and reference specifies a value -to compare against.  The following table lists all possible -modes and the -corresponding test:
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Comparison mode
    -
    The test passes if
    -
    GL_LESS
    -
    alpha < reference
    -
    GL_LEQUAL
    -
    alpha <= reference
    GL_GREATER
    -
    alpha > reference
    GL_GEQUAL
    -
    alpha >= reference
    GL_EQUAL
    -
    alpha == reference
    GL_NOTEQUAL
    -
    alpha != reference
    GL_NEVER
    -
    never pass
    -
    GL_ALWAYS
    -
    always passes
    -
    -
    -The reference parameter is -clamped to the range [0, 1].
    -
    -The alpha test is enabled and disabled with the commands glEnable(GL_ALPHA_TEST) and glDisable(GL_ALPHA_TEST).
    -
    -The default mode is GL_ALWAYS and the default reference value is 0.
    -
    -

    6.3 Stencil Test

    -The stencil buffer stores an N-bit integer value for each pixel in the -frame buffer.  The stencil test compares the stencil buffer value -at the fragment's position to a reference value and possibly discards -the fragment based on the outcome.  Furthermore, the stencil buffer -value may be updated or modified depending on the outcome.  If -there is no stencil buffer the stencil test is bypassed.
    -
    -Stenciling is controlled by the commands
    -
    -
    void glStencilFunc(GLenumfunc, GLint ref, GLuint mask)
    -void glStencilOp(GLenum stencilFail, GLenum depthTestFail, GLenum depthTestPass)
    -
    -
    -The glStencilFunc command controls the -stencil test while glStencilOp -command controls the how the stencil buffer is updated/modified after -the test.
    -
    -ref is clamped to the range [0, -2N-1] where N is the number of bits per stencil value in the -stencil buffer.
    -
    -The following table lists all possible values for the func parameter and when the stencil -test will pass.  Both the stencil buffer value and the stencil -reference value are bit-wise ANDed with the mask parameter before the test.
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Stencil func value
    -
    Stencil test passes if
    -
    GL_LESS
    -
    (ref&mask) < (stencil buffer value -& mask)
    -
    GL_LEQUAL
    -
    (ref -& mask) <= (stencil -buffer value & mask)
    GL_GREATER
    -
    (ref -& mask) > (stencil -buffer value & mask)
    GL_GEQUAL
    -
    (ref -& mask) >= (stencil -buffer value & mask)
    GL_EQUAL
    -
    (ref -& mask) == (stencil -buffer value & mask)
    GL_NOTEQUAL
    -
    (ref -& mask) != (stencil -buffer value & mask)
    GL_NEVER
    -
    never passes
    -
    GL_ALWAYS
    -
    always passes
    -
    -
    -
    -If the stencil test passes, the fragment is passed to the next -per-fragment operation.  Otherwise, if the stencil test fails, the -value in the stencil buffer is updated according to the value of the stencilFail parameter to glStencilOp.
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    stencilFail -value
    -
    New stencil buffer value
    -
    GL_KEEP
    -
    originalValue
    -
    GL_ZERO
    -
    0
    -
    GL_INVERT
    -
    BitWiseInvert(originalValue) -i.e. ~originalValue
    -
    GL_REPLACE
    -
    ref
    -
    GL_INCR
    -
    originalValue + 1, clamped to -[0, 2N-1]
    GL_DECR
    -
    originalValue - 1, clamped to -[0, 2N-1]
    -
    -
    -The depthTestFail and depthTestPass parameters to glStencilOp are ignored.  Values -for func and stencilFail other than those listed -in the table will cause the error GL_INVALID_ENUM to be raised.
    -
    -The stencil test is enabled and disabled with the commands glEnable(GL_STENCIL_TEST) and glDisable(GL_STENCIL_TEST).
    -
    -The default stencil function is GL_ALWAYS.  The default stencil -reference value is 0.  The default stencil mask is ~0.  The -default stencil fail operation is GL_KEEP.
    -
    -Values written into the stencil buffer are masked with the command
    -
    -
    void glStencilMask(GLuintmask)
    -
    -
    -Only the bits which are set in mask -will be modified in the stencil buffer when written to.  If each -stencil buffer value has N bits, only the least significant N bits of mask are relevant.  The default -stencil mask is ~0.
    -
    -

    6.4 Blending and Logicop

    -Blending or a logic operation combines the incoming fragment color with -the destination frame buffer color according to a blending equation or -bit-wise Boolean logical operation.
    -
    -Blending is enabled and disabled with the commands glEnable(GL_BLEND) and glDisable(GL_BLEND).
    -
    -The logic operation is enabled and disabled with the commands glEnable(GL_LOGIC_OP) and glDisable(GL_LOGIC_OP).
    -
    -If both blending and the logic operation are enabled, the logic -operation has higher priority; blending is bypassed.
    -
    -

    6.4.1 Logic Op

    -The command
    -
    -
    void glLogicop(GLenummode)
    -
    -
    -Specifies the Boolean logic operation for combining the incoming -fragment color with the destination frame buffer color.  Both the -incoming fragment color and destination frame buffer colors are -interpreted as four-tuples of unsigned integer color components in the -range [0, 2N-1] where N is the number of bits per color -channel.  N may not be the same for all color channels.
    -
    -The following table lists all values for mode and the boolean arithmetic used -to combine the incoming fragment color value (src) with the destination framebuffer -color value (dst).  Standard ANSI C operators used.
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    LogicOp mode
    -
    Resulting channel value
    -
    GL_CLEAR
    -
    0
    -
    GL_SET
    -
    ~0
    -
    GL_COPY
    -
    src
    -
    GL_COPY_INVERTED
    -
    ~s
    -
    GL_NOOP
    -
    dst
    -
    GL_INVERT
    -
    ~dst
    -
    GL_AND
    -
    src & dst
    -
    GL_NAND
    -
    ~(src & dst)
    -
    GL_AND_REVERSE
    -
    src & ~dst
    -
    GL_AND_INVERTED
    -
    ~src & dst
    -
    GL_OR
    -
    src | dst
    -
    GL_NOR
    -
    ~(src | dst)
    -
    GL_OR_REVERSE
    -
    src | ~dst
    -
    GL_OR_INVERTED
    -
    ~src | dst
    -
    GL_XOR
    -
    src ^ dst
    -
    GL_EQUIV
    -
    ~(src ^ dst)
    -
    -
    -The fragment's color is replaced by the result of the logic operation.
    -
    -Specifying any value for mode -other than those listed in the above table will cause the error -GL_INVALID_ENUM to be raised.
    -
    -The default value for mode is -GL_COPY.  The logic operation is disabled by default.
    -
    -

    6.4.2 Blending

    -The command
    -
    -
    void glBlendFunc(GLenumsrcTerm, GLenum dstTerm)
    -
    -
    -specifies the terms of the blending equation.  If Cf = (Rf, Gf, -Bf, Af) is the incoming fragment color and Cb = (Rb, Gb, Bb, Ab) is the -frame buffer color, then the resulting color Cv = (Rv, Gv, Bv, Av) is -computed by:
    -
    -
    Cv = Cf * srcTerm + Cb * dstTerm
    -
    -
    -All possible values for srcTerm -and the corresponding arithmetic term are listed in the following table:
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    srcTerm
    -
    srcTermArithmetic
    -
    GL_ZERO
    -
    (0, 0, 0, 0)
    -
    GL_ONE
    -
    (1, 1, 1, 1)
    -
    GL_DST_COLOR
    -
    (Rb, Gb, Bb, Ab)
    -
    GL_ONE_MINUS_DST_COLOR
    -
    (1-Rb, 1-Gb, 1-Bb, 1-Ab)
    -
    GL_SRC_ALPHA
    -
    (Af, Af, Af, AF)
    -
    GL_ONE_MINUS_SRC_ALPHA
    -
    (1-Af, 1-Af, 1-Af, 1-Af)
    -
    GL_DST_ALPHA
    -
    (Ab, Ab, Ab, Ab)
    -
    GL_ONE_MINUS_DST_ALPHA
    -
    (1-Ab, 1-Ab, 1-Ab, 1-Ab)
    -
    GL_SRC_ALPHA_SATURATE
    -
    (m, m, m, 1) where m = MIN(Af, -1-Ab)
    -
    -
    -All possible values for srcTerm -and the corresponding arithmetic term are listed in the following table:
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    dstTerm
    -
    dstTermArithmetic
    -
    GL_ZERO
    -
    (0, 0, 0, 0)
    -
    GL_ONE
    -
    (1, 1, 1, 1)
    -
    GL_SRC_COLOR
    -
    (Rf, Gf, Bf, Af)
    -
    GL_ONE_MINUS_SRC_COLOR
    -
    (1-Rf, 1-Gf, 1-Bf, 1-Af)
    -
    GL_SRC_ALPHA
    -
    (Af, Af, Af, AF)
    -
    GL_ONE_MINUS_SRC_ALPHA
    -
    (1-Af, 1-Af, 1-Af, 1-Af)
    -
    GL_DST_ALPHA
    -
    (Ab, Ab, Ab, Ab)
    -
    GL_ONE_MINUS_DST_ALPHA
    -
    (1-Ab, 1-Ab, 1-Ab, 1-Ab)
    -
    -
    -The fragment's color is replaced by the result of the blending equation.
    -
    -Values for srcTerm and dstTerm other than those listed in -the table will cause the error GL_INVALID_ENUM to be raised.
    -
    -The default value for srcTerm -is GL_ONE.  The default value for dstTerm -is GL_ZERO.  Blending is disabled by default.
    -
    -

    6.5 Color Mask

    -The final fragment color is written into the current color buffer at -the end of the per-fragment operations.  Normally, all color -channels in the frame buffer are replaced with the final fragment color. - However, the command
    -
    -
    void glColorMask(GLbooleanredMask, GLboolean greenMask, GLboolean blueMask, GLboolean alphaMask)
    -
    -
    -allows selective writing to individual color channels.  If redMask is GL_TRUE then writing to -the red color channel is enabled, otherwise it's disabled. - Similarly, the green, blue and alpha channels can also be masked.
    -
    -Initially all four mask values are GL_TRUE.
    -
    -Color masking is not enabled/disabled with the glEnable/glDisable commands.
    -
    -

    7. Frame Buffer Operations

    -The frame buffer is considered to be a two-dimensional array of pixels. - The frame buffer is also organized into layers or logical buffers. - There may be a front color buffer, back color buffer and stencil -buffer.  A double-buffered frame buffer has both a front color -buffer and back color buffer.  A single-buffered framebuffer only -has a front color buffer.  Each pixel in a color buffer has a red, -green and blue value and an optional alpha value.
    -
    -

    7.1 Clearing Buffers

    -Buffers are cleared (set to uniform values) with the command
    -
    -
    void glClear(GLbitfieldbuffers)
    -
    -
    -buffers is a bitmask for which -the value may be the bitwise-OR of the values GL_COLOR_BUFFER_BIT and -GL_STENCIL_BUFFER_BIT.  If the GL_COLOR_BUFFER_BIT bit is -specified, the current color buffer will be cleared.  If the -GL_STENCIL_BUFFER_BIT bit is specified, the stencil buffer will be -cleared.
    -
    -The current color buffer is specified with the command
    -
    -
    void glDrawBuffer(GLenum buffer)
    -
    -
    -buffer may be either GL_FRONT, -GL_BACK or GL_NONE.  GL_FRONT indicates that the front color buffer -will be modified by glClear and -any drawing command.  GL_BACK indicates that the back color buffer -will be modified by glClear and -any drawing command.  GL_NONE indicates that neither color buffer -will be modified by glClear or -any drawing command.  GL_BACK is only valid for double-buffered -frame buffers.
    -
    -The current scissor rectangle, set by the glScissor command, effects glClear, limiting -the clear to the scissor rectangle, if it's enabled.  Furthermore, only the color channels enabled by glColorMask will be effected by glClear(GL_COLOR_BUFFER_BIT). - Likewise, only the stencil bits enabled by glStencilMask will be effected by glClear(GL_STENCIL_BUFFER_BIT).
    -
    -The current clear color is set with the command
    -
    -
    void glClearColor(GLclampfred, GLclampf green, GLclampf blue, GLclampf alpha)
    -
    -
    -Subsequent calls to glClear -will use the color (red, green, blue, -alpha) to clear the front or back color buffers.
    -
    -The current stencil clear value is set with the command
    -
    -
    void glClearStencil(GLintclearValue)
    -
    -
    -If the stencil buffer is N bits deep, the least significant N bits of clearValue will be used to clear the -stencil buffer.
    -
    -
    -

    8. Other Features

    -

    8.1 Frame Buffer Readback

    -A rectangular region of pixels can be read from the frame buffer and -placed in client memory with the command
    -
    -
    void glReadPixels(GLintx, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *data)
    -
    -
    -x and y specify the coordinate of the -lower-left corner of the region to read and width and height specify the size of the -rectangular region to read.  format -specifies the format of image data and must be either GL_RGB or -GL_RGBA.  type specify the -data type of the image data and must be either GL_UNSIGNED_BYTE or -GL_FLOAT.  Other values for format -or type will cause the error -GL_INVALID_ENUM to be raised.
    -
    -The framebuffer may contain 3-component colors (red, green, blue) or -4-component colors (red, green, blue, alpha).  If an alpha channel -is not present, alpha values default to 1.0.
    -
    -The frame buffer color components (red, green, blue, alpha) are either -converted to 8-bit unsigned integers in the range[0, 255] if type is GL_UNSIGNED_BYTE or -converted to floating point values in the range [0, 1] if type is GL_FLOAT.  The (red, -green, blue, alpha) tuples are then stored as GL_RGB triplets (by -dropping the alpha component) or GL_RGBA quadruples in client memory.
    -
    -Image data is packed into -client memory according to the pixel packing parameters which are set by -the command
    -
    -
    void glPixelStorei(GLenum pname, GLint value)
    -
    -
    -pname must be -GL_PACK_ROW_LENGTH.  value -indicates the stride (in pixels) between subsequent rows in the -destination image.  If GL_PACK_ROW_LENGTH is zero (the default) -then the width parameter to glReadPixels indicates the row stride.
    -
    -Pixel readback takes place as follows:
    -
    -
    if (GL_PACK_ROW_LENGTH == 0)
    -    rowLength = width;
    -else
    -    rowLength = GL_PACK_ROW_LENGTH
    -
    -if (format == GL_RGB) {
    -    for (i = 0; i < height; -i++) {
    -        for (j = 0; j < width; j++) {
    -            k = (i * -rowLength + j) * 3;
    -            data[k+0] = FrameBuffer(x + j, y + i).red;
    -            data[k+1] = FrameBuffer(x + j, y + i).green;
    -            data[k+2] = FrameBuffer(x + j, y + i).blue;
    -        }
    -    }
    -}
    -else {
    -    for (i = 0; i < height; -i++) {
    -        for (j = 0; j < width; j++) {
    -            k = (i * -rowLength + j) * 4;
    -            data[k+0] = FrameBuffer(x + j, y + i).red;
    -            data[k+1] = FrameBuffer(x + j, y + i).green;
    -            data[k+2] = FrameBuffer(x + j, y + i).blue;
    -            data[k+3] = FrameBuffer(x + j, y + i).alpha;
    -        }
    -    }
    -}
    -
    -
    -The function FrameBuffer(c, r) -returns the pixel in the frame buffer at column c of row r.  data is considered to be either a -GLubyte pointer or a GLfloat pointer, depending on the type parameter.  Similarly, the -FrameBuffer function returns either GLubyte values in the range [0, 255] -or GLfloat values in the range [0,1], depending on the type parameter.
    -
    -Pixels may be read from either the front or back color buffer. - The command
    -
    -
    void glReadBuffer(GLenumbuffer)
    -
    -
    -specifies the source for reading images with glReadPixels.  If buffer is GL_FRONT then front color -buffer is the source.  If buffer -is GL_BACK then the back color buffer is the source.  It is illegal -to specify GL_BACK when the color buffer is not double buffered. - Any invalid value for buffer -will raise the error GL_INVALID_ENUM.
    -
    -The default read source is GL_BACK if the frame buffer is double -buffered.  Otherwise, the default read source is GL_FRONT.
    -
    -

    8.2 Selection Mode

    -Selection mode is typically used to implement picking: determining which -primitive(s) are present at particular window positions.  The -command
    -
    -
    GLint glRenderMode(GLenummode)
    -
    -
    -is used to enable selection mode.  If mode is GL_SELECTION the graphics -library is put into selection mode.  If mode is GL_RENDER the graphic -library is put into normal rendering mode.  Any other value for mode will raise the error -GL_INVALID_ENUM.
    -
    -When in selection mode rendering commands will not effect the -framebuffer.  Instead, a record of the primitives that would have -been drawn is placed in the selection buffer.  The selection buffer -is specified with the command
    -
    -
    void glSelectionBuffer(GLsizein, GLuint *buffer)
    -
    -
    -buffer
    is an array of n -unsigned integers.  No more than n -values will be placed in the buffer.
    -
    -The name stack is a stack -(LIFO) of unsigned integer names.  The following commands -manipulate the name stack:
    -
    -
    void glInitNames(void)
    -void glPushName(GLuint name)
    -void glPopName(void)
    -void glLoadName(GLuint name)
    -
    -
    -glInitNames resets the name -stack to an empty state.  glPushName pushes the given name value onto the stack.  glPopName pops the top name from the -stack.  glLoadName replaces the top value on -the stack with the specified name. - Stack underflow and overflow conditions cause the errors -GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW to be raised.
    -
    -While in selection mode, primitives (points, lines, polygons) are -transformed and clip-tested normally.  Primitives which aren't -discarded by clipping cause the hit data to be updated.  The hit -data consists of three pieces of information: a hit flag, a minimum Z -value and a maximum Z value.  First, the hit flag is set. - Then, for each of the primitive's vertices, the vertex Z value is -compared to the minimum and maximum Z values.  The minimum Z value -is updated if the vertex's Z value is less than the minimum Z value. - The maximum Z value is updated if the vertex's Z value is greater -than the maximum Z value.
    -
    -When any of glInitNames, glPushName, glPopName, glLoadName or glRenderMode are called and the hit -flag is set, a hit record is -written to the selection buffer.
    -
    -A hit record consists of a sequence of unsigned integers.  The -first value is the size of the name stack.  The second value is the -minimum Z value multiplied by 232-1.  The third value is -the maximum Z value multiplied by 232-1.  The remaining -values are the values in the name stack, in bottom to top order. - The hit flag is cleared after a hit record is written to the -selection buffer.  Hit records are places sequentially into the -selection buffer until it is full or selection mode is terminated.
    -
    -Selection mode is terminated by calling glRenderMode(GL_RENDER).   The -return value of glRenderMode -will be -1 if the selection buffer overflowed.  Otherwise, the -return value will indicate the number of values written into the -selection buffer.
    -
    -

    8.3 Synchronization

    -The command
    -
    -
    void glFlush(void)
    -
    -
    -makes the graphics library to flush all pending graphics commands. - The command
    -

    -void glFinish(void)
    -
    -
    -makes the graphics library flush the command queue and wait until those -commands are completed.  glFlush -will not return until all previous graphics commands have been fully -completed.
    -
    -These commands are typically used to force completion of rendering to -the front color buffer.  Otherwise, rendering to the front color -buffer may not appear.  The swapbuffers -command (part of the window system binding library) does an implicit -flush before swapping the front and back color buffers.  The glReadPixels command also does an -implicit flush before reading pixel data from the frame buffer.
    -
    -

    9. State Queries

    -The current value of nearly all library state variables can be queried. - This chapter describes the commands used for querying the value of -state variables.
    -
    -

    9.1 General State Queries

    -The command
    -
    -
    void glGetFloatv(GLenumpname, GLfloat *values)
    -
    -
    -returns the value(s) of the state variable specified by pname.  The following table -lists all accepted values for pname -and a description of the value(s).  Specifying any other value for pname causes the error -GL_INVALID_ENUM to be raised.
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Variable (pname)
    -
    Number of values
    -
    Value(s) Description
    -
    GL_ALPHA_BITS
    -
    1
    -
    Number of bits per alpha value -in the frame buffer.
    -
    GL_ALPHA_TEST
    -
    1
    -
    Zero if the alpha test is -disabled.
    -One if the alpha test is enabled.
    -
    GL_ALPHA_TEST_FUNC
    -
    1
    -
    The alpha test function.
    -
    GL_BLEND
    -
    1
    -
    Zero if blending is disabled.
    -One if blending is enabled.
    -
    GL_BLEND_DST
    -
    1
    -
    Blend destination function/term.
    -
    GL_BLEND_SRC
    -
    1
    -
    Blend source function/term.
    -
    GL_BLUE_BITS
    -
    1
    -
    Number of bits per blue value in -the frame buffer.
    -
    GL_COLOR_CLEAR_VALUE
    -
    4
    -
    Clear color (red, green, blue, -alpha).
    -
    GL_COLOR_WRITE_MASK
    -
    4
    -
    Color buffer writemask (red, -green, blue, alpha).
    -Zero if writing is disabled.
    -One if writing is enabled.
    -
    GL_CULL_FACE
    -
    1
    -
    Zero if polygon culling is -disabled.
    -One if polygon culling is enabled.
    -
    GL_CULL_FACE_MODE
    -
    1
    -
    Polygon cull mode: GL_FRONT, -GL_BACK or GL_FRONT_AND_BACK.
    -
    GL_CURRENT_COLOR
    -
    4
    -
    Current color (red, green, blue, -alpha).
    -
    GL_CURRENT_RASTER_COLOR
    -
    4
    -
    Current raster position color -(red, green, blue, alpha).
    -
    GL_CURRENT_RASTER_TEXTURE_COORDS
    -
    4
    -
    Current raster position texture -coordinates (s, t, r, q).
    -
    GL_CURRENT_RASTER_POSITION
    -
    4
    -
    Current raster position (x, y, -z, w).
    -
    GL_CURRENT_POSITION_VALID
    -
    1
    -
    Zero if current raster position -is invalid.
    -One if current raster position is valid.
    -
    GL_CURRENT_TEXTURE_COORDS
    -
    4
    -
    Current texture coordinates (s, -t, r, q)
    -
    GL_DOUBLEBUFFER
    -
    1
    -
    Zero if color buffer is -single-buffered.
    -One if color buffer is double-buffered.
    -
    GL_DRAW_BUFFER
    -
    1
    -
    Current color draw buffer: -GL_FRONT or GL_BACK.
    -
    GL_FRONT_FACE1
    -
    Polygon front-face winding: -GL_CW or GL_CCW.
    -
    GL_GREEN_BITS
    -
    1
    -
    Number of bits per green value -in the frame buffer.
    -
    GL_LINE_SMOOTH
    -
    1
    -
    Zero if line smoothing is -disabled.
    -One if line smoothing is enabled.
    -
    GL_LINE_STIPPLE
    -
    1
    -
    Zero if line stippling is -disabled.
    -One if line stippling is enabled.
    -
    GL_LINE_STIPPLE_PATTERN
    -
    1
    -
    Line stipple pattern.
    -
    GL_LINE_STIPPLE_REPEAT
    -
    1
    -
    Line stipple repeat factor.
    -
    GL_LINE_WIDTH
    -
    1
    -
    Line width in pixels.
    -
    GL_LINE_WIDTH_GRANULARITY
    -
    1
    -
    Aliased line width granularity.
    -
    GL_LINE_WIDTH_RANGE
    -
    2
    -
    Minimum and maximum aliased line -widths.
    -
    GL_ALIASED_LINE_WIDTH_RANGE
    -
    2
    -
    Minimum and maximum antialiased -line widths.
    GL_COLOR_LOGIC_OP
    -
    1
    -
    Zero if logicop is disabled.
    -One if logicop is enabled.
    -
    GL_LOGIC_OP_MODE
    -
    1
    -
    Logicop function.
    -
    GL_MATRIX_MODE
    -
    1
    -
    Matrix mode: GL_MODELVIEW or -GL_PROJECTION.
    -
    GL_MAX_MODELVIEW_STACK_DEPTH
    -
    1
    -
    Maximum size of the modelview -matrix stack.
    -
    GL_MAX_NAME_STACK_DEPTH
    -
    1
    -
    Maximum size of the selection -name stack.
    -
    GL_MAX_PROJECTION_STACK_DEPTH
    -
    1
    -
    Maximum size of the projection -matrix stack.
    -
    GL_MAX_TEXTURE_SIZE
    -
    1
    -
    Maximum 2D texture image width -and height.
    -
    GL_MAX_VIEWPORT_DIMS
    -
    2Maximum viewport width and -height in pixels.
    -
    GL_MODELVIEW_MATRIX
    -
    16
    -
    Current/top modelview matrix -values.
    -
    GL_MODELVIEW_MATRIX_STACK_DEPTH
    -
    1
    -
    Current size of the modelview -matrix stack.
    -
    GL_NAME_STACK_DEPTH
    -
    1
    -
    Current size of the selection -name stack.
    -
    GL_PACK_ROW_LENGTH
    -
    1
    -
    Pixel packing row length.
    -
    GL_POLYGON_SMOOTH
    -
    1
    -
    Zero if polygon smoothing is -disabled.
    -One if polygon smoothing is enabled.
    -
    GL_PROJECTION_MATRIX
    -
    16
    -
    Current/top projection matrix -values.
    -
    GL_PROJECTION_STACK_DEPTH
    -
    1
    -
    Current size of projection -matrix stack.
    -
    GL_READ_BUFFER
    -
    1
    -
    Current read buffer: GL_FRONT or -GL_BACK.
    -
    GL_RED_BITS
    -
    1
    -
    Number of bits per red value in -the frame buffer.
    -
    GL_RENDER_MODE
    -
    1
    -
    Current rendering mode: -GL_RENDER or GL_SELECTION.
    -
    GL_RGBA_MODE
    -
    1
    -
    Always one.
    -
    GL_SCISSOR_BOX
    -
    4
    -
    Scissor box (x, y, width, -height).
    -
    GL_SCISSOR_TEST
    -
    1
    -
    Zero if scissor test is disabled.
    -One if scissor test is enabled.
    -
    GL_SELECTION_BUFFER_SIZE
    -
    1
    -
    Size of selection buffer.
    -
    GL_SHADE_MODEL
    -
    1
    -
    Shade model: GL_FLAT or -GL_SMOOTH.
    -
    GL_STENCIL_BITS
    -
    1
    -
    Number of bits per stencil value -in the frame buffer.
    -
    GL_STENCIL_CLEAR_VALUE
    -
    1
    -
    Stencil buffer clear value.
    -
    GL_STENCIL_FAIL
    -
    1
    -
    Stencil fail operation.
    -
    GL_STENCIL_FUNC
    -
    1
    -
    Stencil function.
    -
    GL_STENCIL_REF
    -
    1
    -
    Stencil reference value.
    -
    GL_STENCIL_TEST
    -
    1
    -
    Zero if stencil test is disabled.
    -One if stencil test is enabled.
    -
    GL_STENCIL_VALUE_MASK
    -
    1
    -
    Stencil mask value.
    -
    GL_STENCIL_WRITE_MASK
    -
    1
    -
    Stencil buffer write mask.
    -
    GL_TEXTURE_2D
    -
    1
    -
    Zero if 2D texture mapping is -disabled.
    -One if 2D texture mapping is enabled.
    -
    GL_TEXTURE_BINDING_2D1
    -
    Name of currently bound 2D -texture object.
    -
    GL_TEXTURE_ENV_COLOR
    -
    4
    -
    Texture environment color (red, -green, blue, alpha).
    -
    GL_TEXTURE_ENV_MODE
    -
    1
    -
    Texture environment mode.
    -
    GL_UNPACK_ROW_LENGTH
    -
    1
    -
    Pixel unpacking row length.
    -
    GL_UNPACK_LSB_FIRST
    -
    1
    -
    Zero if most significant bit is -unpacked first for bitmaps.
    -One if least significant bit is unpacked first for bitmaps.
    -
    GL_VIEWPORT
    -
    4
    -
    Current viewport (x, y, width, -height).
    -
    -
    -
    -

    9.2 String Queries

    -The command
    -
    -
    const GLubyte *glGetString(GLenum name)
    -
    -
    -is used to query string-valued values.  The legal values for name are described in the following -table:
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    name
    -
    Return value
    -
    GL_VERSION
    -
    The library version, such as -"1.2".
    -
    GL_RENDERER
    -
    The renderer, such as "Mesa DRI -Radeon".
    -
    GL_VENDOR
    -
    The vendor of this -implementation, such as "Tungsten Graphics, Inc."
    -
    GL_EXTENSIONS
    -
    A white-space separated list of -the supported extensions.
    -
    -

    9.3 Error Queries

    -The command
    -
    -
    GLenum glGetError(void)
    -
    -
    -returns the current error code.  The current error code will be -set by a GL command when an error condition has been detected.  If -the current error code is already set, subsequent errors will not be -recorded.  The error code is reset/cleared to GL_NO_ERROR when glGetError returns.  The -following error codes are possible:
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Error code
    -
    Meaning
    -
    GL_NO_ERROR
    -
    No error has been recorded.
    -
    GL_INVALID_ENUM
    -
    An enum parameter had an invalid -value.
    -
    GL_INVALID_VALUE
    -
    A numeric parameter had an -invalid value.
    -
    GL_INVALID_OPERATION
    -
    A function was called when not -legal to do so.
    -
    GL_STACK_OVERFLOW
    -
    The current transformation -matrix stack is full.
    -
    GL_STACK_UNDERFLOW
    -
    The current transformation -matrix stack is empty.
    -
    GL_OUT_OF_MEMORY
    -
    The system ran out of dynamic -memory.
    -
    -
    -
    -

    10. Unsupported Features

    -This section lists other features and functions which are not supported -and not previously discussed.
    -
    -

    10.1 Feedback Mode

    -Feedback mode and the following related functions are not supported.
    -
    -
    glFeedbackBuffer
    -glPassThrough
    -
    -
    -

    10.2 1D and 3D Textures
    -

    -Only 2D texture images are supported.  The following functions -used to specify 1D and 3D texture images are not supported:
    -
    -
    glTexImage1D
    -glTexImage3D
    -glTexSubImage1D
    - glTexSubImage3D
    -glCopyTexImage1D
    - glCopyTexSubImage1D
    - glCopyTexSubImage3D
    -
    -
    -

    10.3 Alternate Texture Image Commands
    -

    -Texture images may only be specified with glTexImage2D.  The following -alternate texture image commands are not supported:
    -
    -
    glTexSubImage2D
    -glCopyTexImage2D
    -glCopyTexSubImage2D
    -
    -
    -

    10.4 Proxy Textures

    -Proxy textures are not supported and the GL_PROXY_TEXTURE_2D token is -not supported by any function.
    -
    -
    -

    10.5 Other Texture Commands

    -The following commands related to texture mapping are not supported by -the subset:
    -
    -
    glPrioritizeTextures
    -glAreTexturesResident
    -glIsTexture
    -glTexEnviv
    -glTexEnvf
    -glTexParameterf
    -glTexParameteriv
    -glTexParameterfv
    -
    -
    -
    -

    10.6 Copy and Draw Pixels
    -

    -The following commands are not supported:
    -
    -
    glDrawPixels
    -glCopyPixels
    -glPixelZoom
    -
    -
    -

    10.7 Color Index Mode
    -

    -Color index mode and the following related commands are not supported:
    -
    - -
    glIndexub
    -
    glIndexi
    -glIndexs
    -glIndexf
    -glIndexd
    -
    glIndexubv
    -
    glIndexiv
    -glIndexsv
    -glIndexfv
    -glIndexdv

    -glIndexMask
    -
    glClearIndex
    -glIndexPointer

    -
    -
    -

    10.8 Pixel Transfer Operations

    -The pixel transfer operations (scale, bias, look-up table, etc) are not -supported and the following commands are omitted:
    -
    -
    glPixelTransferf
    -glPixelTransferi
    -glPixelMapfv
    -glPixelMapuiv
    -glPixelMapusv
    -glGetPixelMapfv
    -glGetPixelMapuiv
    -glGetPixelMapusv
    -
    -
    -

    10.9 Hints

    -Hints and the following related command is not supported:
    -
    -
    glHint
    -

    -
    -

    10.10 State Query Commands
    -

    -The following state query commands are not supported:
    -
    -
    glGetBooleanv
    -glGetIntegerv
    -glGetDoublev
    -glGetPointerv
    -glGetTexEnvi
    -glGetTexEnvf
    -glGetTexParameteriv
    -glGetTexParameterfv
    -glGetTexLevelParameteriv
    -glGetTexLevelParameterfv
    -glGetTexImage
    -glGetClipPlane
    -
    -
    -

    10.11 Attribute Stacks

    -State attribute stacks and the following related commands are not -supported:
    -
    -
    glPushAttrib
    -glPopAtttrib
    -
    -
    -

    10.12 Double-Valued Functions

    -All functions which take double-precision floating point values, but -for which there is an equivalent single-precision valued function, are -omitted.  This includes, but is not limited to:
    -
    -
    glVertex2d
    -glVertex2dv
    -glVertex3d
    - glVertex3dv
    -glVertex4d
    - glVertex4dv
    -glColor3d
    -glColor3dv
    -glColor4d
    - glColor4dv
    -glTexCoord1d
    -glTexCoord1dv
    -glTexCoord2d
    - glTexCoord2dv
    -glTexCoord3d
    - glTexCoord3dv
    -glTexCoord4d
    - glTexCoord4dv
    -glRasterPos2d
    - glRasterPos2dv
    -glRasterPos3d
    - glRasterPos3dv
    -glRasterPos4d
    - glRasterPos4dv
    -glLoadMatrixd
    -glMultMatrixd
    -glScaled
    -glRotated
    -glTranslated
    -glRectd
    -glRectdv
    -

    -
    -

    10.13 Evaluators

    -Evaluators and the following related commands are not supported:
    -
    -
    glMap1f
    -glMap2d
    -glMap2f
    -glGetMapdv
    -glGetMapfv
    -glGetMapiv
    -glEvalCoord1d
    -glEvalCoord1f
    -glEvalCoord1dv
    -glEvalCoord1fv
    -glEvalCoord2d
    -glEvalCoord2f
    -glEvalCoord2dv
    -glEvalCoord2fv
    -glMapGrid1d
    -glMapGrid1f
    -glMapGrid2d
    -glMapGrid2f
    -glEvalPoint1
    -glEvalPoint2
    -glEvalMesh1
    -glEvalMesh2
    -
    -
    -

    10.14 Display Lists

    -Display lists and the following related commands are not supported:
    -
    -
    glIsList
    -glDeleteLists
    -glGenLists
    -glNewList
    -glEndList
    -glCallList
    -glCallLists
    -glListBase
    -
    -
    -

    10.15 Accumulation Buffer

    -The accumulation buffer and the following related commands are not -supported:
    -
    -
    glAccum
    -glClearAccum
    -
    -
    -

    10.16 Fog

    -Fog and the following related commands are not supported:
    -
    -
    glFogi
    -glFogf
    -glFogiv
    -glFogfv
    -
    -
    -

    10.17 Depth Test

    -Depth testing and the following related commands are not supported:
    -
    -
    glDepthFunc
    -glDepthMask
    -glDepthRange
    -glClearDepth
    -
    -
    -

    10.18 Imaging Subset

    -The OpenGL imaging subset (which implements features such as -convolution, histogram, min/max recording, color matrix and color -tables) is not supported.
    -
    -
    -

    Appendix A: Issues

    -This appendix lists documentation and subset issues with their current -status.  For items which are still open, the documentation (above) -follows the recommended solution.
    -
    -

    A.1 Vertex Arrays

    -Should vertex arrays be supported?  Is there a performance -advantage?
    -
    -RESOLUTION: No, there isn't enough of a performance advantage to -justify them.
    -
    -

    A.2 Polygon Antialiasing and Edge Flags

    -Should edge flags be supported for antialiasing?
    -
    -Edge flags don't effect antialiasing, at least not normally.  A -number of approaches to antialiasing have been summarized in email.
    -
    -RECOMMENDATION: don't support edge flags.  They don't effect -polygon antialiasing.
    -
    -RESOLUTION: closed, as of 26 Feb 2003.
    -
    -

    A.3 glRasterPos vs. glWindowPos

    -Should glRasterPos and/or glWindowPos commands be supported?
    -
    -RESOLUTION: Closed: implement glRasterPos commands, but not glWindowPos -commands.
    -
    -

    A.4 GL_IBM_rasterpos_clip extension

    -Should the GL_IBM_rasterpos_clip extension be implemented?
    -
    -RESOLUTION:  No.  It's not required.
    -
    -

    A.5 Image Formats and Types

    -Which image formats and types should be supported for glTexImage2D and glReadPixels?
    -
    -OpenGL specifies a large -variety of image formats and data types.  Only a few are commonly -used.
    -
    -RECOMMENDATION:  we propose a subset:
    -
    -For glTexImage2D only allow type=GL_UNSIGNED_BYTE and format=GL_RGBA, GL_RGB, -GL_INTENSITY.   Only allow internalFormat -to be GL_RGBA, GL_RGB or GL_INTENSITY as well.  Basically, only -support image formats/types that are directly supported by the Radeon -hardware.  This will allow glTexImage2D -to basically just use memcpy to -copy texture images.
    -
    -For glReadPixels, only allow type = GL_UNSIGNED_BYTE or GL_FLOAT. - Only allow format = -GL_RGB or GL_RGBA.  This is just enough to support the OpenGL -conformance tests.
    -
    -RESOLUTION: open
    -
    -

    A.6 Texture Environment Modes

    -Which texture environment modes should be supported?  OpenGL 1.2 -has GL_REPLACE, GL_MODULATE, GL_DECAL and GL_BLEND.  GL_DECAL isn't -defined for all base internal texture formats.  GL_ADD is another -useful mode.  Perhaps drop GL_DECAL mode and add GL_ADD mode.
    -
    -RECOMMENDATION: implement the standard modes GL_REPLACE, GL_MODULATE, -GL_DECAL and GL_BLEND.
    -
    -RESOLUTION: open
    -
    -

    A.7 Truncated Mipmaps and LOD Control

    -Should we support the GL_TEXTURE_BASE_LEVEL, GL_TEXTURE_MAX_LEVEL, -GL_TEXTURE_MIN_LOD and GL_TEXTURE_MAX_LOD texture parameters?
    -
    -RECOMMENDATION:  We propose omitting these features at this time, -in the interest of simplifying the driver.
    -
    -RESOLUTION: open
    -
    -

    A.8 Texture Priorities and Residency

    -Should the subset support texture priorities via glPrioritizeTextures and the glAreTexturesResident command?
    -
    -RECOMMENDATION:  Few applications use these features and -functions.  We propose omitting them to simplify the driver.
    -
    -RESOLUTION: open
    -
    -

    A.9 Pixel Pack/Unpack Alignment Control

    -Should we support the GL_PACK_ALIGNMENT and GL_UNPACK_ALIGNMENT options?
    -
    -These are used to align pixel data addresses to 1, 2 and 4-byte -multiples for glBitmap, glTexImage2D -and glReadPixels.  These -aren't strictly needed since the user can provide a 1, 2 or 4-byte -aligned address and appropriate GL_PACK_ROW_LENGTH or -GL_UNPACK_ROW_LENGTH values instead.
    -
    -RECOMMENDATION:  We recommend omitting them to simplify the driver.
    -
    -RESOLUTION: open
    -
    -

    A.10 Pixel Pack/Unpack Skip Rows/Pixels Control

    -Should we support the GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, -GL_PACK_SKIP_PIXELS and GL_PACK_SKIP_ROWS options for pixel -unpacking/packing?
    -
    -These options aren't really needed since the user can adjust the start -address and GL_PACK/UNPACK_ROW_LENGTH parameters to achieve the same -effect.
    -
    -RECOMMENDATION:  omit these parameters.
    -
    -RESOLUTION: open
    -
    -

    A.11 Texture State Queries

    -Should we support the command glGetTexEnvi/fv, -glGetTexParameteri/fv and glGetTexLevelParameteri/fv?
    -
    -RECOMMENDATION:  No. They're seldom needed and their -implementation is several hundred lines of code in length.
    -
    -RESOLUTION:  open
    -
    -

    A.12 glGetIntegerv, glGetBooleanv and glGetDoublev

    -Should we support the commands glGetIntegerv, -glGetBooleanv and glGetDoublev -in addition to glGetFloatv?
    -
    -RECOMMENDATION:  Omit the boolean, integer and double-valued -functions. All state values which can be queried by these commands can -be expressed as floating point values and queried with glGetFloatv.  The -implementation of the other three commands involves many lines of code.
    -
    -RESOLUTION:  open
    -
    -

    A.13 glBitmap and Per-Fragment Operations

    -Should bitmaps rendered with glBitmap -be subjected to the per-fragment operations?
    -
    -If bitmaps are implemented with points it will be easy to implement the -per-fragment operations.  Otherwise, it could be difficult.
    -
    -RECOMMENDATION:  Implement glBitmap by drawing points/pixels with -the hardware.  This will make supporting the per-fragments -trivially easy.  Also, it makes portrait-mode display relatively -easy.
    -
    -RESOLUTION:  open
    -
    -

    A.14 Reduced gl.h Header File

    -Should we produce a reduced gl.h header file which only defines the -tokens and functions which are implemented by the subset?
    -
    -RECOMMENDATION: yes.  It would be a useful reference to -programmers to quickly determine which functions and tokens are -supported.
    -
    -RESOLUTION: open
    -
    -

    A.15 glPolygonMode

    -Is glPolygonMode needed?
    -
    -RECOMMENDATION: No.  Omit it.
    -
    -RESOLUTION: closed, as of 26 Feb 2003
    -
    -
    -

    - - diff --git a/mesalib/docs/subset.html b/mesalib/docs/subset.html deleted file mode 100644 index 0ceb13666..000000000 --- a/mesalib/docs/subset.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Mesa Subset Driver - - - - -

    Mesa Subset Driver

    - -

    -In 2002/2003 Tungsten Graphics was contracted to develop a subset Mesa/Radeon -driver for an embedded environment. The result is a reduced-size DRI driver -for the ATI R200 chip, for use with -fbdev/DRI environment. -

    - -

    -The specification for this subset can be found -here. -

    - - - diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index 03b64c931..353805b7f 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -328,7 +328,7 @@ static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { #define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} -const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { +static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { STATEVAR(gl_DepthRange), STATEVAR(gl_ClipPlane), STATEVAR(gl_Point), diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am index d81bc0e3f..6e9d738fa 100644 --- a/mesalib/src/mesa/drivers/dri/common/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am @@ -28,11 +28,17 @@ AM_CFLAGS = \ $(API_DEFINES) \ $(LIBDRM_CFLAGS) -noinst_LTLIBRARIES = libdricommon.la +noinst_LTLIBRARIES = \ + libdricommon.la \ + libdri_test_stubs.la libdricommon_la_SOURCES = \ utils.c \ dri_util.c \ xmlconfig.c +libdri_test_stubs_la_SOURCES = \ + dri_test.c +libdri_test_stubs_la_CFLAGS = $(AM_CFLAGS) -DNO_MAIN + sysconf_DATA = drirc diff --git a/mesalib/src/mesa/drivers/dri/common/dri_test.c b/mesalib/src/mesa/drivers/dri/common/dri_test.c index 793f0c37d..35732857d 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_test.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_test.c @@ -82,8 +82,10 @@ _glthread_GetID(void) return 0; } +#ifndef NO_MAIN int main(int argc, char** argv) { void* p = __driDriverExtensions; return (int)(unsigned long)p; } +#endif diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index e6a1e68cb..0000a397a 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -251,14 +251,14 @@ struct dd_function_table { struct gl_texture_object *texObj); /** - * Called by glTexImage[123]D when user specifies a proxy texture - * target. - * - * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. + * Called by glTexImage, glCompressedTexImage, glCopyTexImage + * and glTexStorage to check if the dimensions of the texture image + * are too large. + * \param target any GL_PROXY_TEXTURE_x target + * \return GL_TRUE if the image is OK, GL_FALSE if too large */ GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, + GLint level, gl_format format, GLint width, GLint height, GLint depth, GLint border); /*@}*/ diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index da8fbcd32..83e79a5a3 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1209,44 +1209,22 @@ _mesa_clear_texture_image(struct gl_context *ctx, /** - * This is the fallback for Driver.TestProxyTexImage(). Test the texture - * level, width, height and depth against the ctx->Const limits for textures. - * - * A hardware driver might override this function if, for example, the - * max 3D texture size is 512x512x64 (i.e. not a cube). - * - * Note that width, height, depth == 0 is not an error. However, a - * texture with zero width/height/depth will be considered "incomplete" - * and texturing will effectively be disabled. - * - * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, - * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, - * GL_PROXY_TEXTURE_CUBE_MAP_ARB. - * \param level as passed to glTexImage - * \param internalFormat as passed to glTexImage - * \param format as passed to glTexImage - * \param type as passed to glTexImage - * \param width as passed to glTexImage - * \param height as passed to glTexImage - * \param depth as passed to glTexImage - * \param border as passed to glTexImage - * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. + * Check the width, height, depth and border of a texture image are legal. + * Used by all the glTexImage, glCompressedTexImage and glCopyTexImage + * functions. + * The target and level parameters will have already been validated. + * \return GL_TRUE if size is OK, GL_FALSE otherwise. */ GLboolean -_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border) +_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, + GLint level, GLint width, GLint height, + GLint depth, GLint border) { GLint maxSize; - (void) internalFormat; - (void) format; - (void) type; - switch (target) { + case GL_TEXTURE_1D: case GL_PROXY_TEXTURE_1D: - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); /* level zero size */ maxSize >>= level; /* level size */ if (width < 2 * border || width > 2 * border + maxSize) @@ -1257,9 +1235,8 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, } return GL_TRUE; + case GL_TEXTURE_2D: case GL_PROXY_TEXTURE_2D: - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); maxSize >>= level; if (width < 2 * border || width > 2 * border + maxSize) @@ -1274,9 +1251,8 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, } return GL_TRUE; + case GL_TEXTURE_3D: case GL_PROXY_TEXTURE_3D: - if (level >= ctx->Const.Max3DTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); maxSize >>= level; if (width < 2 * border || width > 2 * border + maxSize) @@ -1295,6 +1271,7 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, } return GL_TRUE; + case GL_TEXTURE_RECTANGLE_NV: case GL_PROXY_TEXTURE_RECTANGLE_NV: if (level != 0) return GL_FALSE; @@ -1305,9 +1282,13 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, return GL_FALSE; return GL_TRUE; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - if (level >= ctx->Const.MaxCubeTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); maxSize >>= level; if (width < 2 * border || width > 2 * border + maxSize) @@ -1322,9 +1303,8 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, } return GL_TRUE; + case GL_TEXTURE_1D_ARRAY_EXT: case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); maxSize >>= level; if (width < 2 * border || width > 2 * border + maxSize) @@ -1337,9 +1317,8 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, } return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); maxSize >>= level; if (width < 2 * border || width > 2 * border + maxSize) @@ -1357,25 +1336,43 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, return GL_TRUE; default: - _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); + _mesa_problem(ctx, "Invalid target in _mesa_legal_texture_dimensions()"); return GL_FALSE; } } /** - * Check if the memory used by the texture would exceed the driver's limit. - * This lets us support a max 3D texture size of 8K (for example) but - * prevents allocating a full 8K x 8K x 8K texture. - * XXX this could be rolled into the proxy texture size test (above) but - * we don't have the actual texture internal format at that point. + * This is the fallback for Driver.TestProxyTexImage() for doing device- + * specific texture image size checks. + * + * A hardware driver might override this function if, for example, the + * max 3D texture size is 512x512x64 (i.e. not a cube). + * + * Note that width, height, depth == 0 is not an error. However, a + * texture with zero width/height/depth will be considered "incomplete" + * and texturing will effectively be disabled. + * + * \param target any texture target/type + * \param level as passed to glTexImage + * \param format the MESA_FORMAT_x for the tex image + * \param width as passed to glTexImage + * \param height as passed to glTexImage + * \param depth as passed to glTexImage + * \param border as passed to glTexImage + * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. */ -static GLboolean -legal_texture_size(struct gl_context *ctx, gl_format format, - GLint width, GLint height, GLint depth) +GLboolean +_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, + gl_format format, + GLint width, GLint height, GLint depth, GLint border) { + /* We just check if the image size is less than MaxTextureMbytes. + * Some drivers may do more specific checks. + */ uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ + mbytes *= _mesa_num_tex_faces(target); return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; } @@ -1663,20 +1660,12 @@ get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) } -/** - * Special value returned by error some texture error checking functions when - * an error is detected and the proxy texture image's width/height/depth/format - * fields should be zeroed-out. - */ -#define PROXY_ERROR 2 - - /** * Test the glTexImage[123]D() parameters for errors. * * \param ctx GL context. * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. + * \param target texture target given by the user (already validated). * \param level image level given by the user. * \param internalFormat internal format given by the user. * \param format pixel data format given by the user. @@ -1686,14 +1675,17 @@ get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) * \param depth image depth given by the user. * \param border image border given by the user. * - * \return PROXY_ERROR if there's an error that should zero-out the proxy image, - * GL_TRUE if a regular GL error is found, or GL_FALSE if no error, + * \return GL_TRUE if a error is found, GL_FALSE otherwise * * Verifies each of the parameters against the constants specified in * __struct gl_contextRec::Const and the supported extensions, and according * to the OpenGL specification. + * Note that we don't fully error-check the width, height, depth values + * here. That's done in _mesa_legal_texture_dimensions() which is used + * by several other GL entrypoints. Plus, texture dims have a special + * interaction with proxy textures. */ -static GLenum +static GLboolean texture_error_check( struct gl_context *ctx, GLuint dimensions, GLenum target, GLint level, GLint internalFormat, @@ -1701,9 +1693,6 @@ texture_error_check( struct gl_context *ctx, GLint width, GLint height, GLint depth, GLint border ) { - const GLenum proxyTarget = _mesa_get_proxy_target(target); - const GLboolean isProxy = target == proxyTarget; - GLboolean sizeOK = GL_TRUE; GLboolean colorFormat; GLenum err; @@ -1720,8 +1709,8 @@ texture_error_check( struct gl_context *ctx, * zero-out behaviour is only used in cases related to memory allocation. */ - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + /* level check */ + if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, "glTexImage%dD(level=%d)", dimensions, level); return GL_TRUE; @@ -1769,30 +1758,11 @@ texture_error_check( struct gl_context *ctx, } } - /* Do this simple check before calling the TestProxyTexImage() function */ - if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - sizeOK = (width == height); - } - - /* - * Use the proxy texture driver hook to see if the size/level/etc are - * legal. - */ - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, format, - type, width, height, - depth, border); - if (!sizeOK) { - if (isProxy) { - /* No GL error is recorded, but we need to zero-out the image dims */ - return PROXY_ERROR; - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", - dimensions, level, width, height, depth); - return GL_TRUE; - } + if ((target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + _mesa_is_cube_face(target)) && width != height) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage2D(cube width != height)"); + return GL_TRUE; } /* Check internalFormat */ @@ -1921,8 +1891,9 @@ texture_error_check( struct gl_context *ctx, /** * Error checking for glCompressedTexImage[123]D(). - * \param reason returns reason for error, if any - * \return error code or GL_NO_ERROR or PROXY_ERROR. + * Note that the width, height and depth values are not fully error checked + * here. + * \return GL_TRUE if a error is found, GL_FALSE otherwise */ static GLenum compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, @@ -1931,7 +1902,6 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize) { - const GLenum proxyTarget = _mesa_get_proxy_target(target); const GLint maxLevels = _mesa_max_texture_levels(ctx, target); GLint expectedSize; GLenum choose_format; @@ -2033,13 +2003,15 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, } /* For cube map, width must equal height */ - if (_mesa_is_cube_face(target) && width != height) { + if ((target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + _mesa_is_cube_face(target)) && width != height) { reason = "width != height"; error = GL_INVALID_VALUE; goto error; } /* check image size against compression block size */ + /* XXX possibly move this into the _mesa_legal_texture_dimensions() func */ { gl_format texFormat = ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format, @@ -2060,20 +2032,6 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, } } - /* check image sizes */ - if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - proxy_format, choose_format, - choose_type, - width, height, depth, border)) { - /* See error comment above */ - if (target == proxyTarget) { - return PROXY_ERROR; - } - reason = "invalid width, height or format"; - error = GL_INVALID_OPERATION; - goto error; - } - /* check image size in bytes */ if (expectedSize != imageSize) { /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] @@ -2091,11 +2049,11 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, goto error; } - return GL_NO_ERROR; + return GL_FALSE; error: _mesa_error(ctx, error, "glCompressedTexImage%dD(%s)", dimensions, reason); - return error; + return GL_TRUE; } @@ -2105,7 +2063,7 @@ error: * * \param ctx GL context. * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. + * \param target texture target given by the user (already validated) * \param level image level given by the user. * \param xoffset sub-image x offset given by the user. * \param yoffset sub-image y offset given by the user. @@ -2131,8 +2089,8 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions, { GLenum err; - /* Basic level check */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + /* level check */ + if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); return GL_TRUE; } @@ -2306,9 +2264,6 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border ) { - const GLenum proxyTarget = _mesa_get_proxy_target(target); - const GLenum type = GL_FLOAT; - GLboolean sizeOK; GLint baseFormat; /* check target */ @@ -2318,8 +2273,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + /* level check */ + if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, "glCopyTexImage%dD(level=%d)", dimensions, level); return GL_TRUE; @@ -2403,25 +2358,10 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, } } - /* Do size, level checking */ - sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) - ? (width == height) : 1; - - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, baseFormat, - type, width, height, - 1, border); - - if (!sizeOK) { - if (dimensions == 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage1D(width=%d)", width); - } - else { - ASSERT(dimensions == 2); - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage2D(width=%d, height=%d)", width, height); - } + if ((target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + _mesa_is_cube_face(target)) && width != height) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage2D(cube width != height)"); return GL_TRUE; } @@ -2497,7 +2437,7 @@ copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, } /* Check level */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, "glCopyTexSubImage%dD(level=%d)", dimensions, level); return GL_TRUE; @@ -2901,9 +2841,11 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, GLsizei imageSize, const GLvoid *pixels) { const char *func = compressed ? "glCompressedTexImage" : "glTexImage"; - GLenum error; struct gl_pixelstore_attrib unpack_no_border; const struct gl_pixelstore_attrib *unpack = &ctx->Unpack; + struct gl_texture_object *texObj; + gl_format texFormat; + GLboolean dimensionsOK, sizeOK; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -2937,22 +2879,23 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, /* general error checking */ if (compressed) { - error = compressed_texture_error_check(ctx, dims, target, level, - internalFormat, - width, height, depth, - border, imageSize); + if (compressed_texture_error_check(ctx, dims, target, level, + internalFormat, + width, height, depth, + border, imageSize)) + return; } else { - error = texture_error_check(ctx, dims, target, level, internalFormat, - format, type, width, height, depth, border); + if (texture_error_check(ctx, dims, target, level, internalFormat, + format, type, width, height, depth, border)) + return; } -#if FEATURE_ES /* Here we convert a cpal compressed image into a regular glTexImage2D * call by decompressing the texture. If we really want to support cpal * textures in any driver this would have to be changed. */ - if (compressed && !error && dims == 2) { + if (ctx->API == API_OPENGLES && compressed && dims == 2) { switch (internalFormat) { case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: @@ -2969,50 +2912,55 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, return; } } -#endif + + texObj = _mesa_get_current_tex_object(ctx, target); + assert(texObj); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, type); + assert(texFormat != MESA_FORMAT_NONE); + + /* check that width, height, depth are legal for the mipmap level */ + dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, level, width, + height, depth, border); + + /* check that the texture won't take too much memory, etc */ + sizeOK = ctx->Driver.TestProxyTexImage(ctx, _mesa_get_proxy_target(target), + level, texFormat, + width, height, depth, border); if (_mesa_is_proxy_texture(target)) { /* Proxy texture: just clear or set state depending on error checking */ struct gl_texture_image *texImage = get_proxy_tex_image(ctx, target, level); - gl_format texFormat = MESA_FORMAT_NONE; - if (!error) { - /* No parameter errors. Choose a texture format and see if we - * can really allocate the texture. - */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, format, type); - if (!legal_texture_size(ctx, texFormat, width, height, depth)) { - error = PROXY_ERROR; - } - } + if (!texImage) + return; /* GL_OUT_OF_MEMORY already recorded */ - if (error == PROXY_ERROR) { - /* image too large, etc. Clear all proxy texture image parameters. */ - if (texImage) - clear_teximage_fields(texImage); - } - else if (error == GL_FALSE) { - /* no error: store the teximage parameters */ - if (texImage) - _mesa_init_teximage_fields(ctx, texImage, width, height, depth, - border, internalFormat, texFormat); + if (dimensionsOK && sizeOK) { + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, + border, internalFormat, texFormat); } else { - /* other, regular error (was already recorded) */ + clear_teximage_fields(texImage); } } else { /* non-proxy target */ const GLuint face = _mesa_tex_target_to_face(target); - struct gl_texture_object *texObj; struct gl_texture_image *texImage; - if (error) { - return; /* error was recorded */ + if (!dimensionsOK) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%uD(invalid width or height or depth)", + dims); + return; + } + + if (!sizeOK) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glTexImage%uD(image too large)", dims); + return; } /* Allow a hardware driver to just strip out the border, to provide @@ -3029,8 +2977,6 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, if (ctx->NewState & _NEW_PIXEL) _mesa_update_state(ctx); - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); { texImage = _mesa_get_tex_image(ctx, texObj, target, level); @@ -3039,38 +2985,27 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims); } else { - gl_format texFormat; - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, format, - type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, - width, height, depth, - border, internalFormat, texFormat); - - /* Give the texture to the driver. may be null. */ - if (compressed) { - ctx->Driver.CompressedTexImage(ctx, dims, texImage, - imageSize, pixels); - } - else { - ctx->Driver.TexImage(ctx, dims, texImage, format, - type, pixels, unpack); - } - - check_gen_mipmap(ctx, target, texObj, level); - - _mesa_update_fbo_texture(ctx, texObj, face, level); + _mesa_init_teximage_fields(ctx, texImage, + width, height, depth, + border, internalFormat, texFormat); - _mesa_dirty_texobj(ctx, texObj, GL_TRUE); + /* Give the texture to the driver. may be null. */ + if (compressed) { + ctx->Driver.CompressedTexImage(ctx, dims, texImage, + imageSize, pixels); } else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims); + ctx->Driver.TexImage(ctx, dims, texImage, format, + type, pixels, unpack); } + + check_gen_mipmap(ctx, target, texObj, level); + + _mesa_update_fbo_texture(ctx, texObj, face, level); + + _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } } _mesa_unlock_texture(ctx, texObj); @@ -3078,6 +3013,7 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, } + /* * Called from the API. Note that width includes the border. */ @@ -3343,6 +3279,7 @@ copyteximage(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texObj; struct gl_texture_image *texImage; const GLuint face = _mesa_tex_target_to_face(target); + gl_format texFormat; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -3360,7 +3297,27 @@ copyteximage(struct gl_context *ctx, GLuint dims, width, height, border)) return; + if (!_mesa_legal_texture_dimensions(ctx, target, level, width, height, + 1, border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%uD(invalid width or height)", dims); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); + assert(texObj); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, GL_NONE); + assert(texFormat != MESA_FORMAT_NONE); + + if (!ctx->Driver.TestProxyTexImage(ctx, _mesa_get_proxy_target(target), + level, texFormat, + width, height, 1, border)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCopyTexImage%uD(image too large)", dims); + return; + } if (border && ctx->Const.StripTextureBorder) { x += border; @@ -3380,45 +3337,33 @@ copyteximage(struct gl_context *ctx, GLuint dims, _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); } else { - /* choose actual hw format */ - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - GL_NONE, GL_NONE); - - if (legal_texture_size(ctx, texFormat, width, height, 1)) { - GLint srcX = x, srcY = y, dstX = 0, dstY = 0, dstZ = 0; + GLint srcX = x, srcY = y, dstX = 0, dstY = 0, dstZ = 0; - /* Free old texture image */ - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + /* Free old texture image */ + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - _mesa_init_teximage_fields(ctx, texImage, width, height, 1, - border, internalFormat, texFormat); + _mesa_init_teximage_fields(ctx, texImage, width, height, 1, + border, internalFormat, texFormat); - /* Allocate texture memory (no pixel data yet) */ - ctx->Driver.TexImage(ctx, dims, texImage, - GL_NONE, GL_NONE, - NULL, &ctx->Unpack); + /* Allocate texture memory (no pixel data yet) */ + ctx->Driver.TexImage(ctx, dims, texImage, + GL_NONE, GL_NONE, + NULL, &ctx->Unpack); - if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, - &width, &height)) { - struct gl_renderbuffer *srcRb = - get_copy_tex_image_source(ctx, texImage->TexFormat); + if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, + &width, &height)) { + struct gl_renderbuffer *srcRb = + get_copy_tex_image_source(ctx, texImage->TexFormat); - ctx->Driver.CopyTexSubImage(ctx, dims, texImage, dstX, dstY, dstZ, - srcRb, srcX, srcY, width, height); - } + ctx->Driver.CopyTexSubImage(ctx, dims, texImage, dstX, dstY, dstZ, + srcRb, srcX, srcY, width, height); + } - check_gen_mipmap(ctx, target, texObj, level); + check_gen_mipmap(ctx, target, texObj, level); - _mesa_update_fbo_texture(ctx, texObj, face, level); + _mesa_update_fbo_texture(ctx, texObj, face, level); - _mesa_dirty_texobj(ctx, texObj, GL_TRUE); - } - else { - /* probably too large of image */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); - } + _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } } _mesa_unlock_texture(ctx, texObj); diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h index 36fd1c2bc..c7c32d8ac 100644 --- a/mesalib/src/mesa/main/teximage.h +++ b/mesalib/src/mesa/main/teximage.h @@ -128,8 +128,8 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target); extern GLboolean _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border); + gl_format format, + GLint width, GLint height, GLint depth, GLint border); extern GLuint @@ -142,6 +142,11 @@ extern GLenum _mesa_es_error_check_format_and_type(GLenum format, GLenum type, unsigned dimensions); +extern GLboolean +_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, + GLint level, GLint width, GLint height, + GLint depth, GLint border); + /** * Lock a texture for updating. See also _mesa_lock_context_textures(). */ diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h index a6f1d3a14..f22c58cad 100644 --- a/mesalib/src/mesa/main/texobj.h +++ b/mesalib/src/mesa/main/texobj.h @@ -85,7 +85,13 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, static inline GLuint _mesa_num_tex_faces(GLenum target) { - return target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + switch (target) { + case GL_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_CUBE_MAP: + return 6; + default: + return 1; + } } diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c index f8a939794..ca02ef301 100644 --- a/mesalib/src/mesa/main/texstorage.c +++ b/mesalib/src/mesa/main/texstorage.c @@ -118,42 +118,42 @@ next_mipmap_level_size(GLenum target, } -/** - * Do actual memory allocation for glTexStorage1/2/3D(). - */ -static void -setup_texstorage(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLuint dims, - GLsizei levels, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei depth) +/** Helper to get a particular texture image in a texture object */ +static struct gl_texture_image * +get_tex_image(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLuint face, GLuint level) +{ + const GLenum faceTarget = + (texObj->Target == GL_TEXTURE_CUBE_MAP || + texObj->Target == GL_PROXY_TEXTURE_CUBE_MAP) + ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : texObj->Target; + return _mesa_get_tex_image(ctx, texObj, faceTarget, level); +} + + + +static GLboolean +initialize_texture_fields(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLint levels, + GLsizei width, GLsizei height, GLsizei depth, + GLenum internalFormat, gl_format texFormat) { const GLenum target = texObj->Target; const GLuint numFaces = _mesa_num_tex_faces(target); - gl_format texFormat; GLint level, levelWidth = width, levelHeight = height, levelDepth = depth; GLuint face; - assert(levels > 0); - assert(width > 0); - assert(height > 0); - assert(depth > 0); - - texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, - internalFormat, GL_NONE, GL_NONE); - /* Set up all the texture object's gl_texture_images */ for (level = 0; level < levels; level++) { for (face = 0; face < numFaces; face++) { - const GLenum faceTarget = - (target == GL_TEXTURE_CUBE_MAP) - ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : target; struct gl_texture_image *texImage = - _mesa_get_tex_image(ctx, texObj, faceTarget, level); + get_tex_image(ctx, texObj, face, level); if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - return; + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage"); + return GL_FALSE; } _mesa_init_teximage_fields(ctx, texImage, @@ -163,49 +163,18 @@ setup_texstorage(struct gl_context *ctx, next_mipmap_level_size(target, &levelWidth, &levelHeight, &levelDepth); } - - assert(levelWidth > 0); - assert(levelHeight > 0); - assert(levelDepth > 0); - - if (!_mesa_is_proxy_texture(texObj->Target)) { - /* Do actual texture memory allocation */ - if (!ctx->Driver.AllocTextureStorage(ctx, texObj, levels, - width, height, depth)) { - /* Reset the texture images' info to zeros. - * Strictly speaking, we probably don't have to do this since - * generating GL_OUT_OF_MEMORY can leave things in an undefined - * state but this puts things in a consistent state. - */ - for (level = 0; level < levels; level++) { - for (face = 0; face < numFaces; face++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - _mesa_init_teximage_fields(ctx, texImage, - 0, 0, 0, 0, - GL_NONE, MESA_FORMAT_NONE); - } - } - } - - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage%uD", dims); - - return; - } - - /* Only set this field for non-proxy texture objects */ - texObj->Immutable = GL_TRUE; - } + return GL_TRUE; } /** * Clear all fields of texture object to zeros. Used for proxy texture tests. + * Used for proxy texture tests (and to clean up when a texture memory + * allocation fails). */ static void -clear_image_fields(struct gl_context *ctx, - GLuint dims, - struct gl_texture_object *texObj) +clear_texture_fields(struct gl_context *ctx, + struct gl_texture_object *texObj) { const GLenum target = texObj->Target; const GLuint numFaces = _mesa_num_tex_faces(target); @@ -214,19 +183,17 @@ clear_image_fields(struct gl_context *ctx, for (level = 0; level < Elements(texObj->Image[0]); level++) { for (face = 0; face < numFaces; face++) { - const GLenum faceTarget = - (target == GL_TEXTURE_CUBE_MAP) - ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : target; struct gl_texture_image *texImage = - _mesa_get_tex_image(ctx, texObj, faceTarget, level); + get_tex_image(ctx, texObj, face, level); if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage%uD", dims); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage"); return; } _mesa_init_teximage_fields(ctx, texImage, - 0, 0, 0, 0, GL_NONE, MESA_FORMAT_NONE); + 0, 0, 0, 0, /* w, h, d, border */ + GL_NONE, MESA_FORMAT_NONE); } } } @@ -301,13 +268,6 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, return GL_TRUE; } - /* levels check */ - if (levels < 1 || height < 1 || depth < 1) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)", - dims); - return GL_TRUE; - } - /* target check */ if (!legal_texobj_target(ctx, dims, target)) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -316,7 +276,14 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, return GL_TRUE; } - /* check levels against maximum */ + /* levels check */ + if (levels < 1) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexStorage%uD(levels < 1)", + dims); + return GL_TRUE; + } + + /* check levels against maximum (note different error than above) */ if (levels > _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glTexStorage%uD(levels too large)", dims); @@ -359,37 +326,76 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) { struct gl_texture_object *texObj; - GLboolean sizeOK; - GLenum proxyTarget = _mesa_get_proxy_target(target); + GLboolean sizeOK, dimensionsOK; + gl_format texFormat; GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_get_current_tex_object(ctx, target); - if (tex_storage_error_check(ctx, dims, target, levels, internalformat, width, height, depth)) { return; /* error was recorded */ } - sizeOK = ctx->Driver.TestProxyTexImage(ctx, proxyTarget, 0, - internalformat, GL_NONE, GL_NONE, + texObj = _mesa_get_current_tex_object(ctx, target); + assert(texObj); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, 0, + internalformat, GL_NONE, GL_NONE); + assert(texFormat != MESA_FORMAT_NONE); + + /* check that width, height, depth are legal for the mipmap level */ + dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0, + width, height, depth, 0); + + sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat, width, height, depth, 0); - if (!sizeOK) { - if (_mesa_is_proxy_texture(texObj->Target)) { - /* clear all image fields for [levels] */ - clear_image_fields(ctx, dims, texObj); + if (_mesa_is_proxy_texture(texObj->Target)) { + if (dimensionsOK && sizeOK) { + initialize_texture_fields(ctx, texObj, levels, width, height, depth, + internalformat, texFormat); } else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexStorage%uD(invalid width, height or depth)", - dims); - return; + /* clear all image fields for [levels] */ + clear_texture_fields(ctx, texObj); } } else { - setup_texstorage(ctx, texObj, dims, levels, internalformat, - width, height, depth); + if (!dimensionsOK) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexStorage%uD(invalid width, height or depth)", dims); + return; + } + + if (!sizeOK) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glTexStorage%uD(texture too large)", dims); + } + + assert(levels > 0); + assert(width > 0); + assert(height > 0); + assert(depth > 0); + + if (!initialize_texture_fields(ctx, texObj, levels, width, height, depth, + internalformat, texFormat)) { + return; + } + + /* Do actual texture memory allocation */ + if (!ctx->Driver.AllocTextureStorage(ctx, texObj, levels, + width, height, depth)) { + /* Reset the texture images' info to zeros. + * Strictly speaking, we probably don't have to do this since + * generating GL_OUT_OF_MEMORY can leave things in an undefined + * state but this puts things in a consistent state. + */ + clear_texture_fields(ctx, texObj); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexStorage%uD", dims); + return; + } + + texObj->Immutable = GL_TRUE; } } diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index bb0552476..e84964c6f 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -244,8 +244,6 @@ struct gl_builtin_uniform_desc { unsigned int num_elements; }; -extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; - /** * \name GLSL uniform arrays and structs require special handling. * diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index bc7b1fa0e..55638a807 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -54,6 +54,27 @@ override_version(struct gl_context *ctx) ctx->Version = major * 10 + minor; } +/** + * Builds the MESA version string. + */ +static void +create_version_string(struct gl_context *ctx, const char *prefix) +{ + static const int max = 100; + + ctx->VersionString = malloc(max); + if (ctx->VersionString) { + _mesa_snprintf(ctx->VersionString, max, + "%s%u.%u Mesa " MESA_VERSION_STRING +#ifdef MESA_GIT_SHA1 + " (" MESA_GIT_SHA1 ")" +#endif + , + prefix, + ctx->Version / 10, ctx->Version % 10); + } +} + /** * Override the context's GLSL version if the environment variable * MESA_GLSL_VERSION_OVERRIDE is set. Valid values for @@ -85,7 +106,6 @@ static void compute_version(struct gl_context *ctx) { GLuint major, minor; - static const int max = 100; const GLboolean ver_1_3 = (ctx->Extensions.ARB_texture_border_clamp && ctx->Extensions.ARB_texture_cube_map && @@ -224,23 +244,12 @@ compute_version(struct gl_context *ctx) override_version(ctx); - ctx->VersionString = malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "%u.%u Mesa " MESA_VERSION_STRING -#ifdef MESA_GIT_SHA1 - " (" MESA_GIT_SHA1 ")" -#endif - , - ctx->Version / 10, ctx->Version % 10); - } + create_version_string(ctx, ""); } static void compute_version_es1(struct gl_context *ctx) { - static const int max = 100; - /* OpenGL ES 1.0 is derived from OpenGL 1.3 */ const GLboolean ver_1_0 = (ctx->Extensions.ARB_texture_env_combine && ctx->Extensions.ARB_texture_env_dot3); @@ -256,23 +265,12 @@ compute_version_es1(struct gl_context *ctx) _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support."); } - ctx->VersionString = malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING -#ifdef MESA_GIT_SHA1 - " (" MESA_GIT_SHA1 ")" -#endif - , - ctx->Version % 10); - } + create_version_string(ctx, "OpenGL ES-CM "); } static void compute_version_es2(struct gl_context *ctx) { - static const int max = 100; - /* OpenGL ES 2.0 is derived from OpenGL 2.0 */ const GLboolean ver_2_0 = (ctx->Extensions.ARB_texture_cube_map && ctx->Extensions.EXT_blend_color && @@ -289,15 +287,7 @@ compute_version_es2(struct gl_context *ctx) _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support."); } - ctx->VersionString = malloc(max); - if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, - "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING -#ifdef MESA_GIT_SHA1 - " (" MESA_GIT_SHA1 ")" -#endif - ); - } + create_version_string(ctx, "OpenGL ES "); } /** diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 518b680f0..4f4fe77da 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -73,19 +73,32 @@ gl_target_to_pipe(GLenum target) { switch (target) { case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: return PIPE_TEXTURE_1D; case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: case GL_TEXTURE_EXTERNAL_OES: return PIPE_TEXTURE_2D; case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: return PIPE_TEXTURE_RECT; case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: return PIPE_TEXTURE_3D; case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: return PIPE_TEXTURE_CUBE; case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: return PIPE_TEXTURE_1D_ARRAY; case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: return PIPE_TEXTURE_2D_ARRAY; case GL_TEXTURE_BUFFER: return PIPE_BUFFER; @@ -1357,6 +1370,52 @@ st_AllocTextureStorage(struct gl_context *ctx, } +static GLboolean +st_TestProxyTexImage(struct gl_context *ctx, GLenum target, + GLint level, gl_format format, + GLint width, GLint height, + GLint depth, GLint border) +{ + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; + + if (pipe->screen->can_create_resource) { + /* Ask the gallium driver if the texture is too large */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + struct pipe_resource pt; + + /* Setup the pipe_resource object + */ + memset(&pt, 0, sizeof(pt)); + + pt.target = gl_target_to_pipe(target); + pt.format = st_mesa_format_to_pipe_format(format); + + st_gl_texture_dims_to_pipe_dims(target, + width, height, depth, + &pt.width0, &pt.height0, + &pt.depth0, &pt.array_size); + + if (level == 0 && (texObj->Sampler.MinFilter == GL_LINEAR || + texObj->Sampler.MinFilter == GL_NEAREST)) { + /* assume just one mipmap level */ + pt.last_level = 0; + } + else { + /* assume a full set of mipmaps */ + pt.last_level = _mesa_logbase2(MAX3(width, height, depth)); + } + + return pipe->screen->can_create_resource(pipe->screen, &pt); + } + else { + /* Use core Mesa fallback */ + return _mesa_test_proxy_teximage(ctx, target, level, format, + width, height, depth, border); + } +} + void st_init_texture_functions(struct dd_function_table *functions) @@ -1384,7 +1443,7 @@ st_init_texture_functions(struct dd_function_table *functions) functions->UnmapTextureImage = st_UnmapTextureImage; /* XXX Temporary until we can query pipe's texture sizes */ - functions->TestProxyTexImage = _mesa_test_proxy_teximage; + functions->TestProxyTexImage = st_TestProxyTexImage; functions->AllocTextureStorage = st_AllocTextureStorage; } diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index 9627a6117..3670683b5 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -117,6 +117,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, { switch (texture) { case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: assert(heightIn == 1); assert(depthIn == 1); *widthOut = widthIn; @@ -125,6 +126,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, *layersOut = 1; break; case GL_TEXTURE_1D_ARRAY: + case GL_PROXY_TEXTURE_1D_ARRAY: assert(depthIn == 1); *widthOut = widthIn; *heightOut = 1; @@ -132,7 +134,9 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, *layersOut = heightIn; break; case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: case GL_TEXTURE_RECTANGLE: + case GL_PROXY_TEXTURE_RECTANGLE: case GL_TEXTURE_EXTERNAL_OES: assert(depthIn == 1); *widthOut = widthIn; @@ -141,6 +145,13 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, *layersOut = 1; break; case GL_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: assert(depthIn == 1); *widthOut = widthIn; *heightOut = heightIn; @@ -148,6 +159,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, *layersOut = 6; break; case GL_TEXTURE_2D_ARRAY: + case GL_PROXY_TEXTURE_2D_ARRAY: *widthOut = widthIn; *heightOut = heightIn; *depthOut = 1; @@ -157,6 +169,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, assert(0 && "Unexpected texture in st_gl_texture_dims_to_pipe_dims()"); /* fall-through */ case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: *widthOut = widthIn; *heightOut = heightIn; *depthOut = depthIn; -- cgit v1.2.3