Skip to content

Commit 90df5e0

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 8c25a8e + 9340fc0 commit 90df5e0

File tree

16 files changed

+744
-111
lines changed

16 files changed

+744
-111
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**********************************************************************************
2+
* Copyright (c) 2008-2009 The Khronos Group Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and/or associated documentation files (the
6+
* "Materials"), to deal in the Materials without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Materials, and to
9+
* permit persons to whom the Materials are furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included
13+
* in all copies or substantial portions of the Materials.
14+
*
15+
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22+
**********************************************************************************/
23+
24+
#ifndef __OPENCL_CL_D3D11_EXT_H
25+
#define __OPENCL_CL_D3D11_EXT_H
26+
27+
#include <d3d11.h>
28+
#include <CL/cl.h>
29+
#include <CL/cl_platform.h>
30+
31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
35+
/******************************************************************************
36+
* cl_nv_d3d11_sharing */
37+
38+
typedef cl_uint cl_d3d11_device_source_nv;
39+
typedef cl_uint cl_d3d11_device_set_nv;
40+
41+
/******************************************************************************/
42+
43+
// Error Codes
44+
#define CL_INVALID_D3D11_DEVICE_NV -1006
45+
#define CL_INVALID_D3D11_RESOURCE_NV -1007
46+
#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_NV -1008
47+
#define CL_D3D11_RESOURCE_NOT_ACQUIRED_NV -1009
48+
49+
// cl_d3d11_device_source_nv
50+
#define CL_D3D11_DEVICE_NV 0x4019
51+
#define CL_D3D11_DXGI_ADAPTER_NV 0x401A
52+
53+
// cl_d3d11_device_set_nv
54+
#define CL_PREFERRED_DEVICES_FOR_D3D11_NV 0x401B
55+
#define CL_ALL_DEVICES_FOR_D3D11_NV 0x401C
56+
57+
// cl_context_info
58+
#define CL_CONTEXT_D3D11_DEVICE_NV 0x401D
59+
60+
// cl_mem_info
61+
#define CL_MEM_D3D11_RESOURCE_NV 0x401E
62+
63+
// cl_image_info
64+
#define CL_IMAGE_D3D11_SUBRESOURCE_NV 0x401F
65+
66+
// cl_command_type
67+
#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_NV 0x4020
68+
#define CL_COMMAND_RELEASE_D3D11_OBJECTS_NV 0x4021
69+
70+
/******************************************************************************/
71+
72+
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11NV_fn)(
73+
cl_platform_id platform,
74+
cl_d3d11_device_source_nv d3d_device_source,
75+
void * d3d_object,
76+
cl_d3d11_device_set_nv d3d_device_set,
77+
cl_uint num_entries,
78+
cl_device_id * devices,
79+
cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0;
80+
81+
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferNV_fn)(
82+
cl_context context,
83+
cl_mem_flags flags,
84+
ID3D11Buffer * resource,
85+
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
86+
87+
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DNV_fn)(
88+
cl_context context,
89+
cl_mem_flags flags,
90+
ID3D11Texture2D * resource,
91+
UINT subresource,
92+
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
93+
94+
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DNV_fn)(
95+
cl_context context,
96+
cl_mem_flags flags,
97+
ID3D11Texture3D * resource,
98+
UINT subresource,
99+
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
100+
101+
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsNV_fn)(
102+
cl_command_queue command_queue,
103+
cl_uint num_objects,
104+
const cl_mem * mem_objects,
105+
cl_uint num_events_in_wait_list,
106+
const cl_event * event_wait_list,
107+
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
108+
109+
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsNV_fn)(
110+
cl_command_queue command_queue,
111+
cl_uint num_objects,
112+
cl_mem * mem_objects,
113+
cl_uint num_events_in_wait_list,
114+
const cl_event * event_wait_list,
115+
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
116+
117+
#ifdef __cplusplus
118+
}
119+
#endif
120+
121+
#endif // __OPENCL_CL_D3D11_H
122+

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ if(POLICY CMP0067)
108108
cmake_policy(SET CMP0067 NEW)
109109
endif()
110110

