-
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 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"),
#include "attrib.h"
#include "blend.h"
#include "buffers.h"
+#include "bufferobj.h"
#include "colormac.h"
#include "colortab.h"
#include "context.h"
attr->RescaleNormals = ctx->Transform.RescaleNormals;
attr->Scissor = ctx->Scissor.Enabled;
attr->Stencil = ctx->Stencil.Enabled;
+ attr->StencilTwoSide = ctx->Stencil.TestTwoSide;
attr->MultisampleEnabled = ctx->Multisample.Enabled;
attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage;
attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
GL_POLYGON_STIPPLE);
TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
- /* XXX two-sided stencil */
+ if (ctx->Extensions.EXT_stencil_two_side) {
+ TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT);
+ }
TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled,
GL_MULTISAMPLE_ARB);
TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage,
_mesa_TexGenfv(GL_T, GL_EYE_PLANE, unit->EyePlaneT);
_mesa_TexGenfv(GL_R, GL_EYE_PLANE, unit->EyePlaneR);
_mesa_TexGenfv(GL_Q, GL_EYE_PLANE, unit->EyePlaneQ);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_S,
+ ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_T,
+ ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_R,
+ ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q,
+ ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE));
if (ctx->Extensions.EXT_texture_lod_bias) {
_mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias);
(GLboolean) (color->ColorMask[1] != 0),
(GLboolean) (color->ColorMask[2] != 0),
(GLboolean) (color->ColorMask[3] != 0));
- _mesa_DrawBuffer(color->DrawBuffer);
+#if 0
+ _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer);
+#else
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer, NULL);
+#endif
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
_mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
/* 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 (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
for (i = 0; i < MAX_LIGHTS; i++) {
GLenum lgt = (GLenum) (GL_LIGHT0 + i);
break;
case GL_PIXEL_MODE_BIT:
MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
+ /* XXX what other pixel state needs to be set by function calls? */
+ _mesa_ReadBuffer(ctx->Pixel.ReadBuffer);
ctx->NewState |= _NEW_PIXEL;
break;
case GL_POINT_BIT:
_mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
_mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV,
ctx->Point.SpriteRMode);
+ _mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN,
+ (GLfloat)ctx->Point.SpriteOrigin);
}
}
break;
break;
case GL_STENCIL_BUFFER_BIT:
{
- const GLint face = 0; /* XXX stencil two side */
+ GLint face;
const struct gl_stencil_attrib *stencil;
stencil = (const struct gl_stencil_attrib *) attr->data;
_mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled);
_mesa_ClearStencil(stencil->Clear);
- _mesa_StencilFunc(stencil->Function[face], stencil->Ref[face],
- stencil->ValueMask[face]);
- _mesa_StencilMask(stencil->WriteMask[face]);
- _mesa_StencilOp(stencil->FailFunc[face],
- stencil->ZFailFunc[face],
- stencil->ZPassFunc[face]);
+ face = stencil->ActiveFace;
+ if (ctx->Extensions.EXT_stencil_two_side) {
+ _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, stencil->TestTwoSide);
+ face ^= 1;
+ }
+ do {
+ _mesa_ActiveStencilFaceEXT(face);
+ _mesa_StencilFunc(stencil->Function[face], stencil->Ref[face],
+ stencil->ValueMask[face]);
+ _mesa_StencilMask(stencil->WriteMask[face]);
+ _mesa_StencilOp(stencil->FailFunc[face],
+ stencil->ZFailFunc[face],
+ stencil->ZPassFunc[face]);
+ face ^= 1;
+ } while (face != (stencil->ActiveFace ^ 1));
}
break;
case GL_TRANSFORM_BIT:
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)
+ if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
/* restore clip planes */
}
+/**
+ * Helper for incrementing/decrementing vertex buffer object reference
+ * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
+ */
+static void
+adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
+{
+ GLuint i;
+ array->Vertex.BufferObj->RefCount += step;
+ array->Normal.BufferObj->RefCount += step;
+ array->Color.BufferObj->RefCount += step;
+ array->SecondaryColor.BufferObj->RefCount += step;
+ array->FogCoord.BufferObj->RefCount += step;
+ array->Index.BufferObj->RefCount += step;
+ array->EdgeFlag.BufferObj->RefCount += step;
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+ array->TexCoord[i].BufferObj->RefCount += step;
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ array->VertexAttrib[i].BufferObj->RefCount += step;
+
+ array->ArrayBufferObj->RefCount += step;
+ array->ElementArrayBufferObj->RefCount += step;
+}
+
+
#define GL_CLIENT_PACK_BIT (1<<20)
#define GL_CLIENT_UNPACK_BIT (1<<21)
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Pack.BufferObj->RefCount++;
+ ctx->Unpack.BufferObj->RefCount++;
+#endif
/* packing attribs */
attr = MALLOC_STRUCT( gl_pixelstore_attrib );
MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
newnode->data = attr;
newnode->next = head;
head = newnode;
+ /* bump reference counts on buffer objects */
+ adjust_buffer_object_ref_counts(&ctx->Array, 1);
}
ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
while (attr) {
switch (attr->kind) {
case GL_CLIENT_PACK_BIT:
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Pack.BufferObj->RefCount--;
+ if (ctx->Pack.BufferObj->RefCount <= 0) {
+ _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );
+ (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );
+ }
+#endif
MEMCPY( &ctx->Pack, attr->data,
sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_UNPACK_BIT:
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Unpack.BufferObj->RefCount--;
+ if (ctx->Unpack.BufferObj->RefCount <= 0) {
+ _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );
+ (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );
+ }
+#endif
MEMCPY( &ctx->Unpack, attr->data,
sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_VERTEX_ARRAY_BIT:
+ adjust_buffer_object_ref_counts(&ctx->Array, -1);
MEMCPY( &ctx->Array, attr->data,
sizeof(struct gl_array_attrib) );
+ /* decrement reference counts on buffer objects */
ctx->NewState |= _NEW_ARRAY;
break;
default: