Build, format, test, and debug Slang shaders with CMake, Python tracing, and regression tests
Work with the Slang shader language: configure builds, format code, write tests, debug instructions, and follow contribution guidelines.
Slang is pre-built in debug configuration. Targets like `slangc`, `slang-test`, and `slangi` are ready to run.
**To rebuild after changes:**
1. Configure CMake:
```bash
cmake --preset default
```
2. Build debug workflow:
```bash
cmake --workflow --preset debug
```
3. Consult `docs/building.md` for detailed build instructions.
**CRITICAL: Format before committing.**
Run the formatting script before submitting any PR:
```bash
./extras/formatting.sh
```
All PRs must adhere to the project's coding style. Unformatted code will not be accepted.
Every PR requires one of these labels:
- Public API changes break ABI compatibility
- Language changes cause existing Slang code to error
Breaking changes are rare. Default to non-breaking unless certain.
When debugging problematic instructions, trace their creation using `_debugUID`.
**Example:** If instruction `_debugUID=1234` is buggy:
```bash
python3 ./extras/insttrace.py 1234 ./build/Debug/bin/slangc tests/my-test.slang -target spirv
```
This prints the callstack where the instruction was created.
All bug fixes and features should include regression tests.
**Test location:** `tests/` directory (`.slang` files)
**Run tests:**
```bash
slang-test tests/path/to/your-new-test.slang
```
Build `slang-test` target first if needed.
For non-GPU-specific features, run tests on CPU:
```slang
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type -cpu
```
**Example:** `tests/language-feature/lambda/lambda-0.slang`
Use `slangi` for logic validation:
```slang
//TEST:INTERPRET(filecheck=CHECK):
void main()
{
//CHECK: hello!
printf("hello!");
}
```
Cannot run locally (D3D12, Vulkan, Metal, WGSL). Submit PR and let CI verify.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/slang-shader-development/raw