From b075718a0fc161d26268abc103b47aeee913ad41 Mon Sep 17 00:00:00 2001 From: Payam Date: Mon, 13 Sep 2021 23:34:29 -0400 Subject: [PATCH] SWDEV-245531 - GLInterop: linux - Buffer Interop adding back two missed changes back to cmakelists and amdhip.def Change-Id: Ibe0ed655d3590f0add13c20b160078ae005feaaf --- hipamd/src/CMakeLists.txt | 6 ++++-- hipamd/src/amdhip.def | 6 ++++++ hipamd/src/hip_gl.cpp | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hipamd/src/CMakeLists.txt b/hipamd/src/CMakeLists.txt index c090abf6af..fb4ccada11 100644 --- a/hipamd/src/CMakeLists.txt +++ b/hipamd/src/CMakeLists.txt @@ -110,7 +110,8 @@ target_sources(amdhip64 PRIVATE hip_stream_ops.cpp hip_stream.cpp hip_surface.cpp - hip_texture.cpp) + hip_texture.cpp + hip_gl.cpp) if(WIN32) target_sources(amdhip64 PRIVATE @@ -135,7 +136,8 @@ target_include_directories(amdhip64 ${PROJECT_BINARY_DIR}/include) target_compile_definitions(amdhip64 PRIVATE __HIP_PLATFORM_AMD__) - +find_package(OpenGL REQUIRED) +target_link_libraries(amdhip64 PRIVATE ${OPENGL_LIBRARIES}) target_link_libraries(amdhip64 PRIVATE ${CMAKE_DL_LIBS}) # Additional dependencies for hipRTC if(WIN32) diff --git a/hipamd/src/amdhip.def b/hipamd/src/amdhip.def index 7731f2aea2..d9cb153016 100644 --- a/hipamd/src/amdhip.def +++ b/hipamd/src/amdhip.def @@ -292,6 +292,12 @@ hipImportExternalSemaphore hipSignalExternalSemaphoresAsync hipWaitExternalSemaphoresAsync hipDestroyExternalSemaphore +hipGLGetDevices +hipGraphicsGLRegisterBuffer +hipGraphicsMapResources +hipGraphicsResourceGetMappedPointer +hipGraphicsUnmapResources +hipGraphicsUnregisterResource hipGraphGetNodes hipGraphGetRootNodes hipGraphKernelNodeGetParams diff --git a/hipamd/src/hip_gl.cpp b/hipamd/src/hip_gl.cpp index 4a9f3c08bf..88870190e6 100644 --- a/hipamd/src/hip_gl.cpp +++ b/hipamd/src/hip_gl.cpp @@ -176,11 +176,15 @@ void setupGLInteropOnce() { HDC dc; HGLRC glrc; + dc = wglGetCurrentDC(); + glrc = wglGetCurrentContext(); + +/* if (!getDeviceGLContext(dc, glrc)) { LogError(" Context setup failed \n"); return; } - +*/ cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)AMD_PLATFORM, CL_GL_CONTEXT_KHR, @@ -197,11 +201,14 @@ void setupGLInteropOnce() { hGL->context = nullptr; hGL->window = 0; hGL->cmap = 0; - + hGL->context = glXGetCurrentContext(); + hGL->display = glXGetCurrentDisplay(); +/* if (!getDeviceGLContext(hGL)) { LogError(" Context setup failed \n"); return; } +*/ cl_context_properties properties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)AMD_PLATFORM,