summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_fragprog.c
diff options
context:
space:
mode:
authorPauli Nieminen <[email protected]>2012-06-12 21:38:56 +0300
committerEric Anholt <[email protected]>2012-08-01 15:55:51 -0700
commitcbdc1d53542b3ecca0085399c4bb3b3371f94809 (patch)
treec835fd6c56f22692f8db127a882ae94e7a70d498 /src/mesa/swrast/s_fragprog.c
parent8129dabb5f5ff717bb1ca32710ca6204d5345461 (diff)
swrast: Support sampler object for texture fetching state
swrast needs to pass sampler object into all texture fetching functions to use correct sampling state when sampler object is bound to the unit. The changes were made using half manual regular expression replace. v2: Fix NULL deref in _swrast_choose_triangle(), because the _Current values aren't set yet, so we need to look at our texObj2D. (anholt) Signed-off-by: Pauli Nieminen <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/swrast/s_fragprog.c')
-rw-r--r--src/mesa/swrast/s_fragprog.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index 8d59371c836..812189f0946 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -24,6 +24,7 @@
#include "main/glheader.h"
#include "main/colormac.h"
+#include "main/samplerobj.h"
#include "program/prog_instruction.h"
#include "s_context.h"
@@ -83,11 +84,12 @@ fetch_texel_lod( struct gl_context *ctx, const GLfloat texcoord[4], GLfloat lamb
if (texObj) {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLfloat rgba[4];
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
- lambda = CLAMP(lambda, texObj->Sampler.MinLod, texObj->Sampler.MaxLod);
+ lambda = CLAMP(lambda, samp->MinLod, samp->MaxLod);
- swrast->TextureSample[unit](ctx, texObj, 1,
- (const GLfloat (*)[4]) texcoord,
+ swrast->TextureSample[unit](ctx, samp, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
&lambda, &rgba);
swizzle_texel(rgba, color, texObj->_Swizzle);
}
@@ -118,6 +120,7 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4],
texObj->Image[0][texObj->BaseLevel];
const struct swrast_texture_image *swImg =
swrast_texture_image_const(texImg);
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
const GLfloat texW = (GLfloat) swImg->WidthScale;
const GLfloat texH = (GLfloat) swImg->HeightScale;
GLfloat lambda;
@@ -130,12 +133,12 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4],
texcoord[0], texcoord[1], texcoord[3],
1.0F / texcoord[3]);
- lambda += lodBias + texUnit->LodBias + texObj->Sampler.LodBias;
+ lambda += lodBias + texUnit->LodBias + samp->LodBias;
- lambda = CLAMP(lambda, texObj->Sampler.MinLod, texObj->Sampler.MaxLod);
+ lambda = CLAMP(lambda, samp->MinLod, samp->MaxLod);
- swrast->TextureSample[unit](ctx, texObj, 1,
- (const GLfloat (*)[4]) texcoord,
+ swrast->TextureSample[unit](ctx, samp, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
&lambda, &rgba);
swizzle_texel(rgba, color, texObj->_Swizzle);
}