Quantcast
Channel: AMD Developer Forums: Message List - OpenGL & Vulkan
Viewing all articles
Browse latest Browse all 631

Buffer to Buffer Copy not working

$
0
0

The following code doesn't actually seem to copy data correctly on either an HD7750 or an HD6450

 

               GLuinttempVBO;          glGenBuffers(1,&tempVBO);          glBindBuffer(GL_COPY_READ_BUFFER,tempVBO);                glBindBuffer(GL_ARRAY_BUFFER, srcVBO);          glBufferData(GL_COPY_READ_BUFFER,oldByteCount,NULL,GL_STATIC_COPY);          glCopyBufferSubData(GL_ARRAY_BUFFER,GL_COPY_READ_BUFFER,0,0,oldByteCount);               glBufferData(GL_ARRAY_BUFFER,newByteCount,NULL,GL_STATIC_DRAW);                    glCopyBufferSubData(GL_COPY_READ_BUFFER,GL_ARRAY_BUFFER,0,0,oldByteCount);          glBindBuffer(GL_COPY_READ_BUFFER,0);          glBindBuffer(GL_ARRAY_BUFFER,0);          glDeleteBuffers(1,&tempVBO);

 

After running that code , if the data is read back using map buffer it will be all zeros or garbage.  However if any other memory operation is performed it'll work.

 

For instance  the following code will correctly copy the data between buffers.  The original code works fine on the various NVIDIA cards I've tested.

 

 

 

                GLuinttempVBO;          glGenBuffers(1,&tempVBO);          glBindBuffer(GL_COPY_READ_BUFFER,tempVBO);                glBindBuffer(GL_ARRAY_BUFFER, srcVBO);          glBufferData(GL_COPY_READ_BUFFER,oldByteCount,NULL,GL_STATIC_COPY);          //glSubBufferData, glBufferData with one byte, whatever           glMapBuffer(GL_COPY_READ_BUFFER,GL_READ_ONLY);          glUnmapBuffer(GL_COPY_READ_BUFFER);               glCopyBufferSubData(GL_ARRAY_BUFFER,GL_COPY_READ_BUFFER,0,0,oldByteCount);               glBufferData(GL_ARRAY_BUFFER,newByteCount,NULL,GL_STATIC_DRAW);                    glMapBuffer(GL_ARRAY_BUFFER,GL_READ_ONLY);          glUnmapBuffer(GL_ARRAY_BUFFER);          glCopyBufferSubData(GL_COPY_READ_BUFFER,GL_ARRAY_BUFFER,0,0,oldByteCount);          glBindBuffer(GL_COPY_READ_BUFFER,0);          glBindBuffer(GL_ARRAY_BUFFER,0);          glDeleteBuffers(1,&tempVBO);

 

 

What am I missing here?


Viewing all articles
Browse latest Browse all 631

Trending Articles