Color conversion from DXGI_FORMAT_B8G8R8A8_UNORM to NV12 in GPU using DirectX11 pixel shaders

前端 未结 1 736
野的像风
野的像风 2020-12-29 13:22

I\'m working on a code to capture the desktop using Desktop duplication and encode the same to h264 using Intel hardwareMFT. The encoder only accepts NV12 format as input. I

相关标签:
1条回答
  • 2020-12-29 13:45

    I am experimenting this RGBA conversion to NV12 in the GPU only, using DirectX11.

    This is a good challenge. I'm not familiar with Directx11, so this is my first experimentation.

    Check this project for updates : D3D11ShaderNV12

    In my current implementation (may not be the last), here is what I do:

    • Step 1: use a DXGI_FORMAT_B8G8R8A8_UNORM as input texture
    • Step 2: make a 1st pass shader to get 3 textures (Y:Luma, U:ChromaCb and V:ChromaCr): see YCbCrPS2.hlsl
    • Step 3: Y is DXGI_FORMAT_R8_UNORM, and is ready for final NV12 texture
    • Step 4: UV needs to be downsampled in a 2nd pass shader: see ScreenPS2.hlsl (using linear filtering)
    • Step 5: a third pass shader to sample Y texture
    • Step 6: a fourth pass shader to sample UV texture using a shift texture (I think other technique could be use)

    My final texture is not DXGI_FORMAT_NV12, but a similar DXGI_FORMAT_R8_UNORM texture. My computer is Windows7, so DXGI_FORMAT_NV12 is not handled. I will try later on a another computer.

    The process with pictures:

    0 讨论(0)
提交回复
热议问题