aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-03 08:16:19 +0200
committermarha <marha@users.sourceforge.net>2012-08-03 09:35:02 +0200
commit18e75aa6ae27a6e44d93babd96afbbe0cd6077c8 (patch)
treea6124cc965bba51de50907418ce63ab4540f582d
parent49838240b7d4cff1ffed1bd91e495f6919061f90 (diff)
downloadvcxsrv-18e75aa6ae27a6e44d93babd96afbbe0cd6077c8.tar.gz
vcxsrv-18e75aa6ae27a6e44d93babd96afbbe0cd6077c8.tar.bz2
vcxsrv-18e75aa6ae27a6e44d93babd96afbbe0cd6077c8.zip
pixman mesa git update 3 Aug 2012
-rw-r--r--mesalib/configure.ac25
-rw-r--r--mesalib/scons/gallium.py6
-rw-r--r--mesalib/src/glsl/SConscript4
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp1
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h2
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c75
-rw-r--r--mesalib/src/mesa/main/attrib.c2
-rw-r--r--mesalib/src/mesa/main/bufferobj.c4
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp5
-rw-r--r--mesalib/src/mesa/main/get.c7
-rw-r--r--mesalib/src/mesa/main/mtypes.h6
-rw-r--r--mesalib/src/mesa/main/samplerobj.c65
-rw-r--r--mesalib/src/mesa/main/samplerobj.h11
-rw-r--r--mesalib/src/mesa/main/texobj.c4
-rw-r--r--mesalib/src/mesa/main/texparam.c8
-rw-r--r--mesalib/src/mesa/main/texstate.c2
-rw-r--r--mesalib/src/mesa/main/version.c2
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_blit.c15
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c2
-rw-r--r--mesalib/src/mesa/swrast/s_atifragshader.c6
-rw-r--r--mesalib/src/mesa/swrast/s_context.c4
-rw-r--r--mesalib/src/mesa/swrast/s_context.h1
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c17
-rw-r--r--mesalib/src/mesa/swrast/s_span.c8
-rw-r--r--mesalib/src/mesa/swrast/s_texcombine.c42
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c18
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.h2
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c696
-rw-r--r--mesalib/src/mesa/swrast/s_triangle.c16
-rw-r--r--mesalib/src/mesa/tnl/t_vb_program.c4
-rw-r--r--pixman/configure.ac2
-rw-r--r--pixman/pixman/Makefile.am1
-rw-r--r--pixman/pixman/make-srgb.pl5
-rw-r--r--pixman/pixman/pixman-matrix.c2
-rw-r--r--pixman/test/glyph-test.c4
-rw-r--r--pixman/test/stress-test.c5
40 files changed, 627 insertions, 464 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index b01b1921b..b6481a69f 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -26,10 +26,6 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_PREREQ([2.2])
LT_INIT([disable-static])
-dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
-USER_CFLAGS="$CFLAGS"
-USER_CXXFLAGS="$CXXFLAGS"
-
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.31
@@ -284,11 +280,11 @@ dnl explicitly requested. If both disabled, set to static since shared
dnl was explicitly requested.
case "x$enable_static$enable_shared" in
xyesyes )
- AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
+ AC_MSG_WARN([Cannot build static and shared libraries, disabling shared])
enable_shared=no
;;
xnono )
- AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
+ AC_MSG_WARN([Cannot disable both static and shared libraries, enabling static])
enable_static=yes
;;
esac
@@ -470,13 +466,6 @@ if test "x$enable_asm" = xyes; then
;;
esac
;;
- powerpc)
- case "$host_os" in
- linux*)
- asm_arch=ppc
- ;;
- esac
- ;;
sparc*)
case "$host_os" in
linux*)
@@ -723,9 +712,7 @@ default_driver="xlib"
case "$host_os" in
linux*)
- case "$host_cpu" in
- i*86|x86_64|powerpc*|sparc*|ia64*) default_driver="dri";;
- esac
+ default_driver="dri"
;;
*freebsd* | dragonfly* | *netbsd*)
case "$host_cpu" in
@@ -882,7 +869,7 @@ PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED],
if test "x$enable_dri" = xyes; then
# DRI must be shared, I think
if test "$enable_static" = yes; then
- AC_MSG_ERROR([Can't use static libraries for DRI drivers])
+ AC_MSG_ERROR([Cannot use static libraries for DRI drivers])
fi
# not a hard requirement as swrast does not depend on it
@@ -1135,7 +1122,7 @@ yes)
dri_drivers=`IFS=', '; echo $with_dri_drivers`
for driver in $dri_drivers; do
test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
- AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
+ AC_MSG_ERROR([DRI driver directory '$driver' does not exist])
done
DRI_DIRS="$dri_drivers"
if test -n "$DRI_DIRS" -a "x$enable_opengl" != xyes; then
@@ -2022,7 +2009,7 @@ if test "x$with_gallium_drivers" != x; then
AC_MSG_ERROR([LLVM 3.1 is required to build the radeonsi driver.])
fi
NEED_RADEON_GALLIUM=yes;
- gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi"
+ gallium_check_st "radeon/drm" "dri-radeonsi" "xorg-radeonsi" "" "" "vdpau-radeonsi" ""
;;
xnouveau)
PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
index 458651b45..f4776d83d 100644
--- a/mesalib/scons/gallium.py
+++ b/mesalib/scons/gallium.py
@@ -141,6 +141,7 @@ def generate(env):
env['msvc'] = env['CC'] == 'cl'
env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc'
env['clang'] = env['CC'] == 'clang'
+ env['icc'] = 'icc' == os.path.basename(env['CC'])
if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64':
# MSVC x64 support is broken in earlier versions of scons
@@ -154,6 +155,7 @@ def generate(env):
gcc = env['gcc']
msvc = env['msvc']
suncc = env['suncc']
+ icc = env['icc']
# Determine whether we are cross compiling; in particular, whether we need
# to compile code generators with a different compiler as the target code.
@@ -382,6 +384,10 @@ def generate(env):
cflags += [
'-Wdeclaration-after-statement',
]
+ if icc:
+ cflags += [
+ '-std=gnu99',
+ ]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index 2fc57c6dd..0855c67bb 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -25,6 +25,10 @@ parser_env.Append(YACCFLAGS = [
'-p', '_mesa_glsl_',
])
+# without this line scons will expect "glsl_parser.hpp" instead of
+# "glsl_parser.h", causing glsl_parser.cpp to be regenerated every time
+parser_env['YACCHXXFILESUFFIX'] = '.h'
+
glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l')
glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y')
glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll')
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 09e1e590d..872fcda71 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -288,6 +288,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(OES_EGL_image_external, true, false, true, false, true, OES_EGL_image_external),
EXT(ARB_shader_bit_encoding, true, true, true, true, false, ARB_shader_bit_encoding),
EXT(ARB_uniform_buffer_object, true, false, true, true, false, ARB_uniform_buffer_object),
+ EXT(OES_standard_derivatives, false, false, true, false, true, OES_standard_derivatives),
};
#undef EXT
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index c0a96c730..66463c5b6 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -203,6 +203,8 @@ struct _mesa_glsl_parse_state {
bool ARB_shader_bit_encoding_warn;
bool ARB_uniform_buffer_object_enable;
bool ARB_uniform_buffer_object_warn;
+ bool OES_standard_derivatives_enable;
+ bool OES_standard_derivatives_warn;
/*@}*/
/** Extensions supported by the OpenGL implementation. */
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 6846bbc60..af89d8180 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -287,7 +287,7 @@ struct gen_mipmap_state
struct decompress_state
{
GLuint ArrayObj;
- GLuint VBO, FBO, RBO;
+ GLuint VBO, FBO, RBO, Sampler;
GLint Width, Height;
};
@@ -1350,15 +1350,13 @@ blitframebuffer_texture(struct gl_context *ctx,
if (readAtt && readAtt->Texture) {
const struct gl_texture_object *texObj = readAtt->Texture;
const GLuint srcLevel = readAtt->TextureLevel;
- const GLenum minFilterSave = texObj->Sampler.MinFilter;
- const GLenum magFilterSave = texObj->Sampler.MagFilter;
const GLint baseLevelSave = texObj->BaseLevel;
const GLint maxLevelSave = texObj->MaxLevel;
- const GLenum wrapSSave = texObj->Sampler.WrapS;
- const GLenum wrapTSave = texObj->Sampler.WrapT;
- const GLenum srgbSave = texObj->Sampler.sRGBDecode;
const GLenum fbo_srgb_save = ctx->Color.sRGBEnabled;
const GLenum target = texObj->Target;
+ GLuint sampler, samplerSave =
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
if (drawAtt->Texture == readAtt->Texture) {
/* Can't use same texture as both the source and dest. We need
@@ -1373,6 +1371,9 @@ blitframebuffer_texture(struct gl_context *ctx,
return mask;
}
+ _mesa_GenSamplers(1, &sampler);
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
+
/*
printf("Blit from texture!\n");
printf(" srcAtt %p dstAtt %p\n", readAtt, drawAtt);
@@ -1381,18 +1382,18 @@ blitframebuffer_texture(struct gl_context *ctx,
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, filter);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
}
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* Always do our blits with no sRGB decode or encode.*/
if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
}
if (ctx->Extensions.EXT_framebuffer_sRGB) {
@@ -1452,21 +1453,17 @@ blitframebuffer_texture(struct gl_context *ctx,
/* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
}
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
- }
if (ctx->Extensions.EXT_framebuffer_sRGB && fbo_srgb_save) {
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_TRUE);
}
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
+ _mesa_DeleteSamplers(1, &sampler);
+
/* Done with color buffer */
mask &= ~GL_COLOR_BUFFER_BIT;
}
@@ -3295,6 +3292,7 @@ decompress_texture_image(struct gl_context *ctx,
struct vertex verts[4];
GLuint fboDrawSave, fboReadSave;
GLuint rbSave;
+ GLuint samplerSave;
if (slice > 0) {
assert(target == GL_TEXTURE_3D ||
@@ -3315,6 +3313,9 @@ decompress_texture_image(struct gl_context *ctx,
_mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_PIXEL_STORE);
+ samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
+
/* Create/bind FBO/renderbuffer */
if (decompress->FBO == 0) {
_mesa_GenFramebuffersEXT(1, &decompress->FBO);
@@ -3362,6 +3363,22 @@ decompress_texture_image(struct gl_context *ctx,
_mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, decompress->VBO);
}
+ if (!decompress->Sampler) {
+ _mesa_GenSamplers(1, &decompress->Sampler);
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler);
+ /* nearest filtering */
+ _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ /* No sRGB decode or encode.*/
+ if (ctx->Extensions.EXT_texture_sRGB_decode) {
+ _mesa_SamplerParameteri(decompress->Sampler, GL_TEXTURE_SRGB_DECODE_EXT,
+ GL_SKIP_DECODE_EXT);
+ }
+
+ } else {
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler);
+ }
+
setup_texture_coords(faceTarget, slice, width, height,
verts[0].tex,
verts[1].tex,
@@ -3387,26 +3404,14 @@ decompress_texture_image(struct gl_context *ctx,
{
/* save texture object state */
- const GLenum minFilterSave = texObj->Sampler.MinFilter;
- const GLenum magFilterSave = texObj->Sampler.MagFilter;
const GLint baseLevelSave = texObj->BaseLevel;
const GLint maxLevelSave = texObj->MaxLevel;
- const GLenum wrapSSave = texObj->Sampler.WrapS;
- const GLenum wrapTSave = texObj->Sampler.WrapT;
- const GLenum srgbSave = texObj->Sampler.sRGBDecode;
/* restrict sampling to the texture level of interest */
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage->Level);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage->Level);
- /* nearest filtering */
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
/* No sRGB decode or encode.*/
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
- }
if (ctx->Extensions.EXT_framebuffer_sRGB) {
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
}
@@ -3417,17 +3422,11 @@ decompress_texture_image(struct gl_context *ctx,
/* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
}
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
- }
+
}
/* read pixels from renderbuffer */
@@ -3455,6 +3454,8 @@ decompress_texture_image(struct gl_context *ctx,
/* disable texture unit */
_mesa_set_enable(ctx, target, GL_FALSE);
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
+
_mesa_meta_end(ctx);
/* restore fbo bindings */
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 318d576e8..8bc7c348f 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -806,7 +806,7 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
samp->CompareFunc);
}
if (ctx->Extensions.ARB_depth_texture)
- _mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, samp->DepthMode);
+ _mesa_TexParameteri(target, GL_DEPTH_TEXTURE_MODE, obj->DepthMode);
}
/* remove saved references to the texture objects */
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 7d72092a2..48edd89c9 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -131,7 +131,7 @@ get_buffer(struct gl_context *ctx, const char *func, GLenum target)
}
-static inline GLenum
+static inline GLbitfield
default_access_mode(const struct gl_context *ctx)
{
/* Table 2.6 on page 31 (page 44 of the PDF) of the OpenGL 1.5 spec says:
@@ -150,7 +150,7 @@ default_access_mode(const struct gl_context *ctx)
* The difference is because GL_OES_mapbuffer only supports mapping buffers
* write-only.
*/
- return (ctx->API == API_OPENGLES)
+ return _mesa_is_gles(ctx)
? GL_MAP_WRITE_BIT : (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
}
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index a7b481ca7..5e13a9357 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -113,7 +113,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_point_sprite", o(ARB_point_sprite), GL, 2003 },
{ "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 },
{ "GL_ARB_robustness", o(dummy_true), GL, 2010 },
- { "GL_ARB_sampler_objects", o(ARB_sampler_objects), GL, 2009 },
+ { "GL_ARB_sampler_objects", o(dummy_true), GL, 2009 },
{ "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL, 2009 },
{ "GL_ARB_shader_bit_encoding", o(ARB_shader_bit_encoding), GL, 2010 },
{ "GL_ARB_shader_objects", o(ARB_shader_objects), GL, 2002 },
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 0233f3802..f743ce109 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -33,6 +33,7 @@ extern "C" {
#include "mtypes.h"
#include "main/uniforms.h"
#include "main/macros.h"
+#include "main/samplerobj.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_cache.h"
@@ -428,11 +429,13 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
const struct gl_texture_object *texObj = texUnit->_Current;
const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine;
+ const struct gl_sampler_object *samp;
GLenum format;
if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
continue;
+ samp = _mesa_get_samplerobj(ctx, i);
format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
key->unit[i].enabled = 1;
@@ -444,7 +447,7 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
translate_tex_src_bit(texUnit->_ReallyEnabled);
key->unit[i].shadow =
- ((texObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
+ ((samp->CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
((format == GL_DEPTH_COMPONENT) ||
(format == GL_DEPTH_STENCIL_EXT)));
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index b9c98fb22..16ad2c430 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -284,11 +284,6 @@ static const int extra_GLSL_130[] = {
EXTRA_END
};
-static const int extra_ARB_sampler_objects[] = {
- EXT(ARB_sampler_objects),
- EXTRA_END
-};
-
static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
EXT(ARB_uniform_buffer_object),
EXT(ARB_geometry_shader4),
@@ -1304,7 +1299,7 @@ static const struct value_desc values[] = {
/* GL_ARB_sampler_objects / GL 3.3 */
{ GL_SAMPLER_BINDING,
- LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects },
+ LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA },
/* GL 3.0 */
{ GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 7d7213f4d..e8adac99d 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -1253,9 +1253,6 @@ struct gl_sampler_object
GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */
GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
-
- /* deprecated sampler state */
- GLenum DepthMode; /**< GL_ARB_depth_texture */
};
@@ -1272,6 +1269,8 @@ struct gl_texture_object
struct gl_sampler_object Sampler;
+ GLenum DepthMode; /**< GL_ARB_depth_texture */
+
GLfloat Priority; /**< in [0,1] */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
@@ -2966,7 +2965,6 @@ struct gl_extensions
GLboolean ARB_occlusion_query;
GLboolean ARB_occlusion_query2;
GLboolean ARB_point_sprite;
- GLboolean ARB_sampler_objects;
GLboolean ARB_seamless_cube_map;
GLboolean ARB_shader_bit_encoding;
GLboolean ARB_shader_objects;
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index 5d1b2adbb..dc8adfc3f 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -133,10 +133,8 @@ _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
sampObj->CompareFailValue = 0.0;
sampObj->sRGBDecode = GL_DECODE_EXT;
sampObj->CubeMapSeamless = GL_FALSE;
- sampObj->DepthMode = 0;
}
-
/**
* Fallback for ctx->Driver.NewSamplerObject();
*/
@@ -162,7 +160,7 @@ _mesa_delete_sampler_object(struct gl_context *ctx,
}
-static void GLAPIENTRY
+void GLAPIENTRY
_mesa_GenSamplers(GLsizei count, GLuint *samplers)
{
GET_CURRENT_CONTEXT(ctx);
@@ -194,7 +192,7 @@ _mesa_GenSamplers(GLsizei count, GLuint *samplers)
}
-static void GLAPIENTRY
+void GLAPIENTRY
_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers)
{
GET_CURRENT_CONTEXT(ctx);
@@ -244,7 +242,7 @@ _mesa_IsSampler(GLuint sampler)
}
-static void GLAPIENTRY
+void GLAPIENTRY
_mesa_BindSampler(GLuint unit, GLuint sampler)
{
struct gl_sampler_object *sampObj;
@@ -584,8 +582,25 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
return GL_TRUE;
}
+static GLuint
+set_sampler_srgb_decode(struct gl_context *ctx,
+ struct gl_sampler_object *samp, GLenum param)
+{
+ if (!ctx->Extensions.EXT_texture_sRGB_decode)
+ return INVALID_PNAME;
-static void GLAPIENTRY
+ if (samp->sRGBDecode == param)
+ return GL_FALSE;
+
+ if (param != GL_DECODE_EXT && param != GL_SKIP_DECODE_EXT)
+ return INVALID_VALUE;
+
+ flush(ctx);
+ samp->sRGBDecode = param;
+ return GL_TRUE;
+}
+
+void GLAPIENTRY
_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
{
struct gl_sampler_object *sampObj;
@@ -636,6 +651,9 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, param);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, param);
+ break;
case GL_TEXTURE_BORDER_COLOR:
/* fall-through */
default:
@@ -720,6 +738,9 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) param);
+ break;
case GL_TEXTURE_BORDER_COLOR:
/* fall-through */
default:
@@ -801,6 +822,9 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, params[0]);
+ break;
case GL_TEXTURE_BORDER_COLOR:
{
GLfloat c[4];
@@ -892,6 +916,9 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+ break;
case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colorf(ctx, sampObj, params);
break;
@@ -974,6 +1001,9 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+ break;
case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colori(ctx, sampObj, params);
break;
@@ -1057,6 +1087,9 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params)
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]);
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]);
+ break;
case GL_TEXTURE_BORDER_COLOR:
res = set_sampler_border_colorui(ctx, sampObj, params);
break;
@@ -1151,6 +1184,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
goto invalid_pname;
*params = sampObj->CubeMapSeamless;
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ if (!ctx->Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+ *params = (GLenum) sampObj->sRGBDecode;
+ break;
default:
goto invalid_pname;
}
@@ -1224,6 +1262,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
goto invalid_pname;
*params = (GLfloat) sampObj->CubeMapSeamless;
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ if (!ctx->Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+ *params = (GLfloat) sampObj->sRGBDecode;
+ break;
default:
goto invalid_pname;
}
@@ -1298,6 +1341,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
goto invalid_pname;
*params = sampObj->CubeMapSeamless;
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ if (!ctx->Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+ *params = (GLenum) sampObj->sRGBDecode;
+ break;
default:
goto invalid_pname;
}
@@ -1372,6 +1420,11 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
goto invalid_pname;
*params = sampObj->CubeMapSeamless;
break;
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ if (!ctx->Extensions.EXT_texture_sRGB_decode)
+ goto invalid_pname;
+ *params = (GLenum) sampObj->sRGBDecode;
+ break;
default:
goto invalid_pname;
}
diff --git a/mesalib/src/mesa/main/samplerobj.h b/mesalib/src/mesa/main/samplerobj.h
index 0bfda4351..2b0cd7946 100644
--- a/mesalib/src/mesa/main/samplerobj.h
+++ b/mesalib/src/mesa/main/samplerobj.h
@@ -77,5 +77,16 @@ _mesa_init_sampler_object_functions(struct dd_function_table *driver);
extern void
_mesa_init_sampler_object_dispatch(struct _glapi_table *disp);
+extern void GLAPIENTRY
+_mesa_BindSampler(GLuint unit, GLuint sampler);
+
+extern void GLAPIENTRY
+_mesa_GenSamplers(GLsizei count, GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers);
+
+extern void GLAPIENTRY
+_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param);
#endif /* SAMPLEROBJ_H */
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index e0494c940..529a6d449 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -145,7 +145,7 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
obj->Sampler.CompareMode = GL_NONE; /* ARB_shadow */
obj->Sampler.CompareFunc = GL_LEQUAL; /* ARB_shadow */
obj->Sampler.CompareFailValue = 0.0F; /* ARB_shadow_ambient */
- obj->Sampler.DepthMode = GL_LUMINANCE; /* ARB_depth_texture */
+ obj->DepthMode = GL_LUMINANCE;
obj->Sampler.CubeMapSeamless = GL_FALSE;
obj->Swizzle[0] = GL_RED;
obj->Swizzle[1] = GL_GREEN;
@@ -259,7 +259,7 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
dest->Sampler.CompareFunc = src->Sampler.CompareFunc;
dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue;
dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless;
- dest->Sampler.DepthMode = src->Sampler.DepthMode;
+ dest->DepthMode = src->DepthMode;
dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode;
dest->_MaxLevel = src->_MaxLevel;
dest->_MaxLambda = src->_MaxLambda;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 1376219d7..9213499a4 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -383,14 +383,14 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_DEPTH_TEXTURE_MODE_ARB:
if (ctx->Extensions.ARB_depth_texture) {
- if (texObj->Sampler.DepthMode == params[0])
+ if (texObj->DepthMode == params[0])
return GL_FALSE;
if (params[0] == GL_LUMINANCE ||
params[0] == GL_INTENSITY ||
params[0] == GL_ALPHA ||
(ctx->Extensions.ARB_texture_rg && params[0] == GL_RED)) {
flush(ctx);
- texObj->Sampler.DepthMode = params[0];
+ texObj->DepthMode = params[0];
return GL_TRUE;
}
goto invalid_param;
@@ -1157,7 +1157,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
case GL_DEPTH_TEXTURE_MODE_ARB:
if (!ctx->Extensions.ARB_depth_texture)
goto invalid_pname;
- *params = (GLfloat) obj->Sampler.DepthMode;
+ *params = (GLfloat) obj->DepthMode;
break;
case GL_TEXTURE_LOD_BIAS:
*params = obj->Sampler.LodBias;
@@ -1303,7 +1303,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
case GL_DEPTH_TEXTURE_MODE_ARB:
if (!ctx->Extensions.ARB_depth_texture)
goto invalid_pname;
- *params = (GLint) obj->Sampler.DepthMode;
+ *params = (GLint) obj->DepthMode;
break;
case GL_TEXTURE_LOD_BIAS:
*params = (GLint) obj->Sampler.LodBias;
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index 8ca9092ce..fa1fef27e 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -407,7 +407,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
- format = texObj->Sampler.DepthMode;
+ format = texObj->DepthMode;
}
calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
texUnit->_CurrentCombine = & texUnit->_EnvMode;
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 91ef2dff4..85e623142 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -170,12 +170,12 @@ compute_version(struct gl_context *ctx)
ctx->Extensions.ARB_explicit_attrib_location &&
ctx->Extensions.ARB_instanced_arrays &&
ctx->Extensions.ARB_occlusion_query2 &&
- ctx->Extensions.ARB_sampler_objects &&
ctx->Extensions.ARB_shader_bit_encoding &&
ctx->Extensions.ARB_texture_rgb10_a2ui &&
ctx->Extensions.ARB_timer_query &&
ctx->Extensions.ARB_vertex_type_2_10_10_10_rev &&
ctx->Extensions.EXT_texture_swizzle);
+ /* ARB_sampler_objects is always enabled in mesa */
if (ver_3_3) {
major = 3;
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index 3d1338674..91212218e 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -37,6 +37,7 @@
#include "main/fbobject.h"
#include "prog_statevars.h"
#include "prog_parameter.h"
+#include "main/samplerobj.h"
/**
@@ -555,11 +556,13 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
const int unit = (int) state[2];
const struct gl_texture_object *texObj
= ctx->Texture.Unit[unit]._Current;
+ const struct gl_sampler_object *samp =
+ _mesa_get_samplerobj(ctx, unit);
if (texObj) {
value[0] =
value[1] =
value[2] =
- value[3] = texObj->Sampler.CompareFailValue;
+ value[3] = samp->CompareFailValue;
}
}
return;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index f27a320a5..fefa59860 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -147,7 +147,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
struct pipe_sampler_view templ;
GLuint swizzle = apply_depthmode(stObj->pt->format,
stObj->base._Swizzle,
- samp->DepthMode);
+ stObj->base.DepthMode);
u_sampler_view_default_template(&templ,
stObj->pt,
@@ -240,7 +240,7 @@ update_single_texture(struct st_context *st,
if (stObj->sampler_view) {
if (check_sampler_swizzle(stObj->sampler_view,
stObj->base._Swizzle,
- samp->DepthMode) ||
+ stObj->base.DepthMode) ||
(st_view_format != stObj->sampler_view->format) ||
stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_blit.c b/mesalib/src/mesa/state_tracker/st_cb_blit.c
index b189cb406..1486779fd 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_blit.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_blit.c
@@ -80,8 +80,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
-
- info->dst.surface = dstRb->surface;
+ info->dst.res = dstRb->texture;
+ info->dst.level = dstRb->surface->u.tex.level;
+ info->dst.layer = dstRb->surface->u.tex.first_layer;
st->pipe->resource_resolve(st->pipe, info);
}
@@ -113,8 +114,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
-
- info->dst.surface = dstRb->surface;
+ info->dst.res = dstRb->texture;
+ info->dst.level = dstRb->surface->u.tex.level;
+ info->dst.layer = dstRb->surface->u.tex.first_layer;
st->pipe->resource_resolve(st->pipe, info);
}
@@ -128,8 +130,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx,
info->src.res = srcRb->texture;
info->src.layer = srcRb->surface->u.tex.first_layer;
-
- info->dst.surface = dstRb->surface;
+ info->dst.res = dstRb->texture;
+ info->dst.level = dstRb->surface->u.tex.level;
+ info->dst.layer = dstRb->surface->u.tex.first_layer;
st->pipe->resource_resolve(st->pipe, info);
}
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 5099acdb5..2f034cb28 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -487,7 +487,6 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
- ctx->Extensions.ARB_sampler_objects = GL_TRUE;
ctx->Extensions.ARB_shader_objects = GL_TRUE;
ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 90af1b009..4d99b17dd 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -680,7 +680,7 @@ compile_instruction(
{
struct ureg_program *ureg = t->ureg;
GLuint i;
- struct ureg_dst dst[1];
+ struct ureg_dst dst[1] = { { 0 } };
struct ureg_src src[4];
unsigned num_dst;
unsigned num_src;
diff --git a/mesalib/src/mesa/swrast/s_atifragshader.c b/mesalib/src/mesa/swrast/s_atifragshader.c
index 1eb026e00..394fac50b 100644
--- a/mesalib/src/mesa/swrast/s_atifragshader.c
+++ b/mesalib/src/mesa/swrast/s_atifragshader.c
@@ -23,6 +23,7 @@
#include "main/colormac.h"
#include "main/macros.h"
#include "main/atifragshader.h"
+#include "main/samplerobj.h"
#include "swrast/s_atifragshader.h"
#include "swrast/s_context.h"
@@ -49,8 +50,9 @@ fetch_texel(struct gl_context * ctx, const GLfloat texcoord[4], GLfloat lambda,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* 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, _mesa_get_samplerobj(ctx, unit),
+ ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat(*)[4]) texcoord,
&lambda, (GLfloat (*)[4]) color);
}
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 432db71c8..4ed7b94c7 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -480,9 +480,7 @@ _swrast_update_texture_samplers(struct gl_context *ctx)
/* Note: If tObj is NULL, the sample function will be a simple
* function that just returns opaque black (0,0,0,1).
*/
- if (tObj) {
- _mesa_update_fetch_functions(tObj);
- }
+ _mesa_update_fetch_functions(ctx, u);
swrast->TextureSample[u] =
_swrast_choose_texture_sample_func(ctx, tObj,
_mesa_get_samplerobj(ctx, u));
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index 26b97f78d..18353c416 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -52,6 +52,7 @@
typedef void (*texture_sample_func)(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4]);
diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c
index 8d59371c8..812189f09 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.c
+++ b/mesalib/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);
}
diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c
index 627ef1136..ef51479fd 100644
--- a/mesalib/src/mesa/swrast/s_span.c
+++ b/mesalib/src/mesa/swrast/s_span.c
@@ -38,6 +38,7 @@
#include "main/macros.h"
#include "main/imports.h"
#include "main/image.h"
+#include "main/samplerobj.h"
#include "s_atifragshader.h"
#include "s_alpha.h"
@@ -497,14 +498,15 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
const struct swrast_texture_image *swImg =
swrast_texture_image_const(img);
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, u);
- needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter)
+ needLambda = (samp->MinFilter != samp->MagFilter)
|| _swrast_use_fragment_program(ctx);
/* LOD is calculated directly in the ansiotropic filter, we can
* skip the normal lambda function as the result is ignored.
*/
- if (obj->Sampler.MaxAnisotropy > 1.0 &&
- obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+ if (samp->MaxAnisotropy > 1.0 &&
+ samp->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
needLambda = GL_FALSE;
}
texW = swImg->WidthScale;
diff --git a/mesalib/src/mesa/swrast/s_texcombine.c b/mesalib/src/mesa/swrast/s_texcombine.c
index 8fbf988b4..2a323613e 100644
--- a/mesalib/src/mesa/swrast/s_texcombine.c
+++ b/mesalib/src/mesa/swrast/s_texcombine.c
@@ -29,6 +29,7 @@
#include "main/colormac.h"
#include "main/imports.h"
#include "main/pixeltransfer.h"
+#include "main/samplerobj.h"
#include "program/prog_instruction.h"
#include "s_context.h"
@@ -652,7 +653,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
span->array->attribs[FRAG_ATTRIB_TEX0 +
ctx->Texture.Unit[unit].BumpTarget - GL_TEXTURE0];
- const struct gl_texture_object *curObj = texUnit->_Current;
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
GLfloat *lambda = span->array->lambda[unit];
float4_array texels = get_texel_array(swrast, unit);
GLuint i;
@@ -663,9 +664,9 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
/* adjust texture lod (lambda) */
if (span->arrayMask & SPAN_LAMBDA) {
- if (texUnit->LodBias + curObj->Sampler.LodBias != 0.0F) {
+ if (texUnit->LodBias + samp->LodBias != 0.0F) {
/* apply LOD bias, but don't clamp yet */
- const GLfloat bias = CLAMP(texUnit->LodBias + curObj->Sampler.LodBias,
+ const GLfloat bias = CLAMP(texUnit->LodBias + samp->LodBias,
-ctx->Const.MaxTextureLodBias,
ctx->Const.MaxTextureLodBias);
GLuint i;
@@ -674,11 +675,11 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
}
}
- if (curObj->Sampler.MinLod != -1000.0 ||
- curObj->Sampler.MaxLod != 1000.0) {
+ if (samp->MinLod != -1000.0 ||
+ samp->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
- const GLfloat min = curObj->Sampler.MinLod;
- const GLfloat max = curObj->Sampler.MaxLod;
+ const GLfloat min = samp->MinLod;
+ const GLfloat max = samp->MaxLod;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat l = lambda[i];
@@ -688,8 +689,9 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
}
/* Sample the texture (span->end = number of fragments) */
- swrast->TextureSample[unit]( ctx, texUnit->_Current, span->end,
- texcoords, lambda, texels );
+ swrast->TextureSample[unit]( ctx, samp,
+ ctx->Texture.Unit[unit]._Current,
+ span->end, texcoords, lambda, texels );
/* manipulate the span values of the bump target
not sure this can work correctly even ignoring
@@ -714,14 +716,15 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
const GLfloat (*texcoords)[4] = (const GLfloat (*)[4])
span->array->attribs[FRAG_ATTRIB_TEX0 + unit];
const struct gl_texture_object *curObj = texUnit->_Current;
+ const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
GLfloat *lambda = span->array->lambda[unit];
float4_array texels = get_texel_array(swrast, unit);
/* adjust texture lod (lambda) */
if (span->arrayMask & SPAN_LAMBDA) {
- if (texUnit->LodBias + curObj->Sampler.LodBias != 0.0F) {
+ if (texUnit->LodBias + samp->LodBias != 0.0F) {
/* apply LOD bias, but don't clamp yet */
- const GLfloat bias = CLAMP(texUnit->LodBias + curObj->Sampler.LodBias,
+ const GLfloat bias = CLAMP(texUnit->LodBias + samp->LodBias,
-ctx->Const.MaxTextureLodBias,
ctx->Const.MaxTextureLodBias);
GLuint i;
@@ -730,11 +733,11 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
}
}
- if (curObj->Sampler.MinLod != -1000.0 ||
- curObj->Sampler.MaxLod != 1000.0) {
+ if (samp->MinLod != -1000.0 ||
+ samp->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
- const GLfloat min = curObj->Sampler.MinLod;
- const GLfloat max = curObj->Sampler.MaxLod;
+ const GLfloat min = samp->MinLod;
+ const GLfloat max = samp->MaxLod;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat l = lambda[i];
@@ -742,8 +745,8 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
}
}
}
- else if (curObj->Sampler.MaxAnisotropy > 1.0 &&
- curObj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+ else if (samp->MaxAnisotropy > 1.0 &&
+ samp->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
/* sample_lambda_2d_aniso is beeing used as texture_sample_func,
* it requires the current SWspan *span as an additional parameter.
* In order to keep the same function signature, the unused lambda
@@ -756,8 +759,9 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
}
/* Sample the texture (span->end = number of fragments) */
- swrast->TextureSample[unit]( ctx, texUnit->_Current, span->end,
- texcoords, lambda, texels );
+ swrast->TextureSample[unit]( ctx, samp,
+ ctx->Texture.Unit[unit]._Current,
+ span->end, texcoords, lambda, texels );
/* GL_EXT_texture_swizzle */
if (curObj->_Swizzle != SWIZZLE_NOOP) {
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 12ee47963..db7c887b6 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -41,6 +41,7 @@
#include "main/texcompress_rgtc.h"
#include "main/texcompress_etc.h"
#include "main/teximage.h"
+#include "main/samplerobj.h"
#include "s_context.h"
#include "s_texfetch.h"
#include "../../gallium/auxiliary/util/u_format_rgb9e5.h"
@@ -1147,13 +1148,14 @@ _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
* Initialize the texture image's FetchTexel methods.
*/
static void
-set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
+set_fetch_functions(struct gl_sampler_object *samp,
+ struct swrast_texture_image *texImage, GLuint dims)
{
gl_format format = texImage->Base.TexFormat;
ASSERT(dims == 1 || dims == 2 || dims == 3);
- if (texImage->Base.TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
+ if (samp->sRGBDecode == GL_SKIP_DECODE_EXT &&
_mesa_get_format_color_encoding(format) == GL_SRGB) {
format = _mesa_get_srgb_format_linear(format);
}
@@ -1163,17 +1165,25 @@ set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
}
void
-_mesa_update_fetch_functions(struct gl_texture_object *texObj)
+_mesa_update_fetch_functions(struct gl_context *ctx, GLuint unit)
{
+ struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ struct gl_sampler_object *samp;
GLuint face, i;
GLuint dims;
+ if (!texObj)
+ return;
+
+ samp = _mesa_get_samplerobj(ctx, unit);
+
dims = _mesa_get_texture_dimensions(texObj->Target);
for (face = 0; face < 6; face++) {
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
if (texObj->Image[face][i]) {
- set_fetch_functions(swrast_texture_image(texObj->Image[face][i]),
+ set_fetch_functions(samp,
+ swrast_texture_image(texObj->Image[face][i]),
dims);
}
}
diff --git a/mesalib/src/mesa/swrast/s_texfetch.h b/mesalib/src/mesa/swrast/s_texfetch.h
index 1aa7ce573..33950ce44 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.h
+++ b/mesalib/src/mesa/swrast/s_texfetch.h
@@ -33,6 +33,6 @@ extern FetchTexelFunc
_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
void
-_mesa_update_fetch_functions(struct gl_texture_object *texObj);
+_mesa_update_fetch_functions(struct gl_context *ctx, GLuint unit);
#endif /* S_TEXFETCH_H */
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index 412316f36..51c899208 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -28,6 +28,7 @@
#include "main/colormac.h"
#include "main/imports.h"
#include "main/texobj.h"
+#include "main/samplerobj.h"
#include "s_context.h"
#include "s_texfilter.h"
@@ -498,7 +499,8 @@ tex_array_slice(GLfloat coord, GLsizei size)
* NOTE: only used for depth texture sampling.
*/
static inline void
-nearest_texcoord(const struct gl_texture_object *texObj,
+nearest_texcoord(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *texObj,
GLuint level,
const GLfloat texcoord[4],
GLint *i, GLint *j, GLint *k)
@@ -510,28 +512,28 @@ nearest_texcoord(const struct gl_texture_object *texObj,
switch (texObj->Target) {
case GL_TEXTURE_RECTANGLE_ARB:
- *i = clamp_rect_coord_nearest(texObj->Sampler.WrapS, texcoord[0], width);
- *j = clamp_rect_coord_nearest(texObj->Sampler.WrapT, texcoord[1], height);
+ *i = clamp_rect_coord_nearest(samp->WrapS, texcoord[0], width);
+ *j = clamp_rect_coord_nearest(samp->WrapT, texcoord[1], height);
*k = 0;
break;
case GL_TEXTURE_1D:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
*j = 0;
*k = 0;
break;
case GL_TEXTURE_2D:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
- *j = nearest_texel_location(texObj->Sampler.WrapT, img, height, texcoord[1]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ *j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
*k = 0;
break;
case GL_TEXTURE_1D_ARRAY_EXT:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
*j = tex_array_slice(texcoord[1], height);
*k = 0;
break;
case GL_TEXTURE_2D_ARRAY_EXT:
- *i = nearest_texel_location(texObj->Sampler.WrapS, img, width, texcoord[0]);
- *j = nearest_texel_location(texObj->Sampler.WrapT, img, height, texcoord[1]);
+ *i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ *j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
*k = tex_array_slice(texcoord[2], depth);
break;
default:
@@ -546,7 +548,8 @@ nearest_texcoord(const struct gl_texture_object *texObj,
* NOTE: only used for depth texture sampling.
*/
static inline void
-linear_texcoord(const struct gl_texture_object *texObj,
+linear_texcoord(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *texObj,
GLuint level,
const GLfloat texcoord[4],
GLint *i0, GLint *i1, GLint *j0, GLint *j1, GLint *slice,
@@ -559,24 +562,24 @@ linear_texcoord(const struct gl_texture_object *texObj,
switch (texObj->Target) {
case GL_TEXTURE_RECTANGLE_ARB:
- clamp_rect_coord_linear(texObj->Sampler.WrapS, texcoord[0],
+ clamp_rect_coord_linear(samp->WrapS, texcoord[0],
width, i0, i1, wi);
- clamp_rect_coord_linear(texObj->Sampler.WrapT, texcoord[1],
+ clamp_rect_coord_linear(samp->WrapT, texcoord[1],
height, j0, j1, wj);
*slice = 0;
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
- linear_texel_locations(texObj->Sampler.WrapT, img, height,
+ linear_texel_locations(samp->WrapT, img, height,
texcoord[1], j0, j1, wj);
*slice = 0;
break;
case GL_TEXTURE_1D_ARRAY_EXT:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
*j0 = tex_array_slice(texcoord[1], height);
*j1 = *j0;
@@ -584,9 +587,9 @@ linear_texcoord(const struct gl_texture_object *texObj,
break;
case GL_TEXTURE_2D_ARRAY_EXT:
- linear_texel_locations(texObj->Sampler.WrapS, img, width,
+ linear_texel_locations(samp->WrapS, img, width,
texcoord[0], i0, i1, wi);
- linear_texel_locations(texObj->Sampler.WrapT, img, height,
+ linear_texel_locations(samp->WrapT, img, height,
texcoord[1], j0, j1, wj);
*slice = tex_array_slice(texcoord[2], depth);
break;
@@ -655,7 +658,7 @@ nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
* determines the subranges in [0, n-1] that are to be minified or magnified.
*/
static inline void
-compute_min_mag_ranges(const struct gl_texture_object *tObj,
+compute_min_mag_ranges(const struct gl_sampler_object *samp,
GLuint n, const GLfloat lambda[],
GLuint *minStart, GLuint *minEnd,
GLuint *magStart, GLuint *magEnd)
@@ -663,12 +666,12 @@ compute_min_mag_ranges(const struct gl_texture_object *tObj,
GLfloat minMagThresh;
/* we shouldn't be here if minfilter == magfilter */
- ASSERT(tObj->Sampler.MinFilter != tObj->Sampler.MagFilter);
+ ASSERT(samp->MinFilter != samp->MagFilter);
/* This bit comes from the OpenGL spec: */
- if (tObj->Sampler.MagFilter == GL_LINEAR
- && (tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
- tObj->Sampler.MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
+ if (samp->MagFilter == GL_LINEAR
+ && (samp->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
+ samp->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
minMagThresh = 0.5F;
}
else {
@@ -764,34 +767,34 @@ compute_min_mag_ranges(const struct gl_texture_object *tObj,
* we return (0,0,0,BorderAlpha).
*/
static inline void
-get_border_color(const struct gl_texture_object *tObj,
+get_border_color(const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
GLfloat rgba[4])
{
switch (img->_BaseFormat) {
case GL_RGB:
- rgba[0] = tObj->Sampler.BorderColor.f[0];
- rgba[1] = tObj->Sampler.BorderColor.f[1];
- rgba[2] = tObj->Sampler.BorderColor.f[2];
+ rgba[0] = samp->BorderColor.f[0];
+ rgba[1] = samp->BorderColor.f[1];
+ rgba[2] = samp->BorderColor.f[2];
rgba[3] = 1.0F;
break;
case GL_ALPHA:
rgba[0] = rgba[1] = rgba[2] = 0.0;
- rgba[3] = tObj->Sampler.BorderColor.f[3];
+ rgba[3] = samp->BorderColor.f[3];
break;
case GL_LUMINANCE:
- rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0];
+ rgba[0] = rgba[1] = rgba[2] = samp->BorderColor.f[0];
rgba[3] = 1.0;
break;
case GL_LUMINANCE_ALPHA:
- rgba[0] = rgba[1] = rgba[2] = tObj->Sampler.BorderColor.f[0];
- rgba[3] = tObj->Sampler.BorderColor.f[3];
+ rgba[0] = rgba[1] = rgba[2] = samp->BorderColor.f[0];
+ rgba[3] = samp->BorderColor.f[3];
break;
case GL_INTENSITY:
- rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->Sampler.BorderColor.f[0];
+ rgba[0] = rgba[1] = rgba[2] = rgba[3] = samp->BorderColor.f[0];
break;
default:
- COPY_4V(rgba, tObj->Sampler.BorderColor.f);
+ COPY_4V(rgba, samp->BorderColor.f);
break;
}
}
@@ -806,19 +809,19 @@ get_border_color(const struct gl_texture_object *tObj,
*/
static inline void
sample_1d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width2; /* without border, power of two */
GLint i;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
/* skip over the border, if any */
i += img->Border;
if (i < 0 || i >= (GLint) img->Width) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, 0, 0, rgba);
@@ -831,7 +834,7 @@ sample_1d_nearest(struct gl_context *ctx,
*/
static inline void
sample_1d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4], GLfloat rgba[4])
{
@@ -842,7 +845,7 @@ sample_1d_linear(struct gl_context *ctx,
GLfloat a;
GLfloat t0[4], t1[4]; /* texels */
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
if (img->Border) {
i0 += img->Border;
@@ -855,13 +858,13 @@ sample_1d_linear(struct gl_context *ctx,
/* fetch texel colors */
if (useBorderColor & I0BIT) {
- get_border_color(tObj, img, t0);
+ get_border_color(samp, img, t0);
}
else {
swImg->FetchTexel(swImg, i0, 0, 0, t0);
}
if (useBorderColor & I1BIT) {
- get_border_color(tObj, img, t1);
+ get_border_color(samp, img, t1);
}
else {
swImg->FetchTexel(swImg, i1, 0, 0, t1);
@@ -873,6 +876,7 @@ sample_1d_linear(struct gl_context *ctx,
static void
sample_1d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -881,13 +885,14 @@ sample_1d_nearest_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_1d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -896,13 +901,14 @@ sample_1d_linear_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_1d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -912,14 +918,14 @@ sample_1d_nearest_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -928,6 +934,7 @@ sample_1d_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_1d_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -937,14 +944,14 @@ sample_1d_linear_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -954,6 +961,7 @@ sample_1d_linear_mipmap_linear(struct gl_context *ctx,
/** Sample 1D texture, nearest filtering for both min/magnification */
static void
sample_nearest_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4] )
@@ -962,7 +970,7 @@ sample_nearest_1d( struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -970,6 +978,7 @@ sample_nearest_1d( struct gl_context *ctx,
/** Sample 1D texture, linear filtering for both min/magnification */
static void
sample_linear_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4] )
@@ -978,7 +987,7 @@ sample_linear_1d( struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -986,6 +995,7 @@ sample_linear_1d( struct gl_context *ctx,
/** Sample 1D texture, using lambda to choose between min/magnification */
static void
sample_lambda_1d( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
@@ -995,37 +1005,37 @@ sample_lambda_1d( struct gl_context *ctx,
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_1d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_1d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_1d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_1d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
@@ -1036,15 +1046,15 @@ sample_lambda_1d( struct gl_context *ctx,
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
@@ -1065,7 +1075,7 @@ sample_lambda_1d( struct gl_context *ctx,
*/
static inline void
sample_2d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
@@ -1076,8 +1086,8 @@ sample_2d_nearest(struct gl_context *ctx,
GLint i, j;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
/* skip over the border, if any */
i += img->Border;
@@ -1085,7 +1095,7 @@ sample_2d_nearest(struct gl_context *ctx,
if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, 0, rgba);
@@ -1099,7 +1109,7 @@ sample_2d_nearest(struct gl_context *ctx,
*/
static inline void
sample_2d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
@@ -1112,8 +1122,8 @@ sample_2d_linear(struct gl_context *ctx,
GLfloat a, b;
GLfloat t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
if (img->Border) {
i0 += img->Border;
@@ -1130,25 +1140,25 @@ sample_2d_linear(struct gl_context *ctx,
/* fetch four texel colors */
if (useBorderColor & (I0BIT | J0BIT)) {
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
}
else {
swImg->FetchTexel(swImg, i0, j0, 0, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
}
else {
swImg->FetchTexel(swImg, i1, j0, 0, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
}
else {
swImg->FetchTexel(swImg, i0, j1, 0, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
}
else {
swImg->FetchTexel(swImg, i1, j1, 0, t11);
@@ -1164,7 +1174,7 @@ sample_2d_linear(struct gl_context *ctx,
*/
static inline void
sample_2d_linear_repeat(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[])
@@ -1178,8 +1188,8 @@ sample_2d_linear_repeat(struct gl_context *ctx,
(void) ctx;
- ASSERT(tObj->Sampler.WrapS == GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT == GL_REPEAT);
+ ASSERT(samp->WrapS == GL_REPEAT);
+ ASSERT(samp->WrapT == GL_REPEAT);
ASSERT(img->Border == 0);
ASSERT(swImg->_IsPowerOfTwo);
@@ -1197,6 +1207,7 @@ sample_2d_linear_repeat(struct gl_context *ctx,
static void
sample_2d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1204,13 +1215,14 @@ sample_2d_nearest_mipmap_nearest(struct gl_context *ctx,
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_2d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1219,13 +1231,14 @@ sample_2d_linear_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_2d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1235,14 +1248,14 @@ sample_2d_nearest_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_2d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -1251,6 +1264,7 @@ sample_2d_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_2d_linear_mipmap_linear( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
@@ -1260,14 +1274,14 @@ sample_2d_linear_mipmap_linear( struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_2d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -1276,26 +1290,27 @@ sample_2d_linear_mipmap_linear( struct gl_context *ctx,
static void
sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
ASSERT(lambda != NULL);
- ASSERT(tObj->Sampler.WrapS == GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT == GL_REPEAT);
+ ASSERT(samp->WrapS == GL_REPEAT);
+ ASSERT(samp->WrapT == GL_REPEAT);
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_linear_repeat(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
@@ -1306,6 +1321,7 @@ sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx,
/** Sample 2D texture, nearest filtering for both min/magnification */
static void
sample_nearest_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1314,7 +1330,7 @@ sample_nearest_2d(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -1322,6 +1338,7 @@ sample_nearest_2d(struct gl_context *ctx,
/** Sample 2D texture, linear filtering for both min/magnification */
static void
sample_linear_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1330,17 +1347,17 @@ sample_linear_2d(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
const struct swrast_texture_image *swImg = swrast_texture_image_const(image);
(void) lambda;
- if (tObj->Sampler.WrapS == GL_REPEAT &&
- tObj->Sampler.WrapT == GL_REPEAT &&
+ if (samp->WrapS == GL_REPEAT &&
+ samp->WrapT == GL_REPEAT &&
swImg->_IsPowerOfTwo &&
image->Border == 0) {
for (i = 0; i < n; i++) {
- sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_linear_repeat(ctx, samp, image, texcoords[i], rgba[i]);
}
}
else {
for (i = 0; i < n; i++) {
- sample_2d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
}
@@ -1356,6 +1373,7 @@ sample_linear_2d(struct gl_context *ctx,
*/
static void
opt_sample_rgb_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1370,8 +1388,8 @@ opt_sample_rgb_2d(struct gl_context *ctx,
GLuint k;
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS==GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
+ ASSERT(samp->WrapS==GL_REPEAT);
+ ASSERT(samp->WrapT==GL_REPEAT);
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
ASSERT(swImg->_IsPowerOfTwo);
@@ -1400,6 +1418,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
*/
static void
opt_sample_rgba_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1414,8 +1433,8 @@ opt_sample_rgba_2d(struct gl_context *ctx,
GLuint i;
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS==GL_REPEAT);
- ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
+ ASSERT(samp->WrapS==GL_REPEAT);
+ ASSERT(samp->WrapT==GL_REPEAT);
ASSERT(img->Border==0);
ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
ASSERT(swImg->_IsPowerOfTwo);
@@ -1437,6 +1456,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
/** Sample 2D texture, using lambda to choose between min/magnification */
static void
sample_lambda_2d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -1446,63 +1466,63 @@ sample_lambda_2d(struct gl_context *ctx,
GLuint minStart, minEnd; /* texels with minification */
GLuint magStart, magEnd; /* texels with magnification */
- const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT)
- && (tObj->Sampler.WrapT == GL_REPEAT)
+ const GLboolean repeatNoBorderPOT = (samp->WrapS == GL_REPEAT)
+ && (samp->WrapT == GL_REPEAT)
&& (tImg->Border == 0 && (tImg->Width == swImg->RowStride))
&& swImg->_IsPowerOfTwo;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
case MESA_FORMAT_RGB888:
- opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,
+ opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case MESA_FORMAT_RGBA8888:
- opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,
+ opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
default:
- sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart );
}
}
else {
- sample_nearest_2d(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, tObj, m, texcoords + minStart,
+ sample_linear_2d(ctx, samp, tObj, m, texcoords + minStart,
NULL, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_2d_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_2d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_2d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_2d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_2d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
if (repeatNoBorderPOT)
- sample_2d_linear_mipmap_linear_repeat(ctx, tObj, m,
+ sample_2d_linear_mipmap_linear_repeat(ctx, samp, tObj, m,
texcoords + minStart, lambda + minStart, rgba + minStart);
else
- sample_2d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_2d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
@@ -1515,30 +1535,30 @@ sample_lambda_2d(struct gl_context *ctx,
/* do the magnified texels */
const GLuint m = magEnd - magStart;
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
if (repeatNoBorderPOT) {
switch (tImg->TexFormat) {
case MESA_FORMAT_RGB888:
- opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,
+ opt_sample_rgb_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
case MESA_FORMAT_RGBA8888:
- opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,
+ opt_sample_rgba_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
- sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart );
}
}
else {
- sample_nearest_2d(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
}
break;
case GL_LINEAR:
- sample_linear_2d(ctx, tObj, m, texcoords + magStart,
+ sample_linear_2d(ctx, samp, tObj, m, texcoords + magStart,
NULL, rgba + magStart);
break;
default:
@@ -1583,6 +1603,7 @@ create_filter_table(void)
*/
static void
sample_2d_ewa(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
const GLfloat texcoord[4],
const GLfloat dudx, const GLfloat dvdx,
@@ -1664,7 +1685,7 @@ sample_2d_ewa(struct gl_context *ctx,
newCoord[0] = u / ((GLfloat) img->Width2);
newCoord[1] = v / ((GLfloat) img->Height2);
- sample_2d_nearest(ctx, tObj, img, newCoord, rgba);
+ sample_2d_nearest(ctx, samp, img, newCoord, rgba);
num[0] += weight * rgba[0];
num[1] += weight * rgba[1];
num[2] += weight * rgba[2];
@@ -1690,7 +1711,7 @@ sample_2d_ewa(struct gl_context *ctx,
rgba[2]=0;
rgba[3]=0;*/
/* not enough pixels in resampling, resort to direct interpolation */
- sample_2d_linear(ctx, tObj, img, texcoord, rgba);
+ sample_2d_linear(ctx, samp, img, texcoord, rgba);
return;
}
@@ -1709,6 +1730,7 @@ sample_2d_ewa(struct gl_context *ctx,
*/
static void
sample_2d_footprint(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
const GLfloat texcoord[4],
const GLfloat dudx, const GLfloat dvdx,
@@ -1751,7 +1773,7 @@ sample_2d_footprint(struct gl_context *ctx,
newCoord[0] = texcoord[0] + ds * ((GLfloat)(s+1) / (numSamples+1) -0.5);
newCoord[1] = texcoord[1] + dt * ((GLfloat)(s+1) / (numSamples+1) -0.5);
- sample_2d_linear(ctx, tObj, img, newCoord, rgba);
+ sample_2d_linear(ctx, samp, img, newCoord, rgba);
num[0] += rgba[0];
num[1] += rgba[1];
num[2] += rgba[2];
@@ -1799,6 +1821,7 @@ texture_unit_index(const struct gl_context *ctx,
*/
static void
sample_lambda_2d_aniso(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda_iso[], GLfloat rgba[][4])
@@ -1806,7 +1829,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
const GLfloat maxEccentricity =
- tObj->Sampler.MaxAnisotropy * tObj->Sampler.MaxAnisotropy;
+ samp->MaxAnisotropy * samp->MaxAnisotropy;
/* re-calculate the lambda values so that they are usable with anisotropic
* filtering
@@ -1837,8 +1860,8 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
/* from swrast/s_texcombine.c _swrast_texture_span */
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
const GLboolean adjustLOD =
- (texUnit->LodBias + tObj->Sampler.LodBias != 0.0F)
- || (tObj->Sampler.MinLod != -1000.0 || tObj->Sampler.MaxLod != 1000.0);
+ (texUnit->LodBias + samp->LodBias != 0.0F)
+ || (samp->MinLod != -1000.0 || samp->MaxLod != 1000.0);
GLuint i;
@@ -1901,18 +1924,18 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
if (adjustLOD) {
/* from swrast/s_texcombine.c _swrast_texture_span */
- if (texUnit->LodBias + tObj->Sampler.LodBias != 0.0F) {
+ if (texUnit->LodBias + samp->LodBias != 0.0F) {
/* apply LOD bias, but don't clamp yet */
const GLfloat bias =
- CLAMP(texUnit->LodBias + tObj->Sampler.LodBias,
+ CLAMP(texUnit->LodBias + samp->LodBias,
-ctx->Const.MaxTextureLodBias,
ctx->Const.MaxTextureLodBias);
lod += bias;
- if (tObj->Sampler.MinLod != -1000.0 ||
- tObj->Sampler.MaxLod != 1000.0) {
+ if (samp->MinLod != -1000.0 ||
+ samp->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
- lod = CLAMP(lod, tObj->Sampler.MinLod, tObj->Sampler.MaxLod);
+ lod = CLAMP(lod, samp->MinLod, samp->MaxLod);
}
}
}
@@ -1921,14 +1944,14 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
* simply return the average of the whole image.
*/
if (lod >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoords[i], rgba[i]);
}
else {
/* don't bother interpolating between multiple LODs; it doesn't
* seem to be worth the extra running time.
*/
- sample_2d_ewa(ctx, tObj, texcoords[i],
+ sample_2d_ewa(ctx, samp, tObj, texcoords[i],
dudx, dvdx, dudy, dvdy, floor(lod), rgba[i]);
/* unused: */
@@ -1952,7 +1975,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
*/
static inline void
sample_3d_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -1964,15 +1987,15 @@ sample_3d_nearest(struct gl_context *ctx,
GLint i, j, k;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
- k = nearest_texel_location(tObj->Sampler.WrapR, img, depth, texcoord[2]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
+ k = nearest_texel_location(samp->WrapR, img, depth, texcoord[2]);
if (i < 0 || i >= (GLint) img->Width ||
j < 0 || j >= (GLint) img->Height ||
k < 0 || k >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, k, rgba);
@@ -1985,7 +2008,7 @@ sample_3d_nearest(struct gl_context *ctx,
*/
static void
sample_3d_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -2000,9 +2023,9 @@ sample_3d_linear(struct gl_context *ctx,
GLfloat t000[4], t010[4], t001[4], t011[4];
GLfloat t100[4], t110[4], t101[4], t111[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
- linear_texel_locations(tObj->Sampler.WrapR, img, depth, texcoord[2], &k0, &k1, &c);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapR, img, depth, texcoord[2], &k0, &k1, &c);
if (img->Border) {
i0 += img->Border;
@@ -2024,50 +2047,50 @@ sample_3d_linear(struct gl_context *ctx,
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
- get_border_color(tObj, img, t000);
+ get_border_color(samp, img, t000);
}
else {
swImg->FetchTexel(swImg, i0, j0, k0, t000);
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
- get_border_color(tObj, img, t100);
+ get_border_color(samp, img, t100);
}
else {
swImg->FetchTexel(swImg, i1, j0, k0, t100);
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
- get_border_color(tObj, img, t010);
+ get_border_color(samp, img, t010);
}
else {
swImg->FetchTexel(swImg, i0, j1, k0, t010);
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
- get_border_color(tObj, img, t110);
+ get_border_color(samp, img, t110);
}
else {
swImg->FetchTexel(swImg, i1, j1, k0, t110);
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
- get_border_color(tObj, img, t001);
+ get_border_color(samp, img, t001);
}
else {
swImg->FetchTexel(swImg, i0, j0, k1, t001);
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
- get_border_color(tObj, img, t101);
+ get_border_color(samp, img, t101);
}
else {
swImg->FetchTexel(swImg, i1, j0, k1, t101);
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
- get_border_color(tObj, img, t011);
+ get_border_color(samp, img, t011);
}
else {
swImg->FetchTexel(swImg, i0, j1, k1, t011);
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
- get_border_color(tObj, img, t111);
+ get_border_color(samp, img, t111);
}
else {
swImg->FetchTexel(swImg, i1, j1, k1, t111);
@@ -2080,6 +2103,7 @@ sample_3d_linear(struct gl_context *ctx,
static void
sample_3d_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4] )
@@ -2087,13 +2111,14 @@ sample_3d_nearest_mipmap_nearest(struct gl_context *ctx,
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_3d_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2102,13 +2127,14 @@ sample_3d_linear_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
static void
sample_3d_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2118,14 +2144,14 @@ sample_3d_nearest_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_3d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -2134,6 +2160,7 @@ sample_3d_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_3d_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2143,14 +2170,14 @@ sample_3d_linear_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_3d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -2160,6 +2187,7 @@ sample_3d_linear_mipmap_linear(struct gl_context *ctx,
/** Sample 3D texture, nearest filtering for both min/magnification */
static void
sample_nearest_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2168,7 +2196,7 @@ sample_nearest_3d(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_3d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_3d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -2176,6 +2204,7 @@ sample_nearest_3d(struct gl_context *ctx,
/** Sample 3D texture, linear filtering for both min/magnification */
static void
sample_linear_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2184,7 +2213,7 @@ sample_linear_3d(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_3d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_3d_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -2192,6 +2221,7 @@ sample_linear_3d(struct gl_context *ctx,
/** Sample 3D texture, using lambda to choose between min/magnification */
static void
sample_lambda_3d(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2201,37 +2231,37 @@ sample_lambda_3d(struct gl_context *ctx,
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_3d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_3d_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_3d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_3d_linear_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_3d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_3d_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_3d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_3d_linear_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
@@ -2242,15 +2272,15 @@ sample_lambda_3d(struct gl_context *ctx,
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
@@ -2347,6 +2377,7 @@ choose_cube_face(const struct gl_texture_object *texObj,
static void
sample_nearest_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2357,7 +2388,7 @@ sample_nearest_cube(struct gl_context *ctx,
const struct gl_texture_image **images;
GLfloat newCoord[4];
images = choose_cube_face(tObj, texcoords[i], newCoord);
- sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel],
+ sample_2d_nearest(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
}
@@ -2365,6 +2396,7 @@ sample_nearest_cube(struct gl_context *ctx,
static void
sample_linear_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2375,7 +2407,7 @@ sample_linear_cube(struct gl_context *ctx,
const struct gl_texture_image **images;
GLfloat newCoord[4];
images = choose_cube_face(tObj, texcoords[i], newCoord);
- sample_2d_linear(ctx, tObj, images[tObj->BaseLevel],
+ sample_2d_linear(ctx, samp, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
}
@@ -2383,6 +2415,7 @@ sample_linear_cube(struct gl_context *ctx,
static void
sample_cube_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2405,13 +2438,14 @@ sample_cube_nearest_mipmap_nearest(struct gl_context *ctx,
level = nearest_mipmap_level(tObj, lambda[i]);
level = MAX2(level - 1, 0);
- sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
+ sample_2d_nearest(ctx, samp, images[level], newCoord, rgba[i]);
}
}
static void
sample_cube_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2424,13 +2458,14 @@ sample_cube_linear_mipmap_nearest(struct gl_context *ctx,
GLint level = nearest_mipmap_level(tObj, lambda[i]);
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
- sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
+ sample_2d_linear(ctx, samp, images[level], newCoord, rgba[i]);
}
}
static void
sample_cube_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2444,14 +2479,14 @@ sample_cube_nearest_mipmap_linear(struct gl_context *ctx,
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
- sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
+ sample_2d_nearest(ctx, samp, images[tObj->_MaxLevel],
newCoord, rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_nearest(ctx, tObj, images[level ], newCoord, t0);
- sample_2d_nearest(ctx, tObj, images[level+1], newCoord, t1);
+ sample_2d_nearest(ctx, samp, images[level ], newCoord, t0);
+ sample_2d_nearest(ctx, samp, images[level+1], newCoord, t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -2460,6 +2495,7 @@ sample_cube_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_cube_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2473,14 +2509,14 @@ sample_cube_linear_mipmap_linear(struct gl_context *ctx,
level = MAX2(level - 1, 0); /* see comment above */
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
- sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],
+ sample_2d_linear(ctx, samp, images[tObj->_MaxLevel],
newCoord, rgba[i]);
}
else {
GLfloat t0[4], t1[4];
const GLfloat f = FRAC(lambda[i]);
- sample_2d_linear(ctx, tObj, images[level ], newCoord, t0);
- sample_2d_linear(ctx, tObj, images[level+1], newCoord, t1);
+ sample_2d_linear(ctx, samp, images[level ], newCoord, t0);
+ sample_2d_linear(ctx, samp, images[level+1], newCoord, t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -2490,6 +2526,7 @@ sample_cube_linear_mipmap_linear(struct gl_context *ctx,
/** Sample cube texture, using lambda to choose between min/magnification */
static void
sample_lambda_cube(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2498,38 +2535,38 @@ sample_lambda_cube(struct gl_context *ctx,
GLuint magStart, magEnd; /* texels with magnification */
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
const GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, tObj, m, texcoords + minStart,
+ sample_nearest_cube(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, tObj, m, texcoords + minStart,
+ sample_linear_cube(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_cube_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_cube_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_cube_linear_mipmap_nearest(ctx, tObj, m,
+ sample_cube_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_cube_nearest_mipmap_linear(ctx, tObj, m,
+ sample_cube_nearest_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_cube_linear_mipmap_linear(ctx, tObj, m,
+ sample_cube_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
@@ -2542,13 +2579,13 @@ sample_lambda_cube(struct gl_context *ctx,
if (magStart < magEnd) {
/* do the magnified texels */
const GLuint m = magEnd - magStart;
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
- sample_nearest_cube(ctx, tObj, m, texcoords + magStart,
+ sample_nearest_cube(ctx, samp, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
case GL_LINEAR:
- sample_linear_cube(ctx, tObj, m, texcoords + magStart,
+ sample_linear_cube(ctx, samp, tObj, m, texcoords + magStart,
lambda + magStart, rgba + magStart);
break;
default:
@@ -2566,6 +2603,7 @@ sample_lambda_cube(struct gl_context *ctx,
static void
sample_nearest_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2579,19 +2617,19 @@ sample_nearest_rect(struct gl_context *ctx,
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS == GL_CLAMP ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(tObj->Sampler.WrapT == GL_CLAMP ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapS == GL_CLAMP ||
+ samp->WrapS == GL_CLAMP_TO_EDGE ||
+ samp->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapT == GL_CLAMP ||
+ samp->WrapT == GL_CLAMP_TO_EDGE ||
+ samp->WrapT == GL_CLAMP_TO_BORDER);
for (i = 0; i < n; i++) {
GLint row, col;
- col = clamp_rect_coord_nearest(tObj->Sampler.WrapS, texcoords[i][0], width);
- row = clamp_rect_coord_nearest(tObj->Sampler.WrapT, texcoords[i][1], height);
+ col = clamp_rect_coord_nearest(samp->WrapS, texcoords[i][0], width);
+ row = clamp_rect_coord_nearest(samp->WrapT, texcoords[i][1], height);
if (col < 0 || col >= width || row < 0 || row >= height)
- get_border_color(tObj, img, rgba[i]);
+ get_border_color(samp, img, rgba[i]);
else
swImg->FetchTexel(swImg, col, row, 0, rgba[i]);
}
@@ -2600,6 +2638,7 @@ sample_nearest_rect(struct gl_context *ctx,
static void
sample_linear_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2613,12 +2652,12 @@ sample_linear_rect(struct gl_context *ctx,
(void) ctx;
(void) lambda;
- ASSERT(tObj->Sampler.WrapS == GL_CLAMP ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapS == GL_CLAMP_TO_BORDER);
- ASSERT(tObj->Sampler.WrapT == GL_CLAMP ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_EDGE ||
- tObj->Sampler.WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapS == GL_CLAMP ||
+ samp->WrapS == GL_CLAMP_TO_EDGE ||
+ samp->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(samp->WrapT == GL_CLAMP ||
+ samp->WrapT == GL_CLAMP_TO_EDGE ||
+ samp->WrapT == GL_CLAMP_TO_BORDER);
for (i = 0; i < n; i++) {
GLint i0, j0, i1, j1;
@@ -2626,9 +2665,9 @@ sample_linear_rect(struct gl_context *ctx,
GLfloat a, b;
GLbitfield useBorderColor = 0x0;
- clamp_rect_coord_linear(tObj->Sampler.WrapS, texcoords[i][0], width,
+ clamp_rect_coord_linear(samp->WrapS, texcoords[i][0], width,
&i0, &i1, &a);
- clamp_rect_coord_linear(tObj->Sampler.WrapT, texcoords[i][1], height,
+ clamp_rect_coord_linear(samp->WrapT, texcoords[i][1], height,
&j0, &j1, &b);
/* compute integer rows/columns */
@@ -2639,22 +2678,22 @@ sample_linear_rect(struct gl_context *ctx,
/* get four texel samples */
if (useBorderColor & (I0BIT | J0BIT))
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
else
swImg->FetchTexel(swImg, i0, j0, 0, t00);
if (useBorderColor & (I1BIT | J0BIT))
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
else
swImg->FetchTexel(swImg, i1, j0, 0, t10);
if (useBorderColor & (I0BIT | J1BIT))
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
else
swImg->FetchTexel(swImg, i0, j1, 0, t01);
if (useBorderColor & (I1BIT | J1BIT))
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
else
swImg->FetchTexel(swImg, i1, j1, 0, t11);
@@ -2666,6 +2705,7 @@ sample_linear_rect(struct gl_context *ctx,
/** Sample Rect texture, using lambda to choose between min/magnification */
static void
sample_lambda_rect(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2675,26 +2715,26 @@ sample_lambda_rect(struct gl_context *ctx,
/* We only need lambda to decide between minification and magnification.
* There is no mipmapping with rectangular textures.
*/
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
- if (tObj->Sampler.MinFilter == GL_NEAREST) {
- sample_nearest_rect(ctx, tObj, minEnd - minStart,
+ if (samp->MinFilter == GL_NEAREST) {
+ sample_nearest_rect(ctx, samp, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
else {
- sample_linear_rect(ctx, tObj, minEnd - minStart,
+ sample_linear_rect(ctx, samp, tObj, minEnd - minStart,
texcoords + minStart, NULL, rgba + minStart);
}
}
if (magStart < magEnd) {
- if (tObj->Sampler.MagFilter == GL_NEAREST) {
- sample_nearest_rect(ctx, tObj, magEnd - magStart,
+ if (samp->MagFilter == GL_NEAREST) {
+ sample_nearest_rect(ctx, samp, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
else {
- sample_linear_rect(ctx, tObj, magEnd - magStart,
+ sample_linear_rect(ctx, samp, tObj, magEnd - magStart,
texcoords + magStart, NULL, rgba + magStart);
}
}
@@ -2710,7 +2750,7 @@ sample_lambda_rect(struct gl_context *ctx,
*/
static void
sample_2d_array_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -2723,15 +2763,15 @@ sample_2d_array_nearest(struct gl_context *ctx,
GLint array;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
- j = nearest_texel_location(tObj->Sampler.WrapT, img, height, texcoord[1]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
+ j = nearest_texel_location(samp->WrapT, img, height, texcoord[1]);
array = tex_array_slice(texcoord[2], depth);
if (i < 0 || i >= (GLint) img->Width ||
j < 0 || j >= (GLint) img->Height ||
array < 0 || array >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, j, array, rgba);
@@ -2744,7 +2784,7 @@ sample_2d_array_nearest(struct gl_context *ctx,
*/
static void
sample_2d_array_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -2759,12 +2799,12 @@ sample_2d_array_linear(struct gl_context *ctx,
GLfloat a, b;
GLfloat t00[4], t01[4], t10[4], t11[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
- linear_texel_locations(tObj->Sampler.WrapT, img, height, texcoord[1], &j0, &j1, &b);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapT, img, height, texcoord[1], &j0, &j1, &b);
array = tex_array_slice(texcoord[2], depth);
if (array < 0 || array >= depth) {
- COPY_4V(rgba, tObj->Sampler.BorderColor.f);
+ COPY_4V(rgba, samp->BorderColor.f);
}
else {
if (img->Border) {
@@ -2783,25 +2823,25 @@ sample_2d_array_linear(struct gl_context *ctx,
/* Fetch texels */
if (useBorderColor & (I0BIT | J0BIT)) {
- get_border_color(tObj, img, t00);
+ get_border_color(samp, img, t00);
}
else {
swImg->FetchTexel(swImg, i0, j0, array, t00);
}
if (useBorderColor & (I1BIT | J0BIT)) {
- get_border_color(tObj, img, t10);
+ get_border_color(samp, img, t10);
}
else {
swImg->FetchTexel(swImg, i1, j0, array, t10);
}
if (useBorderColor & (I0BIT | J1BIT)) {
- get_border_color(tObj, img, t01);
+ get_border_color(samp, img, t01);
}
else {
swImg->FetchTexel(swImg, i0, j1, array, t01);
}
if (useBorderColor & (I1BIT | J1BIT)) {
- get_border_color(tObj, img, t11);
+ get_border_color(samp, img, t11);
}
else {
swImg->FetchTexel(swImg, i1, j1, array, t11);
@@ -2815,6 +2855,7 @@ sample_2d_array_linear(struct gl_context *ctx,
static void
sample_2d_array_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2822,7 +2863,7 @@ sample_2d_array_nearest_mipmap_nearest(struct gl_context *ctx,
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level], texcoord[i],
rgba[i]);
}
}
@@ -2830,6 +2871,7 @@ sample_2d_array_nearest_mipmap_nearest(struct gl_context *ctx,
static void
sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2838,7 +2880,7 @@ sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level],
texcoord[i], rgba[i]);
}
}
@@ -2846,6 +2888,7 @@ sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx,
static void
sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2855,15 +2898,15 @@ sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
@@ -2873,6 +2916,7 @@ sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_2d_array_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2882,15 +2926,15 @@ sample_2d_array_linear_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level ],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level ],
texcoord[i], t0);
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][level+1],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][level+1],
texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
@@ -2901,6 +2945,7 @@ sample_2d_array_linear_mipmap_linear(struct gl_context *ctx,
/** Sample 2D Array texture, nearest filtering for both min/magnification */
static void
sample_nearest_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2909,7 +2954,7 @@ sample_nearest_2d_array(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_array_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -2918,6 +2963,7 @@ sample_nearest_2d_array(struct gl_context *ctx,
/** Sample 2D Array texture, linear filtering for both min/magnification */
static void
sample_linear_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -2926,7 +2972,7 @@ sample_linear_2d_array(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_2d_array_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_2d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -2934,6 +2980,7 @@ sample_linear_2d_array(struct gl_context *ctx,
/** Sample 2D Array texture, using lambda to choose between min/magnification */
static void
sample_lambda_2d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -2943,43 +2990,43 @@ sample_lambda_2d_array(struct gl_context *ctx,
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_2d_array_nearest_mipmap_nearest(ctx, tObj, m,
+ sample_2d_array_nearest_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_2d_array_linear_mipmap_nearest(ctx, tObj, m,
+ sample_2d_array_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_2d_array_nearest_mipmap_linear(ctx, tObj, m,
+ sample_2d_array_nearest_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_2d_array_linear_mipmap_linear(ctx, tObj, m,
+ sample_2d_array_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
@@ -2992,15 +3039,15 @@ sample_lambda_2d_array(struct gl_context *ctx,
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
@@ -3022,7 +3069,7 @@ sample_lambda_2d_array(struct gl_context *ctx,
*/
static void
sample_1d_array_nearest(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -3034,13 +3081,13 @@ sample_1d_array_nearest(struct gl_context *ctx,
GLint array;
(void) ctx;
- i = nearest_texel_location(tObj->Sampler.WrapS, img, width, texcoord[0]);
+ i = nearest_texel_location(samp->WrapS, img, width, texcoord[0]);
array = tex_array_slice(texcoord[1], height);
if (i < 0 || i >= (GLint) img->Width ||
array < 0 || array >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER mode */
- get_border_color(tObj, img, rgba);
+ get_border_color(samp, img, rgba);
}
else {
swImg->FetchTexel(swImg, i, array, 0, rgba);
@@ -3053,7 +3100,7 @@ sample_1d_array_nearest(struct gl_context *ctx,
*/
static void
sample_1d_array_linear(struct gl_context *ctx,
- const struct gl_texture_object *tObj,
+ const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
const GLfloat texcoord[4],
GLfloat rgba[4])
@@ -3067,7 +3114,7 @@ sample_1d_array_linear(struct gl_context *ctx,
GLfloat a;
GLfloat t0[4], t1[4];
- linear_texel_locations(tObj->Sampler.WrapS, img, width, texcoord[0], &i0, &i1, &a);
+ linear_texel_locations(samp->WrapS, img, width, texcoord[0], &i0, &i1, &a);
array = tex_array_slice(texcoord[1], height);
if (img->Border) {
@@ -3084,13 +3131,13 @@ sample_1d_array_linear(struct gl_context *ctx,
/* Fetch texels */
if (useBorderColor & (I0BIT | K0BIT)) {
- get_border_color(tObj, img, t0);
+ get_border_color(samp, img, t0);
}
else {
swImg->FetchTexel(swImg, i0, array, 0, t0);
}
if (useBorderColor & (I1BIT | K0BIT)) {
- get_border_color(tObj, img, t1);
+ get_border_color(samp, img, t1);
}
else {
swImg->FetchTexel(swImg, i1, array, 0, t1);
@@ -3103,6 +3150,7 @@ sample_1d_array_linear(struct gl_context *ctx,
static void
sample_1d_array_nearest_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -3110,7 +3158,7 @@ sample_1d_array_nearest_mipmap_nearest(struct gl_context *ctx,
GLuint i;
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level], texcoord[i],
rgba[i]);
}
}
@@ -3118,6 +3166,7 @@ sample_1d_array_nearest_mipmap_nearest(struct gl_context *ctx,
static void
sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -3126,7 +3175,7 @@ sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx,
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
GLint level = nearest_mipmap_level(tObj, lambda[i]);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level],
texcoord[i], rgba[i]);
}
}
@@ -3134,6 +3183,7 @@ sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx,
static void
sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -3143,14 +3193,14 @@ sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -3159,6 +3209,7 @@ sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx,
static void
sample_1d_array_linear_mipmap_linear(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj,
GLuint n, const GLfloat texcoord[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -3168,14 +3219,14 @@ sample_1d_array_linear_mipmap_linear(struct gl_context *ctx,
for (i = 0; i < n; i++) {
GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
}
else {
GLfloat t0[4], t1[4]; /* texels */
const GLfloat f = FRAC(lambda[i]);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][level+1], texcoord[i], t1);
lerp_rgba(rgba[i], f, t0, t1);
}
}
@@ -3185,6 +3236,7 @@ sample_1d_array_linear_mipmap_linear(struct gl_context *ctx,
/** Sample 1D Array texture, nearest filtering for both min/magnification */
static void
sample_nearest_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -3193,7 +3245,7 @@ sample_nearest_1d_array(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_array_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -3201,6 +3253,7 @@ sample_nearest_1d_array(struct gl_context *ctx,
/** Sample 1D Array texture, linear filtering for both min/magnification */
static void
sample_linear_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
@@ -3209,7 +3262,7 @@ sample_linear_1d_array(struct gl_context *ctx,
struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
(void) lambda;
for (i = 0; i < n; i++) {
- sample_1d_array_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ sample_1d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
}
}
@@ -3217,6 +3270,7 @@ sample_linear_1d_array(struct gl_context *ctx,
/** Sample 1D Array texture, using lambda to choose between min/magnification */
static void
sample_lambda_1d_array(struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -3226,39 +3280,39 @@ sample_lambda_1d_array(struct gl_context *ctx,
GLuint i;
ASSERT(lambda != NULL);
- compute_min_mag_ranges(tObj, n, lambda,
+ compute_min_mag_ranges(samp, n, lambda,
&minStart, &minEnd, &magStart, &magEnd);
if (minStart < minEnd) {
/* do the minified texels */
GLuint m = minEnd - minStart;
- switch (tObj->Sampler.MinFilter) {
+ switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_1d_array_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_1d_array_nearest_mipmap_nearest(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_1d_array_linear_mipmap_nearest(ctx, tObj, m,
+ sample_1d_array_linear_mipmap_nearest(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_1d_array_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_1d_array_nearest_mipmap_linear(ctx, samp, tObj, m, texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_1d_array_linear_mipmap_linear(ctx, tObj, m,
+ sample_1d_array_linear_mipmap_linear(ctx, samp, tObj, m,
texcoords + minStart,
lambda + minStart,
rgba + minStart);
@@ -3271,15 +3325,15 @@ sample_lambda_1d_array(struct gl_context *ctx,
if (magStart < magEnd) {
/* do the magnified texels */
- switch (tObj->Sampler.MagFilter) {
+ switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
texcoords[i], rgba[i]);
break;
default:
@@ -3390,17 +3444,18 @@ shadow_compare4(GLenum function, GLfloat coord,
* Choose the mipmap level to use when sampling from a depth texture.
*/
static int
-choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
+choose_depth_texture_level(const struct gl_sampler_object *samp,
+ const struct gl_texture_object *tObj, GLfloat lambda)
{
GLint level;
- if (tObj->Sampler.MinFilter == GL_NEAREST || tObj->Sampler.MinFilter == GL_LINEAR) {
+ if (samp->MinFilter == GL_NEAREST || samp->MinFilter == GL_LINEAR) {
/* no mipmapping - use base level */
level = tObj->BaseLevel;
}
else {
/* choose mipmap level */
- lambda = CLAMP(lambda, tObj->Sampler.MinLod, tObj->Sampler.MaxLod);
+ lambda = CLAMP(lambda, samp->MinLod, samp->MaxLod);
level = (GLint) lambda;
level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
}
@@ -3415,11 +3470,12 @@ choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
*/
static void
sample_depth_texture( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat texel[][4] )
{
- const GLint level = choose_depth_texture_level(tObj, lambda[0]);
+ const GLint level = choose_depth_texture_level(samp, tObj, lambda[0]);
const struct gl_texture_image *img = tObj->Image[0][level];
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLint width = img->Width;
@@ -3441,34 +3497,34 @@ sample_depth_texture( struct gl_context *ctx,
tObj->Target == GL_TEXTURE_2D_ARRAY_EXT ||
tObj->Target == GL_TEXTURE_CUBE_MAP);
- ambient = tObj->Sampler.CompareFailValue;
+ ambient = samp->CompareFailValue;
- /* XXXX if tObj->Sampler.MinFilter != tObj->Sampler.MagFilter, we're ignoring lambda */
+ /* XXXX if samp->MinFilter != samp->MagFilter, we're ignoring lambda */
- function = (tObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) ?
- tObj->Sampler.CompareFunc : GL_NONE;
+ function = (samp->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) ?
+ samp->CompareFunc : GL_NONE;
- if (tObj->Sampler.MagFilter == GL_NEAREST) {
+ if (samp->MagFilter == GL_NEAREST) {
GLuint i;
for (i = 0; i < n; i++) {
GLfloat depthSample, depthRef;
GLint col, row, slice;
- nearest_texcoord(tObj, level, texcoords[i], &col, &row, &slice);
+ nearest_texcoord(samp, tObj, level, texcoords[i], &col, &row, &slice);
if (col >= 0 && row >= 0 && col < width && row < height &&
slice >= 0 && slice < depth) {
swImg->FetchTexel(swImg, col, row, slice, &depthSample);
}
else {
- depthSample = tObj->Sampler.BorderColor.f[0];
+ depthSample = samp->BorderColor.f[0];
}
depthRef = CLAMP(texcoords[i][compare_coord], 0.0F, 1.0F);
result = shadow_compare(function, depthRef, depthSample, ambient);
- switch (tObj->Sampler.DepthMode) {
+ switch (tObj->DepthMode) {
case GL_LUMINANCE:
ASSIGN_4V(texel[i], result, result, result, 1.0F);
break;
@@ -3489,7 +3545,7 @@ sample_depth_texture( struct gl_context *ctx,
}
else {
GLuint i;
- ASSERT(tObj->Sampler.MagFilter == GL_LINEAR);
+ ASSERT(samp->MagFilter == GL_LINEAR);
for (i = 0; i < n; i++) {
GLfloat depth00, depth01, depth10, depth11, depthRef;
GLint i0, i1, j0, j1;
@@ -3497,7 +3553,7 @@ sample_depth_texture( struct gl_context *ctx,
GLfloat wi, wj;
GLuint useBorderTexel;
- linear_texcoord(tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice,
+ linear_texcoord(samp, tObj, level, texcoords[i], &i0, &i1, &j0, &j1, &slice,
&wi, &wj);
useBorderTexel = 0;
@@ -3517,21 +3573,21 @@ sample_depth_texture( struct gl_context *ctx,
}
if (slice < 0 || slice >= (GLint) depth) {
- depth00 = tObj->Sampler.BorderColor.f[0];
- depth01 = tObj->Sampler.BorderColor.f[0];
- depth10 = tObj->Sampler.BorderColor.f[0];
- depth11 = tObj->Sampler.BorderColor.f[0];
+ depth00 = samp->BorderColor.f[0];
+ depth01 = samp->BorderColor.f[0];
+ depth10 = samp->BorderColor.f[0];
+ depth11 = samp->BorderColor.f[0];
}
else {
/* get four depth samples from the texture */
if (useBorderTexel & (I0BIT | J0BIT)) {
- depth00 = tObj->Sampler.BorderColor.f[0];
+ depth00 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i0, j0, slice, &depth00);
}
if (useBorderTexel & (I1BIT | J0BIT)) {
- depth10 = tObj->Sampler.BorderColor.f[0];
+ depth10 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i1, j0, slice, &depth10);
@@ -3539,13 +3595,13 @@ sample_depth_texture( struct gl_context *ctx,
if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
if (useBorderTexel & (I0BIT | J1BIT)) {
- depth01 = tObj->Sampler.BorderColor.f[0];
+ depth01 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i0, j1, slice, &depth01);
}
if (useBorderTexel & (I1BIT | J1BIT)) {
- depth11 = tObj->Sampler.BorderColor.f[0];
+ depth11 = samp->BorderColor.f[0];
}
else {
swImg->FetchTexel(swImg, i1, j1, slice, &depth11);
@@ -3563,7 +3619,7 @@ sample_depth_texture( struct gl_context *ctx,
depth00, depth01, depth10, depth11,
ambient, wi, wj);
- switch (tObj->Sampler.DepthMode) {
+ switch (tObj->DepthMode) {
case GL_LUMINANCE:
ASSIGN_4V(texel[i], result, result, result, 1.0F);
break;
@@ -3590,6 +3646,7 @@ sample_depth_texture( struct gl_context *ctx,
*/
static void
null_sample_func( struct gl_context *ctx,
+ const struct gl_sampler_object *samp,
const struct gl_texture_object *tObj, GLuint n,
const GLfloat texcoords[][4], const GLfloat lambda[],
GLfloat rgba[][4])
@@ -3599,6 +3656,7 @@ null_sample_func( struct gl_context *ctx,
(void) tObj;
(void) texcoords;
(void) lambda;
+ (void) samp;
for (i = 0; i < n; i++) {
rgba[i][RCOMP] = 0;
rgba[i][GCOMP] = 0;
@@ -3621,7 +3679,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
}
else {
const GLboolean needLambda =
- (GLboolean) (t->Sampler.MinFilter != t->Sampler.MagFilter);
+ (GLboolean) (sampler->MinFilter != sampler->MagFilter);
const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat;
switch (t->Target) {
@@ -3632,11 +3690,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
else if (needLambda) {
return &sample_lambda_1d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_1d;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_1d;
}
case GL_TEXTURE_2D:
@@ -3645,13 +3703,13 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
}
else if (needLambda) {
/* Anisotropic filtering extension. Activated only if mipmaps are used */
- if (t->Sampler.MaxAnisotropy > 1.0 &&
- t->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+ if (sampler->MaxAnisotropy > 1.0 &&
+ sampler->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
return &sample_lambda_2d_aniso;
}
return &sample_lambda_2d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_2d;
}
else {
@@ -3661,10 +3719,10 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
swrast_texture_image_const(img);
texture_sample_func func;
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
func = &sample_nearest_2d;
- if (t->Sampler.WrapS == GL_REPEAT &&
- t->Sampler.WrapT == GL_REPEAT &&
+ if (sampler->WrapS == GL_REPEAT &&
+ sampler->WrapT == GL_REPEAT &&
swImg->_IsPowerOfTwo &&
img->Border == 0) {
if (img->TexFormat == MESA_FORMAT_RGB888)
@@ -3679,11 +3737,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
if (needLambda) {
return &sample_lambda_3d;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_3d;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_3d;
}
case GL_TEXTURE_CUBE_MAP:
@@ -3693,11 +3751,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
else if (needLambda) {
return &sample_lambda_cube;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_cube;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_cube;
}
case GL_TEXTURE_RECTANGLE_NV:
@@ -3707,11 +3765,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
else if (needLambda) {
return &sample_lambda_rect;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_rect;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_rect;
}
case GL_TEXTURE_1D_ARRAY_EXT:
@@ -3721,11 +3779,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
else if (needLambda) {
return &sample_lambda_1d_array;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_1d_array;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_1d_array;
}
case GL_TEXTURE_2D_ARRAY_EXT:
@@ -3735,11 +3793,11 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
else if (needLambda) {
return &sample_lambda_2d_array;
}
- else if (t->Sampler.MinFilter == GL_LINEAR) {
+ else if (sampler->MinFilter == GL_LINEAR) {
return &sample_linear_2d_array;
}
else {
- ASSERT(t->Sampler.MinFilter == GL_NEAREST);
+ ASSERT(sampler->MinFilter == GL_NEAREST);
return &sample_nearest_2d_array;
}
default:
diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c
index e89a999a9..893859db0 100644
--- a/mesalib/src/mesa/swrast/s_triangle.c
+++ b/mesalib/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
diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c
index 7687ae0b3..74772dbbe 100644
--- a/mesalib/src/mesa/tnl/t_vb_program.c
+++ b/mesalib/src/mesa/tnl/t_vb_program.c
@@ -35,6 +35,7 @@
#include "main/colormac.h"
#include "main/macros.h"
#include "main/imports.h"
+#include "main/samplerobj.h"
#include "math/m_xform.h"
#include "program/prog_instruction.h"
#include "program/prog_statevars.h"
@@ -197,7 +198,8 @@ vp_fetch_texel(struct gl_context *ctx, const GLfloat texcoord[4], GLfloat lambda
SWcontext *swrast = SWRAST_CONTEXT(ctx);
/* XXX use a float-valued TextureSample routine here!!! */
- swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current,
+ swrast->TextureSample[unit](ctx, _mesa_get_samplerobj(ctx, unit),
+ ctx->Texture.Unit[unit]._Current,
1, (const GLfloat (*)[4]) texcoord,
&lambda, (GLfloat (*)[4]) color);
}
diff --git a/pixman/configure.ac b/pixman/configure.ac
index 36f423ef7..e3a5ff919 100644
--- a/pixman/configure.ac
+++ b/pixman/configure.ac
@@ -54,7 +54,7 @@ AC_PREREQ([2.57])
m4_define([pixman_major], 0)
m4_define([pixman_minor], 27)
-m4_define([pixman_micro], 1)
+m4_define([pixman_micro], 3)
m4_define([pixman_version],[pixman_major.pixman_minor.pixman_micro])
diff --git a/pixman/pixman/Makefile.am b/pixman/pixman/Makefile.am
index deacf8728..843711a25 100644
--- a/pixman/pixman/Makefile.am
+++ b/pixman/pixman/Makefile.am
@@ -13,6 +13,7 @@ noinst_LTLIBRARIES =
EXTRA_DIST = \
Makefile.win32 \
make-combine.pl \
+ make-srgb.pl \
pixman-combine.c.template \
pixman-combine.h.template \
pixman-region.c \
diff --git a/pixman/pixman/make-srgb.pl b/pixman/pixman/make-srgb.pl
index ebde2eac6..cdaa80ba5 100644
--- a/pixman/pixman/make-srgb.pl
+++ b/pixman/pixman/make-srgb.pl
@@ -72,7 +72,10 @@ print <<"PROLOG";
#include <stdint.h>
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "pixman-private.h"
PROLOG
diff --git a/pixman/pixman/pixman-matrix.c b/pixman/pixman/pixman-matrix.c
index 6d215ff10..a029ab757 100644
--- a/pixman/pixman/pixman-matrix.c
+++ b/pixman/pixman/pixman-matrix.c
@@ -25,7 +25,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <math.h>
diff --git a/pixman/test/glyph-test.c b/pixman/test/glyph-test.c
index 0fb664191..84de5aace 100644
--- a/pixman/test/glyph-test.c
+++ b/pixman/test/glyph-test.c
@@ -199,7 +199,7 @@ create_image (int max_size, const pixman_format_code_t *formats, uint32_t flags)
alpha_x = lcg_rand_n (width);
alpha_y = lcg_rand_n (height);
alpha_map =
- create_image (max_size, formats, (flags & ~ALLOW_ALPHA_MAP));
+ create_image (max_size, formats, (flags & ~(ALLOW_ALPHA_MAP | ALLOW_SOLID)));
pixman_image_set_alpha_map (image, alpha_map, alpha_x, alpha_y);
pixman_image_unref (alpha_map);
}
@@ -330,6 +330,6 @@ int
main (int argc, const char *argv[])
{
return fuzzer_test_main ("glyph", 30000,
- 0x1B7696A2,
+ 0x741CB2DB,
test_glyphs, argc, argv);
}
diff --git a/pixman/test/stress-test.c b/pixman/test/stress-test.c
index 54ab1c5a9..edcfe0947 100644
--- a/pixman/test/stress-test.c
+++ b/pixman/test/stress-test.c
@@ -468,6 +468,11 @@ set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map)
width = lcg_rand_n (image->bits.width) - x + 10;
height = lcg_rand_n (image->bits.height) - y + 10;
+ if (width + x < x)
+ width = INT32_MAX - x;
+ if (height + y < y)
+ height = INT32_MAX - y;
+
pixman_region32_union_rect (
&region, &region, x, y, width, height);
}