SWDEV-418038 - Remove opengl32.lib from linking in runtime

Change-Id: If9416742cd8dc6a35adaccce802d65888e808ef2


[ROCm/clr commit: ad56c20cd0]
This commit is contained in:
German
2023-08-29 17:51:10 -04:00
committed by German Andryeyev
parent 92c16d7d04
commit 476e7f7022
3 changed files with 31 additions and 39 deletions
+1 -1
View File
@@ -75,5 +75,5 @@ target_link_libraries(rocclr PUBLIC pal amdhsaloader)
# support for OGL/D3D interop
if(WIN32)
target_link_libraries(rocclr PUBLIC opengl32.lib dxguid.lib)
target_link_libraries(rocclr PUBLIC dxguid.lib)
endif()
+28 -36
View File
@@ -73,6 +73,10 @@ static PFNGLXRESOURCEDETACHAMD glxResourceReleaseAMD = nullptr;
static PFNGLXRESOURCEDETACHAMD glXResourceDetachAMD = nullptr;
static PFNGLXGETCONTEXTMVPUINFOAMD glXGetContextMVPUInfoAMD = nullptr;
#else
typedef PROC(WINAPI* PFNWGLGETPROCADDRESS)(LPCSTR name);
typedef HGLRC(WINAPI* PFNWGLGETCURRENTCONTEXT)(void);
static PFNWGLGETPROCADDRESS pfnWglGetProcAddress = nullptr;
static PFNWGLGETCURRENTCONTEXT pfnWglGetCurrentContext = nullptr;
static PFNWGLBEGINCLINTEROPAMD wglBeginCLInteropAMD = nullptr;
static PFNWGLENDCLINTEROPAMD wglEndCLInteropAMD = nullptr;
static PFNWGLRESOURCEATTACHAMD wglResourceAttachAMD = nullptr;
@@ -702,32 +706,33 @@ bool Device::initGLInteropPrivateExt(void* GLplatformContext, void* GLdeviceCont
return false;
}
#else
if (!wglBeginCLInteropAMD || !wglEndCLInteropAMD || !wglResourceAttachAMD ||
if (!pfnWglGetProcAddress || !pfnWglGetCurrentContext ||
!wglBeginCLInteropAMD || !wglEndCLInteropAMD || !wglResourceAttachAMD ||
!wglResourceDetachAMD || !wglGetContextGPUInfoAMD) {
HGLRC fakeRC = nullptr;
if (!wglGetCurrentContext()) {
fakeRC = wglCreateContext((HDC)GLdeviceContext);
wglMakeCurrent((HDC)GLdeviceContext, fakeRC);
HMODULE h = static_cast<HMODULE>(amd::Os::loadLibrary("OpenGL32.dll"));
if (nullptr != h) {
pfnWglGetProcAddress =
reinterpret_cast<PFNWGLGETPROCADDRESS>(GetProcAddress(h, "wglGetProcAddress"));
pfnWglGetCurrentContext =
reinterpret_cast<PFNWGLGETCURRENTCONTEXT>(GetProcAddress(h, "wglGetCurrentContext"));
}
wglBeginCLInteropAMD =
(PFNWGLBEGINCLINTEROPAMD)wglGetProcAddress("wglBeginCLInteroperabilityAMD");
wglEndCLInteropAMD = (PFNWGLENDCLINTEROPAMD)wglGetProcAddress("wglEndCLInteroperabilityAMD");
wglResourceAttachAMD = (PFNWGLRESOURCEATTACHAMD)wglGetProcAddress("wglResourceAttachAMD");
wglResourceAcquireAMD = (PFNWGLRESOURCEDETACHAMD)wglGetProcAddress("wglResourceAcquireAMD");
wglResourceReleaseAMD = (PFNWGLRESOURCEDETACHAMD)wglGetProcAddress("wglResourceReleaseAMD");
wglResourceDetachAMD = (PFNWGLRESOURCEDETACHAMD)wglGetProcAddress("wglResourceDetachAMD");
wglGetContextGPUInfoAMD =
(PFNWGLGETCONTEXTGPUINFOAMD)wglGetProcAddress("wglGetContextGPUInfoAMD");
if (fakeRC) {
wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(fakeRC);
if (pfnWglGetProcAddress != nullptr) {
wglBeginCLInteropAMD =
(PFNWGLBEGINCLINTEROPAMD)pfnWglGetProcAddress("wglBeginCLInteroperabilityAMD");
wglEndCLInteropAMD =
(PFNWGLENDCLINTEROPAMD)pfnWglGetProcAddress("wglEndCLInteroperabilityAMD");
wglResourceAttachAMD = (PFNWGLRESOURCEATTACHAMD)pfnWglGetProcAddress("wglResourceAttachAMD");
wglResourceAcquireAMD =
(PFNWGLRESOURCEDETACHAMD)pfnWglGetProcAddress("wglResourceAcquireAMD");
wglResourceReleaseAMD =
(PFNWGLRESOURCEDETACHAMD)pfnWglGetProcAddress("wglResourceReleaseAMD");
wglResourceDetachAMD = (PFNWGLRESOURCEDETACHAMD)pfnWglGetProcAddress("wglResourceDetachAMD");
wglGetContextGPUInfoAMD =
(PFNWGLGETCONTEXTGPUINFOAMD)pfnWglGetProcAddress("wglGetContextGPUInfoAMD");
}
}
if (!wglBeginCLInteropAMD || !wglEndCLInteropAMD || !wglResourceAttachAMD ||
!wglResourceDetachAMD || !wglGetContextGPUInfoAMD) {
!wglResourceDetachAMD || !wglGetContextGPUInfoAMD || !pfnWglGetCurrentContext) {
return false;
}
#endif
@@ -776,13 +781,6 @@ bool Device::glAssociate(void* GLplatformContext, void* GLdeviceContext) const {
!glCanInterop(GLplatformContext, GLdeviceContext)) {
return false;
}
/*
if (m_adp->pAsicInfo->svmFineGrainSystem)
{
flags = GL_INTEROP_SVM;
}
*/
#ifdef ATI_OS_LINUX
GLXContext ctx = (GLXContext)GLplatformContext;
return (glXBeginCLInteropAMD(ctx, 0)) ? true : false;
@@ -793,12 +791,6 @@ bool Device::glAssociate(void* GLplatformContext, void* GLdeviceContext) const {
}
bool Device::glDissociate(void* GLplatformContext, void* GLdeviceContext) const {
/*
if (m_adp->pAsicInfo->svmFineGrainSystem)
{
flags = GL_INTEROP_SVM;
}
*/
#ifdef ATI_OS_LINUX
GLXContext ctx = (GLXContext)GLplatformContext;
if (glXEndCLInteropAMD == nullptr) {
@@ -897,7 +889,7 @@ bool Device::resGLAcquire(void* GLplatformContext, void* mbResHandle, uint type)
GLXContext ctx = (GLXContext)GLplatformContext;
return (glxResourceAcquireAMD(ctx, &hRes)) ? true : false;
#else
HGLRC hRC = wglGetCurrentContext();
HGLRC hRC = pfnWglGetCurrentContext();
//! @todo A temporary workaround for MT issue in conformance fence_sync
if (0 == hRC) {
return true;
@@ -919,7 +911,7 @@ bool Device::resGLRelease(void* GLplatformContext, void* mbResHandle, uint type)
return (glxResourceReleaseAMD(ctx, &hRes)) ? true : false;
#else
// Make the call into the GL driver only if the application GL context is current
HGLRC hRC = wglGetCurrentContext();
HGLRC hRC = pfnWglGetCurrentContext();
//! @todo A temporary workaround for MT issue in conformance fence_sync
if (0 == hRC) {
return true;
+2 -2
View File
@@ -58,8 +58,8 @@ bool amd::ClGlEvent::waitForFence() {
// create a new GL context on this thread, which is shared with the original context
#ifdef _WIN32
HDC tempDC_ = wglGetCurrentDC();
HGLRC tempGLRC_ = wglGetCurrentContext();
HDC tempDC_ = context().glenv()->wglGetCurrentDC_();
HGLRC tempGLRC_ = context().glenv()->wglGetCurrentContext_();
// Set DC and GLRC
if (tempDC_ && tempGLRC_) {
ret = context().glenv()->glClientWaitSync_(gs, GL_SYNC_FLUSH_COMMANDS_BIT,