Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualmhagain

Posted 18 May 2013 - 11:12 AM

For copying FBOs glBlitFramebuffer is provided - see http://www.opengl.org/sdk/docs/man3/xhtml/glBlitFramebuffer.xml.

 

You could also maybe look at GL_ARB_copy_image - the bad news is that it's a GL4.3 extension and so may not be available on all of your target hardware.  Otherwise you may be able to do something with round-tripping through a PBO:

 

// note - these two PBO binds are intentionally the same buffer object
glBindBuffer (GL_PIXEL_PACK_BUFFER, intermediatePBO);
glBindBuffer (GL_PIXEL_UNPACK_BUFFER, intermediatePBO);

// read from source texture to PBO
glBindTexture (GL_TEXTURE_2D, sourceTexture);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

// write from PBO to destination texture
glBindTexture (GL_TEXTURE_2D, destTexture);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

 

All going well, that should run the copy entirely on the GPU, but does have the downside of requiring intermediate storage and an extra copy.


#2mhagain

Posted 18 May 2013 - 11:08 AM

For copying FBOs maybe look at GL_ARB_copy_image - the bad news is that it's a GL4.3 extension and so may not be available on all of your target hardware.  Otherwise you may be able to do something with round-tripping through a PBO:

 

// note - these two PBO binds are intentionally the same buffer object
glBindBuffer (GL_PIXEL_PACK_BUFFER, intermediatePBO);
glBindBuffer (GL_PIXEL_UNPACK_BUFFER, intermediatePBO);

// read from source texture to PBO
glBindTexture (GL_TEXTURE_2D, sourceTexture);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

// write from PBO to destination texture
glBindTexture (GL_TEXTURE_2D, destTexture);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

 

All going well, that should run the copy entirely on the GPU, but does have the downside of requiring intermediate storage and an extra copy.


#1mhagain

Posted 18 May 2013 - 11:07 AM

For copying FBOs maybe look at GL_ARB_copy_image - the bad news is that it's a GL4.3 extension and so may not be available on all of your target hardware.  Otherwise you may be able to do something with round-tripping through a PBO:

 

// note - these two PBO binds are intentionally the same buffer object
glBindBuffer (GL_PIXEL_PACK_BUFFER, intermediatePBO);
glBindBuffer (GL_PIXEL_UNPACK_BUFFER, intermediatePBO);

// read from source texture to PBO
glBindTexture (GL_TEXTURE_2D, sourceTexture);
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

// write from PBO to destination texture
glBindTexture (GL_TEXTURE_2D, destTexture);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void *) 0);

 

All going well, that should run the copy entirely on the GPU, but does have the downside of requiring intermediate storage.


PARTNERS