From d118aca0f6dce5a6fc9c704283373ea1decf42a6 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Fri, 10 Jan 2020 08:53:12 +0100 Subject: [PATCH] Add DX11 shader feature level --- ImGui/impls/windows/imgui_impl_dx11.cpp | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ImGui/impls/windows/imgui_impl_dx11.cpp b/ImGui/impls/windows/imgui_impl_dx11.cpp index 39bc88b..0f6d1b4 100644 --- a/ImGui/impls/windows/imgui_impl_dx11.cpp +++ b/ImGui/impls/windows/imgui_impl_dx11.cpp @@ -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)