yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1// interface-static-method.slang 2 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj 5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 6//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 7 8interface IHideout 9{ 10 int getAnimalCount(); 11} 12 13interface ISuperhero 14{ 15 associatedtype Hideout : IHideout; 16 17 static Hideout getHideout(); 18} 19 20struct Batcave : IHideout 21{ 22 int batCount; 23 24 int getAnimalCount() { return batCount; } 25} 26 27struct Batman : ISuperhero 28{ 29 typedef Batcave Hideout; 30 31 static Batcave getHideout() 32 { 33 Batcave batcave = { 100 }; 34 return batcave; 35 } 36} 37 38int doIt<T:ISuperhero>() 39{ 40 return T.getHideout().getAnimalCount(); 41} 42 43int test(int val) 44{ 45 return doIt<Batman>(); 46} 47 48 49//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 50RWStructuredBuffer<int> outputBuffer; 51 52[numthreads(4, 1, 1)] 53void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 54{ 55 int tid = dispatchThreadID.x; 56 outputBuffer[tid] = test(tid); 57}