summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_triangle.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_triangle.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_triangle.c')
-rw-r--r--src/mesa/swrast/s_triangle.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index e89a999a934..893859db083 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -36,6 +36,7 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/state.h"
+#include "main/samplerobj.h"
#include "program/prog_instruction.h"
#include "s_aatriangle.h"
@@ -1045,18 +1046,25 @@ _swrast_choose_triangle( struct gl_context *ctx )
swrast->_FogEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
+ const struct gl_sampler_object *samp;
const struct gl_texture_image *texImg;
const struct swrast_texture_image *swImg;
GLenum minFilter, magFilter, envMode;
gl_format format;
texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
+ if (ctx->Texture.Unit[0].Sampler)
+ samp = ctx->Texture.Unit[0].Sampler;
+ else if (texObj2D)
+ samp = &texObj2D->Sampler;
+ else
+ samp = NULL;
texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
swImg = swrast_texture_image_const(texImg);
format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
- minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE;
- magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE;
+ minFilter = texObj2D ? samp->MinFilter : GL_NONE;
+ magFilter = texObj2D ? samp->MagFilter : GL_NONE;
envMode = ctx->Texture.Unit[0].EnvMode;
/* First see if we can use an optimized 2-D texture function */
@@ -1065,8 +1073,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
&& !ctx->ATIFragmentShader._Enabled
&& ctx->Texture._EnabledUnits == 0x1
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
- && texObj2D->Sampler.WrapS == GL_REPEAT
- && texObj2D->Sampler.WrapT == GL_REPEAT
+ && samp->WrapS == GL_REPEAT
+ && samp->WrapT == GL_REPEAT
&& texObj2D->_Swizzle == SWIZZLE_NOOP
&& swImg->_IsPowerOfTwo
&& texImg->Border == 0