Re: [Mesa-dev] [PATCH] st/mesa: also clamp and quantize per-unit lod bias

2017-07-26 Thread Nicolai Hähnle

On 25.07.2017 18:51, Samuel Pitoiset wrote:

This should probably go to stable too.


It's not strictly a bug fix, but I guess it's small enough for 17.2.

Reviewed-by: Nicolai Hähnle 



Reviewed-by: Samuel Pitoiset 

On 07/25/2017 05:36 PM, Marek Olšák wrote:

From: Marek Olšák 

---
  src/mesa/state_tracker/st_atom_sampler.c | 7 ---
  src/mesa/state_tracker/st_cb_texture.c   | 2 +-
  src/mesa/state_tracker/st_texture.h  | 1 +
  3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c

index 208b6f7..d9e8de3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -98,35 +98,36 @@ gl_filter_to_img_filter(GLenum filter)
  }
  /**
   * Convert a gl_sampler_object to a pipe_sampler_state object.
   */
  void
  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler)
  {
 memset(sampler, 0, sizeof(*sampler));
 sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
 sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
 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 = msamp->LodBias;
+   sampler->lod_bias = msamp->LodBias + tex_unit_lod_bias;
 /* 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) {
@@ -234,23 +235,23 @@ st_convert_sampler_from_unit(const struct 
st_context *st,

 const struct gl_texture_object *texobj;
 struct gl_context *ctx = st->ctx;
 const struct gl_sampler_object *msamp;
 texobj = ctx->Texture.Unit[texUnit]._Current;
 assert(texobj);
 assert(texobj->Target != GL_TEXTURE_BUFFER);
 msamp = _mesa_get_samplerobj(ctx, texUnit);
-   st_convert_sampler(st, texobj, msamp, sampler);
+   st_convert_sampler(st, texobj, msamp, 
ctx->Texture.Unit[texUnit].LodBias,

+  sampler);
-   sampler->lod_bias += ctx->Texture.Unit[texUnit].LodBias;
 sampler->seamless_cube_map |= ctx->Texture.CubeMapSeamless;
  }
  /**
   * Update the gallium driver's sampler state for fragment, vertex or
   * geometry shader stage.
   */
  static void
  update_shader_samplers(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c

index f66e1bd..eba9c30 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2965,21 +2965,21 @@ st_NewTextureHandle(struct gl_context *ctx, 
struct gl_texture_object *texObj,

 struct st_context *st = st_context(ctx);
 struct st_texture_object *stObj = st_texture_object(texObj);
 struct pipe_context *pipe = st->pipe;
 struct pipe_sampler_view *view;
 struct pipe_sampler_state sampler = {0};
 if (texObj->Target != GL_TEXTURE_BUFFER) {
if (!st_finalize_texture(ctx, pipe, texObj, 0))
   return 0;
-  st_convert_sampler(st, texObj, sampObj, );
+  st_convert_sampler(st, texObj, sampObj, 0, );
view = st_get_texture_sampler_view_from_stobj(st, stObj, 
sampObj, 0);

 } else {
view = st_get_buffer_sampler_view_from_stobj(st, stObj);
 }
 return pipe->create_texture_handle(pipe, view, );
  }
  static void
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h

index a6f6ee8..8448f4c 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -274,20 +274,21 @@ st_convert_image(const struct st_context *st, 
const struct gl_image_unit *u,

  void
  st_convert_image_from_unit(const struct st_context *st,
 struct pipe_image_view *img,
 GLuint imgUnit);
  void
  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler);
  void
  st_convert_sampler_from_unit(const struct st_context *st,
 

Re: [Mesa-dev] [PATCH] st/mesa: also clamp and quantize per-unit lod bias

2017-07-26 Thread Nicolai Hähnle

On 25.07.2017 18:51, Samuel Pitoiset wrote:

This should probably go to stable too.


It's not technically a bug, but I suppose it's fine.

Either way, the patch is

Reviewed-by: Nicolai Hähnle 





Reviewed-by: Samuel Pitoiset 

On 07/25/2017 05:36 PM, Marek Olšák wrote:

From: Marek Olšák 

---
  src/mesa/state_tracker/st_atom_sampler.c | 7 ---
  src/mesa/state_tracker/st_cb_texture.c   | 2 +-
  src/mesa/state_tracker/st_texture.h  | 1 +
  3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c

index 208b6f7..d9e8de3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -98,35 +98,36 @@ gl_filter_to_img_filter(GLenum filter)
  }
  /**
   * Convert a gl_sampler_object to a pipe_sampler_state object.
   */
  void
  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler)
  {
 memset(sampler, 0, sizeof(*sampler));
 sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
 sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
 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 = msamp->LodBias;
+   sampler->lod_bias = msamp->LodBias + tex_unit_lod_bias;
 /* 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) {
@@ -234,23 +235,23 @@ st_convert_sampler_from_unit(const struct 
st_context *st,

 const struct gl_texture_object *texobj;
 struct gl_context *ctx = st->ctx;
 const struct gl_sampler_object *msamp;
 texobj = ctx->Texture.Unit[texUnit]._Current;
 assert(texobj);
 assert(texobj->Target != GL_TEXTURE_BUFFER);
 msamp = _mesa_get_samplerobj(ctx, texUnit);
-   st_convert_sampler(st, texobj, msamp, sampler);
+   st_convert_sampler(st, texobj, msamp, 
ctx->Texture.Unit[texUnit].LodBias,

+  sampler);
-   sampler->lod_bias += ctx->Texture.Unit[texUnit].LodBias;
 sampler->seamless_cube_map |= ctx->Texture.CubeMapSeamless;
  }
  /**
   * Update the gallium driver's sampler state for fragment, vertex or
   * geometry shader stage.
   */
  static void
  update_shader_samplers(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c

index f66e1bd..eba9c30 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2965,21 +2965,21 @@ st_NewTextureHandle(struct gl_context *ctx, 
struct gl_texture_object *texObj,

 struct st_context *st = st_context(ctx);
 struct st_texture_object *stObj = st_texture_object(texObj);
 struct pipe_context *pipe = st->pipe;
 struct pipe_sampler_view *view;
 struct pipe_sampler_state sampler = {0};
 if (texObj->Target != GL_TEXTURE_BUFFER) {
if (!st_finalize_texture(ctx, pipe, texObj, 0))
   return 0;
-  st_convert_sampler(st, texObj, sampObj, );
+  st_convert_sampler(st, texObj, sampObj, 0, );
view = st_get_texture_sampler_view_from_stobj(st, stObj, 
sampObj, 0);

 } else {
view = st_get_buffer_sampler_view_from_stobj(st, stObj);
 }
 return pipe->create_texture_handle(pipe, view, );
  }
  static void
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h

index a6f6ee8..8448f4c 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -274,20 +274,21 @@ st_convert_image(const struct st_context *st, 
const struct gl_image_unit *u,

  void
  st_convert_image_from_unit(const struct st_context *st,
 struct pipe_image_view *img,
 GLuint imgUnit);
  void
  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler);
  void
  st_convert_sampler_from_unit(const struct st_context *st,
 

Re: [Mesa-dev] [PATCH] st/mesa: also clamp and quantize per-unit lod bias

2017-07-25 Thread Samuel Pitoiset

This should probably go to stable too.

Reviewed-by: Samuel Pitoiset 

On 07/25/2017 05:36 PM, Marek Olšák wrote:

From: Marek Olšák 

---
  src/mesa/state_tracker/st_atom_sampler.c | 7 ---
  src/mesa/state_tracker/st_cb_texture.c   | 2 +-
  src/mesa/state_tracker/st_texture.h  | 1 +
  3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index 208b6f7..d9e8de3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -98,35 +98,36 @@ gl_filter_to_img_filter(GLenum filter)
  }
  
  
  /**

   * Convert a gl_sampler_object to a pipe_sampler_state object.
   */
  void
  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler)
  {
 memset(sampler, 0, sizeof(*sampler));
 sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
 sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
 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 = msamp->LodBias;

+   sampler->lod_bias = msamp->LodBias + tex_unit_lod_bias;
 /* 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) {
@@ -234,23 +235,23 @@ st_convert_sampler_from_unit(const struct st_context *st,
 const struct gl_texture_object *texobj;
 struct gl_context *ctx = st->ctx;
 const struct gl_sampler_object *msamp;
  
 texobj = ctx->Texture.Unit[texUnit]._Current;

 assert(texobj);
 assert(texobj->Target != GL_TEXTURE_BUFFER);
  
 msamp = _mesa_get_samplerobj(ctx, texUnit);
  
-   st_convert_sampler(st, texobj, msamp, sampler);

+   st_convert_sampler(st, texobj, msamp, ctx->Texture.Unit[texUnit].LodBias,
+  sampler);
  
-   sampler->lod_bias += ctx->Texture.Unit[texUnit].LodBias;

 sampler->seamless_cube_map |= ctx->Texture.CubeMapSeamless;
  }
  
  
  /**

   * Update the gallium driver's sampler state for fragment, vertex or
   * geometry shader stage.
   */
  static void
  update_shader_samplers(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index f66e1bd..eba9c30 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2965,21 +2965,21 @@ st_NewTextureHandle(struct gl_context *ctx, struct 
gl_texture_object *texObj,
 struct st_context *st = st_context(ctx);
 struct st_texture_object *stObj = st_texture_object(texObj);
 struct pipe_context *pipe = st->pipe;
 struct pipe_sampler_view *view;
 struct pipe_sampler_state sampler = {0};
  
 if (texObj->Target != GL_TEXTURE_BUFFER) {

if (!st_finalize_texture(ctx, pipe, texObj, 0))
   return 0;
  
-  st_convert_sampler(st, texObj, sampObj, );

+  st_convert_sampler(st, texObj, sampObj, 0, );
view = st_get_texture_sampler_view_from_stobj(st, stObj, sampObj, 0);
 } else {
view = st_get_buffer_sampler_view_from_stobj(st, stObj);
 }
  
 return pipe->create_texture_handle(pipe, view, );

  }
  
  
  static void

diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index a6f6ee8..8448f4c 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -274,20 +274,21 @@ st_convert_image(const struct st_context *st, const 
struct gl_image_unit *u,
  
  void

  st_convert_image_from_unit(const struct st_context *st,
 struct pipe_image_view *img,
 GLuint imgUnit);
  
  void

  st_convert_sampler(const struct st_context *st,
 const struct gl_texture_object *texobj,
 const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
 struct pipe_sampler_state *sampler);
  
  void

  st_convert_sampler_from_unit(const struct st_context *st,
   struct pipe_sampler_state *sampler,
   GLuint texUnit);
  
  void

  

[Mesa-dev] [PATCH] st/mesa: also clamp and quantize per-unit lod bias

2017-07-25 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/state_tracker/st_atom_sampler.c | 7 ---
 src/mesa/state_tracker/st_cb_texture.c   | 2 +-
 src/mesa/state_tracker/st_texture.h  | 1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c 
b/src/mesa/state_tracker/st_atom_sampler.c
index 208b6f7..d9e8de3 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -98,35 +98,36 @@ gl_filter_to_img_filter(GLenum filter)
 }
 
 
 /**
  * Convert a gl_sampler_object to a pipe_sampler_state object.
  */
 void
 st_convert_sampler(const struct st_context *st,
const struct gl_texture_object *texobj,
const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
struct pipe_sampler_state *sampler)
 {
memset(sampler, 0, sizeof(*sampler));
sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
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 = msamp->LodBias;
+   sampler->lod_bias = msamp->LodBias + tex_unit_lod_bias;
/* 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) {
@@ -234,23 +235,23 @@ st_convert_sampler_from_unit(const struct st_context *st,
const struct gl_texture_object *texobj;
struct gl_context *ctx = st->ctx;
const struct gl_sampler_object *msamp;
 
texobj = ctx->Texture.Unit[texUnit]._Current;
assert(texobj);
assert(texobj->Target != GL_TEXTURE_BUFFER);
 
msamp = _mesa_get_samplerobj(ctx, texUnit);
 
-   st_convert_sampler(st, texobj, msamp, sampler);
+   st_convert_sampler(st, texobj, msamp, ctx->Texture.Unit[texUnit].LodBias,
+  sampler);
 
-   sampler->lod_bias += ctx->Texture.Unit[texUnit].LodBias;
sampler->seamless_cube_map |= ctx->Texture.CubeMapSeamless;
 }
 
 
 /**
  * Update the gallium driver's sampler state for fragment, vertex or
  * geometry shader stage.
  */
 static void
 update_shader_samplers(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index f66e1bd..eba9c30 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2965,21 +2965,21 @@ st_NewTextureHandle(struct gl_context *ctx, struct 
gl_texture_object *texObj,
struct st_context *st = st_context(ctx);
struct st_texture_object *stObj = st_texture_object(texObj);
struct pipe_context *pipe = st->pipe;
struct pipe_sampler_view *view;
struct pipe_sampler_state sampler = {0};
 
if (texObj->Target != GL_TEXTURE_BUFFER) {
   if (!st_finalize_texture(ctx, pipe, texObj, 0))
  return 0;
 
-  st_convert_sampler(st, texObj, sampObj, );
+  st_convert_sampler(st, texObj, sampObj, 0, );
   view = st_get_texture_sampler_view_from_stobj(st, stObj, sampObj, 0);
} else {
   view = st_get_buffer_sampler_view_from_stobj(st, stObj);
}
 
return pipe->create_texture_handle(pipe, view, );
 }
 
 
 static void
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index a6f6ee8..8448f4c 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -274,20 +274,21 @@ st_convert_image(const struct st_context *st, const 
struct gl_image_unit *u,
 
 void
 st_convert_image_from_unit(const struct st_context *st,
struct pipe_image_view *img,
GLuint imgUnit);
 
 void
 st_convert_sampler(const struct st_context *st,
const struct gl_texture_object *texobj,
const struct gl_sampler_object *msamp,
+   float tex_unit_lod_bias,
struct pipe_sampler_state *sampler);
 
 void
 st_convert_sampler_from_unit(const struct st_context *st,
  struct pipe_sampler_state *sampler,
  GLuint texUnit);
 
 void
 st_update_single_texture(struct st_context *st,
  struct pipe_sampler_view **sampler_view,
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org