Add DX11 shader feature level

This commit is contained in:
Nemirtingas 2020-01-10 08:53:12 +01:00
parent 118dee9278
commit d118aca0f6

View file

@ -379,7 +379,20 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
return output;\
}";
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
const char* target;
switch (g_pd3dDevice->GetFeatureLevel())
{
case D3D_FEATURE_LEVEL_9_1: target = "vs_4_0_level_9_1"; break;
case D3D_FEATURE_LEVEL_9_2: target = "vs_4_0_level_9_2"; break;
case D3D_FEATURE_LEVEL_9_3: target = "vs_4_0_level_9_3"; break;
case D3D_FEATURE_LEVEL_10_0: target = "vs_4_0_level_10_0"; break;
case D3D_FEATURE_LEVEL_10_1: target = "vs_4_0_level_10_1"; break;
case D3D_FEATURE_LEVEL_11_0: target = "vs_4_0_level_11_0"; break;
case D3D_FEATURE_LEVEL_11_1: target = "vs_4_0_level_11_1"; break;
default: target = "vs_4_0";
}
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", target, 0, 0, &g_pVertexShaderBlob, NULL);
if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
return false;
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
@ -435,7 +448,20 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
return out_col; \
}";
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
const char* target;
switch (g_pd3dDevice->GetFeatureLevel())
{
case D3D_FEATURE_LEVEL_9_1: target = "ps_4_0_level_9_1"; break;
case D3D_FEATURE_LEVEL_9_2: target = "ps_4_0_level_9_2"; break;
case D3D_FEATURE_LEVEL_9_3: target = "ps_4_0_level_9_3"; break;
case D3D_FEATURE_LEVEL_10_0: target = "ps_4_0_level_10_0"; break;
case D3D_FEATURE_LEVEL_10_1: target = "ps_4_0_level_10_1"; break;
case D3D_FEATURE_LEVEL_11_0: target = "ps_4_0_level_11_0"; break;
case D3D_FEATURE_LEVEL_11_1: target = "ps_4_0_level_11_1"; break;
default: target = "ps_4_0";
}
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", target, 0, 0, &g_pPixelShaderBlob, NULL);
if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
return false;
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)