mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge 3b3f415af8
into cd0699a338
This commit is contained in:
commit
5b80385c04
@ -317,7 +317,9 @@ OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ((WIN32 OR ANDROID OR
|
|||||||
VERIFY HAVE_OPENEXR)
|
VERIFY HAVE_OPENEXR)
|
||||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
|
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
|
||||||
VISIBLE_IF NOT ANDROID AND NOT WINRT
|
VISIBLE_IF NOT ANDROID AND NOT WINRT
|
||||||
VERIFY HAVE_OPENGL)
|
VERIFY HAVE_OPENGL
|
||||||
|
AND HAVE_GLX OR HAVE_EGL
|
||||||
|
)
|
||||||
OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF
|
OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF
|
||||||
VISIBLE_IF TRUE
|
VISIBLE_IF TRUE
|
||||||
VERIFY HAVE_OPENVX)
|
VERIFY HAVE_OPENVX)
|
||||||
@ -1481,6 +1483,14 @@ if(WITH_OPENGL OR HAVE_OPENGL)
|
|||||||
status(" OpenGL support:" HAVE_OPENGL THEN "YES (${OPENGL_LIBRARIES})" ELSE NO)
|
status(" OpenGL support:" HAVE_OPENGL THEN "YES (${OPENGL_LIBRARIES})" ELSE NO)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_GLX)
|
||||||
|
status(" GLX support:" HAVE_GLX THEN "YES (${OPENGL_glx_LIBRARY})" ELSE NO)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_EGL)
|
||||||
|
status(" EGL support:" HAVE_EGL THEN "YES (${OPENGL_egl_LIBRARY})" ELSE NO)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_VTK OR HAVE_VTK)
|
if(WITH_VTK OR HAVE_VTK)
|
||||||
status(" VTK support:" HAVE_VTK THEN "YES (ver ${VTK_VERSION})" ELSE NO)
|
status(" VTK support:" HAVE_VTK THEN "YES (ver ${VTK_VERSION})" ELSE NO)
|
||||||
endif()
|
endif()
|
||||||
|
@ -65,6 +65,12 @@ ocv_clear_vars(HAVE_OPENGL HAVE_QT_OPENGL)
|
|||||||
if(WITH_OPENGL)
|
if(WITH_OPENGL)
|
||||||
if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTK3 OR (HAVE_GTK AND NOT HAVE_GTK3 AND HAVE_GTKGLEXT))
|
if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTK3 OR (HAVE_GTK AND NOT HAVE_GTK3 AND HAVE_GTKGLEXT))
|
||||||
find_package (OpenGL QUIET)
|
find_package (OpenGL QUIET)
|
||||||
|
if(OpenGL_EGL_FOUND)
|
||||||
|
set(HAVE_EGL TRUE AND OPENCV_ENABLE_EGL)
|
||||||
|
else()
|
||||||
|
set(HAVE_GLX TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(OPENGL_FOUND)
|
if(OPENGL_FOUND)
|
||||||
set(HAVE_OPENGL TRUE)
|
set(HAVE_OPENGL TRUE)
|
||||||
if(QT_QTOPENGL_FOUND)
|
if(QT_QTOPENGL_FOUND)
|
||||||
|
@ -128,6 +128,9 @@ endif()
|
|||||||
if(OPENCV_LIBVA_LINK)
|
if(OPENCV_LIBVA_LINK)
|
||||||
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/va_intel.cpp" "OPENCV_LIBVA_LINK=1")
|
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/va_intel.cpp" "OPENCV_LIBVA_LINK=1")
|
||||||
endif()
|
endif()
|
||||||
|
if(OPENCV_ENABLE_EGL_INTEROP)
|
||||||
|
ocv_append_source_file_compile_definitions("${CMAKE_CURRENT_LIST_DIR}/src/opengl.cpp" "HAVE_EGL_INTEROP")
|
||||||
|
endif()
|
||||||
|
|
||||||
option(OPENCV_ENABLE_ALLOCATOR_STATS "Enable Allocator metrics" ON)
|
option(OPENCV_ENABLE_ALLOCATOR_STATS "Enable Allocator metrics" ON)
|
||||||
|
|
||||||
@ -175,12 +178,15 @@ ocv_create_module(${extra_libs})
|
|||||||
ocv_target_link_libraries(${the_module} PRIVATE
|
ocv_target_link_libraries(${the_module} PRIVATE
|
||||||
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
|
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
|
||||||
"${OPENGL_LIBRARIES}"
|
"${OPENGL_LIBRARIES}"
|
||||||
"${GLX_LIBRARIES}"
|
|
||||||
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
|
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
|
||||||
"${ITT_LIBRARIES}"
|
"${ITT_LIBRARIES}"
|
||||||
"${OPENCV_HAL_LINKER_LIBS}"
|
"${OPENCV_HAL_LINKER_LIBS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (OPENCV_ENABLE_EGL_INTEROP)
|
||||||
|
ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_egl_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(OPENCV_CORE_EXCLUDE_C_API)
|
if(OPENCV_CORE_EXCLUDE_C_API)
|
||||||
ocv_target_compile_definitions(${the_module} PRIVATE "OPENCV_EXCLUDE_C_API=1")
|
ocv_target_compile_definitions(${the_module} PRIVATE "OPENCV_EXCLUDE_C_API=1")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1596,7 +1596,12 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala
|
|||||||
# if defined(__ANDROID__)
|
# if defined(__ANDROID__)
|
||||||
# include <EGL/egl.h>
|
# include <EGL/egl.h>
|
||||||
# elif defined(__linux__)
|
# elif defined(__linux__)
|
||||||
# include <GL/glx.h>
|
# if defined(OPENCV_ENABLE_EGL)
|
||||||
|
# include <EGL/egl.h>
|
||||||
|
# endif
|
||||||
|
# if defined(OPENCV_ENABLE_GLX)
|
||||||
|
# include <GL/glx.h>
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif // HAVE_OPENGL
|
#endif // HAVE_OPENGL
|
||||||
|
|
||||||
@ -1762,19 +1767,32 @@ Context& initializeContextFromGL()
|
|||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
cl_context_properties props[] =
|
cl_context_properties props[] =
|
||||||
{
|
{
|
||||||
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
|
# if defined(OPENCV_ENABLE_EGL) // prefer EGL
|
||||||
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
|
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[i],
|
||||||
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[i],
|
CL_GL_CONTEXT_KHR, (cl_context_properties)eglGetCurrentContext(),
|
||||||
0
|
CL_EGL_DISPLAY_KHR, (cl_context_properties)eglGetCurrentDisplay(),
|
||||||
|
# elif defined(OPENCV_ENABLE_GLX)
|
||||||
|
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[i],
|
||||||
|
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
|
||||||
|
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
|
||||||
|
# endif
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
# if defined(OPENCV_ENABLE_EGL) && defined(OPENCV_ENABLE_GLX) //GLX fallback
|
||||||
|
if(properties[4] == CL_EGL_DISPLAY_KHR && properties[3] == (cl_context_properties)EGL_NO_CONTEXT) {
|
||||||
|
properties[3] = (cl_context_properties)glXGetCurrentContext();
|
||||||
|
properties[4] = (cl_context_properties)CL_GLX_DISPLAY_KHR;
|
||||||
|
properties[5] = (cl_context_properties)glXGetCurrentDisplay();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
context = clCreateContext(props, 1, &devices[devUsed], NULL, NULL, &status);
|
context = clCreateContext(props, 1, &devices[devUsed], NULL, NULL, &status);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (status != CL_SUCCESS)
|
if (status != CL_SUCCESS)
|
||||||
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't create context for OpenGL interop: %d", status));
|
CV_Error_(cv::Error::OpenCLInitError, ("OpenCL: Can't create context for OpenGL interop: %d", status));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user