diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/context.c | 23 | ||||
-rw-r--r-- | src/mesa/main/enums.c | 4 | ||||
-rw-r--r-- | src/mesa/main/fbobject.c | 32 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.c | 108 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.h | 6 | ||||
-rw-r--r-- | src/mesa/main/image.c | 19 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 67 | ||||
-rw-r--r-- | src/mesa/main/rbadaptors.c | 6 | ||||
-rw-r--r-- | src/mesa/main/renderbuffer.c | 23 | ||||
-rw-r--r-- | src/mesa/main/renderbuffer.h | 2 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 2 |
12 files changed, 171 insertions, 123 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 9b043488068..0cff90c77a6 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -95,6 +95,7 @@ #include "fbobject.h" #include "feedback.h" #include "fog.h" +#include "framebuffer.h" #include "get.h" #include "glthread.h" #include "glapioffsets.h" @@ -1423,6 +1424,13 @@ _mesa_free_context_data( GLcontext *ctx ) if (ctx == _mesa_get_current_context()) { _mesa_make_current(NULL, NULL, NULL); } + else { + /* unreference WinSysDraw/Read buffers */ + _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + } _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); @@ -1682,9 +1690,7 @@ void _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ) { -#if 0 GET_CURRENT_CONTEXT(oldCtx); -#endif if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(newCtx, "_mesa_make_current()\n"); @@ -1734,6 +1740,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, _glapi_set_context((void *) newCtx); ASSERT(_mesa_get_current_context() == newCtx); + if (oldCtx) { + _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer); + } + if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ } @@ -1745,18 +1756,18 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(drawBuffer->Name == 0); ASSERT(readBuffer->Name == 0); - newCtx->WinSysDrawBuffer = drawBuffer; - newCtx->WinSysReadBuffer = readBuffer; + _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); + _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); /* * Only set the context's Draw/ReadBuffer fields if they're NULL * or not bound to a user-created FBO. */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { - newCtx->DrawBuffer = drawBuffer; + _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { - newCtx->ReadBuffer = readBuffer; + _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); } newCtx->NewState |= _NEW_BUFFERS; diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 8c1b785aab3..bad33f7f642 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -1003,7 +1003,7 @@ LONGSTRING static const char enum_string_table[] = "GL_NOTEQUAL\0" "GL_NO_ERROR\0" "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" - "GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB\0" + "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" @@ -2744,7 +2744,7 @@ static const enum_elt all_enums[1737] = { 20205, 0x00000205 }, /* GL_NOTEQUAL */ { 20217, 0x00000000 }, /* GL_NO_ERROR */ { 20229, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - { 20263, 0x000086A2 }, /* GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB */ + { 20263, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ { 20301, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ { 20333, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ { 20375, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index cf8de1e0cbe..f7e870b49cd 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -602,7 +602,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) oldRb = ctx->CurrentRenderbuffer; if (oldRb) { - _mesa_dereference_renderbuffer(&oldRb); + _mesa_unreference_renderbuffer(&oldRb); } ASSERT(newRb != &DummyRenderbuffer); @@ -639,7 +639,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&rb); } } } @@ -938,7 +938,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { - struct gl_framebuffer *newFb, *oldFb; + struct gl_framebuffer *newFb; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); @@ -998,12 +998,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } - _glthread_LOCK_MUTEX(newFb->Mutex); - if (bindReadBuf) - newFb->RefCount++; - if (bindDrawBuf) - newFb->RefCount++; - _glthread_UNLOCK_MUTEX(newFb->Mutex); } else { /* Binding the window system framebuffer (which was originally set @@ -1020,22 +1014,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - oldFb = ctx->ReadBuffer; - if (oldFb && oldFb->Name != 0) { - _mesa_dereference_framebuffer(&oldFb); - } - ctx->ReadBuffer = newFb; + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); } if (bindDrawBuf) { - oldFb = ctx->DrawBuffer; - if (oldFb && oldFb->Name != 0) { - /* check if old FB had any texture attachments */ - check_end_texture_render(ctx, oldFb); - /* check if time to delete this framebuffer */ - _mesa_dereference_framebuffer(&oldFb); - } - ctx->DrawBuffer = newFb; + /* check if old FB had any texture attachments */ + check_end_texture_render(ctx, ctx->DrawBuffer); + /* check if time to delete this framebuffer */ + _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); @@ -1083,7 +1069,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) /* But the object will not be freed until it's no longer * bound in any context. */ - _mesa_dereference_framebuffer(&fb); + _mesa_unreference_framebuffer(&fb); } } } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 465197401b7..3136a950e08 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -78,7 +78,7 @@ set_depth_renderbuffer(struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { if (fb->_DepthBuffer) { - _mesa_dereference_renderbuffer(&fb->_DepthBuffer); + _mesa_unreference_renderbuffer(&fb->_DepthBuffer); } fb->_DepthBuffer = rb; if (rb) { @@ -96,7 +96,7 @@ set_stencil_renderbuffer(struct gl_framebuffer *fb, struct gl_renderbuffer *rb) { if (fb->_StencilBuffer) { - _mesa_dereference_renderbuffer(&fb->_StencilBuffer); + _mesa_unreference_renderbuffer(&fb->_StencilBuffer); } fb->_StencilBuffer = rb; if (rb) { @@ -166,6 +166,8 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual) _glthread_INIT_MUTEX(fb->Mutex); + fb->RefCount = 1; + /* save the visual */ fb->Visual = *visual; @@ -198,7 +200,6 @@ void _mesa_destroy_framebuffer(struct gl_framebuffer *fb) { if (fb) { - _glthread_DESTROY_MUTEX(fb->Mutex); _mesa_free_framebuffer_data(fb); _mesa_free(fb); } @@ -215,20 +216,27 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) GLuint i; assert(fb); + assert(fb->RefCount == 0); + + _glthread_DESTROY_MUTEX(fb->Mutex); for (i = 0; i < BUFFER_COUNT; i++) { struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; if (att->Renderbuffer) { - struct gl_renderbuffer *rb = att->Renderbuffer; - /* remove framebuffer's reference to renderbuffer */ - _mesa_dereference_renderbuffer(&rb); - if (rb && rb->Name == 0) { - /* delete window system renderbuffer */ - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&att->Renderbuffer); + } + if (att->Texture) { + /* render to texture */ + att->Texture->RefCount--; + if (att->Texture->RefCount == 0) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) { + ctx->Driver.DeleteTexture(ctx, att->Texture); + } } } att->Type = GL_NONE; - att->Renderbuffer = NULL; + att->Texture = NULL; } /* unbind depth/stencil to decr ref counts */ @@ -238,25 +246,51 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) /** - * Decrement the reference count on a framebuffer and delete it when + * Set *ptr to point to fb, with refcounting and locking. + */ +void +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb) +{ + assert(ptr); + if (*ptr == fb) { + /* no change */ + return; + } + if (*ptr) { + _mesa_unreference_framebuffer(ptr); + } + assert(!*ptr); + assert(fb); + _glthread_LOCK_MUTEX(fb->Mutex); + fb->RefCount++; + _glthread_UNLOCK_MUTEX(fb->Mutex); + *ptr = fb; +} + + +/** + * Undo/remove a reference to a framebuffer object. + * Decrement the framebuffer object's reference count and delete it when * the refcount hits zero. - * Note: we pass the address of a pointer and set it to NULL if we delete it. + * Note: we pass the address of a pointer and set it to NULL. */ void -_mesa_dereference_framebuffer(struct gl_framebuffer **fb) +_mesa_unreference_framebuffer(struct gl_framebuffer **fb) { - GLboolean deleteFlag = GL_FALSE; + assert(fb); + if (*fb) { + GLboolean deleteFlag = GL_FALSE; - _glthread_LOCK_MUTEX((*fb)->Mutex); - { + _glthread_LOCK_MUTEX((*fb)->Mutex); ASSERT((*fb)->RefCount > 0); (*fb)->RefCount--; deleteFlag = ((*fb)->RefCount == 0); - } - _glthread_UNLOCK_MUTEX((*fb)->Mutex); + _glthread_UNLOCK_MUTEX((*fb)->Mutex); + + if (deleteFlag) + (*fb)->Delete(*fb); - if (deleteFlag) { - (*fb)->Delete(*fb); *fb = NULL; } } @@ -605,21 +639,25 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) GLbitfield bufferMask = fb->_ColorDrawBufferMask[output]; GLuint count = 0; GLuint i; - /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK) - * can specify writing to two or four color buffers (for example). - */ - for (i = 0; bufferMask && i < BUFFER_COUNT; i++) { - const GLuint bufferBit = 1 << i; - if (bufferBit & bufferMask) { - struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - if (rb) { - fb->_ColorDrawBuffers[output][count] = rb; - count++; - } - else { - /*_mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");*/ + if (!fb->DeletePending) { + /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK) + * can specify writing to two or four color buffers (for example). + */ + for (i = 0; bufferMask && i < BUFFER_COUNT; i++) { + const GLuint bufferBit = 1 << i; + if (bufferBit & bufferMask) { + struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + if (rb) { + fb->_ColorDrawBuffers[output][count] = rb; + count++; + } + else { + /* + _mesa_warning(ctx, "DrawBuffer names a missing buffer!\n"); + */ + } + bufferMask &= ~bufferBit; } - bufferMask &= ~bufferBit; } } fb->_NumColorDrawBuffers[output] = count; @@ -635,7 +673,7 @@ static void update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) { (void) ctx; - if (fb->_ColorReadBufferIndex == -1) { + if (fb->_ColorReadBufferIndex == -1 || fb->DeletePending) { fb->_ColorReadBuffer = NULL; /* legal! */ } else { diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h index 7f3254fe8ea..4d76f3a90f7 100644 --- a/src/mesa/main/framebuffer.h +++ b/src/mesa/main/framebuffer.h @@ -43,7 +43,11 @@ extern void _mesa_free_framebuffer_data(struct gl_framebuffer *buffer); extern void -_mesa_dereference_framebuffer(struct gl_framebuffer **fb); +_mesa_reference_framebuffer(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb); + +extern void +_mesa_unreference_framebuffer(struct gl_framebuffer **fb); extern void _mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb, diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index fc8e1f0f574..eb91ebb6110 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1182,15 +1182,24 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { /* compute luminance values */ - if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + if (transferOps & IMAGE_RED_TO_LUMINANCE) { + /* Luminance = Red (glGetTexImage) */ for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - luminance[i] = CLAMP(sum, 0.0F, 1.0F); + luminance[i] = rgba[i][RCOMP]; } } else { - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + /* Luminance = Red + Green + Blue (glReadPixels) */ + if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + for (i = 0; i < n; i++) { + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); + } + } + else { + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + } } } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 410d2d3144f..b08e77ea880 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2316,6 +2316,7 @@ struct gl_framebuffer _glthread_Mutex Mutex; /**< for thread safety */ GLuint Name; /* if zero, this is a window system framebuffer */ GLint RefCount; + GLboolean DeletePending; GLvisual Visual; /**< The framebuffer's visual. Immutable if this is a window system buffer. @@ -2612,6 +2613,7 @@ struct gl_matrix_stack #define IMAGE_HISTOGRAM_BIT 0x200 #define IMAGE_MIN_MAX_BIT 0x400 #define IMAGE_CLAMP_BIT 0x800 /* extra */ +#define IMAGE_RED_TO_LUMINANCE 0x1000 /** Pixel Transfer ops up to convolution */ diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index ddf2ac51d3b..4a0c24fdbcc 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5.3 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -112,9 +112,7 @@ userclip_point( GLcontext *ctx, const GLfloat v[] ) /** - * This has been split off to allow the normal shade routines to - * get a little closer to the vertex buffer, and to use the - * GLvector objects directly. + * Compute lighting for the raster position. Both RGB and CI modes computed. * \param ctx the context * \param vertex vertex location * \param normal normal vector @@ -130,13 +128,12 @@ shade_rastpos(GLcontext *ctx, GLfloat Rspec[4], GLfloat *Rindex) { - GLfloat (*base)[3] = ctx->Light._BaseColor; - struct gl_light *light; - GLfloat diffuseColor[4], specularColor[4]; - GLfloat diffuse = 0, specular = 0; + /*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor; + const struct gl_light *light; + GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */ + GLfloat diffuseCI = 0.0, specularCI = 0.0; /* for CI mode only */ - if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1]) - _mesa_validate_all_lighting_tables( ctx ); + _mesa_validate_all_lighting_tables( ctx ); COPY_3V(diffuseColor, base[0]); diffuseColor[3] = CLAMP( @@ -144,28 +141,31 @@ shade_rastpos(GLcontext *ctx, ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0); foreach (light, &ctx->Light.EnabledList) { - GLfloat n_dot_h; GLfloat attenuation = 1.0; - GLfloat VP[3]; + GLfloat VP[3]; /* vector from vertex to light pos */ GLfloat n_dot_VP; - GLfloat *h; GLfloat diffuseContrib[3], specularContrib[3]; - GLboolean normalized; if (!(light->_Flags & LIGHT_POSITIONAL)) { + /* light at infinity */ COPY_3V(VP, light->_VP_inf_norm); attenuation = light->_VP_inf_spot_attenuation; } else { + /* local/positional light */ GLfloat d; + /* VP = vector from vertex pos to light[i].pos */ SUB_3V(VP, light->_Position, vertex); + /* d = length(VP) */ d = (GLfloat) LEN_3FV( VP ); - - if ( d > 1e-6) { + if (d > 1.0e-6) { + /* normalize VP */ GLfloat invd = 1.0F / d; SELF_SCALE_SCALAR_3V(VP, invd); } + + /* atti */ attenuation = 1.0F / (light->ConstantAttenuation + d * (light->LinearAttenuation + d * light->QuadraticAttenuation)); @@ -196,43 +196,39 @@ shade_rastpos(GLcontext *ctx, continue; } + /* Ambient + diffuse */ COPY_3V(diffuseContrib, light->_MatAmbient[0]); ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]); - diffuse += n_dot_VP * light->_dli * attenuation; - ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0); + diffuseCI += n_dot_VP * light->_dli * attenuation; + /* Specular */ { + const GLfloat *h; + GLfloat n_dot_h; + + ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0); + if (ctx->Light.Model.LocalViewer) { GLfloat v[3]; COPY_3V(v, vertex); NORMALIZE_3FV(v); SUB_3V(VP, VP, v); + NORMALIZE_3FV(VP); h = VP; - normalized = 0; } else if (light->_Flags & LIGHT_POSITIONAL) { + ACC_3V(VP, ctx->_EyeZDir); + NORMALIZE_3FV(VP); h = VP; - ACC_3V(h, ctx->_EyeZDir); - normalized = 0; } else { h = light->_h_inf_norm; - normalized = 1; } n_dot_h = DOT3(normal, h); if (n_dot_h > 0.0F) { - GLfloat (*mat)[4] = ctx->Light.Material.Attrib; GLfloat spec_coef; - GLfloat shininess = mat[MAT_ATTRIB_FRONT_SHININESS][0]; - - if (!normalized) { - n_dot_h *= n_dot_h; - n_dot_h /= LEN_SQUARED_3FV( h ); - shininess *= .5; - } - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef ); if (spec_coef > 1.0e-10) { @@ -244,7 +240,8 @@ shade_rastpos(GLcontext *ctx, ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef, light->_MatSpecular[0]); } - specular += spec_coef * light->_sli * attenuation; + /*assert(light->_sli > 0.0);*/ + specularCI += spec_coef * light->_sli * attenuation; } } } @@ -268,8 +265,8 @@ shade_rastpos(GLcontext *ctx, GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT]; GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT]; GLfloat i = (ind[MAT_INDEX_AMBIENT] - + diffuse * (1.0F-specular) * d_a - + specular * s_a); + + diffuseCI * (1.0F-specularCI) * d_a + + specularCI * s_a); if (i > ind[MAT_INDEX_SPECULAR]) { i = ind[MAT_INDEX_SPECULAR]; } diff --git a/src/mesa/main/rbadaptors.c b/src/mesa/main/rbadaptors.c index 313c8d43d62..60f4948becf 100644 --- a/src/mesa/main/rbadaptors.c +++ b/src/mesa/main/rbadaptors.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -45,7 +45,7 @@ Delete_wrapper(struct gl_renderbuffer *rb) /* Decrement reference count on the buffer we're wrapping and delete * it if refcount hits zero. */ - _mesa_dereference_renderbuffer(&rb->Wrapped); + _mesa_unreference_renderbuffer(&rb->Wrapped); /* delete myself */ _mesa_delete_renderbuffer(rb); diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 6b18d60baff..1cc95a7d3b4 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -2089,32 +2089,33 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName) if (!rb) return; - _mesa_dereference_renderbuffer(&rb); + _mesa_unreference_renderbuffer(&rb); fb->Attachment[bufferName].Renderbuffer = NULL; } /** - * Decrement the reference count on a renderbuffer and delete it when + * Decrement a renderbuffer object's reference count and delete it when * the refcount hits zero. - * Note: we pass the address of a pointer and set it to NULL if we delete it. + * Note: we pass the address of a pointer. */ void -_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb) +_mesa_unreference_renderbuffer(struct gl_renderbuffer **rb) { - GLboolean deleteFlag = GL_FALSE; + assert(rb); + if (*rb) { + GLboolean deleteFlag = GL_FALSE; - _glthread_LOCK_MUTEX((*rb)->Mutex); - { + _glthread_LOCK_MUTEX((*rb)->Mutex); ASSERT((*rb)->RefCount > 0); (*rb)->RefCount--; deleteFlag = ((*rb)->RefCount == 0); - } - _glthread_UNLOCK_MUTEX((*rb)->Mutex); + _glthread_UNLOCK_MUTEX((*rb)->Mutex); + + if (deleteFlag) + (*rb)->Delete(*rb); - if (deleteFlag) { - (*rb)->Delete(*rb); *rb = NULL; } } diff --git a/src/mesa/main/renderbuffer.h b/src/mesa/main/renderbuffer.h index 74ca43c57ab..e1a0a559792 100644 --- a/src/mesa/main/renderbuffer.h +++ b/src/mesa/main/renderbuffer.h @@ -99,7 +99,7 @@ extern void _mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName); extern void -_mesa_dereference_renderbuffer(struct gl_renderbuffer **rb); +_mesa_unreference_renderbuffer(struct gl_renderbuffer **rb); extern struct gl_renderbuffer * _mesa_new_depthstencil_renderbuffer(GLcontext *ctx, GLuint name); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 87f8fa7a0d4..994fb167306 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3611,7 +3611,7 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, } _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, type, dest, - &ctx->Pack, 0x0 /*image xfer ops*/); + &ctx->Pack, IMAGE_RED_TO_LUMINANCE); } /* format */ } /* row */ } /* img */ |