0
votes

In EGL, there is shared context.

when a context(created by a first thread) is shared(to a second thread), what resources are made available to the second thread?

Is it textures, buffers, framebuffers, renderbuffers or other objects?

A second question:

If a first thread created textures(handles being 2) and its context is shared to a second thread. In the second thread, when I call glGenTextures. will it give a texture whoes handle is also 2(in this case, it will conflict will the texture in the shared context).

1

1 Answers

4
votes

In general, bulk data resources are shared:

  • Textures
  • Buffers
  • Renderbuffers
  • Shaders / shader programs

Pure state resources are context local:

  • Context settings are context local
  • Vertex array objects (this one normally catches people by surprise)
  • Framebuffer objects (this one normally catches people by surprise)

Some points to note:

  • The application must manually ensure synchronization across the threads. If one thread is modifying some texture data and another thread uses it in a draw then you might get a racy read of the texture data while it is still being updated.
  • State associated with a data resource object (e.g. texture sampler state) is only weakly shared across contexts; state settings which are modified by Context B are only (re)fetched when a resource is bound in a Context A. State settings in Context A will continue to reflect the old values that Context A fetched when the resource was bound; subequent edits made by Context B will only be visible in Context A when a (re)bind of the modified resource happens in Context A.

If a first thread created textures(handles being 2) and its context is shared to a second thread. In the second thread, when I call glGenTextures. will it give a texture whoes handle is also 2(in this case, it will conflict will the texture in the shared context).

No, IDs must obviously be unique within a share group or it wouldn't work.