yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
c3df36043
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -slang -compute -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -slang -compute -shaderobj -output-using-type -cuda 3 4//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 5RWStructuredBuffer<float> outputBuffer; 6 7// A general test for differentiable, force-inlined functions. 8// 9// This test was added to expose a bug in legalizeDefUse() where an IRVar can be be hoisted to 10// after its uses (when it is already in the same block, but gets reinserted), and cause 11// a validation bug. 12// 13 14__generic<T : __BuiltinFloatingPointType, let R : int, let C : int> 15[ForceInline, PreferRecompute, Differentiable] 16vector<T, R> column(matrix<T, R, C> m, int i) { 17 vector<T, R> result; 18 [ForceUnroll] 19 for (int j = 0; j < R; j++) { 20 result[j] = m[j][i]; 21 } 22 return result; 23} 24 25struct Data { 26 float4x4 m; 27 float foo() { 28 return length(column(m, 0).xyz); 29 } 30}; 31 32[numthreads(1, 1, 1)] 33void computeMain(uint3 id : SV_DispatchThreadID) 34{ 35 Data data; 36 // Initialize matrix with some values 37 data.m = float4x4( 38 3.0, 0.0, 0.0, 0.0, 39 0.0, 5.0, 0.0, 0.0, 40 0.0, 0.0, 7.0, 0.0, 41 0.0, 0.0, 0.0, 11.0); 42 43 // Calculate and store result 44 outputBuffer[0] = data.foo(); 45 46 // CHECK: type: float 47 // CHECK: 3.0 48}