From 562e84c20aaf8277c76042a40ce9837e86c78d60 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 20 Jul 2020 20:49:39 -0700 Subject: Added DILIGENT_NO_HLSL CMake option to disable HLSL support in Vulkan and OpenGL backends --- Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 11 ++++++++--- Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp | 10 +++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 2751bbd5..1072d067 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -154,19 +154,23 @@ endif() target_include_directories(Diligent-GraphicsEngineOpenGL-static PRIVATE include - ../HLSL2GLSLConverterLib/include ) - set(PRIVATE_DEPENDENCIES Diligent-BuildSettings Diligent-Common Diligent-TargetPlatform Diligent-GraphicsEngine Diligent-GLSLTools - Diligent-HLSL2GLSLConverterLib ) +if(${DILIGENT_NO_HLSL}) + message("HLSL support is disabled. OpenGL backend will not be able to consume HLSL source.") +else() + target_include_directories(Diligent-GraphicsEngineOpenGL-static PRIVATE ../HLSL2GLSLConverterLib/include) + set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} Diligent-HLSL2GLSLConverterLib) +endif() + set(PUBLIC_DEPENDENCIES Diligent-GraphicsEngineOpenGLInterface ) @@ -244,6 +248,7 @@ PUBLIC ${PUBLIC_DEPENDENCIES} ) +target_compile_definitions(Diligent-GraphicsEngineOpenGL-static PRIVATE DILIGENT_NO_HLSL=$) target_compile_definitions(Diligent-GraphicsEngineOpenGL-shared PUBLIC ENGINE_DLL=1) if(PLATFORM_MACOS) # Silence OpenGL deprecation warnings diff --git a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp index 88dde5f4..dacd1fe3 100644 --- a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp @@ -33,7 +33,11 @@ #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" #include "EngineMemory.h" -#include "HLSL2GLSLConverterObject.hpp" + +#if !DILIGENT_NO_HLSL +# include "HLSL2GLSLConverterObject.hpp" +#endif + #include "EngineFactoryBase.hpp" #if PLATFORM_IOS @@ -273,8 +277,12 @@ GetEngineFactoryOpenGLType LoadGraphicsEngineOpenGL() void EngineFactoryOpenGLImpl::CreateHLSL2GLSLConverter(IHLSL2GLSLConverter** ppConverter) { +#if DILIGENT_NO_HLSL + LOG_ERROR_MESSAGE("Unable to create HLSL2GLSL converter: HLSL support is disabled."); +#else HLSL2GLSLConverterObject* pConverter(NEW_RC_OBJ(GetRawAllocator(), "HLSL2GLSLConverterObject instance", HLSL2GLSLConverterObject)()); pConverter->QueryInterface(IID_HLSL2GLSLConverter, reinterpret_cast(ppConverter)); +#endif } #if PLATFORM_ANDROID -- cgit v1.2.3