title: Copying a single layer of a 2D Texture Array from GPU to CPU
body: <p>I'm using a 2D texture array to store some data. As I often want to bind single layers of this 2D texture array, I create individual <em>GL_TEXTURE_2D</em> texture views for each layer:</p>
  
  <pre><code>for(int l(0); l &lt; m_layers; l++)
  {
      QOpenGLTexture * view_texture = m_texture.createTextureView(QOpenGLTexture::Target::Target2D,
                                                                  m_texture_format,
                                                                  0,0,
                                                                  l,l);
      view_texture-&gt;setMinMagFilters(QOpenGLTexture::Filter::Linear, QOpenGLTexture::Filter::Linear);
      view_texture-&gt;setWrapMode(QOpenGLTexture::WrapMode::MirroredRepeat);
      assert(view_texture != 0);
  
      m_texture_views.push_back(view_texture);
  }
  </code></pre>
  
  <p>These 2D TextureViews work fine. However, if I want to retrieve the 2D texture data from the GPU side using that texture view it doesn't work.</p>
  
  <p>In other words, the following copies no data (but throws no GL errors):</p>
  
  <pre><code>glGetTexImage(GL_TEXTURE_2D, 0, m_pixel_format, m_pixel_type, (GLvoid*) m_raw_data[layer] )
  </code></pre>
  
  <p>However, retrieving the entire <em>GL_TEXTURE_2D_ARRAY</em> does work:</p>
  
  <pre><code>glGetTexImage(GL_TEXTURE_2D_ARRAY, 0, m_pixel_format, m_pixel_type, (GLvoid*) data );
  </code></pre>
  
  <p>There would obviously be a performance loss if I need to copy across all layers of the 2D texture array when only data for a single layer has been modified.</p>
  
  <p>Is there a way to copy GPU->CPU only a single layer of a <em>GL_TEXTURE_2D_ARRAY</em>? I know there is for the opposite (i.e CPU->GPU) so I would be surprised if there wasn't.</p>