Compile shaders with the best profile available.
Instead of always compiling D3D11 shaders with shader model 4, compile
with the latest profile that the current feature level allows.
BUG=angle:495
Change-Id: I478d3d4a1aadf24d893508eee1a8c11e501bc084
Reviewed-on: https://chromium-review.googlesource.com/190340
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
index 5b5a4de..2de24db 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
@@ -3023,24 +3023,43 @@
const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
bool separatedOutputBuffers, D3DWorkaroundType workaround)
{
- const char *profile = NULL;
-
+ const char *profileType = NULL;
switch (type)
{
case rx::SHADER_VERTEX:
- profile = "vs_4_0";
+ profileType = "vs";
break;
case rx::SHADER_PIXEL:
- profile = "ps_4_0";
+ profileType = "ps";
break;
case rx::SHADER_GEOMETRY:
- profile = "gs_4_0";
+ profileType = "gs";
break;
default:
UNREACHABLE();
return NULL;
}
+ const char *profileVersion = NULL;
+ switch (mFeatureLevel)
+ {
+ case D3D_FEATURE_LEVEL_11_0:
+ profileVersion = "5_0";
+ break;
+ case D3D_FEATURE_LEVEL_10_1:
+ profileVersion = "4_1";
+ break;
+ case D3D_FEATURE_LEVEL_10_0:
+ profileVersion = "4_0";
+ break;
+ default:
+ UNREACHABLE();
+ return NULL;
+ }
+
+ char profile[32];
+ snprintf(profile, ArraySize(profile), "%s_%s", profileType, profileVersion);
+
ID3DBlob *binary = (ID3DBlob*)mCompiler.compileToBinary(infoLog, shaderHLSL, profile, D3DCOMPILE_OPTIMIZATION_LEVEL0, false);
if (!binary)
{