diff --git a/BIL/Bil.h b/BIL/Bil.h new file mode 100644 index 000000000..f9ab2c4a1 --- /dev/null +++ b/BIL/Bil.h @@ -0,0 +1,6 @@ + +#pragma once +#ifndef Bil_H +#define Bil_H + +#endif // Bil_H diff --git a/BIL/BilBuilder.cpp b/BIL/BilBuilder.cpp new file mode 100644 index 000000000..e39c9f15f --- /dev/null +++ b/BIL/BilBuilder.cpp @@ -0,0 +1,59 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#include + +#include "BilBuilder.h" + +#ifndef _WIN32 + #include +#endif + +namespace glbil { + +Builder::Builder() +{ +} + +Builder::~Builder() +{ +} + +void MissingFunctionality(const char* fun) +{ + printf("Missing functionality: %s\n", fun); + exit(1); +} + +}; // end glbil namespace diff --git a/BIL/BilBuilder.h b/BIL/BilBuilder.h new file mode 100644 index 000000000..ba993d4bb --- /dev/null +++ b/BIL/BilBuilder.h @@ -0,0 +1,56 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#pragma once +#ifndef BilBuilder_H +#define BilBuilder_H + +#include "Bil.h" +#include "Bir.h" + +#include + +namespace glbil { + +class Builder { +public: + Builder(); + virtual ~Builder(); +}; + +void MissingFunctionality(const char*); + +}; // end glbil namespace + +#endif // BilBuilder_H diff --git a/BIL/BilDisassemble.cpp b/BIL/BilDisassemble.cpp new file mode 100644 index 000000000..6425b8652 --- /dev/null +++ b/BIL/BilDisassemble.cpp @@ -0,0 +1,35 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#include "BilDisassemble.h" diff --git a/BIL/BilDisassemble.h b/BIL/BilDisassemble.h new file mode 100644 index 000000000..3400675e5 --- /dev/null +++ b/BIL/BilDisassemble.h @@ -0,0 +1,36 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#include "Bil.h" + diff --git a/BIL/Bir.h b/BIL/Bir.h new file mode 100644 index 000000000..eee9dece0 --- /dev/null +++ b/BIL/Bir.h @@ -0,0 +1,49 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#pragma once +#ifndef Bir_H +#define Bir_H + +#include "Bil.h" + +#include +#include + +namespace glbil { + + +}; // end glbil namespace + +#endif // Bir_H diff --git a/BIL/CMakeLists.txt b/BIL/CMakeLists.txt new file mode 100644 index 000000000..a6b4251c2 --- /dev/null +++ b/BIL/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8) + +include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}) + +set(SOURCES + GlslangToBil.cpp + BilBuilder.cpp + BilDisassemble.cpp) + +set(HEADERS + GlslangToBil.h + BilBuilder.h + Bir.h + BilDisassemble.h) + +add_library(BIL STATIC ${SOURCES} ${HEADERS}) + +if(WIN32) + source_group("Source" FILES ${SOURCES} ${HEADERS}) +endif(WIN32) + +install(TARGETS BIL + ARCHIVE DESTINATION lib) diff --git a/BIL/GlslangToBil.cpp b/BIL/GlslangToBil.cpp new file mode 100644 index 000000000..bb48a6efe --- /dev/null +++ b/BIL/GlslangToBil.cpp @@ -0,0 +1,50 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#include "Bil.h" +#include "GlslangToBil.h" +#include "BilBuilder.h" +#include "BilDisassemble.h" + +// Glslang includes +#include "glslang/MachineIndependent/localintermediate.h" +#include "glslang/MachineIndependent/SymbolTable.h" + +namespace glslang { + +void GlslangToBil(const glslang::TIntermediate& intermediate) +{ +} + +}; // end namespace glslang diff --git a/BIL/GlslangToBil.h b/BIL/GlslangToBil.h new file mode 100644 index 000000000..b030fe380 --- /dev/null +++ b/BIL/GlslangToBil.h @@ -0,0 +1,41 @@ +// +//Copyright (C) 2014 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. + +#include "../glslang/Include/intermediate.h" + +namespace glslang { + +void GlslangToBil(const glslang::TIntermediate& intermediate); + +}; diff --git a/CMakeLists.txt b/CMakeLists.txt index 2746f8b6d..d852c4801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,3 +16,4 @@ endif(WIN32) add_subdirectory(glslang) add_subdirectory(OGLCompilersDLL) add_subdirectory(StandAlone) +add_subdirectory(BIL) diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index 4c60c4a19..ec4ba6662 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -16,7 +16,8 @@ add_executable(glslangValidator ${SOURCES}) set(LIBRARIES glslang OGLCompiler - OSDependent) + OSDependent + BIL) if(WIN32) set(LIBRARIES ${LIBRARIES} psapi) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 10da8e16d..8d3f5cac8 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -40,6 +40,7 @@ #include "Worklist.h" #include "./../glslang/Include/ShHandle.h" #include "./../glslang/Public/ShaderLang.h" +#include "../BIL/GlslangToBil.h" #include #include #include @@ -64,6 +65,7 @@ enum TOptions { EOptionDumpReflection = 0x100, EOptionSuppressWarnings = 0x200, EOptionDumpVersions = 0x400, + EOptionBil = 0x800, }; // @@ -464,6 +466,9 @@ bool ProcessArguments(int argc, char* argv[]) Work[argc] = 0; if (argv[0][0] == '-') { switch (argv[0][1]) { + case 'b': + Options |= EOptionBil; + break; case 'c': Options |= EOptionDumpConfig; break; @@ -615,6 +620,17 @@ void CompileAndLinkShaders() program.dumpReflection(); } + if (Options & EOptionBil) { + if (CompileFailed || LinkFailed) + printf("Bil is not generated for failed compile or link\n"); + else { + for (int stage = 0; stage < EShLangCount; ++stage) { + if (program.getIntermediate((EShLanguage)stage)) + glslang::GlslangToBil(*program.getIntermediate((EShLanguage)stage)); + } + } + } + // Free everything up, program has to go before the shaders // because it might have merged stuff from the shaders, and // the stuff from the shaders has to have its destructors called @@ -813,6 +829,7 @@ void usage() "\n" "To get other information, use one of the following options:\n" "(Each option must be specified separately, but can go anywhere in the command line.)\n" + " -b create BIL\n" " -c configuration dump; use to create default configuration file (redirect to a .conf file)\n" " -i intermediate tree (glslang AST) is printed out\n" " -l link validation of all input files\n" diff --git a/StandAlone/Worklist.h b/StandAlone/Worklist.h index 1dabec99f..c3040076a 100644 --- a/StandAlone/Worklist.h +++ b/StandAlone/Worklist.h @@ -48,6 +48,7 @@ namespace glslang { name(s) { } std::string name; std::string results; + std::string resultsIndex; }; class TWorklist { diff --git a/Todo.txt b/Todo.txt index 6549c9725..afd370a6f 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,5 +1,8 @@ Current functionality level: ESSL 3.0, GLSL 1.5 +Bugs + - implicitly-sized gl_ClipDistance[] (at least in tessellation shaders) with sizes greater than one are not getting sizes greater than one + + create version system Link Validation diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 42ce63bdf..9ab22ebba 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -479,6 +479,10 @@ public: return layoutLocation != layoutLocationEnd || layoutComponent != layoutComponentEnd; } + bool hasComponent() const + { + return layoutComponent != layoutComponentEnd; + } bool hasBinding() const { return layoutBinding != layoutBindingEnd;