Skip to content

Commit 1e893aa

Browse files
authored
Merge branch 'master' into bugfix/shader-slanggh-6513
2 parents 37df7af + 3058a58 commit 1e893aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1441
-506
lines changed

.github/workflows/ci.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,26 @@ jobs:
169169
-server-count 8 \
170170
-category ${{ matrix.test-category }} \
171171
-api all-cpu \
172-
-expected-failure-list tests/expected-failure-github.txt
172+
-expected-failure-list tests/expected-failure-github.txt \
173+
-show-adapter-info
173174
elif [[ "${{matrix.has-gpu}}" == "true" ]]; then
174175
"$bin_dir/slang-test" \
175176
-use-test-server \
176177
-category ${{ matrix.test-category }} \
177178
-api all-dx12 \
178179
-expected-failure-list tests/expected-failure-github.txt \
179-
-expected-failure-list tests/expected-failure-record-replay-tests.txt
180+
-expected-failure-list tests/expected-failure-record-replay-tests.txt \
181+
-expected-failure-list tests/expected-failure-github-runner.txt \
182+
-show-adapter-info
180183
else
181184
"$bin_dir/slang-test" \
182185
-use-test-server \
183186
-category ${{ matrix.test-category }} \
184187
-api all-dx12 \
185188
-expected-failure-list tests/expected-failure-github.txt \
186-
-expected-failure-list tests/expected-failure-record-replay-tests.txt
189+
-expected-failure-list tests/expected-failure-record-replay-tests.txt \
190+
-expected-failure-list tests/expected-failure-github-runner.txt \
191+
-show-adapter-info
187192
fi
188193
- name: Run Slang examples
189194
if: steps.filter.outputs.should-run == 'true' && matrix.platform != 'wasm' && matrix.full-gpu-tests
@@ -209,7 +214,8 @@ jobs:
209214
-category ${{ matrix.test-category }} \
210215
-emit-spirv-via-glsl \
211216
-api vk \
212-
-expected-failure-list tests/expected-failure.txt
217+
-expected-failure-list tests/expected-failure.txt \
218+
-show-adapter-info
213219
- uses: actions/upload-artifact@v4
214220
if: steps.filter.outputs.should-run == 'true' && ! matrix.full-gpu-tests
215221
with:

CMakeLists.txt

+71-14
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,55 @@ option(
166166
)
167167
mark_as_advanced(SLANG_SPIRV_HEADERS_INCLUDE_DIR)
168168

169+
# Options for user defined paths for external modules.
170+
advanced_option(
171+
SLANG_OVERRIDE_LZ4_PATH
172+
"Build using user defined path for LZ4"
173+
OFF
174+
)
175+
advanced_option(
176+
SLANG_OVERRIDE_MINIZ_PATH
177+
"Build using user defined path for Miniz"
178+
OFF
179+
)
180+
advanced_option(
181+
SLANG_OVERRIDE_UNORDERED_DENSE_PATH
182+
"Build using user defined path for unordered_dense"
183+
OFF
184+
)
185+
advanced_option(
186+
SLANG_OVERRIDE_VULKAN_HEADERS_PATH
187+
"Build using user defined path for Vulkan headers"
188+
OFF
189+
)
190+
advanced_option(
191+
SLANG_OVERRIDE_SPIRV_HEADERS_PATH
192+
"Build using user defined path for SPIR-V headers"
193+
OFF
194+
)
195+
advanced_option(
196+
SLANG_OVERRIDE_SPIRV_TOOLS_PATH
197+
"Build using user defined path for SPIR-V tools"
198+
OFF
199+
)
200+
advanced_option(
201+
SLANG_OVERRIDE_GLSLANG_PATH
202+
"Build using user defined path for glslang"
203+
OFF
204+
)
205+
206+
advanced_option(
207+
SLANG_EXCLUDE_DAWN
208+
"Optionally exclude webgpu_dawn from the build"
209+
OFF
210+
)
211+
212+
advanced_option(
213+
SLANG_EXCLUDE_TINT
214+
"Optionally exclude slang-tint from the build"
215+
OFF
216+
)
217+
169218
if(${SLANG_USE_SYSTEM_LZ4})
170219
add_compile_definitions(SLANG_USE_SYSTEM_LZ4_HEADER)
171220
endif()
@@ -178,6 +227,10 @@ if(${SLANG_USE_SYSTEM_UNORDERED_DENSE})
178227
add_compile_definitions(SLANG_USE_SYSTEM_UNORDERED_DENSE_HEADER)
179228
endif()
180229

