-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e16d20f
commit b6eb23d
Showing
2 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index dc281211..c36b9bcb 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -154,6 +154,8 @@ advanced_option( | ||
"Build using system unordered dense" | ||
OFF | ||
) | ||
+advanced_option(SLANG_USE_SYSTEM_SPIRV_TOOLS "Build using system SPIR-V tools library" OFF) | ||
+advanced_option(SLANG_USE_SYSTEM_GLSLANG "Build using system glslang library" OFF) | ||
|
||
option( | ||
SLANG_SPIRV_HEADERS_INCLUDE_DIR | ||
@@ -289,6 +291,34 @@ if(${SLANG_USE_SYSTEM_UNORDERED_DENSE}) | ||
find_package(unordered_dense CONFIG QUIET) | ||
endif() | ||
|
||
+if(${SLANG_USE_SYSTEM_MINIZ}) | ||
+ find_package(miniz REQUIRED) | ||
+ add_library(miniz ALIAS miniz::miniz) | ||
+endif() | ||
+ | ||
+if(${SLANG_USE_SYSTEM_LZ4}) | ||
+ find_package(lz4 REQUIRED) | ||
+ add_library(lz4_static ALIAS LZ4::lz4) | ||
+endif() | ||
+ | ||
+if(${SLANG_USE_SYSTEM_VULKAN_HEADERS}) | ||
+ find_package(VulkanHeaders REQUIRED) | ||
+endif() | ||
+ | ||
+if(${SLANG_USE_SYSTEM_SPIRV_HEADERS}) | ||
+ find_package(SPIRV-Headers REQUIRED) | ||
+ add_library(SPIRV-Headers ALIAS SPIRV-Headers::SPIRV-Headers) | ||
+endif() | ||
+ | ||
+if(${SLANG_USE_SYSTEM_SPIRV_TOOLS}) | ||
+ find_package(SPIRV-Tools REQUIRED) | ||
+endif() | ||
+ | ||
+if(${SLANG_USE_SYSTEM_GLSLANG}) | ||
+ find_package(glslang REQUIRED) | ||
+ add_library(glslang ALIAS glslang::glslang) | ||
+endif() | ||
+ | ||
add_subdirectory(external) | ||
|
||
# webgpu_dawn is only available as a fetched shared library, since Dawn's nested source | ||
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt | ||
index 43105a5f..8b9c0f14 100644 | ||
--- a/external/CMakeLists.txt | ||
+++ b/external/CMakeLists.txt | ||
@@ -73,19 +73,24 @@ if(NOT ${SLANG_USE_SYSTEM_SPIRV_HEADERS}) | ||
endif() | ||
|
||
if(SLANG_ENABLE_SLANG_GLSLANG) | ||
+if(NOT ${SLANG_USE_SYSTEM_SPIRV_TOOLS}) | ||
# 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 ${system}) | ||
+endif() | ||
|
||
+if(NOT ${SLANG_USE_SYSTEM_GLSLANG}) | ||
# glslang | ||
set(SKIP_GLSLANG_INSTALL ON) | ||
set(ENABLE_OPT ON) | ||
set(ENABLE_PCH OFF) | ||
+ set(ALLOW_EXTERNAL_SPIRV_TOOLS ${SLANG_USE_SYSTEM_SPIRV_TOOLS}) | ||
add_subdirectory(glslang EXCLUDE_FROM_ALL ${system}) | ||
endif() | ||
+endif() | ||
|
||
# imgui | ||
add_library(imgui INTERFACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchFromGitHub, | ||
cmake, | ||
ninja, | ||
python3, | ||
miniz, | ||
lz4, | ||
libxml2, | ||
vulkan-headers, | ||
spirv-headers, | ||
glslang, | ||
llvmPackages_13, | ||
|
||
withLLVM ? true, | ||
withGlslang ? true, | ||
}: | ||
|
||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "shader-slang"; | ||
version = "2024.14.6"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "shader-slang"; | ||
repo = "slang"; | ||
rev = "v${finalAttrs.version}"; | ||
hash = "sha256-q/FR7CA3FddbHBmINOqQqfmOhlusswv3femKFax2AnM="; | ||
fetchSubmodules = true; | ||
}; | ||
|
||
patches = [ ./find-packages.patch ]; | ||
|
||
outputs = [ | ||
"out" | ||
"dev" | ||
"doc" | ||
]; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
ninja | ||
python3 | ||
]; | ||
|
||
buildInputs = | ||
[ | ||
miniz | ||
lz4 | ||
libxml2 | ||
vulkan-headers | ||
spirv-headers | ||
] | ||
++ (lib.optionals withLLVM [ | ||
llvmPackages_13.llvm | ||
llvmPackages_13.libclang | ||
]) | ||
++ (lib.optionals withGlslang [ | ||
glslang | ||
]); | ||
|
||
# Required for spaces in cmakeFlags, see https://github.com/NixOS/nixpkgs/issues/114044 | ||
__structuredAttrs = true; | ||
|
||
cmakeFlags = | ||
[ | ||
"-GNinja Multi-Config" | ||
# The cmake setup hook only specifies `-DCMAKE_BUILD_TYPE=Release`, | ||
# which does nothing for "Ninja Multi-Config". | ||
"-DCMAKE_CONFIGURATION_TYPES=Release" | ||
"-DSLANG_VERSION_FULL=v${finalAttrs.version}-nixpkgs" | ||
"-DSLANG_USE_SYSTEM_MINIZ=ON" | ||
"-DSLANG_USE_SYSTEM_LZ4=ON" | ||
#"-DSLANG_USE_SYSTEM_VULKAN_HEADERS=ON" | ||
"-DSLANG_USE_SYSTEM_SPIRV_HEADERS=ON" | ||
"-DSLANG_SPIRV_HEADERS_INCLUDE_DIR=${spirv-headers}/include" | ||
"-DSLANG_SLANG_LLVM_FLAVOR=${if withLLVM then "USE_SYSTEM_LLVM" else "DISABLE"}" | ||
] | ||
++ (lib.optionals withGlslang [ | ||
"-DSLANG_USE_SYSTEM_SPIRV_TOOLS=ON" | ||
#"-DSLANG_USE_SYSTEM_GLSLANG=ON" | ||
]) | ||
++ lib.optional (!withGlslang) "-DSLANG_ENABLE_SLANG_GLSLANG=OFF"; | ||
|
||
preFixup = '' | ||
rm $out/include/.clang-format | ||
''; | ||
|
||
meta = { | ||
description = "A shading language that makes it easier to build and maintain large shader codebases in a modular and extensible fashion"; | ||
homepage = "https://github.com/shader-slang/slang"; | ||
license = lib.licenses.mit; | ||
maintainers = with lib.maintainers; [ niklaskorz ]; | ||
mainProgram = "slang"; | ||
platforms = lib.platforms.all; | ||
}; | ||
}) |