summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-12-02 16:37:22 +0100
committerMarek Olšák <[email protected]>2016-12-07 18:46:54 +0100
commit132b69c4edb824c70c98f8937c63e49b04f3adff (patch)
tree4ecb36a0bc0b9743c9795c79619a11f171ac8a9e /src/mesa
parent4b0d8b2da09c4d3be675d4312a9efd832126b98c (diff)
st/mesa: round lod_bias to a multiple of 1/256
This reduces the number of sampler states 3.6x in Batman Arkham: Origins. (from ~7200 to ~2000) Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 4568630fd2c..daf98c3abb0 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -159,6 +159,12 @@ convert_sampler(struct st_context *st,
sampler->normalized_coords = 1;
sampler->lod_bias = ctx->Texture.Unit[texUnit].LodBias + msamp->LodBias;
+ /* Reduce the number of states by allowing only the values that AMD GCN
+ * can represent. Apps use lod_bias for smooth transitions to bigger mipmap
+ * levels.
+ */
+ sampler->lod_bias = CLAMP(sampler->lod_bias, -16, 16);
+ sampler->lod_bias = floorf(sampler->lod_bias * 256) / 256;
sampler->min_lod = MAX2(msamp->MinLod, 0.0f);
sampler->max_lod = msamp->MaxLod;