P4 to Git Change 1174258 by cpaquot@hog-ocl on 2015/07/27 12:18:10

EPR #423784 - [CL/GL interop] cannot create a CL context if the GL context is not current
	Only GetProcAddress on the wgl functions glenv's constructor and get the rest of the GL APIs once we know for sure a GL context is current. Sometimes GetProcAddress returns NULL for some GL APIs such as glBindBuffer if no context is current.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/8067/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl.cpp#47 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl_amd.hpp#17 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/gl_functions.hpp#6 edit
Dieser Commit ist enthalten in:
foreman
2015-07-27 12:41:17 -04:00
Ursprung e8d712389d
Commit 91e26f0226
3 geänderte Dateien mit 70 neuen und 32 gelöschten Zeilen
+57 -22
Datei anzeigen
@@ -2417,12 +2417,13 @@ GLFunctions::GLFunctions(HMODULE h) :
{
GetProcAddress_ = (PFN_xxxGetProcAddress) GETPROCADDRESS(h, API_GETPROCADDR);
#define VERIFY_POINTER(p) if (NULL == p) {missed_++;}
#ifndef _WIN32
// Initialize pointers to X11/GLX functions
// We can not link with these functions on compile time since we need to support
// console mode. In console mode X server and X server components may be absent.
// Hence linking with X11 or libGL will fail module image loading in console mode.-tzachi cohen
#define VERIFY_POINTER(p) if (NULL == p) {missed_++;}
glXGetCurrentDrawable_ = (PFNglXGetCurrentDrawable)GETPROCADDRESS(h,"glXGetCurrentDrawable");
VERIFY_POINTER(glXGetCurrentDrawable_)
@@ -2449,10 +2450,23 @@ GLFunctions::GLFunctions(HMODULE h) :
else{
missed_ += 2;
}
#endif
// Initialize pointers to GL functions
#include "gl_functions.hpp"
#else
wglCreateContext_ = (PFN_wglCreateContext)GETPROCADDRESS(h,"wglCreateContext");
VERIFY_POINTER(wglCreateContext_)
wglGetCurrentContext_ = (PFN_wglGetCurrentContext)GETPROCADDRESS(h,"wglGetCurrentContext");
VERIFY_POINTER(wglGetCurrentContext_)
wglGetCurrentDC_ = (PFN_wglGetCurrentDC)GETPROCADDRESS(h,"wglGetCurrentDC");
VERIFY_POINTER(wglGetCurrentDC_)
wglDeleteContext_ = (PFN_wglDeleteContext)GETPROCADDRESS(h,"wglDeleteContext");
VERIFY_POINTER(wglDeleteContext_)
wglMakeCurrent_ = (PFN_wglMakeCurrent)GETPROCADDRESS(h,"wglMakeCurrent");
VERIFY_POINTER(wglMakeCurrent_)
wglShareLists_ = (PFN_wglShareLists)GETPROCADDRESS(h,"wglShareLists");
VERIFY_POINTER(wglShareLists_)
#endif
}
GLFunctions::~GLFunctions()
@@ -2482,27 +2496,48 @@ GLFunctions::init(intptr_t hdc, intptr_t hglrc)
#ifdef _WIN32
DWORD err;
#endif //_WIN32
if (!missed_) {
#ifdef _WIN32
if (!hdc) {
hDC_ = wglGetCurrentDC_();
}
else
{
hDC_ = (HDC) hdc;
}
hOrigGLRC_ = (HGLRC) hglrc;
if (!(hIntGLRC_ = wglCreateContext_(hDC_))) {
err = GetLastError();
return false;
}
if (!wglShareLists_(hOrigGLRC_, hIntGLRC_)) {
err = GetLastError();
return false;
}
if (missed_) {
return false;
}
if (!hdc) {
hDC_ = wglGetCurrentDC_();
}
else
{
hDC_ = (HDC) hdc;
}
hOrigGLRC_ = (HGLRC) hglrc;
if (!(hIntGLRC_ = wglCreateContext_(hDC_))) {
err = GetLastError();
return false;
}
if (!wglShareLists_(hOrigGLRC_, hIntGLRC_)) {
err = GetLastError();
return false;
}
bool makeCurrentNull = false;
if (wglGetCurrentContext_() == NULL) {
wglMakeCurrent_(hDC_, hIntGLRC_);
makeCurrentNull = true;
}
// Initialize pointers to GL functions
#include "gl_functions.hpp"
if (makeCurrentNull) {
wglMakeCurrent_(NULL, NULL);
}
if (missed_ == 0) {
return true;
}
#else //!_WIN32
if (!missed_) {
if (!hdc) {
Dpy_ = glXGetCurrentDisplay_();
}
@@ -2530,9 +2565,9 @@ GLFunctions::init(intptr_t hdc, intptr_t hglrc)
if (!(intCtx_ = glXCreateContext_(intDpy_, vis, origCtx_, true))) {
return false;
}
#endif //!_WIN32
return true;
}
#endif //!_WIN32
return false;
}
+13 -1
Datei anzeigen
@@ -194,6 +194,12 @@ protected:
#define API_GETPROCADDR "wglGetProcAddress"
#define FCN_STR_TYPE LPCSTR
typedef PROC (WINAPI* PFN_xxxGetProcAddress) (LPCSTR fcnName);
typedef HGLRC (APICALL* PFN_wglCreateContext) (HDC hdc);
typedef HGLRC (APICALL* PFN_wglGetCurrentContext) (void);
typedef HDC (APICALL* PFN_wglGetCurrentDC) (void);
typedef BOOL (APICALL* PFN_wglDeleteContext) (HGLRC hglrc);
typedef BOOL (APICALL* PFN_wglMakeCurrent) (HDC hdc, HGLRC hglrc);
typedef BOOL (APICALL* PFN_wglShareLists) (HGLRC hglrc1, HGLRC hglrc2);
#else //!_WIN32
#define APICALL // __stdcall //??? todo odintsov
#define API_GETPROCADDR "glXGetProcAddress"
@@ -215,7 +221,6 @@ protected:
typedef void(*PFNglXDestroyContext)(Display* dpy, GLXContext ctx);
typedef Bool(*PFNglXMakeCurrent)( Display* dpy, GLXDrawable drawable, GLXContext ctx);
typedef void* HMODULE;
#endif //!_WIN32
#define GLPREFIX(rtype, fcn, dclargs) \
@@ -256,6 +261,13 @@ private:
HGLRC hIntGLRC_; // handle for internal GLRC to access shared context
HDC tempDC_;
HGLRC tempGLRC_;
PFN_wglCreateContext wglCreateContext_;
PFN_wglGetCurrentContext wglGetCurrentContext_;
PFN_wglGetCurrentDC wglGetCurrentDC_;
PFN_wglDeleteContext wglDeleteContext_;
PFN_wglMakeCurrent wglMakeCurrent_;
PFN_wglShareLists wglShareLists_;
#else
public:
Display* Dpy_;
@@ -44,13 +44,4 @@ GLPREFIX(void, glTexImage3D, (GLenum target, GLint level, GLint internalformat,
GLPREFIX(GLboolean, glUnmapBuffer, (GLenum target))
#ifdef _WIN32
GLPREFIX(HGLRC, wglCreateContext, (HDC hdc))
GLPREFIX(HGLRC, wglGetCurrentContext, (void))
GLPREFIX(HDC, wglGetCurrentDC, (void))
GLPREFIX(BOOL, wglDeleteContext, (HGLRC hglrc))
GLPREFIX(BOOL, wglMakeCurrent, (HDC hdc, HGLRC hglrc))
GLPREFIX(BOOL, wglShareLists, (HGLRC hglrc1, HGLRC hglrc2))
#endif //_WIN32
#undef GLPREFIX