[Mesa-dev] [PATCH 3/3] st/mesa: round lod_bias to a multiple of 1/256
Marek Olšák
maraeo at gmail.com
Fri Dec 2 20:38:59 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
This reduces the number of sampler states 3.6x in Batman Arkham: Origins.
(from ~7200 to ~2000)
---
src/mesa/state_tracker/st_atom_sampler.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 4568630..daf98c3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -152,20 +152,26 @@ convert_sampler(struct st_context *st,
sampler->wrap_r = gl_wrap_xlate(msamp->WrapR);
sampler->min_img_filter = gl_filter_to_img_filter(msamp->MinFilter);
sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->MinFilter);
sampler->mag_img_filter = gl_filter_to_img_filter(msamp->MagFilter);
if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
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;
if (sampler->max_lod < sampler->min_lod) {
/* The GL spec doesn't seem to specify what to do in this case.
* Swap the values.
*/
float tmp = sampler->max_lod;
sampler->max_lod = sampler->min_lod;
sampler->min_lod = tmp;
--
2.7.4
More information about the mesa-dev
mailing list