From 22a374fc3fdf97a9cc50e9fdc24049c997e6896e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 19 Nov 2007 09:55:17 -0700 Subject: fix out-of-bounds array index (ix=-1) --- src/mesa/swrast/s_aatritemp.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 42d74a1632..29609add17 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -286,7 +286,7 @@ } /* skip fragments with zero coverage */ - while (startX >= 0) { + while (startX > 0) { coverage = compute_coveragef(pMin, pMax, pMid, startX, iy); if (coverage > 0.0F) break; @@ -300,6 +300,7 @@ /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; + ASSERT(ix >= 0); #ifdef DO_INDEX array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy); #else -- cgit v1.2.3 From 87373e30729b29d949ee71cf76d3cb9213ff1333 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 19 Nov 2007 10:37:54 -0700 Subject: fix some texture format assertions, etc --- src/mesa/swrast/s_texfilter.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index bb4e38623c..1a779c800e 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -1036,7 +1036,7 @@ sample_2d_linear_repeat(GLcontext *ctx, ASSERT(tObj->WrapS == GL_REPEAT); ASSERT(tObj->WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); ASSERT(img->_IsPowerOfTwo); COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(texcoord[0], u, width, i0, i1); @@ -1230,7 +1230,7 @@ opt_sample_rgb_2d( GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->_BaseFormat==GL_RGB); + ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB); ASSERT(img->_IsPowerOfTwo); for (k=0; kWrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->_BaseFormat==GL_RGBA); + ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA); ASSERT(img->_IsPowerOfTwo); for (i = 0; i < n; i++) { @@ -1301,7 +1301,7 @@ sample_lambda_2d( GLcontext *ctx, const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT) && (tObj->WrapT == GL_REPEAT) && (tImg->Border == 0 && (tImg->Width == tImg->RowStride)) - && (tImg->_BaseFormat != GL_COLOR_INDEX) + && (tImg->TexFormat->BaseFormat != GL_COLOR_INDEX) && tImg->_IsPowerOfTwo; ASSERT(lambda != NULL); @@ -1316,16 +1316,10 @@ sample_lambda_2d( GLcontext *ctx, if (repeatNoBorderPOT) { switch (tImg->TexFormat->MesaFormat) { case MESA_FORMAT_RGB: - case MESA_FORMAT_RGB888: - /*case MESA_FORMAT_BGR888:*/ opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; case MESA_FORMAT_RGBA: - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ARGB8888: - /*case MESA_FORMAT_ABGR8888:*/ - /*case MESA_FORMAT_BGRA8888:*/ opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; @@ -1379,16 +1373,10 @@ sample_lambda_2d( GLcontext *ctx, if (repeatNoBorderPOT) { switch (tImg->TexFormat->MesaFormat) { case MESA_FORMAT_RGB: - case MESA_FORMAT_RGB888: - /*case MESA_FORMAT_BGR888:*/ opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; case MESA_FORMAT_RGBA: - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ARGB8888: - /*case MESA_FORMAT_ABGR8888:*/ - /*case MESA_FORMAT_BGRA8888:*/ opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; @@ -2095,7 +2083,7 @@ sample_nearest_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint row, col; @@ -2131,7 +2119,7 @@ sample_linear_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); /* XXX lots of opportunity for optimization in this loop */ for (i = 0; i < n; i++) { @@ -2873,8 +2861,8 @@ sample_depth_texture( GLcontext *ctx, (void) lambda; - ASSERT(tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_COMPONENT || - tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL_EXT); + ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT || + img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT); ASSERT(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || @@ -3242,7 +3230,7 @@ sample_depth_texture2(const GLcontext *ctx, * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object * isn't a depth texture. */ - if (texImage->_BaseFormat != GL_DEPTH_COMPONENT) { + if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) { _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture"); return; } @@ -3345,7 +3333,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, } else { const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter); - const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat; + const GLenum format = t->Image[0][t->BaseLevel]->TexFormat->BaseFormat; switch (t->Target) { case GL_TEXTURE_1D: -- cgit v1.2.3 From 827e72de7537e62cac9652f8b7344ff356de9bb1 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 19 Nov 2007 13:05:00 -0700 Subject: clamp lambda to Min/MaxLod --- src/mesa/swrast/s_fragprog.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 6656ebc0d0..474aab3aa2 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.0.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"), @@ -41,9 +41,12 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, { GLchan rgba[4]; SWcontext *swrast = SWRAST_CONTEXT(ctx); + const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; + lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); + /* XXX use a float-valued TextureSample routine here!!! */ - swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current, + swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, &lambda, &rgba); color[0] = CHAN_TO_FLOAT(rgba[0]); -- cgit v1.2.3 From 0fd679a1903d997b53fe20b86821a58c1a66262f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Nov 2007 09:31:16 -0700 Subject: Consolidate point size computation, clamping in get_size(). Also, apply user-defined clamp limits to point size even when not using attentuation or program-computed size. --- src/mesa/swrast/s_points.c | 71 +++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index ce73365a4e..dd664b980e 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -46,6 +46,38 @@ } while(0) + +/** + * Get/compute the point size. + * The size may come from a vertex shader, or computed with attentuation + * or just the glPointSize value. + * Must also clamp to user-defined range and implmentation limits. + */ +static INLINE GLfloat +get_size(const GLcontext *ctx, const SWvertex *vert, GLboolean smoothed) +{ + GLfloat size; + + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + size = vert->pointSize; + } + else { + /* use constant point size */ + size = ctx->Point.Size; + } + /* always clamp to user-specified limits */ + size = CLAMP(size, ctx->Point.MinSize, ctx->Point.MaxSize); + /* clamp to implementation limits */ + if (smoothed) + size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); + else + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + + return size; +} + + /** * Draw a point sprite */ @@ -68,18 +100,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); span.zStep = 0; - /* compute size */ - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - /* use vertex's point size */ - /* first, clamp attenuated size to the user-specifed range */ - size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); - } - else { - /* use constant point size */ - size = ctx->Point.Size; - } - /* clamp to non-AA implementation limits */ - size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + size = get_size(ctx, vert, GL_FALSE); /* span init */ INIT_SPAN(span, GL_POINT); @@ -237,18 +258,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); span.zStep = 0; - /* compute size */ - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - /* use vertex's point size */ - /* first, clamp attenuated size to the user-specifed range */ - size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); - } - else { - /* use constant point size */ - size = ctx->Point.Size; - } - /* clamp to AA implementation limits */ - size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); + size = get_size(ctx, vert, GL_TRUE); /* alpha attenuation / fade factor */ if (ctx->Multisample.Enabled) { @@ -371,18 +381,7 @@ large_point(GLcontext *ctx, const SWvertex *vert) span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); span.zStep = 0; - /* compute size */ - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - /* use vertex's point size */ - /* first, clamp attenuated size to the user-specifed range */ - size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); - } - else { - /* use constant point size */ - size = ctx->Point.Size; - } - /* clamp to non-AA implementation limits */ - size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + size = get_size(ctx, vert, GL_FALSE); /* span init */ INIT_SPAN(span, GL_POINT); -- cgit v1.2.3 From c14d969a69d7b9a060c6701d3f18c51eabc56635 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 23 Nov 2007 09:14:39 -0700 Subject: need to check border width in sample_linear_2d() - fixes failed assertion in texwrap.c test --- src/mesa/swrast/s_texfilter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 1a779c800e..a5594ac623 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1191,7 +1191,8 @@ sample_linear_2d( GLcontext *ctx, (void) lambda; if (tObj->WrapS == GL_REPEAT && tObj->WrapT == GL_REPEAT && - image->_IsPowerOfTwo) { + image->_IsPowerOfTwo && + image->Border == 0) { for (i=0;i Date: Fri, 23 Nov 2007 12:01:57 -0700 Subject: Consolidate texture fetch code and use partial derivatives when possible. --- src/mesa/shader/prog_execute.c | 128 +++++++++++++++++++++-------------------- src/mesa/shader/prog_execute.h | 3 +- src/mesa/swrast/s_fragprog.c | 23 ++++---- 3 files changed, 79 insertions(+), 75 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 28d195d0ee..00a375078b 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -46,9 +46,6 @@ #include "shader/slang/slang_library_noise.h" -/* See comments below for info about this */ -#define LAMBDA_ZERO 1 - /* debug predicate */ #define DEBUG_PROG 0 @@ -302,6 +299,36 @@ fetch_vector1(const struct prog_src_register *source, } +/** + * Fetch texel from texture. Use partial derivatives when possible. + */ +static INLINE void +fetch_texel(GLcontext *ctx, + const struct gl_program_machine *machine, + const struct prog_instruction *inst, + const GLfloat texcoord[4], GLfloat lodBias, + GLfloat color[4]) +{ + /* Note: we only have the right derivatives for fragment input attribs. + */ + if (machine->NumDeriv > 0 && + inst->SrcReg[0].File == PROGRAM_INPUT && + inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) { + /* simple texture fetch for which we should have derivatives */ + GLuint attr = inst->SrcReg[0].Index; + machine->FetchTexelDeriv(ctx, texcoord, + machine->DerivX[attr], + machine->DerivY[attr], + lodBias, + inst->TexSrcUnit, color); + } + else { + machine->FetchTexelLod(ctx, texcoord, lodBias, + inst->TexSrcUnit, color); + } +} + + /** * Test value against zero and return GT, LT, EQ or UN if NaN. */ @@ -1306,33 +1333,18 @@ _mesa_execute_program(GLcontext * ctx, } break; case OPCODE_TEX: /* Both ARB and NV frag prog */ - /* Texel lookup */ + /* Simple texel lookup */ { - /* Note: only use the precomputed lambda value when we're - * sampling texture unit [K] with texcoord[K]. - * Otherwise, the lambda value may have no relation to the - * instruction's texcoord or texture image. Using the wrong - * lambda is usually bad news. - * The rest of the time, just use zero (until we get a more - * sophisticated way of computing lambda). - */ - GLfloat coord[4], color[4], lambda; -#if 0 - if (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) - lambda = span->array->lambda[inst->TexSrcUnit][column]; - else -#endif - lambda = 0.0; - fetch_vector4(&inst->SrcReg[0], machine, coord); - machine->FetchTexelLod(ctx, coord, lambda, inst->TexSrcUnit, - color); + GLfloat texcoord[4], color[4]; + fetch_vector4(&inst->SrcReg[0], machine, texcoord); + + fetch_texel(ctx, machine, inst, texcoord, 0.0, color); + if (DEBUG_PROG) { - printf("TEX (%g, %g, %g, %g) = texture[%d][%g, %g, %g, %g], " - "lod %f\n", + printf("TEX (%g, %g, %g, %g) = texture[%d][%g, %g, %g, %g]\n", color[0], color[1], color[2], color[3], inst->TexSrcUnit, - coord[0], coord[1], coord[2], coord[3], lambda); + texcoord[0], texcoord[1], texcoord[2], texcoord[3]); } store_vector4(inst, machine, color); } @@ -1342,21 +1354,18 @@ _mesa_execute_program(GLcontext * ctx, { const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[inst->TexSrcUnit]; - GLfloat coord[4], color[4], lambda, bias; -#if 0 - if (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) - lambda = span->array->lambda[inst->TexSrcUnit][column]; - else -#endif - lambda = 0.0; - fetch_vector4(&inst->SrcReg[0], machine, coord); - /* coord[3] is the bias to add to lambda */ - bias = texUnit->LodBias + coord[3]; - if (texUnit->_Current) - bias += texUnit->_Current->LodBias; - machine->FetchTexelLod(ctx, coord, lambda + bias, - inst->TexSrcUnit, color); + GLfloat texcoord[4], color[4], lodBias; + + fetch_vector4(&inst->SrcReg[0], machine, texcoord); + + /* texcoord[3] is the bias to add to lambda */ + lodBias = texUnit->LodBias + texcoord[3]; + if (texUnit->_Current) { + lodBias += texUnit->_Current->LodBias; + } + + fetch_texel(ctx, machine, inst, texcoord, lodBias, color); + store_vector4(inst, machine, color); } break; @@ -1368,6 +1377,7 @@ _mesa_execute_program(GLcontext * ctx, fetch_vector4(&inst->SrcReg[1], machine, dtdx); fetch_vector4(&inst->SrcReg[2], machine, dtdy); machine->FetchTexelDeriv(ctx, texcoord, dtdx, dtdy, + 0.0, /* lodBias */ inst->TexSrcUnit, color); store_vector4(inst, machine, color); } @@ -1375,14 +1385,8 @@ _mesa_execute_program(GLcontext * ctx, case OPCODE_TXP: /* GL_ARB_fragment_program only */ /* Texture lookup w/ projective divide */ { - GLfloat texcoord[4], color[4], lambda; -#if 0 - if (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) - lambda = span->array->lambda[inst->TexSrcUnit][column]; - else -#endif - lambda = 0.0; + GLfloat texcoord[4], color[4]; + fetch_vector4(&inst->SrcReg[0], machine, texcoord); /* Not so sure about this test - if texcoord[3] is * zero, we'd probably be fine except for an ASSERT in @@ -1393,22 +1397,19 @@ _mesa_execute_program(GLcontext * ctx, texcoord[1] /= texcoord[3]; texcoord[2] /= texcoord[3]; } - machine->FetchTexelLod(ctx, texcoord, lambda, - inst->TexSrcUnit, color); + + fetch_texel(ctx, machine, inst, texcoord, 0.0, color); + store_vector4(inst, machine, color); } break; case OPCODE_TXP_NV: /* GL_NV_fragment_program only */ - /* Texture lookup w/ projective divide */ + /* Texture lookup w/ projective divide, as above, but do not + * do the divide by w if sampling from a cube map. + */ { - GLfloat texcoord[4], color[4], lambda; -#if 0 - if (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) - lambda = span->array->lambda[inst->TexSrcUnit][column]; - else -#endif - lambda = 0.0; + GLfloat texcoord[4], color[4]; + fetch_vector4(&inst->SrcReg[0], machine, texcoord); if (inst->TexSrcTarget != TEXTURE_CUBE_INDEX && texcoord[3] != 0.0) { @@ -1416,8 +1417,9 @@ _mesa_execute_program(GLcontext * ctx, texcoord[1] /= texcoord[3]; texcoord[2] /= texcoord[3]; } - machine->FetchTexelLod(ctx, texcoord, lambda, - inst->TexSrcUnit, color); + + fetch_texel(ctx, machine, inst, texcoord, 0.0, color); + store_vector4(inst, machine, color); } break; diff --git a/src/mesa/shader/prog_execute.h b/src/mesa/shader/prog_execute.h index be29eceeda..3ea0ba1565 100644 --- a/src/mesa/shader/prog_execute.h +++ b/src/mesa/shader/prog_execute.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -32,6 +32,7 @@ typedef void (*FetchTexelLodFunc)(GLcontext *ctx, const GLfloat texcoord[4], typedef void (*FetchTexelDerivFunc)(GLcontext *ctx, const GLfloat texcoord[4], const GLfloat texdx[4], const GLfloat texdy[4], + GLfloat lodBias, GLuint unit, GLfloat color[4]); diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 474aab3aa2..4067fd6886 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -46,8 +46,7 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); /* XXX use a float-valued TextureSample routine here!!! */ - swrast->TextureSample[unit](ctx, texObj, - 1, (const GLfloat (*)[4]) texcoord, + swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, &lambda, &rgba); color[0] = CHAN_TO_FLOAT(rgba[0]); color[1] = CHAN_TO_FLOAT(rgba[1]); @@ -63,7 +62,7 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, static void fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], const GLfloat texdx[4], const GLfloat texdy[4], - GLuint unit, GLfloat color[4] ) + GLfloat lodBias, GLuint unit, GLfloat color[4] ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; @@ -72,15 +71,17 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], const GLfloat texH = (GLfloat) texImg->HeightScale; GLchan rgba[4]; - GLfloat lambda = _swrast_compute_lambda(texdx[0], texdy[0], /* ds/dx, ds/dy */ - texdx[1], texdy[1], /* dt/dx, dt/dy */ - texdx[3], texdy[2], /* dq/dx, dq/dy */ - texW, texH, - texcoord[0], texcoord[1], texcoord[3], - 1.0F / texcoord[3]); + GLfloat lambda + = _swrast_compute_lambda(texdx[0], texdy[0], /* ds/dx, ds/dy */ + texdx[1], texdy[1], /* dt/dx, dt/dy */ + texdx[3], texdy[2], /* dq/dx, dq/dy */ + texW, texH, + texcoord[0], texcoord[1], texcoord[3], + 1.0F / texcoord[3]) + lodBias; - swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current, - 1, (const GLfloat (*)[4]) texcoord, + lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); + + swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, &lambda, &rgba); color[0] = CHAN_TO_FLOAT(rgba[0]); color[1] = CHAN_TO_FLOAT(rgba[1]); -- cgit v1.2.3 From 74cd0b459f4eafd4b4bc63532b1c3cb6f26153ed Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 26 Nov 2007 09:35:39 -0700 Subject: improve 24-bit Z to 32-bit Z conversion --- src/mesa/swrast/s_readpix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index fe9a70f4ea..916ddc1b97 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -129,7 +129,8 @@ read_depth_pixels( GLcontext *ctx, rb->GetRow(ctx, rb, width, x, y, dest); /* convert range from 24-bit to 32-bit */ for (k = 0; k < width; k++) { - dest[k] = (dest[k] << 8) | (dest[k] >> 24); + /* Note: put MSByte of 24-bit value into LSByte */ + dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff); } } } -- cgit v1.2.3