title: Slow texture fetch in fragment shader using Vulkan
body: <p>I am doing a SSAO shader with a kernel size of 64.</p>
  
  <p>SSAO fragment shader:</p>
  
  <pre><code>const int kernelSize = 64;
  for (int i = 0; i &lt; kernelSize; i++) {
          //Get sample position
          vec3 s = tbn * ubo.kernel[i].xyz;
          s = s * radius + origin;
          vec4 offset = vec4(s, 1.0);
          offset = ubo.projection * offset;
          offset.xy /= offset.w;
          offset.xy = offset.xy * 0.5 + 0.5;
          float sampleDepth = texture(samplerposition, offset.xy).z;
          float rangeCheck = abs(origin.z - sampleDepth) &lt; radius ? 1.0 : 0.0;
          occlusion += (sampleDepth &gt;= s.z ? 1.0 : 0.0) * rangeCheck;
      }
  </code></pre>
  
  <p>The samplerposition texture has the format <code>VK_FORMAT_R16G16B16A16_SFLOAT</code> and is uploaded with the flag <code>VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT</code>.</p>
  
  <p>Im using a laptop with a nvidia K1100M graphic card. If I run the code in renderdoc, this shader takes <strong>114 ms</strong>. And if I change the <code>kernelSize</code> to 1, it takes <strong>1 ms</strong>.</p>
  
  <p>Is this texture fetch time normal? Or can it be that I have set up something wrong somewhere? </p>
  
  <p>Like the layout transition did not go through, so the texture is in <code>VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL</code> instead of <code>VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL</code>.</p>