mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 06:23:01 +08:00
Refactor of glcl sharing
new pattern to load gl and wgl functions from dll Change-Id: I71d7510a210462c09d50e03ce8a444770c017b8d
This commit is contained in:
committed by
sys_ocldev
parent
d1a80db2f2
commit
f18532c8c4
@@ -32,30 +32,31 @@ GLSharingFunctions::~GLSharingFunctions() {
|
||||
}
|
||||
|
||||
GLboolean GLSharingFunctions::initGLFunctions() {
|
||||
GLGetCurrentContext = reinterpret_cast<PFNOGLGetCurrentContext>(loadGlFunction("wglGetCurrentContext", GLHDCType));
|
||||
GLGetCurrentDisplay = reinterpret_cast<PFNOGLGetCurrentDisplay>(loadGlFunction("wglGetCurrentDC", GLHDCType));
|
||||
glGetString = reinterpret_cast<PFNglGetString>(loadGlFunction("glGetString", GLHDCType));
|
||||
glGetIntegerv = reinterpret_cast<PFNglGetIntegerv>(loadGlFunction("glGetIntegerv", GLHDCType));
|
||||
glLibrary.reset(OsLibrary::load(Os::openglDllName));
|
||||
|
||||
pfnWglCreateContext = reinterpret_cast<PFNwglCreateContext>(loadGlFunction("wglCreateContext", GLHDCType));
|
||||
pfnWglDeleteContext = reinterpret_cast<PFNwglDeleteContext>(loadGlFunction("wglDeleteContext", GLHDCType));
|
||||
|
||||
pfnWglShareLists = reinterpret_cast<PFNwglShareLists>(loadGlFunction("wglShareLists", GLHDCType));
|
||||
|
||||
auto wglGetProcAddressFuncPtr = reinterpret_cast<PROC(WINAPI *)(LPCSTR)>(loadGlFunction("wglGetProcAddress", GLHDCType));
|
||||
GLSetSharedOCLContextState = reinterpret_cast<PFNOGLSetSharedOCLContextStateINTEL>(wglGetProcAddressFuncPtr("wglSetSharedOCLContextStateINTEL"));
|
||||
GLAcquireSharedBuffer = reinterpret_cast<PFNOGLAcquireSharedBufferINTEL>(wglGetProcAddressFuncPtr("wglAcquireSharedBufferINTEL"));
|
||||
GLReleaseSharedBuffer = reinterpret_cast<PFNOGLReleaseSharedBufferINTEL>(wglGetProcAddressFuncPtr("wglReleaseSharedBufferINTEL"));
|
||||
GLAcquireSharedRenderBuffer = reinterpret_cast<PFNOGLAcquireSharedRenderBufferINTEL>(wglGetProcAddressFuncPtr("wglAcquireSharedRenderBufferINTEL"));
|
||||
GLReleaseSharedRenderBuffer = reinterpret_cast<PFNOGLReleaseSharedRenderBufferINTEL>(wglGetProcAddressFuncPtr("wglReleaseSharedRenderBufferINTEL"));
|
||||
GLAcquireSharedTexture = reinterpret_cast<PFNOGLAcquireSharedTextureINTEL>(wglGetProcAddressFuncPtr("wglAcquireSharedTextureINTEL"));
|
||||
GLReleaseSharedTexture = reinterpret_cast<PFNOGLReleaseSharedTextureINTEL>(wglGetProcAddressFuncPtr("wglReleaseSharedTextureINTEL"));
|
||||
GLRetainSync = reinterpret_cast<PFNOGLRetainSyncINTEL>(wglGetProcAddressFuncPtr("wglRetainSyncINTEL"));
|
||||
GLReleaseSync = reinterpret_cast<PFNOGLReleaseSyncINTEL>(wglGetProcAddressFuncPtr("wglReleaseSyncINTEL"));
|
||||
GLGetSynciv = reinterpret_cast<PFNOGLGetSyncivINTEL>(wglGetProcAddressFuncPtr("wglGetSyncivINTEL"));
|
||||
glGetStringi = reinterpret_cast<PFNglGetStringi>(wglGetProcAddressFuncPtr("glGetStringi"));
|
||||
this->wglMakeCurrent = reinterpret_cast<PFNwglMakeCurrent>(loadGlFunction("wglMakeCurrent", GLHDCType));
|
||||
if (glLibrary->isLoaded()) {
|
||||
glFunctionHelper wglLibrary(glLibrary.get(), "wglGetProcAddress");
|
||||
GLGetCurrentContext = (*glLibrary)["wglGetCurrentContext"];
|
||||
GLGetCurrentDisplay = (*glLibrary)["wglGetCurrentDC"];
|
||||
glGetString = (*glLibrary)["glGetString"];
|
||||
glGetIntegerv = (*glLibrary)["glGetIntegerv"];
|
||||
pfnWglCreateContext = (*glLibrary)["wglCreateContext"];
|
||||
pfnWglDeleteContext = (*glLibrary)["wglDeleteContext"];
|
||||
pfnWglShareLists = (*glLibrary)["wglShareLists"];
|
||||
|
||||
GLSetSharedOCLContextState = wglLibrary["wglSetSharedOCLContextStateINTEL"];
|
||||
GLAcquireSharedBuffer = wglLibrary["wglAcquireSharedBufferINTEL"];
|
||||
GLReleaseSharedBuffer = wglLibrary["wglReleaseSharedBufferINTEL"];
|
||||
GLAcquireSharedRenderBuffer = wglLibrary["wglAcquireSharedRenderBufferINTEL"];
|
||||
GLReleaseSharedRenderBuffer = wglLibrary["wglReleaseSharedRenderBufferINTEL"];
|
||||
GLAcquireSharedTexture = wglLibrary["wglAcquireSharedTextureINTEL"];
|
||||
GLReleaseSharedTexture = wglLibrary["wglReleaseSharedTextureINTEL"];
|
||||
GLRetainSync = wglLibrary["wglRetainSyncINTEL"];
|
||||
GLReleaseSync = wglLibrary["wglReleaseSyncINTEL"];
|
||||
GLGetSynciv = wglLibrary["wglGetSyncivINTEL"];
|
||||
glGetStringi = wglLibrary["glGetStringi"];
|
||||
wglMakeCurrent = wglLibrary["wglMakeCurrent"];
|
||||
}
|
||||
this->pfnGlArbSyncObjectCleanup = cleanupArbSyncObject;
|
||||
this->pfnGlArbSyncObjectSetup = setupArbSyncObject;
|
||||
this->pfnGlArbSyncObjectSignal = signalArbSyncObject;
|
||||
@@ -120,12 +121,6 @@ bool GLSharingFunctions::isOpenGlSharingSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void *GLSharingFunctions::loadGlFunction(const char *functionName, uint32_t hdc) {
|
||||
|
||||
HMODULE module = LoadLibraryA(Os::openglDllName);
|
||||
return reinterpret_cast<PFNglGetString>(GetProcAddress(module, functionName));
|
||||
}
|
||||
|
||||
void GLSharingFunctions::createBackupContext() {
|
||||
if (pfnWglCreateContext) {
|
||||
GLHGLRCHandleBkpCtx = pfnWglCreateContext(GLHDCHandle);
|
||||
|
||||
Reference in New Issue
Block a user