I am trying to build a native (C++) plugin for the GearVR. But even a very easy plugin seems to fail when “Virtual Reality Supported” and “Multi-Threaded” is set. The native plugin is pretty much the following code:
This leads to following LogCat. As being said, “Single-Threaded” everything runs just fine. Any ideas what needs to be done for a multi-threaded environment?
10-30 11:21:47.131: I/E:\tw\cefb39eb0290d6c5\Software\OculusSDK\Integrations\Unity\Releases\0(12330): OVR_TW_SetDebugMode(0,0)
10-30 11:21:47.131: I/LocalPreferences(12330): Set( dev_timeWarpDebugGraphMode, 0 )
10-30 11:21:47.131: I/LocalPreferences(12330): Couldn’t open /sdcard/.oculusprefs for writing
10-30 11:21:47.131: I/LocalPreferences(12330): Set( dev_timeWarpDebugGraphValue, 0 )
10-30 11:21:47.131: I/LocalPreferences(12330): Couldn’t open /sdcard/.oculusprefs for writing
10-30 11:21:47.136: E/libEGL(12330): eglMakeCurrent:980 error 3002 (EGL_BAD_ACCESS)
10-30 11:21:47.136: E/Unity(12330): [EGL] Unable to acquire context: EGL_BAD_ACCESS: EGL cannot access a requested resource (for example a context is bound in another thread).
10-30 11:21:47.136: E/Unity(12330):
10-30 11:21:47.136: E/Unity(12330): (Filename: ./Runtime/GfxDevice/egl/WindowContextEGL.cpp Line: 205)
10-30 11:21:47.136: E/libEGL(12330): eglMakeCurrent:980 error 3002 (EGL_BAD_ACCESS)
10-30 11:21:47.136: E/Unity(12330): [EGL] Unable to acquire context: EGL_BAD_ACCESS: EGL cannot access a requested resource (for example a context is bound in another thread).
10-30 11:21:47.136: E/Unity(12330):
10-30 11:21:47.136: E/Unity(12330): (Filename: ./Runtime/GfxDevice/egl/WindowContextEGL.cpp Line: 205)
When I am using a shared OpenGL context (created from “UnitySetGraphicsDevice”) any access to a Unity created Texture2D fails.
In my specific case “glFramebufferTexture2D” fails for GearVR. As mentioned the code runs perfectly fine when using single-threaded rendering for Unity or when disabling “Virtual Reality Supported”.
mTextureId = … // from a Unity created Texture2D, the id is valid
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextureId, 0);
← fails with GL Error 1282
Sorry, I think the issue I mentioned earlier is actually unrelated. Can you submit a bug report with a small project that reproduces the problem and PM me the report number? I can take a closer look at the problem this way.
it seems that it is an issue on our site I got a multi-threaded version running with a simple example.
Our “real” project using a shared OpenGL context that is created with the first call to “UnitySetGraphicsDevice”. Then a thread is created that uses that shared context to process an incoming camera frame. We need a shared context because we want to enable the camera frame for Unity as well (live camera texture).
What drives me crazy is that our plugin only fails if “Virtual Reality Supported” is enabled. Are there any changes to the OpenGL context if we enable VR that do not support context sharing?