title: Arrays in uniform blocks cannot be indexed with vertex attributes, right?
body: <p>I was wondering if I can index into a uniform buffer array with a value contained in the vertices I draw, like:</p>
  <pre><code>layout (location = 0) in vec3 position;
  layout (location = 1) in flat int idx;
  
  layout(binding = 0, std140) uniform uniformValues
      {
          float values[100];
  };
  
  void main() 
  {
       values[idx];
  }
  </code></pre>
  <p>My understanding is that this is not possible because</p>
  <pre><code>'in flat int idx'
  </code></pre>
  <p>Is most likely not a 'dynamically uniform expression', and according to the documentation cannot be used to index into a uniform buffer array:</p>
  <blockquote>
  <p>There are places where GLSL requires the expression to be dynamically
  uniform. All of the following must use a dynamically uniform
  expression:</p>
  <pre><code>-The index to buffer-backed interface block arrays.
  </code></pre>
  </blockquote>
  <p>However I came across information from the <a href="https://www.khronos.org/opengl/wiki/Bindless_Texture" rel="nofollow noreferrer">same source</a> regarding how to access an array of samplers holding texture handles for 'bindless textures', and it says (emphasis mine):</p>
  <blockquote>
  <p>Sampler and image types used in default block uniform variables can be
  populated from handles rather than the index of a binding point.
  <strong>These types can also now be passed as Shader Stage inputs/outputs (using the flat interpolation qualifier where needed).</strong> <strong>They can be
  used as Vertex Attributes,</strong> where they are treated as 64-bit integers
  on the OpenGL side. And they <strong>can be used in Interface Blocks of all
  kinds</strong>; buffer-backed interface blocks treat them as 64-bit integers.</p>
  </blockquote>
  <p>It's saying, I believe, that instead of doing this:</p>
  <pre><code>layout (location = 0) in flat int textureBinding;
  
  layout (binding = 0) uniform sampler2D textures[16];
  
  void main()
  {
       textures[textureBinding];
  }
  </code></pre>
  <p>You do this:</p>
  <pre><code>layout (location = 0) in flat int bindlessTextureHandle;
  
  layout (binding = 0) uniform textureBuffer 
  {
        sampler2D textures[200];
  }
  
  void main()
  {
       textures[bindlessTextureHandle];
  }
  </code></pre>
  <p>'bindlessTextureHandle' isn't a 'dynamically uniform expression', how can it be used to index into uniform buffer?</p>
  <p>All of the following must use a dynamically uniformexpression:</p>
  <blockquote>
  <pre><code>-The index to buffer-backed interface block arrays.
  </code></pre>
  </blockquote>
  <p>So why is it saying that you can index into 'interface blocks' of all kinds with values from vertex inputs?</p>
  <p>Also are you allowed to index into:</p>
  <pre><code>'uniform sampler2D[16] textures;'
  </code></pre>
  <p>with a 'non-dynamically uniform expression'?</p>