From 086febc448e083254eb34335fad5e029e7977af4 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Thu, 25 Oct 2018 12:43:02 -0600 Subject: [PATCH] PP: Fix #155: Don't give error on HLSL PP-only parsing. --- StandAlone/StandAlone.cpp | 10 ++++++---- Test/baseResults/hlsl.pp.expand.frag.err | 3 --- Test/runtests | 2 ++ hlsl/hlslParseHelper.cpp | 3 --- 4 files changed, 8 insertions(+), 10 deletions(-) mode change 100644 => 100755 StandAlone/StandAlone.cpp mode change 100644 => 100755 hlsl/hlslParseHelper.cpp diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp old mode 100644 new mode 100755 index f60ffaa7..cb5a8d27 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -961,8 +961,7 @@ void CompileAndLinkShaderUnits(std::vector compUnits) includer.pushExternalLocalDirectory(dir); }); if (Options & EOptionOutputPreprocessed) { std::string str; - if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, - messages, &str, includer)) { + if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, messages, &str, includer)) { PutsIfNonEmpty(str.c_str()); } else { CompileFailed = true; @@ -971,6 +970,7 @@ void CompileAndLinkShaderUnits(std::vector compUnits) StderrIfNonEmpty(shader->getInfoDebugLog()); continue; } + if (! shader->parse(&Resources, defaultVersion, false, messages, includer)) CompileFailed = true; @@ -1167,13 +1167,15 @@ int singleMain() ProcessConfigFile(); + if ((Options & EOptionReadHlsl) && !((Options & EOptionOutputPreprocessed) || (Options & EOptionSpv))) + Error("ERROR: HLSL requires SPIR-V code generation (or preprocessing only)"); + // // Two modes: // 1) linking all arguments together, single-threaded, new C++ interface // 2) independent arguments, can be tackled by multiple asynchronous threads, for testing thread safety, using the old handle interface // - if (Options & EOptionLinkProgram || - Options & EOptionOutputPreprocessed) { + if (Options & (EOptionLinkProgram | EOptionOutputPreprocessed)) { glslang::InitializeProcess(); glslang::InitializeProcess(); // also test reference counting of users glslang::InitializeProcess(); // also test reference counting of users diff --git a/Test/baseResults/hlsl.pp.expand.frag.err b/Test/baseResults/hlsl.pp.expand.frag.err index 1b5681fe..e69de29b 100644 --- a/Test/baseResults/hlsl.pp.expand.frag.err +++ b/Test/baseResults/hlsl.pp.expand.frag.err @@ -1,3 +0,0 @@ -ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan. -ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan. - diff --git a/Test/runtests b/Test/runtests index d36f3a8c..4a4a7614 100755 --- a/Test/runtests +++ b/Test/runtests @@ -208,6 +208,7 @@ diff -b $BASEDIR/hlsl.y-negate-3.vert.out $TARGETDIR/hlsl.y-negate-3.vert.out || # # Testing hlsl_functionality1 # +echo "Testing hlsl_functionality1" $EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.structbuffer.incdec.frag > \ $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out diff -b $BASEDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out || HASERROR=1 @@ -218,6 +219,7 @@ diff -b $BASEDIR/hlsl.noSemantic.functionality1.comp.out $TARGETDIR/hlsl.noSeman # # Testing HLSL-specific PP feature expansion # +echo "Testing HLSL-specific PP feature expansion" $EXE -D -E hlsl.pp.expand.frag > $TARGETDIR/hlsl.pp.expand.frag.out 2> $TARGETDIR/hlsl.pp.expand.frag.err diff -b $BASEDIR/hlsl.pp.expand.frag.out $TARGETDIR/hlsl.pp.expand.frag.out || HASERROR=1 diff -b $BASEDIR/hlsl.pp.expand.frag.err $TARGETDIR/hlsl.pp.expand.frag.err || HASERROR=1 diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp old mode 100644 new mode 100755 index 1672365c..135e1d28 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -97,9 +97,6 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int if (language == EShLangGeometry) globalOutputDefaults.layoutStream = 0; - - if (spvVersion.spv == 0 || spvVersion.vulkan == 0) - infoSink.info << "ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan.\n"; } HlslParseContext::~HlslParseContext()