From a97eac202cec673a0f2e27e808cfdcdd29289c4e Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 19 Jul 2017 11:27:23 -0700 Subject: Build a dynamic library for Slang - Change the `slang` project from a static library to a dynamic one - Add some details around `slang.h` to make sure DLL export stuff is working - Make the `slangc` executable use the dynamic library - Rename the `glslang` sub-project to `slang-glslang` and move it into the main source hierarchy - This reflects the fact that it isn't a stand-alone tool, and isn't in any way a standard binary of glslang, but rather just an artifact of how Slang uses glslang --- slang.h | 2 +- slang.sln | 6 +- source/slang-glslang/slang-glslang.cpp | 204 +++++++++++++++++ source/slang-glslang/slang-glslang.h | 33 +++ source/slang-glslang/slang-glslang.vcxproj | 236 ++++++++++++++++++++ source/slang-glslang/slang-glslang.vcxproj.filters | 247 +++++++++++++++++++++ source/slang/compiler.cpp | 4 +- source/slang/slang.vcxproj | 21 +- source/slangc/main.cpp | 1 + tools/glslang/glslang.cpp | 204 ----------------- tools/glslang/glslang.h | 33 --- tools/glslang/glslang.vcxproj | 235 -------------------- tools/glslang/glslang.vcxproj.filters | 247 --------------------- 13 files changed, 741 insertions(+), 732 deletions(-) create mode 100644 source/slang-glslang/slang-glslang.cpp create mode 100644 source/slang-glslang/slang-glslang.h create mode 100644 source/slang-glslang/slang-glslang.vcxproj create mode 100644 source/slang-glslang/slang-glslang.vcxproj.filters delete mode 100644 tools/glslang/glslang.cpp delete mode 100644 tools/glslang/glslang.h delete mode 100644 tools/glslang/glslang.vcxproj delete mode 100644 tools/glslang/glslang.vcxproj.filters diff --git a/slang.h b/slang.h index 70f070816..a9b69d705 100644 --- a/slang.h +++ b/slang.h @@ -2,7 +2,7 @@ #define SLANG_H #ifdef _MSC_VER -#ifdef SLANG_COMPILING_DLL +#ifdef SLANG_DYNAMIC_EXPORT #define SLANG_API __declspec(dllexport) #else #ifdef SLANG_DYNAMIC diff --git a/slang.sln b/slang.sln index 502bd60a1..c9896ea41 100644 --- a/slang.sln +++ b/slang.sln @@ -13,12 +13,15 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "source\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slangc", "source\slangc\slangc.vcxproj", "{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}" + ProjectSection(ProjectDependencies) = postProject + {C495878A-832C-485B-B347-0998A90CC936} = {C495878A-832C-485B-B347-0998A90CC936} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-test", "tools\slang-test\slang-test.vcxproj", "{0C768A18-1D25-4000-9F37-DA5FE99E3B64}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "render-test", "tools\render-test\render-test.vcxproj", "{96610759-07B9-4EEB-A974-5C634A2E742B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glslang", "tools\glslang\glslang.vcxproj", "{C495878A-832C-485B-B347-0998A90CC936}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-glslang", "source\slang-glslang\slang-glslang.vcxproj", "{C495878A-832C-485B-B347-0998A90CC936}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -92,6 +95,5 @@ Global {E6385042-1649-4803-9EBD-168F8B7EF131} = {B625E3E2-3B0B-4A01-9D10-957F84092E10} {0C768A18-1D25-4000-9F37-DA5FE99E3B64} = {74C5F0DC-93BB-4BF3-AC65-8C65491570F7} {96610759-07B9-4EEB-A974-5C634A2E742B} = {74C5F0DC-93BB-4BF3-AC65-8C65491570F7} - {C495878A-832C-485B-B347-0998A90CC936} = {74C5F0DC-93BB-4BF3-AC65-8C65491570F7} EndGlobalSection EndGlobal diff --git a/source/slang-glslang/slang-glslang.cpp b/source/slang-glslang/slang-glslang.cpp new file mode 100644 index 000000000..650e58ef6 --- /dev/null +++ b/source/slang-glslang/slang-glslang.cpp @@ -0,0 +1,204 @@ +// slang-glslang.cpp +#include "slang-glslang.h" + + +#include "StandAlone/ResourceLimits.h" +#include "StandAlone/Worklist.h" +#include "glslang/Include/ShHandle.h" +#include "glslang/Include/revision.h" +#include "glslang/Public/ShaderLang.h" +#include "SPIRV/GlslangToSpv.h" +#include "SPIRV/GLSL.std.450.h" +#include "SPIRV/doc.h" +#include "SPIRV/disassemble.h" + +#include "../../Slang.h" + +#if 0 +#include +#include +#include +#include +#include +#include +#include +#endif + +#ifdef _WIN32 +#include +#endif + +#include + +// This is a wrapper to allow us to run the `glslang` compiler +// in a controlled fashion. + +#define UNLIMITED 9999 + +static TBuiltInResource gResources = +{ + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED,-UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, + UNLIMITED, UNLIMITED, UNLIMITED, + + { true, true, true, true, true, true, true, true, true, } +}; + +static void dump( + void const* data, + size_t size, + glslang_OutputFunc outputFunc, + void* outputUserData, + FILE* fallbackStream) +{ + if( outputFunc ) + { + outputFunc(data, size, outputUserData); + } + else + { + fwrite(data, 1, size, fallbackStream); + + // also output it for debug purposes + std::string str((char const*)data, size); + OutputDebugStringA(str.c_str()); + } +} + +static void dumpDiagnostics( + glslang_CompileRequest* request, + std::string const& log) +{ + dump(log.c_str(), log.length(), request->diagnosticFunc, request->diagnosticUserData, stderr); +} + +static int glslang_compileGLSLToSPIRV(glslang_CompileRequest* request) +{ + EShLanguage glslangStage; + switch( request->slangStage ) + { +#define CASE(SP, GL) case SLANG_STAGE_##SP: glslangStage = EShLang##GL; break + CASE(VERTEX, Vertex); + CASE(FRAGMENT, Fragment); + CASE(GEOMETRY, Geometry); + CASE(HULL, TessControl); + CASE(DOMAIN, TessEvaluation); + CASE(COMPUTE, Compute); + +#undef CASE + + default: + return 1; + } + + // TODO: compute glslang stage to use + + glslang::TShader* shader = new glslang::TShader(glslangStage); + auto shaderPtr = std::unique_ptr(shader); + + glslang::TProgram* program = new glslang::TProgram(); + auto programPtr = std::unique_ptr(program); + + char const* sourceText = (char const*)request->inputBegin; + char const* sourceTextEnd = (char const*)request->inputEnd; + + int sourceTextLength = (int)(sourceTextEnd - sourceText); + + shader->setPreamble("#extension GL_GOOGLE_cpp_style_line_directive : require\n"); + + shader->setStringsWithLengthsAndNames( + &sourceText, + &sourceTextLength, + &request->sourcePath, + 1); + + EShMessages messages = EShMessages(EShMsgSpvRules | EShMsgVulkanRules); + + if( !shader->parse(&gResources, 110, false, messages) ) + { + dumpDiagnostics(request, shader->getInfoLog()); + return 1; + } + + program->addShader(shader); + + if( !program->link(messages) ) + { + dumpDiagnostics(request, program->getInfoLog()); + return 1; + } + + if( !program->mapIO() ) + { + dumpDiagnostics(request, program->getInfoLog()); + return 1; + } + + for(int stage = 0; stage < EShLangCount; ++stage) + { + auto stageIntermediate = program->getIntermediate((EShLanguage)stage); + if(!stageIntermediate) + continue; + + std::vector spirv; + std::string warningsErrors; + spv::SpvBuildLogger logger; + glslang::GlslangToSpv(*stageIntermediate, spirv, &logger); + + dumpDiagnostics(request, logger.getAllMessages()); + + dump(spirv.data(), spirv.size() * sizeof(unsigned int), request->outputFunc, request->outputUserData, stdout); + } + + return 0; +} + +static int glslang_dissassembleSPIRV(glslang_CompileRequest* request) +{ + typedef unsigned int SPIRVWord; + + SPIRVWord const* spirvBegin = (SPIRVWord const*)request->inputBegin; + SPIRVWord const* spirvEnd = (SPIRVWord const*)request->inputEnd; + + std::vector spirv(spirvBegin, spirvEnd); + + std::stringstream spirvAsmStream; + spv::Disassemble(spirvAsmStream, spirv); + std::string result = spirvAsmStream.str(); + dump(result.c_str(), result.length(), request->outputFunc, request->outputUserData, stdout); + + return 0; +} + +extern "C" +_declspec(dllexport) +int glslang_compile(glslang_CompileRequest* request) +{ + glslang::InitializeProcess(); + + int result = 0; + switch(request->action) + { + default: + result = 1; + break; + + case GLSLANG_ACTION_COMPILE_GLSL_TO_SPIRV: + result = glslang_compileGLSLToSPIRV(request); + break; + + case GLSLANG_ACTION_DISSASSEMBLE_SPIRV: + result = glslang_dissassembleSPIRV(request); + break; + } + + glslang::FinalizeProcess(); + + return result; +} diff --git a/source/slang-glslang/slang-glslang.h b/source/slang-glslang/slang-glslang.h new file mode 100644 index 000000000..748ad3dd1 --- /dev/null +++ b/source/slang-glslang/slang-glslang.h @@ -0,0 +1,33 @@ +// slang-glslang.h +#ifndef SLANG_GLSLANG_H_INCLUDED +#define SLANG_GLSLANG_H_INCLUDED + +typedef void (*glslang_OutputFunc)(void const* data, size_t size, void* userData); + +enum +{ + GLSLANG_ACTION_COMPILE_GLSL_TO_SPIRV, + GLSLANG_ACTION_DISSASSEMBLE_SPIRV, +}; + +struct glslang_CompileRequest +{ + char const* sourcePath; + + void const* inputBegin; + void const* inputEnd; + + glslang_OutputFunc diagnosticFunc; + void* diagnosticUserData; + + glslang_OutputFunc outputFunc; + void* outputUserData; + + int slangStage; + + unsigned action; +}; + +typedef int (*glslang_CompileFunc)(glslang_CompileRequest* request); + +#endif diff --git a/source/slang-glslang/slang-glslang.vcxproj b/source/slang-glslang/slang-glslang.vcxproj new file mode 100644 index 000000000..7f6761c4a --- /dev/null +++ b/source/slang-glslang/slang-glslang.vcxproj @@ -0,0 +1,236 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {C495878A-832C-485B-B347-0998A90CC936} + Win32Proj + slang_glslang + 8.1 + slang-glslang + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)external\glslang\;$(IncludePath) + + + true + $(SolutionDir)external\glslang\;$(IncludePath) + + + false + $(SolutionDir)external\glslang\;$(IncludePath) + + + false + $(SolutionDir)external\glslang\;$(IncludePath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/slang-glslang/slang-glslang.vcxproj.filters b/source/slang-glslang/slang-glslang.vcxproj.filters new file mode 100644 index 000000000..f6975bc2c --- /dev/null +++ b/source/slang-glslang/slang-glslang.vcxproj.filters @@ -0,0 +1,247 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp index 96fccced1..85e78e85b 100644 --- a/source/slang/compiler.cpp +++ b/source/slang/compiler.cpp @@ -14,7 +14,7 @@ #include "emit.h" // Utilities for pass-through modes -#include "../../tools/glslang/glslang.h" +#include "../slang-glslang/slang-glslang.h" #ifdef _WIN32 @@ -354,7 +354,7 @@ namespace Slang HMODULE getGLSLCompilerDLL() { // TODO(tfoley): let user specify version of glslang DLL to use. - static HMODULE glslCompiler = LoadLibraryA("glslang"); + static HMODULE glslCompiler = LoadLibraryA("slang-glslang"); // TODO(tfoley): handle case where we can't find it gracefully assert(glslCompiler); return glslCompiler; diff --git a/source/slang/slang.vcxproj b/source/slang/slang.vcxproj index 17fdea627..f67e7f5bb 100644 --- a/source/slang/slang.vcxproj +++ b/source/slang/slang.vcxproj @@ -27,26 +27,26 @@ - StaticLibrary + DynamicLibrary true v140 Unicode - StaticLibrary + DynamicLibrary true v140 Unicode - StaticLibrary + DynamicLibrary false v140 true Unicode - StaticLibrary + DynamicLibrary false v140 true @@ -90,7 +90,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) ../ MultiThreadedDebug false @@ -106,7 +106,7 @@ Level4 Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) ../ MultiThreadedDebug true @@ -128,7 +128,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) ../ MultiThreaded false @@ -148,7 +148,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) ../ MultiThreaded false @@ -218,6 +218,11 @@ + + + {f9be7957-8399-899e-0c49-e714fddd4b65} + + diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp index a643e26eb..a97c38685 100644 --- a/source/slangc/main.cpp +++ b/source/slangc/main.cpp @@ -1,5 +1,6 @@ // main.cpp +#define SLANG_DYNAMIC #include "../slang.h" #include "core/slang-io.h" diff --git a/tools/glslang/glslang.cpp b/tools/glslang/glslang.cpp deleted file mode 100644 index 19c130329..000000000 --- a/tools/glslang/glslang.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// glslang.cpp -#include "glslang.h" - - -#include "StandAlone/ResourceLimits.h" -#include "StandAlone/Worklist.h" -#include "glslang/Include/ShHandle.h" -#include "glslang/Include/revision.h" -#include "glslang/Public/ShaderLang.h" -#include "SPIRV/GlslangToSpv.h" -#include "SPIRV/GLSL.std.450.h" -#include "SPIRV/doc.h" -#include "SPIRV/disassemble.h" - -#include "../../Slang.h" - -#if 0 -#include -#include -#include -#include -#include -#include -#include -#endif - -#ifdef _WIN32 -#include -#endif - -#include - -// This is a wrapper to allow us to run the `glslang` compiler -// in a controlled fashion. - -#define UNLIMITED 9999 - -static TBuiltInResource gResources = -{ - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED,-UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, UNLIMITED, - UNLIMITED, UNLIMITED, UNLIMITED, - - { true, true, true, true, true, true, true, true, true, } -}; - -static void dump( - void const* data, - size_t size, - glslang_OutputFunc outputFunc, - void* outputUserData, - FILE* fallbackStream) -{ - if( outputFunc ) - { - outputFunc(data, size, outputUserData); - } - else - { - fwrite(data, 1, size, fallbackStream); - - // also output it for debug purposes - std::string str((char const*)data, size); - OutputDebugStringA(str.c_str()); - } -} - -static void dumpDiagnostics( - glslang_CompileRequest* request, - std::string const& log) -{ - dump(log.c_str(), log.length(), request->diagnosticFunc, request->diagnosticUserData, stderr); -} - -static int glslang_compileGLSLToSPIRV(glslang_CompileRequest* request) -{ - EShLanguage glslangStage; - switch( request->slangStage ) - { -#define CASE(SP, GL) case SLANG_STAGE_##SP: glslangStage = EShLang##GL; break - CASE(VERTEX, Vertex); - CASE(FRAGMENT, Fragment); - CASE(GEOMETRY, Geometry); - CASE(HULL, TessControl); - CASE(DOMAIN, TessEvaluation); - CASE(COMPUTE, Compute); - -#undef CASE - - default: - return 1; - } - - // TODO: compute glslang stage to use - - glslang::TShader* shader = new glslang::TShader(glslangStage); - auto shaderPtr = std::unique_ptr(shader); - - glslang::TProgram* program = new glslang::TProgram(); - auto programPtr = std::unique_ptr(program); - - char const* sourceText = (char const*)request->inputBegin; - char const* sourceTextEnd = (char const*)request->inputEnd; - - int sourceTextLength = (int)(sourceTextEnd - sourceText); - - shader->setPreamble("#extension GL_GOOGLE_cpp_style_line_directive : require\n"); - - shader->setStringsWithLengthsAndNames( - &sourceText, - &sourceTextLength, - &request->sourcePath, - 1); - - EShMessages messages = EShMessages(EShMsgSpvRules | EShMsgVulkanRules); - - if( !shader->parse(&gResources, 110, false, messages) ) - { - dumpDiagnostics(request, shader->getInfoLog()); - return 1; - } - - program->addShader(shader); - - if( !program->link(messages) ) - { - dumpDiagnostics(request, program->getInfoLog()); - return 1; - } - - if( !program->mapIO() ) - { - dumpDiagnostics(request, program->getInfoLog()); - return 1; - } - - for(int stage = 0; stage < EShLangCount; ++stage) - { - auto stageIntermediate = program->getIntermediate((EShLanguage)stage); - if(!stageIntermediate) - continue; - - std::vector spirv; - std::string warningsErrors; - spv::SpvBuildLogger logger; - glslang::GlslangToSpv(*stageIntermediate, spirv, &logger); - - dumpDiagnostics(request, logger.getAllMessages()); - - dump(spirv.data(), spirv.size() * sizeof(unsigned int), request->outputFunc, request->outputUserData, stdout); - } - - return 0; -} - -static int glslang_dissassembleSPIRV(glslang_CompileRequest* request) -{ - typedef unsigned int SPIRVWord; - - SPIRVWord const* spirvBegin = (SPIRVWord const*)request->inputBegin; - SPIRVWord const* spirvEnd = (SPIRVWord const*)request->inputEnd; - - std::vector spirv(spirvBegin, spirvEnd); - - std::stringstream spirvAsmStream; - spv::Disassemble(spirvAsmStream, spirv); - std::string result = spirvAsmStream.str(); - dump(result.c_str(), result.length(), request->outputFunc, request->outputUserData, stdout); - - return 0; -} - -extern "C" -_declspec(dllexport) -int glslang_compile(glslang_CompileRequest* request) -{ - glslang::InitializeProcess(); - - int result = 0; - switch(request->action) - { - default: - result = 1; - break; - - case GLSLANG_ACTION_COMPILE_GLSL_TO_SPIRV: - result = glslang_compileGLSLToSPIRV(request); - break; - - case GLSLANG_ACTION_DISSASSEMBLE_SPIRV: - result = glslang_dissassembleSPIRV(request); - break; - } - - glslang::FinalizeProcess(); - - return result; -} diff --git a/tools/glslang/glslang.h b/tools/glslang/glslang.h deleted file mode 100644 index f02d43882..000000000 --- a/tools/glslang/glslang.h +++ /dev/null @@ -1,33 +0,0 @@ -// glslang.h -#ifndef GLSLANG_H_INCLUDED -#define GLSLANG_H_INCLUDED - -typedef void (*glslang_OutputFunc)(void const* data, size_t size, void* userData); - -enum -{ - GLSLANG_ACTION_COMPILE_GLSL_TO_SPIRV, - GLSLANG_ACTION_DISSASSEMBLE_SPIRV, -}; - -struct glslang_CompileRequest -{ - char const* sourcePath; - - void const* inputBegin; - void const* inputEnd; - - glslang_OutputFunc diagnosticFunc; - void* diagnosticUserData; - - glslang_OutputFunc outputFunc; - void* outputUserData; - - int slangStage; - - unsigned action; -}; - -typedef int (*glslang_CompileFunc)(glslang_CompileRequest* request); - -#endif diff --git a/tools/glslang/glslang.vcxproj b/tools/glslang/glslang.vcxproj deleted file mode 100644 index 2d24e513a..000000000 --- a/tools/glslang/glslang.vcxproj +++ /dev/null @@ -1,235 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {C495878A-832C-485B-B347-0998A90CC936} - Win32Proj - glslang - 8.1 - - - - DynamicLibrary - true - v140 - Unicode - - - DynamicLibrary - false - v140 - true - Unicode - - - DynamicLibrary - true - v140 - Unicode - - - DynamicLibrary - false - v140 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)external\glslang\;$(IncludePath) - - - true - $(SolutionDir)external\glslang\;$(IncludePath) - - - false - $(SolutionDir)external\glslang\;$(IncludePath) - - - false - $(SolutionDir)external\glslang\;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tools/glslang/glslang.vcxproj.filters b/tools/glslang/glslang.vcxproj.filters deleted file mode 100644 index eed4da9ba..000000000 --- a/tools/glslang/glslang.vcxproj.filters +++ /dev/null @@ -1,247 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file -- cgit v1.2.3