Hi,
I've debugged what happens, and roughly the sequence is this:

1. main(): createGraphicsContext(traits.get())
   ---> PixelBufferWin32 is created successfully

2. main(): viewer.realize()
---> PixelBufferWin32::makeCurrentImplementation() is called, and succeeds.

3. GraphicsThread::run()
---> PixelBufferWin32::makeCurrentImplementation() is called, and fails with "The requested resource is in use". I don't know why the second makeCurrentImplementation would fail, but going from Juan's hunch that it was failing because some other thread was holding on to it (the main thread in this case),
Good tracking here.
According to the glxMakeCurrent specification making a context current on one thread while another one is holding it is also a mistake and a BadAccess error should be generated.

I added the following code after viewer.realize(); :

    viewer.stopThreading();
    gc->releaseContext();
    viewer.startThreading();

This made it work.
This basically means that the context needs to be released at the end of createGraphicsContext or some other point.

This is obviously not a solution. It worked as-is before on Linux, so perhaps on Windows the makeCurrent() call makes the context "exclusive" to the thread on which it was called, whereas on Linux a subsequent makeCurrent() will still succeed and just remove the context from the previous thread that had it current silently?
If your trace is correct and it's the same for Linux then I think that it has been a matter of luck that a Linux driver didn't complain before. However, I've taking a look at the code searching for how contexts are handled and I've found a fundamental difference between the X11 and Win32 implementations of PixelBufferXYZ::realizeImplementation. In Win32 makeCurrentImplementation is called but not in X11. Maybe adding a releaseContextImplementation(); at the end of that function solves the problem.

Cheers,
Juan
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to