diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-09-16 23:11:56 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-09-16 23:11:56 +0000 |
| commit | 0cc841bc76eda21793f2a158b0ededad5a5ae3bf (patch) | |
| tree | 39e1f2bee602263336754d990eaab557f16b98d6 /Graphics/ShaderTools | |
| parent | Another improvement to texture format tests in OpenGL (diff) | |
| download | DiligentCore-0cc841bc76eda21793f2a158b0ededad5a5ae3bf.tar.gz DiligentCore-0cc841bc76eda21793f2a158b0ededad5a5ae3bf.zip | |
Added GPU vendor and memory size detection (API 240071), closed https://github.com/DiligentGraphics/DiligentCore/issues/144.
Fixed shader model selection in D3D12 backend
Diffstat (limited to 'Graphics/ShaderTools')
| -rw-r--r-- | Graphics/ShaderTools/include/DXCompiler.hpp | 1 | ||||
| -rw-r--r-- | Graphics/ShaderTools/src/DXCompiler.cpp | 25 |
2 files changed, 20 insertions, 6 deletions
diff --git a/Graphics/ShaderTools/include/DXCompiler.hpp b/Graphics/ShaderTools/include/DXCompiler.hpp index 32655a78..6345ad7a 100644 --- a/Graphics/ShaderTools/include/DXCompiler.hpp +++ b/Graphics/ShaderTools/include/DXCompiler.hpp @@ -74,6 +74,7 @@ public: virtual bool Compile(const CompileAttribs& Attribs) = 0; virtual void Compile(const ShaderCreateInfo& ShaderCI, + ShaderVersion ShaderModel, const char* ExtraDefinitions, IDxcBlob** ppByteCodeBlob, std::vector<uint32_t>* pByteCode, diff --git a/Graphics/ShaderTools/src/DXCompiler.cpp b/Graphics/ShaderTools/src/DXCompiler.cpp index 50042df4..b35bfefa 100644 --- a/Graphics/ShaderTools/src/DXCompiler.cpp +++ b/Graphics/ShaderTools/src/DXCompiler.cpp @@ -83,6 +83,7 @@ public: bool Compile(const CompileAttribs& Attribs) override final; virtual void Compile(const ShaderCreateInfo& ShaderCI, + ShaderVersion ShaderModel, const char* ExtraDefinitions, IDxcBlob** ppByteCodeBlob, std::vector<uint32_t>* pByteCode, @@ -412,6 +413,7 @@ void DXCompilerImpl::GetD3D12ShaderReflection(IDxcBlob* pShaderBy void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI, + ShaderVersion ShaderModel, const char* ExtraDefinitions, IDxcBlob** ppByteCodeBlob, std::vector<uint32_t>* pByteCode, @@ -423,15 +425,26 @@ void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI, return; } - // validate shader version - ShaderVersion ShaderModel = ShaderCI.HLSLVersion; - ShaderVersion MaxSM = GetMaxShaderModel(); + ShaderVersion MaxSM = GetMaxShaderModel(); - if (ShaderModel.Major < 6 || ShaderModel.Major > MaxSM.Major) + // validate shader version + if (ShaderModel == ShaderVersion{}) + { ShaderModel = MaxSM; - - if (ShaderModel.Major == MaxSM.Major && ShaderModel.Minor > MaxSM.Minor) + } + else if (ShaderModel.Major < 6) + { + LOG_INFO_MESSAGE("DXC only supports shader model 6.0+. Upgrading the specified shader model ", + Uint32{ShaderModel.Major}, '_', Uint32{ShaderModel.Minor}, " to 6_0"); + ShaderModel = ShaderVersion{6, 0}; + } + else if ((ShaderModel.Major > MaxSM.Major) || + (ShaderModel.Major == MaxSM.Major && ShaderModel.Minor > MaxSM.Minor)) + { + LOG_WARNING_MESSAGE("The maximum supported shader model by DXC is ", Uint32{MaxSM.Major}, '_', Uint32{MaxSM.Minor}, + ". The specified shader model ", Uint32{ShaderModel.Major}, '_', Uint32{ShaderModel.Minor}, " will be downgraded."); ShaderModel = MaxSM; + } const auto Profile = GetHLSLProfileString(ShaderCI.Desc.ShaderType, ShaderModel); const std::wstring wstrProfile{Profile.begin(), Profile.end()}; |
