1

github上有一个没用的D3D12示例代码项目 https://github.com/microsoft/D3D12TranslationLayer

停留在 CreateVideoProcessor 的步骤

ID3D12Device1* device1= {};
ID3D12VideoDevice* videodevice = {};
ID3D12VideoProcessor* VideoProcessor = {};

HRESULT query_device1 = d3d12_device->QueryInterface(MY_IID_PPV_ARGS(&device1));
// S_OK
HRESULT query_videodevice = d3d12_device1->QueryInterface(MY_IID_PPV_ARGS(&videodevice));
// S_OK

auto VPSupport = D3D12_FEATURE_DATA_VIDEO_PROCESS_SUPPORT{};
VPSupport.InputSample.Width = 1920;
VPSupport.InputSample.Height = 1280;
VPSupport.InputSample.Format.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
VPSupport.InputSample.Format.ColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
VPSupport.InputStereoFormat = D3D12_VIDEO_FRAME_STEREO_FORMAT_NONE;
VPSupport.InputFrameRate = DXGI_RATIONAL{ 30, 1 };
VPSupport.OutputFormat.Format = DXGI_FORMAT_NV12;
VPSupport.OutputFormat.ColorSpace = DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709;
VPSupport.OutputStereoFormat = D3D12_VIDEO_FRAME_STEREO_FORMAT_NONE;
VPSupport.OutputFrameRate = DXGI_RATIONAL{ 30, 1 };
VPSupport.SupportFlags = D3D12_VIDEO_PROCESS_SUPPORT_FLAG_SUPPORTED;
HRESULT is_check_support = videodevice->CheckFeatureSupport(D3D12_FEATURE_VIDEO_PROCESS_SUPPORT, &VPSupport, sizeof(VPSupport));
// S_OK

auto out_stream_desc = D3D12_VIDEO_PROCESS_OUTPUT_STREAM_DESC{};
out_stream_desc.Format = DXGI_FORMAT_NV12;
out_stream_desc.ColorSpace = DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709;
out_stream_desc.FrameRate = DXGI_RATIONAL{ 30, 1 };
auto in_stream_desc = D3D12_VIDEO_PROCESS_INPUT_STREAM_DESC{};
in_stream_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
in_stream_desc.ColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
in_stream_desc.FrameRate = DXGI_RATIONAL{ 30, 1 };
in_stream_desc.SourceAspectRatio = DXGI_RATIONAL{ 1920, 1080 };
in_stream_desc.DestinationAspectRatio = DXGI_RATIONAL{ 1920, 1080 };
auto size_range = D3D12_VIDEO_SIZE_RANGE{ 1920, 1080, 1280, 720 };
in_stream_desc.SourceSizeRange = size_range;
in_stream_desc.DestinationSizeRange = size_range;
HRESULT is_create_vp = videodevice->CreateVideoProcessor(0, &out_stream_desc, 1, &in_stream_desc, MY_IID_PPV_ARGS(&VideoProcessor));
// S_OK


如何通过directx12将rgba纹理转换为nv12纹理?

(平台为Windows 1909)

4

0 回答 0