yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jsmall-nvidia'Explicit specialization' experiments with extensions (#2099)3aaa586c9

master
803 B35 linesraw
1//DISABLE_TEST:SIMPLE:-target hlsl -entry computeMain -profile cs_6_2
2
3/* 
4The following works, but *requires* the rotateLeft free function to work around the swizzle issue (seen in explicit-specialization.slang).
5*/
6
7RWStructuredBuffer<int> outputBuffer;
8
9interface IRotatable 
10{
11    This rotateLeft();
12};
13
14extension int : IRotatable
15{
16    This rotateLeft() { const uint u = this; return This((u << 1) | (u >> 31)); }
17};
18
19extension uint : IRotatable
20{
21    This rotateLeft() { let u = this; return This((u << 1) | (u >> 31)); }
22};
23
24T rotateLeft<T : IRotatable>(T a) { return a.rotateLeft(); }
25
26[numthreads(4, 1, 1)]
27void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
28{
29    uint tid = dispatchThreadID.x;
30
31    let v = rotateLeft(tid) + rotateLeft((int)tid);
32   
33    outputBuffer[tid] = v;
34}
35