Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: The speed of uploading textures seems slow.

  1. #11
    Junior Member Newbie
    Join Date
    Sep 2011
    Location
    China
    Posts
    29
    Hi,Aleksandar, I have remove the loop and add a trivial rendering, and move the codes for measuring to make them contain exactly the glTexSubImage() func,like this:

    Code :
     
     
     
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
        glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
     
     
        glBindTexture( GL_TEXTURE_2D, tex1 );
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
     
     
        //--------------codes for timing---------------------------------------start
        GLuint query;
        glGenQueries(1, &query);
        glBeginQuery(GL_TIME_ELAPSED,query);
        //---------------------------------------------------------------------end
        glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0,tex1_width,tex1_height,GL_RED_INTEGER,GL_UNSIGNED_INT,0); //where the data transfer occurs
        DrawSomePoints();
        //-----------codes for timing--------------------------------------------start
        glEndQuery(GL_TIME_ELAPSED);
        GLuint elapsed_time;
        glGetQueryObjectuiv(query, GL_QUERY_RESULT, &elapsed_time);
        glDeleteQueries(1, &query);
        float time_ms = elapsed_time/1000000.0f;
        LogTime( time_ms ); //write time_ms to a log file.
        //-----------------------------------------------------------------------end
     
     
     
     
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
     
     
        Render();
     
     
        //remap the buffer
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
        glBufferData(GL_PIXEL_UNPACK_BUFFER, buffersize, 0, GL_STREAM_DRAW);
        pBufferData = (byte*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER,GL_WRITE_ONLY);
        //pBufferData is a global variable, it will be refilled in another thread which focus on I/O.
     
     
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

    But, the result turns out to be the same as the original, only differs 3-4 ms of transferring 200 M textures. Maybe i should find a new computer......I will continue to try.Thanks for your kind help.

  2. #12
    Advanced Member Frequent Contributor Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    948
    What I tried to achieve is to make you realize what's really happening, not to boost the speed.
    I've overseen that you are uploading data in a separate thread. Do you have an adequate synchronization?

    In order to get better performance you need two PBOs. A separate thread should fill one, while another is used for transferring to graphics memory and for drawing. But, you should fill data between glTexImage2D() and drawing to have an effect. In the best case, a buffer refill should be done in the same procedure (not in the separate thread) and should last exactly the same time as data transfer. In your case Render() waits for texture to be downloaded before executes, so you have no benefits of using PBO (just disable PBO, and use glTexSubImage() with a real pointer to check this; I think you'll get marginally worse results).

    Also, transferring a 200[MB] texture in a single frame is not feasible. 200[MB] * 60[1/s] = 12[GB/s]
    Your problem is not in a transfer speed, but in the wrong way of texture update. The texture should be broken into smaller pieces, and update one at the time. 20-30 [MB/frame] is something you should stick to.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •