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