yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
4ae6e9d8b
master
1#pragma warning(disable:30816) 2 3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 5//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 6//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 7//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj 8 9//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 10 11RWStructuredBuffer<int> outputBuffer; 12 13enum Enum : int8_t 14{ 15}; 16 17struct Hey 18{ 19 double b; 20 Enum e; 21}; 22 23struct Thing : Hey 24{ 25 int a; 26 float b; 27}; 28 29[numthreads(4, 1, 1)] 30void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 31{ 32 const int idx = asint(dispatchThreadID.x); 33 34 int a = sizeof(idx); 35 int b = sizeof(int); 36 int c = sizeof(1 + 1); 37 int d = sizeof(Thing); 38 39 float g[sizeof(a)]; 40 41 int f[sizeof(Thing) + sizeof(float2) + sizeof(g)]; 42 43 int size; 44 45 switch (idx) 46 { 47 default: 48 case 0: size = sizeof(float); break; 49 case 1: size = sizeof(float3); break; 50 case 2: size = sizeof(matrix<uint, 3, 2>); break; 51 case 3: size = sizeof(idx); break; 52 } 53 54 outputBuffer[idx] = size + a + b + c + d + sizeof(f); 55}