yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
cfef0c6f6
master
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 5//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 6//TEST(compute):COMPARE_COMPUTE_EX:-mtl -compute -shaderobj 7 8//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 9 10RWStructuredBuffer<int> outputBuffer; 11 12[numthreads(4, 1, 1)] 13void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 14{ 15 const int id = asint(dispatchThreadID.x); 16 17 { 18 int4 i4 = int4(id, id + 1, id + 2, id + 3); 19 20 // Identity - int vector 21 i4 = asint(i4); 22 23 uint3 u3 = asuint(i4.xyz); 24 // Identity - uint vec 25 u3 = asuint(u3); 26 27 int2 i2 = asint(u3.xy); 28 uint u1 = asuint(i2.x); 29 30 // Identity - uint scalar 31 u1 = asuint(u1); 32 33 outputBuffer[id + 0] = int(u1); 34 } 35 36 { 37 uint v = asuint(id); 38 uint4 u4 = uint4(v, v + 1, v + 2, v + 3); 39 int3 i3 = asint(u4.xyz); 40 uint2 u2 = asuint(i3.xy); 41 int i1 = asint(u2.x); 42 43 // Identity - int scalar 44 i1 = asint(i1); 45 46 outputBuffer[id + 4] = i1; 47 } 48 49 { 50 // Make i4 holds id as floats so we know they are valid float values and not denormals 51 int4 i4 = int4(asint(float(id)), asint(float(id + 1)), asint(float(id + 2)), asint(float(id + 3))); 52 float4 f4 = asfloat(asfloat(i4)); 53 54 // Identity - float vector 55 f4 = asfloat(f4); 56 57 uint3 u3 = asuint(f4.xyz); 58 float2 f2 = asfloat(u3.xy); 59 uint u1 = asuint(f2.x); 60 61 float f1 = asfloat(asfloat(u1)); 62 63 // Identity - float scalar 64 f1 = asfloat(f1); 65 66 int i1 = asint(f1); 67 68 float f1_ = asfloat(i1); 69 int i1_ = asint(f1_); 70 71 outputBuffer[id + 8] = (int)asfloat(i1_); 72 } 73}