Swap chain creation failed

Started by
15 comments, last by galop1n 6 years, 7 months ago

I create my swap chain in the following way:


// Create a DXGI_SWAP_CHAIN_DESC1.
DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {};
swap_chain_desc.Width = static_cast< UINT >(GetWidth());
swap_chain_desc.Height = static_cast< UINT >(GetHeight());
swap_chain_desc.Format = m_display_configuration->GetDisplayFormat();
swap_chain_desc.SampleDesc = m_display_configuration->GetMSAASampleDesc();
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_UNORDERED_ACCESS;
swap_chain_desc.BufferCount = 1u;
swap_chain_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

// Create a DXGI_SWAP_CHAIN_FULLSCREEN_DESC.
DXGI_SWAP_CHAIN_FULLSCREEN_DESC swap_chain_fullscreen_desc = {};
swap_chain_fullscreen_desc.RefreshRate = m_display_configuration->GetDisplayRefreshRate();
swap_chain_fullscreen_desc.Windowed = TRUE;

// Get the IDXGISwapChain1.
ComPtr< IDXGISwapChain1 > swap_chain1;
const HRESULT result_swap_chain1 = dxgi_factory3->CreateSwapChainForHwnd(m_device.Get(), m_hwindow, &swap_chain_desc, &swap_chain_fullscreen_desc, nullptr, swap_chain1.ReleaseAndGetAddressOf());

The only thing that changed is the addition of DXGI_USAGE_UNORDERED_ACCESS (without DXGI_USAGE_UNORDERED_ACCESS, everything works fine).

The error code is 0x80070057 (E_INVALIDARG).

Any ideas what's missing? If I remove DXGI_USAGE_SHADER_INPUT, the issue remains; so it has clearly something to do with DXGI_USAGE_UNORDERED_ACCES.

🧙

Advertisement

Is this D3D12? UAV access is not allowed on Swap Chains any more.

 

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

1 minute ago, ajmiles said:

Is this D3D12? UAV access is not allowed on Swap Chains any more.

D3D11.2 (Windows 8.1)

🧙

Oh, is your "Format" _SRGB? You aren't allowed to create UAVs of SRGB formatted textures.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

2 minutes ago, ajmiles said:

Oh, is your "Format" _SRGB? You aren't allowed to create UAVs of SRGB formatted textures.

DXGI_FORMAT_B8G8R8A8_UNORM

🧙

Did you create your D3D Device with the D3D11_CREATE_DEVICE_DEBUG flag, you should be getting an error printed out for what's up?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

6 minutes ago, ajmiles said:

Oh, is your "Format" _SRGB? You aren't allowed to create UAVs of SRGB formatted textures.

The swapchain is an exception, you cannot create it with a typeless format, so there is a few bypass on aliasing views with different formats. ( not sure if this one is tho ).

 

As UAV for backbuffers is kind of deprecated anyway, i would recommend to not use that, create a separate resource and just perform a final copy to the swap chain at the end.

8 minutes ago, ajmiles said:

Did you create your D3D Device with the D3D11_CREATE_DEVICE_DEBUG flag, you should be getting an error printed out for what's up?

D3D11 ERROR: ID3D11Device::CreateTexture2D: The format (0x57, B8G8R8A8_UNORM) cannot be bound as an UnorderedAccessView, or cast to a format that could be bound as an UnorderedAccessView.  Therefore this format does not support D3D11_BIND_UNORDERED_ACCESS. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT]
Exception thrown at 0x00007FF9EFEE95FC in FPS.exe: Microsoft C++ exception: _com_error at memory location 0x0000009E0273BE00.
D3D11 ERROR: ID3D11Device::CreateTexture2D: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #104: CREATETEXTURE2D_INVALIDARG_RETURN]

🧙

Unless you intended to use Direct2D, which I think requires use of BGRA, you may as well just create your swap chain as R8G8B8A8_UNORM.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

Based on the comments, it's maybe idd. better to use a separate resource (although this feels like a waste).

6 minutes ago, ajmiles said:

Unless you intended to use Direct2D, which I think requires use of BGRA, you may as well just create your swap chain as R8G8B8A8_UNORM.

:o Completely, overlooked that one in DXGI_FORMAT enum.

 

That one works!

🧙

This topic is closed to new replies.

Advertisement