Skip to content

Add CUDA support for D3D11 interop. - #13972

Merged
alalek merged 20 commits into
opencv:3.4from
Mainvooid:add_cuda_support_for_D3D11_interop
Mar 24, 2019
Merged

alalek merged 20 commits into
opencv:3.4from
Mainvooid:add_cuda_support_for_D3D11_interop

Conversation

@Mainvooid

@Mainvooid Mainvooid commented Mar 5, 2019 •

Copy link
Copy Markdown

resolves #13888

This pullrequest changes

Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop.

Comment thread modules/core/src/directx.cpp Resolved
Comment thread modules/core/src/directx.cpp Resolved
Comment thread modules/core/src/directx.cpp Resolved
Comment thread modules/core/src/directx.cpp Resolved
Comment thread cmake/checks/opencl.cpp Resolved
@alalek

alalek commented Mar 6, 2019

Copy link
Copy Markdown
Member

We need compile time check for having cl_d3d11_ext.h.
OpenCV can be build with external OpenCL SDK (useful for Android builds) without this file with NV extensions.

Detect OpenCV device extension "cl_nv_d3d11_sharing"/etc in runtime.
Don't use "Device::getDefault()" here - this call initializes some OpenCL device (by OpenCV choice). You need to select your own - use Device(void* d /* cl_device_id d */) constructor.

@alalek

alalek commented Mar 7, 2019

Copy link
Copy Markdown
Member

"cl_nv_d3d11_sharing"

I believe we could check result of clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DNV"); for NULL instead of checking extensions.

Comment thread modules/core/src/directx.cpp Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread cmake/templates/cvconfig.h.in Resolved
Comment thread CMakeLists.txt Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread modules/core/src/directx.cpp Resolved
Comment thread modules/core/src/directx.cpp Resolved

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

I believe this patch is applicable to 3.4 branch. We will merge patches from 3.4 into master later.

Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
@Mainvooid

Mainvooid commented Mar 14, 2019 •

Copy link
Copy Markdown
Author

Here is a description about support for D3D9:
It is found that only TITAN X in the GTX series supports 'cl_nv_d3d9_sharing', while I cannot test since I do not have this device.

@Mainvooid
Mainvooid changed the base branch from master to 3.4 March 14, 2019 16:24
@Mainvooid
Mainvooid changed the base branch from 3.4 to master March 14, 2019 16:59
@Mainvooid
Mainvooid changed the base branch from master to 3.4 March 14, 2019 17:11
color_detail.hpp: fixed build error : dynamic initialization is not supported for a __constant__ variable.
directx.cpp: Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop.  #13888

Update directx.cpp

Format adjustment.

Update directx.cpp

fix error.

Update directx.cpp

Format adjustment

Update directx.cpp

fix trailing whitespace.

fix format errors

convert indentation to spaces .
Trim trailing whitespace.
Add information about source of cl_d3d11_ext.h
Avoid unrelated changes.

Increase compile-time conditional judgment.

Increase the judgment of whether the OCL device has the required extensions at compile time.

Add compilation option  `HAVE_CLNVEXT`.Check CL support in runtime.

Check result of `clGetExtensionFunctionAddressForPlatform` for KHR is invalid.It always can get the address(from OpenCL.dll),So I check NV support(from nvopencl64.dll) before KHR when `HAVE_CLNVEXT` is enabled.

Delete cl_d3d11_ext.h

Modified parameter list

fix "cannot open include file: 'CL/cl_d3d11_ext.h'"

 remove not referenced var

fix C2143: syntax error

Improve compile-time judgment.

dlrectx.cpp Modify the detection order.
initializeContextFromD3D11Device:
```
    // try with NV(Need to check it first)
    // try with KHR
```

fix warnig C4100

Revert "fix warnig C4100"

This reverts commit 76e5bec.

fix warning C4100

fix warning C4505

Format alignment

Format adjustment and automatically detect header files.

Automatically detect header files when users are not configured or configuration errors occur.

avoid unrelated changes.

Update .cmake

Update .cmake
@alalek

alalek commented Mar 14, 2019

Copy link
Copy Markdown
Member

Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread modules/core/src/directx.cpp Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved
Comment thread CMakeLists.txt Resolved
Comment thread cmake/OpenCVDetectOpenCL.cmake Resolved

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

@alalek
alalek merged commit 097fc1a into opencv:3.4 Mar 24, 2019
@alalek alalek mentioned this pull request Mar 26, 2019
@Mainvooid
Mainvooid deleted the add_cuda_support_for_D3D11_interop branch April 9, 2019 18:29
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
…3D11_interop

* Add CUDA support for D3D11 interop. opencv#13888

color_detail.hpp: fixed build error : dynamic initialization is not supported for a __constant__ variable.
directx.cpp: Add CUDA support(cl_nv_d3d11_sharing) for D3D11 interop.  opencv#13888

Update directx.cpp

Format adjustment.

Update directx.cpp

fix error.

Update directx.cpp

Format adjustment

Update directx.cpp

fix trailing whitespace.

fix format errors

convert indentation to spaces .
Trim trailing whitespace.
Add information about source of cl_d3d11_ext.h
Avoid unrelated changes.

Increase compile-time conditional judgment.

Increase the judgment of whether the OCL device has the required extensions at compile time.

Add compilation option  `HAVE_CLNVEXT`.Check CL support in runtime.

Check result of `clGetExtensionFunctionAddressForPlatform` for KHR is invalid.It always can get the address(from OpenCL.dll),So I check NV support(from nvopencl64.dll) before KHR when `HAVE_CLNVEXT` is enabled.

Delete cl_d3d11_ext.h

Modified parameter list

fix "cannot open include file: 'CL/cl_d3d11_ext.h'"

 remove not referenced var

fix C2143: syntax error

Improve compile-time judgment.

dlrectx.cpp Modify the detection order.
initializeContextFromD3D11Device:
```
    // try with NV(Need to check it first)
    // try with KHR
```

fix warnig C4100

Revert "fix warnig C4100"

This reverts commit 76e5bec.

fix warning C4100

fix warning C4505

Format alignment

Format adjustment and automatically detect header files.

Automatically detect header files when users are not configured or configuration errors occur.

avoid unrelated changes.

Update .cmake

Update .cmake

* fix build errors

* fix warning:defined but not used

* Revert "fix warning:defined but not used"

This reverts commit 7ab3537.

* fix warning:defined but not used

* fix build error for mac

* fix build error for win

* optimizing branch judgment

* Revert "optimizing branch judgment"

This reverts commit 88b72b8.

* fix warning C4702: unreachable code

* remove unused code

* Fix problems that may lead to undefined behavior

* Add status check

* fix error C2664,C2665 : cannot convert argument

* Format adjustment

VSCODE will automatically format the indentation to 4 spaces in some situation.

* fix error C2440

* fix error C2440

* add cl_d3d11_ext.h

* Format adjustment

* remove unnecessary checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants