From 66cda8480b2ac9956e8a3f55bcdeb29438a11760 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 8 Jan 2019 20:19:13 -0800 Subject: Added option to not build glslang --- Graphics/GraphicsEngineVulkan/CMakeLists.txt | 11 +++++++---- Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp | 7 +++++++ .../src/VulkanUtilities/VulkanInstance.cpp | 9 ++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt index 8189865c..e4be34e3 100644 --- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt +++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt @@ -190,9 +190,7 @@ set(PUBLIC_DEPENDENCIES ) target_link_libraries(GraphicsEngineVk-static PRIVATE ${PRIVATE_DEPENDENCIES} PUBLIC ${PUBLIC_DEPENDENCIES}) - target_link_libraries(GraphicsEngineVk-shared PUBLIC GraphicsEngineVk-static) -target_compile_definitions(GraphicsEngineVk-shared PUBLIC ENGINE_DLL=1) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -218,8 +216,13 @@ elseif(PLATFORM_IOS) else() message(FATAL_ERROR "Unknown platform") endif() -target_compile_definitions(GraphicsEngineVk-shared PRIVATE ${PRIVATE_COMPILE_DEFINITIONS}) -target_compile_definitions(GraphicsEngineVk-static PRIVATE ${PRIVATE_COMPILE_DEFINITIONS}) + +if (${NO_GLSLANG}) + message("GLSLang is not being built. Vulkan backend will only be able to consume SPIRV byte code.") +endif() + +target_compile_definitions(GraphicsEngineVk-shared PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ENGINE_DLL=1) +target_compile_definitions(GraphicsEngineVk-static PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} NO_GLSLANG=$) if(PLATFORM_WIN32) diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp index 00629544..b0058a8f 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp @@ -29,7 +29,10 @@ #include "RenderDeviceVkImpl.h" #include "DataBlobImpl.h" #include "GLSLSourceBuilder.h" + +#if !NO_GLSLANG #include "SPIRVUtils.h" +#endif namespace Diligent { @@ -42,6 +45,9 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* { if (CreationAttribs.Source != nullptr || CreationAttribs.FilePath != nullptr) { +#if NO_GLSLANG + LOG_ERROR_AND_THROW("Diligent engine was not linked with glslang and can only consume compiled SPIRV bytecode."); +#else DEV_CHECK_ERR(CreationAttribs.ByteCode == nullptr, "'ByteCode' must be null when shader is created from source code or a file"); DEV_CHECK_ERR(CreationAttribs.ByteCodeSize == 0, "'ByteCodeSize' must be 0 when shader is created from source code or a file"); @@ -59,6 +65,7 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* { LOG_ERROR_AND_THROW("Failed to compile shader"); } +#endif } else if (CreationAttribs.ByteCode != nullptr) { diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp index 4aa776aa..9c884c17 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp @@ -26,7 +26,11 @@ #include "VulkanErrors.h" #include "VulkanUtilities/VulkanInstance.h" #include "VulkanUtilities/VulkanDebug.h" + +#if !NO_GLSLANG #include "SPIRVUtils.h" +#endif + #include "PlatformDefinitions.h" namespace VulkanUtilities @@ -193,8 +197,9 @@ namespace VulkanUtilities CHECK_VK_ERROR(err, "Failed to enumerate physical devices"); VERIFY_EXPR(m_PhysicalDevices.size() == PhysicalDeviceCount); } - +#if !NO_GLSLANG Diligent::InitializeGlslang(); +#endif } VulkanInstance::~VulkanInstance() @@ -205,7 +210,9 @@ namespace VulkanUtilities } vkDestroyInstance(m_VkInstance, m_pVkAllocator); +#if !NO_GLSLANG Diligent::FinalizeGlslang(); +#endif } VkPhysicalDevice VulkanInstance::SelectPhysicalDevice()const -- cgit v1.2.3