summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-12-08 19:24:34 +0800
committerGitHub <noreply@github.com>2023-12-08 19:24:34 +0800
commit4321929879c1ed5b87ff95a99ca7da91e28d18fd (patch)
treeae1460dcb652981468e6fa4897e87b697f2bda33
parent9903688ccc0793259d43f95cae88bd1a8e178824 (diff)
WIP: CMake (#3326)
* More robust input and output selection in generator tools * Add cmake build system * Get slang-test running with cmake * Bump lz4 and miniz dependencies * Make cmake build more declarative * Correct preprocessor logic in slang.h * Add cuda test to compute/simple * Remove empty cmake files * output placement for cmake, and commenting * Correct include paths in spirv-embed-generator * Format cmake with gersemi * Make cmake build clerer * Neaten header generation Also work around https://gitlab.kitware.com/cmake/cmake/-/issues/18399 by introducing correct_generated_properties to set the GENERATED flag in the correct scope * remove unused files * use 3.20 to set GENERATOR property properly * spelling * more flexible linker arg setting * replace slang-static with obj collection * Set rpath and linker path correctly * neaten generated file generation * tests working with cmake build * fix premake5 build * comment and neaten cmake * remove unnecessary dependency * Build aftermath example only when aftermath is enabled * Add slang-llvm and other dependencies * Put modules alongside binaries * Find slang-glslang correctly * Better option handling * comments * add llvm build test * Better option handling * cmake wobble * use UNICODE and _UNICODE * remove other workflows * use ccache * neaten * limit parallel for llvm build * use ninja for build * Windows and Darwin slang-llvm builds * cache key * verbose llvm build * cl on windows * sccache and cl.exe * use cl.exe * Correct package detection * less verbosity * Simplify miniz inclusion * fix build with sccache * Neaten llvm building * neaten * Neaten slang-llvm fetching * more surgical workarounds * Add ci action * Get version from git * better variable naming * add missing include * clean up after premake in cmake * more docs on cmake build * ci wobble * add imgui target * more selective source * do not download swiftshader * Some missing dependencies * only build llvm on dispatch * Disable /Zi in CI where sccache is present * simplify * set PIC for miniz * set policies before project * reengage workaround * more runs on ci * Add cmake presets * Add cpack * move iterator debug level to preset * Correct lib flag * simplify action * Neaten cmake init * Add todo * Add simple test wrapper * Add tests to workflow presets * rename packing preset * Correctly set definitions * docs * correct preset names * Make slang-test depend on test-server/test-process * neaten * use workflow in actions * install docs * Correct module install dir * debug dist workflow * Install headers * neaten header globbing * Neaten dependency handling * make lib and bin variables * Do not set compiler for vs builds, unnecessary * docs * allow setting explicit source for target * maintain archive subdir * cmake docs * install headers * place targets into folders * cmake docs * nest external projects in folder * remove name clash * Neater external packages * meta targets in folder structure * cleaner slang-glslang dll * Add missing static directive to slang-no-embedded-stdlib * more robust module copying * make slang-test the startup project * folder tweak * Make FETCH_BINARY the default on all platforms * Set DEBUG_DIR * add natvis files to source * skip spirv tests * remove test step from debug dist * Add build to .gitignore * redo warnings to be more like premake * Update imgui * clean more premake files * Disable PCH for glslang, gcc throws a warning * Add /MP for msvc builds * warning wobble * Add script to build llvm * Add slang-llvm and generators components * Build slang-llvm in ci * comments * fetch llvm with git * better abi approximation for cache * better sccache key * formatting * Correct logic around disabling problematic debug info for ccache * exclude gcc and clang from windows ci * Make dist workflows use system llvm * naming * restore normal dist builds * formatting * run tests in ci * Correct slang-llvm url setting * Rely on the system to find the test tool library * actions matrix wiggle * cope with OSX ancient bash * Correct compilers on windows * more ci debugging * Correct rpath handling on OSX * neaten * correct path to slang-llvm * Correct rpath separator on osx * Find slang-llvm correctly * smoke tests only on osx * ci wobble * Give MacOS module a dylib suffix * get swiftshader correctly * cope with bsd cp * remove debug output * full tests on osx * ci wobble * Add some vk tests to expected failures * simplify ci * ci wobble * exclude dx12 tests from github ci * remove cmake code for building llvm * warnings * warnings as errors for cl * spirv-tools in path * add aarch64 ci build * Add SLANG_GENERATORS_PATH option for prebuilt generators * neaten * Correct generator target name * remove yaml anchors because github actions does not support them * Demote CMake in docs Also add info on cross compiling * Restore premake CI * use minimal ci for cmake * Write miniz_export for premake build and .gitignore it * Mention build config tool options in docs * Remove redefined macro for miniz * regenerate vs project
-rw-r--r--.github/actions/common-setup/action.yml112
-rw-r--r--.github/workflows/ci.yml141
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules1
-rw-r--r--CMakeLists.txt691
-rw-r--r--CMakePresets.json197
-rw-r--r--build/visual-studio/core/core.vcxproj6
-rw-r--r--build/visual-studio/miniz/miniz.vcxproj12
-rw-r--r--build/visual-studio/slang-rt/slang-rt.vcxproj6
-rw-r--r--build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj610
-rw-r--r--build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters46
-rw-r--r--cmake/AutoOption.cmake44
-rw-r--r--cmake/CCacheDebugInfoWorkaround.cmake23
-rw-r--r--cmake/CompilerFlags.cmake217
-rw-r--r--cmake/FindAftermath.cmake26
-rw-r--r--cmake/FindNVAPI.cmake34
-rw-r--r--cmake/FindOptiX.cmake15
-rw-r--r--cmake/GitVersion.cmake50
-rw-r--r--cmake/Glob.cmake51
-rw-r--r--cmake/LLVM.cmake40
-rw-r--r--cmake/SlangTarget.cmake377
-rw-r--r--docs/building.md209
-rw-r--r--external/CMakeLists.txt78
-rwxr-xr-xexternal/build-llvm.sh134
m---------external/imgui0
m---------external/lz40
m---------external/miniz0
m---------external/spirv-tools0
-rw-r--r--prelude/CMakeLists.txt32
-rw-r--r--premake5.lua9
-rw-r--r--slang.h2
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp5
-rw-r--r--source/core/slang-deflate-compression-system.cpp5
-rw-r--r--source/core/slang-zip-file-system.cpp6
-rw-r--r--source/slang-llvm/slang-llvm-filecheck.cpp188
-rw-r--r--source/slang-llvm/slang-llvm.cpp1066
-rw-r--r--source/slang/CMakeLists.txt187
-rw-r--r--source/slang/slang-compiler.cpp1
-rw-r--r--tests/compute/simple.slang1
-rw-r--r--tests/expected-failure-github.txt5
-rw-r--r--tools/platform/gui.cpp9
-rw-r--r--tools/slang-embed/slang-embed.cpp26
-rw-r--r--tools/slang-generate/main.cpp46
-rw-r--r--tools/slang-spirv-embed-generator/spirv-embed-generator-main.cpp14
-rw-r--r--tools/slang-test/README.md8
-rw-r--r--tools/test-server/test-server-main.cpp4
46 files changed, 4318 insertions, 417 deletions
diff --git a/.github/actions/common-setup/action.yml b/.github/actions/common-setup/action.yml
new file mode 100644
index 000000000..60c81b007
--- /dev/null
+++ b/.github/actions/common-setup/action.yml
@@ -0,0 +1,112 @@
+name: Common setup
+
+description: Performs setup common to all our actions
+
+inputs:
+ os:
+ required: true
+ runs-on:
+ required: true
+ compiler:
+ required: true
+ platform:
+ required: true
+ config:
+ required: true
+runs:
+ using: composite
+ steps:
+ - name: Set up MSVC dev tools on Windows
+ uses: ilammy/msvc-dev-cmd@v1
+ - name: Set up sccache
+ uses: hendrikmuhs/ccache-action@v1.2
+ with:
+ key: ${{github.job}}-${{inputs.os}}-${{inputs.compiler}}-${{inputs.platform}}-${{inputs.config}}
+ variant: sccache
+ - shell: bash
+ run: |
+ # Set up system dependencies
+
+ # Install Ninja
+ case "${{inputs.os}}" in
+ linux*) sudo apt-get install -y ninja-build;;
+ windows*) choco install ninja;;
+ macos*) brew install ninja;;
+ esac
+
+ # Set compiler
+ CC=${{inputs.compiler}}
+ CXX=${{inputs.compiler}}
+ # infer C++ compiler
+ CXX=${CXX/gcc/g++}
+ CXX=${CXX/clang/clang++}
+ # Correct version on older ubuntu
+ if [[ "${{inputs.runs-on}}" == ubuntu-20.04 ]]; then
+ CC=${CC/gcc/gcc-10}
+ CXX=${CXX/g++/g++-10}
+ fi
+ # Export
+ echo "CC=$CC" >> "$GITHUB_ENV"
+ echo "CXX=$CXX" >> "$GITHUB_ENV"
+
+ # Set CMake to use sccache
+ echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
+ echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
+
+ # Some useful variables
+ config=${{inputs.config}}
+ Config=$(echo "${{inputs.config}}" | sed 's/debug/Debug/;s/release/Release/')
+ bin_dir=$(pwd)/build/$Config/bin
+ lib_dir=$(pwd)/build/$Config/lib
+ echo "config=$config" >> "$GITHUB_ENV"
+ echo "Config=$Config" >> "$GITHUB_ENV"
+ echo "bin_dir=$bin_dir" >> "$GITHUB_ENV"
+ echo "lib_dir=$lib_dir" >> "$GITHUB_ENV"
+
+ # Try to restore a LLVM install, and build it otherwise
+ - uses: actions/cache/restore@v3
+ id: cache-llvm
+ with:
+ path: ${{ github.workspace }}/build/llvm-project-install
+ # Use os*compiler*platform in lieu of an ABI key here, which is what we really want
+ key: ${{ inputs.os }}-${{ inputs.compiler }}-${{ inputs.platform }}-${{ hashFiles('external/build-llvm.sh') }}
+ - name: Build LLVM
+ if: steps.cache-llvm.outputs.cache-hit != 'true'
+ shell: bash
+ run: ./external/build-llvm.sh --install-prefix "${{ github.workspace }}/build/llvm-project-install"
+ - uses: actions/cache/save@v3
+ if: steps.cache-llvm.outputs.cache-hit != 'true'
+ with:
+ path: ${{ github.workspace }}/build/llvm-project-install
+ key: ${{ steps.cache-llvm.outputs.cache-primary-key }}
+ - name: Set environment variable for CMake
+ shell: bash
+ run: |
+ echo "LLVM_DIR=${{ github.workspace }}/build/llvm-project-install" >> "$GITHUB_ENV"
+ echo "Clang_DIR=${{ github.workspace }}/build/llvm-project-install" >> "$GITHUB_ENV"
+
+ # Install swiftshader
+ - uses: robinraju/release-downloader@v1.8
+ continue-on-error: true
+ with:
+ latest: true
+ repository: "shader-slang/swiftshader"
+ out-file-path: "swiftshader"
+ extract: true
+ fileName: "vk_swiftshader_${{inputs.os}}_${{inputs.platform}}.zip"
+
+ - name: Install SwiftShader
+ shell: bash
+ run: |
+ case "${{inputs.os}}" in
+ windows*) echo "${{github.workspace}}/swiftshader/" >> "$GITHUB_PATH";;
+ *) echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}${{github.workspace}}/swiftshader" >> "$GITHUB_ENV";;
+ esac
+
+ # Put spirv-tools in path
+ - shell: bash
+ run: |
+ case "${{inputs.os}}" in
+ windows*) echo "${{github.workspace}}/external/slang-binaries/spirv-tools/windows-${{inputs.platform}}/bin" >> "$GITHUB_PATH";;
+ linux*) echo "${{github.workspace}}/external/slang-binaries/spirv-tools/$(uname -m)-linux/bin" >> "$GITHUB_PATH";;
+ esac
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..4c5a863a3
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,141 @@
+name: CI
+
+on:
+ push:
+ branches: [master]
+ pull_request:
+ branches: [master]
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ # Until we switch to CMake fully, just run something minimal
+ include:
+ - os: linux
+ compiler: gcc
+ platform: x64
+ config: debug
+ warnings-as-errors: false
+ test-category: smoke
+ full-gpu-tests: false
+ runs-on: ubuntu-20.04
+ # os: [linux, macos, windows]
+ # compiler: ['gcc', 'clang', 'cl']
+ # config: ['debug', 'release']
+ # platform: ['x64']
+ # full-gpu-tests: [false]
+ # exclude:
+ # # Exclude invalid or undesired os/compiler
+ # - { os: linux, compiler: cl }
+ # - { os: macos, compiler: cl }
+ # - { os: macos, compiler: gcc }
+ # - { os: windows, compiler: gcc }
+ # - { os: windows, compiler: clang }
+ # # or os/config combinations
+ # - { os: macos, config: debug }
+ # include:
+ # - { os: linux, runs-on: ubuntu-20.04 }
+ # - { os: windows, runs-on: windows-latest }
+ # - { os: macos, runs-on: macos-latest }
+ # # Set a test category depending on the config, smoke by default,
+ # # quick or full conditionally otherwise
+ # - test-category: smoke
+ # - { os: windows, test-category: quick }
+ # - { config: release, test-category: full }
+ # # Only CL has werror
+ # - warnings-as-errors: false
+ # - { compiler: cl, warnings-as-errors: true }
+ # # Self-hosted aarch64 build
+ # - os: linux
+ # compiler: gcc
+ # platform: aarch64
+ # config: release
+ # warnings-as-errors: false
+ # test-category: smoke
+ # full-gpu-tests: false
+ # runs-on: [self-hosted, Linux, ARM64]
+ # # Self-hosted full gpu build
+ # - os: windows
+ # compiler: cl
+ # platform: x64
+ # config: release
+ # warnings-as-errors: false
+ # test-category: full
+ # full-gpu-tests: true
+ # runs-on: [Windows, self-hosted]
+ fail-fast: false
+ runs-on: ${{ matrix.runs-on }}
+
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ submodules: 'true'
+ fetch-depth: '0'
+ - name: Setup
+ uses: ./.github/actions/common-setup
+ with:
+ os: ${{matrix.os}}
+ runs-on: ${{matrix.runs-on}}
+ compiler: ${{matrix.compiler}}
+ platform: ${{matrix.platform}}
+ config: ${{matrix.config}}
+ - name: Build Slang
+ run: |
+ if [[ "${{ matrix.os }}" =~ "windows" && "${{ matrix.config }}" != "release" ]]; then
+ # Doing a debug build will try to link against a release built llvm, this
+ # is a problem on Windows, so make slang-llvm in release build and use
+ # that as though it's a fetched binary via these presets.
+ cmake --workflow --preset slang-llvm
+ # Configure, pointing to our just-generated slang-llvm archive
+ cmake --preset default --fresh \
+ -DSLANG_SLANG_LLVM_FLAVOR=FETCH_BINARY \
+ -DSLANG_SLANG_LLVM_BINARY_URL=$(pwd)/build/dist-release/slang-slang-llvm.zip \
+ -DCMAKE_COMPILE_WARNING_AS_ERROR=${{matrix.warnings-as-errors}}
+ cmake --workflow --preset "${{matrix.config}}"
+ else
+ # Otherwise, use the system llvm we have just build or got from the
+ # cache in the setup phase
+ cmake --preset default --fresh \
+ -DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM \
+ -DCMAKE_COMPILE_WARNING_AS_ERROR=${{matrix.warnings-as-errors}}
+ cmake --workflow --preset "${{matrix.config}}"
+ fi
+ - name: Test Slang
+ run: |
+ export SLANG_RUN_SPIRV_VALIDATION=1
+ failed=0
+ if [[ "${{matrix.full-gpu-tests}}" == "true" ]]; then
+ $bin_dir/slang-test \
+ -use-test-server \
+ -server-count 8 \
+ -category ${{ matrix.test-category }} \
+ -api all-cpu ||
+ failed=1
+ $bin_dir/slang-test \
+ -use-test-server \
+ -server-count 8 \
+ -emit-spirv-directly \
+ -api vk \
+ -category ${{ matrix.test-category }} \
+ -expected-failure-list tests/expected-failure.txt ||
+ failed=1
+ else
+ $bin_dir/slang-test \
+ -use-test-server \
+ -api all-dx12 \
+ -category ${{ matrix.test-category }} \
+ -expected-failure-list tests/expected-failure-github.txt ||
+ failed=1
+ fi
+ exit $failed
+ - uses: actions/upload-artifact@v3
+ if: ${{ ! matrix.full-gpu-tests }}
+ with:
+ name: slang-build-${{matrix.os}}-${{matrix.platform}}-${{matrix.compiler}}-${{matrix.config}}
+ # The install directory used in the packaging step
+ path: build/dist-${{matrix.config}}/**/slang/*
diff --git a/.gitignore b/.gitignore
index 12a1e8e64..1a1da1600 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@
bin/
intermediate/
build.*/
+build/
Makefile
# Files generated by test runner.
diff --git a/.gitmodules b/.gitmodules
index f1fa81a52..51b3df8ce 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -22,6 +22,7 @@
[submodule "external/miniz"]
path = external/miniz
url = https://github.com/richgel999/miniz
+ ignore = untracked
[submodule "external/lz4"]
path = external/lz4
url = https://github.com/lz4/lz4
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..3ea4e1ef8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,691 @@
+cmake_minimum_required(VERSION 3.20)
+
+# Our module dir, include that now so that we can get the version automatically
+# from git describe
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+include(GitVersion)
+get_git_version(SLANG_VERSION "${CMAKE_CURRENT_LIST_DIR}")
+
+#
+# Our project
+#
+project(slang VERSION "${SLANG_VERSION}" LANGUAGES)
+
+#
+# Global CMake options
+#
+cmake_policy(SET CMP0135 OLD)
+cmake_policy(SET CMP0077 NEW)
+set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25")
+ cmake_policy(SET CMP0141 NEW)
+endif()
+
+# Don't use absolute paths to the build tree in RPATH, this makes the build
+# tree relocatable
+set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
+
+# Enable placing targets into a hierarchy for IDE generators
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+#
+# CMake-supplied modules and our utils
+#
+enable_language(C CXX)
+
+include(FindPackageHandleStandardArgs)
+include(CMakeDependentOption)
+include(FetchContent)
+include(GNUInstallDirs)
+
+include(CCacheDebugInfoWorkaround)
+include(CompilerFlags)
+include(Glob)
+include(LLVM)
+include(SlangTarget)
+include(AutoOption)
+
+#
+# Options
+#
+
+auto_option(
+ SLANG_ENABLE_CUDA
+ CUDAToolkit
+ "Enable CUDA tests using CUDA found in CUDA_PATH"
+)
+auto_option(
+ SLANG_ENABLE_OPTIX
+ OptiX
+ "Enable OptiX build/tests, requires SLANG_ENABLE_CUDA"
+)
+auto_option(
+ SLANG_ENABLE_NVAPI
+ NVAPI
+ "Enable NVAPI usage (Only available for builds targeting Windows)"
+)
+auto_option(
+ SLANG_ENABLE_XLIB
+ X11
+ "Build gfx and platform with Xlib to support windowed apps on Linux"
+)
+auto_option(
+ SLANG_ENABLE_AFTERMATH
+ Aftermath
+ "Enable Aftermath in GFX, and add aftermath crash example to project"
+)
+option(SLANG_ENABLE_DX_ON_VK "Use dxvk and vkd3d-proton for DirectX support")
+mark_as_advanced(SLANG_ENABLE_DX_ON_VK)
+
+option(SLANG_EMBED_STDLIB_SOURCE "Embed stdlib source in the binary" ON)
+option(SLANG_EMBED_STDLIB "Build slang with an embedded version of the stdlib")
+
+option(SLANG_ENABLE_FULL_IR_VALIDATION "Enable full IR validation (SLOW!)")
+option(SLANG_ENABLE_ASAN "Enable ASAN (address sanitizer)")
+
+set(SLANG_GENERATORS_PATH
+ ""
+ CACHE PATH
+ "An optional path to the outputs of the all-generators target compiled for the build platform, used when cross-compiling"
+)
+
+enum_option(
+ SLANG_SLANG_LLVM_FLAVOR
+ # Default
+ FETCH_BINARY
+ "How to get or build slang-llvm:"
+ # Options
+ FETCH_BINARY
+ "Use a binary distribution of the slang-llvm library instead of building or using LLVM (default for Windows)"
+ USE_SYSTEM_LLVM
+ "Build slang-llvm using system-provided LLVM and Clang binaries (default for non-Windows hosts)"
+ DISABLE
+ "Do not build llvm or fetch slang-llvm"
+)
+macro(slang_llvm_binary_url_option version filename)
+ set(SLANG_SLANG_LLVM_BINARY_URL
+ "https://github.com/shader-slang/slang-llvm/releases/download/${version}/${filename}"
+ CACHE STRING
+ "URL specifying the location of the slang-llvm prebuilt library"
+ )
+endmacro()
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ slang_llvm_binary_url_option("v13.x-42" "slang-llvm-13.x-42-win64.zip")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ slang_llvm_binary_url_option("v13.x-42" "slang-llvm-v13.x-42-macosx-x86_64-release.zip")
+else()
+ slang_llvm_binary_url_option("v13.x-42" "slang-llvm-v13.x-42-linux-x86_64-release.zip")
+endif()
+
+#
+# Option validation
+#
+
+if(NOT SLANG_EMBED_STDLIB AND NOT SLANG_EMBED_STDLIB_SOURCE)
+ message(
+ SEND_ERROR
+ "One of SLANG_EMBED_STDLIB and SLANG_EMBED_STDLIB_SOURCE must be enabled"
+ )
+endif()
+
+if(SLANG_ENABLE_OPTIX AND NOT SLANG_ENABLE_CUDA)
+ message(
+ SEND_ERROR
+ "SLANG_ENABLE_OPTIX is not supported without SLANG_ENABLE_CUDA"
+ )
+endif()
+
+if(SLANG_ENABLE_NVAPI AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ message(SEND_ERROR "SLANG_ENABLE_NVAPI is only supported on Windows")
+endif()
+
+#
+# Clean files from premake
+#
+# The premake builds places generated files in the source tree, make sure these
+# aren't present
+glob_append(
+ premake_generated_files
+ "source/slang/*.meta.slang.h"
+ "source/slang/*-generated-*.h"
+)
+if(premake_generated_files)
+ file(REMOVE ${premake_generated_files})
+endif()
+file(REMOVE external/miniz/miniz_export.h)
+
+#
+# Dependencies, most of these are however handled inside the "auto_option"
+# calls above
+#
+
+find_package(Threads REQUIRED)
+
+if(SLANG_SLANG_LLVM_FLAVOR STREQUAL "USE_SYSTEM_LLVM")
+ find_package(LLVM 13.0 REQUIRED CONFIG)
+ find_package(Clang REQUIRED CONFIG)
+endif()
+
+add_subdirectory(external)
+
+#
+# Our targets
+#
+
+slang_add_target(
+ source/core
+ STATIC
+ EXCLUDE_FROM_ALL
+ USE_EXTRA_WARNINGS
+ LINK_WITH_PRIVATE miniz lz4_static Threads::Threads ${CMAKE_DL_LIBS}
+ INCLUDE_DIRECTORIES_PUBLIC source
+)
+
+slang_add_target(
+ source/slang-rt
+ SHARED
+ # This compiles 'core' again with the SLANG_RT_DYNAMIC_EXPORT macro defined
+ EXTRA_SOURCE_DIRS source/core
+ USE_EXTRA_WARNINGS
+ LINK_WITH_PRIVATE miniz lz4_static Threads::Threads ${CMAKE_DL_LIBS}
+ EXPORT_MACRO_PREFIX SLANG_RT
+ INSTALL
+)
+
+slang_add_target(
+ source/compiler-core
+ STATIC
+ EXCLUDE_FROM_ALL
+ USE_EXTRA_WARNINGS
+ LINK_WITH_PRIVATE core
+ INCLUDE_DIRECTORIES_PUBLIC source
+)
+if(NOT MSVC)
+ # This is necessary to compile the DXC headers
+ set_source_files_properties(
+ source/compiler-core/slang-dxc-compiler.cpp
+ PROPERTIES COMPILE_OPTIONS "-fms-extensions"
+ DIRECTORY ${slang_SOURCE_DIR}
+ )
+endif()
+
+#
+# Tools used to generate source during the build:
+#
+
+add_custom_target(
+ all-generators
+ COMMENT "meta target which depends on all generators"
+)
+set_target_properties(all-generators PROPERTIES FOLDER generators)
+function(generator dir)
+ if(SLANG_GENERATORS_PATH)
+ cmake_parse_arguments(ARG "" "TARGET_NAME" "" ${ARGN})
+ if(ARG_TARGET_NAME)
+ set(target ${ARG_TARGET_NAME})
+ else()
+ get_filename_component(target ${dir} NAME)
+ endif()
+ add_executable(${target} IMPORTED)
+ set_property(
+ TARGET ${target}
+ PROPERTY
+ IMPORTED_LOCATION
+ "${SLANG_GENERATORS_PATH}/${target}${CMAKE_EXECUTABLE_SUFFIX}"
+ )
+ else()
+ slang_add_target(
+ ${dir}
+ EXECUTABLE
+ EXCLUDE_FROM_ALL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core
+ OUTPUT_DIR generators
+ REQUIRED_BY all-generators
+ FOLDER generators
+ INSTALL_COMPONENT generators
+ ${ARGN}
+ )
+ endif()
+endfunction()
+generator(tools/slang-cpp-extractor USE_FEWER_WARNINGS LINK_WITH_PRIVATE compiler-core)
+generator(tools/slang-embed)
+generator(tools/slang-generate USE_FEWER_WARNINGS)
+generator(tools/slang-lookup-generator LINK_WITH_PRIVATE compiler-core)
+generator(tools/slang-spirv-embed-generator LINK_WITH_PRIVATE compiler-core)
+generator(
+ source/slangc
+ TARGET_NAME slang-bootstrap
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE prelude slang-no-embedded-stdlib Threads::Threads
+)
+
+#
+# The compiler itself
+#
+
+# keep these non-trivial targets in their own directories so as not to clutter
+# this file
+add_subdirectory(prelude)
+add_subdirectory(source/slang)
+
+slang_add_target(
+ tools/slangd
+ EXECUTABLE
+ LINK_WITH_PRIVATE core slang slang-reflect-headers Threads::Threads
+ INSTALL
+)
+slang_add_target(
+ source/slangc
+ EXECUTABLE
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core slang Threads::Threads
+ INSTALL
+)
+
+#
+# Our wrappers for glslang and llvm
+#
+slang_add_target(
+ source/slang-glslang
+ MODULE
+ USE_EXTRA_WARNINGS
+ LINK_WITH_PRIVATE glslang SPIRV SPIRV-Tools-opt
+ INSTALL
+)
+# Our only interface is through what we define in source/slang-glslang, in the
+# interests of hygiene, hide anything else we link in.
+add_supported_cxx_linker_flags(slang-glslang PRIVATE "-Wl,--exclude-libs,ALL")
+
+if(SLANG_SLANG_LLVM_FLAVOR STREQUAL "FETCH_BINARY")
+ #
+ # Do some stupid little dance to put everything in the right shape with
+ # correct dependencies
+ #
+
+ set(slang_llvm_filename
+ "${CMAKE_SHARED_LIBRARY_PREFIX}slang-llvm${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ )
+ macro(from_glob dir)
+ # A little helper function
+ file(
+ GLOB_RECURSE slang_llvm_source_object
+ "${dir}/${slang_llvm_filename}"
+ )
+ list(LENGTH slang_llvm_source_object nmatches)
+ if(nmatches EQUAL 0)
+ message(
+ SEND_ERROR
+ "Unable to find ${slang_llvm_filename} in ${SLANG_SLANG_LLVM_BINARY_URL}"
+ )
+ elseif(nmatches GREATER 1)
+ message(
+ SEND_ERROR
+ "Found multiple files named ${slang_llvm_filename} in ${SLANG_SLANG_LLVM_BINARY_URL}"
+ )
+ endif()
+ endmacro()
+
+ if(IS_DIRECTORY "${SLANG_SLANG_LLVM_BINARY_URL}")
+ # Just glob directly from a local directory
+ from_glob("${SLANG_SLANG_LLVM_BINARY_URL}")
+ elseif(
+ SLANG_SLANG_LLVM_BINARY_URL
+ MATCHES
+ "${CMAKE_SHARED_LIBRARY_PREFIX}.+${CMAKE_SHARED_LIBRARY_SUFFIX}$"
+ AND EXISTS "${SLANG_SLANG_LLVM_BINARY_URL}"
+ )
+ # Otherwise, if it's a direct path to a shared object, use that
+ set(slang_llvm_source_object "${SLANG_SLANG_LLVM_BINARY_URL}")
+ else()
+ # Otherwise, download and extract from whatever URL we have
+ fetchcontent_declare(slang-llvm URL "${SLANG_SLANG_LLVM_BINARY_URL}")
+ fetchcontent_populate(slang-llvm)
+ from_glob("${slang-llvm_SOURCE_DIR}")
+ endif()
+
+ set(slang_llvm_dest_object
+ ${CMAKE_BINARY_DIR}/$<CONFIG>/${library_subdir}/${slang_llvm_filename}
+ )
+ add_custom_command(
+ OUTPUT ${slang_llvm_dest_object}
+ COMMAND
+ ${CMAKE_COMMAND} -E copy_if_different ${slang_llvm_source_object}
+ ${slang_llvm_dest_object}
+ DEPENDS ${slang_llvm_source_object}
+ VERBATIM
+ )
+ # Give this copying action a name
+ add_custom_target(copy-slang-llvm DEPENDS ${slang_llvm_dest_object})
+ set_target_properties(copy-slang-llvm PROPERTIES FOLDER generated)
+
+ # Put this into a library target
+ add_library(slang-llvm MODULE IMPORTED GLOBAL)
+ add_dependencies(slang-llvm copy-slang-llvm)
+ set_property(
+ TARGET slang-llvm
+ PROPERTY IMPORTED_LOCATION ${slang_llvm_dest_object}
+ )
+ install(PROGRAMS ${slang_llvm_dest_object} DESTINATION ${module_subdir})
+elseif(SLANG_SLANG_LLVM_FLAVOR STREQUAL "USE_SYSTEM_LLVM")
+ llvm_target_from_components(llvm-dep filecheck native orcjit)
+ clang_target_from_libs(
+ clang-dep
+ clangBasic
+ clangCodeGen
+ clangDriver
+ clangLex
+ clangFrontend
+ clangFrontendTool
+ )
+ slang_add_target(
+ source/slang-llvm
+ MODULE
+ LINK_WITH_PRIVATE core compiler-core llvm-dep clang-dep
+ # We include slang.h, but don't need to link with it
+ INCLUDE_FROM_PRIVATE slang
+ # This uses the SLANG_DLL_EXPORT macro from slang.h, so make sure to set
+ # SLANG_DYNAMIC and SLANG_DYNAMIC_EXPORT
+ EXPORT_MACRO_PREFIX SLANG
+ INSTALL
+ INSTALL_COMPONENT slang-llvm
+ )
+ # If we don't include this, then the symbols in the LLVM linked here may
+ # conflict with those of other LLVMs linked at runtime, for instance in mesa.
+ add_supported_cxx_linker_flags(slang-llvm PRIVATE "-Wl,--exclude-libs,ALL")
+
+ # The LLVM headers need a warning disabling, which somehow slips through \external
+ if(MSVC)
+ target_compile_options(slang-llvm PRIVATE -wd4244)
+ endif()
+
+ # TODO: Put a check here that libslang-llvm.so doesn't have a 'NEEDED'
+ # directive for libLLVM-13.so, it's almost certainly going to break at
+ # runtime in surprising ways when linked alongside Mesa (or anything else
+ # pulling in libLLVM.so)
+endif()
+
+#
+# `platform` contains all the platform abstractions for a GUI application.
+#
+slang_add_target(
+ tools/platform
+ SHARED
+ EXCLUDE_FROM_ALL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE
+ core
+ imgui
+ $<$<BOOL:${SLANG_ENABLE_XLIB}>:X11::X11>
+ ${CMAKE_DL_LIBS}
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE
+ $<$<BOOL:${SLANG_ENABLE_XLIB}>:SLANG_ENABLE_XLIB>
+ INCLUDE_FROM_PRIVATE gfx
+ INCLUDE_DIRECTORIES_PUBLIC tools/platform
+ EXPORT_MACRO_PREFIX SLANG_PLATFORM
+)
+
+#
+# GFX
+#
+slang_add_target(
+ tools/gfx
+ SHARED
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE
+ core
+ slang
+ Vulkan-Headers
+ $<$<BOOL:${SLANG_ENABLE_XLIB}>:X11::X11>
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cudart;CUDA::cuda_driver>
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:GFX_ENABLE_CUDA>
+ $<$<BOOL:${SLANG_ENABLE_OPTIX}>:GFX_OPTIX>
+ $<$<BOOL:${SLANG_ENABLE_NVAPI}>:GFX_NVAPI>
+ $<$<BOOL:${SLANG_ENABLE_XLIB}>:SLANG_ENABLE_XLIB>
+ # This is a shared library, so we need to set a preprocessor macro to mark
+ # exported symbols
+ EXPORT_MACRO_PREFIX SLANG_GFX
+ # slang-gfx is in this directory, anything which depends on gfx should include
+ # this
+ INCLUDE_DIRECTORIES_PUBLIC .
+ REQUIRES copy-gfx-slang-modules
+ INSTALL
+ FOLDER gfx
+)
+set(modules_dest_dir $<TARGET_FILE_DIR:slang-test>)
+add_custom_target(
+ copy-gfx-slang-modules
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${modules_dest_dir}
+ COMMAND
+ ${CMAKE_COMMAND} -E copy tools/gfx/gfx.slang
+ ${modules_dest_dir}/gfx.slang
+ COMMAND
+ ${CMAKE_COMMAND} -E copy tools/gfx/slang.slang
+ ${modules_dest_dir}/slang.slang
+ WORKING_DIRECTORY ${slang_SOURCE_DIR}
+ VERBATIM
+)
+set_target_properties(copy-gfx-slang-modules PROPERTIES FOLDER generators)
+install(
+ FILES ${modules_dest_dir}/gfx.slang ${modules_dest_dir}/slang.slang
+ DESTINATION ${runtime_subdir}
+)
+
+slang_add_target(
+ tools/gfx-util
+ STATIC
+ LINK_WITH_PRIVATE core
+ INCLUDE_FROM_PRIVATE gfx
+ # The headers are included with 'include "gfx-util/blah.h"' which is found
+ # in the tools directory
+ INCLUDE_DIRECTORIES_PUBLIC tools
+ FOLDER gfx
+)
+
+#
+# Installing any documentation
+#
+
+file(GLOB_RECURSE docs CONFIGURE_DEPENDS docs/*.md)
+if(docs)
+ install(FILES ${docs} DESTINATION ${CMAKE_INSTALL_DOCDIR})
+endif()
+
+#
+# The test executables and runtime-loaded modules
+#
+
+slang_add_target(
+ tools/test-server
+ EXECUTABLE
+ EXCLUDE_FROM_ALL
+ LINK_WITH_PRIVATE core compiler-core slang
+ FOLDER test
+)
+slang_add_target(
+ tools/test-process
+ EXECUTABLE
+ EXCLUDE_FROM_ALL
+ LINK_WITH_PRIVATE core compiler-core
+ FOLDER test
+)
+
+slang_add_target(
+ tools/slang-test
+ EXECUTABLE
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core compiler-core slang ${CMAKE_DL_LIBS} Threads::Threads
+ REQUIRES
+ # Shared libraries dlopened by slang-test
+ slang-reflection-test
+ render-test
+ slang-unit-test
+ gfx-unit-test
+ slang-glslang
+ # Used by some tests when they run
+ slangd
+ slang-rt
+ gfx
+ test-server
+ test-process
+ FOLDER test
+ DEBUG_DIR ${slang_SOURCE_DIR}
+)
+if(TARGET slang-llvm)
+ # Only add a dependency here if slang-llvm exists
+ # Pending https://gitlab.kitware.com/cmake/cmake/-/issues/19467 to be able
+ # to use a generator expression in REQUIRES just above.
+ add_dependencies(slang-test slang-llvm)
+endif()
+set_property(
+ DIRECTORY ${slang_SOURCE_DIR}
+ PROPERTY VS_STARTUP_PROJECT slang-test
+)
+
+slang_add_target(
+ tools/unit-test
+ OBJECT
+ EXCLUDE_FROM_ALL
+ INCLUDE_FROM_PRIVATE slang
+ FOLDER test
+)
+
+# These are libraries loaded at runtime from the test executable:
+slang_add_target(
+ tools/gfx-unit-test
+ MODULE
+ EXCLUDE_FROM_ALL
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE SLANG_SHARED_LIBRARY_TOOL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core slang unit-test gfx gfx-util platform
+ OUTPUT_NAME gfx-unit-test-tool
+ FOLDER test/tools
+)
+slang_add_target(
+ tools/slang-unit-test
+ MODULE
+ EXCLUDE_FROM_ALL
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE SLANG_SHARED_LIBRARY_TOOL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core compiler-core unit-test slang Threads::Threads
+ OUTPUT_NAME slang-unit-test-tool
+ FOLDER test/tools
+)
+slang_add_target(
+ tools/slang-reflection-test
+ MODULE
+ EXCLUDE_FROM_ALL
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE SLANG_SHARED_LIBRARY_TOOL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE core slang Threads::Threads
+ OUTPUT_NAME slang-reflection-test-tool
+ FOLDER test/tools
+)
+slang_add_target(
+ tools/render-test
+ MODULE
+ EXCLUDE_FROM_ALL
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE SLANG_SHARED_LIBRARY_TOOL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE
+ core
+ compiler-core
+ slang
+ gfx
+ gfx-util
+ platform
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cudart;CUDA::cuda_driver>
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:RENDER_TEST_CUDA>
+ $<$<BOOL:${SLANG_ENABLE_OPTIX}>:RENDER_TEST_OPTIX>
+ OUTPUT_NAME render-test-tool
+ FOLDER test/tools
+)
+
+slang_add_target(
+ tools/slang-profile
+ EXECUTABLE
+ EXCLUDE_FROM_ALL
+ LINK_WITH_PRIVATE core slang
+ FOLDER test
+)
+
+#
+# Examples
+#
+
+slang_add_target(
+ examples/example-base
+ STATIC
+ EXCLUDE_FROM_ALL
+ LINK_WITH_PRIVATE
+ core
+ slang
+ gfx
+ platform
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cudart;CUDA::cuda_driver>
+ FOLDER examples
+)
+
+add_custom_target(
+ all-examples
+ COMMENT "meta target which depends on all examples"
+)
+set_target_properties(all-examples PROPERTIES FOLDER examples)
+function(example dir)
+ slang_add_target(
+ ${dir}
+ EXECUTABLE
+ EXCLUDE_FROM_ALL
+ USE_FEWER_WARNINGS
+ LINK_WITH_PRIVATE
+ core
+ example-base
+ slang
+ gfx
+ gfx-util
+ platform
+ $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cudart;CUDA::cuda_driver>
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE
+ $<$<BOOL:${SLANG_ENABLE_XLIB}>:SLANG_ENABLE_XLIB>
+ REQUIRED_BY all-examples
+ FOLDER examples
+ DEBUG_DIR ${dir}
+ ${ARGN}
+ )
+endfunction()
+
+example(examples/autodiff-texture WIN32_EXECUTABLE)
+example(examples/cpu-com-example )
+example(examples/cpu-hello-world )
+example(examples/gpu-printing )
+example(examples/hello-world LINK_WITH_PRIVATE Vulkan-Headers)
+example(examples/model-viewer WIN32_EXECUTABLE)
+example(examples/ray-tracing WIN32_EXECUTABLE)
+example(examples/ray-tracing-pipeline WIN32_EXECUTABLE)
+example(examples/shader-object )
+example(examples/shader-toy WIN32_EXECUTABLE)
+example(examples/triangle WIN32_EXECUTABLE)
+if(SLANG_ENABLE_AFTERMATH)
+ example(examples/nv-aftermath-example WIN32_EXECUTABLE)
+endif()
+
+#
+# Testing
+#
+include(CTest)
+add_test(
+ NAME slang-test
+ COMMAND
+ slang-test -bindir ${slang_SOURCE_DIR}/build/$<CONFIG>/${runtime_subdir}
+ -expected-failure-list ${slang_SOURCE_DIR}/tests/expected-failure.txt
+ -expected-failure-list
+ ${slang_SOURCE_DIR}/tests/expected-failure-github.txt
+ WORKING_DIRECTORY ${slang_SOURCE_DIR}
+)
+
+#
+# Packaging
+#
+include(CPack)
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 000000000..c23fbada1
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,197 @@
+{
+ "version": 6,
+ "cmakeMinimumRequired": {
+ "major": 3,
+ "minor": 20,
+ "patch": 0
+ },
+ "configurePresets": [
+ {
+ "name": "default",
+ "description": "Default build using Ninja Multi-Config generator",
+ "generator": "Ninja Multi-Config",
+ "binaryDir": "${sourceDir}/build"
+ },
+ {
+ "name": "msvc-base",
+ "hidden": true,
+ "inherits": "default",
+ "description": "Options specific for MSVC",
+ "cacheVariables": {
+ "CMAKE_C_FLAGS_INIT": "-D_ITERATOR_DEBUG_LEVEL=0 /MP",
+ "CMAKE_CXX_FLAGS_INIT": "-D_ITERATOR_DEBUG_LEVEL=0 /MP"
+ }
+ },
+ {
+ "name": "vs2019",
+ "inherits": "msvc-base",
+ "description": "Visual Studio 2019 project",
+ "generator": "Visual Studio 16 2019"
+ },
+ {
+ "name": "vs2022",
+ "inherits": "msvc-base",
+ "description": "Visual Studio 2022 project",
+ "generator": "Visual Studio 17 2022"
+ },
+ {
+ "name": "single-component",
+ "inherits": "default",
+ "description": "configure to package a single component",
+ "cacheVariables": {
+ "CPACK_ARCHIVE_COMPONENT_INSTALL": "ON"
+ }
+ },
+ {
+ "name": "slang-llvm",
+ "inherits": "single-component",
+ "description": "Build slang-llvm from the system LLVM",
+ "cacheVariables": {
+ "SLANG_SLANG_LLVM_FLAVOR": "USE_SYSTEM_LLVM"
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "debug",
+ "configurePreset": "default",
+ "configuration": "Debug"
+ },
+ {
+ "name": "release",
+ "configurePreset": "default",
+ "configuration": "Release"
+ },
+ {
+ "name": "generators",
+ "inherits": "release",
+ "configurePreset": "single-component",
+ "targets": [
+ "all-generators"
+ ]
+ },
+ {
+ "name": "slang-llvm",
+ "inherits": "release",
+ "configurePreset": "slang-llvm",
+ "targets": [
+ "slang-llvm"
+ ]
+ }
+ ],
+ "packagePresets": [
+ {
+ "name": "base",
+ "hidden": true,
+ "configurePreset": "default",
+ "generators": [
+ "ZIP"
+ ],
+ "variables": {
+ "CPACK_PACKAGE_FILE_NAME": "slang"
+ }
+ },
+ {
+ "name": "release",
+ "inherits": "base",
+ "configurations": [
+ "Release"
+ ],
+ "packageDirectory": "dist-release"
+ },
+ {
+ "name": "debug",
+ "inherits": "base",
+ "configurations": [
+ "Debug"
+ ],
+ "packageDirectory": "dist-debug"
+ },
+ {
+ "name": "generators",
+ "inherits": "release",
+ "configurePreset": "single-component",
+ "variables": {
+ "CPACK_COMPONENTS_ALL": "generators"
+ }
+ },
+ {
+ "name": "slang-llvm",
+ "inherits": "release",
+ "configurePreset": "slang-llvm",
+ "variables": {
+ "CPACK_COMPONENTS_ALL": "slang-llvm"
+ }
+ }
+ ],
+ "workflowPresets": [
+ {
+ "name": "debug",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "default"
+ },
+ {
+ "type": "build",
+ "name": "debug"
+ },
+ {
+ "type": "package",
+ "name": "debug"
+ }
+ ]
+ },
+ {
+ "name": "release",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "default"
+ },
+ {
+ "type": "build",
+ "name": "release"
+ },
+ {
+ "type": "package",
+ "name": "release"
+ }
+ ]
+ },
+ {
+ "name": "generators",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "single-component"
+ },
+ {
+ "type": "build",
+ "name": "generators"
+ },
+ {
+ "type": "package",
+ "name": "generators"
+ }
+ ]
+ },
+ {
+ "name": "slang-llvm",
+ "steps": [
+ {
+ "type": "configure",
+ "name": "slang-llvm"
+ },
+ {
+ "type": "build",
+ "name": "slang-llvm"
+ },
+ {
+ "type": "package",
+ "name": "slang-llvm"
+ }
+ ]
+ }
+ ]
+}
diff --git a/build/visual-studio/core/core.vcxproj b/build/visual-studio/core/core.vcxproj
index 1f8d95a6f..aed281cd5 100644
--- a/build/visual-studio/core/core.vcxproj
+++ b/build/visual-studio/core/core.vcxproj
@@ -158,6 +158,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -175,6 +176,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -192,6 +194,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -209,6 +212,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -229,6 +233,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -249,6 +254,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
diff --git a/build/visual-studio/miniz/miniz.vcxproj b/build/visual-studio/miniz/miniz.vcxproj
index 15eb91f8f..6e091585f 100644
--- a/build/visual-studio/miniz/miniz.vcxproj
+++ b/build/visual-studio/miniz/miniz.vcxproj
@@ -157,7 +157,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -174,7 +174,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -191,7 +191,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -208,7 +208,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -228,7 +228,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -248,7 +248,7 @@
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
diff --git a/build/visual-studio/slang-rt/slang-rt.vcxproj b/build/visual-studio/slang-rt/slang-rt.vcxproj
index 35e3ea987..0d88549e2 100644
--- a/build/visual-studio/slang-rt/slang-rt.vcxproj
+++ b/build/visual-studio/slang-rt/slang-rt.vcxproj
@@ -164,6 +164,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -182,6 +183,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -200,6 +202,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
@@ -218,6 +221,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -239,6 +243,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
@@ -260,6 +265,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;SLANG_RT_DYNAMIC;SLANG_RT_DYNAMIC_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\external\miniz;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
diff --git a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj
index e3634d91e..bc62dce2b 100644
--- a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj
+++ b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj
@@ -1,306 +1,306 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|ARM64">
- <Configuration>Debug</Configuration>
- <Platform>ARM64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug aarch64|Win32">
- <Configuration>Debug aarch64</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug aarch64|x64">
- <Configuration>Debug aarch64</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug aarch64|ARM64">
- <Configuration>Debug aarch64</Configuration>
- <Platform>ARM64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|ARM64">
- <Configuration>Release</Configuration>
- <Platform>ARM64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release aarch64|Win32">
- <Configuration>Release aarch64</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release aarch64|x64">
- <Configuration>Release aarch64</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release aarch64|ARM64">
- <Configuration>Release aarch64</Configuration>
- <Platform>ARM64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9ED23316-AE8B-4018-9407-271F4DDB8CBA}</ProjectGuid>
- <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>vk-pipeline-create</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v142</PlatformToolset>
- <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\bin\windows-x86\debug\</OutDir>
- <IntDir>..\..\..\intermediate\windows-x86\debug\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\bin\windows-x64\debug\</OutDir>
- <IntDir>..\..\..\intermediate\windows-x64\debug\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>..\..\..\bin\windows-aarch64\debug\</OutDir>
- <IntDir>..\..\..\intermediate\windows-aarch64\debug\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\bin\windows-x86\release\</OutDir>
- <IntDir>..\..\..\intermediate\windows-x86\release\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\bin\windows-x64\release\</OutDir>
- <IntDir>..\..\..\intermediate\windows-x64\release\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>..\..\..\bin\windows-aarch64\release\</OutDir>
- <IntDir>..\..\..\intermediate\windows-aarch64\release\vk-pipeline-create\</IntDir>
- <TargetName>vk-pipeline-create</TargetName>
- <TargetExt>.exe</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <MinimalRebuild>false</MinimalRebuild>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <MinimalRebuild>false</MinimalRebuild>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <MinimalRebuild>false</MinimalRebuild>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <Optimization>Full</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <MinimalRebuild>false</MinimalRebuild>
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <Optimization>Full</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <MinimalRebuild>false</MinimalRebuild>
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <Optimization>Full</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <MinimalRebuild>false</MinimalRebuild>
- <StringPooling>true</StringPooling>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <LanguageStandard>stdcpp17</LanguageStandard>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="..\..\..\examples\hello-world\vulkan-api.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp" />
- <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\slang\slang.vcxproj">
- <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project>
- </ProjectReference>
- <ProjectReference Include="..\gfx\gfx.vcxproj">
- <Project>{222F7498-B40C-4F3F-A704-DDEB91A4484A}</Project>
- </ProjectReference>
- <ProjectReference Include="..\gfx-util\gfx-util.vcxproj">
- <Project>{F5ADB74E-02A7-44FB-AA3B-FC02F8AC7A4B}</Project>
- </ProjectReference>
- <ProjectReference Include="..\platform\platform.vcxproj">
- <Project>{3565FE5E-4FA3-11EB-AE93-0242AC130002}</Project>
- </ProjectReference>
- <ProjectReference Include="..\core\core.vcxproj">
- <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug aarch64|Win32">
+ <Configuration>Debug aarch64</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug aarch64|x64">
+ <Configuration>Debug aarch64</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug aarch64|ARM64">
+ <Configuration>Debug aarch64</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release aarch64|Win32">
+ <Configuration>Release aarch64</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release aarch64|x64">
+ <Configuration>Release aarch64</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release aarch64|ARM64">
+ <Configuration>Release aarch64</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9ED23316-AE8B-4018-9407-271F4DDB8CBA}</ProjectGuid>
+ <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>vk-pipeline-create</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-x86\debug\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-x86\debug\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-x64\debug\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-x64\debug\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-aarch64\debug\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-aarch64\debug\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-x86\release\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-x86\release\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-x64\release\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-x64\release\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>..\..\..\bin\windows-aarch64\release\</OutDir>
+ <IntDir>..\..\..\intermediate\windows-aarch64\release\vk-pipeline-create\</IntDir>
+ <TargetName>vk-pipeline-create</TargetName>
+ <TargetExt>.exe</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <Optimization>Full</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <MinimalRebuild>false</MinimalRebuild>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <Optimization>Full</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <MinimalRebuild>false</MinimalRebuild>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <Optimization>Full</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <MinimalRebuild>false</MinimalRebuild>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <LanguageStandard>stdcpp17</LanguageStandard>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\examples\hello-world\vulkan-api.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp" />
+ <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\slang\slang.vcxproj">
+ <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\gfx\gfx.vcxproj">
+ <Project>{222F7498-B40C-4F3F-A704-DDEB91A4484A}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\gfx-util\gfx-util.vcxproj">
+ <Project>{F5ADB74E-02A7-44FB-AA3B-FC02F8AC7A4B}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\platform\platform.vcxproj">
+ <Project>{3565FE5E-4FA3-11EB-AE93-0242AC130002}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\core\core.vcxproj">
+ <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
</Project> \ No newline at end of file
diff --git a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters
index 1068a0300..87f7c2894 100644
--- a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters
+++ b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Header Files">
- <UniqueIdentifier>{21EB8090-0D4E-1035-B6D3-48EBA215DCB7}</UniqueIdentifier>
- </Filter>
- <Filter Include="Source Files">
- <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\..\examples\hello-world\vulkan-api.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{21EB8090-0D4E-1035-B6D3-48EBA215DCB7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\examples\hello-world\vulkan-api.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/cmake/AutoOption.cmake b/cmake/AutoOption.cmake
new file mode 100644
index 000000000..3f7cdee0e
--- /dev/null
+++ b/cmake/AutoOption.cmake
@@ -0,0 +1,44 @@
+function(auto_option name package description)
+ set(${name} "AUTO" CACHE STRING ${description})
+ set_property(CACHE ${name} PROPERTY STRINGS AUTO ON OFF)
+
+ if(${${name}} OR ${${name}} STREQUAL "AUTO")
+ if(${${name}} STREQUAL "AUTO")
+ set(req)
+ else()
+ set(req REQUIRED)
+ endif()
+ find_package(${package} ${req})
+
+ if(${${package}_FOUND})
+ set(${name} TRUE CACHE STRING ${description} FORCE)
+ else()
+ set(${name} FALSE CACHE STRING ${description} FORCE)
+ endif()
+ endif()
+endfunction()
+
+function(enum_option name init description)
+ set(enums)
+ set(is_enum TRUE)
+ foreach(enum_or_desc ${ARGN})
+ if(is_enum)
+ list(APPEND enums ${enum_or_desc})
+ string(APPEND description "\n" "${enum_or_desc}" ": ")
+ set(is_enum FALSE)
+ else()
+ string(APPEND description "${enum_or_desc}")
+ set(is_enum TRUE)
+ endif()
+ endforeach()
+
+ set(${name} ${init} CACHE STRING ${description})
+ set_property(CACHE ${name} PROPERTY STRINGS ${enums})
+
+ foreach(enum ${enums})
+ if(${${name}} STREQUAL ${enum})
+ return()
+ endif()
+ endforeach()
+ message(FATAL_ERROR "${name} must be one of ${enums}")
+endfunction()
diff --git a/cmake/CCacheDebugInfoWorkaround.cmake b/cmake/CCacheDebugInfoWorkaround.cmake
new file mode 100644
index 000000000..82fb299e3
--- /dev/null
+++ b/cmake/CCacheDebugInfoWorkaround.cmake
@@ -0,0 +1,23 @@
+# Make sure that shared debug info doesn't intefere with caching
+# See the sccache readme
+if(
+ MSVC
+ AND (NOT DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
+ AND (
+ CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"
+ OR CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache"
+ )
+)
+ message(
+ NOTICE
+ "Setting embedded debug info for MSVC to work around (s)ccache's inability to cache shared debug info files, Note that this requires CMake 3.25 or greater"
+ )
+ cmake_minimum_required(VERSION 3.25)
+ cmake_policy(GET CMP0141 cmp0141)
+ if(NOT cmp0141 STREQUAL "NEW")
+ message(WARNING "Need CMake policy 0141 enabled")
+ endif()
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
+ "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>"
+ )
+endif()
diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake
new file mode 100644
index 000000000..2a9988d4e
--- /dev/null
+++ b/cmake/CompilerFlags.cmake
@@ -0,0 +1,217 @@
+#
+# Given a list of flags, add those which the C++ compiler supports to the target
+#
+include(CheckCXXCompilerFlag)
+function(add_supported_cxx_flags target)
+ cmake_parse_arguments(ARG "PRIVATE;PUBLIC;INTERFACE" "" "" ${ARGN})
+ set(flags ${ARG_UNPARSED_ARGUMENTS})
+ if(ARG_PRIVATE)
+ set(private PRIVATE)
+ endif()
+ if(ARG_PUBLIC)
+ set(public PUBLIC)
+ endif()
+ if(ARG_INTERFACE)
+ set(interface INTERFACE)
+ endif()
+
+ foreach(flag ${flags})
+ # remove the `no-` prefix from warnings because gcc doesn't treat it as an
+ # error on its own
+ string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
+ string(
+ REGEX REPLACE
+ "[^a-zA-Z0-9]+"
+ "_"
+ test_name
+ "CXXFLAG_${flag_to_test}"
+ )
+ check_cxx_compiler_flag("${flag_to_test}" ${test_name})
+ if(${test_name})
+ target_compile_options(
+ ${target}
+ ${private}
+ ${public}
+ ${interface}
+ ${flag}
+ )
+ endif()
+ endforeach()
+endfunction()
+
+#
+# Given a list of linker flags, add those which the compiler supports to the
+# target
+#
+include(CheckLinkerFlag)
+function(add_supported_cxx_linker_flags target)
+ cmake_parse_arguments(ARG "PRIVATE;PUBLIC;INTERFACE;BEFORE" "" "" ${ARGN})
+ set(flags ${ARG_UNPARSED_ARGUMENTS})
+ if(ARG_BEFORE)
+ set(before BEFORE)
+ endif()
+ if(ARG_PRIVATE)
+ set(private PRIVATE)
+ endif()
+ if(ARG_PUBLIC)
+ set(public PUBLIC)
+ endif()
+ if(ARG_INTERFACE)
+ set(interface INTERFACE)
+ endif()
+
+ foreach(flag ${flags})
+ string(
+ REGEX REPLACE
+ "[^a-zA-Z0-9]+"
+ "_"
+ test_name
+ "CXXLINKFLAG_${flag}"
+ )
+ check_linker_flag(CXX "${flag}" ${test_name})
+ if(${test_name})
+ target_link_options(
+ ${target}
+ ${before}
+ ${private}
+ ${public}
+ ${interface}
+ ${flag}
+ )
+ endif()
+ endforeach()
+endfunction()
+
+#
+# Add our default compiler flags to a target
+#
+# Pass USE_EXTRA_WARNINGS to enable -WExtra or /W3
+#
+function(set_default_compile_options target)
+ cmake_parse_arguments(
+ ARG
+ "USE_EXTRA_WARNINGS;USE_FEWER_WARNINGS"
+ ""
+ ""
+ ${ARGN}
+ )
+
+ set(warning_flags)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ list(
+ APPEND
+ warning_flags
+ -Wall
+ # Disabled warnings:
+ -Wno-switch
+ -Wno-parentheses
+ -Wno-unused-local-typedefs
+ -Wno-class-memaccess
+ -Wno-assume
+ -Wno-reorder
+ -Wno-invalid-offsetof
+ -Wno-newline-eof
+ -Wno-return-std-move
+ # Enabled warnings:
+ # If a function returns an address/reference to a local, we want it to
+ # produce an error, because it probably means something very bad.
+ -Werror=return-local-addr
+ # Some warnings which are on by default in MSVC
+ -Wnarrowing
+ )
+ if(ARG_USE_EXTRA_WARNINGS)
+ list(APPEND warning_flags -Wextra)
+ endif()
+ if(ARG_USE_FEWER_WARNINGS)
+ list(
+ APPEND
+ warning_flags
+ -Wno-class-memaccess
+ -Wno-unused-variable
+ -Wno-unused-parameter
+ -Wno-sign-compare
+ -Wno-unused-function
+ -Wno-unused-value
+ -Wno-unused-but-set-variable
+ -Wno-implicit-fallthrough
+ -Wno-missing-field-initializers
+ -Wno-strict-aliasing
+ -Wno-maybe-uninitialized
+ )
+ endif()
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ list(APPEND warning_flags)
+ if(ARG_USE_EXTRA_WARNINGS)
+ list(APPEND warning_flags /W4)
+ elseif(ARG_USE_FEWER_WARNINGS)
+ list(APPEND warning_flags /W0)
+ else()
+ list(APPEND warning_flags /W2)
+ endif()
+ endif()
+
+ add_supported_cxx_flags(${target} PRIVATE ${warning_flags})
+
+ # Don't assume that symbols will be resolved at runtime
+ add_supported_cxx_linker_flags(${target} PRIVATE "-Wl,--no-undefined")
+
+ set_target_properties(
+ ${target}
+ PROPERTIES # -fvisibility=hidden
+ CXX_VISIBILITY_PRESET
+ hidden
+ # C++ standard
+ CXX_STANDARD
+ 17
+ # pic
+ POSITION_INDEPENDENT_CODE
+ ON
+ )
+
+ target_compile_definitions(
+ ${target}
+ PRIVATE # Add _DEBUG depending on the build configuration
+ $<$<CONFIG:Debug>:_DEBUG>
+ # For including windows.h in a way that minimized namespace
+ # pollution. Although we define these here, we still set them
+ # manually in any header files which may be included by another
+ # project
+ WIN32_LEAN_AND_MEAN
+ VC_EXTRALEAN
+ NOMINMAX
+ # Use multi-byte character set on Windows
+ UNICODE
+ _UNICODE
+ )
+
+ #
+ # Settings dependent on config options
+ #
+
+ if(SLANG_ENABLE_FULL_DEBUG_VALIDATION)
+ target_compile_definitions(
+ ${target}
+ PRIVATE SLANG_ENABLE_FULL_IR_VALIDATION
+ )
+ endif()
+
+ if(SLANG_ENABLE_DX_ON_VK)
+ target_compile_definitions(${target} PRIVATE SLANG_CONFIG_DX_ON_VK)
+ endif()
+
+ if(SLANG_ENABLE_ASAN)
+ add_supported_cxx_flags(
+ ${target}
+ PRIVATE
+ /fsanitize=address
+ -fsanitize=address
+ )
+ add_supported_cxx_linker_flags(
+ ${target}
+ BEFORE
+ PUBLIC
+ /INCREMENTAL:NO
+ -fsanitize=address
+ )
+ endif()
+endfunction()
diff --git a/cmake/FindAftermath.cmake b/cmake/FindAftermath.cmake
new file mode 100644
index 000000000..fe26c1abd
--- /dev/null
+++ b/cmake/FindAftermath.cmake
@@ -0,0 +1,26 @@
+set(Aftermath_ROOT_DIR "" CACHE PATH "Path to an installed Aftermath SDK")
+
+if(Aftermath_ROOT_DIR)
+ find_path(
+ Aftermath_INCLUDE_DIRS
+ NAMES GFSDK_Aftermath.h
+ PATH_SUFFIXES include
+ PATHS "${Aftermath_ROOT_DIR}"
+ NO_DEFAULT_PATH
+ )
+else()
+ find_path(Aftermath_INCLUDE_DIRS NAMES GFSDK_Aftermath.h)
+endif()
+
+# x86_64 only so far
+find_library(
+ Aftermath_LIBRARIES
+ NAMES GFSDK_Aftermath_Lib.x64
+ PATH_SUFFIXES x64
+ PATHS "${Aftermath_ROOT_DIR}/lib"
+)
+
+find_package_handle_standard_args(
+ Aftermath
+ REQUIRED_VARS Aftermath_INCLUDE_DIRS Aftermath_LIBRARIES
+)
diff --git a/cmake/FindNVAPI.cmake b/cmake/FindNVAPI.cmake
new file mode 100644
index 000000000..bd2a18718
--- /dev/null
+++ b/cmake/FindNVAPI.cmake
@@ -0,0 +1,34 @@
+set(NVAPI_ROOT_DIR "" CACHE PATH "Path to an installed NVAPI SDK")
+
+if(NVAPI_ROOT_DIR)
+ find_path(
+ NVAPI_INCLUDE_DIRS
+ NAMES nvapi.h
+ PATHS "${NVAPI_ROOT_DIR}"
+ NO_DEFAULT_PATH
+ )
+else()
+ find_path(
+ NVAPI_INCLUDE_DIRS
+ NAMES nvapi.h
+ PATHS "${slang-SOURCE_DIR}/external/nvapi"
+ NO_DEFAULT_PATH
+ )
+ find_path(NVAPI_INCLUDE_DIRS NAMES nvapi.h)
+
+ # The nvapi.h header is in the root, so we can populate that easily
+ set(NVAPI_ROOT_DIR ${NVAPI_INCLUDE_DIRS})
+endif()
+
+# x86_64 only so far
+find_library(
+ NVAPI_LIBRARIES
+ NAMES nvapi64
+ PATH_SUFFIXES amd64
+ PATHS ${NVAPI_ROOT_DIR}
+)
+
+find_package_handle_standard_args(
+ NVAPI
+ REQUIRED_VARS NVAPI_INCLUDE_DIRS NVAPI_LIBRARIES
+)
diff --git a/cmake/FindOptiX.cmake b/cmake/FindOptiX.cmake
new file mode 100644
index 000000000..d036c4fef
--- /dev/null
+++ b/cmake/FindOptiX.cmake
@@ -0,0 +1,15 @@
+set(Optix_ROOT_DIR "" CACHE PATH "Path to an installed OptiX SDK")
+
+if(Optix_ROOT_DIR)
+ find_path(
+ OptiX_INCLUDE_DIRS
+ NAMES optix.h
+ PATH_SUFFIXES include
+ PATHS "${Optix_ROOT_DIR}"
+ NO_DEFAULT_PATH
+ )
+else()
+ find_path(OptiX_INCLUDE_DIRS NAMES optix.h)
+endif()
+
+find_package_handle_standard_args(OptiX REQUIRED_VARS OptiX_INCLUDE_DIRS)
diff --git a/cmake/GitVersion.cmake b/cmake/GitVersion.cmake
new file mode 100644
index 000000000..7044aaffc
--- /dev/null
+++ b/cmake/GitVersion.cmake
@@ -0,0 +1,50 @@
+find_package(Git)
+
+# Extract a version from the latest tag matching something like v1.2.3.4
+function(get_git_version var dir)
+ if(NOT DEFINED ${var})
+ set(version "0.0")
+ if(GIT_EXECUTABLE)
+ set(command
+ "${GIT_EXECUTABLE}"
+ -C
+ "${dir}"
+ describe
+ --abbrev=0
+ --tags
+ --match
+ v*
+ )
+ execute_process(
+ COMMAND ${command}
+ RESULT_VARIABLE result
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE version
+ )
+ if(NOT result EQUAL 0)
+ message(
+ WARNING
+ "Getting ${var} failed: ${command} returned ${result}"
+ )
+ elseif("${version}" MATCHES "^v([0-9]+(\.[0-9]+)*).*")
+ set(version "${CMAKE_MATCH_1}")
+ else()
+ message(
+ WARNING
+ "Couldn't parse numeric version (like v1.2.3) from ${version}"
+ )
+ endif()
+ else()
+ message(
+ WARNING
+ "Couldn't find git executable to get ${var}, please use -D${var}"
+ )
+ endif()
+ endif()
+
+ set(${var}
+ ${version}
+ CACHE STRING
+ "The project version, detected using git if available"
+ )
+endfunction()
diff --git a/cmake/Glob.cmake b/cmake/Glob.cmake
new file mode 100644
index 000000000..c960e5011
--- /dev/null
+++ b/cmake/Glob.cmake
@@ -0,0 +1,51 @@
+#
+# glob_append(MY_VAR my_glob) will append the results of file(GLOB
+# CONFIGURE_DEPENDS my_glob) to MY_VAR
+#
+# Any number of globs may be specified
+#
+function(glob_append dest)
+ file(GLOB files CONFIGURE_DEPENDS ${ARGN})
+ list(APPEND ${dest} ${files})
+ set(${dest} ${${dest}} PARENT_SCOPE)
+endfunction()
+
+#
+# Perform a recursive glob, and exclude any files appropriately according to
+# the host system and build options
+#
+function(slang_glob_sources var dir)
+ set(patterns
+ "*.cpp"
+ "*.h"
+ "*.natvis"
+ "*.natstepfilter"
+ "*.natjmc"
+ )
+ list(TRANSFORM patterns PREPEND "${dir}/")
+
+ file(GLOB_RECURSE files CONFIGURE_DEPENDS ${patterns})
+
+ if(NOT WIN32)
+ list(FILTER files EXCLUDE REGEX "(^|/)windows/.*")
+ endif()
+
+ if(NOT UNIX)
+ list(FILTER files EXCLUDE REGEX "(^|/)unix/.*")
+ endif()
+
+ if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT SLANG_ENABLE_DX_ON_VK)
+ list(FILTER files EXCLUDE REGEX "(^|/)d3d.*/.*")
+ endif()
+
+ if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows|Linux")
+ list(FILTER files EXCLUDE REGEX "(^|/)vulkan/.*")
+ endif()
+
+ if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ list(FILTER files EXCLUDE REGEX "(^|/)open-gl/.*")
+ endif()
+
+ list(APPEND ${var} ${files})
+ set(${var} ${${var}} PARENT_SCOPE)
+endfunction()
diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
new file mode 100644
index 000000000..10a31e2d1
--- /dev/null
+++ b/cmake/LLVM.cmake
@@ -0,0 +1,40 @@
+# A convenience on top of the llvm package's cmake files, this creates a target
+# to pass to target_link_libraries which correctly pulls in the llvm include
+# dir and other compile dependencies
+function(llvm_target_from_components target_name)
+ set(components ${ARGN})
+ llvm_map_components_to_libnames(llvm_libs
+ ${components}
+ )
+ add_library(${target_name} INTERFACE)
+ target_link_libraries(${target_name} INTERFACE ${llvm_libs})
+ target_include_directories(
+ ${target_name}
+ SYSTEM
+ INTERFACE ${LLVM_INCLUDE_DIRS}
+ )
+ target_compile_definitions(${target_name} INTERFACE ${LLVM_DEFINITIONS})
+ if(NOT LLVM_ENABLE_RTTI)
+ # Make sure that we don't disable rtti if this library wasn't compiled with
+ # support
+ add_supported_cxx_flags(${target_name} INTERFACE -fno-rtti /GR-)
+ endif()
+endfunction()
+
+# The same for clang
+function(clang_target_from_libs target_name)
+ set(clang_libs ${ARGN})
+ add_library(${target_name} INTERFACE)
+ target_link_libraries(${target_name} INTERFACE ${clang_libs})
+ target_include_directories(
+ ${target_name}
+ SYSTEM
+ INTERFACE ${CLANG_INCLUDE_DIRS}
+ )
+ target_compile_definitions(${target_name} INTERFACE ${CLANG_DEFINITIONS})
+ if(NOT LLVM_ENABLE_RTTI)
+ # Make sure that we don't disable rtti if this library wasn't compiled with
+ # support
+ add_supported_cxx_flags(${target_name} INTERFACE -fno-rtti /GR-)
+ endif()
+endfunction()
diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake
new file mode 100644
index 000000000..44d6c945c
--- /dev/null
+++ b/cmake/SlangTarget.cmake
@@ -0,0 +1,377 @@
+#
+# A function to make target creation a little more declarative
+#
+# See the comments on the options below for usage
+#
+function(slang_add_target dir type)
+ set(no_value_args
+ # Don't include in the 'all' target
+ EXCLUDE_FROM_ALL
+ # This is loaded at runtime as a shared library
+ SHARED_LIBRARY_TOOL
+ # -Wextra
+ USE_EXTRA_WARNINGS
+ # don't set -Wall
+ USE_FEWER_WARNINGS
+ # Make this a Windows app, rather than a console app, only makes a
+ # difference when compiling for Windows
+ WIN32_EXECUTABLE
+ # Install this target for a non-component install
+ INSTALL
+ )
+ set(single_value_args
+ # Set the target name, useful for multiple targets from the same
+ # directory.
+ # By default this is the name of the last directory component given
+ TARGET_NAME
+ # Set the output name, otherwise defaults to the target name
+ OUTPUT_NAME
+ # Set an explicit output directory relative to the cmake binary
+ # directory. otherwise defaults to the binary directory root.
+ # Outputs are always placed in a further subdirectory according to
+ # build config
+ OUTPUT_DIR
+ # If this is a shared library then the ${EXPORT_MACRO_PREFIX}_DYNAMIC and
+ # ${EXPORT_MACRO_PREFIX}_DYNAMIC_EXPORT macros are set for using and
+ # building respectively
+ EXPORT_MACRO_PREFIX
+ # The folder in which to place this target for IDE-based generators (VS
+ # and XCode)
+ FOLDER
+ # The working directory for debugging
+ DEBUG_DIR
+ # Install this target as part of a component
+ INSTALL_COMPONENT
+ )
+ set(multi_value_args
+ # Use exactly these sources, instead of globbing from the directory
+ # argument
+ EXPLICIT_SOURCE
+ # Additional directories from which to glob source
+ EXTRA_SOURCE_DIRS
+ # Additional compile definitions
+ EXTRA_COMPILE_DEFINITIONS_PRIVATE
+ EXTRA_COMPILE_DEFINITIONS_PUBLIC
+ # Targets with which to link privately
+ LINK_WITH_PRIVATE
+ # Targets whose headers we use, but don't link with
+ INCLUDE_FROM_PRIVATE
+ # Any include directories other targets need to use this target
+ INCLUDE_DIRECTORIES_PUBLIC
+ # Add a dependency on the new target to the specified targets
+ REQUIRED_BY
+ # Add a dependency to the new target on the specified targets
+ REQUIRES
+ # Globs for any headers to install
+ PUBLIC_HEADERS
+ )
+ cmake_parse_arguments(
+ ARG
+ "${no_value_args}"
+ "${single_value_args}"
+ "${multi_value_args}"
+ ${ARGN}
+ )
+
+ if(DEFINED ARG_UNPARSED_ARGUMENTS OR DEFINED ARG_KEYWORDS_MISSING_VALUES)
+ foreach(unparsed_arg ${ARG_UNPARSED_ARGUMENTS})
+ message(
+ SEND_ERROR
+ "Unrecognized argument in slang_add_target: ${unparsed_arg}"
+ )
+ endforeach()
+ foreach(bad_kwarg ${ARG_KEYWORDS_MISSING_VALUES})
+ message(
+ SEND_ERROR
+ "Keyword argument missing values in slang_add_target: ${bad_kwarg}"
+ )
+ endforeach()
+ return()
+ endif()
+
+ #
+ # Set up some variables, including the target name
+ #
+ get_filename_component(dir_absolute ${dir} ABSOLUTE)
+ if(DEFINED ARG_TARGET_NAME)
+ set(target ${ARG_TARGET_NAME})
+ else()
+ get_filename_component(target ${dir_absolute} NAME)
+ endif()
+
+ #
+ # Find the source for this target
+ #
+ if(ARG_EXPLICIT_SOURCE)
+ list(APPEND source ${ARG_EXPLICIT_SOURCE})
+ else()
+ slang_glob_sources(source ${dir})
+ endif()
+ foreach(extra_dir ${ARG_EXTRA_SOURCE_DIRS})
+ slang_glob_sources(source ${extra_dir})
+ endforeach()
+
+ #
+ # Create the target
+ #
+ set(library_types
+ STATIC
+ SHARED
+ OBJECT
+ MODULE
+ ALIAS
+ )
+ if(type STREQUAL "EXECUTABLE")
+ add_executable(${target} ${source})
+ elseif(type STREQUAL "LIBRARY")
+ add_library(${target} ${source})
+ elseif(type IN_LIST library_types)
+ add_library(${target} ${type} ${source})
+ else()
+ message(
+ SEND_ERROR
+ "Unsupported target type ${type} in slang_add_target"
+ )
+ return()
+ endif()
+
+ #
+ # Set the output directory
+ #
+ # We don't want the output directory to be sensitive to where
+ # slang_add_target is called from, so set it explicitly here.
+ #
+ if(DEFINED ARG_OUTPUT_DIR)
+ set(output_dir "${CMAKE_BINARY_DIR}/${ARG_OUTPUT_DIR}/$<CONFIG>")
+ else()
+ # Default to placing things in the cmake binary root.
+ #
+ # While it would be nice to place things according to their
+ # subdirectory, Windows' inflexibility in being able to find DLLs makes
+ # this tricky there.
+ set(output_dir "${CMAKE_BINARY_DIR}/$<CONFIG>")
+ endif()
+ set(archive_subdir ${library_subdir})
+ if(type STREQUAL "MODULE")
+ set(library_subdir ${module_subdir})
+ endif()
+ set_target_properties(
+ ${target}
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY "${output_dir}/${archive_subdir}"
+ LIBRARY_OUTPUT_DIRECTORY "${output_dir}/${library_subdir}"
+ RUNTIME_OUTPUT_DIRECTORY "${output_dir}/${runtime_subdir}"
+ PDB_OUTPUT_DIRECTORY "${output_dir}/${runtime_subdir}"
+ )
+
+ #
+ # Set common compile options and properties
+ #
+ if(ARG_USE_EXTRA_WARNINGS)
+ set_default_compile_options(${target} USE_EXTRA_WARNINGS)
+ elseif(ARG_USE_FEWER_WARNINGS)
+ set_default_compile_options(${target} USE_FEWER_WARNINGS)
+ else()
+ set_default_compile_options(${target})
+ endif()
+
+ set_target_properties(
+ ${target}
+ PROPERTIES EXCLUDE_FROM_ALL ${ARG_EXCLUDE_FROM_ALL}
+ )
+
+ set_target_properties(
+ ${target}
+ PROPERTIES WIN32_EXECUTABLE ${ARG_WIN32_EXECUTABLE}
+ )
+
+ if(DEFINED ARG_OUTPUT_NAME)
+ set_target_properties(
+ ${target}
+ PROPERTIES OUTPUT_NAME ${ARG_OUTPUT_NAME}
+ )
+ endif()
+
+ if(DEFINED ARG_FOLDER)
+ set_target_properties(${target} PROPERTIES FOLDER ${ARG_FOLDER})
+ endif()
+
+ if(DEFINED ARG_DEBUG_DIR)
+ set_target_properties(
+ ${target}
+ PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${ARG_DEBUG_DIR}
+ )
+ endif()
+
+ #
+ # Link and include from dependencies
+ #
+ target_link_libraries(${target} PRIVATE ${ARG_LINK_WITH_PRIVATE})
+
+ foreach(include_from ${ARG_INCLUDE_FROM_PRIVATE})
+ target_include_directories(
+ ${target}
+ PRIVATE
+ $<TARGET_PROPERTY:${include_from},INTERFACE_INCLUDE_DIRECTORIES>
+ )
+ endforeach()
+
+ #
+ # Set our exported include directories
+ #
+ foreach(inc ${ARG_INCLUDE_DIRECTORIES_PUBLIC})
+ get_filename_component(inc_abs ${inc} ABSOLUTE)
+ target_include_directories(
+ ${target}
+ PUBLIC "$<BUILD_INTERFACE:${inc_abs}>"
+ )
+ endforeach()
+
+ #
+ # Set up export macros
+ #
+ get_target_property(target_type ${target} TYPE)
+ if(DEFINED ARG_EXPORT_MACRO_PREFIX)
+ if(
+ target_type STREQUAL SHARED_LIBRARY
+ OR target_type STREQUAL MODULE_LIBRARY
+ )
+ target_compile_definitions(
+ ${target}
+ PUBLIC "${ARG_EXPORT_MACRO_PREFIX}_DYNAMIC"
+ PRIVATE "${ARG_EXPORT_MACRO_PREFIX}_DYNAMIC_EXPORT"
+ )
+ endif()
+ endif()
+
+ #
+ # Other dependencies
+ #
+ foreach(requirer ${ARG_REQUIRED_BY})
+ add_dependencies(${requirer} ${target})
+ endforeach()
+
+ if(DEFINED ARG_REQUIRES)
+ add_dependencies(${target} ${ARG_REQUIRES})
+ endif()
+
+ #
+ # Other preprocessor defines
+ #
+ if(ARG_EXTRA_COMPILE_DEFINITIONS_PRIVATE)
+ target_compile_definitions(
+ ${target}
+ PRIVATE ${ARG_EXTRA_COMPILE_DEFINITIONS_PRIVATE}
+ )
+ endif()
+ if(ARG_EXTRA_COMPILE_DEFINITIONS_PUBLIC)
+ target_compile_definitions(
+ ${target}
+ PUBLIC ${ARG_EXTRA_COMPILE_DEFINITIONS_PUBLIC}
+ )
+ endif()
+
+ #
+ # Since we do a lot of dynamic loading, unconditionally set the build rpath
+ # to find our libraries. Ordinarily CMake would sort this out, but we do
+ # have libraries which at build time don't depend on any other shared
+ # libraries of ours but which do load them at runtime, hence the need to do
+ # this explicitly here.
+ #
+ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ set(ORIGIN "@loader_path")
+ else()
+ set(ORIGIN "$ORIGIN")
+ endif()
+ set_property(
+ TARGET ${target}
+ APPEND
+ PROPERTY BUILD_RPATH "${ORIGIN}/../${library_subdir}"
+ )
+ set_property(
+ TARGET ${target}
+ APPEND
+ PROPERTY INSTALL_RPATH "${ORIGIN}/../${library_subdir}"
+ )
+
+ # On the same topic, give everything a dylib suffix on Mac OS
+ if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND type STREQUAL "MODULE")
+ set_property(TARGET ${target} PROPERTY SUFFIX ".dylib")
+ endif()
+
+ #
+ # Mark headers for installation
+ #
+ if(ARG_PUBLIC_HEADERS)
+ if(NOT ARG_INSTALL)
+ message(
+ WARNING
+ "${target} was declared with PUBLIC_HEADERS but without INSTALL, the former will do nothing"
+ )
+ endif()
+
+ glob_append(public_headers ${ARG_PUBLIC_HEADERS})
+ if(NOT public_headers)
+ message(WARNING "${target}'s PUBLIC_HEADER globs found no matches")
+ else()
+ set_target_properties(
+ ${target}
+ PROPERTIES PUBLIC_HEADER "${public_headers}"
+ )
+ endif()
+ endif()
+
+ #
+ # Mark for installation
+ #
+ if(ARG_INSTALL OR ARG_INSTALL_COMPONENT)
+ set(component_args)
+ if(ARG_INSTALL_COMPONENT)
+ set(component_args COMPONENT ${ARG_INSTALL_COMPONENT})
+ endif()
+ set(exclude_arg)
+ if(NOT ARG_INSTALL)
+ set(exclude_arg EXCLUDE_FROM_ALL)
+ endif()
+ install(
+ TARGETS ${target}
+ EXPORT SlangTargets
+ ARCHIVE
+ DESTINATION ${archive_subdir}
+ ${component_args}
+ ${exclude_arg}
+ LIBRARY
+ DESTINATION ${library_subdir}
+ ${component_args}
+ ${exclude_arg}
+ RUNTIME
+ DESTINATION ${runtime_subdir}
+ ${component_args}
+ ${exclude_arg}
+ PUBLIC_HEADER
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ ${component_args}
+ ${exclude_arg}
+ )
+ endif()
+endfunction()
+
+# Ideally we'd use CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_RUNTIMEDIR here,
+# however some Slang functionality (specifically generating executables on
+# Linux systems) relies on runtime libraries being at "$ORIGIN/../lib". This
+# could be improved by setting at configure-time that path to be the relative
+# path from CM_I_RD to CM_I_LD.
+set(library_subdir lib)
+set(runtime_subdir bin)
+
+# On Windows, because there's no RPATH, place modules in bin, next to the
+# executables which load them (by deault, CMAKE will place them in lib and
+# expect the application to seek them out there)
+#
+# This variable is used in the above function as and elsewhere for installing
+# an imported module (slang-llvm from binary), hence why it's defined here.
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set(module_subdir ${runtime_subdir})
+else()
+ set(module_subdir ${library_subdir})
+endif()
diff --git a/docs/building.md b/docs/building.md
index c4fb5c013..5c48d0493 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -1,63 +1,57 @@
# Building Slang From Source
-## Get the Source Code
+We support building with both Premake and CMake. Both systems are described below.
-Clone [this](https://github.com/shader-slang/slang) repository, and then run:
-
-```
-% git submodule update --init
-```
-
-The submodule update step is required to pull in dependencies used for testing infrastructure as well as the `glslang` compiler that we currently use for generating SPIR-V.
+# Building Slang with Premake
## Windows Using Visual Studio
If you are using Visual Studio on Windows, then you can just open `slang.sln` and build your desired platform/configuration. `slang.sln` and associated project files are actually just generated using [`premake5`](https://premake.github.io/). See instructions in premake section below for further explanation.
-
+
Whilst using the provided `slang.sln` solution is a fast and easy way to get a build to work, it does not make all binary dependencies available which can add features and improve performance (such as [slang-llvm](https://github.com/shader-slang/slang-llvm)). To get the binary dependencies create the solution using [`premake5`](https://premake.github.io/) described in a later section.
-
+
## Other Targets
-Slang uses [`premake5`](https://premake.github.io/) to generate projects (such as `Makefile`s) that can then be used to build Slang binaries from source.
+Slang uses [`premake5`](https://premake.github.io/) to generate projects (such as `Makefile`s) that can then be used to build Slang binaries from source.
-For Linux and other targets the section below on `premake` describes the process.
+For Linux and other targets the section below on `premake` describes the process.
-Some targets below are described as 'unofficial'. In practice this means that they are not tested as part of contiguous integration. Thus unfortunately it is quite possible from time to time for them to break on a merge of a PR. That said, if broken it is likely only very minor changes are needed to make them work again.
+Some targets below are described as 'unofficial'. In practice this means that they are not tested as part of contiguous integration. Thus unfortunately it is quite possible from time to time for them to break on a merge of a PR. That said, if broken it is likely only very minor changes are needed to make them work again.
### Generated Files
-Slang as part of it's build process generates header files, which are then used to compile the main Slang project. If you use `premake` to create your project, it will automatically generate these files before compiling the rest of the Slang. These are the current header generations which are created via the `slang-generate` and other tools...
+Slang as part of it's build process generates header files, which are then used to compile the main Slang project. If you use `premake` to create your project, it will automatically generate these files before compiling the rest of the Slang. These are the current header generations which are created via the `slang-generate` and other tools...
* core.meta.slang -> core.meta.slang.h
-* hlsl.meta.slang -> hlsl.meta.slang.h
+* hlsl.meta.slang -> hlsl.meta.slang.h
Other files that are generated have `generated` as part of their name.
-It may be necessary or desirable to create a build of Slang without using `premake`.
+It may be necessary or desirable to create a build of Slang without using `premake`.
-One way to do this would be to first compile slang-generate and then invoke it directly or as a dependency in your build. Another perhaps simpler way would be to first compile the same Slang source on another system that does support `premake`, or using a preexisting build mechanism (such as Visual Studio projects on Windows). Then copy the generated header files to your target system. This is appropriate because the generated files are indentical across platforms. It does of course mean that if `core.meta.slang` or `hlsl.meta.slang` files change the headers will need to be regenerated.
+One way to do this would be to first compile slang-generate and then invoke it directly or as a dependency in your build. Another perhaps simpler way would be to first compile the same Slang source on another system that does support `premake`, or using a preexisting build mechanism (such as Visual Studio projects on Windows). Then copy the generated header files to your target system. This is appropriate because the generated files are indentical across platforms. It does of course mean that if `core.meta.slang` or `hlsl.meta.slang` files change the headers will need to be regenerated.
## Premake
-Slang uses the tool [`premake5`](https://premake.github.io/) in order to generate projects that can be built on different targets. On Linux premake will generate Makefile/s and on windows it will generate a Visual Studio solution. Information on invoking premake for different kinds of targets can be found [here](https://github.com/premake/premake-core/wiki/Using-Premake).
+Slang uses the tool [`premake5`](https://premake.github.io/) in order to generate projects that can be built on different targets. On Linux premake will generate Makefile/s and on windows it will generate a Visual Studio solution. Information on invoking premake for different kinds of targets can be found [here](https://github.com/premake/premake-core/wiki/Using-Premake).
-Slang includes `premake5` as part of `slang-binaries` which is in the `external` directory. For the external directory to be setup it is necessary to have updated submodules with `git submodule update --init`.
+Slang includes `premake5` as part of `slang-binaries` which is in the `external` directory. For the external directory to be setup it is necessary to have updated submodules with `git submodule update --init`.
-If you are on a unix-like operating system such as OSX/Linux, it may be necesary to make premake5 executable. Use
+If you are on a unix-like operating system such as OSX/Linux, it may be necesary to make premake5 executable. Use
```
% chmod u+x external/slang-binaries/premake/***path to premake version and os***/premake5
```
-Alternatively you can download and install [`premake5`](https://premake.github.io/) on your build system.
+Alternatively you can download and install [`premake5`](https://premake.github.io/) on your build system.
Run `premake5` with `--help` to in the root of the Slang project to see available command line options (assuming `premake5` is in your `PATH`):
-
+
```
% premake5 --help
```
-To download and use binaries for a particular architecture the [slang-pack](https://github.com/shader-slang/slang-binaries/tree/master/lua-modules) package manager can be invoked via the additional `--deps` and `--arch` options. If `--arch` isn't specified it defaults to `x64`. On Windows targets, the Visual Studio platform setting should be consistent with the `--arch` option such that the appropriate binary dependencies are available. The `--deps=true` option just indicates that on invoking premake it should make the binary dependencies for the `arch` available.
+To download and use binaries for a particular architecture the [slang-pack](https://github.com/shader-slang/slang-binaries/tree/master/lua-modules) package manager can be invoked via the additional `--deps` and `--arch` options. If `--arch` isn't specified it defaults to `x64`. On Windows targets, the Visual Studio platform setting should be consistent with the `--arch` option such that the appropriate binary dependencies are available. The `--deps=true` option just indicates that on invoking premake it should make the binary dependencies for the `arch` available.
Supported `--arch` options are
@@ -72,7 +66,7 @@ For Unix like targets that might have `clang` or `gcc` compilers available you c
% premake5 gmake2 --cc=clang --deps=true --arch=x64
```
-or
+or
```
% premake5 gmake2 --cc=gcc --deps=true --arch=x64
@@ -82,7 +76,7 @@ If you want to build the [`glslang`](https://github.com/KhronosGroup/glslang) li
# Projects using `make`
-The Slang project does not include Makefiles by default - they need to be generated via `premake`. Please read the section on your target operating system on how to use `premake` to create Makefiles.
+The Slang project does not include Makefiles by default - they need to be generated via `premake`. Please read the section on your target operating system on how to use `premake` to create Makefiles.
If building a Makefile based project, for example on Linux, OSX or [Cygwin](https://cygwin.com/), the configuration needs to be specified when invoking make, the following are typical...
@@ -104,7 +98,7 @@ To check what compiler is being used/command line options you can add `verbose=1
### Windows
First download and install [`premake5`](https://premake.github.io/) on your build system. Open up a command line and go to the root directory of the slang source tree (ie the directory containing `slang.h`).
-
+
Assuming premake5 is in your `PATH`, you can create a Visual Studio 2017 project for Slang with the following command line
```
@@ -119,11 +113,11 @@ For Visual Studio 2019 use
These should create a slang.sln in the same directory and which you can then open in the appropriate Visual Studio. Building will build all of Slang, examples and it's test infrastructure.
-### Linux
+### Linux
-On Linux we need to generate Makefiles using `premake`. Please read the `premake` section for more details.
+On Linux we need to generate Makefiles using `premake`. Please read the `premake` section for more details.
-In the terminal go to the root directory of the slang source tree (ie the directory containing `slang.h`). Assuming `premake5` is in your `PATH` use
+In the terminal go to the root directory of the slang source tree (ie the directory containing `slang.h`). Assuming `premake5` is in your `PATH` use
```
% premake5 gmake2 --deps=true --arch=x64
@@ -134,14 +128,14 @@ To create a release build use
```
% make config=release_x64
```
-
+
You can vary the compiler to use via the --cc option with 'gcc' or 'clang' for example
### Mac OSX
-Note that OSX isn't an official target.
+Note that OSX isn't an official target.
-On Mac OSX to generate Makefiles or an XCode project we use `premake`. Please read the `premake` section for more details.
+On Mac OSX to generate Makefiles or an XCode project we use `premake`. Please read the `premake` section for more details.
```
% premake5 gmake2 --deps=true --arch=x64
@@ -165,11 +159,11 @@ Slang can also be built within the Xcode IDE. Invoke `premake` as follows
% premake5 xcode4 --deps=true --arch=x64
```
-Then open the `slang.xcworkspace` project inside of Xcode and build.
+Then open the `slang.xcworkspace` project inside of Xcode and build.
### Cygwin
-Note that Cygwin isn't an official target.
+Note that Cygwin isn't an official target.
One issue with building on [Cygwin](https://cygwin.com/), is that there isn't a binary version of `premake` currently available. It may be possible to make this work by building `premake` from source, and then just doing `premake5 gmake2`. Here we use another approach - using the windows `premake` to create a Cygwin project. To do this use the command line...
@@ -189,7 +183,150 @@ For example to run the tests on a windows release x64 build from the command lin
Note that on windows if you want to run all of the tests from inside visual studio, it is necessary to set the `Working Directory` under "slang-test project" > "Configuration Properties" > "Debugging" > "Working Directory" to the root directory of the slang source tree. You can do this by setting it to `$(ProjectDir)/../..` for all configurations.
-If you only see 'unit-tests' being run (unit tests are prefixed with 'unit-tests/') then the working directory is not correctly set. Most tests are text files describing the test held in the `tests` directory in the root of the slang project.
+If you only see 'unit-tests' being run (unit tests are prefixed with 'unit-tests/') then the working directory is not correctly set. Most tests are text files describing the test held in the `tests` directory in the root of the slang project.
See the [documentation on testing](../tools/slang-test/README.md) for more information.
-
+
+# Building Slang with CMake
+
+### TLDR
+
+`cmake --workflow --preset release` to configure, build, and package a release
+version of Slang.
+
+## Prerequisites:
+
+Please install:
+
+- CMake
+- A C++ compiler with support for C++17. GCC, Clang and MSVC are supported
+- A CMake compatible backend, for example Visual Studio or Ninja
+
+Optional dependencies include
+
+- CUDA
+- OptiX
+- NVAPI
+- Aftermath
+- X11
+
+## Get the Source Code
+
+Clone [this](https://github.com/shader-slang/slang) repository. Make sure to
+fetch the submodules also.
+
+```bash
+git clone https://github.com/shader-slang/slang --recursive
+```
+
+## Configure and build
+
+For a Ninja based build system (all platforms) run:
+```bash
+cmake --preset default
+cmake --build --preset release # or --preset debug
+```
+
+For Visual Studio run:
+```bash
+cmake --preset vs2022 # or --preset vs2019
+start devenv .\build\slang.sln # to optionally open the project in Visual Studio
+cmake --build --preset release # to build from the CLI
+```
+
+## Testing
+
+```bash
+build/Debug/bin/slang-test
+```
+
+See the [documentation on testing](../tools/slang-test/README.md) for more information.
+
+## More niche topics
+
+### CMake options
+
+| Option | Default | Description |
+|-----------------------------------|------------------|--------------------------------------------------------------------|
+| `SLANG_VERSION` | Latest `v*` tag | The project version, detected using git if available |
+| `SLANG_EMBED_STDLIB` | `FALSE` | Build slang with an embedded version of the stdlib |
+| `SLANG_EMBED_STDLIB_SOURCE` | `TRUE` | Embed stdlib source in the binary |
+| `SLANG_ENABLE_ASAN` | `FALSE` | Enable ASAN (address sanitizer) |
+| `SLANG_ENABLE_FULL_IR_VALIDATION` | `FALSE` | Enable full IR validation (SLOW!) |
+| `SLANG_SLANG_LLVM_FLAVOR` | `FETCH_BINARY` | How to set up llvm support |
+| `SLANG_SLANG_LLVM_BINARY_URL` | System dependent | URL specifying the location of the slang-llvm prebuilt library |
+| `SLANG_GENERATORS_PATH` | `` | Path to an installed `all-generators` target for cross compilation |
+
+The following options relate to optional dependencies for additional backends
+and running additional tests. Left unchanged they are auto detected, however
+they can be set to `OFF` to prevent their usage, or set to `ON` to make it an
+error if they can't be found.
+
+| Option | CMake hints | Notes |
+|--------------------------|--------------------------------|---------------------------------------------------------------------|
+| `SLANG_ENABLE_CUDA` | `CUDAToolkit_ROOT` `CUDA_PATH` | |
+| `SLANG_ENABLE_OPTIX` | `Optix_ROOT_DIR` | Requires CUDA |
+| `SLANG_ENABLE_NVAPI` | `NVAPI_ROOT_DIR` | Only available for builds targeting Windows |
+| `SLANG_ENABLE_AFTERMATH` | `Aftermath_ROOT_DIR` | Enable Aftermath in GFX, and add aftermath crash example to project |
+| `SLANG_ENABLE_XLIB` | | |
+
+### LLVM Support
+
+There are several options for getting llvm-support:
+
+- Use a prebuilt binary slang-llvm library: `-DSLANG_SLANG_LLVM_FLAVOR=FETCH_BINARY`,
+ this is the default
+ - You can set `SLANG_SLANG_LLVM_BINARY_URL` to point to a local
+ `libslang-llvm.so/slang-llvm.dll` or set it to a URL of an zip/archive
+ containing such a file
+- Use a system supplied LLVM: `-DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM`, you
+ must have llvm-13.0 and a matching libclang installed. It's important that
+ either:
+ - You don't end up linking to a dynamic libllvm.so, this will almost
+ certainly cause multiple versions of LLVM to be loaded at runtime,
+ leading to errors like `opt: CommandLine Error: Option
+ 'asm-macro-max-nesting-depth' registered more than once!`. Avoid this by
+ compiling LLVM without the dynamic library.
+ - Anything else which may be linked in (for example Mesa, also dynamically
+ loads the same llvm object)
+- Have the Slang build system build LLVM:
+ `-DSLANG_SLANG_LLVM_FLAVOR=BUILD_LLVM`, this will build LLVM binaries at
+ configure time and use that. This is only intended to be used as part of the
+ process of generating the portable binary slang-llvm library. This always
+ builds a `Release` LLVM, so is unsuitable to use when building a `Debug`
+ `slang-llvm` on Windows as the runtime libraries will be incompatible.
+- Do not enable LLVM support: `-DSLANG_SLANG_LLVM_FLAVOR=DISABLE`
+
+To build only a standalone slang-llvm, you can run:
+
+```bash
+cmake --workflow --preset slang-llvm
+```
+
+This will generate `build/dist-release/slang-slang-llvm.zip` containing the
+library. This, of course, uses the system LLVM to build slang-llvm, otherwise
+it would just be a convoluted way to download a prebuilt binary.
+
+### Cross compiling
+
+Slang generates some code at build time, using generators build from this
+codebase. Due to this, for cross compilation one must already have built these
+generators for the build platform. Build them with the `generators` preset, and
+pass the install path to the cross building CMake invocation using
+`SLANG_GENERATORS_PATH`
+
+```bash
+# build the generators
+cmake --workflow --preset generators --fresh
+mkdir my-build-platform-generators
+unzip build/dist-release/slang-generators.zip -d my-build-platform-generators
+# reconfigure, pointing to these generators
+cmake \
+ --preset release \
+ --fresh \
+ -DSLANG_GENERATORS_PATH=my-build-platform-generators/bin \
+ -Dwhatever-other-necessary-options-for-your-cross-build
+# perform the final build
+cmake --workflow --preset release
+```
+
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
new file mode 100644
index 000000000..e61db9921
--- /dev/null
+++ b/external/CMakeLists.txt
@@ -0,0 +1,78 @@
+# Don't let all these packages spam up with status messages, filter to only the
+# important stuff.
+# Don't change things however if the user has explicitly set
+# CMAKE_MESSAGE_LOG_LEVEL
+set(set_cmake_log_level FALSE)
+if(NOT CMAKE_MESSAGE_LOG_LEVEL)
+ set(set_cmake_log_level TRUE)
+ set(CMAKE_MESSAGE_LOG_LEVEL NOTICE)
+endif()
+
+# Miniz
+add_subdirectory(miniz EXCLUDE_FROM_ALL)
+set_property(TARGET miniz PROPERTY POSITION_INDEPENDENT_CODE ON)
+# Work around https://github.com/richgel999/miniz/pull/292
+get_target_property(miniz_c_launcher miniz C_COMPILER_LAUNCHER)
+if(MSVC AND miniz_c_launcher MATCHES "ccache")
+ set_property(TARGET miniz PROPERTY C_COMPILER_LAUNCHER)
+ set_property(TARGET miniz PROPERTY MSVC_DEBUG_INFORMATION_FORMAT "")
+endif()
+
+# LZ4
+set(LZ4_BUNDLED_MODE ON)
+add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL)
+if(MSVC)
+ target_compile_options(
+ lz4_static
+ PRIVATE /wd5045 /wd4820 /wd4711 /wd6385 /wd6262
+ )
+endif()
+
+# Vulkan headers
+add_subdirectory(vulkan EXCLUDE_FROM_ALL)
+
+# SPIRV-Headers
+add_subdirectory(spirv-headers EXCLUDE_FROM_ALL)
+
+# SPIRV-Tools
+set(SPIRV_TOOLS_BUILD_STATIC ON)
+set(SPIRV_WERROR OFF)
+set(SPIRV_HEADER_DIR "${CMAKE_CURRENT_LIST_DIR}/spirv-headers/")
+set(SPIRV_SKIP_TESTS ON)
+add_subdirectory(spirv-tools EXCLUDE_FROM_ALL)
+
+# glslang
+set(SKIP_GLSLANG_INSTALL ON)
+set(ENABLE_OPT ON)
+set(ENABLE_PCH OFF)
+add_subdirectory(glslang EXCLUDE_FROM_ALL)
+
+# imgui
+add_library(imgui INTERFACE)
+target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")
+
+# Tidy things up:
+
+# Restore log level if we set it
+if(set_cmake_log_level)
+ unset(CMAKE_MESSAGE_LOG_LEVEL)
+endif()
+
+# for this directory and all subdirectories, prepend
+# `external/` to the IDE FOLDER property to every target
+function(make_external dir)
+ get_property(external_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
+ foreach(external_target ${external_targets})
+ get_property(folder TARGET ${external_target} PROPERTY FOLDER)
+ set_property(
+ TARGET ${external_target}
+ PROPERTY FOLDER "external/${folder}"
+ )
+ endforeach()
+
+ get_property(subdirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
+ foreach(subdir ${subdirs})
+ make_external(${subdir})
+ endforeach()
+endfunction()
+make_external(.)
diff --git a/external/build-llvm.sh b/external/build-llvm.sh
new file mode 100755
index 000000000..a01158e78
--- /dev/null
+++ b/external/build-llvm.sh
@@ -0,0 +1,134 @@
+#!/usr/bin/env bash
+
+set -e
+
+help() {
+ me=$(basename "$0")
+ cat <<EOF
+$me: Fetch, build and install LLVM for Slang
+
+Options:
+ --repo: The source git repo, default: $repo
+ --branch: The branch (or tag) to fetch, default: $branch
+ --source-dir: Unpack and build in this directory: default $source_dir
+ --config: The configuration to build, default $config
+ --install-prefix: Install under this prefix
+ --: Any following arguments will be passed to the CMake configuration command
+EOF
+}
+
+#
+# Some helper functions
+#
+msg(){
+ printf "%s\n" "$1" >&2
+}
+
+fail() {
+ msg "$1"
+ exit 1
+}
+
+for prog in "cmake" "ninja" "git"; do
+ if ! command -v "$prog" &>/dev/null; then
+ msg "This script needs $prog, but it isn't in \$PATH"
+ missing_bin=1
+ fi
+done
+if [ "$missing_bin" ]; then
+ exit 1
+fi
+
+#
+# Temp dir with cleanup on exit
+#
+temp_dir=$(mktemp -d)
+cleanup() {
+ local exit_status=$?
+ rm -rf "$temp_dir"
+ exit $exit_status
+}
+trap cleanup EXIT SIGHUP SIGINT SIGTERM
+
+#
+# Options and parsing
+#
+repo=https://github.com/llvm/llvm-project
+branch=llvmorg-13.0.1
+source_dir=$temp_dir
+install_prefix=
+config=Release
+extra_arguments=()
+
+while [[ "$#" -gt 0 ]]; do
+ case $1 in
+ -h | --help) help; exit ;;
+ --repo) repo=$2; shift;;
+ --branch) branch=$2; shift;;
+ --source-dir) source_dir=$2; shift;;
+ --config) config=$2; shift;;
+ --install-prefix) install_prefix=$2; shift;;
+ --) shift; extra_arguments+=("$@"); break;;
+ *)
+ msg "Unknown parameter passed: $1"
+ help >&2
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+[ -n "$repo" ] || fail "please set --repo"
+[ -n "$branch" ] || fail "please set --branch"
+[ -n "$source_dir" ] || fail "please set --source-dir"
+[ -n "$config" ] || fail "please set --config"
+[ -n "$install_prefix" ] || fail "please set --install-prefix"
+
+msg "##########################################################"
+msg "# Fetching LLVM from $repo at $branch"
+msg "##########################################################"
+git -c advice.detachedHead=false clone "$repo" --branch "$branch" "$source_dir" --depth 1
+
+msg "##########################################################"
+msg "# Configuring LLVM in $source_dir"
+msg "##########################################################"
+cmake_arguments_for_slang=(
+ # Don't build unnecessary things
+ -DLLVM_BUILD_LLVM_C_DYLIB=0
+ -DLLVM_INCLUDE_BENCHMARKS=0
+ -DLLVM_INCLUDE_DOCS=0
+ -DLLVM_INCLUDE_EXAMPLES=0
+ -DLLVM_INCLUDE_TESTS=0
+ -DLLVM_ENABLE_TERMINFO=0
+ -DCLANG_BUILD_TOOLS=0
+ -DCLANG_ENABLE_STATIC_ANALYZER=0
+ -DCLANG_ENABLE_ARCMT=0
+ -DCLANG_INCLUDE_DOCS=0
+ -DCLANG_INCLUDE_TESTS=0
+ # Requirements for Slang
+ -DLLVM_ENABLE_PROJECTS=clang
+ "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64"
+ -DLLVM_BUILD_TOOLS=1
+)
+build_dir=$source_dir/build
+mkdir -p "$build_dir"
+cmake \
+ -S "$source_dir/llvm" -B "$build_dir" \
+ -G "Ninja Multi-Config" \
+ "${cmake_arguments_for_slang[@]}" \
+ "${extra_arguments[@]}"
+
+msg "##########################################################"
+msg "# Building LLVM in $build_dir"
+msg "##########################################################"
+cmake --build "$build_dir" -j --config "$config"
+
+msg "##########################################################"
+msg "# Installing LLVM to $install_prefix"
+msg "##########################################################"
+cmake --install "$build_dir" --prefix "$install_prefix" --config "$config"
+
+msg "##########################################################"
+msg "LLVM installed in $install_prefix"
+msg "Please add $install_prefix to CMAKE_PREFIX_PATH"
+msg "##########################################################"
diff --git a/external/imgui b/external/imgui
-Subproject fd2a90ee60c1b766af5a5ae167f38d601414141
+Subproject 3c15dffc944419eb4bb17984548468270ca9048
diff --git a/external/lz4 b/external/lz4
-Subproject d44371841a2f1728a3f36839fd4b7e872d0927d
+Subproject 039ab4696526378ec0d111058b48305964284bf
diff --git a/external/miniz b/external/miniz
-Subproject a4264837ae37384b1d7a205a6732db322f0f376
+Subproject 18795fa61e590521381ba9e1fa4a4ab362b095f
diff --git a/external/spirv-tools b/external/spirv-tools
-Subproject 8994351e58e45e1f067733966628383c50341de
+Subproject 866e60defc05326c5cf0ad711ec453dd25e6ede
diff --git a/prelude/CMakeLists.txt b/prelude/CMakeLists.txt
new file mode 100644
index 000000000..751aa9a5c
--- /dev/null
+++ b/prelude/CMakeLists.txt
@@ -0,0 +1,32 @@
+#
+# Use the slang-embed tool to generate a source file for each prelude header.
+# Construct a library called 'prelude' to be linked with by slang
+#
+
+glob_append(SLANG_PRELUDE_HEADERS "*-prelude.h")
+
+set(SLANG_PRELUDE_SOURCE)
+foreach(input ${SLANG_PRELUDE_HEADERS})
+ get_filename_component(input_name ${input} NAME)
+ set(output "${CMAKE_CURRENT_BINARY_DIR}/${input_name}.cpp")
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND slang-embed "${input}" ${output}
+ DEPENDS ${input}
+ VERBATIM
+ )
+ list(APPEND SLANG_PRELUDE_SOURCE ${output})
+endforeach()
+
+slang_add_target(
+ .
+ OBJECT
+ EXPLICIT_SOURCE ${SLANG_PRELUDE_SOURCE}
+ EXCLUDE_FROM_ALL
+ TARGET_NAME prelude
+ INCLUDE_DIRECTORIES_PUBLIC ${CMAKE_CURRENT_LIST_DIR}
+ PUBLIC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/slang*.h
+ # It's an object library, so the install step only installs the headers
+ INSTALL
+ FOLDER generated
+)
diff --git a/premake5.lua b/premake5.lua
index 1af31bb4b..2034d004b 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -924,6 +924,8 @@ standardProject("core", "source/core")
--
warnings "Extra"
+ includedirs { "external/miniz" }
+
if targetInfo.isWindows then
addSourceDir "source/core/windows"
else
@@ -957,6 +959,7 @@ standardProject("slang-rt", "source/slang-rt")
pic "On"
warnings "Extra"
links {"miniz", "lz4"}
+ includedirs { "external/miniz" }
defines { "SLANG_RT_DYNAMIC", "SLANG_RT_DYNAMIC_EXPORT" }
addSourceDir "source/core"
if targetInfo.isWindows then
@@ -1788,6 +1791,12 @@ standardProject("miniz", nil)
"external/miniz/miniz_tinfl.c",
"external/miniz/miniz_zip.c"
}
+
+ -- A file usually created by miniz's build system
+ io.writefile("external/miniz/miniz_export.h", "#define MINIZ_EXPORT")
+ -- Miniz redefines this, so remove it for this project
+ removedefines "WIN32_LEAN_AND_MEAN"
+
filter { "system:linux" }
defines { "_LARGEFILE64_SOURCE" }
diff --git a/slang.h b/slang.h
index f640190a4..c4fb555e6 100644
--- a/slang.h
+++ b/slang.h
@@ -217,7 +217,7 @@ convention for interface methods.
#endif
-#if !defined(SLANG_STATIC) && !defined(SLANG_STATIC)
+#if !defined(SLANG_STATIC) && !defined(SLANG_DYNAMIC)
#define SLANG_DYNAMIC
#endif
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index d8df9714a..79aefc71d 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -632,7 +632,10 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
if (options.libraryPaths.count && options.targetType == SLANG_HOST_EXECUTABLE)
{
- cmdLine.addArg("-Wl,-rpath,$ORIGIN");
+ if(PlatformUtil::isFamily(PlatformFamily::Apple, platformKind))
+ cmdLine.addArg("-Wl,-rpath,@loader_path,-rpath,@loader_path/../lib");
+ else
+ cmdLine.addArg("-Wl,-rpath,$ORIGIN,-rpath,$ORIGIN/../lib");
}
StringSlicePool libPathPool(StringSlicePool::Style::Default);
diff --git a/source/core/slang-deflate-compression-system.cpp b/source/core/slang-deflate-compression-system.cpp
index 6c75de9e4..a8e6302cf 100644
--- a/source/core/slang-deflate-compression-system.cpp
+++ b/source/core/slang-deflate-compression-system.cpp
@@ -6,10 +6,7 @@
// We don't want compress #define to clash
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES 1
-#include "../../external/miniz/miniz.h"
-#include "../../external/miniz/miniz_common.h"
-#include "../../external/miniz/miniz_tdef.h"
-#include "../../external/miniz/miniz_tinfl.h"
+#include <miniz.h>
#include "slang-blob.h"
diff --git a/source/core/slang-zip-file-system.cpp b/source/core/slang-zip-file-system.cpp
index 011fd2aab..9944bd9cf 100644
--- a/source/core/slang-zip-file-system.cpp
+++ b/source/core/slang-zip-file-system.cpp
@@ -12,11 +12,7 @@
#include "slang-implicit-directory-collector.h"
-#include "../../external/miniz/miniz.h"
-#include "../../external/miniz/miniz_common.h"
-#include "../../external/miniz/miniz_tdef.h"
-#include "../../external/miniz/miniz_tinfl.h"
-#include "../../external/miniz/miniz_zip.h"
+#include <miniz.h>
namespace Slang
{
diff --git a/source/slang-llvm/slang-llvm-filecheck.cpp b/source/slang-llvm/slang-llvm-filecheck.cpp
new file mode 100644
index 000000000..bd71eac05
--- /dev/null
+++ b/source/slang-llvm/slang-llvm-filecheck.cpp
@@ -0,0 +1,188 @@
+// This file contains a definition of LLVMFileCheck, an implementaion for
+// IFileCheck.
+
+#include <llvm/ADT/SmallString.h>
+#include <llvm/Support/raw_ostream.h>
+#include <llvm/FileCheck/FileCheck.h>
+
+#include <slang.h>
+#include <slang-com-helper.h>
+#include <slang-com-ptr.h>
+#include <core/slang-com-object.h>
+#include <tools/slang-test/filecheck.h>
+
+namespace slang_llvm
+{
+
+using namespace llvm;
+using namespace Slang;
+
+class LLVMFileCheck : IFileCheck, ComBaseObject
+{
+public:
+ // ICastable
+ virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) override;
+
+ // IUnknown
+ SLANG_COM_BASE_IUNKNOWN_ALL
+ void* getInterface(const Guid& guid);
+ void* getObject(const Guid& guid);
+
+ // IFileCheck
+ virtual TestResult SLANG_MCALL performTest(
+ const char* programName,
+ const char* rulesFilePath,
+ const char* fileCheckPrefix,
+ const char* stringToCheck,
+ const char* stringToCheckName,
+ ReportDiagnostic testReporter,
+ void* reporterData,
+ bool colorDiagnosticOutput) noexcept override;
+
+private:
+ // Everything we need to pass through LLVM back to our diagnostic handler
+ struct ReporterData
+ {
+ ReportDiagnostic reportFun;
+ // User data from the caller of performTest
+ void* data;
+ bool colorDiagnosticOutput;
+ const char* programName;
+ TestMessageType testMessageType;
+ };
+
+ static void fileCheckDiagHandler(const SMDiagnostic& diag, void* reporterData);
+};
+
+class DisplayedStringOStream : public raw_string_ostream
+{
+public:
+ DisplayedStringOStream(std::string& s): raw_string_ostream(s){}
+ virtual bool is_displayed() const override { return true; };
+};
+
+void LLVMFileCheck::fileCheckDiagHandler(const SMDiagnostic& diag, void* dataPtr)
+{
+ const ReporterData& reporterData = *reinterpret_cast<ReporterData*>(dataPtr);
+ std::string s;
+ DisplayedStringOStream o(s);
+ o.enable_colors(reporterData.colorDiagnosticOutput);
+ diag.print(reporterData.programName, o);
+ reporterData.reportFun(reporterData.data, TestMessageType::TestFailure, s.c_str());
+}
+
+TestResult LLVMFileCheck::performTest(
+ const char* const programName,
+ const char* const rulesFilePath,
+ const char* const fileCheckPrefix,
+ const char* const stringToCheck,
+ const char* const stringToCheckName,
+ const ReportDiagnostic testReporter,
+ void* const userReporterData,
+ const bool colorDiagnosticOutput) noexcept
+{
+ //
+ // Set up our FileCheck session
+ //
+ FileCheckRequest fcReq;
+ fcReq.CheckPrefixes = {fileCheckPrefix};
+ FileCheck fc(fcReq);
+
+ //
+ // Set up the LLVM source manager for diagnostic output from our input buffers
+ //
+ SourceMgr sourceManager;
+ auto rulesTextOrError = MemoryBuffer::getFile(rulesFilePath, true);
+ if(std::error_code err = rulesTextOrError.getError())
+ {
+ const std::string message = "Unable to load FileCheck rules file: " + err.message();
+ testReporter(userReporterData, TestMessageType::RunError, message.c_str());
+ return TestResult::Fail;
+ }
+ SmallString<4096> rulesBuffer;
+ StringRef rulesStringRef = fc.CanonicalizeFile(*rulesTextOrError.get(), rulesBuffer);
+ sourceManager.AddNewSourceBuffer(
+ MemoryBuffer::getMemBuffer(rulesStringRef, rulesFilePath),
+ SMLoc());
+
+ SmallString<4096> inputBuffer;
+ const auto inputStringMB = MemoryBuffer::getMemBuffer(
+ StringRef(stringToCheck),
+ stringToCheckName,
+ false);
+ const StringRef inputStringRef = fc.CanonicalizeFile(*inputStringMB.get(), inputBuffer);
+ sourceManager.AddNewSourceBuffer(
+ MemoryBuffer::getMemBuffer(inputStringRef, stringToCheckName),
+ SMLoc());
+
+ // Initialize this with a 'RunError' failure type. We'll "downgrade" this to
+ // 'TestFailure' once we've done the FileCheck setup.
+ ReporterData reporterData{
+ testReporter,
+ userReporterData,
+ colorDiagnosticOutput,
+ programName,
+ TestMessageType::RunError};
+ sourceManager.setDiagHandler(fileCheckDiagHandler, static_cast<void*>(&reporterData));
+
+ auto checkPrefix = fc.buildCheckPrefixRegex();
+ if(fc.readCheckFile(sourceManager, rulesStringRef, checkPrefix))
+ {
+ // FileCheck failed to find or understand any FileCheck rules in
+ // the input file, automatic fail, and reported to the diag handler .
+ return TestResult::Fail;
+ }
+
+ // We've done the FileCheck setup, so make sure that any diagnostics
+ // reported on from here are just a regular test failure.
+ reporterData.testMessageType = TestMessageType::TestFailure;
+ if(!fc.checkInput(sourceManager, inputStringRef))
+ {
+ // An ordinary failure, the FileCheck rules didn't match
+ return TestResult::Fail;
+ }
+
+ return TestResult::Pass;
+}
+
+void* LLVMFileCheck::castAs(const Guid& guid)
+{
+ if (auto ptr = getInterface(guid))
+ {
+ return ptr;
+ }
+ return getObject(guid);
+}
+
+void* LLVMFileCheck::getInterface(const Guid& guid)
+{
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ICastable::getTypeGuid() ||
+ guid == IFileCheck::getTypeGuid())
+ {
+ return static_cast<IFileCheck*>(this);
+ }
+ return nullptr;
+}
+
+void* LLVMFileCheck::getObject(const Guid& guid)
+{
+ SLANG_UNUSED(guid);
+ return nullptr;
+}
+
+} // namespace slang_llvm
+
+extern "C" SLANG_DLL_EXPORT SlangResult createLLVMFileCheck_V1(const SlangUUID& intfGuid, void** out)
+{
+ Slang::ComPtr<slang_llvm::LLVMFileCheck> fileCheck(new slang_llvm::LLVMFileCheck);
+
+ if (auto ptr = fileCheck->castAs(intfGuid))
+ {
+ fileCheck.detach();
+ *out = ptr;
+ return SLANG_OK;
+ }
+
+ return SLANG_E_NO_INTERFACE;
+}
diff --git a/source/slang-llvm/slang-llvm.cpp b/source/slang-llvm/slang-llvm.cpp
new file mode 100644
index 000000000..8ea88f09c
--- /dev/null
+++ b/source/slang-llvm/slang-llvm.cpp
@@ -0,0 +1,1066 @@
+
+#include "clang/Basic/Stack.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/Options.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/FrontendTool/Utils.h"
+
+#include "clang/Lex/PreprocessorOptions.h"
+
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/Statistic.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/LinkAllPasses.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Support/BuryPointer.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/Timer.h"
+
+#include "llvm/Support/raw_ostream.h"
+
+#include "llvm/Target/TargetMachine.h"
+
+// Jit
+#include "llvm/ExecutionEngine/JITEventListener.h"
+#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
+
+#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
+#include "llvm/ExecutionEngine/Orc/LLJIT.h"
+
+#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
+
+#include "llvm/ExecutionEngine/JITSymbol.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IRReader/IRReader.h"
+
+// Slang
+
+#include <slang.h>
+#include <slang-com-helper.h>
+#include <slang-com-ptr.h>
+
+#include <core/slang-list.h>
+#include <core/slang-string.h>
+
+#include <core/slang-hash.h>
+#include <core/slang-com-object.h>
+#include <core/slang-string-util.h>
+#include <core/slang-shared-library.h>
+
+#include <compiler-core/slang-downstream-compiler.h>
+#include <compiler-core/slang-artifact-associated-impl.h>
+#include <compiler-core/slang-artifact-desc-util.h>
+#include <compiler-core/slang-slice-allocator.h>
+
+#include <stdio.h>
+
+// We want to make math functions available to the JIT
+#if SLANG_GCC_FAMILY && __GNUC__ < 6
+# include <cmath>
+# define SLANG_LLVM_STD std::
+#else
+# include <math.h>
+# define SLANG_LLVM_STD
+#endif
+
+#if SLANG_OSX
+// For memset_pattern functions
+// https://www.unix.com/man-page/osx/3/memset_pattern16/
+# include <string.h>
+#endif
+
+#if SLANG_WINDOWS_FAMILY
+
+/*
+It's not clear if this function is needed for ARM WIN targets, but we'll assume it does for now.
+
+https://learn.microsoft.com/en-us/windows/win32/devnotes/-win32-chkstk
+https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/100775
+https://codywu2010.wordpress.com/2010/10/04/__chkstk-and-stack-overflow/
+*/
+
+# if SLANG_PROCESSOR_X86
+extern "C" void /* __declspec(naked)*/ __cdecl _chkstk();
+# else
+extern "C" void /* __declspec(naked)*/ __cdecl __chkstk();
+# endif
+#endif
+
+// Predeclare. We'll use this symbol to lookup timestamp, if we don't have a hash.
+extern "C" SLANG_DLL_EXPORT SlangResult createLLVMDownstreamCompiler_V4(const SlangUUID& intfGuid, Slang::IDownstreamCompiler** out);
+
+namespace slang_llvm {
+
+using namespace clang;
+
+using namespace llvm::opt;
+using namespace llvm;
+using namespace llvm::orc;
+
+using namespace Slang;
+
+class LLVMDownstreamCompiler : public IDownstreamCompiler, ComBaseObject
+{
+public:
+ typedef ComBaseObject Super;
+
+ // IUnknown
+ SLANG_COM_BASE_IUNKNOWN_ALL
+
+ // ICastable
+ virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;
+
+ // IDownstreamCompiler
+ virtual SLANG_NO_THROW const Desc& SLANG_MCALL getDesc() SLANG_OVERRIDE { return m_desc; }
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL compile(const CompileOptions& options, IArtifact** outArtifact) SLANG_OVERRIDE;
+ virtual SLANG_NO_THROW bool SLANG_MCALL canConvert(const ArtifactDesc& from, const ArtifactDesc& to) SLANG_OVERRIDE;
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) SLANG_OVERRIDE;
+ virtual SLANG_NO_THROW bool SLANG_MCALL isFileBased() SLANG_OVERRIDE { return false; }
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getVersionString(slang::IBlob** outVersionString) SLANG_OVERRIDE;
+
+ LLVMDownstreamCompiler():
+ m_desc(SLANG_PASS_THROUGH_LLVM, SemanticVersion(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, LLVM_VERSION_PATCH))
+ {
+ }
+
+ void* getInterface(const Guid& guid);
+ void* getObject(const Guid& guid);
+
+ Desc m_desc;
+};
+
+
+/* !!!!!!!!!!!!!!!!!!!!! LLVMJITSharedLibrary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+/* This implementation uses atomic ref counting to ensure the shared libraries lifetime can outlive the
+LLVMDownstreamCompileResult and the compilation that created it */
+class LLVMJITSharedLibrary : public ISlangSharedLibrary, public ComBaseObject
+{
+public:
+ // ISlangUnknown
+ SLANG_COM_BASE_IUNKNOWN_ALL
+
+ /// ICastable
+ virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;
+
+ // ISlangSharedLibrary impl
+ virtual SLANG_NO_THROW void* SLANG_MCALL findSymbolAddressByName(char const* name) SLANG_OVERRIDE;
+
+ LLVMJITSharedLibrary(std::unique_ptr<llvm::orc::LLJIT> jit) :
+ m_jit(std::move(jit))
+ {
+ }
+
+protected:
+ ISlangUnknown* getInterface(const SlangUUID& uuid);
+ void* getObject(const SlangUUID& uuid);
+
+ std::unique_ptr<llvm::orc::LLJIT> m_jit;
+};
+
+ISlangUnknown* LLVMJITSharedLibrary::getInterface(const SlangUUID& guid)
+{
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ISlangCastable::getTypeGuid() ||
+ guid == ISlangSharedLibrary::getTypeGuid())
+ {
+ return static_cast<ISlangSharedLibrary*>(this);
+ }
+ return nullptr;
+}
+
+void* LLVMJITSharedLibrary::getObject(const SlangUUID& uuid)
+{
+ SLANG_UNUSED(uuid);
+ return nullptr;
+}
+
+void* LLVMJITSharedLibrary::castAs(const Guid& guid)
+{
+ if (auto ptr = getInterface(guid))
+ {
+ return ptr;
+ }
+ return getObject(guid);
+}
+
+void* LLVMJITSharedLibrary::findSymbolAddressByName(char const* name)
+{
+ auto fnExpected = m_jit->lookup(name);
+ if (fnExpected)
+ {
+ auto fn = std::move(*fnExpected);
+ return (void*)fn.getAddress();
+ }
+ return nullptr;
+}
+
+
+static void _ensureSufficientStack() {}
+
+static void _llvmErrorHandler(void* userData, const std::string& message, bool genCrashDiag)
+{
+ //DiagnosticsEngine& diags = *static_cast<DiagnosticsEngine*>(userData);
+ //diags.Report(diag::err_fe_error_backend) << message;
+
+ printf("Clang/LLVM fatal error: %s\n", message.c_str());
+
+ // Run the interrupt handlers to make sure any special cleanups get done, in
+ // particular that we remove files registered with RemoveFileOnSignal.
+ llvm::sys::RunInterruptHandlers();
+
+ // We cannot recover from llvm errors. (!)
+ //
+ // Returning nothing, will still cause LLVM to exit the process.
+}
+
+static Slang::ArtifactDiagnostic::Severity _getSeverity(DiagnosticsEngine::Level level)
+{
+ typedef ArtifactDiagnostic::Severity Severity;
+ typedef DiagnosticsEngine::Level Level;
+ switch (level)
+ {
+ default:
+ case Level::Ignored:
+ case Level::Note:
+ case Level::Remark:
+ {
+ return Severity::Info;
+ }
+ case Level::Warning:
+ {
+ return Severity::Warning;
+ }
+ case Level::Error:
+ case Level::Fatal:
+ {
+ return Severity::Error;
+ }
+ }
+}
+
+class BufferedDiagnosticConsumer : public clang::DiagnosticConsumer
+{
+public:
+
+ BufferedDiagnosticConsumer(IArtifactDiagnostics* diagnostics):
+ m_diagnostics(diagnostics)
+ {
+ }
+
+ void HandleDiagnostic(DiagnosticsEngine::Level level, const Diagnostic& info) override
+ {
+ SmallString<100> text;
+ info.FormatDiagnostic(text);
+
+ ArtifactDiagnostic diagnostic;
+ diagnostic.severity = _getSeverity(level);
+ diagnostic.stage = ArtifactDiagnostic::Stage::Compile;
+ diagnostic.text = TerminatedCharSlice(text.c_str(), Count(text.size()));
+
+ auto location = info.getLocation();
+
+ // Work out what the location is
+ auto& sourceManager = info.getSourceManager();
+
+ // Gets the file/line number
+ const bool useLineDirectives = true;
+ const PresumedLoc presumedLoc = sourceManager.getPresumedLoc(location, useLineDirectives);
+
+ diagnostic.location.line = presumedLoc.getLine();
+ diagnostic.filePath = TerminatedCharSlice(presumedLoc.getFilename());
+
+ m_diagnostics->add(diagnostic);
+ }
+
+ bool hasError() const { return m_diagnostics->getCountAtLeastSeverity(ArtifactDiagnostic::Severity::Error) > 0; }
+
+ ComPtr<IArtifactDiagnostics> m_diagnostics;
+};
+
+/*
+* A question is how to make the prototypes available for these functions. They would need to be defined before the
+* the prelude - or potentially in the prelude.
+*
+* I could just define the prototypes in the prelude, and only impl, if needed. Here though I require that all the functions
+* implemented here, use C style names (ie unmanagled) to simplify lookup.
+*/
+
+struct NameAndFunc
+{
+ typedef void (*Func)();
+
+ const char* name;
+ Func func;
+};
+
+#define SLANG_LLVM_EXPAND(x) x
+
+#define SLANG_LLVM_FUNC(name, cppName, retType, paramTypes) NameAndFunc{ #name, (NameAndFunc::Func)static_cast<retType (*) paramTypes>(&SLANG_LLVM_EXPAND(cppName)) },
+
+// Implementations of maths functions available to JIT
+static float F32_frexp(float x, int* e)
+{
+ float m = ::frexpf(x, e);
+ return m;
+}
+
+static double F64_frexp(double x, int* e)
+{
+ double m = ::frexp(x, e);
+ return m;
+}
+
+static void assertFailed(const char* msg)
+{
+ printf("Assert failed: %s\n", msg);
+ SLANG_BREAKPOINT(0);
+}
+
+#if SLANG_OSX
+
+namespace OSXSpecific
+{
+
+static void bzero(void* dst, size_t size)
+{
+ ::memset(dst, 0, size);
+}
+
+} // OSXSpecific
+#endif
+
+#if SLANG_VC && SLANG_PTR_IS_32
+
+namespace WinSpecific {
+
+// NOTE! These are functions used in 32 bit windows to enable 64 bit maths. This set is probably *not* complete.
+// Check:
+
+// https://source.winehq.org/source/dlls/ntdll/large_int.c
+
+static int64_t __stdcall _alldiv(int64_t a, int64_t b)
+{
+ return a / b;
+}
+
+static int64_t __stdcall _allrem(int64_t a, int64_t b)
+{
+ return a % b;
+}
+
+static uint64_t __stdcall _aullrem(uint64_t a, uint64_t b)
+{
+ return a % b;
+}
+
+static uint64_t __stdcall _aulldiv(uint64_t a, uint64_t b)
+{
+ return a / b;
+}
+
+} // WinSpecific
+
+#endif
+
+// These are only the functions that cannot be implemented with 'reasonable performance' in the prelude.
+// It is assumed that calling from JIT to C function whilst not super expensive, is an issue.
+
+// name, cppName, retType, paramTypes
+#define SLANG_LLVM_FUNCS(x) \
+ x(F64_ceil, ceil, double, (double)) \
+ x(F64_floor, floor, double, (double)) \
+ x(F64_round, round, double, (double)) \
+ x(F64_abs, fabs, double, (double)) \
+ x(F64_sin, sin, double, (double)) \
+ x(F64_cos, cos, double, (double)) \
+ x(F64_tan, tan, double, (double)) \
+ x(F64_asin, asin, double, (double)) \
+ x(F64_acos, acos, double, (double)) \
+ x(F64_atan, atan, double, (double)) \
+ x(F64_sinh, sinh, double, (double)) \
+ x(F64_cosh, cosh, double, (double)) \
+ x(F64_tanh, tanh, double, (double)) \
+ x(F64_log2, log2, double, (double)) \
+ x(F64_log, log, double, (double)) \
+ x(F64_log10, log10, double, (double)) \
+ x(F64_exp2, exp2, double, (double)) \
+ x(F64_exp, exp, double, (double)) \
+ x(F64_fabs, fabs, double, (double)) \
+ x(F64_trunc, trunc, double, (double)) \
+ x(F64_sqrt, sqrt, double, (double)) \
+ \
+ x(F64_isnan, SLANG_LLVM_STD isnan, bool, (double)) \
+ x(F64_isfinite, SLANG_LLVM_STD isfinite, bool, (double)) \
+ x(F64_isinf, SLANG_LLVM_STD isinf, bool, (double)) \
+ \
+ x(F64_atan2, atan2, double, (double, double)) \
+ \
+ x(F64_frexp, F64_frexp, double, (double, int*)) \
+ x(F64_pow, pow, double, (double, double)) \
+ \
+ x(F64_modf, modf, double, (double, double*)) \
+ x(F64_fmod, fmod, double, (double, double)) \
+ x(F64_remainder, remainder, double, (double, double)) \
+ \
+ x(F32_ceil, ceilf, float, (float)) \
+ x(F32_floor, floorf, float, (float)) \
+ x(F32_round, roundf, float, (float)) \
+ x(F32_abs, fabsf, float, (float)) \
+ x(F32_sin, sinf, float, (float)) \
+ x(F32_cos, cosf, float, (float)) \
+ x(F32_tan, tanf, float, (float)) \
+ x(F32_asin, asinf, float, (float)) \
+ x(F32_acos, acosf, float, (float)) \
+ x(F32_atan, atanf, float, (float)) \
+ x(F32_sinh, sinhf, float, (float)) \
+ x(F32_cosh, coshf, float, (float)) \
+ x(F32_tanh, tanhf, float, (float)) \
+ x(F32_log2, log2f, float, (float)) \
+ x(F32_log, logf, float, (float)) \
+ x(F32_log10, log10f, float, (float)) \
+ x(F32_exp2, exp2f, float, (float)) \
+ x(F32_exp, expf, float, (float)) \
+ x(F32_fabs, fabsf, float, (float)) \
+ x(F32_trunc, truncf, float, (float)) \
+ x(F32_sqrt, sqrtf, float, (float)) \
+ \
+ x(F32_isnan, SLANG_LLVM_STD isnan, bool, (float)) \
+ x(F32_isfinite, SLANG_LLVM_STD isfinite, bool, (float)) \
+ x(F32_isinf, SLANG_LLVM_STD isinf, bool, (float)) \
+ \
+ x(F32_atan2, atan2f, float, (float, float)) \
+ \
+ x(F32_frexp, F32_frexp, float, (float, int*)) \
+ x(F32_pow, powf, float, (float, float)) \
+ \
+ x(F32_modf, modff, float, (float, float*)) \
+ x(F32_fmod, fmodf, float, (float, float)) \
+ x(F32_remainder, remainderf, float, (float, float)) \
+ \
+ x(assertFailed, assertFailed, void, (const char*)) \
+ \
+ x(memcpy, memcpy, void*, (void*, const void*, size_t)) \
+ x(memmove, memmove, void*, (void*, const void*, size_t)) \
+ x(memcmp, memcmp, int, (const void*, const void*, size_t)) \
+ x(memset, memset, void*, (void*, int, size_t))
+
+#if SLANG_OSX
+# define SLANG_PLATFORM_FUNCS(x) \
+ x(memset_pattern4, memset_pattern4, void, (void*, const void*, size_t)) \
+ x(memset_pattern8, memset_pattern8, void, (void*, const void*, size_t)) \
+ x(memset_pattern16, memset_pattern16, void, (void*, const void*, size_t)) \
+ \
+ x(__bzero, OSXSpecific::bzero, void, (void*, size_t))
+#endif
+
+#if SLANG_WINDOWS_FAMILY
+# if SLANG_PROCESSOR_X86
+# define SLANG_PLATFORM_FUNCS(x) \
+ x(_chkstk, _chkstk, void, ())
+# else
+# define SLANG_PLATFORM_FUNCS(x) \
+ x(__chkstk, __chkstk, void, ())
+# endif
+#endif
+
+#ifndef SLANG_PLATFORM_FUNCS
+# define SLANG_PLATFORM_FUNCS(x)
+#endif
+
+static int _getOptimizationLevel(DownstreamCompileOptions::OptimizationLevel level)
+{
+ typedef DownstreamCompileOptions::OptimizationLevel OptimizationLevel;
+ switch (level)
+ {
+ case OptimizationLevel::None: return 0;
+ default:
+ case OptimizationLevel::Default: return 1;
+ case OptimizationLevel::High: return 2;
+ case OptimizationLevel::Maximal: return 3;
+ }
+}
+
+static SlangResult _initLLVM()
+{
+ // Initialize targets first, so that --version shows registered targets.
+#if 0
+ llvm::InitializeAllTargets();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmPrinters();
+ llvm::InitializeAllAsmParsers();
+#else
+ // Just initialize items needed for this target.
+
+ llvm::InitializeNativeTarget();
+ llvm::InitializeNativeTargetAsmPrinter();
+ llvm::InitializeNativeTargetAsmParser();
+
+ llvm::InitializeNativeTargetDisassembler();
+#endif
+
+ // Set an error handler, so that any LLVM backend diagnostics go through our
+ // error handler.
+ //llvm::install_fatal_error_handler(_llvmErrorHandler, static_cast<void*>(&clang->getDiagnostics()));
+ // NOTE! Can only be set once.
+ llvm::install_fatal_error_handler(_llvmErrorHandler, nullptr);
+
+ return SLANG_OK;
+}
+
+
+bool LLVMDownstreamCompiler::canConvert(const ArtifactDesc& from, const ArtifactDesc& to)
+{
+ return false;
+}
+
+SlangResult LLVMDownstreamCompiler::convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact)
+{
+ return SLANG_E_NOT_IMPLEMENTED;
+}
+
+SlangResult LLVMDownstreamCompiler::getVersionString(slang::IBlob** outVersionString)
+{
+ StringBuilder versionString;
+ // Append the version
+ m_desc.version.append(versionString);
+
+ // Really we should have a hash to identify the specific version.
+ // For now we'll fall back to just using the timestamp
+
+ {
+ // If we don't have the commitHash, we use the library timestamp, to uniquely identify.
+ versionString << " " << SharedLibraryUtils::getSharedLibraryTimestamp((void*)createLLVMDownstreamCompiler_V4);
+ }
+
+ *outVersionString = StringBlob::moveCreate(versionString).detach();
+ return SLANG_OK;
+}
+
+void* LLVMDownstreamCompiler::castAs(const Guid& guid)
+{
+ if (auto ptr = getInterface(guid))
+ {
+ return ptr;
+ }
+ return getObject(guid);
+}
+
+void* LLVMDownstreamCompiler::getInterface(const Guid& guid)
+{
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ICastable::getTypeGuid() ||
+ guid == IDownstreamCompiler::getTypeGuid())
+ {
+ return static_cast<IDownstreamCompiler*>(this);
+ }
+ return nullptr;
+}
+
+void* LLVMDownstreamCompiler::getObject(const Guid& guid)
+{
+ SLANG_UNUSED(guid);
+ return nullptr;
+}
+
+SlangResult LLVMDownstreamCompiler::compile(const CompileOptions& inOptions, IArtifact** outArtifact)
+{
+ if (!isVersionCompatible(inOptions))
+ {
+ // Not possible to compile with this version of the interface.
+ return SLANG_E_NOT_IMPLEMENTED;
+ }
+
+ CompileOptions options = getCompatibleVersion(&inOptions);
+
+ // Currently supports single source file
+ if (options.sourceArtifacts.count != 1)
+ {
+ return SLANG_FAIL;
+ }
+ IArtifact* sourceArtifact = options.sourceArtifacts[0];
+
+ _ensureSufficientStack();
+
+ static const SlangResult initLLVMResult = _initLLVM();
+ SLANG_RETURN_ON_FAIL(initLLVMResult);
+
+ std::unique_ptr<CompilerInstance> clang(new CompilerInstance());
+ IntrusiveRefCntPtr<DiagnosticIDs> diagID(new DiagnosticIDs());
+
+ // Register the support for object-file-wrapped Clang modules.
+ auto pchOps = clang->getPCHContainerOperations();
+ pchOps->registerWriter(std::make_unique<ObjectFilePCHContainerWriter>());
+ pchOps->registerReader(std::make_unique<ObjectFilePCHContainerReader>());
+
+ IntrusiveRefCntPtr<DiagnosticOptions> diagOpts = new DiagnosticOptions();
+
+ ComPtr<IArtifactDiagnostics> diagnostics(new ArtifactDiagnostics);
+
+
+ // TODO(JS): We might just want this to talk directly to the listener.
+ // For now we just buffer up.
+ BufferedDiagnosticConsumer diagsBuffer(diagnostics);
+
+ IntrusiveRefCntPtr<DiagnosticsEngine> diags = new DiagnosticsEngine(diagID, diagOpts, &diagsBuffer, false);
+
+ ComPtr<ISlangBlob> sourceBlob;
+ SLANG_RETURN_ON_FAIL(sourceArtifact->loadBlob(ArtifactKeep::Yes, sourceBlob.writeRef()));
+
+ const auto sourceSlice = StringUtil::getSlice(sourceBlob);
+ StringRef sourceStringRef(sourceSlice.begin(), sourceSlice.getLength());
+
+ auto sourceBuffer = llvm::MemoryBuffer::getMemBuffer(sourceStringRef);
+
+ auto& invocation = clang->getInvocation();
+
+ std::string verboseOutputString;
+
+ // Capture all of the verbose output into a buffer, so not writen to stdout
+ clang->setVerboseOutputStream(std::make_unique<llvm::raw_string_ostream>(verboseOutputString));
+
+ SmallVector<char> output;
+ clang->setOutputStream(std::make_unique<llvm::raw_svector_ostream>(output));
+
+ frontend::ActionKind action = frontend::ActionKind::EmitLLVMOnly;
+
+ // EmitCodeGenOnly doesn't appear to actually emit anything
+ // EmitLLVM outputs LLVM assembly
+ // EmitLLVMOnly doesn't 'emit' anything, but the IR that is produced is accessible, from the 'action'.
+
+ action = frontend::ActionKind::EmitLLVMOnly;
+
+ //action = frontend::ActionKind::EmitBC;
+ //action = frontend::ActionKind::EmitLLVM;
+ //
+ //action = frontend::ActionKind::EmitCodeGenOnly;
+ //action = frontend::ActionKind::EmitObj;
+ //action = frontend::ActionKind::EmitAssembly;
+
+ Language language;
+ LangStandard::Kind langStd;
+ switch (options.sourceLanguage)
+ {
+ case SLANG_SOURCE_LANGUAGE_CPP:
+ {
+ language = Language::CXX;
+ langStd = LangStandard::Kind::lang_cxx17;
+ break;
+ }
+ case SLANG_SOURCE_LANGUAGE_C:
+ {
+ language = Language::C;
+ langStd = LangStandard::Kind::lang_c17;
+ break;
+ }
+ default:
+ {
+ return SLANG_E_NOT_AVAILABLE;
+ }
+ }
+
+ const InputKind inputKind(language, InputKind::Format::Source);
+
+ {
+ auto& opts = invocation.getFrontendOpts();
+
+ // Add the source
+ // TODO(JS): For the moment this kind of include does *NOT* show a input source filename
+ // not super surprising as one isn't set, but it's not clear how one would be set when the input is a memory buffer.
+ // For Slang usage, this probably isn't an issue, because it's *output* typically holds #line directives.
+ {
+
+ FrontendInputFile inputFile(*sourceBuffer, inputKind);
+ opts.Inputs.push_back(inputFile);
+ }
+
+ opts.ProgramAction = action;
+ }
+
+ {
+ auto& opts = invocation.getPreprocessorOpts();
+
+ // Add definition so that 'LLVM/Clang' compilations can be recognized
+ opts.addMacroDef("SLANG_LLVM");
+
+ for (const auto& define : options.defines)
+ {
+ const Index index = asStringSlice(define.nameWithSig).indexOf('(');
+ if (index >= 0)
+ {
+ // Interface does not support having a signature.
+ return SLANG_E_NOT_AVAILABLE;
+ }
+
+ // TODO(JS): NOTE! The options do not support setting a *value* just that a macro is defined.
+ // So strictly speaking, we should probably have a warning/error if the value is not appropriate
+ opts.addMacroDef(define.nameWithSig.begin());
+ }
+ }
+
+
+ llvm::Triple targetTriple;
+ {
+ auto& opts = invocation.getTargetOpts();
+
+ opts.Triple = LLVM_DEFAULT_TARGET_TRIPLE;
+
+ // A code model isn't set by default, "default" seems to fit the bill here
+ opts.CodeModel = "default";
+
+ targetTriple = llvm::Triple(opts.Triple);
+ }
+
+ {
+ auto opts = invocation.getLangOpts();
+
+ std::vector<std::string> includes;
+ for (const auto& includePath : options.includePaths)
+ {
+ includes.push_back(includePath.begin());
+ }
+
+ clang::CompilerInvocation::setLangDefaults(*opts, inputKind, targetTriple, includes, langStd);
+
+ if (options.floatingPointMode == DownstreamCompileOptions::FloatingPointMode::Fast)
+ {
+ opts->FastMath = true;
+ }
+ }
+
+ {
+ auto& opts = invocation.getHeaderSearchOpts();
+
+ // These only work if the resource directory is setup (or a virtual file system points to it)
+ opts.UseBuiltinIncludes = true;
+ opts.UseStandardSystemIncludes = true;
+ opts.UseStandardCXXIncludes = true;
+
+ /// Use libc++ instead of the default libstdc++.
+ //opts.UseLibcxx = true;
+ }
+
+
+ {
+ auto& opts = invocation.getCodeGenOpts();
+
+ // Set to -O optimization level
+ opts.OptimizationLevel = _getOptimizationLevel(options.optimizationLevel);
+
+ // Copy over the targets CodeModel
+ opts.CodeModel = invocation.getTargetOpts().CodeModel;
+ }
+
+ //const llvm::opt::OptTable& opts = clang::driver::getDriverOptTable();
+
+ // TODO(JS): Need a way to find in system search paths, for now we just don't bother
+ //
+ // The system search paths are for includes for compiler intrinsics it seems.
+ // Infer the builtin include path if unspecified.
+#if 0
+ {
+ auto& searchOpts = clang->getHeaderSearchOpts();
+ if (searchOpts.UseBuiltinIncludes && searchOpts.ResourceDir.empty())
+ {
+ // TODO(JS): Hack - hard coded path such that we can test out the
+ // resource directory functionality.
+
+ StringRef binaryPath = "F:/dev/llvm-12.0/llvm-project-llvmorg-12.0.1/build.vs/Release/bin";
+
+ // Dir is bin/ or lib/, depending on where BinaryPath is.
+
+ // On Windows, libclang.dll is in bin/.
+ // On non-Windows, libclang.so/.dylib is in lib/.
+ // With a static-library build of libclang, LibClangPath will contain the
+ // path of the embedding binary, which for LLVM binaries will be in bin/.
+ // ../lib gets us to lib/ in both cases.
+ SmallString<128> path = llvm::sys::path::parent_path(binaryPath);
+ llvm::sys::path::append(path, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang", CLANG_VERSION_STRING);
+
+ searchOpts.ResourceDir = path.c_str();
+ }
+ }
+#endif
+
+ // Create the actual diagnostics engine.
+ clang->createDiagnostics();
+ clang->setDiagnostics(diags.get());
+
+ if (!clang->hasDiagnostics())
+ return SLANG_FAIL;
+
+ //
+ clang->createFileManager();
+ clang->createSourceManager(clang->getFileManager());
+
+
+ std::unique_ptr<LLVMContext> llvmContext = std::make_unique<LLVMContext>();
+
+ clang::CodeGenAction* codeGenAction = nullptr;
+ std::unique_ptr<FrontendAction> act;
+
+ {
+ // If we are going to just emit IR, we need to have access to the underlying type
+ if (action == frontend::ActionKind::EmitLLVMOnly)
+ {
+ EmitLLVMOnlyAction* llvmOnlyAction = new EmitLLVMOnlyAction(llvmContext.get());
+ codeGenAction = llvmOnlyAction;
+ // Make act the owning ptr
+ act = std::unique_ptr<FrontendAction>(llvmOnlyAction);
+ }
+ else
+ {
+ act = CreateFrontendAction(*clang);
+ }
+
+ if (!act)
+ {
+ return SLANG_FAIL;
+ }
+
+ const bool compileSucceeded = clang->ExecuteAction(*act);
+
+ // If the compilation failed make sure, we have an error
+ if (!compileSucceeded)
+ {
+ diagnostics->requireErrorDiagnostic();
+ }
+
+ if (!compileSucceeded || diagsBuffer.hasError())
+ {
+ diagnostics->setResult(SLANG_FAIL);
+
+ auto artifact = ArtifactUtil::createArtifact(ArtifactDesc::make(ArtifactKind::None, ArtifactPayload::None));
+ ArtifactUtil::addAssociated(artifact, diagnostics);
+
+ *outArtifact = artifact.detach();
+ return SLANG_OK;
+ }
+ }
+
+ std::unique_ptr<llvm::Module> module;
+
+ switch (action)
+ {
+ case frontend::ActionKind::EmitLLVM:
+ {
+ // LLVM output is text, that must be zero terminated
+ output.push_back(char(0));
+
+ StringRef identifier;
+ StringRef data(output.begin(), output.size() - 1);
+
+ MemoryBufferRef memoryBufferRef(data, identifier);
+
+ SMDiagnostic err;
+ module = llvm::parseIR(memoryBufferRef, err, *llvmContext);
+ break;
+ }
+ case frontend::ActionKind::EmitBC:
+ {
+ StringRef identifier;
+ StringRef data(output.begin(), output.size());
+
+ MemoryBufferRef memoryBufferRef(data, identifier);
+
+ SMDiagnostic err;
+ module = llvm::parseIR(memoryBufferRef, err, *llvmContext);
+ break;
+ }
+ case frontend::ActionKind::EmitLLVMOnly:
+ {
+ // Get the module produced by the action
+ module = codeGenAction->takeModule();
+ break;
+ }
+ }
+
+ switch (options.targetType)
+ {
+ // TODO(JS): Shared library may not be appropriate, but as long as the 'shared library' is never accessed as a blob
+ // all is good.
+ case SLANG_SHADER_SHARED_LIBRARY:
+
+ // TODO(JS):
+ // Hmm. What does this even mean?
+ // I guess the idea is it's 'SHADER' style, but is runnable on the host.
+ case SLANG_SHADER_HOST_CALLABLE:
+ {
+ // Try running something in the module on the JIT
+ std::unique_ptr<llvm::orc::LLJIT> jit;
+ {
+ // Create the JIT
+
+ LLJITBuilder jitBuilder;
+
+ Expected<std::unique_ptr< llvm::orc::LLJIT>> expectJit = jitBuilder.create();
+ if (!expectJit)
+ {
+ /* JS: NOTE!
+
+ It is worth saying there can be some odd issues around creating the JIT - if LLVM-C is linked against.
+
+ If it is then LLVM will likely startup saying LLVM-C isn't found.
+ BUT if you have LLVM *installed* on your system (as is reasonable to do from a LLVM distro, then
+ at startup it *MIGHT* find a LLVM-C dll in that installation (ie nothing to do with the version of LLVM
+ linked with). This will likely lead to an odd error saying the 'triple can't be found' and that no
+ targets are registered.
+
+ Also note that the behavior *may* be different with Debug/Release - because of how the linked resolves symbols
+ that are multiply defined.
+
+ If there are problems creating the JIT, check that LLVM-C is not linked against (it should be disabled in the premake).
+ */
+
+ auto err = expectJit.takeError();
+
+ std::string jitErrorString;
+ llvm::raw_string_ostream jitErrorStream(jitErrorString);
+
+ jitErrorStream << err;
+
+ ArtifactDiagnostic diagnostic;
+
+ StringBuilder buf;
+ buf << "Unable to create JIT engine: " << jitErrorString.c_str();
+
+ diagnostic.severity = ArtifactDiagnostic::Severity::Error;
+ diagnostic.stage = ArtifactDiagnostic::Stage::Link;
+ diagnostic.text = TerminatedCharSlice(buf.getBuffer(), buf.getLength());
+
+ // Add the error
+ diagnostics->add(diagnostic);
+ diagnostics->setResult(SLANG_FAIL);
+
+ auto artifact = ArtifactUtil::createArtifact(ArtifactDesc::make(ArtifactKind::None, ArtifactPayload::None));
+ ArtifactUtil::addAssociated(artifact, diagnostics);
+
+ *outArtifact = artifact.detach();
+ return SLANG_OK;
+ }
+ jit = std::move(*expectJit);
+ }
+
+ // Used the following link to test this out
+ // https://www.llvm.org/docs/ORCv2.html
+ // https://www.llvm.org/docs/ORCv2.html#processandlibrarysymbols
+
+ {
+ auto& es = jit->getExecutionSession();
+
+ const DataLayout& dl = jit->getDataLayout();
+ MangleAndInterner mangler(es, dl);
+
+ // The name of the lib must be unique. Should be here as we are only thing adding libs
+ auto stdcLibExpected = es.createJITDylib("stdc");
+
+ if (stdcLibExpected)
+ {
+ auto& stdcLib = *stdcLibExpected;
+
+ // Add all the symbolmap
+ SymbolMap symbolMap;
+
+ //symbolMap.insert(std::make_pair(mangler("sin"), JITEvaluatedSymbol::fromPointer(static_cast<double (*)(double)>(&sin))));
+
+ {
+ static const NameAndFunc funcs[] =
+ {
+ SLANG_LLVM_FUNCS(SLANG_LLVM_FUNC)
+ SLANG_PLATFORM_FUNCS(SLANG_LLVM_FUNC)
+ };
+
+ for (auto& func : funcs)
+ {
+ symbolMap.insert(std::make_pair(mangler(func.name), JITEvaluatedSymbol::fromPointer(func.func)));
+ }
+ }
+
+#if SLANG_PTR_IS_32 && SLANG_VC
+ {
+ // https://docs.microsoft.com/en-us/windows/win32/devnotes/-win32-alldiv
+ symbolMap.insert(std::make_pair(mangler("_alldiv"), JITEvaluatedSymbol::fromPointer(WinSpecific::_alldiv)));
+ symbolMap.insert(std::make_pair(mangler("_allrem"), JITEvaluatedSymbol::fromPointer(WinSpecific::_allrem)));
+ symbolMap.insert(std::make_pair(mangler("_aullrem"), JITEvaluatedSymbol::fromPointer(WinSpecific::_aullrem)));
+ symbolMap.insert(std::make_pair(mangler("_aulldiv"), JITEvaluatedSymbol::fromPointer(WinSpecific::_aulldiv)));
+ }
+#endif
+
+ if (auto err = stdcLib.define(absoluteSymbols(symbolMap)))
+ {
+ return SLANG_FAIL;
+ }
+
+ // Required or the symbols won't be found
+ jit->getMainJITDylib().addToLinkOrder(stdcLib);
+ }
+ }
+
+ ThreadSafeModule threadSafeModule(std::move(module), std::move(llvmContext));
+
+ if (auto err = jit->addIRModule(std::move(threadSafeModule)))
+ {
+ return SLANG_FAIL;
+ }
+
+ if (auto err = jit->initialize(jit->getMainJITDylib()))
+ {
+ return SLANG_FAIL;
+ }
+
+ // Create the shared library
+ ComPtr<ISlangSharedLibrary> sharedLibrary(new LLVMJITSharedLibrary(std::move(jit)));
+
+ // Work out the ArtifactDesc
+ const auto targetDesc = ArtifactDescUtil::makeDescForCompileTarget(options.targetType);
+
+ auto artifact = ArtifactUtil::createArtifact(targetDesc);
+ ArtifactUtil::addAssociated(artifact, diagnostics);
+
+ artifact->addRepresentation(sharedLibrary);
+
+ *outArtifact = artifact.detach();
+ return SLANG_OK;
+ }
+ }
+
+ return SLANG_FAIL;
+}
+
+} // namespace slang_llvm
+
+extern "C" SLANG_DLL_EXPORT SlangResult createLLVMDownstreamCompiler_V4(const SlangUUID& intfGuid, Slang::IDownstreamCompiler** out)
+{
+ Slang::ComPtr<slang_llvm::LLVMDownstreamCompiler> compiler(new slang_llvm::LLVMDownstreamCompiler);
+
+ if (auto ptr = compiler->castAs(intfGuid))
+ {
+ compiler.detach();
+ *out = (Slang::IDownstreamCompiler*)ptr;
+ return SLANG_OK;
+ }
+
+ return SLANG_E_NO_INTERFACE;
+}
diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt
new file mode 100644
index 000000000..c3ea18433
--- /dev/null
+++ b/source/slang/CMakeLists.txt
@@ -0,0 +1,187 @@
+#
+# Compiling the meta.slang files
+#
+
+# List of *.meta.slang headers
+glob_append(SLANG_STDLIB_META_SOURCE "*.meta.slang")
+
+set(SLANG_STDLIB_META_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/stdlib-meta")
+
+# Generate the output file list
+set(SLANG_STDLIB_META_GENERATED_HEADERS)
+foreach(meta_source ${SLANG_STDLIB_META_SOURCE})
+ file(
+ RELATIVE_PATH
+ meta_source_relative
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${meta_source}
+ )
+ list(
+ APPEND
+ SLANG_STDLIB_META_GENERATED_HEADERS
+ "${SLANG_STDLIB_META_OUTPUT_DIR}/${meta_source_relative}.h"
+ )
+endforeach()
+
+add_custom_command(
+ OUTPUT ${SLANG_STDLIB_META_GENERATED_HEADERS}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${SLANG_STDLIB_META_OUTPUT_DIR}
+ COMMAND
+ slang-generate ${SLANG_STDLIB_META_SOURCE} --target-directory
+ ${SLANG_STDLIB_META_OUTPUT_DIR}
+ DEPENDS ${SLANG_STDLIB_META_SOURCE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+ VERBATIM
+)
+
+add_library(
+ slang-meta-headers
+ INTERFACE
+ EXCLUDE_FROM_ALL
+ ${SLANG_STDLIB_META_GENERATED_HEADERS}
+)
+set_target_properties(slang-meta-headers PROPERTIES FOLDER generated)
+target_include_directories(
+ slang-meta-headers
+ INTERFACE ${SLANG_STDLIB_META_OUTPUT_DIR}
+)
+
+#
+# generated headers for reflection
+#
+
+set(SLANG_REFLECT_INPUT
+ 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
+)
+# Make them absolute
+list(TRANSFORM SLANG_REFLECT_INPUT PREPEND "${CMAKE_CURRENT_LIST_DIR}/")
+
+set(SLANG_REFLECT_GENERATED_HEADERS
+ 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
+)
+set(SLANG_REFLECT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ast-reflect")
+list(
+ TRANSFORM SLANG_REFLECT_GENERATED_HEADERS
+ PREPEND "${SLANG_REFLECT_OUTPUT_DIR}/"
+)
+
+add_custom_command(
+ OUTPUT ${SLANG_REFLECT_GENERATED_HEADERS}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${SLANG_REFLECT_OUTPUT_DIR}
+ COMMAND
+ slang-cpp-extractor ${SLANG_REFLECT_INPUT} -strip-prefix slang- -o
+ ${SLANG_REFLECT_OUTPUT_DIR}/slang-generated -output-fields -mark-suffix
+ _CLASS
+ DEPENDS ${SLANG_REFLECT_INPUT}
+ VERBATIM
+)
+
+add_library(
+ slang-reflect-headers
+ INTERFACE
+ EXCLUDE_FROM_ALL
+ ${SLANG_REFLECT_GENERATED_HEADERS}
+)
+set_target_properties(slang-reflect-headers PROPERTIES FOLDER generated)
+target_include_directories(
+ slang-reflect-headers
+ INTERFACE ${SLANG_REFLECT_OUTPUT_DIR}
+)
+
+#
+# Slang static
+#
+
+# TODO: Avoid compiling everything in this directory twice (once here and again
+# for the shared library). This will be easier once premake is gone and we can
+# move slang-stdlib-api.cpp to the build directory. It's basically instant with
+# ccache, but that's not available everywhere.
+slang_add_target(
+ .
+ OBJECT
+ TARGET_NAME slang-no-embedded-stdlib
+ EXCLUDE_FROM_ALL
+ EXTRA_COMPILE_DEFINITIONS_PUBLIC SLANG_STATIC
+ LINK_WITH_PRIVATE
+ core
+ compiler-core
+ # Bundle the source unconditionally
+ slang-meta-headers
+ slang-reflect-headers
+ SPIRV-Headers
+ FOLDER generators
+)
+target_compile_definitions(
+ slang-no-embedded-stdlib
+ PRIVATE SLANG_WITHOUT_EMBEDDED_STD_LIB
+)
+
+#
+# Generate an embeddable stdlib
+#
+
+set(SLANG_STDLIB_GENERATED_HEADER
+ ${CMAKE_CURRENT_BINARY_DIR}/slang-stdlib-generated.h
+)
+add_custom_command(
+ OUTPUT ${SLANG_STDLIB_GENERATED_HEADER}
+ COMMAND
+ slang-bootstrap -archive-type riff-lz4 -save-stdlib-bin-source
+ ${SLANG_STDLIB_GENERATED_HEADER}
+ VERBATIM
+)
+add_library(
+ slang-stdlib-embed-headers
+ INTERFACE
+ EXCLUDE_FROM_ALL
+ ${SLANG_STDLIB_GENERATED_HEADER}
+)
+set_target_properties(slang-stdlib-embed-headers PROPERTIES FOLDER generated)
+target_include_directories(
+ slang-stdlib-embed-headers
+ INTERFACE ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+#
+# Slang itself
+#
+slang_add_target(
+ .
+ SHARED
+ LINK_WITH_PRIVATE
+ core
+ compiler-core
+ prelude
+ slang-reflect-headers
+ SPIRV-Headers
+ # slang.h is in the project root, so include that directory in the interface
+ # for slang
+ INCLUDE_DIRECTORIES_PUBLIC ${slang_SOURCE_DIR}
+ EXPORT_MACRO_PREFIX SLANG
+ INSTALL
+ PUBLIC_HEADERS ${slang_SOURCE_DIR}/slang*.h
+)
+
+if(SLANG_EMBED_STDLIB_SOURCE)
+ target_link_libraries(slang PRIVATE slang-meta-headers)
+else()
+ target_compile_definitions(slang PRIVATE SLANG_DISABLE_STDLIB_SOURCE)
+endif()
+
+if(SLANG_EMBED_STDLIB)
+ target_link_libraries(slang PRIVATE slang-stdlib-embed-headers)
+else()
+ target_compile_definitions(slang PRIVATE SLANG_WITHOUT_EMBEDDED_STD_LIB)
+endif()
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 8956663cc..c2bb515f6 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1354,6 +1354,7 @@ namespace Slang
if (_isCPUHostTarget(target))
{
libraryPaths.add(Path::getParentDirectory(Path::getExecutablePath()));
+ libraryPaths.add(Path::combine(Path::getParentDirectory(Path::getExecutablePath()), "../lib"));
// Set up the library artifact
auto artifact = Artifact::create(ArtifactDesc::make(ArtifactKind::Library, Artifact::Payload::HostCPU), toSlice("slang-rt"));
diff --git a/tests/compute/simple.slang b/tests/compute/simple.slang
index 96cccc090..49628c47f 100644
--- a/tests/compute/simple.slang
+++ b/tests/compute/simple.slang
@@ -2,6 +2,7 @@
//TEST(smoke,compute):COMPARE_COMPUTE:-dx12 -use-dxil -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-vk -shaderobj
+//TEST(smoke,compute):COMPARE_COMPUTE:-cuda -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj
// CHECK: 0
diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt
index 48242fa05..10175ec4f 100644
--- a/tests/expected-failure-github.txt
+++ b/tests/expected-failure-github.txt
@@ -1,2 +1,7 @@
tests/cpu-program/gfx-smoke.slang (cpu)
tests/language-feature/spirv-asm/imageoperands-warning.slang (vk)
+tests/language-feature/saturated-cooperation/simple.slang (vk)
+tests/language-feature/saturated-cooperation/fuse3.slang (vk)
+tests/language-feature/saturated-cooperation/fuse-product.slang (vk)
+tests/language-feature/saturated-cooperation/fuse.slang (vk)
+tests/bugs/byte-address-buffer-interlocked-add-f32.slang (vk)
diff --git a/tools/platform/gui.cpp b/tools/platform/gui.cpp
index a4602e4f2..b1cb59517 100644
--- a/tools/platform/gui.cpp
+++ b/tools/platform/gui.cpp
@@ -3,7 +3,7 @@
#ifdef _WIN32
#include <windows.h>
-#include "external/imgui/examples/imgui_impl_win32.h"
+#include <examples/imgui_impl_win32.h>
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
#endif
@@ -350,12 +350,13 @@ GUI::~GUI()
} // gfx
-#include "external/imgui/imgui.cpp"
-#include "external/imgui/imgui_draw.cpp"
+#include <imgui.cpp>
+#include <imgui_draw.cpp>
+#include <imgui_widgets.cpp>
#ifdef _WIN32
// imgui_impl_win32 defines these, so make sure it doesn't error because
// they're already there
#undef WIN32_LEAN_AND_MEAN
#undef NOMINMAX
-#include "external/imgui/examples/imgui_impl_win32.cpp"
+#include <examples/imgui_impl_win32.cpp>
#endif
diff --git a/tools/slang-embed/slang-embed.cpp b/tools/slang-embed/slang-embed.cpp
index 0edc13683..c3c683f9c 100644
--- a/tools/slang-embed/slang-embed.cpp
+++ b/tools/slang-embed/slang-embed.cpp
@@ -59,6 +59,7 @@ struct App
{
char const* appName = "slang-embed";
char const* inputPath = nullptr;
+ char const* outputPath = nullptr;
Slang::HashSet<Slang::String> includedFiles;
void parseOptions(int argc, char** argv)
@@ -78,9 +79,15 @@ struct App
argc--;
}
+ if( argc > 0 )
+ {
+ outputPath = *argv++;
+ argc--;
+ }
+
if( !inputPath || (argc != 0) )
{
- fprintf(stderr, "usage: %s <inputPath>\n", appName);
+ fprintf(stderr, "usage: %s inputPath [outputPath]\n", appName);
exit(1);
}
}
@@ -201,15 +208,14 @@ struct App
// single invocation of the tool, but for now we only have
// a single file to process.
- // We derive an output path simply by appending `.cpp` to the input path.
- //
- // TODO: If we start adding more complicated options, a `-o` option
- // to specify a desired output path would be an obvious choice.
- //
- char* outputPath = (char*) malloc(strlen(inputPath) + strlen(".cpp") + 1);
- ScopedMemory outputPathCleanup(outputPath);
- strcpy(outputPath, inputPath);
- strcat(outputPath, ".cpp");
+ // We derive an output path simply by appending `.cpp` to the input
+ // path, if not otherwise specified
+ char* defaultOutputPath = (char*) malloc(strlen(inputPath) + strlen(".cpp") + 1);
+ ScopedMemory outputPathCleanup(defaultOutputPath);
+ strcpy(defaultOutputPath, inputPath);
+ strcat(defaultOutputPath, ".cpp");
+ if(!outputPath)
+ outputPath = defaultOutputPath;
FILE* outputFile = fopen(outputPath, "w");
ScopedFile outputFileCleanup(outputFile);
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index af81385dd..d84e594e8 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -697,7 +697,7 @@ void emitTemplateNodes(
void usage(char const* appName)
{
- fprintf(stderr, "usage: %s <input>\n", appName);
+ fprintf(stderr, "usage: %s [FILE]... [--target-directory FILE]\n", appName);
}
SlangResult readAllText(char const * fileName, String& outString)
@@ -804,6 +804,11 @@ SourceFile* parseSourceFile(const String& path)
{
FILE* inputStream;
fopen_s(&inputStream, path.getBuffer(), "rb");
+ if(!inputStream)
+ {
+ fprintf(stderr, "unable to read input file: %s\n", path.getBuffer());
+ return nullptr;
+ }
fseek(inputStream, 0, SEEK_END);
size_t inputSize = ftell(inputStream);
fseek(inputStream, 0, SEEK_SET);
@@ -845,6 +850,7 @@ int main(
{
// Parse command-line arguments.
List<String> inputPaths;
+ String outputDir;
char const* appName = "slang-generate";
{
@@ -855,12 +861,27 @@ int main(
{
appName = *argCursor++;
}
- // Copy the input paths
+ // Parse arguments
for (; argCursor != argEnd; ++argCursor)
{
- // We simplify here because doing so also means paths separators are set to /
- // and that makes path emitting work correctly
- inputPaths.add(Path::simplify(UnownedStringSlice(*argCursor)));
+ const auto arg = UnownedStringSlice(*argCursor);
+ if(arg == "--target-directory")
+ {
+ argCursor++;
+ if(argCursor == argEnd)
+ {
+ usage(appName);
+ fprintf(stderr, "--target-directory expects an argument\n");
+ exit(1);
+ }
+ outputDir = Path::simplify(UnownedStringSlice(*argCursor));
+ }
+ else
+ {
+ // We simplify here because doing so also means paths separators are set to /
+ // and that makes path emitting work correctly
+ inputPaths.add(Path::simplify(arg));
+ }
}
}
@@ -875,9 +896,15 @@ int main(
for (auto& inputPath: inputPaths)
{
SourceFile* sourceFile = parseSourceFile(inputPath);
- if (sourceFile)
+ gSourceFiles.add(sourceFile);
+ }
+
+ for (auto sourceFile : gSourceFiles)
+ {
+ if(!sourceFile)
{
- gSourceFiles.add(sourceFile);
+ fprintf(stderr, "failed to parse source files\n");
+ exit(1);
}
}
@@ -901,7 +928,10 @@ int main(
// update final output only when content has changed
StringBuilder outputPathFinal;
- outputPathFinal << inputPath << ".h";
+ if(outputDir.getLength())
+ outputPathFinal << outputDir << "/" << Slang::Path::getFileName(inputPath) << ".h";
+ else
+ outputPathFinal << inputPath << ".h";
String allTextOld, allTextNew;
readAllText(outputPathFinal.getBuffer(), allTextOld);
diff --git a/tools/slang-spirv-embed-generator/spirv-embed-generator-main.cpp b/tools/slang-spirv-embed-generator/spirv-embed-generator-main.cpp
index 30f1ef6b9..2c07aa27f 100644
--- a/tools/slang-spirv-embed-generator/spirv-embed-generator-main.cpp
+++ b/tools/slang-spirv-embed-generator/spirv-embed-generator-main.cpp
@@ -1,12 +1,12 @@
#include <cstdio>
-#include "source/core/slang-dictionary.h"
-#include "source/core/slang-io.h"
-#include "source/compiler-core/slang-diagnostic-sink.h"
-#include "source/compiler-core/slang-perfect-hash.h"
-#include "source/core/slang-writer.h"
-#include "source/compiler-core/slang-spirv-core-grammar.h"
-#include "source/compiler-core/slang-lexer.h"
+#include "../../source/core/slang-dictionary.h"
+#include "../../source/core/slang-io.h"
+#include "../../source/core/slang-writer.h"
+#include "../../source/compiler-core/slang-diagnostic-sink.h"
+#include "../../source/compiler-core/slang-perfect-hash.h"
+#include "../../source/compiler-core/slang-spirv-core-grammar.h"
+#include "../../source/compiler-core/slang-lexer.h"
using namespace Slang;
diff --git a/tools/slang-test/README.md b/tools/slang-test/README.md
index 9dd46b193..61829e728 100644
--- a/tools/slang-test/README.md
+++ b/tools/slang-test/README.md
@@ -9,7 +9,7 @@ Most command line options are prefixed by - for both switches and parameter opti
An example command line:
```
-slang-test -bindir E:\slang\bin\windows-x64\Debug\\ -category full tests/compute/array-param
+slang-test -bindir E:\slang\build\Debug\bin -category full tests/compute/array-param
```
* The -bindir value means that the tools slang-test will use the binaries found in this directory.
@@ -24,8 +24,8 @@ Most types of test use 'test tools' to implement actual tests. There are current
These are typically implemeted as dlls/shared libraries that are loaded when a test is needed. Sometimes it is necessary or useful to just call one of these test tools directly with the parameters the tool takes. This can be achieved by giving the tool as a 'sub command' name on the command line. All of the parameters after the tool name will be passed directly to the tool. For example
- ```
-slang-test -bindir E:\slang\bin\windows-x64\Debug\\ slangc tests/compute/array-param.slang
+```
+slang-test -bindir E:\slang\build\Debug\bin slangc tests/compute/array-param.slang
```
Will run the 'slangc' tool with the parameters listed after 'slangc' on the command line. Any parameters before the sub command will be parsed as usual by slang-test, and if not applicable to invoking the tool will be ignored. bindir will be used for finding the tool directory. This is by design so that the sub command invocation can just be placed after the normal slang-test commands, and removed when no longer needed.
@@ -79,7 +79,7 @@ A test may be in one or more categories. The categories are specified in the tes
Specifies the directory where executables will be found.
-Eg -bindir "windows-x64\Debug\\"
+Eg -bindir "path/to/slang/output/directory/bin"
### category
diff --git a/tools/test-server/test-server-main.cpp b/tools/test-server/test-server-main.cpp
index 9f7376556..dc6a7916d 100644
--- a/tools/test-server/test-server-main.cpp
+++ b/tools/test-server/test-server-main.cpp
@@ -214,10 +214,8 @@ ISlangSharedLibrary* TestServer::loadSharedLibrary(const String& name, Diagnosti
auto loader = DefaultSharedLibraryLoader::getSingleton();
- auto toolPath = Path::combine(m_exeDirectory, name);
-
ComPtr<ISlangSharedLibrary> sharedLibrary;
- if (SLANG_FAILED(loader->loadSharedLibrary(toolPath.getBuffer(), sharedLibrary.writeRef())))
+ if (SLANG_FAILED(loader->loadSharedLibrary(name.getBuffer(), sharedLibrary.writeRef())))
{
if (sink)
{