230+
if(SLANG_OVERRIDE_SPIRV_HEADERS_PATH)
231+
add_compile_definitions(SLANG_USE_SYSTEM_SPIRV_HEADER)
232+
endif()
233+
181234
enum_option(
182235
SLANG_LIB_TYPE
183236
# Default
@@ -251,24 +304,28 @@ if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY)
251304
)
252305
endif()
253306

254-
set(webgpu_dawn_release_tag "webgpu_dawn-0")
255-
if(
256-
CMAKE_SYSTEM_NAME MATCHES "Windows"
257-
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
258-
)
259-
set(SLANG_WEBGPU_DAWN_BINARY_URL
260-
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
307+
if(NOT SLANG_EXCLUDE_DAWN)
308+
set(webgpu_dawn_release_tag "webgpu_dawn-0")
309+
if(
310+
CMAKE_SYSTEM_NAME MATCHES "Windows"
311+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
261312
)
313+
set(SLANG_WEBGPU_DAWN_BINARY_URL
314+
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
315+
)
316+
endif()
262317
endif()
263318

264-
set(slang_tint_release_tag "slang-tint-0")
265-
if(
266-
CMAKE_SYSTEM_NAME MATCHES "Windows"
267-
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
268-
)
269-
set(SLANG_SLANG_TINT_BINARY_URL
270-
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
319+
if(NOT SLANG_EXCLUDE_TINT)
320+
set(slang_tint_release_tag "slang-tint-0")
321+
if(
322+
CMAKE_SYSTEM_NAME MATCHES "Windows"
323+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
271324
)
325+
set(SLANG_SLANG_TINT_BINARY_URL
326+
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
327+
)
328+
endif()
272329
endif()
273330

274331
#

docs/assets/moduletree.png

73.6 KB
Loading

docs/user-guide/04-modules-and-access-control.md

+33-4
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ It is only valid for the user code to `import m`. Attempting to `import helper`
120120
Multiple `import`s of the same module from different input files will only cause the module to be loaded once (there is no need for "include guards" or `#pragma once`).
121121
Note that preprocessor definitions in the current file will not affect the compilation of `import`ed code, and the preprocessor definitions in the imported code is not visible to the current file.
122122

123-
> #### Note ####
124-
> Future versions of the Slang system will support loading of modules from pre-compiled binaries instead of source code.
125-
> The same `import` keyword will continue to work in that case.
126-
127123
## Access Control
128124

129125
Slang supports access control modifiers: `public`, `internal` and `private`. The module boundary plays an important role in access control.
@@ -195,6 +191,39 @@ The Slang compiler enforces the following rules regarding access control:
195191
- Type definitions themselves cannot be `private`, for example, `private struct S {}` is not valid code.
196192
- `interface` requirements cannot be `private`.
197193

194+
## Organizing File Structure of Modules
195+
196+
Slang does not seek to impose any specific organization of modules. However, there are some conventions that have emerged as being useful.
197+
198+
### Module Organization Suggestions
199+
200+
- The top-level directory contains modules that would be `import`ed by user code.
201+
- The implementation details of the modules are placed in files at lower levels of the tree.
202+
203+
This has the benefit that it is easy for a user to distinguish the public API from the implementation details.
204+
205+
### Module Organization Example
206+
207+
<img src="../assets/moduletree.png" width="300em" alt="Module organization tree diagram"/>
208+
209+
### Module Organization Example
210+
211+
The above diagram shows a module organization example.
212+
213+
Top-level module files such as `utils.slang` are those that are directly `import`ed by user code. The implementation details of the module are placed in the lower levels of the tree, organized into similarly named subdirectories for clarity.
214+
215+
Modules like `utils.slang` needn't contain anything more than a module declaration and a list of included files, with optional `import` statement(s) to pull in any external dependencies, e.g.
216+
217+
```
218+
module utils;
219+
import slangpy;
220+
221+
__include "utils/accumlator.slang";
222+
__include "utils/tonemap.slang";
223+
__include "utils/fill.slang";
224+
```
225+
226+
Here, all the public symbols defined in `accumlator.slang`, `tonemap.slang`, and `fill.slang` are visible to the user of the `utils` module, and these constituent helper files do not need to clutter the top-level file hierarchy.
198227

199228
## Legacy Modules
200229

docs/user-guide/toc.html

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<li data-link="modules#defining-a-module"><span>Defining a Module</span></li>
5959
<li data-link="modules#importing-a-module"><span>Importing a Module</span></li>
6060
<li data-link="modules#access-control"><span>Access Control</span></li>
61+
<li data-link="modules#organizing-file-structure-of-modules"><span>Organizing File Structure of Modules</span></li>
6162
<li data-link="modules#legacy-modules"><span>Legacy Modules</span></li>
6263
</ul>
6364
</li>

external/CMakeLists.txt

+78-8
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,32 @@ if(NOT SLANG_ENABLE_EXTERNAL_COMPILER_WARNINGS)
2727
endif()
2828
endif()
2929

30+
# Unordered dense
3031
if(NOT ${SLANG_USE_SYSTEM_UNORDERED_DENSE})
31-
add_subdirectory(unordered_dense EXCLUDE_FROM_ALL ${system})
32+
if(NOT SLANG_OVERRIDE_UNORDERED_DENSE_PATH)
33+
add_subdirectory(unordered_dense EXCLUDE_FROM_ALL ${system})
34+
else()
35+
add_subdirectory(
36+
${SLANG_OVERRIDE_UNORDERED_DENSE_PATH}
37+
unordered_dense
38+
EXCLUDE_FROM_ALL
39+
${system}
40+
)
41+
endif()
3242
endif()
3343

3444
# Miniz
3545
if(NOT ${SLANG_USE_SYSTEM_MINIZ})
36-
add_subdirectory(miniz EXCLUDE_FROM_ALL ${system})
46+
if(NOT SLANG_OVERRIDE_MINIZ_PATH)
47+
add_subdirectory(miniz EXCLUDE_FROM_ALL ${system})
48+
else()
49+
add_subdirectory(
50+
${SLANG_OVERRIDE_MINIZ_PATH}
51+
miniz
52+
EXCLUDE_FROM_ALL
53+
${system}
54+
)
55+
endif()
3756
set_property(TARGET miniz PROPERTY POSITION_INDEPENDENT_CODE ON)
3857
# Work around https://github.com/richgel999/miniz/pull/292
3958
get_target_property(miniz_c_launcher miniz C_COMPILER_LAUNCHER)
@@ -46,7 +65,16 @@ endif()
4665
# LZ4
4766
if(NOT ${SLANG_USE_SYSTEM_LZ4})
4867
set(LZ4_BUNDLED_MODE ON)
49-
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL ${system})
68+
if(NOT SLANG_OVERRIDE_LZ4_PATH)
69+
add_subdirectory(lz4/build/cmake EXCLUDE_FROM_ALL ${system})
70+
else()
71+
add_subdirectory(
72+
${SLANG_OVERRIDE_LZ4_PATH}/build/cmake
73+
lz4/build/cmake
74+
EXCLUDE_FROM_ALL
75+
${system}
76+
)
77+
endif()
5078
if(MSVC)
5179
target_compile_options(
5280
lz4_static
@@ -57,7 +85,16 @@ endif()
5785

5886
# Vulkan headers
5987
if(NOT ${SLANG_USE_SYSTEM_VULKAN_HEADERS})
60-
add_subdirectory(vulkan EXCLUDE_FROM_ALL ${system})
88+
if(NOT SLANG_OVERRIDE_VULKAN_HEADERS_PATH)
89+
add_subdirectory(vulkan EXCLUDE_FROM_ALL ${system})
90+
else()
91+
add_subdirectory(
92+
${SLANG_OVERRIDE_VULKAN_HEADERS_PATH}
93+
vulkan
94+
EXCLUDE_FROM_ALL
95+
${system}
96+
)
97+
endif()
6198
endif()
6299

63100
# metal-cpp headers
@@ -69,22 +106,55 @@ target_include_directories(
69106

70107
# SPIRV-Headers
71108
if(NOT ${SLANG_USE_SYSTEM_SPIRV_HEADERS})
72-
add_subdirectory(spirv-headers EXCLUDE_FROM_ALL ${system})
109+
if(NOT SLANG_OVERRIDE_SPIRV_HEADERS_PATH)
110+
add_subdirectory(spirv-headers EXCLUDE_FROM_ALL ${system})
111+
else()
112+
add_subdirectory(
113+
${SLANG_OVERRIDE_SPIRV_HEADERS_PATH}
114+
spirv-headers
115+
EXCLUDE_FROM_ALL
116+
${system}
117+
)
118+
endif()
73119
endif()
74120

75121
if(SLANG_ENABLE_SLANG_GLSLANG)
76122
# SPIRV-Tools
77123
set(SPIRV_TOOLS_BUILD_STATIC ON)
78124
set(SPIRV_WERROR OFF)
79-
set(SPIRV_HEADER_DIR "${CMAKE_CURRENT_LIST_DIR}/spirv-headers/")
125+
# Headers
126+
if(NOT SLANG_OVERRIDE_SPIRV_HEADERS_PATH)
127+
set(SPIRV_HEADER_DIR "${CMAKE_CURRENT_LIST_DIR}/spirv-headers/")
128+
else()
129+
set(SPIRV_HEADER_DIR ${SLANG_OVERRIDE_SPIRV_HEADERS_PATH})
130+
endif()
80131
set(SPIRV_SKIP_TESTS ON)
81-
add_subdirectory(spirv-tools EXCLUDE_FROM_ALL ${system})
132+
# Tools
133+
if(NOT SLANG_OVERRIDE_SPIRV_TOOLS_PATH)
134+
add_subdirectory(spirv-tools EXCLUDE_FROM_ALL ${system})
135+
else()
136+
add_subdirectory(
137+
${SLANG_OVERRIDE_SPIRV_TOOLS_PATH}
138+
spirv-tools
139+
EXCLUDE_FROM_ALL
140+
${system}
141+
)
142+
endif()
82143

83144
# glslang
84145
set(SKIP_GLSLANG_INSTALL ON)
85146
set(ENABLE_OPT ON)
86147
set(ENABLE_PCH OFF)
87-
add_subdirectory(glslang EXCLUDE_FROM_ALL ${system})
148+
if(NOT SLANG_OVERRIDE_GLSLANG_PATH)
149+
add_subdirectory(glslang EXCLUDE_FROM_ALL ${system})
150+
else()
151+
add_subdirectory(
152+
${SLANG_OVERRIDE_GLSLANG_PATH}
153+
glslang
154+
EXCLUDE_FROM_ALL
155+
${system}
156+
)
157+
endif()
88158
endif()
89159

90160
# imgui

include/slang-gfx.h

+9
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ class IShaderProgram : public ISlangUnknown
163163
SeparateEntryPointCompilation
164164
};
165165

166+
enum class DownstreamLinkMode
167+
{
168+
None,
169+
Deferred,
170+
};
171+
166172
struct Desc
167173
{
168174
// TODO: Tess doesn't like this but doesn't know what to do about it
@@ -180,6 +186,9 @@ class IShaderProgram : public ISlangUnknown
180186
// An array of Slang entry points. The size of the array must be `entryPointCount`.
181187
// Each element must define only 1 Slang EntryPoint.
182188
slang::IComponentType** slangEntryPoints = nullptr;
189+
190+
// Indicates whether the app is responsible for final downstream linking.
191+
DownstreamLinkMode downstreamLinkMode = DownstreamLinkMode::None;
183192
};
184193

185194
struct CreateDesc2

include/slang.h

+3
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ typedef uint32_t SlangSizeT;
653653
SLANG_PASS_THROUGH_SPIRV_OPT, ///< SPIRV-opt
654654
SLANG_PASS_THROUGH_METAL, ///< Metal compiler
655655
SLANG_PASS_THROUGH_TINT, ///< Tint WGSL compiler
656+
SLANG_PASS_THROUGH_SPIRV_LINK, ///< SPIRV-link
656657
SLANG_PASS_THROUGH_COUNT_OF,
657658
};
658659

@@ -1008,6 +1009,8 @@ typedef uint32_t SlangSizeT;
10081009

10091010
EmitReflectionJSON, // bool
10101011
SaveGLSLModuleBinSource,
1012+
1013+
SkipDownstreamLinking, // bool, experimental
10111014
CountOf,
10121015
};
10131016

0 commit comments

Comments
 (0)