diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-09-14 15:37:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-14 15:37:05 -0700 |
| commit | 10b62eecd94be53eca4ac2555af860f864966d76 (patch) | |
| tree | 9a140acfda0e3f0755f2c120870c72d5a8f4b232 /tests/ir/loop.slang | |
| parent | 8cdfce564546c03c2c1ce179561591276aeb23a8 (diff) | |
IR: handle control flow constructs (#186)
* IR: handle control flow constructs
This change includes a bunch of fixes and additions to the IR path:
- `slang-ir-assembly` is now a valid output target (so we can use it for testing)
- This uses what used to be the IR "dumping" logic, revamped to support much prettier output.
- A future change will need to add back support for less prettified output to use when actually debugging
- IR generation for `for` loops and `if` statements is supported
- HLSL output from the above control flow constructs is implemented
- Revamped the handling of l-values, and in particular work on compound ops like `+=`
- Add basic IR support for `groupshared` variables
- Add basic IR support for storing compute thread-group size
- Output semantics on entry point parameters
- This uses the AST structures to find semantics, so its still needs work
- Pass through loop unroll flags
- This is required to match `fxc` output, at least until we implement
unrolling ourselves.
* Fixup: 64-bit build issues.
* fixup for merge
Diffstat (limited to 'tests/ir/loop.slang')
| -rw-r--r-- | tests/ir/loop.slang | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ir/loop.slang b/tests/ir/loop.slang new file mode 100644 index 000000000..d637e4536 --- /dev/null +++ b/tests/ir/loop.slang @@ -0,0 +1,33 @@ +//TEST:SIMPLE:-target slang-ir-assembly -profile cs_4_0 -entry main + +#define GROUP_THREAD_COUNT 64 + +StructuredBuffer<float4> input; +RWStructuredBuffer<float4> output; + +groupshared float4 s[GROUP_THREAD_COUNT]; + +[numthreads(GROUP_THREAD_COUNT, 1, 1)] +void main( + uint dispatchThreadID : SV_DispatchThreadIndex, + uint groupThreadID : SV_GroupThreadIndex, + uint groupID : SV_GroupIndex ) +{ + // the actual algorithm being done here is bogus + + // load shared memory + s[groupThreadID] = input[dispatchThreadID]; + + // do some sum passes + for(uint stride = 1; stride < GROUP_THREAD_COUNT; stride <<= 1) + { + GroupMemoryBarrierWithGroupSync(); + + s[groupThreadID] += s[groupThreadID - stride]; + } + + GroupMemoryBarrierWithGroupSync(); + + output[dispatchThreadID] = s[0]; +} + |
