blob: 0eaa1da279727fbdacf1416a6067166f82aa95d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
//DISABLE_TEST:SIMPLE:-target hlsl -entry computeMain -profile cs_6_2
/* Slang doesn't have explicit template specialization.
Here's an attempt to use the extension mechanism.
This doesn't work and produces 9 errors of the form
> error 30052: invalid swizzle pattern 'rotateLeft' on type 'uint'
> let v = tid.rotateLeft();
Presumably for each letter of 'rotateLeft' after r, thinking it's a swizzle?
*/
RWStructuredBuffer<int> outputBuffer;
interface IRotatable
{
This rotateLeft();
};
extension int : IRotatable
{
This rotateLeft() { const uint u = this; return This((u << 1) | (u >> 31)); }
};
extension uint : IRotatable
{
This rotateLeft() { let u = this; return This((u << 1) | (u >> 31)); }
};
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
uint tid = dispatchThreadID.x;
uint v = tid.rotateLeft();
outputBuffer[tid] = v;
}
|