[Mesa-dev] [PATCH 3/3] st/mesa: round lod_bias to a multiple of 1/256
Roland Scheidegger
sroland at vmware.com
Fri Dec 2 21:18:27 UTC 2016
Ideally this wouldn't be tied to specific hardware... That said, I
believe the clamping limits are sane (d3d10 will use these too). If GL
has some requirements for lod accuracy or if it's queryable, it should
probably honor this (d3d10 only would require 6 fractional bits),
although I'd guess that 8 fractional bits is probably safe...
Roland
Am 02.12.2016 um 21:38 schrieb Marek Olšák:
> 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;
>
More information about the mesa-dev
mailing list