Skip to content

DirectX: Support conversion for more types, including float16 types#20260

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
JoeHowse:DirectX-float16-conversions
Jun 11, 2021
Merged

DirectX: Support conversion for more types, including float16 types#20260
opencv-pushbot merged 1 commit intoopencv:masterfrom
JoeHowse:DirectX-float16-conversions

Conversation

@JoeHowse
Copy link
Copy Markdown
Contributor

Support the following conversions from OpenCV types to DXGI types (via functions such as cv::directx::convertToD3D11Texture2D):

  • CV_16FC4 --> DXGI_FORMAT_R16G16B16A16_FLOAT
  • CV_16FC2 --> DXGI_FORMAT_R16G16_FLOAT
  • CV_16FC1 --> DXGI_FORMAT_R16_FLOAT
  • CV_32FC2 --> DXGI_FORMAT_R32G32_FLOAT
  • CV_32FC1 --> DXGI_FORMAT_D32_FLOAT
  • CV_32SC2 --> DXGI_FORMAT_R32G32_UINT
  • CV_32SC2 --> DXGI_FORMAT_R32G32_SINT
  • CV_8UC4 --> DXGI_FORMAT_R8G8_B8G8_UNORM **
  • CV_8UC4 --> DXGI_FORMAT_G8R8_G8B8_UNORM **

Of these, conversion to DXGI_FORMAT_R16G16B16A16_FLOAT is the most widely useful because this is a standard format for the back buffer when Windows is running in HDR mode.

With the changes, I have successfully tested the CV_16FC4 --> DXGI_FORMAT_R16G16B16A16_FLOAT conversion in a closed-source project that performs HDR rendering.

** DXGI_FORMAT_R8G8_B8G8_UNORM and DXGI_FORMAT_G8R8_G8B8_UNORM are packed formats. Using these formats in OpenCV (with a CV_8UC4 representation) would be unusual but it is possible. For example, they would be compatible with basic arithmetic manipulations such as cv::addWeighted to blend two images.

Support the following type conversions:

* CV_16FC4 --> DXGI_FORMAT_R16G16B16A16_FLOAT

* CV_16FC2 --> DXGI_FORMAT_R16G16_FLOAT

* CV_16FC1 --> DXGI_FORMAT_R16_FLOAT

* CV_32FC2 --> DXGI_FORMAT_R32G32_FLOAT

* CV_32FC1 --> DXGI_FORMAT_D32_FLOAT

* CV_32SC2 --> DXGI_FORMAT_R32G32_UINT

* CV_32SC2 --> DXGI_FORMAT_R32G32_SINT

* CV_8UC4 -->  DXGI_FORMAT_R8G8_B8G8_UNORM

* CV_8UC4 -->  DXGI_FORMAT_G8R8_G8B8_UNORM
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution 👍

@opencv-pushbot opencv-pushbot merged commit 438e2dc into opencv:master Jun 11, 2021
@alalek alalek mentioned this pull request Jun 13, 2021
@JoeHowse JoeHowse deleted the DirectX-float16-conversions branch June 20, 2021 13:38
@alalek alalek mentioned this pull request Oct 15, 2021
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