summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-04-10 12:44:46 -0600
committerBrian Paul <[email protected]>2011-04-10 13:12:49 -0600
commitecfaab88b2577bd0395bc05d75a036126806a9c4 (patch)
tree5abb78f767f546778d551a57f7f2cfe20c479f50 /src/mesa/main
parent1cbd3a1cc734df16610a59dc49cdb42c70dc3270 (diff)
mesa: move sampler state into new gl_sampler_object type
gl_texture_object contains an instance of this type for the regular texture object sampling state. glGenSamplers() generates new instances of gl_sampler_object which can override that state with glBindSampler().
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c25
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp7
-rw-r--r--src/mesa/main/mtypes.h60
-rw-r--r--src/mesa/main/texfetch.c2
-rw-r--r--src/mesa/main/texobj.c90
-rw-r--r--src/mesa/main/texparam.c160
-rw-r--r--src/mesa/main/texstate.c8
7 files changed, 195 insertions, 157 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 6a2f4870db9..57310040235 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -770,6 +770,7 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
/* Restore texture object state for each target */
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
const struct gl_texture_object *obj = NULL;
+ const struct gl_sampler_object *samp;
GLenum target;
obj = &texstate->SavedObj[u][tgt];
@@ -797,26 +798,28 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
_mesa_BindTexture(target, obj->Name);
- _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor.f);
+ samp = &obj->Sampler;
+
+ _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR);
+ _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter);
+ _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, samp->MinLod);
+ _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, samp->MaxLod);
+ _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, samp->LodBias);
_mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR);
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, obj->MinFilter);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter);
- _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod);
- _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod);
- _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, obj->LodBias);
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel);
if (target != GL_TEXTURE_RECTANGLE_ARB)
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
_mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
- obj->MaxAnisotropy);
+ samp->MaxAnisotropy);
}
if (ctx->Extensions.ARB_shadow_ambient) {
_mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB,
- obj->CompareFailValue);
+ samp->CompareFailValue);
}
}
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index bf65a4f6485..43930a4b30e 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -439,9 +439,10 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
key->unit[i].source_index =
translate_tex_src_bit(texUnit->_ReallyEnabled);
- key->unit[i].shadow = ((texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
- ((format == GL_DEPTH_COMPONENT) ||
- (format == GL_DEPTH_STENCIL_EXT)));
+ key->unit[i].shadow =
+ ((texObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
+ ((format == GL_DEPTH_COMPONENT) ||
+ (format == GL_DEPTH_STENCIL_EXT)));
key->unit[i].NumArgsRGB = comb->_NumArgsRGB;
key->unit[i].NumArgsA = comb->_NumArgsA;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 13e4325ee45..9e2905ab2b1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1305,37 +1305,58 @@ typedef enum
/**
- * Texture object state. Contains the array of mipmap images, border color,
- * wrap modes, filter modes, shadow/texcompare state, and the per-texture
- * color palette.
+ * Sampler object state. These objects are new with GL_ARB_sampler_objects
+ * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
*/
-struct gl_texture_object
+struct gl_sampler_object
{
- _glthread_Mutex Mutex; /**< for thread safety */
- GLint RefCount; /**< reference count */
- GLuint Name; /**< the user-visible texture object ID */
- GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
- GLfloat Priority; /**< in [0,1] */
- union {
- GLfloat f[4];
- GLuint ui[4];
- GLint i[4];
- } BorderColor; /**< Interpreted according to texture format */
+ GLuint Name;
+ GLint RefCount;
+
GLenum WrapS; /**< S-axis texture image wrap mode */
GLenum WrapT; /**< T-axis texture image wrap mode */
GLenum WrapR; /**< R-axis texture image wrap mode */
GLenum MinFilter; /**< minification filter */
GLenum MagFilter; /**< magnification filter */
+ union {
+ GLfloat f[4];
+ GLuint ui[4];
+ GLint i[4];
+ } BorderColor; /**< Interpreted according to texture format */
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
GLfloat LodBias; /**< OpenGL 1.4 */
- GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
- GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLenum CompareMode; /**< GL_ARB_shadow */
GLenum CompareFunc; /**< GL_ARB_shadow */
GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */
+ GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
+
+ /* deprecated sampler state */
GLenum DepthMode; /**< GL_ARB_depth_texture */
+
+ /** Is the texture object complete with respect to this sampler? */
+ GLboolean _CompleteTexture;
+};
+
+
+/**
+ * Texture object state. Contains the array of mipmap images, border color,
+ * wrap modes, filter modes, shadow/texcompare state, and the per-texture
+ * color palette.
+ */
+struct gl_texture_object
+{
+ _glthread_Mutex Mutex; /**< for thread safety */
+ GLint RefCount; /**< reference count */
+ GLuint Name; /**< the user-visible texture object ID */
+ GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
+
+ struct gl_sampler_object Sampler;
+
+ GLfloat Priority; /**< in [0,1] */
+ GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
+ GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
GLint CropRect[4]; /**< GL_OES_draw_texture */
@@ -1345,7 +1366,6 @@ struct gl_texture_object
GLboolean _Complete; /**< Is texture object complete? */
GLboolean _RenderToTexture; /**< Any rendering to this texture? */
GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
- GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
@@ -1429,6 +1449,9 @@ struct gl_texture_unit
GLenum BumpTarget;
GLfloat RotMatrix[4]; /* 2x2 matrix */
+ /** Current sampler object (GL_ARB_sampler_objects) */
+ struct gl_sampler_object *Sampler;
+
/**
* \name GL_EXT_texture_env_combine
*/
@@ -2363,6 +2386,9 @@ struct gl_shared_state
/* GL_ARB_sync */
struct simple_node SyncObjects;
+ /** GL_ARB_sampler_objects */
+ struct _mesa_HashTable *SamplerObjects;
+
void *DriverData; /**< Device driver shared state */
};
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
index b2181af2931..caabc19bb17 100644
--- a/src/mesa/main/texfetch.c
+++ b/src/mesa/main/texfetch.c
@@ -975,7 +975,7 @@ _mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
ASSERT(dims == 1 || dims == 2 || dims == 3);
- if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT &&
+ if (texImage->TexObject->Sampler.sRGBDecode == GL_SKIP_DECODE_EXT &&
_mesa_get_format_color_encoding(format) == GL_SRGB) {
format = _mesa_get_srgb_format_linear(format);
}
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 61b9bc70d77..43d6e52dfe9 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -116,35 +116,37 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
obj->Name = name;
obj->Target = target;
obj->Priority = 1.0F;
+ obj->BaseLevel = 0;
+ obj->MaxLevel = 1000;
+
+ /* sampler state */
if (target == GL_TEXTURE_RECTANGLE_NV) {
- obj->WrapS = GL_CLAMP_TO_EDGE;
- obj->WrapT = GL_CLAMP_TO_EDGE;
- obj->WrapR = GL_CLAMP_TO_EDGE;
- obj->MinFilter = GL_LINEAR;
+ obj->Sampler.WrapS = GL_CLAMP_TO_EDGE;
+ obj->Sampler.WrapT = GL_CLAMP_TO_EDGE;
+ obj->Sampler.WrapR = GL_CLAMP_TO_EDGE;
+ obj->Sampler.MinFilter = GL_LINEAR;
}
else {
- obj->WrapS = GL_REPEAT;
- obj->WrapT = GL_REPEAT;
- obj->WrapR = GL_REPEAT;
- obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
+ obj->Sampler.WrapS = GL_REPEAT;
+ obj->Sampler.WrapT = GL_REPEAT;
+ obj->Sampler.WrapR = GL_REPEAT;
+ obj->Sampler.MinFilter = GL_NEAREST_MIPMAP_LINEAR;
}
- obj->MagFilter = GL_LINEAR;
- obj->MinLod = -1000.0;
- obj->MaxLod = 1000.0;
- obj->LodBias = 0.0;
- obj->BaseLevel = 0;
- obj->MaxLevel = 1000;
- obj->MaxAnisotropy = 1.0;
- obj->CompareMode = GL_NONE; /* ARB_shadow */
- obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */
- obj->CompareFailValue = 0.0F; /* ARB_shadow_ambient */
- obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */
+ obj->Sampler.MagFilter = GL_LINEAR;
+ obj->Sampler.MinLod = -1000.0;
+ obj->Sampler.MaxLod = 1000.0;
+ obj->Sampler.LodBias = 0.0;
+ obj->Sampler.MaxAnisotropy = 1.0;
+ 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->Swizzle[0] = GL_RED;
obj->Swizzle[1] = GL_GREEN;
obj->Swizzle[2] = GL_BLUE;
obj->Swizzle[3] = GL_ALPHA;
obj->_Swizzle = SWIZZLE_NOOP;
- obj->sRGBDecode = GL_DECODE_EXT;
+ obj->Sampler.sRGBDecode = GL_DECODE_EXT;
}
@@ -160,10 +162,10 @@ finish_texture_init(struct gl_context *ctx, GLenum target,
if (target == GL_TEXTURE_RECTANGLE_NV) {
/* have to init wrap and filter state here - kind of klunky */
- obj->WrapS = GL_CLAMP_TO_EDGE;
- obj->WrapT = GL_CLAMP_TO_EDGE;
- obj->WrapR = GL_CLAMP_TO_EDGE;
- obj->MinFilter = GL_LINEAR;
+ obj->Sampler.WrapS = GL_CLAMP_TO_EDGE;
+ obj->Sampler.WrapT = GL_CLAMP_TO_EDGE;
+ obj->Sampler.WrapR = GL_CLAMP_TO_EDGE;
+ obj->Sampler.MinFilter = GL_LINEAR;
if (ctx->Driver.TexParameter) {
static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
@@ -231,25 +233,25 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
dest->Target = src->Target;
dest->Name = src->Name;
dest->Priority = src->Priority;
- dest->BorderColor.f[0] = src->BorderColor.f[0];
- dest->BorderColor.f[1] = src->BorderColor.f[1];
- dest->BorderColor.f[2] = src->BorderColor.f[2];
- dest->BorderColor.f[3] = src->BorderColor.f[3];
- dest->WrapS = src->WrapS;
- dest->WrapT = src->WrapT;
- dest->WrapR = src->WrapR;
- dest->MinFilter = src->MinFilter;
- dest->MagFilter = src->MagFilter;
- dest->MinLod = src->MinLod;
- dest->MaxLod = src->MaxLod;
- dest->LodBias = src->LodBias;
+ dest->Sampler.BorderColor.f[0] = src->Sampler.BorderColor.f[0];
+ dest->Sampler.BorderColor.f[1] = src->Sampler.BorderColor.f[1];
+ dest->Sampler.BorderColor.f[2] = src->Sampler.BorderColor.f[2];
+ dest->Sampler.BorderColor.f[3] = src->Sampler.BorderColor.f[3];
+ dest->Sampler.WrapS = src->Sampler.WrapS;
+ dest->Sampler.WrapT = src->Sampler.WrapT;
+ dest->Sampler.WrapR = src->Sampler.WrapR;
+ dest->Sampler.MinFilter = src->Sampler.MinFilter;
+ dest->Sampler.MagFilter = src->Sampler.MagFilter;
+ dest->Sampler.MinLod = src->Sampler.MinLod;
+ dest->Sampler.MaxLod = src->Sampler.MaxLod;
+ dest->Sampler.LodBias = src->Sampler.LodBias;
dest->BaseLevel = src->BaseLevel;
dest->MaxLevel = src->MaxLevel;
- dest->MaxAnisotropy = src->MaxAnisotropy;
- dest->CompareMode = src->CompareMode;
- dest->CompareFunc = src->CompareFunc;
- dest->CompareFailValue = src->CompareFailValue;
- dest->DepthMode = src->DepthMode;
+ dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy;
+ dest->Sampler.CompareMode = src->Sampler.CompareMode;
+ dest->Sampler.CompareFunc = src->Sampler.CompareFunc;
+ dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue;
+ dest->Sampler.DepthMode = src->Sampler.DepthMode;
dest->_MaxLevel = src->_MaxLevel;
dest->_MaxLambda = src->_MaxLambda;
dest->GenerateMipmap = src->GenerateMipmap;
@@ -506,7 +508,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
}
/* extra checking for mipmaps */
- if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) {
+ if (t->Sampler.MinFilter != GL_NEAREST && t->Sampler.MinFilter != GL_LINEAR) {
/*
* Mipmapping: determine if we have a complete set of mipmaps
*/
@@ -761,8 +763,8 @@ _mesa_get_fallback_texture(struct gl_context *ctx)
/* create texture object */
texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D);
assert(texObj->RefCount == 1);
- texObj->MinFilter = GL_NEAREST;
- texObj->MagFilter = GL_NEAREST;
+ texObj->Sampler.MinFilter = GL_NEAREST;
+ texObj->Sampler.MagFilter = GL_NEAREST;
/* create level[0] texture image */
texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0);
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 34b6addb9b0..3d56dac3f91 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -216,13 +216,13 @@ set_tex_parameteri(struct gl_context *ctx,
{
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
- if (texObj->MinFilter == params[0])
+ if (texObj->Sampler.MinFilter == params[0])
return GL_FALSE;
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
incomplete(ctx, texObj);
- texObj->MinFilter = params[0];
+ texObj->Sampler.MinFilter = params[0];
return GL_TRUE;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
@@ -230,7 +230,7 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_LINEAR_MIPMAP_LINEAR:
if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
incomplete(ctx, texObj);
- texObj->MinFilter = params[0];
+ texObj->Sampler.MinFilter = params[0];
return GL_TRUE;
}
/* fall-through */
@@ -240,13 +240,13 @@ set_tex_parameteri(struct gl_context *ctx,
return GL_FALSE;
case GL_TEXTURE_MAG_FILTER:
- if (texObj->MagFilter == params[0])
+ if (texObj->Sampler.MagFilter == params[0])
return GL_FALSE;
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
flush(ctx); /* does not effect completeness */
- texObj->MagFilter = params[0];
+ texObj->Sampler.MagFilter = params[0];
return GL_TRUE;
default:
goto invalid_param;
@@ -254,31 +254,31 @@ set_tex_parameteri(struct gl_context *ctx,
return GL_FALSE;
case GL_TEXTURE_WRAP_S:
- if (texObj->WrapS == params[0])
+ if (texObj->Sampler.WrapS == params[0])
return GL_FALSE;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
flush(ctx);
- texObj->WrapS = params[0];
+ texObj->Sampler.WrapS = params[0];
return GL_TRUE;
}
return GL_FALSE;
case GL_TEXTURE_WRAP_T:
- if (texObj->WrapT == params[0])
+ if (texObj->Sampler.WrapT == params[0])
return GL_FALSE;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
flush(ctx);
- texObj->WrapT = params[0];
+ texObj->Sampler.WrapT = params[0];
return GL_TRUE;
}
return GL_FALSE;
case GL_TEXTURE_WRAP_R:
- if (texObj->WrapR == params[0])
+ if (texObj->Sampler.WrapR == params[0])
return GL_FALSE;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
flush(ctx);
- texObj->WrapR = params[0];
+ texObj->Sampler.WrapR = params[0];
return GL_TRUE;
}
return GL_FALSE;
@@ -318,12 +318,12 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_TEXTURE_COMPARE_MODE_ARB:
if (ctx->Extensions.ARB_shadow) {
- if (texObj->CompareMode == params[0])
+ if (texObj->Sampler.CompareMode == params[0])
return GL_FALSE;
if (params[0] == GL_NONE ||
params[0] == GL_COMPARE_R_TO_TEXTURE_ARB) {
flush(ctx);
- texObj->CompareMode = params[0];
+ texObj->Sampler.CompareMode = params[0];
return GL_TRUE;
}
goto invalid_param;
@@ -332,13 +332,13 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_TEXTURE_COMPARE_FUNC_ARB:
if (ctx->Extensions.ARB_shadow) {
- if (texObj->CompareFunc == params[0])
+ if (texObj->Sampler.CompareFunc == params[0])
return GL_FALSE;
switch (params[0]) {
case GL_LEQUAL:
case GL_GEQUAL:
flush(ctx);
- texObj->CompareFunc = params[0];
+ texObj->Sampler.CompareFunc = params[0];
return GL_TRUE;
case GL_EQUAL:
case GL_NOTEQUAL:
@@ -348,7 +348,7 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_NEVER:
if (ctx->Extensions.EXT_shadow_funcs) {
flush(ctx);
- texObj->CompareFunc = params[0];
+ texObj->Sampler.CompareFunc = params[0];
return GL_TRUE;
}
/* fall-through */
@@ -360,14 +360,14 @@ set_tex_parameteri(struct gl_context *ctx,
case GL_DEPTH_TEXTURE_MODE_ARB:
if (ctx->Extensions.ARB_depth_texture) {
- if (texObj->DepthMode == params[0])
+ if (texObj->Sampler.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->DepthMode = params[0];
+ texObj->Sampler.DepthMode = params[0];
return GL_TRUE;
}
goto invalid_param;
@@ -429,9 +429,9 @@ set_tex_parameteri(struct gl_context *ctx,
if (ctx->Extensions.EXT_texture_sRGB_decode) {
GLenum decode = params[0];
if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) {
- if (texObj->sRGBDecode != decode) {
+ if (texObj->Sampler.sRGBDecode != decode) {
flush(ctx);
- texObj->sRGBDecode = decode;
+ texObj->Sampler.sRGBDecode = decode;
_mesa_update_fetch_functions(texObj);
}
return GL_TRUE;
@@ -466,17 +466,17 @@ set_tex_parameterf(struct gl_context *ctx,
{
switch (pname) {
case GL_TEXTURE_MIN_LOD:
- if (texObj->MinLod == params[0])
+ if (texObj->Sampler.MinLod == params[0])
return GL_FALSE;
flush(ctx);
- texObj->MinLod = params[0];
+ texObj->Sampler.MinLod = params[0];
return GL_TRUE;
case GL_TEXTURE_MAX_LOD:
- if (texObj->MaxLod == params[0])
+ if (texObj->Sampler.MaxLod == params[0])
return GL_FALSE;
flush(ctx);
- texObj->MaxLod = params[0];
+ texObj->Sampler.MaxLod = params[0];
return GL_TRUE;
case GL_TEXTURE_PRIORITY:
@@ -486,7 +486,7 @@ set_tex_parameterf(struct gl_context *ctx,
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
- if (texObj->MaxAnisotropy == params[0])
+ if (texObj->Sampler.MaxAnisotropy == params[0])
return GL_FALSE;
if (params[0] < 1.0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
@@ -494,7 +494,7 @@ set_tex_parameterf(struct gl_context *ctx,
}
flush(ctx);
/* clamp to max, that's what NVIDIA does */
- texObj->MaxAnisotropy = MIN2(params[0],
+ texObj->Sampler.MaxAnisotropy = MIN2(params[0],
ctx->Const.MaxTextureMaxAnisotropy);
return GL_TRUE;
}
@@ -508,9 +508,9 @@ set_tex_parameterf(struct gl_context *ctx,
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
if (ctx->Extensions.ARB_shadow_ambient) {
- if (texObj->CompareFailValue != params[0]) {
+ if (texObj->Sampler.CompareFailValue != params[0]) {
flush(ctx);
- texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F);
+ texObj->Sampler.CompareFailValue = CLAMP(params[0], 0.0F, 1.0F);
return GL_TRUE;
}
}
@@ -523,9 +523,9 @@ set_tex_parameterf(struct gl_context *ctx,
case GL_TEXTURE_LOD_BIAS:
/* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
if (ctx->Extensions.EXT_texture_lod_bias) {
- if (texObj->LodBias != params[0]) {
+ if (texObj->Sampler.LodBias != params[0]) {
flush(ctx);
- texObj->LodBias = params[0];
+ texObj->Sampler.LodBias = params[0];
return GL_TRUE;
}
return GL_FALSE;
@@ -536,15 +536,15 @@ set_tex_parameterf(struct gl_context *ctx,
flush(ctx);
/* ARB_texture_float disables clamping */
if (ctx->Extensions.ARB_texture_float) {
- texObj->BorderColor.f[RCOMP] = params[0];
- texObj->BorderColor.f[GCOMP] = params[1];
- texObj->BorderColor.f[BCOMP] = params[2];
- texObj->BorderColor.f[ACOMP] = params[3];
+ texObj->Sampler.BorderColor.f[RCOMP] = params[0];
+ texObj->Sampler.BorderColor.f[GCOMP] = params[1];
+ texObj->Sampler.BorderColor.f[BCOMP] = params[2];
+ texObj->Sampler.BorderColor.f[ACOMP] = params[3];
} else {
- texObj->BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F);
- texObj->BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F);
- texObj->BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F);
- texObj->BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F);
+ texObj->Sampler.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F);
+ texObj->Sampler.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F);
+ texObj->Sampler.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F);
+ texObj->Sampler.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F);
}
return GL_TRUE;
@@ -784,7 +784,7 @@ _mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
case GL_TEXTURE_BORDER_COLOR:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
/* set the integer-valued border color */
- COPY_4V(texObj->BorderColor.i, params);
+ COPY_4V(texObj->Sampler.BorderColor.i, params);
break;
default:
_mesa_TexParameteriv(target, pname, params);
@@ -814,7 +814,7 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
case GL_TEXTURE_BORDER_COLOR:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
/* set the unsigned integer-valued border color */
- COPY_4V(texObj->BorderColor.ui, params);
+ COPY_4V(texObj->Sampler.BorderColor.ui, params);
break;
default:
_mesa_TexParameteriv(target, pname, (const GLint *) params);
@@ -1101,36 +1101,36 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
_mesa_lock_texture(ctx, obj);
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
- *params = ENUM_TO_FLOAT(obj->MagFilter);
+ *params = ENUM_TO_FLOAT(obj->Sampler.MagFilter);
break;
case GL_TEXTURE_MIN_FILTER:
- *params = ENUM_TO_FLOAT(obj->MinFilter);
+ *params = ENUM_TO_FLOAT(obj->Sampler.MinFilter);
break;
case GL_TEXTURE_WRAP_S:
- *params = ENUM_TO_FLOAT(obj->WrapS);
+ *params = ENUM_TO_FLOAT(obj->Sampler.WrapS);
break;
case GL_TEXTURE_WRAP_T:
- *params = ENUM_TO_FLOAT(obj->WrapT);
+ *params = ENUM_TO_FLOAT(obj->Sampler.WrapT);
break;
case GL_TEXTURE_WRAP_R:
- *params = ENUM_TO_FLOAT(obj->WrapR);
+ *params = ENUM_TO_FLOAT(obj->Sampler.WrapR);
break;
case GL_TEXTURE_BORDER_COLOR:
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state_locked(ctx);
if(ctx->Color._ClampFragmentColor)
{
- params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
- params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
- params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
- params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
+ params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
+ params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
+ params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
+ params[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F);
}
else
{
- params[0] = obj->BorderColor.f[0];
- params[1] = obj->BorderColor.f[1];
- params[2] = obj->BorderColor.f[2];
- params[3] = obj->BorderColor.f[3];
+ params[0] = obj->Sampler.BorderColor.f[0];
+ params[1] = obj->Sampler.BorderColor.f[1];
+ params[2] = obj->Sampler.BorderColor.f[2];
+ params[3] = obj->Sampler.BorderColor.f[3];
}
break;
case GL_TEXTURE_RESIDENT:
@@ -1147,10 +1147,10 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
*params = obj->Priority;
break;
case GL_TEXTURE_MIN_LOD:
- *params = obj->MinLod;
+ *params = obj->Sampler.MinLod;
break;
case GL_TEXTURE_MAX_LOD:
- *params = obj->MaxLod;
+ *params = obj->Sampler.MaxLod;
break;
case GL_TEXTURE_BASE_LEVEL:
*params = (GLfloat) obj->BaseLevel;
@@ -1160,14 +1160,14 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
- *params = obj->MaxAnisotropy;
+ *params = obj->Sampler.MaxAnisotropy;
}
else
error = GL_TRUE;
break;
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
if (ctx->Extensions.ARB_shadow_ambient) {
- *params = obj->CompareFailValue;
+ *params = obj->Sampler.CompareFailValue;
}
else
error = GL_TRUE;
@@ -1177,28 +1177,28 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
break;
case GL_TEXTURE_COMPARE_MODE_ARB:
if (ctx->Extensions.ARB_shadow) {
- *params = (GLfloat) obj->CompareMode;
+ *params = (GLfloat) obj->Sampler.CompareMode;
}
else
error = GL_TRUE;
break;
case GL_TEXTURE_COMPARE_FUNC_ARB:
if (ctx->Extensions.ARB_shadow) {
- *params = (GLfloat) obj->CompareFunc;
+ *params = (GLfloat) obj->Sampler.CompareFunc;
}
else
error = GL_TRUE;
break;
case GL_DEPTH_TEXTURE_MODE_ARB:
if (ctx->Extensions.ARB_depth_texture) {
- *params = (GLfloat) obj->DepthMode;
+ *params = (GLfloat) obj->Sampler.DepthMode;
}
else
error = GL_TRUE;
break;
case GL_TEXTURE_LOD_BIAS:
if (ctx->Extensions.EXT_texture_lod_bias) {
- *params = obj->LodBias;
+ *params = obj->Sampler.LodBias;
}
else
error = GL_TRUE;
@@ -1265,27 +1265,27 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
_mesa_lock_texture(ctx, obj);
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
- *params = (GLint) obj->MagFilter;
+ *params = (GLint) obj->Sampler.MagFilter;
break;;
case GL_TEXTURE_MIN_FILTER:
- *params = (GLint) obj->MinFilter;
+ *params = (GLint) obj->Sampler.MinFilter;
break;;
case GL_TEXTURE_WRAP_S:
- *params = (GLint) obj->WrapS;
+ *params = (GLint) obj->Sampler.WrapS;
break;;
case GL_TEXTURE_WRAP_T:
- *params = (GLint) obj->WrapT;
+ *params = (GLint) obj->Sampler.WrapT;
break;;
case GL_TEXTURE_WRAP_R:
- *params = (GLint) obj->WrapR;
+ *params = (GLint) obj->Sampler.WrapR;
break;;
case GL_TEXTURE_BORDER_COLOR:
{
GLfloat b[4];
- b[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
- b[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
- b[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
- b[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
+ b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
+ b[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
+ b[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
+ b[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F);
params[0] = FLOAT_TO_INT(b[0]);
params[1] = FLOAT_TO_INT(b[1]);
params[2] = FLOAT_TO_INT(b[2]);
@@ -1306,10 +1306,10 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
*params = FLOAT_TO_INT(obj->Priority);
break;;
case GL_TEXTURE_MIN_LOD:
- *params = (GLint) obj->MinLod;
+ *params = (GLint) obj->Sampler.MinLod;
break;;
case GL_TEXTURE_MAX_LOD:
- *params = (GLint) obj->MaxLod;
+ *params = (GLint) obj->Sampler.MaxLod;
break;;
case GL_TEXTURE_BASE_LEVEL:
*params = obj->BaseLevel;
@@ -1319,7 +1319,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
- *params = (GLint) obj->MaxAnisotropy;
+ *params = (GLint) obj->Sampler.MaxAnisotropy;
}
else {
error = GL_TRUE;
@@ -1327,7 +1327,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
if (ctx->Extensions.ARB_shadow_ambient) {
- *params = (GLint) FLOAT_TO_INT(obj->CompareFailValue);
+ *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue);
}
else {
error = GL_TRUE;
@@ -1338,7 +1338,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_TEXTURE_COMPARE_MODE_ARB:
if (ctx->Extensions.ARB_shadow) {
- *params = (GLint) obj->CompareMode;
+ *params = (GLint) obj->Sampler.CompareMode;
}
else {
error = GL_TRUE;
@@ -1346,7 +1346,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_TEXTURE_COMPARE_FUNC_ARB:
if (ctx->Extensions.ARB_shadow) {
- *params = (GLint) obj->CompareFunc;
+ *params = (GLint) obj->Sampler.CompareFunc;
}
else {
error = GL_TRUE;
@@ -1354,7 +1354,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_DEPTH_TEXTURE_MODE_ARB:
if (ctx->Extensions.ARB_depth_texture) {
- *params = (GLint) obj->DepthMode;
+ *params = (GLint) obj->Sampler.DepthMode;
}
else {
error = GL_TRUE;
@@ -1362,7 +1362,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
break;
case GL_TEXTURE_LOD_BIAS:
if (ctx->Extensions.EXT_texture_lod_bias) {
- *params = (GLint) obj->LodBias;
+ *params = (GLint) obj->Sampler.LodBias;
}
else {
error = GL_TRUE;
@@ -1422,7 +1422,7 @@ _mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
switch (pname) {
case GL_TEXTURE_BORDER_COLOR:
- COPY_4V(params, texObj->BorderColor.i);
+ COPY_4V(params, texObj->Sampler.BorderColor.i);
break;
default:
_mesa_GetTexParameteriv(target, pname, params);
@@ -1442,7 +1442,7 @@ _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
switch (pname) {
case GL_TEXTURE_BORDER_COLOR:
- COPY_4V(params, texObj->BorderColor.i);
+ COPY_4V(params, texObj->Sampler.BorderColor.i);
break;
default:
{
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 82e69ae11b5..1810b88b2bf 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -407,7 +407,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
}
else if (format == GL_DEPTH_COMPONENT ||
format == GL_DEPTH_STENCIL_EXT) {
- format = texObj->DepthMode;
+ format = texObj->Sampler.DepthMode;
}
calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
texUnit->_CurrentCombine = & texUnit->_EnvMode;
@@ -827,6 +827,12 @@ _mesa_free_texture_data(struct gl_context *ctx)
/* GL_ARB_texture_buffer_object */
_mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
+
+#if FEATURE_sampler_objects
+ for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
+ }
+#endif
}