diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user-guide/10-link-time-specialization.md | 24 | ||||
| -rw-r--r-- | docs/user-guide/toc.html | 1 |
2 files changed, 3 insertions, 22 deletions
diff --git a/docs/user-guide/10-link-time-specialization.md b/docs/user-guide/10-link-time-specialization.md index 516fd19b5..e5bc97930 100644 --- a/docs/user-guide/10-link-time-specialization.md +++ b/docs/user-guide/10-link-time-specialization.md @@ -163,16 +163,9 @@ import common; export struct Sampler : ISampler = FooSampler; ``` -The `=` syntax is a syntactic sugar that expands to the following code: - -```csharp -export struct Sampler : ISampler -{ - FooSampler inner; - int getSampleCount() { return inner.getSampleCount(); } - float sample(int index) { return inner.sample(index); } -} -``` +The `=` syntax defines a typealias that allows `Sampler` to resolve to `FooSampler` at link-time. +Note that both the name and type conformance clauses must match exactly between an `export` and an `extern` declaration +for link-time types to resolve correctly. Link-time types can also be generic, and may conform to generic interfaces. When all these three modules are linked, we will produce a specialized shader that uses the `FooSampler`. @@ -196,17 +189,6 @@ void main(uint tid : SV_DispatchThreadID) } ``` -## Restrictions - -Unlike preprocessors, link-time constants and types can only be used in places where shader parameter layout cannot be -affected. This means that link-time constants and types are subject to the following restrictions: -- Link-time constants cannot be used to define array sizes. -- Link-time types are considered "incomplete" types. A struct or array type that has incomplete typed element is also an incomplete type. - Incomplete types cannot be used as `ConstantBuffer` or `ParameterBlock` element type, and cannot be used directly as the type of - a uniform variable. - -However it is allowed to use incomplete types as the element type of `StructuredBuffer` or `GLSLStorageBuffer`. - ## Using Precompiling Modules with the API In addition to using `slangc` for precompiling Slang modules, the `IModule` class provides a method to serialize itself to disk: diff --git a/docs/user-guide/toc.html b/docs/user-guide/toc.html index b32ad71da..89ddf34d9 100644 --- a/docs/user-guide/toc.html +++ b/docs/user-guide/toc.html @@ -148,7 +148,6 @@ <li data-link="link-time-specialization#link-time-constants"><span>Link-time Constants</span></li> <li data-link="link-time-specialization#link-time-types"><span>Link-time Types</span></li> <li data-link="link-time-specialization#providing-default-settings"><span>Providing Default Settings</span></li> -<li data-link="link-time-specialization#restrictions"><span>Restrictions</span></li> <li data-link="link-time-specialization#using-precompiling-modules-with-the-api"><span>Using Precompiling Modules with the API</span></li> <li data-link="link-time-specialization#additional-remarks"><span>Additional Remarks</span></li> </ul> |
