yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
e420f2f98
master
1//TEST:SIMPLE(filecheck=MTL): -target metal -stage compute -entry computeMain 2//TEST:SIMPLE(filecheck=LIB): -target metallib -stage compute -entry computeMain 3 4// MTL: float S1_test{{.*}}(const S1_default{{.*}} constant* this{{.*}} 5// LIB: computeMain 6 7struct S1 8{ 9 Texture2D tex[32]; 10 SamplerState samplers[32]; 11 float data; 12 float test(int i) 13 { 14 return tex[i].SampleLevel(samplers[i], float2(0.0, 0.0), 0.0).x + data; 15 } 16} 17 18struct S0 19{ 20 float data; 21 RaytracingAccelerationStructure acc; 22 ParameterBlock<S1> s; 23} 24 25ParameterBlock<S0> g; 26RWStructuredBuffer<float> buffer; 27 28[shader("compute")] 29[numthreads(1,1,1)] 30void computeMain( 31 uint3 sv_dispatchThreadID : SV_DispatchThreadID) 32{ 33 buffer[0] = g.data * g.s.test(sv_dispatchThreadID.x); 34}