<div dir="ltr">On Wed, Sep 9, 2015 at 5:26 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 09/09/2015 04:35 AM, Krzesimir Nowak wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Passes the shader piglit tests and introduces no regressions.<br>
<br>
This commit finally makes use of the refactoring in previous<br>
commits.<br>
---<br>
  src/gallium/drivers/softpipe/sp_screen.c     |  2 +-<br>
  src/gallium/drivers/softpipe/sp_tex_sample.c | 47 +++++++++++++++++++++++++++-<br>
  2 files changed, 47 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c<br>
index 0bfd9c3..7ca8a67 100644<br>
--- a/src/gallium/drivers/softpipe/sp_screen.c<br>
+++ b/src/gallium/drivers/softpipe/sp_screen.c<br>
@@ -193,9 +193,9 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)<br>
     case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:<br>
        return 4;<br>
     case PIPE_CAP_TEXTURE_GATHER_SM5:<br>
+   case PIPE_CAP_TEXTURE_QUERY_LOD:<br>
        return 1;<br>
     case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:<br>
-   case PIPE_CAP_TEXTURE_QUERY_LOD:<br>
     case PIPE_CAP_SAMPLE_SHADING:<br>
     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:<br>
        return 0;<br>
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c<br>
index 6e639e0..499c8f9 100644<br>
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c<br>
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c<br>
@@ -3566,6 +3566,51 @@ sp_tgsi_get_samples(struct tgsi_sampler *tgsi_sampler,<br>
     sample_mip(sp_sview, sp_samp, cs, ct, cp, c0, lod, &filt_args, rgba);<br>
  }<br>
<br>
+static void<br>
+sp_tgsi_query_lod(struct tgsi_sampler *tgsi_sampler,<br>
+                  const unsigned sview_index,<br>
+                  const unsigned sampler_index,<br>
+                  const float s[TGSI_QUAD_SIZE],<br>
+                  const float t[TGSI_QUAD_SIZE],<br>
+                  const float p[TGSI_QUAD_SIZE],<br>
+                  const float c0[TGSI_QUAD_SIZE],<br>
+                  enum tgsi_sampler_control control,<br>
+                  float mipmap[TGSI_QUAD_SIZE],<br>
+                  float lod[TGSI_QUAD_SIZE])<br>
+{<br>
+   static const float lod_in[TGSI_QUAD_SIZE] = { 0.0, 0.0, 0.0, 0.0 };<br>
+<br>
+   struct sp_tgsi_sampler *sp_tgsi_samp = (struct sp_tgsi_sampler *)tgsi_sampler;<br>
</blockquote>
<br></div></div>
Can that be const-qualified, and the tgsi_sampler function parameter?<br></blockquote><div><br></div><div>It cannot for now - please see my reply for patch 8/9.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ideally, we'd also have a cast-wrapper function to use instead of an inline cast here and elsewhere.  That could be done as a follow-up.<div><div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+   struct sp_sampler_view *sp_sview;<br>
+   struct sp_sampler *sp_samp;<br>
+   struct sp_mip *mip;<br>
+   int i;<br>
+   float cs[TGSI_QUAD_SIZE];<br>
+   float ct[TGSI_QUAD_SIZE];<br>
+   float cp[TGSI_QUAD_SIZE];<br>
+<br>
+   assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);<br>
+   assert(sampler_index < PIPE_MAX_SAMPLERS);<br>
+   assert(sp_tgsi_samp->sp_sampler[sampler_index]);<br>
+<br>
+   sp_sview = &sp_tgsi_samp->sp_sview[sview_index];<br>
+   sp_samp = sp_tgsi_samp->sp_sampler[sampler_index];<br>
+   /* always have a view here but texture is NULL if no sampler view was set. */<br>
+   if (!sp_sview->base.texture) {<br>
+      for (i = 0; i < TGSI_QUAD_SIZE; i++) {<br>
+         mipmap[i] = 0.0f;<br>
+         lod[i] = 0.0f;<br>
+      }<br>
+      return;<br>
+   }<br>
+<br>
+   sp_sview->convert_coords(sp_sview, sp_samp, s, t, p, c0, cs, ct, cp);<br>
+<br>
+   compute_lambda_lod_not_clamped(sp_sview, sp_samp,<br>
+                                  cs, ct, cp, lod_in, control, lod);<br>
+   get_filters(sp_sview, sp_samp, control, &mip, NULL, NULL);<br>
+   mip->level(sp_sview, sp_samp, lod, mipmap);<br>
+}<br>
<br>
  static void<br>
  sp_tgsi_get_texel(struct tgsi_sampler *tgsi_sampler,<br>
@@ -3602,7 +3647,7 @@ sp_create_tgsi_sampler(void)<br>
     samp->base.get_dims = sp_tgsi_get_dims;<br>
     samp->base.get_samples = sp_tgsi_get_samples;<br>
     samp->base.get_texel = sp_tgsi_get_texel;<br>
+   samp->base.query_lod = sp_tgsi_query_lod;<br>
<br>
     return samp;<br>
  }<br>
-<br>
<br>
</blockquote>
<br></div></div>
Reviewed-by: Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>><br>
<br>
</blockquote></div><br></div></div>