Search code examples
directx-10

CreateTexture2D() fails when using DXGI_FORMAT_YUY2 as Format


When D3D10_TEXTURE2D_DESC contains the following:

textureDesc.Width               = 1920 * 2;
textureDesc.Height              = 1080 * 2;
textureDesc.MipLevels           = 1;
textureDesc.ArraySize           = 1;
textureDesc.Format              = DXGI_FORMAT_YUY2;
textureDesc.SampleDesc.Count    = 1;
textureDesc.SampleDesc.Quality  = 0;
textureDesc.Usage               = D3D10_USAGE_DYNAMIC;
textureDesc.BindFlags           = D3D10_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags      = D3D10_CPU_ACCESS_WRITE;
textureDesc.MiscFlags           = 0;

the ID3D10Device::CreateTexture2D() fails.
But, if I change Format to DXGI_FORMAT_R8G8B8A8_UNORM, the ID3D10Device::CreateTexture2D() succeeds. Can somebody explain why?


Solution

  • I know, that DirectX can output comments about error to stderr or stdout if you set D3D10_CREATE_DEVICE_DEBUG flag. Looks like it will help you to find the reason of failed.