I'm trying to initialize Direct3D11 in C++. On machines that have Visual Studio installed(all of those are running on Windows 10), it runs fine. On other computers (without Visual studio installed, Windows 10 and 7) it returns E_INVALIDARG.
The flag P_FeatureLevelsSupported says 0 on those computers. On mine it says D3D_FEATURE_LEVEL_11_1. So I guess it has something to do with the DirectX installation or maybe because the SDK is missing( but wouldn't that be strange? :D )
By running dxdiag, I know that those machines support DirectX11_0.
Is there something i need to install? The software has to run on the PCs of our clients.
The Code that causes the error:
const D3D_FEATURE_LEVEL lvl[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, D3D_FEATURE_LEVEL_9_1,
};
D3D_FEATURE_LEVEL P_FeatureLevelsSupported;
//see microsoft documentation, we use 11_1 or 11_0 if 11_1 is not supported by the client machine
//https://learn.microsoft.com/en-us/windows/desktop/direct3d11/overviews-direct3d-11-devices-initialize
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, lvl, _countof(lvl), D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, &P_FeatureLevelsSupported, &deviceContext);
if(result == E_INVALIDARG) //check with FEATURE_LEVEL_11_0
D3D11CreateDeviceAndSwapChain(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
D3D11_CREATE_DEVICE_DEBUG,
&lvl[1],
_countof(lvl) - 1,
D3D11_SDK_VERSION,
&swapChainDesc,
&swapChain,
&device,
&P_FeatureLevelsSupported,
&deviceContext);
Thanks in advance :)
You are asking to create the debug device by passing in
D3D11_CREATE_DEVICE_DEBUG
. For that to succeed you must have D3D11*SDKLayers.dll installed which you probably have on your dev machines. See here for details which includes:If you don't need a debug device when on a customer machine just remove that flag.