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:-vk -compute -shaderobj -emit-spirv-via-glsl -output-using-type 2//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -d3d12 -profile cs_6_6 -shaderobj -output-using-type 4//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 5//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type 6 7//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=gOutputBuffer 8RWStructuredBuffer<uint64_t> gOutputBuffer; 9 10int64_t icast(double x) 11{ 12 return bit_cast<int64_t>(x); 13} 14 15int64_t icast(uint64_t x) 16{ 17 return bit_cast<int64_t>(x); 18} 19 20uint64_t ucast(double x) 21{ 22 return bit_cast<uint64_t>(x); 23} 24 25uint64_t ucast(int64_t x) 26{ 27 return bit_cast<uint64_t>(x); 28} 29 30[numthreads(1, 1, 1)] 31[shader("compute")] 32void computeMain() 33{ 34 double t1 = -1.0; 35 uint64_t t2 = 2; 36 gOutputBuffer[0] = icast(t1); // 0xBFF0000000000000 => 13830554455654793216 37 gOutputBuffer[1] = icast(t2); // 0x0000000000000002 => 2 38 39 double t3 = 3.0; 40 int64_t t4 = -4; 41 gOutputBuffer[2] = ucast(t3); // 0x4008000000000000 => 4613937818241073152 42 gOutputBuffer[3] = ucast(t4); // 0xFFFFFFFFFFFFFFFC => 18446744073709551612 43}