You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/user-guide/a2-02-metal-target-specific.md
+18-1
Original file line number
Diff line number
Diff line change
@@ -274,4 +274,21 @@ The HLSL `:register()` semantic is respected when emitting Metal code.
274
274
275
275
Since metal does not differentiate a constant buffer, a shader resource (read-only) buffer and an unordered access buffer, Slang will map `register(tN)`, `register(uN)` and `register(bN)` to `[[buffer(N)]]` when such `register` semantic is declared on a buffer typed parameter.
276
276
277
-
`spaceN` specifiers inside `register` semantics are ignored.
277
+
`spaceN` specifiers inside `register` semantics are ignored.
278
+
279
+
## Specialization Constants
280
+
281
+
Specialization constants declared with the `[SpecializationConstant]` or `[vk::constant_id]` attribute will be translated into a `function_constant` when generating Metal source.
282
+
For example:
283
+
284
+
```csharp
285
+
[vk::constant_id(7)]
286
+
constinta=2;
287
+
```
288
+
289
+
Translates to:
290
+
291
+
```metal
292
+
constant int fc_a_0 [[function_constant(7)]];
293
+
constant int a_0 = is_function_constant_defined(fc_a_0) ? fc_a_0 : 2;
Copy file name to clipboardexpand all lines: docs/user-guide/a2-03-wgsl-target-specific.md
+17-1
Original file line number
Diff line number
Diff line change
@@ -161,4 +161,20 @@ Since the WGSL matrix multiplication convention is the normal one, where inner p
161
161
162
162
The `[vk::binding(index,set)]` attribute is respected when emitting WGSL code, and will translate to `@binding(index) @group(set)` in WGSL.
163
163
164
-
If the `[vk::binding()]` attribute is not specified by a `:register()` semantic is present, Slang will derive the binding from the `register` semantic the same way as the SPIRV and GLSL backends.
164
+
If the `[vk::binding()]` attribute is not specified by a `:register()` semantic is present, Slang will derive the binding from the `register` semantic the same way as the SPIRV and GLSL backends.
165
+
166
+
## Specialization Constants
167
+
168
+
Specialization constants declared with the `[SpecializationConstant]` or `[vk::constant_id]` attribute will be translated into a global `override` declaration when generating WGSL source.
0 commit comments