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
- Set `SLANG_RUN_SPIRV_VALIDATION=1` for static validation; use `-skip-spirv-validation` to see SPIRV output even when validation fails
210
210
-`slangc -target spirv-asm -emit-spirv-via-glsl` — generate reference SPIRV via GLSL for comparison
211
211
212
+
#### Assertion Behavior (`SLANG_ASSERT`)
213
+
214
+
On Windows, assertion failures normally open a modal dialog that blocks execution. Set the `SLANG_ASSERT` environment variable to control this:
215
+
216
+
| Value | Behavior |
217
+
|---|---|
218
+
|`system`| Use the system `assert()`, which shows a modal dialog and allows the developers to attach the debugger |
219
+
|`debugbreak`| When a debugger is already attached, it will hit a debug-break; fall back to `system` behavior when a debugger is not attached |
220
+
|`release-assert-only`| Skip debug-only assertions (`SLANG_ASSERT`, `SLANG_ASSERT_FAILURE`) and continue; `SLANG_RELEASE_ASSERT` still fires |
221
+
|*(unset)*| Throws an exception |
222
+
223
+
The behavior on Windows after an exception is thrown is controlled by a CMake option `SLANG_BOOTSTRAP_IGNORE_ABORT_MSG` or `-ignore-abort-msg` command-line argument.
224
+
Both options are highly recommended for unattended automation with LLM workflow.
225
+
212
226
#### RTX Remix Testing
213
227
214
228
Use the `/repro-remix` skill or see `extras/repro-remix.md`.
`__first(P)` and `__last(P)` are partial operations and require `P` to be known non-empty. For generic pack parameters, non-emptiness can be expressed with:
294
+
295
+
```hlsl
296
+
void foo<each T>() where nonempty(T)
297
+
{
298
+
// `__first(T)` is well-formed here.
299
+
}
300
+
```
301
+
302
+
`__trimHead(P)` and `__trimTail(P)` are total operations and yield an empty pack when applied to an empty pack.
303
+
304
+
> 📝 **Remark:** The operand of `nonempty(...)` must be a direct reference to a generic type pack or value pack
305
+
> parameter declared in the current generic declaration. `optional nonempty(...)` is parsed but rejected as invalid.
Copy file name to clipboardExpand all lines: docs/user-guide/06-interfaces-generics.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1183,6 +1183,36 @@ struct Dims<let each D : int>
1183
1183
inttypeCount<eachT>() { returncountof(T); }
1184
1184
```
1185
1185
1186
+
### Builtin Variadic Pack Operators
1187
+
1188
+
Slang also supports simple pack queries:
1189
+
1190
+
-`__first(P)` returns the first element of a type pack, value pack, or tuple-like pack source.
1191
+
-`__last(P)` returns the last element.
1192
+
-`__trimHead(P)` returns the pack with the first element removed.
1193
+
-`__trimTail(P)` returns the pack with the last element removed.
1194
+
1195
+
For example:
1196
+
1197
+
```csharp
1198
+
intfirstValue<leteachD : int>() wherenonempty(D)
1199
+
{
1200
+
return__first(D);
1201
+
}
1202
+
1203
+
intrestCount<leteachD : int>()
1204
+
{
1205
+
returncountof(__trimHead(D));
1206
+
}
1207
+
1208
+
structFirstTypeHolder<eachT> where nonempty(T)
1209
+
{
1210
+
__first(T) value;
1211
+
}
1212
+
```
1213
+
1214
+
`__first(...)` and `__last(...)` are only valid on packs that are known to be non-empty. For generic packs, use a `where nonempty(P)` constraint to make that guarantee explicit.
0 commit comments