aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authordan sinclair <dsinclair@google.com>2019-05-27 20:07:26 -0400
committerGitHub <noreply@github.com>2019-05-27 20:07:26 -0400
commit47dfd3c7f3e337153ee84556a4558b2ede08c3ab (patch)
treee6f18252668b6ed50b18881a0a4634918ba6cdfc /CMakeLists.txt
parentdbfc621216f3771e1ce5b1863f9be5443f3da9a4 (diff)
downloadamber-47dfd3c7f3e337153ee84556a4558b2ede08c3ab.tar.gz
Add HLSL support through DXC (#511)
This Cl adds DXC to the Amber third_party directory and enables using HLSL as the shader language in AmberScript. Fixes #34
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt32
1 files changed, 26 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8042b7..10864c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,8 @@ option(AMBER_SKIP_SAMPLES
option(AMBER_USE_LOCAL_VULKAN "Build with vulkan in third_party" OFF)
option(AMBER_ENABLE_SWIFTSHADER
"Build using SwiftShader" ${AMBER_ENABLE_SWIFTSHADER})
-option(AMBER_USE_LOCAL_VULKAN "Build with vulkan in third_party" OFF)
+option(AMBER_USE_DXC "Enable DXC integration" ${AMBER_USE_DXC})
+
if(WIN32)
# On Windows, CMake by default compiles with the shared CRT.
# Default it to the static CRT.
@@ -53,7 +54,6 @@ if(WIN32)
${AMBER_ENABLE_SHARED_CRT})
endif(WIN32)
-
if (${AMBER_SKIP_SPIRV_TOOLS})
set(AMBER_ENABLE_SPIRV_TOOLS FALSE)
set(AMBER_ENABLE_SHADERC FALSE)
@@ -66,11 +66,13 @@ else()
set(AMBER_ENABLE_SHADERC TRUE)
endif()
endif()
+
if (${AMBER_SKIP_TESTS})
set(AMBER_ENABLE_TESTS FALSE)
else()
set(AMBER_ENABLE_TESTS TRUE)
endif()
+
if (${AMBER_SKIP_SAMPLES})
set(AMBER_ENABLE_SAMPLES FALSE)
else()
@@ -82,17 +84,21 @@ if (${AMBER_ENABLE_SWIFTSHADER})
set(AMBER_USE_LOCAL_VULKAN TRUE)
endif()
-if (${AMBER_USE_LOCAL_VULKAN})
- message(STATUS "Using python3")
- # vulkan-loaders requires python 3
- find_package(PythonInterp 3 REQUIRED)
+if (${AMBER_USE_DXC})
+ set(AMBER_ENABLE_DXC TRUE)
+else()
+ set(AMBER_ENABLE_DXC FALSE)
endif()
+message(STATUS "Using python3")
+find_package(PythonInterp 3 REQUIRED)
+
message(STATUS "Amber enable SPIRV-Tools: ${AMBER_ENABLE_SPIRV_TOOLS}")
message(STATUS "Amber enable Shaderc: ${AMBER_ENABLE_SHADERC}")
message(STATUS "Amber enable tests: ${AMBER_ENABLE_TESTS}")
message(STATUS "Amber enable samples: ${AMBER_ENABLE_SAMPLES}")
message(STATUS "Amber enable SwiftShader: ${AMBER_ENABLE_SWIFTSHADER}")
+message(STATUS "Amber enable DXC: ${AMBER_ENABLE_DXC}")
include_directories("${PROJECT_SOURCE_DIR}/include")
include_directories("${PROJECT_SOURCE_DIR}")
@@ -112,6 +118,20 @@ add_definitions(-DAMBER_ENGINE_VULKAN=$<BOOL:${Vulkan_FOUND}>)
add_definitions(-DAMBER_ENGINE_DAWN=$<BOOL:${Dawn_FOUND}>)
add_definitions(-DAMBER_ENABLE_SPIRV_TOOLS=$<BOOL:${AMBER_ENABLE_SPIRV_TOOLS}>)
add_definitions(-DAMBER_ENABLE_SHADERC=$<BOOL:${AMBER_ENABLE_SHADERC}>)
+add_definitions(-DAMBER_ENABLE_DXC=$<BOOL:${AMBER_ENABLE_DXC}>)
+
+set(CMAKE_DEBUG_POSTFIX "")
+
+# This has to be done very early so the link path will get set correctly for all
+# the various libraries and binaries.
+if (${AMBER_ENABLE_DXC})
+ link_directories("${CMAKE_BINARY_DIR}/third_party/dxc/lib")
+
+ if (MSVC)
+ # DXC turns this off all over the place so we have to do the same.
+ add_definitions(/D_ITERATOR_DEBUG_LEVEL=0)
+ endif()
+endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
message(STATUS "No build type selected, default to Debug")