-
Notifications
You must be signed in to change notification settings - Fork 434
Shader Model 6
Shader Model 6 is the latest HLSL compiler technology. It is required for DirectX Raytracing, DirectX Mesh Shaders, and a number of other DirectX 12 features. The DXIL compiler (DXC
) generates Shader Model 6 programs, and the compiler is based on LLVM and is hosted on GitHub. A prebuilt version of DXC.EXE
is provided in the Windows 10 SDK (17134 or later).
DirectX 11 does not support Shader Model 6 shaders.
While most modern DirectX 12 drivers support Shader Model 6, you need to verify the level of support required by your program.
D3D12_FEATURE_DATA_SHADER_MODEL shaderModel = { D3D_SHADER_MODEL_6_0 };
if (FAILED(device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel))))
{
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_5_1;
}
For higher shader models, you may be running on a system that doesn't recognize them, so the logic is slightly more complex in this case. This code finds the highest possible supported level, which is overkill in most cases, but is a useful reference:
D3D12_FEATURE_DATA_SHADER_MODEL shaderModel = {};
#if defined(NTDDI_WIN10_VB) && (NTDDI_VERSION >= NTDDI_WIN10_VB)
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_6;
#elif defined(NTDDI_WIN10_19H1) && (NTDDI_VERSION >= NTDDI_WIN10_19H1)
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_5;
#elif defined(NTDDI_WIN10_RS5) && (NTDDI_VERSION >= NTDDI_WIN10_RS5)
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_4;
#elif defined(NTDDI_WIN10_RS4) && (NTDDI_VERSION >= NTDDI_WIN10_RS4)
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_2;
#else
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_0;
#endif
HRESULT hr = device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel));
while (hr == E_INVALIDARG && shaderModel.HighestShaderModel > D3D_SHADER_MODEL_6_0)
{
shaderModel.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(static_cast<int>(shaderModel.HighestShaderModel) - 1);
hr = device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel));
}
if (FAILED(hr))
{
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_5_1;
}
Announcing Microsoft DirectX Raytracing! (requires Shader Model 6.3 or later)
Direct Machine Learning (DirectML) (requires Shader Model 6.4 or later)
Mesh Shaders and Amplification Shaders: Reinventing the Geometry Pipeline (requires Shader Model 6.5 or later)
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Xbox One
- Xbox Series X|S
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- MinGW 12.2, 13.2
- CMake 3.20