summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2014-06-14 02:49:11 +0200
committerMarek Olšák <[email protected]>2014-06-19 00:17:09 +0200
commit552c70a837b68124a8cd85873d45075fa17659f4 (patch)
treec3a3dc14a91b2d1c715cbb7709138a7f1572b3ed
parentc530282bbc5e235bee11f3d253d1bda20f5b98ba (diff)
st/mesa: set sampler_view::last_level correctly
It was set to pipe_resource::last_level and _MaxLevel was embedded in max_lod, that's why it worked for ordinary texturing. However, min_lod doesn't have any effect on texelFetch and textureQueryLevels, so we must still set last_level correctly. Reviewed-by: Roland Scheidegger <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c7
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c11
2 files changed, 12 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 3929251f83a..17b536bf504 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -160,11 +160,8 @@ convert_sampler(struct st_context *st,
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.
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index f34a5986308..2e10bc3e241 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -212,6 +212,12 @@ check_sampler_swizzle(const struct st_texture_object *stObj,
}
+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,
@@ -244,6 +250,8 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
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) {
@@ -279,7 +287,8 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
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);
}
}