Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX D3D11CreateDeviceAndSwapChain returning E_INVALIDARG

I have the following call, and no matter what I try, hresult is always E_INVALIDARG:

LogMessage(L"Creating swap chain. Emulation: " + std::to_wstring(useSoftwareEmulation) + L", Debugging: " + std::to_wstring(enableRenderDebugging));
HRESULT hresult = D3D11CreateDeviceAndSwapChain(
    (useSoftwareEmulation ? NULL : currentAdapter), 
    (useSoftwareEmulation ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_UNKNOWN), 
    NULL, 
    (enableRenderDebugging ? D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_DEBUGGABLE : 0),
    NULL,
    0,
    D3D11_SDK_VERSION,
    &swapChainDescriptor, 
    &swapChain,
    &graphicsCardInterface, 
    &runningFeatureLevel, 
    &graphicsCardContext
    );

According to the log line above, both useSoftwareEmulation and enableRenderDebugging are false.

The types of all the other variables are as such:

currentAdapter is a IDXGIAdapter*

swapChainDescriptor is a DXGI_SWAP_CHAIN_DESC

swapChain is a IDXGISwapChain*

graphicsCardInterface is a ID3D11Device*

runningFeatureLevel is a D3D_FEATURE_LEVEL

graphicsCardContext is a ID3D11DeviceContext*

like image 491
Xenoprimate Avatar asked Sep 05 '25 03:09

Xenoprimate


1 Answers

False alarm: I had an error in my swapChainDescriptor (namely, my MSAA count and quality values were swapped).

Hope this might help anyone else in the future.

like image 73
Xenoprimate Avatar answered Sep 07 '25 23:09

Xenoprimate