Skip to content

Commit 9fcff61

Browse files
committed
Test
1 parent 6ec8020 commit 9fcff61

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

docs/autodiff-tips-custom-diffs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ One of the key strengths of Slang's autodiff system is its flexibility. You are
107107

108108
This means you can address just the parts of your function stack that truly need custom derivatives (e.g., the opaque or numerically unstable sections) while still leveraging Slang's powerful autodiff for the rest of your computations. This hybrid approach offers the best of both worlds: the convenience and efficiency of automatic differentiation where it's most effective, and the precision and control of custom derivatives where they are absolutely necessary.
109109

110-
For examples of this in practice, take a look at some of the [experiments]() in our SlangPy samples repository. In particular, you can see a user-defined custom derivative function invoking bwd\_diff() to make use of automatic differentiation for the functions it calls out to in the [differentiable splatting experiment](https://github.com/shader-slang/slangpy-samples/blob/main/experiments/diff-splatting/diffsplatting2d.slang#L512).
110+
For examples of this in practice, take a look at some of the [experiments](https://github.com/shader-slang/slangpy-samples/blob/main/experiments) in our SlangPy samples repository. In particular, you can see a user-defined custom derivative function invoking bwd\_diff() to make use of automatic differentiation for the functions it calls out to in the [differentiable splatting experiment](https://github.com/shader-slang/slangpy-samples/blob/main/experiments/diff-splatting/diffsplatting2d.slang#L512).
111111

112112
# Approximating Derivatives for Inherently Undifferentiable Functions
113113

docs/compilation-api.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The Slang compilation API is provided as a dynamic library. Linking to it, you h
2626
* [Post-Compilation Reflection](#post-compilation-reflection)
2727
* [Complete Example](#complete-example)
2828

29-
### Basic Compilation
29+
## Basic Compilation
3030

3131
This is the overall flow needed to compile even the simplest applications.
3232

@@ -38,24 +38,24 @@ This is the overall flow needed to compile even the simplest applications.
3838
6. [Link Program](#link)
3939
7. [Get Target Kernel Code](#get-target-kernel-code)
4040

41-
### Step-by-step
42-
#### Includes
41+
## Step-by-step
42+
### Includes
4343
The main header file is `slang.h`, though you also need `slang-com-ptr.h` to have the definition of Slang::ComPtr used throughout the API. `slang-com-helper.h` is nice to have, since it provides helpers for checking API return values and otherwise using COM.
4444
```cpp
4545
#include "slang.h"
4646
#include "slang-com-ptr.h"
4747
#include "slang-com-helper.h"
4848
```
4949

50-
#### Create Global Session
50+
### Create Global Session
5151
The global API call to `createGlobalSession` is always going to be the first runtime step, since it establishes a connection to the Slang API implementation.
5252

5353
```cpp
5454
Slang::ComPtr<slang::IGlobalSession> globalSession;
5555
createGlobalSession(globalSession.writeRef());
5656
```
5757
58-
#### Create Session
58+
### Create Session
5959
To read more about what sessions are all about, see [About Sessions](#about-sessions).
6060
Creating a session sets the configuration for what you are going to do with the API.
6161
@@ -69,7 +69,7 @@ The `SessionDesc` object holds all the configuration for the Session.
6969
slang::SessionDesc sessionDesc = {};
7070
```
7171

72-
##### List of enabled compilation targets
72+
#### List of enabled compilation targets
7373

7474
Here, only one target is enabled, `spirv_1_5`. You can enable more targets, for example, if you need to be able to compile the same source to DXIL as well as SPIRV.
7575
```cpp
@@ -81,7 +81,7 @@ Here, only one target is enabled, `spirv_1_5`. You can enable more targets, for
8181
sessionDesc.targetCount = 1;
8282
```
8383
84-
##### Preprocessor defines
84+
#### Preprocessor defines
8585
8686
Slang supports using the preprocessor.
8787
```cpp
@@ -94,7 +94,7 @@ Slang supports using the preprocessor.
9494
sessionDesc.preprocessorMacroCount = preprocessorMacroDesc.size();
9595
```
9696

97-
##### Compiler options
97+
#### Compiler options
9898

9999
Here is where you can specify Session-wide options. Check the [User Guide](https://docs.shader-slang.org/en/latest/external/slang/docs/user-guide/08-compiling.html#compiler-options) for info on available options.
100100

@@ -110,7 +110,7 @@ Here is where you can specify Session-wide options. Check the [User Guide](https
110110
sessionDesc.compilerOptionEntryCount = options.size();
111111
```
112112
113-
##### Create the session
113+
#### Create the session
114114
115115
With a fully populated `SessionDesc`, the session can be created.
116116
@@ -119,7 +119,7 @@ With a fully populated `SessionDesc`, the session can be created.
119119
globalSession->createSession(sessionDesc, session.writeRef());
120120
```
121121

122-
#### Load Modules
122+
### Load Modules
123123

124124
Modules are the granularity of shader source code that can be compiled in Slang. When using the compilation API, there are two main functions to consider.
125125

@@ -142,11 +142,11 @@ Modules are the granularity of shader source code that can be compiled in Slang.
142142
}
143143
```
144144
145-
##### Life Time of Modules
145+
#### Life Time of Modules
146146
147147
Modules are owned by the slang Session. Once loaded, they are valid as long as the Session is valid.
148148
149-
#### Query Entry Points
149+
### Query Entry Points
150150
151151
Slang shaders may contain many entry points, and it's necessary to be able to identify them programatically in the Compilation API in order to select which entry points to compile.
152152
@@ -170,7 +170,7 @@ A common way to query an entry-point is by using the `IModule::findEntryPointByN
170170
It is also possible to query entry-points by index, and work backwards to check the name of the entry-points that are returned at different indices.
171171
Check the [User Guide](https://docs.shader-slang.org/en/latest/external/slang/docs/user-guide/09-reflection.html#program-reflection) for info.
172172

173-
#### Compose Modules and Entry Points
173+
### Compose Modules and Entry Points
174174

175175
Up to this point, modules have been loaded, and entry points have been identified, but to move forward with defining a GPU program, the relevant subset need to be selected for _composition_ into a unified program.
176176

@@ -194,7 +194,7 @@ Up to this point, modules have been loaded, and entry points have been identifie
194194
}
195195
```
196196
197-
#### Link
197+
### Link
198198
199199
Ensure that there are no missing dependencies in the composed program by using `link()`.
200200
@@ -210,7 +210,7 @@ Ensure that there are no missing dependencies in the composed program by using `
210210
}
211211
```
212212

213-
#### Get Target Kernel Code
213+
### Get Target Kernel Code
214214

215215
Finally, it's time to compile the linked Slang program to the target format.
216216

@@ -266,7 +266,7 @@ Both methods cache results within the session and will return a pre-compiled blo
266266
About Sessions
267267
--------------
268268

269-
#### What's a session?
269+
### What's a session?
270270

271271
A session is a scope for caching and reuse. As you use the Slang API, the session caches everything that is loaded in it.
272272

@@ -278,7 +278,7 @@ It's strongly recommended to use as few session objects as possible in applicati
278278

279279
Using long-lived sessions with Slang API is a big advantage over compiling with the standalone `slangc` compiler executable, since each invocation of `slangc` creates a new session object by necessity.
280280

281-
#### When do I need a new Session?
281+
### When do I need a new Session?
282282

283283
A session does have some global state in it which currently makes it unable to cache and reuse artifacts, namely, the `#define` configurations. Unique combinations of preprocessor `#defines` used in your shaders will require unique session objects.
284284

@@ -296,16 +296,16 @@ API methods for module precompilation are described in the [User Guide](https://
296296
Specialization
297297
--------------
298298

299-
#### Link-time Constants
299+
### Link-time Constants
300300

301301
This form of specialization involves placing relevant constant definitions in a separate Module that can be selectively included. For example, if you have two variants of a shader that differ in constants that they use, you can create two different Modules for the constants, one for each variant. When composing one variant or the other, just select the right constants module in createCompositeComponentType(). This is described also in the [User Guide](https://docs.shader-slang.org/en/latest/external/slang/docs/user-guide/10-link-time-specialization.html#link-time-constants)
302302

303-
#### Link-time Types
303+
### Link-time Types
304304

305305
Similar to Link-time Constants. This form of specialization simply puts different versions of user types in separate modules so that the needed implementation can be selected when creating the CompositeComponentType.
306306
[User Guide](https://docs.shader-slang.org/en/latest/external/slang/docs/user-guide/10-link-time-specialization.html#link-time-types)
307307

308-
#### Generics Specialization
308+
### Generics Specialization
309309

310310
Say you have a shader that has a feature in it that can be in one of two states, "High Quality" and "Low Quality". One way to support both modes of operation is to use generics. Put the logic for the two modes into two structs, both conforming to an interface (e.g. `IQuality`) that can be consistently used by callers.
311311

@@ -569,7 +569,7 @@ void computeMain(uint3 threadId_0 : SV_DispatchThreadID)
569569

570570
Notice in particular the switch case added in the function `float U_S11specialized8IQuality8getValuep0pf_0(uint2 _S1)`.
571571

572-
#### Supporting both specialization and dynamic dispatch
572+
### Supporting both specialization and dynamic dispatch
573573

574574
In the prior example, `HighQuality` and `LowQuality` are both supported in a single uber-shader, compiled to support dynamic dispatch on the call to `getValue()`. To achieve this, two `ITypeConformance` objects were added to the composite component.
575575

@@ -813,7 +813,7 @@ int main()
813813
}
814814
```
815815

816-
#### Compile it (g++ directions)
816+
### Compile it (g++ directions)
817817
* Assumes Slang is installed in the current directory at `slang`.
818818
* Assumes program is saved to "shortest.cpp".
819819
* Assumes a release build of Slang.
@@ -824,7 +824,7 @@ If any of the above assumptions are wrong in your case, adjust the paths below t
824824
g++ -I./slang/include --std=c++14 shortest.cpp -L./slang/build/Release/lib/ -l:libslang.so
825825
```
826826

827-
#### Run it
827+
### Run it
828828

829829
```bat
830830
LD_LIBRARY_PATH=slang/build/Release/lib ./a.out

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def setup(app):
172172
myst_title_to_header = True
173173

174174
# Suppress specific warnings
175-
suppress_warnings = ["myst.header", "myst.xref_missing", "myst.xref_ambiguous"]
175+
suppress_warnings = ["myst.header", "myst.xref_ambiguous"]
176176

177177
linkcheck_anchors = False
178178
linkcheck_ignore = [

0 commit comments

Comments
 (0)