yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -compute -entry computeMain -allow-glsl -profile cs_6_6 -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type 3//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -output-using-type -emit-spirv-directly 4 5//TEST_INPUT: ubuffer(data=[0], stride=4):out,name outputBuffer 6RWStructuredBuffer<int> outputBuffer; 7 8bool Test_unpackUnorm4x8() 9{ 10 vector<float,4> val; 11 val[0] = 1.f / 1.f; 12 val[1] = 1.f / 2.f; 13 val[2] = 1.f / 4.f; 14 val[3] = 1.f / 8.f; 15 16 const uint32_t packed = packUnorm4x8(val); 17 const vector<float,4> unpacked = unpackUnorm4x8(packed); 18 19 return true 20 && int(unpacked[0] * 1.f) == 1 21 && int(unpacked[1] * 2.f) == 1 22 && int(unpacked[2] * 4.f) == 1 23 && int(unpacked[3] * 8.f) == 1 24 ; 25} 26 27bool Test_unpackSnorm4x8() 28{ 29 vector<float,4> val; 30 val[0] = 1.f / 1.f; 31 val[1] = 1.f / 2.f; 32 val[2] = 1.f / 4.f; 33 val[3] = 1.f / 8.f; 34 35 const uint32_t packed = packSnorm4x8(val); 36 const vector<float,4> unpacked = unpackSnorm4x8(packed); 37 38 return true 39 && int(unpacked[0] * 1.f) == 1 40 && int(unpacked[1] * 2.f) == 1 41 && int(unpacked[2] * 4.f) == 1 42 && int(unpacked[3] * 8.f) == 1 43 ; 44} 45 46[numthreads(4, 1, 1)] 47void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 48{ 49 //BUF:1 50 outputBuffer[0] = int(true 51 && Test_unpackUnorm4x8() 52 && Test_unpackSnorm4x8() 53 ); 54}