# Shared context problem

**URL:** <https://forums.imgtec.com/t/shared-context-problem/2353>\
**Category:** PowerVR Insider\
**Tags:** pvrvframe\
**Created:** [August 20, 2015, 10:56pm UTC](https://forums.imgtec.com/t/shared-context-problem/2353 "2015-08-20T22:56:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sketchylizard](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sketchylizard](https://forums.imgtec.com/u/sketchylizard)\
**Post date:** [August 20, 2015, 10:56pm UTC](https://forums.imgtec.com/t/shared-context-problem/2353/1 "2015-08-20T22:56:17Z")

</div>

I am trying to create two contexts, context1 and context2 where context2 passes context1 as the sharedContext parameter of eglCreateContext. I started with the Hello\_Triangles example from [https://www.khronos.org/assets/uploads/books/openglr\_es\_20\_programming\_guide\_sample.pdf](https://www.khronos.org/assets/uploads/books/openglr_es_20_programming_guide_sample.pdf) and added a second thread. I extended the CreateEGLContext function to create two contexts, context1 & context2. I also moved the call to Init from main to the thread function.

The example doesn’t work if context2 passes context1 as the “shared context” parameter of eglCreateContext but it does if I pass EGL\_NO\_CONTEXT.

I’ve attached the three files that I modified to this message.

Any ideas why the shared context doesn’t work?

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [August 21, 2015, 8:42am UTC](https://forums.imgtec.com/t/shared-context-problem/2353/2 "2015-08-21T08:42:25Z")

</div>

Hi Jason,

[blockquote]I’ve attached the three files that I modified to this message.[/blockquote]  
I can’t see your attachments. We’ve been having some issues with the attachment system lately, so it may be a problem on our side (I’ll chase up the web team about this). Would it be possible to host the files on another service, e.g. Dropbox or Pastebin, and share a URL with us?

We have a multi-threading demo in our SDK where a shared context is used to load resources on a background thread. You can find the source code for the demo here: [https://github.com/powervr-graphics/Native\_SDK/tree/3.5/Examples/Intermediate/MultiThreading](https://github.com/powervr-graphics/Native_SDK/tree/3.5/Examples/Intermediate/MultiThreading)

---

<div class="post-metadata">

**Author:** ![sketchylizard](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sketchylizard](https://forums.imgtec.com/u/sketchylizard)\
**Post date:** [August 21, 2015, 11:48am UTC](https://forums.imgtec.com/t/shared-context-problem/2353/3 "2015-08-21T11:48:31Z")

</div>

Apparently .c & .h files are also blocked. I have put them on DropBox. [https://www.dropbox.com/sh/jxxv14nwte31fnf/AACDaxbx-qzD5vxtYdEDYPaqa?dl=0](https://www.dropbox.com/sh/jxxv14nwte31fnf/AACDaxbx-qzD5vxtYdEDYPaqa?dl=0)

---

<div class="post-metadata">

**Author:** ![sketchylizard](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sketchylizard](https://forums.imgtec.com/u/sketchylizard)\
**Post date:** [August 24, 2015, 7:51pm UTC](https://forums.imgtec.com/t/shared-context-problem/2353/4 "2015-08-24T19:51:59Z")

</div>

Has anyone had a chance to look at the sample code that I posted on dropbox? I have looked at the multithreaded sample but there are some differences. For one, it doesn’t attempt to render on the second thread. Another difference that comes to mind is that the thread that creates the window and has the message pump is the same thread that does the rendering. For various reasons I can’t set mine up that way.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [August 27, 2015, 1:44pm UTC](https://forums.imgtec.com/t/shared-context-problem/2353/5 "2015-08-27T13:44:07Z")

</div>

Hi Jason,

Apologies for the delayed response. I’ve replied to your email, but will continue posting updates in this chain so other developers can benefit from seeing the discussion.

From your email, it seems that you encountered this problem in our PVRVFrame emulator rather than PowerVR graphics drivers. I’ll ask the PVRVFrame lead engineer to take a look at the source code example you have provided.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![sketchylizard](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sketchylizard](https://forums.imgtec.com/u/sketchylizard)\
**Post date:** [August 27, 2015, 2:08pm UTC](https://forums.imgtec.com/t/shared-context-problem/2353/6 "2015-08-27T14:08:55Z")

</div>

I was using PVRVFrame version 10.1.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [September 2, 2015, 9:28am UTC](https://forums.imgtec.com/t/shared-context-problem/2353/7 "2015-09-02T09:28:08Z")

</div>

The PVRVFrame lead was able to reproduce the issue. Unfortunately, he hasn’t been able to isolate the cause. It’s unlikely we will have time to fix the issue for our upcoming 4.0 SDK. We’ve filed the bug as BRN57422 in our tracker and will aim to resolve the issue in a future release.
