We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4314 - Getting Display Handle
Summary: Getting Display Handle
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Martin Gerhardy
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-14 09:13 UTC by Martin Gerhardy
Modified: 2018-11-13 00:39 UTC (History)
0 users

See Also:


Attachments
Small testcase (not written by me) for the CL/GL sharing (387.12 KB, application/zip)
2018-10-14 09:16 UTC, Martin Gerhardy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Gerhardy 2018-10-14 09:13:15 UTC
I'm having trouble setting up the OpenCL OpenGL sharing context. When doing the init of the OpenCL context, you have to specify the display and the context handle. The context should not be a problem - we could just use SDL_GL_GetCurrentContext (which hopefully directly maps to glXGetCurrentContext or eglGetCurrentContext) - but OpenCL also needs to get the display handle and here it gets ... tricky. For windows this is wglGetCurrentDC and for linux it is glXGetCurrentDisplay - or eglGetCurrentDisplay if you are using EGL. To be honest, I don't know a way to check at runtime whether my context is egl or glx/wgl - I could only check this at compile time afair.

Therefore it would be nice if we could also get something similar as SDL_GL_GetCurrentContext for the display. E.g. SDL_GL_GetCurrentDisplay(SDLWindow* window)
Comment 1 Martin Gerhardy 2018-10-14 09:16:37 UTC
Created attachment 3373 [details]
Small testcase (not written by me) for the CL/GL sharing

Attached a small glx example where the CL sharing works with glfw and glx

And this is the OpenCL extension I'm talking about:
https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/cl_khr_gl_sharing.html
Comment 2 Martin Gerhardy 2018-10-14 09:46:39 UTC
And the last thing - We also need to know which type of handle it is. Is it glx, egl, wgl, ...? this is due to the fact that OpenCL must know this, too. 


https://github.com/mgerhardy/engine/blob/master/src/modules/computevideo/cl/CLComputeVideo.cpp

CL_WGL_HDC_KHR
CL_GLX_DISPLAY_KHR
CL_EGL_DISPLAY_KHR

CL_CGL_SHAREGROUP_KHR for CGL is quite easy I suppose.
CL_GL_CONTEXT_KHR is for the gl context.
Comment 3 Sam Lantinga 2018-11-03 00:13:02 UTC
Would you like to propose an API change for this?
Comment 4 Martin Gerhardy 2018-11-08 07:54:33 UTC
What do you think about this?

/**
 *  \brief Get the display of the given window
 *
 *  \param window   Window from which the display should be queried
 */
extern DECLSPEC SDL_GLDisplay SDLCALL SDL_GL_GetDisplay(SDL_Window * window);

If nobody votes against this, I would implement it.
Comment 5 Sam Lantinga 2018-11-13 00:39:47 UTC
That sounds reasonable. Let's call it SDL_GL_GetCurrentDisplay() to match the naming from the platform extensions.

Thanks!