diff options
author | Brian Paul <[email protected]> | 2004-10-02 16:39:09 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-10-02 16:39:09 +0000 |
commit | 53f82c5aadbb15585754bfacf3237093eccdb2ce (patch) | |
tree | 93c013f62d99caf8581c774f768cb7f365350095 /src/mesa/main | |
parent | 289ffee2a017308a9a97689662293613dc62d9e9 (diff) |
added support for GL_ARB_draw_buffers
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/attrib.c | 11 | ||||
-rw-r--r-- | src/mesa/main/blend.c | 9 | ||||
-rw-r--r-- | src/mesa/main/buffers.c | 393 | ||||
-rw-r--r-- | src/mesa/main/buffers.h | 3 | ||||
-rw-r--r-- | src/mesa/main/config.h | 15 | ||||
-rw-r--r-- | src/mesa/main/context.c | 9 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 2 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 34 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 20 | ||||
-rw-r--r-- | src/mesa/main/extensions.h | 6 | ||||
-rw-r--r-- | src/mesa/main/get.c | 149 | ||||
-rw-r--r-- | src/mesa/main/glheader.h | 12 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 220 | ||||
-rw-r--r-- | src/mesa/main/state.c | 4 |
14 files changed, 591 insertions, 296 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 1f490540d89..37fcef51136 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.2 + * Version: 6.3 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -830,7 +830,8 @@ _mesa_PopAttrib(void) (GLboolean) (color->ColorMask[1] != 0), (GLboolean) (color->ColorMask[2] != 0), (GLboolean) (color->ColorMask[3] != 0)); - _mesa_DrawBuffer(color->DrawBuffer); + _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers, + color->DrawBuffer); _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled); @@ -928,9 +929,8 @@ _mesa_PopAttrib(void) /* lighting enable */ _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); /* per-light state */ - - if (ctx->ModelviewMatrixStack.Top->flags & MAT_DIRTY_INVERSE) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + if (ctx->ModelviewMatrixStack.Top->flags & MAT_DIRTY_INVERSE) + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); for (i = 0; i < MAX_LIGHTS; i++) { GLenum lgt = (GLenum) (GL_LIGHT0 + i); @@ -1079,7 +1079,6 @@ _mesa_PopAttrib(void) const struct gl_transform_attrib *xform; xform = (const struct gl_transform_attrib *) attr->data; _mesa_MatrixMode(xform->MatrixMode); - if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY) _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index fde542c4b95..0257528581b 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -549,7 +549,6 @@ void _mesa_init_color( GLcontext * ctx ) ctx->Color.ColorMask[3] = 0xff; ctx->Color.ClearIndex = 0; ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 ); - ctx->Color.DrawBuffer = GL_FRONT; ctx->Color.AlphaEnabled = GL_FALSE; ctx->Color.AlphaFunc = GL_ALWAYS; ctx->Color.AlphaRef = 0; @@ -568,12 +567,12 @@ void _mesa_init_color( GLcontext * ctx ) ctx->Color.DitherFlag = GL_TRUE; if (ctx->Visual.doubleBufferMode) { - ctx->Color.DrawBuffer = GL_BACK; - ctx->Color._DrawDestMask = DD_BACK_LEFT_BIT; + ctx->Color.DrawBuffer[0] = GL_BACK; + ctx->Color._DrawDestMask[0] = DD_BACK_LEFT_BIT; } else { - ctx->Color.DrawBuffer = GL_FRONT; - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT; + ctx->Color.DrawBuffer[0] = GL_FRONT; + ctx->Color._DrawDestMask[0] = DD_FRONT_LEFT_BIT; } } diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 4c5c077669a..35e03d7eb5c 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -149,7 +149,7 @@ _mesa_Clear( GLbitfield mask ) */ ddMask = 0; if (mask & GL_COLOR_BUFFER_BIT) - ddMask |= ctx->Color._DrawDestMask; + ddMask |= ctx->Color._DrawDestMask[0]; if ((mask & GL_DEPTH_BUFFER_BIT) && ctx->Visual.depthBits > 0) ddMask |= GL_DEPTH_BUFFER_BIT; if ((mask & GL_STENCIL_BUFFER_BIT) && ctx->Visual.stencilBits > 0) @@ -164,6 +164,121 @@ _mesa_Clear( GLbitfield mask ) } + +/** + * Return bitmask of DD_* flags indicating which color buffers are + * available to the rendering context; + */ +static GLuint +supported_buffer_bitmask(const GLcontext *ctx) +{ + GLuint mask = DD_FRONT_LEFT_BIT; /* always have this */ + GLuint i; + + if (ctx->Visual.stereoMode) { + mask |= DD_FRONT_RIGHT_BIT; + if (ctx->Visual.doubleBufferMode) { + mask |= DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT; + } + } + else if (ctx->Visual.doubleBufferMode) { + mask |= DD_BACK_LEFT_BIT; + } + + for (i = 0; i < ctx->Visual.numAuxBuffers; i++) { + mask |= (DD_AUX0_BIT << i); + } + + return mask; +} + + +/** + * Helper routine used by glDrawBuffer and glDrawBuffersARB. + * Given a GLenum naming (a) color buffer(s), return the corresponding + * bitmask of DD_* flags. + */ +static GLuint +draw_buffer_enum_to_bitmask(GLenum buffer) +{ + switch (buffer) { + case GL_FRONT: + return DD_FRONT_LEFT_BIT | DD_FRONT_RIGHT_BIT; + case GL_BACK: + return DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT; + case GL_NONE: + return 0; + case GL_RIGHT: + return DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT; + case GL_FRONT_RIGHT: + return DD_FRONT_RIGHT_BIT; + case GL_BACK_RIGHT: + return DD_BACK_RIGHT_BIT; + case GL_BACK_LEFT: + return DD_BACK_LEFT_BIT; + case GL_FRONT_AND_BACK: + return DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT + | DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT; + case GL_LEFT: + return DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT; + case GL_FRONT_LEFT: + return DD_FRONT_LEFT_BIT; + case GL_AUX0: + return DD_AUX0_BIT; + case GL_AUX1: + return DD_AUX1_BIT; + case GL_AUX2: + return DD_AUX2_BIT; + case GL_AUX3: + return DD_AUX3_BIT; + default: + /* error */ + return ~0; + } +} + + +/** + * Helper routine used by glReadBuffer. + * Given a GLenum naming (a) color buffer(s), return the corresponding + * bitmask of DD_* flags. + */ +static GLuint +read_buffer_enum_to_bitmask(GLenum buffer) +{ + switch (buffer) { + case GL_FRONT: + return DD_FRONT_LEFT_BIT; + case GL_BACK: + return DD_BACK_LEFT_BIT; + case GL_RIGHT: + return DD_FRONT_RIGHT_BIT; + case GL_FRONT_RIGHT: + return DD_FRONT_RIGHT_BIT; + case GL_BACK_RIGHT: + return DD_BACK_RIGHT_BIT; + case GL_BACK_LEFT: + return DD_BACK_LEFT_BIT; + case GL_LEFT: + return DD_FRONT_LEFT_BIT; + case GL_FRONT_LEFT: + return DD_FRONT_LEFT_BIT; + case GL_AUX0: + return DD_AUX0_BIT; + case GL_AUX1: + return DD_AUX1_BIT; + case GL_AUX2: + return DD_AUX2_BIT; + case GL_AUX3: + return DD_AUX3_BIT; + default: + /* error */ + return ~0; + } +} + + + /** * Specify which color buffers to draw into. * @@ -179,6 +294,7 @@ _mesa_Clear( GLbitfield mask ) void GLAPIENTRY _mesa_DrawBuffer( GLenum mode ) { + GLenum destMask, supportedMask; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */ @@ -188,124 +304,22 @@ _mesa_DrawBuffer( GLenum mode ) /* * Do error checking and compute the _DrawDestMask bitfield. */ - switch (mode) { - case GL_FRONT: - /* never an error */ - if (ctx->Visual.stereoMode) - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT | DD_FRONT_RIGHT_BIT; - else - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT; - break; - case GL_BACK: - if (!ctx->Visual.doubleBufferMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_BACK)"); - return; - } - if (ctx->Visual.stereoMode) - ctx->Color._DrawDestMask = DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT; - else - ctx->Color._DrawDestMask = DD_BACK_LEFT_BIT; - break; - case GL_NONE: - /* never an error */ - ctx->Color._DrawDestMask = 0; - break; -#if _HAVE_FULL_GL - case GL_RIGHT: - if (!ctx->Visual.stereoMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_RIGHT)"); - return;} - if (ctx->Visual.doubleBufferMode) - ctx->Color._DrawDestMask = DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT; - else - ctx->Color._DrawDestMask = DD_FRONT_RIGHT_BIT; - break; - case GL_FRONT_RIGHT: - if (!ctx->Visual.stereoMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_FRONT_RIGHT)"); - return; - } - ctx->Color._DrawDestMask = DD_FRONT_RIGHT_BIT; - break; - case GL_BACK_RIGHT: - if (!ctx->Visual.stereoMode || !ctx->Visual.doubleBufferMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_BACK_RIGHT)"); - return; - } - ctx->Color._DrawDestMask = DD_BACK_RIGHT_BIT; - break; - case GL_BACK_LEFT: - if (!ctx->Visual.doubleBufferMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_BACK_LEFT)"); - return; - } - ctx->Color._DrawDestMask = DD_BACK_LEFT_BIT; - break; - case GL_FRONT_AND_BACK: - if (!ctx->Visual.doubleBufferMode) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_FRONT_AND_BACK)"); - return; - } - if (ctx->Visual.stereoMode) - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT - | DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT; - else - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT; - break; - case GL_LEFT: - /* never an error */ - if (ctx->Visual.doubleBufferMode) - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT; - else - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT; - break; - case GL_FRONT_LEFT: - /* never an error */ - ctx->Color._DrawDestMask = DD_FRONT_LEFT_BIT; - break; - case GL_AUX0: - if (ctx->Visual.numAuxBuffers >= 1) { - ctx->Color._DrawDestMask = DD_AUX0_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_AUX0)" ); - return; - } - break; - case GL_AUX1: - if (ctx->Visual.numAuxBuffers >= 2) { - ctx->Color._DrawDestMask = DD_AUX1_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_AUX1)" ); - return; - } - break; - case GL_AUX2: - if (ctx->Visual.numAuxBuffers >= 3) { - ctx->Color._DrawDestMask = DD_AUX2_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_AUX2)" ); - return; - } - break; - case GL_AUX3: - if (ctx->Visual.numAuxBuffers >= 4) { - ctx->Color._DrawDestMask = DD_AUX3_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer(GL_AUX3)" ); - return; - } - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" ); - return; + destMask = draw_buffer_enum_to_bitmask(mode); + if (destMask == ~0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(mode)"); + return; + } + + supportedMask = supported_buffer_bitmask(ctx); + destMask &= supportedMask; + + if (destMask == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(mode)"); + return; } - ctx->Color.DrawBuffer = mode; + ctx->Color.DrawBuffer[0] = mode; + ctx->Color._DrawDestMask[0] = destMask; ctx->NewState |= _NEW_COLOR; /* @@ -317,6 +331,60 @@ _mesa_DrawBuffer( GLenum mode ) /** + * Called by glDrawBuffersARB; specifies the destination color buffers + * for N fragment program color outputs. + */ +void GLAPIENTRY +_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) +{ + GLint i; + GLuint usedBufferMask, supportedMask; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (n < 1 || n > ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)" ); + return; + } + + supportedMask = supported_buffer_bitmask(ctx); + usedBufferMask = 0; + for (i = 0; i < n; i++) { + GLuint destMask = draw_buffer_enum_to_bitmask(buffers[i]); + if (destMask == ~0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)"); + return; + } + destMask &= supportedMask; + if (destMask == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffersARB(unsupported buffer)"); + return; + } + if (destMask & usedBufferMask) { + /* can't use a dest buffer more than once! */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawBuffersARB(duplicated buffer)"); + return; + } + /* update bitmask */ + usedBufferMask |= destMask; + /* save state */ + ctx->Color.DrawBuffer[i] = buffers[i]; + ctx->Color._DrawDestMask[i] = destMask; + } + + ctx->NewState |= _NEW_COLOR; + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + (*ctx->Driver.DrawBuffers)(ctx, n, buffers); +} + + +/** * Set the color buffer source for reading pixels. * * \param mode color buffer. @@ -330,89 +398,24 @@ _mesa_DrawBuffer( GLenum mode ) void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ) { + GLuint srcMask, supportedMask; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(mode)); - /* - * Do error checking and compute ctx->Pixel._ReadSrcMask. - */ - switch (mode) { - case GL_LEFT: - case GL_FRONT: - case GL_FRONT_LEFT: - /* Front-Left buffer, always exists */ - ctx->Pixel._ReadSrcMask = DD_FRONT_LEFT_BIT; - break; - case GL_BACK: - case GL_BACK_LEFT: - /* Back-Left buffer, requires double buffering */ - if (!ctx->Visual.doubleBufferMode) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); - return; - } - ctx->Pixel._ReadSrcMask = DD_BACK_LEFT_BIT; - break; -#if _HAVE_FULL_GL - case GL_FRONT_RIGHT: - case GL_RIGHT: - if (!ctx->Visual.stereoMode) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); - return; - } - ctx->Pixel._ReadSrcMask = DD_FRONT_RIGHT_BIT; - break; - case GL_BACK_RIGHT: - if (!ctx->Visual.stereoMode || !ctx->Visual.doubleBufferMode) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" ); - return; - } - ctx->Pixel._ReadSrcMask = DD_BACK_RIGHT_BIT; - break; - case GL_AUX0: - if (ctx->Visual.numAuxBuffers >= 1) { - ctx->Pixel._ReadSrcMask = DD_AUX0_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer(GL_AUX0)" ); - return; - } - break; - case GL_AUX1: - if (ctx->Visual.numAuxBuffers >= 2) { - ctx->Pixel._ReadSrcMask = DD_AUX1_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer(GL_AUX1)" ); - return; - } - break; - case GL_AUX2: - if (ctx->Visual.numAuxBuffers >= 3) { - ctx->Pixel._ReadSrcMask = DD_AUX2_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer(GL_AUX2)" ); - return; - } - break; - case GL_AUX3: - if (ctx->Visual.numAuxBuffers >= 4) { - ctx->Pixel._ReadSrcMask = DD_AUX3_BIT; - } - else { - _mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer(GL_AUX3)" ); - return; - } - break; -#endif - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glReadBuffer" ); - return; + srcMask = read_buffer_enum_to_bitmask(mode); + if (srcMask == ~0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(mode)"); + return; } - + supportedMask = supported_buffer_bitmask(ctx); + if ((srcMask & supportedMask) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(mode)"); + return; + } + ctx->Pixel._ReadSrcMask = srcMask; ctx->Pixel.ReadBuffer = mode; ctx->NewState |= _NEW_PIXEL; @@ -423,6 +426,7 @@ _mesa_ReadBuffer( GLenum mode ) (*ctx->Driver.ReadBuffer)(ctx, mode); } + #if _HAVE_FULL_GL /** @@ -485,6 +489,7 @@ _mesa_ResizeBuffersMESA( void ) } } + /* * XXX move somewhere else someday? */ @@ -550,6 +555,8 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) ctx->Driver.Scissor( ctx, x, y, width, height ); } + + /**********************************************************************/ /** \name State management */ /*@{*/ diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index 83e1b482511..f9369864b65 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -50,6 +50,9 @@ extern void GLAPIENTRY _mesa_DrawBuffer( GLenum mode ); extern void GLAPIENTRY +_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers); + +extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); extern void GLAPIENTRY diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 496997b9574..bc9202eaede 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -202,6 +202,13 @@ /*@}*/ +/** For GL_ARB_draw_buffers */ +/*@{*/ +#define MAX_DRAW_BUFFERS 1 +/*@}*/ + + + /** * \name Mesa-specific parameters */ @@ -283,4 +290,12 @@ /*@}*/ +/** + * Maximum number of temporary vertices required for clipping. + * + * Used in array_cache and tnl modules. + */ +#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) + + #endif /* CONFIG_H */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 96c436971b1..44e3fcb9adc 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1050,7 +1050,7 @@ _mesa_init_constants( GLcontext *ctx ) assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); - /* Constants, may be overriden by device drivers */ + /* Constants, may be overriden (usually only reduced) by device drivers */ ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; @@ -1077,8 +1077,10 @@ _mesa_init_constants( GLcontext *ctx ) ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT; ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES; ctx->Const.MaxLights = MAX_LIGHTS; - ctx->Const.MaxSpotExponent = 128.0; ctx->Const.MaxShininess = 128.0; + ctx->Const.MaxSpotExponent = 128.0; + ctx->Const.MaxViewportWidth = MAX_WIDTH; + ctx->Const.MaxViewportHeight = MAX_HEIGHT; #if FEATURE_ARB_vertex_program ctx->Const.MaxVertexProgramInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS; ctx->Const.MaxVertexProgramAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; @@ -1110,6 +1112,9 @@ _mesa_init_constants( GLcontext *ctx ) ctx->Const.CheckArrayBounds = GL_FALSE; #endif + ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS; + + /* sanity checks */ ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits)); } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index e314fd8fa12..68e6273a679 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -615,6 +615,8 @@ struct dd_function_table { void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval); /** Specify the current buffer for writing */ void (*DrawBuffer)( GLcontext *ctx, GLenum buffer ); + /** Specify the buffers for writing for fragment programs*/ + void (*DrawBuffers)( GLcontext *ctx, GLsizei n, const GLenum *buffers ); /** Enable or disable server-side gl capabilities */ void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state); /** Specify fog parameters */ diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index ebf3af326a9..ef2dada7101 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -314,6 +314,8 @@ typedef enum { /* GL_ARB_occlusion_query */ OPCODE_BEGIN_QUERY_ARB, OPCODE_END_QUERY_ARB, + /* GL_ARB_draw_buffers */ + OPCODE_DRAW_BUFFERS_ARB, /* Vertex attributes -- fallback for when optimized display * list build isn't active. @@ -782,6 +784,7 @@ _mesa_init_lists( void ) InstSize[OPCODE_BEGIN_QUERY_ARB] = 3; InstSize[OPCODE_END_QUERY_ARB] = 2; #endif + InstSize[OPCODE_DRAW_BUFFERS_ARB] = 2 + MAX_DRAW_BUFFERS; InstSize[OPCODE_ATTR_1F] = 3; InstSize[OPCODE_ATTR_2F] = 4; InstSize[OPCODE_ATTR_3F] = 5; @@ -4683,6 +4686,27 @@ save_EndQueryARB(GLenum target) #endif /* FEATURE_ARB_occlusion_query */ +static void GLAPIENTRY +save_DrawBuffersARB(GLsizei count, const GLenum *buffers) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS ); + if (n) { + GLint i; + n[1].i = count; + if (count > MAX_DRAW_BUFFERS) + count = MAX_DRAW_BUFFERS; + for (i = 0; i < count; i++) { + n[2 + i].e = buffers[i]; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->DrawBuffersARB)(count, buffers); + } +} + static void save_Attr1f( GLenum attr, GLfloat x ) { @@ -6043,6 +6067,15 @@ execute_list( GLcontext *ctx, GLuint list ) ctx->Exec->EndQueryARB(n[1].e); break; #endif + case OPCODE_DRAW_BUFFERS_ARB: + { + GLenum buffers[MAX_DRAW_BUFFERS]; + GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); + for (i = 0; i < count; i++) + buffers[i] = n[2 + i].e; + ctx->Exec->DrawBuffersARB(n[1].i, buffers); + } + break; case OPCODE_ATTR_1F: (*ctx->Exec->VertexAttrib1fNV)(n[1].e, n[2].f); break; @@ -7635,6 +7668,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize ) table->GetQueryObjectivARB = _mesa_GetQueryObjectivARB; table->GetQueryObjectuivARB = _mesa_GetQueryObjectuivARB; #endif + table->DrawBuffersARB = save_DrawBuffersARB; /* 299. GL_EXT_blend_equation_separate */ table->BlendEquationSeparateEXT = save_BlendEquationSeparateEXT; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index efdee0c67de..a8003116fad 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.2 + * Version: 6.3 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -45,6 +45,7 @@ static const struct { int flag_offset; } default_extensions[] = { { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, + { OFF, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_MESAX_half_float_pixel", F(ARB_half_float_pixel) }, { OFF, "GL_ARB_imaging", F(ARB_imaging) }, @@ -166,6 +167,7 @@ void _mesa_enable_sw_extensions(GLcontext *ctx) { ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_draw_buffers = GL_TRUE; #if FEATURE_ARB_fragment_program ctx->Extensions.ARB_fragment_program = GL_TRUE; #endif @@ -331,6 +333,22 @@ _mesa_enable_1_5_extensions(GLcontext *ctx) /** + * Enable all OpenGL 2.0 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_0_extensions(GLcontext *ctx) +{ + ctx->Extensions.ARB_draw_buffers = GL_TRUE; + ctx->Extensions.ARB_point_sprite = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + /* Also, shading language */ +} + + + +/** * Either enable or disable the named extension. */ static void diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 54aa25511b4..9d843a8b6b6 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -10,9 +10,9 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.3 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -50,6 +50,8 @@ extern void _mesa_enable_1_4_extensions(GLcontext *ctx); extern void _mesa_enable_1_5_extensions(GLcontext *ctx); +extern void _mesa_enable_2_0_extensions(GLcontext *ctx); + extern void _mesa_enable_extension(GLcontext *ctx, const char *name); extern void _mesa_disable_extension(GLcontext *ctx, const char *name); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 98ab70eb4d0..6eac604ea51 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -5,7 +5,7 @@ /* * Mesa 3-D graphics library - * Version: 6.2 + * Version: 6.3 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -380,7 +380,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = ctx->Visual.doubleBufferMode; break; case GL_DRAW_BUFFER: - *params = ENUM_TO_BOOL(ctx->Color.DrawBuffer); + *params = ENUM_TO_BOOL(ctx->Color.DrawBuffer[0]); break; case GL_EDGE_FLAG: FLUSH_CURRENT(ctx, 0); @@ -1691,6 +1691,38 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; #endif + case GL_MAX_DRAW_BUFFERS_ARB: + CHECK_EXTENSION_B(ARB_draw_buffers, pname); + *params = INT_TO_BOOL(ctx->Const.MaxDrawBuffers); + break; + case GL_DRAW_BUFFER0_ARB: + case GL_DRAW_BUFFER1_ARB: + case GL_DRAW_BUFFER2_ARB: + case GL_DRAW_BUFFER3_ARB: + case GL_DRAW_BUFFER4_ARB: + case GL_DRAW_BUFFER5_ARB: + case GL_DRAW_BUFFER6_ARB: + case GL_DRAW_BUFFER7_ARB: + case GL_DRAW_BUFFER8_ARB: + case GL_DRAW_BUFFER9_ARB: + case GL_DRAW_BUFFER10_ARB: + case GL_DRAW_BUFFER11_ARB: + case GL_DRAW_BUFFER12_ARB: + case GL_DRAW_BUFFER13_ARB: + case GL_DRAW_BUFFER14_ARB: + case GL_DRAW_BUFFER15_ARB: + CHECK_EXTENSION_B(ARB_draw_buffers, pname); + { + GLuint i = pname - GL_DRAW_BUFFER0_ARB; + if (i >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetBooleanv(GL_DRAW_BUFFERx_ARB)"); + return; + } + *params = INT_TO_BOOL(ctx->Color.DrawBuffer[i]); + } + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -1947,7 +1979,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) ctx->Visual.doubleBufferMode; break; case GL_DRAW_BUFFER: - *params = ENUM_TO_DOUBLE(ctx->Color.DrawBuffer); + *params = ENUM_TO_DOUBLE(ctx->Color.DrawBuffer[0]); break; case GL_EDGE_FLAG: FLUSH_CURRENT(ctx, 0); @@ -3253,6 +3285,38 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) break; #endif + case GL_MAX_DRAW_BUFFERS_ARB: + CHECK_EXTENSION_D(ARB_draw_buffers, pname); + *params = (GLdouble) ctx->Const.MaxDrawBuffers; + break; + case GL_DRAW_BUFFER0_ARB: + case GL_DRAW_BUFFER1_ARB: + case GL_DRAW_BUFFER2_ARB: + case GL_DRAW_BUFFER3_ARB: + case GL_DRAW_BUFFER4_ARB: + case GL_DRAW_BUFFER5_ARB: + case GL_DRAW_BUFFER6_ARB: + case GL_DRAW_BUFFER7_ARB: + case GL_DRAW_BUFFER8_ARB: + case GL_DRAW_BUFFER9_ARB: + case GL_DRAW_BUFFER10_ARB: + case GL_DRAW_BUFFER11_ARB: + case GL_DRAW_BUFFER12_ARB: + case GL_DRAW_BUFFER13_ARB: + case GL_DRAW_BUFFER14_ARB: + case GL_DRAW_BUFFER15_ARB: + CHECK_EXTENSION_D(ARB_draw_buffers, pname); + { + GLuint i = pname - GL_DRAW_BUFFER0_ARB; + if (i >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetDoublev(GL_DRAW_BUFFERx_ARB)"); + return; + } + *params = (GLdouble) ctx->Color.DrawBuffer[i]; + } + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev(pname=0x%x)", pname); } @@ -3509,7 +3573,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) ctx->Visual.doubleBufferMode; break; case GL_DRAW_BUFFER: - *params = ENUM_TO_FLOAT(ctx->Color.DrawBuffer); + *params = ENUM_TO_FLOAT(ctx->Color.DrawBuffer[0]); break; case GL_EDGE_FLAG: FLUSH_CURRENT(ctx, 0); @@ -4791,6 +4855,38 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; #endif + case GL_MAX_DRAW_BUFFERS_ARB: + CHECK_EXTENSION_F(ARB_draw_buffers, pname); + *params = (GLfloat) ctx->Const.MaxDrawBuffers; + break; + case GL_DRAW_BUFFER0_ARB: + case GL_DRAW_BUFFER1_ARB: + case GL_DRAW_BUFFER2_ARB: + case GL_DRAW_BUFFER3_ARB: + case GL_DRAW_BUFFER4_ARB: + case GL_DRAW_BUFFER5_ARB: + case GL_DRAW_BUFFER6_ARB: + case GL_DRAW_BUFFER7_ARB: + case GL_DRAW_BUFFER8_ARB: + case GL_DRAW_BUFFER9_ARB: + case GL_DRAW_BUFFER10_ARB: + case GL_DRAW_BUFFER11_ARB: + case GL_DRAW_BUFFER12_ARB: + case GL_DRAW_BUFFER13_ARB: + case GL_DRAW_BUFFER14_ARB: + case GL_DRAW_BUFFER15_ARB: + CHECK_EXTENSION_F(ARB_draw_buffers, pname); + { + GLuint i = pname - GL_DRAW_BUFFER0_ARB; + if (i >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFloatv(GL_DRAW_BUFFERx_ARB)"); + return; + } + *params = (GLfloat) ctx->Color.DrawBuffer[i]; + } + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(0x%x)", pname); } @@ -5048,7 +5144,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = (GLint) ctx->Visual.doubleBufferMode; break; case GL_DRAW_BUFFER: - *params = (GLint) ctx->Color.DrawBuffer; + *params = (GLint) ctx->Color.DrawBuffer[0]; break; case GL_EDGE_FLAG: FLUSH_CURRENT(ctx, 0); @@ -6367,6 +6463,38 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; #endif + case GL_MAX_DRAW_BUFFERS_ARB: + CHECK_EXTENSION_I(ARB_draw_buffers, pname); + *params = ctx->Const.MaxDrawBuffers; + break; + case GL_DRAW_BUFFER0_ARB: + case GL_DRAW_BUFFER1_ARB: + case GL_DRAW_BUFFER2_ARB: + case GL_DRAW_BUFFER3_ARB: + case GL_DRAW_BUFFER4_ARB: + case GL_DRAW_BUFFER5_ARB: + case GL_DRAW_BUFFER6_ARB: + case GL_DRAW_BUFFER7_ARB: + case GL_DRAW_BUFFER8_ARB: + case GL_DRAW_BUFFER9_ARB: + case GL_DRAW_BUFFER10_ARB: + case GL_DRAW_BUFFER11_ARB: + case GL_DRAW_BUFFER12_ARB: + case GL_DRAW_BUFFER13_ARB: + case GL_DRAW_BUFFER14_ARB: + case GL_DRAW_BUFFER15_ARB: + CHECK_EXTENSION_I(ARB_draw_buffers, pname); + { + GLuint i = pname - GL_DRAW_BUFFER0_ARB; + if (i >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetIntegerv(GL_DRAW_BUFFERx_ARB)"); + return; + } + *params = (GLint) ctx->Color.DrawBuffer[i]; + } + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } @@ -6489,6 +6617,7 @@ _mesa_GetString( GLenum name ) static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING; static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING; static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING; + static const char *version_2_0 = "1.5 Mesa " MESA_VERSION_STRING;/*XXX FIX*/ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); @@ -6533,7 +6662,15 @@ _mesa_GetString( GLenum name ) if (ctx->Extensions.ARB_occlusion_query && ctx->Extensions.ARB_vertex_buffer_object && ctx->Extensions.EXT_shadow_funcs) { - return (const GLubyte *) version_1_5; + if (ctx->Extensions.ARB_draw_buffers && + ctx->Extensions.ARB_point_sprite && + ctx->Extensions.ARB_texture_non_power_of_two && + ctx->Extensions.EXT_stencil_two_side) { + return (const GLubyte *) version_2_0; + } + else { + return (const GLubyte *) version_1_5; + } } else { return (const GLubyte *) version_1_4; diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 025b3a5857d..3057770d095 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -246,10 +246,14 @@ typedef GLushort GLhalfARB; #endif /* XXX temporary hack - remove when glext.h is updated */ -#ifndef GL_POINT_SPRITE_COORD_ORIGIN -#define GL_POINT_SPRITE_COORD_ORIGIN 0x10000 -#define GL_LOWER_LEFT 0x10001 -#define GL_UPPER_LEFT 0x10002 +#ifndef GL_CURRENT_PROGRAM +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #endif diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index be6882f203f..07119a2fb6e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -7,7 +7,7 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.3 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -150,71 +150,89 @@ struct gl_texture_format; /** - * These define the aliases between numbered vertex attributes and - * conventional OpenGL vertex attributes. We use these values in - * quite a few places. - * - * New in Mesa 4.1. + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). */ enum { - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR0 = 3, - VERT_ATTRIB_COLOR1 = 4, - VERT_ATTRIB_FOG = 5, - VERT_ATTRIB_SIX = 6, - VERT_ATTRIB_SEVEN = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_MAX = 16 -} ; - -/* These are used in bitfields in many places */ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX) -#define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_SIX = 6, + VERT_ATTRIB_SEVEN = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_MAX = 16 +}; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX) +#define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) #define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ -/* Fragment programs use a different but related set of attributes: +/** + * Indexes for fragment program input attributes. */ +enum { + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11 +}; -/* Fragment input registers / attributes */ -#define FRAG_ATTRIB_WPOS 0 -#define FRAG_ATTRIB_COL0 1 -#define FRAG_ATTRIB_COL1 2 -#define FRAG_ATTRIB_FOGC 3 -#define FRAG_ATTRIB_TEX0 4 -#define FRAG_ATTRIB_TEX1 5 -#define FRAG_ATTRIB_TEX2 6 -#define FRAG_ATTRIB_TEX3 7 -#define FRAG_ATTRIB_TEX4 8 -#define FRAG_ATTRIB_TEX5 9 -#define FRAG_ATTRIB_TEX6 10 -#define FRAG_ATTRIB_TEX7 11 - -/* Bitmasks for the above */ +/* + * Bitflags for fragment attributes. + */ +/*@{*/ #define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) @@ -236,6 +254,7 @@ enum { FRAG_BIT_TEX5| \ FRAG_BIT_TEX6| \ FRAG_BIT_TEX7) +/*@}*/ /** @@ -261,14 +280,6 @@ enum { /** - * Maximum number of temporary vertices required for clipping. - * - * Used in array_cache and tnl modules. - */ -#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1) - - -/** * Data structure for color tables */ struct gl_color_table { @@ -433,7 +444,7 @@ struct gl_accum_attrib { /** - * Color buffers attributes. + * Color buffer attributes. */ struct gl_colorbuffer_attrib { GLuint ClearIndex; /**< Index to use for glClear */ @@ -442,8 +453,8 @@ struct gl_colorbuffer_attrib { GLuint IndexMask; /**< Color index write mask */ GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */ - GLenum DrawBuffer; /**< Which buffer to draw into */ - GLbitfield _DrawDestMask; /**< bitmask of DD_*_BIT bits */ + GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ + GLbitfield _DrawDestMask[MAX_DRAW_BUFFERS];/**< bitmask of DD_*_BIT bits */ /** * \name alpha testing @@ -698,6 +709,9 @@ struct gl_histogram_attrib { }; +/** + * Color Min/max state. + */ struct gl_minmax_attrib { GLenum Format; GLboolean Sink; @@ -705,6 +719,9 @@ struct gl_minmax_attrib { }; +/** + * Image convolution state. + */ struct gl_convolution_attrib { GLenum Format; GLenum InternalFormat; @@ -714,10 +731,16 @@ struct gl_convolution_attrib { }; +/** + * Light state flags. + */ +/*@{*/ #define LIGHT_SPOT 0x1 #define LIGHT_LOCAL_VIEWER 0x2 #define LIGHT_POSITIONAL 0x4 #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) +/*@}*/ + /** * Lighting attributes. @@ -767,6 +790,9 @@ struct gl_line_attrib { }; +/** + * Display list state. + */ struct gl_list_attrib { GLuint ListBase; }; @@ -787,6 +813,9 @@ struct gl_list_extensions { }; +/** + * Multisample state + */ struct gl_multisample_attrib { GLboolean Enabled; GLboolean SampleAlphaToCoverage; @@ -944,27 +973,45 @@ struct gl_stencil_attrib { #define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */ +/** + * An index for each type of texture object + */ +/*@{*/ #define TEXTURE_1D_INDEX 0 #define TEXTURE_2D_INDEX 1 #define TEXTURE_3D_INDEX 2 #define TEXTURE_CUBE_INDEX 3 #define TEXTURE_RECT_INDEX 4 +/*@}*/ -/* Texture.Unit[]._ReallyEnabled flags: */ +/** + * Bit flags for each type of texture object + * Used for Texture.Unit[]._ReallyEnabled flags. + */ +/*@{*/ #define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) #define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) #define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) #define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) #define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +/*@}*/ -/* TexGenEnabled flags */ +/** + * TexGenEnabled flags. + */ +/*@{*/ #define S_BIT 1 #define T_BIT 2 #define R_BIT 4 #define Q_BIT 8 +/*@}*/ + -/* Bitmap versions of the GL_ constants. */ +/** + * Bit flag versions of the corresponding GL_ constants. + */ +/*@{*/ #define TEXGEN_SPHERE_MAP 0x1 #define TEXGEN_OBJ_LINEAR 0x2 #define TEXGEN_EYE_LINEAR 0x4 @@ -978,6 +1025,8 @@ struct gl_stencil_attrib { TEXGEN_REFLECTION_MAP_NV | \ TEXGEN_NORMAL_MAP_NV | \ TEXGEN_EYE_LINEAR) +/*@}*/ + /* A selection of state flags to make driver and module's lives easier. */ #define ENABLE_TEXGEN0 0x1 @@ -1133,6 +1182,11 @@ struct gl_texture_image { /*@}*/ }; + +/** + * Indexes for cube map faces. + */ +/*@{*/ #define FACE_POS_X 0 #define FACE_NEG_X 1 #define FACE_POS_Y 2 @@ -1140,6 +1194,8 @@ struct gl_texture_image { #define FACE_POS_Z 4 #define FACE_NEG_Z 5 #define MAX_FACES 6 +/*@}*/ + /** * Texture object record @@ -1195,6 +1251,7 @@ struct gl_texture_object { /*@}*/ }; + /** * Texture combine environment state. * @@ -1215,6 +1272,7 @@ struct gl_tex_env_combine_state { GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */ }; + /** * Texture unit record */ @@ -1414,7 +1472,7 @@ struct gl_client_array { /** - * Array attributes. + * Vertex array state */ struct gl_array_attrib { struct gl_client_array Vertex; /**< client data descriptors */ @@ -1444,6 +1502,9 @@ struct gl_array_attrib { }; +/** + * Feedback buffer state + */ struct gl_feedback { GLenum Type; GLuint _Mask; /* FB_* bits */ @@ -1454,7 +1515,7 @@ struct gl_feedback { /** - * Selection attributes. + * Selection buffer state */ struct gl_selection { GLuint *Buffer; /**< selection buffer */ @@ -1494,7 +1555,7 @@ struct gl_2d_map /** - * All evaluator control points + * All evaluator control point state */ struct gl_evaluators { @@ -1561,7 +1622,7 @@ enum register_file }; -/* Vertex and fragment instructions */ +/** Vertex and fragment instructions */ struct vp_instruction; struct fp_instruction; @@ -1633,7 +1694,7 @@ struct program_state { /** - * State vars for GL_NV_vertex_program + * State vars for GL_ARB/GL_NV_vertex_program */ struct vertex_program_state { @@ -1650,6 +1711,7 @@ struct vertex_program_state /* Only used during program execution (may be moved someday): */ GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4]; GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4]; + GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS]; GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4]; GLint AddressReg[4]; @@ -1826,6 +1888,7 @@ struct gl_constants GLuint MaxLights; GLfloat MaxShininess; /* GL_NV_light_max_exponent */ GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */ + GLuint MaxViewportWidth, MaxViewportHeight; /* GL_ARB_vertex_program */ GLuint MaxVertexProgramInstructions; GLuint MaxVertexProgramAttribs; @@ -1848,6 +1911,8 @@ struct gl_constants GLuint MaxProgramMatrixStackDepth; /* vertex array / buffer object bounds checking */ GLboolean CheckArrayBounds; + /* GL_ARB_draw_buffers */ + GLuint MaxDrawBuffers; }; @@ -1864,6 +1929,7 @@ struct gl_extensions /*@{*/ GLboolean dummy; /* don't remove this! */ GLboolean ARB_depth_texture; + GLboolean ARB_draw_buffers; GLboolean ARB_fragment_program; GLboolean ARB_half_float_pixel; GLboolean ARB_imaging; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 21e07e70d1e..449e4631e77 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -724,6 +724,7 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->UnmapBufferARB = _mesa_UnmapBufferARB; #endif + /* ARB 29. GL_ARB_occlusion_query */ #if FEATURE_ARB_occlusion_query exec->GenQueriesARB = _mesa_GenQueriesARB; exec->DeleteQueriesARB = _mesa_DeleteQueriesARB; @@ -734,6 +735,9 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) exec->GetQueryObjectivARB = _mesa_GetQueryObjectivARB; exec->GetQueryObjectuivARB = _mesa_GetQueryObjectuivARB; #endif + + /* ARB 37. GL_ARB_draw_buffers */ + exec->DrawBuffersARB = _mesa_DrawBuffersARB; } /*@}*/ |