If your card didn't support Direct3D 11 features the program would fail at device initialisation and not shader creation, so if you are initialising your device with D3D_FEATURE_LEVEL_11_0
and it succeeds, that means that your problem lies somewhere in the shader code. This is quite likely given that IntelliSense doesn't work with HLSL.
Luckily your framework comes with some error reporting facilities, so you can simply look at shader_errors.txt file to see where your problem lies.
If the above is not the case (i.e. you've already changed your Direct3D feature level) then you have several options:
Change your shader model to match Direct3D feature level in
D3DX11CompileFromFile()
method, e.g. if you are usingD3D_FEATURE_LEVEL_10_0
set your shader models tovs_4_0
andps_4_0
.If you're using Windows 8 (somewhat unlikely on a machine with no DX11 support) then you can use
D3D_DRIVER_TYPE_WARP
in your device initialisation, which is a fast software rasterizer, but on older versions of Windows it doesn't support 11_0 feature level.As a last resort you can use
D3D_DRIVER_TYPE_REFERENCE
which supports all Direct3D features, but is extremely slow, to a point of being unusable.
Ultimately it is always a good idea to have some form of a fallback option in case the hardware you're running on doesn't support your desired feature level. For example:
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
HRESULT result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, &featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_device, NULL, &m_deviceContext);
if (FAILED(result))
{
featureLevel = D3D_FEATURE_LEVEL_10_0;
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_DEBUG, &featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_device, NULL, &m_deviceContext);
if (FAILED(result))
{
// OK, now quit, we need at least DirectX 10 compatible hardware
return false;
}
}
// In shader class
if (m_device->GetFeatureLevel() == D3D_FEATURE_LEVEL_11_0)
{
// use 5.0 shader model
}
else
{
// use 4.0 shader model
}