111+
if(POLICY CMP0068)
112+
cmake_policy(SET CMP0068 NEW) # CMake 3.9+: `RPATH` settings on macOS do not affect `install_name`.
113+
endif()
114+
111115
include(cmake/OpenCVUtils.cmake)
112116
ocv_cmake_reset_hooks()
113117
ocv_check_environment_variables(OPENCV_CMAKE_HOOKS_DIR)
@@ -368,6 +372,9 @@ OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON
368372
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON
369373
VISIBLE_IF WIN32 AND NOT WINRT
370374
VERIFY HAVE_DIRECTX)
375+
OCV_OPTION(WITH_OPENCL_D3D11_NV "Include NVIDIA OpenCL D3D11 support" WITH_DIRECTX
376+
VISIBLE_IF WIN32 AND NOT WINRT
377+
VERIFY HAVE_OPENCL_D3D11_NV)
371378
OCV_OPTION(WITH_LIBREALSENSE "Include Intel librealsense support" OFF
372379
VISIBLE_IF NOT WITH_INTELPERC
373380
VERIFY HAVE_LIBREALSENSE)
@@ -1570,6 +1577,7 @@ if(WITH_OPENCL OR HAVE_OPENCL)
15701577
IF HAVE_OPENCL_SVM THEN "SVM"
15711578
IF HAVE_CLAMDFFT THEN "AMDFFT"
15721579
IF HAVE_CLAMDBLAS THEN "AMDBLAS"
1580+
IF HAVE_OPENCL_D3D11_NV THEN "NVD3D11"
15731581
ELSE "no extra features")
15741582
status("")
15751583
status(" OpenCL:" HAVE_OPENCL THEN "YES (${opencl_features})" ELSE "NO")

cmake/OpenCVDetectOpenCL.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ set(OPENCL_FOUND ON CACHE BOOL "OpenCL library is found")
22
if(APPLE)
33
set(OPENCL_LIBRARY "-framework OpenCL" CACHE STRING "OpenCL library")
44
set(OPENCL_INCLUDE_DIR "" CACHE PATH "OpenCL include directory")
5-
else(APPLE)
5+
else()
66
set(OPENCL_LIBRARY "" CACHE STRING "OpenCL library")
77
set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2" CACHE PATH "OpenCL include directory")
88
ocv_install_3rdparty_licenses(opencl-headers "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/LICENSE.txt")
9-
endif(APPLE)
9+
endif()
1010
mark_as_advanced(OPENCL_INCLUDE_DIR OPENCL_LIBRARY)
1111

1212
if(OPENCL_FOUND)
13+
14+
if(WITH_OPENCL_D3D11_NV AND EXISTS "${OPENCL_INCLUDE_DIR}/CL/cl_d3d11_ext.h")
15+
set(HAVE_OPENCL_D3D11_NV ON)
16+
endif()
17+
1318
if(OPENCL_LIBRARY)
1419
set(HAVE_OPENCL_STATIC ON)
1520
set(OPENCL_LIBRARIES "${OPENCL_LIBRARY}")

cmake/templates/cvconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
#cmakedefine HAVE_OPENCL_STATIC
101101
#cmakedefine HAVE_OPENCL_SVM
102102

103+
/* NVIDIA OpenCL D3D Extensions support */
104+
#cmakedefine HAVE_OPENCL_D3D11_NV
105+
103106
/* OpenEXR codec */
104107
#cmakedefine HAVE_OPENEXR
105108

modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#define clWaitForEvents clWaitForEvents_
9797

9898
#if defined __APPLE__
99+
#define CL_SILENCE_DEPRECATION
99100
#include <OpenCL/cl.h>
100101
#else
101102
#include <CL/cl.h>

0 commit comments

Comments
 (0)