Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: uploading a texture from a different thread

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2012
    Location
    Gouda, the Netherlands
    Posts
    6

    uploading a texture from a different thread

    Hi,

    I have a multithreaded application.
    All calculations are performed in threads and then in the main thread the opengl commands are executed.
    This includes uploading textures. The odd thing is, that most of the time this texture uploading takes 0.003-0.005 seconds but occasionally it takes 0.012 and more seconds to upload. This makes animations going a bit choppy.
    So I was wondering: is it possible somehow to upload textures from a different thread? Or is there a common explanation for this irregularity?

    Please note that the texture is always the same size, comes from the same memory location and that always the same opengl commands are executed (translate/rotate/glTexSubImage2D/create quad). Also in my testcase no other threads are running.

  2. #2
    Intern Newbie
    Join Date
    May 2010
    Posts
    38
    Perhaps using PBO with orphaning might help.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2012
    Location
    Gouda, the Netherlands
    Posts
    6
    Quote Originally Posted by Ludde View Post
    Perhaps using PBO with orphaning might help.
    Hi,

    Thanks. Can you elaborate? Or maybe even have an example?
    Of course I googled for it ("pbo with orphaning") but that gives mostly slightly unrelated hits.

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,145
    The first hit on the Google will help you. Just enter "PBO OpenGL". It is a Songho tutorial.
    PBO may hide part of the transfer time if you have something to do on the CPU in the meanwhile, but don't expect miracles.
    Considering other questions...

    Quote Originally Posted by Folkert van Heusden
    So I was wondering: is it possible somehow to upload textures from a different thread?
    Of course, but there is no guarantee it would prevent that irregularity. You need to make another rendering context in the same sharing group as the main (drawing) context, and use it for updating the texture. That requires precise synchronization, since you shouldn’t use the texture while it is updating (use sync object in OpenGL 3.2+).

    Quote Originally Posted by Folkert van Heusden
    Or is there a common explanation for this irregularity?
    No. You have to measure both CPU and GPU time in order to find where the problem is. On the other hand, who knows what your multitasking OS is working behind the curtains. I had a very strange problem with the application that worked extremely fluently on XP but had jerky camera motion on Win7 on the same machine. The problem was probably in fetching data from the hard disk that blocked updating GPU’s memory and vice versa. Who knows...

  5. #5
    Intern Newbie
    Join Date
    May 2010
    Posts
    38
    This link describes a scenario that looks like yours.
    http://forum-archive.developer.nvidi...aded&pid=21223

    Regarding PBO and orphaning, its just that you perform a glBufferData(...) with Data pointer equal to NULL(orphaning). By doing this you tell the driver that you dont care about the "current" data thats in the PBO. The driver may then give you a temporary copy of the PBO just to avoid GPU blocking if its currently using it. But like Aleksandar says, dont expect it to solve your issue... :-)

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
  •