How to render an I420 frame using DirectX?

Viewed 17

I'm currently using the below code in windows store app (UWP) to render a ARGB32 frame by creating a D2D bitmap and rendering it using Direct3D. I tried using the DXGI_FORMAT_YUY2/DXGI_FORMAT_NV12 format for creating a D2D bitmap to render a I420 frame using DirectX. But getting an error, bitmap not supported.

Any thoughts on how can I use this format or this is not possible with DirectX?

void D3DPanel::RenderFrameDirect2D(const Platform::Array<uint8>^ buffer,int width,int height)
{
            HRESULT hr;

            bool isDraw = false;

            hr = m_d2dContext->CreateBitmap(D2D1::SizeU(width, height),      
                    buffer->Data,
                    width * 4,
                    D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE)),
                    &bitmap);
                m_d2dContext->BeginDraw();
                m_d2dContext->DrawBitmap(bitmap);
                bitmap->Release();
    
                if (FAILED(hr))
                {
                    return;
                }
    
                hr = m_d2dContext->EndDraw();
               DXGI_PRESENT_PARAMETERS parameters = { 0 };
               parameters.DirtyRectsCount = 0;
               parameters.pDirtyRects = nullptr;
               parameters.pScrollRect = nullptr;
               parameters.pScrollOffset = nullptr;

               HRESULT hr = S_OK;

               hr = m_swapChain->Present1(1, 0, &parameters);

               m_dxgiOutput->WaitForVBlank();
    }
0 Answers
Related