sampler->lod_bias = ctx->Texture.Unit[texUnit].LodBias + msamp->LodBias;
- sampler->min_lod = CLAMP(msamp->MinLod,
- 0.0f,
- (GLfloat) texobj->MaxLevel - texobj->BaseLevel);
- sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel - texobj->BaseLevel,
- msamp->MaxLod);
+ sampler->min_lod = MAX2(msamp->MinLod, 0.0f);
+ sampler->max_lod = msamp->MaxLod;
if (sampler->max_lod < sampler->min_lod) {
/* The GL spec doesn't seem to specify what to do in this case.
* Swap the values.
}
+static unsigned last_level(struct st_texture_object *stObj)
+{
+ return MIN2(stObj->base._MaxLevel, stObj->pt->last_level);
+}
+
+
static struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
struct st_texture_object *stObj,
templ.u.buf.last_element = f + (n - 1);
} else {
templ.u.tex.first_level = stObj->base.BaseLevel;
+ templ.u.tex.last_level = last_level(stObj);
+ assert(templ.u.tex.first_level <= templ.u.tex.last_level);
}
if (swizzle != SWIZZLE_NOOP) {
if (*sv) {
if (check_sampler_swizzle(stObj, *sv) ||
(format != (*sv)->format) ||
- stObj->base.BaseLevel != (*sv)->u.tex.first_level) {
+ stObj->base.BaseLevel != (*sv)->u.tex.first_level ||
+ last_level(stObj) != (*sv)->u.tex.last_level) {
pipe_sampler_view_reference(sv, NULL);
}
}