yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
41e7e565e
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj 4//DISABLE_TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<float> outputBuffer; 8 9typedef DifferentialPair<float> dpfloat; 10typedef float.Differential dfloat; 11 12//CHK: note: checkpointing context of 24 bytes associated with function: 'test_simple_loop' 13[Differentiable] 14float test_simple_loop(float y) 15{ 16 //CHK: note: 20 bytes (FixedArray<float, 5> ) used to checkpoint the following item: 17 float t = y; 18 19 //CHK: note: 4 bytes (int32_t) used for a loop counter here: 20 for (int i = 0; i < 3; i++) 21 { 22 t = t * t; 23 } 24 25 return t; 26} 27 28[numthreads(1, 1, 1)] 29void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 30{ 31 { 32 dpfloat dpa = dpfloat(1.0, 0.0); 33 34 __bwd_diff(test_simple_loop)(dpa, 1.0f); 35 outputBuffer[0] = dpa.d; // Expect: 8.0 36 } 37 38 { 39 dpfloat dpa = dpfloat(0.4, 0.0); 40 41 __bwd_diff(test_simple_loop)(dpa, 1.0f); 42 outputBuffer[1] = dpa.d; // Expect: 0.0131072 43 } 44} 45 46//CHK-NOT: note