From: Brian Paul Date: Wed, 14 May 2008 22:05:25 +0000 (-0600) Subject: mesa: sync up swrast/s_fragprog.c with master X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afa4c792b00070a5c50730ba455df18629d4e550;p=mesa.git mesa: sync up swrast/s_fragprog.c with master --- diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 6ee8bfd0a5e..40ed48696ca 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"), @@ -33,18 +33,21 @@ /** - * Fetch a texel. + * Fetch a texel with given lod. + * Called via machine->FetchTexelLod() */ static void -fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, - GLuint unit, GLfloat color[4] ) +fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, + GLuint unit, GLfloat color[4] ) { 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, - 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]); @@ -56,6 +59,7 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, /** * Fetch a texel with the given partial derivatives to compute a level * of detail in the mipmap. + * Called via machine->FetchTexelDeriv() */ static void fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], @@ -69,15 +73,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; + + lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); - swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current, - 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]); @@ -132,7 +138,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, /* init call stack */ machine->StackDepth = 0; - machine->FetchTexelLod = fetch_texel; + machine->FetchTexelLod = fetch_texel_lod; machine->FetchTexelDeriv = fetch_texel_deriv; }