<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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On 09/09/2015 04:35 AM, Krzesimir Nowak wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
This introduces new vfunc in tgsi_sampler just for this opcode. I<br>
decided against extending get_samples vfunc to return the mipmap level<br>
and LOD - the function's prototype is already too scary and doing the<br>
sampling for textureQueryLod would be a waste of time.<br>
---<br>
  src/gallium/auxiliary/tgsi/tgsi_exec.c | 44 ++++++++++++++++++++++++++++++++++<br>
  src/gallium/auxiliary/tgsi/tgsi_exec.h | 10 ++++++++<br>
  2 files changed, 54 insertions(+)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c<br>
index 9544623..054ad08 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c<br>
@@ -2132,6 +2132,44 @@ exec_tex(struct tgsi_exec_machine *mach,<br>
     }<br>
  }<br>
<br>
+static void<br>
+exec_lodq(struct tgsi_exec_machine *mach,<br>
+          const struct tgsi_full_instruction *inst)<br>
+{<br>
+   uint unit;<br>
+   int dim;<br>
+   int i;<br>
+   union tgsi_exec_channel coords[4];<br>
+   const union tgsi_exec_channel *args[Elements(coords)];<br>
+   union tgsi_exec_channel r[2];<br>
+<br>
+   unit = fetch_sampler_unit(mach, inst, 1);<br>
+   dim = tgsi_util_get_texture_coord_dim(inst->Texture.Texture, NULL);<br>
+   assert(dim <= Elements(coords));<br>
+   /* fetch coordinates */<br>
+   for (i = 0; i < dim; i++) {<br>
+      FETCH(&coords[i], 0, TGSI_CHAN_X + i);<br>
+      args[i] = &coords[i];<br>
+   }<br>
+   for (i = dim; i < Elements(coords); i++) {<br>
+      args[i] = &ZeroVec;<br>
+   }<br>
+   mach->Sampler->query_lod(mach->Sampler, unit, unit,<br>
+                            args[0]->f,<br>
+                            args[1]->f,<br>
+                            args[2]->f,<br>
+                            args[3]->f,<br>
+                            tgsi_sampler_lod_none,<br>
+                            r[0].f,<br>
+                            r[1].f);<br>
+<br>
+   if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {<br>
+      store_dest(mach, &r[0], &inst->Dst[0], inst, TGSI_CHAN_X, TGSI_EXEC_DATA_FLOAT);<br>
+   }<br>
+   if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {<br>
+      store_dest(mach, &r[1], &inst->Dst[0], inst, TGSI_CHAN_Y, TGSI_EXEC_DATA_FLOAT);<br>
+   }<br>
+}<br>
<br>
  static void<br>
  exec_txd(struct tgsi_exec_machine *mach,<br>
@@ -4378,6 +4416,12 @@ exec_instruction(<br>
        exec_tex(mach, inst, TEX_MODIFIER_GATHER, 2);<br>
        break;<br>
<br>
+   case TGSI_OPCODE_LODQ:<br>
+      /* src[0] = texcoord */<br>
+      /* src[1] = sampler unit */<br>
+      exec_lodq(mach, inst);<br>
+      break;<br>
+<br>
     case TGSI_OPCODE_UP2H:<br>
        assert (0);<br>
        break;<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
index 5d56aab..556e0af 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h<br>
@@ -138,6 +138,16 @@ struct tgsi_sampler<br>
                       const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE],<br>
                       const int lod[TGSI_QUAD_SIZE], const int8_t offset[3],<br>
                       float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);<br>
+   void (*query_lod)(struct tgsi_sampler *tgsi_sampler,<br>
</blockquote>
<br></div></div>
Can tgsi_sampler be const-qualified?<span class=""><br></span></blockquote><div><br></div><div>It cannot be. I tried, but later, on softpipe side, we get the sp_sampler instance and modify it in convert_cube. It is nothing that ugly cast cannot "fix", but yeah...<br><br></div><div>This seems like hack I could fix in followup commits:<br><a href="http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/softpipe/sp_tex_sample.h?id=bf58a2c362d5afdba512f40b3eb300154201c7f0#n122">http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/softpipe/sp_tex_sample.h?id=bf58a2c362d5afdba512f40b3eb300154201c7f0#n122</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+                     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>
<br>
  #define TGSI_EXEC_NUM_TEMPS       4096<br>
<br>
</blockquote>
<br></span>
Reviewed-by: Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>><br>
<br>
</blockquote></div><br></div></div>