Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Rendering on Different Areas of a Context

  1. #1
    Junior Member Newbie sinaxp19's Avatar
    Join Date
    Mar 2015
    Posts
    18

    Rendering on Different Areas of a Context

    Hi,
    I have a large panel with multiple user controls and have two options before I proceed:

    1. Take a single context, (maybe define one FBO per control), and render each control data to this context via different threads.
    2. Take one context per control and render to it normally with its own thread (multiple contexts, multiple threads).
    Since concurrency is very important for me (data load is high) which approach is better suited for me? How should I manage multiple threads accessing the same thread?

    Thanks

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,673
    I want to make sure we're all on the same page on what you're trying to do. You have multiple controls (ie; windows), and you want to render with OpenGL to these controls (ie: windows). Correct?

  3. #3
    Junior Member Newbie sinaxp19's Avatar
    Join Date
    Mar 2015
    Posts
    18
    You're right except that all rendering is done in a single window. I'm building something like task-manager's performance tab in windows: a single windows form (maybe in future, a WPF panel) which contains about 16 analytic histograms (each showing data from its proprietary source of 10^8 points loaded into its VBO). that would be 16 rectangular panes on a form which show data using OpenGL. Since data load in high and each dataset has a different source, I'll be uploading data to each VBO from a separate thread.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,103
    Quote Originally Posted by sinaxp19 View Post
    I'll be uploading data to each VBO from a separate thread.
    You need one context per thread. A context cannot be made current in more than one thread at any given time.

  5. #5
    Junior Member Newbie sinaxp19's Avatar
    Join Date
    Mar 2015
    Posts
    18
    Quote Originally Posted by GClements View Post
    You need one context per thread. A context cannot be made current in more than one thread at any given time.
    Thanks GClements. I know that about contexts and I'll be using my own dispatcher to keep track of the current context and who has it current... but since the context switching process is also a time consuming task, the question remains: single context (maybe with multiple FBOs) or multiple contexts? (see my reply to Alfonse)

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    256
    You could map/unmap the VBOs from the main thread and just fill in the data from the worker threads.

  7. #7
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214
    Quote Originally Posted by mbentrup View Post
    You could map/unmap the VBOs from the main thread and just fill in the data from the worker threads.
    I wouldn't recommend that. Unless a dual copy engine is used, I think the fastest way to update resources is to use the drawing thread itself. The resource preparation threads should just feed it through message-queues.

  8. #8
    Junior Member Newbie sinaxp19's Avatar
    Join Date
    Mar 2015
    Posts
    18
    Quote Originally Posted by mbentrup View Post
    You could map/unmap the VBOs from the main thread and just fill in the data from the worker threads.
    Quote Originally Posted by Aleksandar View Post
    I wouldn't recommend that. Unless a dual copy engine is used, I think the fastest way to update resources is to use the drawing thread itself. The resource preparation threads should just feed it through message-queues.
    I didn't know you could access VBO without a context (even in unsafe mode). But it seems to make things messy since every kind of access violation may happen.

  9. #9
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214
    Quote Originally Posted by sinaxp19 View Post
    I didn't know you could access VBO without a context (even in unsafe mode). But it seems to make things messy since every kind of access violation may happen.
    Who said that you should, or even could, access VBO without a context being bound to the thread executing OpenGL commands? I just said you should prepare data for VBOs in separate threads and post them to the rendering thread (with bound context) through message queues. The rendering context should upload data using glBufferSubData() at its disposal.

  10. #10
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    256
    Quote Originally Posted by sinaxp19 View Post
    I didn't know you could access VBO without a context (even in unsafe mode). But it seems to make things messy since every kind of access violation may happen.
    You don't access the VBO, you access the memory that it is mapped to, and all threads in a process share their memory. You have to be careful regarding synchronization, but otherwise it is perfectly safe.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: 07-23-2018, 10:14 PM
  2. many rendering context
    By psp in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 10-25-2004, 11:06 AM
  3. Rendering context in VC++
    By NOAH IV in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-04-2002, 04:11 AM
  4. Can't get Rendering Context
    By mike in forum OpenGL: Linux
    Replies: 0
    Last Post: 07-12-2000, 02:15 AM
  5. GL Rendering Context
    By imported_Adrian in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 04-09-2000, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean