1

I am creating an texture with the MiscFlags D3D11_RESOURCE_MISC_GDI_COMPATIBLE. Yet debug layer is showing following error. If I use D3D10_RESOURCE_MISC_GDI_COMPATIBLE flag CreateTexture2D() - throws exception. Why debug layer expects D3D10_RESOURCE_MISC instead of D3D11_RESOURCE_MISC ?

DXGI ERROR: IDXGISurface1::GetDC: GetDC can only be called for textures that were created with the D3D10_RESOURCE_MISC_GDI_COMPATIBLE flag. [ MISCELLANEOUS ERROR #89: ]

TRY_POINTER(renderer);
D3D11_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Width = gsl::narrow_cast<UINT>(width);
desc.Height = gsl::narrow_cast<UINT>(height);
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0;
desc.MipLevels = 1;
desc.SampleDesc.Count = 1;
desc.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE;

ID3D11DevicePtr device = renderer->Device();
ID3D11Texture2DPtr  texture2D;
IF_FAILED_THROW_HR(device->CreateTexture2D(&desc, nullptr, &texture2D));

1 Answers1

0

Sorry. It's my fault. IDXGISurface1 was become null before the usage of the GDI Compatible DC from the surface. Now it's working! No DXGI errors.