diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang-glslang/slang-glslang.cpp | 204 | ||||
| -rw-r--r-- | source/slang-glslang/slang-glslang.h | 33 | ||||
| -rw-r--r-- | source/slang-glslang/slang-glslang.vcxproj | 236 | ||||
| -rw-r--r-- | source/slang-glslang/slang-glslang.vcxproj.filters | 247 | ||||
| -rw-r--r-- | source/slang/compiler.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang.vcxproj | 21 | ||||
| -rw-r--r-- | source/slangc/main.cpp | 1 |
7 files changed, 736 insertions, 10 deletions
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 <cstring> +#include <cstdlib> +#include <cctype> +#include <cmath> +#include <array> +#include <memory> +#include <thread> +#endif + +#ifdef _WIN32 +#include <Windows.h> +#endif + +#include <sstream> + +// 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<glslang::TShader>(shader); + + glslang::TProgram* program = new glslang::TProgram(); + auto programPtr = std::unique_ptr<glslang::TProgram>(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<unsigned int> 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<SPIRVWord> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C495878A-832C-485B-B347-0998A90CC936}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>slang_glslang</RootNamespace> + <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> + <ProjectName>slang-glslang</ProjectName> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v140</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v140</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v140</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\build\slang-build.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\build\slang-build.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\build\slang-build.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\..\build\slang-build.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <IncludePath>$(SolutionDir)external\glslang\;$(IncludePath)</IncludePath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <IncludePath>$(SolutionDir)external\glslang\;$(IncludePath)</IncludePath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <IncludePath>$(SolutionDir)external\glslang\;$(IncludePath)</IncludePath> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <IncludePath>$(SolutionDir)external\glslang\;$(IncludePath)</IncludePath> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;GLSLANG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\external\glslang\glslang\GenericCodeGen\CodeGen.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\GenericCodeGen\Link.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Constant.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\glslang_tab.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\InfoSink.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Initialize.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Intermediate.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\intermOut.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\IntermTraverse.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\iomapper.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\limits.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\linkValidate.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\parseConst.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ParseContextBase.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ParseHelper.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\PoolAlloc.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\Pp.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpAtom.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpContext.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpScanner.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpTokens.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\propagateNoContraction.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\reflection.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\RemoveTree.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Scan.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ShaderLang.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\SymbolTable.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Versions.cpp" /> + <ClCompile Include="..\..\external\glslang\glslang\OSDependent\Windows\ossource.cpp" /> + <ClCompile Include="..\..\external\glslang\OGLCompilersDLL\InitializeDll.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\disassemble.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\doc.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\GlslangToSpv.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\InReadableOrder.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\Logger.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\SpvBuilder.cpp" /> + <ClCompile Include="..\..\external\glslang\SPIRV\SPVRemapper.cpp" /> + <ClCompile Include="..\..\external\glslang\StandAlone\ResourceLimits.cpp" /> + <ClCompile Include="..\..\external\glslang\StandAlone\StandAlone.cpp" /> + <ClCompile Include="slang-glslang.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\glslang_tab.cpp.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\gl_types.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Initialize.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\iomapper.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\LiveTraverser.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\localintermediate.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\ParseHelper.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\parseVersions.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpContext.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpTokens.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\propagateNoContraction.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\reflection.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\RemoveTree.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Scan.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\ScanContext.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\SymbolTable.h" /> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Versions.h" /> + <ClInclude Include="..\..\external\glslang\glslang\OSDependent\osinclude.h" /> + <ClInclude Include="..\..\external\glslang\OGLCompilersDLL\InitializeDll.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\bitutils.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\disassemble.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\doc.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.AMD.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.KHR.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.NV.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.std.450.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\GlslangToSpv.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\hex_float.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\Logger.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\spirv.hpp" /> + <ClInclude Include="..\..\external\glslang\SPIRV\SpvBuilder.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\spvIR.h" /> + <ClInclude Include="..\..\external\glslang\SPIRV\SPVRemapper.h" /> + <ClInclude Include="..\..\external\glslang\StandAlone\ResourceLimits.h" /> + <ClInclude Include="..\..\external\glslang\StandAlone\Worklist.h" /> + <ClInclude Include="slang-glslang.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Constant.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\glslang_tab.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\InfoSink.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Initialize.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Intermediate.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\intermOut.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\IntermTraverse.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\iomapper.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\limits.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\linkValidate.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\parseConst.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ParseContextBase.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ParseHelper.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\PoolAlloc.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\propagateNoContraction.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\reflection.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\RemoveTree.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Scan.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\ShaderLang.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\SymbolTable.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\Versions.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\Pp.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpAtom.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpContext.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpScanner.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpTokens.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\OSDependent\Windows\ossource.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\StandAlone\ResourceLimits.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\StandAlone\StandAlone.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\GenericCodeGen\CodeGen.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\glslang\GenericCodeGen\Link.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\OGLCompilersDLL\InitializeDll.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\disassemble.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\doc.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\GlslangToSpv.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\InReadableOrder.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\Logger.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\SpvBuilder.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\external\glslang\SPIRV\SPVRemapper.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="slang-glslang.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\gl_types.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\glslang_tab.cpp.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Initialize.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\iomapper.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\LiveTraverser.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\localintermediate.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\ParseHelper.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\parseVersions.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\propagateNoContraction.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\reflection.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\RemoveTree.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Scan.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\ScanContext.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\SymbolTable.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\Versions.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpContext.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\MachineIndependent\preprocessor\PpTokens.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\glslang\OSDependent\osinclude.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\StandAlone\ResourceLimits.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\StandAlone\Worklist.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\OGLCompilersDLL\InitializeDll.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\bitutils.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\disassemble.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\doc.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.AMD.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.KHR.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.ext.NV.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\GLSL.std.450.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\GlslangToSpv.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\hex_float.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\Logger.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\spirv.hpp"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\SpvBuilder.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\spvIR.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\external\glslang\SPIRV\SPVRemapper.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="slang-glslang.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ 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 @@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <PlatformToolset>v140</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <PlatformToolset>v140</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>v140</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>v140</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> @@ -90,7 +90,7 @@ </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../</AdditionalIncludeDirectories> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <MultiProcessorCompilation>false</MultiProcessorCompilation> @@ -106,7 +106,7 @@ </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../</AdditionalIncludeDirectories> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BrowseInformation>true</BrowseInformation> @@ -128,7 +128,7 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../</AdditionalIncludeDirectories> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <MultiProcessorCompilation>false</MultiProcessorCompilation> @@ -148,7 +148,7 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>SLANG_DYNAMIC;SLANG_DYNAMIC_EXPORT;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../</AdditionalIncludeDirectories> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <MultiProcessorCompilation>false</MultiProcessorCompilation> @@ -218,6 +218,11 @@ <ClCompile Include="token.cpp" /> <ClCompile Include="type-layout.cpp" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\core\core.vcxproj"> + <Project>{f9be7957-8399-899e-0c49-e714fddd4b65}</Project> + </ProjectReference> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> 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" |
