From dfe13b54286b27dd15f591455bbb86b7798285c2 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 28 Jun 2018 11:14:48 -0700 Subject: Share graphics API layer between tests/examples (#603) The `render-test` project has an in-progress graphics API abstraction layer, and it makes sense to share this code with our examples rather than write a bunch of redundant code between examples and tests. Most of this change is just moving files from `tools/render-test/*` to a new library project at `tools/slang-graphics/`. The most complicated code change there is renaming from `render_test` to `slang_graphics`. The existing `hello` example was ported to use the graphics API layer instead of raw D3D11 API calls. It is still hard-coded to use the D3D11 back-end and the `SLANG_DXBC` target, so more work is needed if we want to actually support multiple APIs in the examples. I also went ahead and implemented an extremely rudimentary set of APIs to abstract over the Windows platform calls that were being made in the example, so that we could potentially run that same example on other platforms. I did *not* port `render-test` to use those APIs, and I also did not implement them for anything but Windows (my assumption is that for most other platforms we would just use SDL2, and require people to ensure it is installed to their machine before building Slang examples). --- premake5.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index 9bb41e71b..2953922b2 100644 --- a/premake5.lua +++ b/premake5.lua @@ -266,6 +266,8 @@ end -- example "hello" uuid "E6385042-1649-4803-9EBD-168F8B7EF131" + includedirs { ".", "tools" } + links { "core", "slang-graphics" } -- -- Note how we are calling our custom `example()` subroutine with -- the same syntax sugar that Premake usually advocates for their @@ -300,7 +302,6 @@ standardProject "core" warnings "Extra" flags { "FatalWarnings" } - -- -- `slang-generate` is a tool we use for source code generation on -- the compiler. It depends on the `core` library, so we need to @@ -363,8 +364,31 @@ tool "slang-eval-test" tool "render-test" uuid "96610759-07B9-4EEB-A974-5C634A2E742B" + includedirs { ".", "external", "source", "tools/slang-graphics" } + links { "core", "slang", "slang-graphics" } + filter { "system:windows" } + + systemversion "10.0.14393.0" + + -- For Windows targets, we want to copy d3dcompiler_47.dll, + -- dxcompiler.dll, and dxil.dll from the Windows SDK redistributable + -- directory into the output directory. + postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/"'} + +-- +-- `slang-graphics` is a utility library for doing GPU rendering +-- and compute, which is used by both our testing and exmaples. +-- It depends on teh `core` library, so we need to declare that: +-- + +tool "slang-graphics" + uuid "222F7498-B40C-4F3F-A704-DDEB91A4484A" + -- Unlike most of the code under `tools/`, this is a library + -- rather than a stand-alone executable. + kind "StaticLib" + includedirs { ".", "external", "source" } - links { "core", "slang" } + filter { "system:windows" } systemversion "10.0.14393.0" @@ -374,6 +398,8 @@ tool "render-test" -- directory into the output directory. postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/"'} + + -- -- The `slangc` command-line application is just a very thin wrapper -- around the Slang dynamic library, so its build is extermely simple. -- cgit v1.2.3