summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-20 01:54:45 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-20 01:54:45 +0000
commit7d27dcd7dc3d6a990a106e95e254009176e7ee53 (patch)
tree39e2df8b4f0a25a0c4b3238de6672cf769db2818 /Graphics/GraphicsEngineD3D11
parentD3D backends: properly handling the issue with static sampler arrays in shade... (diff)
downloadDiligentCore-7d27dcd7dc3d6a990a106e95e254009176e7ee53.tar.gz
DiligentCore-7d27dcd7dc3d6a990a106e95e254009176e7ee53.zip
Added HLSLVersion, GLSLVersion and GLESSLVersion to ShaderCreateInfo struct (API Version 240035)
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp
index 996b2af5..18d8b8bc 100644
--- a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp
@@ -30,7 +30,23 @@
namespace Diligent
{
-static const char* GetD3D11ShaderModel(ID3D11Device* pd3d11Device)
+static const std::string HLSLVersionToShaderModelString(const ShaderCreateInfo::ShaderVersion& Version, Uint8 MaxMajorRevision, Uint8 MaxMinorRevision)
+{
+ std::string ModelStr;
+ if (Version.Major > MaxMajorRevision || Version.Major == MaxMajorRevision && Version.Minor > MaxMinorRevision)
+ {
+ ModelStr = std::to_string(Uint32{MaxMajorRevision}) + '_' + std::to_string(Uint32{MaxMinorRevision});
+ LOG_ERROR_MESSAGE("Shader model ", Uint32{Version.Major}, "_", Uint32{Version.Minor}, " is not supported by this device. "
+ "Maximum supported model: ", ModelStr, ". Attempting to use ", ModelStr, '.');
+ }
+ else
+ {
+ ModelStr = std::to_string(Uint32{Version.Major}) + '_' + std::to_string(Uint32{Version.Minor});
+ }
+ return ModelStr;
+}
+
+static const std::string GetD3D11ShaderModel(ID3D11Device* pd3d11Device, const ShaderCreateInfo::ShaderVersion& HLSLVersion)
{
auto d3dDeviceFeatureLevel = pd3d11Device->GetFeatureLevel();
switch(d3dDeviceFeatureLevel)
@@ -44,13 +60,16 @@ static const char* GetD3D11ShaderModel(ID3D11Device* pd3d11Device)
#endif
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
- return "5_0";
+ return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ?
+ std::string{"5_0"} : HLSLVersionToShaderModelString(HLSLVersion, 5, 0);
case D3D_FEATURE_LEVEL_10_1:
- return "4_1";
+ return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ?
+ std::string{"4_1"} : HLSLVersionToShaderModelString(HLSLVersion, 4, 1);
case D3D_FEATURE_LEVEL_10_0:
- return "4_0";
+ return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ?
+ std::string{"4_0"} : HLSLVersionToShaderModelString(HLSLVersion, 4, 0);
default:
UNEXPECTED("Unexpected D3D feature level ", static_cast<Uint32>(d3dDeviceFeatureLevel));
@@ -67,7 +86,7 @@ ShaderD3D11Impl::ShaderD3D11Impl(IReferenceCounters* pRefCounters,
pRenderDeviceD3D11,
ShaderCI.Desc
},
- ShaderD3DBase{ShaderCI, GetD3D11ShaderModel(pRenderDeviceD3D11->GetD3D11Device())}
+ ShaderD3DBase{ShaderCI, GetD3D11ShaderModel(pRenderDeviceD3D11->GetD3D11Device(), ShaderCI.HLSLVersion).c_str()}
{
auto *pDeviceD3D11 = pRenderDeviceD3D11->GetD3D11Device();
switch (ShaderCI.Desc.ShaderType)