From 84eabf7ea7e932fb3b9715a8aed64b1c14f8a96e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 8 Jan 2017 21:20:25 -0400 Subject: [PATCH 1/2] Add a CMake option to disable compilation of HLSL input support. --- CMakeLists.txt | 10 +++++++++- StandAlone/CMakeLists.txt | 5 ++++- glslang/MachineIndependent/ShaderLang.cpp | 19 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b22e5e..600130de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON) option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON) +option(DISABLE_HLSL "Disables HLSL input support" OFF) + enable_testing() set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix") @@ -20,6 +22,10 @@ if(ENABLE_NV_EXTENSIONS) add_definitions(-DNV_EXTENSIONS) endif(ENABLE_NV_EXTENSIONS) +if(DISABLE_HLSL) + add_definitions(-DDISABLE_HLSL) +endif(DISABLE_HLSL) + if(WIN32) set(CMAKE_DEBUG_POSTFIX "d") include(ChooseMSVCCRT.cmake) @@ -63,5 +69,7 @@ if(ENABLE_GLSLANG_BINARIES) add_subdirectory(StandAlone) endif() add_subdirectory(SPIRV) -add_subdirectory(hlsl) +if(NOT DISABLE_HLSL) + add_subdirectory(hlsl) +endif() add_subdirectory(gtests) diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index 231ba277..3a09799c 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -22,11 +22,14 @@ set(LIBRARIES glslang OGLCompiler OSDependent - HLSL SPIRV SPVRemapper glslang-default-resource-limits) +if(NOT DISABLE_HLSL) + set(LIBRARIES ${LIBRARIES} HLSL) +endif() + if(WIN32) set(LIBRARIES ${LIBRARIES} psapi) elseif(UNIX) diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index b5e08a7e..b6f504c2 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -47,11 +47,14 @@ #include #include "SymbolTable.h" #include "ParseHelper.h" -#include "../../hlsl/hlslParseHelper.h" -#include "../../hlsl/hlslParseables.h" #include "Scan.h" #include "ScanContext.h" + +#ifndef DISABLE_HLSL +#include "../../hlsl/hlslParseHelper.h" +#include "../../hlsl/hlslParseables.h" #include "../../hlsl/hlslScanContext.h" +#endif #include "../Include/ShHandle.h" #include "../../OGLCompilersDLL/InitializeDll.h" @@ -73,7 +76,9 @@ TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource sourc { switch (source) { case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns +#ifndef DISABLE_HLSL case EShSourceHlsl: return new TBuiltInParseablesHlsl(); // HLSL intrinsics +#endif default: infoSink.info.message(EPrefixInternalError, "Unable to determine source language"); @@ -88,15 +93,21 @@ TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& SpvVersion spvVersion, bool forwardCompatible, EShMessages messages, bool parsingBuiltIns, const std::string sourceEntryPointName = "") { +#ifdef DISABLE_HLSL + (void)sourceEntryPointName; // Unused argument. +#endif + switch (source) { case EShSourceGlsl: intermediate.setEntryPointName("main"); return new TParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion, language, infoSink, forwardCompatible, messages); +#ifndef DISABLE_HLSL case EShSourceHlsl: return new HlslParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion, language, infoSink, sourceEntryPointName.c_str(), forwardCompatible, messages); +#endif default: infoSink.info.message(EPrefixInternalError, "Unable to determine source language"); return nullptr; @@ -1085,7 +1096,9 @@ int ShInitialize() PerProcessGPA = new TPoolAllocator(); glslang::TScanContext::fillInKeywordMap(); +#ifndef DISABLE_HLSL glslang::HlslScanContext::fillInKeywordMap(); +#endif return 1; } @@ -1178,7 +1191,9 @@ int __fastcall ShFinalize() } glslang::TScanContext::deleteKeywordMap(); +#ifndef DISABLE_HLSL glslang::HlslScanContext::deleteKeywordMap(); +#endif return 1; } From ff21a25bc8eedc305b6392e87006c8c50f98146e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 9 Jan 2017 18:10:14 -0400 Subject: [PATCH 2/2] Change disabled-by-default DISABLE_HLSL option to enabled-by-default ENABLE_HLSL. Matches existing options. --- CMakeLists.txt | 10 +++++----- StandAlone/CMakeLists.txt | 2 +- glslang/MachineIndependent/ShaderLang.cpp | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 600130de..2ddc1835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON) option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON) -option(DISABLE_HLSL "Disables HLSL input support" OFF) +option(ENABLE_HLSL "Enables HLSL input support" ON) enable_testing() @@ -22,9 +22,9 @@ if(ENABLE_NV_EXTENSIONS) add_definitions(-DNV_EXTENSIONS) endif(ENABLE_NV_EXTENSIONS) -if(DISABLE_HLSL) - add_definitions(-DDISABLE_HLSL) -endif(DISABLE_HLSL) +if(ENABLE_HLSL) + add_definitions(-DENABLE_HLSL) +endif(ENABLE_HLSL) if(WIN32) set(CMAKE_DEBUG_POSTFIX "d") @@ -69,7 +69,7 @@ if(ENABLE_GLSLANG_BINARIES) add_subdirectory(StandAlone) endif() add_subdirectory(SPIRV) -if(NOT DISABLE_HLSL) +if(ENABLE_HLSL) add_subdirectory(hlsl) endif() add_subdirectory(gtests) diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index 3a09799c..e7e9a2af 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -26,7 +26,7 @@ set(LIBRARIES SPVRemapper glslang-default-resource-limits) -if(NOT DISABLE_HLSL) +if(ENABLE_HLSL) set(LIBRARIES ${LIBRARIES} HLSL) endif() diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index b6f504c2..e552d1a4 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -50,7 +50,7 @@ #include "Scan.h" #include "ScanContext.h" -#ifndef DISABLE_HLSL +#ifdef ENABLE_HLSL #include "../../hlsl/hlslParseHelper.h" #include "../../hlsl/hlslParseables.h" #include "../../hlsl/hlslScanContext.h" @@ -76,7 +76,7 @@ TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource sourc { switch (source) { case EShSourceGlsl: return new TBuiltIns(); // GLSL builtIns -#ifndef DISABLE_HLSL +#ifdef ENABLE_HLSL case EShSourceHlsl: return new TBuiltInParseablesHlsl(); // HLSL intrinsics #endif @@ -93,7 +93,7 @@ TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& SpvVersion spvVersion, bool forwardCompatible, EShMessages messages, bool parsingBuiltIns, const std::string sourceEntryPointName = "") { -#ifdef DISABLE_HLSL +#ifndef ENABLE_HLSL (void)sourceEntryPointName; // Unused argument. #endif @@ -103,7 +103,7 @@ TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& return new TParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion, language, infoSink, forwardCompatible, messages); -#ifndef DISABLE_HLSL +#ifdef ENABLE_HLSL case EShSourceHlsl: return new HlslParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion, language, infoSink, sourceEntryPointName.c_str(), forwardCompatible, messages); @@ -1096,7 +1096,7 @@ int ShInitialize() PerProcessGPA = new TPoolAllocator(); glslang::TScanContext::fillInKeywordMap(); -#ifndef DISABLE_HLSL +#ifdef ENABLE_HLSL glslang::HlslScanContext::fillInKeywordMap(); #endif @@ -1191,7 +1191,7 @@ int __fastcall ShFinalize() } glslang::TScanContext::deleteKeywordMap(); -#ifndef DISABLE_HLSL +#ifdef ENABLE_HLSL glslang::HlslScanContext::deleteKeywordMap(); #endif