summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-08-25 01:56:42 +0000
committerazhirnov <zh1dron@gmail.com>2020-08-25 01:56:42 +0000
commit1313de1ab167fe67d14fa2a848946f442491ca11 (patch)
treea87dad429e9a639b5403d0c923ca2d35b610479c /Graphics/GraphicsEngineVulkan
parentadded AdapterId to Vulkan backend (diff)
downloadDiligentCore-1313de1ab167fe67d14fa2a848946f442491ca11.tar.gz
DiligentCore-1313de1ab167fe67d14fa2a848946f442491ca11.zip
added HLSLTools, HLSL shader compiler refactoring
added ShaderCompiler field to ShaderCreateInfo, fixed tests that doesn't compile on DXC, added dxc/WinAdapter.h to fix compilation on linux
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/CMakeLists.txt1
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp48
2 files changed, 28 insertions, 21 deletions
diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
index 647cf48f..4d4e495b 100644
--- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt
+++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt
@@ -179,6 +179,7 @@ set(PRIVATE_DEPENDENCIES
Diligent-TargetPlatform
Diligent-GraphicsEngineNextGenBase
Diligent-GLSLTools
+ Diligent-HLSLTools
)
if (${DILIGENT_NO_HLSL})
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 65e9f274..554d9b73 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -64,32 +64,38 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters,
"# define VULKAN 1\n"
"#endif\n";
- if (CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL &&
- (CreationAttribs.HLSLVersion.Major == 0 || CreationAttribs.HLSLVersion.Major > 5) &&
- HasDXILCompilerForVulkan())
- {
- m_SPIRV = HLSLtoSPIRVusingDXIL(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput);
- }
- else
+ switch (CreationAttribs.ShaderCompiler)
{
+ case SHADER_COMPILER_DXC:
+ m_SPIRV = DXILtoSPIRV(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput);
+ break;
+
+ case SHADER_COMPILER_DEFAULT:
+ case SHADER_COMPILER_GLSLANG:
+ {
#if DILIGENT_NO_GLSLANG
- LOG_ERROR_AND_THROW("Diligent engine was not linked with glslang and can only consume compiled SPIRV bytecode.");
+ LOG_ERROR_AND_THROW("Diligent engine was not linked with glslang, use DXIL compiler or precompiled SPIRV bytecode.");
#else
- if (CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL)
- {
- m_SPIRV = HLSLtoSPIRV(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput);
+ if (CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL)
+ {
+ m_SPIRV = HLSLtoSPIRV(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput);
+ }
+ else
+ {
+ auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pRenderDeviceVk->GetDeviceCaps(),
+ TargetGLSLCompiler::glslang,
+ VulkanDefine);
+
+ m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(),
+ static_cast<int>(GLSLSource.length()),
+ CreationAttribs.ppCompilerOutput);
+ }
+#endif
+ break;
}
- else
- {
- auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pRenderDeviceVk->GetDeviceCaps(),
- TargetGLSLCompiler::glslang,
- VulkanDefine);
- m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(),
- static_cast<int>(GLSLSource.length()),
- CreationAttribs.ppCompilerOutput);
- }
-#endif
+ default:
+ LOG_ERROR_AND_THROW("Unsupported shader compiler");
}
if (m_SPIRV.empty())