Quantcast
Channel: AMD Developer Forums: Message List - OpenGL & Vulkan
Viewing all articles
Browse latest Browse all 631

OpenGL: multi-thread object creation slow/unstable performance

$
0
0

I'm creating my graphics resources in another thread using both D3D/GL. D3D one is pretty stable and good, but the GL one is not so good compared to D3D.

 

Here's a brief description of what I do (on windows 7 SP1) :

  • Create main context and make it current for the main thread
  • Create a second loader context with shared parameter set to the main context (sharing resources). I also don't create another window and just use GetDC to fetch a new DC for the new context (also context params are same as the first one)
  • Create a thread, at the start of the thread make loader context to current
  • Load and create opengl objects in the loader thread, using only commands like glGen/glBind/glBufferData/... functions
  • After it's ready, call glFlush in loader thread to sync VBOs
  • After process is finished, render stuff in the main thread

 

I took a similiar (but much easier) approach for D3D, the frame rates are smooth except the first object creation which I have a spike in frame-time.

But in OpenGL performance is inferior, and in the first object creation, I get a HUGE spike.

I've also noticed that even if I don't create objects from the loader context and instead create them normally in the main thread, just creating the second context shared with the first one, concludes to horrible performance through out the whole proceeding frames, so it doesn't seem to matter if I load in another thread or use the worker thread/context.

 

In the image below, I'm running on 13.9 drivers, OpenGL, and second shared context is also created, check out the frame-time graph which is about 12ms through the whole runtime, not just loading time

gl-with-mtload.png

 

In the image below, I've turned off threaded loading and also the creation of the secondary context, check out the improvement:

gl-without-mtload.png

Today, I've upgraded to 13.12 drivers, check out the improvement of frame-times for threaded object creation:

gl-13.12.png

Compare these to the similiar D3D implementation:

d3d-mtload.png

 

It looks like driver is constantly doing some overhead work to sync shared resources among contexts through out the whole lifetime of application

So is this AMD's driver fault ?! Or I'm doing something wrong with my OpenGL method ?


Viewing all articles
Browse latest Browse all 631

Trending Articles