DXGI/NvEnc YUV44 10bit format compatability

469 Views Asked by At

Using DirectX 11, DXGI DDA and NvEnc. I have to support YUV420, YUV444, 8bit, and 10bit. I have the conversions working great for YUV420, YUV444, and 8bit. With 10bit i Run into a bit of a problem of DXGI_FORMAT compatibility with the NV_ENC_BUFFER_FORMATS.

I have compute shaders to convert the DDA capture formats (DXGI_FORMAT_B8G8R8A8_UNORM for 8bit, DXGI_FORMAT_R16G16B16A16_FLOAT for 10bit) to the YUV formats for NvEnc. Using the builtin RGB formats within NvEnc doesnt seem to work, since they all convert to YUV420 internally (no YUV444) and give me no control over the chromaticity coordinates (BT.601, BT.709 for example)

The YUV444 10bit formats that DXGI supports are:

DXGI_FORMAT_Y410 (10bit packed, 2bit alpha, 32bit per pixel)

DXGI_FORMAT_Y416 (10bit unpacked as 16bit per channel, 16bit alpha, 64bit per pixel)

The YUV444 10bit formats that NvEnc supports are:

NV_ENC_BUFFER_FORMAT_YUV444_10BIT (10bit unpacked as 16bit per channel, no alpha, 48bit per pixel)

So here is the problem. There are no compatible formats here. It seems my only option to convert between the two is a structured buffer (and do more manual work), or a DXGI_FORMAT_R16_FLOAT format and making the dimensions be 3x my frame dimensions. It would also require me to build another pipeline. I have 4 for each conversion already, since I have to write the mousepointer (color, masked color, or monochrome) into the image as well. And this would just make my system more obnoxious and bloated than it already is.

Do I have a better option? Is there something I am missing about these formats? Nvidia doesnt talk about these formats at all except within the NvEncodeApi.h header where they are defined.

1

There are 1 best solutions below

2
On

Direct3D can't work directly with the video formats, but they are all designed to 'map' to non-video formats.

For example, DXGI_FORMAT_Y410:

10-bit per channel packed YUV 4:4:4 video resource format. Valid view formats for this video resource format are DXGI_FORMAT_R10G10B10A2_UNORM and DXGI_FORMAT_R10G10B10A2_UINT. For UAVs, an additional valid view format is DXGI_FORMAT_R32_UINT. By using DXGI_FORMAT_R32_UINT for UAVs, you can both read and write as opposed to just write for DXGI_FORMAT_R10G10B10A2_UNORM and DXGI_FORMAT_R10G10B10A2_UINT. Supported view types are SRV and UAV. One view provides a straightforward mapping of the entire surface. The mapping to the view channel is U->R10, Y->G10, V->B10, and A->A2.

See Microsoft Docs.