From 47ed0f68602a8ed0c425d2a4666969ad0db04ca6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 4 Dec 2020 13:03:29 -0500 Subject: Projects in 'build' and Slang API separation (#1624) * #include an absolute path didn't work - because paths were taken to always be relative. * Move reflection to reflection-api. * Slight reorg to pull out potentially Slang internal functions from the reflection API impls. * Remove visual studio projects * Fix for slang-binaries copy. * Add the visual studio projects in build/visual-studio * Remove miniz project. * Differentiate the linePath from the filePath. * Improve comment in premake5.lua + to kick of CI. * Kick CI. --- build/visual-studio/core/core.vcxproj | 263 ++ build/visual-studio/core/core.vcxproj.filters | 263 ++ .../cpu-hello-world/cpu-hello-world.vcxproj | 184 ++ .../cpu-hello-world.vcxproj.filters | 18 + build/visual-studio/gfx/gfx.vcxproj | 222 ++ build/visual-studio/gfx/gfx.vcxproj.filters | 141 ++ .../gpu-printing/gpu-printing.vcxproj | 190 ++ .../gpu-printing/gpu-printing.vcxproj.filters | 35 + .../visual-studio/hello-world/hello-world.vcxproj | 184 ++ .../hello-world/hello-world.vcxproj.filters | 18 + .../heterogeneous-hello-world.vcxproj | 185 ++ .../heterogeneous-hello-world.vcxproj.filters | 21 + build/visual-studio/miniz/miniz.vcxproj | 165 ++ .../model-viewer/model-viewer.vcxproj | 184 ++ .../model-viewer/model-viewer.vcxproj.filters | 18 + .../render-test-tool/render-test-tool.vcxproj | 217 ++ .../render-test-tool.vcxproj.filters | 69 + .../run-generators/run-generators.vcxproj | 246 ++ .../run-generators/run-generators.vcxproj.filters | 44 + .../slang-cpp-extractor.vcxproj | 192 ++ .../slang-cpp-extractor.vcxproj.filters | 63 + .../visual-studio/slang-embed/slang-embed.vcxproj | 171 ++ .../slang-embed/slang-embed.vcxproj.filters | 13 + .../slang-generate/slang-generate.vcxproj | 171 ++ .../slang-generate/slang-generate.vcxproj.filters | 13 + .../slang-reflection-test-tool.vcxproj | 182 ++ .../slang-reflection-test-tool.vcxproj.filters | 13 + build/visual-studio/slang-test/slang-test.vcxproj | 203 ++ .../slang-test/slang-test.vcxproj.filters | 78 + build/visual-studio/slang/slang.vcxproj | 443 ++++ build/visual-studio/slang/slang.vcxproj.filters | 736 ++++++ build/visual-studio/slangc/slangc.vcxproj | 174 ++ build/visual-studio/slangc/slangc.vcxproj.filters | 13 + examples/cpu-hello-world/cpu-hello-world.vcxproj | 184 -- .../cpu-hello-world.vcxproj.filters | 18 - examples/gpu-printing/gpu-printing.vcxproj | 190 -- examples/gpu-printing/gpu-printing.vcxproj.filters | 35 - examples/hello-world/hello-world.vcxproj | 184 -- examples/hello-world/hello-world.vcxproj.filters | 18 - .../heterogeneous-hello-world.vcxproj | 185 -- .../heterogeneous-hello-world.vcxproj.filters | 21 - examples/model-viewer/model-viewer.vcxproj | 184 -- examples/model-viewer/model-viewer.vcxproj.filters | 18 - premake5.lua | 107 +- slang.sln | 54 +- source/core/core.vcxproj | 263 -- source/core/core.vcxproj.filters | 263 -- source/miniz/miniz.vcxproj | 165 -- source/slang-glslang/slang-glslang.vcxproj | 435 ---- source/slang-glslang/slang-glslang.vcxproj.filters | 798 ------- source/slang/run-generators.vcxproj | 246 -- source/slang/run-generators.vcxproj.filters | 44 - source/slang/slang-api.cpp | 698 ++++++ source/slang/slang-compiler.cpp | 1 - source/slang/slang-reflection-api.cpp | 2507 +++++++++++++++++++ source/slang/slang-reflection.cpp | 2508 -------------------- source/slang/slang-reflection.h | 26 - source/slang/slang.cpp | 692 +----- source/slang/slang.vcxproj | 443 ---- source/slang/slang.vcxproj.filters | 736 ------ source/slangc/slangc.vcxproj | 174 -- source/slangc/slangc.vcxproj.filters | 13 - tools/gfx/gfx.vcxproj | 222 -- tools/gfx/gfx.vcxproj.filters | 141 -- tools/render-test/render-test-tool.vcxproj | 217 -- tools/render-test/render-test-tool.vcxproj.filters | 69 - .../slang-cpp-extractor.vcxproj | 192 -- .../slang-cpp-extractor.vcxproj.filters | 63 - tools/slang-embed/slang-embed.vcxproj | 171 -- tools/slang-embed/slang-embed.vcxproj.filters | 13 - tools/slang-generate/main.cpp | 10 +- tools/slang-generate/slang-generate.vcxproj | 171 -- .../slang-generate/slang-generate.vcxproj.filters | 13 - .../slang-reflection-test-tool.vcxproj | 182 -- .../slang-reflection-test-tool.vcxproj.filters | 13 - tools/slang-test/slang-test.vcxproj | 203 -- tools/slang-test/slang-test.vcxproj.filters | 78 - 77 files changed, 8431 insertions(+), 9669 deletions(-) create mode 100644 build/visual-studio/core/core.vcxproj create mode 100644 build/visual-studio/core/core.vcxproj.filters create mode 100644 build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj create mode 100644 build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj.filters create mode 100644 build/visual-studio/gfx/gfx.vcxproj create mode 100644 build/visual-studio/gfx/gfx.vcxproj.filters create mode 100644 build/visual-studio/gpu-printing/gpu-printing.vcxproj create mode 100644 build/visual-studio/gpu-printing/gpu-printing.vcxproj.filters create mode 100644 build/visual-studio/hello-world/hello-world.vcxproj create mode 100644 build/visual-studio/hello-world/hello-world.vcxproj.filters create mode 100644 build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj create mode 100644 build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters create mode 100644 build/visual-studio/miniz/miniz.vcxproj create mode 100644 build/visual-studio/model-viewer/model-viewer.vcxproj create mode 100644 build/visual-studio/model-viewer/model-viewer.vcxproj.filters create mode 100644 build/visual-studio/render-test-tool/render-test-tool.vcxproj create mode 100644 build/visual-studio/render-test-tool/render-test-tool.vcxproj.filters create mode 100644 build/visual-studio/run-generators/run-generators.vcxproj create mode 100644 build/visual-studio/run-generators/run-generators.vcxproj.filters create mode 100644 build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj create mode 100644 build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters create mode 100644 build/visual-studio/slang-embed/slang-embed.vcxproj create mode 100644 build/visual-studio/slang-embed/slang-embed.vcxproj.filters create mode 100644 build/visual-studio/slang-generate/slang-generate.vcxproj create mode 100644 build/visual-studio/slang-generate/slang-generate.vcxproj.filters create mode 100644 build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj create mode 100644 build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj.filters create mode 100644 build/visual-studio/slang-test/slang-test.vcxproj create mode 100644 build/visual-studio/slang-test/slang-test.vcxproj.filters create mode 100644 build/visual-studio/slang/slang.vcxproj create mode 100644 build/visual-studio/slang/slang.vcxproj.filters create mode 100644 build/visual-studio/slangc/slangc.vcxproj create mode 100644 build/visual-studio/slangc/slangc.vcxproj.filters delete mode 100644 examples/cpu-hello-world/cpu-hello-world.vcxproj delete mode 100644 examples/cpu-hello-world/cpu-hello-world.vcxproj.filters delete mode 100644 examples/gpu-printing/gpu-printing.vcxproj delete mode 100644 examples/gpu-printing/gpu-printing.vcxproj.filters delete mode 100644 examples/hello-world/hello-world.vcxproj delete mode 100644 examples/hello-world/hello-world.vcxproj.filters delete mode 100644 examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj delete mode 100644 examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters delete mode 100644 examples/model-viewer/model-viewer.vcxproj delete mode 100644 examples/model-viewer/model-viewer.vcxproj.filters delete mode 100644 source/core/core.vcxproj delete mode 100644 source/core/core.vcxproj.filters delete mode 100644 source/miniz/miniz.vcxproj delete mode 100644 source/slang-glslang/slang-glslang.vcxproj delete mode 100644 source/slang-glslang/slang-glslang.vcxproj.filters delete mode 100644 source/slang/run-generators.vcxproj delete mode 100644 source/slang/run-generators.vcxproj.filters create mode 100644 source/slang/slang-api.cpp create mode 100644 source/slang/slang-reflection-api.cpp delete mode 100644 source/slang/slang-reflection.cpp delete mode 100644 source/slang/slang-reflection.h delete mode 100644 source/slang/slang.vcxproj delete mode 100644 source/slang/slang.vcxproj.filters delete mode 100644 source/slangc/slangc.vcxproj delete mode 100644 source/slangc/slangc.vcxproj.filters delete mode 100644 tools/gfx/gfx.vcxproj delete mode 100644 tools/gfx/gfx.vcxproj.filters delete mode 100644 tools/render-test/render-test-tool.vcxproj delete mode 100644 tools/render-test/render-test-tool.vcxproj.filters delete mode 100644 tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj delete mode 100644 tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters delete mode 100644 tools/slang-embed/slang-embed.vcxproj delete mode 100644 tools/slang-embed/slang-embed.vcxproj.filters delete mode 100644 tools/slang-generate/slang-generate.vcxproj delete mode 100644 tools/slang-generate/slang-generate.vcxproj.filters delete mode 100644 tools/slang-reflection-test/slang-reflection-test-tool.vcxproj delete mode 100644 tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters delete mode 100644 tools/slang-test/slang-test.vcxproj delete mode 100644 tools/slang-test/slang-test.vcxproj.filters diff --git a/build/visual-studio/core/core.vcxproj b/build/visual-studio/core/core.vcxproj new file mode 100644 index 000000000..7c97eed01 --- /dev/null +++ b/build/visual-studio/core/core.vcxproj @@ -0,0 +1,263 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + true + Win32Proj + core + + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\core\ + core + .lib + + + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\core\ + core + .lib + + + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\core\ + core + .lib + + + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\core\ + core + .lib + + + + NotUsing + Level4 + true + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + true + + + + + NotUsing + Level4 + true + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + true + + + + + NotUsing + Level4 + true + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + true + + + + + NotUsing + Level4 + true + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/visual-studio/core/core.vcxproj.filters b/build/visual-studio/core/core.vcxproj.filters new file mode 100644 index 000000000..9a680cb39 --- /dev/null +++ b/build/visual-studio/core/core.vcxproj.filters @@ -0,0 +1,263 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + 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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header 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 + + + \ No newline at end of file diff --git a/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj b/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj new file mode 100644 index 000000000..72c9eac45 --- /dev/null +++ b/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4B47A364-37C4-96A7-6041-97BB4C1D333B} + true + Win32Proj + cpu-hello-world + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\cpu-hello-world\ + cpu-hello-world + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\cpu-hello-world\ + cpu-hello-world + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\cpu-hello-world\ + cpu-hello-world + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\cpu-hello-world\ + cpu-hello-world + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj.filters b/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj.filters new file mode 100644 index 000000000..ea71bfe9d --- /dev/null +++ b/build/visual-studio/cpu-hello-world/cpu-hello-world.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/gfx/gfx.vcxproj b/build/visual-studio/gfx/gfx.vcxproj new file mode 100644 index 000000000..9a188c070 --- /dev/null +++ b/build/visual-studio/gfx/gfx.vcxproj @@ -0,0 +1,222 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + true + Win32Proj + gfx + 10.0.14393.0 + + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\gfx\ + gfx + .lib + + + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\gfx\ + gfx + .lib + + + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\gfx\ + gfx + .lib + + + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\gfx\ + gfx + .lib + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\external\imgui;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../../bin/windows-x86/debug/" + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\external\imgui;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../../bin/windows-x64/debug/" + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\external\imgui;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../../bin/windows-x86/release/" + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\external\imgui;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../../bin/windows-x64/release/" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/visual-studio/gfx/gfx.vcxproj.filters b/build/visual-studio/gfx/gfx.vcxproj.filters new file mode 100644 index 000000000..2044ede93 --- /dev/null +++ b/build/visual-studio/gfx/gfx.vcxproj.filters @@ -0,0 +1,141 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + 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 + + + + + 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 + + + \ No newline at end of file diff --git a/build/visual-studio/gpu-printing/gpu-printing.vcxproj b/build/visual-studio/gpu-printing/gpu-printing.vcxproj new file mode 100644 index 000000000..1640b22e8 --- /dev/null +++ b/build/visual-studio/gpu-printing/gpu-printing.vcxproj @@ -0,0 +1,190 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {57C81DD3-4304-213D-AC16-39349871C957} + true + Win32Proj + gpu-printing + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\gpu-printing\ + gpu-printing + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\gpu-printing\ + gpu-printing + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\gpu-printing\ + gpu-printing + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\gpu-printing\ + gpu-printing + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + + + + + + + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/gpu-printing/gpu-printing.vcxproj.filters b/build/visual-studio/gpu-printing/gpu-printing.vcxproj.filters new file mode 100644 index 000000000..5f7207f25 --- /dev/null +++ b/build/visual-studio/gpu-printing/gpu-printing.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/hello-world/hello-world.vcxproj b/build/visual-studio/hello-world/hello-world.vcxproj new file mode 100644 index 000000000..9984aca49 --- /dev/null +++ b/build/visual-studio/hello-world/hello-world.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {010BE414-ED5B-CF56-16C0-BD18027062C0} + true + Win32Proj + hello-world + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\hello-world\ + hello-world + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\hello-world\ + hello-world + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\hello-world\ + hello-world + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\hello-world\ + hello-world + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + + + + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/hello-world/hello-world.vcxproj.filters b/build/visual-studio/hello-world/hello-world.vcxproj.filters new file mode 100644 index 000000000..9399d6c61 --- /dev/null +++ b/build/visual-studio/hello-world/hello-world.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj new file mode 100644 index 000000000..b5de40a53 --- /dev/null +++ b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {150CAA5A-0177-6A66-AA92-CFCB96DC2D49} + true + Win32Proj + heterogeneous-hello-world + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\heterogeneous-hello-world\ + heterogeneous-hello-world + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\heterogeneous-hello-world\ + heterogeneous-hello-world + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\heterogeneous-hello-world\ + heterogeneous-hello-world + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\heterogeneous-hello-world\ + heterogeneous-hello-world + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters new file mode 100644 index 000000000..67b3afa91 --- /dev/null +++ b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/miniz/miniz.vcxproj b/build/visual-studio/miniz/miniz.vcxproj new file mode 100644 index 000000000..0ce8e2054 --- /dev/null +++ b/build/visual-studio/miniz/miniz.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F} + true + Win32Proj + miniz + + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\miniz\ + miniz + .lib + + + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\miniz\ + miniz + .lib + + + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\miniz\ + miniz + .lib + + + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\miniz\ + miniz + .lib + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/build/visual-studio/model-viewer/model-viewer.vcxproj b/build/visual-studio/model-viewer/model-viewer.vcxproj new file mode 100644 index 000000000..f1e17ddca --- /dev/null +++ b/build/visual-studio/model-viewer/model-viewer.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {2F8724C6-1BC3-2730-84D5-3F277030D04A} + true + Win32Proj + model-viewer + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\model-viewer\ + model-viewer + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\model-viewer\ + model-viewer + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\model-viewer\ + model-viewer + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\model-viewer\ + model-viewer + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;..\..\..\tools;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + + + + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/model-viewer/model-viewer.vcxproj.filters b/build/visual-studio/model-viewer/model-viewer.vcxproj.filters new file mode 100644 index 000000000..a113f30bd --- /dev/null +++ b/build/visual-studio/model-viewer/model-viewer.vcxproj.filters @@ -0,0 +1,18 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/render-test-tool/render-test-tool.vcxproj b/build/visual-studio/render-test-tool/render-test-tool.vcxproj new file mode 100644 index 000000000..c55e7af5e --- /dev/null +++ b/build/visual-studio/render-test-tool/render-test-tool.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {61F7EB00-7281-4BF3-9470-7C2EA92620C3} + true + Win32Proj + render-test-tool + 10.0.14393.0 + + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\render-test-tool\ + render-test-tool + .dll + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\render-test-tool\ + render-test-tool + .dll + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\render-test-tool\ + render-test-tool + .dll + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\render-test-tool\ + render-test-tool + .dll + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\tools\gfx;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x86\debug\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../../bin/windows-x86/debug/" "windows-x86" + + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\tools\gfx;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x64\debug\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../../bin/windows-x64/debug/" "windows-x64" + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\tools\gfx;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x86\release\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../../bin/windows-x86/release/" "windows-x86" + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;..\..\..\external;..\..\..\source;..\..\..\tools\gfx;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x64\release\render-test-tool.lib + + + "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../../bin/windows-x64/release/" "windows-x64" + + + + + + + + + + + + + + + + + + + + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {222F7498-B40C-4F3F-A704-DDEB91A4484A} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/render-test-tool/render-test-tool.vcxproj.filters b/build/visual-studio/render-test-tool/render-test-tool.vcxproj.filters new file mode 100644 index 000000000..1c0d82cdd --- /dev/null +++ b/build/visual-studio/render-test-tool/render-test-tool.vcxproj.filters @@ -0,0 +1,69 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/run-generators/run-generators.vcxproj b/build/visual-studio/run-generators/run-generators.vcxproj new file mode 100644 index 000000000..d326efb61 --- /dev/null +++ b/build/visual-studio/run-generators/run-generators.vcxproj @@ -0,0 +1,246 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223} + true + Win32Proj + run-generators + + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + true + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + StaticLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\run-generators\ + run-generators + .lib + + + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\run-generators\ + run-generators + .lib + + + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\run-generators\ + run-generators + .lib + + + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\run-generators\ + run-generators + .lib + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + + + + + + + + + + + + Document + "../../../bin/windows-x86/debug/slang-embed" %(Identity) + "../../../bin/windows-x64/debug/slang-embed" %(Identity) + "../../../bin/windows-x86/release/slang-embed" %(Identity) + "../../../bin/windows-x64/release/slang-embed" %(Identity) + ../../../prelude/slang-cpp-prelude.h.cpp + slang-embed %(Identity) + ../../../bin/windows-x86/debug/slang-embed.exe + ../../../bin/windows-x64/debug/slang-embed.exe + ../../../bin/windows-x86/release/slang-embed.exe + ../../../bin/windows-x64/release/slang-embed.exe + + + Document + "../../../bin/windows-x86/debug/slang-embed" %(Identity) + "../../../bin/windows-x64/debug/slang-embed" %(Identity) + "../../../bin/windows-x86/release/slang-embed" %(Identity) + "../../../bin/windows-x64/release/slang-embed" %(Identity) + ../../../prelude/slang-cuda-prelude.h.cpp + slang-embed %(Identity) + ../../../bin/windows-x86/debug/slang-embed.exe + ../../../bin/windows-x64/debug/slang-embed.exe + ../../../bin/windows-x86/release/slang-embed.exe + ../../../bin/windows-x64/release/slang-embed.exe + + + Document + "../../../bin/windows-x86/debug/slang-embed" %(Identity) + "../../../bin/windows-x64/debug/slang-embed" %(Identity) + "../../../bin/windows-x86/release/slang-embed" %(Identity) + "../../../bin/windows-x64/release/slang-embed" %(Identity) + ../../../prelude/slang-hlsl-prelude.h.cpp + slang-embed %(Identity) + ../../../bin/windows-x86/debug/slang-embed.exe + ../../../bin/windows-x64/debug/slang-embed.exe + ../../../bin/windows-x86/release/slang-embed.exe + ../../../bin/windows-x64/release/slang-embed.exe + + + Document + "../../../bin/windows-x86/debug/slang-generate" %(Identity) + "../../../bin/windows-x64/debug/slang-generate" %(Identity) + "../../../bin/windows-x86/release/slang-generate" %(Identity) + "../../../bin/windows-x64/release/slang-generate" %(Identity) + ../../../source/slang/core.meta.slang.h + slang-generate %(Identity) + ../../../bin/windows-x86/debug/slang-generate.exe + ../../../bin/windows-x64/debug/slang-generate.exe + ../../../bin/windows-x86/release/slang-generate.exe + ../../../bin/windows-x64/release/slang-generate.exe + + + Document + "../../../bin/windows-x86/debug/slang-generate" %(Identity) + "../../../bin/windows-x64/debug/slang-generate" %(Identity) + "../../../bin/windows-x86/release/slang-generate" %(Identity) + "../../../bin/windows-x64/release/slang-generate" %(Identity) + ../../../source/slang/hlsl.meta.slang.h + slang-generate %(Identity) + ../../../bin/windows-x86/debug/slang-generate.exe + ../../../bin/windows-x64/debug/slang-generate.exe + ../../../bin/windows-x86/release/slang-generate.exe + ../../../bin/windows-x64/release/slang-generate.exe + + + Document + "../../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS + "../../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS + "../../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS + "../../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS + ../../../source/slang/slang-generated-obj.h;../../../source/slang/slang-generated-obj-macro.h;../../../source/slang/slang-generated-ast.h;../../../source/slang/slang-generated-ast-macro.h;../../../source/slang/slang-generated-value.h;../../../source/slang/slang-generated-value-macro.h + C++ Extractor %(Identity) + ../../../bin/windows-x86/debug/slang-cpp-extractor.exe;../../../source/slang/slang-ast-support-types.h;../../../source/slang/slang-ast-base.h;../../../source/slang/slang-ast-decl.h;../../../source/slang/slang-ast-expr.h;../../../source/slang/slang-ast-modifier.h;../../../source/slang/slang-ast-stmt.h;../../../source/slang/slang-ast-type.h;../../../source/slang/slang-ast-val.h + ../../../bin/windows-x64/debug/slang-cpp-extractor.exe;../../../source/slang/slang-ast-support-types.h;../../../source/slang/slang-ast-base.h;../../../source/slang/slang-ast-decl.h;../../../source/slang/slang-ast-expr.h;../../../source/slang/slang-ast-modifier.h;../../../source/slang/slang-ast-stmt.h;../../../source/slang/slang-ast-type.h;../../../source/slang/slang-ast-val.h + ../../../bin/windows-x86/release/slang-cpp-extractor.exe;../../../source/slang/slang-ast-support-types.h;../../../source/slang/slang-ast-base.h;../../../source/slang/slang-ast-decl.h;../../../source/slang/slang-ast-expr.h;../../../source/slang/slang-ast-modifier.h;../../../source/slang/slang-ast-stmt.h;../../../source/slang/slang-ast-type.h;../../../source/slang/slang-ast-val.h + ../../../bin/windows-x64/release/slang-cpp-extractor.exe;../../../source/slang/slang-ast-support-types.h;../../../source/slang/slang-ast-base.h;../../../source/slang/slang-ast-decl.h;../../../source/slang/slang-ast-expr.h;../../../source/slang/slang-ast-modifier.h;../../../source/slang/slang-ast-stmt.h;../../../source/slang/slang-ast-type.h;../../../source/slang/slang-ast-val.h + + + + + + \ No newline at end of file diff --git a/build/visual-studio/run-generators/run-generators.vcxproj.filters b/build/visual-studio/run-generators/run-generators.vcxproj.filters new file mode 100644 index 000000000..17a7477ed --- /dev/null +++ b/build/visual-studio/run-generators/run-generators.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Source Files + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj b/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj new file mode 100644 index 000000000..ff2403239 --- /dev/null +++ b/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj @@ -0,0 +1,192 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} + true + Win32Proj + slang-cpp-extractor + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang-cpp-extractor\ + slang-cpp-extractor + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang-cpp-extractor\ + slang-cpp-extractor + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang-cpp-extractor\ + slang-cpp-extractor + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang-cpp-extractor\ + slang-cpp-extractor + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + + + + + + + + + + + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters b/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters new file mode 100644 index 000000000..83789882f --- /dev/null +++ b/build/visual-studio/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters @@ -0,0 +1,63 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/slang-embed/slang-embed.vcxproj b/build/visual-studio/slang-embed/slang-embed.vcxproj new file mode 100644 index 000000000..85feb094a --- /dev/null +++ b/build/visual-studio/slang-embed/slang-embed.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {7F773DD9-EB8F-2403-B43C-B49C2014B99C} + true + Win32Proj + slang-embed + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang-embed\ + slang-embed + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang-embed\ + slang-embed + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang-embed\ + slang-embed + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang-embed\ + slang-embed + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang-embed/slang-embed.vcxproj.filters b/build/visual-studio/slang-embed/slang-embed.vcxproj.filters new file mode 100644 index 000000000..b0e124ebd --- /dev/null +++ b/build/visual-studio/slang-embed/slang-embed.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/slang-generate/slang-generate.vcxproj b/build/visual-studio/slang-generate/slang-generate.vcxproj new file mode 100644 index 000000000..f0238aa27 --- /dev/null +++ b/build/visual-studio/slang-generate/slang-generate.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {66174227-8541-41FC-A6DF-4764FC66F78E} + true + Win32Proj + slang-generate + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang-generate\ + slang-generate + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang-generate\ + slang-generate + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang-generate\ + slang-generate + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang-generate\ + slang-generate + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang-generate/slang-generate.vcxproj.filters b/build/visual-studio/slang-generate/slang-generate.vcxproj.filters new file mode 100644 index 000000000..74def4b00 --- /dev/null +++ b/build/visual-studio/slang-generate/slang-generate.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj b/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj new file mode 100644 index 000000000..372771e63 --- /dev/null +++ b/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj @@ -0,0 +1,182 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} + true + Win32Proj + slang-reflection-test-tool + + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang-reflection-test-tool\ + slang-reflection-test-tool + .dll + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x86\debug\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x64\debug\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x86\release\slang-reflection-test-tool.lib + + + + + NotUsing + Level3 + NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x64\release\slang-reflection-test-tool.lib + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj.filters b/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj.filters new file mode 100644 index 000000000..e44b7e3b8 --- /dev/null +++ b/build/visual-studio/slang-reflection-test-tool/slang-reflection-test-tool.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/slang-test/slang-test.vcxproj b/build/visual-studio/slang-test/slang-test.vcxproj new file mode 100644 index 000000000..4a56eb437 --- /dev/null +++ b/build/visual-studio/slang-test/slang-test.vcxproj @@ -0,0 +1,203 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {0C768A18-1D25-4000-9F37-DA5FE99E3B64} + true + Win32Proj + slang-test + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang-test\ + slang-test + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang-test\ + slang-test + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang-test\ + slang-test + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang-test\ + slang-test + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + ..\..\..;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang-test/slang-test.vcxproj.filters b/build/visual-studio/slang-test/slang-test.vcxproj.filters new file mode 100644 index 000000000..8718a4d86 --- /dev/null +++ b/build/visual-studio/slang-test/slang-test.vcxproj.filters @@ -0,0 +1,78 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header 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 + + + \ No newline at end of file diff --git a/build/visual-studio/slang/slang.vcxproj b/build/visual-studio/slang/slang.vcxproj new file mode 100644 index 000000000..21c80b11e --- /dev/null +++ b/build/visual-studio/slang/slang.vcxproj @@ -0,0 +1,443 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + true + Win32Proj + slang + + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + true + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + DynamicLibrary + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slang\ + slang + .dll + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slang\ + slang + .dll + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slang\ + slang + .dll + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slang\ + slang + .dll + + + + NotUsing + Level4 + true + _DEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) + ..\..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x86\debug\slang.lib + true + + + IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug > nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\debug > nul) + + + + + NotUsing + Level4 + true + _DEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) + ..\..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + MultiThreadedDebug + + + Windows + true + ..\..\..\bin\windows-x64\debug\slang.lib + true + + + IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug > nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\debug > nul) + + + + + NotUsing + Level4 + true + NDEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) + ..\..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x86\release\slang.lib + true + + + IF EXIST ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release > nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\..\bin\windows-x86\release > nul) + + + + + NotUsing + Level4 + true + NDEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) + ..\..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + + + Windows + true + true + ..\..\..\bin\windows-x64\release\slang.lib + true + + + IF EXIST ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release > nul) ELSE (xcopy /Q /Y /I ..\..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\..\bin\windows-x64\release > nul) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slang/slang.vcxproj.filters b/build/visual-studio/slang/slang.vcxproj.filters new file mode 100644 index 000000000..d83093235 --- /dev/null +++ b/build/visual-studio/slang/slang.vcxproj.filters @@ -0,0 +1,736 @@ + + + + + {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + 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 + + + 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 + + + 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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Header Files + + + Header Files + + + Header 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 + + + 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 + + + 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 + + + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/build/visual-studio/slangc/slangc.vcxproj b/build/visual-studio/slangc/slangc.vcxproj new file mode 100644 index 000000000..b05f61ae7 --- /dev/null +++ b/build/visual-studio/slangc/slangc.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7} + true + Win32Proj + slangc + + + + Application + true + Unicode + v140 + + + Application + true + Unicode + v140 + + + Application + false + Unicode + v140 + + + Application + false + Unicode + v140 + + + + + + + + + + + + + + + + + + + true + ..\..\..\bin\windows-x86\debug\ + ..\..\..\intermediate\windows-x86\debug\slangc\ + slangc + .exe + + + true + ..\..\..\bin\windows-x64\debug\ + ..\..\..\intermediate\windows-x64\debug\slangc\ + slangc + .exe + + + false + ..\..\..\bin\windows-x86\release\ + ..\..\..\intermediate\windows-x86\release\slangc\ + slangc + .exe + + + false + ..\..\..\bin\windows-x64\release\ + ..\..\..\intermediate\windows-x64\release\slangc\ + slangc + .exe + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + _DEBUG;%(PreprocessorDefinitions) + EditAndContinue + Disabled + MultiThreadedDebug + + + Console + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + NotUsing + Level3 + NDEBUG;%(PreprocessorDefinitions) + Full + true + true + false + true + MultiThreaded + + + Console + true + true + + + + + + + + {F9BE7957-8399-899E-0C49-E714FDDD4B65} + + + {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} + + + + + + \ No newline at end of file diff --git a/build/visual-studio/slangc/slangc.vcxproj.filters b/build/visual-studio/slangc/slangc.vcxproj.filters new file mode 100644 index 000000000..216e5673a --- /dev/null +++ b/build/visual-studio/slangc/slangc.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} + + + + + Source Files + + + \ No newline at end of file diff --git a/examples/cpu-hello-world/cpu-hello-world.vcxproj b/examples/cpu-hello-world/cpu-hello-world.vcxproj deleted file mode 100644 index d150aa51d..000000000 --- a/examples/cpu-hello-world/cpu-hello-world.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4B47A364-37C4-96A7-6041-97BB4C1D333B} - true - Win32Proj - cpu-hello-world - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\cpu-hello-world\ - cpu-hello-world - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\cpu-hello-world\ - cpu-hello-world - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\cpu-hello-world\ - cpu-hello-world - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\cpu-hello-world\ - cpu-hello-world - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/examples/cpu-hello-world/cpu-hello-world.vcxproj.filters b/examples/cpu-hello-world/cpu-hello-world.vcxproj.filters deleted file mode 100644 index 1ceeb57d7..000000000 --- a/examples/cpu-hello-world/cpu-hello-world.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/examples/gpu-printing/gpu-printing.vcxproj b/examples/gpu-printing/gpu-printing.vcxproj deleted file mode 100644 index 1cb664892..000000000 --- a/examples/gpu-printing/gpu-printing.vcxproj +++ /dev/null @@ -1,190 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {57C81DD3-4304-213D-AC16-39349871C957} - true - Win32Proj - gpu-printing - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\gpu-printing\ - gpu-printing - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\gpu-printing\ - gpu-printing - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\gpu-printing\ - gpu-printing - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\gpu-printing\ - gpu-printing - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - - - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/examples/gpu-printing/gpu-printing.vcxproj.filters b/examples/gpu-printing/gpu-printing.vcxproj.filters deleted file mode 100644 index 7b1743f46..000000000 --- a/examples/gpu-printing/gpu-printing.vcxproj.filters +++ /dev/null @@ -1,35 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/examples/hello-world/hello-world.vcxproj b/examples/hello-world/hello-world.vcxproj deleted file mode 100644 index db6f52a86..000000000 --- a/examples/hello-world/hello-world.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {010BE414-ED5B-CF56-16C0-BD18027062C0} - true - Win32Proj - hello-world - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\hello-world\ - hello-world - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\hello-world\ - hello-world - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\hello-world\ - hello-world - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\hello-world\ - hello-world - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/examples/hello-world/hello-world.vcxproj.filters b/examples/hello-world/hello-world.vcxproj.filters deleted file mode 100644 index a02cb79fc..000000000 --- a/examples/hello-world/hello-world.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj b/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj deleted file mode 100644 index 8a53a719a..000000000 --- a/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {150CAA5A-0177-6A66-AA92-CFCB96DC2D49} - true - Win32Proj - heterogeneous-hello-world - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\heterogeneous-hello-world\ - heterogeneous-hello-world - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\heterogeneous-hello-world\ - heterogeneous-hello-world - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\heterogeneous-hello-world\ - heterogeneous-hello-world - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\heterogeneous-hello-world\ - heterogeneous-hello-world - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters b/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters deleted file mode 100644 index 0d3970688..000000000 --- a/examples/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/examples/model-viewer/model-viewer.vcxproj b/examples/model-viewer/model-viewer.vcxproj deleted file mode 100644 index 97896612d..000000000 --- a/examples/model-viewer/model-viewer.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2F8724C6-1BC3-2730-84D5-3F277030D04A} - true - Win32Proj - model-viewer - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\model-viewer\ - model-viewer - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\model-viewer\ - model-viewer - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\model-viewer\ - model-viewer - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\model-viewer\ - model-viewer - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\tools;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - - - - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/examples/model-viewer/model-viewer.vcxproj.filters b/examples/model-viewer/model-viewer.vcxproj.filters deleted file mode 100644 index a02cb79fc..000000000 --- a/examples/model-viewer/model-viewer.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index bc0154319..2cdaf45ef 100644 --- a/premake5.lua +++ b/premake5.lua @@ -154,7 +154,7 @@ if enableCuda then end -- Is true when the target is really windows (ie not something on top of windows like cygwin) -local isTargetWindows = (os.target() == "windows") and not (targetDetail == "mingw" or targetDetail == "cygwin") +isTargetWindows = (os.target() == "windows") and not (targetDetail == "mingw" or targetDetail == "cygwin") -- Even if we have the nvapi path, we only want to currently enable on windows targets @@ -163,7 +163,6 @@ enableNvapi = not not (os.isdir(nvapiPath) and isTargetWindows and _OPTIONS["ena if enableNvapi then printf("Enabled NVAPI") end - overrideModule = {} local overrideModulePath = _OPTIONS["override-module"] if overrideModulePath then @@ -201,9 +200,13 @@ workspace "slang" -- and configuration options, e.g. `bin/windows-x64/debug/` targetdir("bin/" .. targetName .. "/%{cfg.buildcfg:lower()}") + -- C++11 + cppdialect "C++11" -- Statically link to the C/C++ runtime rather than create a DLL dependency. - flags { "StaticRuntime", "C++11" } - + staticruntime "On" + + -- Statically link to the C/C++ runtime rather than create a DLL dependency. + -- Once we've set up the common settings, we will make some tweaks -- that only apply in a subset of cases. Each call to `filter()` -- changes the "active" filter for subsequent commands. In @@ -314,6 +317,24 @@ function addSourceDir(path) } end +-- +-- A function to return a name to place project files under +-- in build directory +-- +-- This is complicated in so far as when this is used (with location for example) +-- we can't use Tokens +-- https://github.com/premake/premake-core/wiki/Tokens + +function getBuildLocationName() + if not not targetDetail then + return targetDetail + elseif isTargetWindows then + return "visual-studio" + else + return os.target() + end +end + -- -- Next we will define a helper routine that all of our -- projects will bottleneck through. Here `name` is @@ -326,10 +347,8 @@ end -- -- baseSlangProject("slangc", "source/slangc") -- --- NOTE! This function does not add any source from the sourceDir --- add the source after calling this function with 'addSourceDir', or --- use `baseSlangProjectAddFiles` --- +-- NOTE! This function will add any source from the sourceDir, *if* it's specified. +-- Pass nil if adding files is not wanted. function baseSlangProject(name, sourceDir) -- Start a new project in premake. This switches @@ -344,30 +363,24 @@ function baseSlangProject(name, sourceDir) -- projects. If we don't have a stable UUID, then the -- output files might have spurious diffs whenever we -- re-run premake generation. - uuid(os.uuid(name .. '|' .. sourceDir)) - - -- Set the location where the project file will be placed. - -- We set the project files to reside in their source - -- directory, because in Visual Studio the default - -- working directory when launching a project in the - -- debugger is its project directory. This ensures that - -- examples will work as expected for VS users. - -- - -- TODO: consider only setting this for examples, since - -- it is less relevant to other projects. - -- - - location(sourceDir) - if os.target() == "windows" then + if sourceDir then + uuid(os.uuid(name .. '|' .. sourceDir)) else - location "intermediate/project/%{prj.name}" + -- If we don't have a sourceDir, the name will have to be enough + uuid(os.uuid(name)) end + + -- Location could do with a better name than 'other' - but it seems as if %{cfg.buildcfg:lower()} and similar variables + -- is not available for location to expand. + location("build/" .. getBuildLocationName() .. "/" .. name) + -- The intermediate ("object") directory will use a similar -- naming scheme to the output directory, but will also use -- the project name to avoid cases where multiple projects -- have source files with the same name. + -- objdir("intermediate/" .. targetName .. "/%{cfg.buildcfg:lower()}/%{prj.name}") -- All of our projects are written in C++. @@ -404,25 +417,19 @@ function baseSlangProject(name, sourceDir) if overrideModule.addBaseProjectOptions then overrideModule.addBaseProjectOptions() end -end - -function baseSlangProjectAddFiles(name, sourceDir) - - -- - -- Set up the base project - -- - - baseSlangProject(name, sourceDir) -- -- Add the files in the sourceDir -- NOTE! This doesn't recursively add files in subdirectories -- - addSourceDir(sourceDir) + if not not sourceDir then + addSourceDir(sourceDir) + end end --- We can now use the `baseSlangProjectAddFiles()` subroutine to + +-- We can now use the `baseSlangProject()` subroutine to -- define helpers for the different categories of project -- in our source tree. -- @@ -445,7 +452,7 @@ function tool(name) -- Now we invoke our shared project configuration logic, -- specifying that the project lives under the `tools/` path. -- - baseSlangProjectAddFiles(name, "tools/" .. name) + baseSlangProject(name, "tools/" .. name) -- Finally, we set the project "kind" to produce a console -- application. This is a reasonable default for tools, @@ -459,7 +466,7 @@ end -- "Standard" projects will be those that go to make the binary -- packages for slang: the shared libraries and executables. -- -function standardProject(name) +function standardProject(name, sourceDir) -- Because Premake is stateful, any `group()` call by another -- project would still be in effect when we create a project -- here (e.g., if somebody had called `tool()` before @@ -468,16 +475,15 @@ function standardProject(name) -- group "" - -- A standard project has its code under `source/` - -- - baseSlangProjectAddFiles(name, "source/" .. name) + baseSlangProject(name, sourceDir) end + function toolSharedLibrary(name) group "test-tool" -- specifying that the project lives under the `tools/` path. -- - baseSlangProjectAddFiles(name .. "-tool", "tools/" .. name) + baseSlangProject(name .. "-tool", "tools/" .. name) defines { "SLANG_SHARED_LIBRARY_TOOL" } @@ -491,7 +497,7 @@ function example(name) group "examples" -- They have their source code under `examples//` - baseSlangProjectAddFiles(name, "examples/" .. name) + baseSlangProject(name, "examples/" .. name) -- By default, all of our examples are GUI applications. One some -- platforms there is no meaningful distinction between GUI and @@ -574,7 +580,7 @@ example "cpu-hello-world" -- and the various tool projects. It's build is pretty simple: -- -standardProject "core" +standardProject("core", "source/core") uuid "F9BE7957-8399-899E-0C49-E714FDDD4B65" kind "StaticLib" @@ -793,12 +799,12 @@ tool "gfx" -- it also depends on `core`: -- -standardProject "slangc" +standardProject("slangc", "source/slangc") uuid "D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7" kind "ConsoleApp" links { "core", "slang" } -generatorProject("run-generators", "source/slang/") +generatorProject("run-generators", nil) -- We make 'source/slang' the location of the source, to make paths to source -- relative to that @@ -954,7 +960,7 @@ generatorProject("run-generators", "source/slang/") -- First up is the `slang` dynamic library project: -- -standardProject "slang" +standardProject("slang", "source/slang") uuid "DB00DA62-0533-4AFD-B59F-A67D5B3A0808" kind "SharedLib" links { "core" } @@ -1002,7 +1008,7 @@ standardProject "slang" if not buildGlslang then filter { "system:windows" } postbuildcommands { - "{COPY} ../../external/slang-binaries/bin/" .. targetName .. "/slang-glslang.dll %{cfg.targetdir}" + "{COPY} ../../../external/slang-binaries/bin/" .. targetName .. "/slang-glslang.dll %{cfg.targetdir}" } filter { "system:linux" } @@ -1058,10 +1064,11 @@ if enableProfile then end -standardProject "miniz" +standardProject("miniz", nil) uuid "E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F" kind "StaticLib" + -- Add the files explicitly files { "external/miniz/miniz.c", @@ -1077,7 +1084,7 @@ standardProject "miniz" if buildGlslang then -standardProject "slang-spirv-tools" +standardProject("slang-spirv-tools", nil) uuid "C36F6185-49B3-467E-8388-D0E9BF5F7BB8" kind "StaticLib" includedirs { "external/spirv-tools", "external/spirv-tools/include", "external/spirv-headers/include", "external/spirv-tools-generated"} @@ -1103,7 +1110,7 @@ standardProject "slang-spirv-tools" -- The following is a tailored build of glslang that pulls in the pieces we care -- about whle trying to leave out the rest: -- -standardProject "slang-glslang" +standardProject("slang-glslang", nil) uuid "C495878A-832C-485B-B347-0998A90CC936" kind "SharedLib" includedirs { "external/glslang", "external/spirv-tools", "external/spirv-tools/include", "external/spirv-headers/include", "external/spirv-tools-generated", "external/glslang-generated" } diff --git a/slang.sln b/slang.sln index dc52f6d78..9ffa3b4d3 100644 --- a/slang.sln +++ b/slang.sln @@ -1,55 +1,55 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "source\core\core.vcxproj", "{F9BE7957-8399-899E-0C49-E714FDDD4B65}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "build\visual-studio\core\core.vcxproj", "{F9BE7957-8399-899E-0C49-E714FDDD4B65}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpu-hello-world", "examples\cpu-hello-world\cpu-hello-world.vcxproj", "{4B47A364-37C4-96A7-6041-97BB4C1D333B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpu-hello-world", "build\visual-studio\cpu-hello-world\cpu-hello-world.vcxproj", "{4B47A364-37C4-96A7-6041-97BB4C1D333B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpu-printing", "examples\gpu-printing\gpu-printing.vcxproj", "{57C81DD3-4304-213D-AC16-39349871C957}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpu-printing", "build\visual-studio\gpu-printing\gpu-printing.vcxproj", "{57C81DD3-4304-213D-AC16-39349871C957}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello-world", "examples\hello-world\hello-world.vcxproj", "{010BE414-ED5B-CF56-16C0-BD18027062C0}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hello-world", "build\visual-studio\hello-world\hello-world.vcxproj", "{010BE414-ED5B-CF56-16C0-BD18027062C0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "heterogeneous-hello-world", "examples\heterogeneous-hello-world\heterogeneous-hello-world.vcxproj", "{150CAA5A-0177-6A66-AA92-CFCB96DC2D49}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "heterogeneous-hello-world", "build\visual-studio\heterogeneous-hello-world\heterogeneous-hello-world.vcxproj", "{150CAA5A-0177-6A66-AA92-CFCB96DC2D49}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "model-viewer", "examples\model-viewer\model-viewer.vcxproj", "{2F8724C6-1BC3-2730-84D5-3F277030D04A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "model-viewer", "build\visual-studio\model-viewer\model-viewer.vcxproj", "{2F8724C6-1BC3-2730-84D5-3F277030D04A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "generator", "generator", "{F3AB4ED5-5F37-BC99-6848-3F8ED452189A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "run-generators", "source\slang\run-generators.vcxproj", "{811F1997-6DDA-0843-1692-818D022C53D3}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "run-generators", "build\visual-studio\run-generators\run-generators.vcxproj", "{E145B2B8-CD13-A6BE-B6A7-16E5A2148223}" ProjectSection(ProjectDependencies) = postProject {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} = {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} {66174227-8541-41FC-A6DF-4764FC66F78E} = {66174227-8541-41FC-A6DF-4764FC66F78E} {7F773DD9-EB8F-2403-B43C-B49C2014B99C} = {7F773DD9-EB8F-2403-B43C-B49C2014B99C} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniz", "source\miniz\miniz.vcxproj", "{E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniz", "build\visual-studio\miniz\miniz.vcxproj", "{E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "source\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "build\visual-studio\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" ProjectSection(ProjectDependencies) = postProject - {811F1997-6DDA-0843-1692-818D022C53D3} = {811F1997-6DDA-0843-1692-818D022C53D3} + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223} = {E145B2B8-CD13-A6BE-B6A7-16E5A2148223} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slangc", "source\slangc\slangc.vcxproj", "{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slangc", "build\visual-studio\slangc\slangc.vcxproj", "{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test-tool", "test-tool", "{57B5AA5E-C340-1823-CC51-9B17385C7423}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "render-test-tool", "tools\render-test\render-test-tool.vcxproj", "{61F7EB00-7281-4BF3-9470-7C2EA92620C3}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "render-test-tool", "build\visual-studio\render-test-tool\render-test-tool.vcxproj", "{61F7EB00-7281-4BF3-9470-7C2EA92620C3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-reflection-test-tool", "tools\slang-reflection-test\slang-reflection-test-tool.vcxproj", "{C5ACCA6E-C04D-4B36-8516-3752B3C13C2F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-reflection-test-tool", "build\visual-studio\slang-reflection-test-tool\slang-reflection-test-tool.vcxproj", "{C5ACCA6E-C04D-4B36-8516-3752B3C13C2F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{FD47AE19-69FD-260F-F2F1-20E65EA61D13}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gfx", "tools\gfx\gfx.vcxproj", "{222F7498-B40C-4F3F-A704-DDEB91A4484A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gfx", "build\visual-studio\gfx\gfx.vcxproj", "{222F7498-B40C-4F3F-A704-DDEB91A4484A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-cpp-extractor", "tools\slang-cpp-extractor\slang-cpp-extractor.vcxproj", "{CA8A30D1-8FA9-4330-B7F7-84709246D8DC}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-cpp-extractor", "build\visual-studio\slang-cpp-extractor\slang-cpp-extractor.vcxproj", "{CA8A30D1-8FA9-4330-B7F7-84709246D8DC}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-embed", "tools\slang-embed\slang-embed.vcxproj", "{7F773DD9-EB8F-2403-B43C-B49C2014B99C}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-embed", "build\visual-studio\slang-embed\slang-embed.vcxproj", "{7F773DD9-EB8F-2403-B43C-B49C2014B99C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-generate", "tools\slang-generate\slang-generate.vcxproj", "{66174227-8541-41FC-A6DF-4764FC66F78E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-generate", "build\visual-studio\slang-generate\slang-generate.vcxproj", "{66174227-8541-41FC-A6DF-4764FC66F78E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-test", "tools\slang-test\slang-test.vcxproj", "{0C768A18-1D25-4000-9F37-DA5FE99E3B64}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-test", "build\visual-studio\slang-test\slang-test.vcxproj", "{0C768A18-1D25-4000-9F37-DA5FE99E3B64}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -107,14 +107,14 @@ Global {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|Win32.Build.0 = Release|Win32 {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|x64.ActiveCfg = Release|x64 {2F8724C6-1BC3-2730-84D5-3F277030D04A}.Release|x64.Build.0 = Release|x64 - {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|Win32.Build.0 = Debug|Win32 - {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|x64.ActiveCfg = Debug|x64 - {811F1997-6DDA-0843-1692-818D022C53D3}.Debug|x64.Build.0 = Debug|x64 - {811F1997-6DDA-0843-1692-818D022C53D3}.Release|Win32.ActiveCfg = Release|Win32 - {811F1997-6DDA-0843-1692-818D022C53D3}.Release|Win32.Build.0 = Release|Win32 - {811F1997-6DDA-0843-1692-818D022C53D3}.Release|x64.ActiveCfg = Release|x64 - {811F1997-6DDA-0843-1692-818D022C53D3}.Release|x64.Build.0 = Release|x64 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Debug|Win32.ActiveCfg = Debug|Win32 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Debug|Win32.Build.0 = Debug|Win32 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Debug|x64.ActiveCfg = Debug|x64 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Debug|x64.Build.0 = Debug|x64 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Release|Win32.ActiveCfg = Release|Win32 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Release|Win32.Build.0 = Release|Win32 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Release|x64.ActiveCfg = Release|x64 + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223}.Release|x64.Build.0 = Release|x64 {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F}.Debug|Win32.ActiveCfg = Debug|Win32 {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F}.Debug|Win32.Build.0 = Debug|Win32 {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F}.Debug|x64.ActiveCfg = Debug|x64 @@ -205,7 +205,7 @@ Global {010BE414-ED5B-CF56-16C0-BD18027062C0} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} {150CAA5A-0177-6A66-AA92-CFCB96DC2D49} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} {2F8724C6-1BC3-2730-84D5-3F277030D04A} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231} - {811F1997-6DDA-0843-1692-818D022C53D3} = {F3AB4ED5-5F37-BC99-6848-3F8ED452189A} + {E145B2B8-CD13-A6BE-B6A7-16E5A2148223} = {F3AB4ED5-5F37-BC99-6848-3F8ED452189A} {61F7EB00-7281-4BF3-9470-7C2EA92620C3} = {57B5AA5E-C340-1823-CC51-9B17385C7423} {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} = {57B5AA5E-C340-1823-CC51-9B17385C7423} {222F7498-B40C-4F3F-A704-DDEB91A4484A} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13} diff --git a/source/core/core.vcxproj b/source/core/core.vcxproj deleted file mode 100644 index 528c7c590..000000000 --- a/source/core/core.vcxproj +++ /dev/null @@ -1,263 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - true - Win32Proj - core - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\core\ - core - .lib - - - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\core\ - core - .lib - - - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\core\ - core - .lib - - - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\core\ - core - .lib - - - - NotUsing - Level4 - true - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - true - - - - - NotUsing - Level4 - true - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - true - - - - - NotUsing - Level4 - true - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - true - - - - - NotUsing - Level4 - true - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/core/core.vcxproj.filters b/source/core/core.vcxproj.filters deleted file mode 100644 index fc5cede9e..000000000 --- a/source/core/core.vcxproj.filters +++ /dev/null @@ -1,263 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - 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 - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header 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 - - - \ No newline at end of file diff --git a/source/miniz/miniz.vcxproj b/source/miniz/miniz.vcxproj deleted file mode 100644 index 334b33c06..000000000 --- a/source/miniz/miniz.vcxproj +++ /dev/null @@ -1,165 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F} - true - Win32Proj - miniz - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\miniz\ - miniz - .lib - - - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\miniz\ - miniz - .lib - - - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\miniz\ - miniz - .lib - - - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\miniz\ - miniz - .lib - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/source/slang-glslang/slang-glslang.vcxproj b/source/slang-glslang/slang-glslang.vcxproj deleted file mode 100644 index 5a6508f1d..000000000 --- a/source/slang-glslang/slang-glslang.vcxproj +++ /dev/null @@ -1,435 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C495878A-832C-485B-B347-0998A90CC936} - true - Win32Proj - slang-glslang - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-glslang\ - slang-glslang - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-glslang\ - slang-glslang - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-glslang\ - slang-glslang - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-glslang\ - slang-glslang - .dll - - - - NotUsing - Level3 - _DEBUG;ENABLE_OPT=1;AMD_EXTENSIONS;NV_EXTENSIONS;%(PreprocessorDefinitions) - ..\..\external\glslang;..\..\external\spirv-tools;..\..\external\spirv-tools\include;..\..\external\spirv-headers\include;..\..\external\spirv-tools\build;..\..\external\spirv-tools-generated;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - $(IntDir)/%(RelativeDir)/$(Configuration)/ - - - Windows - true - ..\..\bin\windows-x86\debug\slang-glslang.lib - - - - - NotUsing - Level3 - _DEBUG;ENABLE_OPT=1;AMD_EXTENSIONS;NV_EXTENSIONS;%(PreprocessorDefinitions) - ..\..\external\glslang;..\..\external\spirv-tools;..\..\external\spirv-tools\include;..\..\external\spirv-headers\include;..\..\external\spirv-tools\build;..\..\external\spirv-tools-generated;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - $(IntDir)/%(RelativeDir)/$(Configuration)/ - - - Windows - true - ..\..\bin\windows-x64\debug\slang-glslang.lib - - - - - NotUsing - Level3 - NDEBUG;ENABLE_OPT=1;AMD_EXTENSIONS;NV_EXTENSIONS;%(PreprocessorDefinitions) - ..\..\external\glslang;..\..\external\spirv-tools;..\..\external\spirv-tools\include;..\..\external\spirv-headers\include;..\..\external\spirv-tools\build;..\..\external\spirv-tools-generated;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - $(IntDir)/%(RelativeDir)/$(Configuration)/ - - - Windows - true - true - ..\..\bin\windows-x86\release\slang-glslang.lib - - - - - NotUsing - Level3 - NDEBUG;ENABLE_OPT=1;AMD_EXTENSIONS;NV_EXTENSIONS;%(PreprocessorDefinitions) - ..\..\external\glslang;..\..\external\spirv-tools;..\..\external\spirv-tools\include;..\..\external\spirv-headers\include;..\..\external\spirv-tools\build;..\..\external\spirv-tools-generated;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - $(IntDir)/%(RelativeDir)/$(Configuration)/ - - - Windows - true - true - ..\..\bin\windows-x64\release\slang-glslang.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/slang-glslang/slang-glslang.vcxproj.filters b/source/slang-glslang/slang-glslang.vcxproj.filters deleted file mode 100644 index a922440de..000000000 --- a/source/slang-glslang/slang-glslang.vcxproj.filters +++ /dev/null @@ -1,798 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - {0f17aa89-8c4d-488f-9577-c32b50f9b081} - - - {79d3e53a-e1bb-41a8-9a8c-65ed15905fce} - - - {cbc707d5-9925-4cfc-a98f-24edb5d66cfa} - - - {525e4d11-95f7-4087-af42-3148dd340ae1} - - - {b2f07a8e-0eda-425b-b3d1-bf3e95a84878} - - - - - 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 - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\opt - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\val - - - Source Files\spirv-tools\util - - - Source Files\spirv-tools\util - - - Source Files\spirv-tools\util - - - Source Files\spirv-tools\util - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - Source Files\glslang - - - \ No newline at end of file diff --git a/source/slang/run-generators.vcxproj b/source/slang/run-generators.vcxproj deleted file mode 100644 index e38f9dc2d..000000000 --- a/source/slang/run-generators.vcxproj +++ /dev/null @@ -1,246 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {811F1997-6DDA-0843-1692-818D022C53D3} - true - Win32Proj - run-generators - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\run-generators\ - run-generators - .lib - - - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\run-generators\ - run-generators - .lib - - - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\run-generators\ - run-generators - .lib - - - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\run-generators\ - run-generators - .lib - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - - - - - - - - - - Document - "../../bin/windows-x86/debug/slang-embed" %(Identity) - "../../bin/windows-x64/debug/slang-embed" %(Identity) - "../../bin/windows-x86/release/slang-embed" %(Identity) - "../../bin/windows-x64/release/slang-embed" %(Identity) - ../../prelude/slang-cpp-prelude.h.cpp - slang-embed %(Identity) - ../../bin/windows-x86/debug/slang-embed.exe - ../../bin/windows-x64/debug/slang-embed.exe - ../../bin/windows-x86/release/slang-embed.exe - ../../bin/windows-x64/release/slang-embed.exe - - - Document - "../../bin/windows-x86/debug/slang-embed" %(Identity) - "../../bin/windows-x64/debug/slang-embed" %(Identity) - "../../bin/windows-x86/release/slang-embed" %(Identity) - "../../bin/windows-x64/release/slang-embed" %(Identity) - ../../prelude/slang-cuda-prelude.h.cpp - slang-embed %(Identity) - ../../bin/windows-x86/debug/slang-embed.exe - ../../bin/windows-x64/debug/slang-embed.exe - ../../bin/windows-x86/release/slang-embed.exe - ../../bin/windows-x64/release/slang-embed.exe - - - Document - "../../bin/windows-x86/debug/slang-embed" %(Identity) - "../../bin/windows-x64/debug/slang-embed" %(Identity) - "../../bin/windows-x86/release/slang-embed" %(Identity) - "../../bin/windows-x64/release/slang-embed" %(Identity) - ../../prelude/slang-hlsl-prelude.h.cpp - slang-embed %(Identity) - ../../bin/windows-x86/debug/slang-embed.exe - ../../bin/windows-x64/debug/slang-embed.exe - ../../bin/windows-x86/release/slang-embed.exe - ../../bin/windows-x64/release/slang-embed.exe - - - Document - "../../bin/windows-x86/debug/slang-generate" %(Identity) - "../../bin/windows-x64/debug/slang-generate" %(Identity) - "../../bin/windows-x86/release/slang-generate" %(Identity) - "../../bin/windows-x64/release/slang-generate" %(Identity) - core.meta.slang.h - slang-generate %(Identity) - ../../bin/windows-x86/debug/slang-generate.exe - ../../bin/windows-x64/debug/slang-generate.exe - ../../bin/windows-x86/release/slang-generate.exe - ../../bin/windows-x64/release/slang-generate.exe - - - Document - "../../bin/windows-x86/debug/slang-generate" %(Identity) - "../../bin/windows-x64/debug/slang-generate" %(Identity) - "../../bin/windows-x86/release/slang-generate" %(Identity) - "../../bin/windows-x64/release/slang-generate" %(Identity) - hlsl.meta.slang.h - slang-generate %(Identity) - ../../bin/windows-x86/debug/slang-generate.exe - ../../bin/windows-x64/debug/slang-generate.exe - ../../bin/windows-x86/release/slang-generate.exe - ../../bin/windows-x64/release/slang-generate.exe - - - Document - "../../bin/windows-x86/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS - "../../bin/windows-x64/debug/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS - "../../bin/windows-x86/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS - "../../bin/windows-x64/release/slang-cpp-extractor" -d %(RootDir)%(Directory) slang-ast-support-types.h slang-ast-base.h slang-ast-decl.h slang-ast-expr.h slang-ast-modifier.h slang-ast-stmt.h slang-ast-type.h slang-ast-val.h -strip-prefix slang- -o slang-generated -output-fields -mark-suffix _CLASS - slang-generated-obj.h;slang-generated-obj-macro.h;slang-generated-ast.h;slang-generated-ast-macro.h;slang-generated-value.h;slang-generated-value-macro.h - C++ Extractor %(Identity) - ../../bin/windows-x86/debug/slang-cpp-extractor.exe;slang-ast-support-types.h;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h - ../../bin/windows-x64/debug/slang-cpp-extractor.exe;slang-ast-support-types.h;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h - ../../bin/windows-x86/release/slang-cpp-extractor.exe;slang-ast-support-types.h;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h - ../../bin/windows-x64/release/slang-cpp-extractor.exe;slang-ast-support-types.h;slang-ast-base.h;slang-ast-decl.h;slang-ast-expr.h;slang-ast-modifier.h;slang-ast-stmt.h;slang-ast-type.h;slang-ast-val.h - - - - - - \ No newline at end of file diff --git a/source/slang/run-generators.vcxproj.filters b/source/slang/run-generators.vcxproj.filters deleted file mode 100644 index e8ec8394a..000000000 --- a/source/slang/run-generators.vcxproj.filters +++ /dev/null @@ -1,44 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Header Files - - - \ No newline at end of file diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp new file mode 100644 index 000000000..ea6c7820b --- /dev/null +++ b/source/slang/slang-api.cpp @@ -0,0 +1,698 @@ +// slang-api.cpp + +#include "slang-compiler.h" + +#include "slang-repro.h" + +#include "../../slang-tag-version.h" + +// implementation of C interface + +SLANG_API SlangSession* spCreateSession(const char*) +{ + Slang::ComPtr globalSession; + if (SLANG_FAILED(slang_createGlobalSession(SLANG_API_VERSION, globalSession.writeRef()))) + { + return nullptr; + } + // Will be returned with a refcount of 1 + return globalSession.detach(); +} + +SLANG_API SlangResult slang_createGlobalSession( + SlangInt apiVersion, + slang::IGlobalSession** outGlobalSession) +{ + Slang::ComPtr globalSession; + SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(apiVersion, globalSession.writeRef())); + SLANG_RETURN_ON_FAIL(globalSession->compileStdLib()); + *outGlobalSession = globalSession.detach(); + return SLANG_OK; +} + +SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib( + SlangInt apiVersion, + slang::IGlobalSession** outGlobalSession) +{ + if (apiVersion != 0) + return SLANG_E_NOT_IMPLEMENTED; + + // Create the session + Slang::Session* globalSession = new Slang::Session(); + // Put an interface ref on it + Slang::ComPtr result(globalSession); + + // Initialize it + globalSession->init(); + + *outGlobalSession = result.detach(); + return SLANG_OK; +} + +SLANG_API void spDestroySession( + SlangSession* inSession) +{ + if (!inSession) return; + + Slang::Session* session = Slang::asInternal(inSession); + // It is assumed there is only a single reference on the session (the one placed + // with spCreateSession) if this function is called + SLANG_ASSERT(session->debugGetReferenceCount() == 1); + // Release + session->release(); +} + +SLANG_API const char* spGetBuildTagString() +{ + return SLANG_TAG_VERSION; +} + +SLANG_API void spAddBuiltins( + SlangSession* session, + char const* sourcePath, + char const* sourceString) +{ + session->addBuiltins(sourcePath, sourceString); +} + +SLANG_API void spSessionSetSharedLibraryLoader( + SlangSession* session, + ISlangSharedLibraryLoader* loader) +{ + session->setSharedLibraryLoader(loader); +} + +SLANG_API ISlangSharedLibraryLoader* spSessionGetSharedLibraryLoader( + SlangSession* session) +{ + return session->getSharedLibraryLoader(); +} + +SLANG_API SlangResult spSessionCheckCompileTargetSupport( + SlangSession* session, + SlangCompileTarget target) +{ + return session->checkCompileTargetSupport(target); +} + +SLANG_API SlangResult spSessionCheckPassThroughSupport( + SlangSession* session, + SlangPassThrough passThrough) +{ + return session->checkPassThroughSupport(passThrough); +} + +SLANG_API SlangCompileRequest* spCreateCompileRequest( + SlangSession* session) +{ + slang::ICompileRequest* request = nullptr; + // Will return with suitable ref count + session->createCompileRequest(&request); + return request; +} + +SLANG_API SlangProfileID spFindProfile( + SlangSession* session, + char const* name) +{ + return session->findProfile(name); +} + +/* !!!!!!!!!!!!!!!!!!SlangCompileRequest API!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +/*! +@brief Destroy a compile request. +*/ +SLANG_API void spDestroyCompileRequest( + slang::ICompileRequest* request) +{ + if (request) + { + request->release(); + } +} + +/* All other functions just call into the ICompileResult interface. */ + +SLANG_API void spSetFileSystem( + slang::ICompileRequest* request, + ISlangFileSystem* fileSystem) +{ + SLANG_ASSERT(request); + request->setFileSystem(fileSystem); +} + +SLANG_API void spSetCompileFlags( + slang::ICompileRequest* request, + SlangCompileFlags flags) +{ + SLANG_ASSERT(request); + request->setCompileFlags(flags); +} + +SLANG_API void spSetDumpIntermediates( + slang::ICompileRequest* request, + int enable) +{ + SLANG_ASSERT(request); + request->setDumpIntermediates(enable); +} + +SLANG_API void spSetDumpIntermediatePrefix( + slang::ICompileRequest* request, + const char* prefix) +{ + SLANG_ASSERT(request); + request->setDumpIntermediatePrefix(prefix); +} + +SLANG_API void spSetLineDirectiveMode( + slang::ICompileRequest* request, + SlangLineDirectiveMode mode) +{ + SLANG_ASSERT(request); + request->setLineDirectiveMode(mode); +} + +SLANG_API void spSetCommandLineCompilerMode( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + request->setCommandLineCompilerMode(); +} + +SLANG_API void spSetCodeGenTarget( + slang::ICompileRequest* request, + SlangCompileTarget target) +{ + SLANG_ASSERT(request); + request->setCodeGenTarget(target); +} + +SLANG_API int spAddCodeGenTarget( + slang::ICompileRequest* request, + SlangCompileTarget target) +{ + SLANG_ASSERT(request); + return request->addCodeGenTarget(target); +} + +SLANG_API void spSetTargetProfile( + slang::ICompileRequest* request, + int targetIndex, + SlangProfileID profile) +{ + SLANG_ASSERT(request); + request->setTargetProfile(targetIndex, profile); +} + +SLANG_API void spSetTargetFlags( + slang::ICompileRequest* request, + int targetIndex, + SlangTargetFlags flags) +{ + SLANG_ASSERT(request); + request->setTargetFlags(targetIndex, flags); +} + +SLANG_API void spSetTargetFloatingPointMode( + slang::ICompileRequest* request, + int targetIndex, + SlangFloatingPointMode mode) +{ + SLANG_ASSERT(request); + request->setTargetFloatingPointMode(targetIndex, mode); +} + +SLANG_API void spSetMatrixLayoutMode( + slang::ICompileRequest* request, + SlangMatrixLayoutMode mode) +{ + SLANG_ASSERT(request); + request->setMatrixLayoutMode(mode); +} + +SLANG_API void spSetTargetMatrixLayoutMode( + slang::ICompileRequest* request, + int targetIndex, + SlangMatrixLayoutMode mode) +{ + SLANG_ASSERT(request); + request->setTargetMatrixLayoutMode(targetIndex, mode); +} + +SLANG_API void spSetDebugInfoLevel( + slang::ICompileRequest* request, + SlangDebugInfoLevel level) +{ + SLANG_ASSERT(request); + request->setDebugInfoLevel(level); +} + +SLANG_API void spSetOptimizationLevel( + slang::ICompileRequest* request, + SlangOptimizationLevel level) +{ + SLANG_ASSERT(request); + request->setOptimizationLevel(level); +} + +SLANG_API void spSetOutputContainerFormat( + slang::ICompileRequest* request, + SlangContainerFormat format) +{ + SLANG_ASSERT(request); + request->setOutputContainerFormat(format); +} + +SLANG_API void spSetPassThrough( + slang::ICompileRequest* request, + SlangPassThrough passThrough) +{ + SLANG_ASSERT(request); + request->setPassThrough(passThrough); +} + +SLANG_API void spSetDiagnosticCallback( + slang::ICompileRequest* request, + SlangDiagnosticCallback callback, + void const* userData) +{ + SLANG_ASSERT(request); + request->setDiagnosticCallback(callback, userData); +} + +SLANG_API void spSetWriter( + slang::ICompileRequest* request, + SlangWriterChannel chan, + ISlangWriter* writer) +{ + SLANG_ASSERT(request); + request->setWriter(chan, writer); +} + +SLANG_API ISlangWriter* spGetWriter( + slang::ICompileRequest* request, + SlangWriterChannel chan) +{ + SLANG_ASSERT(request); + return request->getWriter(chan); +} + +SLANG_API void spAddSearchPath( + slang::ICompileRequest* request, + const char* path) +{ + SLANG_ASSERT(request); + request->addSearchPath(path); +} + +SLANG_API void spAddPreprocessorDefine( + slang::ICompileRequest* request, + const char* key, + const char* value) +{ + SLANG_ASSERT(request); + request->addPreprocessorDefine(key, value); +} + +SLANG_API char const* spGetDiagnosticOutput( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->getDiagnosticOutput(); +} + +SLANG_API SlangResult spGetDiagnosticOutputBlob( + slang::ICompileRequest* request, + ISlangBlob** outBlob) +{ + SLANG_ASSERT(request); + return request->getDiagnosticOutputBlob(outBlob); +} + +// New-fangled compilation API + +SLANG_API int spAddTranslationUnit( + slang::ICompileRequest* request, + SlangSourceLanguage language, + char const* inName) +{ + SLANG_ASSERT(request); + return request->addTranslationUnit(language, inName); +} + +SLANG_API void spSetDefaultModuleName( + slang::ICompileRequest* request, + const char* defaultModuleName) +{ + SLANG_ASSERT(request); + request->setDefaultModuleName(defaultModuleName); +} + +SLANG_API SlangResult spAddLibraryReference( + slang::ICompileRequest* request, + const void* libData, + size_t libDataSize) +{ + SLANG_ASSERT(request); + return request->addLibraryReference(libData, libDataSize); +} + +SLANG_API void spTranslationUnit_addPreprocessorDefine( + slang::ICompileRequest* request, + int translationUnitIndex, + const char* key, + const char* value) +{ + SLANG_ASSERT(request); + request->addTranslationUnitPreprocessorDefine(translationUnitIndex, key, value); +} + +SLANG_API void spAddTranslationUnitSourceFile( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* path) +{ + SLANG_ASSERT(request); + request->addTranslationUnitSourceFile(translationUnitIndex, path); +} + +SLANG_API void spAddTranslationUnitSourceString( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* path, + char const* source) +{ + SLANG_ASSERT(request); + request->addTranslationUnitSourceString(translationUnitIndex, path, source); +} + +SLANG_API void spAddTranslationUnitSourceStringSpan( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* path, + char const* sourceBegin, + char const* sourceEnd) +{ + SLANG_ASSERT(request); + request->addTranslationUnitSourceStringSpan(translationUnitIndex, path, sourceBegin, sourceEnd); +} + +SLANG_API void spAddTranslationUnitSourceBlob( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* path, + ISlangBlob* sourceBlob) +{ + SLANG_ASSERT(request); + request->addTranslationUnitSourceBlob(translationUnitIndex, path, sourceBlob); +} + +SLANG_API int spAddEntryPoint( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* name, + SlangStage stage) +{ + SLANG_ASSERT(request); + return request->addEntryPoint(translationUnitIndex, name, stage); +} + +SLANG_API int spAddEntryPointEx( + slang::ICompileRequest* request, + int translationUnitIndex, + char const* name, + SlangStage stage, + int genericParamTypeNameCount, + char const ** genericParamTypeNames) +{ + SLANG_ASSERT(request); + return request->addEntryPointEx(translationUnitIndex, name, stage, genericParamTypeNameCount, genericParamTypeNames); +} + +SLANG_API SlangResult spSetGlobalGenericArgs( + slang::ICompileRequest* request, + int genericArgCount, + char const** genericArgs) +{ + SLANG_ASSERT(request); + return request->setGlobalGenericArgs(genericArgCount, genericArgs); +} + +SLANG_API SlangResult spSetTypeNameForGlobalExistentialTypeParam( + slang::ICompileRequest* request, + int slotIndex, + char const* typeName) +{ + SLANG_ASSERT(request); + return request->setTypeNameForGlobalExistentialTypeParam(slotIndex, typeName); +} + +SLANG_API SlangResult spSetTypeNameForEntryPointExistentialTypeParam( + slang::ICompileRequest* request, + int entryPointIndex, + int slotIndex, + char const* typeName) +{ + SLANG_ASSERT(request); + return request->setTypeNameForEntryPointExistentialTypeParam(entryPointIndex, slotIndex, typeName); +} + +SLANG_API SlangResult spCompile( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->compile(); +} + +SLANG_API int +spGetDependencyFileCount( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->getDependencyFileCount(); +} + +SLANG_API char const* +spGetDependencyFilePath( + slang::ICompileRequest* request, + int index) +{ + SLANG_ASSERT(request); + return request->getDependencyFilePath(index); +} + +SLANG_API int +spGetTranslationUnitCount( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->getTranslationUnitCount(); +} + +SLANG_API void const* spGetEntryPointCode( + slang::ICompileRequest* request, + int entryPointIndex, + size_t* outSize) +{ + SLANG_ASSERT(request); + return request->getEntryPointCode(entryPointIndex, outSize); +} + +SLANG_API SlangResult spGetEntryPointCodeBlob( + slang::ICompileRequest* request, + int entryPointIndex, + int targetIndex, + ISlangBlob** outBlob) +{ + SLANG_ASSERT(request); + return request->getEntryPointCodeBlob(entryPointIndex, targetIndex, outBlob); +} + +SLANG_API SlangResult spGetEntryPointHostCallable( + slang::ICompileRequest* request, + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary) +{ + SLANG_ASSERT(request); + return request->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary); +} + +SLANG_API SlangResult spGetTargetCodeBlob( + slang::ICompileRequest* request, + int targetIndex, + ISlangBlob** outBlob) +{ + SLANG_ASSERT(request); + return request->getTargetCodeBlob(targetIndex, outBlob); +} + +SLANG_API SlangResult spGetTargetHostCallable( + slang::ICompileRequest* request, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary) +{ + SLANG_ASSERT(request); + return request->getTargetHostCallable(targetIndex, outSharedLibrary); +} + +SLANG_API char const* spGetEntryPointSource( + slang::ICompileRequest* request, + int entryPointIndex) +{ + SLANG_ASSERT(request); + return request->getEntryPointSource(entryPointIndex); +} + +SLANG_API void const* spGetCompileRequestCode( + slang::ICompileRequest* request, + size_t* outSize) +{ + SLANG_ASSERT(request); + return request->getCompileRequestCode(outSize); +} + +SLANG_API SlangResult spGetContainerCode( + slang::ICompileRequest* request, + ISlangBlob** outBlob) +{ + SLANG_ASSERT(request); + return request->getContainerCode(outBlob); +} + +SLANG_API SlangResult spLoadRepro( + slang::ICompileRequest* request, + ISlangFileSystem* fileSystem, + const void* data, + size_t size) +{ + SLANG_ASSERT(request); + return request->loadRepro(fileSystem, data, size); +} + +SLANG_API SlangResult spSaveRepro( + slang::ICompileRequest* request, + ISlangBlob** outBlob) +{ + SLANG_ASSERT(request); + return request->saveRepro(outBlob); +} + +SLANG_API SlangResult spEnableReproCapture( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->enableReproCapture(); +} + +SLANG_API SlangResult spCompileRequest_getProgram( + slang::ICompileRequest* request, + slang::IComponentType** outProgram) +{ + SLANG_ASSERT(request); + return request->getProgram(outProgram); +} + +SLANG_API SlangResult spCompileRequest_getModule( + slang::ICompileRequest* request, + SlangInt translationUnitIndex, + slang::IModule** outModule) +{ + SLANG_ASSERT(request); + return request->getModule(translationUnitIndex, outModule); +} + +SLANG_API SlangResult spCompileRequest_getSession( + slang::ICompileRequest* request, + slang::ISession** outSession) +{ + SLANG_ASSERT(request); + return request->getSession(outSession); +} + +SLANG_API SlangResult spCompileRequest_getEntryPoint( + slang::ICompileRequest* request, + SlangInt entryPointIndex, + slang::IComponentType** outEntryPoint) +{ + SLANG_ASSERT(request); + return request->getEntryPoint(entryPointIndex, outEntryPoint); +} + +// Get the output code associated with a specific translation unit +SLANG_API char const* spGetTranslationUnitSource( + slang::ICompileRequest* /*request*/, + int /*translationUnitIndex*/) +{ + fprintf(stderr, "DEPRECATED: spGetTranslationUnitSource()\n"); + return nullptr; +} + +SLANG_API SlangResult spProcessCommandLineArguments( + SlangCompileRequest* request, + char const* const* args, + int argCount) +{ + return request->processCommandLineArguments(args, argCount); +} + +// Reflection API + +SLANG_API SlangReflection* spGetReflection( + slang::ICompileRequest* request) +{ + SLANG_ASSERT(request); + return request->getReflection(); +} + +// ... rest of reflection API implementation is in `Reflection.cpp` + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! Session !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +SLANG_API SlangResult spExtractRepro(SlangSession* session, const void* reproData, size_t reproDataSize, ISlangMutableFileSystem* fileSystem) +{ + using namespace Slang; + SLANG_UNUSED(session); + + List buffer; + { + MemoryStreamBase memoryStream(FileAccess::Read, reproData, reproDataSize); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&memoryStream, buffer)); + } + + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); + + ReproUtil::RequestState* requestState = ReproUtil::getRequest(buffer); + return ReproUtil::extractFiles(base, requestState, fileSystem); +} + +SLANG_API SlangResult spLoadReproAsFileSystem( + SlangSession* session, + const void* reproData, + size_t reproDataSize, + ISlangFileSystem* replaceFileSystem, + ISlangFileSystemExt** outFileSystem) +{ + using namespace Slang; + + SLANG_UNUSED(session); + + MemoryStreamBase stream(FileAccess::Read, reproData, reproDataSize); + + List buffer; + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&stream, buffer)); + + auto requestState = ReproUtil::getRequest(buffer); + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); + + RefPtr cacheFileSystem; + SLANG_RETURN_ON_FAIL(ReproUtil::loadFileSystem(base, requestState, replaceFileSystem, cacheFileSystem)); + + *outFileSystem = cacheFileSystem.detach(); + return SLANG_OK; +} + diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 0d92fbacc..158aac141 100755 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -17,7 +17,6 @@ #include "slang-parser.h" #include "slang-preprocessor.h" #include "slang-type-layout.h" -#include "slang-reflection.h" #include "slang-emit.h" #include "slang-glsl-extension-tracker.h" diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp new file mode 100644 index 000000000..61990b7d0 --- /dev/null +++ b/source/slang/slang-reflection-api.cpp @@ -0,0 +1,2507 @@ +// slang-reflection-api.cpp + +#include "../core/slang-basic.h" +#include "slang-syntax.h" + +#include "../../slang.h" + +#include "slang-compiler.h" +#include "slang-type-layout.h" +#include "slang-syntax.h" +#include + +// Don't signal errors for stuff we don't implement here, +// and instead just try to return things defensively +// +// Slang developers can switch this when debugging. +#define SLANG_REFLECTION_UNEXPECTED() do {} while(0) + +namespace Slang +{ + +// Conversion routines to help with strongly-typed reflection API + +static inline UserDefinedAttribute* convert(SlangReflectionUserAttribute* attrib) +{ + return (UserDefinedAttribute*)attrib; +} +static inline SlangReflectionUserAttribute* convert(UserDefinedAttribute* attrib) +{ + return (SlangReflectionUserAttribute*)attrib; +} + +static inline Type* convert(SlangReflectionType* type) +{ + return (Type*) type; +} + +static inline SlangReflectionType* convert(Type* type) +{ + return (SlangReflectionType*) type; +} + +static inline TypeLayout* convert(SlangReflectionTypeLayout* type) +{ + return (TypeLayout*) type; +} + +static inline SlangReflectionTypeLayout* convert(TypeLayout* type) +{ + return (SlangReflectionTypeLayout*) type; +} + +static inline SpecializationParamLayout* convert(SlangReflectionTypeParameter * typeParam) +{ + return (SpecializationParamLayout*) typeParam; +} + +static inline VarDeclBase* convert(SlangReflectionVariable* var) +{ + return (VarDeclBase*) var; +} + +static inline SlangReflectionVariable* convert(VarDeclBase* var) +{ + return (SlangReflectionVariable*) var; +} + +static inline VarLayout* convert(SlangReflectionVariableLayout* var) +{ + return (VarLayout*) var; +} + +static inline SlangReflectionVariableLayout* convert(VarLayout* var) +{ + return (SlangReflectionVariableLayout*) var; +} + +static inline EntryPointLayout* convert(SlangReflectionEntryPoint* entryPoint) +{ + return (EntryPointLayout*) entryPoint; +} + +static inline SlangReflectionEntryPoint* convert(EntryPointLayout* entryPoint) +{ + return (SlangReflectionEntryPoint*) entryPoint; +} + +static inline ProgramLayout* convert(SlangReflection* program) +{ + return (ProgramLayout*) program; +} + +static inline SlangReflection* convert(ProgramLayout* program) +{ + return (SlangReflection*) program; +} + +// user attribute + +static unsigned int getUserAttributeCount(Decl* decl) +{ + unsigned int count = 0; + for (auto x : decl->getModifiersOfType()) + { + SLANG_UNUSED(x); + count++; + } + return count; +} + +static SlangReflectionUserAttribute* findUserAttributeByName(Session* session, Decl* decl, const char* name) +{ + auto nameObj = session->tryGetNameObj(name); + for (auto x : decl->getModifiersOfType()) + { + if (x->keywordName == nameObj) + return (SlangReflectionUserAttribute*)(x); + } + return nullptr; +} + +static SlangReflectionUserAttribute* getUserAttributeByIndex(Decl* decl, unsigned int index) +{ + unsigned int id = 0; + for (auto x : decl->getModifiersOfType()) + { + if (id == index) + return convert(x); + id++; + } + return nullptr; +} + + +// Attempt "do what I mean" remapping from the parameter category the user asked about, +// over to a parameter category that they might have meant. +static SlangParameterCategory maybeRemapParameterCategory( + TypeLayout* typeLayout, + SlangParameterCategory category) +{ + // Do we have an entry for the category they asked about? Then use that. + if (typeLayout->FindResourceInfo(LayoutResourceKind(category))) + return category; + + // Do we have an entry for the `DescriptorTableSlot` category? + if (typeLayout->FindResourceInfo(LayoutResourceKind::DescriptorTableSlot)) + { + // Is the category they were asking about one that makes sense for the type + // of this variable? + Type* type = typeLayout->getType(); + while (auto arrayType = as(type)) + type = arrayType->baseType; + switch (spReflectionType_GetKind(convert(type))) + { + case SLANG_TYPE_KIND_CONSTANT_BUFFER: + if (category == SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER) + return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; + break; + + case SLANG_TYPE_KIND_RESOURCE: + if (category == SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE) + return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; + break; + + case SLANG_TYPE_KIND_SAMPLER_STATE: + if (category == SLANG_PARAMETER_CATEGORY_SAMPLER_STATE) + return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; + break; + + // TODO: implement more helpers here + + default: + break; + } + } + + return category; +} + +// Helpers for getting parameter count + +static unsigned getParameterCount(RefPtr typeLayout) +{ + if (auto parameterGroupLayout = as(typeLayout)) + { + typeLayout = parameterGroupLayout->offsetElementTypeLayout; + } + + if (auto structLayout = as(typeLayout)) + { + return (unsigned)structLayout->fields.getCount(); + } + + return 0; +} + +static VarLayout* getParameterByIndex(RefPtr typeLayout, unsigned index) +{ + if (auto parameterGroupLayout = as(typeLayout)) + { + typeLayout = parameterGroupLayout->offsetElementTypeLayout; + } + + if (auto structLayout = as(typeLayout)) + { + return structLayout->fields[index]; + } + + return 0; +} + +static SlangParameterCategory getParameterCategory( + LayoutResourceKind kind) +{ + return SlangParameterCategory(kind); +} + +static SlangParameterCategory getParameterCategory( + TypeLayout* typeLayout) +{ + auto resourceInfoCount = typeLayout->resourceInfos.getCount(); + if (resourceInfoCount == 1) + { + return getParameterCategory(typeLayout->resourceInfos[0].kind); + } + else if (resourceInfoCount == 0) + { + // TODO: can this ever happen? + return SLANG_PARAMETER_CATEGORY_NONE; + } + return SLANG_PARAMETER_CATEGORY_MIXED; +} + +static bool hasDefaultConstantBuffer(ScopeLayout* layout) +{ + auto typeLayout = layout->parametersLayout->getTypeLayout(); + return as(typeLayout) != nullptr; +} + + +} // namespace Slang + +using namespace Slang; + +// Implementation to back public-facing reflection API + +SLANG_API char const* spReflectionUserAttribute_GetName(SlangReflectionUserAttribute* attrib) +{ + auto userAttr = convert(attrib); + if (!userAttr) return nullptr; + return userAttr->getKeywordName()->text.getBuffer(); +} +SLANG_API unsigned int spReflectionUserAttribute_GetArgumentCount(SlangReflectionUserAttribute* attrib) +{ + auto userAttr = convert(attrib); + if (!userAttr) return 0; + return (unsigned int)userAttr->args.getCount(); +} +SlangReflectionType* spReflectionUserAttribute_GetArgumentType(SlangReflectionUserAttribute* attrib, unsigned int index) +{ + auto userAttr = convert(attrib); + if (!userAttr) return nullptr; + return convert(userAttr->args[index]->type.type); +} +SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueInt(SlangReflectionUserAttribute* attrib, unsigned int index, int * rs) +{ + auto userAttr = convert(attrib); + if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; + if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; + NodeBase* val = nullptr; + if (userAttr->intArgVals.TryGetValue(index, val)) + { + *rs = (int)as(val)->value; + return 0; + } + return SLANG_ERROR_INVALID_PARAMETER; +} +SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueFloat(SlangReflectionUserAttribute* attrib, unsigned int index, float * rs) +{ + auto userAttr = convert(attrib); + if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; + if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; + if (auto cexpr = as(userAttr->args[index])) + { + *rs = (float)cexpr->value; + return 0; + } + return SLANG_ERROR_INVALID_PARAMETER; +} +SLANG_API const char* spReflectionUserAttribute_GetArgumentValueString(SlangReflectionUserAttribute* attrib, unsigned int index, size_t* bufLen) +{ + auto userAttr = convert(attrib); + if (!userAttr) return nullptr; + if (index >= (unsigned int)userAttr->args.getCount()) return nullptr; + if (auto cexpr = as(userAttr->args[index])) + { + if (bufLen) + *bufLen = cexpr->token.getContentLength(); + return cexpr->token.getContent().begin(); + } + return nullptr; +} + +// type Reflection + +SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return SLANG_TYPE_KIND_NONE; + + // TODO(tfoley: Don't emit the same type more than once... + + if (auto basicType = as(type)) + { + return SLANG_TYPE_KIND_SCALAR; + } + else if (auto vectorType = as(type)) + { + return SLANG_TYPE_KIND_VECTOR; + } + else if (auto matrixType = as(type)) + { + return SLANG_TYPE_KIND_MATRIX; + } + else if (auto parameterBlockType = as(type)) + { + return SLANG_TYPE_KIND_PARAMETER_BLOCK; + } + else if (auto constantBufferType = as(type)) + { + return SLANG_TYPE_KIND_CONSTANT_BUFFER; + } + else if( auto streamOutputType = as(type) ) + { + return SLANG_TYPE_KIND_OUTPUT_STREAM; + } + else if (as(type)) + { + return SLANG_TYPE_KIND_TEXTURE_BUFFER; + } + else if (as(type)) + { + return SLANG_TYPE_KIND_SHADER_STORAGE_BUFFER; + } + else if (auto samplerStateType = as(type)) + { + return SLANG_TYPE_KIND_SAMPLER_STATE; + } + else if (auto textureType = as(type)) + { + return SLANG_TYPE_KIND_RESOURCE; + } + else if (auto feedbackType = as(type)) + { + return SLANG_TYPE_KIND_FEEDBACK; + } + // TODO: need a better way to handle this stuff... +#define CASE(TYPE) \ + else if(as(type)) do { \ + return SLANG_TYPE_KIND_RESOURCE; \ + } while(0) + + CASE(HLSLStructuredBufferType); + CASE(HLSLRWStructuredBufferType); + CASE(HLSLRasterizerOrderedStructuredBufferType); + CASE(HLSLAppendStructuredBufferType); + CASE(HLSLConsumeStructuredBufferType); + CASE(HLSLByteAddressBufferType); + CASE(HLSLRWByteAddressBufferType); + CASE(HLSLRasterizerOrderedByteAddressBufferType); + CASE(UntypedBufferResourceType); +#undef CASE + + else if (auto arrayType = as(type)) + { + return SLANG_TYPE_KIND_ARRAY; + } + else if( auto declRefType = as(type) ) + { + const auto& declRef = declRefType->declRef; + if(declRef.is() ) + { + return SLANG_TYPE_KIND_STRUCT; + } + else if (declRef.is()) + { + return SLANG_TYPE_KIND_GENERIC_TYPE_PARAMETER; + } + else if (declRef.is()) + { + return SLANG_TYPE_KIND_INTERFACE; + } + else if (declRef.is()) + { + // This is a reference to an entry point + return SLANG_TYPE_KIND_STRUCT; + } + } + else if( auto specializedType = as(type) ) + { + return SLANG_TYPE_KIND_SPECIALIZED; + } + else if (auto errorType = as(type)) + { + // This means we saw a type we didn't understand in the user's code + return SLANG_TYPE_KIND_NONE; + } + + SLANG_REFLECTION_UNEXPECTED(); + return SLANG_TYPE_KIND_NONE; +} + +SLANG_API unsigned int spReflectionType_GetFieldCount(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + // TODO: maybe filter based on kind + + if(auto declRefType = as(type)) + { + auto declRef = declRefType->declRef; + if( auto structDeclRef = declRef.as()) + { + return (unsigned int)getFields(structDeclRef, MemberFilterStyle::Instance).getCount(); + } + } + + return 0; +} + +SLANG_API SlangReflectionVariable* spReflectionType_GetFieldByIndex(SlangReflectionType* inType, unsigned index) +{ + auto type = convert(inType); + if(!type) return nullptr; + + // TODO: maybe filter based on kind + + if(auto declRefType = as(type)) + { + auto declRef = declRefType->declRef; + if( auto structDeclRef = declRef.as()) + { + auto fields = getFields(structDeclRef, MemberFilterStyle::Instance); + auto fieldDeclRef = fields[index]; + return (SlangReflectionVariable*) fieldDeclRef.getDecl(); + } + } + + return nullptr; +} + +SLANG_API size_t spReflectionType_GetElementCount(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + if(auto arrayType = as(type)) + { + return arrayType->arrayLength ? (size_t) getIntVal(arrayType->arrayLength) : 0; + } + else if( auto vectorType = as(type)) + { + return (size_t) getIntVal(vectorType->elementCount); + } + + return 0; +} + +SLANG_API SlangReflectionType* spReflectionType_GetElementType(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return nullptr; + + if(auto arrayType = as(type)) + { + return (SlangReflectionType*) arrayType->baseType; + } + else if( auto parameterGroupType = as(type)) + { + return convert(parameterGroupType->elementType); + } + else if( auto vectorType = as(type)) + { + return convert(vectorType->elementType); + } + else if( auto matrixType = as(type)) + { + return convert(matrixType->getElementType()); + } + + return nullptr; +} + +SLANG_API unsigned int spReflectionType_GetRowCount(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + if(auto matrixType = as(type)) + { + return (unsigned int) getIntVal(matrixType->getRowCount()); + } + else if(auto vectorType = as(type)) + { + return 1; + } + else if( auto basicType = as(type) ) + { + return 1; + } + + return 0; +} + +SLANG_API unsigned int spReflectionType_GetColumnCount(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + if(auto matrixType = as(type)) + { + return (unsigned int) getIntVal(matrixType->getColumnCount()); + } + else if(auto vectorType = as(type)) + { + return (unsigned int) getIntVal(vectorType->elementCount); + } + else if( auto basicType = as(type) ) + { + return 1; + } + + return 0; +} + +SLANG_API SlangScalarType spReflectionType_GetScalarType(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + if(auto matrixType = as(type)) + { + type = matrixType->getElementType(); + } + else if(auto vectorType = as(type)) + { + type = vectorType->elementType; + } + + if(auto basicType = as(type)) + { + switch (basicType->baseType) + { +#define CASE(BASE, TAG) \ + case BaseType::BASE: return SLANG_SCALAR_TYPE_##TAG + + CASE(Void, VOID); + CASE(Bool, BOOL); + CASE(Int8, INT8); + CASE(Int16, INT16); + CASE(Int, INT32); + CASE(Int64, INT64); + CASE(UInt8, UINT8); + CASE(UInt16, UINT16); + CASE(UInt, UINT32); + CASE(UInt64, UINT64); + CASE(Half, FLOAT16); + CASE(Float, FLOAT32); + CASE(Double, FLOAT64); + +#undef CASE + + default: + SLANG_REFLECTION_UNEXPECTED(); + return SLANG_SCALAR_TYPE_NONE; + break; + } + } + + return SLANG_SCALAR_TYPE_NONE; +} + +SLANG_API unsigned int spReflectionType_GetUserAttributeCount(SlangReflectionType* inType) +{ + auto type = convert(inType); + if (!type) return 0; + if (auto declRefType = as(type)) + { + return getUserAttributeCount(declRefType->declRef.getDecl()); + } + return 0; +} +SLANG_API SlangReflectionUserAttribute* spReflectionType_GetUserAttribute(SlangReflectionType* inType, unsigned int index) +{ + auto type = convert(inType); + if (!type) return 0; + if (auto declRefType = as(type)) + { + return getUserAttributeByIndex(declRefType->declRef.getDecl(), index); + } + return 0; +} +SLANG_API SlangReflectionUserAttribute* spReflectionType_FindUserAttributeByName(SlangReflectionType* inType, char const* name) +{ + auto type = convert(inType); + if (!type) return 0; + if (auto declRefType = as(type)) + { + ASTBuilder* astBuilder = declRefType->getASTBuilder(); + auto globalSession = astBuilder->getGlobalSession(); + + return findUserAttributeByName(globalSession, declRefType->declRef.getDecl(), name); + } + return 0; +} + +SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + while(auto arrayType = as(type)) + { + type = arrayType->baseType; + } + + if(auto textureType = as(type)) + { + return textureType->getShape(); + } + + // TODO: need a better way to handle this stuff... +#define CASE(TYPE, SHAPE, ACCESS) \ + else if(as(type)) do { \ + return SHAPE; \ + } while(0) + + CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); + CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); + CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); + CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); + CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); + CASE(HLSLByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); + CASE(HLSLRWByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); + CASE(HLSLRasterizerOrderedByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); + CASE(RaytracingAccelerationStructureType, SLANG_ACCELERATION_STRUCTURE, SLANG_RESOURCE_ACCESS_READ); + CASE(UntypedBufferResourceType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); +#undef CASE + + return SLANG_RESOURCE_NONE; +} + +SLANG_API SlangResourceAccess spReflectionType_GetResourceAccess(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return 0; + + while(auto arrayType = as(type)) + { + type = arrayType->baseType; + } + + if(auto textureType = as(type)) + { + return textureType->getAccess(); + } + + // TODO: need a better way to handle this stuff... +#define CASE(TYPE, SHAPE, ACCESS) \ + else if(as(type)) do { \ + return ACCESS; \ + } while(0) + + CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); + CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); + CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); + CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); + CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); + CASE(HLSLByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); + CASE(HLSLRWByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); + CASE(HLSLRasterizerOrderedByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); + CASE(UntypedBufferResourceType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); + + // This isn't entirely accurate, but I can live with it for now + CASE(GLSLShaderStorageBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); +#undef CASE + + return SLANG_RESOURCE_ACCESS_NONE; +} + +SLANG_API char const* spReflectionType_GetName(SlangReflectionType* inType) +{ + auto type = convert(inType); + + if( auto declRefType = as(type) ) + { + auto declRef = declRefType->declRef; + + // Don't return a name for auto-generated anonymous types + // that represent `cbuffer` members, etc. + auto decl = declRef.getDecl(); + if(decl->hasModifier()) + return nullptr; + + return getText(declRef.getName()).begin(); + } + + return nullptr; +} + +SLANG_API SlangReflectionType * spReflection_FindTypeByName(SlangReflection * reflection, char const * name) +{ + auto programLayout = convert(reflection); + auto program = programLayout->getProgram(); + + // TODO: We should extend this API to support getting error messages + // when type lookup fails. + // + Slang::DiagnosticSink sink( + programLayout->getTargetReq()->getLinkage()->getSourceManager()); + + try + { + Type* result = program->getTypeFromString(name, &sink); + return (SlangReflectionType*)result; + } + catch( ... ) + { + return nullptr; + } +} + +SLANG_API SlangReflectionTypeLayout* spReflection_GetTypeLayout( + SlangReflection* reflection, + SlangReflectionType* inType, + SlangLayoutRules /*rules*/) +{ + auto context = convert(reflection); + auto type = convert(inType); + auto targetReq = context->getTargetReq(); + + auto typeLayout = targetReq->getTypeLayout(type); + return convert(typeLayout); +} + +SLANG_API SlangReflectionType* spReflectionType_GetResourceResultType(SlangReflectionType* inType) +{ + auto type = convert(inType); + if(!type) return nullptr; + + while(auto arrayType = as(type)) + { + type = arrayType->baseType; + } + + if (auto textureType = as(type)) + { + return convert(textureType->elementType); + } + + // TODO: need a better way to handle this stuff... +#define CASE(TYPE, SHAPE, ACCESS) \ + else if(as(type)) do { \ + return convert(as(type)->elementType); \ + } while(0) + + // TODO: structured buffer needs to expose type layout! + + CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); + CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); + CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); + CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); + CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); +#undef CASE + + return nullptr; +} + +// type Layout Reflection + +SLANG_API SlangReflectionType* spReflectionTypeLayout_GetType(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + return (SlangReflectionType*) typeLayout->type; +} + +SLANG_API SlangTypeKind spReflectionTypeLayout_getKind(SlangReflectionTypeLayout* inTypeLayout) +{ + if(!inTypeLayout) return SLANG_TYPE_KIND_NONE; + + if( auto type = spReflectionTypeLayout_GetType(inTypeLayout) ) + { + return spReflectionType_GetKind(type); + } + + auto typeLayout = convert(inTypeLayout); + if( as(typeLayout) ) + { + return SLANG_TYPE_KIND_STRUCT; + } + else if( as(typeLayout) ) + { + return SLANG_TYPE_KIND_CONSTANT_BUFFER; + } + + return SLANG_TYPE_KIND_NONE; +} + +namespace +{ + static size_t getReflectionSize(LayoutSize size) + { + if(size.isFinite()) + return size.getFiniteValue(); + + return SLANG_UNBOUNDED_SIZE; + } +} + +SLANG_API size_t spReflectionTypeLayout_GetSize(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto info = typeLayout->FindResourceInfo(LayoutResourceKind(category)); + if(!info) return 0; + + return getReflectionSize(info->count); +} + +SLANG_API int32_t spReflectionTypeLayout_getAlignment(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + if( category == SLANG_PARAMETER_CATEGORY_UNIFORM ) + { + return int32_t(typeLayout->uniformAlignment); + } + else + { + return 1; + } +} + +SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetFieldByIndex(SlangReflectionTypeLayout* inTypeLayout, unsigned index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + if(auto structTypeLayout = as(typeLayout)) + { + return (SlangReflectionVariableLayout*) structTypeLayout->fields[index].Ptr(); + } + + return nullptr; +} + +SLANG_API SlangInt spReflectionTypeLayout_findFieldIndexByName(SlangReflectionTypeLayout* inTypeLayout, const char* nameBegin, const char* nameEnd) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return -1; + + UnownedStringSlice name = nameEnd != nullptr ? UnownedStringSlice(nameBegin, nameEnd) : UnownedTerminatedStringSlice(nameBegin); + + if(auto structTypeLayout = as(typeLayout)) + { + Index fieldCount = structTypeLayout->fields.getCount(); + for(Index f = 0; f < fieldCount; ++f) + { + auto field = structTypeLayout->fields[f]; + if(getReflectionName(field->varDecl)->text.getUnownedSlice() == name) + return f; + } + } + + return -1; +} + +SLANG_API size_t spReflectionTypeLayout_GetElementStride(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + if( auto arrayTypeLayout = as(typeLayout)) + { + switch (category) + { + // We store the stride explicitly for the uniform case + case SLANG_PARAMETER_CATEGORY_UNIFORM: + return arrayTypeLayout->uniformStride; + + // For most other cases (resource registers), the "stride" + // of an array is simply the number of resources (if any) + // consumed by its element type. + default: + { + auto elementTypeLayout = arrayTypeLayout->elementTypeLayout; + auto info = elementTypeLayout->FindResourceInfo(LayoutResourceKind(category)); + if(!info) return 0; + return getReflectionSize(info->count); + } + + // An important special case, though, is Vulkan descriptor-table slots, + // where an entire array will use a single `binding`, so that the + // effective stride is zero: + case SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT: + return 0; + } + } + + return 0; +} + +SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_GetElementTypeLayout(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + if( auto arrayTypeLayout = as(typeLayout)) + { + return (SlangReflectionTypeLayout*) arrayTypeLayout->elementTypeLayout.Ptr(); + } + else if( auto constantBufferTypeLayout = as(typeLayout)) + { + return convert(constantBufferTypeLayout->offsetElementTypeLayout.Ptr()); + } + else if( auto structuredBufferTypeLayout = as(typeLayout)) + { + return convert(structuredBufferTypeLayout->elementTypeLayout.Ptr()); + } + else if( auto specializedTypeLayout = as(typeLayout) ) + { + return convert(specializedTypeLayout->baseTypeLayout.Ptr()); + } + + return nullptr; +} + +SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetElementVarLayout(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + if( auto parameterGroupTypeLayout = as(typeLayout)) + { + return convert(parameterGroupTypeLayout->elementVarLayout.Ptr()); + } + + return nullptr; +} + +SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_getContainerVarLayout(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + if( auto parameterGroupTypeLayout = as(typeLayout)) + { + return convert(parameterGroupTypeLayout->containerVarLayout.Ptr()); + } + + return nullptr; +} + +SLANG_API SlangParameterCategory spReflectionTypeLayout_GetParameterCategory(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; + + return getParameterCategory(typeLayout); +} + +SLANG_API unsigned spReflectionTypeLayout_GetCategoryCount(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return (unsigned) typeLayout->resourceInfos.getCount(); +} + +SLANG_API SlangParameterCategory spReflectionTypeLayout_GetCategoryByIndex(SlangReflectionTypeLayout* inTypeLayout, unsigned index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; + + return typeLayout->resourceInfos[index].kind; +} + +SLANG_API SlangMatrixLayoutMode spReflectionTypeLayout_GetMatrixLayoutMode(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; + + if( auto matrixLayout = as(typeLayout) ) + { + return matrixLayout->mode; + } + else + { + return SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; + } + +} + +SLANG_API int spReflectionTypeLayout_getGenericParamIndex(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return -1; + + if(auto genericParamTypeLayout = as(typeLayout)) + { + return (int) genericParamTypeLayout->paramIndex; + } + else + { + return -1; + } +} + +SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getPendingDataTypeLayout(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + auto pendingDataTypeLayout = typeLayout->pendingDataTypeLayout.Ptr(); + return convert(pendingDataTypeLayout); +} + +SLANG_API SlangReflectionVariableLayout* spReflectionVariableLayout_getPendingDataLayout(SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return nullptr; + + auto pendingDataLayout = varLayout->pendingVarLayout.Ptr(); + return convert(pendingDataLayout); +} + +SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_getSpecializedTypePendingDataVarLayout(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return nullptr; + + if( auto specializedTypeLayout = as(typeLayout) ) + { + auto pendingDataVarLayout = specializedTypeLayout->pendingDataVarLayout.Ptr(); + return convert(pendingDataVarLayout); + } + else + { + return nullptr; + } +} + +namespace Slang +{ + struct BindingRangePathLink + { + BindingRangePathLink( + BindingRangePathLink* parent, + VarLayout* var) + : parent(parent) + , var(var) + {} + + BindingRangePathLink* parent; + VarLayout* var; + }; + + + Int _calcIndexOffset(BindingRangePathLink* path, LayoutResourceKind kind) + { + Int result = 0; + for( auto link = path; link; link = link->parent ) + { + if( auto resInfo = link->var->FindResourceInfo(kind) ) + { + result += resInfo->index; + } + } + return result; + } + + Int _calcSpaceOffset(BindingRangePathLink* path, LayoutResourceKind kind) + { + Int result = 0; + for( auto link = path; link; link = link->parent ) + { + if( auto resInfo = link->var->FindResourceInfo(kind) ) + { + result += resInfo->space; + } + } + return result; + } + + SlangBindingType _calcResourceBindingType( + Type* type) + { + if( auto resourceType = as(type) ) + { + auto shape = resourceType->getBaseShape(); + + auto access = resourceType->getAccess(); + auto mutableFlag = access != SLANG_RESOURCE_ACCESS_READ ? SLANG_BINDING_TYPE_MUTABLE_FLAG : 0; + + switch( shape ) + { + default: + return SLANG_BINDING_TYPE_TEXTURE | mutableFlag; + + case SLANG_TEXTURE_BUFFER: + return SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag; + } + + } + else if( auto structuredBufferType = as(type) ) + { + if( as(type) ) + { + return SLANG_BINDING_TYPE_RAW_BUFFER; + } + else + { + return SLANG_BINDING_TYPE_MUTABLE_RAW_BUFFER; + } + } + else if( as(type) ) + { + return SLANG_BINDING_TYPE_RAY_TRACTING_ACCELERATION_STRUCTURE; + } + else if( auto untypedBufferType = as(type) ) + { + if( as(type) ) + { + return SLANG_BINDING_TYPE_RAW_BUFFER; + } + else + { + return SLANG_BINDING_TYPE_MUTABLE_RAW_BUFFER; + } + } + else if( as(type) ) + { + return SLANG_BINDING_TYPE_CONSTANT_BUFFER; + } + else + { + SLANG_UNEXPECTED("unhandled resource binding type"); + } + } + + SlangBindingType _calcResourceBindingType( + TypeLayout* typeLayout) + { + if(auto type = typeLayout->getType()) + { + return _calcResourceBindingType(type); + } + + if(as(typeLayout)) + { + return SLANG_BINDING_TYPE_CONSTANT_BUFFER; + } + else + { + SLANG_UNEXPECTED("unhandled resource binding type"); + } + } + + + SlangBindingType _calcBindingType( + Slang::TypeLayout* typeLayout, + LayoutResourceKind kind) + { + switch( kind ) + { + default: + return SLANG_BINDING_TYPE_UNKNOWN; + + // Some cases of `LayoutResourceKind` can be mapped + // directly to a `BindingType` because there is only + // one case of types that have that resource kind. + + #define CASE(FROM, TO) \ + case LayoutResourceKind::FROM: return SLANG_BINDING_TYPE_##TO + + CASE(ConstantBuffer, CONSTANT_BUFFER); + CASE(SamplerState, SAMPLER); + CASE(VaryingInput, VARYING_INPUT); + CASE(VaryingOutput, VARYING_OUTPUT); + CASE(ExistentialObjectParam, EXISTENTIAL_VALUE); + CASE(PushConstantBuffer, PUSH_CONSTANT); + // TODO: register space + + #undef CASE + + case LayoutResourceKind::ShaderResource: + case LayoutResourceKind::UnorderedAccess: + case LayoutResourceKind::DescriptorTableSlot: + return _calcResourceBindingType(typeLayout); + } + } + + static DeclRefType* asInterfaceType(Type* type) + { + if(auto declRefType = as(type)) + { + if(declRefType->declRef.as()) + { + return declRefType; + } + } + return nullptr; + } + + struct ExtendedTypeLayoutContext + { + TypeLayout* m_typeLayout; + TypeLayout::ExtendedInfo* m_extendedInfo; + + Dictionary m_mapSpaceToDescriptorSetIndex; + + Int _findOrAddDescriptorSet(Int space) + { + Int index = 0; + if(m_mapSpaceToDescriptorSetIndex.TryGetValue(space, index)) + return index; + + index = m_extendedInfo->m_descriptorSets.getCount(); + m_mapSpaceToDescriptorSetIndex.Add(space, index); + + RefPtr descriptorSet = new TypeLayout::ExtendedInfo::DescriptorSetInfo(); + m_extendedInfo->m_descriptorSets.add(descriptorSet); + + return index; + } + + void addRangesRec(TypeLayout* typeLayout, BindingRangePathLink* path, LayoutSize multiplier) + { + if( auto structTypeLayout = as(typeLayout) ) + { + // For a structure type, we need to recursively + // add the ranges for each field. + // + // Along the way we will make sure to properly update + // the offset information on the fields so that + // they properly show their binding-range offset + // within the parent type. + // + Index structBindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); + for( auto fieldVarLayout : structTypeLayout->fields ) + { + Index fieldBindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); + fieldVarLayout->bindingRangeOffset = fieldBindingRangeIndex - structBindingRangeIndex; + + auto fieldTypeLayout = fieldVarLayout->getTypeLayout(); + + + BindingRangePathLink fieldLink(path, fieldVarLayout); + addRangesRec(fieldTypeLayout, &fieldLink, multiplier); + } + return; + } + else if( auto arrayTypeLayout = as(typeLayout) ) + { + // For an array, we need to recursively add the + // element type of the array, but with an adjusted + // `multiplier` to account for the element count. + // + auto elementTypeLayout = arrayTypeLayout->elementTypeLayout; + LayoutSize elementCount = LayoutSize::infinite(); + if( auto arrayType = as(arrayTypeLayout->type) ) + { + if( auto elementCountVal = arrayType->arrayLength ) + { + elementCount = LayoutSize::RawValue(getIntVal(elementCountVal)); + } + } + addRangesRec(elementTypeLayout, path, multiplier * elementCount); + return; + } + else if( auto parameterGroupTypeLayout = as(typeLayout)) + { + // A parameter group (whether a `ConstantBuffer<>` or `ParameterBlock<>` + // introduces a separately-allocated "sub-object" in the application's + // layout for shader objects. + // + // We will represent the parameter group with a single sub-object + // binding range (and an associated sub-object range). + // + // We start out by looking at the resources consumed by the parameter group + // itself, to determine what kind of binding range to report it as. + // + Index bindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); + SlangBindingType bindingType = SLANG_BINDING_TYPE_CONSTANT_BUFFER; + Index spaceOffset = -1; + LayoutResourceKind kind = LayoutResourceKind::None; + for(auto& resInfo : parameterGroupTypeLayout->resourceInfos) + { + kind = resInfo.kind; + switch(kind) + { + default: + continue; + + case LayoutResourceKind::ConstantBuffer: + case LayoutResourceKind::PushConstantBuffer: + case LayoutResourceKind::RegisterSpace: + case LayoutResourceKind::DescriptorTableSlot: + break; + } + + bindingType = _calcBindingType(typeLayout, kind); + spaceOffset = _calcSpaceOffset(path, kind); + break; + } + + TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; + bindingRange.leafTypeLayout = typeLayout; + bindingRange.bindingType = bindingType; + bindingRange.count = multiplier; + bindingRange.descriptorSetIndex = -1; + bindingRange.firstDescriptorRangeIndex = 0; + bindingRange.descriptorRangeCount = 0; + + if( kind == LayoutResourceKind::PushConstantBuffer ) + { + if(auto resInfo = parameterGroupTypeLayout->elementVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform)) + { + bindingRange.count *= resInfo->count; + } + } + + // Every parameter group will introduce a sub-object range, + // which will include bindings based on the type of data + // inside the sub-object. + // + TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange; + subObjectRange.bindingRangeIndex = bindingRangeIndex; + + // It is possible that the sub-object has descriptor ranges + // that will need to be exposed upward, into the parent. + // + if( spaceOffset != -1 ) + { + Int descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); + auto descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; + auto firstDescriptorRangeIndex = descriptorSet->descriptorRanges.getCount(); + + // TODO: We need to recursively add descriptor ranges (but not binding + // ranges!) for anything in the element type that "leaks" into + // the surrounding context. + // + switch(kind) + { + case LayoutResourceKind::RegisterSpace: + case LayoutResourceKind::Uniform: + case LayoutResourceKind::None: + break; + + default: + { + // This means we are in the constant-buffer-like case + // (even if the user wrote `ParameterBlock`), and any + // resource usage inside the element type should "leak" + // out to the parent scope. + // + // It *also* means we should add a suitable descriptor + // range if one is required for the "container" type. + // + for(auto resInfo : parameterGroupTypeLayout->containerVarLayout->typeLayout->resourceInfos) + { + switch( resInfo.kind ) + { + case LayoutResourceKind::RegisterSpace: + case LayoutResourceKind::Uniform: + continue; + + default: + break; + } + + TypeLayout::ExtendedInfo::DescriptorRangeInfo descriptorRange; + descriptorRange.kind = resInfo.kind; + descriptorRange.bindingType = _calcBindingType(typeLayout, resInfo.kind); + descriptorRange.count = multiplier; + descriptorRange.indexOffset = _calcIndexOffset(path, resInfo.kind); + + if( resInfo.kind == LayoutResourceKind::PushConstantBuffer ) + { + if(auto uniformResInfo = parameterGroupTypeLayout->elementVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform)) + { + descriptorRange.count *= uniformResInfo->count; + } + } + + descriptorSet->descriptorRanges.add(descriptorRange); + } + + // Now we need to recursively walk the element type and add all its + // descriptor ranges, so that they can be used for binding in + // the parent. + // + // We have this a bit by collecting both binding ranges and + // descriptor ranges, and then throwing away the binding ranges + // from the element type. + // + BindingRangePathLink elementPath(path, parameterGroupTypeLayout->elementVarLayout); + + Index bindingRangeCountBefore = m_extendedInfo->m_bindingRanges.getCount(); + Index subObjectRangeCountBefore = m_extendedInfo->m_subObjectRanges.getCount(); + + addRangesRec(parameterGroupTypeLayout->elementVarLayout->typeLayout, &elementPath, multiplier); + + m_extendedInfo->m_bindingRanges.setCount(bindingRangeCountBefore); + m_extendedInfo->m_subObjectRanges.setCount(subObjectRangeCountBefore); + } + break; + } + + auto descriptorRangeCount = descriptorSet->descriptorRanges.getCount() - firstDescriptorRangeIndex; + bindingRange.descriptorSetIndex = descriptorSetIndex; + bindingRange.firstDescriptorRangeIndex = firstDescriptorRangeIndex; + bindingRange.descriptorRangeCount = descriptorRangeCount; + } + + m_extendedInfo->m_bindingRanges.add(bindingRange); + m_extendedInfo->m_subObjectRanges.add(subObjectRange); + return; + } + else if(asInterfaceType(typeLayout->type)) + { + // An `interface` type should introduce a sub-object range, + // with no concrete descriptor ranges to store its value + // (since we don't know until runtime what type of + // value will be plugged in). + // + + LayoutResourceKind kind = LayoutResourceKind::ExistentialObjectParam; + auto count = multiplier; + auto spaceOffset = _calcSpaceOffset(path, kind); + + Int descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); + auto descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; + + TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; + bindingRange.leafTypeLayout = typeLayout; + bindingRange.bindingType = SLANG_BINDING_TYPE_EXISTENTIAL_VALUE; + bindingRange.count = multiplier; + bindingRange.descriptorSetIndex = descriptorSetIndex; + bindingRange.firstDescriptorRangeIndex = descriptorSet->descriptorRanges.getCount(); + bindingRange.descriptorRangeCount = 1; + + TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange; + subObjectRange.bindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); + + m_extendedInfo->m_bindingRanges.add(bindingRange); + m_extendedInfo->m_subObjectRanges.add(subObjectRange); + } + // TODO: We need to handle `interface` types here, because they are + // another case that introduces a "sub-object" for the purposes of + // application-side allocation. + // + // TODO: There are a few cases of "leaf" fields that might + // still result in multiple descriptors (or at least multiple + // `LayoutResourceKind`s) depending on the target. + // + // For eample, combined texture-sampler types should be treated + // as "leaf" fields for this code (since a portable engine would + // need to abstract over them), but would map to two descriptors + // on targets that don't actually support combining them. + else + { + Int resourceKindCount = typeLayout->resourceInfos.getCount(); + if(resourceKindCount == 0) + { + // This is a field that consumes no resources, and as + // such does not need a binding or descriptor ranges + // allocated for it. + // + return; + } + else if(resourceKindCount == 1) + { + auto& resInfo = typeLayout->resourceInfos[0]; + LayoutResourceKind kind = resInfo.kind; + + if(kind == LayoutResourceKind::Uniform) + { + // We do not consider uniform resource usage + // in the ranges we compute. + // + // TODO: We may need to revise that rule for types that + // represent resources, even when one or more targets + // map those resource types to ordinary/uniform data. + // + return; + } + + // This leaf field will map to a single binding range and, + // if it is appropriate, a single descriptor range. + // + auto bindingType = _calcBindingType(typeLayout, kind); + auto count = resInfo.count * multiplier; + auto indexOffset = _calcIndexOffset(path, kind); + auto spaceOffset = _calcSpaceOffset(path, kind); + + Int descriptorSetIndex = -1; + Int firstDescriptorIndex = 0; + RefPtr descriptorSet; + switch( kind ) + { + case LayoutResourceKind::RegisterSpace: + case LayoutResourceKind::VaryingInput: + case LayoutResourceKind::VaryingOutput: + case LayoutResourceKind::HitAttributes: + case LayoutResourceKind::RayPayload: + // Resource kinds that represent "varying" input/output + // do not manifest as entries in API descriptor tables. + // + // TODO: Neither do root constants, if we are being + // precise. This API really needs to carefully match + // the semantics of the target platform/API in terms + // of what things are descriptor-bound and which are + // not, so that a user can easily allocate the platform-specific + // descriptor sets using this info. + // + // (That said, we are purposefully *not* breaking apart + // samplers and SRV/UAV/CBV stuff for our D3D reflection + // of descriptor sets. It seems like the policy here + // really requires careful thought) + // + // TODO: Maybe the best answer is to leave decomposition + // of stuff into descriptor sets up to the application + // layer? This is especially true if a common case would + // be an application that doesn't support arbitrary manual + // binding of parameters to register/spaces. + // + break; + + default: + { + TypeLayout::ExtendedInfo::DescriptorRangeInfo descriptorRange; + descriptorRange.kind = kind; + descriptorRange.bindingType = bindingType; + descriptorRange.count = count; + descriptorRange.indexOffset = indexOffset; + + descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); + descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; + + firstDescriptorIndex = descriptorSet->descriptorRanges.getCount(); + descriptorSet->descriptorRanges.add(descriptorRange); + } + break; + } + + + TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; + bindingRange.leafTypeLayout = typeLayout; + bindingRange.bindingType = _calcBindingType(typeLayout, kind); + bindingRange.count = count; + bindingRange.descriptorSetIndex = descriptorSetIndex; + bindingRange.firstDescriptorRangeIndex = firstDescriptorIndex; + bindingRange.descriptorRangeCount = 1; + + m_extendedInfo->m_bindingRanges.add(bindingRange); + } + else + { + // This type appears to be one that consumes multiple + // resource kinds, but was not handled by any of + // the special-case logic above. In such a case we + // are in trouble. + // + return; + } + } + } + }; + + TypeLayout::ExtendedInfo* getExtendedTypeLayout(TypeLayout* typeLayout) + { + if( !typeLayout->m_extendedInfo ) + { + RefPtr extendedInfo = new TypeLayout::ExtendedInfo; + + ExtendedTypeLayoutContext context; + context.m_typeLayout = typeLayout; + context.m_extendedInfo = extendedInfo; + + context.addRangesRec(typeLayout, nullptr, 1); + + typeLayout->m_extendedInfo = extendedInfo; + } + return typeLayout->m_extendedInfo; + } +} + +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeCount(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + return extTypeLayout->m_bindingRanges.getCount(); +} + +SLANG_API SlangBindingType spReflectionTypeLayout_getBindingRangeType(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return SLANG_BINDING_TYPE_UNKNOWN; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + if(index < 0) return 0; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + auto& bindingRange = extTypeLayout->m_bindingRanges[index]; + + return bindingRange.bindingType; +} + +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeBindingCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + if(index < 0) return 0; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + auto& bindingRange = extTypeLayout->m_bindingRanges[index]; + + auto count = bindingRange.count; + return count.isFinite() ? SlangInt(count.getFiniteValue()) : -1; +} + +#if 0 +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return Slang::_findBindingRange(typeLayout, index).indexOffset; +} + +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return Slang::_findBindingRange(typeLayout, index).spaceOffset; +} +#endif + +SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getBindingRangeLeafTypeLayout(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + if(index < 0) return 0; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + auto& bindingRange = extTypeLayout->m_bindingRanges[index]; + + return convert(bindingRange.leafTypeLayout); +} + +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeDescriptorSetIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + if(index < 0) return 0; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + auto& bindingRange = extTypeLayout->m_bindingRanges[index]; + + return bindingRange.descriptorSetIndex; +} + +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeFirstDescriptorRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + if(index < 0) return 0; + if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; + auto& bindingRange = extTypeLayout->m_bindingRanges[index]; + + return bindingRange.firstDescriptorRangeIndex; +} + +SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetCount(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + return extTypeLayout->m_descriptorSets.getCount(); +} + +SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + return descriptorSet->spaceOffset; +} + +SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + return descriptorSet->descriptorRanges.getCount(); +} + +SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + if(rangeIndex < 0) return 0; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + auto& range = descriptorSet->descriptorRanges[rangeIndex]; + + return range.indexOffset; +} + +SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeDescriptorCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + if(rangeIndex < 0) return 0; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + auto& range = descriptorSet->descriptorRanges[rangeIndex]; + + auto count = range.count; + return count.isFinite() ? count.getFiniteValue() : -1; +} + +SLANG_API SlangBindingType spReflectionTypeLayout_getDescriptorSetDescriptorRangeType(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + if(rangeIndex < 0) return 0; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + auto& range = descriptorSet->descriptorRanges[rangeIndex]; + + return range.bindingType; +} + +SLANG_API SlangParameterCategory spReflectionTypeLayout_getDescriptorSetDescriptorRangeCategory(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(setIndex < 0) return 0; + if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; + auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; + + if(rangeIndex < 0) return 0; + if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; + auto& range = descriptorSet->descriptorRanges[rangeIndex]; + + return SlangParameterCategory(range.kind); +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeCount(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + return extTypeLayout->m_subObjectRanges.getCount(); +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeBindingRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); + + if(subObjectRangeIndex < 0) return 0; + if(subObjectRangeIndex >= extTypeLayout->m_subObjectRanges.getCount()) return 0; + + return extTypeLayout->m_subObjectRanges[subObjectRangeIndex].bindingRangeIndex; +} + + +#if 0 +SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeSubObjectRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return Slang::_findBindingRange(typeLayout, index).subObjectRangeIndex; +} +#endif + + +SLANG_API SlangInt spReflectionTypeLayout_getFieldBindingRangeOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt fieldIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + if( auto structTypeLayout = as(typeLayout) ) + { + getExtendedTypeLayout(structTypeLayout); + + return structTypeLayout->fields[fieldIndex]->bindingRangeOffset; + } + + return 0; +} + +#if 0 +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeCount(SlangReflectionTypeLayout* inTypeLayout) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return Slang::_calcSubObjectRangeCount(typeLayout); +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeObjectCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto count = Slang::_findSubObjectRange(typeLayout, index).count; + return count.isFinite() ? SlangInt(count.getFiniteValue()) : -1; +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeBindingRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return Slang::_findSubObjectRange(typeLayout, index).bindingRangeIndex; +} + + +SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getSubObjectRangeTypeLayout(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + return convert(Slang::_findSubObjectRange(typeLayout, index).leafTypeLayout); +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); + return Slang::_getSubObjectDescriptorRangeCount(subObjectRange); +} + +SLANG_API SlangBindingType spReflectionTypeLayout_getSubObjectRangeDescriptorRangeBindingType(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); + return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).bindingType; +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeBindingCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); + auto count = Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).count; + return count.isFinite() ? count.getFiniteValue() : -1; +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); + return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).indexOffset; +} + +SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) +{ + auto typeLayout = convert(inTypeLayout); + if(!typeLayout) return 0; + + auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); + return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).spaceOffset; +} +#endif + +// Variable Reflection + +SLANG_API char const* spReflectionVariable_GetName(SlangReflectionVariable* inVar) +{ + auto var = convert(inVar); + if(!var) return nullptr; + + // If the variable is one that has an "external" name that is supposed + // to be exposed for reflection, then report it here + if(auto reflectionNameMod = var->findModifier()) + return getText(reflectionNameMod->nameAndLoc.name).getBuffer(); + + return getText(var->getName()).getBuffer(); +} + +SLANG_API SlangReflectionType* spReflectionVariable_GetType(SlangReflectionVariable* inVar) +{ + auto var = convert(inVar); + if(!var) return nullptr; + + return convert(var->getType()); +} + +SLANG_API SlangReflectionModifier* spReflectionVariable_FindModifier(SlangReflectionVariable* inVar, SlangModifierID modifierID) +{ + auto var = convert(inVar); + if(!var) return nullptr; + + Modifier* modifier = nullptr; + switch( modifierID ) + { + case SLANG_MODIFIER_SHARED: + modifier = var->findModifier(); + break; + + default: + return nullptr; + } + + return (SlangReflectionModifier*) modifier; +} + +SLANG_API unsigned int spReflectionVariable_GetUserAttributeCount(SlangReflectionVariable* inVar) +{ + auto varDecl = convert(inVar); + if (!varDecl) return 0; + return getUserAttributeCount(varDecl); +} +SLANG_API SlangReflectionUserAttribute* spReflectionVariable_GetUserAttribute(SlangReflectionVariable* inVar, unsigned int index) +{ + auto varDecl = convert(inVar); + if (!varDecl) return 0; + return getUserAttributeByIndex(varDecl, index); +} +SLANG_API SlangReflectionUserAttribute* spReflectionVariable_FindUserAttributeByName(SlangReflectionVariable* inVar, SlangSession* session, char const* name) +{ + auto varDecl = convert(inVar); + if (!varDecl) return 0; + return findUserAttributeByName(asInternal(session), varDecl, name); +} + +// Variable Layout Reflection + +SLANG_API SlangReflectionVariable* spReflectionVariableLayout_GetVariable(SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return nullptr; + + return convert(varLayout->varDecl.getDecl()); +} + +SLANG_API SlangReflectionTypeLayout* spReflectionVariableLayout_GetTypeLayout(SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return nullptr; + + return convert(varLayout->getTypeLayout()); +} + +SLANG_API size_t spReflectionVariableLayout_GetOffset(SlangReflectionVariableLayout* inVarLayout, SlangParameterCategory category) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return 0; + + auto info = varLayout->FindResourceInfo(LayoutResourceKind(category)); + + if (!info) + { + // No match with requested category? Try again with one they might have meant... + category = maybeRemapParameterCategory(varLayout->getTypeLayout(), category); + info = varLayout->FindResourceInfo(LayoutResourceKind(category)); + } + + if(!info) return 0; + + return info->index; +} + +SLANG_API size_t spReflectionVariableLayout_GetSpace(SlangReflectionVariableLayout* inVarLayout, SlangParameterCategory category) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return 0; + + + auto info = varLayout->FindResourceInfo(LayoutResourceKind(category)); + if (!info) + { + // No match with requested category? Try again with one they might have meant... + category = maybeRemapParameterCategory(varLayout->getTypeLayout(), category); + info = varLayout->FindResourceInfo(LayoutResourceKind(category)); + } + + UInt space = 0; + + // First, deal with any offset applied to the specific resource kind specified + if (info) + { + space += info->space; + } + + // Note: this code used to try and take a variable with + // an offset for `LayoutResourceKind::RegisterSpace` and + // add it to the space returned, but that isn't going + // to be right in some cases. + // + // Imageine if we have: + // + // struct X { Texture2D y; } + // struct S { Texture2D t; ParmaeterBlock x; } + // + // Texture2D gA; + // S gS; + // + // We expect `gS` to have an offset for `LayoutResourceKind::ShaderResourceView` + // of one (since its texture must come after `gA`), and an offset for + // `LayoutResourceKind::RegisterSpace` of one (since the default space will be + // space zero). It would be incorrect for us to imply that `gS.t` should + // be `t1, space1`, though, because the space offset of `gS` doesn't actually + // apply to `t`. + // + // For now we are punting on this issue and leaving it in the hands of the + // application to determine when a space offset from an "outer" variable should + // apply to the locations of things in an "inner" variable. + // + // There is no policy we can apply locally in this function that + // will Just Work, so the best we can do is try to not lie. + + return space; +} + +SLANG_API char const* spReflectionVariableLayout_GetSemanticName(SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return 0; + + if (!(varLayout->flags & Slang::VarLayoutFlag::HasSemantic)) + return 0; + + return varLayout->semanticName.getBuffer(); +} + +SLANG_API size_t spReflectionVariableLayout_GetSemanticIndex(SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return 0; + + if (!(varLayout->flags & Slang::VarLayoutFlag::HasSemantic)) + return 0; + + return varLayout->semanticIndex; +} + +SLANG_API SlangStage spReflectionVariableLayout_getStage( + SlangReflectionVariableLayout* inVarLayout) +{ + auto varLayout = convert(inVarLayout); + if(!varLayout) return SLANG_STAGE_NONE; + + // A parameter that is not a varying input or output is + // not considered to belong to a single stage. + // + // TODO: We might need to reconsider this for, e.g., entry + // point parameters, where they might be stage-specific even + // if they are uniform. + if (!varLayout->FindResourceInfo(Slang::LayoutResourceKind::VaryingInput) + && !varLayout->FindResourceInfo(Slang::LayoutResourceKind::VaryingOutput)) + { + return SLANG_STAGE_NONE; + } + + // TODO: We should find the stage for a variable layout by + // walking up the tree of layout information, until we find + // something that has a definitive stage attached to it (e.g., + // either an entry point or a GLSL translation unit). + // + // We don't currently have parent links in the reflection layout + // information, so doing that walk would be tricky right now, so + // it is easier to just bloat the representation and store yet another + // field on every variable layout. + return (SlangStage) varLayout->stage; +} + + +// Shader Parameter Reflection + +SLANG_API unsigned spReflectionParameter_GetBindingIndex(SlangReflectionParameter* inVarLayout) +{ + SlangReflectionVariableLayout* varLayout = (SlangReflectionVariableLayout*)inVarLayout; + return (unsigned) spReflectionVariableLayout_GetOffset( + varLayout, + spReflectionTypeLayout_GetParameterCategory( + spReflectionVariableLayout_GetTypeLayout(varLayout))); +} + +SLANG_API unsigned spReflectionParameter_GetBindingSpace(SlangReflectionParameter* inVarLayout) +{ + SlangReflectionVariableLayout* varLayout = (SlangReflectionVariableLayout*)inVarLayout; + return (unsigned) spReflectionVariableLayout_GetSpace( + varLayout, + spReflectionTypeLayout_GetParameterCategory( + spReflectionVariableLayout_GetTypeLayout(varLayout))); +} + + + +// Entry Point Reflection + +SLANG_API char const* spReflectionEntryPoint_getName( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + return entryPointLayout ? getCstr(entryPointLayout->name) : nullptr; +} + +SLANG_API unsigned spReflectionEntryPoint_getParameterCount( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) return 0; + + return getParameterCount(entryPointLayout->parametersLayout->typeLayout); +} + +SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getParameterByIndex( + SlangReflectionEntryPoint* inEntryPoint, + unsigned index) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) return 0; + + return convert(getParameterByIndex(entryPointLayout->parametersLayout->typeLayout, index)); +} + +SLANG_API SlangStage spReflectionEntryPoint_getStage(SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + + if(!entryPointLayout) return SLANG_STAGE_NONE; + + return SlangStage(entryPointLayout->profile.getStage()); +} + +SLANG_API void spReflectionEntryPoint_getComputeThreadGroupSize( + SlangReflectionEntryPoint* inEntryPoint, + SlangUInt axisCount, + SlangUInt* outSizeAlongAxis) +{ + auto entryPointLayout = convert(inEntryPoint); + + if(!entryPointLayout) return; + if(!axisCount) return; + if(!outSizeAlongAxis) return; + + auto entryPointFunc = entryPointLayout->entryPoint; + if(!entryPointFunc) return; + + SlangUInt sizeAlongAxis[3] = { 1, 1, 1 }; + + // First look for the HLSL case, where we have an attribute attached to the entry point function + auto numThreadsAttribute = entryPointFunc.getDecl()->findModifier(); + if (numThreadsAttribute) + { + sizeAlongAxis[0] = numThreadsAttribute->x; + sizeAlongAxis[1] = numThreadsAttribute->y; + sizeAlongAxis[2] = numThreadsAttribute->z; + } + + // + + if(axisCount > 0) outSizeAlongAxis[0] = sizeAlongAxis[0]; + if(axisCount > 1) outSizeAlongAxis[1] = sizeAlongAxis[1]; + if(axisCount > 2) outSizeAlongAxis[2] = sizeAlongAxis[2]; + for( SlangUInt aa = 3; aa < axisCount; ++aa ) + { + outSizeAlongAxis[aa] = 1; + } +} + +SLANG_API int spReflectionEntryPoint_usesAnySampleRateInput( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) + return 0; + + if (entryPointLayout->profile.getStage() != Stage::Fragment) + return 0; + + return (entryPointLayout->flags & EntryPointLayout::Flag::usesAnySampleRateInput) != 0; +} + +SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getVarLayout( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) + return nullptr; + + return convert(entryPointLayout->parametersLayout); +} + +SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getResultVarLayout( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) + return nullptr; + + return convert(entryPointLayout->resultLayout); +} + +SLANG_API int spReflectionEntryPoint_hasDefaultConstantBuffer( + SlangReflectionEntryPoint* inEntryPoint) +{ + auto entryPointLayout = convert(inEntryPoint); + if(!entryPointLayout) + return 0; + + return hasDefaultConstantBuffer(entryPointLayout); +} + + +// SlangReflectionTypeParameter +SLANG_API char const* spReflectionTypeParameter_GetName(SlangReflectionTypeParameter * inTypeParam) +{ + auto specializationParam = convert(inTypeParam); + if( auto genericParamLayout = as(specializationParam) ) + { + return genericParamLayout->decl->getName()->text.getBuffer(); + } + // TODO: Add case for existential type parameter? They don't have as simple of a notion of "name" as the generic case... + return nullptr; +} + +SLANG_API unsigned spReflectionTypeParameter_GetIndex(SlangReflectionTypeParameter * inTypeParam) +{ + auto typeParam = convert(inTypeParam); + return (unsigned)(typeParam->index); +} + +SLANG_API unsigned int spReflectionTypeParameter_GetConstraintCount(SlangReflectionTypeParameter* inTypeParam) +{ + auto specializationParam = convert(inTypeParam); + if(auto genericParamLayout = as(specializationParam)) + { + if( auto globalGenericParamDecl = as(genericParamLayout->decl) ) + { + auto constraints = globalGenericParamDecl->getMembersOfType(); + return (unsigned int)constraints.getCount(); + } + // TODO: Add case for entry-point generic parameters. + } + // TODO: Add case for existential type parameters. + return 0; +} + +SLANG_API SlangReflectionType* spReflectionTypeParameter_GetConstraintByIndex(SlangReflectionTypeParameter * inTypeParam, unsigned index) +{ + auto specializationParam = convert(inTypeParam); + if(auto genericParamLayout = as(specializationParam)) + { + if( auto globalGenericParamDecl = as(genericParamLayout->decl) ) + { + auto constraints = globalGenericParamDecl->getMembersOfType(); + return (SlangReflectionType*)constraints[index]->sup.Ptr(); + } + // TODO: Add case for entry-point generic parameters. + } + // TODO: Add case for existential type parameters. + return 0; +} + +// Shader Reflection + +SLANG_API unsigned spReflection_GetParameterCount(SlangReflection* inProgram) +{ + auto program = convert(inProgram); + if(!program) return 0; + + auto globalStructLayout = getGlobalStructLayout(program); + if (!globalStructLayout) + return 0; + + return (unsigned) globalStructLayout->fields.getCount(); +} + +SLANG_API SlangReflectionParameter* spReflection_GetParameterByIndex(SlangReflection* inProgram, unsigned index) +{ + auto program = convert(inProgram); + if(!program) return nullptr; + + auto globalStructLayout = getGlobalStructLayout(program); + if (!globalStructLayout) + return 0; + + return convert(globalStructLayout->fields[index].Ptr()); +} + +SLANG_API SlangReflectionVariableLayout* spReflection_getGlobalParamsVarLayout(SlangReflection* inProgram) +{ + auto program = convert(inProgram); + if(!program) return nullptr; + + return convert(program->parametersLayout); +} + +SLANG_API unsigned int spReflection_GetTypeParameterCount(SlangReflection * reflection) +{ + auto program = convert(reflection); + return (unsigned int) program->specializationParams.getCount(); +} + +SLANG_API SlangReflectionTypeParameter* spReflection_GetTypeParameterByIndex(SlangReflection * reflection, unsigned int index) +{ + auto program = convert(reflection); + return (SlangReflectionTypeParameter*) program->specializationParams[index].Ptr(); +} + +SLANG_API SlangReflectionTypeParameter * spReflection_FindTypeParameter(SlangReflection * inProgram, char const * name) +{ + auto program = convert(inProgram); + if (!program) return nullptr; + for( auto& param : program->specializationParams ) + { + auto genericParamLayout = as(param); + if(!genericParamLayout) + continue; + + if(getText(genericParamLayout->decl->getName()) != UnownedTerminatedStringSlice(name)) + continue; + + return (SlangReflectionTypeParameter*) genericParamLayout; + } + + return 0; +} + +SLANG_API SlangUInt spReflection_getEntryPointCount(SlangReflection* inProgram) +{ + auto program = convert(inProgram); + if(!program) return 0; + + return SlangUInt(program->entryPoints.getCount()); +} + +SLANG_API SlangReflectionEntryPoint* spReflection_getEntryPointByIndex(SlangReflection* inProgram, SlangUInt index) +{ + auto program = convert(inProgram); + if(!program) return 0; + + return convert(program->entryPoints[(int) index].Ptr()); +} + +SLANG_API SlangReflectionEntryPoint* spReflection_findEntryPointByName(SlangReflection* inProgram, char const* name) +{ + auto program = convert(inProgram); + if(!program) return 0; + + // TODO: improve on naive linear search + for(auto ep : program->entryPoints) + { + if(ep->entryPoint.getName()->text == name) + { + return convert(ep); + } + } + + return nullptr; +} + +SLANG_API SlangUInt spReflection_getGlobalConstantBufferBinding(SlangReflection* inProgram) +{ + auto program = convert(inProgram); + if (!program) return 0; + auto cb = program->parametersLayout->FindResourceInfo(LayoutResourceKind::ConstantBuffer); + if (!cb) return 0; + return cb->index; +} + +SLANG_API size_t spReflection_getGlobalConstantBufferSize(SlangReflection* inProgram) +{ + auto program = convert(inProgram); + if (!program) return 0; + auto structLayout = getGlobalStructLayout(program); + auto uniform = structLayout->FindResourceInfo(LayoutResourceKind::Uniform); + if (!uniform) return 0; + return getReflectionSize(uniform->count); +} + +SLANG_API SlangReflectionType* spReflection_specializeType( + SlangReflection* inProgramLayout, + SlangReflectionType* inType, + SlangInt specializationArgCount, + SlangReflectionType* const* specializationArgs, + ISlangBlob** outDiagnostics) +{ + auto programLayout = convert(inProgramLayout); + if(!programLayout) return nullptr; + + auto unspecializedType = convert(inType); + if(!unspecializedType) return nullptr; + + auto linkage = programLayout->getProgram()->getLinkage(); + + DiagnosticSink sink(linkage->getSourceManager()); + + auto specializedType = linkage->specializeType(unspecializedType, specializationArgCount, (Type* const*) specializationArgs, &sink); + + sink.getBlobIfNeeded(outDiagnostics); + + return convert(specializedType); +} + +SLANG_API SlangUInt spReflection_getHashedStringCount( + SlangReflection* reflection) +{ + auto programLayout = convert(reflection); + auto slices = programLayout->hashedStringLiteralPool.getAdded(); + return slices.getCount(); +} + +SLANG_API const char* spReflection_getHashedString( + SlangReflection* reflection, + SlangUInt index, + size_t* outCount) +{ + auto programLayout = convert(reflection); + + auto slices = programLayout->hashedStringLiteralPool.getAdded(); + auto slice = slices[Index(index)]; + + *outCount = slice.getLength(); + return slice.begin(); +} + +SLANG_API int spComputeStringHash(const char* chars, size_t count) +{ + return (int)getStableHashCode32(chars, count); +} + +SLANG_API SlangReflectionTypeLayout* spReflection_getGlobalParamsTypeLayout( + SlangReflection* reflection) +{ + auto programLayout = convert(reflection); + if(!programLayout) return nullptr; + + return convert(programLayout->parametersLayout->typeLayout); +} diff --git a/source/slang/slang-reflection.cpp b/source/slang/slang-reflection.cpp deleted file mode 100644 index 42355ca02..000000000 --- a/source/slang/slang-reflection.cpp +++ /dev/null @@ -1,2508 +0,0 @@ -// slang-reflection.cpp -#include "slang-reflection.h" - -#include "slang-compiler.h" -#include "slang-type-layout.h" -#include "slang-syntax.h" -#include - -// Don't signal errors for stuff we don't implement here, -// and instead just try to return things defensively -// -// Slang developers can switch this when debugging. -#define SLANG_REFLECTION_UNEXPECTED() do {} while(0) - -// Implementation to back public-facing reflection API - -using namespace Slang; - - -// Conversion routines to help with strongly-typed reflection API -static inline Session* convert(SlangSession* session) -{ - return (Session*)session; -} - -static inline UserDefinedAttribute* convert(SlangReflectionUserAttribute* attrib) -{ - return (UserDefinedAttribute*)attrib; -} -static inline SlangReflectionUserAttribute* convert(UserDefinedAttribute* attrib) -{ - return (SlangReflectionUserAttribute*)attrib; -} -static inline Type* convert(SlangReflectionType* type) -{ - return (Type*) type; -} - -static inline SlangReflectionType* convert(Type* type) -{ - return (SlangReflectionType*) type; -} - -static inline TypeLayout* convert(SlangReflectionTypeLayout* type) -{ - return (TypeLayout*) type; -} - -static inline SlangReflectionTypeLayout* convert(TypeLayout* type) -{ - return (SlangReflectionTypeLayout*) type; -} - -static inline SpecializationParamLayout* convert(SlangReflectionTypeParameter * typeParam) -{ - return (SpecializationParamLayout*) typeParam; -} - -static inline VarDeclBase* convert(SlangReflectionVariable* var) -{ - return (VarDeclBase*) var; -} - -static inline SlangReflectionVariable* convert(VarDeclBase* var) -{ - return (SlangReflectionVariable*) var; -} - -static inline VarLayout* convert(SlangReflectionVariableLayout* var) -{ - return (VarLayout*) var; -} - -static inline SlangReflectionVariableLayout* convert(VarLayout* var) -{ - return (SlangReflectionVariableLayout*) var; -} - -static inline EntryPointLayout* convert(SlangReflectionEntryPoint* entryPoint) -{ - return (EntryPointLayout*) entryPoint; -} - -static inline SlangReflectionEntryPoint* convert(EntryPointLayout* entryPoint) -{ - return (SlangReflectionEntryPoint*) entryPoint; -} - -static inline ProgramLayout* convert(SlangReflection* program) -{ - return (ProgramLayout*) program; -} - -static inline SlangReflection* convert(ProgramLayout* program) -{ - return (SlangReflection*) program; -} - -// user attaribute - -unsigned int getUserAttributeCount(Decl* decl) -{ - unsigned int count = 0; - for (auto x : decl->getModifiersOfType()) - { - SLANG_UNUSED(x); - count++; - } - return count; -} - -SlangReflectionUserAttribute* findUserAttributeByName(Session* session, Decl* decl, const char* name) -{ - auto nameObj = session->tryGetNameObj(name); - for (auto x : decl->getModifiersOfType()) - { - if (x->keywordName == nameObj) - return (SlangReflectionUserAttribute*)(x); - } - return nullptr; -} - -SlangReflectionUserAttribute* getUserAttributeByIndex(Decl* decl, unsigned int index) -{ - unsigned int id = 0; - for (auto x : decl->getModifiersOfType()) - { - if (id == index) - return convert(x); - id++; - } - return nullptr; -} - -SLANG_API char const* spReflectionUserAttribute_GetName(SlangReflectionUserAttribute* attrib) -{ - auto userAttr = convert(attrib); - if (!userAttr) return nullptr; - return userAttr->getKeywordName()->text.getBuffer(); -} -SLANG_API unsigned int spReflectionUserAttribute_GetArgumentCount(SlangReflectionUserAttribute* attrib) -{ - auto userAttr = convert(attrib); - if (!userAttr) return 0; - return (unsigned int)userAttr->args.getCount(); -} -SlangReflectionType* spReflectionUserAttribute_GetArgumentType(SlangReflectionUserAttribute* attrib, unsigned int index) -{ - auto userAttr = convert(attrib); - if (!userAttr) return nullptr; - return convert(userAttr->args[index]->type.type); -} -SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueInt(SlangReflectionUserAttribute* attrib, unsigned int index, int * rs) -{ - auto userAttr = convert(attrib); - if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; - if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; - NodeBase* val = nullptr; - if (userAttr->intArgVals.TryGetValue(index, val)) - { - *rs = (int)as(val)->value; - return 0; - } - return SLANG_ERROR_INVALID_PARAMETER; -} -SLANG_API SlangResult spReflectionUserAttribute_GetArgumentValueFloat(SlangReflectionUserAttribute* attrib, unsigned int index, float * rs) -{ - auto userAttr = convert(attrib); - if (!userAttr) return SLANG_ERROR_INVALID_PARAMETER; - if (index >= (unsigned int)userAttr->args.getCount()) return SLANG_ERROR_INVALID_PARAMETER; - if (auto cexpr = as(userAttr->args[index])) - { - *rs = (float)cexpr->value; - return 0; - } - return SLANG_ERROR_INVALID_PARAMETER; -} -SLANG_API const char* spReflectionUserAttribute_GetArgumentValueString(SlangReflectionUserAttribute* attrib, unsigned int index, size_t* bufLen) -{ - auto userAttr = convert(attrib); - if (!userAttr) return nullptr; - if (index >= (unsigned int)userAttr->args.getCount()) return nullptr; - if (auto cexpr = as(userAttr->args[index])) - { - if (bufLen) - *bufLen = cexpr->token.getContentLength(); - return cexpr->token.getContent().begin(); - } - return nullptr; -} - - - -// type Reflection - - -SLANG_API SlangTypeKind spReflectionType_GetKind(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return SLANG_TYPE_KIND_NONE; - - // TODO(tfoley: Don't emit the same type more than once... - - if (auto basicType = as(type)) - { - return SLANG_TYPE_KIND_SCALAR; - } - else if (auto vectorType = as(type)) - { - return SLANG_TYPE_KIND_VECTOR; - } - else if (auto matrixType = as(type)) - { - return SLANG_TYPE_KIND_MATRIX; - } - else if (auto parameterBlockType = as(type)) - { - return SLANG_TYPE_KIND_PARAMETER_BLOCK; - } - else if (auto constantBufferType = as(type)) - { - return SLANG_TYPE_KIND_CONSTANT_BUFFER; - } - else if( auto streamOutputType = as(type) ) - { - return SLANG_TYPE_KIND_OUTPUT_STREAM; - } - else if (as(type)) - { - return SLANG_TYPE_KIND_TEXTURE_BUFFER; - } - else if (as(type)) - { - return SLANG_TYPE_KIND_SHADER_STORAGE_BUFFER; - } - else if (auto samplerStateType = as(type)) - { - return SLANG_TYPE_KIND_SAMPLER_STATE; - } - else if (auto textureType = as(type)) - { - return SLANG_TYPE_KIND_RESOURCE; - } - else if (auto feedbackType = as(type)) - { - return SLANG_TYPE_KIND_FEEDBACK; - } - // TODO: need a better way to handle this stuff... -#define CASE(TYPE) \ - else if(as(type)) do { \ - return SLANG_TYPE_KIND_RESOURCE; \ - } while(0) - - CASE(HLSLStructuredBufferType); - CASE(HLSLRWStructuredBufferType); - CASE(HLSLRasterizerOrderedStructuredBufferType); - CASE(HLSLAppendStructuredBufferType); - CASE(HLSLConsumeStructuredBufferType); - CASE(HLSLByteAddressBufferType); - CASE(HLSLRWByteAddressBufferType); - CASE(HLSLRasterizerOrderedByteAddressBufferType); - CASE(UntypedBufferResourceType); -#undef CASE - - else if (auto arrayType = as(type)) - { - return SLANG_TYPE_KIND_ARRAY; - } - else if( auto declRefType = as(type) ) - { - const auto& declRef = declRefType->declRef; - if(declRef.is() ) - { - return SLANG_TYPE_KIND_STRUCT; - } - else if (declRef.is()) - { - return SLANG_TYPE_KIND_GENERIC_TYPE_PARAMETER; - } - else if (declRef.is()) - { - return SLANG_TYPE_KIND_INTERFACE; - } - else if (declRef.is()) - { - // This is a reference to an entry point - return SLANG_TYPE_KIND_STRUCT; - } - } - else if( auto specializedType = as(type) ) - { - return SLANG_TYPE_KIND_SPECIALIZED; - } - else if (auto errorType = as(type)) - { - // This means we saw a type we didn't understand in the user's code - return SLANG_TYPE_KIND_NONE; - } - - SLANG_REFLECTION_UNEXPECTED(); - return SLANG_TYPE_KIND_NONE; -} - -SLANG_API unsigned int spReflectionType_GetFieldCount(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - // TODO: maybe filter based on kind - - if(auto declRefType = as(type)) - { - auto declRef = declRefType->declRef; - if( auto structDeclRef = declRef.as()) - { - return (unsigned int)getFields(structDeclRef, MemberFilterStyle::Instance).getCount(); - } - } - - return 0; -} - -SLANG_API SlangReflectionVariable* spReflectionType_GetFieldByIndex(SlangReflectionType* inType, unsigned index) -{ - auto type = convert(inType); - if(!type) return nullptr; - - // TODO: maybe filter based on kind - - if(auto declRefType = as(type)) - { - auto declRef = declRefType->declRef; - if( auto structDeclRef = declRef.as()) - { - auto fields = getFields(structDeclRef, MemberFilterStyle::Instance); - auto fieldDeclRef = fields[index]; - return (SlangReflectionVariable*) fieldDeclRef.getDecl(); - } - } - - return nullptr; -} - -SLANG_API size_t spReflectionType_GetElementCount(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - if(auto arrayType = as(type)) - { - return arrayType->arrayLength ? (size_t) getIntVal(arrayType->arrayLength) : 0; - } - else if( auto vectorType = as(type)) - { - return (size_t) getIntVal(vectorType->elementCount); - } - - return 0; -} - -SLANG_API SlangReflectionType* spReflectionType_GetElementType(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return nullptr; - - if(auto arrayType = as(type)) - { - return (SlangReflectionType*) arrayType->baseType; - } - else if( auto parameterGroupType = as(type)) - { - return convert(parameterGroupType->elementType); - } - else if( auto vectorType = as(type)) - { - return convert(vectorType->elementType); - } - else if( auto matrixType = as(type)) - { - return convert(matrixType->getElementType()); - } - - return nullptr; -} - -SLANG_API unsigned int spReflectionType_GetRowCount(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - if(auto matrixType = as(type)) - { - return (unsigned int) getIntVal(matrixType->getRowCount()); - } - else if(auto vectorType = as(type)) - { - return 1; - } - else if( auto basicType = as(type) ) - { - return 1; - } - - return 0; -} - -SLANG_API unsigned int spReflectionType_GetColumnCount(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - if(auto matrixType = as(type)) - { - return (unsigned int) getIntVal(matrixType->getColumnCount()); - } - else if(auto vectorType = as(type)) - { - return (unsigned int) getIntVal(vectorType->elementCount); - } - else if( auto basicType = as(type) ) - { - return 1; - } - - return 0; -} - -SLANG_API SlangScalarType spReflectionType_GetScalarType(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - if(auto matrixType = as(type)) - { - type = matrixType->getElementType(); - } - else if(auto vectorType = as(type)) - { - type = vectorType->elementType; - } - - if(auto basicType = as(type)) - { - switch (basicType->baseType) - { -#define CASE(BASE, TAG) \ - case BaseType::BASE: return SLANG_SCALAR_TYPE_##TAG - - CASE(Void, VOID); - CASE(Bool, BOOL); - CASE(Int8, INT8); - CASE(Int16, INT16); - CASE(Int, INT32); - CASE(Int64, INT64); - CASE(UInt8, UINT8); - CASE(UInt16, UINT16); - CASE(UInt, UINT32); - CASE(UInt64, UINT64); - CASE(Half, FLOAT16); - CASE(Float, FLOAT32); - CASE(Double, FLOAT64); - -#undef CASE - - default: - SLANG_REFLECTION_UNEXPECTED(); - return SLANG_SCALAR_TYPE_NONE; - break; - } - } - - return SLANG_SCALAR_TYPE_NONE; -} - -SLANG_API unsigned int spReflectionType_GetUserAttributeCount(SlangReflectionType* inType) -{ - auto type = convert(inType); - if (!type) return 0; - if (auto declRefType = as(type)) - { - return getUserAttributeCount(declRefType->declRef.getDecl()); - } - return 0; -} -SLANG_API SlangReflectionUserAttribute* spReflectionType_GetUserAttribute(SlangReflectionType* inType, unsigned int index) -{ - auto type = convert(inType); - if (!type) return 0; - if (auto declRefType = as(type)) - { - return getUserAttributeByIndex(declRefType->declRef.getDecl(), index); - } - return 0; -} -SLANG_API SlangReflectionUserAttribute* spReflectionType_FindUserAttributeByName(SlangReflectionType* inType, char const* name) -{ - auto type = convert(inType); - if (!type) return 0; - if (auto declRefType = as(type)) - { - ASTBuilder* astBuilder = declRefType->getASTBuilder(); - auto globalSession = astBuilder->getGlobalSession(); - - return findUserAttributeByName(globalSession, declRefType->declRef.getDecl(), name); - } - return 0; -} - -SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - while(auto arrayType = as(type)) - { - type = arrayType->baseType; - } - - if(auto textureType = as(type)) - { - return textureType->getShape(); - } - - // TODO: need a better way to handle this stuff... -#define CASE(TYPE, SHAPE, ACCESS) \ - else if(as(type)) do { \ - return SHAPE; \ - } while(0) - - CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); - CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); - CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); - CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); - CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); - CASE(HLSLByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); - CASE(HLSLRWByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); - CASE(HLSLRasterizerOrderedByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); - CASE(RaytracingAccelerationStructureType, SLANG_ACCELERATION_STRUCTURE, SLANG_RESOURCE_ACCESS_READ); - CASE(UntypedBufferResourceType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); -#undef CASE - - return SLANG_RESOURCE_NONE; -} - -SLANG_API SlangResourceAccess spReflectionType_GetResourceAccess(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return 0; - - while(auto arrayType = as(type)) - { - type = arrayType->baseType; - } - - if(auto textureType = as(type)) - { - return textureType->getAccess(); - } - - // TODO: need a better way to handle this stuff... -#define CASE(TYPE, SHAPE, ACCESS) \ - else if(as(type)) do { \ - return ACCESS; \ - } while(0) - - CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); - CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); - CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); - CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); - CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); - CASE(HLSLByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); - CASE(HLSLRWByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); - CASE(HLSLRasterizerOrderedByteAddressBufferType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); - CASE(UntypedBufferResourceType, SLANG_BYTE_ADDRESS_BUFFER, SLANG_RESOURCE_ACCESS_READ); - - // This isn't entirely accurate, but I can live with it for now - CASE(GLSLShaderStorageBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); -#undef CASE - - return SLANG_RESOURCE_ACCESS_NONE; -} - -SLANG_API char const* spReflectionType_GetName(SlangReflectionType* inType) -{ - auto type = convert(inType); - - if( auto declRefType = as(type) ) - { - auto declRef = declRefType->declRef; - - // Don't return a name for auto-generated anonymous types - // that represent `cbuffer` members, etc. - auto decl = declRef.getDecl(); - if(decl->hasModifier()) - return nullptr; - - return getText(declRef.getName()).begin(); - } - - return nullptr; -} - -SLANG_API SlangReflectionType * spReflection_FindTypeByName(SlangReflection * reflection, char const * name) -{ - auto programLayout = convert(reflection); - auto program = programLayout->getProgram(); - - // TODO: We should extend this API to support getting error messages - // when type lookup fails. - // - Slang::DiagnosticSink sink( - programLayout->getTargetReq()->getLinkage()->getSourceManager()); - - try - { - Type* result = program->getTypeFromString(name, &sink); - return (SlangReflectionType*)result; - } - catch( ... ) - { - return nullptr; - } -} - -SLANG_API SlangReflectionTypeLayout* spReflection_GetTypeLayout( - SlangReflection* reflection, - SlangReflectionType* inType, - SlangLayoutRules /*rules*/) -{ - auto context = convert(reflection); - auto type = convert(inType); - auto targetReq = context->getTargetReq(); - - auto typeLayout = targetReq->getTypeLayout(type); - return convert(typeLayout); -} - -SLANG_API SlangReflectionType* spReflectionType_GetResourceResultType(SlangReflectionType* inType) -{ - auto type = convert(inType); - if(!type) return nullptr; - - while(auto arrayType = as(type)) - { - type = arrayType->baseType; - } - - if (auto textureType = as(type)) - { - return convert(textureType->elementType); - } - - // TODO: need a better way to handle this stuff... -#define CASE(TYPE, SHAPE, ACCESS) \ - else if(as(type)) do { \ - return convert(as(type)->elementType); \ - } while(0) - - // TODO: structured buffer needs to expose type layout! - - CASE(HLSLStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ); - CASE(HLSLRWStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_READ_WRITE); - CASE(HLSLRasterizerOrderedStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_RASTER_ORDERED); - CASE(HLSLAppendStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_APPEND); - CASE(HLSLConsumeStructuredBufferType, SLANG_STRUCTURED_BUFFER, SLANG_RESOURCE_ACCESS_CONSUME); -#undef CASE - - return nullptr; -} - -// type Layout Reflection - -SLANG_API SlangReflectionType* spReflectionTypeLayout_GetType(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - return (SlangReflectionType*) typeLayout->type; -} - -SLANG_API SlangTypeKind spReflectionTypeLayout_getKind(SlangReflectionTypeLayout* inTypeLayout) -{ - if(!inTypeLayout) return SLANG_TYPE_KIND_NONE; - - if( auto type = spReflectionTypeLayout_GetType(inTypeLayout) ) - { - return spReflectionType_GetKind(type); - } - - auto typeLayout = convert(inTypeLayout); - if( as(typeLayout) ) - { - return SLANG_TYPE_KIND_STRUCT; - } - else if( as(typeLayout) ) - { - return SLANG_TYPE_KIND_CONSTANT_BUFFER; - } - - return SLANG_TYPE_KIND_NONE; -} - -namespace -{ - static size_t getReflectionSize(LayoutSize size) - { - if(size.isFinite()) - return size.getFiniteValue(); - - return SLANG_UNBOUNDED_SIZE; - } -} - -SLANG_API size_t spReflectionTypeLayout_GetSize(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto info = typeLayout->FindResourceInfo(LayoutResourceKind(category)); - if(!info) return 0; - - return getReflectionSize(info->count); -} - -SLANG_API int32_t spReflectionTypeLayout_getAlignment(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - if( category == SLANG_PARAMETER_CATEGORY_UNIFORM ) - { - return int32_t(typeLayout->uniformAlignment); - } - else - { - return 1; - } -} - -SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetFieldByIndex(SlangReflectionTypeLayout* inTypeLayout, unsigned index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - if(auto structTypeLayout = as(typeLayout)) - { - return (SlangReflectionVariableLayout*) structTypeLayout->fields[index].Ptr(); - } - - return nullptr; -} - -SLANG_API SlangInt spReflectionTypeLayout_findFieldIndexByName(SlangReflectionTypeLayout* inTypeLayout, const char* nameBegin, const char* nameEnd) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return -1; - - UnownedStringSlice name = nameEnd != nullptr ? UnownedStringSlice(nameBegin, nameEnd) : UnownedTerminatedStringSlice(nameBegin); - - if(auto structTypeLayout = as(typeLayout)) - { - Index fieldCount = structTypeLayout->fields.getCount(); - for(Index f = 0; f < fieldCount; ++f) - { - auto field = structTypeLayout->fields[f]; - if(getReflectionName(field->varDecl)->text.getUnownedSlice() == name) - return f; - } - } - - return -1; -} - -SLANG_API size_t spReflectionTypeLayout_GetElementStride(SlangReflectionTypeLayout* inTypeLayout, SlangParameterCategory category) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - if( auto arrayTypeLayout = as(typeLayout)) - { - switch (category) - { - // We store the stride explicitly for the uniform case - case SLANG_PARAMETER_CATEGORY_UNIFORM: - return arrayTypeLayout->uniformStride; - - // For most other cases (resource registers), the "stride" - // of an array is simply the number of resources (if any) - // consumed by its element type. - default: - { - auto elementTypeLayout = arrayTypeLayout->elementTypeLayout; - auto info = elementTypeLayout->FindResourceInfo(LayoutResourceKind(category)); - if(!info) return 0; - return getReflectionSize(info->count); - } - - // An important special case, though, is Vulkan descriptor-table slots, - // where an entire array will use a single `binding`, so that the - // effective stride is zero: - case SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT: - return 0; - } - } - - return 0; -} - -SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_GetElementTypeLayout(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - if( auto arrayTypeLayout = as(typeLayout)) - { - return (SlangReflectionTypeLayout*) arrayTypeLayout->elementTypeLayout.Ptr(); - } - else if( auto constantBufferTypeLayout = as(typeLayout)) - { - return convert(constantBufferTypeLayout->offsetElementTypeLayout.Ptr()); - } - else if( auto structuredBufferTypeLayout = as(typeLayout)) - { - return convert(structuredBufferTypeLayout->elementTypeLayout.Ptr()); - } - else if( auto specializedTypeLayout = as(typeLayout) ) - { - return convert(specializedTypeLayout->baseTypeLayout.Ptr()); - } - - return nullptr; -} - -SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetElementVarLayout(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - if( auto parameterGroupTypeLayout = as(typeLayout)) - { - return convert(parameterGroupTypeLayout->elementVarLayout.Ptr()); - } - - return nullptr; -} - -SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_getContainerVarLayout(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - if( auto parameterGroupTypeLayout = as(typeLayout)) - { - return convert(parameterGroupTypeLayout->containerVarLayout.Ptr()); - } - - return nullptr; -} - -static SlangParameterCategory getParameterCategory( - LayoutResourceKind kind) -{ - return SlangParameterCategory(kind); -} - -static SlangParameterCategory getParameterCategory( - TypeLayout* typeLayout) -{ - auto resourceInfoCount = typeLayout->resourceInfos.getCount(); - if(resourceInfoCount == 1) - { - return getParameterCategory(typeLayout->resourceInfos[0].kind); - } - else if(resourceInfoCount == 0) - { - // TODO: can this ever happen? - return SLANG_PARAMETER_CATEGORY_NONE; - } - return SLANG_PARAMETER_CATEGORY_MIXED; -} - -SLANG_API SlangParameterCategory spReflectionTypeLayout_GetParameterCategory(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; - - return getParameterCategory(typeLayout); -} - -SLANG_API unsigned spReflectionTypeLayout_GetCategoryCount(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return (unsigned) typeLayout->resourceInfos.getCount(); -} - -SLANG_API SlangParameterCategory spReflectionTypeLayout_GetCategoryByIndex(SlangReflectionTypeLayout* inTypeLayout, unsigned index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return SLANG_PARAMETER_CATEGORY_NONE; - - return typeLayout->resourceInfos[index].kind; -} - -SLANG_API SlangMatrixLayoutMode spReflectionTypeLayout_GetMatrixLayoutMode(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; - - if( auto matrixLayout = as(typeLayout) ) - { - return matrixLayout->mode; - } - else - { - return SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; - } - -} - -SLANG_API int spReflectionTypeLayout_getGenericParamIndex(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return -1; - - if(auto genericParamTypeLayout = as(typeLayout)) - { - return (int) genericParamTypeLayout->paramIndex; - } - else - { - return -1; - } -} - -SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getPendingDataTypeLayout(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - auto pendingDataTypeLayout = typeLayout->pendingDataTypeLayout.Ptr(); - return convert(pendingDataTypeLayout); -} - -SLANG_API SlangReflectionVariableLayout* spReflectionVariableLayout_getPendingDataLayout(SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return nullptr; - - auto pendingDataLayout = varLayout->pendingVarLayout.Ptr(); - return convert(pendingDataLayout); -} - -SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_getSpecializedTypePendingDataVarLayout(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return nullptr; - - if( auto specializedTypeLayout = as(typeLayout) ) - { - auto pendingDataVarLayout = specializedTypeLayout->pendingDataVarLayout.Ptr(); - return convert(pendingDataVarLayout); - } - else - { - return nullptr; - } -} - -namespace Slang -{ - struct BindingRangePathLink - { - BindingRangePathLink( - BindingRangePathLink* parent, - VarLayout* var) - : parent(parent) - , var(var) - {} - - BindingRangePathLink* parent; - VarLayout* var; - }; - - - Int _calcIndexOffset(BindingRangePathLink* path, LayoutResourceKind kind) - { - Int result = 0; - for( auto link = path; link; link = link->parent ) - { - if( auto resInfo = link->var->FindResourceInfo(kind) ) - { - result += resInfo->index; - } - } - return result; - } - - Int _calcSpaceOffset(BindingRangePathLink* path, LayoutResourceKind kind) - { - Int result = 0; - for( auto link = path; link; link = link->parent ) - { - if( auto resInfo = link->var->FindResourceInfo(kind) ) - { - result += resInfo->space; - } - } - return result; - } - - SlangBindingType _calcResourceBindingType( - Type* type) - { - if( auto resourceType = as(type) ) - { - auto shape = resourceType->getBaseShape(); - - auto access = resourceType->getAccess(); - auto mutableFlag = access != SLANG_RESOURCE_ACCESS_READ ? SLANG_BINDING_TYPE_MUTABLE_FLAG : 0; - - switch( shape ) - { - default: - return SLANG_BINDING_TYPE_TEXTURE | mutableFlag; - - case SLANG_TEXTURE_BUFFER: - return SLANG_BINDING_TYPE_TYPED_BUFFER | mutableFlag; - } - - } - else if( auto structuredBufferType = as(type) ) - { - if( as(type) ) - { - return SLANG_BINDING_TYPE_RAW_BUFFER; - } - else - { - return SLANG_BINDING_TYPE_MUTABLE_RAW_BUFFER; - } - } - else if( as(type) ) - { - return SLANG_BINDING_TYPE_RAY_TRACTING_ACCELERATION_STRUCTURE; - } - else if( auto untypedBufferType = as(type) ) - { - if( as(type) ) - { - return SLANG_BINDING_TYPE_RAW_BUFFER; - } - else - { - return SLANG_BINDING_TYPE_MUTABLE_RAW_BUFFER; - } - } - else if( as(type) ) - { - return SLANG_BINDING_TYPE_CONSTANT_BUFFER; - } - else - { - SLANG_UNEXPECTED("unhandled resource binding type"); - } - } - - SlangBindingType _calcResourceBindingType( - TypeLayout* typeLayout) - { - if(auto type = typeLayout->getType()) - { - return _calcResourceBindingType(type); - } - - if(as(typeLayout)) - { - return SLANG_BINDING_TYPE_CONSTANT_BUFFER; - } - else - { - SLANG_UNEXPECTED("unhandled resource binding type"); - } - } - - - SlangBindingType _calcBindingType( - Slang::TypeLayout* typeLayout, - LayoutResourceKind kind) - { - switch( kind ) - { - default: - return SLANG_BINDING_TYPE_UNKNOWN; - - // Some cases of `LayoutResourceKind` can be mapped - // directly to a `BindingType` because there is only - // one case of types that have that resource kind. - - #define CASE(FROM, TO) \ - case LayoutResourceKind::FROM: return SLANG_BINDING_TYPE_##TO - - CASE(ConstantBuffer, CONSTANT_BUFFER); - CASE(SamplerState, SAMPLER); - CASE(VaryingInput, VARYING_INPUT); - CASE(VaryingOutput, VARYING_OUTPUT); - CASE(ExistentialObjectParam, EXISTENTIAL_VALUE); - CASE(PushConstantBuffer, PUSH_CONSTANT); - // TODO: register space - - #undef CASE - - case LayoutResourceKind::ShaderResource: - case LayoutResourceKind::UnorderedAccess: - case LayoutResourceKind::DescriptorTableSlot: - return _calcResourceBindingType(typeLayout); - } - } - - static DeclRefType* asInterfaceType(Type* type) - { - if(auto declRefType = as(type)) - { - if(declRefType->declRef.as()) - { - return declRefType; - } - } - return nullptr; - } - - struct ExtendedTypeLayoutContext - { - TypeLayout* m_typeLayout; - TypeLayout::ExtendedInfo* m_extendedInfo; - - Dictionary m_mapSpaceToDescriptorSetIndex; - - Int _findOrAddDescriptorSet(Int space) - { - Int index = 0; - if(m_mapSpaceToDescriptorSetIndex.TryGetValue(space, index)) - return index; - - index = m_extendedInfo->m_descriptorSets.getCount(); - m_mapSpaceToDescriptorSetIndex.Add(space, index); - - RefPtr descriptorSet = new TypeLayout::ExtendedInfo::DescriptorSetInfo(); - m_extendedInfo->m_descriptorSets.add(descriptorSet); - - return index; - } - - void addRangesRec(TypeLayout* typeLayout, BindingRangePathLink* path, LayoutSize multiplier) - { - if( auto structTypeLayout = as(typeLayout) ) - { - // For a structure type, we need to recursively - // add the ranges for each field. - // - // Along the way we will make sure to properly update - // the offset information on the fields so that - // they properly show their binding-range offset - // within the parent type. - // - Index structBindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); - for( auto fieldVarLayout : structTypeLayout->fields ) - { - Index fieldBindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); - fieldVarLayout->bindingRangeOffset = fieldBindingRangeIndex - structBindingRangeIndex; - - auto fieldTypeLayout = fieldVarLayout->getTypeLayout(); - - - BindingRangePathLink fieldLink(path, fieldVarLayout); - addRangesRec(fieldTypeLayout, &fieldLink, multiplier); - } - return; - } - else if( auto arrayTypeLayout = as(typeLayout) ) - { - // For an array, we need to recursively add the - // element type of the array, but with an adjusted - // `multiplier` to account for the element count. - // - auto elementTypeLayout = arrayTypeLayout->elementTypeLayout; - LayoutSize elementCount = LayoutSize::infinite(); - if( auto arrayType = as(arrayTypeLayout->type) ) - { - if( auto elementCountVal = arrayType->arrayLength ) - { - elementCount = LayoutSize::RawValue(getIntVal(elementCountVal)); - } - } - addRangesRec(elementTypeLayout, path, multiplier * elementCount); - return; - } - else if( auto parameterGroupTypeLayout = as(typeLayout)) - { - // A parameter group (whether a `ConstantBuffer<>` or `ParameterBlock<>` - // introduces a separately-allocated "sub-object" in the application's - // layout for shader objects. - // - // We will represent the parameter group with a single sub-object - // binding range (and an associated sub-object range). - // - // We start out by looking at the resources consumed by the parameter group - // itself, to determine what kind of binding range to report it as. - // - Index bindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); - SlangBindingType bindingType = SLANG_BINDING_TYPE_CONSTANT_BUFFER; - Index spaceOffset = -1; - LayoutResourceKind kind = LayoutResourceKind::None; - for(auto& resInfo : parameterGroupTypeLayout->resourceInfos) - { - kind = resInfo.kind; - switch(kind) - { - default: - continue; - - case LayoutResourceKind::ConstantBuffer: - case LayoutResourceKind::PushConstantBuffer: - case LayoutResourceKind::RegisterSpace: - case LayoutResourceKind::DescriptorTableSlot: - break; - } - - bindingType = _calcBindingType(typeLayout, kind); - spaceOffset = _calcSpaceOffset(path, kind); - break; - } - - TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; - bindingRange.leafTypeLayout = typeLayout; - bindingRange.bindingType = bindingType; - bindingRange.count = multiplier; - bindingRange.descriptorSetIndex = -1; - bindingRange.firstDescriptorRangeIndex = 0; - bindingRange.descriptorRangeCount = 0; - - if( kind == LayoutResourceKind::PushConstantBuffer ) - { - if(auto resInfo = parameterGroupTypeLayout->elementVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform)) - { - bindingRange.count *= resInfo->count; - } - } - - // Every parameter group will introduce a sub-object range, - // which will include bindings based on the type of data - // inside the sub-object. - // - TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange; - subObjectRange.bindingRangeIndex = bindingRangeIndex; - - // It is possible that the sub-object has descriptor ranges - // that will need to be exposed upward, into the parent. - // - if( spaceOffset != -1 ) - { - Int descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); - auto descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; - auto firstDescriptorRangeIndex = descriptorSet->descriptorRanges.getCount(); - - // TODO: We need to recursively add descriptor ranges (but not binding - // ranges!) for anything in the element type that "leaks" into - // the surrounding context. - // - switch(kind) - { - case LayoutResourceKind::RegisterSpace: - case LayoutResourceKind::Uniform: - case LayoutResourceKind::None: - break; - - default: - { - // This means we are in the constant-buffer-like case - // (even if the user wrote `ParameterBlock`), and any - // resource usage inside the element type should "leak" - // out to the parent scope. - // - // It *also* means we should add a suitable descriptor - // range if one is required for the "container" type. - // - for(auto resInfo : parameterGroupTypeLayout->containerVarLayout->typeLayout->resourceInfos) - { - switch( resInfo.kind ) - { - case LayoutResourceKind::RegisterSpace: - case LayoutResourceKind::Uniform: - continue; - - default: - break; - } - - TypeLayout::ExtendedInfo::DescriptorRangeInfo descriptorRange; - descriptorRange.kind = resInfo.kind; - descriptorRange.bindingType = _calcBindingType(typeLayout, resInfo.kind); - descriptorRange.count = multiplier; - descriptorRange.indexOffset = _calcIndexOffset(path, resInfo.kind); - - if( resInfo.kind == LayoutResourceKind::PushConstantBuffer ) - { - if(auto uniformResInfo = parameterGroupTypeLayout->elementVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform)) - { - descriptorRange.count *= uniformResInfo->count; - } - } - - descriptorSet->descriptorRanges.add(descriptorRange); - } - - // Now we need to recursively walk the element type and add all its - // descriptor ranges, so that they can be used for binding in - // the parent. - // - // We have this a bit by collecting both binding ranges and - // descriptor ranges, and then throwing away the binding ranges - // from the element type. - // - BindingRangePathLink elementPath(path, parameterGroupTypeLayout->elementVarLayout); - - Index bindingRangeCountBefore = m_extendedInfo->m_bindingRanges.getCount(); - Index subObjectRangeCountBefore = m_extendedInfo->m_subObjectRanges.getCount(); - - addRangesRec(parameterGroupTypeLayout->elementVarLayout->typeLayout, &elementPath, multiplier); - - m_extendedInfo->m_bindingRanges.setCount(bindingRangeCountBefore); - m_extendedInfo->m_subObjectRanges.setCount(subObjectRangeCountBefore); - } - break; - } - - auto descriptorRangeCount = descriptorSet->descriptorRanges.getCount() - firstDescriptorRangeIndex; - bindingRange.descriptorSetIndex = descriptorSetIndex; - bindingRange.firstDescriptorRangeIndex = firstDescriptorRangeIndex; - bindingRange.descriptorRangeCount = descriptorRangeCount; - } - - m_extendedInfo->m_bindingRanges.add(bindingRange); - m_extendedInfo->m_subObjectRanges.add(subObjectRange); - return; - } - else if(asInterfaceType(typeLayout->type)) - { - // An `interface` type should introduce a sub-object range, - // with no concrete descriptor ranges to store its value - // (since we don't know until runtime what type of - // value will be plugged in). - // - - LayoutResourceKind kind = LayoutResourceKind::ExistentialObjectParam; - auto count = multiplier; - auto spaceOffset = _calcSpaceOffset(path, kind); - - Int descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); - auto descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; - - TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; - bindingRange.leafTypeLayout = typeLayout; - bindingRange.bindingType = SLANG_BINDING_TYPE_EXISTENTIAL_VALUE; - bindingRange.count = multiplier; - bindingRange.descriptorSetIndex = descriptorSetIndex; - bindingRange.firstDescriptorRangeIndex = descriptorSet->descriptorRanges.getCount(); - bindingRange.descriptorRangeCount = 1; - - TypeLayout::ExtendedInfo::SubObjectRangeInfo subObjectRange; - subObjectRange.bindingRangeIndex = m_extendedInfo->m_bindingRanges.getCount(); - - m_extendedInfo->m_bindingRanges.add(bindingRange); - m_extendedInfo->m_subObjectRanges.add(subObjectRange); - } - // TODO: We need to handle `interface` types here, because they are - // another case that introduces a "sub-object" for the purposes of - // application-side allocation. - // - // TODO: There are a few cases of "leaf" fields that might - // still result in multiple descriptors (or at least multiple - // `LayoutResourceKind`s) depending on the target. - // - // For eample, combined texture-sampler types should be treated - // as "leaf" fields for this code (since a portable engine would - // need to abstract over them), but would map to two descriptors - // on targets that don't actually support combining them. - else - { - Int resourceKindCount = typeLayout->resourceInfos.getCount(); - if(resourceKindCount == 0) - { - // This is a field that consumes no resources, and as - // such does not need a binding or descriptor ranges - // allocated for it. - // - return; - } - else if(resourceKindCount == 1) - { - auto& resInfo = typeLayout->resourceInfos[0]; - LayoutResourceKind kind = resInfo.kind; - - if(kind == LayoutResourceKind::Uniform) - { - // We do not consider uniform resource usage - // in the ranges we compute. - // - // TODO: We may need to revise that rule for types that - // represent resources, even when one or more targets - // map those resource types to ordinary/uniform data. - // - return; - } - - // This leaf field will map to a single binding range and, - // if it is appropriate, a single descriptor range. - // - auto bindingType = _calcBindingType(typeLayout, kind); - auto count = resInfo.count * multiplier; - auto indexOffset = _calcIndexOffset(path, kind); - auto spaceOffset = _calcSpaceOffset(path, kind); - - Int descriptorSetIndex = -1; - Int firstDescriptorIndex = 0; - RefPtr descriptorSet; - switch( kind ) - { - case LayoutResourceKind::RegisterSpace: - case LayoutResourceKind::VaryingInput: - case LayoutResourceKind::VaryingOutput: - case LayoutResourceKind::HitAttributes: - case LayoutResourceKind::RayPayload: - // Resource kinds that represent "varying" input/output - // do not manifest as entries in API descriptor tables. - // - // TODO: Neither do root constants, if we are being - // precise. This API really needs to carefully match - // the semantics of the target platform/API in terms - // of what things are descriptor-bound and which are - // not, so that a user can easily allocate the platform-specific - // descriptor sets using this info. - // - // (That said, we are purposefully *not* breaking apart - // samplers and SRV/UAV/CBV stuff for our D3D reflection - // of descriptor sets. It seems like the policy here - // really requires careful thought) - // - // TODO: Maybe the best answer is to leave decomposition - // of stuff into descriptor sets up to the application - // layer? This is especially true if a common case would - // be an application that doesn't support arbitrary manual - // binding of parameters to register/spaces. - // - break; - - default: - { - TypeLayout::ExtendedInfo::DescriptorRangeInfo descriptorRange; - descriptorRange.kind = kind; - descriptorRange.bindingType = bindingType; - descriptorRange.count = count; - descriptorRange.indexOffset = indexOffset; - - descriptorSetIndex = _findOrAddDescriptorSet(spaceOffset); - descriptorSet = m_extendedInfo->m_descriptorSets[descriptorSetIndex]; - - firstDescriptorIndex = descriptorSet->descriptorRanges.getCount(); - descriptorSet->descriptorRanges.add(descriptorRange); - } - break; - } - - - TypeLayout::ExtendedInfo::BindingRangeInfo bindingRange; - bindingRange.leafTypeLayout = typeLayout; - bindingRange.bindingType = _calcBindingType(typeLayout, kind); - bindingRange.count = count; - bindingRange.descriptorSetIndex = descriptorSetIndex; - bindingRange.firstDescriptorRangeIndex = firstDescriptorIndex; - bindingRange.descriptorRangeCount = 1; - - m_extendedInfo->m_bindingRanges.add(bindingRange); - } - else - { - // This type appears to be one that consumes multiple - // resource kinds, but was not handled by any of - // the special-case logic above. In such a case we - // are in trouble. - // - return; - } - } - } - }; - - TypeLayout::ExtendedInfo* getExtendedTypeLayout(TypeLayout* typeLayout) - { - if( !typeLayout->m_extendedInfo ) - { - RefPtr extendedInfo = new TypeLayout::ExtendedInfo; - - ExtendedTypeLayoutContext context; - context.m_typeLayout = typeLayout; - context.m_extendedInfo = extendedInfo; - - context.addRangesRec(typeLayout, nullptr, 1); - - typeLayout->m_extendedInfo = extendedInfo; - } - return typeLayout->m_extendedInfo; - } -} - -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeCount(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - return extTypeLayout->m_bindingRanges.getCount(); -} - -SLANG_API SlangBindingType spReflectionTypeLayout_getBindingRangeType(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return SLANG_BINDING_TYPE_UNKNOWN; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; - auto& bindingRange = extTypeLayout->m_bindingRanges[index]; - - return bindingRange.bindingType; -} - -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeBindingCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; - auto& bindingRange = extTypeLayout->m_bindingRanges[index]; - - auto count = bindingRange.count; - return count.isFinite() ? SlangInt(count.getFiniteValue()) : -1; -} - -#if 0 -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return Slang::_findBindingRange(typeLayout, index).indexOffset; -} - -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return Slang::_findBindingRange(typeLayout, index).spaceOffset; -} -#endif - -SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getBindingRangeLeafTypeLayout(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; - auto& bindingRange = extTypeLayout->m_bindingRanges[index]; - - return convert(bindingRange.leafTypeLayout); -} - -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeDescriptorSetIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; - auto& bindingRange = extTypeLayout->m_bindingRanges[index]; - - return bindingRange.descriptorSetIndex; -} - -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeFirstDescriptorRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - if(index < 0) return 0; - if(index >= extTypeLayout->m_bindingRanges.getCount()) return 0; - auto& bindingRange = extTypeLayout->m_bindingRanges[index]; - - return bindingRange.firstDescriptorRangeIndex; -} - -SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetCount(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - return extTypeLayout->m_descriptorSets.getCount(); -} - -SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - return descriptorSet->spaceOffset; -} - -SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - return descriptorSet->descriptorRanges.getCount(); -} - -SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; - auto& range = descriptorSet->descriptorRanges[rangeIndex]; - - return range.indexOffset; -} - -SLANG_API SlangInt spReflectionTypeLayout_getDescriptorSetDescriptorRangeDescriptorCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; - auto& range = descriptorSet->descriptorRanges[rangeIndex]; - - auto count = range.count; - return count.isFinite() ? count.getFiniteValue() : -1; -} - -SLANG_API SlangBindingType spReflectionTypeLayout_getDescriptorSetDescriptorRangeType(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; - auto& range = descriptorSet->descriptorRanges[rangeIndex]; - - return range.bindingType; -} - -SLANG_API SlangParameterCategory spReflectionTypeLayout_getDescriptorSetDescriptorRangeCategory(SlangReflectionTypeLayout* inTypeLayout, SlangInt setIndex, SlangInt rangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(setIndex < 0) return 0; - if(setIndex >= extTypeLayout->m_descriptorSets.getCount()) return 0; - auto descriptorSet = extTypeLayout->m_descriptorSets[setIndex]; - - if(rangeIndex < 0) return 0; - if(rangeIndex >= descriptorSet->descriptorRanges.getCount()) return 0; - auto& range = descriptorSet->descriptorRanges[rangeIndex]; - - return SlangParameterCategory(range.kind); -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeCount(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - return extTypeLayout->m_subObjectRanges.getCount(); -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeBindingRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto extTypeLayout = Slang::getExtendedTypeLayout(typeLayout); - - if(subObjectRangeIndex < 0) return 0; - if(subObjectRangeIndex >= extTypeLayout->m_subObjectRanges.getCount()) return 0; - - return extTypeLayout->m_subObjectRanges[subObjectRangeIndex].bindingRangeIndex; -} - - -#if 0 -SLANG_API SlangInt spReflectionTypeLayout_getBindingRangeSubObjectRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return Slang::_findBindingRange(typeLayout, index).subObjectRangeIndex; -} -#endif - - -SLANG_API SlangInt spReflectionTypeLayout_getFieldBindingRangeOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt fieldIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - if( auto structTypeLayout = as(typeLayout) ) - { - getExtendedTypeLayout(structTypeLayout); - - return structTypeLayout->fields[fieldIndex]->bindingRangeOffset; - } - - return 0; -} - -#if 0 -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeCount(SlangReflectionTypeLayout* inTypeLayout) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return Slang::_calcSubObjectRangeCount(typeLayout); -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeObjectCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto count = Slang::_findSubObjectRange(typeLayout, index).count; - return count.isFinite() ? SlangInt(count.getFiniteValue()) : -1; -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeBindingRangeIndex(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return Slang::_findSubObjectRange(typeLayout, index).bindingRangeIndex; -} - - -SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_getSubObjectRangeTypeLayout(SlangReflectionTypeLayout* inTypeLayout, SlangInt index) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - return convert(Slang::_findSubObjectRange(typeLayout, index).leafTypeLayout); -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); - return Slang::_getSubObjectDescriptorRangeCount(subObjectRange); -} - -SLANG_API SlangBindingType spReflectionTypeLayout_getSubObjectRangeDescriptorRangeBindingType(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); - return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).bindingType; -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeBindingCount(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); - auto count = Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).count; - return count.isFinite() ? count.getFiniteValue() : -1; -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeIndexOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); - return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).indexOffset; -} - -SLANG_API SlangInt spReflectionTypeLayout_getSubObjectRangeDescriptorRangeSpaceOffset(SlangReflectionTypeLayout* inTypeLayout, SlangInt subObjectRangeIndex, SlangInt bindingRangeIndexInSubObject) -{ - auto typeLayout = convert(inTypeLayout); - if(!typeLayout) return 0; - - auto subObjectRange = Slang::_findSubObjectRange(typeLayout, subObjectRangeIndex); - return Slang::_getSubObjectDescriptorRange(subObjectRange, bindingRangeIndexInSubObject).spaceOffset; -} -#endif - -// Variable Reflection - -SLANG_API char const* spReflectionVariable_GetName(SlangReflectionVariable* inVar) -{ - auto var = convert(inVar); - if(!var) return nullptr; - - // If the variable is one that has an "external" name that is supposed - // to be exposed for reflection, then report it here - if(auto reflectionNameMod = var->findModifier()) - return getText(reflectionNameMod->nameAndLoc.name).getBuffer(); - - return getText(var->getName()).getBuffer(); -} - -SLANG_API SlangReflectionType* spReflectionVariable_GetType(SlangReflectionVariable* inVar) -{ - auto var = convert(inVar); - if(!var) return nullptr; - - return convert(var->getType()); -} - -SLANG_API SlangReflectionModifier* spReflectionVariable_FindModifier(SlangReflectionVariable* inVar, SlangModifierID modifierID) -{ - auto var = convert(inVar); - if(!var) return nullptr; - - Modifier* modifier = nullptr; - switch( modifierID ) - { - case SLANG_MODIFIER_SHARED: - modifier = var->findModifier(); - break; - - default: - return nullptr; - } - - return (SlangReflectionModifier*) modifier; -} - -SLANG_API unsigned int spReflectionVariable_GetUserAttributeCount(SlangReflectionVariable* inVar) -{ - auto varDecl = convert(inVar); - if (!varDecl) return 0; - return getUserAttributeCount(varDecl); -} -SLANG_API SlangReflectionUserAttribute* spReflectionVariable_GetUserAttribute(SlangReflectionVariable* inVar, unsigned int index) -{ - auto varDecl = convert(inVar); - if (!varDecl) return 0; - return getUserAttributeByIndex(varDecl, index); -} -SLANG_API SlangReflectionUserAttribute* spReflectionVariable_FindUserAttributeByName(SlangReflectionVariable* inVar, SlangSession* session, char const* name) -{ - auto varDecl = convert(inVar); - if (!varDecl) return 0; - return findUserAttributeByName(convert(session), varDecl, name); -} - -// Variable Layout Reflection - -SLANG_API SlangReflectionVariable* spReflectionVariableLayout_GetVariable(SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return nullptr; - - return convert(varLayout->varDecl.getDecl()); -} - -SLANG_API SlangReflectionTypeLayout* spReflectionVariableLayout_GetTypeLayout(SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return nullptr; - - return convert(varLayout->getTypeLayout()); -} - -namespace Slang -{ - // Attempt "do what I mean" remapping from the parameter category the user asked about, - // over to a parameter category that they might have meant. - static SlangParameterCategory maybeRemapParameterCategory( - TypeLayout* typeLayout, - SlangParameterCategory category) - { - // Do we have an entry for the category they asked about? Then use that. - if (typeLayout->FindResourceInfo(LayoutResourceKind(category))) - return category; - - // Do we have an entry for the `DescriptorTableSlot` category? - if (typeLayout->FindResourceInfo(LayoutResourceKind::DescriptorTableSlot)) - { - // Is the category they were asking about one that makes sense for the type - // of this variable? - Type* type = typeLayout->getType(); - while (auto arrayType = as(type)) - type = arrayType->baseType; - switch (spReflectionType_GetKind(convert(type))) - { - case SLANG_TYPE_KIND_CONSTANT_BUFFER: - if(category == SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER) - return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; - break; - - case SLANG_TYPE_KIND_RESOURCE: - if(category == SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE) - return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; - break; - - case SLANG_TYPE_KIND_SAMPLER_STATE: - if(category == SLANG_PARAMETER_CATEGORY_SAMPLER_STATE) - return SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT; - break; - - // TODO: implement more helpers here - - default: - break; - } - } - - return category; - } -} - -SLANG_API size_t spReflectionVariableLayout_GetOffset(SlangReflectionVariableLayout* inVarLayout, SlangParameterCategory category) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return 0; - - auto info = varLayout->FindResourceInfo(LayoutResourceKind(category)); - - if (!info) - { - // No match with requested category? Try again with one they might have meant... - category = maybeRemapParameterCategory(varLayout->getTypeLayout(), category); - info = varLayout->FindResourceInfo(LayoutResourceKind(category)); - } - - if(!info) return 0; - - return info->index; -} - -SLANG_API size_t spReflectionVariableLayout_GetSpace(SlangReflectionVariableLayout* inVarLayout, SlangParameterCategory category) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return 0; - - - auto info = varLayout->FindResourceInfo(LayoutResourceKind(category)); - if (!info) - { - // No match with requested category? Try again with one they might have meant... - category = maybeRemapParameterCategory(varLayout->getTypeLayout(), category); - info = varLayout->FindResourceInfo(LayoutResourceKind(category)); - } - - UInt space = 0; - - // First, deal with any offset applied to the specific resource kind specified - if (info) - { - space += info->space; - } - - // Note: this code used to try and take a variable with - // an offset for `LayoutResourceKind::RegisterSpace` and - // add it to the space returned, but that isn't going - // to be right in some cases. - // - // Imageine if we have: - // - // struct X { Texture2D y; } - // struct S { Texture2D t; ParmaeterBlock x; } - // - // Texture2D gA; - // S gS; - // - // We expect `gS` to have an offset for `LayoutResourceKind::ShaderResourceView` - // of one (since its texture must come after `gA`), and an offset for - // `LayoutResourceKind::RegisterSpace` of one (since the default space will be - // space zero). It would be incorrect for us to imply that `gS.t` should - // be `t1, space1`, though, because the space offset of `gS` doesn't actually - // apply to `t`. - // - // For now we are punting on this issue and leaving it in the hands of the - // application to determine when a space offset from an "outer" variable should - // apply to the locations of things in an "inner" variable. - // - // There is no policy we can apply locally in this function that - // will Just Work, so the best we can do is try to not lie. - - return space; -} - -SLANG_API char const* spReflectionVariableLayout_GetSemanticName(SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return 0; - - if (!(varLayout->flags & Slang::VarLayoutFlag::HasSemantic)) - return 0; - - return varLayout->semanticName.getBuffer(); -} - -SLANG_API size_t spReflectionVariableLayout_GetSemanticIndex(SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return 0; - - if (!(varLayout->flags & Slang::VarLayoutFlag::HasSemantic)) - return 0; - - return varLayout->semanticIndex; -} - -SLANG_API SlangStage spReflectionVariableLayout_getStage( - SlangReflectionVariableLayout* inVarLayout) -{ - auto varLayout = convert(inVarLayout); - if(!varLayout) return SLANG_STAGE_NONE; - - // A parameter that is not a varying input or output is - // not considered to belong to a single stage. - // - // TODO: We might need to reconsider this for, e.g., entry - // point parameters, where they might be stage-specific even - // if they are uniform. - if (!varLayout->FindResourceInfo(Slang::LayoutResourceKind::VaryingInput) - && !varLayout->FindResourceInfo(Slang::LayoutResourceKind::VaryingOutput)) - { - return SLANG_STAGE_NONE; - } - - // TODO: We should find the stage for a variable layout by - // walking up the tree of layout information, until we find - // something that has a definitive stage attached to it (e.g., - // either an entry point or a GLSL translation unit). - // - // We don't currently have parent links in the reflection layout - // information, so doing that walk would be tricky right now, so - // it is easier to just bloat the representation and store yet another - // field on every variable layout. - return (SlangStage) varLayout->stage; -} - - -// Shader Parameter Reflection - -SLANG_API unsigned spReflectionParameter_GetBindingIndex(SlangReflectionParameter* inVarLayout) -{ - SlangReflectionVariableLayout* varLayout = (SlangReflectionVariableLayout*)inVarLayout; - return (unsigned) spReflectionVariableLayout_GetOffset( - varLayout, - spReflectionTypeLayout_GetParameterCategory( - spReflectionVariableLayout_GetTypeLayout(varLayout))); -} - -SLANG_API unsigned spReflectionParameter_GetBindingSpace(SlangReflectionParameter* inVarLayout) -{ - SlangReflectionVariableLayout* varLayout = (SlangReflectionVariableLayout*)inVarLayout; - return (unsigned) spReflectionVariableLayout_GetSpace( - varLayout, - spReflectionTypeLayout_GetParameterCategory( - spReflectionVariableLayout_GetTypeLayout(varLayout))); -} - -// Helpers for getting parameter count - -namespace Slang -{ - static unsigned getParameterCount(RefPtr typeLayout) - { - if(auto parameterGroupLayout = as(typeLayout)) - { - typeLayout = parameterGroupLayout->offsetElementTypeLayout; - } - - if(auto structLayout = as(typeLayout)) - { - return (unsigned) structLayout->fields.getCount(); - } - - return 0; - } - - static VarLayout* getParameterByIndex(RefPtr typeLayout, unsigned index) - { - if(auto parameterGroupLayout = as(typeLayout)) - { - typeLayout = parameterGroupLayout->offsetElementTypeLayout; - } - - if(auto structLayout = as(typeLayout)) - { - return structLayout->fields[index]; - } - - return 0; - } -} - -// Entry Point Reflection - -SLANG_API char const* spReflectionEntryPoint_getName( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - return entryPointLayout ? getCstr(entryPointLayout->name) : nullptr; -} - -SLANG_API unsigned spReflectionEntryPoint_getParameterCount( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) return 0; - - return getParameterCount(entryPointLayout->parametersLayout->typeLayout); -} - -SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getParameterByIndex( - SlangReflectionEntryPoint* inEntryPoint, - unsigned index) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) return 0; - - return convert(getParameterByIndex(entryPointLayout->parametersLayout->typeLayout, index)); -} - -SLANG_API SlangStage spReflectionEntryPoint_getStage(SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - - if(!entryPointLayout) return SLANG_STAGE_NONE; - - return SlangStage(entryPointLayout->profile.getStage()); -} - -SLANG_API void spReflectionEntryPoint_getComputeThreadGroupSize( - SlangReflectionEntryPoint* inEntryPoint, - SlangUInt axisCount, - SlangUInt* outSizeAlongAxis) -{ - auto entryPointLayout = convert(inEntryPoint); - - if(!entryPointLayout) return; - if(!axisCount) return; - if(!outSizeAlongAxis) return; - - auto entryPointFunc = entryPointLayout->entryPoint; - if(!entryPointFunc) return; - - SlangUInt sizeAlongAxis[3] = { 1, 1, 1 }; - - // First look for the HLSL case, where we have an attribute attached to the entry point function - auto numThreadsAttribute = entryPointFunc.getDecl()->findModifier(); - if (numThreadsAttribute) - { - sizeAlongAxis[0] = numThreadsAttribute->x; - sizeAlongAxis[1] = numThreadsAttribute->y; - sizeAlongAxis[2] = numThreadsAttribute->z; - } - - // - - if(axisCount > 0) outSizeAlongAxis[0] = sizeAlongAxis[0]; - if(axisCount > 1) outSizeAlongAxis[1] = sizeAlongAxis[1]; - if(axisCount > 2) outSizeAlongAxis[2] = sizeAlongAxis[2]; - for( SlangUInt aa = 3; aa < axisCount; ++aa ) - { - outSizeAlongAxis[aa] = 1; - } -} - -SLANG_API int spReflectionEntryPoint_usesAnySampleRateInput( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) - return 0; - - if (entryPointLayout->profile.getStage() != Stage::Fragment) - return 0; - - return (entryPointLayout->flags & EntryPointLayout::Flag::usesAnySampleRateInput) != 0; -} - -SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getVarLayout( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) - return nullptr; - - return convert(entryPointLayout->parametersLayout); -} - -SLANG_API SlangReflectionVariableLayout* spReflectionEntryPoint_getResultVarLayout( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) - return nullptr; - - return convert(entryPointLayout->resultLayout); -} - - -static bool hasDefaultConstantBuffer(ScopeLayout* layout) -{ - auto typeLayout = layout->parametersLayout->getTypeLayout(); - return as(typeLayout) != nullptr; -} - -SLANG_API int spReflectionEntryPoint_hasDefaultConstantBuffer( - SlangReflectionEntryPoint* inEntryPoint) -{ - auto entryPointLayout = convert(inEntryPoint); - if(!entryPointLayout) - return 0; - - return hasDefaultConstantBuffer(entryPointLayout); -} - - -// SlangReflectionTypeParameter -SLANG_API char const* spReflectionTypeParameter_GetName(SlangReflectionTypeParameter * inTypeParam) -{ - auto specializationParam = convert(inTypeParam); - if( auto genericParamLayout = as(specializationParam) ) - { - return genericParamLayout->decl->getName()->text.getBuffer(); - } - // TODO: Add case for existential type parameter? They don't have as simple of a notion of "name" as the generic case... - return nullptr; -} - -SLANG_API unsigned spReflectionTypeParameter_GetIndex(SlangReflectionTypeParameter * inTypeParam) -{ - auto typeParam = convert(inTypeParam); - return (unsigned)(typeParam->index); -} - -SLANG_API unsigned int spReflectionTypeParameter_GetConstraintCount(SlangReflectionTypeParameter* inTypeParam) -{ - auto specializationParam = convert(inTypeParam); - if(auto genericParamLayout = as(specializationParam)) - { - if( auto globalGenericParamDecl = as(genericParamLayout->decl) ) - { - auto constraints = globalGenericParamDecl->getMembersOfType(); - return (unsigned int)constraints.getCount(); - } - // TODO: Add case for entry-point generic parameters. - } - // TODO: Add case for existential type parameters. - return 0; -} - -SLANG_API SlangReflectionType* spReflectionTypeParameter_GetConstraintByIndex(SlangReflectionTypeParameter * inTypeParam, unsigned index) -{ - auto specializationParam = convert(inTypeParam); - if(auto genericParamLayout = as(specializationParam)) - { - if( auto globalGenericParamDecl = as(genericParamLayout->decl) ) - { - auto constraints = globalGenericParamDecl->getMembersOfType(); - return (SlangReflectionType*)constraints[index]->sup.Ptr(); - } - // TODO: Add case for entry-point generic parameters. - } - // TODO: Add case for existential type parameters. - return 0; -} - -// Shader Reflection - -SLANG_API unsigned spReflection_GetParameterCount(SlangReflection* inProgram) -{ - auto program = convert(inProgram); - if(!program) return 0; - - auto globalStructLayout = getGlobalStructLayout(program); - if (!globalStructLayout) - return 0; - - return (unsigned) globalStructLayout->fields.getCount(); -} - -SLANG_API SlangReflectionParameter* spReflection_GetParameterByIndex(SlangReflection* inProgram, unsigned index) -{ - auto program = convert(inProgram); - if(!program) return nullptr; - - auto globalStructLayout = getGlobalStructLayout(program); - if (!globalStructLayout) - return 0; - - return convert(globalStructLayout->fields[index].Ptr()); -} - -SLANG_API SlangReflectionVariableLayout* spReflection_getGlobalParamsVarLayout(SlangReflection* inProgram) -{ - auto program = convert(inProgram); - if(!program) return nullptr; - - return convert(program->parametersLayout); -} - -SLANG_API unsigned int spReflection_GetTypeParameterCount(SlangReflection * reflection) -{ - auto program = convert(reflection); - return (unsigned int) program->specializationParams.getCount(); -} - -SLANG_API SlangReflectionTypeParameter* spReflection_GetTypeParameterByIndex(SlangReflection * reflection, unsigned int index) -{ - auto program = convert(reflection); - return (SlangReflectionTypeParameter*) program->specializationParams[index].Ptr(); -} - -SLANG_API SlangReflectionTypeParameter * spReflection_FindTypeParameter(SlangReflection * inProgram, char const * name) -{ - auto program = convert(inProgram); - if (!program) return nullptr; - for( auto& param : program->specializationParams ) - { - auto genericParamLayout = as(param); - if(!genericParamLayout) - continue; - - if(getText(genericParamLayout->decl->getName()) != UnownedTerminatedStringSlice(name)) - continue; - - return (SlangReflectionTypeParameter*) genericParamLayout; - } - - return 0; -} - -SLANG_API SlangUInt spReflection_getEntryPointCount(SlangReflection* inProgram) -{ - auto program = convert(inProgram); - if(!program) return 0; - - return SlangUInt(program->entryPoints.getCount()); -} - -SLANG_API SlangReflectionEntryPoint* spReflection_getEntryPointByIndex(SlangReflection* inProgram, SlangUInt index) -{ - auto program = convert(inProgram); - if(!program) return 0; - - return convert(program->entryPoints[(int) index].Ptr()); -} - -SLANG_API SlangReflectionEntryPoint* spReflection_findEntryPointByName(SlangReflection* inProgram, char const* name) -{ - auto program = convert(inProgram); - if(!program) return 0; - - // TODO: improve on naive linear search - for(auto ep : program->entryPoints) - { - if(ep->entryPoint.getName()->text == name) - { - return convert(ep); - } - } - - return nullptr; -} - -SLANG_API SlangUInt spReflection_getGlobalConstantBufferBinding(SlangReflection* inProgram) -{ - auto program = convert(inProgram); - if (!program) return 0; - auto cb = program->parametersLayout->FindResourceInfo(LayoutResourceKind::ConstantBuffer); - if (!cb) return 0; - return cb->index; -} - -SLANG_API size_t spReflection_getGlobalConstantBufferSize(SlangReflection* inProgram) -{ - auto program = convert(inProgram); - if (!program) return 0; - auto structLayout = getGlobalStructLayout(program); - auto uniform = structLayout->FindResourceInfo(LayoutResourceKind::Uniform); - if (!uniform) return 0; - return getReflectionSize(uniform->count); -} - -SLANG_API SlangReflectionType* spReflection_specializeType( - SlangReflection* inProgramLayout, - SlangReflectionType* inType, - SlangInt specializationArgCount, - SlangReflectionType* const* specializationArgs, - ISlangBlob** outDiagnostics) -{ - auto programLayout = convert(inProgramLayout); - if(!programLayout) return nullptr; - - auto unspecializedType = convert(inType); - if(!unspecializedType) return nullptr; - - auto linkage = programLayout->getProgram()->getLinkage(); - - DiagnosticSink sink(linkage->getSourceManager()); - - auto specializedType = linkage->specializeType(unspecializedType, specializationArgCount, (Type* const*) specializationArgs, &sink); - - sink.getBlobIfNeeded(outDiagnostics); - - return convert(specializedType); -} - -SLANG_API SlangUInt spReflection_getHashedStringCount( - SlangReflection* reflection) -{ - auto programLayout = convert(reflection); - auto slices = programLayout->hashedStringLiteralPool.getAdded(); - return slices.getCount(); -} - -SLANG_API const char* spReflection_getHashedString( - SlangReflection* reflection, - SlangUInt index, - size_t* outCount) -{ - auto programLayout = convert(reflection); - - auto slices = programLayout->hashedStringLiteralPool.getAdded(); - auto slice = slices[Index(index)]; - - *outCount = slice.getLength(); - return slice.begin(); -} - -SLANG_API int spComputeStringHash(const char* chars, size_t count) -{ - return (int)getStableHashCode32(chars, count); -} - -SLANG_API SlangReflectionTypeLayout* spReflection_getGlobalParamsTypeLayout( - SlangReflection* reflection) -{ - auto programLayout = convert(reflection); - if(!programLayout) return nullptr; - - return convert(programLayout->parametersLayout->typeLayout); -} diff --git a/source/slang/slang-reflection.h b/source/slang/slang-reflection.h deleted file mode 100644 index ea3021bd6..000000000 --- a/source/slang/slang-reflection.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef SLANG_REFLECTION_H -#define SLANG_REFLECTION_H - -#include "../core/slang-basic.h" -#include "slang-syntax.h" - -#include "../../slang.h" - -namespace Slang { - -class ProgramLayout; -class TypeLayout; - -// - -SlangTypeKind getReflectionTypeKind(Type* type); - -SlangTypeKind getReflectionParameterCategory(TypeLayout* typeLayout); - -UInt getReflectionFieldCount(Type* type); -UInt getReflectionFieldByIndex(Type* type, UInt index); -UInt getReflectionFieldByIndex(TypeLayout* typeLayout, UInt index); - -} - -#endif // SLANG_REFLECTION_H diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index d31b0302b..254a37c24 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1,5 +1,4 @@ #include "../../slang.h" -#include "../../slang-tag-version.h" #include "../core/slang-io.h" #include "../core/slang-string-util.h" @@ -11,7 +10,7 @@ #include "slang-mangle.h" #include "slang-parser.h" #include "slang-preprocessor.h" -#include "slang-reflection.h" + #include "slang-type-layout.h" #include "slang-options.h" @@ -3259,117 +3258,6 @@ Session::~Session() } -// implementation of C interface - -SLANG_API SlangSession* spCreateSession(const char*) -{ - Slang::ComPtr globalSession; - if (SLANG_FAILED(slang_createGlobalSession(SLANG_API_VERSION, globalSession.writeRef()))) - { - return nullptr; - } - // Will be returned with a refcount of 1 - return globalSession.detach(); -} - -SLANG_API SlangResult slang_createGlobalSession( - SlangInt apiVersion, - slang::IGlobalSession** outGlobalSession) -{ - Slang::ComPtr globalSession; - SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(apiVersion, globalSession.writeRef())); - SLANG_RETURN_ON_FAIL(globalSession->compileStdLib()); - *outGlobalSession = globalSession.detach(); - return SLANG_OK; -} - -SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib( - SlangInt apiVersion, - slang::IGlobalSession** outGlobalSession) -{ - if (apiVersion != 0) - return SLANG_E_NOT_IMPLEMENTED; - - // Create the session - Slang::Session* globalSession = new Slang::Session(); - // Put an interface ref on it - Slang::ComPtr result(globalSession); - - // Initialize it - globalSession->init(); - - *outGlobalSession = result.detach(); - return SLANG_OK; -} - -SLANG_API void spDestroySession( - SlangSession* inSession) -{ - if(!inSession) return; - - Slang::Session* session = Slang::asInternal(inSession); - // It is assumed there is only a single reference on the session (the one placed - // with spCreateSession) if this function is called - SLANG_ASSERT(session->debugGetReferenceCount() == 1); - // Release - session->release(); -} - -SLANG_API const char* spGetBuildTagString() -{ - return SLANG_TAG_VERSION; -} - -SLANG_API void spAddBuiltins( - SlangSession* session, - char const* sourcePath, - char const* sourceString) -{ - session->addBuiltins(sourcePath, sourceString); -} - -SLANG_API void spSessionSetSharedLibraryLoader( - SlangSession* session, - ISlangSharedLibraryLoader* loader) -{ - session->setSharedLibraryLoader(loader); -} - -SLANG_API ISlangSharedLibraryLoader* spSessionGetSharedLibraryLoader( - SlangSession* session) -{ - return session->getSharedLibraryLoader(); -} - -SLANG_API SlangResult spSessionCheckCompileTargetSupport( - SlangSession* session, - SlangCompileTarget target) -{ - return session->checkCompileTargetSupport(target); -} - -SLANG_API SlangResult spSessionCheckPassThroughSupport( - SlangSession* session, - SlangPassThrough passThrough) -{ - return session->checkPassThroughSupport(passThrough); -} - -SLANG_API SlangCompileRequest* spCreateCompileRequest( - SlangSession* session) -{ - slang::ICompileRequest* request = nullptr; - // Will return with suitable ref count - session->createCompileRequest(&request); - return request; -} - -SLANG_API SlangProfileID spFindProfile( - SlangSession* session, - char const* name) -{ - return session->findProfile(name); -} /* !!!!!!!!!!!!!!!!!! EndToEndCompileRequestImpl !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -4065,582 +3953,4 @@ SlangResult EndToEndCompileRequest::getEntryPoint(SlangInt entryPointIndex, slan } // namespace Slang -/* !!!!!!!!!!!!!!!!!!SlangCompileRequest API!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -/*! -@brief Destroy a compile request. -*/ -SLANG_API void spDestroyCompileRequest( - slang::ICompileRequest* request) -{ - if (request) - { - request->release(); - } -} - -/* All other functions just call into the ICompileResult interface. */ - -SLANG_API void spSetFileSystem( - slang::ICompileRequest* request, - ISlangFileSystem* fileSystem) -{ - SLANG_ASSERT(request); - request->setFileSystem(fileSystem); -} - -SLANG_API void spSetCompileFlags( - slang::ICompileRequest* request, - SlangCompileFlags flags) -{ - SLANG_ASSERT(request); - request->setCompileFlags(flags); -} - -SLANG_API void spSetDumpIntermediates( - slang::ICompileRequest* request, - int enable) -{ - SLANG_ASSERT(request); - request->setDumpIntermediates(enable); -} - -SLANG_API void spSetDumpIntermediatePrefix( - slang::ICompileRequest* request, - const char* prefix) -{ - SLANG_ASSERT(request); - request->setDumpIntermediatePrefix(prefix); -} - -SLANG_API void spSetLineDirectiveMode( - slang::ICompileRequest* request, - SlangLineDirectiveMode mode) -{ - SLANG_ASSERT(request); - request->setLineDirectiveMode(mode); -} - -SLANG_API void spSetCommandLineCompilerMode( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - request->setCommandLineCompilerMode(); -} - -SLANG_API void spSetCodeGenTarget( - slang::ICompileRequest* request, - SlangCompileTarget target) -{ - SLANG_ASSERT(request); - request->setCodeGenTarget(target); -} - -SLANG_API int spAddCodeGenTarget( - slang::ICompileRequest* request, - SlangCompileTarget target) -{ - SLANG_ASSERT(request); - return request->addCodeGenTarget(target); -} - -SLANG_API void spSetTargetProfile( - slang::ICompileRequest* request, - int targetIndex, - SlangProfileID profile) -{ - SLANG_ASSERT(request); - request->setTargetProfile(targetIndex, profile); -} - -SLANG_API void spSetTargetFlags( - slang::ICompileRequest* request, - int targetIndex, - SlangTargetFlags flags) -{ - SLANG_ASSERT(request); - request->setTargetFlags(targetIndex, flags); -} - -SLANG_API void spSetTargetFloatingPointMode( - slang::ICompileRequest* request, - int targetIndex, - SlangFloatingPointMode mode) -{ - SLANG_ASSERT(request); - request->setTargetFloatingPointMode(targetIndex, mode); -} - -SLANG_API void spSetMatrixLayoutMode( - slang::ICompileRequest* request, - SlangMatrixLayoutMode mode) -{ - SLANG_ASSERT(request); - request->setMatrixLayoutMode(mode); -} - -SLANG_API void spSetTargetMatrixLayoutMode( - slang::ICompileRequest* request, - int targetIndex, - SlangMatrixLayoutMode mode) -{ - SLANG_ASSERT(request); - request->setTargetMatrixLayoutMode(targetIndex, mode); -} - -SLANG_API void spSetDebugInfoLevel( - slang::ICompileRequest* request, - SlangDebugInfoLevel level) -{ - SLANG_ASSERT(request); - request->setDebugInfoLevel(level); -} - -SLANG_API void spSetOptimizationLevel( - slang::ICompileRequest* request, - SlangOptimizationLevel level) -{ - SLANG_ASSERT(request); - request->setOptimizationLevel(level); -} - -SLANG_API void spSetOutputContainerFormat( - slang::ICompileRequest* request, - SlangContainerFormat format) -{ - SLANG_ASSERT(request); - request->setOutputContainerFormat(format); -} - -SLANG_API void spSetPassThrough( - slang::ICompileRequest* request, - SlangPassThrough passThrough) -{ - SLANG_ASSERT(request); - request->setPassThrough(passThrough); -} - -SLANG_API void spSetDiagnosticCallback( - slang::ICompileRequest* request, - SlangDiagnosticCallback callback, - void const* userData) -{ - SLANG_ASSERT(request); - request->setDiagnosticCallback(callback, userData); -} - -SLANG_API void spSetWriter( - slang::ICompileRequest* request, - SlangWriterChannel chan, - ISlangWriter* writer) -{ - SLANG_ASSERT(request); - request->setWriter(chan, writer); -} - -SLANG_API ISlangWriter* spGetWriter( - slang::ICompileRequest* request, - SlangWriterChannel chan) -{ - SLANG_ASSERT(request); - return request->getWriter(chan); -} - -SLANG_API void spAddSearchPath( - slang::ICompileRequest* request, - const char* path) -{ - SLANG_ASSERT(request); - request->addSearchPath(path); -} - -SLANG_API void spAddPreprocessorDefine( - slang::ICompileRequest* request, - const char* key, - const char* value) -{ - SLANG_ASSERT(request); - request->addPreprocessorDefine(key, value); -} - -SLANG_API char const* spGetDiagnosticOutput( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->getDiagnosticOutput(); -} - -SLANG_API SlangResult spGetDiagnosticOutputBlob( - slang::ICompileRequest* request, - ISlangBlob** outBlob) -{ - SLANG_ASSERT(request); - return request->getDiagnosticOutputBlob(outBlob); -} - -// New-fangled compilation API - -SLANG_API int spAddTranslationUnit( - slang::ICompileRequest* request, - SlangSourceLanguage language, - char const* inName) -{ - SLANG_ASSERT(request); - return request->addTranslationUnit(language, inName); -} - -SLANG_API void spSetDefaultModuleName( - slang::ICompileRequest* request, - const char* defaultModuleName) -{ - SLANG_ASSERT(request); - request->setDefaultModuleName(defaultModuleName); -} - -SLANG_API SlangResult spAddLibraryReference( - slang::ICompileRequest* request, - const void* libData, - size_t libDataSize) -{ - SLANG_ASSERT(request); - return request->addLibraryReference(libData, libDataSize); -} - -SLANG_API void spTranslationUnit_addPreprocessorDefine( - slang::ICompileRequest* request, - int translationUnitIndex, - const char* key, - const char* value) -{ - SLANG_ASSERT(request); - request->addTranslationUnitPreprocessorDefine(translationUnitIndex, key, value); -} - -SLANG_API void spAddTranslationUnitSourceFile( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* path) -{ - SLANG_ASSERT(request); - request->addTranslationUnitSourceFile(translationUnitIndex, path); -} - -SLANG_API void spAddTranslationUnitSourceString( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* path, - char const* source) -{ - SLANG_ASSERT(request); - request->addTranslationUnitSourceString(translationUnitIndex, path, source); -} - -SLANG_API void spAddTranslationUnitSourceStringSpan( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* path, - char const* sourceBegin, - char const* sourceEnd) -{ - SLANG_ASSERT(request); - request->addTranslationUnitSourceStringSpan(translationUnitIndex, path, sourceBegin, sourceEnd); -} - -SLANG_API void spAddTranslationUnitSourceBlob( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* path, - ISlangBlob* sourceBlob) -{ - SLANG_ASSERT(request); - request->addTranslationUnitSourceBlob(translationUnitIndex, path, sourceBlob); -} - -SLANG_API int spAddEntryPoint( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* name, - SlangStage stage) -{ - SLANG_ASSERT(request); - return request->addEntryPoint(translationUnitIndex, name, stage); -} - -SLANG_API int spAddEntryPointEx( - slang::ICompileRequest* request, - int translationUnitIndex, - char const* name, - SlangStage stage, - int genericParamTypeNameCount, - char const ** genericParamTypeNames) -{ - SLANG_ASSERT(request); - return request->addEntryPointEx(translationUnitIndex, name, stage, genericParamTypeNameCount, genericParamTypeNames); -} - -SLANG_API SlangResult spSetGlobalGenericArgs( - slang::ICompileRequest* request, - int genericArgCount, - char const** genericArgs) -{ - SLANG_ASSERT(request); - return request->setGlobalGenericArgs(genericArgCount, genericArgs); -} - -SLANG_API SlangResult spSetTypeNameForGlobalExistentialTypeParam( - slang::ICompileRequest* request, - int slotIndex, - char const* typeName) -{ - SLANG_ASSERT(request); - return request->setTypeNameForGlobalExistentialTypeParam(slotIndex, typeName); -} - -SLANG_API SlangResult spSetTypeNameForEntryPointExistentialTypeParam( - slang::ICompileRequest* request, - int entryPointIndex, - int slotIndex, - char const* typeName) -{ - SLANG_ASSERT(request); - return request->setTypeNameForEntryPointExistentialTypeParam(entryPointIndex, slotIndex, typeName); -} - -SLANG_API SlangResult spCompile( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->compile(); -} - -SLANG_API int -spGetDependencyFileCount( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->getDependencyFileCount(); -} - -SLANG_API char const* -spGetDependencyFilePath( - slang::ICompileRequest* request, - int index) -{ - SLANG_ASSERT(request); - return request->getDependencyFilePath(index); -} - -SLANG_API int -spGetTranslationUnitCount( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->getTranslationUnitCount(); -} - -SLANG_API void const* spGetEntryPointCode( - slang::ICompileRequest* request, - int entryPointIndex, - size_t* outSize) -{ - SLANG_ASSERT(request); - return request->getEntryPointCode(entryPointIndex, outSize); -} - -SLANG_API SlangResult spGetEntryPointCodeBlob( - slang::ICompileRequest* request, - int entryPointIndex, - int targetIndex, - ISlangBlob** outBlob) -{ - SLANG_ASSERT(request); - return request->getEntryPointCodeBlob(entryPointIndex, targetIndex, outBlob); -} - -SLANG_API SlangResult spGetEntryPointHostCallable( - slang::ICompileRequest* request, - int entryPointIndex, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary) -{ - SLANG_ASSERT(request); - return request->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary); -} - -SLANG_API SlangResult spGetTargetCodeBlob( - slang::ICompileRequest* request, - int targetIndex, - ISlangBlob** outBlob) -{ - SLANG_ASSERT(request); - return request->getTargetCodeBlob(targetIndex, outBlob); -} - -SLANG_API SlangResult spGetTargetHostCallable( - slang::ICompileRequest* request, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary) -{ - SLANG_ASSERT(request); - return request->getTargetHostCallable(targetIndex, outSharedLibrary); -} - -SLANG_API char const* spGetEntryPointSource( - slang::ICompileRequest* request, - int entryPointIndex) -{ - SLANG_ASSERT(request); - return request->getEntryPointSource(entryPointIndex); -} - -SLANG_API void const* spGetCompileRequestCode( - slang::ICompileRequest* request, - size_t* outSize) -{ - SLANG_ASSERT(request); - return request->getCompileRequestCode(outSize); -} - -SLANG_API SlangResult spGetContainerCode( - slang::ICompileRequest* request, - ISlangBlob** outBlob) -{ - SLANG_ASSERT(request); - return request->getContainerCode(outBlob); -} - -SLANG_API SlangResult spLoadRepro( - slang::ICompileRequest* request, - ISlangFileSystem* fileSystem, - const void* data, - size_t size) -{ - SLANG_ASSERT(request); - return request->loadRepro(fileSystem, data, size); -} - -SLANG_API SlangResult spSaveRepro( - slang::ICompileRequest* request, - ISlangBlob** outBlob) -{ - SLANG_ASSERT(request); - return request->saveRepro(outBlob); -} - -SLANG_API SlangResult spEnableReproCapture( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->enableReproCapture(); -} - -SLANG_API SlangResult spCompileRequest_getProgram( - slang::ICompileRequest* request, - slang::IComponentType** outProgram) -{ - SLANG_ASSERT(request); - return request->getProgram(outProgram); -} - -SLANG_API SlangResult spCompileRequest_getModule( - slang::ICompileRequest* request, - SlangInt translationUnitIndex, - slang::IModule** outModule) -{ - SLANG_ASSERT(request); - return request->getModule(translationUnitIndex, outModule); -} - -SLANG_API SlangResult spCompileRequest_getSession( - slang::ICompileRequest* request, - slang::ISession** outSession) -{ - SLANG_ASSERT(request); - return request->getSession(outSession); -} - -SLANG_API SlangResult spCompileRequest_getEntryPoint( - slang::ICompileRequest* request, - SlangInt entryPointIndex, - slang::IComponentType** outEntryPoint) -{ - SLANG_ASSERT(request); - return request->getEntryPoint(entryPointIndex, outEntryPoint); -} - -// Get the output code associated with a specific translation unit -SLANG_API char const* spGetTranslationUnitSource( - slang::ICompileRequest* /*request*/, - int /*translationUnitIndex*/) -{ - fprintf(stderr, "DEPRECATED: spGetTranslationUnitSource()\n"); - return nullptr; -} - -SLANG_API SlangResult spProcessCommandLineArguments( - SlangCompileRequest* request, - char const* const* args, - int argCount) -{ - return request->processCommandLineArguments(args, argCount); -} - -// Reflection API - -SLANG_API SlangReflection* spGetReflection( - slang::ICompileRequest* request) -{ - SLANG_ASSERT(request); - return request->getReflection(); -} - -// ... rest of reflection API implementation is in `Reflection.cpp` - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! Session !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -SLANG_API SlangResult spExtractRepro(SlangSession* session, const void* reproData, size_t reproDataSize, ISlangMutableFileSystem* fileSystem) -{ - using namespace Slang; - SLANG_UNUSED(session); - - List buffer; - { - MemoryStreamBase memoryStream(FileAccess::Read, reproData, reproDataSize); - SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&memoryStream, buffer)); - } - - MemoryOffsetBase base; - base.set(buffer.getBuffer(), buffer.getCount()); - - ReproUtil::RequestState* requestState = ReproUtil::getRequest(buffer); - return ReproUtil::extractFiles(base, requestState, fileSystem); -} - -SLANG_API SlangResult spLoadReproAsFileSystem( - SlangSession* session, - const void* reproData, - size_t reproDataSize, - ISlangFileSystem* replaceFileSystem, - ISlangFileSystemExt** outFileSystem) -{ - using namespace Slang; - - SLANG_UNUSED(session); - - MemoryStreamBase stream(FileAccess::Read, reproData, reproDataSize); - - List buffer; - SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&stream, buffer)); - - auto requestState = ReproUtil::getRequest(buffer); - MemoryOffsetBase base; - base.set(buffer.getBuffer(), buffer.getCount()); - - RefPtr cacheFileSystem; - SLANG_RETURN_ON_FAIL(ReproUtil::loadFileSystem(base, requestState, replaceFileSystem, cacheFileSystem)); - - *outFileSystem = cacheFileSystem.detach(); - return SLANG_OK; -} - diff --git a/source/slang/slang.vcxproj b/source/slang/slang.vcxproj deleted file mode 100644 index 08c1f03a4..000000000 --- a/source/slang/slang.vcxproj +++ /dev/null @@ -1,443 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - true - Win32Proj - slang - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang\ - slang - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang\ - slang - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang\ - slang - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang\ - slang - .dll - - - - NotUsing - Level4 - true - _DEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) - ..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x86\debug\slang.lib - true - - - IF EXIST ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\bin\windows-x86\debug > nul) ELSE (xcopy /Q /Y /I ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\bin\windows-x86\debug > nul) - - - - - NotUsing - Level4 - true - _DEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) - ..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x64\debug\slang.lib - true - - - IF EXIST ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\bin\windows-x64\debug > nul) ELSE (xcopy /Q /Y /I ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\bin\windows-x64\debug > nul) - - - - - NotUsing - Level4 - true - NDEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) - ..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x86\release\slang.lib - true - - - IF EXIST ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\bin\windows-x86\release > nul) ELSE (xcopy /Q /Y /I ..\..\external\slang-binaries\bin\windows-x86\slang-glslang.dll ..\..\bin\windows-x86\release > nul) - - - - - NotUsing - Level4 - true - NDEBUG;SLANG_DYNAMIC_EXPORT;%(PreprocessorDefinitions) - ..\..\external\spirv-headers\include;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x64\release\slang.lib - true - - - IF EXIST ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll\ (xcopy /Q /E /Y /I ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\bin\windows-x64\release > nul) ELSE (xcopy /Q /Y /I ..\..\external\slang-binaries\bin\windows-x64\slang-glslang.dll ..\..\bin\windows-x64\release > nul) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - - - - \ No newline at end of file diff --git a/source/slang/slang.vcxproj.filters b/source/slang/slang.vcxproj.filters deleted file mode 100644 index 8659054c7..000000000 --- a/source/slang/slang.vcxproj.filters +++ /dev/null @@ -1,736 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - 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 - - - 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 - - - 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 - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Header Files - - - Header Files - - - Header 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 - - - 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 - - - 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 - - - Source Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/source/slangc/slangc.vcxproj b/source/slangc/slangc.vcxproj deleted file mode 100644 index 77a7dcea5..000000000 --- a/source/slangc/slangc.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7} - true - Win32Proj - slangc - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slangc\ - slangc - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slangc\ - slangc - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slangc\ - slangc - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slangc\ - slangc - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - - - - \ No newline at end of file diff --git a/source/slangc/slangc.vcxproj.filters b/source/slangc/slangc.vcxproj.filters deleted file mode 100644 index e9ae1c092..000000000 --- a/source/slangc/slangc.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/gfx/gfx.vcxproj b/tools/gfx/gfx.vcxproj deleted file mode 100644 index 327f6d629..000000000 --- a/tools/gfx/gfx.vcxproj +++ /dev/null @@ -1,222 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - true - Win32Proj - gfx - 10.0.14393.0 - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - StaticLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\gfx\ - gfx - .lib - - - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\gfx\ - gfx - .lib - - - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\gfx\ - gfx - .lib - - - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\gfx\ - gfx - .lib - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\..\external\imgui;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/" - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\..\external\imgui;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/" - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\..\external\imgui;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/" - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\..\external\imgui;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tools/gfx/gfx.vcxproj.filters b/tools/gfx/gfx.vcxproj.filters deleted file mode 100644 index f5fba2295..000000000 --- a/tools/gfx/gfx.vcxproj.filters +++ /dev/null @@ -1,141 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - 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 - - - - - 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 - - - \ No newline at end of file diff --git a/tools/render-test/render-test-tool.vcxproj b/tools/render-test/render-test-tool.vcxproj deleted file mode 100644 index cd05a53a2..000000000 --- a/tools/render-test/render-test-tool.vcxproj +++ /dev/null @@ -1,217 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {61F7EB00-7281-4BF3-9470-7C2EA92620C3} - true - Win32Proj - render-test-tool - 10.0.14393.0 - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\render-test-tool\ - render-test-tool - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\render-test-tool\ - render-test-tool - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\render-test-tool\ - render-test-tool - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\render-test-tool\ - render-test-tool - .dll - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x86\debug\render-test-tool.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/" "windows-x86" - - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x64\debug\render-test-tool.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/" "windows-x64" - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x86\release\render-test-tool.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/" "windows-x86" - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x64\release\render-test-tool.lib - - - "$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/" "windows-x64" - - - - - - - - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {222F7498-B40C-4F3F-A704-DDEB91A4484A} - - - - - - \ No newline at end of file diff --git a/tools/render-test/render-test-tool.vcxproj.filters b/tools/render-test/render-test-tool.vcxproj.filters deleted file mode 100644 index 36b384bb0..000000000 --- a/tools/render-test/render-test-tool.vcxproj.filters +++ /dev/null @@ -1,69 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj b/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj deleted file mode 100644 index 319632499..000000000 --- a/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj +++ /dev/null @@ -1,192 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {CA8A30D1-8FA9-4330-B7F7-84709246D8DC} - true - Win32Proj - slang-cpp-extractor - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-cpp-extractor\ - slang-cpp-extractor - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-cpp-extractor\ - slang-cpp-extractor - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-cpp-extractor\ - slang-cpp-extractor - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-cpp-extractor\ - slang-cpp-extractor - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - - - - \ No newline at end of file diff --git a/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters b/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters deleted file mode 100644 index e5097b221..000000000 --- a/tools/slang-cpp-extractor/slang-cpp-extractor.vcxproj.filters +++ /dev/null @@ -1,63 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-embed/slang-embed.vcxproj b/tools/slang-embed/slang-embed.vcxproj deleted file mode 100644 index 67ddcd6e8..000000000 --- a/tools/slang-embed/slang-embed.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7F773DD9-EB8F-2403-B43C-B49C2014B99C} - true - Win32Proj - slang-embed - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-embed\ - slang-embed - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-embed\ - slang-embed - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-embed\ - slang-embed - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-embed\ - slang-embed - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - - - - \ No newline at end of file diff --git a/tools/slang-embed/slang-embed.vcxproj.filters b/tools/slang-embed/slang-embed.vcxproj.filters deleted file mode 100644 index 56c2872ac..000000000 --- a/tools/slang-embed/slang-embed.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp index 796bbd59d..8e4824065 100644 --- a/tools/slang-generate/main.cpp +++ b/tools/slang-generate/main.cpp @@ -47,6 +47,8 @@ struct Node struct SourceFile : public RefObject { String inputPath; + String linePath; ///< The path to this file for #line output + StringSpan text; Node* node = nullptr; SourceFile() = default; @@ -658,7 +660,7 @@ void emitTemplateNodes( if (lineIndex >= 0) { StringBuilder buf; - buf << "SLANG_RAW(\"#line " << (lineIndex + 1) << " \\\"" << sourceFile->inputPath << "\\\"\")\n"; + buf << "SLANG_RAW(\"#line " << (lineIndex + 1) << " \\\"" << sourceFile->linePath << "\\\"\")\n"; emit(stream, buf.getUnownedSlice()); } @@ -806,7 +808,13 @@ SourceFile* parseSourceFile(const String& path) StringSpan span = StringSpan(input, inputEnd); SourceFile* sourceFile = new SourceFile(); + sourceFile->inputPath = path; + + // We use the fileName as the line path, as the path as passed to the command could contain a complicated + // depending on the project location. + sourceFile->linePath = Path::getFileName(path); + sourceFile->text = span; Node* node = parseSourceFile(sourceFile); diff --git a/tools/slang-generate/slang-generate.vcxproj b/tools/slang-generate/slang-generate.vcxproj deleted file mode 100644 index 39bcef167..000000000 --- a/tools/slang-generate/slang-generate.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {66174227-8541-41FC-A6DF-4764FC66F78E} - true - Win32Proj - slang-generate - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-generate\ - slang-generate - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-generate\ - slang-generate - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-generate\ - slang-generate - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-generate\ - slang-generate - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - - - - \ No newline at end of file diff --git a/tools/slang-generate/slang-generate.vcxproj.filters b/tools/slang-generate/slang-generate.vcxproj.filters deleted file mode 100644 index e9ae1c092..000000000 --- a/tools/slang-generate/slang-generate.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj deleted file mode 100644 index 51018db26..000000000 --- a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} - true - Win32Proj - slang-reflection-test-tool - - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - true - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - DynamicLibrary - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-reflection-test-tool\ - slang-reflection-test-tool - .dll - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-reflection-test-tool\ - slang-reflection-test-tool - .dll - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-reflection-test-tool\ - slang-reflection-test-tool - .dll - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-reflection-test-tool\ - slang-reflection-test-tool - .dll - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x86\debug\slang-reflection-test-tool.lib - - - - - NotUsing - Level3 - _DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Windows - true - ..\..\bin\windows-x64\debug\slang-reflection-test-tool.lib - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x86\release\slang-reflection-test-tool.lib - - - - - NotUsing - Level3 - NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Windows - true - true - ..\..\bin\windows-x64\release\slang-reflection-test-tool.lib - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - - - - \ No newline at end of file diff --git a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters b/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters deleted file mode 100644 index 2e5dbea25..000000000 --- a/tools/slang-reflection-test/slang-reflection-test-tool.vcxproj.filters +++ /dev/null @@ -1,13 +0,0 @@ - - - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Source Files - - - \ No newline at end of file diff --git a/tools/slang-test/slang-test.vcxproj b/tools/slang-test/slang-test.vcxproj deleted file mode 100644 index c667d294f..000000000 --- a/tools/slang-test/slang-test.vcxproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {0C768A18-1D25-4000-9F37-DA5FE99E3B64} - true - Win32Proj - slang-test - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - Unicode - v140 - - - Application - false - Unicode - v140 - - - - - - - - - - - - - - - - - - - true - ..\..\bin\windows-x86\debug\ - ..\..\intermediate\windows-x86\debug\slang-test\ - slang-test - .exe - - - true - ..\..\bin\windows-x64\debug\ - ..\..\intermediate\windows-x64\debug\slang-test\ - slang-test - .exe - - - false - ..\..\bin\windows-x86\release\ - ..\..\intermediate\windows-x86\release\slang-test\ - slang-test - .exe - - - false - ..\..\bin\windows-x64\release\ - ..\..\intermediate\windows-x64\release\slang-test\ - slang-test - .exe - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - _DEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - MultiThreadedDebug - - - Console - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - ..\..;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - - - Console - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {F9BE7957-8399-899E-0C49-E714FDDD4B65} - - - {DB00DA62-0533-4AFD-B59F-A67D5B3A0808} - - - {E76ACB11-4A12-4F0A-BE1E-CE0B8836EB7F} - - - - - - \ No newline at end of file diff --git a/tools/slang-test/slang-test.vcxproj.filters b/tools/slang-test/slang-test.vcxproj.filters deleted file mode 100644 index e31239bc6..000000000 --- a/tools/slang-test/slang-test.vcxproj.filters +++ /dev/null @@ -1,78 +0,0 @@ - - - - - {21EB8090-0D4E-1035-B6D3-48EBA215DCB7} - - - {E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header 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 - - - \ No newline at end of file -- cgit v1.2.3