title: Problem with HLSL looping/sampling
body: <p>I have a piece of HLSL code which looks like this:</p>
  
  <pre><code>float4 GetIndirection(float2 TexCoord)
  {
      float4 indirection = tex2D(IndirectionSampler, TexCoord);
  
      for (half mip = indirection.b * 255; mip &gt; 1 &amp;&amp; indirection.a &lt; 128; mip--)
      {
          indirection = tex2Dlod(IndirectionSampler, float4(TexCoord, 0, mip));
      }
      return indirection;
  }
  </code></pre>
  
  <p>The results I am getting are consistent with that loop only executing once. I checked the shader in PIX and things got even more weird, the yellow arrow indicating position in the code gets to the loop, goes through it once, and jumps back to the start, at that point the yellow arrow never moves again but the cursor moves through the code and returns a result (a bug in PIX, or am I just using it wrong?)</p>
  
  <p>I have a suspicion this may be a problem to do with texture reads getting moved outside the loop by the compiler, however I thought that didn't happen with tex2Dlod since I'm setting the LOD manually :/</p>
  
  <p>So:</p>
  
  <p>1) What's the problem?</p>
  
  <p>2) Any suggested solutions? </p>