wheelinlight's picture

Uploading data and instantly downloading it


I want to benchmark the transfer speed of different transfer methods on different hardware.

I have written a small benchmark program that will upload/download data between graphics card and CPU. So far I got the upload part working. Now I want to download the data back to the CPU memory. But all I get when downloading (and saving to a file) is a black image, this means no data has been downloaded I suppose. Do i need to render the data first for it to be available for download? Rendering is not what I want to do, I just want to measure the transfer speeds.

GL.BindTexture(TextureTarget.Texture2D, texture);
GL.TexImage2D(TextureTarget.Texture2D, 0, transferSettings.InternalPixelFormat, transferSettings.ImageSize.Width,
       transferSettings.ImageSize.Height, 0, transferSettings.OpenGLPixelFormat, PixelType.UnsignedByte, bitmap);
GL.ReadPixels(0, 0, transferSettings.ImageSize.Width, transferSettings.ImageSize.Height, transferSettings.OpenGLPixelFormat, 
       PixelType.UnsignedByte, dest); //dest is locked bitmapdata

Thanks in advance!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Pathogen-David's picture

glReadPixels is for reading data out of the framebuffer. You probably want glCopyTexImage2D instead. Also make sure you are re-locking the bitmap before you try to look at its contents.