Re: [Mesa-dev] [PATCH 3/3] st/mesa: round lod_bias to a multiple of 1/256

2016-12-02 Thread Marek Olšák
On Fri, Dec 2, 2016 at 10:18 PM, Roland Scheidegger  wrote:
> 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...

AMD DX10 GPUs have 6 fractional bits. DX11 and later GPUs have 8
fractional bits.

Marek
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] st/mesa: round lod_bias to a multiple of 1/256

2016-12-02 Thread Roland Scheidegger
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 
> 
> 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;
> 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] st/mesa: round lod_bias to a multiple of 1/256

2016-12-02 Thread Marek Olšák
From: Marek Olšák 

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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev