2017-09-21 101 views
0

此前,swapchain設置爲RGB32格式,它工作正常。如何創建交換鏈格式DXGI_FORMAT_420_OPAQUE?

我想接收yv12數據並進行渲染。

因此我將swapChain格式更改爲DXGI_FORMAT_420_OPAQUE

DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 }; 

swapChainDesc.Width = 0; 
swapChainDesc.Height = 0; 
swapChainDesc.Format = DXGI_FORMAT_420_OPAQUE;// DXGI_FORMAT_B8G8R8A8_UNORM 
swapChainDesc.Stereo = false; 
swapChainDesc.SampleDesc.Count = 1; 
swapChainDesc.SampleDesc.Quality = 0; 
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; 
swapChainDesc.BufferCount = 2; 
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; 
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; 
swapChainDesc.Flags = 0; 


dxgiFactory->CreateSwapChainForHwnd(_direct3DDevice, _hwnd, &swapChainDesc, nullptr, nullptr, &_DXGISwapChain); 


IDXGISurface *dxgiBackBuffer; 
_DXGISwapChain->GetBuffer(0, IID_PPV_ARGS(&dxgiBackBuffer)); 

然後在dxgiBackBuffer我得到一個NullReferenceException

我認爲你不能根據yv12 format創建後臺緩衝區。

你知道我錯了嗎?

回答

1

受支持的交換鏈格式是在DXGI hardware feature levels格式表中列爲'顯示出'的那些格式。沒有Direct3D硬件功能級別支持用於顯示的YUV格式。您必須在某處着色器中執行YUV到RGB色彩空間的轉換。