0
votes

Render target description as below, my app crashed when CreateTexture2D is called, but nothing wrong with shader resource.

CD3D11_TEXTURE2D_DESC renderTargetDesc(
    DXGI_FORMAT_R8_UNORM,
    static_cast<UINT>(m_renderTargetSize.Width),
    static_cast<UINT>(m_renderTargetSize.Height),
    1,
    1,
    D3D11_BIND_RENDER_TARGET
    );

m_d3dDevice->CreateTexture2D(
    &renderTargetDesc,
    nullptr,
    &m_renderTarget
);

But I found that DXGI_FORMAT_R8_UNORM format is supported by render target: http://msdn.microsoft.com/en-us/library/windows/desktop/hh404483(v=vs.85).aspx

Can anyone tell me where the problem is? Thanks very much!

1

1 Answers

0
votes

Not all the hardware are equals, you should check usage first using ID3D11Device::CheckFormatSupport as documented here.

Modern GPU are unlickly to support rendering on something less than 32bits per pixel. Windows driver are also more likely to provide emulation on missing feature behind the hood than on a phone where performance and battery consumption should be double checked.

You should add the debug layer flag at device creation and look at the console log, you will see error messages related to invalid parameters to your calls.