Jump to content
  • Advertisement
Sign in to follow this  
matt77hias

Swap chain creation failed

This topic is 431 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by matt77hias

Share this post


Link to post
Share on other sites
Advertisement
1 minute ago, ajmiles said:

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

D3D11.2 (Windows 8.1)

Edited by matt77hias

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Edited by matt77hias

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!