cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

ladka
Journeyman III

wglMakeAssociatedContextCurrentAMD and OpenGL-OpenCL Interop

So I have a software architecture where I pick a differing GPU for each thread in my program and run OpenCL on each thread (and hence GPU) in parallel.  So far so good.  As you might imaging, not all GPUs are attached to the one driving the screen.

I'm on Win 7 (on Mac I have all this stuff working because MacOS abstracts a lot of this stuff)

Now I need to add OpenGL commands and OpenGL-OpenCL interop.  All works okay if I created use  CreateWindowEx and get the HDC for that window.  And then use wglCreateContext, etc.

However,  I want to make an OpenGL context for each of the GPUs separately.  So I'm using WGL_AMD_GPU_association, and specifically  wglCreateAssociatedContextAMD to create a context for each GPU available through WGL_AMD_GPU_association. As stated in the doc, I'm using wglMakeAssociatedContextCurrentAMD to set the OpenGL context instead of wglMakeCurrent, because as the AMD docs say, there is no HDC per se.

Now my dilemma, I want to associate each of the HGLRC made with wglCreateAssociatedContextAMD creating a context with clCreateContext.  First I call wglCreateAssociatedContextAMD... then I call  clGetGLContextInfo for the information: CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR.  I make sure the cl_device_id returned there matches the device I'm getting to create a cl_context for.  In the call to clCreateContext set the properties  CL_CONTEXT_PLATFORM to the proper cl_platform,  CL_GL_CONTEXT_KHR to the HGLRC created with wglCreateAssociatedContextAMD.

For CL_WGL_HDC_KHR I've tried two things: first after calling wglMakeAssociatedContextCurrentAMD, I call wglCurrentDC() (which before the call to wglMakeAssociatedContextCurrentAMD was NULL, for the purposed of this discussion), and I've also tried setting it to NULL.  I've also tried leaving the CL_GL_CONTEXT_KHR descriptor out of the equation.  All cases return to me the error  CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR.

Is OpenGL-OpenCL interop supported on GL contexts made with wglCreateAssociatedContextAMD?

Pete

0 Likes
3 Replies
himanshu_gautam
Grandmaster

Hi

So far wglCreateAssociatedContextAMD is not tested and no sample are written using this path. So please provide us the minimal test case (attached in zip format) which you are using. so that i can forward that to the AMD GL team and will get back to you.



0 Likes

Hi,

Any progress there? I also have the same problem, when using an AMD associated OpenGL context (created by wglCreateAssociatedContextAMD) for OpenGL-OpenCL interoperation:

clCreateContext() returns CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR

Thanks,

chunyang

0 Likes

Do you still see this problem?  Can you please provide us with a minimal test case (attached in zip format) so that we can route it to the AMD GL team and report back?


--Prasad

0 Likes