Could Not initialize Direct3D
Make sure that you're definitely ending up picking the 10 feature level. You'll also need to change the shader profile argument for D3DX11CompileFromFile. It's probably "ps_5_0" / "vs_5_0" right now. Change it accordingly -- on your card you'd need to use 4 instead.
I think your problem is in the "1" in this line:
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1,
That parameter tells the function how many "features levels" are in "featureLevel", you are passing 1, so if your featureLevel array looks like this:
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
You are asking for feature level 11.
To fix, pass 3 instead of 1 and the other feature levels will also be considered by the function.
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1,
That parameter tells the function how many "features levels" are in "featureLevel", you are passing 1, so if your featureLevel array looks like this:
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
You are asking for feature level 11.
To fix, pass 3 instead of 1 and the other feature levels will also be considered by the function.
Make sure that you're definitely ending up picking the 10 feature level. You'll also need to change the shader profile argument for D3DX11CompileFromFile. It's probably "ps_5_0" / "vs_5_0" right now. Change it accordingly -- on your card you'd need to use 4 instead.
It wasn't doing this, MY GPU doesn't support Feature level11 so I needed 10/10.1:
// Set the feature level to DirectX 11.
featureLevel = D3D_FEATURE_LEVEL_10_0;
// Create the swap chain, Direct3D device, and Direct3D device context.
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1,
D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_device, NULL, &m_deviceContext); //Used for GPU
Then I needed to add a flag to my shader code 'D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY' and change it to use 'vs_4_0' :
// Compile the vertex shader code.
result = D3DX11CompileFromFile(vsFilename, NULL, NULL, "LightVertexShader", "vs_4_0", D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY, 0, NULL,
&vertexShaderBuffer, &errorMessage, NULL);
(Same for PS)
Sorted now, It all runs on GPU and not CPU emulation :3!
EDIT: Thanks for all your help guys!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement