diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-09-01 14:51:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-01 14:51:31 +0800 |
| commit | b46f46c5e8603fdafca258028227adf25f95807f (patch) | |
| tree | 8fc008037ca72f79eea8ae0bbc644b34489e759f | |
| parent | 288a63dea8c441df6edc4f8fae10d340c20e1ba3 (diff) | |
Remove ForceUnroll attribute from link-time specialization documentation (#8225)
The link-time specialization documentation contained an incorrect
example that used `[ForceUnroll]` with a link-time type method call,
which would cause a compilation error. The issue was that
`[ForceUnroll]` requires loop bounds to be known at compile time, but
`sampler.getSampleCount()` is a method call that returns a value at
runtime.
**Problem:**
The documentation example showed:
```csharp
Sampler sampler;
[ForceUnroll]
for (int i = 0; i < sampler.getSampleCount(); i++)
output[tid] += sampler.sample(i);
```
This would fail with error: `loop does not terminate within the limited
number of iterations, unrolling is aborted.`
**Solution:**
Removed the `[ForceUnroll]` attribute entirely, leaving a simple loop:
```csharp
Sampler sampler;
for (int i = 0; i < sampler.getSampleCount(); i++)
output[tid] += sampler.sample(i);
```
Since the loop bounds come from a runtime method call, there's no way
for the loop to be unrolled regardless of the directive used, so the
simplest solution is to remove the unroll attribute completely.
- [x] Remove ForceUnroll attribute from documentation example
- [x] Remove explanatory note about unroll vs ForceUnroll
- [x] Remove test cases for the removed functionality
- [x] Fix missing closing backticks in code block
Fixes #8161.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bmillsNV <163073245+bmillsNV@users.noreply.github.com>
Co-authored-by: expipiplus1 <857308+expipiplus1@users.noreply.github.com>
| -rw-r--r-- | docs/user-guide/10-link-time-specialization.md | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/docs/user-guide/10-link-time-specialization.md b/docs/user-guide/10-link-time-specialization.md index b08ef1f0d..516fd19b5 100644 --- a/docs/user-guide/10-link-time-specialization.md +++ b/docs/user-guide/10-link-time-specialization.md @@ -149,7 +149,6 @@ RWStructuredBuffer<float> output; void main(uint tid : SV_DispatchThreadID) { Sampler sampler; - [ForceUnroll] for (int i = 0; i < sampler.getSampleCount(); i++) output[tid] += sampler.sample(i); } |
