{"id":5459,"date":"2021-12-08T09:46:51","date_gmt":"2021-12-08T17:46:51","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/directx\/?p=5459"},"modified":"2021-12-08T10:44:46","modified_gmt":"2021-12-08T18:44:46","slug":"announcing-new-directx-12-feature-video-encoding","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/directx\/announcing-new-directx-12-feature-video-encoding\/","title":{"rendered":"Announcing new DirectX 12 feature &#8211; Video Encoding!"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p><span data-contrast=\"auto\">Today DirectX 12 provides APIs to support GPU acceleration for several video applications such as Video Decoding, Video Processing and Motion estimation as detailed in <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/medfound\/direct3d-12-video-overview\">Direct3D 12 Video Overview<\/a>.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">We are\u00a0happy to announce that D3D12 has added a new Video Encode feature to the existing video API families, with a new set of interfaces that allow developers to perform video encoding using GPU accelerated video engines.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">This feature provides a new way for apps to implement video encoding consistently with the\u00a0DirectX\u00a012 principles and style.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"2\"><span data-contrast=\"none\">Video Encode API Remarks<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">In terms of data flow, the API takes each video frame represented by <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/nn-d3d12-id3d12resource\">ID3D12Resource<\/a> textures and compresses them into an <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/nn-d3d12-id3d12resource\">ID3D12Resource<\/a> buffer, that contains the slice headers and\u00a0payload of each encoded frame. Currently only <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/dxgiformat\/ne-dxgiformat-dxgi_format\">DXGI_FORMAT_NV12<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/dxgiformat\/ne-dxgiformat-dxgi_format\">DXGI_FORMAT_P010<\/a> are\u00a0available depending on driver support, so input content may need to be color converted and\u00a0down sampled\u00a0previously by the API user.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">The available codecs today are H264 and HEVC\u00a0and specific support for each codec and their encoding tools\u00a0must\u00a0be queried\u00a0using\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videodevice-checkfeaturesupport\">ID3D12VideoDevice::CheckFeatureSupport<\/a> as\u00a0there are\u00a0driver support\u00a0requirements.<\/span><\/p>\n<p><span data-contrast=\"auto\">The responsibility for handling the rest of the bitstream codec headers (i.e.\u00a0SEI\/VUI\/VPS\/SPS\/PPS) is completely delegated to the user, who will generate and pack them into the final bitstream along with the compressed bitstream obtained from the GPU operation for each frame.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Following\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/medfound\/direct3d-12-video-overview#reference-frames\">DirectX\u00a012 principles and style<\/a>, reference frames are managed\u00a0explicitly,\u00a0and their memory is completely tracked by the API user. This allows for clear usage of array of textures or texture arrays to store the DPB having explicit memory budgeting\/management\u00a0control and\u00a0enables\u00a0the API user to have full control\u00a0of\u00a0the DPB size and the reference picture selection strategies. Other aspects of reference picture management such as I\/P\/B picture type selection and B-frame group-of-pictures reordering are also in control in the user, who will track the display ordering and reference frame dependencies topology and submit GPU operations in encode order with the desired picture type.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">A considerable number of configurable parameters are exposed by this API for the user to tweak different aspects of the encoding process and make them fit best for their scenarios such as: custom slices partitioning scheme, active (i.e. CBR, VBR, QBVR) and passive (Absolute\/Delta custom QP maps) rate control configuration modes, custom codec encoding tools usage, custom codec block and transform sizes, motion vector precision limit, explicit usage of intra-refresh sessions, dynamic reconfiguration of video stream resolution\/rate control\/slices partitioning and more.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">This API also reports\u00a0encode\u00a0statistics and can be used along with <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videoencodecommandlist-setpredication\">SetPredication <\/a><\/span><span data-contrast=\"auto\">and <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/direct3d12\/timing\">Timestamp<\/a><\/span><span data-contrast=\"auto\">\u00a0D3D12 Features.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"2\"><span data-contrast=\"none\">Video Encode API documentation resources<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">The API usage is similar to other existing Video DirectX 12 features and the high-level steps are:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<ul>\n<li><span data-contrast=\"auto\"> Call <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videodevice-checkfeaturesupport\">ID3D12VideoDevice::CheckFeatureSupport<\/a> to check for the support details for\u00a0DirectX12 video encoding operations. Pass a value from the <a href=\"https:\/\/github.com\/microsoft\/DirectX-Headers\/blob\/0644e7014faf33358b4e220875305d29715db0f8\/include\/directx\/d3d12video.h#L309\">D3D12_FEATURE_VIDEO<\/a> enumeration to specify the feature for which you are requesting support information.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\"> Call <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videodevice3-createvideoencoder\">ID3D12VideoDevice::CreateVideoEncoder<\/a> to create an instance of the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nn-d3d12video-id3d12videoencoder\">ID3D12VideoEncoder<\/a> interface, which holds the state of the encoding session.<\/span><\/li>\n<li><span data-contrast=\"auto\"> Call <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videodevice3-createvideoencoderheap\">ID3D12VideoDevice::CreateVideoEncoderHeap<\/a> to create an instance of the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nn-d3d12video-id3d12videoencoderheap\">ID3D12VideoEncoderHeap<\/a> interface. This object contains the resolution-dependent driver resources and state.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\"> To Encode a frame:\u00a0<\/span>\n<ul>\n<li><span data-contrast=\"auto\"> All input and output parameters for video encode operations are organized into the input and output parameters structures: <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/ns-d3d12video-d3d12_video_encoder_encodeframe_input_arguments\">D3D12_VIDEO_ENCODER_ENCODEFRAME_INPUT_ARGUMENTS<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/ns-d3d12video-d3d12_video_encoder_encodeframe_output_arguments\">D3D12_VIDEO_ENCODER_ENCODEFRAME_OUTPUT_ARGUMENTS<\/a> to record the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videoencodecommandlist2-encodeframe\">ID3D12VideoCommandList2::EncodeFrame<\/a> command.\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\"> After the encoding operation, the user must also perform <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/nf-d3d12video-id3d12videoencodecommandlist2-resolveencoderoutputmetadata\">ID3D12VideoCommandList2::ResolveEncoderOutputMetadata<\/a> to resolve hardware dependent encoding results from <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/ns-d3d12video-d3d12_video_encoder_resolve_metadata_input_arguments\">D3D12_VIDEO_ENCODER_RESOLVE_METADATA_INPUT_ARGUMENTS<\/a> into <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12video\/ns-d3d12video-d3d12_video_encoder_output_metadata\">D3D12_VIDEO_ENCODER_RESOLVE_METADATA_OUTPUT_ARGUMENTS<\/a>.\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\"> When the command list is properly recorded, call <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/d3d12\/nf-d3d12-id3d12commandqueue-executecommandlists\">ID3D12CommandQueue::ExecuteCommandLists<\/a> on the video command queue to submit the frame encoding and metadata resolving operations to the GPU.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">The detailed API interfaces and structures definition can be found <a href=\"https:\/\/github.com\/microsoft\/DirectX-Headers\/blob\/main\/include\/directx\/d3d12video.h\">here<\/a>.<\/span><\/p>\n<p><span data-contrast=\"auto\">For finding more design details and detailed documentation for the API, please refer to <a href=\"https:\/\/github.com\/microsoft\/DirectX-Specs\/blob\/master\/d3d\/D3D12VideoEncoding.md\">this document<\/a>.<\/span><\/p>\n<h3 aria-level=\"2\"><span data-contrast=\"none\">Video Encode API supported platforms<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:40,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\"><span class=\"NormalTextRun SCXW151938990 BCX8\">The Video Encode API\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">is\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">included as part of\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">Windows\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">11\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">and\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">can\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">also be<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">\u00a0found in\u00a0<\/span><span class=\"NormalTextRun SCXW151938990 BCX8\">the<\/span> <a href=\"https:\/\/devblogs.microsoft.com\/directx\/directx12agility\/\">DirectX 12 Agility SDK <\/a><span class=\"NormalTextRun SCXW67570689 BCX8\">(<\/span><span class=\"NormalTextRun ContextualSpellingAndGrammarErrorV2 SCXW67570689 BCX8\">version<\/span><span class=\"NormalTextRun SCXW67570689 BCX8\">\u00a0<a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Direct3D.D3D12\/1.700.10-preview\">1.700.10-preview<\/a> or newer)<\/span>.<\/span><\/p>\n<p><span class=\"TextRun SCXW218240782 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW218240782 BCX8\">P<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\">lease see below the list of hardware platforms that currently have support for Video Encode<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\"> for both H264 and HEVC codecs<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\"> and the<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\">ir<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\"> minimum driver version requirements<\/span><span class=\"NormalTextRun SCXW218240782 BCX8\">.<\/span><\/span><span class=\"EOP SCXW218240782 BCX8\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 154px;\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\">Vendor<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">Supported platforms<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">Minimum video driver version<\/td>\n<\/tr>\n<tr style=\"height: 70px;\">\n<td style=\"width: 33.3333%; height: 70px;\">AMD<\/td>\n<td style=\"width: 33.3333%; height: 70px;\">\n<ul>\n<li>Radeon RX 5000 series or greater<\/li>\n<li>Ryzen 2xxxx series or greater<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.3333%; height: 70px;\" width=\"282\">In development \u2013 ETA Q2 \u20182022<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\">Intel<\/td>\n<td style=\"width: 33.3333%;\" width=\"256\">\n<ul>\n<li>Tiger Lake<\/li>\n<li>Ice Lake<\/li>\n<li>Alder Lake (from early 2022)<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.3333%;\" width=\"282\">v30.0.100.9955<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\">NVIDIA<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">\n<ul>\n<li>GeForce GTX 10xx and above<\/li>\n<li>GeForce RTX 20xx and above<\/li>\n<li>Quadro RTX<\/li>\n<li>NVIDIA RTX<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">v471.41<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Today DirectX 12 provides APIs to support GPU acceleration for several video applications such as Video Decoding, Video Processing and Motion estimation as detailed in Direct3D 12 Video Overview.\u00a0 We are\u00a0happy to announce that D3D12 has added a new Video Encode feature to the existing video API families, with a new set of interfaces [&hellip;]<\/p>\n","protected":false},"author":70024,"featured_media":12651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5459","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-directx"],"acf":[],"blog_post_summary":"<p>Introduction Today DirectX 12 provides APIs to support GPU acceleration for several video applications such as Video Decoding, Video Processing and Motion estimation as detailed in Direct3D 12 Video Overview.\u00a0 We are\u00a0happy to announce that D3D12 has added a new Video Encode feature to the existing video API families, with a new set of interfaces [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/5459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/users\/70024"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/comments?post=5459"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/5459\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media\/12651"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media?parent=5459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/categories?post=5459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/tags?post=5459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}