title: performance warning when using glMapBufferRange
body: <p>When i try to update an array buffer using <code>glMapBufferRange</code>, the data updates but as soon as the next draw of the buffer occurs a performance warning is generated (via <code>glDebugMessageCallback</code>) as follows:</p>
  
  <blockquote>
    <p>"Buffer performance warning: Buffer object 3 (bound to
    GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (0),
    GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (1),
    GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (2),
    GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (3), and
    GL_ARRAY_BUFFER_ARB, usage hint is GL_STREAM_DRAW) is being
    copied/moved from VIDEO memory to HOST memory."</p>
  </blockquote>
  
  <p>I create the array buffer as follows:</p>
  
  <pre><code>glGenBuffers(1, &amp;vbo);
  glBindBuffer(GL_ARRAY_BUFFER, vbo);
  glBufferData(GL_ARRAY_BUFFER, dataSizeBytes, vertData,GL_STREAM_DRAW);
  </code></pre>
  
  <p>Then i update with replacement vertex data:</p>
  
  <pre><code>//NO PERFORMANCE WARNING IF I USE glBufferSubData
  //glBufferSubData(GL_ARRAY_BUFFER, 0, dataSizeBytes, vertData);
  
  float* dataBlock = reinterpret_cast&lt;float*&gt;(
      glMapBufferRange(GL_ARRAY_BUFFER, 0,
      dataSizeBytes,
      GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT));
  
  memcpy(dataBlock, vertData, dataSizeBytes);
  glUnmapBuffer(GL_ARRAY_BUFFER);
  </code></pre>
  
  <p>As soon as <code>glDrawElements</code> is called for this buffer the performance warning is generated.  I tried removing the unsynchronized flag and the invalidate flag but those didnt seem to make a difference. </p>
  
  <p>I assume im doing something wrong but im not sure what it is.  The code still works and draws everything correctly (but i see that performance warning which irks me). As commented <code>glBufferSubData</code> doesnt generate any warning, but <code>glMapBufferRange</code> triggers the error (after draw).</p>
  
  <p>If i try to update the <code>ELEMENT_ARRAY_BUFFER</code> i get a similar performance warning.</p>
  
  <hr>
  
  <p>UPDATE 1:
  If I allocate the data with <code>GL_STREAM_DRAW</code> or <code>GL_DYNAMIC_DRAW</code> I get the performance warning. If I use <code>GL_STATIC_DRAW</code> I get no warning.  However this vertex buffer is meant to be updated every frame.  If I use <code>glBufferSubData</code> I get no warning regardless of the storage hint.</p>